@desplega.ai/agent-swarm 1.113.0 → 1.114.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 (204) hide show
  1. package/README.md +2 -2
  2. package/dist/{actions-q4n7cz6e.js → actions-bm8vdxys.js} +7 -8
  3. package/dist/{app-es4nzc71.js → app-bhwdxmvp.js} +5 -5
  4. package/dist/{assistant-0x8ey0vs.js → assistant-15mp2apr.js} +18 -17
  5. package/dist/{boot-reembed-69agkhv6.js → boot-reembed-awr2179r.js} +6 -6
  6. package/dist/{boot-reembed-p0ny05t8.js → boot-reembed-b9sbk87z.js} +5 -5
  7. package/dist/{boot-scrub-logs-yybrkmvr.js → boot-scrub-logs-c1zsaw9m.js} +4 -4
  8. package/dist/{claude-adapter-mma9a1yr.js → claude-adapter-2k45y7p7.js} +2 -2
  9. package/dist/{claude-managed-adapter-pv2nbqy4.js → claude-managed-adapter-kysmkz89.js} +2 -2
  10. package/dist/cli-0kgcv878.js +344 -0
  11. package/dist/cli-0pygq9r1.js +429 -0
  12. package/dist/{cli-h3k622d0.js → cli-113wmegp.js} +90 -3
  13. package/dist/{cli-7ga43spr.js → cli-1yjrbg1f.js} +1 -1
  14. package/dist/{cli-r5g6ngtn.js → cli-2t4e4ayk.js} +1 -1
  15. package/dist/{cli-y4ycrnjc.js → cli-312v3c41.js} +1 -1
  16. package/dist/{cli-ceewqajw.js → cli-46b6kc7f.js} +5 -5
  17. package/dist/cli-49j095n9.js +393 -0
  18. package/dist/{cli-hjhvekf4.js → cli-5afkmcfj.js} +10 -7
  19. package/dist/{cli-bgvskydy.js → cli-5ktc9fd4.js} +1 -1
  20. package/dist/cli-7rgh0w0k.js +262 -0
  21. package/dist/{cli-9cy6nc5m.js → cli-8fjwym53.js} +1 -1
  22. package/dist/{cli-z46pnksz.js → cli-a6tzw6vq.js} +175 -28
  23. package/dist/{cli-q21d49ac.js → cli-bw80ck94.js} +1 -1
  24. package/dist/{cli-f3qa069v.js → cli-byjcad11.js} +1 -1
  25. package/dist/{cli-4xyj9jtq.js → cli-e2xbxmhd.js} +996 -470
  26. package/dist/{cli-6wscj9z0.js → cli-e7306swv.js} +14 -14
  27. package/dist/{cli-c3frqf65.js → cli-f5pzfvwb.js} +3 -3
  28. package/dist/{cli-30bbaveh.js → cli-f9n2jg31.js} +2 -2
  29. package/dist/{cli-dcfyyh3t.js → cli-ftyf58xj.js} +2 -2
  30. package/dist/{cli-trmapn9k.js → cli-hq39e630.js} +5 -5
  31. package/dist/{cli-y6mrptcn.js → cli-hvg05qwm.js} +1 -1
  32. package/dist/cli-jkhwmmgg.js +136 -0
  33. package/dist/{cli-ncfgsqbd.js → cli-jzwtn8rm.js} +77 -18
  34. package/dist/{cli-tbw13sx8.js → cli-k6h2zkw3.js} +1 -1
  35. package/dist/{cli-qwgtacd6.js → cli-pnfyyp6h.js} +1240 -335
  36. package/dist/{cli-gtkqc144.js → cli-q1z5d5ss.js} +13 -7
  37. package/dist/{cli-bnzbn8j8.js → cli-q4e2x252.js} +3 -3
  38. package/dist/{cli-mq580e06.js → cli-r3mtrrzp.js} +16 -16
  39. package/dist/{cli-ywez6yps.js → cli-sq7f72d6.js} +1 -1
  40. package/dist/{cli-36ymmpmp.js → cli-w3nq88yc.js} +2 -2
  41. package/dist/{cli-pwc5e83c.js → cli-w4wk3kx6.js} +12 -7
  42. package/dist/{cli-anrj584m.js → cli-xz9aq0rf.js} +1 -1
  43. package/dist/{cli-hsetkkd3.js → cli-zmmp2r79.js} +22 -9
  44. package/dist/cli.js +32 -15
  45. package/dist/{codex-adapter-5cmy858w.js → codex-adapter-4z8m9mb5.js} +9 -9
  46. package/dist/{codex-session-runner-46q8mrba.js → codex-session-runner-rbct46dg.js} +9 -9
  47. package/dist/{commands-z5dbwta3.js → commands-zk4d6esf.js} +4 -4
  48. package/dist/{db-bbgahh4z.js → db-stn16jp2.js} +4 -4
  49. package/dist/{handlers-6b44317z.js → handlers-gshprvpf.js} +16 -30
  50. package/dist/{hook-sbp5fmps.js → hook-amzx9tap.js} +7 -7
  51. package/dist/{http-2xz43gz3.js → http-6g0hfzax.js} +1659 -728
  52. package/dist/{index-wz1ea15p.js → index-2dgfj9av.js} +3 -3
  53. package/dist/{index-vfedgdw6.js → index-df8fmphk.js} +43 -16
  54. package/dist/{index-0gzmqj4k.js → index-f03rnnrs.js} +13 -10
  55. package/dist/{index-5ghxn8s6.js → index-jbm7qcqk.js} +12 -9
  56. package/dist/{index-ykvs43z4.js → index-t2snazez.js} +4 -4
  57. package/dist/{index-nhat35em.js → index-ty42rxw9.js} +14 -11
  58. package/dist/{keepalive-62gfj91d.js → keepalive-pm6g2wpw.js} +7 -6
  59. package/dist/{lead-ag0akn0v.js → lead-h79fzpzw.js} +33 -29
  60. package/dist/{maintenance-xxrrzk5x.js → maintenance-433zndy1.js} +6 -6
  61. package/dist/{mistral-conversations-26yrnbf1.js → mistral-conversations-7gqnz2wt.js} +7 -7
  62. package/dist/oauth-refresh-sweep-mjsbmsk2.js +114 -0
  63. package/dist/{onboard-64zyfcbs.js → onboard-vdr9hc3f.js} +2 -2
  64. package/dist/{otel-zjd9zaxs.js → otel-g299k41b.js} +2 -2
  65. package/dist/{otel-impl-b86qseaa.js → otel-impl-yswd0fty.js} +1 -1
  66. package/dist/{pi-mono-adapter-kxjxpfgy.js → pi-mono-adapter-vbrvg1p8.js} +16 -108
  67. package/dist/{pricing-refresh-cgtkffpa.js → pricing-refresh-2kk2ap9b.js} +6 -6
  68. package/dist/rbac-roles-2wgh9b5t.js +276 -0
  69. package/dist/rbac-roles-xdc5208b.js +28 -0
  70. package/dist/{seed-pricing-1r1y1xkq.js → seed-pricing-m9h69d2t.js} +5 -5
  71. package/dist/{setup-mkcgkjf7.js → setup-eynkvafa.js} +2 -2
  72. package/dist/{worker-351sze63.js → worker-136q8dc2.js} +33 -29
  73. package/openapi.json +1320 -17
  74. package/package.json +3 -3
  75. package/src/agentmail/handlers.ts +16 -6
  76. package/src/agentmail/templates.ts +25 -5
  77. package/src/be/audit-user.ts +28 -4
  78. package/src/be/db-queries/oauth.ts +42 -0
  79. package/src/be/db.ts +61 -8
  80. package/src/be/identity.ts +79 -0
  81. package/src/be/mcp-proxy.ts +132 -0
  82. package/src/be/migrations/109_rbac_roles.sql +79 -0
  83. package/src/be/migrations/111_oauth_credential_bindings.sql +6 -0
  84. package/src/be/migrations/112_script_connections_graphql.sql +96 -0
  85. package/src/be/oauth-credential-bindings.ts +35 -0
  86. package/src/be/oauth-refresh-sweep.ts +159 -0
  87. package/src/be/rbac-audit.ts +41 -13
  88. package/src/be/rbac-roles.ts +417 -0
  89. package/src/be/script-connections.ts +456 -37
  90. package/src/be/script-credential-broker.ts +29 -3
  91. package/src/be/scripts/typecheck.ts +40 -7
  92. package/src/be/users.ts +24 -0
  93. package/src/cli.tsx +17 -0
  94. package/src/github/handlers.ts +10 -9
  95. package/src/github/templates.ts +45 -9
  96. package/src/gitlab/handlers.ts +20 -8
  97. package/src/gitlab/templates.ts +18 -6
  98. package/src/http/all-routes.ts +3 -0
  99. package/src/http/approval-requests.ts +12 -0
  100. package/src/http/config.ts +44 -10
  101. package/src/http/core.ts +30 -3
  102. package/src/http/index.ts +25 -1
  103. package/src/http/mcp-oauth.ts +2 -0
  104. package/src/http/mcp-servers.ts +6 -3
  105. package/src/http/oauth-generic.ts +105 -0
  106. package/src/http/poll.ts +13 -1
  107. package/src/http/script-connection-proxy.ts +116 -0
  108. package/src/http/script-connections.ts +1657 -0
  109. package/src/http/scripts.ts +21 -7
  110. package/src/http/tasks.ts +16 -14
  111. package/src/http/x.ts +6 -2
  112. package/src/integrations/kapso/inbound.ts +23 -6
  113. package/src/jira/sync.ts +111 -17
  114. package/src/jira/templates.ts +10 -2
  115. package/src/mcp-client/http-client.ts +194 -0
  116. package/src/oauth/app-validation.ts +16 -0
  117. package/src/oauth/ensure-token.ts +69 -14
  118. package/src/oauth/mcp-wrapper.ts +15 -0
  119. package/src/oauth/wrapper.ts +48 -20
  120. package/src/prompts/session-templates.ts +3 -3
  121. package/src/providers/pi-mono-mcp-client.ts +2 -133
  122. package/src/rbac/admission.ts +44 -0
  123. package/src/rbac/index.ts +2 -0
  124. package/src/rbac/legacy-policy.ts +3 -0
  125. package/src/rbac/permissions.ts +12 -0
  126. package/src/scheduler/scheduler.ts +9 -1
  127. package/src/scripts-runtime/api-client.ts +70 -14
  128. package/src/scripts-runtime/api-types.ts +38 -6
  129. package/src/scripts-runtime/credential-broker/default-bindings.ts +1 -0
  130. package/src/scripts-runtime/credential-broker/types.ts +8 -0
  131. package/src/scripts-runtime/ctx.ts +11 -1
  132. package/src/scripts-runtime/eval-harness.ts +5 -1
  133. package/src/scripts-runtime/executors/types.ts +2 -1
  134. package/src/scripts-runtime/loader.ts +3 -1
  135. package/src/scripts-runtime/mcp-client.ts +87 -0
  136. package/src/scripts-runtime/sdk-allowlist.ts +1 -0
  137. package/src/scripts-runtime/types/stdlib.d.ts +6 -0
  138. package/src/scripts-runtime/types/swarm-sdk.d.ts +8 -0
  139. package/src/server.ts +12 -0
  140. package/src/slack/assistant.ts +14 -6
  141. package/src/slack/enrich.ts +17 -0
  142. package/src/slack/handlers.ts +8 -22
  143. package/src/slack/thread-buffer.ts +6 -3
  144. package/src/tests/agentmail-handlers.test.ts +32 -3
  145. package/src/tests/approval-requests.test.ts +61 -0
  146. package/src/tests/audit-user.test.ts +47 -1
  147. package/src/tests/credential-broker.test.ts +5 -2
  148. package/src/tests/delete-page-tool.test.ts +197 -0
  149. package/src/tests/github-handlers.test.ts +28 -2
  150. package/src/tests/gitlab-handlers.test.ts +125 -0
  151. package/src/tests/identity.test.ts +117 -0
  152. package/src/tests/jira-sync.test.ts +99 -1
  153. package/src/tests/kapso-inbound.test.ts +7 -0
  154. package/src/tests/mcp-tools-user.test.ts +60 -6
  155. package/src/tests/oauth-credential-bindings.test.ts +490 -0
  156. package/src/tests/oauth-refresh-sweep.test.ts +160 -0
  157. package/src/tests/prompt-template-remaining.test.ts +2 -2
  158. package/src/tests/rbac-admission-e2e.test.ts +241 -0
  159. package/src/tests/rbac-admission.test.ts +433 -0
  160. package/src/tests/rbac-e2e-helpers.ts +3 -0
  161. package/src/tests/rbac-engine.test.ts +41 -0
  162. package/src/tests/rbac-roles.test.ts +326 -0
  163. package/src/tests/schedule-target-type.test.ts +50 -0
  164. package/src/tests/scheduled-tasks.test.ts +40 -0
  165. package/src/tests/script-connections-http.test.ts +1158 -0
  166. package/src/tests/script-connections-mcp.test.ts +894 -0
  167. package/src/tests/script-connections.test.ts +727 -5
  168. package/src/tests/scripts-external-api.test.ts +49 -1
  169. package/src/tests/scripts-runtime-secret-egress.test.ts +1 -0
  170. package/src/tests/scripts-runtime.test.ts +104 -0
  171. package/src/tests/slack-identity-resolution.test.ts +37 -3
  172. package/src/tests/slack-thread-buffer.test.ts +28 -0
  173. package/src/tests/tool-annotations.test.ts +1 -0
  174. package/src/tests/user-token-rest-auth.test.ts +30 -1
  175. package/src/tests/workflow-swarm-script.test.ts +44 -0
  176. package/src/tests/workflow-triggers-v2.test.ts +300 -1
  177. package/src/tools/credential-bindings/tool.ts +277 -18
  178. package/src/tools/delete-page.ts +145 -0
  179. package/src/tools/mcp-servers/mcp-server-delete.ts +7 -4
  180. package/src/tools/request-human-input.ts +2 -0
  181. package/src/tools/resolve-user.ts +77 -27
  182. package/src/tools/script-connections/tool.ts +275 -31
  183. package/src/tools/templates.ts +5 -1
  184. package/src/tools/tool-config.ts +2 -1
  185. package/src/tools/workflows/create-workflow.ts +8 -1
  186. package/src/tools/workflows/update-workflow.ts +11 -2
  187. package/src/types.ts +63 -6
  188. package/src/utils/scoped-resource.ts +25 -0
  189. package/src/workflows/executors/human-in-the-loop.ts +1 -0
  190. package/src/workflows/executors/swarm-script.ts +7 -1
  191. package/src/workflows/triggers.ts +146 -18
  192. package/templates/skills/swarm-scripts/content.md +33 -8
  193. package/dist/cli-bgef578c.js +0 -771
  194. package/dist/cli-c9mtm09b.js +0 -43
  195. package/dist/{anthropic-messages-8nc6r2dw.js → anthropic-messages-kq3pjhbp.js} +6 -6
  196. package/dist/{azure-openai-responses-6yfzw3qw.js → azure-openai-responses-gm1ejtmn.js} +7 -7
  197. package/dist/{cli-vbraamxr.js → cli-6b4wwmm8.js} +9 -9
  198. package/dist/{cli-2fc97xm5.js → cli-ggy8c7tk.js} +3 -3
  199. package/dist/{cli-2r7s8jhp.js → cli-sznberje.js} +3 -3
  200. package/dist/{google-generative-ai-vfq6ymz9.js → google-generative-ai-hyrra2jm.js} +3 -3
  201. package/dist/{google-vertex-mj5y5rfj.js → google-vertex-8bs2pzgn.js} +3 -3
  202. package/dist/{openai-codex-responses-8h6kvfv8.js → openai-codex-responses-3nkvje79.js} +4 -4
  203. package/dist/{openai-completions-x6kjnqjd.js → openai-completions-0asftkwg.js} +11 -11
  204. package/dist/{openai-responses-7jwyz3ds.js → openai-responses-pmatek45.js} +10 -10
