@desplega.ai/agent-swarm 1.145.0 → 1.147.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 (221) hide show
  1. package/README.md +2 -1
  2. package/dist/{acp-adapter-580t41c0.js → acp-adapter-9n319wqc.js} +61 -6
  3. package/dist/{actions-m662tjng.js → actions-2vxqvpr9.js} +9 -8
  4. package/dist/{app-zb3rndm8.js → app-w066xfy0.js} +6 -5
  5. package/dist/assistant-kt31dj2h.js +236 -0
  6. package/dist/{boot-reembed-072x00vn.js → boot-reembed-az5rassp.js} +7 -6
  7. package/dist/{boot-reembed-65zz2smt.js → boot-reembed-j3mm3rfz.js} +8 -7
  8. package/dist/{boot-scrub-logs-yz0ams04.js → boot-scrub-logs-b6h54817.js} +4 -4
  9. package/dist/{claude-adapter-paj270y2.js → claude-adapter-w1z04ann.js} +8 -6
  10. package/dist/{claude-managed-setup-w619jncn.js → claude-managed-setup-f5pmsyrp.js} +24 -3
  11. package/dist/{claude-sdk-session-swt80j9z.js → claude-sdk-session-f0cc1kec.js} +8 -6
  12. package/dist/{cli-dt553ktb.js → cli-0b6y7kxm.js} +1 -1
  13. package/dist/{cli-bxdhw615.js → cli-12fz972k.js} +4 -4
  14. package/dist/{cli-s2f20r5w.js → cli-1th1728g.js} +2 -2
  15. package/dist/{cli-rs6ec3b9.js → cli-3tgwnf43.js} +3 -3
  16. package/dist/{cli-gxnzc6wh.js → cli-4nr988h6.js} +1 -1
  17. package/dist/{cli-axs8e6d4.js → cli-53s590z8.js} +1 -1
  18. package/dist/{cli-ygbjp3z8.js → cli-54wwve05.js} +5 -4
  19. package/dist/{cli-v0asr5yv.js → cli-719k9j2c.js} +2 -2
  20. package/dist/{cli-anktweqr.js → cli-89xfd7f9.js} +21 -47
  21. package/dist/{cli-q34a0e10.js → cli-8v0g1yc8.js} +1 -1
  22. package/dist/cli-9d8ntetj.js +42 -0
  23. package/dist/{cli-z9fprcrf.js → cli-atcve9y8.js} +881 -738
  24. package/dist/{cli-jmb7g47h.js → cli-b5bq9crk.js} +14 -31
  25. package/dist/cli-d8brzxjb.js +190 -0
  26. package/dist/{cli-gzky0gkr.js → cli-de14znh8.js} +2 -2
  27. package/dist/{cli-xytwff7f.js → cli-dttph1bw.js} +2 -2
  28. package/dist/cli-ep19k3mb.js +19 -0
  29. package/dist/{cli-m1xa8be7.js → cli-f146mn5s.js} +7 -50
  30. package/dist/{cli-1fj0chdk.js → cli-f7dsy61y.js} +5 -3
  31. package/dist/{cli-f567d5c1.js → cli-ftht3zzj.js} +2782 -2589
  32. package/dist/{cli-a0g1gbt5.js → cli-hbv0kq6w.js} +2 -2
  33. package/dist/{cli-fhsz3twr.js → cli-jsp14b6c.js} +171 -1
  34. package/dist/{cli-7fnkj1hj.js → cli-kpv03zhj.js} +21 -17
  35. package/dist/{cli-m4j6trn4.js → cli-m8yrsg97.js} +2 -2
  36. package/dist/cli-m9sxbkhm.js +779 -0
  37. package/dist/cli-mmemxxdc.js +823 -0
  38. package/dist/{cli-tqtvj5pt.js → cli-n8508nre.js} +1 -1
  39. package/dist/{cli-z96t0thj.js → cli-p1d5b073.js} +37 -2
  40. package/dist/{cli-gh8y8f36.js → cli-rw51bq3j.js} +13 -10
  41. package/dist/{cli-59ej1c07.js → cli-smby5m17.js} +7 -6
  42. package/dist/{cli-65vqzz3v.js → cli-tzvk9haz.js} +94 -372
  43. package/dist/{cli-dc9k2ba9.js → cli-w9kb3bk1.js} +1 -1
  44. package/dist/{cli-kpev657q.js → cli-y6b6fb76.js} +25 -3
  45. package/dist/{cli-123q2get.js → cli-yz3djrm0.js} +9 -9
  46. package/dist/{cli-wvp6bvy4.js → cli-zhjmqxzh.js} +1 -1
  47. package/dist/cli.js +13 -13
  48. package/dist/{codex-adapter-k98vaw2r.js → codex-adapter-zw4dwsx7.js} +2 -2
  49. package/dist/{codex-hook-9pf19cks.js → codex-hook-bw8p5nh4.js} +2 -2
  50. package/dist/{codex-session-runner-tngtphx7.js → codex-session-runner-k981s65v.js} +2 -2
  51. package/dist/{commands-y8nbr3fv.js → commands-sykrxx7e.js} +4 -4
  52. package/dist/{db-30p4h2t1.js → db-sfbsc8wt.js} +6 -4
  53. package/dist/handlers-0aspcejm.js +603 -0
  54. package/dist/{hook-dcw4jfbj.js → hook-4nvqj2sb.js} +7 -5
  55. package/dist/{hook-21jexvfx.js → hook-hxccs7m5.js} +24 -49
  56. package/dist/{http-r4kq5g8d.js → http-y06z517d.js} +230 -94
  57. package/dist/{index-q3qja6ta.js → index-hssww7kj.js} +15 -14
  58. package/dist/{index-gay66b9w.js → index-k8znfx0z.js} +13 -12
  59. package/dist/{index-53zyht4z.js → index-tce1rss4.js} +371 -110
  60. package/dist/{index-nqvf26za.js → index-x5j894zf.js} +14 -13
  61. package/dist/{keepalive-xs8fa55y.js → keepalive-w733ax66.js} +6 -6
  62. package/dist/{lead-d9m2t4s0.js → lead-75bjqa9d.js} +29 -27
  63. package/dist/{maintenance-3zh82g6z.js → maintenance-w4f1zjck.js} +8 -7
  64. package/dist/{oauth-refresh-sweep-03snsye5.js → oauth-refresh-sweep-wdetky26.js} +5 -5
  65. package/dist/{onboard-0cg1925x.js → onboard-bb5net8s.js} +2 -2
  66. package/dist/{otel-impl-0ab95z27.js → otel-impl-0w7c14ap.js} +1 -1
  67. package/dist/{pi-mono-adapter-dtkz4e7j.js → pi-mono-adapter-2has4gnp.js} +12 -2
  68. package/dist/{pricing-refresh-e5jhzz4j.js → pricing-refresh-9nzsrgcq.js} +6 -6
  69. package/dist/{rbac-roles-p1mf40z3.js → rbac-roles-r3hqjp09.js} +5 -5
  70. package/dist/{rbac-roles-2w3cmrkc.js → rbac-roles-z1jrffbt.js} +4 -4
  71. package/dist/{registry-9kdck5ye.js → registry-v5wytg0s.js} +1 -2
  72. package/dist/{render-v2-xhawry3k.js → render-v2-vbr89fnb.js} +6 -5
  73. package/dist/{seed-pricing-t223sw91.js → seed-pricing-g62hy1pk.js} +7 -5
  74. package/dist/{setup-zcs0rce7.js → setup-gnfqnptp.js} +2 -2
  75. package/dist/{worker-qnp2ka62.js → worker-kznxp4qm.js} +29 -27
  76. package/openapi.json +263 -12
  77. package/package.json +1 -1
  78. package/plugin/commands/start-worker.md +4 -9
  79. package/plugin/pi-skills/start-worker/SKILL.md +4 -9
  80. package/src/be/db/agents.ts +556 -0
  81. package/src/be/db/context-versions.ts +117 -0
  82. package/src/be/db/runtime.ts +406 -0
  83. package/src/be/db/tasks/read.ts +1167 -0
  84. package/src/be/db/tasks/write.ts +953 -0
  85. package/src/be/db.ts +584 -3429
  86. package/src/be/migrations/147_scheduled_tasks_parent_task.sql +7 -0
  87. package/src/be/migrations/148_pages_svg.sql +123 -0
  88. package/src/be/migrations/149_session_tokens.sql +24 -0
  89. package/src/be/scripts/typecheck.ts +1 -0
  90. package/src/be/seed-pricing.ts +13 -8
  91. package/src/be/seed-scripts/catalog/ops-catalog-audit.inline.ts +1 -1
  92. package/src/be/seed-scripts/catalog/ops-catalog-audit.ts +1 -1
  93. package/src/be/seed-scripts/catalog/star-history-refresh.ts +101 -0
  94. package/src/be/seed-scripts/catalog/star-history-renderer.ts +119 -0
  95. package/src/be/seed-scripts/index.ts +17 -0
  96. package/src/be/seed-skills/index.ts +14 -0
  97. package/src/be/swarm-config-guard.ts +5 -2
  98. package/src/be/task-attachment-store.ts +70 -0
  99. package/src/be/users.ts +77 -0
  100. package/src/commands/attachments-section.ts +37 -0
  101. package/src/commands/claude-managed-setup.ts +45 -3
  102. package/src/commands/claude-md-session.ts +408 -0
  103. package/src/commands/context-preamble.ts +15 -3
  104. package/src/commands/profile-sync.ts +205 -5
  105. package/src/commands/provider-credentials.ts +60 -27
  106. package/src/commands/runner.ts +63 -58
  107. package/src/commands/templates.ts +25 -2
  108. package/src/hooks/hook.ts +26 -67
  109. package/src/http/agents.ts +40 -1
  110. package/src/http/auth.ts +13 -1
  111. package/src/http/fs.ts +21 -51
  112. package/src/http/index.ts +2 -0
  113. package/src/http/mcp.ts +32 -0
  114. package/src/http/pages-public.ts +20 -4
  115. package/src/http/pages.ts +11 -3
  116. package/src/http/poll.ts +4 -0
  117. package/src/http/repos.ts +3 -3
  118. package/src/http/sessions.ts +82 -0
  119. package/src/http/tasks.ts +10 -2
  120. package/src/http/utils.ts +79 -1
  121. package/src/prompts/session-templates.ts +12 -8
  122. package/src/providers/acp-adapter.ts +62 -8
  123. package/src/providers/pi-mono-adapter.ts +23 -6
  124. package/src/providers/pricing-sources.md +11 -0
  125. package/src/scheduler/scheduler.test.ts +49 -2
  126. package/src/scheduler/scheduler.ts +4 -0
  127. package/src/scripts-runtime/sdk-allowlist.ts +1 -0
  128. package/src/scripts-runtime/types/stdlib.d.ts +8 -0
  129. package/src/scripts-runtime/types/swarm-sdk.d.ts +8 -0
  130. package/src/server.ts +2 -0
  131. package/src/slack/assistant.ts +87 -46
  132. package/src/slack/handlers.test.ts +1 -3
  133. package/src/slack/handlers.ts +102 -87
  134. package/src/slack/inbound-files.ts +466 -0
  135. package/src/slack/templates.ts +14 -0
  136. package/src/tasks/task-terminal-effects.ts +158 -0
  137. package/src/tests/acp-adapter.test.ts +369 -117
  138. package/src/tests/budget-claim-gate.test.ts +1 -0
  139. package/src/tests/build-pi-skills.test.ts +5 -7
  140. package/src/tests/claude-managed-setup.test.ts +52 -4
  141. package/src/tests/claude-md-session.test.ts +603 -0
  142. package/src/tests/codex-skill-resolver.test.ts +19 -0
  143. package/src/tests/context-versioning.test.ts +107 -0
  144. package/src/tests/cors-allowlist.test.ts +309 -0
  145. package/src/tests/credential-check.test.ts +157 -14
  146. package/src/tests/db-agents.test.ts +91 -0
  147. package/src/tests/db-context-versions.test.ts +37 -0
  148. package/src/tests/db-extraction-contract.test.ts +45 -0
  149. package/src/tests/db-runtime.test.ts +70 -0
  150. package/src/tests/db-task-read-contract.test.ts +624 -0
  151. package/src/tests/db-task-write-contract.test.ts +653 -0
  152. package/src/tests/db-tasks-read.test.ts +183 -0
  153. package/src/tests/db-tasks-write.test.ts +230 -0
  154. package/src/tests/defer-task.test.ts +389 -0
  155. package/src/tests/docs-index-footprint.test.js +2 -2
  156. package/src/tests/e2e-visuals-stage.test.ts +151 -0
  157. package/src/tests/file-lock.test.ts +144 -0
  158. package/src/tests/fixtures/file-lock-holder.ts +13 -0
  159. package/src/tests/fixtures/hold-file-lock.ts +25 -0
  160. package/src/tests/heartbeat-expiry.test.ts +188 -0
  161. package/src/tests/http-api-integration.test.ts +78 -1
  162. package/src/tests/pages-public-html.test.ts +43 -0
  163. package/src/tests/pages-svg-migration.test.ts +42 -0
  164. package/src/tests/preload.ts +4 -1
  165. package/src/tests/profile-sync-warning.test.ts +16 -0
  166. package/src/tests/profile-sync.test.ts +126 -0
  167. package/src/tests/prompt-template-session.test.ts +20 -4
  168. package/src/tests/provider-registration.test.ts +93 -0
  169. package/src/tests/rbac-e2e-helpers.test.ts +53 -0
  170. package/src/tests/rbac-e2e-helpers.ts +19 -2
  171. package/src/tests/reload-config.test.ts +26 -0
  172. package/src/tests/routing-affinity-inventory.test.ts +1 -1
  173. package/src/tests/runner-attachments-section.test.ts +22 -2
  174. package/src/tests/runner-context-preamble.test.ts +30 -0
  175. package/src/tests/runner-deployment-resume.test.ts +107 -0
  176. package/src/tests/runner-repo-autostash.test.ts +12 -0
  177. package/src/tests/script-connections.test.ts +4 -0
  178. package/src/tests/seed-scripts.test.ts +2 -2
  179. package/src/tests/session-tokens.test.ts +279 -0
  180. package/src/tests/slack-file-tools-attachments.test.ts +408 -0
  181. package/src/tests/slack-inbound-files.test.ts +847 -0
  182. package/src/tests/star-history-refresh.test.ts +102 -0
  183. package/src/tests/swarm-config-reserved-keys.test.ts +21 -0
  184. package/src/tests/swarm-repos.test.ts +20 -0
  185. package/src/tests/tool-annotations.test.ts +4 -3
  186. package/src/tests/ui-logs-parser.test.ts +176 -0
  187. package/src/tools/create-page.ts +4 -2
  188. package/src/tools/defer-task.ts +239 -0
  189. package/src/tools/repos/update-repo.ts +2 -2
  190. package/src/tools/schedules/create-schedule.ts +1 -0
  191. package/src/tools/schedules/list-schedules.ts +1 -0
  192. package/src/tools/schedules/patch-schedule.ts +1 -0
  193. package/src/tools/schedules/update-schedule.ts +1 -0
  194. package/src/tools/slack-download-file.ts +60 -29
  195. package/src/tools/slack-read.ts +73 -32
  196. package/src/tools/store-progress.ts +16 -146
  197. package/src/tools/tool-config.ts +1 -0
  198. package/src/tools/utils.ts +21 -0
  199. package/src/types.ts +37 -4
  200. package/src/utils/acp-session-token.ts +56 -0
  201. package/src/utils/file-lock.ts +111 -0
  202. package/src/utils/heartbeat-expiry.ts +78 -0
  203. package/src/utils/request-auth-context.ts +2 -0
  204. package/src/utils/task-attachment-links.ts +22 -0
  205. package/templates/skills/code-quality/content.md +8 -5
  206. package/templates/skills/download-task-attachment/content.md +2 -1
  207. package/{plugin/pi-skills → templates/skills}/review-offered-task/SKILL.md +5 -5
  208. package/templates/skills/review-offered-task/config.json +14 -0
  209. package/{plugin/commands/review-offered-task.md → templates/skills/review-offered-task/content.md} +3 -8
  210. package/templates/skills/scheduling/content.md +4 -0
  211. package/templates/skills/slack-interaction/content.md +2 -2
  212. package/templates/skills/work-on-task/SKILL.md +16 -0
  213. package/templates/skills/work-on-task/config.json +14 -0
  214. package/templates/skills/work-on-task/content.md +11 -0
  215. package/dist/assistant-0qt42nzg.js +0 -212
  216. package/dist/cli-fs1kkqgr.js +0 -317
  217. package/dist/cli-jnf5zghe.js +0 -269
  218. package/dist/cli-n1q8q14d.js +0 -177
  219. package/dist/handlers-yfp1qn81.js +0 -592
  220. package/plugin/commands/work-on-task.md +0 -39
  221. package/plugin/pi-skills/work-on-task/SKILL.md +0 -39
