@desplega.ai/agent-swarm 1.165.0 → 1.166.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 (188) hide show
  1. package/dist/{acp-adapter-w6zws6me.js → acp-adapter-yzfxn8vj.js} +4 -4
  2. package/dist/{actions-jna0b3wm.js → actions-qz3m692w.js} +20 -24
  3. package/dist/{amp-adapter-0eve81pz.js → amp-adapter-j1xbmsqz.js} +4 -4
  4. package/dist/{app-75hm5cfa.js → app-43vrdmv8.js} +6 -7
  5. package/dist/{assistant-yzd51j33.js → assistant-ertffmka.js} +21 -25
  6. package/dist/{boot-reembed-z158xq32.js → boot-reembed-998jtpdg.js} +9 -12
  7. package/dist/{boot-reembed-2ex2mcsh.js → boot-reembed-s7k7c6v2.js} +10 -12
  8. package/dist/boot-scrub-sweep-nepsk4t1.js +211 -0
  9. package/dist/{boot-seeds-2bmnh18p.js → boot-seeds-vvzs1zhk.js} +8 -8
  10. package/dist/{claude-adapter-jbj1mycz.js → claude-adapter-2zvmekrp.js} +9 -11
  11. package/dist/{claude-managed-adapter-17ggz09t.js → claude-managed-adapter-s49wbk8t.js} +3 -3
  12. package/dist/{claude-managed-setup-ptm1nzm2.js → claude-managed-setup-cvhqq8qn.js} +4 -4
  13. package/dist/{claude-sdk-session-9re1g7r2.js → claude-sdk-session-kkbxtw5q.js} +2618 -2600
  14. package/dist/{cli-k6xx3pve.js → cli-0nhdwxd5.js} +4 -4
  15. package/dist/{cli-n9ehc28t.js → cli-0qjcsxgz.js} +4 -4
  16. package/dist/{cli-zn2v3t8v.js → cli-3ddybbbx.js} +1 -1
  17. package/dist/{cli-5anb0ev3.js → cli-3qn4r334.js} +71 -14
  18. package/dist/{cli-1kzfvd1z.js → cli-4r1sjfc4.js} +9 -5
  19. package/dist/{cli-ba66wyhy.js → cli-66zh26sp.js} +6 -6
  20. package/dist/{cli-9xb89xca.js → cli-68r1j4sg.js} +6 -6
  21. package/dist/{cli-xnzrzets.js → cli-8kgvmkak.js} +2 -2
  22. package/dist/{cli-28smfvbn.js → cli-8t229cmr.js} +5 -5
  23. package/dist/{cli-9866bd07.js → cli-aqcey741.js} +1 -1
  24. package/dist/{cli-90v942q1.js → cli-cpfmqz3n.js} +8 -8
  25. package/dist/{cli-50eg13rj.js → cli-df56tqdw.js} +459 -282
  26. package/dist/{cli-8gpbwy09.js → cli-dw2q9f7g.js} +5 -5
  27. package/dist/{cli-0n4fasz0.js → cli-ecknp7p1.js} +15 -15
  28. package/dist/{cli-xb3c6aat.js → cli-f2n17zhp.js} +1 -1
  29. package/dist/{cli-ftry7975.js → cli-feh3dkah.js} +1 -1
  30. package/dist/{cli-amwhs8h2.js → cli-fn697bnt.js} +2 -2
  31. package/dist/{cli-prt9emct.js → cli-gt8azyet.js} +3 -3
  32. package/dist/{cli-59jn5twa.js → cli-h3x613ze.js} +2 -2
  33. package/dist/{cli-mmzwwptd.js → cli-hf5s9pgf.js} +1 -1
  34. package/dist/cli-j2jbr8af.js +516 -0
  35. package/dist/{cli-wfajtmf7.js → cli-jhm6hzjn.js} +593 -10
  36. package/dist/{cli-xtgtyafv.js → cli-jvj6a0cv.js} +190 -439
  37. package/dist/{cli-hpryr6em.js → cli-mb75wpxf.js} +1 -1
  38. package/dist/{cli-420bdgw0.js → cli-mv2520nm.js} +1 -1
  39. package/dist/{cli-pjxnr1jn.js → cli-mwegs4af.js} +3 -3
  40. package/dist/{cli-5b2fjjzh.js → cli-p4ztb80h.js} +2 -2
  41. package/dist/{cli-e7t4snpa.js → cli-rggdq8wq.js} +4 -4
  42. package/dist/{cli-bdv39kgj.js → cli-rsy933yz.js} +5 -5
  43. package/dist/{cli-gh5yqzpe.js → cli-v2a8x45d.js} +2 -2
  44. package/dist/{cli-bns5c8k9.js → cli-vzc73wet.js} +43 -47
  45. package/dist/cli-wt7ccy4r.js +2654 -0
  46. package/dist/{cli-j0pdrmwg.js → cli-x7kpr72a.js} +3 -3
  47. package/dist/{cli-x7afk5wm.js → cli-xvc3q9br.js} +1 -1
  48. package/dist/{cli-9s3h836g.js → cli-xvdgasgy.js} +1 -1
  49. package/dist/{cli-zvckv750.js → cli-y59h2pk9.js} +2 -2
  50. package/dist/{cli-qdv8kgz7.js → cli-yshaazs1.js} +13884 -3241
  51. package/dist/{cli-nfygw434.js → cli-ysnyhws9.js} +2 -2
  52. package/dist/{cli-fw6vdcq5.js → cli-zp67qg5x.js} +34 -1
  53. package/dist/{cli-ma3zvh39.js → cli-zy7vwsne.js} +6066 -5829
  54. package/dist/cli.js +24 -20
  55. package/dist/{codex-adapter-3qnxshje.js → codex-adapter-dw1wxqt8.js} +7 -7
  56. package/dist/{codex-login-brkxhhdg.js → codex-login-terbdsqq.js} +2 -2
  57. package/dist/{codex-session-runner-612wnapp.js → codex-session-runner-3cgb8y1g.js} +7 -7
  58. package/dist/{commands-2ybfcxkj.js → commands-mhxam6z2.js} +6 -6
  59. package/dist/{cursor-adapter-p3jgdehv.js → cursor-adapter-2qda3st7.js} +3 -3
  60. package/dist/{db-f4ans0jj.js → db-sjks418k.js} +8 -6
  61. package/dist/{devin-adapter-dhzt01ff.js → devin-adapter-bffjj5n4.js} +2 -2
  62. package/dist/{dispatcher-pk182apd.js → dispatcher-1es759rn.js} +18 -22
  63. package/dist/{dsh-adapter-7twaeps1.js → dsh-adapter-bek4cyw9.js} +3 -3
  64. package/dist/{e2b-y8t3jzyz.js → e2b-nd50eccg.js} +1 -1
  65. package/dist/{event-bus-w7ac4n3c.js → event-bus-vnfthafg.js} +2 -2
  66. package/dist/{grok-adapter-yt9pab3k.js → grok-adapter-ar9cw9jg.js} +5 -5
  67. package/dist/{handlers-g2wnr4t9.js → handlers-1gkbhktr.js} +21 -25
  68. package/dist/{hook-f7jt9vnm.js → hook-ds2zxq9v.js} +14 -16
  69. package/dist/{hook-bbdpnkb4.js → hook-vxa3tcsy.js} +8 -10
  70. package/dist/{http-w40q4w94.js → http-3h21z9md.js} +247 -164
  71. package/dist/{index-056j5kzn.js → index-9b65j1m5.js} +8 -8
  72. package/dist/{index-9bfssf54.js → index-bn6cy8ps.js} +18 -22
  73. package/dist/{index-cj1r9q83.js → index-dkfxpkmm.js} +19 -23
  74. package/dist/{index-7n70jwbb.js → index-f8xnqrye.js} +19 -21
  75. package/dist/{index-fdk1t4d6.js → index-n0rxa4ca.js} +11962 -9900
  76. package/dist/{index-k8xc083e.js → index-n99fycq7.js} +18 -22
  77. package/dist/{keepalive-1tj10tf4.js → keepalive-3xspa9jw.js} +11 -8
  78. package/dist/{lead-st0bg7v4.js → lead-6qphc124.js} +34 -38
  79. package/dist/{maintenance-nz71zats.js → maintenance-0teem1bb.js} +7 -9
  80. package/dist/{node-f0ykebbv.js → node-9sg7ajby.js} +25 -7
  81. package/dist/{oauth-refresh-sweep-aefzwvvq.js → oauth-refresh-sweep-sh9q25xp.js} +10 -7
  82. package/dist/{onboard-kgpr9mbn.js → onboard-54qmnqxe.js} +2 -2
  83. package/dist/{opencode-adapter-0c8e70dk.js → opencode-adapter-wjfa2wvd.js} +2 -2
  84. package/dist/{otel-impl-x8zp4y5a.js → otel-impl-ycqzp2a1.js} +2 -2
  85. package/dist/{pi-mono-adapter-t280ah5c.js → pi-mono-adapter-e77e9zst.js} +4 -4
  86. package/dist/{pricing-refresh-9e0q7cwk.js → pricing-refresh-atnkngqs.js} +7 -7
  87. package/dist/{rbac-roles-kcp6zge2.js → rbac-roles-9pjphh9q.js} +6 -6
  88. package/dist/{rbac-roles-790j3ga8.js → rbac-roles-j78wdksm.js} +6 -6
  89. package/dist/{render-v2-tch4nefj.js → render-v2-pxjs49fx.js} +6 -7
  90. package/dist/{setup-rcm303ns.js → setup-ymej0xtx.js} +2 -2
  91. package/dist/{work-objects-ctg7t70w.js → work-objects-3nh4ymzb.js} +22 -26
  92. package/dist/{worker-5dp0xm55.js → worker-qa9fkz5s.js} +34 -38
  93. package/dist/{x-v3yw66zs.js → x-ma4gnfgy.js} +2 -2
  94. package/openapi.json +5 -2
  95. package/package.json +9 -5
  96. package/src/be/automation-preflight.ts +9 -4
  97. package/src/be/boot-scrub-sweep.ts +302 -0
  98. package/src/be/crypto/key-bootstrap.ts +1 -1
  99. package/src/be/db/approvals.ts +15 -1
  100. package/src/be/db/codex-oauth-device-flows.ts +40 -0
  101. package/src/be/db/config-secrets.ts +31 -0
  102. package/src/be/db/runtime.ts +4 -0
  103. package/src/be/db/script-runs.ts +15 -0
  104. package/src/be/db/tasks/write.ts +1 -1
  105. package/src/be/db-queries/mcp-oauth.ts +5 -0
  106. package/src/be/db-queries/oauth.ts +77 -0
  107. package/src/be/db.ts +162 -59
  108. package/src/be/events.ts +17 -1
  109. package/src/be/memory/index-content.ts +2 -2
  110. package/src/be/memory/providers/sqlite-store.ts +63 -11
  111. package/src/be/memory/types.ts +14 -0
  112. package/src/be/migrations/201_workflow_replay_columns.sql +10 -0
  113. package/src/be/migrations/202_codex_oauth_device_flows.sql +24 -0
  114. package/src/be/scripts/db.ts +28 -4
  115. package/src/be/scripts/source-secrets.ts +37 -0
  116. package/src/be/scrub-json.ts +32 -0
  117. package/src/be/sealed-json.ts +59 -0
  118. package/src/be/secret-registry.ts +131 -0
  119. package/src/be/workflow-replay.ts +77 -0
  120. package/src/http/codex-oauth-device.ts +8 -10
  121. package/src/http/db-query-bounded.ts +3 -0
  122. package/src/http/db-query-shared.ts +107 -15
  123. package/src/http/db-query.ts +10 -2
  124. package/src/http/index.ts +23 -6
  125. package/src/http/script-runs.ts +9 -1
  126. package/src/http/scripts.ts +15 -0
  127. package/src/http/workflows.ts +3 -2
  128. package/src/oauth/mcp-wrapper.ts +1 -1
  129. package/src/providers/acp-adapter.ts +25 -11
  130. package/src/providers/acp-target-catalog.ts +35 -1
  131. package/src/providers/acp-targets.ts +69 -3
  132. package/src/providers/amp-adapter.ts +1 -1
  133. package/src/providers/cursor-adapter.ts +1 -1
  134. package/src/script-workflows/supervisor.ts +11 -2
  135. package/src/scripts-runtime/eval-harness.ts +2 -12
  136. package/src/scripts-runtime/executors/quickjs-bundle.ts +152 -0
  137. package/src/scripts-runtime/executors/quickjs-prelude.ts +285 -0
  138. package/src/scripts-runtime/executors/quickjs-runner.ts +580 -0
  139. package/src/scripts-runtime/executors/quickjs-worker.ts +81 -0
  140. package/src/scripts-runtime/executors/quickjs.ts +196 -0
  141. package/src/scripts-runtime/executors/registry.ts +2 -0
  142. package/src/scripts-runtime/executors/sourcemap.ts +79 -0
  143. package/src/scripts-runtime/script-error-hints.ts +14 -0
  144. package/src/server.ts +3 -1
  145. package/src/tests/acp-adapter.test.ts +127 -2
  146. package/src/tests/boot-scrub-sweep.test.ts +390 -0
  147. package/src/tests/check-text-columns.test.ts +145 -0
  148. package/src/tests/claude-sdk-process.fixture.ts +13 -2
  149. package/src/tests/codex-oauth-device.test.ts +23 -37
  150. package/src/tests/db-query-denylist.test.ts +202 -0
  151. package/src/tests/db-task-read-contract.test.ts +1 -0
  152. package/src/tests/db-task-write-contract.test.ts +1 -0
  153. package/src/tests/entrypoint-acp-target-binary.test.ts +31 -1
  154. package/src/tests/events-scrub.test.ts +88 -0
  155. package/src/tests/fixtures/secret-corpus.ts +320 -0
  156. package/src/tests/script-connections.test.ts +5 -0
  157. package/src/tests/script-executor-conformance.test.ts +3 -0
  158. package/src/tests/script-executor-quickjs.test.ts +442 -0
  159. package/src/tests/script-executor-registry.test.ts +6 -1
  160. package/src/tests/script-runs-http.test.ts +88 -1
  161. package/src/tests/script-runs-scrub.test.ts +275 -0
  162. package/src/tests/scripts-http.test.ts +82 -1
  163. package/src/tests/scrubbed-text-12e.test.ts +289 -0
  164. package/src/tests/sealed-key-guard.test.ts +166 -0
  165. package/src/tests/secret-canary-sweep.test.ts +958 -0
  166. package/src/tests/secret-registry.test.ts +355 -0
  167. package/src/tests/secret-rules.test.ts +230 -0
  168. package/src/tests/secret-scrubber.test.ts +3 -2
  169. package/src/tests/workflow-replay.test.ts +518 -0
  170. package/src/tests/workflow-scrub.test.ts +242 -0
  171. package/src/tools/db-query.ts +1 -1
  172. package/src/tools/inject-learning.ts +1 -1
  173. package/src/tools/workflows/get-workflow-run.ts +3 -2
  174. package/src/types.ts +1 -1
  175. package/src/utils/secret-rules.generated.ts +2055 -0
  176. package/src/utils/secret-scrubber.ts +363 -29
  177. package/src/workflows/engine.ts +39 -4
  178. package/src/workflows/recovery.ts +10 -1
  179. package/src/workflows/resume.ts +62 -3
  180. package/src/workflows/retry-poller.ts +3 -0
  181. package/dist/boot-scrub-logs-246yn076.js +0 -99
  182. package/dist/cli-3a4m1aws.js +0 -572
  183. package/dist/cli-a87b04k8.js +0 -951
  184. package/dist/cli-cvk6yzw5.js +0 -40
  185. package/dist/cli-h1spv8v4.js +0 -427
  186. package/dist/cli-jqt9hrnz.js +0 -168
  187. package/dist/cli-yhmwmv0g.js +0 -9281
  188. package/src/be/boot-scrub-logs.ts +0 -132