package/README.md CHANGED
@@ -129,7 +129,7 @@ Check [our templates](https://templates.agent-swarm.dev) for a quick start.
129
129
  - **Scheduled & recurring tasks** — cron-based automation for standing work, with schedules that can target agent tasks, workflows, or catalog scripts. [Scheduling →](https://docs.agent-swarm.dev/docs/concepts/scheduling)
130
130
  - **Durable script workflows** — launch background script runs, inspect their journals, and track them from the dashboard when a one-shot `script-run` is too small. [Guide →](https://docs.agent-swarm.dev/docs/guides/script-workflow-runs)
131
131
  - **Scripts as external APIs** — expose a saved script as a public `POST /api/x/script/<id>` endpoint with optional bearer auth, typed input validation, and per-endpoint usage tracking. [Guide →](https://docs.agent-swarm.dev/docs/guides/scripts-external-apis)
132
- - **Typed script API connections** — lead-managed OpenAPI connections let scripts call approved external APIs through generated `ctx.api.*` clients while credential bindings keep raw secrets out of source and args. [Guide →](https://docs.agent-swarm.dev/docs/guides/scripts-credential-broker)
132
+ - **Typed script API connections** — lead-managed OpenAPI, GraphQL, and MCP connections generate `ctx.api.*` / `ctx.mcp.*` clients for scripts, with credential bindings and OAuth-backed auth kept server-side. [Guide →](https://docs.agent-swarm.dev/docs/guides/script-connections)
133
133
  - **E2B-backed eval harness** — run a scenario × harness-config matrix against real swarm stacks, capture transcripts/artifacts, and grade outcomes with deterministic checks plus LLM or agentic judges. [Guide →](https://docs.agent-swarm.dev/docs/guides/evals-harness)
134
134
  - **Harness & LLM agnostic** — run with Claude Code, Claude Bridge, OpenAI Codex, pi-mono (Anthropic, OpenRouter, or Amazon Bedrock), Devin, Claude Managed Agents, raw LLMs, or opencode. Tasks, schedules, and workflow agent-task nodes can use portable `modelTier` intent (`smol`, `regular`, `smart`, `ultra`), and operators can set per-agent reasoning effort (`off` → `xhigh`) without changing task payloads. [Harness config →](https://docs.agent-swarm.dev/docs/guides/harness-configuration) · [Add a new provider →](https://docs.agent-swarm.dev/docs/guides/harness-providers)
135
135
  - **OpenTelemetry traces plus OTLP cost/token metrics** — export API + worker traces and finalized session cost/token counters through the same OTLP pipeline for dashboarding in SigNoz, Datadog, Tempo, or another compatible backend. [Observability →](https://docs.agent-swarm.dev/docs/guides/observability-opentelemetry)
@@ -137,7 +137,7 @@ Check [our templates](https://templates.agent-swarm.dev) for a quick start.
137
137
  - **Skills & MCP servers** — reusable procedural knowledge, bundled skill reference files, and per-agent MCP servers with scope cascade. [MCP tools →](https://docs.agent-swarm.dev/docs/reference/mcp-tools)
138
138
  - **External tool-router access** — the `x` command and `swarm_x` MCP tool let humans and agents execute approved third-party routes such as Composio without baking bespoke MCP servers first. [CLI →](https://docs.agent-swarm.dev/docs/reference/cli) · [Composio →](https://docs.agent-swarm.dev/docs/integrations/composio)
139
139
  - **Config-driven metrics dashboards** — define read-only SQL widgets, version them, and render them in the dashboard without shipping custom frontend code. [Metrics API →](https://docs.agent-swarm.dev/docs/api-reference/stats)
140
- - **DB-backed pages** — agents publish HTML or JSON pages (reports, dashboards, action specs) via the `create_page` MCP tool with public / authed / password modes, version history, view counters, diff helpers, and PDF export. [MCP tools → Pages](https://docs.agent-swarm.dev/docs/reference/mcp-tools#pages-tools)
140
+ - **DB-backed pages** — agents publish HTML or JSON pages (reports, dashboards, action specs) via `create_page`, remove stale pages with `delete-page`, and share them with public / authed / password modes, version history, view counters, diff helpers, and PDF export. [MCP tools → Pages](https://docs.agent-swarm.dev/docs/reference/mcp-tools#pages-tools)
141
141
  - **KV store** — Redis-like namespaced key/value store with auto-scoped context (Slack thread / PR / Linear issue / page). [MCP tools → KV](https://docs.agent-swarm.dev/docs/reference/mcp-tools#kv-tools)
142
142
  - **Real-time dashboard + task attachments** — monitor agents, tasks, and inter-agent chat, create tasks with uploaded files from the sessions composer, and preview task attachments inline above session prompts. [app.agent-swarm.dev →](https://app.agent-swarm.dev)
143
143
 
@@ -1,8 +1,7 @@
1
1
  import {
2
2
  resolveSlackUserId
3
- } from "./cli-pwc5e83c.js";
4
- import"./cli-c9mtm09b.js";
5
- import"./cli-h3k622d0.js";
3
+ } from "./cli-w4wk3kx6.js";
4
+ import"./cli-113wmegp.js";
6
5
  import {
7
6
  buildCancelledBlocks,
8
7
  getTaskLink
@@ -11,7 +10,7 @@ import"./cli-wspgs9bt.js";
11
10
  import {
12
11
  createTaskWithSiblingAwareness,
13
12
  slackContextKey
14
- } from "./cli-y4ycrnjc.js";
13
+ } from "./cli-312v3c41.js";
15
14
  import"./cli-dh55d5fg.js";
16
15
  import {
17
16
  cancelTask,
@@ -19,11 +18,11 @@ import {
19
18
  getLeadAgent,
20
19
  getTaskById,
21
20
  init_db
22
- } from "./cli-ncfgsqbd.js";
21
+ } from "./cli-jzwtn8rm.js";
23
22
  import"./cli-z2zcxes1.js";
24
- import"./cli-q21d49ac.js";
25
- import"./cli-anrj584m.js";
26
- import"./cli-c3frqf65.js";
23
+ import"./cli-bw80ck94.js";
24
+ import"./cli-xz9aq0rf.js";
25
+ import"./cli-f5pzfvwb.js";
27
26
  import"./cli-4j2mrzag.js";
28
27
  import"./cli-p9swy5t3.js";
29
28
 
@@ -3,17 +3,17 @@ import {
3
3
  initSlackApp,
4
4
  startSlackApp,
5
5
  stopSlackApp
6
- } from "./cli-trmapn9k.js";
6
+ } from "./cli-hq39e630.js";
7
7
  import"./cli-rkndnn90.js";
8
8
  import"./cli-b0p7rfnd.js";
9
9
  import"./cli-6xd0bvf8.js";
10
10
  import"./cli-wspgs9bt.js";
11
11
  import"./cli-dh55d5fg.js";
12
- import"./cli-ncfgsqbd.js";
12
+ import"./cli-jzwtn8rm.js";
13
13
  import"./cli-z2zcxes1.js";
14
- import"./cli-q21d49ac.js";
15
- import"./cli-anrj584m.js";
16
- import"./cli-c3frqf65.js";
14
+ import"./cli-bw80ck94.js";
15
+ import"./cli-xz9aq0rf.js";
16
+ import"./cli-f5pzfvwb.js";
17
17
  import"./cli-4j2mrzag.js";
18
18
  import"./cli-e15jhafb.js";
19
19
  import"./cli-7wmybrt5.js";
@@ -1,26 +1,26 @@
1
1
  import {
2
2
  bufferThreadMessage,
3
3
  wasEventSeen
4
- } from "./cli-hjhvekf4.js";
4
+ } from "./cli-5afkmcfj.js";
5
5
  import {
6
6
  hasOtherUserMention
7
- } from "./cli-bgvskydy.js";
7
+ } from "./cli-5ktc9fd4.js";
8
8
  import {
9
9
  require_dist
10
- } from "./cli-trmapn9k.js";
10
+ } from "./cli-hq39e630.js";
11
11
  import"./cli-rkndnn90.js";
12
12
  import"./cli-b0p7rfnd.js";
13
13
  import {
14
- resolveSlackUserId
15
- } from "./cli-pwc5e83c.js";
16
- import"./cli-c9mtm09b.js";
17
- import"./cli-h3k622d0.js";
14
+ resolveSlackUserId,
15
+ rewriteSlackMentions
16
+ } from "./cli-w4wk3kx6.js";
17
+ import"./cli-113wmegp.js";
18
18
  import"./cli-6xd0bvf8.js";
19
19
  import"./cli-wspgs9bt.js";
20
20
  import {
21
21
  createTaskWithSiblingAwareness,
22
22
  slackContextKey
23
- } from "./cli-y4ycrnjc.js";
23
+ } from "./cli-312v3c41.js";
24
24
  import"./cli-dh55d5fg.js";
25
25
  import {
26
26
  getAgentWorkingOnThread,
@@ -29,11 +29,11 @@ import {
29
29
  init_db,
30
30
  init_resolver,
31
31
  resolveTemplate
32
- } from "./cli-ncfgsqbd.js";
32
+ } from "./cli-jzwtn8rm.js";
33
33
  import"./cli-z2zcxes1.js";
34
- import"./cli-q21d49ac.js";
35
- import"./cli-anrj584m.js";
36
- import"./cli-c3frqf65.js";
34
+ import"./cli-bw80ck94.js";
35
+ import"./cli-xz9aq0rf.js";
36
+ import"./cli-f5pzfvwb.js";
37
37
  import"./cli-4j2mrzag.js";
38
38
  import"./cli-e15jhafb.js";
39
39
  import"./cli-7wmybrt5.js";
@@ -95,6 +95,7 @@ function createAssistant() {
95
95
  const channelId = message.channel;
96
96
  const messageText = msg.text || "";
97
97
  const userId = msg.user || "";
98
+ const renderedMessageText = rewriteSlackMentions(messageText);
98
99
  if (!cachedBotUserId) {
99
100
  try {
100
101
  const authResult = await client.auth.test();
@@ -122,7 +123,7 @@ function createAssistant() {
122
123
  return;
123
124
  }
124
125
  const latestTask = getMostRecentTaskInThread(channelId, threadTs);
125
- createTaskWithSiblingAwareness(messageText, {
126
+ createTaskWithSiblingAwareness(renderedMessageText, {
126
127
  agentId: workingAgent.id,
127
128
  source: "slack",
128
129
  slackChannelId: channelId,
@@ -136,8 +137,8 @@ function createAssistant() {
136
137
  return;
137
138
  }
138
139
  await safeSetStatus("Processing your request...");
139
- if (messageText) {
140
- const title = messageText.length > 50 ? `${messageText.slice(0, 47)}...` : messageText;
140
+ if (renderedMessageText) {
141
+ const title = renderedMessageText.length > 50 ? `${renderedMessageText.slice(0, 47)}...` : renderedMessageText;
141
142
  await safeSetTitle(title);
142
143
  }
143
144
  const ctx = await getThreadContext();
@@ -146,7 +147,7 @@ function createAssistant() {
146
147
  [User is viewing channel <#${ctx.channel_id}>]` : "";
147
148
  const lead = getLeadAgent();
148
149
  if (!lead) {
149
- createTaskWithSiblingAwareness(messageText + channelContext, {
150
+ createTaskWithSiblingAwareness(renderedMessageText + channelContext, {
150
151
  source: "slack",
151
152
  slackChannelId: channelId,
152
153
  slackThreadTs: threadTs,
@@ -158,7 +159,7 @@ function createAssistant() {
158
159
  await say(offlineResult.text);
159
160
  return;
160
161
  }
161
- createTaskWithSiblingAwareness(messageText + channelContext, {
162
+ createTaskWithSiblingAwareness(renderedMessageText + channelContext, {
162
163
  agentId: lead.id,
163
164
  source: "slack",
164
165
  slackChannelId: channelId,
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  embedScript,
3
3
  embeddingProvider
4
- } from "./cli-30bbaveh.js";
5
- import"./cli-f3qa069v.js";
4
+ } from "./cli-f9n2jg31.js";
5
+ import"./cli-byjcad11.js";
6
6
  import"./cli-q25ejbyn.js";
7
7
  import {
8
8
  getDb,
9
9
  init_db
10
- } from "./cli-ncfgsqbd.js";
10
+ } from "./cli-jzwtn8rm.js";
11
11
  import"./cli-z2zcxes1.js";
12
- import"./cli-q21d49ac.js";
13
- import"./cli-anrj584m.js";
14
- import"./cli-c3frqf65.js";
12
+ import"./cli-bw80ck94.js";
13
+ import"./cli-xz9aq0rf.js";
14
+ import"./cli-f5pzfvwb.js";
15
15
  import"./cli-4j2mrzag.js";
16
16
  import"./cli-p9swy5t3.js";
17
17
 
@@ -3,16 +3,16 @@ import {
3
3
  getEmbeddingProvider,
4
4
  getMemoryStore,
5
5
  init_constants
6
- } from "./cli-f3qa069v.js";
6
+ } from "./cli-byjcad11.js";
7
7
  import"./cli-q25ejbyn.js";
8
8
  import {
9
9
  getDb,
10
10
  init_db
11
- } from "./cli-ncfgsqbd.js";
11
+ } from "./cli-jzwtn8rm.js";
12
12
  import"./cli-z2zcxes1.js";
13
- import"./cli-q21d49ac.js";
14
- import"./cli-anrj584m.js";
15
- import"./cli-c3frqf65.js";
13
+ import"./cli-bw80ck94.js";
14
+ import"./cli-xz9aq0rf.js";
15
+ import"./cli-f5pzfvwb.js";
16
16
  import"./cli-4j2mrzag.js";
17
17
  import"./cli-p9swy5t3.js";
18
18
 
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  getDb,
3
3
  init_db
4
- } from "./cli-ncfgsqbd.js";
4
+ } from "./cli-jzwtn8rm.js";
5
5
  import"./cli-z2zcxes1.js";
6
- import"./cli-q21d49ac.js";
7
- import"./cli-anrj584m.js";
8
- import"./cli-c3frqf65.js";
6
+ import"./cli-bw80ck94.js";
7
+ import"./cli-xz9aq0rf.js";
8
+ import"./cli-f5pzfvwb.js";
9
9
  import {
10
10
  init_secret_scrubber,
11
11
  scrubSecrets
@@ -12,9 +12,9 @@ import {
12
12
  resolveClaudeBinary,
13
13
  resolveClaudeBinaryArgv,
14
14
  resolveClaudeBridgeEnabled
15
- } from "./cli-2fc97xm5.js";
16
- import"./cli-psrqtw2m.js";
15
+ } from "./cli-ggy8c7tk.js";
17
16
  import"./cli-tng3131n.js";
17
+ import"./cli-psrqtw2m.js";
18
18
  import"./cli-zm7njwzd.js";
19
19
  import"./cli-tghre7g6.js";
20
20
  import"./cli-tkmm5nf9.js";
@@ -3,10 +3,10 @@ import {
3
3
  checkClaudeManagedCredentials,
4
4
  composeManagedUserMessage,
5
5
  normalizeRepoUrl
6
- } from "./cli-2r7s8jhp.js";
6
+ } from "./cli-sznberje.js";
7
7
  import"./cli-07er7wrs.js";
8
- import"./cli-yv9dttkh.js";
9
8
  import"./cli-d6n0thxw.js";
9
+ import"./cli-yv9dttkh.js";
10
10
  import"./cli-gz9sbyk3.js";
11
11
  import"./cli-tghre7g6.js";
12
12
  import"./cli-4j2mrzag.js";
@@ -0,0 +1,344 @@
1
+ import {
2
+ init_zod
3
+ } from "./cli-bw80ck94.js";
4
+ import {
5
+ _enum
6
+ } from "./cli-xz9aq0rf.js";
7
+
8
+ // src/rbac/permissions.ts
9
+ init_zod();
10
+ var PERMISSIONS = {
11
+ "user.manage": {
12
+ description: "Create, update, or deactivate user profiles.",
13
+ namespace: "user"
14
+ },
15
+ "agent.profile.update.any": {
16
+ description: "Update another agent's profile.",
17
+ namespace: "agent"
18
+ },
19
+ "agent.context.read.any": {
20
+ description: "View or diff another agent's context history.",
21
+ namespace: "agent"
22
+ },
23
+ "task.cancel.any": {
24
+ description: "Cancel any task (beyond tasks the caller created).",
25
+ namespace: "task"
26
+ },
27
+ "task.read.own": {
28
+ description: "Read details of a task the principal requested.",
29
+ namespace: "task"
30
+ },
31
+ "task.cancel.own": {
32
+ description: "Cancel a task the principal requested.",
33
+ namespace: "task"
34
+ },
35
+ "task.action.own": {
36
+ description: "Run actions (follow-up, retry, ...) on a task the principal requested.",
37
+ namespace: "task"
38
+ },
39
+ "task.fs.mutate": {
40
+ description: "Mutate a task's filesystem artifacts and attachments.",
41
+ namespace: "task"
42
+ },
43
+ "memory.learning.inject": {
44
+ description: "Inject a learning into another agent's memory.",
45
+ namespace: "memory"
46
+ },
47
+ "memory.delete.any": {
48
+ description: "Delete a memory entry (own entries, or swarm-scoped entries as lead).",
49
+ namespace: "memory"
50
+ },
51
+ "channel.delete": {
52
+ description: "Delete a Slack channel.",
53
+ namespace: "channel"
54
+ },
55
+ "integration.kapso.manage": {
56
+ description: "Register or unregister a Kapso inbound number.",
57
+ namespace: "integration"
58
+ },
59
+ "integration.slack.post": {
60
+ description: "Post to a direct Slack channel.",
61
+ namespace: "integration"
62
+ },
63
+ "integration.slack.read": {
64
+ description: "Read a direct Slack channel.",
65
+ namespace: "integration"
66
+ },
67
+ "integration.slack.thread.start": {
68
+ description: "Start a thread in a direct Slack channel.",
69
+ namespace: "integration"
70
+ },
71
+ "integration.slack.upload": {
72
+ description: "Upload a file to a direct Slack channel.",
73
+ namespace: "integration"
74
+ },
75
+ "integration.slack.delete": {
76
+ description: "Delete a Slack message.",
77
+ namespace: "integration"
78
+ },
79
+ "integration.slack.update": {
80
+ description: "Update (edit) a Slack message.",
81
+ namespace: "integration"
82
+ },
83
+ "credential-binding.manage": {
84
+ description: "Manage script credential bindings.",
85
+ namespace: "credential-binding"
86
+ },
87
+ "script-connection.manage": {
88
+ description: "Manage script connections.",
89
+ namespace: "script-connection"
90
+ },
91
+ "script-connection.invoke": {
92
+ description: "Invoke a script MCP connection through the server-side proxy.",
93
+ namespace: "script-connection"
94
+ },
95
+ "config.credential-bindings.write": {
96
+ description: "Write the SCRIPT_CREDENTIAL_BINDINGS swarm-config key.",
97
+ namespace: "config"
98
+ },
99
+ "config.write.any": {
100
+ description: "Write any swarm-config key.",
101
+ namespace: "config"
102
+ },
103
+ "config.delete.any": {
104
+ description: "Delete any swarm-config entry.",
105
+ namespace: "config"
106
+ },
107
+ "config.read.secrets": {
108
+ description: "Read unmasked secret config values.",
109
+ namespace: "config"
110
+ },
111
+ "skill.create.swarm": {
112
+ description: "Create a swarm-scoped skill.",
113
+ namespace: "skill"
114
+ },
115
+ "skill.install.any": {
116
+ description: "Install a skill for another agent.",
117
+ namespace: "skill"
118
+ },
119
+ "skill.install.global": {
120
+ description: "Install a remote/global skill.",
121
+ namespace: "skill"
122
+ },
123
+ "skill.uninstall.any": {
124
+ description: "Uninstall a skill for another agent.",
125
+ namespace: "skill"
126
+ },
127
+ "skill.update.any": {
128
+ description: "Update a skill the caller does not own.",
129
+ namespace: "skill"
130
+ },
131
+ "skill.promote.swarm": {
132
+ description: "Promote a skill to swarm scope (skill-approval path).",
133
+ namespace: "skill"
134
+ },
135
+ "skill.delete.any": {
136
+ description: "Delete a skill the caller does not own.",
137
+ namespace: "skill"
138
+ },
139
+ "mcp-server.create.swarm": {
140
+ description: "Create a swarm- or global-scoped MCP server.",
141
+ namespace: "mcp-server"
142
+ },
143
+ "mcp-server.install.any": {
144
+ description: "Install an MCP server for another agent.",
145
+ namespace: "mcp-server"
146
+ },
147
+ "mcp-server.uninstall.any": {
148
+ description: "Uninstall an MCP server for another agent.",
149
+ namespace: "mcp-server"
150
+ },
151
+ "mcp-server.delete.any": {
152
+ description: "Delete an MCP server the caller does not own.",
153
+ namespace: "mcp-server"
154
+ },
155
+ "mcp-server.update.any": {
156
+ description: "Update an MCP server the caller does not own.",
157
+ namespace: "mcp-server"
158
+ },
159
+ "mcp-oauth.authorize.any": {
160
+ description: "Start an MCP-server OAuth authorize flow for a caller-supplied user scope.",
161
+ namespace: "mcp-oauth"
162
+ },
163
+ "kv.write.any": {
164
+ description: "Write another agent's task:agent: KV namespace.",
165
+ namespace: "kv"
166
+ },
167
+ "page.delete.any": {
168
+ description: "Delete a page the caller does not own.",
169
+ namespace: "page"
170
+ },
171
+ "script.global.write": {
172
+ description: "Create or update a global-scope script.",
173
+ namespace: "script"
174
+ },
175
+ "script.global.delete": {
176
+ description: "Delete a global-scope script.",
177
+ namespace: "script"
178
+ }
179
+ };
180
+ var PERMISSION_VERBS = Object.keys(PERMISSIONS);
181
+ var PermissionVerbSchema = _enum(PERMISSION_VERBS);
182
+
183
+ // src/rbac/admission.ts
184
+ function isRbacEnabled() {
185
+ return process.env.RBAC_ENABLED === "true";
186
+ }
187
+ function decideAdmission(input) {
188
+ if (input.grant.grantsAll) {
189
+ return { allow: true };
190
+ }
191
+ if (input.rbac && "permission" in input.rbac) {
192
+ const verb = input.rbac.permission;
193
+ if (input.grant.verbs.has(verb)) {
194
+ return { allow: true, verb };
195
+ }
196
+ return { allow: false, reason: `admission: missing permission '${verb}'`, verb };
197
+ }
198
+ const method = input.method.toUpperCase();
199
+ if (method === "GET" || method === "HEAD") {
200
+ return { allow: true };
201
+ }
202
+ return { allow: false, reason: "admission: route has no permission verb (operator-only)" };
203
+ }
204
+ // src/rbac/legacy-policy.ts
205
+ var leadOnly = {
206
+ name: "lead-only",
207
+ denyReason: "requires lead agent",
208
+ evaluate: (principal) => principal.kind === "agent" && principal.isLead
209
+ };
210
+ var leadOrTaskCreator = {
211
+ name: "lead-or-task-creator",
212
+ denyReason: "requires lead agent or task creator",
213
+ evaluate: (principal, resource) => {
214
+ if (principal.kind !== "agent")
215
+ return false;
216
+ if (principal.isLead)
217
+ return true;
218
+ return resource?.kind === "task" && resource.creatorAgentId != null && resource.creatorAgentId === principal.agentId;
219
+ }
220
+ };
221
+ var leadOrResourceOwner = {
222
+ name: "lead-or-resource-owner",
223
+ denyReason: "requires lead agent or resource owner",
224
+ evaluate: (principal, resource) => {
225
+ if (principal.kind !== "agent")
226
+ return false;
227
+ if (principal.isLead)
228
+ return true;
229
+ return resource?.kind === "owned" && resource.ownerAgentId != null && resource.ownerAgentId === principal.agentId;
230
+ }
231
+ };
232
+ var leadOrOwnNamespace = {
233
+ name: "lead-or-own-namespace",
234
+ denyReason: "requires lead agent or your own task:agent: namespace",
235
+ evaluate: (principal, resource) => {
236
+ if (principal.kind !== "agent")
237
+ return false;
238
+ if (principal.isLead)
239
+ return true;
240
+ return principal.agentId !== "" && resource?.kind === "kv-namespace" && resource.namespace === `task:agent:${principal.agentId}`;
241
+ }
242
+ };
243
+ var anyAuthenticated = {
244
+ name: "any-authenticated",
245
+ denyReason: "requires an authenticated principal",
246
+ evaluate: () => true
247
+ };
248
+ var requesterOwnsTask = {
249
+ name: "requester-owns-task",
250
+ denyReason: "not the task requester",
251
+ evaluate: (principal, resource) => {
252
+ if (principal.kind !== "user")
253
+ return true;
254
+ return resource?.kind === "task" && resource.requestedByUserId === principal.userId;
255
+ }
256
+ };
257
+ var memoryOwnerOrLeadSwarm = {
258
+ name: "memory-owner-or-lead-swarm",
259
+ denyReason: "requires memory owner, or lead agent for swarm-scoped memories",
260
+ evaluate: (principal, resource) => {
261
+ if (principal.kind !== "agent" || resource?.kind !== "owned")
262
+ return false;
263
+ if (resource.ownerAgentId != null && resource.ownerAgentId === principal.agentId)
264
+ return true;
265
+ return principal.isLead && resource.scope === "swarm";
266
+ }
267
+ };
268
+ var taskFsMutate = {
269
+ name: "operator-or-user-or-lead-or-task-owner",
270
+ denyReason: "requires operator, user, lead agent, task assignee, or task creator",
271
+ evaluate: (principal, resource) => {
272
+ if (principal.kind === "operator" || principal.kind === "user")
273
+ return true;
274
+ if (principal.isLead)
275
+ return true;
276
+ if (resource?.kind !== "task")
277
+ return false;
278
+ return resource.agentId != null && resource.agentId === principal.agentId || resource.creatorAgentId != null && resource.creatorAgentId === principal.agentId;
279
+ }
280
+ };
281
+ var LEGACY_POLICY = {
282
+ "user.manage": leadOnly,
283
+ "agent.profile.update.any": leadOnly,
284
+ "agent.context.read.any": leadOnly,
285
+ "task.cancel.any": leadOrTaskCreator,
286
+ "task.read.own": requesterOwnsTask,
287
+ "task.cancel.own": requesterOwnsTask,
288
+ "task.action.own": requesterOwnsTask,
289
+ "task.fs.mutate": taskFsMutate,
290
+ "memory.learning.inject": leadOnly,
291
+ "memory.delete.any": memoryOwnerOrLeadSwarm,
292
+ "channel.delete": leadOnly,
293
+ "integration.kapso.manage": leadOnly,
294
+ "integration.slack.post": leadOnly,
295
+ "integration.slack.read": leadOnly,
296
+ "integration.slack.thread.start": leadOnly,
297
+ "integration.slack.upload": leadOnly,
298
+ "integration.slack.delete": leadOnly,
299
+ "integration.slack.update": leadOnly,
300
+ "credential-binding.manage": leadOnly,
301
+ "script-connection.manage": leadOnly,
302
+ "script-connection.invoke": anyAuthenticated,
303
+ "config.credential-bindings.write": leadOnly,
304
+ "config.write.any": leadOnly,
305
+ "config.delete.any": leadOnly,
306
+ "config.read.secrets": leadOnly,
307
+ "skill.create.swarm": leadOnly,
308
+ "skill.install.any": leadOnly,
309
+ "skill.install.global": leadOnly,
310
+ "skill.uninstall.any": leadOnly,
311
+ "skill.update.any": leadOrResourceOwner,
312
+ "skill.promote.swarm": leadOnly,
313
+ "skill.delete.any": leadOrResourceOwner,
314
+ "mcp-server.create.swarm": leadOnly,
315
+ "mcp-server.install.any": leadOnly,
316
+ "mcp-server.uninstall.any": leadOnly,
317
+ "mcp-server.delete.any": leadOrResourceOwner,
318
+ "mcp-server.update.any": leadOrResourceOwner,
319
+ "mcp-oauth.authorize.any": anyAuthenticated,
320
+ "kv.write.any": leadOrOwnNamespace,
321
+ "page.delete.any": leadOrResourceOwner,
322
+ "script.global.write": leadOnly,
323
+ "script.global.delete": leadOnly
324
+ };
325
+
326
+ // src/rbac/can.ts
327
+ var auditSink = null;
328
+ function setAuditSink(fn) {
329
+ auditSink = fn;
330
+ }
331
+ function clearAuditSink() {
332
+ auditSink = null;
333
+ }
334
+ function can(check) {
335
+ const rule = LEGACY_POLICY[check.verb];
336
+ const decision = rule.evaluate(check.principal, check.resource) ? { allow: true } : { allow: false, reason: rule.denyReason, missing: check.verb };
337
+ if (auditSink) {
338
+ try {
339
+ auditSink(check, decision);
340
+ } catch {}
341
+ }
342
+ return decision;
343
+ }
344
+ export { isRbacEnabled, decideAdmission, setAuditSink, clearAuditSink, can, PermissionVerbSchema };