@@ -1,6 +1,10 @@
1
1
  import {
2
2
  require_follow_redirects
3
3
  } from "./cli-q51yprfq.js";
4
+ import {
5
+ init_task_attachment_links,
6
+ taskAttachmentDisplayUrl
7
+ } from "./cli-9d8ntetj.js";
4
8
  import {
5
9
  require_jws,
6
10
  require_p_retry
@@ -45,9 +49,8 @@ import {
45
49
  setSlackMessageTracking,
46
50
  slackContextKey,
47
51
  updateSlackMessageRecord
48
- } from "./cli-f567d5c1.js";
52
+ } from "./cli-ftht3zzj.js";
49
53
  import {
50
- buildAgentFsLiveUrl,
51
54
  getAppUrl,
52
55
  init_constants
53
56
  } from "./cli-e29gmdmw.js";
@@ -54435,28 +54438,7 @@ var version = package_default.version;
54435
54438
  init_db();
54436
54439
  init_context_key();
54437
54440
  init_env_flag();
54438
-
54439
- // src/utils/task-attachment-links.ts
54440
- init_constants();
54441
- function taskAttachmentDisplayUrl(attachment) {
54442
- if (attachment.kind === "url")
54443
- return attachment.url ?? "";
54444
- if (attachment.kind === "page") {
54445
- return attachment.pageId ? `${getAppUrl()}/pages/${attachment.pageId}` : "page:";
54446
- }
54447
- if (attachment.providerId === "agent-fs" || attachment.kind === "agent-fs") {
54448
- const liveUrl = buildAgentFsLiveUrl({
54449
- path: attachment.path,
54450
- orgId: attachment.orgId,
54451
- driveId: attachment.driveId
54452
- });
54453
- return liveUrl ?? `agent-fs:${attachment.path ?? ""}`;
54454
- }
54455
- if (attachment.providerId === "local-fs" || attachment.kind === "shared-fs") {
54456
- return `${getAppUrl()}/api/fs/tasks/${attachment.taskId}/files/${attachment.id}/raw`;
54457
- }
54458
- return attachment.path ?? attachment.providerKey ?? "";
54459
- }
54441
+ init_task_attachment_links();
54460
54442
 