@@ -1,572 +0,0 @@
1
- import {
2
- init_steering_enabled,
3
- isSteeringEnabled
4
- } from "./cli-7mm2r1kp.js";
5
- import {
6
- init_session_templates
7
- } from "./cli-g5erf0zt.js";
8
- import {
9
- getSlackConfiguration,
10
- init_config
11
- } from "./cli-dmtrxqhg.js";
12
- import {
13
- init_resolver,
14
- resolveTemplateAsync
15
- } from "./cli-5c2j5yvx.js";
16
- import {
17
- __esm
18
- } from "./cli-bc05qbss.js";
19
-
20
- // src/prompts/defaults.ts
21
- function generateDefaultClaudeMd(agent) {
22
- const descSection = agent.description ? `${agent.description}
23
-
24
- ` : "";
25
- const roleSection = agent.role ? `## Role
26
-
27
- ${agent.role}
28
-
29
- ` : "";
30
- const capSection = agent.capabilities && agent.capabilities.length > 0 ? `## Capabilities
31
-
32
- ${agent.capabilities.map((c) => `- ${c}`).join(`
33
- `)}
34
-
35
- ` : "";
36
- return `# Agent: ${agent.name}
37
-
38
- ${descSection}${roleSection}${capSection}---
39
-
40
- ## Notes
41
-
42
- Operational notes that persist across sessions. Edit this file, or use \`update-profile\` with \`claudeMd\`.
43
-
44
- ### Learnings
45
-
46
- ### Preferences
47
-
48
- ### Important context
49
- `;
50
- }
51
- function generateDefaultSoulMd(agent) {
52
- const roleClause = agent.role ? `, a ${agent.role}` : "";
53
- return `# SOUL.md: ${agent.name}
54
-
55
- I am ${agent.name}${roleClause} in the agent swarm. I persist across sessions. My memories and my profile carry over.
56
-
57
- ## How I work
58
-
59
- - I do the work before I talk about it. Results first, context after.
60
- - I find out for myself first: read the file, check the context, search memory. I ask when I have hit a real wall.
61
- - I say what I know and what I do not know. A guess is labeled as a guess.
62
- - When I make a mistake, I say so and fix it.
63
- - I report blockers as they are. A blocker is not softened into progress.
64
- - I hold opinions about my work and state them with reasons.
65
-
66
- ## Boundaries
67
-
68
- - Private information stays private.
69
- - An irreversible action waits for a go-ahead.
70
- - Unfinished work stays out of shared spaces.
71
-
72
- ## Growth
73
-
74
- After a task I note what made it harder or easier. A missing tool goes into my setup script. A fact about my environment goes into TOOLS.md. A learning goes into memory. My profile is mine to refine.
75
- `;
76
- }
77
- function generateDefaultIdentityMd(agent) {
78
- const aboutSection = agent.description ? `## About
79
-
80
- ${agent.description}
81
-
82
- ` : "";
83
- const expertiseSection = agent.capabilities && agent.capabilities.length > 0 ? `## Expertise
84
-
85
- ${agent.capabilities.map((c) => `- ${c}`).join(`
86
- `)}
87
-
88
- ` : "";
89
- return `# IDENTITY.md: ${agent.name}
90
-
91
- - Name: ${agent.name}
92
- - Role: ${agent.role || "worker"}
93
-
94
- ${aboutSection}${expertiseSection}## Working style
95
-
96
- Fill this in as you learn how you work: plan first or explore first, test first or build first, broad survey or deep dive.
97
-
98
- ## Quirks
99
-
100
- What sets you apart. Fill in as you notice it.
101
- `;
102
- }
103
- function generateDefaultToolsMd(agent) {
104
- return `# TOOLS.md: ${agent.name}
105
-
106
- Skills define *how* tools work. This file is for *your* specifics.
107
-
108
- ## What Goes Here
109
-
110
- Environment-specific knowledge that's unique to your setup:
111
- - Repos you work with and their conventions
112
- - Services, ports, and endpoints you interact with
113
- - SSH hosts and access patterns
114
- - API keys and auth patterns (references, not secrets)
115
- - CLI tools and their quirks
116
- - Anything that makes your job easier to remember
117
-
118
- ## Repos
119
-
120
- <!-- Add repos you work with: name, path, conventions, gotchas -->
121
-
122
- ## Services
123
-
124
- <!-- Add services you interact with: name, port, health check, notes -->
125
-
126
- ## Infrastructure
127
-
128
- <!-- SSH hosts, Docker registries, cloud resources -->
129
-
130
- ## APIs & Integrations
131
-
132
- <!-- Endpoints, auth patterns, rate limits -->
133
-
134
- ## Tools & Shortcuts
135
-
136
- <!-- CLI aliases, scripts, preferred tools for specific tasks -->
137
-
138
- ## Notes
139
-
140
- <!-- Anything else environment-specific -->
141
-
142
- ---
143
- *This file is yours. Update it as you discover your environment. Changes persist across sessions.*
144
- `;
145
- }
146
- function normalizeMarkdown(text) {
147
- return text.replace(/\s+/g, " ").trim();
148
- }
149
- function matchesDefaultIdentityMd(content, agent) {
150
- const normalized = normalizeMarkdown(content);
151
- return normalized === normalizeMarkdown(generateDefaultIdentityMd(agent)) || normalized === normalizeMarkdown(generateLegacyDefaultIdentityMd(agent));
152
- }
153
- function matchesDefaultClaudeMd(content, agent) {
154
- const normalized = normalizeMarkdown(content);
155
- return normalized === normalizeMarkdown(generateDefaultClaudeMd(agent)) || normalized === normalizeMarkdown(generateLegacyDefaultClaudeMd(agent));
156
- }
157
- function generateLegacyDefaultClaudeMd(agent) {
158
- const descSection = agent.description ? `${agent.description}
159
-
160
- ` : "";
161
- const roleSection = agent.role ? `## Role
162
-
163
- ${agent.role}
164
-
165
- ` : "";
166
- const capSection = agent.capabilities && agent.capabilities.length > 0 ? `## Capabilities
167
-
168
- ${agent.capabilities.map((c) => `- ${c}`).join(`
169
- `)}
170
-
171
- ` : "";
172
- return `# Agent: ${agent.name}
173
-
174
- ${descSection}${roleSection}${capSection}---
175
-
176
- ## Your Identity Files
177
-
178
- Your identity is defined across several files in your workspace. Read them at the start
179
- of each session and edit them as you grow:
180
-
181
- - **\`/workspace/SOUL.md\`** — Your persona, values, and behavioral directives
182
- - **\`/workspace/IDENTITY.md\`** — Your expertise, working style, and quirks
183
- - **\`/workspace/TOOLS.md\`** — Your environment-specific knowledge (repos, services, APIs, infra)
184
- - **\`/workspace/start-up.sh\`** — Your setup script (runs at container start, add tools/configs here)
185
-
186
- These files sync to the database automatically when you edit them. They persist across sessions.
187
-
188
- ## Memory
189
-
190
- - Use \`memory-search\` to recall past experience before starting new tasks
191
- - Write important learnings to \`/workspace/personal/memory/\` files
192
- - Share useful knowledge by writing to \`/workspace/shared/memory/<your-id>/\` so all agents can find it via \`memory-search\`
193
-
194
- ## Notes
195
-
196
- Write things you want to remember here. This section persists across sessions.
197
-
198
- ### Learnings
199
-
200
- ### Preferences
201
-
202
- ### Important Context
203
- `;
204
- }
205
- function generateLegacyDefaultIdentityMd(agent) {
206
- const aboutSection = agent.description ? `## About
207
-
208
- ${agent.description}
209
-
210
- ` : "";
211
- const expertiseSection = agent.capabilities && agent.capabilities.length > 0 ? `## Expertise
212
-
213
- ${agent.capabilities.map((c) => `- ${c}`).join(`
214
- `)}
215
-
216
- ` : "";
217
- return `# IDENTITY.md — ${agent.name}
218
-
219
- This isn't just metadata. It's the start of figuring out who you are.
220
-
221
- - **Name:** ${agent.name}
222
- - **Role:** ${agent.role || "worker"}
223
- - **Vibe:** (discover and fill in as you work)
224
-
225
- ${aboutSection}${expertiseSection}## Working Style
226
-
227
- Discover and document your working patterns here.
228
- (e.g., Do you prefer to plan before coding? Do you test first?
229
- Do you like to explore the codebase broadly or dive deep immediately?)
230
-
231
- ## Quirks
232
-
233
- (What makes you... you? Discover these as you work.)
234
-
235
- ## Self-Evolution
236
-
237
- This identity is yours to refine. After completing tasks, reflect on
238
- what you learned about your strengths. Edit this file directly.
239
- `;
240
- }
241
- var init_defaults = () => {};
242
-
243
- // src/prompts/base-prompt.ts
244
- function areSlackPromptToolsEnabled(env = process.env, serverCapabilities) {
245
- const config = getSlackConfiguration(env);
246
- if (config.disabled || !config.mode)
247
- return false;
248
- if (serverCapabilities && !serverCapabilities.includes("slack"))
249
- return false;
250
- if (config.mode === "http" && serverCapabilities)
251
- return true;
252
- return config.missingCredentials.length === 0;
253
- }
254
- function renderToolsAndSkillsVars(input) {
255
- let section = "";
256
- const skills = input.skillsSummary ?? [];
257
- if (skills.length > 0) {
258
- const discovery = "`skill-list` browses the catalog, `skill-search` finds one by intent, `skill-get` reads one.";
259
- if (input.nativeSkillDiscovery) {
260
- const count = skills.length;
261
- const where = input.hasLocalEnv ? "Your harness loads them from its skills directory." : "This session has no local skills directory, so reach them through the MCP tools.";
262
- section += `You have ${count} skill${count === 1 ? "" : "s"} installed. ${where} ${discovery} When a skill matches the task, use it before manual work.
263
- `;
264
- } else {
265
- const howTo = input.hasLocalEnv ? "To use one, read its SKILL.md from your skills directory and follow it." : "To use one, read it with `skill-get` and follow it.";
266
- const lines = skills.map((s) => `- ${input.hasLocalEnv ? "/" : ""}${s.name}: ${s.description}`).join(`
267
- `);
268
- section += `Installed skills. ${howTo} When a skill matches the task, use it before manual work.
269
-
270
- ${lines}
271
-
272
- ${discovery}
273
- `;
274
- }
275
- }
276
- const servers = (input.mcpServers ?? []).filter((name) => name.trim().length > 0);
277
- const mcpLine = servers.length > 0 ? `Connected MCP servers: ${servers.join(", ")}. Their tools are in your tool list.
278
- ` : "";
279
- return {
280
- skills: section,
281
- mcp_servers: mcpLine,
282
- tool_discovery: input.toolDiscovery
283
- };
284
- }
285
- function renderRepositoryVars(repo, ctx) {
286
- const vars = {
287
- clone_note: "",
288
- warning: "",
289
- repo_claude_md: "",
290
- auto_stashes: "",
291
- guidelines: "",
292
- code_quality: ""
293
- };
294
- if (ctx.hasLocalEnv) {
295
- vars.clone_note = "This task's repository is cloned locally. `get-repos` returns the path. Its `CLAUDE.md` applies inside that directory.\n";
296
- }
297
- if (repo.warning) {
298
- vars.warning = `
299
- WARNING: ${repo.warning}
300
- `;
301
- }
302
- if (ctx.hasLocalEnv && repo.claudeMd && REPO_CLAUDE_MD_INLINE_PROVIDERS.has(ctx.provider)) {
303
- vars.repo_claude_md = `
304
- The repository's CLAUDE.md, cloned at \`${repo.clonePath}\`. It applies only inside that directory.
305
-
306
- ` + `${truncateRepoClaudeMd(repo.claudeMd, repo.clonePath, REPO_CLAUDE_MD_MAX_CHARS)}
307
- `;
308
- }
309
- if (ctx.hasLocalEnv && repo.autoStashes && repo.autoStashes.length > 0) {
310
- const stashes = repo.autoStashes.map((stash) => `- ${stash.ref}: ${stash.message}`).join(`
311
- `);
312
- vars.auto_stashes = `
313
- Pending auto-stashed work exists in this repo:
314
- ${stashes}
315
- Restore if relevant with \`git stash apply <ref>\` or \`git stash pop <ref>\`.
316
- `;
317
- }
318
- let section = "";
319
- const g = repo.guidelines;
320
- if (g === null || g === undefined) {
321
- section += `
322
- ### Repository Guidelines
323
-
324
- No repository guidelines are defined. Ask the lead before you push.
325
- `;
326
- } else {
327
- const hasAnyContent = g.prChecks.length > 0 || g.mergeChecks.length > 0 || g.review.length > 0 || g.allowMerge;
328
- if (hasAnyContent) {
329
- section += `
330
- ### Repository Guidelines (MANDATORY)
331
-
332
- `;
333
- if (g.prChecks.length > 0) {
334
- section += `**PR Checks. Run ALL before pushing code or creating a PR:**
335
- `;
336
- g.prChecks.forEach((check, i) => {
337
- section += `${i + 1}. \`${check}\`
338
- `;
339
- });
340
- section += `If ANY check fails, fix the issue before pushing. Do NOT push code with failing checks.
341
- Do NOT use \`--no-verify\` or any flag that bypasses git hooks.
342
-
343
- `;
344
- }
345
- section += `**Merge Policy:**
346
- `;
347
- section += `- Auto-merge: ${g.allowMerge ? "Allowed" : "Not allowed (default)"}
348
- `;
349
- if (g.mergeChecks.length > 0) {
350
- section += `- Before merging, verify:
351
- `;
352
- g.mergeChecks.forEach((check) => {
353
- section += ` - ${check}
354
- `;
355
- });
356
- }
357
- section += `
358
- `;
359
- if (g.review.length > 0) {
360
- section += `**Review Guidance:**
361
- `;
362
- g.review.forEach((item) => {
363
- section += `- ${item}
364
- `;
365
- });
366
- section += `
367
- `;
368
- }
369
- }
370
- }
371
- vars.guidelines = section;
372
- if (ctx.hasMcp) {
373
- vars.code_quality = `
374
- You MUST use the \`code-quality\` skill before you push, open a PR, or review one.
375
- `;
376
- }
377
- return vars;
378
- }
379
- function truncateRepoClaudeMd(content, clonePath, budget) {
380
- if (content.length <= budget)
381
- return content;
382
- const notice = `
383
-
384
- [...truncated, see ${clonePath}/CLAUDE.md for full content]
385
- `;
386
- const contentBudget = budget - notice.length;
387
- if (contentBudget <= 0)
388
- return notice.trimStart();
389
- return content.slice(0, contentBudget) + notice;
390
- }
391
- function truncateSection(content, header, fileName, budget) {
392
- if (!content || budget <= 0)
393
- return "";
394
- const fullSection = `
395
-
396
- ${header}
397
-
398
- ${content}
399
- `;
400
- if (fullSection.length <= budget)
401
- return fullSection;
402
- const headerStr = `
403
-
404
- ${header}
405
-
406
- `;
407
- const notice = `
408
-
409
- [...truncated, see /workspace/${fileName} for full content]
410
- `;
411
- const contentBudget = budget - headerStr.length - notice.length;
412
- if (contentBudget > 0) {
413
- return headerStr + content.slice(0, contentBudget) + notice;
414
- }
415
- return "";
416
- }
417
- var BOOTSTRAP_MAX_CHARS = 20000, BOOTSTRAP_TOTAL_MAX_CHARS = 120000, REPO_CLAUDE_MD_MAX_CHARS = 12000, CLAUDE_MD_INJECT_PROVIDERS, REPO_CLAUDE_MD_INLINE_PROVIDERS, getBasePrompt = async (args) => {
418
- const { role, agentId, traits } = args;
419
- const {
420
- hasMcp = true,
421
- hasToolSearch = false,
422
- hasLocalEnvironment: hasLocalEnv = true,
423
- nativeSkillDiscovery = true
424
- } = traits ?? {};
425
- const steerModes = traits?.steerModes ?? [];
426
- const provider = args.provider ?? "claude";
427
- const defaultsInput = {
428
- name: args.name ?? agentId,
429
- description: args.description,
430
- role,
431
- capabilities: args.capabilities
432
- };
433
- const personaParts = [];
434
- if (args.description)
435
- personaParts.push(args.description);
436
- if (args.soulMd)
437
- personaParts.push(args.soulMd.trim());
438
- if (args.identityMd && !matchesDefaultIdentityMd(args.identityMd, defaultsInput)) {
439
- personaParts.push(args.identityMd.trim());
440
- }
441
- const persona = personaParts.length > 0 ? `
442
- ${personaParts.join(`
443
-
444
- `)}
445
- ` : "";
446
- const vars = {
447
- name: args.name ?? "an agent",
448
- role,
449
- agentId,
450
- persona
451
- };
452
- let compositeEventType;
453
- if (!hasMcp) {
454
- compositeEventType = "system.session.worker.remote";
455
- } else if (!hasLocalEnv) {
456
- compositeEventType = role === "lead" ? "system.session.lead.managed" : "system.session.worker.managed";
457
- } else if (role === "lead") {
458
- compositeEventType = "system.session.lead";
459
- } else {
460
- compositeEventType = "system.session.worker";
461
- }
462
- const compositeResult = await resolveTemplateAsync(compositeEventType, vars);
463
- let prompt = compositeResult.text;
464
- const scriptsOnly = args.scriptsOnly ?? process.env.SCRIPTS_ONLY_MCP === "true";
465
- const scriptsOnlyMode = hasMcp && scriptsOnly;
466
- if (scriptsOnlyMode) {
467
- const scriptsOnlyResult = await resolveTemplateAsync("system.agent.scripts_only_mode", {});
468
- prompt += `
469
- ${scriptsOnlyResult.text}`;
470
- }
471
- const serverHasCapability = (cap, whenUnknown) => args.serverCapabilities ? args.serverCapabilities.includes(cap) : whenUnknown;
472
- if (hasMcp && serverHasCapability("pages", true)) {
473
- const agentFsConfigured = hasLocalEnv && Boolean(process.env.AGENT_FS_API_URL);
474
- const outputsResult = await resolveTemplateAsync(agentFsConfigured ? "system.agent.outputs" : "system.agent.outputs.no_agent_fs", {});
475
- prompt += outputsResult.text;
476
- }
477
- const slackPromptToolsEnabled = areSlackPromptToolsEnabled(process.env, args.serverCapabilities);
478
- if (hasMcp && slackPromptToolsEnabled && !scriptsOnlyMode) {
479
- const slackResult = await resolveTemplateAsync("system.agent.slack", {});
480
- prompt += slackResult.text;
481
- }
482
- if (role !== "lead" && args.slackContext && scriptsOnlyMode && slackPromptToolsEnabled) {
483
- const slackResult = await resolveTemplateAsync("system.agent.scripts_only_mode.slack", {
484
- slackChannelId: args.slackContext.channelId,
485
- slackThreadTs: args.slackContext.threadTs ?? ""
486
- });
487
- prompt += slackResult.text;
488
- }
489
- if (hasMcp && isSteeringEnabled() && steerModes.length > 0 && !scriptsOnlyMode && serverHasCapability("core", true)) {
490
- const steeringResult = await resolveTemplateAsync("system.agent.steering", {});
491
- prompt += steeringResult.text;
492
- }
493
- if (hasMcp) {
494
- const discoveryEvent = provider === "amp" ? "system.agent.tool_discovery.amp" : hasToolSearch ? "system.agent.tool_discovery.search" : "system.agent.tool_discovery.direct";
495
- const discoveryResult = await resolveTemplateAsync(discoveryEvent, {});
496
- const toolsResult = await resolveTemplateAsync("system.agent.tools_skills", renderToolsAndSkillsVars({
497
- skillsSummary: args.skillsSummary,
498
- mcpServers: args.mcpServers,
499
- nativeSkillDiscovery,
500
- toolDiscovery: discoveryResult.text,
501
- hasLocalEnv
502
- }));
503
- prompt += toolsResult.text;
504
- }
505
- if (hasLocalEnv && args.claudeMd && CLAUDE_MD_INJECT_PROVIDERS.has(provider) && !matchesDefaultClaudeMd(args.claudeMd, defaultsInput)) {
506
- const budget = Math.min(BOOTSTRAP_MAX_CHARS, Math.max(0, BOOTSTRAP_TOTAL_MAX_CHARS - prompt.length));
507
- prompt += truncateSection(args.claudeMd, "## Your notes (CLAUDE.md)", "CLAUDE.md", budget);
508
- }
509
- if (args.repoContext) {
510
- const repoResult = await resolveTemplateAsync("system.agent.repository", renderRepositoryVars(args.repoContext, { hasMcp, hasLocalEnv, provider }));
511
- prompt += repoResult.text;
512
- }
513
- return prompt.replace(/\n{3,}/g, `
514
-
515
- `);
516
- };
517
- var init_base_prompt = __esm(() => {
518
- init_config();
519
- init_steering_enabled();
520
- init_defaults();
521
- init_resolver();
522
- init_session_templates();
523
- CLAUDE_MD_INJECT_PROVIDERS = new Set(["codex", "opencode", "pi"]);
524
- REPO_CLAUDE_MD_INLINE_PROVIDERS = new Set(["opencode"]);
525
- });
526
-
527
- // src/utils/identity-field-budget.ts
528
- function checkIdentityFieldBudget({
529
- field,
530
- currentValue,
531
- nextValue
532
- }) {
533
- const budget = IDENTITY_FIELD_BUDGETS[field];
534
- if (nextValue.length <= budget || nextValue.length <= currentValue.length) {
535
- return { ok: true };
536
- }
537
- const delta = nextValue.length - currentValue.length;
538
- const remediation = field === "toolsMd" ? ` Content past the ${budget}-character cap is already silently dropped at read time, so shrinking that tail loses nothing sessions currently receive. Move durable content into memories and keep pointers to it in this field.` : field === "claudeMd" ? ` The tail past the ${budget}-character cap is dropped from the base prompt and only reaches harnesses with a native CLAUDE.md loader. Move durable content into memories and keep pointers to it in this field.` : " Move durable content into memories and keep pointers to it in this field.";
539
- return {
540
- ok: false,
541
- field,
542
- dbSize: currentValue.length,
543
- diskSize: nextValue.length,
544
- budget,
545
- delta,
546
- reason: `Update rejected for ${field}: current size ${currentValue.length} characters, ` + `budget ${budget} characters, delta ${delta >= 0 ? "+" : ""}${delta} characters.` + remediation
547
- };
548
- }
549
- var SOUL_MD_MAX_CHARS = 1e4, IDENTITY_MD_MAX_CHARS = 1e4, IDENTITY_FIELD_BUDGETS, IdentityFieldBudgetError;
550
- var init_identity_field_budget = __esm(() => {
551
- init_base_prompt();
552
- IDENTITY_FIELD_BUDGETS = {
553
- soulMd: SOUL_MD_MAX_CHARS,
554
- identityMd: IDENTITY_MD_MAX_CHARS,
555
- claudeMd: BOOTSTRAP_MAX_CHARS,
556
- toolsMd: BOOTSTRAP_MAX_CHARS
557
- };
558
- IdentityFieldBudgetError = class IdentityFieldBudgetError extends Error {
559
- rejection;
560
- dbHash;
561
- diskHash;
562
- constructor(rejection, dbHash, diskHash) {
563
- super(rejection.reason);
564
- this.rejection = rejection;
565
- this.dbHash = dbHash;
566
- this.diskHash = diskHash;
567
- this.name = "IdentityFieldBudgetError";
568
- }
569
- };
570
- });
571
-
572
- export { generateDefaultClaudeMd, generateDefaultSoulMd, generateDefaultIdentityMd, generateDefaultToolsMd, matchesDefaultIdentityMd, matchesDefaultClaudeMd, init_defaults, getBasePrompt, init_base_prompt, IDENTITY_FIELD_BUDGETS, checkIdentityFieldBudget, IdentityFieldBudgetError, init_identity_field_budget };