@desplega.ai/agent-swarm 1.146.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 (214) hide show
  1. package/README.md +1 -1
  2. package/dist/{acp-adapter-jnq4612m.js → acp-adapter-9n319wqc.js} +42 -4
  3. package/dist/{actions-s41xcn3f.js → actions-2vxqvpr9.js} +9 -8
  4. package/dist/{app-j8bfw3f6.js → app-w066xfy0.js} +6 -5
  5. package/dist/assistant-kt31dj2h.js +236 -0
  6. package/dist/{boot-reembed-jxdz46jp.js → boot-reembed-az5rassp.js} +7 -6
  7. package/dist/{boot-reembed-x1476agm.js → boot-reembed-j3mm3rfz.js} +8 -7
  8. package/dist/{boot-scrub-logs-rab9h5bt.js → boot-scrub-logs-b6h54817.js} +4 -4
  9. package/dist/{claude-adapter-ep6qekbm.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-0wp3qrcy.js → claude-sdk-session-f0cc1kec.js} +8 -6
  12. package/dist/{cli-bafd6xnf.js → cli-0b6y7kxm.js} +1 -1
  13. package/dist/{cli-jyy3e193.js → cli-12fz972k.js} +4 -4
  14. package/dist/{cli-pzfc7j7g.js → cli-1th1728g.js} +2 -2
  15. package/dist/{cli-68h2mfrn.js → cli-3tgwnf43.js} +3 -3
  16. package/dist/{cli-q3qr220d.js → cli-4nr988h6.js} +1 -1
  17. package/dist/{cli-m4xsy03s.js → cli-53s590z8.js} +1 -1
  18. package/dist/{cli-c8q7292f.js → cli-54wwve05.js} +5 -4
  19. package/dist/{cli-rymrjneb.js → cli-719k9j2c.js} +2 -2
  20. package/dist/{cli-zn65x0w8.js → cli-89xfd7f9.js} +21 -47
  21. package/dist/{cli-506z6jqa.js → cli-8v0g1yc8.js} +1 -1
  22. package/dist/cli-9d8ntetj.js +42 -0
  23. package/dist/{cli-dhg6j8h3.js → cli-atcve9y8.js} +826 -737
  24. package/dist/{cli-46yck6nj.js → cli-b5bq9crk.js} +14 -31
  25. package/dist/cli-d8brzxjb.js +190 -0
  26. package/dist/{cli-a960nkfb.js → cli-de14znh8.js} +2 -2
  27. package/dist/{cli-s8sbe32s.js → cli-dttph1bw.js} +2 -2
  28. package/dist/cli-ep19k3mb.js +19 -0
  29. package/dist/{cli-d9pnxgth.js → cli-f146mn5s.js} +7 -50
  30. package/dist/{cli-qar1f940.js → cli-f7dsy61y.js} +5 -3
  31. package/dist/{cli-d4xqde2b.js → cli-ftht3zzj.js} +2780 -2587
  32. package/dist/{cli-pmwbdw36.js → cli-hbv0kq6w.js} +2 -2
  33. package/dist/{cli-fhsz3twr.js → cli-jsp14b6c.js} +171 -1
  34. package/dist/{cli-2zvtzevh.js → cli-kpv03zhj.js} +13 -11
  35. package/dist/{cli-a9bn9svs.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-6xwhtc64.js → cli-n8508nre.js} +1 -1
  39. package/dist/{cli-q0qq1sxw.js → cli-p1d5b073.js} +37 -2
  40. package/dist/{cli-yqeb27t1.js → cli-rw51bq3j.js} +13 -10
  41. package/dist/{cli-zww3vcnm.js → cli-smby5m17.js} +7 -6
  42. package/dist/{cli-ah5hjk49.js → cli-tzvk9haz.js} +94 -372
  43. package/dist/{cli-yxwe913z.js → cli-w9kb3bk1.js} +1 -1
  44. package/dist/{cli-skd674mt.js → cli-y6b6fb76.js} +25 -3
  45. package/dist/{cli-3k2g3kg2.js → cli-yz3djrm0.js} +9 -9
  46. package/dist/{cli-4secrq32.js → cli-zhjmqxzh.js} +1 -1
  47. package/dist/cli.js +13 -13
  48. package/dist/{codex-adapter-d6qajxj3.js → codex-adapter-zw4dwsx7.js} +2 -2
  49. package/dist/{codex-hook-n7m5k7cr.js → codex-hook-bw8p5nh4.js} +2 -2
  50. package/dist/{codex-session-runner-v9krqe4x.js → codex-session-runner-k981s65v.js} +2 -2
  51. package/dist/{commands-923wsas7.js → commands-sykrxx7e.js} +4 -4
  52. package/dist/{db-m1hy4zh5.js → db-sfbsc8wt.js} +6 -4
  53. package/dist/handlers-0aspcejm.js +603 -0
  54. package/dist/{hook-ee4hff56.js → hook-4nvqj2sb.js} +7 -5
  55. package/dist/{hook-bxe3bkdy.js → hook-hxccs7m5.js} +24 -49
  56. package/dist/{http-a8rx91me.js → http-y06z517d.js} +223 -92
  57. package/dist/{index-697zfzv1.js → index-hssww7kj.js} +15 -14
  58. package/dist/{index-3x9g3nbg.js → index-k8znfx0z.js} +13 -12
  59. package/dist/{index-1j9va48r.js → index-tce1rss4.js} +371 -110
  60. package/dist/{index-jj4q3x59.js → index-x5j894zf.js} +14 -13
  61. package/dist/{keepalive-sds4e4ce.js → keepalive-w733ax66.js} +6 -6
  62. package/dist/{lead-ggq6szk8.js → lead-75bjqa9d.js} +29 -27
  63. package/dist/{maintenance-093p41d4.js → maintenance-w4f1zjck.js} +8 -7
  64. package/dist/{oauth-refresh-sweep-dvzq4ckj.js → oauth-refresh-sweep-wdetky26.js} +5 -5
  65. package/dist/{onboard-ydr9tzw5.js → onboard-bb5net8s.js} +2 -2
  66. package/dist/{otel-impl-zx3tdf3j.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-7e6pqnzp.js → pricing-refresh-9nzsrgcq.js} +6 -6
  69. package/dist/{rbac-roles-p2rh6d0r.js → rbac-roles-r3hqjp09.js} +5 -5
  70. package/dist/{rbac-roles-0dv1wt0w.js → rbac-roles-z1jrffbt.js} +4 -4
  71. package/dist/{registry-9kdck5ye.js → registry-v5wytg0s.js} +1 -2
  72. package/dist/{render-v2-4k3jt4r2.js → render-v2-vbr89fnb.js} +6 -5
  73. package/dist/{seed-pricing-2cc1qmcd.js → seed-pricing-g62hy1pk.js} +7 -5
  74. package/dist/{setup-c5yss30k.js → setup-gnfqnptp.js} +2 -2
  75. package/dist/{worker-7srgeqcr.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 +583 -3428
  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 +1 -1
  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/mcp.ts +32 -0
  113. package/src/http/pages-public.ts +20 -4
  114. package/src/http/poll.ts +4 -0
  115. package/src/http/repos.ts +3 -3
  116. package/src/http/sessions.ts +82 -0
  117. package/src/http/tasks.ts +10 -2
  118. package/src/prompts/session-templates.ts +4 -2
  119. package/src/providers/acp-adapter.ts +42 -6
  120. package/src/providers/pi-mono-adapter.ts +23 -6
  121. package/src/scheduler/scheduler.test.ts +49 -2
  122. package/src/scheduler/scheduler.ts +4 -0
  123. package/src/scripts-runtime/sdk-allowlist.ts +1 -0
  124. package/src/scripts-runtime/types/stdlib.d.ts +8 -0
  125. package/src/scripts-runtime/types/swarm-sdk.d.ts +8 -0
  126. package/src/server.ts +2 -0
  127. package/src/slack/assistant.ts +87 -46
  128. package/src/slack/handlers.test.ts +1 -3
  129. package/src/slack/handlers.ts +102 -87
  130. package/src/slack/inbound-files.ts +466 -0
  131. package/src/slack/templates.ts +14 -0
  132. package/src/tasks/task-terminal-effects.ts +158 -0
  133. package/src/tests/acp-adapter.test.ts +327 -192
  134. package/src/tests/budget-claim-gate.test.ts +1 -0
  135. package/src/tests/build-pi-skills.test.ts +5 -7
  136. package/src/tests/claude-managed-setup.test.ts +52 -4
  137. package/src/tests/claude-md-session.test.ts +603 -0
  138. package/src/tests/codex-skill-resolver.test.ts +19 -0
  139. package/src/tests/context-versioning.test.ts +107 -0
  140. package/src/tests/credential-check.test.ts +157 -14
  141. package/src/tests/db-agents.test.ts +91 -0
  142. package/src/tests/db-context-versions.test.ts +37 -0
  143. package/src/tests/db-extraction-contract.test.ts +45 -0
  144. package/src/tests/db-runtime.test.ts +70 -0
  145. package/src/tests/db-task-read-contract.test.ts +624 -0
  146. package/src/tests/db-task-write-contract.test.ts +653 -0
  147. package/src/tests/db-tasks-read.test.ts +183 -0
  148. package/src/tests/db-tasks-write.test.ts +230 -0
  149. package/src/tests/defer-task.test.ts +389 -0
  150. package/src/tests/docs-index-footprint.test.js +2 -2
  151. package/src/tests/e2e-visuals-stage.test.ts +151 -0
  152. package/src/tests/file-lock.test.ts +144 -0
  153. package/src/tests/fixtures/file-lock-holder.ts +13 -0
  154. package/src/tests/fixtures/hold-file-lock.ts +25 -0
  155. package/src/tests/heartbeat-expiry.test.ts +188 -0
  156. package/src/tests/http-api-integration.test.ts +78 -1
  157. package/src/tests/pages-public-html.test.ts +43 -0
  158. package/src/tests/pages-svg-migration.test.ts +42 -0
  159. package/src/tests/preload.ts +4 -1
  160. package/src/tests/profile-sync-warning.test.ts +16 -0
  161. package/src/tests/profile-sync.test.ts +126 -0
  162. package/src/tests/prompt-template-session.test.ts +20 -4
  163. package/src/tests/provider-registration.test.ts +93 -0
  164. package/src/tests/rbac-e2e-helpers.test.ts +53 -0
  165. package/src/tests/rbac-e2e-helpers.ts +19 -2
  166. package/src/tests/routing-affinity-inventory.test.ts +1 -1
  167. package/src/tests/runner-attachments-section.test.ts +22 -2
  168. package/src/tests/runner-context-preamble.test.ts +30 -0
  169. package/src/tests/runner-deployment-resume.test.ts +107 -0
  170. package/src/tests/runner-repo-autostash.test.ts +12 -0
  171. package/src/tests/script-connections.test.ts +4 -0
  172. package/src/tests/seed-scripts.test.ts +2 -2
  173. package/src/tests/session-tokens.test.ts +279 -0
  174. package/src/tests/slack-file-tools-attachments.test.ts +408 -0
  175. package/src/tests/slack-inbound-files.test.ts +847 -0
  176. package/src/tests/star-history-refresh.test.ts +102 -0
  177. package/src/tests/swarm-repos.test.ts +20 -0
  178. package/src/tests/tool-annotations.test.ts +4 -3
  179. package/src/tests/ui-logs-parser.test.ts +176 -0
  180. package/src/tools/create-page.ts +4 -2
  181. package/src/tools/defer-task.ts +239 -0
  182. package/src/tools/repos/update-repo.ts +2 -2
  183. package/src/tools/schedules/create-schedule.ts +1 -0
  184. package/src/tools/schedules/list-schedules.ts +1 -0
  185. package/src/tools/schedules/patch-schedule.ts +1 -0
  186. package/src/tools/schedules/update-schedule.ts +1 -0
  187. package/src/tools/slack-download-file.ts +60 -29
  188. package/src/tools/slack-read.ts +73 -32
  189. package/src/tools/store-progress.ts +16 -146
  190. package/src/tools/tool-config.ts +1 -0
  191. package/src/tools/utils.ts +21 -0
  192. package/src/types.ts +37 -4
  193. package/src/utils/acp-session-token.ts +56 -0
  194. package/src/utils/file-lock.ts +111 -0
  195. package/src/utils/heartbeat-expiry.ts +78 -0
  196. package/src/utils/request-auth-context.ts +2 -0
  197. package/src/utils/task-attachment-links.ts +22 -0
  198. package/templates/skills/code-quality/content.md +8 -5
  199. package/templates/skills/download-task-attachment/content.md +2 -1
  200. package/{plugin/pi-skills → templates/skills}/review-offered-task/SKILL.md +5 -5
  201. package/templates/skills/review-offered-task/config.json +14 -0
  202. package/{plugin/commands/review-offered-task.md → templates/skills/review-offered-task/content.md} +3 -8
  203. package/templates/skills/scheduling/content.md +4 -0
  204. package/templates/skills/slack-interaction/content.md +2 -2
  205. package/templates/skills/work-on-task/SKILL.md +16 -0
  206. package/templates/skills/work-on-task/config.json +14 -0
  207. package/templates/skills/work-on-task/content.md +11 -0
  208. package/dist/assistant-dx3ew4d8.js +0 -212
  209. package/dist/cli-00kyrp1a.js +0 -317
  210. package/dist/cli-n1q8q14d.js +0 -177
  211. package/dist/cli-ss6vybmt.js +0 -269
  212. package/dist/handlers-e9vp2fr8.js +0 -592
  213. package/plugin/commands/work-on-task.md +0 -39
  214. package/plugin/pi-skills/work-on-task/SKILL.md +0 -39
@@ -11,14 +11,14 @@ import {
11
11
  getResumeGeneration,
12
12
  repointTrackerSyncBySwarmId,
13
13
  resolveLeadOnlyRecoveryAssignment
14
- } from "./cli-qar1f940.js";
14
+ } from "./cli-f7dsy61y.js";
15
15
  import {
16
16
  isMultiRuntimeEnabled
17
17
  } from "./cli-07jd68a1.js";