54461
54443
  // src/slack/ack.ts
54462
54444
  init_db();
@@ -54493,7 +54475,7 @@ async function initOtel(serviceRole = process.env.AGENT_ROLE || "api") {
54493
54475
  return;
54494
54476
  initialized = true;
54495
54477
  try {
54496
- const impl = await import("./otel-impl-0ab95z27.js");
54478
+ const impl = await import("./otel-impl-0w7c14ap.js");
54497
54479
  await impl.boot(serviceRole);
54498
54480
  realWithSpan = impl.withSpan;
54499
54481
  realStartSpan = impl.startSpan;
@@ -54585,6 +54567,7 @@ init_db();
54585
54567
 
54586
54568
  // src/slack/blocks.ts
54587
54569
  init_constants();
54570
+ init_task_attachment_links();
54588
54571
  var MAX_SECTION_LENGTH = 2900;
54589
54572
  var MAX_BLOCKS_PER_COMPLETION_MESSAGE = 45;
54590
54573
  function getTaskLink(taskId) {
@@ -55810,13 +55793,13 @@ async function initSlackApp() {
55810
55793
  logLevel: import_bolt.LogLevel.DEBUG,
55811
55794
  ...slackApiUrl ? { clientOptions: { slackApiUrl } } : {}
55812
55795
  });
55813
- const { registerMessageHandler } = await import("./handlers-yfp1qn81.js");
55814
- const { registerCommandHandler } = await import("./commands-y8nbr3fv.js");
55815
- const { registerActionHandlers } = await import("./actions-m662tjng.js");
55796
+ const { registerMessageHandler } = await import("./handlers-0aspcejm.js");
55797
+ const { registerCommandHandler } = await import("./commands-sykrxx7e.js");
55798
+ const { registerActionHandlers } = await import("./actions-2vxqvpr9.js");
55816
55799
  registerMessageHandler(app);
55817
55800
  registerCommandHandler(app);
55818
55801
  registerActionHandlers(app);
55819
- const { createAssistant } = await import("./assistant-0qt42nzg.js");
55802
+ const { createAssistant } = await import("./assistant-kt31dj2h.js");
55820
55803
  app.assistant(createAssistant());
55821
55804
  return app;
55822
55805
  }
@@ -55825,7 +55808,7 @@ async function startSlackApp() {
55825
55808
  await initSlackApp();
55826
55809
  }
55827
55810
  if (app) {
55828
- const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-xhawry3k.js");
55811
+ const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-vbr89fnb.js");
55829
55812
  if (isSlackRenderV2Enabled2())
55830
55813
  await ensureSlackRenderV2Activation();
55831
55814
  await app.start();
@@ -56975,4 +56958,4 @@ function _resetSlackRenderV2ForTests() {
56975
56958
  cachedTeamId = undefined;
56976
56959
  }
56977
56960
 
56978
- export { initialize, ensure, require_dist7 as require_dist, isPollTracingEnabled, initOtel, withSpan, startSpan, withSpanContext, withRemoteContext, injectTraceContext, recordSessionCost, recordDbRetentionSweep, recordDbRetentionStatement, ackSlackMessage, taskAttachmentDisplayUrl, getTaskLink, markdownToSlack, buildCancelledBlocks, buildBufferFlushBlocks, buildTreeBlocks, getAgentDisplayName, getAgentEmoji, isSlackRenderV2Enabled, isSlackDelegationEnabled, callSlackWithRetry, formatV2Duration, renderThreadTree, ensureSlackThreadTree, childOutcomeContent, streamOutcomeCard, processSlackRenderV2, _resetSlackRenderV2ForTests, registerTreeMessage, getSlackApp, initSlackApp, startSlackApp, stopSlackApp };
56961
+ export { initialize, ensure, require_dist7 as require_dist, isPollTracingEnabled, initOtel, withSpan, startSpan, withSpanContext, withRemoteContext, injectTraceContext, recordSessionCost, recordDbRetentionSweep, recordDbRetentionStatement, ackSlackMessage, getTaskLink, markdownToSlack, buildCancelledBlocks, buildBufferFlushBlocks, buildTreeBlocks, getAgentDisplayName, getAgentEmoji, isSlackRenderV2Enabled, isSlackDelegationEnabled, callSlackWithRetry, formatV2Duration, renderThreadTree, ensureSlackThreadTree, childOutcomeContent, streamOutcomeCard, processSlackRenderV2, _resetSlackRenderV2ForTests, registerTreeMessage, getSlackApp, initSlackApp, startSlackApp, stopSlackApp };
@@ -0,0 +1,190 @@
1
+ import {
2
+ CLAUDE_MD_LINEAGE_PATH,
3
+ CLAUDE_MD_LOCK_PATH,
4
+ CLAUDE_MD_PATH,
5
+ claudeMdLineageOf,
6
+ claudeMdPendingRecord,
7
+ contentSha256,
8
+ effectiveClaudeMdLineage,
9
+ hookWrittenLineage,
10
+ init_file_lock,
11
+ init_profile_sync,
12
+ parseClaudeMdLineage,
13
+ parseClaudeMdPendingRecord,
14
+ planClaudeMdSync,
15
+ withFileLock
16
+ } from "./cli-m9sxbkhm.js";
17
+ import {
18
+ init_secret_scrubber,
19
+ scrubSecrets
20
+ } from "./cli-xqcq9y5e.js";
21
+
22
+ // src/commands/claude-md-session.ts
23
+ init_file_lock();
24
+ init_secret_scrubber();
25
+ init_profile_sync();
26
+ import { rename } from "node:fs/promises";
27
+ var readText = async (path) => {
28
+ const file = Bun.file(path);
29
+ return await file.exists() ? await file.text() : undefined;
30
+ };
31
+ var DEFAULT_CLAUDE_MD_SESSION_PATHS = {
32
+ file: CLAUDE_MD_PATH,
33
+ backup: `${CLAUDE_MD_PATH}.bak`,
34
+ record: CLAUDE_MD_LINEAGE_PATH,
35
+ lock: CLAUDE_MD_LOCK_PATH
36
+ };
37
+ var SESSION_START_LOCK_WAIT_MS = 40000;
38
+ var STOP_LOCK_WAIT_MS = 15000;
39
+ async function writeAtomic(path, data) {
40
+ const tmp = `${path}.${process.pid}.${crypto.randomUUID()}.tmp`;
41
+ await Bun.write(tmp, data);
42
+ try {
43
+ await rename(tmp, path);
44
+ } catch (error) {
45
+ await Bun.file(tmp).delete().catch(() => {});
46
+ throw error;
47
+ }
48
+ }
49
+ async function writeUnderPendingRecord(paths, pauses, content, lineage) {
50
+ await writeAtomic(paths.record, claudeMdPendingRecord(contentSha256(content)));
51
+ await Bun.write(paths.file, content);
52
+ await pauses.afterFileWrite?.();
53
+ try {
54
+ await pauses.beforeRecordCommit?.();
55
+ await writeAtomic(paths.record, JSON.stringify(lineage));
56
+ } catch (error) {
57
+ console.warn(scrubSecrets(`[claude-md] lineage not recorded, the file stays unpushable: ${String(error)}`));
58
+ }
59
+ }
60
+ function hasUnknownLineage(content, rawRecord) {
61
+ if (rawRecord === undefined)
62
+ return false;
63
+ if (parseClaudeMdLineage(rawRecord))
64
+ return false;
65
+ return parseClaudeMdPendingRecord(rawRecord) !== contentSha256(content);
66
+ }
67
+ function unsyncedCopyPath(paths, content) {
68
+ return `${paths.file}.unsynced-${contentSha256(content).slice(0, 12)}`;
69
+ }
70
+ async function saveUnsynced(paths, content) {
71
+ const copy = unsyncedCopyPath(paths, content);
72
+ await writeAtomic(copy, content);
73
+ console.warn(scrubSecrets(`[claude-md] CLAUDE.md content of unknown lineage was not synced; saved to ${copy} ` + "instead of discarding it. It may hold an agent's edit: compare it with the current " + "value before re-applying anything."));
74
+ }
75
+ async function deleteIfPresent(path) {
76
+ try {
77
+ await Bun.file(path).delete();
78
+ } catch (error) {
79
+ if (error.code !== "ENOENT")
80
+ throw error;
81
+ }
82
+ }
83
+ function warnLockMiss(step, miss) {
84
+ const detail = miss.error === undefined ? "" : `: ${String(miss.error)}`;
85
+ console.warn(scrubSecrets(`[claude-md] no lock at ${step} (${miss.reason})${detail}`));
86
+ }
87
+ async function materializeClaudeMd(content, paths = DEFAULT_CLAUDE_MD_SESSION_PATHS, options = {}) {
88
+ const pauses = options.testPauses ?? {};
89
+ const locked = await withFileLock(paths.lock, () => materializeUnlocked(content, paths, pauses), {
90
+ waitMs: options.lockWaitMs ?? SESSION_START_LOCK_WAIT_MS
91
+ });
92
+ if (locked.acquired)
93
+ return "materialized";
94
+ warnLockMiss("SessionStart", locked);
95
+ if (locked.reason === "unsupported")
96
+ await materializeUnlocked(content, paths, pauses);
97
+ return locked.reason;
98
+ }
99
+ async function materializeUnlocked(content, paths, pauses) {
100
+ const state = await readClaudeMdSyncState(paths);
101
+ if (state) {
102
+ const { content: existing, record } = state;
103
+ if (state.lineageUnknown)
104
+ await saveUnsynced(paths, existing);
105
+ const lineage = record ? claudeMdLineageOf(existing, record) : hookWrittenLineage(existing);
106
+ await Bun.write(paths.backup, existing);
107
+ const sidecar = { ...lineage, of: contentSha256(existing) };
108
+ await writeAtomic(`${paths.backup}.lineage`, JSON.stringify(sidecar)).catch(() => {});
109
+ }
110
+ const hash = contentSha256(content);
111
+ await writeUnderPendingRecord(paths, pauses, content, { written: hash, base: hash });
112
+ }
113
+ async function restoreUnlocked(paths, pauses) {
114
+ const backup = Bun.file(paths.backup);
115
+ const sidecar = Bun.file(`${paths.backup}.lineage`);
116
+ if (await backup.exists()) {
117
+ const content = await backup.text();
118
+ const raw = await sidecar.exists() ? await sidecar.text() : undefined;
119
+ let lineage = null;
120
+ try {
121
+ const pinnedTo = raw ? JSON.parse(raw).of : undefined;
122
+ if (pinnedTo === contentSha256(content))
123
+ lineage = parseClaudeMdLineage(raw);
124
+ } catch {
125
+ lineage = null;
126
+ }
127
+ await writeUnderPendingRecord(paths, pauses, content, lineage ?? hookWrittenLineage(content));
128
+ await backup.delete();
129
+ await sidecar.delete().catch(() => {});
130
+ } else {
131
+ await deleteIfPresent(paths.file);
132
+ await deleteIfPresent(paths.record).catch(() => {});
133
+ }
134
+ }
135
+ function unpushedContent(state, couldPush) {
136
+ if (!state)
137
+ return null;
138
+ if (state.lineageUnknown)
139
+ return state.content;
140
+ return !couldPush && planClaudeMdSync(state) ? state.content : null;
141
+ }
142
+ async function restoreSavingUnpushed(paths, pauses, unpushed) {
143
+ try {
144
+ if (unpushed !== null)
145
+ await saveUnsynced(paths, unpushed);
146
+ await restoreUnlocked(paths, pauses);
147
+ } catch (error) {
148
+ console.warn(scrubSecrets(`[claude-md] .bak not restored: ${String(error)}`));
149
+ }
150
+ }
151
+ async function readClaudeMdSyncState(paths = DEFAULT_CLAUDE_MD_SESSION_PATHS, readFile = readText) {
152
+ const content = await readFile(paths.file);
153
+ if (content === undefined)
154
+ return null;
155
+ const raw = await readFile(paths.record);
156
+ return {
157
+ content,
158
+ record: effectiveClaudeMdLineage(raw, content),
159
+ lineageUnknown: hasUnknownLineage(content, raw)
160
+ };
161
+ }
162
+ async function stopClaudeMd(sync, paths = DEFAULT_CLAUDE_MD_SESSION_PATHS, options = {}) {
163
+ const pauses = options.testPauses ?? {};
164
+ const locked = await withFileLock(paths.lock, async () => {
165
+ const state = await readClaudeMdSyncState(paths);
166
+ const body = state ? planClaudeMdSync(state) : null;
167
+ if (body) {
168
+ await sync(body).catch((error) => {
169
+ console.warn(scrubSecrets(`[claude-md] sync failed: ${String(error)}`));
170
+ });
171
+ }
172
+ await restoreSavingUnpushed(paths, pauses, unpushedContent(state, true));
173
+ return body ? "synced" : "not-an-edit";
174
+ }, { waitMs: options.lockWaitMs ?? STOP_LOCK_WAIT_MS });
175
+ if (locked.acquired)
176
+ return locked.value;
177
+ warnLockMiss("Stop", locked);
178
+ if (locked.reason === "unsupported") {
179
+ const state = await readClaudeMdSyncState(paths).catch((error) => {
180
+ console.warn(scrubSecrets(`[claude-md] .bak not restored: ${String(error)}`));
181
+ return;
182
+ });
183
+ if (state !== undefined) {
184
+ await restoreSavingUnpushed(paths, pauses, unpushedContent(state, false));
185
+ }
186
+ }
187
+ return locked.reason;
188
+ }
189
+
190
+ export { materializeClaudeMd, stopClaudeMd };
@@ -7,14 +7,14 @@ import {
7
7
  restoreScratchScriptLastUsedIfUnchanged,
8
8
  runScript,
9
9
  touchScratchScriptLastUsed
10
- } from "./cli-rs6ec3b9.js";
10
+ } from "./cli-3tgwnf43.js";
11
11
  import {
12
12
  defaultAssetKey,
13
13
  getDbClient,
14
14
  getLeadAgent,
15
15
  init_db,
16
16
  init_key
17
- } from "./cli-f567d5c1.js";
17
+ } from "./cli-ftht3zzj.js";
18
18
  import {
19
19
  init_zod
20
20
  } from "./cli-sd0mxa3c.js";
