@desplega.ai/agent-swarm 2.5.1 → 2.5.2

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 (155) hide show
  1. package/dist/{acp-adapter-7g6bpwbk.js → acp-adapter-csh0zz3b.js} +1 -1
  2. package/dist/{actions-w8xd014k.js → actions-6xx079d1.js} +17 -17
  3. package/dist/{amp-adapter-z4qvhacj.js → amp-adapter-8n6f0hz8.js} +2 -2
  4. package/dist/{app-nndcvftq.js → app-ft6r6v23.js} +3 -3
  5. package/dist/{assistant-hjmqyscx.js → assistant-vt2cyfzd.js} +18 -18
  6. package/dist/{boot-reembed-r8rhf9h8.js → boot-reembed-r3e808ky.js} +1 -1
  7. package/dist/{boot-reembed-vwcj2y5d.js → boot-reembed-tgrfy27t.js} +1 -1
  8. package/dist/{boot-scrub-sweep-fr9q36ne.js → boot-scrub-sweep-masdwxkm.js} +2 -2
  9. package/dist/{boot-seeds-9jqwnegq.js → boot-seeds-0n82qc7q.js} +4 -4
  10. package/dist/{claude-adapter-2f8b85df.js → claude-adapter-s7j47k06.js} +2 -2
  11. package/dist/{claude-managed-setup-c3hp36ph.js → claude-managed-setup-3hzrgrnk.js} +1 -1
  12. package/dist/{claude-sdk-session-05kat8rv.js → claude-sdk-session-0zrdzyx2.js} +6905 -6855
  13. package/dist/{cli-mz2ygeyq.js → cli-0vgy5wfw.js} +2 -2
  14. package/dist/{cli-eym3jg7w.js → cli-14v1sxxy.js} +6 -6
  15. package/dist/{cli-e9btqw4y.js → cli-15xd0j7w.js} +18 -13
  16. package/dist/{cli-v2g93k4v.js → cli-3e9vs93g.js} +4 -4
  17. package/dist/{cli-1dp1zj04.js → cli-4qkg9968.js} +3 -3
  18. package/dist/{cli-ba8ne1es.js → cli-4rvr7zfx.js} +10 -0
  19. package/dist/{cli-rngde2jv.js → cli-6y43v79h.js} +1 -1
  20. package/dist/{cli-z63a269p.js → cli-7ccf7akh.js} +1 -1
  21. package/dist/{cli-z2dv25mf.js → cli-86zpfje5.js} +116 -5
  22. package/dist/{cli-fes51ya2.js → cli-aaqnqpyw.js} +2 -2
  23. package/dist/{cli-qfm6my86.js → cli-b1tv22wr.js} +1 -1
  24. package/dist/{cli-xc65x52q.js → cli-b63d08rs.js} +1 -1
  25. package/dist/{cli-gwcf52gz.js → cli-b6tnjdvx.js} +11 -7
  26. package/dist/{cli-9mm5ade4.js → cli-bpbcpd8b.js} +1 -1
  27. package/dist/{cli-qfjm4gvt.js → cli-cf63dnxj.js} +2 -2
  28. package/dist/{cli-q9pzwxvk.js → cli-csh8fnbg.js} +82 -16
  29. package/dist/{cli-0jy85zz4.js → cli-cyfgxnvb.js} +7 -7
  30. package/dist/{cli-y3zyaee5.js → cli-d172svcw.js} +5 -5
  31. package/dist/{cli-mq7kg1b1.js → cli-e91vshb1.js} +41 -6
  32. package/dist/{cli-cah5detr.js → cli-edtm741g.js} +5 -5
  33. package/dist/{cli-ajqhxtnz.js → cli-f3pfn4x3.js} +1 -1
  34. package/dist/{cli-hadv0725.js → cli-f55b6ky0.js} +1 -1
  35. package/dist/{cli-r9fy0ddc.js → cli-fgn7yg5r.js} +1 -1
  36. package/dist/{cli-kcsd1ez8.js → cli-h5d22pfs.js} +249 -68
  37. package/dist/{cli-2wba1ac9.js → cli-ha22h0eg.js} +20 -20
  38. package/dist/{cli-pyy4c9ch.js → cli-j3dwd4kz.js} +173 -134
  39. package/dist/{cli-j1eghqfm.js → cli-jmcjbjkt.js} +1 -1
  40. package/dist/{cli-22rmcjkg.js → cli-kcnwn85g.js} +4 -3
  41. package/dist/{cli-rh5smt8t.js → cli-mntxtkhn.js} +12 -2
  42. package/dist/{cli-2jg61wab.js → cli-n2918sed.js} +9 -9
  43. package/dist/{cli-3ee5z0q0.js → cli-qrjv7t18.js} +1 -1
  44. package/dist/{cli-sn1vbtg2.js → cli-vaxw3bg0.js} +3 -3
  45. package/dist/{cli-cwyafhw1.js → cli-wadzapwb.js} +1 -1
  46. package/dist/{cli-jpxsrxcb.js → cli-xw9q173h.js} +1 -1
  47. package/dist/{cli-znvq0k3t.js → cli-xzge46sj.js} +2 -2
  48. package/dist/{cli-nj12tn2c.js → cli-y3dzwyy3.js} +3 -3
  49. package/dist/{cli-xd4eqtr2.js → cli-ydg6ep51.js} +1 -1
  50. package/dist/cli.js +16 -15
  51. package/dist/{codex-adapter-p4ptwar5.js → codex-adapter-brh2tcxr.js} +1 -1
  52. package/dist/{codex-session-runner-964c7dnk.js → codex-session-runner-0dnj21qs.js} +1 -1
  53. package/dist/{commands-mbvhbrcy.js → commands-1cnvseqx.js} +2 -2
  54. package/dist/{controller-gnq1k1mf.js → controller-kc7s9xhn.js} +2 -2
  55. package/dist/{controllers-connect-6dkm71tg.js → controllers-connect-jzx7t4bn.js} +18 -18
  56. package/dist/{cursor-adapter-yq5xgfcg.js → cursor-adapter-qpwp5sfg.js} +1 -1
  57. package/dist/{db-af9y8nkf.js → db-4vq88jkc.js} +3 -3
  58. package/dist/{db-88wcymxt.js → db-v5ytg5pw.js} +1 -1
  59. package/dist/{dispatcher-606ydx5v.js → dispatcher-trtcrqae.js} +16 -16
  60. package/dist/{dsh-adapter-tvhc4k2d.js → dsh-adapter-f20xwn1z.js} +1 -1
  61. package/dist/{external-channel-y8q5z8z2.js → external-channel-n9bymc2n.js} +2 -2
  62. package/dist/{grok-adapter-39aha52t.js → grok-adapter-4kpmmnr6.js} +2 -2
  63. package/dist/{handlers-rk9dqech.js → handlers-ptsraqa8.js} +19 -19
  64. package/dist/{heartbeat-jfe9zfjr.js → heartbeat-60qtxtjf.js} +19 -19
  65. package/dist/{hook-ffevzed1.js → hook-ngtvh729.js} +1 -1
  66. package/dist/{hook-b1mez1m8.js → hook-rbktcstg.js} +1 -1
  67. package/dist/{http-d5b44f1r.js → http-z8xy72gp.js} +334 -86
  68. package/dist/{index-nq8hhv28.js → index-06qkmcx6.js} +10 -9
  69. package/dist/{index-d2qeem97.js → index-1cscynkb.js} +16 -16
  70. package/dist/{index-5en23s5z.js → index-a9nsavhx.js} +1 -1
  71. package/dist/{index-4q3vj1yr.js → index-r70q0xjx.js} +16 -16
  72. package/dist/{index-mj46rk9k.js → index-s193j5fh.js} +19 -19
  73. package/dist/{keepalive-wsby1btq.js → keepalive-a9srcphj.js} +3 -3
  74. package/dist/{lead-paa141j6.js → lead-3devneqy.js} +26 -26
  75. package/dist/{maintenance-vnshcyv9.js → maintenance-0er16h2y.js} +1 -1
  76. package/dist/{oauth-refresh-sweep-d6sqn5np.js → oauth-refresh-sweep-b65jcyw2.js} +2 -2
  77. package/dist/{onboard-nr4xhpzy.js → onboard-wqywz5py.js} +2 -2
  78. package/dist/{otel-impl-ytn9wyv9.js → otel-impl-vk32s884.js} +1 -1
  79. package/dist/{pricing-refresh-pva04zee.js → pricing-refresh-t27anv4z.js} +3 -3
  80. package/dist/rbac-roles-452665y0.js +26 -0
  81. package/dist/{rbac-roles-7rc1q3g4.js → rbac-roles-bmcgsxjn.js} +12 -2
  82. package/dist/{render-v2-pyfsg9zk.js → render-v2-0ttsk2j4.js} +3 -3
  83. package/dist/{resume-phj8xhqr.js → resume-a26kvr41.js} +5 -5
  84. package/dist/{session-access-jzx2z9h5.js → session-access-dgh9nkwk.js} +4 -4
  85. package/dist/{setup-rfg0f0sg.js → setup-9vc9qahm.js} +1 -1
  86. package/dist/{work-objects-44z2yjg8.js → work-objects-vn8nkxwn.js} +19 -19
  87. package/dist/{worker-zsfqzxhm.js → worker-1x1h8vnm.js} +26 -26
  88. package/openapi.json +463 -3
  89. package/package.json +4 -3
  90. package/src/be/db/session-tree.ts +89 -2
  91. package/src/be/db/session-visibility.ts +31 -0
  92. package/src/be/db/tasks/read.ts +18 -5
  93. package/src/be/db.ts +2 -0
  94. package/src/be/migrations/233_script_run_session_tokens.sql +8 -0
  95. package/src/be/migrations/235_chat_relay_defer.sql +86 -0
  96. package/src/be/migrations/237_session_inbox_cleanup.sql +75 -0
  97. package/src/be/rbac-roles.ts +138 -0
  98. package/src/be/scripts/run-credential.ts +64 -0
  99. package/src/be/scripts/run-saved.ts +3 -2
  100. package/src/be/users.ts +28 -4
  101. package/src/http/all-routes.ts +1 -0
  102. package/src/http/approval-requests.ts +46 -6
  103. package/src/http/index.ts +2 -0
  104. package/src/http/schedules.ts +26 -0
  105. package/src/http/scripts.ts +2 -2
  106. package/src/http/sessions.ts +93 -2
  107. package/src/http/user-roles.ts +173 -0
  108. package/src/http/users.ts +9 -0
  109. package/src/http/x.ts +2 -2
  110. package/src/integrations/chat-sdk/commands.ts +14 -1
  111. package/src/integrations/chat-sdk/inbound.ts +40 -5
  112. package/src/integrations/chat-sdk/outbound.ts +35 -10
  113. package/src/integrations/chat-sdk/reactions.ts +107 -0
  114. package/src/integrations/chat-sdk/relay.ts +75 -7
  115. package/src/integrations/chat-sdk/thread-buffer.ts +2 -0
  116. package/src/integrations/reaction-events.ts +20 -0
  117. package/src/providers/amp-adapter.ts +1 -1
  118. package/src/rbac/legacy-policy.ts +3 -0
  119. package/src/rbac/permissions.ts +8 -0
  120. package/src/scheduler/schedule-task.ts +44 -3
  121. package/src/scheduler/scheduler.ts +4 -4
  122. package/src/scripts-runtime/loader.ts +8 -1
  123. package/src/slack/ack.ts +2 -1
  124. package/src/slack/reaction-shortcode.ts +4 -7
  125. package/src/tasks/worker-follow-up.ts +30 -0
  126. package/src/tests/approval-requests-notifications.test.ts +189 -0
  127. package/src/tests/chat-sdk-commands.test.ts +12 -0
  128. package/src/tests/chat-sdk-inbound.test.ts +163 -9
  129. package/src/tests/chat-sdk-outbound-files.test.ts +9 -2
  130. package/src/tests/chat-sdk-relay.test.ts +361 -10
  131. package/src/tests/chat-sdk-tools.test.ts +104 -0
  132. package/src/tests/docs-index-footprint.test.js +3 -3
  133. package/src/tests/http-users.test.ts +38 -0
  134. package/src/tests/migration-237-session-inbox-cleanup.test.ts +136 -0
  135. package/src/tests/rbac-engine.test.ts +2 -0
  136. package/src/tests/rbac-roles.test.ts +10 -0
  137. package/src/tests/schedule-http-triage-tools.test.ts +44 -0
  138. package/src/tests/script-api-credential.test.ts +173 -0
  139. package/src/tests/script-connections.test.ts +4 -0
  140. package/src/tests/script-run-config-scope.test.ts +120 -0
  141. package/src/tests/script-run-token.test.ts +75 -0
  142. package/src/tests/scripts-http.test.ts +19 -0
  143. package/src/tests/sessions-tree.test.ts +242 -0
  144. package/src/tests/user-roles-http.test.ts +204 -0
  145. package/src/tests/workflow-hitl-dynamic-questions.test.ts +1 -1
  146. package/src/tools/chat-reply.ts +2 -0
  147. package/src/tools/schedules/patch-schedule.ts +18 -0
  148. package/src/tools/schedules/update-schedule.ts +18 -0
  149. package/src/types.ts +16 -0
  150. package/src/workflows/approval-notifications.ts +214 -0
  151. package/src/workflows/executors/human-in-the-loop.ts +11 -172
  152. package/src/workflows/executors/swarm-script.ts +2 -2
  153. package/templates/schedules/weekly-harness-upgrade-check/content.md +1 -1
  154. package/templates/skills/code-quality/content.md +1 -1
  155. package/dist/rbac-roles-ff1ffmec.js +0 -12
