madarx 2.21.0 → 2.22.0

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 (1210) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-build-manifest.json +403 -396
  3. package/.next/standalone/.next/app-path-routes-manifest.json +79 -78
  4. package/.next/standalone/.next/build-manifest.json +2 -2
  5. package/.next/standalone/.next/prerender-manifest.json +3 -3
  6. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  7. package/.next/standalone/.next/server/app/_not-found.html +2 -2
  8. package/.next/standalone/.next/server/app/_not-found.rsc +3 -3
  9. package/.next/standalone/.next/server/app/activity/page_client-reference-manifest.js +1 -1
  10. package/.next/standalone/.next/server/app/admin/page.js +3 -3
  11. package/.next/standalone/.next/server/app/admin/page_client-reference-manifest.js +1 -1
  12. package/.next/standalone/.next/server/app/agents/[id]/page.js +3 -3
  13. package/.next/standalone/.next/server/app/agents/[id]/page.js.nft.json +1 -1
  14. package/.next/standalone/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
  15. package/.next/standalone/.next/server/app/agents/page.js +1 -1
  16. package/.next/standalone/.next/server/app/agents/page_client-reference-manifest.js +1 -1
  17. package/.next/standalone/.next/server/app/api/activity/route_client-reference-manifest.js +1 -1
  18. package/.next/standalone/.next/server/app/api/admin/audit-export/route_client-reference-manifest.js +1 -1
  19. package/.next/standalone/.next/server/app/api/admin/share-links/route_client-reference-manifest.js +1 -1
  20. package/.next/standalone/.next/server/app/api/agent-memory/route_client-reference-manifest.js +1 -1
  21. package/.next/standalone/.next/server/app/api/agent-runs/[id]/cancel/route_client-reference-manifest.js +1 -1
  22. package/.next/standalone/.next/server/app/api/agent-runs/[id]/events/route_client-reference-manifest.js +1 -1
  23. package/.next/standalone/.next/server/app/api/agent-runs/[id]/log/route_client-reference-manifest.js +1 -1
  24. package/.next/standalone/.next/server/app/api/agent-runs/[id]/route_client-reference-manifest.js +1 -1
  25. package/.next/standalone/.next/server/app/api/agent-runs/route_client-reference-manifest.js +1 -1
  26. package/.next/standalone/.next/server/app/api/agents/[id]/active-run/route_client-reference-manifest.js +1 -1
  27. package/.next/standalone/.next/server/app/api/agents/[id]/chain/route_client-reference-manifest.js +1 -1
  28. package/.next/standalone/.next/server/app/api/agents/[id]/memory/route_client-reference-manifest.js +1 -1
  29. package/.next/standalone/.next/server/app/api/agents/[id]/reports/route_client-reference-manifest.js +1 -1
  30. package/.next/standalone/.next/server/app/api/agents/[id]/run/route_client-reference-manifest.js +1 -1
  31. package/.next/standalone/.next/server/app/api/agents/[id]/skills/route.js.nft.json +1 -1
  32. package/.next/standalone/.next/server/app/api/agents/[id]/skills/route_client-reference-manifest.js +1 -1
  33. package/.next/standalone/.next/server/app/api/agents/active-runs/route.js +1 -0
  34. package/.next/standalone/.next/server/app/api/agents/active-runs/route.js.nft.json +1 -0
  35. package/.next/standalone/.next/server/app/api/agents/active-runs/route_client-reference-manifest.js +1 -0
  36. package/.next/standalone/.next/server/app/api/agents/create/route_client-reference-manifest.js +1 -1
  37. package/.next/standalone/.next/server/app/api/agents/ops/route_client-reference-manifest.js +1 -1
  38. package/.next/standalone/.next/server/app/api/agents/resume-approval/route_client-reference-manifest.js +1 -1
  39. package/.next/standalone/.next/server/app/api/approvals/[id]/route_client-reference-manifest.js +1 -1
  40. package/.next/standalone/.next/server/app/api/approvals/route_client-reference-manifest.js +1 -1
  41. package/.next/standalone/.next/server/app/api/artifacts/[id]/acl/route_client-reference-manifest.js +1 -1
  42. package/.next/standalone/.next/server/app/api/artifacts/[id]/protect/route_client-reference-manifest.js +1 -1
  43. package/.next/standalone/.next/server/app/api/artifacts/[id]/raw/route_client-reference-manifest.js +1 -1
  44. package/.next/standalone/.next/server/app/api/artifacts/[id]/route_client-reference-manifest.js +1 -1
  45. package/.next/standalone/.next/server/app/api/artifacts/[id]/share-link/[linkId]/route_client-reference-manifest.js +1 -1
  46. package/.next/standalone/.next/server/app/api/artifacts/[id]/share-link/route_client-reference-manifest.js +1 -1
  47. package/.next/standalone/.next/server/app/api/artifacts/upload/route_client-reference-manifest.js +1 -1
  48. package/.next/standalone/.next/server/app/api/audit/list/route_client-reference-manifest.js +1 -1
  49. package/.next/standalone/.next/server/app/api/audit/search/route_client-reference-manifest.js +1 -1
  50. package/.next/standalone/.next/server/app/api/auth/callback/route_client-reference-manifest.js +1 -1
  51. package/.next/standalone/.next/server/app/api/auth/config/route_client-reference-manifest.js +1 -1
  52. package/.next/standalone/.next/server/app/api/auth/join-bootstrap/route_client-reference-manifest.js +1 -1
  53. package/.next/standalone/.next/server/app/api/auth/session/route_client-reference-manifest.js +1 -1
  54. package/.next/standalone/.next/server/app/api/brand/route_client-reference-manifest.js +1 -1
  55. package/.next/standalone/.next/server/app/api/brand/share/route_client-reference-manifest.js +1 -1
  56. package/.next/standalone/.next/server/app/api/chat/sessions/[id]/route_client-reference-manifest.js +1 -1
  57. package/.next/standalone/.next/server/app/api/chat/sessions/route_client-reference-manifest.js +1 -1
  58. package/.next/standalone/.next/server/app/api/cloud/schema/route_client-reference-manifest.js +1 -1
  59. package/.next/standalone/.next/server/app/api/config/env/route_client-reference-manifest.js +1 -1
  60. package/.next/standalone/.next/server/app/api/config/route_client-reference-manifest.js +1 -1
  61. package/.next/standalone/.next/server/app/api/connections/[service]/route_client-reference-manifest.js +1 -1
  62. package/.next/standalone/.next/server/app/api/connections/[service]/verify/route_client-reference-manifest.js +1 -1
  63. package/.next/standalone/.next/server/app/api/connections/route_client-reference-manifest.js +1 -1
  64. package/.next/standalone/.next/server/app/api/cron/tick/route_client-reference-manifest.js +1 -1
  65. package/.next/standalone/.next/server/app/api/dashboard/spaces/[id]/move/route_client-reference-manifest.js +1 -1
  66. package/.next/standalone/.next/server/app/api/dashboard/spaces/[id]/route_client-reference-manifest.js +1 -1
  67. package/.next/standalone/.next/server/app/api/dashboard/spaces/[id]/share-link/[linkId]/route_client-reference-manifest.js +1 -1
  68. package/.next/standalone/.next/server/app/api/dashboard/spaces/[id]/share-link/route_client-reference-manifest.js +1 -1
  69. package/.next/standalone/.next/server/app/api/dashboard/spaces/import/route_client-reference-manifest.js +1 -1
  70. package/.next/standalone/.next/server/app/api/dashboard/spaces/route_client-reference-manifest.js +1 -1
  71. package/.next/standalone/.next/server/app/api/disk/files/[id]/blob/route_client-reference-manifest.js +1 -1
  72. package/.next/standalone/.next/server/app/api/disk/files/[id]/route_client-reference-manifest.js +1 -1
  73. package/.next/standalone/.next/server/app/api/disk/files/[id]/transcribe/route_client-reference-manifest.js +1 -1
  74. package/.next/standalone/.next/server/app/api/disk/files/route_client-reference-manifest.js +1 -1
  75. package/.next/standalone/.next/server/app/api/disk/folders/route_client-reference-manifest.js +1 -1
  76. package/.next/standalone/.next/server/app/api/events/since/[cursor]/route_client-reference-manifest.js +1 -1
  77. package/.next/standalone/.next/server/app/api/events/stream/route_client-reference-manifest.js +1 -1
  78. package/.next/standalone/.next/server/app/api/fs/create-folder/route_client-reference-manifest.js +1 -1
  79. package/.next/standalone/.next/server/app/api/fs/pick-folder/route_client-reference-manifest.js +1 -1
  80. package/.next/standalone/.next/server/app/api/hail/engagements/[id]/blueprint/route_client-reference-manifest.js +1 -1
  81. package/.next/standalone/.next/server/app/api/hail/engagements/[id]/diagnostic/route_client-reference-manifest.js +1 -1
  82. package/.next/standalone/.next/server/app/api/hail/engagements/[id]/governance/route_client-reference-manifest.js +1 -1
  83. package/.next/standalone/.next/server/app/api/hail/engagements/[id]/interview/route_client-reference-manifest.js +1 -1
  84. package/.next/standalone/.next/server/app/api/hail/engagements/[id]/pilot/route_client-reference-manifest.js +1 -1
  85. package/.next/standalone/.next/server/app/api/hail/engagements/[id]/quarterly/route_client-reference-manifest.js +1 -1
  86. package/.next/standalone/.next/server/app/api/hail/engagements/[id]/route_client-reference-manifest.js +1 -1
  87. package/.next/standalone/.next/server/app/api/hail/engagements/[id]/setup-package/route_client-reference-manifest.js +1 -1
  88. package/.next/standalone/.next/server/app/api/hail/engagements/route_client-reference-manifest.js +1 -1
  89. package/.next/standalone/.next/server/app/api/hail/interviews/[id]/responses/route_client-reference-manifest.js +1 -1
  90. package/.next/standalone/.next/server/app/api/hail/interviews/[id]/route_client-reference-manifest.js +1 -1
  91. package/.next/standalone/.next/server/app/api/hail/setup-packages/[id]/apply/route_client-reference-manifest.js +1 -1
  92. package/.next/standalone/.next/server/app/api/hail/setup-packages/validate/route_client-reference-manifest.js +1 -1
  93. package/.next/standalone/.next/server/app/api/heartbeat/tick/route_client-reference-manifest.js +1 -1
  94. package/.next/standalone/.next/server/app/api/heartbeat/worker/route_client-reference-manifest.js +1 -1
  95. package/.next/standalone/.next/server/app/api/help/route_client-reference-manifest.js +1 -1
  96. package/.next/standalone/.next/server/app/api/hermes/jobs/[id]/events/route_client-reference-manifest.js +1 -1
  97. package/.next/standalone/.next/server/app/api/hermes/jobs/[id]/route_client-reference-manifest.js +1 -1
  98. package/.next/standalone/.next/server/app/api/hermes/jobs/route_client-reference-manifest.js +1 -1
  99. package/.next/standalone/.next/server/app/api/integrations/google/callback/route_client-reference-manifest.js +1 -1
  100. package/.next/standalone/.next/server/app/api/integrations/google/oauth/route_client-reference-manifest.js +1 -1
  101. package/.next/standalone/.next/server/app/api/marketplace/[id]/route_client-reference-manifest.js +1 -1
  102. package/.next/standalone/.next/server/app/api/marketplace/open-design/route_client-reference-manifest.js +1 -1
  103. package/.next/standalone/.next/server/app/api/marketplace/route_client-reference-manifest.js +1 -1
  104. package/.next/standalone/.next/server/app/api/mines/import-roots/route_client-reference-manifest.js +1 -1
  105. package/.next/standalone/.next/server/app/api/mines/portfolio/route_client-reference-manifest.js +1 -1
  106. package/.next/standalone/.next/server/app/api/mines/projects/[id]/chunks/route_client-reference-manifest.js +1 -1
  107. package/.next/standalone/.next/server/app/api/mines/projects/[id]/diligence/route_client-reference-manifest.js +1 -1
  108. package/.next/standalone/.next/server/app/api/mines/projects/[id]/import/route_client-reference-manifest.js +1 -1
  109. package/.next/standalone/.next/server/app/api/mines/projects/[id]/publish/route_client-reference-manifest.js +1 -1
  110. package/.next/standalone/.next/server/app/api/mines/projects/route_client-reference-manifest.js +1 -1
  111. package/.next/standalone/.next/server/app/api/missions/route_client-reference-manifest.js +1 -1
  112. package/.next/standalone/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
  113. package/.next/standalone/.next/server/app/api/onboarding/blueprint/route.js.nft.json +1 -1
  114. package/.next/standalone/.next/server/app/api/onboarding/blueprint/route_client-reference-manifest.js +1 -1
  115. package/.next/standalone/.next/server/app/api/onboarding/launch/route.js.nft.json +1 -1
  116. package/.next/standalone/.next/server/app/api/onboarding/launch/route_client-reference-manifest.js +1 -1
  117. package/.next/standalone/.next/server/app/api/orchestrator/command/route_client-reference-manifest.js +1 -1
  118. package/.next/standalone/.next/server/app/api/orchestrator/stream/attach/route_client-reference-manifest.js +1 -1
  119. package/.next/standalone/.next/server/app/api/orchestrator/stream/route.js +31 -14
  120. package/.next/standalone/.next/server/app/api/orchestrator/stream/route_client-reference-manifest.js +1 -1
  121. package/.next/standalone/.next/server/app/api/orchestrator/upload/route_client-reference-manifest.js +1 -1
  122. package/.next/standalone/.next/server/app/api/org/route_client-reference-manifest.js +1 -1
  123. package/.next/standalone/.next/server/app/api/orgs/[id]/invites/[inviteId]/route_client-reference-manifest.js +1 -1
  124. package/.next/standalone/.next/server/app/api/orgs/[id]/invites/route_client-reference-manifest.js +1 -1
  125. package/.next/standalone/.next/server/app/api/orgs/[id]/members/[userId]/role/route_client-reference-manifest.js +1 -1
  126. package/.next/standalone/.next/server/app/api/orgs/[id]/members/[userId]/route_client-reference-manifest.js +1 -1
  127. package/.next/standalone/.next/server/app/api/orgs/[id]/members/route_client-reference-manifest.js +1 -1
  128. package/.next/standalone/.next/server/app/api/orgs/[id]/route_client-reference-manifest.js +1 -1
  129. package/.next/standalone/.next/server/app/api/orgs/invites/pending/route_client-reference-manifest.js +1 -1
  130. package/.next/standalone/.next/server/app/api/orgs/join/route_client-reference-manifest.js +1 -1
  131. package/.next/standalone/.next/server/app/api/orgs/join-complete/route_client-reference-manifest.js +1 -1
  132. package/.next/standalone/.next/server/app/api/orgs/route_client-reference-manifest.js +1 -1
  133. package/.next/standalone/.next/server/app/api/printing-press/clis/route_client-reference-manifest.js +1 -1
  134. package/.next/standalone/.next/server/app/api/printing-press/install/route_client-reference-manifest.js +1 -1
  135. package/.next/standalone/.next/server/app/api/printing-press/security-mode/route_client-reference-manifest.js +1 -1
  136. package/.next/standalone/.next/server/app/api/privacy/config/route_client-reference-manifest.js +1 -1
  137. package/.next/standalone/.next/server/app/api/privacy/verify/route_client-reference-manifest.js +1 -1
  138. package/.next/standalone/.next/server/app/api/processes/[id]/route_client-reference-manifest.js +1 -1
  139. package/.next/standalone/.next/server/app/api/processes/[id]/share-link/route_client-reference-manifest.js +1 -1
  140. package/.next/standalone/.next/server/app/api/processes/[id]/stages/[stageId]/override/route_client-reference-manifest.js +1 -1
  141. package/.next/standalone/.next/server/app/api/processes/[id]/stages/[stageId]/retry/route_client-reference-manifest.js +1 -1
  142. package/.next/standalone/.next/server/app/api/processes/[id]/stages/[stageId]/submit/route_client-reference-manifest.js +1 -1
  143. package/.next/standalone/.next/server/app/api/processes/definitions/[slug]/route_client-reference-manifest.js +1 -1
  144. package/.next/standalone/.next/server/app/api/processes/definitions/[slug]/settings/route_client-reference-manifest.js +1 -1
  145. package/.next/standalone/.next/server/app/api/processes/definitions/route_client-reference-manifest.js +1 -1
  146. package/.next/standalone/.next/server/app/api/processes/definitions/validate/route_client-reference-manifest.js +1 -1
  147. package/.next/standalone/.next/server/app/api/processes/route_client-reference-manifest.js +1 -1
  148. package/.next/standalone/.next/server/app/api/processes/start-and-route/route_client-reference-manifest.js +1 -1
  149. package/.next/standalone/.next/server/app/api/projects/[slug]/library/route_client-reference-manifest.js +1 -1
  150. package/.next/standalone/.next/server/app/api/projects/[slug]/route_client-reference-manifest.js +1 -1
  151. package/.next/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
  152. package/.next/standalone/.next/server/app/api/runs/approve-claude-run/route_client-reference-manifest.js +1 -1
  153. package/.next/standalone/.next/server/app/api/runs/claude-code-dry-run/route_client-reference-manifest.js +1 -1
  154. package/.next/standalone/.next/server/app/api/runs/competitor-report/route_client-reference-manifest.js +1 -1
  155. package/.next/standalone/.next/server/app/api/runs/engine-ping/route_client-reference-manifest.js +1 -1
  156. package/.next/standalone/.next/server/app/api/runs/marketing-plan/route_client-reference-manifest.js +1 -1
  157. package/.next/standalone/.next/server/app/api/schedules/upsert/route_client-reference-manifest.js +1 -1
  158. package/.next/standalone/.next/server/app/api/secrets/[name]/route_client-reference-manifest.js +1 -1
  159. package/.next/standalone/.next/server/app/api/secrets/route_client-reference-manifest.js +1 -1
  160. package/.next/standalone/.next/server/app/api/settings/trust-mode/route_client-reference-manifest.js +1 -1
  161. package/.next/standalone/.next/server/app/api/share/[token]/otp/route_client-reference-manifest.js +1 -1
  162. package/.next/standalone/.next/server/app/api/share/[token]/route_client-reference-manifest.js +1 -1
  163. package/.next/standalone/.next/server/app/api/share/[token]/verify/route_client-reference-manifest.js +1 -1
  164. package/.next/standalone/.next/server/app/api/share/space/[token]/otp/route_client-reference-manifest.js +1 -1
  165. package/.next/standalone/.next/server/app/api/share/space/[token]/route_client-reference-manifest.js +1 -1
  166. package/.next/standalone/.next/server/app/api/share/space/[token]/verify/route_client-reference-manifest.js +1 -1
  167. package/.next/standalone/.next/server/app/api/shared/spaces/[id]/acl/route_client-reference-manifest.js +1 -1
  168. package/.next/standalone/.next/server/app/api/shared/spaces/publish/route_client-reference-manifest.js +1 -1
  169. package/.next/standalone/.next/server/app/api/shared/spaces/route_client-reference-manifest.js +1 -1
  170. package/.next/standalone/.next/server/app/api/shared/spaces/status/route_client-reference-manifest.js +1 -1
  171. package/.next/standalone/.next/server/app/api/shared/spaces/unpublish/route_client-reference-manifest.js +1 -1
  172. package/.next/standalone/.next/server/app/api/state/route_client-reference-manifest.js +1 -1
  173. package/.next/standalone/.next/server/app/api/system/update/route_client-reference-manifest.js +1 -1
  174. package/.next/standalone/.next/server/app/api/tasks/[id]/active-run/route_client-reference-manifest.js +1 -1
  175. package/.next/standalone/.next/server/app/api/tasks/[id]/attachments/route_client-reference-manifest.js +1 -1
  176. package/.next/standalone/.next/server/app/api/tasks/[id]/checklist/[itemId]/route_client-reference-manifest.js +1 -1
  177. package/.next/standalone/.next/server/app/api/tasks/[id]/checklist/route_client-reference-manifest.js +1 -1
  178. package/.next/standalone/.next/server/app/api/tasks/[id]/checkout/route_client-reference-manifest.js +1 -1
  179. package/.next/standalone/.next/server/app/api/tasks/[id]/children/route_client-reference-manifest.js +1 -1
  180. package/.next/standalone/.next/server/app/api/tasks/[id]/comments/route_client-reference-manifest.js +1 -1
  181. package/.next/standalone/.next/server/app/api/tasks/[id]/events/route_client-reference-manifest.js +1 -1
  182. package/.next/standalone/.next/server/app/api/tasks/[id]/live-runs/route_client-reference-manifest.js +1 -1
  183. package/.next/standalone/.next/server/app/api/tasks/[id]/release/route_client-reference-manifest.js +1 -1
  184. package/.next/standalone/.next/server/app/api/tasks/[id]/route_client-reference-manifest.js +1 -1
  185. package/.next/standalone/.next/server/app/api/tasks/route_client-reference-manifest.js +1 -1
  186. package/.next/standalone/.next/server/app/api/tool-allowlists/[id]/route_client-reference-manifest.js +1 -1
  187. package/.next/standalone/.next/server/app/api/tool-allowlists/route_client-reference-manifest.js +1 -1
  188. package/.next/standalone/.next/server/app/api/tool-egress/route_client-reference-manifest.js +1 -1
  189. package/.next/standalone/.next/server/app/api/tools/[name]/approve/route_client-reference-manifest.js +1 -1
  190. package/.next/standalone/.next/server/app/api/tools/[name]/route_client-reference-manifest.js +1 -1
  191. package/.next/standalone/.next/server/app/api/tools/route_client-reference-manifest.js +1 -1
  192. package/.next/standalone/.next/server/app/api/transcripts/route_client-reference-manifest.js +1 -1
  193. package/.next/standalone/.next/server/app/api/voice/providers/route_client-reference-manifest.js +1 -1
  194. package/.next/standalone/.next/server/app/api/voice/realtime/context/route_client-reference-manifest.js +1 -1
  195. package/.next/standalone/.next/server/app/api/voice/realtime/session/route_client-reference-manifest.js +1 -1
  196. package/.next/standalone/.next/server/app/api/voice/realtime/tool-result/route_client-reference-manifest.js +1 -1
  197. package/.next/standalone/.next/server/app/api/voice/realtime/tools/route_client-reference-manifest.js +1 -1
  198. package/.next/standalone/.next/server/app/api/voice/tts/route_client-reference-manifest.js +1 -1
  199. package/.next/standalone/.next/server/app/api/whatsapp/allowlist/route_client-reference-manifest.js +1 -1
  200. package/.next/standalone/.next/server/app/api/whatsapp/disconnect/route_client-reference-manifest.js +1 -1
  201. package/.next/standalone/.next/server/app/api/whatsapp/messages/route_client-reference-manifest.js +1 -1
  202. package/.next/standalone/.next/server/app/api/whatsapp/qr/route_client-reference-manifest.js +1 -1
  203. package/.next/standalone/.next/server/app/api/whatsapp/send/route_client-reference-manifest.js +1 -1
  204. package/.next/standalone/.next/server/app/api/whatsapp/status/route_client-reference-manifest.js +1 -1
  205. package/.next/standalone/.next/server/app/approvals/page.js +2 -2
  206. package/.next/standalone/.next/server/app/approvals/page_client-reference-manifest.js +1 -1
  207. package/.next/standalone/.next/server/app/architecture/page_client-reference-manifest.js +1 -1
  208. package/.next/standalone/.next/server/app/architecture.html +2 -2
  209. package/.next/standalone/.next/server/app/architecture.rsc +3 -3
  210. package/.next/standalone/.next/server/app/audit/live/page_client-reference-manifest.js +1 -1
  211. package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  212. package/.next/standalone/.next/server/app/brand/page_client-reference-manifest.js +1 -1
  213. package/.next/standalone/.next/server/app/brand.html +2 -2
  214. package/.next/standalone/.next/server/app/brand.rsc +3 -3
  215. package/.next/standalone/.next/server/app/disk/page_client-reference-manifest.js +1 -1
  216. package/.next/standalone/.next/server/app/federated-ai/page_client-reference-manifest.js +1 -1
  217. package/.next/standalone/.next/server/app/federated-ai.html +2 -2
  218. package/.next/standalone/.next/server/app/federated-ai.rsc +3 -3
  219. package/.next/standalone/.next/server/app/hail/[id]/governance/page_client-reference-manifest.js +1 -1
  220. package/.next/standalone/.next/server/app/hail/[id]/interview/page.js +2 -2
  221. package/.next/standalone/.next/server/app/hail/[id]/interview/page_client-reference-manifest.js +1 -1
  222. package/.next/standalone/.next/server/app/hail/[id]/page.js +1 -1
  223. package/.next/standalone/.next/server/app/hail/[id]/page_client-reference-manifest.js +1 -1
  224. package/.next/standalone/.next/server/app/hail/[id]/setup/page.js +2 -2
  225. package/.next/standalone/.next/server/app/hail/[id]/setup/page_client-reference-manifest.js +1 -1
  226. package/.next/standalone/.next/server/app/hail/page.js +2 -2
  227. package/.next/standalone/.next/server/app/hail/page_client-reference-manifest.js +1 -1
  228. package/.next/standalone/.next/server/app/help/[slug]/page_client-reference-manifest.js +1 -1
  229. package/.next/standalone/.next/server/app/help/page_client-reference-manifest.js +1 -1
  230. package/.next/standalone/.next/server/app/index.html +2 -2
  231. package/.next/standalone/.next/server/app/index.rsc +4 -4
  232. package/.next/standalone/.next/server/app/join/page_client-reference-manifest.js +1 -1
  233. package/.next/standalone/.next/server/app/join.html +1 -1
  234. package/.next/standalone/.next/server/app/join.rsc +3 -3
  235. package/.next/standalone/.next/server/app/login/page_client-reference-manifest.js +1 -1
  236. package/.next/standalone/.next/server/app/marketplace/page.js +2 -2
  237. package/.next/standalone/.next/server/app/marketplace/page_client-reference-manifest.js +1 -1
  238. package/.next/standalone/.next/server/app/mines/[projectId]/page_client-reference-manifest.js +1 -1
  239. package/.next/standalone/.next/server/app/mines/[projectId]/results/page_client-reference-manifest.js +1 -1
  240. package/.next/standalone/.next/server/app/mines/page_client-reference-manifest.js +1 -1
  241. package/.next/standalone/.next/server/app/missions/page.js +2 -2
  242. package/.next/standalone/.next/server/app/missions/page_client-reference-manifest.js +1 -1
  243. package/.next/standalone/.next/server/app/onboarding/org/page_client-reference-manifest.js +1 -1
  244. package/.next/standalone/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
  245. package/.next/standalone/.next/server/app/onboarding/team/page_client-reference-manifest.js +1 -1
  246. package/.next/standalone/.next/server/app/onboarding.html +2 -2
  247. package/.next/standalone/.next/server/app/onboarding.rsc +3 -3
  248. package/.next/standalone/.next/server/app/org/page.js +1 -1
  249. package/.next/standalone/.next/server/app/org/page.js.nft.json +1 -1
  250. package/.next/standalone/.next/server/app/org/page_client-reference-manifest.js +1 -1
  251. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  252. package/.next/standalone/.next/server/app/projects/[slug]/log/page_client-reference-manifest.js +1 -1
  253. package/.next/standalone/.next/server/app/projects/[slug]/page.js +2 -2
  254. package/.next/standalone/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
  255. package/.next/standalone/.next/server/app/projects/new/page.js +2 -2
  256. package/.next/standalone/.next/server/app/projects/new/page_client-reference-manifest.js +1 -1
  257. package/.next/standalone/.next/server/app/projects/new.html +2 -2
  258. package/.next/standalone/.next/server/app/projects/new.rsc +4 -4
  259. package/.next/standalone/.next/server/app/projects/page.js +16 -12
  260. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  261. package/.next/standalone/.next/server/app/reports/[file]/route_client-reference-manifest.js +1 -1
  262. package/.next/standalone/.next/server/app/reports/page_client-reference-manifest.js +1 -1
  263. package/.next/standalone/.next/server/app/runtime/page_client-reference-manifest.js +1 -1
  264. package/.next/standalone/.next/server/app/schedules/page.js +2 -2
  265. package/.next/standalone/.next/server/app/schedules/page_client-reference-manifest.js +1 -1
  266. package/.next/standalone/.next/server/app/settings/account/page_client-reference-manifest.js +1 -1
  267. package/.next/standalone/.next/server/app/settings/advanced/page_client-reference-manifest.js +1 -1
  268. package/.next/standalone/.next/server/app/settings/appearance/page_client-reference-manifest.js +1 -1
  269. package/.next/standalone/.next/server/app/settings/brand/page_client-reference-manifest.js +1 -1
  270. package/.next/standalone/.next/server/app/settings/brand.html +2 -2
  271. package/.next/standalone/.next/server/app/settings/brand.rsc +3 -3
  272. package/.next/standalone/.next/server/app/settings/connectors/page_client-reference-manifest.js +1 -1
  273. package/.next/standalone/.next/server/app/settings/engines/page_client-reference-manifest.js +1 -1
  274. package/.next/standalone/.next/server/app/settings/onboarding/page_client-reference-manifest.js +1 -1
  275. package/.next/standalone/.next/server/app/settings/onboarding.html +2 -2
  276. package/.next/standalone/.next/server/app/settings/onboarding.rsc +3 -3
  277. package/.next/standalone/.next/server/app/settings/organization/page.js +1 -1
  278. package/.next/standalone/.next/server/app/settings/organization/page.js.nft.json +1 -1
  279. package/.next/standalone/.next/server/app/settings/organization/page_client-reference-manifest.js +1 -1
  280. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  281. package/.next/standalone/.next/server/app/settings/runtime/page_client-reference-manifest.js +1 -1
  282. package/.next/standalone/.next/server/app/settings/team/page_client-reference-manifest.js +1 -1
  283. package/.next/standalone/.next/server/app/settings/tools/page_client-reference-manifest.js +1 -1
  284. package/.next/standalone/.next/server/app/settings.html +2 -2
  285. package/.next/standalone/.next/server/app/settings.rsc +3 -3
  286. package/.next/standalone/.next/server/app/share/[token]/page_client-reference-manifest.js +1 -1
  287. package/.next/standalone/.next/server/app/share/space/[token]/page_client-reference-manifest.js +1 -1
  288. package/.next/standalone/.next/server/app/tasks/[id]/page.js +2 -2
  289. package/.next/standalone/.next/server/app/tasks/[id]/page_client-reference-manifest.js +1 -1
  290. package/.next/standalone/.next/server/app/tasks/page.js +2 -2
  291. package/.next/standalone/.next/server/app/tasks/page_client-reference-manifest.js +1 -1
  292. package/.next/standalone/.next/server/app/team/[agentId]/page_client-reference-manifest.js +1 -1
  293. package/.next/standalone/.next/server/app/team/page_client-reference-manifest.js +1 -1
  294. package/.next/standalone/.next/server/app/tools/page_client-reference-manifest.js +1 -1
  295. package/.next/standalone/.next/server/app/whatsapp/page_client-reference-manifest.js +1 -1
  296. package/.next/standalone/.next/server/app/whatsapp.html +2 -2
  297. package/.next/standalone/.next/server/app/whatsapp.rsc +3 -3
  298. package/.next/standalone/.next/server/app/workflows/[caseId]/page_client-reference-manifest.js +1 -1
  299. package/.next/standalone/.next/server/app/workflows/new/[caseId]/page_client-reference-manifest.js +1 -1
  300. package/.next/standalone/.next/server/app/workflows/new/definition/page_client-reference-manifest.js +1 -1
  301. package/.next/standalone/.next/server/app/workflows/page_client-reference-manifest.js +1 -1
  302. package/.next/standalone/.next/server/app/workflows/share/[caseId]/page_client-reference-manifest.js +1 -1
  303. package/.next/standalone/.next/server/app-paths-manifest.json +79 -78
  304. package/.next/standalone/.next/server/chunks/1699.js +34 -20
  305. package/.next/standalone/.next/server/chunks/4740.js +1 -1
  306. package/.next/standalone/.next/server/chunks/511.js +7 -7
  307. package/.next/standalone/.next/server/chunks/6059.js +1 -1
  308. package/.next/standalone/.next/server/chunks/7098.js +1 -0
  309. package/.next/standalone/.next/server/functions-config-manifest.json +53 -52
  310. package/.next/standalone/.next/server/middleware-manifest.json +5 -5
  311. package/.next/standalone/.next/server/pages/404.html +2 -2
  312. package/.next/standalone/.next/server/pages/500.html +1 -1
  313. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  314. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  315. package/.next/standalone/.next/static/IDXwXTmFu4HQak2wJH1Qy/_buildManifest.js +1 -0
  316. package/.next/standalone/.next/static/chunks/app/activity/loading-1ba78d5ff6330abc.js +1 -0
  317. package/.next/standalone/.next/static/chunks/app/agents/[id]/loading-1ba78d5ff6330abc.js +1 -0
  318. package/.next/standalone/.next/static/chunks/app/agents/[id]/page-b10b2ac79b5980a8.js +1 -0
  319. package/.next/standalone/.next/static/chunks/app/agents/loading-1ba78d5ff6330abc.js +1 -0
  320. package/.next/standalone/.next/static/chunks/app/agents/page-c3aa602e9ee205d1.js +1 -0
  321. package/.next/standalone/.next/static/chunks/app/api/activity/route-1ba78d5ff6330abc.js +1 -0
  322. package/.next/standalone/.next/static/chunks/app/api/admin/audit-export/route-1ba78d5ff6330abc.js +1 -0
  323. package/.next/standalone/.next/static/chunks/app/api/admin/share-links/route-1ba78d5ff6330abc.js +1 -0
  324. package/.next/standalone/.next/static/chunks/app/api/agent-memory/route-1ba78d5ff6330abc.js +1 -0
  325. package/.next/standalone/.next/static/chunks/app/api/agent-runs/[id]/cancel/route-1ba78d5ff6330abc.js +1 -0
  326. package/.next/standalone/.next/static/chunks/app/api/agent-runs/[id]/events/route-1ba78d5ff6330abc.js +1 -0
  327. package/.next/standalone/.next/static/chunks/app/api/agent-runs/[id]/log/route-1ba78d5ff6330abc.js +1 -0
  328. package/.next/standalone/.next/static/chunks/app/api/agent-runs/[id]/route-1ba78d5ff6330abc.js +1 -0
  329. package/.next/standalone/.next/static/chunks/app/api/agent-runs/route-1ba78d5ff6330abc.js +1 -0
  330. package/.next/standalone/.next/static/chunks/app/api/agents/[id]/active-run/route-1ba78d5ff6330abc.js +1 -0
  331. package/.next/standalone/.next/static/chunks/app/api/agents/[id]/chain/route-1ba78d5ff6330abc.js +1 -0
  332. package/.next/standalone/.next/static/chunks/app/api/agents/[id]/memory/route-1ba78d5ff6330abc.js +1 -0
  333. package/.next/standalone/.next/static/chunks/app/api/agents/[id]/reports/route-1ba78d5ff6330abc.js +1 -0
  334. package/.next/standalone/.next/static/chunks/app/api/agents/[id]/run/route-1ba78d5ff6330abc.js +1 -0
  335. package/.next/standalone/.next/static/chunks/app/api/agents/[id]/skills/route-1ba78d5ff6330abc.js +1 -0
  336. package/.next/standalone/.next/static/chunks/app/api/agents/active-runs/route-1ba78d5ff6330abc.js +1 -0
  337. package/.next/standalone/.next/static/chunks/app/api/agents/create/route-1ba78d5ff6330abc.js +1 -0
  338. package/.next/standalone/.next/static/chunks/app/api/agents/ops/route-1ba78d5ff6330abc.js +1 -0
  339. package/.next/standalone/.next/static/chunks/app/api/agents/resume-approval/route-1ba78d5ff6330abc.js +1 -0
  340. package/.next/standalone/.next/static/chunks/app/api/approvals/[id]/route-1ba78d5ff6330abc.js +1 -0
  341. package/.next/standalone/.next/static/chunks/app/api/approvals/route-1ba78d5ff6330abc.js +1 -0
  342. package/.next/standalone/.next/static/chunks/app/api/artifacts/[id]/acl/route-1ba78d5ff6330abc.js +1 -0
  343. package/.next/standalone/.next/static/chunks/app/api/artifacts/[id]/protect/route-1ba78d5ff6330abc.js +1 -0
  344. package/.next/standalone/.next/static/chunks/app/api/artifacts/[id]/raw/route-1ba78d5ff6330abc.js +1 -0
  345. package/.next/standalone/.next/static/chunks/app/api/artifacts/[id]/route-1ba78d5ff6330abc.js +1 -0
  346. package/.next/standalone/.next/static/chunks/app/api/artifacts/[id]/share-link/[linkId]/route-1ba78d5ff6330abc.js +1 -0
  347. package/.next/standalone/.next/static/chunks/app/api/artifacts/[id]/share-link/route-1ba78d5ff6330abc.js +1 -0
  348. package/.next/standalone/.next/static/chunks/app/api/artifacts/upload/route-1ba78d5ff6330abc.js +1 -0
  349. package/.next/standalone/.next/static/chunks/app/api/audit/list/route-1ba78d5ff6330abc.js +1 -0
  350. package/.next/standalone/.next/static/chunks/app/api/audit/search/route-1ba78d5ff6330abc.js +1 -0
  351. package/.next/standalone/.next/static/chunks/app/api/auth/callback/route-1ba78d5ff6330abc.js +1 -0
  352. package/.next/standalone/.next/static/chunks/app/api/auth/config/route-1ba78d5ff6330abc.js +1 -0
  353. package/.next/standalone/.next/static/chunks/app/api/auth/join-bootstrap/route-1ba78d5ff6330abc.js +1 -0
  354. package/.next/standalone/.next/static/chunks/app/api/auth/session/route-1ba78d5ff6330abc.js +1 -0
  355. package/.next/standalone/.next/static/chunks/app/api/brand/route-1ba78d5ff6330abc.js +1 -0
  356. package/.next/standalone/.next/static/chunks/app/api/brand/share/route-1ba78d5ff6330abc.js +1 -0
  357. package/.next/standalone/.next/static/chunks/app/api/chat/sessions/[id]/route-1ba78d5ff6330abc.js +1 -0
  358. package/.next/standalone/.next/static/chunks/app/api/chat/sessions/route-1ba78d5ff6330abc.js +1 -0
  359. package/.next/standalone/.next/static/chunks/app/api/cloud/schema/route-1ba78d5ff6330abc.js +1 -0
  360. package/.next/standalone/.next/static/chunks/app/api/config/env/route-1ba78d5ff6330abc.js +1 -0
  361. package/.next/standalone/.next/static/chunks/app/api/config/route-1ba78d5ff6330abc.js +1 -0
  362. package/.next/standalone/.next/static/chunks/app/api/connections/[service]/route-1ba78d5ff6330abc.js +1 -0
  363. package/.next/standalone/.next/static/chunks/app/api/connections/[service]/verify/route-1ba78d5ff6330abc.js +1 -0
  364. package/.next/standalone/.next/static/chunks/app/api/connections/route-1ba78d5ff6330abc.js +1 -0
  365. package/.next/standalone/.next/static/chunks/app/api/cron/tick/route-1ba78d5ff6330abc.js +1 -0
  366. package/.next/standalone/.next/static/chunks/app/api/dashboard/spaces/[id]/move/route-1ba78d5ff6330abc.js +1 -0
  367. package/.next/standalone/.next/static/chunks/app/api/dashboard/spaces/[id]/route-1ba78d5ff6330abc.js +1 -0
  368. package/.next/standalone/.next/static/chunks/app/api/dashboard/spaces/[id]/share-link/[linkId]/route-1ba78d5ff6330abc.js +1 -0
  369. package/.next/standalone/.next/static/chunks/app/api/dashboard/spaces/[id]/share-link/route-1ba78d5ff6330abc.js +1 -0
  370. package/.next/standalone/.next/static/chunks/app/api/dashboard/spaces/import/route-1ba78d5ff6330abc.js +1 -0
  371. package/.next/standalone/.next/static/chunks/app/api/dashboard/spaces/route-1ba78d5ff6330abc.js +1 -0
  372. package/.next/standalone/.next/static/chunks/app/api/disk/files/[id]/blob/route-1ba78d5ff6330abc.js +1 -0
  373. package/.next/standalone/.next/static/chunks/app/api/disk/files/[id]/route-1ba78d5ff6330abc.js +1 -0
  374. package/.next/standalone/.next/static/chunks/app/api/disk/files/[id]/transcribe/route-1ba78d5ff6330abc.js +1 -0
  375. package/.next/standalone/.next/static/chunks/app/api/disk/files/route-1ba78d5ff6330abc.js +1 -0
  376. package/.next/standalone/.next/static/chunks/app/api/disk/folders/route-1ba78d5ff6330abc.js +1 -0
  377. package/.next/standalone/.next/static/chunks/app/api/events/since/[cursor]/route-1ba78d5ff6330abc.js +1 -0
  378. package/.next/standalone/.next/static/chunks/app/api/events/stream/route-1ba78d5ff6330abc.js +1 -0
  379. package/.next/standalone/.next/static/chunks/app/api/fs/create-folder/route-1ba78d5ff6330abc.js +1 -0
  380. package/.next/standalone/.next/static/chunks/app/api/fs/pick-folder/route-1ba78d5ff6330abc.js +1 -0
  381. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/blueprint/route-1ba78d5ff6330abc.js +1 -0
  382. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/diagnostic/route-1ba78d5ff6330abc.js +1 -0
  383. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/governance/route-1ba78d5ff6330abc.js +1 -0
  384. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/interview/route-1ba78d5ff6330abc.js +1 -0
  385. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/pilot/route-1ba78d5ff6330abc.js +1 -0
  386. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/quarterly/route-1ba78d5ff6330abc.js +1 -0
  387. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/route-1ba78d5ff6330abc.js +1 -0
  388. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/setup-package/route-1ba78d5ff6330abc.js +1 -0
  389. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/route-1ba78d5ff6330abc.js +1 -0
  390. package/.next/standalone/.next/static/chunks/app/api/hail/interviews/[id]/responses/route-1ba78d5ff6330abc.js +1 -0
  391. package/.next/standalone/.next/static/chunks/app/api/hail/interviews/[id]/route-1ba78d5ff6330abc.js +1 -0
  392. package/.next/standalone/.next/static/chunks/app/api/hail/setup-packages/[id]/apply/route-1ba78d5ff6330abc.js +1 -0
  393. package/.next/standalone/.next/static/chunks/app/api/hail/setup-packages/validate/route-1ba78d5ff6330abc.js +1 -0
  394. package/.next/standalone/.next/static/chunks/app/api/heartbeat/tick/route-1ba78d5ff6330abc.js +1 -0
  395. package/.next/standalone/.next/static/chunks/app/api/heartbeat/worker/route-1ba78d5ff6330abc.js +1 -0
  396. package/.next/standalone/.next/static/chunks/app/api/help/route-1ba78d5ff6330abc.js +1 -0
  397. package/.next/standalone/.next/static/chunks/app/api/hermes/jobs/[id]/events/route-1ba78d5ff6330abc.js +1 -0
  398. package/.next/standalone/.next/static/chunks/app/api/hermes/jobs/[id]/route-1ba78d5ff6330abc.js +1 -0
  399. package/.next/standalone/.next/static/chunks/app/api/hermes/jobs/route-1ba78d5ff6330abc.js +1 -0
  400. package/.next/standalone/.next/static/chunks/app/api/integrations/google/callback/route-1ba78d5ff6330abc.js +1 -0
  401. package/.next/standalone/.next/static/chunks/app/api/integrations/google/oauth/route-1ba78d5ff6330abc.js +1 -0
  402. package/.next/standalone/.next/static/chunks/app/api/marketplace/[id]/route-1ba78d5ff6330abc.js +1 -0
  403. package/.next/standalone/.next/static/chunks/app/api/marketplace/open-design/route-1ba78d5ff6330abc.js +1 -0
  404. package/.next/standalone/.next/static/chunks/app/api/marketplace/route-1ba78d5ff6330abc.js +1 -0
  405. package/.next/standalone/.next/static/chunks/app/api/mines/import-roots/route-1ba78d5ff6330abc.js +1 -0
  406. package/.next/standalone/.next/static/chunks/app/api/mines/portfolio/route-1ba78d5ff6330abc.js +1 -0
  407. package/.next/standalone/.next/static/chunks/app/api/mines/projects/[id]/chunks/route-1ba78d5ff6330abc.js +1 -0
  408. package/.next/standalone/.next/static/chunks/app/api/mines/projects/[id]/diligence/route-1ba78d5ff6330abc.js +1 -0
  409. package/.next/standalone/.next/static/chunks/app/api/mines/projects/[id]/import/route-1ba78d5ff6330abc.js +1 -0
  410. package/.next/standalone/.next/static/chunks/app/api/mines/projects/[id]/publish/route-1ba78d5ff6330abc.js +1 -0
  411. package/.next/standalone/.next/static/chunks/app/api/mines/projects/route-1ba78d5ff6330abc.js +1 -0
  412. package/.next/standalone/.next/static/chunks/app/api/missions/route-1ba78d5ff6330abc.js +1 -0
  413. package/.next/standalone/.next/static/chunks/app/api/models/route-1ba78d5ff6330abc.js +1 -0
  414. package/.next/standalone/.next/static/chunks/app/api/onboarding/blueprint/route-1ba78d5ff6330abc.js +1 -0
  415. package/.next/standalone/.next/static/chunks/app/api/onboarding/launch/route-1ba78d5ff6330abc.js +1 -0
  416. package/.next/standalone/.next/static/chunks/app/api/orchestrator/command/route-1ba78d5ff6330abc.js +1 -0
  417. package/.next/standalone/.next/static/chunks/app/api/orchestrator/stream/attach/route-1ba78d5ff6330abc.js +1 -0
  418. package/.next/standalone/.next/static/chunks/app/api/orchestrator/stream/route-1ba78d5ff6330abc.js +1 -0
  419. package/.next/standalone/.next/static/chunks/app/api/orchestrator/upload/route-1ba78d5ff6330abc.js +1 -0
  420. package/.next/standalone/.next/static/chunks/app/api/org/route-1ba78d5ff6330abc.js +1 -0
  421. package/.next/standalone/.next/static/chunks/app/api/orgs/[id]/invites/[inviteId]/route-1ba78d5ff6330abc.js +1 -0
  422. package/.next/standalone/.next/static/chunks/app/api/orgs/[id]/invites/route-1ba78d5ff6330abc.js +1 -0
  423. package/.next/standalone/.next/static/chunks/app/api/orgs/[id]/members/[userId]/role/route-1ba78d5ff6330abc.js +1 -0
  424. package/.next/standalone/.next/static/chunks/app/api/orgs/[id]/members/[userId]/route-1ba78d5ff6330abc.js +1 -0
  425. package/.next/standalone/.next/static/chunks/app/api/orgs/[id]/members/route-1ba78d5ff6330abc.js +1 -0
  426. package/.next/standalone/.next/static/chunks/app/api/orgs/[id]/route-1ba78d5ff6330abc.js +1 -0
  427. package/.next/standalone/.next/static/chunks/app/api/orgs/invites/pending/route-1ba78d5ff6330abc.js +1 -0
  428. package/.next/standalone/.next/static/chunks/app/api/orgs/join/route-1ba78d5ff6330abc.js +1 -0
  429. package/.next/standalone/.next/static/chunks/app/api/orgs/join-complete/route-1ba78d5ff6330abc.js +1 -0
  430. package/.next/standalone/.next/static/chunks/app/api/orgs/route-1ba78d5ff6330abc.js +1 -0
  431. package/.next/standalone/.next/static/chunks/app/api/printing-press/clis/route-1ba78d5ff6330abc.js +1 -0
  432. package/.next/standalone/.next/static/chunks/app/api/printing-press/install/route-1ba78d5ff6330abc.js +1 -0
  433. package/.next/standalone/.next/static/chunks/app/api/printing-press/security-mode/route-1ba78d5ff6330abc.js +1 -0
  434. package/.next/standalone/.next/static/chunks/app/api/privacy/config/route-1ba78d5ff6330abc.js +1 -0
  435. package/.next/standalone/.next/static/chunks/app/api/privacy/verify/route-1ba78d5ff6330abc.js +1 -0
  436. package/.next/standalone/.next/static/chunks/app/api/processes/[id]/route-1ba78d5ff6330abc.js +1 -0
  437. package/.next/standalone/.next/static/chunks/app/api/processes/[id]/share-link/route-1ba78d5ff6330abc.js +1 -0
  438. package/.next/standalone/.next/static/chunks/app/api/processes/[id]/stages/[stageId]/override/route-1ba78d5ff6330abc.js +1 -0
  439. package/.next/standalone/.next/static/chunks/app/api/processes/[id]/stages/[stageId]/retry/route-1ba78d5ff6330abc.js +1 -0
  440. package/.next/standalone/.next/static/chunks/app/api/processes/[id]/stages/[stageId]/submit/route-1ba78d5ff6330abc.js +1 -0
  441. package/.next/standalone/.next/static/chunks/app/api/processes/definitions/[slug]/route-1ba78d5ff6330abc.js +1 -0
  442. package/.next/standalone/.next/static/chunks/app/api/processes/definitions/[slug]/settings/route-1ba78d5ff6330abc.js +1 -0
  443. package/.next/standalone/.next/static/chunks/app/api/processes/definitions/route-1ba78d5ff6330abc.js +1 -0
  444. package/.next/standalone/.next/static/chunks/app/api/processes/definitions/validate/route-1ba78d5ff6330abc.js +1 -0
  445. package/.next/standalone/.next/static/chunks/app/api/processes/route-1ba78d5ff6330abc.js +1 -0
  446. package/.next/standalone/.next/static/chunks/app/api/processes/start-and-route/route-1ba78d5ff6330abc.js +1 -0
  447. package/.next/standalone/.next/static/chunks/app/api/projects/[slug]/library/route-1ba78d5ff6330abc.js +1 -0
  448. package/.next/standalone/.next/static/chunks/app/api/projects/[slug]/route-1ba78d5ff6330abc.js +1 -0
  449. package/.next/standalone/.next/static/chunks/app/api/projects/route-1ba78d5ff6330abc.js +1 -0
  450. package/.next/standalone/.next/static/chunks/app/api/runs/approve-claude-run/route-1ba78d5ff6330abc.js +1 -0
  451. package/.next/standalone/.next/static/chunks/app/api/runs/claude-code-dry-run/route-1ba78d5ff6330abc.js +1 -0
  452. package/.next/standalone/.next/static/chunks/app/api/runs/competitor-report/route-1ba78d5ff6330abc.js +1 -0
  453. package/.next/standalone/.next/static/chunks/app/api/runs/engine-ping/route-1ba78d5ff6330abc.js +1 -0
  454. package/.next/standalone/.next/static/chunks/app/api/runs/marketing-plan/route-1ba78d5ff6330abc.js +1 -0
  455. package/.next/standalone/.next/static/chunks/app/api/schedules/upsert/route-1ba78d5ff6330abc.js +1 -0
  456. package/.next/standalone/.next/static/chunks/app/api/secrets/[name]/route-1ba78d5ff6330abc.js +1 -0
  457. package/.next/standalone/.next/static/chunks/app/api/secrets/route-1ba78d5ff6330abc.js +1 -0
  458. package/.next/standalone/.next/static/chunks/app/api/settings/trust-mode/route-1ba78d5ff6330abc.js +1 -0
  459. package/.next/standalone/.next/static/chunks/app/api/share/[token]/otp/route-1ba78d5ff6330abc.js +1 -0
  460. package/.next/standalone/.next/static/chunks/app/api/share/[token]/route-1ba78d5ff6330abc.js +1 -0
  461. package/.next/standalone/.next/static/chunks/app/api/share/[token]/verify/route-1ba78d5ff6330abc.js +1 -0
  462. package/.next/standalone/.next/static/chunks/app/api/share/space/[token]/otp/route-1ba78d5ff6330abc.js +1 -0
  463. package/.next/standalone/.next/static/chunks/app/api/share/space/[token]/route-1ba78d5ff6330abc.js +1 -0
  464. package/.next/standalone/.next/static/chunks/app/api/share/space/[token]/verify/route-1ba78d5ff6330abc.js +1 -0
  465. package/.next/standalone/.next/static/chunks/app/api/shared/spaces/[id]/acl/route-1ba78d5ff6330abc.js +1 -0
  466. package/.next/standalone/.next/static/chunks/app/api/shared/spaces/publish/route-1ba78d5ff6330abc.js +1 -0
  467. package/.next/standalone/.next/static/chunks/app/api/shared/spaces/route-1ba78d5ff6330abc.js +1 -0
  468. package/.next/standalone/.next/static/chunks/app/api/shared/spaces/status/route-1ba78d5ff6330abc.js +1 -0
  469. package/.next/standalone/.next/static/chunks/app/api/shared/spaces/unpublish/route-1ba78d5ff6330abc.js +1 -0
  470. package/.next/standalone/.next/static/chunks/app/api/state/route-1ba78d5ff6330abc.js +1 -0
  471. package/.next/standalone/.next/static/chunks/app/api/system/update/route-1ba78d5ff6330abc.js +1 -0
  472. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/active-run/route-1ba78d5ff6330abc.js +1 -0
  473. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/attachments/route-1ba78d5ff6330abc.js +1 -0
  474. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/checklist/[itemId]/route-1ba78d5ff6330abc.js +1 -0
  475. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/checklist/route-1ba78d5ff6330abc.js +1 -0
  476. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/checkout/route-1ba78d5ff6330abc.js +1 -0
  477. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/children/route-1ba78d5ff6330abc.js +1 -0
  478. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/comments/route-1ba78d5ff6330abc.js +1 -0
  479. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/events/route-1ba78d5ff6330abc.js +1 -0
  480. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/live-runs/route-1ba78d5ff6330abc.js +1 -0
  481. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/release/route-1ba78d5ff6330abc.js +1 -0
  482. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/route-1ba78d5ff6330abc.js +1 -0
  483. package/.next/standalone/.next/static/chunks/app/api/tasks/route-1ba78d5ff6330abc.js +1 -0
  484. package/.next/standalone/.next/static/chunks/app/api/tool-allowlists/[id]/route-1ba78d5ff6330abc.js +1 -0
  485. package/.next/standalone/.next/static/chunks/app/api/tool-allowlists/route-1ba78d5ff6330abc.js +1 -0
  486. package/.next/standalone/.next/static/chunks/app/api/tool-egress/route-1ba78d5ff6330abc.js +1 -0
  487. package/.next/standalone/.next/static/chunks/app/api/tools/[name]/approve/route-1ba78d5ff6330abc.js +1 -0
  488. package/.next/standalone/.next/static/chunks/app/api/tools/[name]/route-1ba78d5ff6330abc.js +1 -0
  489. package/.next/standalone/.next/static/chunks/app/api/tools/route-1ba78d5ff6330abc.js +1 -0
  490. package/.next/standalone/.next/static/chunks/app/api/transcripts/route-1ba78d5ff6330abc.js +1 -0
  491. package/.next/standalone/.next/static/chunks/app/api/voice/providers/route-1ba78d5ff6330abc.js +1 -0
  492. package/.next/standalone/.next/static/chunks/app/api/voice/realtime/context/route-1ba78d5ff6330abc.js +1 -0
  493. package/.next/standalone/.next/static/chunks/app/api/voice/realtime/session/route-1ba78d5ff6330abc.js +1 -0
  494. package/.next/standalone/.next/static/chunks/app/api/voice/realtime/tool-result/route-1ba78d5ff6330abc.js +1 -0
  495. package/.next/standalone/.next/static/chunks/app/api/voice/realtime/tools/route-1ba78d5ff6330abc.js +1 -0
  496. package/.next/standalone/.next/static/chunks/app/api/voice/tts/route-1ba78d5ff6330abc.js +1 -0
  497. package/.next/standalone/.next/static/chunks/app/api/whatsapp/allowlist/route-1ba78d5ff6330abc.js +1 -0
  498. package/.next/standalone/.next/static/chunks/app/api/whatsapp/disconnect/route-1ba78d5ff6330abc.js +1 -0
  499. package/.next/standalone/.next/static/chunks/app/api/whatsapp/messages/route-1ba78d5ff6330abc.js +1 -0
  500. package/.next/standalone/.next/static/chunks/app/api/whatsapp/qr/route-1ba78d5ff6330abc.js +1 -0
  501. package/.next/standalone/.next/static/chunks/app/api/whatsapp/send/route-1ba78d5ff6330abc.js +1 -0
  502. package/.next/standalone/.next/static/chunks/app/api/whatsapp/status/route-1ba78d5ff6330abc.js +1 -0
  503. package/.next/standalone/.next/static/chunks/app/approvals/loading-1ba78d5ff6330abc.js +1 -0
  504. package/.next/standalone/.next/static/chunks/app/architecture/loading-1ba78d5ff6330abc.js +1 -0
  505. package/.next/standalone/.next/static/chunks/app/audit/loading-1ba78d5ff6330abc.js +1 -0
  506. package/.next/standalone/.next/static/chunks/app/brand/loading-1ba78d5ff6330abc.js +1 -0
  507. package/.next/standalone/.next/static/chunks/app/disk/loading-1ba78d5ff6330abc.js +1 -0
  508. package/.next/standalone/.next/static/chunks/app/federated-ai/loading-1ba78d5ff6330abc.js +1 -0
  509. package/.next/standalone/.next/static/chunks/app/help/loading-1ba78d5ff6330abc.js +1 -0
  510. package/.next/standalone/.next/static/chunks/app/layout-7c734abe785c0d86.js +1 -0
  511. package/.next/standalone/.next/static/chunks/app/loading-1ba78d5ff6330abc.js +1 -0
  512. package/.next/standalone/.next/static/chunks/app/marketplace/loading-1ba78d5ff6330abc.js +1 -0
  513. package/.next/standalone/.next/static/chunks/app/missions/loading-1ba78d5ff6330abc.js +1 -0
  514. package/.next/standalone/.next/static/chunks/app/onboarding/loading-1ba78d5ff6330abc.js +1 -0
  515. package/.next/standalone/.next/static/chunks/app/org/loading-1ba78d5ff6330abc.js +1 -0
  516. package/.next/standalone/.next/static/chunks/app/page-9d742c9099ab9cd7.js +1 -0
  517. package/.next/standalone/.next/static/chunks/app/projects/[slug]/loading-1ba78d5ff6330abc.js +1 -0
  518. package/.next/standalone/.next/static/chunks/app/projects/[slug]/page-abbc7f06e58ff9ee.js +1 -0
  519. package/.next/standalone/.next/static/chunks/app/projects/loading-1ba78d5ff6330abc.js +1 -0
  520. package/.next/standalone/.next/static/chunks/app/projects/page-87457ee2932c33a3.js +1 -0
  521. package/.next/standalone/.next/static/chunks/app/reports/[file]/route-1ba78d5ff6330abc.js +1 -0
  522. package/.next/standalone/.next/static/chunks/app/reports/loading-1ba78d5ff6330abc.js +1 -0
  523. package/.next/standalone/.next/static/chunks/app/runtime/loading-1ba78d5ff6330abc.js +1 -0
  524. package/.next/standalone/.next/static/chunks/app/schedules/loading-1ba78d5ff6330abc.js +1 -0
  525. package/.next/standalone/.next/static/chunks/app/settings/loading-1ba78d5ff6330abc.js +1 -0
  526. package/.next/standalone/.next/static/chunks/app/settings/page-1ba78d5ff6330abc.js +1 -0
  527. package/.next/standalone/.next/static/chunks/app/tasks/[id]/loading-1ba78d5ff6330abc.js +1 -0
  528. package/.next/standalone/.next/static/chunks/app/tasks/loading-1ba78d5ff6330abc.js +1 -0
  529. package/.next/standalone/.next/static/chunks/app/tools/loading-1ba78d5ff6330abc.js +1 -0
  530. package/.next/standalone/.next/static/chunks/app/tools/page-1ba78d5ff6330abc.js +1 -0
  531. package/.next/standalone/.next/static/chunks/app/whatsapp/loading-1ba78d5ff6330abc.js +1 -0
  532. package/.next/standalone/.next/static/chunks/app/workflows/share/[caseId]/page-1ba78d5ff6330abc.js +1 -0
  533. package/.next/standalone/CHANGELOG.md +12 -0
  534. package/.next/standalone/package.json +1 -1
  535. package/.next/static/IDXwXTmFu4HQak2wJH1Qy/_buildManifest.js +1 -0
  536. package/.next/static/chunks/app/activity/loading-1ba78d5ff6330abc.js +1 -0
  537. package/.next/static/chunks/app/agents/[id]/loading-1ba78d5ff6330abc.js +1 -0
  538. package/.next/static/chunks/app/agents/[id]/page-b10b2ac79b5980a8.js +1 -0
  539. package/.next/static/chunks/app/agents/loading-1ba78d5ff6330abc.js +1 -0
  540. package/.next/static/chunks/app/agents/page-c3aa602e9ee205d1.js +1 -0
  541. package/.next/static/chunks/app/api/activity/route-1ba78d5ff6330abc.js +1 -0
  542. package/.next/static/chunks/app/api/admin/audit-export/route-1ba78d5ff6330abc.js +1 -0
  543. package/.next/static/chunks/app/api/admin/share-links/route-1ba78d5ff6330abc.js +1 -0
  544. package/.next/static/chunks/app/api/agent-memory/route-1ba78d5ff6330abc.js +1 -0
  545. package/.next/static/chunks/app/api/agent-runs/[id]/cancel/route-1ba78d5ff6330abc.js +1 -0
  546. package/.next/static/chunks/app/api/agent-runs/[id]/events/route-1ba78d5ff6330abc.js +1 -0
  547. package/.next/static/chunks/app/api/agent-runs/[id]/log/route-1ba78d5ff6330abc.js +1 -0
  548. package/.next/static/chunks/app/api/agent-runs/[id]/route-1ba78d5ff6330abc.js +1 -0
  549. package/.next/static/chunks/app/api/agent-runs/route-1ba78d5ff6330abc.js +1 -0
  550. package/.next/static/chunks/app/api/agents/[id]/active-run/route-1ba78d5ff6330abc.js +1 -0
  551. package/.next/static/chunks/app/api/agents/[id]/chain/route-1ba78d5ff6330abc.js +1 -0
  552. package/.next/static/chunks/app/api/agents/[id]/memory/route-1ba78d5ff6330abc.js +1 -0
  553. package/.next/static/chunks/app/api/agents/[id]/reports/route-1ba78d5ff6330abc.js +1 -0
  554. package/.next/static/chunks/app/api/agents/[id]/run/route-1ba78d5ff6330abc.js +1 -0
  555. package/.next/static/chunks/app/api/agents/[id]/skills/route-1ba78d5ff6330abc.js +1 -0
  556. package/.next/static/chunks/app/api/agents/active-runs/route-1ba78d5ff6330abc.js +1 -0
  557. package/.next/static/chunks/app/api/agents/create/route-1ba78d5ff6330abc.js +1 -0
  558. package/.next/static/chunks/app/api/agents/ops/route-1ba78d5ff6330abc.js +1 -0
  559. package/.next/static/chunks/app/api/agents/resume-approval/route-1ba78d5ff6330abc.js +1 -0
  560. package/.next/static/chunks/app/api/approvals/[id]/route-1ba78d5ff6330abc.js +1 -0
  561. package/.next/static/chunks/app/api/approvals/route-1ba78d5ff6330abc.js +1 -0
  562. package/.next/static/chunks/app/api/artifacts/[id]/acl/route-1ba78d5ff6330abc.js +1 -0
  563. package/.next/static/chunks/app/api/artifacts/[id]/protect/route-1ba78d5ff6330abc.js +1 -0
  564. package/.next/static/chunks/app/api/artifacts/[id]/raw/route-1ba78d5ff6330abc.js +1 -0
  565. package/.next/static/chunks/app/api/artifacts/[id]/route-1ba78d5ff6330abc.js +1 -0
  566. package/.next/static/chunks/app/api/artifacts/[id]/share-link/[linkId]/route-1ba78d5ff6330abc.js +1 -0
  567. package/.next/static/chunks/app/api/artifacts/[id]/share-link/route-1ba78d5ff6330abc.js +1 -0
  568. package/.next/static/chunks/app/api/artifacts/upload/route-1ba78d5ff6330abc.js +1 -0
  569. package/.next/static/chunks/app/api/audit/list/route-1ba78d5ff6330abc.js +1 -0
  570. package/.next/static/chunks/app/api/audit/search/route-1ba78d5ff6330abc.js +1 -0
  571. package/.next/static/chunks/app/api/auth/callback/route-1ba78d5ff6330abc.js +1 -0
  572. package/.next/static/chunks/app/api/auth/config/route-1ba78d5ff6330abc.js +1 -0
  573. package/.next/static/chunks/app/api/auth/join-bootstrap/route-1ba78d5ff6330abc.js +1 -0
  574. package/.next/static/chunks/app/api/auth/session/route-1ba78d5ff6330abc.js +1 -0
  575. package/.next/static/chunks/app/api/brand/route-1ba78d5ff6330abc.js +1 -0
  576. package/.next/static/chunks/app/api/brand/share/route-1ba78d5ff6330abc.js +1 -0
  577. package/.next/static/chunks/app/api/chat/sessions/[id]/route-1ba78d5ff6330abc.js +1 -0
  578. package/.next/static/chunks/app/api/chat/sessions/route-1ba78d5ff6330abc.js +1 -0
  579. package/.next/static/chunks/app/api/cloud/schema/route-1ba78d5ff6330abc.js +1 -0
  580. package/.next/static/chunks/app/api/config/env/route-1ba78d5ff6330abc.js +1 -0
  581. package/.next/static/chunks/app/api/config/route-1ba78d5ff6330abc.js +1 -0
  582. package/.next/static/chunks/app/api/connections/[service]/route-1ba78d5ff6330abc.js +1 -0
  583. package/.next/static/chunks/app/api/connections/[service]/verify/route-1ba78d5ff6330abc.js +1 -0
  584. package/.next/static/chunks/app/api/connections/route-1ba78d5ff6330abc.js +1 -0
  585. package/.next/static/chunks/app/api/cron/tick/route-1ba78d5ff6330abc.js +1 -0
  586. package/.next/static/chunks/app/api/dashboard/spaces/[id]/move/route-1ba78d5ff6330abc.js +1 -0
  587. package/.next/static/chunks/app/api/dashboard/spaces/[id]/route-1ba78d5ff6330abc.js +1 -0
  588. package/.next/static/chunks/app/api/dashboard/spaces/[id]/share-link/[linkId]/route-1ba78d5ff6330abc.js +1 -0
  589. package/.next/static/chunks/app/api/dashboard/spaces/[id]/share-link/route-1ba78d5ff6330abc.js +1 -0
  590. package/.next/static/chunks/app/api/dashboard/spaces/import/route-1ba78d5ff6330abc.js +1 -0
  591. package/.next/static/chunks/app/api/dashboard/spaces/route-1ba78d5ff6330abc.js +1 -0
  592. package/.next/static/chunks/app/api/disk/files/[id]/blob/route-1ba78d5ff6330abc.js +1 -0
  593. package/.next/static/chunks/app/api/disk/files/[id]/route-1ba78d5ff6330abc.js +1 -0
  594. package/.next/static/chunks/app/api/disk/files/[id]/transcribe/route-1ba78d5ff6330abc.js +1 -0
  595. package/.next/static/chunks/app/api/disk/files/route-1ba78d5ff6330abc.js +1 -0
  596. package/.next/static/chunks/app/api/disk/folders/route-1ba78d5ff6330abc.js +1 -0
  597. package/.next/static/chunks/app/api/events/since/[cursor]/route-1ba78d5ff6330abc.js +1 -0
  598. package/.next/static/chunks/app/api/events/stream/route-1ba78d5ff6330abc.js +1 -0
  599. package/.next/static/chunks/app/api/fs/create-folder/route-1ba78d5ff6330abc.js +1 -0
  600. package/.next/static/chunks/app/api/fs/pick-folder/route-1ba78d5ff6330abc.js +1 -0
  601. package/.next/static/chunks/app/api/hail/engagements/[id]/blueprint/route-1ba78d5ff6330abc.js +1 -0
  602. package/.next/static/chunks/app/api/hail/engagements/[id]/diagnostic/route-1ba78d5ff6330abc.js +1 -0
  603. package/.next/static/chunks/app/api/hail/engagements/[id]/governance/route-1ba78d5ff6330abc.js +1 -0
  604. package/.next/static/chunks/app/api/hail/engagements/[id]/interview/route-1ba78d5ff6330abc.js +1 -0
  605. package/.next/static/chunks/app/api/hail/engagements/[id]/pilot/route-1ba78d5ff6330abc.js +1 -0
  606. package/.next/static/chunks/app/api/hail/engagements/[id]/quarterly/route-1ba78d5ff6330abc.js +1 -0
  607. package/.next/static/chunks/app/api/hail/engagements/[id]/route-1ba78d5ff6330abc.js +1 -0
  608. package/.next/static/chunks/app/api/hail/engagements/[id]/setup-package/route-1ba78d5ff6330abc.js +1 -0
  609. package/.next/static/chunks/app/api/hail/engagements/route-1ba78d5ff6330abc.js +1 -0
  610. package/.next/static/chunks/app/api/hail/interviews/[id]/responses/route-1ba78d5ff6330abc.js +1 -0
  611. package/.next/static/chunks/app/api/hail/interviews/[id]/route-1ba78d5ff6330abc.js +1 -0
  612. package/.next/static/chunks/app/api/hail/setup-packages/[id]/apply/route-1ba78d5ff6330abc.js +1 -0
  613. package/.next/static/chunks/app/api/hail/setup-packages/validate/route-1ba78d5ff6330abc.js +1 -0
  614. package/.next/static/chunks/app/api/heartbeat/tick/route-1ba78d5ff6330abc.js +1 -0
  615. package/.next/static/chunks/app/api/heartbeat/worker/route-1ba78d5ff6330abc.js +1 -0
  616. package/.next/static/chunks/app/api/help/route-1ba78d5ff6330abc.js +1 -0
  617. package/.next/static/chunks/app/api/hermes/jobs/[id]/events/route-1ba78d5ff6330abc.js +1 -0
  618. package/.next/static/chunks/app/api/hermes/jobs/[id]/route-1ba78d5ff6330abc.js +1 -0
  619. package/.next/static/chunks/app/api/hermes/jobs/route-1ba78d5ff6330abc.js +1 -0
  620. package/.next/static/chunks/app/api/integrations/google/callback/route-1ba78d5ff6330abc.js +1 -0
  621. package/.next/static/chunks/app/api/integrations/google/oauth/route-1ba78d5ff6330abc.js +1 -0
  622. package/.next/static/chunks/app/api/marketplace/[id]/route-1ba78d5ff6330abc.js +1 -0
  623. package/.next/static/chunks/app/api/marketplace/open-design/route-1ba78d5ff6330abc.js +1 -0
  624. package/.next/static/chunks/app/api/marketplace/route-1ba78d5ff6330abc.js +1 -0
  625. package/.next/static/chunks/app/api/mines/import-roots/route-1ba78d5ff6330abc.js +1 -0
  626. package/.next/static/chunks/app/api/mines/portfolio/route-1ba78d5ff6330abc.js +1 -0
  627. package/.next/static/chunks/app/api/mines/projects/[id]/chunks/route-1ba78d5ff6330abc.js +1 -0
  628. package/.next/static/chunks/app/api/mines/projects/[id]/diligence/route-1ba78d5ff6330abc.js +1 -0
  629. package/.next/static/chunks/app/api/mines/projects/[id]/import/route-1ba78d5ff6330abc.js +1 -0
  630. package/.next/static/chunks/app/api/mines/projects/[id]/publish/route-1ba78d5ff6330abc.js +1 -0
  631. package/.next/static/chunks/app/api/mines/projects/route-1ba78d5ff6330abc.js +1 -0
  632. package/.next/static/chunks/app/api/missions/route-1ba78d5ff6330abc.js +1 -0
  633. package/.next/static/chunks/app/api/models/route-1ba78d5ff6330abc.js +1 -0
  634. package/.next/static/chunks/app/api/onboarding/blueprint/route-1ba78d5ff6330abc.js +1 -0
  635. package/.next/static/chunks/app/api/onboarding/launch/route-1ba78d5ff6330abc.js +1 -0
  636. package/.next/static/chunks/app/api/orchestrator/command/route-1ba78d5ff6330abc.js +1 -0
  637. package/.next/static/chunks/app/api/orchestrator/stream/attach/route-1ba78d5ff6330abc.js +1 -0
  638. package/.next/static/chunks/app/api/orchestrator/stream/route-1ba78d5ff6330abc.js +1 -0
  639. package/.next/static/chunks/app/api/orchestrator/upload/route-1ba78d5ff6330abc.js +1 -0
  640. package/.next/static/chunks/app/api/org/route-1ba78d5ff6330abc.js +1 -0
  641. package/.next/static/chunks/app/api/orgs/[id]/invites/[inviteId]/route-1ba78d5ff6330abc.js +1 -0
  642. package/.next/static/chunks/app/api/orgs/[id]/invites/route-1ba78d5ff6330abc.js +1 -0
  643. package/.next/static/chunks/app/api/orgs/[id]/members/[userId]/role/route-1ba78d5ff6330abc.js +1 -0
  644. package/.next/static/chunks/app/api/orgs/[id]/members/[userId]/route-1ba78d5ff6330abc.js +1 -0
  645. package/.next/static/chunks/app/api/orgs/[id]/members/route-1ba78d5ff6330abc.js +1 -0
  646. package/.next/static/chunks/app/api/orgs/[id]/route-1ba78d5ff6330abc.js +1 -0
  647. package/.next/static/chunks/app/api/orgs/invites/pending/route-1ba78d5ff6330abc.js +1 -0
  648. package/.next/static/chunks/app/api/orgs/join/route-1ba78d5ff6330abc.js +1 -0
  649. package/.next/static/chunks/app/api/orgs/join-complete/route-1ba78d5ff6330abc.js +1 -0
  650. package/.next/static/chunks/app/api/orgs/route-1ba78d5ff6330abc.js +1 -0
  651. package/.next/static/chunks/app/api/printing-press/clis/route-1ba78d5ff6330abc.js +1 -0
  652. package/.next/static/chunks/app/api/printing-press/install/route-1ba78d5ff6330abc.js +1 -0
  653. package/.next/static/chunks/app/api/printing-press/security-mode/route-1ba78d5ff6330abc.js +1 -0
  654. package/.next/static/chunks/app/api/privacy/config/route-1ba78d5ff6330abc.js +1 -0
  655. package/.next/static/chunks/app/api/privacy/verify/route-1ba78d5ff6330abc.js +1 -0
  656. package/.next/static/chunks/app/api/processes/[id]/route-1ba78d5ff6330abc.js +1 -0
  657. package/.next/static/chunks/app/api/processes/[id]/share-link/route-1ba78d5ff6330abc.js +1 -0
  658. package/.next/static/chunks/app/api/processes/[id]/stages/[stageId]/override/route-1ba78d5ff6330abc.js +1 -0
  659. package/.next/static/chunks/app/api/processes/[id]/stages/[stageId]/retry/route-1ba78d5ff6330abc.js +1 -0
  660. package/.next/static/chunks/app/api/processes/[id]/stages/[stageId]/submit/route-1ba78d5ff6330abc.js +1 -0
  661. package/.next/static/chunks/app/api/processes/definitions/[slug]/route-1ba78d5ff6330abc.js +1 -0
  662. package/.next/static/chunks/app/api/processes/definitions/[slug]/settings/route-1ba78d5ff6330abc.js +1 -0
  663. package/.next/static/chunks/app/api/processes/definitions/route-1ba78d5ff6330abc.js +1 -0
  664. package/.next/static/chunks/app/api/processes/definitions/validate/route-1ba78d5ff6330abc.js +1 -0
  665. package/.next/static/chunks/app/api/processes/route-1ba78d5ff6330abc.js +1 -0
  666. package/.next/static/chunks/app/api/processes/start-and-route/route-1ba78d5ff6330abc.js +1 -0
  667. package/.next/static/chunks/app/api/projects/[slug]/library/route-1ba78d5ff6330abc.js +1 -0
  668. package/.next/static/chunks/app/api/projects/[slug]/route-1ba78d5ff6330abc.js +1 -0
  669. package/.next/static/chunks/app/api/projects/route-1ba78d5ff6330abc.js +1 -0
  670. package/.next/static/chunks/app/api/runs/approve-claude-run/route-1ba78d5ff6330abc.js +1 -0
  671. package/.next/static/chunks/app/api/runs/claude-code-dry-run/route-1ba78d5ff6330abc.js +1 -0
  672. package/.next/static/chunks/app/api/runs/competitor-report/route-1ba78d5ff6330abc.js +1 -0
  673. package/.next/static/chunks/app/api/runs/engine-ping/route-1ba78d5ff6330abc.js +1 -0
  674. package/.next/static/chunks/app/api/runs/marketing-plan/route-1ba78d5ff6330abc.js +1 -0
  675. package/.next/static/chunks/app/api/schedules/upsert/route-1ba78d5ff6330abc.js +1 -0
  676. package/.next/static/chunks/app/api/secrets/[name]/route-1ba78d5ff6330abc.js +1 -0
  677. package/.next/static/chunks/app/api/secrets/route-1ba78d5ff6330abc.js +1 -0
  678. package/.next/static/chunks/app/api/settings/trust-mode/route-1ba78d5ff6330abc.js +1 -0
  679. package/.next/static/chunks/app/api/share/[token]/otp/route-1ba78d5ff6330abc.js +1 -0
  680. package/.next/static/chunks/app/api/share/[token]/route-1ba78d5ff6330abc.js +1 -0
  681. package/.next/static/chunks/app/api/share/[token]/verify/route-1ba78d5ff6330abc.js +1 -0
  682. package/.next/static/chunks/app/api/share/space/[token]/otp/route-1ba78d5ff6330abc.js +1 -0
  683. package/.next/static/chunks/app/api/share/space/[token]/route-1ba78d5ff6330abc.js +1 -0
  684. package/.next/static/chunks/app/api/share/space/[token]/verify/route-1ba78d5ff6330abc.js +1 -0
  685. package/.next/static/chunks/app/api/shared/spaces/[id]/acl/route-1ba78d5ff6330abc.js +1 -0
  686. package/.next/static/chunks/app/api/shared/spaces/publish/route-1ba78d5ff6330abc.js +1 -0
  687. package/.next/static/chunks/app/api/shared/spaces/route-1ba78d5ff6330abc.js +1 -0
  688. package/.next/static/chunks/app/api/shared/spaces/status/route-1ba78d5ff6330abc.js +1 -0
  689. package/.next/static/chunks/app/api/shared/spaces/unpublish/route-1ba78d5ff6330abc.js +1 -0
  690. package/.next/static/chunks/app/api/state/route-1ba78d5ff6330abc.js +1 -0
  691. package/.next/static/chunks/app/api/system/update/route-1ba78d5ff6330abc.js +1 -0
  692. package/.next/static/chunks/app/api/tasks/[id]/active-run/route-1ba78d5ff6330abc.js +1 -0
  693. package/.next/static/chunks/app/api/tasks/[id]/attachments/route-1ba78d5ff6330abc.js +1 -0
  694. package/.next/static/chunks/app/api/tasks/[id]/checklist/[itemId]/route-1ba78d5ff6330abc.js +1 -0
  695. package/.next/static/chunks/app/api/tasks/[id]/checklist/route-1ba78d5ff6330abc.js +1 -0
  696. package/.next/static/chunks/app/api/tasks/[id]/checkout/route-1ba78d5ff6330abc.js +1 -0
  697. package/.next/static/chunks/app/api/tasks/[id]/children/route-1ba78d5ff6330abc.js +1 -0
  698. package/.next/static/chunks/app/api/tasks/[id]/comments/route-1ba78d5ff6330abc.js +1 -0
  699. package/.next/static/chunks/app/api/tasks/[id]/events/route-1ba78d5ff6330abc.js +1 -0
  700. package/.next/static/chunks/app/api/tasks/[id]/live-runs/route-1ba78d5ff6330abc.js +1 -0
  701. package/.next/static/chunks/app/api/tasks/[id]/release/route-1ba78d5ff6330abc.js +1 -0
  702. package/.next/static/chunks/app/api/tasks/[id]/route-1ba78d5ff6330abc.js +1 -0
  703. package/.next/static/chunks/app/api/tasks/route-1ba78d5ff6330abc.js +1 -0
  704. package/.next/static/chunks/app/api/tool-allowlists/[id]/route-1ba78d5ff6330abc.js +1 -0
  705. package/.next/static/chunks/app/api/tool-allowlists/route-1ba78d5ff6330abc.js +1 -0
  706. package/.next/static/chunks/app/api/tool-egress/route-1ba78d5ff6330abc.js +1 -0
  707. package/.next/static/chunks/app/api/tools/[name]/approve/route-1ba78d5ff6330abc.js +1 -0
  708. package/.next/static/chunks/app/api/tools/[name]/route-1ba78d5ff6330abc.js +1 -0
  709. package/.next/static/chunks/app/api/tools/route-1ba78d5ff6330abc.js +1 -0
  710. package/.next/static/chunks/app/api/transcripts/route-1ba78d5ff6330abc.js +1 -0
  711. package/.next/static/chunks/app/api/voice/providers/route-1ba78d5ff6330abc.js +1 -0
  712. package/.next/static/chunks/app/api/voice/realtime/context/route-1ba78d5ff6330abc.js +1 -0
  713. package/.next/static/chunks/app/api/voice/realtime/session/route-1ba78d5ff6330abc.js +1 -0
  714. package/.next/static/chunks/app/api/voice/realtime/tool-result/route-1ba78d5ff6330abc.js +1 -0
  715. package/.next/static/chunks/app/api/voice/realtime/tools/route-1ba78d5ff6330abc.js +1 -0
  716. package/.next/static/chunks/app/api/voice/tts/route-1ba78d5ff6330abc.js +1 -0
  717. package/.next/static/chunks/app/api/whatsapp/allowlist/route-1ba78d5ff6330abc.js +1 -0
  718. package/.next/static/chunks/app/api/whatsapp/disconnect/route-1ba78d5ff6330abc.js +1 -0
  719. package/.next/static/chunks/app/api/whatsapp/messages/route-1ba78d5ff6330abc.js +1 -0
  720. package/.next/static/chunks/app/api/whatsapp/qr/route-1ba78d5ff6330abc.js +1 -0
  721. package/.next/static/chunks/app/api/whatsapp/send/route-1ba78d5ff6330abc.js +1 -0
  722. package/.next/static/chunks/app/api/whatsapp/status/route-1ba78d5ff6330abc.js +1 -0
  723. package/.next/static/chunks/app/approvals/loading-1ba78d5ff6330abc.js +1 -0
  724. package/.next/static/chunks/app/architecture/loading-1ba78d5ff6330abc.js +1 -0
  725. package/.next/static/chunks/app/audit/loading-1ba78d5ff6330abc.js +1 -0
  726. package/.next/static/chunks/app/brand/loading-1ba78d5ff6330abc.js +1 -0
  727. package/.next/static/chunks/app/disk/loading-1ba78d5ff6330abc.js +1 -0
  728. package/.next/static/chunks/app/federated-ai/loading-1ba78d5ff6330abc.js +1 -0
  729. package/.next/static/chunks/app/help/loading-1ba78d5ff6330abc.js +1 -0
  730. package/.next/static/chunks/app/layout-7c734abe785c0d86.js +1 -0
  731. package/.next/static/chunks/app/loading-1ba78d5ff6330abc.js +1 -0
  732. package/.next/static/chunks/app/marketplace/loading-1ba78d5ff6330abc.js +1 -0
  733. package/.next/static/chunks/app/missions/loading-1ba78d5ff6330abc.js +1 -0
  734. package/.next/static/chunks/app/onboarding/loading-1ba78d5ff6330abc.js +1 -0
  735. package/.next/static/chunks/app/org/loading-1ba78d5ff6330abc.js +1 -0
  736. package/.next/static/chunks/app/page-9d742c9099ab9cd7.js +1 -0
  737. package/.next/static/chunks/app/projects/[slug]/loading-1ba78d5ff6330abc.js +1 -0
  738. package/.next/static/chunks/app/projects/[slug]/page-abbc7f06e58ff9ee.js +1 -0
  739. package/.next/static/chunks/app/projects/loading-1ba78d5ff6330abc.js +1 -0
  740. package/.next/static/chunks/app/projects/page-87457ee2932c33a3.js +1 -0
  741. package/.next/static/chunks/app/reports/[file]/route-1ba78d5ff6330abc.js +1 -0
  742. package/.next/static/chunks/app/reports/loading-1ba78d5ff6330abc.js +1 -0
  743. package/.next/static/chunks/app/runtime/loading-1ba78d5ff6330abc.js +1 -0
  744. package/.next/static/chunks/app/schedules/loading-1ba78d5ff6330abc.js +1 -0
  745. package/.next/static/chunks/app/settings/loading-1ba78d5ff6330abc.js +1 -0
  746. package/.next/static/chunks/app/settings/page-1ba78d5ff6330abc.js +1 -0
  747. package/.next/static/chunks/app/tasks/[id]/loading-1ba78d5ff6330abc.js +1 -0
  748. package/.next/static/chunks/app/tasks/loading-1ba78d5ff6330abc.js +1 -0
  749. package/.next/static/chunks/app/tools/loading-1ba78d5ff6330abc.js +1 -0
  750. package/.next/static/chunks/app/tools/page-1ba78d5ff6330abc.js +1 -0
  751. package/.next/static/chunks/app/whatsapp/loading-1ba78d5ff6330abc.js +1 -0
  752. package/.next/static/chunks/app/workflows/share/[caseId]/page-1ba78d5ff6330abc.js +1 -0
  753. package/CHANGELOG.md +12 -0
  754. package/app/agents/agent-events-bus.js +4 -0
  755. package/app/api/agents/active-runs/route.js +59 -0
  756. package/app/api/orchestrator/stream/route.js +67 -6
  757. package/app/components/app-topbar.jsx +34 -88
  758. package/app/components/dashboard/bg-agent-reducer.js +125 -0
  759. package/app/components/dashboard/use-bg-agents.js +34 -0
  760. package/app/projects/[slug]/page.js +2 -0
  761. package/app/projects/[slug]/project-scope-sync.jsx +26 -0
  762. package/lib/active-runs.js +5 -0
  763. package/lib/agent-config.js +3 -1
  764. package/lib/agent-engines.js +1 -1
  765. package/lib/agent-routing.js +54 -1
  766. package/lib/cli-action-flow.js +88 -0
  767. package/lib/delegation.js +94 -1
  768. package/lib/heartbeat-worker.js +13 -0
  769. package/lib/orchestrator-tools.js +149 -2
  770. package/lib/role-capability-map.js +22 -0
  771. package/lib/seeds.js +33 -0
  772. package/lib/tools/adapters/disk.js +107 -0
  773. package/package.json +1 -1
  774. package/.next/standalone/.next/server/chunks/8352.js +0 -1
  775. package/.next/standalone/.next/static/chunks/app/activity/loading-fc50c67f9bcca1d8.js +0 -1
  776. package/.next/standalone/.next/static/chunks/app/agents/[id]/loading-fc50c67f9bcca1d8.js +0 -1
  777. package/.next/standalone/.next/static/chunks/app/agents/[id]/page-721c43e75cb2dd59.js +0 -1
  778. package/.next/standalone/.next/static/chunks/app/agents/loading-fc50c67f9bcca1d8.js +0 -1
  779. package/.next/standalone/.next/static/chunks/app/agents/page-b1bcb39a46a254aa.js +0 -1
  780. package/.next/standalone/.next/static/chunks/app/api/activity/route-fc50c67f9bcca1d8.js +0 -1
  781. package/.next/standalone/.next/static/chunks/app/api/admin/audit-export/route-fc50c67f9bcca1d8.js +0 -1
  782. package/.next/standalone/.next/static/chunks/app/api/admin/share-links/route-fc50c67f9bcca1d8.js +0 -1
  783. package/.next/standalone/.next/static/chunks/app/api/agent-memory/route-fc50c67f9bcca1d8.js +0 -1
  784. package/.next/standalone/.next/static/chunks/app/api/agent-runs/[id]/cancel/route-fc50c67f9bcca1d8.js +0 -1
  785. package/.next/standalone/.next/static/chunks/app/api/agent-runs/[id]/events/route-fc50c67f9bcca1d8.js +0 -1
  786. package/.next/standalone/.next/static/chunks/app/api/agent-runs/[id]/log/route-fc50c67f9bcca1d8.js +0 -1
  787. package/.next/standalone/.next/static/chunks/app/api/agent-runs/[id]/route-fc50c67f9bcca1d8.js +0 -1
  788. package/.next/standalone/.next/static/chunks/app/api/agent-runs/route-fc50c67f9bcca1d8.js +0 -1
  789. package/.next/standalone/.next/static/chunks/app/api/agents/[id]/active-run/route-fc50c67f9bcca1d8.js +0 -1
  790. package/.next/standalone/.next/static/chunks/app/api/agents/[id]/chain/route-fc50c67f9bcca1d8.js +0 -1
  791. package/.next/standalone/.next/static/chunks/app/api/agents/[id]/memory/route-fc50c67f9bcca1d8.js +0 -1
  792. package/.next/standalone/.next/static/chunks/app/api/agents/[id]/reports/route-fc50c67f9bcca1d8.js +0 -1
  793. package/.next/standalone/.next/static/chunks/app/api/agents/[id]/run/route-fc50c67f9bcca1d8.js +0 -1
  794. package/.next/standalone/.next/static/chunks/app/api/agents/[id]/skills/route-fc50c67f9bcca1d8.js +0 -1
  795. package/.next/standalone/.next/static/chunks/app/api/agents/create/route-fc50c67f9bcca1d8.js +0 -1
  796. package/.next/standalone/.next/static/chunks/app/api/agents/ops/route-fc50c67f9bcca1d8.js +0 -1
  797. package/.next/standalone/.next/static/chunks/app/api/agents/resume-approval/route-fc50c67f9bcca1d8.js +0 -1
  798. package/.next/standalone/.next/static/chunks/app/api/approvals/[id]/route-fc50c67f9bcca1d8.js +0 -1
  799. package/.next/standalone/.next/static/chunks/app/api/approvals/route-fc50c67f9bcca1d8.js +0 -1
  800. package/.next/standalone/.next/static/chunks/app/api/artifacts/[id]/acl/route-fc50c67f9bcca1d8.js +0 -1
  801. package/.next/standalone/.next/static/chunks/app/api/artifacts/[id]/protect/route-fc50c67f9bcca1d8.js +0 -1
  802. package/.next/standalone/.next/static/chunks/app/api/artifacts/[id]/raw/route-fc50c67f9bcca1d8.js +0 -1
  803. package/.next/standalone/.next/static/chunks/app/api/artifacts/[id]/route-fc50c67f9bcca1d8.js +0 -1
  804. package/.next/standalone/.next/static/chunks/app/api/artifacts/[id]/share-link/[linkId]/route-fc50c67f9bcca1d8.js +0 -1
  805. package/.next/standalone/.next/static/chunks/app/api/artifacts/[id]/share-link/route-fc50c67f9bcca1d8.js +0 -1
  806. package/.next/standalone/.next/static/chunks/app/api/artifacts/upload/route-fc50c67f9bcca1d8.js +0 -1
  807. package/.next/standalone/.next/static/chunks/app/api/audit/list/route-fc50c67f9bcca1d8.js +0 -1
  808. package/.next/standalone/.next/static/chunks/app/api/audit/search/route-fc50c67f9bcca1d8.js +0 -1
  809. package/.next/standalone/.next/static/chunks/app/api/auth/callback/route-fc50c67f9bcca1d8.js +0 -1
  810. package/.next/standalone/.next/static/chunks/app/api/auth/config/route-fc50c67f9bcca1d8.js +0 -1
  811. package/.next/standalone/.next/static/chunks/app/api/auth/join-bootstrap/route-fc50c67f9bcca1d8.js +0 -1
  812. package/.next/standalone/.next/static/chunks/app/api/auth/session/route-fc50c67f9bcca1d8.js +0 -1
  813. package/.next/standalone/.next/static/chunks/app/api/brand/route-fc50c67f9bcca1d8.js +0 -1
  814. package/.next/standalone/.next/static/chunks/app/api/brand/share/route-fc50c67f9bcca1d8.js +0 -1
  815. package/.next/standalone/.next/static/chunks/app/api/chat/sessions/[id]/route-fc50c67f9bcca1d8.js +0 -1
  816. package/.next/standalone/.next/static/chunks/app/api/chat/sessions/route-fc50c67f9bcca1d8.js +0 -1
  817. package/.next/standalone/.next/static/chunks/app/api/cloud/schema/route-fc50c67f9bcca1d8.js +0 -1
  818. package/.next/standalone/.next/static/chunks/app/api/config/env/route-fc50c67f9bcca1d8.js +0 -1
  819. package/.next/standalone/.next/static/chunks/app/api/config/route-fc50c67f9bcca1d8.js +0 -1
  820. package/.next/standalone/.next/static/chunks/app/api/connections/[service]/route-fc50c67f9bcca1d8.js +0 -1
  821. package/.next/standalone/.next/static/chunks/app/api/connections/[service]/verify/route-fc50c67f9bcca1d8.js +0 -1
  822. package/.next/standalone/.next/static/chunks/app/api/connections/route-fc50c67f9bcca1d8.js +0 -1
  823. package/.next/standalone/.next/static/chunks/app/api/cron/tick/route-fc50c67f9bcca1d8.js +0 -1
  824. package/.next/standalone/.next/static/chunks/app/api/dashboard/spaces/[id]/move/route-fc50c67f9bcca1d8.js +0 -1
  825. package/.next/standalone/.next/static/chunks/app/api/dashboard/spaces/[id]/route-fc50c67f9bcca1d8.js +0 -1
  826. package/.next/standalone/.next/static/chunks/app/api/dashboard/spaces/[id]/share-link/[linkId]/route-fc50c67f9bcca1d8.js +0 -1
  827. package/.next/standalone/.next/static/chunks/app/api/dashboard/spaces/[id]/share-link/route-fc50c67f9bcca1d8.js +0 -1
  828. package/.next/standalone/.next/static/chunks/app/api/dashboard/spaces/import/route-fc50c67f9bcca1d8.js +0 -1
  829. package/.next/standalone/.next/static/chunks/app/api/dashboard/spaces/route-fc50c67f9bcca1d8.js +0 -1
  830. package/.next/standalone/.next/static/chunks/app/api/disk/files/[id]/blob/route-fc50c67f9bcca1d8.js +0 -1
  831. package/.next/standalone/.next/static/chunks/app/api/disk/files/[id]/route-fc50c67f9bcca1d8.js +0 -1
  832. package/.next/standalone/.next/static/chunks/app/api/disk/files/[id]/transcribe/route-fc50c67f9bcca1d8.js +0 -1
  833. package/.next/standalone/.next/static/chunks/app/api/disk/files/route-fc50c67f9bcca1d8.js +0 -1
  834. package/.next/standalone/.next/static/chunks/app/api/disk/folders/route-fc50c67f9bcca1d8.js +0 -1
  835. package/.next/standalone/.next/static/chunks/app/api/events/since/[cursor]/route-fc50c67f9bcca1d8.js +0 -1
  836. package/.next/standalone/.next/static/chunks/app/api/events/stream/route-fc50c67f9bcca1d8.js +0 -1
  837. package/.next/standalone/.next/static/chunks/app/api/fs/create-folder/route-fc50c67f9bcca1d8.js +0 -1
  838. package/.next/standalone/.next/static/chunks/app/api/fs/pick-folder/route-fc50c67f9bcca1d8.js +0 -1
  839. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/blueprint/route-fc50c67f9bcca1d8.js +0 -1
  840. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/diagnostic/route-fc50c67f9bcca1d8.js +0 -1
  841. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/governance/route-fc50c67f9bcca1d8.js +0 -1
  842. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/interview/route-fc50c67f9bcca1d8.js +0 -1
  843. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/pilot/route-fc50c67f9bcca1d8.js +0 -1
  844. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/quarterly/route-fc50c67f9bcca1d8.js +0 -1
  845. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/route-fc50c67f9bcca1d8.js +0 -1
  846. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/[id]/setup-package/route-fc50c67f9bcca1d8.js +0 -1
  847. package/.next/standalone/.next/static/chunks/app/api/hail/engagements/route-fc50c67f9bcca1d8.js +0 -1
  848. package/.next/standalone/.next/static/chunks/app/api/hail/interviews/[id]/responses/route-fc50c67f9bcca1d8.js +0 -1
  849. package/.next/standalone/.next/static/chunks/app/api/hail/interviews/[id]/route-fc50c67f9bcca1d8.js +0 -1
  850. package/.next/standalone/.next/static/chunks/app/api/hail/setup-packages/[id]/apply/route-fc50c67f9bcca1d8.js +0 -1
  851. package/.next/standalone/.next/static/chunks/app/api/hail/setup-packages/validate/route-fc50c67f9bcca1d8.js +0 -1
  852. package/.next/standalone/.next/static/chunks/app/api/heartbeat/tick/route-fc50c67f9bcca1d8.js +0 -1
  853. package/.next/standalone/.next/static/chunks/app/api/heartbeat/worker/route-fc50c67f9bcca1d8.js +0 -1
  854. package/.next/standalone/.next/static/chunks/app/api/help/route-fc50c67f9bcca1d8.js +0 -1
  855. package/.next/standalone/.next/static/chunks/app/api/hermes/jobs/[id]/events/route-fc50c67f9bcca1d8.js +0 -1
  856. package/.next/standalone/.next/static/chunks/app/api/hermes/jobs/[id]/route-fc50c67f9bcca1d8.js +0 -1
  857. package/.next/standalone/.next/static/chunks/app/api/hermes/jobs/route-fc50c67f9bcca1d8.js +0 -1
  858. package/.next/standalone/.next/static/chunks/app/api/integrations/google/callback/route-fc50c67f9bcca1d8.js +0 -1
  859. package/.next/standalone/.next/static/chunks/app/api/integrations/google/oauth/route-fc50c67f9bcca1d8.js +0 -1
  860. package/.next/standalone/.next/static/chunks/app/api/marketplace/[id]/route-fc50c67f9bcca1d8.js +0 -1
  861. package/.next/standalone/.next/static/chunks/app/api/marketplace/open-design/route-fc50c67f9bcca1d8.js +0 -1
  862. package/.next/standalone/.next/static/chunks/app/api/marketplace/route-fc50c67f9bcca1d8.js +0 -1
  863. package/.next/standalone/.next/static/chunks/app/api/mines/import-roots/route-fc50c67f9bcca1d8.js +0 -1
  864. package/.next/standalone/.next/static/chunks/app/api/mines/portfolio/route-fc50c67f9bcca1d8.js +0 -1
  865. package/.next/standalone/.next/static/chunks/app/api/mines/projects/[id]/chunks/route-fc50c67f9bcca1d8.js +0 -1
  866. package/.next/standalone/.next/static/chunks/app/api/mines/projects/[id]/diligence/route-fc50c67f9bcca1d8.js +0 -1
  867. package/.next/standalone/.next/static/chunks/app/api/mines/projects/[id]/import/route-fc50c67f9bcca1d8.js +0 -1
  868. package/.next/standalone/.next/static/chunks/app/api/mines/projects/[id]/publish/route-fc50c67f9bcca1d8.js +0 -1
  869. package/.next/standalone/.next/static/chunks/app/api/mines/projects/route-fc50c67f9bcca1d8.js +0 -1
  870. package/.next/standalone/.next/static/chunks/app/api/missions/route-fc50c67f9bcca1d8.js +0 -1
  871. package/.next/standalone/.next/static/chunks/app/api/models/route-fc50c67f9bcca1d8.js +0 -1
  872. package/.next/standalone/.next/static/chunks/app/api/onboarding/blueprint/route-fc50c67f9bcca1d8.js +0 -1
  873. package/.next/standalone/.next/static/chunks/app/api/onboarding/launch/route-fc50c67f9bcca1d8.js +0 -1
  874. package/.next/standalone/.next/static/chunks/app/api/orchestrator/command/route-fc50c67f9bcca1d8.js +0 -1
  875. package/.next/standalone/.next/static/chunks/app/api/orchestrator/stream/attach/route-fc50c67f9bcca1d8.js +0 -1
  876. package/.next/standalone/.next/static/chunks/app/api/orchestrator/stream/route-fc50c67f9bcca1d8.js +0 -1
  877. package/.next/standalone/.next/static/chunks/app/api/orchestrator/upload/route-fc50c67f9bcca1d8.js +0 -1
  878. package/.next/standalone/.next/static/chunks/app/api/org/route-fc50c67f9bcca1d8.js +0 -1
  879. package/.next/standalone/.next/static/chunks/app/api/orgs/[id]/invites/[inviteId]/route-fc50c67f9bcca1d8.js +0 -1
  880. package/.next/standalone/.next/static/chunks/app/api/orgs/[id]/invites/route-fc50c67f9bcca1d8.js +0 -1
  881. package/.next/standalone/.next/static/chunks/app/api/orgs/[id]/members/[userId]/role/route-fc50c67f9bcca1d8.js +0 -1
  882. package/.next/standalone/.next/static/chunks/app/api/orgs/[id]/members/[userId]/route-fc50c67f9bcca1d8.js +0 -1
  883. package/.next/standalone/.next/static/chunks/app/api/orgs/[id]/members/route-fc50c67f9bcca1d8.js +0 -1
  884. package/.next/standalone/.next/static/chunks/app/api/orgs/[id]/route-fc50c67f9bcca1d8.js +0 -1
  885. package/.next/standalone/.next/static/chunks/app/api/orgs/invites/pending/route-fc50c67f9bcca1d8.js +0 -1
  886. package/.next/standalone/.next/static/chunks/app/api/orgs/join/route-fc50c67f9bcca1d8.js +0 -1
  887. package/.next/standalone/.next/static/chunks/app/api/orgs/join-complete/route-fc50c67f9bcca1d8.js +0 -1
  888. package/.next/standalone/.next/static/chunks/app/api/orgs/route-fc50c67f9bcca1d8.js +0 -1
  889. package/.next/standalone/.next/static/chunks/app/api/printing-press/clis/route-fc50c67f9bcca1d8.js +0 -1
  890. package/.next/standalone/.next/static/chunks/app/api/printing-press/install/route-fc50c67f9bcca1d8.js +0 -1
  891. package/.next/standalone/.next/static/chunks/app/api/printing-press/security-mode/route-fc50c67f9bcca1d8.js +0 -1
  892. package/.next/standalone/.next/static/chunks/app/api/privacy/config/route-fc50c67f9bcca1d8.js +0 -1
  893. package/.next/standalone/.next/static/chunks/app/api/privacy/verify/route-fc50c67f9bcca1d8.js +0 -1
  894. package/.next/standalone/.next/static/chunks/app/api/processes/[id]/route-fc50c67f9bcca1d8.js +0 -1
  895. package/.next/standalone/.next/static/chunks/app/api/processes/[id]/share-link/route-fc50c67f9bcca1d8.js +0 -1
  896. package/.next/standalone/.next/static/chunks/app/api/processes/[id]/stages/[stageId]/override/route-fc50c67f9bcca1d8.js +0 -1
  897. package/.next/standalone/.next/static/chunks/app/api/processes/[id]/stages/[stageId]/retry/route-fc50c67f9bcca1d8.js +0 -1
  898. package/.next/standalone/.next/static/chunks/app/api/processes/[id]/stages/[stageId]/submit/route-fc50c67f9bcca1d8.js +0 -1
  899. package/.next/standalone/.next/static/chunks/app/api/processes/definitions/[slug]/route-fc50c67f9bcca1d8.js +0 -1
  900. package/.next/standalone/.next/static/chunks/app/api/processes/definitions/[slug]/settings/route-fc50c67f9bcca1d8.js +0 -1
  901. package/.next/standalone/.next/static/chunks/app/api/processes/definitions/route-fc50c67f9bcca1d8.js +0 -1
  902. package/.next/standalone/.next/static/chunks/app/api/processes/definitions/validate/route-fc50c67f9bcca1d8.js +0 -1
  903. package/.next/standalone/.next/static/chunks/app/api/processes/route-fc50c67f9bcca1d8.js +0 -1
  904. package/.next/standalone/.next/static/chunks/app/api/processes/start-and-route/route-fc50c67f9bcca1d8.js +0 -1
  905. package/.next/standalone/.next/static/chunks/app/api/projects/[slug]/library/route-fc50c67f9bcca1d8.js +0 -1
  906. package/.next/standalone/.next/static/chunks/app/api/projects/[slug]/route-fc50c67f9bcca1d8.js +0 -1
  907. package/.next/standalone/.next/static/chunks/app/api/projects/route-fc50c67f9bcca1d8.js +0 -1
  908. package/.next/standalone/.next/static/chunks/app/api/runs/approve-claude-run/route-fc50c67f9bcca1d8.js +0 -1
  909. package/.next/standalone/.next/static/chunks/app/api/runs/claude-code-dry-run/route-fc50c67f9bcca1d8.js +0 -1
  910. package/.next/standalone/.next/static/chunks/app/api/runs/competitor-report/route-fc50c67f9bcca1d8.js +0 -1
  911. package/.next/standalone/.next/static/chunks/app/api/runs/engine-ping/route-fc50c67f9bcca1d8.js +0 -1
  912. package/.next/standalone/.next/static/chunks/app/api/runs/marketing-plan/route-fc50c67f9bcca1d8.js +0 -1
  913. package/.next/standalone/.next/static/chunks/app/api/schedules/upsert/route-fc50c67f9bcca1d8.js +0 -1
  914. package/.next/standalone/.next/static/chunks/app/api/secrets/[name]/route-fc50c67f9bcca1d8.js +0 -1
  915. package/.next/standalone/.next/static/chunks/app/api/secrets/route-fc50c67f9bcca1d8.js +0 -1
  916. package/.next/standalone/.next/static/chunks/app/api/settings/trust-mode/route-fc50c67f9bcca1d8.js +0 -1
  917. package/.next/standalone/.next/static/chunks/app/api/share/[token]/otp/route-fc50c67f9bcca1d8.js +0 -1
  918. package/.next/standalone/.next/static/chunks/app/api/share/[token]/route-fc50c67f9bcca1d8.js +0 -1
  919. package/.next/standalone/.next/static/chunks/app/api/share/[token]/verify/route-fc50c67f9bcca1d8.js +0 -1
  920. package/.next/standalone/.next/static/chunks/app/api/share/space/[token]/otp/route-fc50c67f9bcca1d8.js +0 -1
  921. package/.next/standalone/.next/static/chunks/app/api/share/space/[token]/route-fc50c67f9bcca1d8.js +0 -1
  922. package/.next/standalone/.next/static/chunks/app/api/share/space/[token]/verify/route-fc50c67f9bcca1d8.js +0 -1
  923. package/.next/standalone/.next/static/chunks/app/api/shared/spaces/[id]/acl/route-fc50c67f9bcca1d8.js +0 -1
  924. package/.next/standalone/.next/static/chunks/app/api/shared/spaces/publish/route-fc50c67f9bcca1d8.js +0 -1
  925. package/.next/standalone/.next/static/chunks/app/api/shared/spaces/route-fc50c67f9bcca1d8.js +0 -1
  926. package/.next/standalone/.next/static/chunks/app/api/shared/spaces/status/route-fc50c67f9bcca1d8.js +0 -1
  927. package/.next/standalone/.next/static/chunks/app/api/shared/spaces/unpublish/route-fc50c67f9bcca1d8.js +0 -1
  928. package/.next/standalone/.next/static/chunks/app/api/state/route-fc50c67f9bcca1d8.js +0 -1
  929. package/.next/standalone/.next/static/chunks/app/api/system/update/route-fc50c67f9bcca1d8.js +0 -1
  930. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/active-run/route-fc50c67f9bcca1d8.js +0 -1
  931. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/attachments/route-fc50c67f9bcca1d8.js +0 -1
  932. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/checklist/[itemId]/route-fc50c67f9bcca1d8.js +0 -1
  933. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/checklist/route-fc50c67f9bcca1d8.js +0 -1
  934. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/checkout/route-fc50c67f9bcca1d8.js +0 -1
  935. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/children/route-fc50c67f9bcca1d8.js +0 -1
  936. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/comments/route-fc50c67f9bcca1d8.js +0 -1
  937. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/events/route-fc50c67f9bcca1d8.js +0 -1
  938. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/live-runs/route-fc50c67f9bcca1d8.js +0 -1
  939. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/release/route-fc50c67f9bcca1d8.js +0 -1
  940. package/.next/standalone/.next/static/chunks/app/api/tasks/[id]/route-fc50c67f9bcca1d8.js +0 -1
  941. package/.next/standalone/.next/static/chunks/app/api/tasks/route-fc50c67f9bcca1d8.js +0 -1
  942. package/.next/standalone/.next/static/chunks/app/api/tool-allowlists/[id]/route-fc50c67f9bcca1d8.js +0 -1
  943. package/.next/standalone/.next/static/chunks/app/api/tool-allowlists/route-fc50c67f9bcca1d8.js +0 -1
  944. package/.next/standalone/.next/static/chunks/app/api/tool-egress/route-fc50c67f9bcca1d8.js +0 -1
  945. package/.next/standalone/.next/static/chunks/app/api/tools/[name]/approve/route-fc50c67f9bcca1d8.js +0 -1
  946. package/.next/standalone/.next/static/chunks/app/api/tools/[name]/route-fc50c67f9bcca1d8.js +0 -1
  947. package/.next/standalone/.next/static/chunks/app/api/tools/route-fc50c67f9bcca1d8.js +0 -1
  948. package/.next/standalone/.next/static/chunks/app/api/transcripts/route-fc50c67f9bcca1d8.js +0 -1
  949. package/.next/standalone/.next/static/chunks/app/api/voice/providers/route-fc50c67f9bcca1d8.js +0 -1
  950. package/.next/standalone/.next/static/chunks/app/api/voice/realtime/context/route-fc50c67f9bcca1d8.js +0 -1
  951. package/.next/standalone/.next/static/chunks/app/api/voice/realtime/session/route-fc50c67f9bcca1d8.js +0 -1
  952. package/.next/standalone/.next/static/chunks/app/api/voice/realtime/tool-result/route-fc50c67f9bcca1d8.js +0 -1
  953. package/.next/standalone/.next/static/chunks/app/api/voice/realtime/tools/route-fc50c67f9bcca1d8.js +0 -1
  954. package/.next/standalone/.next/static/chunks/app/api/voice/tts/route-fc50c67f9bcca1d8.js +0 -1
  955. package/.next/standalone/.next/static/chunks/app/api/whatsapp/allowlist/route-fc50c67f9bcca1d8.js +0 -1
  956. package/.next/standalone/.next/static/chunks/app/api/whatsapp/disconnect/route-fc50c67f9bcca1d8.js +0 -1
  957. package/.next/standalone/.next/static/chunks/app/api/whatsapp/messages/route-fc50c67f9bcca1d8.js +0 -1
  958. package/.next/standalone/.next/static/chunks/app/api/whatsapp/qr/route-fc50c67f9bcca1d8.js +0 -1
  959. package/.next/standalone/.next/static/chunks/app/api/whatsapp/send/route-fc50c67f9bcca1d8.js +0 -1
  960. package/.next/standalone/.next/static/chunks/app/api/whatsapp/status/route-fc50c67f9bcca1d8.js +0 -1
  961. package/.next/standalone/.next/static/chunks/app/approvals/loading-fc50c67f9bcca1d8.js +0 -1
  962. package/.next/standalone/.next/static/chunks/app/architecture/loading-fc50c67f9bcca1d8.js +0 -1
  963. package/.next/standalone/.next/static/chunks/app/audit/loading-fc50c67f9bcca1d8.js +0 -1
  964. package/.next/standalone/.next/static/chunks/app/brand/loading-fc50c67f9bcca1d8.js +0 -1
  965. package/.next/standalone/.next/static/chunks/app/disk/loading-fc50c67f9bcca1d8.js +0 -1
  966. package/.next/standalone/.next/static/chunks/app/federated-ai/loading-fc50c67f9bcca1d8.js +0 -1
  967. package/.next/standalone/.next/static/chunks/app/help/loading-fc50c67f9bcca1d8.js +0 -1
  968. package/.next/standalone/.next/static/chunks/app/layout-457acc50d33a5e0e.js +0 -1
  969. package/.next/standalone/.next/static/chunks/app/loading-fc50c67f9bcca1d8.js +0 -1
  970. package/.next/standalone/.next/static/chunks/app/marketplace/loading-fc50c67f9bcca1d8.js +0 -1
  971. package/.next/standalone/.next/static/chunks/app/missions/loading-fc50c67f9bcca1d8.js +0 -1
  972. package/.next/standalone/.next/static/chunks/app/onboarding/loading-fc50c67f9bcca1d8.js +0 -1
  973. package/.next/standalone/.next/static/chunks/app/org/loading-fc50c67f9bcca1d8.js +0 -1
  974. package/.next/standalone/.next/static/chunks/app/page-aa1d178b557f45b7.js +0 -1
  975. package/.next/standalone/.next/static/chunks/app/projects/[slug]/loading-fc50c67f9bcca1d8.js +0 -1
  976. package/.next/standalone/.next/static/chunks/app/projects/[slug]/page-0bc910eac788bf29.js +0 -1
  977. package/.next/standalone/.next/static/chunks/app/projects/loading-fc50c67f9bcca1d8.js +0 -1
  978. package/.next/standalone/.next/static/chunks/app/projects/page-61f935c0aaf292ef.js +0 -1
  979. package/.next/standalone/.next/static/chunks/app/reports/[file]/route-fc50c67f9bcca1d8.js +0 -1
  980. package/.next/standalone/.next/static/chunks/app/reports/loading-fc50c67f9bcca1d8.js +0 -1
  981. package/.next/standalone/.next/static/chunks/app/runtime/loading-fc50c67f9bcca1d8.js +0 -1
  982. package/.next/standalone/.next/static/chunks/app/schedules/loading-fc50c67f9bcca1d8.js +0 -1
  983. package/.next/standalone/.next/static/chunks/app/settings/loading-fc50c67f9bcca1d8.js +0 -1
  984. package/.next/standalone/.next/static/chunks/app/settings/page-fc50c67f9bcca1d8.js +0 -1
  985. package/.next/standalone/.next/static/chunks/app/tasks/[id]/loading-fc50c67f9bcca1d8.js +0 -1
  986. package/.next/standalone/.next/static/chunks/app/tasks/loading-fc50c67f9bcca1d8.js +0 -1
  987. package/.next/standalone/.next/static/chunks/app/tools/loading-fc50c67f9bcca1d8.js +0 -1
  988. package/.next/standalone/.next/static/chunks/app/tools/page-fc50c67f9bcca1d8.js +0 -1
  989. package/.next/standalone/.next/static/chunks/app/whatsapp/loading-fc50c67f9bcca1d8.js +0 -1
  990. package/.next/standalone/.next/static/chunks/app/workflows/share/[caseId]/page-fc50c67f9bcca1d8.js +0 -1
  991. package/.next/standalone/.next/static/mu47BRCkKEvvz6S5ipLGz/_buildManifest.js +0 -1
  992. package/.next/static/chunks/app/activity/loading-fc50c67f9bcca1d8.js +0 -1
  993. package/.next/static/chunks/app/agents/[id]/loading-fc50c67f9bcca1d8.js +0 -1
  994. package/.next/static/chunks/app/agents/[id]/page-721c43e75cb2dd59.js +0 -1
  995. package/.next/static/chunks/app/agents/loading-fc50c67f9bcca1d8.js +0 -1
  996. package/.next/static/chunks/app/agents/page-b1bcb39a46a254aa.js +0 -1
  997. package/.next/static/chunks/app/api/activity/route-fc50c67f9bcca1d8.js +0 -1
  998. package/.next/static/chunks/app/api/admin/audit-export/route-fc50c67f9bcca1d8.js +0 -1
  999. package/.next/static/chunks/app/api/admin/share-links/route-fc50c67f9bcca1d8.js +0 -1
  1000. package/.next/static/chunks/app/api/agent-memory/route-fc50c67f9bcca1d8.js +0 -1
  1001. package/.next/static/chunks/app/api/agent-runs/[id]/cancel/route-fc50c67f9bcca1d8.js +0 -1
  1002. package/.next/static/chunks/app/api/agent-runs/[id]/events/route-fc50c67f9bcca1d8.js +0 -1
  1003. package/.next/static/chunks/app/api/agent-runs/[id]/log/route-fc50c67f9bcca1d8.js +0 -1
  1004. package/.next/static/chunks/app/api/agent-runs/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1005. package/.next/static/chunks/app/api/agent-runs/route-fc50c67f9bcca1d8.js +0 -1
  1006. package/.next/static/chunks/app/api/agents/[id]/active-run/route-fc50c67f9bcca1d8.js +0 -1
  1007. package/.next/static/chunks/app/api/agents/[id]/chain/route-fc50c67f9bcca1d8.js +0 -1
  1008. package/.next/static/chunks/app/api/agents/[id]/memory/route-fc50c67f9bcca1d8.js +0 -1
  1009. package/.next/static/chunks/app/api/agents/[id]/reports/route-fc50c67f9bcca1d8.js +0 -1
  1010. package/.next/static/chunks/app/api/agents/[id]/run/route-fc50c67f9bcca1d8.js +0 -1
  1011. package/.next/static/chunks/app/api/agents/[id]/skills/route-fc50c67f9bcca1d8.js +0 -1
  1012. package/.next/static/chunks/app/api/agents/create/route-fc50c67f9bcca1d8.js +0 -1
  1013. package/.next/static/chunks/app/api/agents/ops/route-fc50c67f9bcca1d8.js +0 -1
  1014. package/.next/static/chunks/app/api/agents/resume-approval/route-fc50c67f9bcca1d8.js +0 -1
  1015. package/.next/static/chunks/app/api/approvals/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1016. package/.next/static/chunks/app/api/approvals/route-fc50c67f9bcca1d8.js +0 -1
  1017. package/.next/static/chunks/app/api/artifacts/[id]/acl/route-fc50c67f9bcca1d8.js +0 -1
  1018. package/.next/static/chunks/app/api/artifacts/[id]/protect/route-fc50c67f9bcca1d8.js +0 -1
  1019. package/.next/static/chunks/app/api/artifacts/[id]/raw/route-fc50c67f9bcca1d8.js +0 -1
  1020. package/.next/static/chunks/app/api/artifacts/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1021. package/.next/static/chunks/app/api/artifacts/[id]/share-link/[linkId]/route-fc50c67f9bcca1d8.js +0 -1
  1022. package/.next/static/chunks/app/api/artifacts/[id]/share-link/route-fc50c67f9bcca1d8.js +0 -1
  1023. package/.next/static/chunks/app/api/artifacts/upload/route-fc50c67f9bcca1d8.js +0 -1
  1024. package/.next/static/chunks/app/api/audit/list/route-fc50c67f9bcca1d8.js +0 -1
  1025. package/.next/static/chunks/app/api/audit/search/route-fc50c67f9bcca1d8.js +0 -1
  1026. package/.next/static/chunks/app/api/auth/callback/route-fc50c67f9bcca1d8.js +0 -1
  1027. package/.next/static/chunks/app/api/auth/config/route-fc50c67f9bcca1d8.js +0 -1
  1028. package/.next/static/chunks/app/api/auth/join-bootstrap/route-fc50c67f9bcca1d8.js +0 -1
  1029. package/.next/static/chunks/app/api/auth/session/route-fc50c67f9bcca1d8.js +0 -1
  1030. package/.next/static/chunks/app/api/brand/route-fc50c67f9bcca1d8.js +0 -1
  1031. package/.next/static/chunks/app/api/brand/share/route-fc50c67f9bcca1d8.js +0 -1
  1032. package/.next/static/chunks/app/api/chat/sessions/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1033. package/.next/static/chunks/app/api/chat/sessions/route-fc50c67f9bcca1d8.js +0 -1
  1034. package/.next/static/chunks/app/api/cloud/schema/route-fc50c67f9bcca1d8.js +0 -1
  1035. package/.next/static/chunks/app/api/config/env/route-fc50c67f9bcca1d8.js +0 -1
  1036. package/.next/static/chunks/app/api/config/route-fc50c67f9bcca1d8.js +0 -1
  1037. package/.next/static/chunks/app/api/connections/[service]/route-fc50c67f9bcca1d8.js +0 -1
  1038. package/.next/static/chunks/app/api/connections/[service]/verify/route-fc50c67f9bcca1d8.js +0 -1
  1039. package/.next/static/chunks/app/api/connections/route-fc50c67f9bcca1d8.js +0 -1
  1040. package/.next/static/chunks/app/api/cron/tick/route-fc50c67f9bcca1d8.js +0 -1
  1041. package/.next/static/chunks/app/api/dashboard/spaces/[id]/move/route-fc50c67f9bcca1d8.js +0 -1
  1042. package/.next/static/chunks/app/api/dashboard/spaces/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1043. package/.next/static/chunks/app/api/dashboard/spaces/[id]/share-link/[linkId]/route-fc50c67f9bcca1d8.js +0 -1
  1044. package/.next/static/chunks/app/api/dashboard/spaces/[id]/share-link/route-fc50c67f9bcca1d8.js +0 -1
  1045. package/.next/static/chunks/app/api/dashboard/spaces/import/route-fc50c67f9bcca1d8.js +0 -1
  1046. package/.next/static/chunks/app/api/dashboard/spaces/route-fc50c67f9bcca1d8.js +0 -1
  1047. package/.next/static/chunks/app/api/disk/files/[id]/blob/route-fc50c67f9bcca1d8.js +0 -1
  1048. package/.next/static/chunks/app/api/disk/files/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1049. package/.next/static/chunks/app/api/disk/files/[id]/transcribe/route-fc50c67f9bcca1d8.js +0 -1
  1050. package/.next/static/chunks/app/api/disk/files/route-fc50c67f9bcca1d8.js +0 -1
  1051. package/.next/static/chunks/app/api/disk/folders/route-fc50c67f9bcca1d8.js +0 -1
  1052. package/.next/static/chunks/app/api/events/since/[cursor]/route-fc50c67f9bcca1d8.js +0 -1
  1053. package/.next/static/chunks/app/api/events/stream/route-fc50c67f9bcca1d8.js +0 -1
  1054. package/.next/static/chunks/app/api/fs/create-folder/route-fc50c67f9bcca1d8.js +0 -1
  1055. package/.next/static/chunks/app/api/fs/pick-folder/route-fc50c67f9bcca1d8.js +0 -1
  1056. package/.next/static/chunks/app/api/hail/engagements/[id]/blueprint/route-fc50c67f9bcca1d8.js +0 -1
  1057. package/.next/static/chunks/app/api/hail/engagements/[id]/diagnostic/route-fc50c67f9bcca1d8.js +0 -1
  1058. package/.next/static/chunks/app/api/hail/engagements/[id]/governance/route-fc50c67f9bcca1d8.js +0 -1
  1059. package/.next/static/chunks/app/api/hail/engagements/[id]/interview/route-fc50c67f9bcca1d8.js +0 -1
  1060. package/.next/static/chunks/app/api/hail/engagements/[id]/pilot/route-fc50c67f9bcca1d8.js +0 -1
  1061. package/.next/static/chunks/app/api/hail/engagements/[id]/quarterly/route-fc50c67f9bcca1d8.js +0 -1
  1062. package/.next/static/chunks/app/api/hail/engagements/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1063. package/.next/static/chunks/app/api/hail/engagements/[id]/setup-package/route-fc50c67f9bcca1d8.js +0 -1
  1064. package/.next/static/chunks/app/api/hail/engagements/route-fc50c67f9bcca1d8.js +0 -1
  1065. package/.next/static/chunks/app/api/hail/interviews/[id]/responses/route-fc50c67f9bcca1d8.js +0 -1
  1066. package/.next/static/chunks/app/api/hail/interviews/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1067. package/.next/static/chunks/app/api/hail/setup-packages/[id]/apply/route-fc50c67f9bcca1d8.js +0 -1
  1068. package/.next/static/chunks/app/api/hail/setup-packages/validate/route-fc50c67f9bcca1d8.js +0 -1
  1069. package/.next/static/chunks/app/api/heartbeat/tick/route-fc50c67f9bcca1d8.js +0 -1
  1070. package/.next/static/chunks/app/api/heartbeat/worker/route-fc50c67f9bcca1d8.js +0 -1
  1071. package/.next/static/chunks/app/api/help/route-fc50c67f9bcca1d8.js +0 -1
  1072. package/.next/static/chunks/app/api/hermes/jobs/[id]/events/route-fc50c67f9bcca1d8.js +0 -1
  1073. package/.next/static/chunks/app/api/hermes/jobs/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1074. package/.next/static/chunks/app/api/hermes/jobs/route-fc50c67f9bcca1d8.js +0 -1
  1075. package/.next/static/chunks/app/api/integrations/google/callback/route-fc50c67f9bcca1d8.js +0 -1
  1076. package/.next/static/chunks/app/api/integrations/google/oauth/route-fc50c67f9bcca1d8.js +0 -1
  1077. package/.next/static/chunks/app/api/marketplace/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1078. package/.next/static/chunks/app/api/marketplace/open-design/route-fc50c67f9bcca1d8.js +0 -1
  1079. package/.next/static/chunks/app/api/marketplace/route-fc50c67f9bcca1d8.js +0 -1
  1080. package/.next/static/chunks/app/api/mines/import-roots/route-fc50c67f9bcca1d8.js +0 -1
  1081. package/.next/static/chunks/app/api/mines/portfolio/route-fc50c67f9bcca1d8.js +0 -1
  1082. package/.next/static/chunks/app/api/mines/projects/[id]/chunks/route-fc50c67f9bcca1d8.js +0 -1
  1083. package/.next/static/chunks/app/api/mines/projects/[id]/diligence/route-fc50c67f9bcca1d8.js +0 -1
  1084. package/.next/static/chunks/app/api/mines/projects/[id]/import/route-fc50c67f9bcca1d8.js +0 -1
  1085. package/.next/static/chunks/app/api/mines/projects/[id]/publish/route-fc50c67f9bcca1d8.js +0 -1
  1086. package/.next/static/chunks/app/api/mines/projects/route-fc50c67f9bcca1d8.js +0 -1
  1087. package/.next/static/chunks/app/api/missions/route-fc50c67f9bcca1d8.js +0 -1
  1088. package/.next/static/chunks/app/api/models/route-fc50c67f9bcca1d8.js +0 -1
  1089. package/.next/static/chunks/app/api/onboarding/blueprint/route-fc50c67f9bcca1d8.js +0 -1
  1090. package/.next/static/chunks/app/api/onboarding/launch/route-fc50c67f9bcca1d8.js +0 -1
  1091. package/.next/static/chunks/app/api/orchestrator/command/route-fc50c67f9bcca1d8.js +0 -1
  1092. package/.next/static/chunks/app/api/orchestrator/stream/attach/route-fc50c67f9bcca1d8.js +0 -1
  1093. package/.next/static/chunks/app/api/orchestrator/stream/route-fc50c67f9bcca1d8.js +0 -1
  1094. package/.next/static/chunks/app/api/orchestrator/upload/route-fc50c67f9bcca1d8.js +0 -1
  1095. package/.next/static/chunks/app/api/org/route-fc50c67f9bcca1d8.js +0 -1
  1096. package/.next/static/chunks/app/api/orgs/[id]/invites/[inviteId]/route-fc50c67f9bcca1d8.js +0 -1
  1097. package/.next/static/chunks/app/api/orgs/[id]/invites/route-fc50c67f9bcca1d8.js +0 -1
  1098. package/.next/static/chunks/app/api/orgs/[id]/members/[userId]/role/route-fc50c67f9bcca1d8.js +0 -1
  1099. package/.next/static/chunks/app/api/orgs/[id]/members/[userId]/route-fc50c67f9bcca1d8.js +0 -1
  1100. package/.next/static/chunks/app/api/orgs/[id]/members/route-fc50c67f9bcca1d8.js +0 -1
  1101. package/.next/static/chunks/app/api/orgs/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1102. package/.next/static/chunks/app/api/orgs/invites/pending/route-fc50c67f9bcca1d8.js +0 -1
  1103. package/.next/static/chunks/app/api/orgs/join/route-fc50c67f9bcca1d8.js +0 -1
  1104. package/.next/static/chunks/app/api/orgs/join-complete/route-fc50c67f9bcca1d8.js +0 -1
  1105. package/.next/static/chunks/app/api/orgs/route-fc50c67f9bcca1d8.js +0 -1
  1106. package/.next/static/chunks/app/api/printing-press/clis/route-fc50c67f9bcca1d8.js +0 -1
  1107. package/.next/static/chunks/app/api/printing-press/install/route-fc50c67f9bcca1d8.js +0 -1
  1108. package/.next/static/chunks/app/api/printing-press/security-mode/route-fc50c67f9bcca1d8.js +0 -1
  1109. package/.next/static/chunks/app/api/privacy/config/route-fc50c67f9bcca1d8.js +0 -1
  1110. package/.next/static/chunks/app/api/privacy/verify/route-fc50c67f9bcca1d8.js +0 -1
  1111. package/.next/static/chunks/app/api/processes/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1112. package/.next/static/chunks/app/api/processes/[id]/share-link/route-fc50c67f9bcca1d8.js +0 -1
  1113. package/.next/static/chunks/app/api/processes/[id]/stages/[stageId]/override/route-fc50c67f9bcca1d8.js +0 -1
  1114. package/.next/static/chunks/app/api/processes/[id]/stages/[stageId]/retry/route-fc50c67f9bcca1d8.js +0 -1
  1115. package/.next/static/chunks/app/api/processes/[id]/stages/[stageId]/submit/route-fc50c67f9bcca1d8.js +0 -1
  1116. package/.next/static/chunks/app/api/processes/definitions/[slug]/route-fc50c67f9bcca1d8.js +0 -1
  1117. package/.next/static/chunks/app/api/processes/definitions/[slug]/settings/route-fc50c67f9bcca1d8.js +0 -1
  1118. package/.next/static/chunks/app/api/processes/definitions/route-fc50c67f9bcca1d8.js +0 -1
  1119. package/.next/static/chunks/app/api/processes/definitions/validate/route-fc50c67f9bcca1d8.js +0 -1
  1120. package/.next/static/chunks/app/api/processes/route-fc50c67f9bcca1d8.js +0 -1
  1121. package/.next/static/chunks/app/api/processes/start-and-route/route-fc50c67f9bcca1d8.js +0 -1
  1122. package/.next/static/chunks/app/api/projects/[slug]/library/route-fc50c67f9bcca1d8.js +0 -1
  1123. package/.next/static/chunks/app/api/projects/[slug]/route-fc50c67f9bcca1d8.js +0 -1
  1124. package/.next/static/chunks/app/api/projects/route-fc50c67f9bcca1d8.js +0 -1
  1125. package/.next/static/chunks/app/api/runs/approve-claude-run/route-fc50c67f9bcca1d8.js +0 -1
  1126. package/.next/static/chunks/app/api/runs/claude-code-dry-run/route-fc50c67f9bcca1d8.js +0 -1
  1127. package/.next/static/chunks/app/api/runs/competitor-report/route-fc50c67f9bcca1d8.js +0 -1
  1128. package/.next/static/chunks/app/api/runs/engine-ping/route-fc50c67f9bcca1d8.js +0 -1
  1129. package/.next/static/chunks/app/api/runs/marketing-plan/route-fc50c67f9bcca1d8.js +0 -1
  1130. package/.next/static/chunks/app/api/schedules/upsert/route-fc50c67f9bcca1d8.js +0 -1
  1131. package/.next/static/chunks/app/api/secrets/[name]/route-fc50c67f9bcca1d8.js +0 -1
  1132. package/.next/static/chunks/app/api/secrets/route-fc50c67f9bcca1d8.js +0 -1
  1133. package/.next/static/chunks/app/api/settings/trust-mode/route-fc50c67f9bcca1d8.js +0 -1
  1134. package/.next/static/chunks/app/api/share/[token]/otp/route-fc50c67f9bcca1d8.js +0 -1
  1135. package/.next/static/chunks/app/api/share/[token]/route-fc50c67f9bcca1d8.js +0 -1
  1136. package/.next/static/chunks/app/api/share/[token]/verify/route-fc50c67f9bcca1d8.js +0 -1
  1137. package/.next/static/chunks/app/api/share/space/[token]/otp/route-fc50c67f9bcca1d8.js +0 -1
  1138. package/.next/static/chunks/app/api/share/space/[token]/route-fc50c67f9bcca1d8.js +0 -1
  1139. package/.next/static/chunks/app/api/share/space/[token]/verify/route-fc50c67f9bcca1d8.js +0 -1
  1140. package/.next/static/chunks/app/api/shared/spaces/[id]/acl/route-fc50c67f9bcca1d8.js +0 -1
  1141. package/.next/static/chunks/app/api/shared/spaces/publish/route-fc50c67f9bcca1d8.js +0 -1
  1142. package/.next/static/chunks/app/api/shared/spaces/route-fc50c67f9bcca1d8.js +0 -1
  1143. package/.next/static/chunks/app/api/shared/spaces/status/route-fc50c67f9bcca1d8.js +0 -1
  1144. package/.next/static/chunks/app/api/shared/spaces/unpublish/route-fc50c67f9bcca1d8.js +0 -1
  1145. package/.next/static/chunks/app/api/state/route-fc50c67f9bcca1d8.js +0 -1
  1146. package/.next/static/chunks/app/api/system/update/route-fc50c67f9bcca1d8.js +0 -1
  1147. package/.next/static/chunks/app/api/tasks/[id]/active-run/route-fc50c67f9bcca1d8.js +0 -1
  1148. package/.next/static/chunks/app/api/tasks/[id]/attachments/route-fc50c67f9bcca1d8.js +0 -1
  1149. package/.next/static/chunks/app/api/tasks/[id]/checklist/[itemId]/route-fc50c67f9bcca1d8.js +0 -1
  1150. package/.next/static/chunks/app/api/tasks/[id]/checklist/route-fc50c67f9bcca1d8.js +0 -1
  1151. package/.next/static/chunks/app/api/tasks/[id]/checkout/route-fc50c67f9bcca1d8.js +0 -1
  1152. package/.next/static/chunks/app/api/tasks/[id]/children/route-fc50c67f9bcca1d8.js +0 -1
  1153. package/.next/static/chunks/app/api/tasks/[id]/comments/route-fc50c67f9bcca1d8.js +0 -1
  1154. package/.next/static/chunks/app/api/tasks/[id]/events/route-fc50c67f9bcca1d8.js +0 -1
  1155. package/.next/static/chunks/app/api/tasks/[id]/live-runs/route-fc50c67f9bcca1d8.js +0 -1
  1156. package/.next/static/chunks/app/api/tasks/[id]/release/route-fc50c67f9bcca1d8.js +0 -1
  1157. package/.next/static/chunks/app/api/tasks/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1158. package/.next/static/chunks/app/api/tasks/route-fc50c67f9bcca1d8.js +0 -1
  1159. package/.next/static/chunks/app/api/tool-allowlists/[id]/route-fc50c67f9bcca1d8.js +0 -1
  1160. package/.next/static/chunks/app/api/tool-allowlists/route-fc50c67f9bcca1d8.js +0 -1
  1161. package/.next/static/chunks/app/api/tool-egress/route-fc50c67f9bcca1d8.js +0 -1
  1162. package/.next/static/chunks/app/api/tools/[name]/approve/route-fc50c67f9bcca1d8.js +0 -1
  1163. package/.next/static/chunks/app/api/tools/[name]/route-fc50c67f9bcca1d8.js +0 -1
  1164. package/.next/static/chunks/app/api/tools/route-fc50c67f9bcca1d8.js +0 -1
  1165. package/.next/static/chunks/app/api/transcripts/route-fc50c67f9bcca1d8.js +0 -1
  1166. package/.next/static/chunks/app/api/voice/providers/route-fc50c67f9bcca1d8.js +0 -1
  1167. package/.next/static/chunks/app/api/voice/realtime/context/route-fc50c67f9bcca1d8.js +0 -1
  1168. package/.next/static/chunks/app/api/voice/realtime/session/route-fc50c67f9bcca1d8.js +0 -1
  1169. package/.next/static/chunks/app/api/voice/realtime/tool-result/route-fc50c67f9bcca1d8.js +0 -1
  1170. package/.next/static/chunks/app/api/voice/realtime/tools/route-fc50c67f9bcca1d8.js +0 -1
  1171. package/.next/static/chunks/app/api/voice/tts/route-fc50c67f9bcca1d8.js +0 -1
  1172. package/.next/static/chunks/app/api/whatsapp/allowlist/route-fc50c67f9bcca1d8.js +0 -1
  1173. package/.next/static/chunks/app/api/whatsapp/disconnect/route-fc50c67f9bcca1d8.js +0 -1
  1174. package/.next/static/chunks/app/api/whatsapp/messages/route-fc50c67f9bcca1d8.js +0 -1
  1175. package/.next/static/chunks/app/api/whatsapp/qr/route-fc50c67f9bcca1d8.js +0 -1
  1176. package/.next/static/chunks/app/api/whatsapp/send/route-fc50c67f9bcca1d8.js +0 -1
  1177. package/.next/static/chunks/app/api/whatsapp/status/route-fc50c67f9bcca1d8.js +0 -1
  1178. package/.next/static/chunks/app/approvals/loading-fc50c67f9bcca1d8.js +0 -1
  1179. package/.next/static/chunks/app/architecture/loading-fc50c67f9bcca1d8.js +0 -1
  1180. package/.next/static/chunks/app/audit/loading-fc50c67f9bcca1d8.js +0 -1
  1181. package/.next/static/chunks/app/brand/loading-fc50c67f9bcca1d8.js +0 -1
  1182. package/.next/static/chunks/app/disk/loading-fc50c67f9bcca1d8.js +0 -1
  1183. package/.next/static/chunks/app/federated-ai/loading-fc50c67f9bcca1d8.js +0 -1
  1184. package/.next/static/chunks/app/help/loading-fc50c67f9bcca1d8.js +0 -1
  1185. package/.next/static/chunks/app/layout-457acc50d33a5e0e.js +0 -1
  1186. package/.next/static/chunks/app/loading-fc50c67f9bcca1d8.js +0 -1
  1187. package/.next/static/chunks/app/marketplace/loading-fc50c67f9bcca1d8.js +0 -1
  1188. package/.next/static/chunks/app/missions/loading-fc50c67f9bcca1d8.js +0 -1
  1189. package/.next/static/chunks/app/onboarding/loading-fc50c67f9bcca1d8.js +0 -1
  1190. package/.next/static/chunks/app/org/loading-fc50c67f9bcca1d8.js +0 -1
  1191. package/.next/static/chunks/app/page-aa1d178b557f45b7.js +0 -1
  1192. package/.next/static/chunks/app/projects/[slug]/loading-fc50c67f9bcca1d8.js +0 -1
  1193. package/.next/static/chunks/app/projects/[slug]/page-0bc910eac788bf29.js +0 -1
  1194. package/.next/static/chunks/app/projects/loading-fc50c67f9bcca1d8.js +0 -1
  1195. package/.next/static/chunks/app/projects/page-61f935c0aaf292ef.js +0 -1
  1196. package/.next/static/chunks/app/reports/[file]/route-fc50c67f9bcca1d8.js +0 -1
  1197. package/.next/static/chunks/app/reports/loading-fc50c67f9bcca1d8.js +0 -1
  1198. package/.next/static/chunks/app/runtime/loading-fc50c67f9bcca1d8.js +0 -1
  1199. package/.next/static/chunks/app/schedules/loading-fc50c67f9bcca1d8.js +0 -1
  1200. package/.next/static/chunks/app/settings/loading-fc50c67f9bcca1d8.js +0 -1
  1201. package/.next/static/chunks/app/settings/page-fc50c67f9bcca1d8.js +0 -1
  1202. package/.next/static/chunks/app/tasks/[id]/loading-fc50c67f9bcca1d8.js +0 -1
  1203. package/.next/static/chunks/app/tasks/loading-fc50c67f9bcca1d8.js +0 -1
  1204. package/.next/static/chunks/app/tools/loading-fc50c67f9bcca1d8.js +0 -1
  1205. package/.next/static/chunks/app/tools/page-fc50c67f9bcca1d8.js +0 -1
  1206. package/.next/static/chunks/app/whatsapp/loading-fc50c67f9bcca1d8.js +0 -1
  1207. package/.next/static/chunks/app/workflows/share/[caseId]/page-fc50c67f9bcca1d8.js +0 -1
  1208. package/.next/static/mu47BRCkKEvvz6S5ipLGz/_buildManifest.js +0 -1
  1209. /package/.next/standalone/.next/static/{mu47BRCkKEvvz6S5ipLGz → IDXwXTmFu4HQak2wJH1Qy}/_ssgManifest.js +0 -0
  1210. /package/.next/static/{mu47BRCkKEvvz6S5ipLGz → IDXwXTmFu4HQak2wJH1Qy}/_ssgManifest.js +0 -0
@@ -48,11 +48,13 @@ You DELEGATE specialist work; you do not perform it yourself. Specialist domain
48
48
 
49
49
  For ANY request longer than a one-line factual reply, set the goal in one sentence, then call route_goal(goal) FIRST. It returns the live registry — every active agent with its role/mission/skills/granted tools, the tool catalog, and whether Tool Smith can build what's missing. Reason over it and pick exactly one ladder step:
50
50
  1. delegate — a live specialist fits the goal: dispatch it with run_agent (pass instruction + expected_output so it knows what "done" means).
51
- 2. create_then_delegate — no fit specialist exists yet: create_agent for the role the goal needs, then run_agent it.
51
+ 2. create_then_delegate — no fit specialist exists yet: create_agent for the role the goal needs, then run_agent it. BEFORE creating, CHECK THE ROSTER (route_goal's recommended_specialists, or list_agents) — if an existing agent already owns the tool the goal needs, delegate to it; never spawn a duplicate. When you do create one, grant it the tools the goal needs or it cannot finish.
52
52
  3. build_capability — a specialist exists but lacks a required tool: call request_capability so Tool Smith builds and grants it, tell the principal it's being built, then delegate.
53
53
  4. direct_fallback — ONLY a trivial one-line factual ask, or no capability can be built: answer in chat (or, if you must act and a tool was re-granted for this one turn, do so — audited).
54
54
  This works for ANY goal, not a fixed list of domains — route_goal grounds the decision in real capabilities. fast_path_hint is a shortcut for obvious cases, never the whole answer. You always own: presentation choice, artifact verification, escalation to principal, and approval gating for irreversible actions.
55
55
 
56
+ TASK TRACKING (automatic): every run_agent delegation is filed as a tracked task on the /tasks board (assignee = the specialist), runs to completion, and its status is updated for you (in_progress → in_review → done, or blocked on failure). A background sweep re-drives any task that stalls. You do not need to create the task yourself — but you DO own making sure the goal is actually met: verify the returned artifact satisfies the expected_output before telling the principal it is done; if a task came back blocked or partial, re-dispatch or escalate. Use list_agents to see your workforce and their open task load before assigning more work.
57
+
56
58
  TOOL_USE_DISCIPLINE
57
59
  - Never end a turn with a promise of future action. If you say you will do X, call the tool for X in the same response.
58
60
  - Keep calling tools until: (a) task complete, (b) result verified, (c) artifact on canvas or a one-line chat answer is appropriate.
@@ -163,7 +165,7 @@ ${c}`)}catch{}return b}let x=[{id:"claude-sonnet-4-6",label:"Sonnet 4.6",engine:
163
165
  WHERE slug=?`).run(g.title,g.description,l,g.risk_level,m,j,g.slug):i.prepare(`INSERT INTO composite_tools
164
166
  (slug, title, description, spec_json, risk_level, input_schema_json, status,
165
167
  created_by_user_id, created_by_agent_id, created_at, updated_at)
166
- VALUES (?, ?, ?, ?, ?, ?, 'active', ?, ?, ?, ?)`).run(g.slug,g.title,g.description,l,g.risk_level,m,b.created_by_user_id||null,b.created_by_agent_id||null,j,j),{slug:g.slug,risk_level:g.risk_level,warnings:d.warnings}}function i(a){let b=(0,e.getDb)();return b.prepare("SELECT slug FROM composite_tools WHERE slug=?").get(a)?(b.prepare("UPDATE composite_tools SET status='archived', updated_at=? WHERE slug=?").run((0,e.nowIso)(),a),{ok:!0,slug:a}):{ok:!1,error:"not_found",slug:a}}function j(a){return(0,e.getDb)().prepare("SELECT * FROM composite_tools WHERE slug=? AND status='active'").get(a)||null}function k(a){let b=j(a);if(!b)return null;try{return JSON.parse(b.spec_json)}catch{return null}}function l(){let a;try{a=(0,e.getDb)().prepare("SELECT * FROM composite_tools WHERE status='active' ORDER BY slug ASC").all()}catch{return[]}return a.map(a=>{let b,{approval_required:c,approval_mode:d}=function(a){let b=f.pE.indexOf(a)>=f.pE.indexOf("medium");return{approval_required:b,approval_mode:b?"approval_required":"auto"}}(a.risk_level);try{b=JSON.parse(a.input_schema_json||"")||{type:"object",properties:{}}}catch{b={type:"object",properties:{}}}return{name:a.slug,title:a.title||a.slug,description:a.description||`Composite tool: ${a.slug}`,category:"composite",risk_level:a.risk_level,approval_required:c,approval_mode:d,required_env:[],enabled:!0,available:!0,missing_env:[],allowlist_required:!1,allowlist_scope_key:null,allowlist_default_allow:!1,input_schema:b,source:{kind:"composite",composite_slug:a.slug}}})}e=(g.then?(await g)():g)[0],d()}catch(a){d(a)}})},5295:(a,b,c)=>{"use strict";c.d(b,{W6:()=>i,Wp:()=>h,Wq:()=>f,xU:()=>g});let d=new Set(["travel","email","calendar","supabase","vercel","mines"]),e={travel:"travel_concierge",email:"personal_assistant",github:"engineering_lead",calendar:"ops_manager",supabase:"web_ecommerce",vercel:"web_ecommerce",browser:"web_ecommerce",voice:"content_social"},f=[[/\b(flight|flights|fly|airfare|airline|hotel|hotels|itinerary|trip|travel|book a (room|stay))\b/i,"travel"],[/\b(email|inbox|reply to .*(mail|message)|draft a (reply|mail|email)|gmail)\b/i,"email"],[/\b(pull request|\bpr\b|open an? issue|github|merge|commit|repo|repository)\b/i,"github"],[/\b(calendar|schedule a (meeting|call)|book (a )?(meeting|slot|30 ?min)|invite .* to)\b/i,"calendar"],[/\b(deploy|vercel|production build|ship the site)\b/i,"vercel"],[/\b(supabase|database row|insert into|update the table|sql)\b/i,"supabase"]],g=["travel-concierge"];function h(a){return!!(a&&d.has(a.category))}function i(a){return e[a]||null}},5735:(a,b,c)=>{"use strict";c.d(b,{zP:()=>l});let d=new Set(["intake_form","agent_run","policy_gate","human_approval","package"]),e=new Set(["text","email","number","textarea","select","shareholders"]),f=new Set(["low","medium","high","irreversible_external"]),g=/^[a-z][a-z0-9-]{2,63}$/;function h(a,b,c){a.push(`${b}: ${c}`)}function i(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}let j=new Set(["and","or"]),k=new Set(["eq","neq","lt","lte","gt","gte","in","nin"]);function l(a,b={}){var c;let m,n=[],o=[];try{m=JSON.stringify(a)}catch{return{ok:!1,errors:["spec: not JSON-serialisable"],warnings:[],normalized:null}}if(!m||"undefined"===m)return{ok:!1,errors:["spec: required"],warnings:[],normalized:null};if(Buffer.byteLength(m,"utf8")>65536)return{ok:!1,errors:[`spec: serialized length ${Buffer.byteLength(m,"utf8")} bytes exceeds 65536-byte cap`],warnings:[],normalized:null};if(!i(a))return{ok:!1,errors:["spec: must be an object"],warnings:[],normalized:null};a.slug&&"string"==typeof a.slug?g.test(a.slug)||h(n,"slug",`does not match ${g} (lowercase, starts with letter, 3-64 chars, [a-z0-9-])`):h(n,"slug","required (string)"),a.name&&"string"==typeof a.name||h(n,"name","required (string)");let p=a.schema_version??1;if(null==a.schema_version||Number.isInteger(a.schema_version)||h(n,"schema_version","must be an integer"),null!=a.version&&(!Number.isInteger(a.version)||a.version<1)&&h(n,"version","must be a positive integer"),!Array.isArray(a.stages)||0===a.stages.length)return h(n,"stages","required (non-empty array)"),{ok:!1,errors:n,warnings:o,normalized:null};let q=new Set;a.stages.forEach((a,b)=>{let c=`stages[${b}]`;if(!i(a))return void h(n,c,"must be an object");a.slug&&"string"==typeof a.slug?g.test(a.slug)?q.has(a.slug)?h(n,`${c}.slug`,`duplicate stage slug "${a.slug}"`):q.add(a.slug):h(n,`${c}.slug`,`does not match ${g}`):h(n,`${c}.slug`,"required (string)"),a.name&&"string"==typeof a.name||h(n,`${c}.name`,"required (string)"),a.kind&&d.has(a.kind)||h(n,`${c}.kind`,`unknown kind "${a.kind}" (allowed: ${[...d].join(", ")})`)});let r=a.stages[0];if(r&&r.kind&&"intake_form"!==r.kind&&h(n,"stages[0].kind",`first stage must be "intake_form" (got "${r.kind}")`),a.stages.forEach((a,c)=>{if(!a||!d.has(a.kind))return;let g=`stages[${c}]`;if(!i(a.config))return void h(n,`${g}.config`,"must be an object");switch(a.kind){case"intake_form":!function(a,b,c){let d=a?.config?.form_schema;if(!i(d))return h(b,`${c}.config.form_schema`,"required (must be object)");if(!Array.isArray(d.fields)||0===d.fields.length)return h(b,`${c}.config.form_schema.fields`,"must be a non-empty array");let f=new Set;d.fields.forEach((a,d)=>{let g=`${c}.config.form_schema.fields[${d}]`;if(!i(a))return void h(b,g,"must be an object");a.name&&"string"==typeof a.name||h(b,`${g}.name`,"required (string)"),a.label&&"string"==typeof a.label||h(b,`${g}.label`,"required (string)"),a.type&&e.has(a.type)||h(b,`${g}.type`,`unknown type "${a.type}" (allowed: ${[...e].join(", ")})`),"select"!==a.type||Array.isArray(a.options)&&0!==a.options.length||h(b,`${g}.options`,"select requires a non-empty options[] array"),a.name&&(f.has(a.name)&&h(b,`${g}.name`,`duplicate field name "${a.name}"`),f.add(a.name))})}(a,n,g);break;case"agent_run":let l=a.config||{};if(l.agent_template_slug&&"string"==typeof l.agent_template_slug?b.knownAgentTemplates&&!b.knownAgentTemplates.has(l.agent_template_slug)&&h(n,`${g}.config.agent_template_slug`,`unknown template "${l.agent_template_slug}"`):h(n,`${g}.config.agent_template_slug`,"required (string)"),l.prompt&&"string"==typeof l.prompt?l.prompt.length>8e3&&h(n,`${g}.config.prompt`,`exceeds 8000 chars (got ${l.prompt.length})`):h(n,`${g}.config.prompt`,"required (string)"),null!=l.timeout_ms&&(!Number.isInteger(l.timeout_ms)||l.timeout_ms<1e3||l.timeout_ms>6e5)&&h(n,`${g}.config.timeout_ms`,"must be integer 1000..600000"),null!=l.on_outcome)if(i(l.on_outcome))for(let[a,b]of Object.entries(l.on_outcome)){if("string"!=typeof b){h(n,`${g}.config.on_outcome.${a}`,'value must be a string (stage slug or "fail")');continue}"fail"!==b&&q&&!q.has(b)&&h(n,`${g}.config.on_outcome.${a}`,`references non-existent stage "${b}"`)}else h(n,`${g}.config.on_outcome`,"must be an object");break;case"policy_gate":!function(a,b,c){let d=a.config||{};if(!Array.isArray(d.rules)||0===d.rules.length)return h(b,`${c}.config.rules`,"required (non-empty array)");d.rules.forEach((a,d)=>{let e=`${c}.config.rules[${d}]`;"string"==typeof a?a.trim()||h(b,e,"empty rule expression"):i(a)&&"string"==typeof a.op?function a(b,c,d,e=0){if(e>20)return void h(c,d,"predicate nesting too deep");if(!i(b))return void h(c,d,"predicate must be an object");let f=b.op;j.has(f)?Array.isArray(b.rules)&&0!==b.rules.length?b.rules.forEach((b,f)=>a(b,c,`${d}.rules[${f}]`,e+1)):h(c,`${d}.rules`,`"${f}" requires a non-empty rules[] array`):"not"===f?i(b.rule)?a(b.rule,c,`${d}.rule`,e+1):h(c,`${d}.rule`,'"not" requires a rule object'):k.has(f)?("string"==typeof b.path&&b.path.trim()||h(c,`${d}.path`,"required (non-empty string)"),"value"in b?"in"!==f&&"nin"!==f||Array.isArray(b.value)||h(c,`${d}.value`,`"${f}" requires an array value`):h(c,`${d}.value`,"required")):h(c,`${d}.op`,`unknown predicate op "${f}"`)}(a,b,e):i(a)?a.expr&&"string"==typeof a.expr&&a.expr.trim()||h(b,`${e}.expr`,"required (non-empty string)"):h(b,e,"rule must be a JSON predicate, a string, or { expr, label }")})}(a,n,g);break;case"human_approval":let m=a.config||{};m.action_type&&"string"==typeof m.action_type?m.action_type.startsWith("process.stage.")||h(n,`${g}.config.action_type`,'must start with "process.stage."'):h(n,`${g}.config.action_type`,"required (string)"),m.risk&&f.has(m.risk)||h(n,`${g}.config.risk`,`must be one of ${[...f].join(", ")}`),null!=m.summary_template&&"string"!=typeof m.summary_template&&h(n,`${g}.config.summary_template`,"must be a string");break;case"package":let o=a.config||{};o.title_template&&"string"==typeof o.title_template||h(n,`${g}.config.title_template`,"required (string)"),null!=o.include_stages&&(Array.isArray(o.include_stages)?o.include_stages.forEach((a,b)=>{"string"!=typeof a?h(n,`${g}.config.include_stages[${b}]`,"must be a string"):q.has(a)||h(n,`${g}.config.include_stages[${b}]`,`unknown stage slug "${a}"`)}):h(n,`${g}.config.include_stages`,"must be an array of stage slugs"))}}),a.stages.forEach((a,b)=>{if(!i(a))return;let c=`stages[${b}]`;null==a.on_pass_stage_slug||"fail"===a.on_pass_stage_slug||q.has(a.on_pass_stage_slug)||h(n,`${c}.on_pass_stage_slug`,`references non-existent stage "${a.on_pass_stage_slug}"`),null==a.on_fail_stage_slug||"fail"===a.on_fail_stage_slug||q.has(a.on_fail_stage_slug)||h(n,`${c}.on_fail_stage_slug`,`references non-existent stage "${a.on_fail_stage_slug}"`)}),0===n.length&&function(a){let b=new Map(a.map(a=>[a.slug,a])),c=new Map(a.map(a=>[a.slug,0]));for(let d of a)if(0===c.get(d.slug)&&function a(d){if(!b.has(d))return!1;let e=c.get(d);if(1===e)return!0;if(2===e)return!1;c.set(d,1);let f=b.get(d).on_pass_stage_slug;return!!(f&&"fail"!==f&&a(f))||(c.set(d,2),!1)}(d.slug))return!0;return!1}(a.stages)&&h(n,"stages","routing graph contains a cycle"),0===n.length){let b=new Set;a.stages.forEach(a=>{a.on_pass_stage_slug&&"fail"!==a.on_pass_stage_slug&&b.add(a.on_pass_stage_slug),a.on_fail_stage_slug&&"fail"!==a.on_fail_stage_slug&&b.add(a.on_fail_stage_slug);let c=a?.config?.on_outcome;if(i(c))for(let a of Object.values(c))"string"==typeof a&&"fail"!==a&&b.add(a)}),a.stages.forEach((a,c)=>{0!==c&&(b.has(a.slug)||o.push(`stages[${c}] "${a.slug}": orphan stage (no inbound edges)`))})}return n.length>0?{ok:!1,errors:n,warnings:o,normalized:null}:{ok:!0,errors:[],warnings:o,normalized:{schema_version:p,slug:(c=a).slug,name:c.name,version:c.version||1,description:c.description||null,category:c.category||null,source:c.source||"api",status:c.status||"draft",stages:c.stages.map(a=>({slug:a.slug,name:a.name,kind:a.kind,config:structuredClone(a.config||{}),on_pass_stage_slug:a.on_pass_stage_slug||null,on_fail_stage_slug:a.on_fail_stage_slug||null,required:!1!==a.required}))}}}},7183:(a,b,c)=>{"use strict";c.d(b,{X:()=>e});let d=Object.create(null);for(let a of["00_historic","01_arcgis_data","02_assay_labs","03_cad_files","04_official_database","05_drill_campaign","06_exploration_geos","07_geophysics","08_backup_bd","09_petrography","10_presentations","11_general_pictures","12_safety","13_reports","14_inegi_data","15_sgm_data","16_claims_properties","17_minesight","18_exported_maps","19_survey","20_geotechnical","21_general_files","22_qa_qc","uncategorized"]){let b=a.match(/^(\d{2})_/);b&&(d[b[1]]=a)}function e(a){let b=String(a||"").split(/[/\\]/).filter(Boolean),c=null;for(let a of b){let b=a.match(/^(\d{2})[-_ ]/i);if(!b)continue;let e=b[1];Object.prototype.hasOwnProperty.call(d,e)&&(c=d[e])}return c??"uncategorized"}},7945:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{H6:()=>j,WV:()=>l});var e=c(73024),f=c(73136),g=c(76760),h=c(9013),i=a([h]);h=(i.then?(await i)():i)[0];let k=(0,g.dirname)((0,f.fileURLToPath)("file:///home/runner/work/madarx-os/madarx-os/lib/process/seeds/hail-engagement-lifecycle.js")),l="hail-engagement-lifecycle",m=null;function j(){let a=(m||(m=function(){let a=(0,g.join)(k,"specs","hail-engagement-lifecycle.json");return JSON.parse((0,e.readFileSync)(a,"utf8"))}()),m);return(0,h.R1)(a,{source_spec_json:JSON.stringify(a)})}d()}catch(a){d(a)}})},8437:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{D6:()=>l,ct:()=>n,jT:()=>m,r2:()=>o,t6:()=>p,v:()=>q,zU:()=>i});var e=c(34255),f=c(40563),g=c(9001),h=a([e,f,g]);[e,f,g]=h.then?(await h)():h;let r=new Set;function i(a){return"function"!=typeof a?()=>{}:(r.add(a),()=>{r.delete(a)})}function j(){try{(0,g.jO)("approvals")}catch{}}function k(a){return a?{...a,payload:function(a,b=null){try{return JSON.parse(a)}catch{return b}}(a.payload,{})}:null}function l({action_type:a,risk:b="medium",summary:c,payload:d={},requested_by:f="system",expires_at:g=null,project_id:h=null}){let i=(0,e.getDb)(),k=(0,e.newId)("approval"),l=(0,e.nowIso)(),n=h||d?.project_id||d?.projectId||null;return i.prepare(`
168
+ VALUES (?, ?, ?, ?, ?, ?, 'active', ?, ?, ?, ?)`).run(g.slug,g.title,g.description,l,g.risk_level,m,b.created_by_user_id||null,b.created_by_agent_id||null,j,j),{slug:g.slug,risk_level:g.risk_level,warnings:d.warnings}}function i(a){let b=(0,e.getDb)();return b.prepare("SELECT slug FROM composite_tools WHERE slug=?").get(a)?(b.prepare("UPDATE composite_tools SET status='archived', updated_at=? WHERE slug=?").run((0,e.nowIso)(),a),{ok:!0,slug:a}):{ok:!1,error:"not_found",slug:a}}function j(a){return(0,e.getDb)().prepare("SELECT * FROM composite_tools WHERE slug=? AND status='active'").get(a)||null}function k(a){let b=j(a);if(!b)return null;try{return JSON.parse(b.spec_json)}catch{return null}}function l(){let a;try{a=(0,e.getDb)().prepare("SELECT * FROM composite_tools WHERE status='active' ORDER BY slug ASC").all()}catch{return[]}return a.map(a=>{let b,{approval_required:c,approval_mode:d}=function(a){let b=f.pE.indexOf(a)>=f.pE.indexOf("medium");return{approval_required:b,approval_mode:b?"approval_required":"auto"}}(a.risk_level);try{b=JSON.parse(a.input_schema_json||"")||{type:"object",properties:{}}}catch{b={type:"object",properties:{}}}return{name:a.slug,title:a.title||a.slug,description:a.description||`Composite tool: ${a.slug}`,category:"composite",risk_level:a.risk_level,approval_required:c,approval_mode:d,required_env:[],enabled:!0,available:!0,missing_env:[],allowlist_required:!1,allowlist_scope_key:null,allowlist_default_allow:!1,input_schema:b,source:{kind:"composite",composite_slug:a.slug}}})}e=(g.then?(await g)():g)[0],d()}catch(a){d(a)}})},5295:(a,b,c)=>{"use strict";c.d(b,{Op:()=>j,W6:()=>i,Wp:()=>h,Wq:()=>f,xU:()=>g});let d=new Set(["travel","email","calendar","supabase","vercel","mines"]),e={travel:"travel_concierge",email:"personal_assistant",github:"engineering_lead",calendar:"ops_manager",supabase:"web_ecommerce",vercel:"web_ecommerce",browser:"web_ecommerce",voice:"content_social"},f=[[/\b(flight|flights|fly|airfare|airline|hotel|hotels|itinerary|trip|travel|book a (room|stay))\b/i,"travel"],[/\b(email|inbox|reply to .*(mail|message)|draft a (reply|mail|email)|gmail)\b/i,"email"],[/\b(pull request|\bpr\b|open an? issue|github|merge|commit|repo|repository)\b/i,"github"],[/\b(calendar|schedule a (meeting|call)|book (a )?(meeting|slot|30 ?min)|invite .* to)\b/i,"calendar"],[/\b(deploy|vercel|production build|ship the site)\b/i,"vercel"],[/\b(supabase|database row|insert into|update the table|sql)\b/i,"supabase"],[/\b(image|images|photo|photograph|photoshoot|picture|visual|visuals|render|rendering|artwork|illustration|graphic|poster|advert|advertisement|\bad\b|\bads\b|banner|logo|thumbnail|mockup|still[\s-]?life|moodboard|generate (an?|the) (image|picture|visual|ad)|text[\s-]?to[\s-]?image)\b/i,"media"]],g=["travel-concierge"];function h(a){return!!(a&&d.has(a.category))}function i(a){return e[a]||null}function j(a){let b=String(a||"");if(!b.trim())return[];let c=[];for(let[a,d]of f)a.test(b)&&!c.includes(d)&&c.push(d);return c}},5735:(a,b,c)=>{"use strict";c.d(b,{zP:()=>l});let d=new Set(["intake_form","agent_run","policy_gate","human_approval","package"]),e=new Set(["text","email","number","textarea","select","shareholders"]),f=new Set(["low","medium","high","irreversible_external"]),g=/^[a-z][a-z0-9-]{2,63}$/;function h(a,b,c){a.push(`${b}: ${c}`)}function i(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}let j=new Set(["and","or"]),k=new Set(["eq","neq","lt","lte","gt","gte","in","nin"]);function l(a,b={}){var c;let m,n=[],o=[];try{m=JSON.stringify(a)}catch{return{ok:!1,errors:["spec: not JSON-serialisable"],warnings:[],normalized:null}}if(!m||"undefined"===m)return{ok:!1,errors:["spec: required"],warnings:[],normalized:null};if(Buffer.byteLength(m,"utf8")>65536)return{ok:!1,errors:[`spec: serialized length ${Buffer.byteLength(m,"utf8")} bytes exceeds 65536-byte cap`],warnings:[],normalized:null};if(!i(a))return{ok:!1,errors:["spec: must be an object"],warnings:[],normalized:null};a.slug&&"string"==typeof a.slug?g.test(a.slug)||h(n,"slug",`does not match ${g} (lowercase, starts with letter, 3-64 chars, [a-z0-9-])`):h(n,"slug","required (string)"),a.name&&"string"==typeof a.name||h(n,"name","required (string)");let p=a.schema_version??1;if(null==a.schema_version||Number.isInteger(a.schema_version)||h(n,"schema_version","must be an integer"),null!=a.version&&(!Number.isInteger(a.version)||a.version<1)&&h(n,"version","must be a positive integer"),!Array.isArray(a.stages)||0===a.stages.length)return h(n,"stages","required (non-empty array)"),{ok:!1,errors:n,warnings:o,normalized:null};let q=new Set;a.stages.forEach((a,b)=>{let c=`stages[${b}]`;if(!i(a))return void h(n,c,"must be an object");a.slug&&"string"==typeof a.slug?g.test(a.slug)?q.has(a.slug)?h(n,`${c}.slug`,`duplicate stage slug "${a.slug}"`):q.add(a.slug):h(n,`${c}.slug`,`does not match ${g}`):h(n,`${c}.slug`,"required (string)"),a.name&&"string"==typeof a.name||h(n,`${c}.name`,"required (string)"),a.kind&&d.has(a.kind)||h(n,`${c}.kind`,`unknown kind "${a.kind}" (allowed: ${[...d].join(", ")})`)});let r=a.stages[0];if(r&&r.kind&&"intake_form"!==r.kind&&h(n,"stages[0].kind",`first stage must be "intake_form" (got "${r.kind}")`),a.stages.forEach((a,c)=>{if(!a||!d.has(a.kind))return;let g=`stages[${c}]`;if(!i(a.config))return void h(n,`${g}.config`,"must be an object");switch(a.kind){case"intake_form":!function(a,b,c){let d=a?.config?.form_schema;if(!i(d))return h(b,`${c}.config.form_schema`,"required (must be object)");if(!Array.isArray(d.fields)||0===d.fields.length)return h(b,`${c}.config.form_schema.fields`,"must be a non-empty array");let f=new Set;d.fields.forEach((a,d)=>{let g=`${c}.config.form_schema.fields[${d}]`;if(!i(a))return void h(b,g,"must be an object");a.name&&"string"==typeof a.name||h(b,`${g}.name`,"required (string)"),a.label&&"string"==typeof a.label||h(b,`${g}.label`,"required (string)"),a.type&&e.has(a.type)||h(b,`${g}.type`,`unknown type "${a.type}" (allowed: ${[...e].join(", ")})`),"select"!==a.type||Array.isArray(a.options)&&0!==a.options.length||h(b,`${g}.options`,"select requires a non-empty options[] array"),a.name&&(f.has(a.name)&&h(b,`${g}.name`,`duplicate field name "${a.name}"`),f.add(a.name))})}(a,n,g);break;case"agent_run":let l=a.config||{};if(l.agent_template_slug&&"string"==typeof l.agent_template_slug?b.knownAgentTemplates&&!b.knownAgentTemplates.has(l.agent_template_slug)&&h(n,`${g}.config.agent_template_slug`,`unknown template "${l.agent_template_slug}"`):h(n,`${g}.config.agent_template_slug`,"required (string)"),l.prompt&&"string"==typeof l.prompt?l.prompt.length>8e3&&h(n,`${g}.config.prompt`,`exceeds 8000 chars (got ${l.prompt.length})`):h(n,`${g}.config.prompt`,"required (string)"),null!=l.timeout_ms&&(!Number.isInteger(l.timeout_ms)||l.timeout_ms<1e3||l.timeout_ms>6e5)&&h(n,`${g}.config.timeout_ms`,"must be integer 1000..600000"),null!=l.on_outcome)if(i(l.on_outcome))for(let[a,b]of Object.entries(l.on_outcome)){if("string"!=typeof b){h(n,`${g}.config.on_outcome.${a}`,'value must be a string (stage slug or "fail")');continue}"fail"!==b&&q&&!q.has(b)&&h(n,`${g}.config.on_outcome.${a}`,`references non-existent stage "${b}"`)}else h(n,`${g}.config.on_outcome`,"must be an object");break;case"policy_gate":!function(a,b,c){let d=a.config||{};if(!Array.isArray(d.rules)||0===d.rules.length)return h(b,`${c}.config.rules`,"required (non-empty array)");d.rules.forEach((a,d)=>{let e=`${c}.config.rules[${d}]`;"string"==typeof a?a.trim()||h(b,e,"empty rule expression"):i(a)&&"string"==typeof a.op?function a(b,c,d,e=0){if(e>20)return void h(c,d,"predicate nesting too deep");if(!i(b))return void h(c,d,"predicate must be an object");let f=b.op;j.has(f)?Array.isArray(b.rules)&&0!==b.rules.length?b.rules.forEach((b,f)=>a(b,c,`${d}.rules[${f}]`,e+1)):h(c,`${d}.rules`,`"${f}" requires a non-empty rules[] array`):"not"===f?i(b.rule)?a(b.rule,c,`${d}.rule`,e+1):h(c,`${d}.rule`,'"not" requires a rule object'):k.has(f)?("string"==typeof b.path&&b.path.trim()||h(c,`${d}.path`,"required (non-empty string)"),"value"in b?"in"!==f&&"nin"!==f||Array.isArray(b.value)||h(c,`${d}.value`,`"${f}" requires an array value`):h(c,`${d}.value`,"required")):h(c,`${d}.op`,`unknown predicate op "${f}"`)}(a,b,e):i(a)?a.expr&&"string"==typeof a.expr&&a.expr.trim()||h(b,`${e}.expr`,"required (non-empty string)"):h(b,e,"rule must be a JSON predicate, a string, or { expr, label }")})}(a,n,g);break;case"human_approval":let m=a.config||{};m.action_type&&"string"==typeof m.action_type?m.action_type.startsWith("process.stage.")||h(n,`${g}.config.action_type`,'must start with "process.stage."'):h(n,`${g}.config.action_type`,"required (string)"),m.risk&&f.has(m.risk)||h(n,`${g}.config.risk`,`must be one of ${[...f].join(", ")}`),null!=m.summary_template&&"string"!=typeof m.summary_template&&h(n,`${g}.config.summary_template`,"must be a string");break;case"package":let o=a.config||{};o.title_template&&"string"==typeof o.title_template||h(n,`${g}.config.title_template`,"required (string)"),null!=o.include_stages&&(Array.isArray(o.include_stages)?o.include_stages.forEach((a,b)=>{"string"!=typeof a?h(n,`${g}.config.include_stages[${b}]`,"must be a string"):q.has(a)||h(n,`${g}.config.include_stages[${b}]`,`unknown stage slug "${a}"`)}):h(n,`${g}.config.include_stages`,"must be an array of stage slugs"))}}),a.stages.forEach((a,b)=>{if(!i(a))return;let c=`stages[${b}]`;null==a.on_pass_stage_slug||"fail"===a.on_pass_stage_slug||q.has(a.on_pass_stage_slug)||h(n,`${c}.on_pass_stage_slug`,`references non-existent stage "${a.on_pass_stage_slug}"`),null==a.on_fail_stage_slug||"fail"===a.on_fail_stage_slug||q.has(a.on_fail_stage_slug)||h(n,`${c}.on_fail_stage_slug`,`references non-existent stage "${a.on_fail_stage_slug}"`)}),0===n.length&&function(a){let b=new Map(a.map(a=>[a.slug,a])),c=new Map(a.map(a=>[a.slug,0]));for(let d of a)if(0===c.get(d.slug)&&function a(d){if(!b.has(d))return!1;let e=c.get(d);if(1===e)return!0;if(2===e)return!1;c.set(d,1);let f=b.get(d).on_pass_stage_slug;return!!(f&&"fail"!==f&&a(f))||(c.set(d,2),!1)}(d.slug))return!0;return!1}(a.stages)&&h(n,"stages","routing graph contains a cycle"),0===n.length){let b=new Set;a.stages.forEach(a=>{a.on_pass_stage_slug&&"fail"!==a.on_pass_stage_slug&&b.add(a.on_pass_stage_slug),a.on_fail_stage_slug&&"fail"!==a.on_fail_stage_slug&&b.add(a.on_fail_stage_slug);let c=a?.config?.on_outcome;if(i(c))for(let a of Object.values(c))"string"==typeof a&&"fail"!==a&&b.add(a)}),a.stages.forEach((a,c)=>{0!==c&&(b.has(a.slug)||o.push(`stages[${c}] "${a.slug}": orphan stage (no inbound edges)`))})}return n.length>0?{ok:!1,errors:n,warnings:o,normalized:null}:{ok:!0,errors:[],warnings:o,normalized:{schema_version:p,slug:(c=a).slug,name:c.name,version:c.version||1,description:c.description||null,category:c.category||null,source:c.source||"api",status:c.status||"draft",stages:c.stages.map(a=>({slug:a.slug,name:a.name,kind:a.kind,config:structuredClone(a.config||{}),on_pass_stage_slug:a.on_pass_stage_slug||null,on_fail_stage_slug:a.on_fail_stage_slug||null,required:!1!==a.required}))}}}},7183:(a,b,c)=>{"use strict";c.d(b,{X:()=>e});let d=Object.create(null);for(let a of["00_historic","01_arcgis_data","02_assay_labs","03_cad_files","04_official_database","05_drill_campaign","06_exploration_geos","07_geophysics","08_backup_bd","09_petrography","10_presentations","11_general_pictures","12_safety","13_reports","14_inegi_data","15_sgm_data","16_claims_properties","17_minesight","18_exported_maps","19_survey","20_geotechnical","21_general_files","22_qa_qc","uncategorized"]){let b=a.match(/^(\d{2})_/);b&&(d[b[1]]=a)}function e(a){let b=String(a||"").split(/[/\\]/).filter(Boolean),c=null;for(let a of b){let b=a.match(/^(\d{2})[-_ ]/i);if(!b)continue;let e=b[1];Object.prototype.hasOwnProperty.call(d,e)&&(c=d[e])}return c??"uncategorized"}},7945:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{H6:()=>j,WV:()=>l});var e=c(73024),f=c(73136),g=c(76760),h=c(9013),i=a([h]);h=(i.then?(await i)():i)[0];let k=(0,g.dirname)((0,f.fileURLToPath)("file:///home/runner/work/madarx-os/madarx-os/lib/process/seeds/hail-engagement-lifecycle.js")),l="hail-engagement-lifecycle",m=null;function j(){let a=(m||(m=function(){let a=(0,g.join)(k,"specs","hail-engagement-lifecycle.json");return JSON.parse((0,e.readFileSync)(a,"utf8"))}()),m);return(0,h.R1)(a,{source_spec_json:JSON.stringify(a)})}d()}catch(a){d(a)}})},8437:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{D6:()=>l,ct:()=>n,jT:()=>m,r2:()=>o,t6:()=>p,v:()=>q,zU:()=>i});var e=c(34255),f=c(40563),g=c(9001),h=a([e,f,g]);[e,f,g]=h.then?(await h)():h;let r=new Set;function i(a){return"function"!=typeof a?()=>{}:(r.add(a),()=>{r.delete(a)})}function j(){try{(0,g.jO)("approvals")}catch{}}function k(a){return a?{...a,payload:function(a,b=null){try{return JSON.parse(a)}catch{return b}}(a.payload,{})}:null}function l({action_type:a,risk:b="medium",summary:c,payload:d={},requested_by:f="system",expires_at:g=null,project_id:h=null}){let i=(0,e.getDb)(),k=(0,e.newId)("approval"),l=(0,e.nowIso)(),n=h||d?.project_id||d?.projectId||null;return i.prepare(`
167
169
  INSERT INTO approval_requests (id, status, action_type, risk, summary, payload, requested_by, created_at, expires_at, project_id)
168
170
  VALUES (?, 'pending', ?, ?, ?, ?, ?, ?, ?, ?)
169
171
  `).run(k,a,b,c,JSON.stringify(d),f,l,g,n),i.prepare(`
@@ -891,7 +893,11 @@ ${b}
891
893
  INSERT INTO heartbeat_tasks
892
894
  (id, agent_id, schedule_id, type, status, priority, payload, attempts, max_attempts, run_after, created_at, updated_at)
893
895
  VALUES (?, NULL, NULL, ?, 'queued', 0, ?, 0, 99, ?, ?, ?)
894
- `).run(b,"update_check",c,e,d,d)}(a)}catch{}try{!function(a){try{if(a.prepare("SELECT id FROM tool_allowlists WHERE tool_name = 'email_send' LIMIT 1").get())return;let b=null;try{let a=(0,e.execFileSync)("git",["config","user.email"],{stdio:["ignore","pipe","ignore"],timeout:3e3}).toString().trim();a.includes("@")&&(b=a.split("@").pop().toLowerCase().trim())}catch{}if(!b)return void console.warn("[seeds] Could not determine email domain from git config user.email. Add a recipient_domain allowlist entry for email_send manually via the dashboard.");let c=`tal-seed-email-${Date.now().toString(36)}`,d=new Date().toISOString();a.prepare(`
896
+ `).run(b,"update_check",c,e,d,d)}(a)}catch{}try{!function(a){if(a.prepare("SELECT id FROM heartbeat_tasks WHERE type = 'task_sweep' AND status IN ('queued','leased','running') LIMIT 1").get())return;let b=`hbtask-sweep-${Date.now().toString(36)}`,c=JSON.stringify({type:"task_sweep"}),d=new Date().toISOString(),e=new Date(Date.now()+12e4).toISOString();a.prepare(`
897
+ INSERT INTO heartbeat_tasks
898
+ (id, agent_id, schedule_id, type, status, priority, payload, attempts, max_attempts, run_after, created_at, updated_at)
899
+ VALUES (?, NULL, NULL, ?, 'queued', 0, ?, 0, 99, ?, ?, ?)
900
+ `).run(b,"task_sweep",c,e,d,d)}(a)}catch{}try{!function(a){try{if(a.prepare("SELECT id FROM tool_allowlists WHERE tool_name = 'email_send' LIMIT 1").get())return;let b=null;try{let a=(0,e.execFileSync)("git",["config","user.email"],{stdio:["ignore","pipe","ignore"],timeout:3e3}).toString().trim();a.includes("@")&&(b=a.split("@").pop().toLowerCase().trim())}catch{}if(!b)return void console.warn("[seeds] Could not determine email domain from git config user.email. Add a recipient_domain allowlist entry for email_send manually via the dashboard.");let c=`tal-seed-email-${Date.now().toString(36)}`,d=new Date().toISOString();a.prepare(`
895
901
  INSERT INTO tool_allowlists (id, tool_name, scope_key, scope_value, label, created_at)
896
902
  VALUES (?, 'email_send', 'recipient_domain', ?, ?, ?)
897
903
  `).run(c,b,"Seeded from git config on first install",d),console.info(`[seeds] Email allowlist seeded: email_send / recipient_domain = ${b}`)}catch(a){console.warn("[seeds] seedDefaultEmailAllowlist failed:",a?.message||a)}}(a)}catch{}try{(0,j.jz)(a)}catch{}try{(0,o.y)({})}catch{}try{(0,i.fP)(a)}catch{}try{(0,k.yi)(a)}catch{}try{(0,s.r)(a),E&&(0,r.fx)()}catch{}try{(0,t._)(a),E&&((0,u.H6)(),(0,v.r1)()),(0,w.$F)()}catch{}try{(0,x.zc)(a)}catch{}if("1"===process.env.MADARX_SEED_DEFAULT_AGENTS)try{(0,y.g)()}catch{}if(E)try{(0,z.W)()}catch{}try{(0,A.mx)(a)}catch{}!function(a){try{let b=a.prepare("SELECT id, name FROM agents WHERE id = 'ops-agent' LIMIT 1").get();if(b){"Ops Agent"===b.name&&(a.prepare("UPDATE agents SET name = 'Caretaker' WHERE id = 'ops-agent'").run(),a.prepare("UPDATE schedules SET name = 'Caretaker' WHERE agent_id = 'ops-agent' AND name = 'Ops Agent'").run());return}(0,m.W1)({silent:!0})}catch(a){console.warn("[seeds] seedOpsAgentIfMissing failed:",a?.message||a)}}(a),function(a){try{if(a.prepare("SELECT id FROM agents WHERE id = 'tool-smith-agent' LIMIT 1").get())return;(0,k.pz)("tool-smith","personal",{seed:!0,agent_id:"tool-smith-agent"})}catch(a){console.warn("[seeds] seedToolSmithAgentIfMissing failed:",a?.message||a)}}(a);for(let b of l.xU)try{if(a.prepare("SELECT agent_id FROM agent_template_installations WHERE template_slug = ? LIMIT 1").get(b))continue;(0,k.pz)(b,"personal",{seed:!0})}catch(a){console.warn(`[seeds] seedSpecialistAgentsIfMissing(${b}) failed:`,a?.message||a)}try{(0,m.OH)()}catch(a){console.warn("[seeds] migrateDefaultAgentSkills failed:",a?.message||a)}try{(0,q.k2)()}catch{}try{!function(a){try{if(a.prepare("SELECT value FROM config WHERE key = 'cto_brief_seeded'").get())return;let b=g.join(h.Dl,"seed-assets","cto-brief.html");if(!f.existsSync(b))return;let c=f.readFileSync(b,"utf8");(0,m.Dg)({title:"madarX OS — Vision, Plan & Open Questions (CTO Brief)",kind:"html",content:c,space_id:"default",agent_id:"main-orchestrator",dedupe_key:""}),a.prepare("INSERT OR REPLACE INTO config (key, value) VALUES ('cto_brief_seeded', '1')").run()}catch(a){console.warn("[seeds] seedCtoBriefArtifact failed:",a?.message||a)}}(a)}catch{}try{!function(a){try{let b=(0,B.YO)();if(!b||"0.0.0"===b)return;let c=a.prepare("SELECT value FROM config WHERE key = 'last_release_noted'").get(),d=c?.value||null;if(d===b)return;let e=()=>a.prepare("INSERT OR REPLACE INTO config (key, value) VALUES ('last_release_noted', ?)").run(b);if(!d)return void e();let i=function(a,b){if(!a||!b)return null;let c=a.split("\n"),d=b.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),e=RegExp(`^##\\s*\\[${d}\\]`),f=-1;for(let a=0;a<c.length;a++)if(e.test(c[a])){f=a;break}if(-1===f)return null;let g=c.length;for(let a=f+1;a<c.length;a++)if(/^##\s*\[/.test(c[a])){g=a;break}return c.slice(f,g).join("\n").trim()||null}(function(){for(let a of[g.join(h.Dl,"CHANGELOG.md"),g.join(process.cwd(),"CHANGELOG.md"),g.join(process.cwd(),".next","standalone","CHANGELOG.md")])try{if(f.existsSync(a))return f.readFileSync(a,"utf8")}catch{}return null}(),b);if(!i)return void e();let j=i,k="markdown";try{let a=(0,n.K8)({version:b,markdown:i});a&&a.includes("<!DOCTYPE")&&(j=a,k="html")}catch(a){console.warn("[seeds] renderChangelogHtml failed, using markdown:",a?.message||a)}(0,m.Dg)({title:`madarX ${b} — What's new`,kind:k,content:j,space_id:"default",agent_id:"main-orchestrator",dedupe_key:""}),e()}catch(a){console.warn("[seeds] seedReleaseNotesArtifact failed:",a?.message||a)}}(a)}catch{}try{(0,p.d)(a)}catch{}if(!process.env.MADARX_DATA_DIR&&!process.env.VILLA515_DATA_DIR)try{!function(a){if(!globalThis.__madarxDiskEncryptionCheckRan){if(globalThis.__madarxDiskEncryptionCheckRan=!0,a)try{if(a.prepare("SELECT id FROM audit_logs WHERE type = 'disk_encryption.health' AND at > datetime('now', '-1 hour') LIMIT 1").get())return}catch{}try{let a=new c.U(c(123)).pathname;(0,e.spawnSync)(process.execPath,["--no-warnings",a],{stdio:"ignore",detached:!1,timeout:1e4,env:{...process.env}})}catch{}}}(a)}catch{}}finally{globalThis.__madarxSuppressStateEmits=!1}}d()}catch(a){d(a)}})},23737:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{n:()=>l});var e=c(40718),f=c(4638),g=c(60105),h=a([e,f,g]);[e,f,g]=h.then?(await h)():h;let m=new Set(["__composite_slug","approval_id"]);function i(a,b){let c=a;for(let a of b.split(".")){if(null==c)return;c=c[a]}return c}function j(a,b){if("string"==typeof a){let c=a.match(/^\{\{\s*([a-zA-Z0-9_.-]+)\s*\}\}$/);if(c){let a=i(b,c[1]);return void 0===a?"":a}return a.replace(/\{\{\s*([a-zA-Z0-9_.-]+)\s*\}\}/g,(a,c)=>{let d=i(b,c);return void 0===d?"":"string"==typeof d?d:JSON.stringify(d)})}if(Array.isArray(a))return a.map(a=>j(a,b));if(a&&"object"==typeof a){let c={};for(let[d,e]of Object.entries(a))c[d]=j(e,b);return c}return a}async function k(a,b,d){let e=j(a.prompt,b);if("function"==typeof d.__synthesize)try{let a=await d.__synthesize(e);return{ok:!0,text:String(a??"")}}catch(a){return{ok:!0,text:"",skipped:!0,reason:String(a?.message||a)}}try{let{chatWithClaude:a}=await Promise.resolve().then(c.bind(c,19151)),b=await a({messages:[{role:"user",content:e}]}),d="string"==typeof b?b:b?.text||b?.content||"";return{ok:!0,text:String(d||"")}}catch(a){return{ok:!0,text:"",skipped:!0,reason:String(a?.message||a)}}}async function l(a={},b={}){let c=a.__composite_slug,d=c?(0,f.t2)(c):null;if(!d)return{ok:!1,status:"error",error:"not_found",message:`Unknown composite tool: ${c||"(none)"}`};let h={};for(let[b,c]of Object.entries(a))m.has(b)||(h[b]=c);let i={input:h},n=[],o={agent_id:b.agent_id,project_id:b.project_id,org_id:b.org_id,actor_role:b.actor_role,owner_trusted:b.owner_trusted,acting_on_behalf_of_user_id:b.acting_on_behalf_of_user_id||b.user_id||null};for(let a of d.steps)if("tool_call"===a.kind){let b,d=j(a.input_template||{},i);try{b=await (0,e.executeRegistryTool)(a.tool,d,o)}catch(b){return{ok:!1,status:"error",error:"step_failed",failed_step:a.id,failed_tool:a.tool,message:`Composite ${c} aborted at step '${a.id}' (${a.tool}): ${String(b?.message||b)}`,completed_steps:n.map(a=>a.id)}}if(!(b&&!1!==b.ok&&"approval_required"!==b.status&&"allowlist_violation"!==b.status&&"rate_limited"!==b.status&&"error"!==b.status))return{ok:!1,status:"error",error:"step_failed",failed_step:a.id,failed_tool:a.tool,step_result:b,message:`Composite ${c} aborted at step '${a.id}' (${a.tool}): ${b?.status||b?.error||"failed"}`,completed_steps:n.map(a=>a.id)};i[a.id]=b,n.push({id:a.id,kind:"tool_call",tool:a.tool,ok:!0,status:b.status})}else if("llm_synthesis"===a.kind){let c=await k(a,i,b);i[a.id]=c,n.push({id:a.id,kind:"llm_synthesis",ok:!0,skipped:!!c.skipped})}else if("artifact_write"===a.kind)try{let d=j(a.title_template||`${c} output`,i),e=a.content_ref?j(a.content_ref,i):"",f=(0,g.Dg)({title:String(d),kind:"markdown",content:"string"==typeof e?e:JSON.stringify(e,null,2),agent_id:b.agent_id||null,project_id:b.project_id||null});i[a.id]=f,n.push({id:a.id,kind:"artifact_write",ok:!0,artifact_id:f?.id||null})}catch(b){return{ok:!1,status:"error",error:"step_failed",failed_step:a.id,message:`Composite ${c} aborted at artifact_write '${a.id}': ${String(b?.message||b)}`,completed_steps:n.map(a=>a.id)}}return{ok:!0,status:"complete",composite:c,steps:n,result:n.length?i[n[n.length-1].id]:null}}d()}catch(a){d(a)}})},24516:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{AQ:()=>r,e3:()=>q,getSecret:()=>n,setSecret:()=>o,yz:()=>p});var e=c(77598),f=c(34255),g=c(87181),h=a([f]);f=(h.then?(await h)():h)[0];let s="aes-256-gcm",t=new Map;function i(){return(0,g.K2)({db:(0,f.getDb)(),allowGenerate:!0})}function j(a={}){return a.scope?String(a.scope):a.agent_id?`agent:${a.agent_id}`:a.project_id?`project:${a.project_id}`:"global"}function k(a,b={}){return b.project_id?String(b.project_id):String(a).startsWith("project:")?String(a).slice(8):null}function l(a,b,c){return`${a}::${b}::${c||""}`}function m(a,b,c){return(0,f.getDb)().prepare("SELECT * FROM secrets WHERE name = ? AND scope = ? AND COALESCE(project_id, '') = COALESCE(?, '') AND status = 'active' LIMIT 1").get(a,b,c||null)}function n(a,b={}){let c=[];b.agent_id&&c.push([`agent:${b.agent_id}`,null]),b.project_id&&c.push([`project:${b.project_id}`,String(b.project_id)]);let d=j(b);c.push([d,k(d,b)]),c.push(["global",null]);let g=new Set;for(let[b,d]of c){let c=l(a,b,d);if(g.has(c))continue;if(g.add(c),t.has(c))return t.get(c);let h=m(a,b,d);if(h)return function(a,b){let c;try{c=function(a,b,c,d){let f=(0,e.createDecipheriv)(s,d,b);return f.setAuthTag(c),Buffer.concat([f.update(a),f.final()]).toString("utf8")}(Buffer.from(a.value_encrypted),Buffer.from(a.iv),Buffer.from(a.auth_tag),i())}catch(b){throw console.warn(`[secrets] decrypt failed for ${a.name} (scope=${a.scope}, id=${a.id}): ${b?.message||b}. The active MADARX_MASTER_KEY does not match the key that encrypted this row. Either restore the original key or re-store this secret with the current key.`),b}return(0,f.getDb)().prepare("UPDATE secrets SET last_used_at = ? WHERE id = ?").run((0,f.nowIso)(),a.id),t.set(b,c),c}(h,c)}return Object.prototype.hasOwnProperty.call(process.env,a)?process.env[a]:null}function o(a,b,c={}){if(!a||"string"!=typeof a)throw Error("name is required");if(null==b)throw Error("value is required");let d=j(c),g=k(d,c),h=(0,f.getDb)(),n=(0,f.nowIso)(),p=m(a,d,g);p&&h.prepare("UPDATE secrets SET status = ?, rotated_at = ? WHERE id = ?").run("rotated",n,p.id),t.delete(l(a,d,g));let{iv:q,encrypted:r,authTag:u}=function(a,b){let c=(0,e.randomBytes)(12),d=(0,e.createCipheriv)(s,b,c),f=Buffer.concat([d.update(String(a),"utf8"),d.final()]);return{iv:c,encrypted:f,authTag:d.getAuthTag()}}(b,i());h.prepare(`INSERT INTO secrets (id, name, scope, value_encrypted, iv, auth_tag, status, source, metadata_json, project_id, created_at)
@@ -3470,7 +3476,7 @@ Next action: choose a specialized agent, create a local run folder, keep human-i
3470
3476
  </html>`}c.d(b,{i:()=>f,o:()=>e})},67179:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{getConfig:()=>g,setConfig:()=>h});var e=c(34255),f=a([e]);function g(a,b=null){if(!a)return b;let c=(0,e.getDb)().prepare("SELECT value FROM config WHERE key = ?").get(String(a));return c?c.value:b}function h(a,b){if(!a)throw Error("config key is required");let c=null==b?"":String(b);return(0,e.getDb)().prepare(`
3471
3477
  INSERT INTO config (key, value) VALUES (?, ?)
3472
3478
  ON CONFLICT(key) DO UPDATE SET value = excluded.value
3473
- `).run(String(a),c),c}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},68732:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{x:()=>k,y:()=>l});var e=c(31421),f=c(60105),g=c(8437),h=c(26531),i=a([f,g]);function j(a){return(0,h.nc)(String(a||"").slice(0,Number(process.env.MADARX_TOOL_OUTPUT_MAX_BYTES||5e4)))}function k(a={}){let b=String(a.command||""),c=Array.isArray(a.args)?a.args.map(String):[],{path:d}=(0,h.hC)(a.cwd||"."),e=(0,h.IB)(b,c);if(e.blocked)throw Error(e.reason);return{command:b,args:c,cwd:d,classified:e}}async function l(a={},b={}){let{command:c,args:d,cwd:h,classified:i}=k(a);if(i.approval_required&&!b.owner_trusted&&!(0,g.v)(a.approval_id,{action_type:"terminal_run",matches:a=>{var b;return a.command===c&&(b=a.args,JSON.stringify(b||[])===JSON.stringify(d||[]))&&a.cwd===h}})){let a=(0,g.D6)({action_type:"terminal_run",risk:i.risk,summary:`Run ${c} ${d.join(" ")}`.trim(),payload:{command:c,args:d,cwd:h,reason:i.reason}});return{ok:!1,status:"approval_required",approval_request_id:a.id,reason:i.reason}}let m=Math.max(1,Math.min(6e5,Number(a.timeout_ms||process.env.MADARX_TERMINAL_TIMEOUT_MS||18e4))),n=Date.now();return await new Promise(a=>{let b="",g="",i=(0,e.spawn)(c,d,{cwd:h,shell:!1,stdio:["ignore","pipe","pipe"]}),k=setTimeout(()=>i.kill("SIGTERM"),m);i.stdout.on("data",a=>{b+=a}),i.stderr.on("data",a=>{g+=a}),i.on("error",e=>{clearTimeout(k),(0,f.appendAudit)({type:"local.terminal_run",summary:`terminal_run failed: ${c}`,status:"failed",meta:{command:c,args:d,cwd:h,error:e.message}}),a({ok:!1,tool:"terminal_run",status:"failed",command:c,args:d,cwd:h,error:e.message,stdout:j(b),stderr:j(g)})}),i.on("close",(e,i)=>{clearTimeout(k);let l=i?"timeout":0===e?"complete":"failed";(0,f.appendAudit)({type:"local.terminal_run",summary:`terminal_run ${l}: ${c}`,status:l,meta:{command:c,args:d,cwd:h,exit_code:e,signal:i,duration_ms:Date.now()-n,stdout_preview:j(b),stderr_preview:j(g)}}),a({ok:0===e&&!i,tool:"terminal_run",status:l,command:c,args:d,cwd:h,exit_code:e,signal:i,stdout:j(b),stderr:j(g),duration_ms:Date.now()-n})})})}[f,g]=i.then?(await i)():i,d()}catch(a){d(a)}})},69102:(a,b,c)=>{"use strict";let d,e;c.d(b,{K3:()=>f,rU:()=>l,tj:()=>j});let f=Number(process.env.MINES_OCR_THRESHOLD_CHARS_PER_PAGE)||80,g=process.env.MINES_OCR_LANGS||"spa+eng";async function h(){return void 0===d&&(d=(async()=>{try{return await import("tesseract.js")}catch{return null}})().catch(()=>null)),d}async function i(){return void 0===e&&(e=(async()=>{try{let a=await import("pdf-to-png-converter");if("function"==typeof a?.pdfToPng)return async b=>(await a.pdfToPng(b,{viewportScale:2})).map((a,b)=>({page:a.pageNumber||b+1,buffer:a.content}))}catch{}return null})().catch(()=>null)),e}function j(a,b){let c=b;return(null==c||Number.isNaN(Number(c)))&&(c=String(a??"").trim().length),Number(c)<f}async function k(a,b=g){let c=await h(),d=c?.recognize||c?.default?.recognize;if("function"!=typeof d)return null;try{let{data:c}=await d(a,b);return{text:String(c?.text||""),confidence:Number(c?.confidence??0)}}catch{return null}}async function l(a,b){let c,d=await i(),e=await h();if(!d||!e)return{available:!1,pages:[]};try{c=await d(a)}catch{return{available:!1,pages:[]}}let[f,g]=Array.isArray(b)?b:[null,null],j=[];for(let a of c){if(null!=f&&a.page<f||null!=g&&a.page>g)continue;let b=await k(a.buffer);j.push({page:a.page,text:b?.text||"",confidence:b?.confidence??0})}return{available:!0,pages:j}}},69143:a=>{"use strict";a.exports=JSON.parse('{"schema_version":1,"slug":"contract-review","name":"Contract Review","version":1,"description":"Paste a contract draft and route it through an automated clause review, then counsel approval, then a packaged review report.","category":"legal","source":"marketplace","status":"published","stages":[{"slug":"intake","name":"Contract intake","kind":"intake_form","config":{"form_schema":{"title":"Contract Review — Intake","description":"Paste the contract text and a few details for the reviewer.","fields":[{"name":"counterparty","label":"Counterparty name","type":"text","required":true},{"name":"contract_title","label":"Contract title","type":"text","required":true},{"name":"contract_type","label":"Contract type","type":"select","required":true,"options":["MSA","SOW","NDA","DPA","Order Form","Other"]},{"name":"value_usd","label":"Contract value (USD)","type":"number","required":false,"min":0},{"name":"contract_text","label":"Contract text","type":"textarea","required":true,"min_length":200,"placeholder":"Paste the full contract text here. Minimum 200 characters."},{"name":"notes","label":"Reviewer notes","type":"textarea","required":false}]}}},{"slug":"clause-review","name":"Automated clause review","kind":"agent_run","config":{"agent_template_slug":"contract-reviewer","prompt":"You are a contract reviewer. Read the contract text in the intake payload and produce a structured review. Return strict JSON only, no surrounding prose: { \\"outcome\\": \\"pass\\" | \\"reject\\", \\"flags\\": [{ \\"clause\\": string, \\"severity\\": \\"low\\" | \\"medium\\" | \\"high\\", \\"concern\\": string, \\"suggested_edit\\": string }], \\"overall_recommendation\\": \\"approve\\" | \\"amend\\" | \\"reject\\", \\"summary\\": \\"one paragraph\\" }. Set outcome=\\"reject\\" only when the contract is so broken counsel cannot fix it (corrupted text, wrong document, illegal clauses). Set outcome=\\"pass\\" otherwise — counsel approval is the real gate. Focus on: indemnity scope, liability cap, IP assignment, auto-renewal, termination for convenience, data-processing addendum, governing law. If a clause is missing entirely from the contract, list it as severity high with concern \\"missing\\".","output_schema":"contract_review_v1","timeout_ms":90000,"on_outcome":{"pass":"counsel-approval","reject":"fail"}},"on_pass_stage_slug":"counsel-approval","on_fail_stage_slug":null},{"slug":"counsel-approval","name":"Counsel approval","kind":"human_approval","config":{"action_type":"process.stage.approve","risk":"high","summary_template":"Approve contract review for {{intake.contract_title}} with {{intake.counterparty}} — recommendation {{clause-review.overall_recommendation}}"},"on_pass_stage_slug":"final-package","on_fail_stage_slug":null},{"slug":"final-package","name":"Review report","kind":"package","config":{"title_template":"Contract review — {{intake.contract_title}}","include_stages":["intake","clause-review","counsel-approval"]}}]}')},69286:(a,b,c)=>{"use strict";c.d(b,{XI:()=>e,fd:()=>f,yQ:()=>g});let d=new Map;function e(a){let b=String(a||"");b&&d.set(b,(d.get(b)||0)+1)}function f(a){let b=String(a||"");if(!b)return;let c=(d.get(b)||0)-1;c<=0?d.delete(b):d.set(b,c)}function g(a){return(d.get(String(a||""))||0)>0}},69635:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{f:()=>l,x:()=>k});var e=c(24516),f=c(58282),g=a([e,f]);[e,f]=g.then?(await g)():g;let m="https://api.resend.com";function h(a,b={}){try{let c=(0,e.getSecret)(a,{agent_id:b.agent_id,project_id:b.project_id});if(c)return c}catch{}return process.env[a]||null}function i(a,b={}){let c=h(a,b);if(!c)throw Error(`${a} not configured`);return c}async function j(a){try{let b=await a.json();return b?.message||b?.name||`HTTP ${a.status}`}catch{return`HTTP ${a.status}`}}async function k(a={},b={}){let c=String(a.to||"").trim();if(!c)throw Error('"to" is required');let d=String(a.subject||"").trim();if(!d)throw Error('"subject" is required');if(!a.text&&!a.html)throw Error('Either "text" or "html" body content is required');let e=function(a){let b=String(a||"").trim(),c=b.lastIndexOf("@");return c<0?null:b.slice(c+1).toLowerCase().trim()}(c);if(!e)throw Error(`"to" must be a valid email address containing "@"; got: ${c}`);let g=a.recipient_domain?String(a.recipient_domain).toLowerCase().trim():null;if(!g)throw Error(`"recipient_domain" is required and must be set to "${e}" (the domain of the "to" address). Retry with: { ..., recipient_domain: "${e}" }`);if(g!==e)throw Error(`"recipient_domain" mismatch: declared "${g}" but "to" address "${c}" has domain "${e}". Set recipient_domain: "${e}" and retry.`);let l=i("RESEND_API_KEY",b),n=b.agent_id??null,o=a.from?String(a.from).trim():null;if(o||(o=h("RESEND_FROM_EMAIL",b)),!o)throw Error('Sender address not configured. Set RESEND_FROM_EMAIL via the secrets vault or pass "from" explicitly in the input. Resend\'s test sender (onboarding@resend.dev) requires a verified account.');let p={from:o,to:c,subject:d,...a.text?{text:String(a.text)}:{},...a.html?{html:String(a.html)}:{},...a.reply_to?{reply_to:String(a.reply_to)}:{}},q=(0,f.N)("email_send",n),r=await q(`${m}/emails`,{method:"POST",headers:{Authorization:`Bearer ${l}`,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(p)});if(!r.ok){let a=await j(r);throw Error(`Resend API error (${r.status}): ${a}`)}let s=await r.json();return{ok:!0,id:s.id,to:c,recipient_domain:e}}async function l(a={},b={}){let c=String(a.email_id||"").trim();if(!c)throw Error('"email_id" is required');let d=i("RESEND_API_KEY",b),e=b.agent_id??null,g=(0,f.N)("email_status_lookup",e),h=await g(`${m}/emails/${encodeURIComponent(c)}`,{headers:{Authorization:`Bearer ${d}`,Accept:"application/json"}});if(!h.ok){let a=await j(h);throw Error(`Resend API error (${h.status}): ${a}`)}let k=await h.json();return{id:k.id,to:k.to,from:k.from,subject:k.subject,last_event:k.last_event,created_at:k.created_at}}d()}catch(a){d(a)}})},69722:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{zc:()=>j});var e=c(34255),f=c(18530),g=c(69143),h=c(4249),i=a([e]);e=(i.then?(await i)():i)[0];let k={"vendor-onboarding":f,"contract-review":g,"support-escalation":h},l=[{slug:"vendor-onboarding",title:"Vendor Onboarding",category:"procurement",tags:["workflow","procurement","starter"],risk_summary:"Intake → automated risk review → buyer sign-off → onboarding pack. All write actions are gated by human_approval."},{slug:"contract-review",title:"Contract Review",category:"legal",tags:["workflow","legal","starter"],risk_summary:"Intake → automated clause review → counsel approval (high-risk gate) → review report. Drafts only; no signature step."},{slug:"support-escalation",title:"Support Escalation",category:"support",tags:["workflow","support","starter"],risk_summary:"Intake → automated triage → supervisor sign-off → resolution pack. Customer-visible copy never sent without human approval."}].map(a=>{let b=k[a.slug];return{...a,description:b.description,author:"madarx",source_kind:"builtin",source_url:null,version:"1.0",spec:b}});function j(a){try{for(let b of l)!function(a,b){let c=`workflow:${b.slug}`,d=JSON.stringify({summary:b.description,source_spec_json:b.spec}),f=JSON.stringify(b.tags||[]),g=a.prepare("SELECT id FROM marketplace_items WHERE kind='workflow' AND slug=?").get(b.slug),h=[b.title,b.description,b.category,b.author,b.source_kind,b.source_url,b.version,d,b.risk_summary,f];if(g)return a.prepare("UPDATE marketplace_items SET title=?, description=?, category=?, author=?, source_kind=?, source_url=?, version=?, manifest_json=?, risk_summary=?, tags=? WHERE id=?").run(...h,c);a.prepare("INSERT INTO marketplace_items (id, kind, slug, title, description, category, author, source_kind, source_url, version, manifest_json, risk_summary, tags, created_at) VALUES (?, 'workflow', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)").run(c,b.slug,...h,(0,e.nowIso)()),a.prepare("INSERT OR IGNORE INTO marketplace_installations (item_id, installed) VALUES (?, 0)").run(c)}(a,b)}catch(a){console.warn("[marketplace-workflows] seed failed:",a?.message||a)}}l.map(a=>a.slug),d()}catch(a){d(a)}})},70845:(a,b,c)=>{"use strict";c.d(b,{H:()=>f});var d=c(14972);function e(a,b,c){var e;let f=(0,d.uX)(b);return{label:a,value_usd:f.in_situ_value_usd,delta_pct:(e=f.in_situ_value_usd,null==e||null==c||0===c?null:Math.round((e-c)/c*1e4)/100),assumptions:b}}function f(a={},b={}){let c=(0,d.uX)(a),g=c.in_situ_value_usd,h=Number(b.grade_std_au_gpt??a.grade_std_au_gpt??0)||0,i=Number(b.grade_std_cu_pct??a.grade_std_cu_pct??0)||0,j=Number(b.grade_std_ag_gpt??a.grade_std_ag_gpt??0)||0,k=[["-20%",.8],["-10%",.9],["base",1],["+10%",1.1],["+20%",1.2]].map(([b,c])=>e(b,{...{...a},price_au_usd_oz:null==a.price_au_usd_oz?a.price_au_usd_oz:a.price_au_usd_oz*c,price_ag_usd_oz:null==a.price_ag_usd_oz?a.price_ag_usd_oz:a.price_ag_usd_oz*c,price_cu_usd_lb:null==a.price_cu_usd_lb?a.price_cu_usd_lb:a.price_cu_usd_lb*c},g)),l=[["-2σ",-2],["-1σ",-1],["base",0],["+1σ",1],["+2σ",2]].map(([b,c])=>e(b,{...{...a},grade_au_gpt:null==a.grade_au_gpt?a.grade_au_gpt:Math.max(0,a.grade_au_gpt+c*h),grade_ag_gpt:null==a.grade_ag_gpt?a.grade_ag_gpt:Math.max(0,a.grade_ag_gpt+c*j),grade_cu_pct:null==a.grade_cu_pct?a.grade_cu_pct:Math.max(0,a.grade_cu_pct+c*i)},g)),m=[["-20%",.8],["-10%",.9],["base",1],["+10%",1.1],["+20%",1.2]].map(([b,c])=>e(b,{...{...a},recovery_au:null==a.recovery_au?a.recovery_au:Math.min(1,Math.max(0,a.recovery_au*c)),recovery_ag:null==a.recovery_ag?a.recovery_ag:Math.min(1,Math.max(0,a.recovery_ag*c)),recovery_cu:null==a.recovery_cu?a.recovery_cu:Math.min(1,Math.max(0,a.recovery_cu*c))},g)),n=[["-20%",.8],["-10%",.9],["base",1],["+10%",1.1],["+20%",1.2]].map(([b,c])=>e(b,{...{...a},in_situ_factor:null==a.in_situ_factor?a.in_situ_factor:a.in_situ_factor*c},g));return{base_value_usd:g,base_result:c,drivers:{commodity_price:k,grade:l,recovery:m,in_situ_factor:n}}}},70952:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{f:()=>n});var e=c(34255),f=c(44986),g=c(69102),h=c(14207),i=a([e,h]);[e,h]=i.then?(await i)():i;let o=Number(process.env.MINES_CHUNK_TOKENS)||600,p=Number(process.env.MINES_CHUNK_OVERLAP_TOKENS)||100;async function j(a){try{switch(a){case"pdf-parse":return await import("pdf-parse");case"mammoth":return await import("mammoth");case"officeparser":return await import("officeparser");default:return null}}catch{return null}}function k(a){return Math.ceil(String(a||"").length/4)}let q=["de","la","el","que","en","los","para","con","del","una","por","se","su"],r=["the","of","and","to","in","for","is","that","with","from","this","are"];function l(a){let b=String(a||"").toLowerCase().split(/[^a-záéíóúñ]+/i).filter(Boolean).slice(0,400);if(b.length<5)return"es";let c=0,d=0;for(let a of b)q.includes(a)&&c++,r.includes(a)&&d++;return d>1.2*c?"en":"es"}async function m(a,b,c,d){if("pdf"===b){let b=await j("pdf-parse"),e="function"==typeof b?b:"function"==typeof b?.default?b.default:null,f=b?.PDFParse||b?.default?.PDFParse||null;if(!e&&!f)return{available:!1,error:"parser_unavailable:pdf",pages:[]};let h=d.readDocument(a),i="",k=1,l=null;try{if(f){let a=new f({data:h}),b=await a.getText();try{a.destroy?.()}catch{}i=String(b?.text||""),k=Number(b?.total)||(Array.isArray(b?.pages)?b.pages.length:1)||1,Array.isArray(b?.pages)&&(l=b.pages.map((a,b)=>({page:Number(a?.num??a?.page??b+1),text:String(a?.text||"")})))}else{let a=await e(h);i=String(a?.text||""),k=Number(a?.numpages)||1}}catch(a){return{available:!0,error:"parse_error:"+(a?.message||"pdf"),pages:[]}}let m=i.length/k;if(c||(0,g.tj)(i,m)){let b=await (0,g.rU)(a);return b.available?{available:!0,isScanned:!0,ocrApplied:!0,pageCount:b.pages.length||k,pages:b.pages.map(a=>({page:a.page,text:a.text}))}:{available:!0,isScanned:!0,ocrApplied:!1,ocrSkipped:!0,pageCount:k,pages:[]}}if(l)return{available:!0,isScanned:!1,ocrApplied:!1,pageCount:k,pages:l};let n=i.includes("\f")?i.split("\f"):[i];return{available:!0,isScanned:!1,ocrApplied:!1,pageCount:k,pages:n.map((a,b)=>({page:b+1,text:a}))}}if("docx"===b){let b=await j("mammoth"),c=b?.extractRawText||b?.default?.extractRawText;if("function"!=typeof c)return{available:!1,error:"parser_unavailable:docx",pages:[]};try{let b=await c({path:a});return{available:!0,isScanned:!1,ocrApplied:!1,pageCount:1,pages:[{page:1,text:b?.value||""}]}}catch(a){return{available:!0,error:"parse_error:"+(a?.message||"docx"),pages:[]}}}if("pptx"===b){let b=await j("officeparser"),c=b?.parseOfficeAsync||b?.default?.parseOfficeAsync||b?.parseOffice||b?.default?.parseOffice;if("function"!=typeof c)return{available:!1,error:"parser_unavailable:pptx",pages:[]};try{let b=await c(a);return{available:!0,isScanned:!1,ocrApplied:!1,pageCount:1,pages:[{page:1,text:String(b||"")}]}}catch(a){return{available:!0,error:"parse_error:"+(a?.message||"pptx"),pages:[]}}}return{available:!1,error:"unsupported_file_type:"+b,pages:[]}}async function n(a,b={}){let c=a?.source_document_id;if(!c)return{status:"error",error:"source_document_id_required"};let d=(0,e.getDb)(),i=d.prepare("SELECT id, project_id, document_category, original_path, file_type FROM mines_source_documents WHERE id = ?").get(c);if(!i)return{status:"error",error:"source_document_not_found"};let j=d.prepare(`
3479
+ `).run(String(a),c),c}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},68732:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{x:()=>k,y:()=>l});var e=c(31421),f=c(60105),g=c(8437),h=c(26531),i=a([f,g]);function j(a){return(0,h.nc)(String(a||"").slice(0,Number(process.env.MADARX_TOOL_OUTPUT_MAX_BYTES||5e4)))}function k(a={}){let b=String(a.command||""),c=Array.isArray(a.args)?a.args.map(String):[],{path:d}=(0,h.hC)(a.cwd||"."),e=(0,h.IB)(b,c);if(e.blocked)throw Error(e.reason);return{command:b,args:c,cwd:d,classified:e}}async function l(a={},b={}){let{command:c,args:d,cwd:h,classified:i}=k(a);if(i.approval_required&&!b.owner_trusted&&!(0,g.v)(a.approval_id,{action_type:"terminal_run",matches:a=>{var b;return a.command===c&&(b=a.args,JSON.stringify(b||[])===JSON.stringify(d||[]))&&a.cwd===h}})){let a=(0,g.D6)({action_type:"terminal_run",risk:i.risk,summary:`Run ${c} ${d.join(" ")}`.trim(),payload:{command:c,args:d,cwd:h,reason:i.reason}});return{ok:!1,status:"approval_required",approval_request_id:a.id,reason:i.reason}}let m=Math.max(1,Math.min(6e5,Number(a.timeout_ms||process.env.MADARX_TERMINAL_TIMEOUT_MS||18e4))),n=Date.now();return await new Promise(a=>{let b="",g="",i=(0,e.spawn)(c,d,{cwd:h,shell:!1,stdio:["ignore","pipe","pipe"]}),k=setTimeout(()=>i.kill("SIGTERM"),m);i.stdout.on("data",a=>{b+=a}),i.stderr.on("data",a=>{g+=a}),i.on("error",e=>{clearTimeout(k),(0,f.appendAudit)({type:"local.terminal_run",summary:`terminal_run failed: ${c}`,status:"failed",meta:{command:c,args:d,cwd:h,error:e.message}}),a({ok:!1,tool:"terminal_run",status:"failed",command:c,args:d,cwd:h,error:e.message,stdout:j(b),stderr:j(g)})}),i.on("close",(e,i)=>{clearTimeout(k);let l=i?"timeout":0===e?"complete":"failed";(0,f.appendAudit)({type:"local.terminal_run",summary:`terminal_run ${l}: ${c}`,status:l,meta:{command:c,args:d,cwd:h,exit_code:e,signal:i,duration_ms:Date.now()-n,stdout_preview:j(b),stderr_preview:j(g)}}),a({ok:0===e&&!i,tool:"terminal_run",status:l,command:c,args:d,cwd:h,exit_code:e,signal:i,stdout:j(b),stderr:j(g),duration_ms:Date.now()-n})})})}[f,g]=i.then?(await i)():i,d()}catch(a){d(a)}})},69102:(a,b,c)=>{"use strict";let d,e;c.d(b,{K3:()=>f,rU:()=>l,tj:()=>j});let f=Number(process.env.MINES_OCR_THRESHOLD_CHARS_PER_PAGE)||80,g=process.env.MINES_OCR_LANGS||"spa+eng";async function h(){return void 0===d&&(d=(async()=>{try{return await import("tesseract.js")}catch{return null}})().catch(()=>null)),d}async function i(){return void 0===e&&(e=(async()=>{try{let a=await import("pdf-to-png-converter");if("function"==typeof a?.pdfToPng)return async b=>(await a.pdfToPng(b,{viewportScale:2})).map((a,b)=>({page:a.pageNumber||b+1,buffer:a.content}))}catch{}return null})().catch(()=>null)),e}function j(a,b){let c=b;return(null==c||Number.isNaN(Number(c)))&&(c=String(a??"").trim().length),Number(c)<f}async function k(a,b=g){let c=await h(),d=c?.recognize||c?.default?.recognize;if("function"!=typeof d)return null;try{let{data:c}=await d(a,b);return{text:String(c?.text||""),confidence:Number(c?.confidence??0)}}catch{return null}}async function l(a,b){let c,d=await i(),e=await h();if(!d||!e)return{available:!1,pages:[]};try{c=await d(a)}catch{return{available:!1,pages:[]}}let[f,g]=Array.isArray(b)?b:[null,null],j=[];for(let a of c){if(null!=f&&a.page<f||null!=g&&a.page>g)continue;let b=await k(a.buffer);j.push({page:a.page,text:b?.text||"",confidence:b?.confidence??0})}return{available:!0,pages:j}}},69143:a=>{"use strict";a.exports=JSON.parse('{"schema_version":1,"slug":"contract-review","name":"Contract Review","version":1,"description":"Paste a contract draft and route it through an automated clause review, then counsel approval, then a packaged review report.","category":"legal","source":"marketplace","status":"published","stages":[{"slug":"intake","name":"Contract intake","kind":"intake_form","config":{"form_schema":{"title":"Contract Review — Intake","description":"Paste the contract text and a few details for the reviewer.","fields":[{"name":"counterparty","label":"Counterparty name","type":"text","required":true},{"name":"contract_title","label":"Contract title","type":"text","required":true},{"name":"contract_type","label":"Contract type","type":"select","required":true,"options":["MSA","SOW","NDA","DPA","Order Form","Other"]},{"name":"value_usd","label":"Contract value (USD)","type":"number","required":false,"min":0},{"name":"contract_text","label":"Contract text","type":"textarea","required":true,"min_length":200,"placeholder":"Paste the full contract text here. Minimum 200 characters."},{"name":"notes","label":"Reviewer notes","type":"textarea","required":false}]}}},{"slug":"clause-review","name":"Automated clause review","kind":"agent_run","config":{"agent_template_slug":"contract-reviewer","prompt":"You are a contract reviewer. Read the contract text in the intake payload and produce a structured review. Return strict JSON only, no surrounding prose: { \\"outcome\\": \\"pass\\" | \\"reject\\", \\"flags\\": [{ \\"clause\\": string, \\"severity\\": \\"low\\" | \\"medium\\" | \\"high\\", \\"concern\\": string, \\"suggested_edit\\": string }], \\"overall_recommendation\\": \\"approve\\" | \\"amend\\" | \\"reject\\", \\"summary\\": \\"one paragraph\\" }. Set outcome=\\"reject\\" only when the contract is so broken counsel cannot fix it (corrupted text, wrong document, illegal clauses). Set outcome=\\"pass\\" otherwise — counsel approval is the real gate. Focus on: indemnity scope, liability cap, IP assignment, auto-renewal, termination for convenience, data-processing addendum, governing law. If a clause is missing entirely from the contract, list it as severity high with concern \\"missing\\".","output_schema":"contract_review_v1","timeout_ms":90000,"on_outcome":{"pass":"counsel-approval","reject":"fail"}},"on_pass_stage_slug":"counsel-approval","on_fail_stage_slug":null},{"slug":"counsel-approval","name":"Counsel approval","kind":"human_approval","config":{"action_type":"process.stage.approve","risk":"high","summary_template":"Approve contract review for {{intake.contract_title}} with {{intake.counterparty}} — recommendation {{clause-review.overall_recommendation}}"},"on_pass_stage_slug":"final-package","on_fail_stage_slug":null},{"slug":"final-package","name":"Review report","kind":"package","config":{"title_template":"Contract review — {{intake.contract_title}}","include_stages":["intake","clause-review","counsel-approval"]}}]}')},69286:(a,b,c)=>{"use strict";c.d(b,{XI:()=>e,fd:()=>f,su:()=>h,yQ:()=>g});let d=new Map;function e(a){let b=String(a||"");b&&d.set(b,(d.get(b)||0)+1)}function f(a){let b=String(a||"");if(!b)return;let c=(d.get(b)||0)-1;c<=0?d.delete(b):d.set(b,c)}function g(a){return(d.get(String(a||""))||0)>0}function h(){return Array.from(d.keys()).filter(a=>(d.get(a)||0)>0)}},69635:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{f:()=>l,x:()=>k});var e=c(24516),f=c(58282),g=a([e,f]);[e,f]=g.then?(await g)():g;let m="https://api.resend.com";function h(a,b={}){try{let c=(0,e.getSecret)(a,{agent_id:b.agent_id,project_id:b.project_id});if(c)return c}catch{}return process.env[a]||null}function i(a,b={}){let c=h(a,b);if(!c)throw Error(`${a} not configured`);return c}async function j(a){try{let b=await a.json();return b?.message||b?.name||`HTTP ${a.status}`}catch{return`HTTP ${a.status}`}}async function k(a={},b={}){let c=String(a.to||"").trim();if(!c)throw Error('"to" is required');let d=String(a.subject||"").trim();if(!d)throw Error('"subject" is required');if(!a.text&&!a.html)throw Error('Either "text" or "html" body content is required');let e=function(a){let b=String(a||"").trim(),c=b.lastIndexOf("@");return c<0?null:b.slice(c+1).toLowerCase().trim()}(c);if(!e)throw Error(`"to" must be a valid email address containing "@"; got: ${c}`);let g=a.recipient_domain?String(a.recipient_domain).toLowerCase().trim():null;if(!g)throw Error(`"recipient_domain" is required and must be set to "${e}" (the domain of the "to" address). Retry with: { ..., recipient_domain: "${e}" }`);if(g!==e)throw Error(`"recipient_domain" mismatch: declared "${g}" but "to" address "${c}" has domain "${e}". Set recipient_domain: "${e}" and retry.`);let l=i("RESEND_API_KEY",b),n=b.agent_id??null,o=a.from?String(a.from).trim():null;if(o||(o=h("RESEND_FROM_EMAIL",b)),!o)throw Error('Sender address not configured. Set RESEND_FROM_EMAIL via the secrets vault or pass "from" explicitly in the input. Resend\'s test sender (onboarding@resend.dev) requires a verified account.');let p={from:o,to:c,subject:d,...a.text?{text:String(a.text)}:{},...a.html?{html:String(a.html)}:{},...a.reply_to?{reply_to:String(a.reply_to)}:{}},q=(0,f.N)("email_send",n),r=await q(`${m}/emails`,{method:"POST",headers:{Authorization:`Bearer ${l}`,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(p)});if(!r.ok){let a=await j(r);throw Error(`Resend API error (${r.status}): ${a}`)}let s=await r.json();return{ok:!0,id:s.id,to:c,recipient_domain:e}}async function l(a={},b={}){let c=String(a.email_id||"").trim();if(!c)throw Error('"email_id" is required');let d=i("RESEND_API_KEY",b),e=b.agent_id??null,g=(0,f.N)("email_status_lookup",e),h=await g(`${m}/emails/${encodeURIComponent(c)}`,{headers:{Authorization:`Bearer ${d}`,Accept:"application/json"}});if(!h.ok){let a=await j(h);throw Error(`Resend API error (${h.status}): ${a}`)}let k=await h.json();return{id:k.id,to:k.to,from:k.from,subject:k.subject,last_event:k.last_event,created_at:k.created_at}}d()}catch(a){d(a)}})},69722:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{zc:()=>j});var e=c(34255),f=c(18530),g=c(69143),h=c(4249),i=a([e]);e=(i.then?(await i)():i)[0];let k={"vendor-onboarding":f,"contract-review":g,"support-escalation":h},l=[{slug:"vendor-onboarding",title:"Vendor Onboarding",category:"procurement",tags:["workflow","procurement","starter"],risk_summary:"Intake → automated risk review → buyer sign-off → onboarding pack. All write actions are gated by human_approval."},{slug:"contract-review",title:"Contract Review",category:"legal",tags:["workflow","legal","starter"],risk_summary:"Intake → automated clause review → counsel approval (high-risk gate) → review report. Drafts only; no signature step."},{slug:"support-escalation",title:"Support Escalation",category:"support",tags:["workflow","support","starter"],risk_summary:"Intake → automated triage → supervisor sign-off → resolution pack. Customer-visible copy never sent without human approval."}].map(a=>{let b=k[a.slug];return{...a,description:b.description,author:"madarx",source_kind:"builtin",source_url:null,version:"1.0",spec:b}});function j(a){try{for(let b of l)!function(a,b){let c=`workflow:${b.slug}`,d=JSON.stringify({summary:b.description,source_spec_json:b.spec}),f=JSON.stringify(b.tags||[]),g=a.prepare("SELECT id FROM marketplace_items WHERE kind='workflow' AND slug=?").get(b.slug),h=[b.title,b.description,b.category,b.author,b.source_kind,b.source_url,b.version,d,b.risk_summary,f];if(g)return a.prepare("UPDATE marketplace_items SET title=?, description=?, category=?, author=?, source_kind=?, source_url=?, version=?, manifest_json=?, risk_summary=?, tags=? WHERE id=?").run(...h,c);a.prepare("INSERT INTO marketplace_items (id, kind, slug, title, description, category, author, source_kind, source_url, version, manifest_json, risk_summary, tags, created_at) VALUES (?, 'workflow', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)").run(c,b.slug,...h,(0,e.nowIso)()),a.prepare("INSERT OR IGNORE INTO marketplace_installations (item_id, installed) VALUES (?, 0)").run(c)}(a,b)}catch(a){console.warn("[marketplace-workflows] seed failed:",a?.message||a)}}l.map(a=>a.slug),d()}catch(a){d(a)}})},70845:(a,b,c)=>{"use strict";c.d(b,{H:()=>f});var d=c(14972);function e(a,b,c){var e;let f=(0,d.uX)(b);return{label:a,value_usd:f.in_situ_value_usd,delta_pct:(e=f.in_situ_value_usd,null==e||null==c||0===c?null:Math.round((e-c)/c*1e4)/100),assumptions:b}}function f(a={},b={}){let c=(0,d.uX)(a),g=c.in_situ_value_usd,h=Number(b.grade_std_au_gpt??a.grade_std_au_gpt??0)||0,i=Number(b.grade_std_cu_pct??a.grade_std_cu_pct??0)||0,j=Number(b.grade_std_ag_gpt??a.grade_std_ag_gpt??0)||0,k=[["-20%",.8],["-10%",.9],["base",1],["+10%",1.1],["+20%",1.2]].map(([b,c])=>e(b,{...{...a},price_au_usd_oz:null==a.price_au_usd_oz?a.price_au_usd_oz:a.price_au_usd_oz*c,price_ag_usd_oz:null==a.price_ag_usd_oz?a.price_ag_usd_oz:a.price_ag_usd_oz*c,price_cu_usd_lb:null==a.price_cu_usd_lb?a.price_cu_usd_lb:a.price_cu_usd_lb*c},g)),l=[["-2σ",-2],["-1σ",-1],["base",0],["+1σ",1],["+2σ",2]].map(([b,c])=>e(b,{...{...a},grade_au_gpt:null==a.grade_au_gpt?a.grade_au_gpt:Math.max(0,a.grade_au_gpt+c*h),grade_ag_gpt:null==a.grade_ag_gpt?a.grade_ag_gpt:Math.max(0,a.grade_ag_gpt+c*j),grade_cu_pct:null==a.grade_cu_pct?a.grade_cu_pct:Math.max(0,a.grade_cu_pct+c*i)},g)),m=[["-20%",.8],["-10%",.9],["base",1],["+10%",1.1],["+20%",1.2]].map(([b,c])=>e(b,{...{...a},recovery_au:null==a.recovery_au?a.recovery_au:Math.min(1,Math.max(0,a.recovery_au*c)),recovery_ag:null==a.recovery_ag?a.recovery_ag:Math.min(1,Math.max(0,a.recovery_ag*c)),recovery_cu:null==a.recovery_cu?a.recovery_cu:Math.min(1,Math.max(0,a.recovery_cu*c))},g)),n=[["-20%",.8],["-10%",.9],["base",1],["+10%",1.1],["+20%",1.2]].map(([b,c])=>e(b,{...{...a},in_situ_factor:null==a.in_situ_factor?a.in_situ_factor:a.in_situ_factor*c},g));return{base_value_usd:g,base_result:c,drivers:{commodity_price:k,grade:l,recovery:m,in_situ_factor:n}}}},70952:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{f:()=>n});var e=c(34255),f=c(44986),g=c(69102),h=c(14207),i=a([e,h]);[e,h]=i.then?(await i)():i;let o=Number(process.env.MINES_CHUNK_TOKENS)||600,p=Number(process.env.MINES_CHUNK_OVERLAP_TOKENS)||100;async function j(a){try{switch(a){case"pdf-parse":return await import("pdf-parse");case"mammoth":return await import("mammoth");case"officeparser":return await import("officeparser");default:return null}}catch{return null}}function k(a){return Math.ceil(String(a||"").length/4)}let q=["de","la","el","que","en","los","para","con","del","una","por","se","su"],r=["the","of","and","to","in","for","is","that","with","from","this","are"];function l(a){let b=String(a||"").toLowerCase().split(/[^a-záéíóúñ]+/i).filter(Boolean).slice(0,400);if(b.length<5)return"es";let c=0,d=0;for(let a of b)q.includes(a)&&c++,r.includes(a)&&d++;return d>1.2*c?"en":"es"}async function m(a,b,c,d){if("pdf"===b){let b=await j("pdf-parse"),e="function"==typeof b?b:"function"==typeof b?.default?b.default:null,f=b?.PDFParse||b?.default?.PDFParse||null;if(!e&&!f)return{available:!1,error:"parser_unavailable:pdf",pages:[]};let h=d.readDocument(a),i="",k=1,l=null;try{if(f){let a=new f({data:h}),b=await a.getText();try{a.destroy?.()}catch{}i=String(b?.text||""),k=Number(b?.total)||(Array.isArray(b?.pages)?b.pages.length:1)||1,Array.isArray(b?.pages)&&(l=b.pages.map((a,b)=>({page:Number(a?.num??a?.page??b+1),text:String(a?.text||"")})))}else{let a=await e(h);i=String(a?.text||""),k=Number(a?.numpages)||1}}catch(a){return{available:!0,error:"parse_error:"+(a?.message||"pdf"),pages:[]}}let m=i.length/k;if(c||(0,g.tj)(i,m)){let b=await (0,g.rU)(a);return b.available?{available:!0,isScanned:!0,ocrApplied:!0,pageCount:b.pages.length||k,pages:b.pages.map(a=>({page:a.page,text:a.text}))}:{available:!0,isScanned:!0,ocrApplied:!1,ocrSkipped:!0,pageCount:k,pages:[]}}if(l)return{available:!0,isScanned:!1,ocrApplied:!1,pageCount:k,pages:l};let n=i.includes("\f")?i.split("\f"):[i];return{available:!0,isScanned:!1,ocrApplied:!1,pageCount:k,pages:n.map((a,b)=>({page:b+1,text:a}))}}if("docx"===b){let b=await j("mammoth"),c=b?.extractRawText||b?.default?.extractRawText;if("function"!=typeof c)return{available:!1,error:"parser_unavailable:docx",pages:[]};try{let b=await c({path:a});return{available:!0,isScanned:!1,ocrApplied:!1,pageCount:1,pages:[{page:1,text:b?.value||""}]}}catch(a){return{available:!0,error:"parse_error:"+(a?.message||"docx"),pages:[]}}}if("pptx"===b){let b=await j("officeparser"),c=b?.parseOfficeAsync||b?.default?.parseOfficeAsync||b?.parseOffice||b?.default?.parseOffice;if("function"!=typeof c)return{available:!1,error:"parser_unavailable:pptx",pages:[]};try{let b=await c(a);return{available:!0,isScanned:!1,ocrApplied:!1,pageCount:1,pages:[{page:1,text:String(b||"")}]}}catch(a){return{available:!0,error:"parse_error:"+(a?.message||"pptx"),pages:[]}}}return{available:!1,error:"unsupported_file_type:"+b,pages:[]}}async function n(a,b={}){let c=a?.source_document_id;if(!c)return{status:"error",error:"source_document_id_required"};let d=(0,e.getDb)(),i=d.prepare("SELECT id, project_id, document_category, original_path, file_type FROM mines_source_documents WHERE id = ?").get(c);if(!i)return{status:"error",error:"source_document_not_found"};let j=d.prepare(`
3474
3480
  UPDATE mines_source_documents
3475
3481
  SET extraction_status = ?, extraction_error = ?, language = ?, is_scanned = ?,
3476
3482
  ocr_applied = ?, page_count = ?, avg_chars_per_page = ?, updated_at = ?
@@ -3493,14 +3499,14 @@ Next action: choose a specialized agent, create a local run folder, keep human-i
3493
3499
  SELECT COUNT(*) AS n,
3494
3500
  SUM(CASE WHEN au_ppm IS NOT NULL OR ag_ppm IS NOT NULL OR cu_pct IS NOT NULL THEN 1 ELSE 0 END) AS grade_n
3495
3501
  FROM mines_assay_samples WHERE project_id = ?
3496
- `).get(a)||{n:0,grade_n:0}).grade_n||0)>0,i=d.has("resource_estimate");d.has("reserve_estimate"),d.has("opex"),d.has("production_schedule");let j=h.filter(a=>!d.has(a)),k=0===j.length,l=i||f,m=String(c.asset_stage||"").toLowerCase(),n=m.includes("exploration")||m.includes("prospect")||m.includes("early");if("t1_in_situ"===b.force_tier)return{status:"ok",project_id:a,tier:"t1_in_situ",t1_ready:l,t2_ready:k,t2_blocked:!0,blocking_inputs_missing:j,t2_blocking_reason:j.length?`T2 DCF blocked: missing ${j.join(", ")}.`:"T1 was explicitly requested.",confidence:i?"moderate":"indicative",reason:"T1 in-situ valuation explicitly requested."};if(k&&!n)return{status:"ok",project_id:a,tier:"t2_dcf",t1_ready:l,t2_ready:!0,t2_blocked:!1,blocking_inputs_missing:[],t2_blocking_reason:null,confidence:"modelled",reason:"Reserve estimate, production schedule, and operating-cost facts are present; DCF is allowed."};let o="t2_dcf"===b.force_tier,p=[...new Set([...j,...k&&n?["asset_stage_not_dcf_ready"]:[]])];return{status:"ok",project_id:a,tier:"t1_in_situ",t1_ready:l,t2_ready:!1,t2_blocked:!0,blocking_inputs_missing:p,t2_blocking_reason:p.length?`T2 DCF blocked: missing or unsuitable inputs (${p.join(", ")}).`:"T2 DCF blocked by exploration-stage policy.",confidence:i?"moderate":"indicative",reason:o?"Forced T2 request was rejected because DCF prerequisites are incomplete or the asset stage is not DCF-ready; using T1 in-situ instead.":"Exploration/resource-stage projects use T1 in-situ until reserve, production schedule, and cost inputs are present."}}d()}catch(a){d(a)}})},72189:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{X:()=>t,Z6:()=>p,dd:()=>n,mr:()=>r,sq:()=>q,sv:()=>o,vO:()=>s});var e=c(73024),f=c(76760),g=c(60105),h=c(8437),i=c(26531),j=a([g,h]);[g,h]=j.then?(await j)():j;let u=new Set([".git","node_modules",".next","data"]);function k(a,b,c={}){(0,g.appendAudit)({type:`local.${a}`,summary:`${a} ${b}`,status:b,meta:c})}function l(a,b,c){return(0,h.D6)({action_type:a,risk:"medium",summary:`${a} requested for ${c}`,payload:{input:{...b,content:b.content?`[${String(b.content).length} chars]`:void 0},path:c}})}function m(a){return b=>b.path===a}async function n(a={}){let{path:b}=(0,i.hC)(a.path),c=Number(process.env.MADARX_FILE_READ_MAX_BYTES||1e5),d=e.statSync(b);if(!d.isFile())throw Error("Path is not a file");if(d.size>c)throw Error(`File too large: ${d.size} bytes`);let f=e.readFileSync(b,"utf8").split(/\r?\n/),g=Math.max(1,Number(a.offset||1)),h=Math.max(1,Math.min(2e3,Number(a.limit||500))),j=f.slice(g-1,g-1+h).join("\n");return k("file_read","complete",{path:b,bytes:Buffer.byteLength(j)}),{ok:!0,tool:"file_read",path:b,content:(0,i.nc)(j),metadata:{line_count:f.length,offset:g,limit:h}}}async function o(a={}){let{path:b}=(0,i.hC)(a.path||"."),c=Math.max(1,Math.min(500,Number(a.limit||100))),d=[];for(let a of e.readdirSync(b,{withFileTypes:!0})){if(d.length>=c)break;try{(0,i.hC)(f.join(b,a.name))}catch{continue}u.has(a.name)||d.push({name:a.name,type:a.isDirectory()?"directory":a.isFile()?"file":"other"})}return k("directory_list","complete",{path:b,count:d.length}),{ok:!0,tool:"directory_list",path:b,entries:d,metadata:{count:d.length}}}function p(a={}){let{path:b}=(0,i.hC)(a.path);if((0,i.Oe)(b))throw Error(`Write access denied: path is under a read-only root: ${a.path}`);return{absPath:b}}async function q(a={},b={}){let{absPath:c}=p(a);if(!b.owner_trusted&&!(0,h.v)(a.approval_id,{action_type:"file_write",matches:m(c)})){let b=l("file_write",a,c);return{ok:!1,status:"approval_required",approval_request_id:b.id,reason:"File writes require approval"}}return!1!==a.create_dirs&&e.mkdirSync(f.dirname(c),{recursive:!0}),e.writeFileSync(c,String(a.content??""),"utf8"),k("file_write","complete",{path:c}),{ok:!0,tool:"file_write",path:c,metadata:{bytes:Buffer.byteLength(String(a.content??""))}}}function r(a={}){let{path:b}=(0,i.hC)(a.path);if((0,i.Oe)(b))throw Error(`Write access denied: path is under a read-only root: ${a.path}`);let c=String(a.old_string??"");if(!c)throw Error("old_string is required");let d=e.readFileSync(b,"utf8"),f=d.split(c).length-1;if(!f)throw Error("old_string not found");if(f>1&&!a.replace_all)throw Error("old_string is ambiguous");return{absPath:b,content:d,matches:f,oldString:c}}async function s(a={},b={}){let{absPath:c,content:d,matches:f,oldString:g}=r(a),i=String(a.new_string??"");if(!b.owner_trusted&&!(0,h.v)(a.approval_id,{action_type:"file_patch",matches:m(c)})){let b=l("file_patch",{...a,new_string:`[${i.length} chars]`},c);return{ok:!1,status:"approval_required",approval_request_id:b.id,reason:"File patches require approval"}}return e.writeFileSync(c,a.replace_all?d.split(g).join(i):d.replace(g,i),"utf8"),k("file_patch","complete",{path:c,replacements:a.replace_all?f:1}),{ok:!0,tool:"file_patch",path:c,metadata:{replacements:a.replace_all?f:1}}}async function t(a={}){let{path:b}=(0,i.hC)(a.path||"."),c=String(a.pattern||"");if(!c)throw Error("pattern is required");let d=Math.max(1,Math.min(200,Number(a.limit||50))),g=RegExp(c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"i"),h=a.target||"content",j=a.file_glob?String(a.file_glob):null,l=j?RegExp("^"+j.split("*").map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*")+"$","i"):null,m=[];for(let a of function a(b,c=[],d=1e3){if(c.length>=d)return c;for(let g of e.readdirSync(b,{withFileTypes:!0})){if(u.has(g.name))continue;let e=f.join(b,g.name);if(g.isDirectory()?a(e,c,d):g.isFile()&&c.push(e),c.length>=d)break}return c}(b,[],5e3)){if(m.length>=d)break;try{(0,i.hC)(a)}catch{continue}if(!l||l.test(f.basename(a))){if("path"===h||"name"===h){g.test("name"===h?f.basename(a):a)&&m.push({path:a});continue}e.statSync(a).size>25e4||/\.sqlite/.test(a)||/^\.env/.test(f.basename(a))||e.readFileSync(a,"utf8").split(/\r?\n/).forEach((b,c)=>{m.length<d&&g.test(b)&&m.push({path:a,line:c+1,text:(0,i.nc)(b)})})}}return k("file_search","complete",{path:b,count:m.length}),{ok:!0,tool:"file_search",path:b,results:m,metadata:{count:m.length}}}d()}catch(a){d(a)}})},72326:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{let E;c.d(b,{$k:()=>o,GK:()=>q,Iu:()=>A,M2:()=>z,No:()=>w,Qp:()=>p,Ys:()=>t,bD:()=>y,d:()=>D});var e=c(76760),f=c(73024),g=c(48161),h=c(31421),i=c(73136),j=c(19151),k=c(9001),l=c(9381),m=c(51867),n=a([j,k]);[j,k]=n.then?(await n)():n;let F=e.resolve(e.dirname((0,i.fileURLToPath)("file:///home/runner/work/madarx-os/madarx-os/lib/agent-engines.js")),".."),G=process.env.OLLAMA_BASE_URL||"http://127.0.0.1:11434",H=[{id:"anthropic",label:"Anthropic API",description:"Server-native Claude Messages API brain with madarX governed tool_use.",default_model:"claude-sonnet-4-6",mode:"api"},{id:"claude-code",label:"Claude Code CLI",description:"Local Claude Code runner for developer/repo agents using the authenticated CLI.",default_model:"sonnet",mode:"local-cli"},{id:"ollama",label:"Ollama Local LLM",description:"Local or Ollama-hosted models through the Ollama chat API.",default_model:process.env.OLLAMA_MODEL||"",mode:"local-llm"},{id:"hermes",label:"Hermes",description:"Hermes as a meta-agent/router. Available through governed Hermes job tools.",default_model:"",mode:"orchestrator"},{id:"codex",label:"Codex CLI",description:"Local Codex CLI coding runner. Available through approval-gated terminal/tool workflows.",default_model:"",mode:"local-cli"}];function o(a){let b=String(a||"").trim().toLowerCase();return b?["anthropic","anthropic-api","claude-api","api"].includes(b)?"anthropic":["claude-code","claude code","claude_cli","claude-cli"].includes(b)?"claude-code":b.includes("hermes")&&b.includes("claude code")?"anthropic":["ollama","local","local-llm","local llm"].includes(b)?"ollama":["hermes","hermes-agent"].includes(b)?"hermes":["codex","codex-cli","openai-codex"].includes(b)?"codex":b:"claude-code"}function p(a){let b=o(a);return H.find(a=>a.id===b)?.default_model||""}async function q(a){let b=o(a);if("anthropic"===b){let{resolveAnthropicApiKey:a}=await Promise.resolve().then(c.bind(c,65451));if(!a()){let a=Error("The Anthropic API engine is selected but no API key is configured. Add ANTHROPIC_API_KEY to the secrets vault or .env.local, or switch to the Claude Code CLI engine.");throw a.code="engine_unavailable",a.engine=b,a}return!0}if("claude-code"===b){if(process.env.MADARX_MOCK_CLAUDE_CODE_RESPONSE)return!0;if(!await t("claude")){let a=Error("The Claude Code CLI engine is selected but the `claude` binary is not installed or not on PATH. Install Claude Code and sign in, or switch to the Anthropic API engine.");throw a.code="engine_unavailable",a.engine=b,a}return!0}if("codex"===b){if(process.env.MADARX_MOCK_CODEX_RESPONSE)return!0;if(!await t("codex")){let a=Error("The Codex CLI engine is selected but the `codex` binary is not installed or not on PATH.");throw a.code="engine_unavailable",a.engine=b,a}}return!0}let I=new Map;function r(a){if(I.has(a))return I.get(a);for(let b of[process.env[`MADARX_${a.toUpperCase()}_BIN`],e.join(g.homedir(),".local","bin",a),`/opt/homebrew/bin/${a}`,`/usr/local/bin/${a}`,e.join(g.homedir(),".npm-global","bin",a)].filter(Boolean))try{return f.accessSync(b,f.constants.X_OK),I.set(a,b),b}catch{}return null}function s(a){return I.get(a)||r(a)||a}async function t(a){return!!r(a)||new Promise(b=>{let c=(0,h.spawn)("sh",["-lc",`command -v ${a}`],{shell:!1}),d="";c.stdout.on("data",a=>{d+=a.toString()}),c.on("error",()=>b(!1)),c.on("close",c=>{let f=0===c?d.trim().split("\n").pop()?.trim():"";f&&e.isAbsolute(f)&&I.set(a,f),b(0===c)})})}async function u(){return!process.env.MADARX_MOCK_CLAUDE_CODE_RESPONSE&&("1"===process.env.MADARX_CC_FORCE_PARTIAL||"0"!==process.env.MADARX_CC_FORCE_PARTIAL&&(void 0!==E?E:E=await new Promise(a=>{try{let b=(0,h.spawn)(s("claude"),["--help"],{shell:!1}),c="";b.stdout.on("data",a=>{c+=a.toString()}),b.stderr.on("data",a=>{c+=a.toString()}),b.on("error",()=>a(!1)),b.on("close",()=>a(c.includes("include-partial-messages")))}catch{a(!1)}})))}async function v(){try{let a=await fetch(`${G}/api/tags`,{signal:AbortSignal.timeout(1500)});if(!a.ok)return[];return((await a.json()).models||[]).map(a=>({name:a.name||a.model,model:a.model||a.name,size:a.size||0,details:a.details||{},local:!a.remote_host,remote_host:a.remote_host||null})).filter(a=>a.name)}catch{return[]}}async function w(){let[a,b,c]=await Promise.all([v(),t("claude"),t("codex")]),d=process.env.OLLAMA_MODEL||(process.env.MADARX_MOCK_OLLAMA_RESPONSE?"qwen3.5:latest":""),e=a[0]?.name||d;return H.map(f=>({...f,default_model:"ollama"===f.id?e:f.default_model,available:"claude-code"===f.id?b:"codex"===f.id?c:"ollama"!==f.id||!!(a.length||process.env.MADARX_MOCK_OLLAMA_RESPONSE),models:"ollama"===f.id?a.length?a:d?[{name:d,model:d,local:!0,fallback:!0}]:[]:f.default_model?[{name:f.default_model,model:f.default_model}]:[]}))}function x(a,b,{cwd:c=process.cwd(),timeoutMs:d=12e4,closeStdin:e=!1,onChunk:f,env:g}={}){return new Promise((i,j)=>{let k=(0,h.spawn)(a,b,{shell:!1,cwd:c,env:g??{...process.env}});e&&k.stdin.end();let l="",m="",n=setTimeout(()=>{k.kill("SIGTERM"),j(Error(`${a} timed out after ${d}ms`))},d);k.stdout.on("data",a=>{let b=a.toString();l+=b,f?.(b)}),k.stderr.on("data",a=>{m+=a.toString()}),k.on("error",a=>{clearTimeout(n),j(a)}),k.on("close",b=>{if(clearTimeout(n),0===b||1===b&&l.trim())return void i(l.trim());j(Error(`${a} exited ${b}: ${m.trim()||l.trim()}`))})})}async function y({model:a,systemPrompt:b,userMessage:c,maxTokens:d=2048,onChunk:e,onThinking:f}={}){if(process.env.MADARX_MOCK_OLLAMA_RESPONSE)return process.env.MADARX_MOCK_OLLAMA_RESPONSE;let g=!!(e||f),h=g&&(0,m.Zf)()&&"1"===process.env.MADARX_OLLAMA_THINK,i={model:a||process.env.OLLAMA_MODEL,stream:g,options:{num_predict:d},messages:[{role:"system",content:b},{role:"user",content:c}]};h&&(i.think=!0);let j=await fetch(`${G}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!j.ok)throw Error(`Ollama chat failed: HTTP ${j.status}`);if(!g){let a=await j.json(),b=a.message?.content||a.response||"";if(!b.trim())throw Error("Ollama returned no text");return b.trim()}let k="",l="",n=j.body.getReader(),o=new TextDecoder,p="";for(;;){let a,{done:b,value:c}=await n.read();if(b)break;for(p+=o.decode(c,{stream:!0});(a=p.indexOf("\n"))>=0;){let b,c=p.slice(0,a).trim();if(p=p.slice(a+1),!c)continue;try{b=JSON.parse(c)}catch{continue}let d=b.message?.content||b.response||"",g=b.message?.thinking||"";d&&(k+=d,e?.(d,k)),g&&(l+=g,f?.(l,g))}}if(!k.trim())throw Error("Ollama returned no text");return k.trim()}async function z({model:a,systemPrompt:b,userMessage:c,maxTurns:d,allowedTools:e=[],timeoutMs:f,onChunk:g,onAssistantText:h,onThinking:i,onStatus:j,onToolStart:l,onToolResult:n,cwd:o,addDirs:p=[],agentId:q,agentName:r,verbosity:t}={}){if(process.env.MADARX_MOCK_CLAUDE_CODE_RESPONSE)return process.env.MADARX_MOCK_CLAUDE_CODE_RESPONSE;let v=`${b}
3502
+ `).get(a)||{n:0,grade_n:0}).grade_n||0)>0,i=d.has("resource_estimate");d.has("reserve_estimate"),d.has("opex"),d.has("production_schedule");let j=h.filter(a=>!d.has(a)),k=0===j.length,l=i||f,m=String(c.asset_stage||"").toLowerCase(),n=m.includes("exploration")||m.includes("prospect")||m.includes("early");if("t1_in_situ"===b.force_tier)return{status:"ok",project_id:a,tier:"t1_in_situ",t1_ready:l,t2_ready:k,t2_blocked:!0,blocking_inputs_missing:j,t2_blocking_reason:j.length?`T2 DCF blocked: missing ${j.join(", ")}.`:"T1 was explicitly requested.",confidence:i?"moderate":"indicative",reason:"T1 in-situ valuation explicitly requested."};if(k&&!n)return{status:"ok",project_id:a,tier:"t2_dcf",t1_ready:l,t2_ready:!0,t2_blocked:!1,blocking_inputs_missing:[],t2_blocking_reason:null,confidence:"modelled",reason:"Reserve estimate, production schedule, and operating-cost facts are present; DCF is allowed."};let o="t2_dcf"===b.force_tier,p=[...new Set([...j,...k&&n?["asset_stage_not_dcf_ready"]:[]])];return{status:"ok",project_id:a,tier:"t1_in_situ",t1_ready:l,t2_ready:!1,t2_blocked:!0,blocking_inputs_missing:p,t2_blocking_reason:p.length?`T2 DCF blocked: missing or unsuitable inputs (${p.join(", ")}).`:"T2 DCF blocked by exploration-stage policy.",confidence:i?"moderate":"indicative",reason:o?"Forced T2 request was rejected because DCF prerequisites are incomplete or the asset stage is not DCF-ready; using T1 in-situ instead.":"Exploration/resource-stage projects use T1 in-situ until reserve, production schedule, and cost inputs are present."}}d()}catch(a){d(a)}})},72189:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{X:()=>t,Z6:()=>p,dd:()=>n,mr:()=>r,sq:()=>q,sv:()=>o,vO:()=>s});var e=c(73024),f=c(76760),g=c(60105),h=c(8437),i=c(26531),j=a([g,h]);[g,h]=j.then?(await j)():j;let u=new Set([".git","node_modules",".next","data"]);function k(a,b,c={}){(0,g.appendAudit)({type:`local.${a}`,summary:`${a} ${b}`,status:b,meta:c})}function l(a,b,c){return(0,h.D6)({action_type:a,risk:"medium",summary:`${a} requested for ${c}`,payload:{input:{...b,content:b.content?`[${String(b.content).length} chars]`:void 0},path:c}})}function m(a){return b=>b.path===a}async function n(a={}){let{path:b}=(0,i.hC)(a.path),c=Number(process.env.MADARX_FILE_READ_MAX_BYTES||1e5),d=e.statSync(b);if(!d.isFile())throw Error("Path is not a file");if(d.size>c)throw Error(`File too large: ${d.size} bytes`);let f=e.readFileSync(b,"utf8").split(/\r?\n/),g=Math.max(1,Number(a.offset||1)),h=Math.max(1,Math.min(2e3,Number(a.limit||500))),j=f.slice(g-1,g-1+h).join("\n");return k("file_read","complete",{path:b,bytes:Buffer.byteLength(j)}),{ok:!0,tool:"file_read",path:b,content:(0,i.nc)(j),metadata:{line_count:f.length,offset:g,limit:h}}}async function o(a={}){let{path:b}=(0,i.hC)(a.path||"."),c=Math.max(1,Math.min(500,Number(a.limit||100))),d=[];for(let a of e.readdirSync(b,{withFileTypes:!0})){if(d.length>=c)break;try{(0,i.hC)(f.join(b,a.name))}catch{continue}u.has(a.name)||d.push({name:a.name,type:a.isDirectory()?"directory":a.isFile()?"file":"other"})}return k("directory_list","complete",{path:b,count:d.length}),{ok:!0,tool:"directory_list",path:b,entries:d,metadata:{count:d.length}}}function p(a={}){let{path:b}=(0,i.hC)(a.path);if((0,i.Oe)(b))throw Error(`Write access denied: path is under a read-only root: ${a.path}`);return{absPath:b}}async function q(a={},b={}){let{absPath:c}=p(a);if(!b.owner_trusted&&!(0,h.v)(a.approval_id,{action_type:"file_write",matches:m(c)})){let b=l("file_write",a,c);return{ok:!1,status:"approval_required",approval_request_id:b.id,reason:"File writes require approval"}}return!1!==a.create_dirs&&e.mkdirSync(f.dirname(c),{recursive:!0}),e.writeFileSync(c,String(a.content??""),"utf8"),k("file_write","complete",{path:c}),{ok:!0,tool:"file_write",path:c,metadata:{bytes:Buffer.byteLength(String(a.content??""))}}}function r(a={}){let{path:b}=(0,i.hC)(a.path);if((0,i.Oe)(b))throw Error(`Write access denied: path is under a read-only root: ${a.path}`);let c=String(a.old_string??"");if(!c)throw Error("old_string is required");let d=e.readFileSync(b,"utf8"),f=d.split(c).length-1;if(!f)throw Error("old_string not found");if(f>1&&!a.replace_all)throw Error("old_string is ambiguous");return{absPath:b,content:d,matches:f,oldString:c}}async function s(a={},b={}){let{absPath:c,content:d,matches:f,oldString:g}=r(a),i=String(a.new_string??"");if(!b.owner_trusted&&!(0,h.v)(a.approval_id,{action_type:"file_patch",matches:m(c)})){let b=l("file_patch",{...a,new_string:`[${i.length} chars]`},c);return{ok:!1,status:"approval_required",approval_request_id:b.id,reason:"File patches require approval"}}return e.writeFileSync(c,a.replace_all?d.split(g).join(i):d.replace(g,i),"utf8"),k("file_patch","complete",{path:c,replacements:a.replace_all?f:1}),{ok:!0,tool:"file_patch",path:c,metadata:{replacements:a.replace_all?f:1}}}async function t(a={}){let{path:b}=(0,i.hC)(a.path||"."),c=String(a.pattern||"");if(!c)throw Error("pattern is required");let d=Math.max(1,Math.min(200,Number(a.limit||50))),g=RegExp(c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"i"),h=a.target||"content",j=a.file_glob?String(a.file_glob):null,l=j?RegExp("^"+j.split("*").map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*")+"$","i"):null,m=[];for(let a of function a(b,c=[],d=1e3){if(c.length>=d)return c;for(let g of e.readdirSync(b,{withFileTypes:!0})){if(u.has(g.name))continue;let e=f.join(b,g.name);if(g.isDirectory()?a(e,c,d):g.isFile()&&c.push(e),c.length>=d)break}return c}(b,[],5e3)){if(m.length>=d)break;try{(0,i.hC)(a)}catch{continue}if(!l||l.test(f.basename(a))){if("path"===h||"name"===h){g.test("name"===h?f.basename(a):a)&&m.push({path:a});continue}e.statSync(a).size>25e4||/\.sqlite/.test(a)||/^\.env/.test(f.basename(a))||e.readFileSync(a,"utf8").split(/\r?\n/).forEach((b,c)=>{m.length<d&&g.test(b)&&m.push({path:a,line:c+1,text:(0,i.nc)(b)})})}}return k("file_search","complete",{path:b,count:m.length}),{ok:!0,tool:"file_search",path:b,results:m,metadata:{count:m.length}}}d()}catch(a){d(a)}})},72326:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{let F;c.d(b,{$k:()=>o,GK:()=>q,Iu:()=>A,M2:()=>z,No:()=>w,Qp:()=>p,Ys:()=>t,bD:()=>y,d:()=>E,vB:()=>D});var e=c(76760),f=c(73024),g=c(48161),h=c(31421),i=c(73136),j=c(19151),k=c(9001),l=c(9381),m=c(51867),n=a([j,k]);[j,k]=n.then?(await n)():n;let G=e.resolve(e.dirname((0,i.fileURLToPath)("file:///home/runner/work/madarx-os/madarx-os/lib/agent-engines.js")),".."),H=process.env.OLLAMA_BASE_URL||"http://127.0.0.1:11434",I=[{id:"anthropic",label:"Anthropic API",description:"Server-native Claude Messages API brain with madarX governed tool_use.",default_model:"claude-sonnet-4-6",mode:"api"},{id:"claude-code",label:"Claude Code CLI",description:"Local Claude Code runner for developer/repo agents using the authenticated CLI.",default_model:"sonnet",mode:"local-cli"},{id:"ollama",label:"Ollama Local LLM",description:"Local or Ollama-hosted models through the Ollama chat API.",default_model:process.env.OLLAMA_MODEL||"",mode:"local-llm"},{id:"hermes",label:"Hermes",description:"Hermes as a meta-agent/router. Available through governed Hermes job tools.",default_model:"",mode:"orchestrator"},{id:"codex",label:"Codex CLI",description:"Local Codex CLI coding runner. Available through approval-gated terminal/tool workflows.",default_model:"",mode:"local-cli"}];function o(a){let b=String(a||"").trim().toLowerCase();return b?["anthropic","anthropic-api","claude-api","api"].includes(b)?"anthropic":["claude-code","claude code","claude_cli","claude-cli"].includes(b)?"claude-code":b.includes("hermes")&&b.includes("claude code")?"anthropic":["ollama","local","local-llm","local llm"].includes(b)?"ollama":["hermes","hermes-agent"].includes(b)?"hermes":["codex","codex-cli","openai-codex"].includes(b)?"codex":b:"claude-code"}function p(a){let b=o(a);return I.find(a=>a.id===b)?.default_model||""}async function q(a){let b=o(a);if("anthropic"===b){let{resolveAnthropicApiKey:a}=await Promise.resolve().then(c.bind(c,65451));if(!a()){let a=Error("The Anthropic API engine is selected but no API key is configured. Add ANTHROPIC_API_KEY to the secrets vault or .env.local, or switch to the Claude Code CLI engine.");throw a.code="engine_unavailable",a.engine=b,a}return!0}if("claude-code"===b){if(process.env.MADARX_MOCK_CLAUDE_CODE_RESPONSE)return!0;if(!await t("claude")){let a=Error("The Claude Code CLI engine is selected but the `claude` binary is not installed or not on PATH. Install Claude Code and sign in, or switch to the Anthropic API engine.");throw a.code="engine_unavailable",a.engine=b,a}return!0}if("codex"===b){if(process.env.MADARX_MOCK_CODEX_RESPONSE)return!0;if(!await t("codex")){let a=Error("The Codex CLI engine is selected but the `codex` binary is not installed or not on PATH.");throw a.code="engine_unavailable",a.engine=b,a}}return!0}let J=new Map;function r(a){if(J.has(a))return J.get(a);for(let b of[process.env[`MADARX_${a.toUpperCase()}_BIN`],e.join(g.homedir(),".local","bin",a),`/opt/homebrew/bin/${a}`,`/usr/local/bin/${a}`,e.join(g.homedir(),".npm-global","bin",a)].filter(Boolean))try{return f.accessSync(b,f.constants.X_OK),J.set(a,b),b}catch{}return null}function s(a){return J.get(a)||r(a)||a}async function t(a){return!!r(a)||new Promise(b=>{let c=(0,h.spawn)("sh",["-lc",`command -v ${a}`],{shell:!1}),d="";c.stdout.on("data",a=>{d+=a.toString()}),c.on("error",()=>b(!1)),c.on("close",c=>{let f=0===c?d.trim().split("\n").pop()?.trim():"";f&&e.isAbsolute(f)&&J.set(a,f),b(0===c)})})}async function u(){return!process.env.MADARX_MOCK_CLAUDE_CODE_RESPONSE&&("1"===process.env.MADARX_CC_FORCE_PARTIAL||"0"!==process.env.MADARX_CC_FORCE_PARTIAL&&(void 0!==F?F:F=await new Promise(a=>{try{let b=(0,h.spawn)(s("claude"),["--help"],{shell:!1}),c="";b.stdout.on("data",a=>{c+=a.toString()}),b.stderr.on("data",a=>{c+=a.toString()}),b.on("error",()=>a(!1)),b.on("close",()=>a(c.includes("include-partial-messages")))}catch{a(!1)}})))}async function v(){try{let a=await fetch(`${H}/api/tags`,{signal:AbortSignal.timeout(1500)});if(!a.ok)return[];return((await a.json()).models||[]).map(a=>({name:a.name||a.model,model:a.model||a.name,size:a.size||0,details:a.details||{},local:!a.remote_host,remote_host:a.remote_host||null})).filter(a=>a.name)}catch{return[]}}async function w(){let[a,b,c]=await Promise.all([v(),t("claude"),t("codex")]),d=process.env.OLLAMA_MODEL||(process.env.MADARX_MOCK_OLLAMA_RESPONSE?"qwen3.5:latest":""),e=a[0]?.name||d;return I.map(f=>({...f,default_model:"ollama"===f.id?e:f.default_model,available:"claude-code"===f.id?b:"codex"===f.id?c:"ollama"!==f.id||!!(a.length||process.env.MADARX_MOCK_OLLAMA_RESPONSE),models:"ollama"===f.id?a.length?a:d?[{name:d,model:d,local:!0,fallback:!0}]:[]:f.default_model?[{name:f.default_model,model:f.default_model}]:[]}))}function x(a,b,{cwd:c=process.cwd(),timeoutMs:d=12e4,closeStdin:e=!1,onChunk:f,env:g}={}){return new Promise((i,j)=>{let k=(0,h.spawn)(a,b,{shell:!1,cwd:c,env:g??{...process.env}});e&&k.stdin.end();let l="",m="",n=setTimeout(()=>{k.kill("SIGTERM"),j(Error(`${a} timed out after ${d}ms`))},d);k.stdout.on("data",a=>{let b=a.toString();l+=b,f?.(b)}),k.stderr.on("data",a=>{m+=a.toString()}),k.on("error",a=>{clearTimeout(n),j(a)}),k.on("close",b=>{if(clearTimeout(n),0===b||1===b&&l.trim())return void i(l.trim());j(Error(`${a} exited ${b}: ${m.trim()||l.trim()}`))})})}async function y({model:a,systemPrompt:b,userMessage:c,maxTokens:d=2048,onChunk:e,onThinking:f}={}){if(process.env.MADARX_MOCK_OLLAMA_RESPONSE)return process.env.MADARX_MOCK_OLLAMA_RESPONSE;let g=!!(e||f),h=g&&(0,m.Zf)()&&"1"===process.env.MADARX_OLLAMA_THINK,i={model:a||process.env.OLLAMA_MODEL,stream:g,options:{num_predict:d},messages:[{role:"system",content:b},{role:"user",content:c}]};h&&(i.think=!0);let j=await fetch(`${H}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!j.ok)throw Error(`Ollama chat failed: HTTP ${j.status}`);if(!g){let a=await j.json(),b=a.message?.content||a.response||"";if(!b.trim())throw Error("Ollama returned no text");return b.trim()}let k="",l="",n=j.body.getReader(),o=new TextDecoder,p="";for(;;){let a,{done:b,value:c}=await n.read();if(b)break;for(p+=o.decode(c,{stream:!0});(a=p.indexOf("\n"))>=0;){let b,c=p.slice(0,a).trim();if(p=p.slice(a+1),!c)continue;try{b=JSON.parse(c)}catch{continue}let d=b.message?.content||b.response||"",g=b.message?.thinking||"";d&&(k+=d,e?.(d,k)),g&&(l+=g,f?.(l,g))}}if(!k.trim())throw Error("Ollama returned no text");return k.trim()}async function z({model:a,systemPrompt:b,userMessage:c,maxTurns:d,allowedTools:e=[],timeoutMs:f,onChunk:g,onAssistantText:h,onThinking:i,onStatus:j,onToolStart:l,onToolResult:n,cwd:o,addDirs:p=[],agentId:q,agentName:r,verbosity:t}={}){if(process.env.MADARX_MOCK_CLAUDE_CODE_RESPONSE)return process.env.MADARX_MOCK_CLAUDE_CODE_RESPONSE;let v=`${b}
3497
3503
 
3498
3504
  ${c}`,w=Number(d||process.env.CLAUDE_CODE_MAX_TURNS||30),y=t||(0,m._e)(),A=(0,m.Zf)(y),B=A&&await u(),C=["-p",v,"--max-turns",String(w),"--output-format","stream-json","--verbose","--permission-mode","bypassPermissions","--setting-sources","project,local,user"];for(let a of(B&&C.push("--include-partial-messages"),p))a&&C.push("--add-dir",a);e.length&&C.push("--allowedTools",e.join(",")),a&&"claude-code"!==a&&C.splice(2,0,"--model",a);let D=function(){let a={...process.env};return"1"===process.env.MADARX_CLI_USE_API_KEY||(delete a.ANTHROPIC_API_KEY,delete a.ANTHROPIC_AUTH_TOKEN),a}();if(A){let a=(0,m.s_)(y);a>0&&(D.MAX_THINKING_TOKENS=String(Math.max(1024,a)))}let E=[],F=[],G="",H="",I="",J="",K=function({agentId:a,agentName:b,partial:c=!1,onText:d,onTextDelta:e,onThinkingDelta:f,onToolStart:g,onToolResult:h,onResult:i,onStatus:j}){let l="",m=new Map,n=new Map;return function(o){let p;for(l+=o;(p=l.indexOf("\n"))>=0;){let o,q=l.slice(0,p).trim();if(l=l.slice(p+1),!q||"{"!==q[0])continue;try{o=JSON.parse(q)}catch{continue}if(!o||"object"!=typeof o)continue;if("stream_event"===o.type&&o.event&&"object"==typeof o.event){let a=o.event;if("content_block_delta"===a.type&&a.delta){let b=a.delta;"text_delta"===b.type&&"string"==typeof b.text?e?.(b.text):"thinking_delta"===b.type&&"string"==typeof b.thinking&&f?.(b.thinking)}else"content_block_start"===a.type&&a.content_block?.type==="thinking"?j?.("thinking"):"message_start"===a.type&&j?.("generating");continue}if("result"===o.type){"string"==typeof o.result&&o.result.trim()&&i?.(o.result.trim());continue}let r=o.message?.content;if(Array.isArray(r)){if("assistant"===o.type){let e=r.some(a=>a?.type==="tool_use");if(!c)for(let a of r)a?.type==="thinking"&&"string"==typeof a.thinking&&a.thinking&&f?.(a.thinking);let h=r.filter(a=>a?.type==="text"&&"string"==typeof a.text).map(a=>a.text).join("");for(let c of(h&&d?.(h,{isFinal:!e}),r))c?.type==="tool_use"&&(c.id&&(m.set(c.id,c.name||"tool"),n.set(c.id,Date.now())),g?.({id:c.id,name:c.name||"tool",input:c.input}),a&&(0,k.AC)({type:"agent_tool_start",agent_id:a,agent_name:b||a,tool:c.name||"tool",input_summary:function(a,b){if(!b||"object"!=typeof b)return"";if("Bash"===a)return String(b.command||"").slice(0,120);if("WebSearch"===a)return String(b.query||"").slice(0,120);if("WebFetch"===a)return String(b.url||"").slice(0,120);if("Read"===a||"Glob"===a||"Grep"===a||"LS"===a)return String(b.file_path||b.pattern||b.path||"").slice(0,120);if("Write"===a||"Edit"===a||"MultiEdit"===a)return String(b.file_path||"").slice(0,120);if("TodoWrite"===a)return Array.isArray(b.todos)?`${b.todos.length} todos`:"";try{return JSON.stringify(b).slice(0,120)}catch{return""}}(c.name,c.input)}))}else if("user"===o.type){for(let c of r)if(c?.type==="tool_result"){let d=m.get(c.tool_use_id)||"tool",e=n.get(c.tool_use_id),f=e?Date.now()-e:null,{preview:g,chars:i,lines:j}=function(a){let b=a?.content,c="";return"string"==typeof b?c=b:Array.isArray(b)&&(c=b.map(a=>"string"==typeof a?a:a?.type==="text"&&"string"==typeof a.text?a.text:"").join("")),{preview:(c=String(c||"")).slice(0,200),chars:c.length,lines:c?c.split("\n").length:0}}(c);h?.({tool_use_id:c.tool_use_id,name:d,isError:!!c.is_error,durationMs:f,preview:g,chars:i,lines:j}),a&&(0,k.AC)({type:"agent_tool_result",agent_id:a,agent_name:b||a,tool:d,status:c.is_error?"error":"done",isError:!!c.is_error,duration_ms:f}),m.delete(c.tool_use_id),n.delete(c.tool_use_id)}}}}}}({agentId:q,agentName:r,partial:B,onText:(a,b={})=>{E.push(a),b.isFinal?F.push(a):G=a,B||h?.(E.join("").trim())},onTextDelta:a=>{I+=a,h?.(I.trim())},onThinkingDelta:a=>{J+=a,i?.(J.trim(),a)},onStatus:a=>{j?.(a)},onResult:a=>{H=a},onToolStart:l,onToolResult:n});await x(s("claude"),C,{cwd:o,timeoutMs:f??Number(process.env.CLAUDE_CODE_TICK_TIMEOUT_MS||6e5),closeStdin:!0,env:D,onChunk:a=>{K(a),g?.(a)}});let L=F.join("").trim()||G.trim()||E.join("").trim()||H.trim();if(!L)throw Error("Claude Code returned no assistant text");return L}async function A({systemPrompt:a,userMessage:b,onChunk:c}){if(process.env.MADARX_MOCK_CODEX_RESPONSE)return process.env.MADARX_MOCK_CODEX_RESPONSE;let d=a?`${a}
3499
3505
 
3500
- ${b}`:b;return x(s("codex"),["exec",d],{timeoutMs:Number(process.env.CODEX_TICK_TIMEOUT_MS||18e4),closeStdin:!0,onChunk:c})}async function B({model:a,systemPrompt:b,userMessage:c,maxTokens:d=2048}){var e;let f=(e=await (0,j.chatWithClaude)([{role:"user",content:c}],b,[],{max_tokens:d,model:a}),(e?.content||[]).filter(a=>a?.type==="text"||"string"==typeof a?.text).map(a=>a.text||"").join("\n").trim());if(!f)throw Error("Anthropic returned no text");return f}function C(a){try{return!!a&&f.statSync(a).isDirectory()}catch{return!1}}async function D({agent:a,systemPrompt:b,userMessage:c,maxTokens:d=2048}){let e=o(a.engine),f=a.model||p(e);if("ollama"===e)return y({model:f,systemPrompt:b,userMessage:c,maxTokens:d});if("claude-code"===e){try{(0,l.Jh)()}catch{}let d=[l.un,l.nJ].filter(C);return z({model:f,systemPrompt:b,userMessage:c,cwd:function(){for(let a of[l.un,l.nJ,F,process.cwd()])if(C(a))return a;return process.cwd()}(),addDirs:d,agentId:a.id,agentName:a.name})}if("anthropic"===e)return B({model:f,systemPrompt:b,userMessage:c,maxTokens:d});if("codex"===e)return A({systemPrompt:b,userMessage:c});if("hermes"===e){let a=Error('The Hermes engine cannot run scheduled autonomous ticks yet — it has no governed tool loop, so a tick would only fabricate output. Switch this agent to the "Anthropic API" engine, or drive Hermes via its governed job tools (send_to_hermes / start_hermes_job) from the console.');throw a.code="engine_cannot_run_tools",a.engine="hermes",a}throw Error(`Unknown agent engine: ${a.engine}`)}d()}catch(a){d(a)}})},72550:(a,b,c)=>{"use strict";c.d(b,{Kd:()=>e});let d={google:{label:"Google",authorize_url:"https://accounts.google.com/o/oauth2/v2/auth",token_url:"https://oauth2.googleapis.com/token",pkce:!0,default_scopes:["openid","email"],extra_auth_params:{access_type:"offline",prompt:"consent"}},meta:{label:"Meta (Facebook/Instagram)",authorize_url:"https://www.facebook.com/v19.0/dialog/oauth",token_url:"https://graph.facebook.com/v19.0/oauth/access_token",pkce:!1,default_scopes:["public_profile"],extra_auth_params:{}},linkedin:{label:"LinkedIn",authorize_url:"https://www.linkedin.com/oauth/v2/authorization",token_url:"https://www.linkedin.com/oauth/v2/accessToken",pkce:!1,default_scopes:["r_liteprofile"],extra_auth_params:{}},tiktok:{label:"TikTok",authorize_url:"https://www.tiktok.com/v2/auth/authorize/",token_url:"https://open.tiktokapis.com/v2/oauth/token/",pkce:!0,default_scopes:["user.info.basic"],extra_auth_params:{}},hubspot:{label:"HubSpot",authorize_url:"https://app.hubspot.com/oauth/authorize",token_url:"https://api.hubapi.com/oauth/v1/token",pkce:!1,default_scopes:["oauth"],extra_auth_params:{}}};function e(a,b={}){let c=a&&d[a]?d[a]:null,f=b.authorize_url||c?.authorize_url||null,g=b.token_url||c?.token_url||null;if(!f||!g)return null;let h=Array.isArray(b.scopes)&&b.scopes.length?b.scopes.slice():(c?.default_scopes||[]).slice(),i="boolean"==typeof b.pkce?b.pkce:!!c?.pkce,j={...c?.extra_auth_params||{},...b.extra_auth_params&&"object"==typeof b.extra_auth_params?b.extra_auth_params:{}};return{provider:a||"custom",label:c?.label||a||"Custom provider",authorize_url:f,token_url:g,scopes:h,pkce:i,extra_auth_params:j}}},73066:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Kg:()=>k,kA:()=>l,v2:()=>j});var e=c(73024),f=c(76760),g=c(9381),h=c(61423),i=a([h]);h=(i.then?(await i)():i)[0];let m="artifacts";function j(a){var b;let c=null;return(c=a&&"object"==typeof a?a:(0,h.U1)(a||h.Sk)||null)?f.join((b=c,b?.folder_path?b.folder_path:b?.slug?(0,h.ct)(b.slug):(0,h.ct)(h.Sk)),m):f.join((0,h.ct)(h.Sk),m)}function k(a){let b=j(a);return e.mkdirSync(b,{recursive:!0}),b}function l(a){if(!a)return!1;let b=f.resolve(a);return[f.resolve(g.yQ),...function(){try{return(0,h.hF)({status:"all"}).map(a=>f.resolve(j(a)))}catch{return[]}}()].some(a=>b===a||b.startsWith(`${a}${f.sep}`))}d()}catch(a){d(a)}})},73662:(a,b,c)=>{"use strict";c.d(b,{nA:()=>g});let d=/^[a-z][a-z0-9-]{2,63}$/,e=/^\/[a-z][a-z0-9-]{1,63}$/;function f(a,b,c){a.push(`${b}: ${c}`)}function g(a,b={}){var c;let h,i=[],j=[];try{h=JSON.stringify(a)}catch{return{ok:!1,errors:["spec: not JSON-serialisable"],warnings:[],normalized:null}}if(!h||"undefined"===h)return{ok:!1,errors:["spec: required"],warnings:[],normalized:null};if(Buffer.byteLength(h,"utf8")>65536)return{ok:!1,errors:["spec: exceeds 64KB"],warnings:[],normalized:null};return null===a||"object"!=typeof a||Array.isArray(a)?{ok:!1,errors:["spec: must be an object"],warnings:[],normalized:null}:(a.slug&&"string"==typeof a.slug?d.test(a.slug)||f(i,"slug",`does not match ${d} (lowercase, starts with letter, 3-64 chars, [a-z0-9-])`):f(i,"slug","required (string)"),a.title&&"string"==typeof a.title||f(i,"title","required (non-empty string)"),null!=a.description&&"string"!=typeof a.description&&f(i,"description","must be a string"),a.markdown&&"string"==typeof a.markdown?a.markdown.length>1e5&&f(i,"markdown",`exceeds 100000 chars (got ${a.markdown.length})`):f(i,"markdown","required (non-empty string)"),null!=a.invocation&&("string"!=typeof a.invocation?f(i,"invocation","must be a string"):e.test(a.invocation)||f(i,"invocation",`must match ${e} (e.g. "/my-skill")`)),null!=a.trigger_examples&&(Array.isArray(a.trigger_examples)?a.trigger_examples.forEach((a,b)=>{"string"==typeof a&&a.trim()||f(i,`trigger_examples[${b}]`,"must be a non-empty string")}):f(i,"trigger_examples","must be an array of strings")),null!=a.category&&"string"!=typeof a.category&&f(i,"category","must be a string"),i.length>0)?{ok:!1,errors:i,warnings:j,normalized:null}:{ok:!0,errors:[],warnings:j,normalized:{slug:(c=a).slug,title:c.title,description:c.description||null,category:"string"==typeof c.category&&c.category?c.category:"authored",invocation:"string"==typeof c.invocation&&c.invocation?c.invocation:`/${c.slug}`,markdown:c.markdown,trigger_examples:Array.isArray(c.trigger_examples)?c.trigger_examples.filter(a=>"string"==typeof a&&a.trim()):[]}}}},73899:(a,b,c)=>{"use strict";function d(a,b=null){if(!a)return b;try{return JSON.parse(a)}catch{return b}}c.d(b,{lp:()=>g,oi:()=>d,qY:()=>h});let e=/mars|accent|primary|brand|red|orange|coral/i,f=/^#?(ffffff|000000|fff|0f0f11|111318|1a1817|f7f4ee|e8e8e5|dcdcd8)$/i;function g(a){let b=Array.isArray(a?.colors)?a.colors:[];if(0===b.length)return"#c2452a";let c=b.find(a=>e.test(a?.name||""));if(c?.value)return c.value;let d=b.find(a=>a?.value&&!f.test(a.value));return d?.value||b[0].value||"#c2452a"}function h(a){try{let b=a.prepare("SELECT slug FROM marketplace_items WHERE kind = 'agent'").all();return new Set(b.map(a=>a.slug))}catch{return new Set}}},73912:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{AB:()=>y,CS:()=>s,Io:()=>w,QM:()=>v,R1:()=>z,Ww:()=>x,dh:()=>q,mM:()=>u,uT:()=>p,vV:()=>r,xP:()=>t});var e=c(73024),f=c(76760),g=c(77598),h=c(34255),i=c(9381),j=c(61423),k=c(9001),l=a([h,j,k]);[h,j,k]=l.then?(await l)():l;let A=f.join(i.nJ,"disk");function m(a){return a?{...a}:null}function n(a){return a?{...a,local_only:1===a.local_only}:null}function o(a={}){try{(0,k.jO)("disk",a)}catch{}}function p(a){let b=(0,h.getDb)();return a?b.prepare("SELECT * FROM disk_folders WHERE project_id = ? ORDER BY path ASC").all(a).map(m):b.prepare("SELECT * FROM disk_folders ORDER BY path ASC").all().map(m)}function q(a){let b=(0,j.U1)(a);if(!b)throw Error("project not found");return(0,j.yK)(b.id,b.slug),m((0,h.getDb)().prepare("SELECT * FROM disk_folders WHERE project_id = ? AND parent_id IS NULL LIMIT 1").get(b.id))}function r(a,b,c){if("object"==typeof a&&a){let d=a;a=d.project_id||d.projectId,b=d.parent_id||d.parentId||null,c=d.name}let d=(0,j.U1)(a);if(!d)throw Error("project not found");let g=String(c||"").trim();if(!g)throw Error("name is required");let i=(0,h.getDb)(),k=b?i.prepare("SELECT * FROM disk_folders WHERE id = ?").get(b):q(d.id);if(!k)throw Error("parent folder not found");if(i.prepare("SELECT * FROM disk_folders WHERE project_id = ? AND parent_id = ? AND name = ? LIMIT 1").get(d.id,k.id,g)){let a=Error(`Folder "${g}" already exists.`);throw a.code="FOLDER_EXISTS",a}let l=`${k.path.replace(/\/$/,"")}/${g}/`,n=(0,h.nowIso)(),p=(0,h.newId)("df");try{i.prepare("INSERT INTO disk_folders (id, project_id, parent_id, name, path, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)").run(p,d.id,k.id,g,l,n,n)}catch(a){if(String(a?.message||"").includes("UNIQUE constraint failed")){let a=Error(`Folder "${g}" already exists.`);throw a.code="FOLDER_EXISTS",a}throw a}let r=f.join(A,l.replace(/^\/+|\/+$/g,""));e.mkdirSync(r,{recursive:!0});let s=m(i.prepare("SELECT * FROM disk_folders WHERE id = ?").get(p));return o({project_id:d.id,folder_id:s?.id||p,action:"folder.create"}),s}function s(a={}){let b=(0,h.getDb)(),c=[],d=[];a.project_id&&(c.push("project_id = ?"),d.push(a.project_id)),a.folder_id&&(c.push("folder_id = ?"),d.push(a.folder_id));let e=`SELECT * FROM disk_files ${c.length?"WHERE "+c.join(" AND "):""} ORDER BY updated_at DESC`;return b.prepare(e).all(...d).map(n)}function t(){let a=(0,h.getDb)().prepare(`SELECT project_id, COUNT(*) AS count
3506
+ ${b}`:b;return x(s("codex"),["exec",d],{timeoutMs:Number(process.env.CODEX_TICK_TIMEOUT_MS||18e4),closeStdin:!0,onChunk:c})}async function B({model:a,systemPrompt:b,userMessage:c,maxTokens:d=2048}){var e;let f=(e=await (0,j.chatWithClaude)([{role:"user",content:c}],b,[],{max_tokens:d,model:a}),(e?.content||[]).filter(a=>a?.type==="text"||"string"==typeof a?.text).map(a=>a.text||"").join("\n").trim());if(!f)throw Error("Anthropic returned no text");return f}function C(a){try{return!!a&&f.statSync(a).isDirectory()}catch{return!1}}function D(){for(let a of[l.un,l.nJ,G,process.cwd()])if(C(a))return a;return process.cwd()}async function E({agent:a,systemPrompt:b,userMessage:c,maxTokens:d=2048}){let e=o(a.engine),f=a.model||p(e);if("ollama"===e)return y({model:f,systemPrompt:b,userMessage:c,maxTokens:d});if("claude-code"===e){try{(0,l.Jh)()}catch{}let d=[l.un,l.nJ].filter(C);return z({model:f,systemPrompt:b,userMessage:c,cwd:D(),addDirs:d,agentId:a.id,agentName:a.name})}if("anthropic"===e)return B({model:f,systemPrompt:b,userMessage:c,maxTokens:d});if("codex"===e)return A({systemPrompt:b,userMessage:c});if("hermes"===e){let a=Error('The Hermes engine cannot run scheduled autonomous ticks yet — it has no governed tool loop, so a tick would only fabricate output. Switch this agent to the "Anthropic API" engine, or drive Hermes via its governed job tools (send_to_hermes / start_hermes_job) from the console.');throw a.code="engine_cannot_run_tools",a.engine="hermes",a}throw Error(`Unknown agent engine: ${a.engine}`)}d()}catch(a){d(a)}})},72550:(a,b,c)=>{"use strict";c.d(b,{Kd:()=>e});let d={google:{label:"Google",authorize_url:"https://accounts.google.com/o/oauth2/v2/auth",token_url:"https://oauth2.googleapis.com/token",pkce:!0,default_scopes:["openid","email"],extra_auth_params:{access_type:"offline",prompt:"consent"}},meta:{label:"Meta (Facebook/Instagram)",authorize_url:"https://www.facebook.com/v19.0/dialog/oauth",token_url:"https://graph.facebook.com/v19.0/oauth/access_token",pkce:!1,default_scopes:["public_profile"],extra_auth_params:{}},linkedin:{label:"LinkedIn",authorize_url:"https://www.linkedin.com/oauth/v2/authorization",token_url:"https://www.linkedin.com/oauth/v2/accessToken",pkce:!1,default_scopes:["r_liteprofile"],extra_auth_params:{}},tiktok:{label:"TikTok",authorize_url:"https://www.tiktok.com/v2/auth/authorize/",token_url:"https://open.tiktokapis.com/v2/oauth/token/",pkce:!0,default_scopes:["user.info.basic"],extra_auth_params:{}},hubspot:{label:"HubSpot",authorize_url:"https://app.hubspot.com/oauth/authorize",token_url:"https://api.hubapi.com/oauth/v1/token",pkce:!1,default_scopes:["oauth"],extra_auth_params:{}}};function e(a,b={}){let c=a&&d[a]?d[a]:null,f=b.authorize_url||c?.authorize_url||null,g=b.token_url||c?.token_url||null;if(!f||!g)return null;let h=Array.isArray(b.scopes)&&b.scopes.length?b.scopes.slice():(c?.default_scopes||[]).slice(),i="boolean"==typeof b.pkce?b.pkce:!!c?.pkce,j={...c?.extra_auth_params||{},...b.extra_auth_params&&"object"==typeof b.extra_auth_params?b.extra_auth_params:{}};return{provider:a||"custom",label:c?.label||a||"Custom provider",authorize_url:f,token_url:g,scopes:h,pkce:i,extra_auth_params:j}}},73066:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Kg:()=>k,kA:()=>l,v2:()=>j});var e=c(73024),f=c(76760),g=c(9381),h=c(61423),i=a([h]);h=(i.then?(await i)():i)[0];let m="artifacts";function j(a){var b;let c=null;return(c=a&&"object"==typeof a?a:(0,h.U1)(a||h.Sk)||null)?f.join((b=c,b?.folder_path?b.folder_path:b?.slug?(0,h.ct)(b.slug):(0,h.ct)(h.Sk)),m):f.join((0,h.ct)(h.Sk),m)}function k(a){let b=j(a);return e.mkdirSync(b,{recursive:!0}),b}function l(a){if(!a)return!1;let b=f.resolve(a);return[f.resolve(g.yQ),...function(){try{return(0,h.hF)({status:"all"}).map(a=>f.resolve(j(a)))}catch{return[]}}()].some(a=>b===a||b.startsWith(`${a}${f.sep}`))}d()}catch(a){d(a)}})},73662:(a,b,c)=>{"use strict";c.d(b,{nA:()=>g});let d=/^[a-z][a-z0-9-]{2,63}$/,e=/^\/[a-z][a-z0-9-]{1,63}$/;function f(a,b,c){a.push(`${b}: ${c}`)}function g(a,b={}){var c;let h,i=[],j=[];try{h=JSON.stringify(a)}catch{return{ok:!1,errors:["spec: not JSON-serialisable"],warnings:[],normalized:null}}if(!h||"undefined"===h)return{ok:!1,errors:["spec: required"],warnings:[],normalized:null};if(Buffer.byteLength(h,"utf8")>65536)return{ok:!1,errors:["spec: exceeds 64KB"],warnings:[],normalized:null};return null===a||"object"!=typeof a||Array.isArray(a)?{ok:!1,errors:["spec: must be an object"],warnings:[],normalized:null}:(a.slug&&"string"==typeof a.slug?d.test(a.slug)||f(i,"slug",`does not match ${d} (lowercase, starts with letter, 3-64 chars, [a-z0-9-])`):f(i,"slug","required (string)"),a.title&&"string"==typeof a.title||f(i,"title","required (non-empty string)"),null!=a.description&&"string"!=typeof a.description&&f(i,"description","must be a string"),a.markdown&&"string"==typeof a.markdown?a.markdown.length>1e5&&f(i,"markdown",`exceeds 100000 chars (got ${a.markdown.length})`):f(i,"markdown","required (non-empty string)"),null!=a.invocation&&("string"!=typeof a.invocation?f(i,"invocation","must be a string"):e.test(a.invocation)||f(i,"invocation",`must match ${e} (e.g. "/my-skill")`)),null!=a.trigger_examples&&(Array.isArray(a.trigger_examples)?a.trigger_examples.forEach((a,b)=>{"string"==typeof a&&a.trim()||f(i,`trigger_examples[${b}]`,"must be a non-empty string")}):f(i,"trigger_examples","must be an array of strings")),null!=a.category&&"string"!=typeof a.category&&f(i,"category","must be a string"),i.length>0)?{ok:!1,errors:i,warnings:j,normalized:null}:{ok:!0,errors:[],warnings:j,normalized:{slug:(c=a).slug,title:c.title,description:c.description||null,category:"string"==typeof c.category&&c.category?c.category:"authored",invocation:"string"==typeof c.invocation&&c.invocation?c.invocation:`/${c.slug}`,markdown:c.markdown,trigger_examples:Array.isArray(c.trigger_examples)?c.trigger_examples.filter(a=>"string"==typeof a&&a.trim()):[]}}}},73899:(a,b,c)=>{"use strict";function d(a,b=null){if(!a)return b;try{return JSON.parse(a)}catch{return b}}c.d(b,{lp:()=>g,oi:()=>d,qY:()=>h});let e=/mars|accent|primary|brand|red|orange|coral/i,f=/^#?(ffffff|000000|fff|0f0f11|111318|1a1817|f7f4ee|e8e8e5|dcdcd8)$/i;function g(a){let b=Array.isArray(a?.colors)?a.colors:[];if(0===b.length)return"#c2452a";let c=b.find(a=>e.test(a?.name||""));if(c?.value)return c.value;let d=b.find(a=>a?.value&&!f.test(a.value));return d?.value||b[0].value||"#c2452a"}function h(a){try{let b=a.prepare("SELECT slug FROM marketplace_items WHERE kind = 'agent'").all();return new Set(b.map(a=>a.slug))}catch{return new Set}}},73912:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{AB:()=>y,CS:()=>s,Io:()=>w,QM:()=>v,R1:()=>z,Ww:()=>x,dh:()=>q,mM:()=>u,uT:()=>p,vV:()=>r,xP:()=>t});var e=c(73024),f=c(76760),g=c(77598),h=c(34255),i=c(9381),j=c(61423),k=c(9001),l=a([h,j,k]);[h,j,k]=l.then?(await l)():l;let A=f.join(i.nJ,"disk");function m(a){return a?{...a}:null}function n(a){return a?{...a,local_only:1===a.local_only}:null}function o(a={}){try{(0,k.jO)("disk",a)}catch{}}function p(a){let b=(0,h.getDb)();return a?b.prepare("SELECT * FROM disk_folders WHERE project_id = ? ORDER BY path ASC").all(a).map(m):b.prepare("SELECT * FROM disk_folders ORDER BY path ASC").all().map(m)}function q(a){let b=(0,j.U1)(a);if(!b)throw Error("project not found");return(0,j.yK)(b.id,b.slug),m((0,h.getDb)().prepare("SELECT * FROM disk_folders WHERE project_id = ? AND parent_id IS NULL LIMIT 1").get(b.id))}function r(a,b,c){if("object"==typeof a&&a){let d=a;a=d.project_id||d.projectId,b=d.parent_id||d.parentId||null,c=d.name}let d=(0,j.U1)(a);if(!d)throw Error("project not found");let g=String(c||"").trim();if(!g)throw Error("name is required");let i=(0,h.getDb)(),k=b?i.prepare("SELECT * FROM disk_folders WHERE id = ?").get(b):q(d.id);if(!k)throw Error("parent folder not found");if(i.prepare("SELECT * FROM disk_folders WHERE project_id = ? AND parent_id = ? AND name = ? LIMIT 1").get(d.id,k.id,g)){let a=Error(`Folder "${g}" already exists.`);throw a.code="FOLDER_EXISTS",a}let l=`${k.path.replace(/\/$/,"")}/${g}/`,n=(0,h.nowIso)(),p=(0,h.newId)("df");try{i.prepare("INSERT INTO disk_folders (id, project_id, parent_id, name, path, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)").run(p,d.id,k.id,g,l,n,n)}catch(a){if(String(a?.message||"").includes("UNIQUE constraint failed")){let a=Error(`Folder "${g}" already exists.`);throw a.code="FOLDER_EXISTS",a}throw a}let r=f.join(A,l.replace(/^\/+|\/+$/g,""));e.mkdirSync(r,{recursive:!0});let s=m(i.prepare("SELECT * FROM disk_folders WHERE id = ?").get(p));return o({project_id:d.id,folder_id:s?.id||p,action:"folder.create"}),s}function s(a={}){let b=(0,h.getDb)(),c=[],d=[];a.project_id&&(c.push("project_id = ?"),d.push(a.project_id)),a.folder_id&&(c.push("folder_id = ?"),d.push(a.folder_id));let e=`SELECT * FROM disk_files ${c.length?"WHERE "+c.join(" AND "):""} ORDER BY updated_at DESC`;return b.prepare(e).all(...d).map(n)}function t(){let a=(0,h.getDb)().prepare(`SELECT project_id, COUNT(*) AS count
3501
3507
  FROM disk_files
3502
3508
  WHERE project_id IS NOT NULL
3503
- GROUP BY project_id`).all(),b=Object.create(null);for(let c of a)b[c.project_id]=c.count;return b}function u(a){return n((0,h.getDb)().prepare("SELECT * FROM disk_files WHERE id = ?").get(a))}function v(a,b,c,d={}){if("object"==typeof a&&a){let e=a;a=e.project_id||e.projectId,b=e.folder_id||e.folderId||null,c={name:e.name,content:e.content||e.buffer||"",type:e.mime_type||e.type||""},d={...e,local_only:e.local_only}}let i=(0,j.U1)(a);if(!i)throw Error("project not found");let k=b?(0,h.getDb)().prepare("SELECT * FROM disk_folders WHERE id = ?").get(b):q(i.id);if(!k)throw Error("folder not found");let l=Buffer.isBuffer(c?.buffer)?c.buffer:Buffer.from(c?.content||""),m=String(c?.name||d.name||"upload.bin").replace(/[\\/]+/g,"-"),n=g.createHash("sha256").update(l).digest("hex"),p=f.join(A,k.path.replace(/^\/+|\/+$/g,""));e.mkdirSync(p,{recursive:!0});let r=f.join(p,`${n.slice(0,12)}-${m}`);e.existsSync(r)||e.writeFileSync(r,l);let s=(0,h.nowIso)(),t=(0,h.newId)("file");(0,h.getDb)().prepare("INSERT INTO disk_files (id, project_id, folder_id, name, kind, mime_type, size_bytes, sha256, storage_path, local_only, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)").run(t,i.id,k.id,m,function(a,b=""){let c=f.extname(a||"").toLowerCase();return[".md",".markdown"].includes(c)?"md":".pdf"===c?"pdf":[".mp3",".wav",".m4a",".ogg",".webm"].includes(c)||b.startsWith("audio/")?"audio":[".png",".jpg",".jpeg",".webp",".gif"].includes(c)||b.startsWith("image/")?"image":[".txt",".csv",".json",".yaml",".yml"].includes(c)||b.startsWith("text/")?"text":"other"}(m,c?.type||d.mime_type||""),c?.type||d.mime_type||null,l.length,n,r,+!!d.local_only,s,s);let w=u(t);try{(0,j.Ip)(i.id,{action:"project.file.uploaded",title:`Uploaded ${m}`,summary:`Attached ${m} to the project folder`,status:"complete",source:"disk",details:{file_id:t,folder_id:k.id,kind:w.kind,size_bytes:w.size_bytes,local_only:w.local_only}})}catch{}return o({project_id:i.id,folder_id:k.id,file_id:t,action:"file.upload"}),w}function w(a,b={}){let c=["name","folder_id","local_only"],d=Object.entries(b).filter(([a,b])=>c.includes(a)&&void 0!==b);if(!d.length)return u(a);let e=d.map(([a])=>`${a} = ?`).concat("updated_at = ?").join(", "),f=d.map(([a,b])=>"local_only"===a?+!!b:b).concat((0,h.nowIso)(),a);(0,h.getDb)().prepare(`UPDATE disk_files SET ${e} WHERE id = ?`).run(...f);let g=u(a);return o({project_id:g?.project_id||null,folder_id:g?.folder_id||null,file_id:a,action:"file.update"}),g}function x(a){let b=u(a);if(!b)return!1;(0,h.getDb)().prepare("DELETE FROM disk_files WHERE id = ?").run(a);try{e.unlinkSync(b.storage_path)}catch{}return o({project_id:b.project_id,folder_id:b.folder_id||null,file_id:a,action:"file.delete"}),!0}function y(a,b){if(!b)throw Error("engine parameter required");let c=u(a);if(!c)throw Error("file not found");return c.local_only&&!["ollama","local_whisper"].includes(String(b))?{...c,content:"<redacted: local_only>",redacted:!0}:{...c,content:e.readFileSync(c.storage_path,"utf8"),redacted:!1}}function z(a,b){let c=y(a,b);if(c.redacted){let a=Error("local_only: engine not permitted");throw a.code="LOCAL_ONLY_DENIED",a}return c.storage_path}d()}catch(a){d(a)}})},78335:()=>{},78708:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$A:()=>n,Ac:()=>j,FT:()=>k,N3:()=>q,Us:()=>m,f3:()=>o,uS:()=>p});var e=c(76760),f=c(73024),g=c(34255),h=c(9381),i=a([g]);g=(i.then?(await i)():i)[0];let p=e.join(h.un,"generated-clis"),q=e.join(h.un,"skills","printing-press");e.join(h.nJ,"printing-press-clis.json");let r=/^[a-z0-9][a-z0-9-]{0,63}$/;function j(a){return"string"==typeof a&&r.test(a)}function k(a){let b=e.resolve(a),c=e.resolve(p);if(!b.startsWith(c+e.sep)&&b!==c)throw Error(`Path is not under workspace/generated-clis/: ${a}`);return b}function l(a){if(!a)return null;let b=null,c=[],d=[];try{b=a.manifest_json?JSON.parse(a.manifest_json):null}catch{b=null}try{c=a.declared_scopes?JSON.parse(a.declared_scopes):[]}catch{c=[]}try{d=a.required_secrets?JSON.parse(a.required_secrets):[]}catch{d=[]}return{slug:a.slug,source_kind:a.source_kind,source_url:a.source_url||null,installed_at:a.installed_at,updated_at:a.updated_at,path:a.path,declared_scopes:c,required_secrets:d,quota_bytes:a.quota_bytes||0x6400000,manifest:b,status:a.status}}function m({includeRemoved:a=!1}={}){let b=(0,g.getDb)();return(a?b.prepare("SELECT * FROM printing_press_clis ORDER BY installed_at DESC").all():b.prepare("SELECT * FROM printing_press_clis WHERE status != 'removed' ORDER BY installed_at DESC").all()).map(l)}function n(a){if(!j(a))return null;let b=(0,g.getDb)().prepare("SELECT * FROM printing_press_clis WHERE slug = ?").get(a);return l(b)}function o(a){let b=n(a);if(!b)return null;try{return{slug:a,bytes:function a(b){if(!f.existsSync(b))return 0;let c=0;for(let d of f.readdirSync(b,{withFileTypes:!0})){let g=e.join(b,d.name);if(d.isDirectory())c+=a(g);else if(d.isFile())try{c+=f.statSync(g).size}catch{}}return c}(b.path),quota_bytes:b.quota_bytes}}catch{return{slug:a,bytes:0,quota_bytes:b.quota_bytes,error:"measure_failed"}}}d()}catch(a){d(a)}})},79133:(a,b,c)=>{"use strict";c.d(b,{A5:()=>j,Pf:()=>h,decryptFromDiskBuffer:()=>k});var d=c(77598),e=c(87181);let f=Buffer.from("madarx-artifact-dek-v1"),g="1"===process.env.MADARX_ARTIFACT_ENCRYPTION;function h(){return g}function i(a){if(!a)throw Error("deriveOrgDek requires orgId");let b=(0,d.createHash)("sha256").update(a).digest(),c=(0,e.K2)({allowGenerate:!0});return Buffer.from((0,d.hkdfSync)("sha256",c,b,f,32))}function j(a,b){let{ciphertext:c,iv:e,authTag:f}=function(a,b){let c=i(a),e=(0,d.randomBytes)(12),f=(0,d.createCipheriv)("aes-256-gcm",c,e),g=Buffer.isBuffer(b)?b:Buffer.from(b,"utf8");return{ciphertext:Buffer.concat([f.update(g),f.final()]),iv:e,authTag:f.getAuthTag()}}(a,b);return Buffer.concat([e,f,c])}function k(a,b){if(!Buffer.isBuffer(b)||b.length<28)throw Error("Invalid encrypted artifact: too short");let c=b.subarray(0,12),e=b.subarray(12,28),f=b.subarray(28),g=i(a),h=(0,d.createDecipheriv)("aes-256-gcm",g,c);return h.setAuthTag(e),Buffer.concat([h.update(f),h.final()])}},79278:(a,b,c)=>{"use strict";c.d(b,{Pw:()=>o,pE:()=>f});let d=/^[a-z][a-z0-9-]{2,63}$/,e=new Set(["bearer","api_key","basic","oauth2","none"]),f=["low","medium","high","irreversible_external"],g=new Set(["GET","POST","PUT","PATCH","DELETE"]),h=new Set(["POST","PUT","PATCH","DELETE"]),i=/^[a-z][a-z0-9_]{0,63}$/,j=/^[A-Z][A-Z0-9_]{1,63}$/,k=new Set(["token","key","secret","password","value","api_key","bearer","credentials","access_token","refresh_token","client_id","client_secret"]);function l(a,b,c){a.push(`${b}: ${c}`)}function m(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function n(a){return f.indexOf(a)}function o(a,b={}){let c,p=[],q=[];try{c=JSON.stringify(a)}catch{return{ok:!1,errors:["manifest: not JSON-serialisable"],warnings:[],normalized:null}}if(!c||"undefined"===c)return{ok:!1,errors:["manifest: required"],warnings:[],normalized:null};if(Buffer.byteLength(c,"utf8")>65536)return{ok:!1,errors:[`manifest: serialized length ${Buffer.byteLength(c,"utf8")} bytes exceeds 65536-byte cap`],warnings:[],normalized:null};if(!m(a))return{ok:!1,errors:["manifest: must be a plain object"],warnings:[],normalized:null};a.slug&&"string"==typeof a.slug?d.test(a.slug)||l(p,"slug",`does not match ${d} (lowercase, starts with letter, 3-64 chars, hyphens allowed)`):l(p,"slug","required (string)"),null!=a.title&&"string"!=typeof a.title&&l(p,"title","must be a string");let r=null;if(a.base_url&&"string"==typeof a.base_url){let b;try{b=new URL(a.base_url)}catch{l(p,"base_url","must be a valid URL")}b&&("https:"!==b.protocol&&l(p,"base_url","must be https"),r=b.hostname.toLowerCase())}else l(p,"base_url","required (string)");let s=[];if(Array.isArray(a.allowed_hosts)&&0!==a.allowed_hosts.length?((s=a.allowed_hosts.map(a=>"string"==typeof a?a.toLowerCase():a)).forEach((a,b)=>{if("string"!=typeof a||!a)return void l(p,`allowed_hosts[${b}]`,"must be a non-empty string");(function(a){if(!a)return!1;let b=String(a).toLowerCase().replace(/^\[|\]$/g,"");if("localhost"===b||"::1"===b||b.endsWith(".localhost")||b.endsWith(".local"))return!0;if(b.includes(":"))return!!(b.startsWith("fc")||b.startsWith("fd")||b.startsWith("fe80:"))||"::"===b;let c=b.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(!c)return!1;let[d,e]=[Number(c[1]),Number(c[2])];return 10===d||127===d||0===d||169===d&&254===e||192===d&&168===e||172===d&&!!(e>=16)&&!!(e<=31)})(a)&&l(p,`allowed_hosts[${b}]`,`private/local hosts are not allowed ('${a}')`)}),r&&!s.includes(r)&&l(p,"allowed_hosts",`must include base_url host '${r}'`)):l(p,"allowed_hosts","required (non-empty array of host strings)"),!function(a,b){if(!m(a))return l(b,"auth","required (plain object)");for(let c of(a.type&&e.has(a.type)||l(b,"auth.type",`must be one of ${[...e].join(", ")}`),Object.keys(a)))k.has(c.toLowerCase())&&l(b,"auth",`raw secrets are not allowed; reference by *_ref only (found field '${c}')`);let c=a.type;if(("bearer"===c||"api_key"===c)&&(a.secret_ref&&"string"==typeof a.secret_ref?j.test(a.secret_ref)||l(b,"auth.secret_ref",`must match ${j} (uppercase, starts with letter, underscores/digits, max 64 chars)`):l(b,"auth.secret_ref","required for bearer/api_key auth (string)")),"basic"===c&&(a.username_ref&&"string"==typeof a.username_ref?j.test(a.username_ref)||l(b,"auth.username_ref",`must match ${j}`):l(b,"auth.username_ref","required for basic auth (string)"),a.password_ref&&"string"==typeof a.password_ref?j.test(a.password_ref)||l(b,"auth.password_ref",`must match ${j}`):l(b,"auth.password_ref","required for basic auth (string)")),"oauth2"===c){for(let c of(a.access_token_ref&&"string"==typeof a.access_token_ref?j.test(a.access_token_ref)||l(b,"auth.access_token_ref",`must match ${j}`):l(b,"auth.access_token_ref","required for oauth2 auth (vault ref)"),["refresh_token_ref","client_id_ref","client_secret_ref"]))null!=a[c]&&("string"==typeof a[c]&&j.test(a[c])||l(b,`auth.${c}`,`must match ${j}`));if(null!=a.token_url){let c=!1;try{c="https:"===new URL(a.token_url).protocol}catch{c=!1}c||l(b,"auth.token_url","must be a valid https URL")}}}(a.auth,p),null!=a.default_headers&&function(a,b){if(!m(a))return l(b,"default_headers","must be a plain object");for(let[c,d]of Object.entries(a))"string"!=typeof d&&l(b,`default_headers.${c}`,"header value must be a string"),/authorization/i.test(c)&&l(b,"default_headers",`must not set Authorization (use auth); found header '${c}'`)}(a.default_headers,p),!m(a.endpoints)||0===Object.keys(a.endpoints).length)return l(p,"endpoints","required (non-empty plain object)"),{ok:!1,errors:p,warnings:q,normalized:null};let t=Object.entries(a.endpoints);if(t.length>50)return l(p,"endpoints","exceeds 50 endpoint cap"),{ok:!1,errors:p,warnings:q,normalized:null};let u={};for(let[a,b]of t){let c=`endpoints.${a}`;i.test(a)||l(p,c,`endpoint name must match ${i}`);let d=function(a,b,c){let d;if(!m(a))return l(b,c,"must be a plain object"),null;if(a.method&&g.has(a.method)||l(b,`${c}.method`,`must be one of ${[...g].join(", ")} (uppercase)`),a.path&&"string"==typeof a.path)if(a.path.startsWith("/"))for(let d of function(a){let b,c=[],d=/\{([^}]+)\}/g;for(;null!==(b=d.exec(a));)c.push(b[1]);return c}(a.path))/^[a-z][a-z0-9_]*$/.test(d)||l(b,`${c}.path`,`placeholder '{${d}}' must match /^[a-z][a-z0-9_]*$/`);else l(b,`${c}.path`,"must start with '/'");else l(b,`${c}.path`,"required (string starting with /)");null!=a.description&&"string"!=typeof a.description&&l(b,`${c}.description`,"must be a string"),null==a.input_schema||m(a.input_schema)||l(b,`${c}.input_schema`,"must be a plain object");let e=a.method,i=h.has(e),j=a.risk,k=!1;return null==j||f.includes(j)||(l(b,`${c}.risk`,`must be one of ${f.join(", ")}`),j=void 0),null==j?d=i?"medium":"low":i&&n(j)<n("medium")?(d="medium",k=!0):d=j,{effectiveRisk:d,clampWarning:k}}(b,p,c);if(d){let{effectiveRisk:e,clampWarning:f}=d;f&&q.push(`${c}.risk: clamped low→medium for write method`),u[a]={method:b.method,path:b.path??null,risk:e,input_schema:null!=b.input_schema?structuredClone(b.input_schema):null,description:b.description??null}}}if(p.length>0)return{ok:!1,errors:p,warnings:q,normalized:null};let v={},w=new Set(["type","header","prefix","query_param","secret_ref","username_ref","password_ref","access_token_ref","refresh_token_ref","client_id_ref","client_secret_ref","token_url","provider"]);for(let[b,c]of Object.entries(a.auth))w.has(b)&&(v[b]=c);return{ok:!0,errors:[],warnings:q,normalized:{slug:a.slug,title:a.title??null,base_url:a.base_url,allowed_hosts:s,auth:v,default_headers:null!=a.default_headers?structuredClone(a.default_headers):{},endpoints:u}}}},80987:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Cw:()=>s,ID:()=>r,VC:()=>t,gE:()=>q});var e=c(31421),f=c(76760),g=c(73024),h=c(80099),i=c(9381),j=c(78708),k=c(41249),l=c(24516),m=a([j,l]);[j,l]=m.then?(await m)():m;let u=f.join(i.Dl,"scripts","printing-press"),v=f.join(u,"install.mjs"),w=f.join(u,"install-cli.mjs");function n(){return(0,k.Qw)((0,k.U5)())}function o(a,b,{cwd:c,timeoutMs:d,env:f}={}){return new Promise((g,h)=>{let i=(0,e.spawn)(a,b,{cwd:c,shell:!1,env:f||{PATH:process.env.PATH,HOME:process.env.HOME,NODE_ENV:"production"}}),j=Buffer.alloc(0),k=Buffer.alloc(0),l=!1,m=!1,n=!1,o=setTimeout(()=>{n=!0;try{i.kill("SIGKILL")}catch{}},d||6e4);i.stdout.on("data",a=>{j.length+a.length>262144?(j=Buffer.concat([j,a.slice(0,262144-j.length)]),l=!0):j=Buffer.concat([j,a])}),i.stderr.on("data",a=>{k.length+a.length>262144?(k=Buffer.concat([k,a.slice(0,262144-k.length)]),m=!0):k=Buffer.concat([k,a])}),i.on("error",a=>{clearTimeout(o),h(a)}),i.on("close",(a,b)=>{clearTimeout(o),g({exit_code:a,signal:b,timed_out:n,stdout:j.toString("utf8"),stderr:k.toString("utf8"),stdout_truncated:l,stderr_truncated:m})})})}function p(a){return(a?.declared_scopes||[]).some(a=>"string"==typeof a&&/write|mutate|delete|push/i.test(a))}async function q(a={},b={}){let c=n();if(!g.existsSync(u))return{ok:!1,status:"misconfigured",reason:`sub-package missing at ${u}`};let d=await o("node",[v],{cwd:u,timeoutMs:3e5});return d.timed_out?{ok:!1,status:"timeout",stderr:d.stderr}:0!==d.exit_code?{ok:!1,status:"failed",exit_code:d.exit_code,stderr:d.stderr,security_mode:c.mode}:{ok:!0,status:"installed",skills_dir:j.N3,security_mode:c.mode,stdout_tail:d.stdout.slice(-1024)}}async function r(a={},b={}){let c=n(),d=String(a.slug||"").trim();if(!(0,j.Ac)(d))return{ok:!1,status:"invalid_input",reason:"slug must match /^[a-z0-9][a-z0-9-]{0,63}$/"};let e=String(a.source||"starter-pack"),g=new Set(["starter-pack","github","local","spec"]);if(!g.has(e))return{ok:!1,status:"invalid_input",reason:`source must be one of ${[...g].join(", ")}`};let h=a.source_url?String(a.source_url):null;if("starter-pack"!==e&&!h)return{ok:!1,status:"invalid_input",reason:`source_url required when source=${e}`};let i=f.join(j.uS,d);try{(0,j.FT)(i)}catch(a){return{ok:!1,status:"unsafe_path",reason:a.message}}let k=[w,d,"--source",e];h&&k.push("--source-url",h);let l=await o("node",k,{cwd:u,timeoutMs:3e5});if(l.timed_out)return{ok:!1,status:"timeout",stderr:l.stderr};if(0!==l.exit_code)return{ok:!1,status:"failed",exit_code:l.exit_code,stderr:l.stderr};let m=(0,j.$A)(d);return m&&p(m)&&!c.allow_network_write_clis?{ok:!1,status:"refused",reason:`Security mode "${c.mode}" forbids CLIs declaring write scopes. Declared: ${JSON.stringify(m.declared_scopes)}`,cli:m}:{ok:!0,status:"generated",cli:m,security_mode:c.mode}}async function s(a={},b={}){let c,d,e=n(),h=String(a.slug||"").trim();if(!(0,j.Ac)(h))return{ok:!1,status:"invalid_input",reason:"invalid slug"};let i=(0,j.$A)(h);if(!i||"removed"===i.status)return{ok:!1,status:"not_installed",slug:h};if("disabled"===i.status)return{ok:!1,status:"disabled",slug:h};if(p(i)&&!e.allow_network_write_clis)return{ok:!1,status:"refused",reason:`Security mode "${e.mode}" forbids running CLIs with write scopes.`};let k=Array.isArray(a.args)?a.args.map(String):[];for(let a of k)if(/[;&|`$<>]/.test(a))return{ok:!1,status:"unsafe_args",reason:`argv contains shell metacharacter: ${a}`};try{(0,j.FT)(i.path)}catch(a){return{ok:!1,status:"unsafe_path",reason:a.message}}let m=process.env.GOBIN||(process.env.GOPATH?`${process.env.GOPATH}/bin`:null)||(process.env.HOME?`${process.env.HOME}/go/bin`:null),q=m?f.join(m,`${h}-pp-cli`):null,r=f.join(i.path,"bin"),t=f.join(i.path,"index.js");if(q&&g.existsSync(q))c=q,d=k;else if(g.existsSync(r))c=r,d=k;else{if(!g.existsSync(t))return{ok:!1,status:"no_entry_point",reason:`No entry point found. Tried: ${q||"(no go bin dir)"} , ${r}, ${t}`};c=process.execPath,d=[t,...k]}let u=function(a,b={}){let c={PATH:process.env.PATH,HOME:process.env.HOME,NODE_ENV:"production",PRINTING_PRESS_CLI_SLUG:a.slug,PRINTING_PRESS_DATA_DIR:a.path};for(let d of a.required_secrets||[])if("string"==typeof d&&/^[A-Z][A-Z0-9_]*$/.test(d))try{let a=(0,l.getSecret)(d,{agent_id:b.agent_id,project_id:b.project_id});a&&(c[d]=a)}catch{}return c}(i,b),v=Math.min(Number(a.timeout_ms)||6e4,3e5),w=await o(c,d,{cwd:i.path,timeoutMs:v,env:u});return{ok:0===w.exit_code,status:w.timed_out?"timeout":0===w.exit_code?"complete":"failed",slug:h,exit_code:w.exit_code,timed_out:w.timed_out,stdout:w.stdout,stderr:w.stderr,stdout_truncated:w.stdout_truncated,stderr_truncated:w.stderr_truncated,security_mode:e.mode}}let x=/\b(INSERT|UPDATE|DELETE|DROP|ALTER|CREATE|REPLACE|ATTACH|DETACH|PRAGMA|VACUUM|REINDEX|TRUNCATE)\b/i;async function t(a={},b={}){let c,d=String(a.slug||"").trim();if(!(0,j.Ac)(d))return{ok:!1,status:"invalid_input",reason:"invalid slug"};let e=(0,j.$A)(d);if(!e||"removed"===e.status)return{ok:!1,status:"not_installed",slug:d};let i=String(a.sql||"").trim();if(!i)return{ok:!1,status:"invalid_input",reason:"sql is required"};if(i.includes(";"))return{ok:!1,status:"unsafe_sql",reason:"multi-statement queries are not allowed"};if(x.test(i))return{ok:!1,status:"unsafe_sql",reason:"only SELECT-style read queries are permitted"};if(!/^\s*(SELECT|WITH)\b/i.test(i))return{ok:!1,status:"unsafe_sql",reason:"query must begin with SELECT or WITH"};let k=process.env.XDG_DATA_HOME||(process.env.HOME?f.join(process.env.HOME,".local","share"):null),l=[f.join(e.path,"data.sqlite"),f.join(e.path,`${d}.sqlite`),k?f.join(k,`${d}-pp-cli`,"data.db"):null,k?f.join(k,`${d}-pp-cli`,"data.sqlite"):null].filter(Boolean),m=l.find(a=>g.existsSync(a));if(!m)return{ok:!1,status:"no_mirror",reason:"CLI has no local SQLite mirror",tried:l};if(m.startsWith(f.resolve(e.path)+f.sep))try{(0,j.FT)(m)}catch(a){return{ok:!1,status:"unsafe_path",reason:a.message}}let n=Array.isArray(a.params)?a.params:[];try{c=new h.DatabaseSync(m,{readOnly:!0})}catch(a){return{ok:!1,status:"open_failed",reason:a.message}}try{let a=c.prepare(i).all(...n).slice(0,1e3);return{ok:!0,status:"complete",slug:d,row_count:a.length,truncated:1e3===a.length,rows:a}}catch(a){return{ok:!1,status:"query_failed",reason:a.message}}finally{try{c.close()}catch{}}}d()}catch(a){d(a)}})},81553:(a,b,c)=>{"use strict";c.d(b,{YO:()=>j,ct:()=>m,mU:()=>k,rd:()=>g,runUpdateCheck:()=>n,shouldAutoApply:()=>o});var d=c(73024),e=c(76760),f=c(73136);let g="madarx",h=`https://registry.npmjs.org/${g}/latest`,i=e.dirname((0,f.fileURLToPath)("file:///home/runner/work/madarx-os/madarx-os/lib/update-check.js"));function j(){if(process.env.MADARX_VERSION)return process.env.MADARX_VERSION;for(let a of[e.join(i,"..","package.json"),e.join(process.cwd(),"package.json"),e.join(process.cwd(),".next","standalone","package.json")]){let b=function(a){try{let b=JSON.parse(d.readFileSync(a,"utf8"));if(b&&b.name===g&&b.version)return b.version}catch{}return null}(a);if(b)return b}return"0.0.0"}function k(a,b){let c=a=>String(a).split("-")[0].split(".").slice(0,3).map(a=>parseInt(a,10)||0),d=c(a),e=c(b);for(let a=0;a<Math.max(d.length,e.length);a++){let b=(d[a]||0)-(e[a]||0);if(0!==b)return b>0?1:-1}return 0}async function l({fetchImpl:a=fetch,timeoutMs:b=4e3}={}){try{let c=await a(h,{signal:AbortSignal.timeout(b)});if(!c.ok)return null;let d=await c.json();return d?.version||null}catch{return null}}function m(a){try{return JSON.parse(d.readFileSync(a,"utf8"))}catch{return null}}async function n({file:a,current:b=j(),fetchImpl:c=fetch,nowIso:f}={}){let g=await l({fetchImpl:c}),h=f||new Date().toISOString();if(!g){let c=a?m(a):null;return{ts:h,current:b,latest:c?.latest||null,behind:!1,reachable:!1}}let i=k(g,b)>0,o={ts:h,current:b,latest:g,behind:i,reachable:!0};return a&&(d.mkdirSync(e.dirname(a),{recursive:!0}),d.writeFileSync(a,JSON.stringify(o,null,2))),o}function o({behind:a,mode:b,apply:c}){return!!a&&"weekly"===b&&"auto"===c}},81833:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{BQ:()=>o,HO:()=>s,Jh:()=>n,OT:()=>r,Om:()=>k,bz:()=>m,cN:()=>p,h5:()=>q,iF:()=>i,k2:()=>l,pp:()=>j});var e=c(34255),f=a([e]);function g(a){return a?{id:String(a.id),name:String(a.name||""),position:Number(a.position)||0,is_active:1===a.is_active,created_at:a.created_at,updated_at:a.updated_at}:null}function h(a,b){return String(a||"").trim().slice(0,32)||b}function i(){let a=(0,e.getDb)();l();let b=a.prepare("SELECT * FROM dashboard_spaces ORDER BY position ASC, created_at ASC").all().map(g),c=b.find(a=>a.is_active)||b[0]||null;return{spaces:b,active_space_id:c?c.id:null}}function j(a){if(!a)return null;let b=(0,e.getDb)().prepare("SELECT * FROM dashboard_spaces WHERE id = ?").get(String(a));return g(b)}function k(a=[],{fallback:b="default"}={}){for(let b of Array.isArray(a)?a:[a])if(b&&j(b))return b;return b}function l(){let a=(0,e.getDb)(),b=a.prepare("SELECT COUNT(*) AS n FROM dashboard_spaces").get().n;if(0===b){let b=(0,e.nowIso)();a.prepare("INSERT INTO dashboard_spaces (id, name, position, is_active, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)").run("default","main",0,1,b,b)}a.prepare("UPDATE artifacts SET space_id = 'default' WHERE space_id IS NULL").run()}function m({name:a}={}){let b=(0,e.getDb)();l();let c=b.prepare("SELECT COUNT(*) AS n FROM dashboard_spaces").get().n;if(c>=32){let a=Error("Maximum of 32 spaces reached.");throw a.code="SPACE_LIMIT",a}let d=b.prepare("SELECT MAX(position) AS m FROM dashboard_spaces").get().m,f=(Number(d)||0)+1,g=(0,e.newId)("space"),i=(0,e.nowIso)(),k=h(a,`Space ${c+1}`);return b.prepare("INSERT INTO dashboard_spaces (id, name, position, is_active, created_at, updated_at) VALUES (?, ?, ?, 0, ?, ?)").run(g,k,f,i,i),j(g)}function n(a,b){let c=j(a);if(!c){let a=Error("Space not found.");throw a.code="SPACE_NOT_FOUND",a}let d=h(b,c.name);return d===c.name?c:((0,e.getDb)().prepare("UPDATE dashboard_spaces SET name = ?, updated_at = ? WHERE id = ?").run(d,(0,e.nowIso)(),a),j(a))}function o(a){if(!j(a)){let a=Error("Space not found.");throw a.code="SPACE_NOT_FOUND",a}let b=(0,e.getDb)(),c=(0,e.nowIso)(),d=b.prepare("BEGIN IMMEDIATE");try{d.run(),b.prepare("UPDATE dashboard_spaces SET is_active = 0, updated_at = ? WHERE is_active = 1").run(c),b.prepare("UPDATE dashboard_spaces SET is_active = 1, updated_at = ? WHERE id = ?").run(c,a),b.prepare("COMMIT").run()}catch(a){try{b.prepare("ROLLBACK").run()}catch{}throw a}return j(a)}function p(a){let b=(0,e.getDb)(),c=j(a);if(!c)return null;if(b.prepare("SELECT COUNT(*) AS n FROM dashboard_spaces").get().n<=1){let a=Error("Cannot delete the last remaining space.");throw a.code="SPACE_LAST",a}let d=b.prepare("SELECT * FROM dashboard_spaces WHERE id != ? ORDER BY position ASC, created_at ASC LIMIT 1").get(a);if(!d){let a=Error("No fallback space available.");throw a.code="SPACE_NO_FALLBACK",a}let f=(0,e.nowIso)(),g=b.prepare("BEGIN IMMEDIATE");try{g.run(),b.prepare("UPDATE artifacts SET space_id = ? WHERE space_id = ?").run(d.id,a),b.prepare("UPDATE space_share_links SET revoked = 1 WHERE space_id = ? AND revoked = 0").run(a),b.prepare("DELETE FROM dashboard_spaces WHERE id = ?").run(a),c.is_active&&b.prepare("UPDATE dashboard_spaces SET is_active = 1, updated_at = ? WHERE id = ?").run(f,d.id),b.prepare("COMMIT").run()}catch(a){try{b.prepare("ROLLBACK").run()}catch{}throw a}return{deleted_id:a,moved_to:d.id}}function q(a,b){if(!a){let a=Error("artifact_id is required.");throw a.code="ARTIFACT_REQUIRED",a}let c=j(b);if(!c){let a=Error("Space not found.");throw a.code="SPACE_NOT_FOUND",a}let d=(0,e.getDb)(),f=d.prepare("SELECT id FROM artifacts WHERE id = ?").get(String(a));if(!f){let a=Error("Artifact not found.");throw a.code="ARTIFACT_NOT_FOUND",a}return d.prepare("UPDATE artifacts SET space_id = ?, pinned_to_space_at = datetime('now') WHERE id = ?").run(c.id,f.id),{artifact_id:f.id,space_id:c.id}}function r(){let a=(0,e.getDb)();l();let b=a.prepare("SELECT * FROM dashboard_spaces ORDER BY position ASC, created_at ASC").all().map(g),c=a.prepare("SELECT id, space_id FROM artifacts WHERE space_id IS NOT NULL").all(),d=new Map(b.map(a=>[a.id,[]]));for(let a of c)d.has(a.space_id)&&d.get(a.space_id).push(String(a.id));let f=b.map(a=>({...a,artifact_ids:d.get(a.id)||[]})),h=f.find(a=>a.is_active)||f[0]||null;return{spaces:f,active_space_id:h?h.id:null}}function s({spaces:a=[],active_space_id:b=null}={}){if(!Array.isArray(a)||0===a.length)return null;let c=(0,e.getDb)();l();let d=c.prepare("SELECT COUNT(*) AS n FROM dashboard_spaces").get().n;if(!(1===d&&c.prepare("SELECT id FROM dashboard_spaces WHERE id = 'default'").get()))return null;let f=a.filter(a=>a&&"string"==typeof a.id&&a.id.length>0).slice(0,32);if(0===f.length)return null;let g=(0,e.nowIso)(),i=c.prepare("BEGIN IMMEDIATE");try{i.run(),c.prepare("DELETE FROM dashboard_spaces").run(),f.forEach((a,d)=>{let e=String(a.id),f=h(a.name,`Space ${d+1}`),i=b?e===String(b):0===d;c.prepare("INSERT INTO dashboard_spaces (id, name, position, is_active, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)").run(e,f,d,+!!i,g,g);let j=Array.isArray(a.artifactIds)?a.artifactIds:[],k=c.prepare("UPDATE artifacts SET space_id = ? WHERE id = ? AND (space_id IS NULL OR space_id = ?)");for(let a of j)"string"==typeof a&&k.run(e,a,e)});let a=c.prepare("SELECT COUNT(*) AS n FROM dashboard_spaces WHERE is_active = 1").get().n;if(0===a){let a=c.prepare("SELECT id FROM dashboard_spaces ORDER BY position ASC, created_at ASC LIMIT 1").get();a&&c.prepare("UPDATE dashboard_spaces SET is_active = 1 WHERE id = ?").run(a.id)}c.prepare("COMMIT").run()}catch(a){try{c.prepare("ROLLBACK").run()}catch{}throw a}return r()}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},81992:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{cS:()=>j,r_:()=>i,vg:()=>k});var e=c(25938),f=a([e]);function g(a,{includeBody:b=!1}={}){let c=Object.fromEntries((a.payload?.headers||[]).map(a=>[String(a.name).toLowerCase(),a.value])),d={id:a.id,thread_id:a.threadId,from:c.from||null,subject:c.subject||null,date:c.date||null,snippet:a.snippet||""};return b&&(d.to=c.to||null,d.body_text=function a(b={}){if(b.body?.data)return function(a=""){if(!a)return"";try{return Buffer.from(String(a),"base64url").toString("utf8")}catch{return""}}(b.body.data);let c=Array.isArray(b.parts)?b.parts:[],d=c.find(a=>"text/plain"===a.mimeType&&a.body?.data)||c.find(a=>a.body?.data);return d?a(d):""}(a.payload||{})),d}async function h(a,b,c,d){let f=(0,e.s)(d,c),g=await f(a,{headers:{Authorization:`Bearer ${b}`}});if(!g.ok)throw Error(`google api failed: ${g.status}`);return g.json()}async function i(a={},b={}){let c="gmail_messages_list",d=await (0,e.r)(b,c),f=new URL("https://gmail.googleapis.com/gmail/v1/users/me/messages");for(let b of(a.max_results&&f.searchParams.set("maxResults",String(a.max_results)),a.q&&f.searchParams.set("q",a.q),a.label_ids||a.labelIds||[]))f.searchParams.append("labelIds",String(b));let j=(await h(f,d,b,c)).messages||[];return Promise.all(j.map(async a=>{let e=await h(`https://gmail.googleapis.com/gmail/v1/users/me/messages/${encodeURIComponent(a.id)}?format=metadata`,d,b,c);return g(e)}))}async function j(a={},b={}){if(!a.message_id)throw Error("message_id is required");let c="gmail_message_read",d=await (0,e.r)(b,c),f=await h(`https://gmail.googleapis.com/gmail/v1/users/me/messages/${encodeURIComponent(a.message_id)}?format=full`,d,b,c);return g(f,{includeBody:!0})}async function k(a={},b={}){if(!a.thread_id)throw Error("thread_id is required");let c="gmail_thread_read",d=await (0,e.r)(b,c),f=await h(`https://gmail.googleapis.com/gmail/v1/users/me/threads/${encodeURIComponent(a.thread_id)}?format=full`,d,b,c);return{id:f.id,messages:(f.messages||[]).map(a=>g(a,{includeBody:!0}))}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},83963:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Dn:()=>ae,Fp:()=>aa,Fy:()=>F,G:()=>ai,HB:()=>R,Mu:()=>Y,Q4:()=>J,Qf:()=>_,Rz:()=>W,V0:()=>ag,VI:()=>P,Vk:()=>N,WH:()=>$,WX:()=>Z,X1:()=>X,createTask:()=>S,eE:()=>ac,fI:()=>B,gf:()=>I,gg:()=>O,hC:()=>ap,hW:()=>ak,iR:()=>ad,ij:()=>an,jN:()=>G,kP:()=>D,lC:()=>T,n5:()=>ao,nV:()=>aj,qF:()=>am,qt:()=>ah,rN:()=>ab,s_:()=>Q,vQ:()=>V,w4:()=>al,yS:()=>U,yX:()=>E,zP:()=>H});var e=c(34255),f=c(40563),g=c(61423),h=c(18313),i=a([e,f,g]);function j(a,b=null){if(!a)return b;try{return JSON.parse(a)}catch{return b}}function k(a){return null==a?null:JSON.stringify(a)}function l(a){let b=globalThis.__madarxLiveEventBus;if(!b?.subscribers)return{id:a.id||(0,e.newId)("evt"),ts:a.ts||Date.now(),...a};let c={id:a.id||`evt-${b.nextId++}-${Math.random().toString(36).slice(2,8)}`,ts:a.ts||Date.now(),...a};for(let a of b.subscribers)try{a(c)}catch{}return c}function m(a){return a?{...a,tools:j(a.tools,[]),files:j(a.files,[]),memory:j(a.memory,[]),permissions_json:j(a.permissions_json,{}),metadata_json:j(a.metadata_json,{})}:null}function n(a){return a?{...a,parent_task_id:a.parent_task_id||null,tags:j(a.tags_json,[]),watchers:j(a.watchers_json,[]),due_at:a.due_at||null,estimate_minutes:null==a.estimate_minutes?null:Number(a.estimate_minutes),recurrence:a.recurrence||null,acceptance_criteria:a.acceptance_criteria||null}:null}function o(a){return a?{id:a.id,task_id:a.task_id,label:a.label,done:!!a.done,position:Number(a.position)||0,created_at:a.created_at,done_at:a.done_at||null}:null}function p(a){if(null==a)return null;if(Array.isArray(a)){let b=a.map(a=>String(a).trim()).filter(Boolean).slice(0,24);return b.length?b:[]}return"string"==typeof a?a.split(",").map(a=>a.trim()).filter(Boolean).slice(0,24):null}function q(a){if(null==a)return null;let b=(Array.isArray(a)?a:String(a).split(",")).map(a=>String(a).trim()).filter(Boolean).slice(0,24);return Array.from(new Set(b))}function r(a){if(!a)return null;let b=String(a).trim();if(!b)return null;if(/^\d{4}-\d{2}-\d{2}$/.test(b))return`${b}T23:59:59.000Z`;let c=new Date(b);return Number.isNaN(c.getTime())?null:c.toISOString()}function s(a){if(null==a||""===a)return null;let b=Number(a);return!Number.isFinite(b)||b<0?null:Math.round(b)}function t(a){if(!a)return null;let b=String(a).trim();return b?b.length>64?b.slice(0,64):b:null}function u(a){return a?{...a}:null}function v(a){return a?{...a,payload:j(a.payload_json,null)}:null}function w(a){return a?{...a,usage:j(a.usage_json,null),result:j(a.result_json,null)}:null}function x(a){return a?{...a,payload:j(a.payload_json,null)}:null}function y(a){return a?{...a,details:j(a.details_json,null),cursor:a.seq}:null}function z(a){return m((0,e.getDb)().prepare("SELECT * FROM agents WHERE id = ?").get(a))}function A(a){if(!a)return null;let b=z(a);if(!b)throw Error(`Agent not found: ${a}`);if("terminated"===b.status)throw Error(`Terminated agents cannot receive assignments: ${a}`);return b}function B(a){if(!a?.type||!1===a.persist)return null;let b=function(a){let b={agent_run_start:"agent.run.status",agent_run_complete:"agent.run.status",agent_tool_start:"agent.run.event",agent_tool_result:"agent.run.event",log:"agent.run.log"},c=(0,h._d)(b[a.type]||a.type,null);return c&&h.eh.includes(c)?{actor_type:a.actor_type||(a.agent_id?"agent":"system"),actor_id:a.actor_id||a.agent_id||null,agent_id:a.agent_id||null,run_id:a.run_id||null,entity_type:a.entity_type||(a.task_id?"task":a.run_id?"agent_run":a.agent_id?"agent":"event"),entity_id:a.entity_id||a.task_id||a.run_id||a.id||null,action:c,details:{...a,legacy_type:b[a.type]?a.type:void 0},created_at:a.created_at||(0,e.nowIso)()}:null}(a);return b?C(b):null}function C({actor_type:a="system",actor_id:b=null,agent_id:c=null,run_id:d=null,entity_type:f=null,entity_id:g=null,action:h,details:i=null,created_at:j=(0,e.nowIso)()}={}){if(!h)throw Error("activity action is required");let l=(0,e.getDb)(),m=(0,e.newId)("activity");l.prepare(`
3509
+ GROUP BY project_id`).all(),b=Object.create(null);for(let c of a)b[c.project_id]=c.count;return b}function u(a){return n((0,h.getDb)().prepare("SELECT * FROM disk_files WHERE id = ?").get(a))}function v(a,b,c,d={}){if("object"==typeof a&&a){let e=a;a=e.project_id||e.projectId,b=e.folder_id||e.folderId||null,c={name:e.name,content:e.content||e.buffer||"",type:e.mime_type||e.type||""},d={...e,local_only:e.local_only}}let i=(0,j.U1)(a);if(!i)throw Error("project not found");let k=b?(0,h.getDb)().prepare("SELECT * FROM disk_folders WHERE id = ?").get(b):q(i.id);if(!k)throw Error("folder not found");let l=Buffer.isBuffer(c?.buffer)?c.buffer:Buffer.from(c?.content||""),m=String(c?.name||d.name||"upload.bin").replace(/[\\/]+/g,"-"),n=g.createHash("sha256").update(l).digest("hex"),p=f.join(A,k.path.replace(/^\/+|\/+$/g,""));e.mkdirSync(p,{recursive:!0});let r=f.join(p,`${n.slice(0,12)}-${m}`);e.existsSync(r)||e.writeFileSync(r,l);let s=(0,h.nowIso)(),t=(0,h.newId)("file");(0,h.getDb)().prepare("INSERT INTO disk_files (id, project_id, folder_id, name, kind, mime_type, size_bytes, sha256, storage_path, local_only, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)").run(t,i.id,k.id,m,function(a,b=""){let c=f.extname(a||"").toLowerCase();return[".md",".markdown"].includes(c)?"md":".pdf"===c?"pdf":[".mp3",".wav",".m4a",".ogg",".webm"].includes(c)||b.startsWith("audio/")?"audio":[".png",".jpg",".jpeg",".webp",".gif"].includes(c)||b.startsWith("image/")?"image":[".txt",".csv",".json",".yaml",".yml"].includes(c)||b.startsWith("text/")?"text":"other"}(m,c?.type||d.mime_type||""),c?.type||d.mime_type||null,l.length,n,r,+!!d.local_only,s,s);let w=u(t);try{(0,j.Ip)(i.id,{action:"project.file.uploaded",title:`Uploaded ${m}`,summary:`Attached ${m} to the project folder`,status:"complete",source:"disk",details:{file_id:t,folder_id:k.id,kind:w.kind,size_bytes:w.size_bytes,local_only:w.local_only}})}catch{}return o({project_id:i.id,folder_id:k.id,file_id:t,action:"file.upload"}),w}function w(a,b={}){let c=["name","folder_id","local_only"],d=Object.entries(b).filter(([a,b])=>c.includes(a)&&void 0!==b);if(!d.length)return u(a);let e=d.map(([a])=>`${a} = ?`).concat("updated_at = ?").join(", "),f=d.map(([a,b])=>"local_only"===a?+!!b:b).concat((0,h.nowIso)(),a);(0,h.getDb)().prepare(`UPDATE disk_files SET ${e} WHERE id = ?`).run(...f);let g=u(a);return o({project_id:g?.project_id||null,folder_id:g?.folder_id||null,file_id:a,action:"file.update"}),g}function x(a){let b=u(a);if(!b)return!1;(0,h.getDb)().prepare("DELETE FROM disk_files WHERE id = ?").run(a);try{e.unlinkSync(b.storage_path)}catch{}return o({project_id:b.project_id,folder_id:b.folder_id||null,file_id:a,action:"file.delete"}),!0}function y(a,b){if(!b)throw Error("engine parameter required");let c=u(a);if(!c)throw Error("file not found");return c.local_only&&!["ollama","local_whisper"].includes(String(b))?{...c,content:"<redacted: local_only>",redacted:!0}:{...c,content:e.readFileSync(c.storage_path,"utf8"),redacted:!1}}function z(a,b){let c=y(a,b);if(c.redacted){let a=Error("local_only: engine not permitted");throw a.code="LOCAL_ONLY_DENIED",a}return c.storage_path}d()}catch(a){d(a)}})},78335:()=>{},78708:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$A:()=>n,Ac:()=>j,FT:()=>k,N3:()=>q,Us:()=>m,f3:()=>o,uS:()=>p});var e=c(76760),f=c(73024),g=c(34255),h=c(9381),i=a([g]);g=(i.then?(await i)():i)[0];let p=e.join(h.un,"generated-clis"),q=e.join(h.un,"skills","printing-press");e.join(h.nJ,"printing-press-clis.json");let r=/^[a-z0-9][a-z0-9-]{0,63}$/;function j(a){return"string"==typeof a&&r.test(a)}function k(a){let b=e.resolve(a),c=e.resolve(p);if(!b.startsWith(c+e.sep)&&b!==c)throw Error(`Path is not under workspace/generated-clis/: ${a}`);return b}function l(a){if(!a)return null;let b=null,c=[],d=[];try{b=a.manifest_json?JSON.parse(a.manifest_json):null}catch{b=null}try{c=a.declared_scopes?JSON.parse(a.declared_scopes):[]}catch{c=[]}try{d=a.required_secrets?JSON.parse(a.required_secrets):[]}catch{d=[]}return{slug:a.slug,source_kind:a.source_kind,source_url:a.source_url||null,installed_at:a.installed_at,updated_at:a.updated_at,path:a.path,declared_scopes:c,required_secrets:d,quota_bytes:a.quota_bytes||0x6400000,manifest:b,status:a.status}}function m({includeRemoved:a=!1}={}){let b=(0,g.getDb)();return(a?b.prepare("SELECT * FROM printing_press_clis ORDER BY installed_at DESC").all():b.prepare("SELECT * FROM printing_press_clis WHERE status != 'removed' ORDER BY installed_at DESC").all()).map(l)}function n(a){if(!j(a))return null;let b=(0,g.getDb)().prepare("SELECT * FROM printing_press_clis WHERE slug = ?").get(a);return l(b)}function o(a){let b=n(a);if(!b)return null;try{return{slug:a,bytes:function a(b){if(!f.existsSync(b))return 0;let c=0;for(let d of f.readdirSync(b,{withFileTypes:!0})){let g=e.join(b,d.name);if(d.isDirectory())c+=a(g);else if(d.isFile())try{c+=f.statSync(g).size}catch{}}return c}(b.path),quota_bytes:b.quota_bytes}}catch{return{slug:a,bytes:0,quota_bytes:b.quota_bytes,error:"measure_failed"}}}d()}catch(a){d(a)}})},79133:(a,b,c)=>{"use strict";c.d(b,{A5:()=>j,Pf:()=>h,decryptFromDiskBuffer:()=>k});var d=c(77598),e=c(87181);let f=Buffer.from("madarx-artifact-dek-v1"),g="1"===process.env.MADARX_ARTIFACT_ENCRYPTION;function h(){return g}function i(a){if(!a)throw Error("deriveOrgDek requires orgId");let b=(0,d.createHash)("sha256").update(a).digest(),c=(0,e.K2)({allowGenerate:!0});return Buffer.from((0,d.hkdfSync)("sha256",c,b,f,32))}function j(a,b){let{ciphertext:c,iv:e,authTag:f}=function(a,b){let c=i(a),e=(0,d.randomBytes)(12),f=(0,d.createCipheriv)("aes-256-gcm",c,e),g=Buffer.isBuffer(b)?b:Buffer.from(b,"utf8");return{ciphertext:Buffer.concat([f.update(g),f.final()]),iv:e,authTag:f.getAuthTag()}}(a,b);return Buffer.concat([e,f,c])}function k(a,b){if(!Buffer.isBuffer(b)||b.length<28)throw Error("Invalid encrypted artifact: too short");let c=b.subarray(0,12),e=b.subarray(12,28),f=b.subarray(28),g=i(a),h=(0,d.createDecipheriv)("aes-256-gcm",g,c);return h.setAuthTag(e),Buffer.concat([h.update(f),h.final()])}},79278:(a,b,c)=>{"use strict";c.d(b,{Pw:()=>o,pE:()=>f});let d=/^[a-z][a-z0-9-]{2,63}$/,e=new Set(["bearer","api_key","basic","oauth2","none"]),f=["low","medium","high","irreversible_external"],g=new Set(["GET","POST","PUT","PATCH","DELETE"]),h=new Set(["POST","PUT","PATCH","DELETE"]),i=/^[a-z][a-z0-9_]{0,63}$/,j=/^[A-Z][A-Z0-9_]{1,63}$/,k=new Set(["token","key","secret","password","value","api_key","bearer","credentials","access_token","refresh_token","client_id","client_secret"]);function l(a,b,c){a.push(`${b}: ${c}`)}function m(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function n(a){return f.indexOf(a)}function o(a,b={}){let c,p=[],q=[];try{c=JSON.stringify(a)}catch{return{ok:!1,errors:["manifest: not JSON-serialisable"],warnings:[],normalized:null}}if(!c||"undefined"===c)return{ok:!1,errors:["manifest: required"],warnings:[],normalized:null};if(Buffer.byteLength(c,"utf8")>65536)return{ok:!1,errors:[`manifest: serialized length ${Buffer.byteLength(c,"utf8")} bytes exceeds 65536-byte cap`],warnings:[],normalized:null};if(!m(a))return{ok:!1,errors:["manifest: must be a plain object"],warnings:[],normalized:null};a.slug&&"string"==typeof a.slug?d.test(a.slug)||l(p,"slug",`does not match ${d} (lowercase, starts with letter, 3-64 chars, hyphens allowed)`):l(p,"slug","required (string)"),null!=a.title&&"string"!=typeof a.title&&l(p,"title","must be a string");let r=null;if(a.base_url&&"string"==typeof a.base_url){let b;try{b=new URL(a.base_url)}catch{l(p,"base_url","must be a valid URL")}b&&("https:"!==b.protocol&&l(p,"base_url","must be https"),r=b.hostname.toLowerCase())}else l(p,"base_url","required (string)");let s=[];if(Array.isArray(a.allowed_hosts)&&0!==a.allowed_hosts.length?((s=a.allowed_hosts.map(a=>"string"==typeof a?a.toLowerCase():a)).forEach((a,b)=>{if("string"!=typeof a||!a)return void l(p,`allowed_hosts[${b}]`,"must be a non-empty string");(function(a){if(!a)return!1;let b=String(a).toLowerCase().replace(/^\[|\]$/g,"");if("localhost"===b||"::1"===b||b.endsWith(".localhost")||b.endsWith(".local"))return!0;if(b.includes(":"))return!!(b.startsWith("fc")||b.startsWith("fd")||b.startsWith("fe80:"))||"::"===b;let c=b.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(!c)return!1;let[d,e]=[Number(c[1]),Number(c[2])];return 10===d||127===d||0===d||169===d&&254===e||192===d&&168===e||172===d&&!!(e>=16)&&!!(e<=31)})(a)&&l(p,`allowed_hosts[${b}]`,`private/local hosts are not allowed ('${a}')`)}),r&&!s.includes(r)&&l(p,"allowed_hosts",`must include base_url host '${r}'`)):l(p,"allowed_hosts","required (non-empty array of host strings)"),!function(a,b){if(!m(a))return l(b,"auth","required (plain object)");for(let c of(a.type&&e.has(a.type)||l(b,"auth.type",`must be one of ${[...e].join(", ")}`),Object.keys(a)))k.has(c.toLowerCase())&&l(b,"auth",`raw secrets are not allowed; reference by *_ref only (found field '${c}')`);let c=a.type;if(("bearer"===c||"api_key"===c)&&(a.secret_ref&&"string"==typeof a.secret_ref?j.test(a.secret_ref)||l(b,"auth.secret_ref",`must match ${j} (uppercase, starts with letter, underscores/digits, max 64 chars)`):l(b,"auth.secret_ref","required for bearer/api_key auth (string)")),"basic"===c&&(a.username_ref&&"string"==typeof a.username_ref?j.test(a.username_ref)||l(b,"auth.username_ref",`must match ${j}`):l(b,"auth.username_ref","required for basic auth (string)"),a.password_ref&&"string"==typeof a.password_ref?j.test(a.password_ref)||l(b,"auth.password_ref",`must match ${j}`):l(b,"auth.password_ref","required for basic auth (string)")),"oauth2"===c){for(let c of(a.access_token_ref&&"string"==typeof a.access_token_ref?j.test(a.access_token_ref)||l(b,"auth.access_token_ref",`must match ${j}`):l(b,"auth.access_token_ref","required for oauth2 auth (vault ref)"),["refresh_token_ref","client_id_ref","client_secret_ref"]))null!=a[c]&&("string"==typeof a[c]&&j.test(a[c])||l(b,`auth.${c}`,`must match ${j}`));if(null!=a.token_url){let c=!1;try{c="https:"===new URL(a.token_url).protocol}catch{c=!1}c||l(b,"auth.token_url","must be a valid https URL")}}}(a.auth,p),null!=a.default_headers&&function(a,b){if(!m(a))return l(b,"default_headers","must be a plain object");for(let[c,d]of Object.entries(a))"string"!=typeof d&&l(b,`default_headers.${c}`,"header value must be a string"),/authorization/i.test(c)&&l(b,"default_headers",`must not set Authorization (use auth); found header '${c}'`)}(a.default_headers,p),!m(a.endpoints)||0===Object.keys(a.endpoints).length)return l(p,"endpoints","required (non-empty plain object)"),{ok:!1,errors:p,warnings:q,normalized:null};let t=Object.entries(a.endpoints);if(t.length>50)return l(p,"endpoints","exceeds 50 endpoint cap"),{ok:!1,errors:p,warnings:q,normalized:null};let u={};for(let[a,b]of t){let c=`endpoints.${a}`;i.test(a)||l(p,c,`endpoint name must match ${i}`);let d=function(a,b,c){let d;if(!m(a))return l(b,c,"must be a plain object"),null;if(a.method&&g.has(a.method)||l(b,`${c}.method`,`must be one of ${[...g].join(", ")} (uppercase)`),a.path&&"string"==typeof a.path)if(a.path.startsWith("/"))for(let d of function(a){let b,c=[],d=/\{([^}]+)\}/g;for(;null!==(b=d.exec(a));)c.push(b[1]);return c}(a.path))/^[a-z][a-z0-9_]*$/.test(d)||l(b,`${c}.path`,`placeholder '{${d}}' must match /^[a-z][a-z0-9_]*$/`);else l(b,`${c}.path`,"must start with '/'");else l(b,`${c}.path`,"required (string starting with /)");null!=a.description&&"string"!=typeof a.description&&l(b,`${c}.description`,"must be a string"),null==a.input_schema||m(a.input_schema)||l(b,`${c}.input_schema`,"must be a plain object");let e=a.method,i=h.has(e),j=a.risk,k=!1;return null==j||f.includes(j)||(l(b,`${c}.risk`,`must be one of ${f.join(", ")}`),j=void 0),null==j?d=i?"medium":"low":i&&n(j)<n("medium")?(d="medium",k=!0):d=j,{effectiveRisk:d,clampWarning:k}}(b,p,c);if(d){let{effectiveRisk:e,clampWarning:f}=d;f&&q.push(`${c}.risk: clamped low→medium for write method`),u[a]={method:b.method,path:b.path??null,risk:e,input_schema:null!=b.input_schema?structuredClone(b.input_schema):null,description:b.description??null}}}if(p.length>0)return{ok:!1,errors:p,warnings:q,normalized:null};let v={},w=new Set(["type","header","prefix","query_param","secret_ref","username_ref","password_ref","access_token_ref","refresh_token_ref","client_id_ref","client_secret_ref","token_url","provider"]);for(let[b,c]of Object.entries(a.auth))w.has(b)&&(v[b]=c);return{ok:!0,errors:[],warnings:q,normalized:{slug:a.slug,title:a.title??null,base_url:a.base_url,allowed_hosts:s,auth:v,default_headers:null!=a.default_headers?structuredClone(a.default_headers):{},endpoints:u}}}},80987:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Cw:()=>s,ID:()=>r,VC:()=>t,gE:()=>q});var e=c(31421),f=c(76760),g=c(73024),h=c(80099),i=c(9381),j=c(78708),k=c(41249),l=c(24516),m=a([j,l]);[j,l]=m.then?(await m)():m;let u=f.join(i.Dl,"scripts","printing-press"),v=f.join(u,"install.mjs"),w=f.join(u,"install-cli.mjs");function n(){return(0,k.Qw)((0,k.U5)())}function o(a,b,{cwd:c,timeoutMs:d,env:f}={}){return new Promise((g,h)=>{let i=(0,e.spawn)(a,b,{cwd:c,shell:!1,env:f||{PATH:process.env.PATH,HOME:process.env.HOME,NODE_ENV:"production"}}),j=Buffer.alloc(0),k=Buffer.alloc(0),l=!1,m=!1,n=!1,o=setTimeout(()=>{n=!0;try{i.kill("SIGKILL")}catch{}},d||6e4);i.stdout.on("data",a=>{j.length+a.length>262144?(j=Buffer.concat([j,a.slice(0,262144-j.length)]),l=!0):j=Buffer.concat([j,a])}),i.stderr.on("data",a=>{k.length+a.length>262144?(k=Buffer.concat([k,a.slice(0,262144-k.length)]),m=!0):k=Buffer.concat([k,a])}),i.on("error",a=>{clearTimeout(o),h(a)}),i.on("close",(a,b)=>{clearTimeout(o),g({exit_code:a,signal:b,timed_out:n,stdout:j.toString("utf8"),stderr:k.toString("utf8"),stdout_truncated:l,stderr_truncated:m})})})}function p(a){return(a?.declared_scopes||[]).some(a=>"string"==typeof a&&/write|mutate|delete|push/i.test(a))}async function q(a={},b={}){let c=n();if(!g.existsSync(u))return{ok:!1,status:"misconfigured",reason:`sub-package missing at ${u}`};let d=await o("node",[v],{cwd:u,timeoutMs:3e5});return d.timed_out?{ok:!1,status:"timeout",stderr:d.stderr}:0!==d.exit_code?{ok:!1,status:"failed",exit_code:d.exit_code,stderr:d.stderr,security_mode:c.mode}:{ok:!0,status:"installed",skills_dir:j.N3,security_mode:c.mode,stdout_tail:d.stdout.slice(-1024)}}async function r(a={},b={}){let c=n(),d=String(a.slug||"").trim();if(!(0,j.Ac)(d))return{ok:!1,status:"invalid_input",reason:"slug must match /^[a-z0-9][a-z0-9-]{0,63}$/"};let e=String(a.source||"starter-pack"),g=new Set(["starter-pack","github","local","spec"]);if(!g.has(e))return{ok:!1,status:"invalid_input",reason:`source must be one of ${[...g].join(", ")}`};let h=a.source_url?String(a.source_url):null;if("starter-pack"!==e&&!h)return{ok:!1,status:"invalid_input",reason:`source_url required when source=${e}`};let i=f.join(j.uS,d);try{(0,j.FT)(i)}catch(a){return{ok:!1,status:"unsafe_path",reason:a.message}}let k=[w,d,"--source",e];h&&k.push("--source-url",h);let l=await o("node",k,{cwd:u,timeoutMs:3e5});if(l.timed_out)return{ok:!1,status:"timeout",stderr:l.stderr};if(0!==l.exit_code)return{ok:!1,status:"failed",exit_code:l.exit_code,stderr:l.stderr};let m=(0,j.$A)(d);return m&&p(m)&&!c.allow_network_write_clis?{ok:!1,status:"refused",reason:`Security mode "${c.mode}" forbids CLIs declaring write scopes. Declared: ${JSON.stringify(m.declared_scopes)}`,cli:m}:{ok:!0,status:"generated",cli:m,security_mode:c.mode}}async function s(a={},b={}){let c,d,e=n(),h=String(a.slug||"").trim();if(!(0,j.Ac)(h))return{ok:!1,status:"invalid_input",reason:"invalid slug"};let i=(0,j.$A)(h);if(!i||"removed"===i.status)return{ok:!1,status:"not_installed",slug:h};if("disabled"===i.status)return{ok:!1,status:"disabled",slug:h};if(p(i)&&!e.allow_network_write_clis)return{ok:!1,status:"refused",reason:`Security mode "${e.mode}" forbids running CLIs with write scopes.`};let k=Array.isArray(a.args)?a.args.map(String):[];for(let a of k)if(/[;&|`$<>]/.test(a))return{ok:!1,status:"unsafe_args",reason:`argv contains shell metacharacter: ${a}`};try{(0,j.FT)(i.path)}catch(a){return{ok:!1,status:"unsafe_path",reason:a.message}}let m=process.env.GOBIN||(process.env.GOPATH?`${process.env.GOPATH}/bin`:null)||(process.env.HOME?`${process.env.HOME}/go/bin`:null),q=m?f.join(m,`${h}-pp-cli`):null,r=f.join(i.path,"bin"),t=f.join(i.path,"index.js");if(q&&g.existsSync(q))c=q,d=k;else if(g.existsSync(r))c=r,d=k;else{if(!g.existsSync(t))return{ok:!1,status:"no_entry_point",reason:`No entry point found. Tried: ${q||"(no go bin dir)"} , ${r}, ${t}`};c=process.execPath,d=[t,...k]}let u=function(a,b={}){let c={PATH:process.env.PATH,HOME:process.env.HOME,NODE_ENV:"production",PRINTING_PRESS_CLI_SLUG:a.slug,PRINTING_PRESS_DATA_DIR:a.path};for(let d of a.required_secrets||[])if("string"==typeof d&&/^[A-Z][A-Z0-9_]*$/.test(d))try{let a=(0,l.getSecret)(d,{agent_id:b.agent_id,project_id:b.project_id});a&&(c[d]=a)}catch{}return c}(i,b),v=Math.min(Number(a.timeout_ms)||6e4,3e5),w=await o(c,d,{cwd:i.path,timeoutMs:v,env:u});return{ok:0===w.exit_code,status:w.timed_out?"timeout":0===w.exit_code?"complete":"failed",slug:h,exit_code:w.exit_code,timed_out:w.timed_out,stdout:w.stdout,stderr:w.stderr,stdout_truncated:w.stdout_truncated,stderr_truncated:w.stderr_truncated,security_mode:e.mode}}let x=/\b(INSERT|UPDATE|DELETE|DROP|ALTER|CREATE|REPLACE|ATTACH|DETACH|PRAGMA|VACUUM|REINDEX|TRUNCATE)\b/i;async function t(a={},b={}){let c,d=String(a.slug||"").trim();if(!(0,j.Ac)(d))return{ok:!1,status:"invalid_input",reason:"invalid slug"};let e=(0,j.$A)(d);if(!e||"removed"===e.status)return{ok:!1,status:"not_installed",slug:d};let i=String(a.sql||"").trim();if(!i)return{ok:!1,status:"invalid_input",reason:"sql is required"};if(i.includes(";"))return{ok:!1,status:"unsafe_sql",reason:"multi-statement queries are not allowed"};if(x.test(i))return{ok:!1,status:"unsafe_sql",reason:"only SELECT-style read queries are permitted"};if(!/^\s*(SELECT|WITH)\b/i.test(i))return{ok:!1,status:"unsafe_sql",reason:"query must begin with SELECT or WITH"};let k=process.env.XDG_DATA_HOME||(process.env.HOME?f.join(process.env.HOME,".local","share"):null),l=[f.join(e.path,"data.sqlite"),f.join(e.path,`${d}.sqlite`),k?f.join(k,`${d}-pp-cli`,"data.db"):null,k?f.join(k,`${d}-pp-cli`,"data.sqlite"):null].filter(Boolean),m=l.find(a=>g.existsSync(a));if(!m)return{ok:!1,status:"no_mirror",reason:"CLI has no local SQLite mirror",tried:l};if(m.startsWith(f.resolve(e.path)+f.sep))try{(0,j.FT)(m)}catch(a){return{ok:!1,status:"unsafe_path",reason:a.message}}let n=Array.isArray(a.params)?a.params:[];try{c=new h.DatabaseSync(m,{readOnly:!0})}catch(a){return{ok:!1,status:"open_failed",reason:a.message}}try{let a=c.prepare(i).all(...n).slice(0,1e3);return{ok:!0,status:"complete",slug:d,row_count:a.length,truncated:1e3===a.length,rows:a}}catch(a){return{ok:!1,status:"query_failed",reason:a.message}}finally{try{c.close()}catch{}}}d()}catch(a){d(a)}})},81553:(a,b,c)=>{"use strict";c.d(b,{YO:()=>j,ct:()=>m,mU:()=>k,rd:()=>g,runUpdateCheck:()=>n,shouldAutoApply:()=>o});var d=c(73024),e=c(76760),f=c(73136);let g="madarx",h=`https://registry.npmjs.org/${g}/latest`,i=e.dirname((0,f.fileURLToPath)("file:///home/runner/work/madarx-os/madarx-os/lib/update-check.js"));function j(){if(process.env.MADARX_VERSION)return process.env.MADARX_VERSION;for(let a of[e.join(i,"..","package.json"),e.join(process.cwd(),"package.json"),e.join(process.cwd(),".next","standalone","package.json")]){let b=function(a){try{let b=JSON.parse(d.readFileSync(a,"utf8"));if(b&&b.name===g&&b.version)return b.version}catch{}return null}(a);if(b)return b}return"0.0.0"}function k(a,b){let c=a=>String(a).split("-")[0].split(".").slice(0,3).map(a=>parseInt(a,10)||0),d=c(a),e=c(b);for(let a=0;a<Math.max(d.length,e.length);a++){let b=(d[a]||0)-(e[a]||0);if(0!==b)return b>0?1:-1}return 0}async function l({fetchImpl:a=fetch,timeoutMs:b=4e3}={}){try{let c=await a(h,{signal:AbortSignal.timeout(b)});if(!c.ok)return null;let d=await c.json();return d?.version||null}catch{return null}}function m(a){try{return JSON.parse(d.readFileSync(a,"utf8"))}catch{return null}}async function n({file:a,current:b=j(),fetchImpl:c=fetch,nowIso:f}={}){let g=await l({fetchImpl:c}),h=f||new Date().toISOString();if(!g){let c=a?m(a):null;return{ts:h,current:b,latest:c?.latest||null,behind:!1,reachable:!1}}let i=k(g,b)>0,o={ts:h,current:b,latest:g,behind:i,reachable:!0};return a&&(d.mkdirSync(e.dirname(a),{recursive:!0}),d.writeFileSync(a,JSON.stringify(o,null,2))),o}function o({behind:a,mode:b,apply:c}){return!!a&&"weekly"===b&&"auto"===c}},81833:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{BQ:()=>o,HO:()=>s,Jh:()=>n,OT:()=>r,Om:()=>k,bz:()=>m,cN:()=>p,h5:()=>q,iF:()=>i,k2:()=>l,pp:()=>j});var e=c(34255),f=a([e]);function g(a){return a?{id:String(a.id),name:String(a.name||""),position:Number(a.position)||0,is_active:1===a.is_active,created_at:a.created_at,updated_at:a.updated_at}:null}function h(a,b){return String(a||"").trim().slice(0,32)||b}function i(){let a=(0,e.getDb)();l();let b=a.prepare("SELECT * FROM dashboard_spaces ORDER BY position ASC, created_at ASC").all().map(g),c=b.find(a=>a.is_active)||b[0]||null;return{spaces:b,active_space_id:c?c.id:null}}function j(a){if(!a)return null;let b=(0,e.getDb)().prepare("SELECT * FROM dashboard_spaces WHERE id = ?").get(String(a));return g(b)}function k(a=[],{fallback:b="default"}={}){for(let b of Array.isArray(a)?a:[a])if(b&&j(b))return b;return b}function l(){let a=(0,e.getDb)(),b=a.prepare("SELECT COUNT(*) AS n FROM dashboard_spaces").get().n;if(0===b){let b=(0,e.nowIso)();a.prepare("INSERT INTO dashboard_spaces (id, name, position, is_active, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)").run("default","main",0,1,b,b)}a.prepare("UPDATE artifacts SET space_id = 'default' WHERE space_id IS NULL").run()}function m({name:a}={}){let b=(0,e.getDb)();l();let c=b.prepare("SELECT COUNT(*) AS n FROM dashboard_spaces").get().n;if(c>=32){let a=Error("Maximum of 32 spaces reached.");throw a.code="SPACE_LIMIT",a}let d=b.prepare("SELECT MAX(position) AS m FROM dashboard_spaces").get().m,f=(Number(d)||0)+1,g=(0,e.newId)("space"),i=(0,e.nowIso)(),k=h(a,`Space ${c+1}`);return b.prepare("INSERT INTO dashboard_spaces (id, name, position, is_active, created_at, updated_at) VALUES (?, ?, ?, 0, ?, ?)").run(g,k,f,i,i),j(g)}function n(a,b){let c=j(a);if(!c){let a=Error("Space not found.");throw a.code="SPACE_NOT_FOUND",a}let d=h(b,c.name);return d===c.name?c:((0,e.getDb)().prepare("UPDATE dashboard_spaces SET name = ?, updated_at = ? WHERE id = ?").run(d,(0,e.nowIso)(),a),j(a))}function o(a){if(!j(a)){let a=Error("Space not found.");throw a.code="SPACE_NOT_FOUND",a}let b=(0,e.getDb)(),c=(0,e.nowIso)(),d=b.prepare("BEGIN IMMEDIATE");try{d.run(),b.prepare("UPDATE dashboard_spaces SET is_active = 0, updated_at = ? WHERE is_active = 1").run(c),b.prepare("UPDATE dashboard_spaces SET is_active = 1, updated_at = ? WHERE id = ?").run(c,a),b.prepare("COMMIT").run()}catch(a){try{b.prepare("ROLLBACK").run()}catch{}throw a}return j(a)}function p(a){let b=(0,e.getDb)(),c=j(a);if(!c)return null;if(b.prepare("SELECT COUNT(*) AS n FROM dashboard_spaces").get().n<=1){let a=Error("Cannot delete the last remaining space.");throw a.code="SPACE_LAST",a}let d=b.prepare("SELECT * FROM dashboard_spaces WHERE id != ? ORDER BY position ASC, created_at ASC LIMIT 1").get(a);if(!d){let a=Error("No fallback space available.");throw a.code="SPACE_NO_FALLBACK",a}let f=(0,e.nowIso)(),g=b.prepare("BEGIN IMMEDIATE");try{g.run(),b.prepare("UPDATE artifacts SET space_id = ? WHERE space_id = ?").run(d.id,a),b.prepare("UPDATE space_share_links SET revoked = 1 WHERE space_id = ? AND revoked = 0").run(a),b.prepare("DELETE FROM dashboard_spaces WHERE id = ?").run(a),c.is_active&&b.prepare("UPDATE dashboard_spaces SET is_active = 1, updated_at = ? WHERE id = ?").run(f,d.id),b.prepare("COMMIT").run()}catch(a){try{b.prepare("ROLLBACK").run()}catch{}throw a}return{deleted_id:a,moved_to:d.id}}function q(a,b){if(!a){let a=Error("artifact_id is required.");throw a.code="ARTIFACT_REQUIRED",a}let c=j(b);if(!c){let a=Error("Space not found.");throw a.code="SPACE_NOT_FOUND",a}let d=(0,e.getDb)(),f=d.prepare("SELECT id FROM artifacts WHERE id = ?").get(String(a));if(!f){let a=Error("Artifact not found.");throw a.code="ARTIFACT_NOT_FOUND",a}return d.prepare("UPDATE artifacts SET space_id = ?, pinned_to_space_at = datetime('now') WHERE id = ?").run(c.id,f.id),{artifact_id:f.id,space_id:c.id}}function r(){let a=(0,e.getDb)();l();let b=a.prepare("SELECT * FROM dashboard_spaces ORDER BY position ASC, created_at ASC").all().map(g),c=a.prepare("SELECT id, space_id FROM artifacts WHERE space_id IS NOT NULL").all(),d=new Map(b.map(a=>[a.id,[]]));for(let a of c)d.has(a.space_id)&&d.get(a.space_id).push(String(a.id));let f=b.map(a=>({...a,artifact_ids:d.get(a.id)||[]})),h=f.find(a=>a.is_active)||f[0]||null;return{spaces:f,active_space_id:h?h.id:null}}function s({spaces:a=[],active_space_id:b=null}={}){if(!Array.isArray(a)||0===a.length)return null;let c=(0,e.getDb)();l();let d=c.prepare("SELECT COUNT(*) AS n FROM dashboard_spaces").get().n;if(!(1===d&&c.prepare("SELECT id FROM dashboard_spaces WHERE id = 'default'").get()))return null;let f=a.filter(a=>a&&"string"==typeof a.id&&a.id.length>0).slice(0,32);if(0===f.length)return null;let g=(0,e.nowIso)(),i=c.prepare("BEGIN IMMEDIATE");try{i.run(),c.prepare("DELETE FROM dashboard_spaces").run(),f.forEach((a,d)=>{let e=String(a.id),f=h(a.name,`Space ${d+1}`),i=b?e===String(b):0===d;c.prepare("INSERT INTO dashboard_spaces (id, name, position, is_active, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)").run(e,f,d,+!!i,g,g);let j=Array.isArray(a.artifactIds)?a.artifactIds:[],k=c.prepare("UPDATE artifacts SET space_id = ? WHERE id = ? AND (space_id IS NULL OR space_id = ?)");for(let a of j)"string"==typeof a&&k.run(e,a,e)});let a=c.prepare("SELECT COUNT(*) AS n FROM dashboard_spaces WHERE is_active = 1").get().n;if(0===a){let a=c.prepare("SELECT id FROM dashboard_spaces ORDER BY position ASC, created_at ASC LIMIT 1").get();a&&c.prepare("UPDATE dashboard_spaces SET is_active = 1 WHERE id = ?").run(a.id)}c.prepare("COMMIT").run()}catch(a){try{c.prepare("ROLLBACK").run()}catch{}throw a}return r()}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},81992:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{cS:()=>j,r_:()=>i,vg:()=>k});var e=c(25938),f=a([e]);function g(a,{includeBody:b=!1}={}){let c=Object.fromEntries((a.payload?.headers||[]).map(a=>[String(a.name).toLowerCase(),a.value])),d={id:a.id,thread_id:a.threadId,from:c.from||null,subject:c.subject||null,date:c.date||null,snippet:a.snippet||""};return b&&(d.to=c.to||null,d.body_text=function a(b={}){if(b.body?.data)return function(a=""){if(!a)return"";try{return Buffer.from(String(a),"base64url").toString("utf8")}catch{return""}}(b.body.data);let c=Array.isArray(b.parts)?b.parts:[],d=c.find(a=>"text/plain"===a.mimeType&&a.body?.data)||c.find(a=>a.body?.data);return d?a(d):""}(a.payload||{})),d}async function h(a,b,c,d){let f=(0,e.s)(d,c),g=await f(a,{headers:{Authorization:`Bearer ${b}`}});if(!g.ok)throw Error(`google api failed: ${g.status}`);return g.json()}async function i(a={},b={}){let c="gmail_messages_list",d=await (0,e.r)(b,c),f=new URL("https://gmail.googleapis.com/gmail/v1/users/me/messages");for(let b of(a.max_results&&f.searchParams.set("maxResults",String(a.max_results)),a.q&&f.searchParams.set("q",a.q),a.label_ids||a.labelIds||[]))f.searchParams.append("labelIds",String(b));let j=(await h(f,d,b,c)).messages||[];return Promise.all(j.map(async a=>{let e=await h(`https://gmail.googleapis.com/gmail/v1/users/me/messages/${encodeURIComponent(a.id)}?format=metadata`,d,b,c);return g(e)}))}async function j(a={},b={}){if(!a.message_id)throw Error("message_id is required");let c="gmail_message_read",d=await (0,e.r)(b,c),f=await h(`https://gmail.googleapis.com/gmail/v1/users/me/messages/${encodeURIComponent(a.message_id)}?format=full`,d,b,c);return g(f,{includeBody:!0})}async function k(a={},b={}){if(!a.thread_id)throw Error("thread_id is required");let c="gmail_thread_read",d=await (0,e.r)(b,c),f=await h(`https://gmail.googleapis.com/gmail/v1/users/me/threads/${encodeURIComponent(a.thread_id)}?format=full`,d,b,c);return{id:f.id,messages:(f.messages||[]).map(a=>g(a,{includeBody:!0}))}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},83963:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Dn:()=>af,Fp:()=>ab,Fy:()=>F,G:()=>aj,HB:()=>R,Mu:()=>Z,Q4:()=>J,Qf:()=>aa,Rz:()=>X,V0:()=>ah,VI:()=>P,Vk:()=>N,WH:()=>_,WX:()=>$,X1:()=>Y,createTask:()=>S,eE:()=>ad,fI:()=>B,gf:()=>I,gg:()=>O,hC:()=>ar,hW:()=>al,iR:()=>ae,ij:()=>ap,jN:()=>G,kP:()=>D,lC:()=>U,n5:()=>aq,nV:()=>ak,qF:()=>ao,qt:()=>ai,rN:()=>ac,s_:()=>Q,sweepTasks:()=>T,uB:()=>am,vQ:()=>W,w4:()=>an,yS:()=>V,yX:()=>E,zP:()=>H});var e=c(34255),f=c(40563),g=c(61423),h=c(18313),i=a([e,f,g]);function j(a,b=null){if(!a)return b;try{return JSON.parse(a)}catch{return b}}function k(a){return null==a?null:JSON.stringify(a)}function l(a){let b=globalThis.__madarxLiveEventBus;if(!b?.subscribers)return{id:a.id||(0,e.newId)("evt"),ts:a.ts||Date.now(),...a};let c={id:a.id||`evt-${b.nextId++}-${Math.random().toString(36).slice(2,8)}`,ts:a.ts||Date.now(),...a};for(let a of b.subscribers)try{a(c)}catch{}return c}function m(a){return a?{...a,tools:j(a.tools,[]),files:j(a.files,[]),memory:j(a.memory,[]),permissions_json:j(a.permissions_json,{}),metadata_json:j(a.metadata_json,{})}:null}function n(a){return a?{...a,parent_task_id:a.parent_task_id||null,tags:j(a.tags_json,[]),watchers:j(a.watchers_json,[]),due_at:a.due_at||null,estimate_minutes:null==a.estimate_minutes?null:Number(a.estimate_minutes),recurrence:a.recurrence||null,acceptance_criteria:a.acceptance_criteria||null}:null}function o(a){return a?{id:a.id,task_id:a.task_id,label:a.label,done:!!a.done,position:Number(a.position)||0,created_at:a.created_at,done_at:a.done_at||null}:null}function p(a){if(null==a)return null;if(Array.isArray(a)){let b=a.map(a=>String(a).trim()).filter(Boolean).slice(0,24);return b.length?b:[]}return"string"==typeof a?a.split(",").map(a=>a.trim()).filter(Boolean).slice(0,24):null}function q(a){if(null==a)return null;let b=(Array.isArray(a)?a:String(a).split(",")).map(a=>String(a).trim()).filter(Boolean).slice(0,24);return Array.from(new Set(b))}function r(a){if(!a)return null;let b=String(a).trim();if(!b)return null;if(/^\d{4}-\d{2}-\d{2}$/.test(b))return`${b}T23:59:59.000Z`;let c=new Date(b);return Number.isNaN(c.getTime())?null:c.toISOString()}function s(a){if(null==a||""===a)return null;let b=Number(a);return!Number.isFinite(b)||b<0?null:Math.round(b)}function t(a){if(!a)return null;let b=String(a).trim();return b?b.length>64?b.slice(0,64):b:null}function u(a){return a?{...a}:null}function v(a){return a?{...a,payload:j(a.payload_json,null)}:null}function w(a){return a?{...a,usage:j(a.usage_json,null),result:j(a.result_json,null)}:null}function x(a){return a?{...a,payload:j(a.payload_json,null)}:null}function y(a){return a?{...a,details:j(a.details_json,null),cursor:a.seq}:null}function z(a){return m((0,e.getDb)().prepare("SELECT * FROM agents WHERE id = ?").get(a))}function A(a){if(!a)return null;let b=z(a);if(!b)throw Error(`Agent not found: ${a}`);if("terminated"===b.status)throw Error(`Terminated agents cannot receive assignments: ${a}`);return b}function B(a){if(!a?.type||!1===a.persist)return null;let b=function(a){let b={agent_run_start:"agent.run.status",agent_run_complete:"agent.run.status",agent_tool_start:"agent.run.event",agent_tool_result:"agent.run.event",log:"agent.run.log"},c=(0,h._d)(b[a.type]||a.type,null);return c&&h.eh.includes(c)?{actor_type:a.actor_type||(a.agent_id?"agent":"system"),actor_id:a.actor_id||a.agent_id||null,agent_id:a.agent_id||null,run_id:a.run_id||null,entity_type:a.entity_type||(a.task_id?"task":a.run_id?"agent_run":a.agent_id?"agent":"event"),entity_id:a.entity_id||a.task_id||a.run_id||a.id||null,action:c,details:{...a,legacy_type:b[a.type]?a.type:void 0},created_at:a.created_at||(0,e.nowIso)()}:null}(a);return b?C(b):null}function C({actor_type:a="system",actor_id:b=null,agent_id:c=null,run_id:d=null,entity_type:f=null,entity_id:g=null,action:h,details:i=null,created_at:j=(0,e.nowIso)()}={}){if(!h)throw Error("activity action is required");let l=(0,e.getDb)(),m=(0,e.newId)("activity");l.prepare(`
3504
3510
  INSERT INTO activity_log
3505
3511
  (id, actor_type, actor_id, agent_id, run_id, entity_type, entity_id, action, details_json, created_at)
3506
3512
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
@@ -3518,42 +3524,50 @@ ${b}`:b;return x(s("codex"),["exec",d],{timeoutMs:Number(process.env.CODEX_TICK_
3518
3524
  `).run(d,a.workspace_id||"local",String(a.title||"Untitled task"),a.description||null,g,i,f?.id||null,a.created_by_agent_id||null,a.created_by_user_id||null,a.parent_task_id||null,a.project_id||null,a.goal_id||null,a.blocked_reason||null,m,k(j),n,k(l),o,a.acceptance_criteria||null,a.recurred_from_task_id||null,c,c,"in_progress"===g?c:null,"done"===g?c:null,"cancelled"===g?c:null),Array.isArray(a.checklist)&&a.checklist.length){let f=b.prepare(`
3519
3525
  INSERT INTO task_checklist_items (id, task_id, label, done, position, created_at, done_at)
3520
3526
  VALUES (?, ?, ?, 0, ?, ?, NULL)
3521
- `);a.checklist.map(a=>String(a).trim()).filter(Boolean).slice(0,30).forEach((a,b)=>{f.run((0,e.newId)("ckl"),d,a,b,c)})}let u=O(d);return M(u,{action:"task.updated",liveType:"task.updated",actor_type:a.created_by_agent_id?"agent":a.created_by_user_id?"user":"system",actor_id:a.created_by_agent_id||a.created_by_user_id||null,agent_id:f?.id||null,details:{event:"created"},event_type:"task.created",wake_reason:f?"task_assigned":null}),f&&M(u,{action:"task.assigned",liveType:"task.assigned",actor_type:a.created_by_agent_id?"agent":a.created_by_user_id?"user":"system",actor_id:a.created_by_agent_id||a.created_by_user_id||null,agent_id:f.id,details:{assignee_agent_id:f.id},event_type:"task.assigned"}),a.parent_task_id&&K(a.parent_task_id,{event_type:"task.child_created",actor_type:a.created_by_agent_id?"agent":a.created_by_user_id?"user":"system",actor_id:a.created_by_agent_id||a.created_by_user_id||null,agent_id:f?.id||null,payload:{child_task_id:u.id}}),u}function T(a,b={}){let c=(0,e.getDb)(),d=O(a);if(!d)throw Error(`Task not found: ${a}`);let f=void 0===b.status?d.status:(0,h.NV)(b.status,d.status),g=void 0===b.priority?d.priority:(0,h.Hb)(b.priority,d.priority),i=void 0===b.assignee_agent_id?d.assignee_agent_id?A(d.assignee_agent_id):null:b.assignee_agent_id?A(b.assignee_agent_id):null;if((0,h.ab)(d.status,f),"in_progress"===f&&!i?.id)throw Error("in_progress requires assignee_agent_id");let j=d.assignee_agent_id!==(i?.id||null)||"in_progress"===d.status&&"in_progress"!==f,l=void 0===b.tags?d.tags:p(b.tags)||[],m=void 0===b.watchers?d.watchers:q(b.watchers)||[],n=void 0===b.due_at?d.due_at:r(b.due_at),o=void 0===b.estimate_minutes?d.estimate_minutes:s(b.estimate_minutes),u=void 0===b.recurrence?d.recurrence:t(b.recurrence),v=void 0===b.acceptance_criteria?d.acceptance_criteria:b.acceptance_criteria||null,w={title:b.title??d.title,description:b.description??d.description,status:f,priority:g,assignee_agent_id:i?.id||null,blocked_reason:"blocked"===f?b.blocked_reason??d.blocked_reason??"Blocked":b.blocked_reason??null,due_at:n,tags_json:k(l),estimate_minutes:o,watchers_json:k(m),recurrence:u,acceptance_criteria:v,checkout_run_id:j?null:d.checkout_run_id,execution_run_id:j?null:d.execution_run_id,updated_at:(0,e.nowIso)(),started_at:d.started_at||("in_progress"===f?(0,e.nowIso)():null),completed_at:"done"===f?d.completed_at||(0,e.nowIso)():null,cancelled_at:"cancelled"===f?d.cancelled_at||(0,e.nowIso)():null};c.prepare(`
3527
+ `);a.checklist.map(a=>String(a).trim()).filter(Boolean).slice(0,30).forEach((a,b)=>{f.run((0,e.newId)("ckl"),d,a,b,c)})}let u=O(d);return M(u,{action:"task.updated",liveType:"task.updated",actor_type:a.created_by_agent_id?"agent":a.created_by_user_id?"user":"system",actor_id:a.created_by_agent_id||a.created_by_user_id||null,agent_id:f?.id||null,details:{event:"created"},event_type:"task.created",wake_reason:f&&!a.suppress_wake?"task_assigned":null}),f&&M(u,{action:"task.assigned",liveType:"task.assigned",actor_type:a.created_by_agent_id?"agent":a.created_by_user_id?"user":"system",actor_id:a.created_by_agent_id||a.created_by_user_id||null,agent_id:f.id,details:{assignee_agent_id:f.id},event_type:"task.assigned"}),a.parent_task_id&&K(a.parent_task_id,{event_type:"task.child_created",actor_type:a.created_by_agent_id?"agent":a.created_by_user_id?"user":"system",actor_id:a.created_by_agent_id||a.created_by_user_id||null,agent_id:f?.id||null,payload:{child_task_id:u.id}}),u}function T({now:a=Date.now(),staleMinutes:b=30}={}){let c=(0,e.getDb)(),d=new Date(a).toISOString(),f=new Date(a-60*b*1e3).toISOString(),g={assigned_woken:[],rewoken:[],overdue_woken:[],scanned:0},i=c.prepare("SELECT 1 FROM heartbeat_tasks WHERE type = 'agent-task' AND status IN ('queued','leased','running') AND payload LIKE ? LIMIT 1"),j=(a,b,c)=>{if(al(a)||i.get(`%"task_id":"${a}"%`))return;let d=O(a);!(!d||!d.assignee_agent_id||(0,h.uB)(d.status))&&L({task:d,reason:b,triggerSource:"task-sweep"})&&g[c].push(a)},k=c.prepare("SELECT id FROM tasks WHERE status = 'todo' AND assignee_agent_id IS NOT NULL").all();for(let a of(g.scanned+=k.length,k))j(a.id,"task_assigned","assigned_woken");let l=c.prepare("SELECT id FROM tasks WHERE status = 'in_progress' AND assignee_agent_id IS NOT NULL AND updated_at < ?").all(f);for(let a of(g.scanned+=l.length,l))j(a.id,"task_blockers_resolved","rewoken");let m=c.prepare("SELECT id FROM tasks WHERE due_at IS NOT NULL AND due_at < ? AND status NOT IN ('done','cancelled')").all(d);for(let a of(g.scanned+=m.length,m))j(a.id,"task_blockers_resolved","overdue_woken");return g}function U(a,b={}){let c=(0,e.getDb)(),d=O(a);if(!d)throw Error(`Task not found: ${a}`);let f=void 0===b.status?d.status:(0,h.NV)(b.status,d.status),g=void 0===b.priority?d.priority:(0,h.Hb)(b.priority,d.priority),i=void 0===b.assignee_agent_id?d.assignee_agent_id?A(d.assignee_agent_id):null:b.assignee_agent_id?A(b.assignee_agent_id):null;if((0,h.ab)(d.status,f),"in_progress"===f&&!i?.id)throw Error("in_progress requires assignee_agent_id");let j=d.assignee_agent_id!==(i?.id||null)||"in_progress"===d.status&&"in_progress"!==f,l=void 0===b.tags?d.tags:p(b.tags)||[],m=void 0===b.watchers?d.watchers:q(b.watchers)||[],n=void 0===b.due_at?d.due_at:r(b.due_at),o=void 0===b.estimate_minutes?d.estimate_minutes:s(b.estimate_minutes),u=void 0===b.recurrence?d.recurrence:t(b.recurrence),v=void 0===b.acceptance_criteria?d.acceptance_criteria:b.acceptance_criteria||null,w={title:b.title??d.title,description:b.description??d.description,status:f,priority:g,assignee_agent_id:i?.id||null,blocked_reason:"blocked"===f?b.blocked_reason??d.blocked_reason??"Blocked":b.blocked_reason??null,due_at:n,tags_json:k(l),estimate_minutes:o,watchers_json:k(m),recurrence:u,acceptance_criteria:v,checkout_run_id:j?null:d.checkout_run_id,execution_run_id:j?null:d.execution_run_id,updated_at:(0,e.nowIso)(),started_at:d.started_at||("in_progress"===f?(0,e.nowIso)():null),completed_at:"done"===f?d.completed_at||(0,e.nowIso)():null,cancelled_at:"cancelled"===f?d.cancelled_at||(0,e.nowIso)():null};c.prepare(`
3522
3528
  UPDATE tasks SET
3523
3529
  title = ?, description = ?, status = ?, priority = ?, assignee_agent_id = ?, blocked_reason = ?,
3524
3530
  due_at = ?, tags_json = ?, estimate_minutes = ?, watchers_json = ?, recurrence = ?, acceptance_criteria = ?,
3525
3531
  checkout_run_id = ?, execution_run_id = ?, updated_at = ?, started_at = ?, completed_at = ?, cancelled_at = ?
3526
3532
  WHERE id = ?
3527
- `).run(w.title,w.description,w.status,w.priority,w.assignee_agent_id,w.blocked_reason,w.due_at,w.tags_json,w.estimate_minutes,w.watchers_json,w.recurrence,w.acceptance_criteria,w.checkout_run_id,w.execution_run_id,w.updated_at,w.started_at,w.completed_at,w.cancelled_at,a);let x=O(a),y=b.actor_type||"system",z=b.actor_id||null;if(d.assignee_agent_id!==x.assignee_agent_id&&M(x,{action:d.assignee_agent_id?"task.reassigned":"task.assigned",liveType:d.assignee_agent_id?"task.reassigned":"task.assigned",actor_type:y,actor_id:z,agent_id:x.assignee_agent_id,details:{from:d.assignee_agent_id,to:x.assignee_agent_id,execution_lock_cleared:j},event_type:d.assignee_agent_id?"task.reassigned":"task.assigned",wake_reason:d.assignee_agent_id?"task_reassigned":"task_assigned"}),d.status!==x.status&&M(x,{action:"task.updated",liveType:"task.updated",actor_type:y,actor_id:z,agent_id:x.assignee_agent_id,details:{from:d.status,to:x.status,execution_lock_cleared:j},event_type:"blocked"===x.status?"task.blocked":"done"===x.status?"task.completed":"cancelled"===x.status?"task.cancelled":"blocked"===d.status?"task.unblocked":"task.status_changed",wake_reason:"blocked"===d.status&&"blocked"!==x.status?"task_blockers_resolved":null}),void 0!==b.title||void 0!==b.description||void 0!==b.priority||void 0!==b.due_at||void 0!==b.tags||void 0!==b.estimate_minutes||void 0!==b.watchers||void 0!==b.recurrence||void 0!==b.acceptance_criteria){let a=["title","description","priority","due_at","tags","estimate_minutes","watchers","recurrence","acceptance_criteria"].filter(a=>void 0!==b[a]);M(x,{action:"task.updated",liveType:"task.updated",actor_type:y,actor_id:z,agent_id:x.assignee_agent_id,details:{fields:a},event_type:"task.updated"})}if("done"!==d.status&&"done"===x.status&&x.recurrence&&!x.recurred_from_task_id)try{!function(a,{actor_type:b="system",actor_id:c=null}={}){let d=function(a,b){if(!a)return null;let c=new Date(b||Date.now());if(Number.isNaN(c.getTime()))return null;let d=String(a).trim().toLowerCase(),e=d.match(/^every\s+(\d+)\s*(m|h|d|w)$/);if(e){let a=Number(e[1]),b=e[2];return new Date(c.getTime()+("m"===b?6e4*a:"h"===b?36e5*a:"d"===b?864e5*a:7*a*864e5)).toISOString()}if("daily"===d||/^daily\b/.test(d))return new Date(c.getTime()+864e5).toISOString();if("weekly"===d||/^weekly\b/.test(d))return new Date(c.getTime()+6048e5).toISOString();if("monthly"===d||/^monthly\b/.test(d)){let a=new Date(c);return a.setUTCMonth(a.getUTCMonth()+1),a.toISOString()}return null}(a.recurrence,a.due_at||(0,e.nowIso)());if(!d)return;let f=U(a.id).map(a=>a.label);S({title:a.title,description:a.description,project_id:a.project_id,assignee_agent_id:a.assignee_agent_id,priority:a.priority,parent_task_id:a.parent_task_id,goal_id:a.goal_id,due_at:d,tags:a.tags,watchers:a.watchers,estimate_minutes:a.estimate_minutes,recurrence:a.recurrence,acceptance_criteria:a.acceptance_criteria,recurred_from_task_id:a.id,checklist:f,created_by_agent_id:"agent"===b?c:null,created_by_user_id:"user"===b?c:null,status:a.assignee_agent_id?"todo":"backlog"})}(x,{actor_type:y,actor_id:z})}catch(a){console.warn(`[delegation] recurrence rollover failed for task ${x.id}:`,a?.message||a)}return x}function U(a){return(0,e.getDb)().prepare("SELECT * FROM task_checklist_items WHERE task_id = ? ORDER BY position ASC, created_at ASC").all(a).map(o)}function V(a,{label:b,position:c}={}){if(!O(a))throw Error(`Task not found: ${a}`);let d=String(b||"").trim();if(!d)throw Error("label is required");let f=(0,e.getDb)(),g=U(a),h=null==c?g.length:Math.max(0,Math.min(g.length,Number(c))),i=(0,e.newId)("ckl");return f.prepare(`
3533
+ `).run(w.title,w.description,w.status,w.priority,w.assignee_agent_id,w.blocked_reason,w.due_at,w.tags_json,w.estimate_minutes,w.watchers_json,w.recurrence,w.acceptance_criteria,w.checkout_run_id,w.execution_run_id,w.updated_at,w.started_at,w.completed_at,w.cancelled_at,a);let x=O(a),y=b.actor_type||"system",z=b.actor_id||null;if(d.assignee_agent_id!==x.assignee_agent_id&&M(x,{action:d.assignee_agent_id?"task.reassigned":"task.assigned",liveType:d.assignee_agent_id?"task.reassigned":"task.assigned",actor_type:y,actor_id:z,agent_id:x.assignee_agent_id,details:{from:d.assignee_agent_id,to:x.assignee_agent_id,execution_lock_cleared:j},event_type:d.assignee_agent_id?"task.reassigned":"task.assigned",wake_reason:d.assignee_agent_id?"task_reassigned":"task_assigned"}),d.status!==x.status&&M(x,{action:"task.updated",liveType:"task.updated",actor_type:y,actor_id:z,agent_id:x.assignee_agent_id,details:{from:d.status,to:x.status,execution_lock_cleared:j},event_type:"blocked"===x.status?"task.blocked":"done"===x.status?"task.completed":"cancelled"===x.status?"task.cancelled":"blocked"===d.status?"task.unblocked":"task.status_changed",wake_reason:"blocked"===d.status&&"blocked"!==x.status?"task_blockers_resolved":null}),void 0!==b.title||void 0!==b.description||void 0!==b.priority||void 0!==b.due_at||void 0!==b.tags||void 0!==b.estimate_minutes||void 0!==b.watchers||void 0!==b.recurrence||void 0!==b.acceptance_criteria){let a=["title","description","priority","due_at","tags","estimate_minutes","watchers","recurrence","acceptance_criteria"].filter(a=>void 0!==b[a]);M(x,{action:"task.updated",liveType:"task.updated",actor_type:y,actor_id:z,agent_id:x.assignee_agent_id,details:{fields:a},event_type:"task.updated"})}if("done"!==d.status&&"done"===x.status&&x.recurrence&&!x.recurred_from_task_id)try{!function(a,{actor_type:b="system",actor_id:c=null}={}){let d=function(a,b){if(!a)return null;let c=new Date(b||Date.now());if(Number.isNaN(c.getTime()))return null;let d=String(a).trim().toLowerCase(),e=d.match(/^every\s+(\d+)\s*(m|h|d|w)$/);if(e){let a=Number(e[1]),b=e[2];return new Date(c.getTime()+("m"===b?6e4*a:"h"===b?36e5*a:"d"===b?864e5*a:7*a*864e5)).toISOString()}if("daily"===d||/^daily\b/.test(d))return new Date(c.getTime()+864e5).toISOString();if("weekly"===d||/^weekly\b/.test(d))return new Date(c.getTime()+6048e5).toISOString();if("monthly"===d||/^monthly\b/.test(d)){let a=new Date(c);return a.setUTCMonth(a.getUTCMonth()+1),a.toISOString()}return null}(a.recurrence,a.due_at||(0,e.nowIso)());if(!d)return;let f=V(a.id).map(a=>a.label);S({title:a.title,description:a.description,project_id:a.project_id,assignee_agent_id:a.assignee_agent_id,priority:a.priority,parent_task_id:a.parent_task_id,goal_id:a.goal_id,due_at:d,tags:a.tags,watchers:a.watchers,estimate_minutes:a.estimate_minutes,recurrence:a.recurrence,acceptance_criteria:a.acceptance_criteria,recurred_from_task_id:a.id,checklist:f,created_by_agent_id:"agent"===b?c:null,created_by_user_id:"user"===b?c:null,status:a.assignee_agent_id?"todo":"backlog"})}(x,{actor_type:y,actor_id:z})}catch(a){console.warn(`[delegation] recurrence rollover failed for task ${x.id}:`,a?.message||a)}return x}function V(a){return(0,e.getDb)().prepare("SELECT * FROM task_checklist_items WHERE task_id = ? ORDER BY position ASC, created_at ASC").all(a).map(o)}function W(a,{label:b,position:c}={}){if(!O(a))throw Error(`Task not found: ${a}`);let d=String(b||"").trim();if(!d)throw Error("label is required");let f=(0,e.getDb)(),g=V(a),h=null==c?g.length:Math.max(0,Math.min(g.length,Number(c))),i=(0,e.newId)("ckl");return f.prepare(`
3528
3534
  INSERT INTO task_checklist_items (id, task_id, label, done, position, created_at, done_at)
3529
3535
  VALUES (?, ?, ?, 0, ?, ?, NULL)
3530
- `).run(i,a,d.slice(0,240),h,(0,e.nowIso)()),o(f.prepare("SELECT * FROM task_checklist_items WHERE id = ?").get(i))}function W(a,b={}){let c=(0,e.getDb)(),d=c.prepare("SELECT * FROM task_checklist_items WHERE id = ?").get(a);if(!d)throw Error(`Checklist item not found: ${a}`);let f=void 0===b.label?d.label:String(b.label||"").trim().slice(0,240),g=void 0===b.done?!!d.done:!!b.done,h=g?d.done_at||(0,e.nowIso)():null;return c.prepare("UPDATE task_checklist_items SET label = ?, done = ?, done_at = ? WHERE id = ?").run(f,+!!g,h,a),o(c.prepare("SELECT * FROM task_checklist_items WHERE id = ?").get(a))}function X(a){return(0,e.getDb)().prepare("DELETE FROM task_checklist_items WHERE id = ?").run(a),{ok:!0}}function Y(a){return(0,e.getDb)().prepare("SELECT id, run_id, agent_id, path, kind, title, created_at FROM artifacts WHERE task_id = ? ORDER BY created_at DESC").all(a)}function Z(a,b){return(0,e.getDb)().prepare("UPDATE artifacts SET task_id = ? WHERE id = ?").run(b,a),{ok:!0}}function $(a,{body:b,author_agent_id:c=null,author_user_id:d=null,created_by_run_id:f=null}={}){let g=O(a);if(!g)throw Error(`Task not found: ${a}`);let h=(0,e.getDb)(),i=(0,e.newId)("comment"),j=(0,e.nowIso)();return h.prepare(`
3536
+ `).run(i,a,d.slice(0,240),h,(0,e.nowIso)()),o(f.prepare("SELECT * FROM task_checklist_items WHERE id = ?").get(i))}function X(a,b={}){let c=(0,e.getDb)(),d=c.prepare("SELECT * FROM task_checklist_items WHERE id = ?").get(a);if(!d)throw Error(`Checklist item not found: ${a}`);let f=void 0===b.label?d.label:String(b.label||"").trim().slice(0,240),g=void 0===b.done?!!d.done:!!b.done,h=g?d.done_at||(0,e.nowIso)():null;return c.prepare("UPDATE task_checklist_items SET label = ?, done = ?, done_at = ? WHERE id = ?").run(f,+!!g,h,a),o(c.prepare("SELECT * FROM task_checklist_items WHERE id = ?").get(a))}function Y(a){return(0,e.getDb)().prepare("DELETE FROM task_checklist_items WHERE id = ?").run(a),{ok:!0}}function Z(a){return(0,e.getDb)().prepare("SELECT id, run_id, agent_id, path, kind, title, created_at FROM artifacts WHERE task_id = ? ORDER BY created_at DESC").all(a)}function $(a,b){return(0,e.getDb)().prepare("UPDATE artifacts SET task_id = ? WHERE id = ?").run(b,a),{ok:!0}}function _(a,{body:b,author_agent_id:c=null,author_user_id:d=null,created_by_run_id:f=null}={}){let g=O(a);if(!g)throw Error(`Task not found: ${a}`);let h=(0,e.getDb)(),i=(0,e.newId)("comment"),j=(0,e.nowIso)();return h.prepare(`
3531
3537
  INSERT INTO task_comments (id, task_id, author_agent_id, author_user_id, created_by_run_id, body, created_at)
3532
3538
  VALUES (?, ?, ?, ?, ?, ?, ?)
3533
- `).run(i,a,c,d,f,String(b||"").trim(),j),K(a,{event_type:"task.comment_added",actor_type:c?"agent":d?"user":"system",actor_id:c||d||null,agent_id:g.assignee_agent_id||null,run_id:f,payload:{comment_id:i}}),C({actor_type:c?"agent":d?"user":"system",actor_id:c||d||null,agent_id:g.assignee_agent_id||null,run_id:f,entity_type:"task",entity_id:a,action:"task.comment.added",details:{comment_id:i,body:String(b||"").slice(0,400)}}),l({type:"task.comment.added",task_id:a,agent_id:g.assignee_agent_id||null,actor_type:c?"agent":d?"user":"system",actor_id:c||d||null,run_id:f,entity_type:"task",entity_id:a,details:{comment_id:i},persist:!1}),g.assignee_agent_id&&g.assignee_agent_id!==c&&L({task:g,reason:"task_commented",commentId:i,actorId:c||d||null,triggerSource:"task.comment.added"}),u(h.prepare("SELECT * FROM task_comments WHERE id = ?").get(i))}function _(a,{run_id:b=null}={}){let c=(0,e.getDb)(),d=b||(0,e.newId)("checkout"),f=(0,e.nowIso)();if(!c.prepare(`
3539
+ `).run(i,a,c,d,f,String(b||"").trim(),j),K(a,{event_type:"task.comment_added",actor_type:c?"agent":d?"user":"system",actor_id:c||d||null,agent_id:g.assignee_agent_id||null,run_id:f,payload:{comment_id:i}}),C({actor_type:c?"agent":d?"user":"system",actor_id:c||d||null,agent_id:g.assignee_agent_id||null,run_id:f,entity_type:"task",entity_id:a,action:"task.comment.added",details:{comment_id:i,body:String(b||"").slice(0,400)}}),l({type:"task.comment.added",task_id:a,agent_id:g.assignee_agent_id||null,actor_type:c?"agent":d?"user":"system",actor_id:c||d||null,run_id:f,entity_type:"task",entity_id:a,details:{comment_id:i},persist:!1}),g.assignee_agent_id&&g.assignee_agent_id!==c&&L({task:g,reason:"task_commented",commentId:i,actorId:c||d||null,triggerSource:"task.comment.added"}),u(h.prepare("SELECT * FROM task_comments WHERE id = ?").get(i))}function aa(a,{run_id:b=null}={}){let c=(0,e.getDb)(),d=b||(0,e.newId)("checkout"),f=(0,e.nowIso)();if(!c.prepare(`
3534
3540
  UPDATE tasks
3535
3541
  SET checkout_run_id = ?, execution_run_id = COALESCE(execution_run_id, ?), updated_at = ?, started_at = COALESCE(started_at, ?), status = CASE WHEN status = 'todo' THEN 'in_progress' ELSE status END
3536
3542
  WHERE id = ? AND assignee_agent_id IS NOT NULL AND (checkout_run_id IS NULL OR checkout_run_id = ?)
3537
- `).run(d,b||null,f,f,a,d).changes)throw Error("Task checkout failed");return O(a)}function aa(a,{clearExecution:b=!0}={}){return(0,e.getDb)().prepare(`
3543
+ `).run(d,b||null,f,f,a,d).changes)throw Error("Task checkout failed");return O(a)}function ab(a,{clearExecution:b=!0}={}){return(0,e.getDb)().prepare(`
3538
3544
  UPDATE tasks
3539
3545
  SET checkout_run_id = NULL, execution_run_id = CASE WHEN ? THEN NULL ELSE execution_run_id END, updated_at = ?
3540
3546
  WHERE id = ?
3541
- `).run(+!!b,(0,e.nowIso)(),a),O(a)}function ab(a){return w((0,e.getDb)().prepare("SELECT * FROM agent_runs WHERE id = ?").get(a))}function ac({task_id:a,agent_id:b,status:c,limit:d=100}={}){let f=[],g=[];a&&(f.push("task_id = ?"),g.push(a)),b&&(f.push("agent_id = ?"),g.push(b)),c&&(f.push("status = ?"),g.push(c));let h=f.length?`WHERE ${f.join(" AND ")}`:"";return(0,e.getDb)().prepare(`SELECT * FROM agent_runs ${h} ORDER BY created_at DESC LIMIT ?`).all(...g,d).map(w)}function ad(a){return(0,e.getDb)().prepare("SELECT * FROM agent_run_events WHERE run_id = ? ORDER BY seq ASC").all(a).map(x)}function ae(a,{agent_id:b=null,task_id:c=null,event_type:d="log",stream:f="system",level:g="info",message:i="",payload:j=null,created_at:m=(0,e.nowIso)()}={}){if(!h.rb.includes(d))throw Error(`Invalid run event type: ${d}`);let n=(0,e.getDb)(),o=(0,e.newId)("arunevt"),p=function(a){let b=(0,e.getDb)().prepare("SELECT COALESCE(MAX(seq), 0) AS max_seq FROM agent_run_events WHERE run_id = ?").get(a);return Number(b?.max_seq||0)+1}(a);n.prepare(`
3547
+ `).run(+!!b,(0,e.nowIso)(),a),O(a)}function ac(a){return w((0,e.getDb)().prepare("SELECT * FROM agent_runs WHERE id = ?").get(a))}function ad({task_id:a,agent_id:b,status:c,limit:d=100}={}){let f=[],g=[];a&&(f.push("task_id = ?"),g.push(a)),b&&(f.push("agent_id = ?"),g.push(b)),c&&(f.push("status = ?"),g.push(c));let h=f.length?`WHERE ${f.join(" AND ")}`:"";return(0,e.getDb)().prepare(`SELECT * FROM agent_runs ${h} ORDER BY created_at DESC LIMIT ?`).all(...g,d).map(w)}function ae(a){return(0,e.getDb)().prepare("SELECT * FROM agent_run_events WHERE run_id = ? ORDER BY seq ASC").all(a).map(x)}function af(a,{agent_id:b=null,task_id:c=null,event_type:d="log",stream:f="system",level:g="info",message:i="",payload:j=null,created_at:m=(0,e.nowIso)()}={}){if(!h.rb.includes(d))throw Error(`Invalid run event type: ${d}`);let n=(0,e.getDb)(),o=(0,e.newId)("arunevt"),p=function(a){let b=(0,e.getDb)().prepare("SELECT COALESCE(MAX(seq), 0) AS max_seq FROM agent_run_events WHERE run_id = ?").get(a);return Number(b?.max_seq||0)+1}(a);n.prepare(`
3542
3548
  INSERT INTO agent_run_events
3543
3549
  (id, run_id, agent_id, task_id, seq, event_type, stream, level, message, payload_json, created_at)
3544
3550
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
3545
- `).run(o,a,b,c,p,d,f,g,i||null,k(j),m);let q=x(n.prepare("SELECT * FROM agent_run_events WHERE id = ?").get(o));return l({type:"log"===d?"agent.run.log":"agent.run.event",agent_id:b,run_id:a,task_id:c,entity_type:c?"task":"agent_run",entity_id:c||a,details:{event_type:d,level:g,message:i,payload:j,seq:p},persist:!1}),q}function af(a,b={}){let c=ab(a);if(!c)throw Error(`Run not found: ${a}`);let d=(0,e.getDb)(),f=b.status?(0,h.vI)(b.status,c.status):c.status,g=(0,e.nowIso)();return d.prepare(`
3551
+ `).run(o,a,b,c,p,d,f,g,i||null,k(j),m);let q=x(n.prepare("SELECT * FROM agent_run_events WHERE id = ?").get(o));return l({type:"log"===d?"agent.run.log":"agent.run.event",agent_id:b,run_id:a,task_id:c,entity_type:c?"task":"agent_run",entity_id:c||a,details:{event_type:d,level:g,message:i,payload:j,seq:p},persist:!1}),q}function ag(a,b={}){let c=ac(a);if(!c)throw Error(`Run not found: ${a}`);let d=(0,e.getDb)(),f=b.status?(0,h.vI)(b.status,c.status):c.status,g=(0,e.nowIso)();return d.prepare(`
3546
3552
  UPDATE agent_runs
3547
3553
  SET status = ?, started_at = COALESCE(?, started_at), finished_at = ?, error = ?, session_id_after = COALESCE(?, session_id_after),
3548
3554
  usage_json = COALESCE(?, usage_json), result_json = COALESCE(?, result_json), stdout_excerpt = COALESCE(?, stdout_excerpt),
3549
3555
  stderr_excerpt = COALESCE(?, stderr_excerpt), updated_at = ?
3550
3556
  WHERE id = ?
3551
- `).run(f,b.started_at||null,b.finished_at||null,b.error??null,b.session_id_after||null,b.usage?k(b.usage):null,b.result?k(b.result):null,b.stdout_excerpt||null,b.stderr_excerpt||null,g,a),C({actor_type:"agent",actor_id:c.agent_id,agent_id:c.agent_id,run_id:a,entity_type:c.task_id?"task":"agent_run",entity_id:c.task_id||a,action:"agent.run.status",details:{status:f,error:b.error||null}}),l({type:"agent.run.status",agent_id:c.agent_id,run_id:a,task_id:c.task_id,entity_type:c.task_id?"task":"agent_run",entity_id:c.task_id||a,details:{status:f,error:b.error||null},persist:!1}),ab(a)}function ag(a){let b=ab(a),c=(0,e.nowIso)(),d=af(a,{status:"running",started_at:b?.started_at||c});return ae(a,{agent_id:d.agent_id,task_id:d.task_id,event_type:"lifecycle",message:"Run started",payload:{status:"running"}}),d.task_id&&_(d.task_id,{run_id:a}),d}function ah(a,{message:b="Approval required",payload:c=null}={}){let d=af(a,{status:"waiting_approval"});return ae(a,{agent_id:d.agent_id,task_id:d.task_id,event_type:"approval_required",level:"warn",message:b,payload:c}),d}function ai(a,{status:b="succeeded",error:c=null,usage:d=null,result:f=null,stdout_excerpt:g=null,stderr_excerpt:i=null,session_id_after:j=null}={}){let k=(0,h.vI)(b,"succeeded"),l=(0,e.nowIso)(),m=af(a,{status:k,finished_at:l,error:c,usage:d,result:f,stdout_excerpt:g,stderr_excerpt:i,session_id_after:j});return ae(a,{agent_id:m.agent_id,task_id:m.task_id,event_type:c?"error":"lifecycle",level:c?"error":"info",message:c||`Run ${k}`,payload:{status:k}}),m.task_id&&aa(m.task_id,{clearExecution:!0}),m}function aj(a){return ai(a,{status:"cancelled",error:"Cancelled by user"})}function ak(a){return w((0,e.getDb)().prepare(`
3557
+ `).run(f,b.started_at||null,b.finished_at||null,b.error??null,b.session_id_after||null,b.usage?k(b.usage):null,b.result?k(b.result):null,b.stdout_excerpt||null,b.stderr_excerpt||null,g,a),C({actor_type:"agent",actor_id:c.agent_id,agent_id:c.agent_id,run_id:a,entity_type:c.task_id?"task":"agent_run",entity_id:c.task_id||a,action:"agent.run.status",details:{status:f,error:b.error||null}}),l({type:"agent.run.status",agent_id:c.agent_id,run_id:a,task_id:c.task_id,entity_type:c.task_id?"task":"agent_run",entity_id:c.task_id||a,details:{status:f,error:b.error||null},persist:!1}),ac(a)}function ah(a){let b=ac(a),c=(0,e.nowIso)(),d=ag(a,{status:"running",started_at:b?.started_at||c});return af(a,{agent_id:d.agent_id,task_id:d.task_id,event_type:"lifecycle",message:"Run started",payload:{status:"running"}}),d.task_id&&aa(d.task_id,{run_id:a}),d}function ai(a,{message:b="Approval required",payload:c=null}={}){let d=ag(a,{status:"waiting_approval"});return af(a,{agent_id:d.agent_id,task_id:d.task_id,event_type:"approval_required",level:"warn",message:b,payload:c}),d}function aj(a,{status:b="succeeded",error:c=null,usage:d=null,result:f=null,stdout_excerpt:g=null,stderr_excerpt:i=null,session_id_after:j=null}={}){let k=(0,h.vI)(b,"succeeded"),l=(0,e.nowIso)(),m=ag(a,{status:k,finished_at:l,error:c,usage:d,result:f,stdout_excerpt:g,stderr_excerpt:i,session_id_after:j});return af(a,{agent_id:m.agent_id,task_id:m.task_id,event_type:c?"error":"lifecycle",level:c?"error":"info",message:c||`Run ${k}`,payload:{status:k}}),m.task_id&&ab(m.task_id,{clearExecution:!0}),m}function ak(a){return aj(a,{status:"cancelled",error:"Cancelled by user"})}function al(a){return w((0,e.getDb)().prepare(`
3552
3558
  SELECT * FROM agent_runs
3553
3559
  WHERE task_id = ? AND status IN ('queued', 'running', 'waiting_approval')
3554
3560
  ORDER BY created_at DESC
3555
3561
  LIMIT 1
3556
- `).get(a))}function al(a){let b=O(a);if(!b)return null;let c=ak(a),d=w((0,e.getDb)().prepare(`
3562
+ `).get(a))}function am({limit:a=50}={}){return(0,e.getDb)().prepare(`
3563
+ SELECT r.id, r.agent_id, r.status, r.trigger_source, r.started_at, r.created_at, r.task_id,
3564
+ a.name AS agent_name
3565
+ FROM agent_runs r
3566
+ LEFT JOIN agents a ON a.id = r.agent_id
3567
+ WHERE r.status IN ('queued', 'running', 'waiting_approval')
3568
+ ORDER BY r.created_at DESC
3569
+ LIMIT ?
3570
+ `).all(a).map(a=>({run_id:a.id,agent_id:a.agent_id,agent_name:a.agent_name||a.agent_id,status:a.status,triggered_by:a.trigger_source||null,started_at:a.started_at||a.created_at||null,task_id:a.task_id||null}))}function an(a){let b=O(a);if(!b)return null;let c=al(a),d=w((0,e.getDb)().prepare(`
3557
3571
  SELECT * FROM agent_runs
3558
3572
  WHERE task_id = ?
3559
3573
  ORDER BY created_at DESC
@@ -3563,7 +3577,7 @@ ${b}`:b;return x(s("codex"),["exec",d],{timeoutMs:Number(process.env.CODEX_TICK_
3563
3577
  WHERE task_id = ? AND status IN ('failed', 'timed_out', 'cancelled')
3564
3578
  ORDER BY COALESCE(finished_at, updated_at, created_at) DESC
3565
3579
  LIMIT 1
3566
- `).get(a)),g="blocked"===b.status||c?.status==="waiting_approval"||!!f?.error;return{task_id:a,active_run_id:c?.id||null,active_run_status:c?.status||null,last_run_id:d?.id||null,last_run_status:d?.status||null,last_failure_run_id:f?.id||null,last_failure_status:f?.status||null,last_failure_error:f?.error||null,checkout_run_id:b.checkout_run_id||null,execution_run_id:b.execution_run_id||null,needs_action:g,needs_action_reason:"blocked"===b.status?b.blocked_reason||"Task is blocked":c?.status==="waiting_approval"?"Run is waiting for approval":f?.error?f.error:null}}function am(a){return ac({task_id:a}).filter(a=>(0,h.MK)(a.status))}function an(a,b={}){let c=(0,e.getDb)(),d=(0,e.nowIso)();c.prepare(`
3580
+ `).get(a)),g="blocked"===b.status||c?.status==="waiting_approval"||!!f?.error;return{task_id:a,active_run_id:c?.id||null,active_run_status:c?.status||null,last_run_id:d?.id||null,last_run_status:d?.status||null,last_failure_run_id:f?.id||null,last_failure_status:f?.status||null,last_failure_error:f?.error||null,checkout_run_id:b.checkout_run_id||null,execution_run_id:b.execution_run_id||null,needs_action:g,needs_action_reason:"blocked"===b.status?b.blocked_reason||"Task is blocked":c?.status==="waiting_approval"?"Run is waiting for approval":f?.error?f.error:null}}function ao(a){return ad({task_id:a}).filter(a=>(0,h.MK)(a.status))}function ap(a,b={}){let c=(0,e.getDb)(),d=(0,e.nowIso)();c.prepare(`
3567
3581
  INSERT INTO agent_runtime_state
3568
3582
  (agent_id, session_id, state_json, last_run_id, last_run_status, total_input_tokens, total_output_tokens,
3569
3583
  total_cached_input_tokens, total_cost_cents, last_error, created_at, updated_at)
@@ -3579,12 +3593,12 @@ ${b}`:b;return x(s("codex"),["exec",d],{timeoutMs:Number(process.env.CODEX_TICK_
3579
3593
  total_cost_cents = excluded.total_cost_cents,
3580
3594
  last_error = excluded.last_error,
3581
3595
  updated_at = excluded.updated_at
3582
- `).run(a,b.session_id||null,b.state?k(b.state):null,b.last_run_id||null,b.last_run_status||null,Number(b.total_input_tokens||0),Number(b.total_output_tokens||0),Number(b.total_cached_input_tokens||0),Number(b.total_cost_cents||0),b.last_error||null,d,d)}function ao({task_id:a,agent_id:b,trigger_source:c="task_assigned",trigger_detail:d=null}={}){if(!O(a))throw Error(`Task not found: ${a}`);if(!b)throw Error("agent_id is required for task runs");let f=function({agent_id:a,task_id:b=null,trigger_source:c="manual",trigger_detail:d=null,status:f="queued",session_id_before:g=null}={}){if(!a)throw Error("agent_id is required");let i=(0,e.getDb)(),j=(0,e.nowIso)(),k=(0,e.newId)("arun");return i.prepare(`
3596
+ `).run(a,b.session_id||null,b.state?k(b.state):null,b.last_run_id||null,b.last_run_status||null,Number(b.total_input_tokens||0),Number(b.total_output_tokens||0),Number(b.total_cached_input_tokens||0),Number(b.total_cost_cents||0),b.last_error||null,d,d)}function aq({task_id:a,agent_id:b,trigger_source:c="task_assigned",trigger_detail:d=null}={}){if(!O(a))throw Error(`Task not found: ${a}`);if(!b)throw Error("agent_id is required for task runs");let f=function({agent_id:a,task_id:b=null,trigger_source:c="manual",trigger_detail:d=null,status:f="queued",session_id_before:g=null}={}){if(!a)throw Error("agent_id is required");let i=(0,e.getDb)(),j=(0,e.nowIso)(),k=(0,e.newId)("arun");return i.prepare(`
3583
3597
  INSERT INTO agent_runs
3584
3598
  (id, agent_id, task_id, trigger_source, trigger_detail, status, started_at, finished_at, error,
3585
3599
  session_id_before, session_id_after, usage_json, result_json, stdout_excerpt, stderr_excerpt, created_at, updated_at)
3586
3600
  VALUES (?, ?, ?, ?, ?, ?, NULL, NULL, NULL, ?, NULL, NULL, NULL, NULL, NULL, ?, ?)
3587
- `).run(k,a,b,c,d,(0,h.vI)(f),g,j,j),ae(k,{agent_id:a,task_id:b,event_type:"lifecycle",level:"info",message:"Run queued",payload:{status:"queued"}}),C({actor_type:"agent",actor_id:a,agent_id:a,run_id:k,entity_type:b?"task":"agent_run",entity_id:b||k,action:"agent.run.queued",details:{trigger_source:c,trigger_detail:d,task_id:b}}),l({type:"agent.run.queued",agent_id:a,run_id:k,task_id:b,entity_type:b?"task":"agent_run",entity_id:b||k,details:{trigger_source:c,trigger_detail:d},persist:!1}),ab(k)}({agent_id:b,task_id:a,trigger_source:c,trigger_detail:d});return _(a,{run_id:f.id}),!function({agent_id:a,task_key:b,adapter_type:c="default",session_params:d=null,session_display_id:f=null,last_run_id:g=null,last_error:h=null}={}){if(!a||!b)return;let i=(0,e.getDb)(),j=(0,e.nowIso)(),l=i.prepare("SELECT id FROM agent_task_sessions WHERE agent_id = ? AND task_key = ?").get(a,b),m=l?.id||(0,e.newId)("atsession");i.prepare(`
3601
+ `).run(k,a,b,c,d,(0,h.vI)(f),g,j,j),af(k,{agent_id:a,task_id:b,event_type:"lifecycle",level:"info",message:"Run queued",payload:{status:"queued"}}),C({actor_type:"agent",actor_id:a,agent_id:a,run_id:k,entity_type:b?"task":"agent_run",entity_id:b||k,action:"agent.run.queued",details:{trigger_source:c,trigger_detail:d,task_id:b}}),l({type:"agent.run.queued",agent_id:a,run_id:k,task_id:b,entity_type:b?"task":"agent_run",entity_id:b||k,details:{trigger_source:c,trigger_detail:d},persist:!1}),ac(k)}({agent_id:b,task_id:a,trigger_source:c,trigger_detail:d});return aa(a,{run_id:f.id}),!function({agent_id:a,task_key:b,adapter_type:c="default",session_params:d=null,session_display_id:f=null,last_run_id:g=null,last_error:h=null}={}){if(!a||!b)return;let i=(0,e.getDb)(),j=(0,e.nowIso)(),l=i.prepare("SELECT id FROM agent_task_sessions WHERE agent_id = ? AND task_key = ?").get(a,b),m=l?.id||(0,e.newId)("atsession");i.prepare(`
3588
3602
  INSERT INTO agent_task_sessions
3589
3603
  (id, agent_id, task_key, adapter_type, session_params_json, session_display_id, last_run_id, last_error, created_at, updated_at)
3590
3604
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
@@ -3595,7 +3609,7 @@ ${b}`:b;return x(s("codex"),["exec",d],{timeoutMs:Number(process.env.CODEX_TICK_
3595
3609
  last_run_id = COALESCE(excluded.last_run_id, agent_task_sessions.last_run_id),
3596
3610
  last_error = excluded.last_error,
3597
3611
  updated_at = excluded.updated_at
3598
- `).run(m,a,b,c,d?k(d):null,f,g,h,j,j)}({agent_id:b,task_key:a,last_run_id:f.id}),f}function ap(){let a=(0,e.getDb)(),b=b=>a.prepare(b).get(),c=b=>a.prepare(b).all();return{tasks_by_status:c("SELECT status, COUNT(*) AS count FROM tasks GROUP BY status ORDER BY status ASC"),tasks_by_assignee:c("SELECT assignee_agent_id, COUNT(*) AS count FROM tasks GROUP BY assignee_agent_id ORDER BY count DESC"),blocked_tasks:N({status:"blocked",limit:100}),stale_tasks:c(`
3612
+ `).run(m,a,b,c,d?k(d):null,f,g,h,j,j)}({agent_id:b,task_key:a,last_run_id:f.id}),f}function ar(){let a=(0,e.getDb)(),b=b=>a.prepare(b).get(),c=b=>a.prepare(b).all();return{tasks_by_status:c("SELECT status, COUNT(*) AS count FROM tasks GROUP BY status ORDER BY status ASC"),tasks_by_assignee:c("SELECT assignee_agent_id, COUNT(*) AS count FROM tasks GROUP BY assignee_agent_id ORDER BY count DESC"),blocked_tasks:N({status:"blocked",limit:100}),stale_tasks:c(`
3599
3613
  SELECT * FROM task_lifecycle_view
3600
3614
  WHERE status IN ('todo', 'in_progress', 'blocked', 'in_review') AND age_seconds > 86400
3601
3615
  ORDER BY age_seconds DESC