@@ -4,12 +4,12 @@ import {
4
4
  linkIdentity,
5
5
  recordUnmappedIdentity,
6
6
  resolveIdentity
7
- } from "./cli-z96t0thj.js";
7
+ } from "./cli-p1d5b073.js";
8
8
  import {
9
9
  getKv,
10
10
  init_db,
11
11
  upsertKv
12
- } from "./cli-f567d5c1.js";
12
+ } from "./cli-ftht3zzj.js";
13
13
 
14
14
  // src/slack/enrich.ts
15
15
  init_db();
@@ -0,0 +1,19 @@
1
+ // src/be/seed-skills/render.ts
2
+ var YAML_IMPLICIT_NON_STRING = /^(?:~|null|true|false|yes|no|on|off|[-+]?(?:0b[01_]+|0o[0-7_]+|0x[0-9a-f_]+|[0-9][0-9_]*(?:\.[0-9_]*)?(?:e[-+]?[0-9]+)?|\.[0-9][0-9_]*(?:e[-+]?[0-9]+)?)|[-+]?\.(?:inf|nan)|[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}(?:[t ].*)?)$/i;
3
+ function yamlScalar(value) {
4
+ const unsafe = value === "" || /(: )|(:$)|( #)|[\n\t]|^[\s\-?:,[\]{}#&*!|>'"%@`]|\s$/.test(value) || YAML_IMPLICIT_NON_STRING.test(value);
5
+ return unsafe ? JSON.stringify(value) : value;
6
+ }
7
+ function buildSkillContent(config, body) {
8
+ const userInvocable = config.userInvocable === false ? `
9
+ user-invocable: false` : "";
10
+ return `---
11
+ name: ${config.name}
12
+ description: ${yamlScalar(config.description)}${userInvocable}
13
+ ---
14
+
15
+ ${body.trim()}
16
+ `;
17
+ }
18
+
19
+ export { buildSkillContent };
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createAdditiveBuffer,
3
3
  extractSlackMessageText
4
- } from "./cli-jnf5zghe.js";
4
+ } from "./cli-mmemxxdc.js";
5
5
  import {
6
6
  rewriteSlackMentions
7
- } from "./cli-xytwff7f.js";
7
+ } from "./cli-dttph1bw.js";
8
8
  import {
9
9
  createTaskWithSiblingAwareness
10
- } from "./cli-axs8e6d4.js";
10
+ } from "./cli-53s590z8.js";
11
11
  import {
12
12
  buildBufferFlushBlocks,
13
13
  ensureSlackThreadTree,
@@ -16,7 +16,7 @@ import {
16
16
  getSlackApp,
17
17
  isSlackRenderV2Enabled,
18
18
  registerTreeMessage
19
- } from "./cli-jmb7g47h.js";
19
+ } from "./cli-b5bq9crk.js";
20
20
  import {
21
21
  createLogEntry,
22
22
  getAgentById,
@@ -29,13 +29,11 @@ import {
29
29
  init_steering,
30
30
  requestSteering,
31
31
  slackContextKey
32
- } from "./cli-f567d5c1.js";
32
+ } from "./cli-ftht3zzj.js";
33
33
  import {
34
- init_registry,
35
34
  init_steering_enabled,
36
- isSteeringEnabled,
37
- registerTemplate
38
- } from "./cli-7fnkj1hj.js";
35
+ isSteeringEnabled
36
+ } from "./cli-kpv03zhj.js";
39
37
 