18
18
  import {
19
19
  getExecutorRegistry,
20
20
  recoverIncompleteRuns
21
- } from "./cli-3k2g3kg2.js";
21
+ } from "./cli-yz3djrm0.js";
22
22
  import {
23
23
  MAX_EMPTY_POLLS,
24
24
  assignUnassignedTaskPending,
@@ -61,13 +61,13 @@ import {
61
61
  releaseStaleReviewingTasks,
62
62
  supersedeTask,
63
63
  updateAgentStatus
64
- } from "./cli-d4xqde2b.js";
64
+ } from "./cli-ftht3zzj.js";
65
65
  import {
66
66
  init_registry,
67
67
  init_resolver,
68
68
  registerTemplate,
69
69
  resolveTemplate
70
- } from "./cli-2zvtzevh.js";
70
+ } from "./cli-kpv03zhj.js";
71
71
  import {
72
72
  init_secret_scrubber,
73
73
  scrubSecrets
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  contentSha256,
3
3
  init_profile_sync
4
- } from "./cli-00kyrp1a.js";
4
+ } from "./cli-m9sxbkhm.js";
5
5
  import {
6
6
  OpenAI,
7
7
  init_openai
@@ -11,7 +11,7 @@ import {
11
11
  getDbClient,
12
12
  init_db,
13
13
  isSqliteVecAvailable
14
- } from "./cli-d4xqde2b.js";
14
+ } from "./cli-ftht3zzj.js";
15
15
  import {
16
16
  __esm,
17
17
  __export,
@@ -3,7 +3,7 @@ import {
3
3
  } from "./cli-epan13p1.js";
4
4
  import {
5
5
  embedScript
6
- } from "./cli-pmwbdw36.js";
6
+ } from "./cli-hbv0kq6w.js";
7
7
  import {
8
8
  detachedProcessGroup,
9
9
  registerProcessGroup,
@@ -23,7 +23,7 @@ import {
23
23
  oauthAppRowToProviderConfig,
24
24
  updateAuthorizationTokens,
25
25
  upsertAuthorization
26
- } from "./cli-4secrq32.js";
26
+ } from "./cli-zhjmqxzh.js";
27
27
  import {
28
28
  CredentialBroker,
29
29
  DEFAULT_CREDENTIAL_BINDINGS,
@@ -44,7 +44,7 @@ import {
44
44
  normalizeDateRequired,
45
45
  placeholderForConfigKey,
46
46
  upsertSwarmConfig
47
- } from "./cli-d4xqde2b.js";
47
+ } from "./cli-ftht3zzj.js";
48
48
  import {
49
49
  init_env_flag,
50
50
  isEnvFlagEnabled
@@ -49,7 +49,7 @@ import {
49
49
  import {
50
50
  init_package,
51
51
  package_default
52
- } from "./cli-yxwe913z.js";
52
+ } from "./cli-w9kb3bk1.js";
53
53
  import {
54
54
  init_secret_scrubber,
55
55
  scrubSecrets
@@ -3,7 +3,7 @@ import {
3
3
  getAgentById,
4
4
  getInProgressTasksByContextKey,
5
5
  init_db
6
- } from "./cli-d4xqde2b.js";
6
+ } from "./cli-ftht3zzj.js";
7
7
 
8
8
  // src/tasks/sibling-awareness.ts
9
9
  init_db();
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  SYSTEM_COLUMN_KINDS,
3
3
  listAppRecords
4
- } from "./cli-a960nkfb.js";
4
+ } from "./cli-de14znh8.js";
5
5
  import {
6
6
  getScriptApiTypes,
7
7
  getScriptMcpTypes,
8
8
  require_typescript
9
- } from "./cli-68h2mfrn.js";
9
+ } from "./cli-3tgwnf43.js";
10
10
  import {
11
11
  deleteSwarmConfigByKey,
12
12
  getAgentById,
@@ -15,7 +15,7 @@ import {
15
15
  getSwarmConfigs,
16
16
  init_db,
17
17
  upsertSwarmConfig
18
- } from "./cli-d4xqde2b.js";
18
+ } from "./cli-ftht3zzj.js";
19
19
  import {
20
20
  init_secret_scrubber,
21
21
  scrubSecrets
@@ -135,7 +135,7 @@ async function ensureAgentFsSharedProvisioning(options) {
135
135
  await upsertSwarmConfig({ scope: "global", key, value, isSecret: false, description });
136
136
  }
137
137
  process.env.AGENT_FS_API_URL = apiUrl;
138
- const { resetFileStorageProvider } = await import("./registry-9kdck5ye.js");
138
+ const { resetFileStorageProvider } = await import("./registry-v5wytg0s.js");
139
139
  resetFileStorageProvider();
140
140
  return { apiUrl, apiKey, orgId, driveId, authHeaders };
141
141
  }