@@ -4,11 +4,11 @@ import {
4
4
  getActivePricingRow2,
5
5
  insertPricingRow2,
6
6
  init_db3
7
- } from "./cli-q9pzwxvk.js";
7
+ } from "./cli-csh8fnbg.js";
8
8
  import {
9
9
  loadModelsDevCache,
10
10
  buildModelsDevSeedRows
11
- } from "./cli-9mm5ade4.js";
11
+ } from "./cli-bpbcpd8b.js";
12
12
  import {
13
13
  setRuntimeModelCatalog,
14
14
  init_runtime_model_catalog
@@ -10,7 +10,7 @@ import {
10
10
  getMostRecentTaskInThread2,
11
11
  reactionName,
12
12
  init_db3
13
- } from "./cli-q9pzwxvk.js";
13
+ } from "./cli-csh8fnbg.js";
14
14
  import {
15
15
  TaskCreationBlockedError,
16
16
  buildEffectiveText,
@@ -23,7 +23,7 @@ import {
23
23
  extractTaskFromMessage,
24
24
  extractSlackMessageText,
25
25
  dispatchPre2
26
- } from "./cli-kcsd1ez8.js";
26
+ } from "./cli-h5d22pfs.js";
27
27
  import {
28
28
  noteSlackInboundSideEffect,
29
29
  ignoreSlackInbound,
@@ -34,14 +34,14 @@ import {
34
34
  isSlackRenderV2Enabled2,
35
35
  ensureSlackThreadTree2,
36
36
  registerTreeMessage
37
- } from "./cli-e9btqw4y.js";
37
+ } from "./cli-15xd0j7w.js";
38
38
  import {
39
39
  isBlockExternalEnabled2,
40
40
  invalidateChannelExternality2,
41
41
  getChannelBlockReason2,
42
42
  shouldBlockChannel2,
43
43
  leaveExternalChannel2
44
- } from "./cli-xc65x52q.js";
44
+ } from "./cli-b63d08rs.js";
45
45
  import {
46
46
  workflowEventBus2,
47
47
  init_event_bus
@@ -50,7 +50,7 @@ import {
50
50
  enrichSlackUserEmail,
51
51
  resolveSlackUserId,
52
52
  rewriteSlackMentions
53
- } from "./cli-sn1vbtg2.js";
53
+ } from "./cli-vaxw3bg0.js";
54
54
  import {
55
55
  wasEventSeen,
56
56
  requestSlackThreadSteering,
@@ -58,7 +58,7 @@ import {
58
58
  bufferThreadMessage,
59
59
  getBufferMessageCount,
60
60
  instantFlush
61
- } from "./cli-cah5detr.js";
61
+ } from "./cli-edtm741g.js";
62
62
  import {
63
63
  resolveTemplate,
64
64
  init_resolver
@@ -47,10 +47,10 @@ import {
47
47
  checkDependencies2,
48
48
  emitBuiltInIntegrationConnectedOnce2,
49
49
  init_db3
50
- } from "./cli-q9pzwxvk.js";
50
+ } from "./cli-csh8fnbg.js";
51
51
  import {
52
52
  getChannelBlockReason2
53
- } from "./cli-xc65x52q.js";
53
+ } from "./cli-b63d08rs.js";
54
54
  import {
55
55
  require_dist5,
56
56
  require_axios,
@@ -67,7 +67,7 @@ import {
67
67
  import {
68
68
  isTerminalTaskStatus,
69
69
  init_types
70
- } from "./cli-rh5smt8t.js";
70
+ } from "./cli-mntxtkhn.js";
71
71
  import {
72
72
  taskAttachmentDisplayUrl,
73
73
  init_task_attachment_links
@@ -6197,6 +6197,11 @@ init_db3();
6197
6197
  // src/slack/ack.ts
6198
6198
  init_db3();
6199
6199
 
6200
+ // src/integrations/reaction-events.ts
6201
+ function terminalReactionEvent(status) {
6202
+ return status === "completed" ? "completed" : "failed";
6203
+ }
6204
+
6200
6205
  // src/otel.ts
6201
6206
  function otelConfigured() {
6202
6207
  return Boolean(process.env.OTEL_EXPORTER_OTLP_ENDPOINT);
@@ -6235,7 +6240,7 @@ async function initOtel(serviceRole = process.env.AGENT_ROLE || "api") {
6235
6240
  return;
6236
6241
  initialized = true;
6237
6242
  try {
6238
- const impl = await import("./otel-impl-ytn9wyv9.js");
6243
+ const impl = await import("./otel-impl-vk32s884.js");
6239
6244
  await impl.boot(serviceRole, {
6240
6245
  exportConsoleLogs: serviceRole === "api" && isApiLogExportEnabled()
6241
6246
  });
@@ -6392,7 +6397,7 @@ async function finalizeSlackMessageReaction(client, channel, timestamp, outcome,
6392
6397
  await addReaction(client, channel, timestamp, outcome, event);
6393
6398
  }
6394
6399
  function terminalReactionChoice(task) {
6395
- const event = task.status === "completed" ? "completed" : "failed";
6400
+ const event = terminalReactionEvent(task.status);
6396
6401
  return { name: reactionName(event), event };
6397
6402
  }
6398
6403
  async function finalizeSlackSteerReactions(tasks, reactionFor) {
@@ -10080,17 +10085,17 @@ async function initSlackApp2() {
10080
10085
  });
10081
10086
  initialized2 = true;
10082
10087
  app.use(slackInboundOutcomeMiddleware());
10083
- const { registerMessageHandler } = await import("./handlers-rk9dqech.js");
10084
- const { registerCommandHandler } = await import("./commands-mbvhbrcy.js");
10085
- const { registerActionHandlers } = await import("./actions-w8xd014k.js");
10086
- const { registerWorkObjectHandlers } = await import("./work-objects-44z2yjg8.js");
10088
+ const { registerMessageHandler } = await import("./handlers-ptsraqa8.js");
10089
+ const { registerCommandHandler } = await import("./commands-1cnvseqx.js");
10090
+ const { registerActionHandlers } = await import("./actions-6xx079d1.js");
10091
+ const { registerWorkObjectHandlers } = await import("./work-objects-vn8nkxwn.js");
10087
10092
  registerMessageHandler(app);
10088
10093
  registerCommandHandler(app);
10089
10094
  registerActionHandlers(app);
10090
10095
  registerWorkObjectHandlers(app);
10091
- const { createAssistant } = await import("./assistant-hjmqyscx.js");
10096
+ const { createAssistant } = await import("./assistant-vt2cyfzd.js");
10092
10097
  app.assistant(createAssistant());
10093
- const { isBlockExternalEnabled, scanExternalChannelsOnBoot } = await import("./external-channel-y8q5z8z2.js");
10098
+ const { isBlockExternalEnabled, scanExternalChannelsOnBoot } = await import("./external-channel-n9bymc2n.js");
10094
10099
  if (isBlockExternalEnabled()) {
10095
10100
  scanExternalChannelsOnBoot(app.client).catch((error) => {
10096
10101
  console.error("[Slack] External channel boot scan failed:", error);
@@ -10103,7 +10108,7 @@ async function startSlackApp2() {
10103
10108
  await initSlackApp2();
10104
10109
  }
10105
10110
  if (app) {
10106
- const { isSlackRenderV2Enabled } = await import("./render-v2-pyfsg9zk.js");
10111
+ const { isSlackRenderV2Enabled } = await import("./render-v2-0ttsk2j4.js");
10107
10112
  if (isSlackRenderV2Enabled())
10108
10113
  await ensureSlackRenderV2Activation2();
10109
10114
  await app.start();
@@ -10126,4 +10131,4 @@ async function stopSlackApp2() {
10126
10131
  initialized2 = false;
10127
10132
  }
10128
10133
 
10129
- export { require_dist4, getSlackConnectionState, noteSlackInboundSideEffect, ignoreSlackInbound, reportSlackInboundFailure, isAdmittedSlackDelivery, getSlackInboundDiagnostics, isPollTracingEnabled, initOtel, withSpan2, startSpan2, withSpanContext2, withRemoteContext2, injectTraceContext2, recordSessionCost2, recordDbRetentionSweep2, recordDbRetentionStatement2, slackTaskOutput, ackSlackMessage, getTaskLink, getTaskUrl, markdownToSlack, buildMrkdwnSectionBlocks, buildCaptionBlock, buildCancelledBlocks, buildBufferFlushBlocks, buildTreeBlocks, taskCitationIssues, stripInvalidTaskCitations, taskCitationSourceGroups, renderTaskCitations, taskCitationWarnings, MAX_TASK_CITATIONS, CitationInputSchema, TaskCitationSchema, upsertTaskCitations, getTaskCitations, getTaskCitationsForTasks, hasTaskCitationCheckRefusal, initialize, ensure, getAgentDisplayName, getAgentEmoji, markSlackSessionProcessing, isSlackRenderV2Enabled2, ensureSlackThreadTree2, processSlackRenderV22, registerTreeMessage, getSlackApp2, initSlackApp2, startSlackApp2, stopSlackApp2 };
10134
+ export { require_dist4, getSlackConnectionState, noteSlackInboundSideEffect, ignoreSlackInbound, reportSlackInboundFailure, isAdmittedSlackDelivery, getSlackInboundDiagnostics, terminalReactionEvent, isPollTracingEnabled, initOtel, withSpan2, startSpan2, withSpanContext2, withRemoteContext2, injectTraceContext2, recordSessionCost2, recordDbRetentionSweep2, recordDbRetentionStatement2, slackTaskOutput, ackSlackMessage, getTaskLink, getTaskUrl, markdownToSlack, buildMrkdwnSectionBlocks, buildCaptionBlock, buildCancelledBlocks, buildBufferFlushBlocks, buildTreeBlocks, taskCitationIssues, stripInvalidTaskCitations, taskCitationSourceGroups, renderTaskCitations, taskCitationWarnings, MAX_TASK_CITATIONS, CitationInputSchema, TaskCitationSchema, upsertTaskCitations, getTaskCitations, getTaskCitationsForTasks, hasTaskCitationCheckRefusal, initialize, ensure, getAgentDisplayName, getAgentEmoji, markSlackSessionProcessing, isSlackRenderV2Enabled2, ensureSlackThreadTree2, processSlackRenderV22, registerTreeMessage, getSlackApp2, initSlackApp2, startSlackApp2, stopSlackApp2 };
@@ -7,20 +7,20 @@ import {
7
7
  tierConfigKey,
8
8
  init_model_tier_keys,
9
9
  init_db3
10
- } from "./cli-q9pzwxvk.js";
10
+ } from "./cli-csh8fnbg.js";
11
11
  import {
12
12
  ensureRbacSeedsSynced2,
13
13
  init_rbac_roles
14
- } from "./cli-z2dv25mf.js";
14
+ } from "./cli-86zpfje5.js";
15
15
  import {
16
16
  seedPricingFromModelsDev
17
- } from "./cli-9mm5ade4.js";
17
+ } from "./cli-bpbcpd8b.js";
18
18
  import {
19
19
  MODEL_TIERS,
20
20
  DEFAULT_MODEL_TIER_MAP,
21
21
  ProviderNameSchema,
22
22
  init_types
23
- } from "./cli-rh5smt8t.js";
23
+ } from "./cli-mntxtkhn.js";
24
24
 
25
25
  // src/be/boot-seeds.ts
26
26
  init_db3();
@@ -15,7 +15,7 @@ import {
15
15
  init_secret_registry,
16
16
  upsertSwarmConfig2,
17
17
  init_db3
18
- } from "./cli-q9pzwxvk.js";
18
+ } from "./cli-csh8fnbg.js";
19
19
  import {
20
20
  createRuntimeProvider,
21
21
  init_runtime_providers
@@ -25,7 +25,7 @@ import {
25
25
  init_session_token_connections,
26
26
  insertSessionToken,
27
27
  init_users
28
- } from "./cli-gwcf52gz.js";
28
+ } from "./cli-b6tnjdvx.js";
29
29
  import {
30
30
  RuntimeControllerCreateSchema,
31
31
  RuntimeControllerUpdateSchema,
@@ -33,7 +33,7 @@ import {
33
33
  RuntimePoolUpdateSchema,
34
34
  RuntimePoolCreateAgentSchema,
35
35
  init_types
36
- } from "./cli-rh5smt8t.js";
36
+ } from "./cli-mntxtkhn.js";
37
37
  import {
38
38
  scrubSecrets,
39
39
  registerVolatileSecret,
@@ -317,10 +317,12 @@ var init_legacy_policy = __esm(() => {
317
317
  "script.api.update": leadOnly,
318
318
  "script.api.rotate": leadOnly,
319
319
  "script.api.delete": leadOnly,
320
+ "schedule.deferral.update.any": leadOrResourceOwner,
320
321
  "runtime_pool.write": operatorOrUser,
321
322
  "runtime_pool.bind": leadOrOperatorOrUser,
322
323
  "runtime_controller.write": operatorOrUser,
323
324
  "agent.token.manage": operatorOrUser,
325
+ "user.role.manage": operatorOrUser,
324
326
  "extension.write": extensionWrite,
325
327
  "extension.activate": extensionActivation,
326
328
  "extension.install.inline": leadOrOperatorOrUser
@@ -374,6 +376,10 @@ var init_permissions = __esm(() => {
374
376
  description: "Mint, rotate, or revoke an agent-bound worker token.",
375
377
  namespace: "agent"
376
378
  },
379
+ "user.role.manage": {
380
+ description: "Assign or remove a person's RBAC roles.",
381
+ namespace: "user"
382
+ },
377
383
  "task.cancel.any": {
378
384
  description: "Cancel any task (beyond tasks the caller created).",
379
385
  namespace: "task"
@@ -678,6 +684,10 @@ var init_permissions = __esm(() => {
678
684
  description: "Delete an external script API endpoint.",
679
685
  namespace: "script"
680
686
  },
687
+ "schedule.deferral.update.any": {
688
+ description: "Change a defer-task schedule the caller did not create.",
689
+ namespace: "schedule"
690
+ },
681
691
  "runtime_pool.write": {
682
692
  description: "Create, update, or delete runtime pools (image, provider kind, placement).",
683
693
  namespace: "runtime_pool"
@@ -9,7 +9,7 @@ import {
9
9
  acquireOAuthRefreshLock,
10
10
  releaseOAuthRefreshLock,
11
11
  init_oauth
12
- } from "./cli-q9pzwxvk.js";
12
+ } from "./cli-csh8fnbg.js";
13
13
  import {
14
14
  scrubSecrets,
15
15
  registerVolatileSecret,
@@ -21,7 +21,7 @@ import {
21
21
  import {
22
22
  DEFAULT_MODEL_TIER_MAP,
23
23
  init_types
24
- } from "./cli-rh5smt8t.js";
24
+ } from "./cli-mntxtkhn.js";
25
25
  import {
26
26
  getOpenRouterBaseUrl,
27
27
  getOpenRouterAttributionHeaders,
@@ -1,12 +1,14 @@
1
1
  import {
2
2
  getDb2,
3
3
  getDbClient2,
4
+ invalidateTelemetryUserRole,
5
+ init_telemetry_identity,
4
6
  init_db3
5
- } from "./cli-q9pzwxvk.js";
7
+ } from "./cli-csh8fnbg.js";
6
8
  import {
7
9
  PermissionVerbSchema,
8
10
  init_rbac
9
- } from "./cli-ba8ne1es.js";
11
+ } from "./cli-4rvr7zfx.js";
10
12
  import {
11
13
  init_env_flag
12
14
  } from "./cli-cebvbc9t.js";
@@ -15,6 +17,16 @@ import {
15
17
  } from "./cli-242037k3.js";
16
18
 
17
19
  // src/be/rbac-roles.ts
20
+ function roleRowToUserRole(row) {
21
+ return {
22
+ id: row.id,
23
+ name: row.name,
24
+ description: row.description,
25
+ isBuiltin: row.isBuiltin === 1,
26
+ grantsAll: row.grantsAll === 1,
27
+ createdAt: row.createdAt
28
+ };
29
+ }
18
30
  function validateBuiltinVerb(roleName, verb) {
19
31
  const parsed = PermissionVerbSchema.safeParse(verb);
20
32
  if (!parsed.success) {
@@ -69,6 +81,88 @@ async function getUserGrant2(userId) {
69
81
  }
70
82
  return { grantsAll: false, verbs };
71
83
  }
84
+ async function listUserRoles2(userId) {
85
+ const rows = await getDbClient2().query(`SELECT r.id, r.name, r.description, r.isBuiltin, r.grantsAll, r.createdAt
86
+ FROM principal_roles pr
87
+ JOIN roles r ON r.id = pr.roleId
88
+ WHERE pr.principalType = 'user' AND pr.principalId = ?
89
+ ORDER BY r.name`, [userId]);
90
+ return rows.map(roleRowToUserRole);
91
+ }
92
+ async function listRbacRoles2() {
93
+ const client = getDbClient2();
94
+ const roles = await client.query("SELECT id, name, description, isBuiltin, grantsAll, createdAt FROM roles ORDER BY name");
95
+ const perms = await client.query("SELECT roleId, verb FROM role_permissions ORDER BY verb");
96
+ return roles.map((row) => ({
97
+ ...roleRowToUserRole(row),
98
+ primary: PRIMARY_ROLE_NAMES2.includes(row.name),
99
+ verbs: perms.filter((p) => p.roleId === row.id).map((p) => p.verb)
100
+ }));
101
+ }
102
+ async function assertNotLastAdmin2(userId) {
103
+ const client = getDbClient2();
104
+ const self = await client.get(`SELECT COUNT(*) AS n
105
+ FROM users u
106
+ JOIN principal_roles pr ON pr.principalType = 'user' AND pr.principalId = u.id
107
+ JOIN roles r ON r.id = pr.roleId AND r.grantsAll = 1
108
+ WHERE u.status = 'active' AND u.id = ?`, [userId]);
109
+ if ((self?.n ?? 0) === 0)
110
+ return;
111
+ const others = await client.get(`SELECT COUNT(DISTINCT u.id) AS n
112
+ FROM users u
113
+ JOIN principal_roles pr ON pr.principalType = 'user' AND pr.principalId = u.id
114
+ JOIN roles r ON r.id = pr.roleId AND r.grantsAll = 1
115
+ WHERE u.status = 'active' AND u.id <> ?`, [userId]);
116
+ if ((others?.n ?? 0) === 0)
117
+ throw new LastAdminError2;
118
+ }
119
+ async function setUserRoles2(userId, roleNames, actorUserId) {
120
+ const names = [...new Set(roleNames)];
121
+ if (names.filter((name) => PRIMARY_ROLE_NAMES2.includes(name)).length !== 1) {
122
+ throw new InvalidRoleSetError2(`Pick exactly one primary role: ${PRIMARY_ROLE_NAMES2.join(", ")}`);
123
+ }
124
+ return getDbClient2().transaction(async (tx) => {
125
+ const wanted = [];
126
+ for (const name of names) {
127
+ const row = await tx.get("SELECT id, name, grantsAll FROM roles WHERE name = ?", [name]);
128
+ if (!row)
129
+ throw new InvalidRoleSetError2(`Unknown role: ${name}`);
130
+ wanted.push(row);
131
+ }
132
+ const current = await tx.query(`SELECT r.id, r.name, r.grantsAll
133
+ FROM principal_roles pr JOIN roles r ON r.id = pr.roleId
134
+ WHERE pr.principalType = 'user' AND pr.principalId = ?
135
+ ORDER BY r.name`, [userId]);
136
+ const wantsAll = wanted.some((r) => r.grantsAll === 1);
137
+ if (current.some((r) => r.grantsAll === 1) && !wantsAll) {
138
+ const user = await tx.get("SELECT status FROM users WHERE id = ?", [
139
+ userId
140
+ ]);
141
+ if (user?.status === "active") {
142
+ const others = await tx.get(`SELECT COUNT(DISTINCT u.id) AS n
143
+ FROM users u
144
+ JOIN principal_roles pr ON pr.principalType = 'user' AND pr.principalId = u.id
145
+ JOIN roles r ON r.id = pr.roleId AND r.grantsAll = 1
146
+ WHERE u.status = 'active' AND u.id <> ?`, [userId]);
147
+ if ((others?.n ?? 0) === 0)
148
+ throw new LastAdminError2;
149
+ }
150
+ }
151
+ const wantedIds = new Set(wanted.map((r) => r.id));
152
+ for (const row of current) {
153
+ if (!wantedIds.has(row.id)) {
154
+ await tx.run(`DELETE FROM principal_roles
155
+ WHERE principalType = 'user' AND principalId = ? AND roleId = ?`, [userId, row.id]);
156
+ }
157
+ }
158
+ for (const row of wanted) {
159
+ await tx.run(`INSERT OR IGNORE INTO principal_roles (principalType, principalId, roleId, created_by)
160
+ VALUES ('user', ?, ?, ?)`, [userId, row.id, actorUserId]);
161
+ }
162
+ getDbClient2().afterCommit(() => invalidateTelemetryUserRole(userId));
163
+ return { before: current.map((r) => r.name), after: wanted.map((r) => r.name).sort() };
164
+ });
165
+ }
72
166
  function ensureRbacSeedsSynced2(opts) {
73
167
  const db = getDb2();
74
168
  const desiredVerbsByRoleId = validatedBuiltinVerbSets();
@@ -145,7 +239,7 @@ function ensureRbacSeedsSynced2(opts) {
145
239
  }
146
240
  return stats;
147
241
  }
148
- var DEFAULT_ROLE_ID = "rbac-role-admin", BUILTIN_ROLES, CREATE_USER_DEFAULT_ROLE_TRIGGER_SQL = `
242
+ var DEFAULT_ROLE_ID = "rbac-role-admin", BUILTIN_ROLES, PRIMARY_ROLE_NAMES2, CREATE_USER_DEFAULT_ROLE_TRIGGER_SQL = `
149
243
  CREATE TRIGGER IF NOT EXISTS trg_users_default_role
150
244
  AFTER INSERT ON users
151
245
  BEGIN
@@ -153,9 +247,10 @@ BEGIN
153
247
  SELECT 'user', NEW.id, 'rbac-role-admin'
154
248
  WHERE EXISTS (SELECT 1 FROM roles WHERE id = 'rbac-role-admin');
155
249
  END;
156
- `, loggedInvalidGrantVerbs;
250
+ `, loggedInvalidGrantVerbs, InvalidRoleSetError2, LastAdminError2;
157
251
  var init_rbac_roles = __esm(() => {
158
252
  init_rbac();
253
+ init_telemetry_identity();
159
254
  init_env_flag();
160
255
  init_db3();
161
256
  BUILTIN_ROLES = [
@@ -183,9 +278,25 @@ var init_rbac_roles = __esm(() => {
183
278
  "session.share",
184
279
  "session.presence"
185
280
  ]
281
+ },
282
+ {
283
+ id: "rbac-role-viewer",
284
+ name: "viewer",
285
+ description: "Read-only: no task, approval or script writes.",
286
+ isBuiltin: true,
287
+ grantsAll: false,
288
+ verbs: ["favorite.write.own", "session.presence"]
186
289
  }
187
290
  ];
291
+ PRIMARY_ROLE_NAMES2 = ["admin", "requester", "viewer"];
188
292
  loggedInvalidGrantVerbs = new Set;
293
+ InvalidRoleSetError2 = class InvalidRoleSetError2 extends Error {
294
+ };
295
+ LastAdminError2 = class LastAdminError2 extends Error {
296
+ constructor() {
297
+ super("last_admin");
298
+ }
299
+ };
189
300
  });
190
301
 
191
- export { getUserGrant2, ensureRbacSeedsSynced2, init_rbac_roles };
302
+ export { PRIMARY_ROLE_NAMES2, getUserGrant2, listUserRoles2, listRbacRoles2, InvalidRoleSetError2, LastAdminError2, assertNotLastAdmin2, setUserRoles2, ensureRbacSeedsSynced2, init_rbac_roles };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ampBillsCacheWrites,
3
3
  resolveAmpModel
4
- } from "./cli-jpxsrxcb.js";
4
+ } from "./cli-xw9q173h.js";
5
5
  import {
6
6
  CONTEXT_FORMULA,
7
7
  computeContextUsedUnified,
@@ -36,7 +36,7 @@ import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
36
36
  import { tmpdir } from "node:os";
37
37
  import { join } from "node:path";
38
38
  init_secret_scrubber();
39
- var AMP_PACKAGE = "@ampcode/cli@0.0.1792670445-ge8d5b3";
39
+ var AMP_PACKAGE = "@ampcode/cli@0.0.1792728062-g40cf3f";
40
40
  var AMP_MCP_SERVER_NAME = "agent-swarm";
41
41
  var AMP_PLUGIN_MODE_KEY = "agent-swarm";
42
42
  var AMP_LIVE_TEST_TIMEOUT_MS = 5000;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_package,
3
3
  package_default
4
- } from "./cli-22rmcjkg.js";
4
+ } from "./cli-kcnwn85g.js";
5
5
 
6
6
  // src/commands/shared/client-config.ts
7
7
  init_package();
@@ -4,7 +4,7 @@ import {
4
4
  claimKv2,
5
5
  deleteKv2,
6
6
  init_db3
7
- } from "./cli-q9pzwxvk.js";
7
+ } from "./cli-csh8fnbg.js";
8
8
  import {
9
9
  isEnvFlagEnabled,
10
10
  init_env_flag
@@ -5,7 +5,7 @@ import {
5
5
  validateRuntimeTokenTtlHours,
6
6
  init_swarm_config_guard,
7
7
  init_db3
8
- } from "./cli-q9pzwxvk.js";
8
+ } from "./cli-csh8fnbg.js";
9
9
  import {
10
10
  registerVolatileSecret,
11
11
  unregisterVolatileSecret,
@@ -282,7 +282,10 @@ function runtimeTokenTtlMs() {
282
282
  async function mintRuntimeToken(agentId, runtimeId, ttlMs = runtimeTokenTtlMs()) {
283
283
  return await insertSessionToken(agentId, null, runtimeId, ttlMs);
284
284
  }
285
- async function insertSessionToken(agentId, taskId, runtimeId, ttlMs, parentRuntimeId = null, expiresAtCeiling, controllerId = null, parentTokenId = null) {
285
+ async function mintScriptRunToken(agentId, ttlMs) {
286
+ return await insertSessionToken(agentId, null, null, ttlMs, null, undefined, null, null, true);
287
+ }
288
+ async function insertSessionToken(agentId, taskId, runtimeId, ttlMs, parentRuntimeId = null, expiresAtCeiling, controllerId = null, parentTokenId = null, scriptRun = false) {
286
289
  const plaintext = `${SESSION_TOKEN_PREFIX}${base62(randomBytes(24))}`;
287
290
  const tokenId = randomUUID().replace(/-/g, "");
288
291
  const hash = sha256Hex(plaintext);
@@ -290,8 +293,8 @@ async function insertSessionToken(agentId, taskId, runtimeId, ttlMs, parentRunti
290
293
  const now = new Date;
291
294
  const expiresAt = new Date(Math.min(now.getTime() + ttlMs, expiresAtCeiling ? Date.parse(expiresAtCeiling) : Infinity)).toISOString();
292
295
  await getDbClient2().run(`INSERT INTO session_tokens
293
- (id, tokenHash, tokenPreview, agentId, taskId, runtimeId, parentRuntimeId, expiresAt, createdAt, controllerId, parentTokenId)
294
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
296
+ (id, tokenHash, tokenPreview, agentId, taskId, runtimeId, parentRuntimeId, expiresAt, createdAt, controllerId, parentTokenId, scriptRun)
297
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
295
298
  tokenId,
296
299
  hash,
297
300
  preview,
@@ -302,7 +305,8 @@ async function insertSessionToken(agentId, taskId, runtimeId, ttlMs, parentRunti
302
305
  expiresAt,
303
306
  now.toISOString(),
304
307
  controllerId,
305
- parentTokenId
308
+ parentTokenId,
309
+ scriptRun ? 1 : 0
306
310
  ]);
307
311
  return { tokenId, plaintext };
308
312
  }
@@ -426,7 +430,7 @@ async function resolveSessionToken(plaintext, options = {}) {
426
430
  function fingerprintApiKey(rawKey) {
427
431
  return `op:${sha256Hex(rawKey).slice(0, 16)}`;
428
432
  }
429
- var TOKEN_PREFIX = "aswt_", SESSION_TOKEN_PREFIX = "aseph_", InvalidRuntimeTokenError, AGENT_TOKEN_BINDING = "taskId IS NULL AND runtimeId IS NULL AND controllerId IS NULL AND parentRuntimeId IS NULL", AGENT_TOKEN_NO_EXPIRY = "9999-12-31T23:59:59.999Z", AGENT_TOKEN_DEFAULT_TTL_MS = null, AgentTokenExistsError;
433
+ var TOKEN_PREFIX = "aswt_", SESSION_TOKEN_PREFIX = "aseph_", InvalidRuntimeTokenError, AGENT_TOKEN_BINDING = "taskId IS NULL AND runtimeId IS NULL AND controllerId IS NULL AND parentRuntimeId IS NULL AND scriptRun = 0", AGENT_TOKEN_NO_EXPIRY = "9999-12-31T23:59:59.999Z", AGENT_TOKEN_DEFAULT_TTL_MS = null, AgentTokenExistsError;
430
434
  var init_users = __esm(() => {
431
435
  init_telemetry_identity();
432
436
  init_secret_scrubber();
@@ -445,4 +449,4 @@ var init_users = __esm(() => {
445
449
  };
446
450
  });
447
451
 
448
- export { registerSessionTokenConnection, closeSessionTokenConnections, init_session_token_connections, findUserById, findUserByExternalId, findUserByEmail, findUsersByName, getUserIdentities, listUserEvents, listUserTokens, recordIdentityEvent, findOrCreateUserByEmail, linkIdentity, unlinkIdentity, mintToken, revokeToken, resolveUserByToken, InvalidRuntimeTokenError, mintSessionToken, mintRuntimeToken, insertSessionToken, revokeSessionToken, revokeRuntimeTokensForRuntime, AgentTokenExistsError, mintAgentToken, rotateAgentToken, revokeAgentTokens, resolveSessionToken, fingerprintApiKey, init_users };
452
+ export { registerSessionTokenConnection, closeSessionTokenConnections, init_session_token_connections, findUserById, findUserByExternalId, findUserByEmail, findUsersByName, getUserIdentities, listUserEvents, listUserTokens, recordIdentityEvent, findOrCreateUserByEmail, linkIdentity, unlinkIdentity, mintToken, revokeToken, resolveUserByToken, InvalidRuntimeTokenError, mintSessionToken, mintRuntimeToken, mintScriptRunToken, insertSessionToken, revokeSessionToken, revokeRuntimeTokensForRuntime, AgentTokenExistsError, mintAgentToken, rotateAgentToken, revokeAgentTokens, resolveSessionToken, fingerprintApiKey, init_users };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getDb2,
3
3
  init_db3
4
- } from "./cli-q9pzwxvk.js";
4
+ } from "./cli-csh8fnbg.js";
5
5
  import {
6
6
  openAICompatibleProviderIds,
7
7
  withRegistryCatalogSections,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runStopHookSessionSummarySubprocess
3
- } from "./cli-ajqhxtnz.js";
3
+ } from "./cli-f3pfn4x3.js";
4
4
  import {
5
5
  CONTEXT_FORMULA,
6
6
  getContextWindowSize,
@@ -1236,7 +1236,7 @@ class ClaudeAdapter2 {
1236
1236
  if (transport === "sdk" && isClaudeBridgeEffective(sourceEnv)) {
1237
1237
  throw new Error("CLAUDE_TRANSPORT=sdk cannot run with an effective Claude Bridge configuration. Select CLI transport or disable the bridge.");
1238
1238
  }
1239
- const claudeSdk = transport === "sdk" ? await import("./claude-sdk-session-05kat8rv.js") : undefined;
1239
+ const claudeSdk = transport === "sdk" ? await import("./claude-sdk-session-0zrdzyx2.js") : undefined;
1240
1240
  claudeSdk?.validateClaudeSdkAdditionalArgs([
1241
1241
  ...claudeBinaryArgv.slice(1),
1242
1242
  ...config.additionalArgs ?? []