40
38
  // src/slack/event-dedup.ts
41
39
  var DEFAULT_TTL_MS = 300000;
@@ -80,47 +78,6 @@ function wasEventSeen(eventId) {
80
78
  return checkAndInsert(defaultCache, eventId, Date.now());
81
79
  }
82
80
 
83
- // src/slack/templates.ts
84
- init_registry();
85
- registerTemplate({
86
- eventType: "slack.assistant.greeting",
87
- header: "",
88
- defaultBody: "Hi! I'm your Agent Swarm assistant. How can I help?",
89
- variables: [],
90
- category: "system"
91
- });
92
- registerTemplate({
93
- eventType: "slack.assistant.suggested_prompts",
94
- header: "",
95
- defaultBody: `Try these:
96
- - Check status: What's the current status of all agents?
97
- - Assign a task: Can you help me with...
98
- - List recent tasks: Show me the most recent tasks`,
99
- variables: [],
100
- category: "system"
101
- });
102
- registerTemplate({
103
- eventType: "slack.assistant.offline",
104
- header: "",
105
- defaultBody: "No agents are available right now. Your request has been queued and will be processed when agents come back online.",
106
- variables: [],
107
- category: "system"
108
- });
109
- registerTemplate({
110
- eventType: "slack.message.thread_context",
111
- header: "",
112
- defaultBody: `<thread_context>
113
- {{thread_messages}}
114
- </thread_context>`,
115
- variables: [
116
- {
117
- name: "thread_messages",
118
- description: "Formatted thread messages (user: text pairs)"
119
- }
120
- ],
121
- category: "system"
122
- });
123
-
124
81
  // src/slack/steering.ts