@@ -732,6 +732,7 @@ export interface SwarmSdk {
732
732
  task_list(args?: Record<string, unknown>): Promise<unknown>;
733
733
  task_get(args: { taskId: string }): Promise<unknown>;
734
734
  task_storeProgress(args: Record<string, unknown>): Promise<unknown>;
735
+ task_defer(args: { taskId: string; delayMs?: number; runAt?: string; summary: string; note: string; checks?: string[] }): Promise<unknown>;
735
736
  task_poll(args?: Record<string, unknown>): Promise<unknown>;
736
737
  // --- kv ---
737
738
  kv_get<T = unknown>(args: { key: string; namespace?: string }): Promise<KvSdkResponse<KvEntry<T>>>;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runStopHookSessionSummarySubprocess
3
- } from "./cli-zn65x0w8.js";
3
+ } from "./cli-89xfd7f9.js";
4
4
  import {
5
5
  SessionErrorTracker,
6
6
  buildOtelTraceparentEnv,
@@ -817,7 +817,7 @@ class ClaudeAdapter {
817
817
  if (transport === "sdk" && isClaudeBridgeEffective(sourceEnv)) {
818
818
  throw new Error("CLAUDE_TRANSPORT=sdk cannot run with an effective Claude Bridge configuration. Select CLI transport or disable the bridge.");
819
819
  }
820
- const claudeSdk = transport === "sdk" ? await import("./claude-sdk-session-0wp3qrcy.js") : undefined;
820
+ const claudeSdk = transport === "sdk" ? await import("./claude-sdk-session-f0cc1kec.js") : undefined;
821
821
  claudeSdk?.validateClaudeSdkAdditionalArgs([
822
822
  ...claudeBinaryArgv.slice(1),
823
823
  ...config.additionalArgs ?? []
@@ -1,3 +1,7 @@
1
+ import {
2
+ materializeClaudeMd,
3
+ stopClaudeMd
4
+ } from "./cli-d8brzxjb.js";
1
5
  import {
2
6
  summarizeSession
3
7
  } from "./cli-rvqz34y5.js";
@@ -18,10 +22,11 @@ import {
18
22
  import {
19
23
  buildIndependentIdentityPayloads,
20
24
  contentSha256,
25
+ fetchWithSyncTimeout,
21
26
  init_profile_sync,
22
27
  readIdentityBaselines,
23
28
  warnProfileFileTooLarge
24
- } from "./cli-00kyrp1a.js";
29
+ } from "./cli-m9sxbkhm.js";
25
30
  import {
26
31
  MAX_PROFILE_FILE_LENGTH,
27
32
  getMcpBaseUrl,
@@ -30,7 +35,7 @@ import {
30
35
  import {
31
36
  init_package,
32
37
  package_default
33
- } from "./cli-yxwe913z.js";
38
+ } from "./cli-w9kb3bk1.js";
34
39
  import {
35
40
  init_secret_scrubber,
36
41
  scrubSecrets
@@ -42,8 +47,6 @@ init_profile_sync();
42
47
  init_constants();
43
48
  init_secret_scrubber();
44
49
  var SERVER_NAME = package_default.config?.name ?? "agent-swarm";
45
- var CLAUDE_MD_PATH = `${process.env.HOME}/.claude/CLAUDE.md`;
46
- var CLAUDE_MD_BACKUP_PATH = `${process.env.HOME}/.claude/CLAUDE.md.bak`;
47
50
  var SOUL_MD_PATH = "/workspace/SOUL.md";
48
51
  var IDENTITY_MD_PATH = "/workspace/IDENTITY.md";
49
52
  var TOOLS_MD_PATH = "/workspace/TOOLS.md";
@@ -113,30 +116,6 @@ async function fetchTaskDetails(taskId) {
113
116
  return null;
114
117
  }
115
118
  }
116
- async function backupExistingClaudeMd() {
117
- const file = Bun.file(CLAUDE_MD_PATH);
118
- if (await file.exists()) {
119
- const content = await file.text();
120
- await Bun.write(CLAUDE_MD_BACKUP_PATH, content);
121
- }
122
- }
123
- async function writeAgentClaudeMd(content) {
124
- const dir = `${process.env.HOME}/.claude`;
125
- try {
126
- await Bun.$`mkdir -p ${dir}`.quiet();
127
- } catch {}
128
- await Bun.write(CLAUDE_MD_PATH, content);
129
- }
130
- async function restoreClaudeMdBackup() {
131
- const backupFile = Bun.file(CLAUDE_MD_BACKUP_PATH);
132
- if (await backupFile.exists()) {
133
- const content = await backupFile.text();
134
- await Bun.write(CLAUDE_MD_PATH, content);
135
- await Bun.$`rm -f ${CLAUDE_MD_BACKUP_PATH}`.quiet();
136
- } else {
137
- await Bun.$`rm -f ${CLAUDE_MD_PATH}`.quiet();
138
- }
139
- }
140
119
  async function resolveStopHookTaskContext(env = process.env) {
141
120
  let taskContext = "";
142
121
  let taskId = env.AGENT_SWARM_TASK_ID || undefined;
@@ -379,20 +358,17 @@ async function handleHook() {
379
358
  return;
380
359
  }
381
360
  };
382
- const syncClaudeMdToServer = async (agentId) => {
383
- if (!mcpConfig)
384
- return;
385
- const file = Bun.file(CLAUDE_MD_PATH);
386
- if (!await file.exists())
387
- return;
388
- const content = await file.text();
389
- if (!content.trim())
390
- return;
391
- await postHookProfileUpdate({
392
- url: `${getBaseUrl()}/api/agents/${agentId}/profile`,
393
- headers: mcpConfig.headers,
394
- body: { claudeMd: content, changeSource: "session_sync" },
395
- label: "claudeMd"
361
+ const syncAndRestoreClaudeMd = async (agentId) => {
362
+ await stopClaudeMd(async (body) => {
363
+ if (!mcpConfig)
364
+ return;
365
+ await postHookProfileUpdate({
366
+ url: `${getBaseUrl()}/api/agents/${agentId}/profile`,
367
+ headers: mcpConfig.headers,
368
+ body,
369
+ label: "claudeMd",
370
+ fetchImpl: fetchWithSyncTimeout()
371
+ });
396
372
  });
397
373
  };
398
374
  const IDENTITY_FILE_MIN_LENGTH = 500;
@@ -636,9 +612,8 @@ You do not have a pre-defined agent ID, you will receive one when you join the s
636
612
  break;
637
613
  if (agentInfo.claudeMd) {
638
614
  try {
639
- await backupExistingClaudeMd();
640
- await writeAgentClaudeMd(agentInfo.claudeMd);
641
- console.log("Loaded your personal CLAUDE.md configuration.");
615
+ const outcome = await materializeClaudeMd(agentInfo.claudeMd);
616
+ console.log(outcome === "busy" || outcome === "error" ? "CLAUDE.md is being updated by another session; keeping the current copy." : "Loaded your personal CLAUDE.md configuration.");
642
617
  } catch (error) {
643
618
  console.log(`Warning: Could not load CLAUDE.md: ${error.message}`);
644
619
  }
@@ -833,10 +808,9 @@ You do not have a pre-defined agent ID, you will receive one when you join the s
833
808
  } catch {}
834
809
  if (agentInfo?.id) {
835
810
  try {
836
- await syncClaudeMdToServer(agentInfo.id);
811
+ await syncAndRestoreClaudeMd(agentInfo.id);
837
812
  await syncIdentityFilesToServer(agentInfo.id);
838
813
  await syncSetupScriptToServer(agentInfo.id);
839
- await restoreClaudeMdBackup();
840
814
  } catch {}
841
815
  }
842
816
  if (process.env.AGENT_SWARM_ADAPTER_SESSION_SUMMARY === "1") {
@@ -5,7 +5,7 @@ import {
5
5
  getDb,
6
6
  getDbClient,
7
7
  init_db
8
- } from "./cli-d4xqde2b.js";
8
+ } from "./cli-ftht3zzj.js";
9
9
 
10
10
  // src/be/rbac-roles.ts
11
11
  init_db();
@@ -0,0 +1,42 @@
1
+ import {
2
+ buildAgentFsLiveUrl,
3
+ getAppUrl,
4
+ init_constants
5
+ } from "./cli-e29gmdmw.js";
6
+ import {
7
+ __esm
8
+ } from "./cli-bc05qbss.js";
9
+
10
+ // src/utils/task-attachment-links.ts
11
+ function shellQuote(value) {
12
+ return `'${value.replace(/'/g, `'\\''`)}'`;
13
+ }
14
+ function taskAttachmentFetchCommand(taskId, attachmentId, name) {
15
+ const url = `$MCP_BASE_URL/api/fs/tasks/${taskId}/files/${attachmentId}/raw`;
16
+ const outPath = shellQuote(`/tmp/attachments/${attachmentId}/${name.replace(/\//g, "_")}`);
17
+ return `curl -s -H "Authorization: Bearer \${AGENT_SWARM_API_KEY:-$API_KEY}" -H "X-Agent-ID: $AGENT_ID" "${url}" --create-dirs -o ${outPath}`;
18
+ }
19
+ function taskAttachmentDisplayUrl(attachment) {
20
+ if (attachment.kind === "url")
21
+ return attachment.url ?? "";
22
+ if (attachment.kind === "page") {
23
+ return attachment.pageId ? `${getAppUrl()}/pages/${attachment.pageId}` : "page:";
24
+ }
25
+ if (attachment.providerId === "agent-fs" || attachment.kind === "agent-fs") {
26
+ const liveUrl = buildAgentFsLiveUrl({
27
+ path: attachment.path,
28
+ orgId: attachment.orgId,
29
+ driveId: attachment.driveId
30
+ });
31
+ return liveUrl ?? `agent-fs:${attachment.path ?? ""}`;
32
+ }
33
+ if (attachment.providerId === "local-fs" || attachment.kind === "shared-fs") {
34
+ return `${getAppUrl()}/api/fs/tasks/${attachment.taskId}/files/${attachment.id}/raw`;
35
+ }
36
+ return attachment.path ?? attachment.providerKey ?? "";
37
+ }
38
+ var init_task_attachment_links = __esm(() => {
39
+ init_constants();
40
+ });
41
+
42
+ export { taskAttachmentFetchCommand, taskAttachmentDisplayUrl, init_task_attachment_links };