125
82
  init_db();
126
83
  init_steering();
@@ -2,8 +2,9 @@ import {
2
2
  isMultiRuntimeEnabled
3
3
  } from "./cli-07jd68a1.js";
4
4
  import {
5
+ init_task_attachment_links,
5
6
  taskAttachmentDisplayUrl
6
- } from "./cli-jmb7g47h.js";
7
+ } from "./cli-9d8ntetj.js";
7
8
  import {
8
9
  buildRoutingAffinityFromAgent,
9
10
  createLogEntry,
@@ -25,11 +26,11 @@ import {
25
26
  updateAgentMaxTasks,
26
27
  updateAgentStatus,
27
28
  upsertSwarmConfig
28
- } from "./cli-f567d5c1.js";
29
+ } from "./cli-ftht3zzj.js";
29
30
  import {
30
31
  init_resolver,
31
32
  resolveTemplate
32
- } from "./cli-7fnkj1hj.js";
33
+ } from "./cli-kpv03zhj.js";
33
34
  import {
34
35
  init_env_flag,
35
36
  isEnvFlagEnabled
@@ -363,6 +364,7 @@ async function createTrackerAgentMapping(data) {
363
364
  init_db();
364
365
  init_resolver();
365
366
  init_env_flag();
367
+ init_task_attachment_links();
366
368
  init_templates();
367
369
  var WORKER_LIVENESS_WINDOW_SECONDS = Number(process.env.WORKER_LIVENESS_WINDOW_SECONDS || "30");
368
370
  function isCrashResumePinEnabled() {