@gencode/agents 0.0.1

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 (353) hide show
  1. package/dist/bootstrap/bootstrap-layout.d.ts +23 -0
  2. package/dist/bootstrap/bootstrap-layout.d.ts.map +1 -0
  3. package/dist/bootstrap/bootstrap-layout.js +151 -0
  4. package/dist/bootstrap/bootstrap-layout.js.map +1 -0
  5. package/dist/bootstrap/bootstrap.d.ts +36 -0
  6. package/dist/bootstrap/bootstrap.d.ts.map +1 -0
  7. package/dist/bootstrap/bootstrap.js +136 -0
  8. package/dist/bootstrap/bootstrap.js.map +1 -0
  9. package/dist/bootstrap/templates/AGENTS_MD.d.ts +2 -0
  10. package/dist/bootstrap/templates/AGENTS_MD.d.ts.map +1 -0
  11. package/dist/bootstrap/templates/AGENTS_MD.js +223 -0
  12. package/dist/bootstrap/templates/AGENTS_MD.js.map +1 -0
  13. package/dist/bootstrap/templates/BOOTSTRAP_MD.d.ts +2 -0
  14. package/dist/bootstrap/templates/BOOTSTRAP_MD.d.ts.map +1 -0
  15. package/dist/bootstrap/templates/BOOTSTRAP_MD.js +66 -0
  16. package/dist/bootstrap/templates/BOOTSTRAP_MD.js.map +1 -0
  17. package/dist/bootstrap/templates/HEARTBEAT_MD.d.ts +2 -0
  18. package/dist/bootstrap/templates/HEARTBEAT_MD.d.ts.map +1 -0
  19. package/dist/bootstrap/templates/HEARTBEAT_MD.js +16 -0
  20. package/dist/bootstrap/templates/HEARTBEAT_MD.js.map +1 -0
  21. package/dist/bootstrap/templates/IDENTITY_MD.d.ts +2 -0
  22. package/dist/bootstrap/templates/IDENTITY_MD.d.ts.map +1 -0
  23. package/dist/bootstrap/templates/IDENTITY_MD.js +31 -0
  24. package/dist/bootstrap/templates/IDENTITY_MD.js.map +1 -0
  25. package/dist/bootstrap/templates/SOUL_MD.d.ts +2 -0
  26. package/dist/bootstrap/templates/SOUL_MD.d.ts.map +1 -0
  27. package/dist/bootstrap/templates/SOUL_MD.js +47 -0
  28. package/dist/bootstrap/templates/SOUL_MD.js.map +1 -0
  29. package/dist/bootstrap/templates/TOOLS_MD.d.ts +2 -0
  30. package/dist/bootstrap/templates/TOOLS_MD.d.ts.map +1 -0
  31. package/dist/bootstrap/templates/TOOLS_MD.js +51 -0
  32. package/dist/bootstrap/templates/TOOLS_MD.js.map +1 -0
  33. package/dist/bootstrap/templates/USER_MD.d.ts +2 -0
  34. package/dist/bootstrap/templates/USER_MD.d.ts.map +1 -0
  35. package/dist/bootstrap/templates/USER_MD.js +27 -0
  36. package/dist/bootstrap/templates/USER_MD.js.map +1 -0
  37. package/dist/bootstrap/templates/index.d.ts +3 -0
  38. package/dist/bootstrap/templates/index.d.ts.map +1 -0
  39. package/dist/bootstrap/templates/index.js +26 -0
  40. package/dist/bootstrap/templates/index.js.map +1 -0
  41. package/dist/commands/compact.d.ts +28 -0
  42. package/dist/commands/compact.d.ts.map +1 -0
  43. package/dist/commands/compact.js +57 -0
  44. package/dist/commands/compact.js.map +1 -0
  45. package/dist/commands/help.d.ts +3 -0
  46. package/dist/commands/help.d.ts.map +1 -0
  47. package/dist/commands/help.js +50 -0
  48. package/dist/commands/help.js.map +1 -0
  49. package/dist/commands/index.d.ts +6 -0
  50. package/dist/commands/index.d.ts.map +1 -0
  51. package/dist/commands/index.js +32 -0
  52. package/dist/commands/index.js.map +1 -0
  53. package/dist/commands/new.d.ts +3 -0
  54. package/dist/commands/new.d.ts.map +1 -0
  55. package/dist/commands/new.js +4 -0
  56. package/dist/commands/new.js.map +1 -0
  57. package/dist/commands/registry.d.ts +11 -0
  58. package/dist/commands/registry.d.ts.map +1 -0
  59. package/dist/commands/registry.js +122 -0
  60. package/dist/commands/registry.js.map +1 -0
  61. package/dist/commands/reset.d.ts +3 -0
  62. package/dist/commands/reset.d.ts.map +1 -0
  63. package/dist/commands/reset.js +4 -0
  64. package/dist/commands/reset.js.map +1 -0
  65. package/dist/commands/skill.d.ts +7 -0
  66. package/dist/commands/skill.d.ts.map +1 -0
  67. package/dist/commands/skill.js +23 -0
  68. package/dist/commands/skill.js.map +1 -0
  69. package/dist/commands/types.d.ts +57 -0
  70. package/dist/commands/types.d.ts.map +1 -0
  71. package/dist/commands/types.js +2 -0
  72. package/dist/commands/types.js.map +1 -0
  73. package/dist/config/agents-config.d.ts +85 -0
  74. package/dist/config/agents-config.d.ts.map +1 -0
  75. package/dist/config/agents-config.js +257 -0
  76. package/dist/config/agents-config.js.map +1 -0
  77. package/dist/config/index.d.ts +9 -0
  78. package/dist/config/index.d.ts.map +1 -0
  79. package/dist/config/index.js +9 -0
  80. package/dist/config/index.js.map +1 -0
  81. package/dist/config/types.d.ts +87 -0
  82. package/dist/config/types.d.ts.map +1 -0
  83. package/dist/config/types.js +6 -0
  84. package/dist/config/types.js.map +1 -0
  85. package/dist/history/compaction.d.ts +42 -0
  86. package/dist/history/compaction.d.ts.map +1 -0
  87. package/dist/history/compaction.js +135 -0
  88. package/dist/history/compaction.js.map +1 -0
  89. package/dist/history/index.d.ts +57 -0
  90. package/dist/history/index.d.ts.map +1 -0
  91. package/dist/history/index.js +145 -0
  92. package/dist/history/index.js.map +1 -0
  93. package/dist/history/limit.d.ts +13 -0
  94. package/dist/history/limit.d.ts.map +1 -0
  95. package/dist/history/limit.js +32 -0
  96. package/dist/history/limit.js.map +1 -0
  97. package/dist/history/repair.d.ts +13 -0
  98. package/dist/history/repair.d.ts.map +1 -0
  99. package/dist/history/repair.js +25 -0
  100. package/dist/history/repair.js.map +1 -0
  101. package/dist/history/token-estimate.d.ts +22 -0
  102. package/dist/history/token-estimate.d.ts.map +1 -0
  103. package/dist/history/token-estimate.js +38 -0
  104. package/dist/history/token-estimate.js.map +1 -0
  105. package/dist/index.d.ts +41 -0
  106. package/dist/index.d.ts.map +1 -0
  107. package/dist/index.js +35 -0
  108. package/dist/index.js.map +1 -0
  109. package/dist/llm/client.d.ts +53 -0
  110. package/dist/llm/client.d.ts.map +1 -0
  111. package/dist/llm/client.js +214 -0
  112. package/dist/llm/client.js.map +1 -0
  113. package/dist/llm/openai-completions-compat.d.ts +23 -0
  114. package/dist/llm/openai-completions-compat.d.ts.map +1 -0
  115. package/dist/llm/openai-completions-compat.js +602 -0
  116. package/dist/llm/openai-completions-compat.js.map +1 -0
  117. package/dist/llm/openai-stream-error.d.ts +11 -0
  118. package/dist/llm/openai-stream-error.d.ts.map +1 -0
  119. package/dist/llm/openai-stream-error.js +77 -0
  120. package/dist/llm/openai-stream-error.js.map +1 -0
  121. package/dist/loop-detection/session-state.d.ts +5 -0
  122. package/dist/loop-detection/session-state.d.ts.map +1 -0
  123. package/dist/loop-detection/session-state.js +16 -0
  124. package/dist/loop-detection/session-state.js.map +1 -0
  125. package/dist/loop-detection/tool-loop-detection.d.ts +122 -0
  126. package/dist/loop-detection/tool-loop-detection.d.ts.map +1 -0
  127. package/dist/loop-detection/tool-loop-detection.js +516 -0
  128. package/dist/loop-detection/tool-loop-detection.js.map +1 -0
  129. package/dist/memory/builtin-provider.d.ts +5 -0
  130. package/dist/memory/builtin-provider.d.ts.map +1 -0
  131. package/dist/memory/builtin-provider.js +42 -0
  132. package/dist/memory/builtin-provider.js.map +1 -0
  133. package/dist/memory/config.d.ts +50 -0
  134. package/dist/memory/config.d.ts.map +1 -0
  135. package/dist/memory/config.js +46 -0
  136. package/dist/memory/config.js.map +1 -0
  137. package/dist/memory/embedding-registry.d.ts +37 -0
  138. package/dist/memory/embedding-registry.d.ts.map +1 -0
  139. package/dist/memory/embedding-registry.js +56 -0
  140. package/dist/memory/embedding-registry.js.map +1 -0
  141. package/dist/memory/embeddings.d.ts +11 -0
  142. package/dist/memory/embeddings.d.ts.map +1 -0
  143. package/dist/memory/embeddings.js +40 -0
  144. package/dist/memory/embeddings.js.map +1 -0
  145. package/dist/memory/fs-utils.d.ts +12 -0
  146. package/dist/memory/fs-utils.d.ts.map +1 -0
  147. package/dist/memory/fs-utils.js +24 -0
  148. package/dist/memory/fs-utils.js.map +1 -0
  149. package/dist/memory/hybrid.d.ts +43 -0
  150. package/dist/memory/hybrid.d.ts.map +1 -0
  151. package/dist/memory/hybrid.js +80 -0
  152. package/dist/memory/hybrid.js.map +1 -0
  153. package/dist/memory/internal.d.ts +28 -0
  154. package/dist/memory/internal.d.ts.map +1 -0
  155. package/dist/memory/internal.js +270 -0
  156. package/dist/memory/internal.js.map +1 -0
  157. package/dist/memory/manager-search.d.ts +61 -0
  158. package/dist/memory/manager-search.d.ts.map +1 -0
  159. package/dist/memory/manager-search.js +106 -0
  160. package/dist/memory/manager-search.js.map +1 -0
  161. package/dist/memory/manager.d.ts +126 -0
  162. package/dist/memory/manager.d.ts.map +1 -0
  163. package/dist/memory/manager.js +1006 -0
  164. package/dist/memory/manager.js.map +1 -0
  165. package/dist/memory/memory-schema.d.ts +11 -0
  166. package/dist/memory/memory-schema.d.ts.map +1 -0
  167. package/dist/memory/memory-schema.js +78 -0
  168. package/dist/memory/memory-schema.js.map +1 -0
  169. package/dist/memory/memory.d.ts +46 -0
  170. package/dist/memory/memory.d.ts.map +1 -0
  171. package/dist/memory/memory.js +127 -0
  172. package/dist/memory/memory.js.map +1 -0
  173. package/dist/memory/mmr.d.ts +22 -0
  174. package/dist/memory/mmr.d.ts.map +1 -0
  175. package/dist/memory/mmr.js +112 -0
  176. package/dist/memory/mmr.js.map +1 -0
  177. package/dist/memory/provider-registry.d.ts +29 -0
  178. package/dist/memory/provider-registry.d.ts.map +1 -0
  179. package/dist/memory/provider-registry.js +58 -0
  180. package/dist/memory/provider-registry.js.map +1 -0
  181. package/dist/memory/provider.d.ts +40 -0
  182. package/dist/memory/provider.d.ts.map +1 -0
  183. package/dist/memory/provider.js +2 -0
  184. package/dist/memory/provider.js.map +1 -0
  185. package/dist/memory/session-files.d.ts +13 -0
  186. package/dist/memory/session-files.d.ts.map +1 -0
  187. package/dist/memory/session-files.js +116 -0
  188. package/dist/memory/session-files.js.map +1 -0
  189. package/dist/memory/sqlite-vec.d.ts +10 -0
  190. package/dist/memory/sqlite-vec.d.ts.map +1 -0
  191. package/dist/memory/sqlite-vec.js +20 -0
  192. package/dist/memory/sqlite-vec.js.map +1 -0
  193. package/dist/memory/sqlite.d.ts +2 -0
  194. package/dist/memory/sqlite.d.ts.map +1 -0
  195. package/dist/memory/sqlite.js +12 -0
  196. package/dist/memory/sqlite.js.map +1 -0
  197. package/dist/memory/temporal-decay.d.ts +26 -0
  198. package/dist/memory/temporal-decay.d.ts.map +1 -0
  199. package/dist/memory/temporal-decay.js +119 -0
  200. package/dist/memory/temporal-decay.js.map +1 -0
  201. package/dist/memory/watch-bridge.d.ts +20 -0
  202. package/dist/memory/watch-bridge.d.ts.map +1 -0
  203. package/dist/memory/watch-bridge.js +128 -0
  204. package/dist/memory/watch-bridge.js.map +1 -0
  205. package/dist/plugins/boundary-file-read.d.ts +13 -0
  206. package/dist/plugins/boundary-file-read.d.ts.map +1 -0
  207. package/dist/plugins/boundary-file-read.js +31 -0
  208. package/dist/plugins/boundary-file-read.js.map +1 -0
  209. package/dist/plugins/config-state.d.ts +35 -0
  210. package/dist/plugins/config-state.d.ts.map +1 -0
  211. package/dist/plugins/config-state.js +97 -0
  212. package/dist/plugins/config-state.js.map +1 -0
  213. package/dist/plugins/discovery.d.ts +21 -0
  214. package/dist/plugins/discovery.d.ts.map +1 -0
  215. package/dist/plugins/discovery.js +425 -0
  216. package/dist/plugins/discovery.js.map +1 -0
  217. package/dist/plugins/hooks.d.ts +112 -0
  218. package/dist/plugins/hooks.d.ts.map +1 -0
  219. package/dist/plugins/hooks.js +19 -0
  220. package/dist/plugins/hooks.js.map +1 -0
  221. package/dist/plugins/index.d.ts +20 -0
  222. package/dist/plugins/index.d.ts.map +1 -0
  223. package/dist/plugins/index.js +11 -0
  224. package/dist/plugins/index.js.map +1 -0
  225. package/dist/plugins/loader.d.ts +60 -0
  226. package/dist/plugins/loader.d.ts.map +1 -0
  227. package/dist/plugins/loader.js +224 -0
  228. package/dist/plugins/loader.js.map +1 -0
  229. package/dist/plugins/manager.d.ts +20 -0
  230. package/dist/plugins/manager.d.ts.map +1 -0
  231. package/dist/plugins/manager.js +33 -0
  232. package/dist/plugins/manager.js.map +1 -0
  233. package/dist/plugins/manifest-registry.d.ts +15 -0
  234. package/dist/plugins/manifest-registry.d.ts.map +1 -0
  235. package/dist/plugins/manifest-registry.js +37 -0
  236. package/dist/plugins/manifest-registry.js.map +1 -0
  237. package/dist/plugins/manifest.d.ts +6 -0
  238. package/dist/plugins/manifest.d.ts.map +1 -0
  239. package/dist/plugins/manifest.js +80 -0
  240. package/dist/plugins/manifest.js.map +1 -0
  241. package/dist/plugins/path-safety.d.ts +6 -0
  242. package/dist/plugins/path-safety.d.ts.map +1 -0
  243. package/dist/plugins/path-safety.js +32 -0
  244. package/dist/plugins/path-safety.js.map +1 -0
  245. package/dist/plugins/runtime-context.d.ts +12 -0
  246. package/dist/plugins/runtime-context.d.ts.map +1 -0
  247. package/dist/plugins/runtime-context.js +2 -0
  248. package/dist/plugins/runtime-context.js.map +1 -0
  249. package/dist/plugins/runtime.d.ts +12 -0
  250. package/dist/plugins/runtime.d.ts.map +1 -0
  251. package/dist/plugins/runtime.js +13 -0
  252. package/dist/plugins/runtime.js.map +1 -0
  253. package/dist/plugins/schema-validator.d.ts +17 -0
  254. package/dist/plugins/schema-validator.d.ts.map +1 -0
  255. package/dist/plugins/schema-validator.js +26 -0
  256. package/dist/plugins/schema-validator.js.map +1 -0
  257. package/dist/plugins/tool-hooks.d.ts +4 -0
  258. package/dist/plugins/tool-hooks.d.ts.map +1 -0
  259. package/dist/plugins/tool-hooks.js +60 -0
  260. package/dist/plugins/tool-hooks.js.map +1 -0
  261. package/dist/plugins/tools.d.ts +20 -0
  262. package/dist/plugins/tools.d.ts.map +1 -0
  263. package/dist/plugins/tools.js +42 -0
  264. package/dist/plugins/tools.js.map +1 -0
  265. package/dist/plugins/types.d.ts +61 -0
  266. package/dist/plugins/types.d.ts.map +1 -0
  267. package/dist/plugins/types.js +2 -0
  268. package/dist/plugins/types.js.map +1 -0
  269. package/dist/plugins/utils.d.ts +4 -0
  270. package/dist/plugins/utils.d.ts.map +1 -0
  271. package/dist/plugins/utils.js +22 -0
  272. package/dist/plugins/utils.js.map +1 -0
  273. package/dist/runner/runner.d.ts +14 -0
  274. package/dist/runner/runner.d.ts.map +1 -0
  275. package/dist/runner/runner.js +893 -0
  276. package/dist/runner/runner.js.map +1 -0
  277. package/dist/session/session.d.ts +45 -0
  278. package/dist/session/session.d.ts.map +1 -0
  279. package/dist/session/session.js +167 -0
  280. package/dist/session/session.js.map +1 -0
  281. package/dist/skills/skills.d.ts +23 -0
  282. package/dist/skills/skills.d.ts.map +1 -0
  283. package/dist/skills/skills.js +109 -0
  284. package/dist/skills/skills.js.map +1 -0
  285. package/dist/subagent/registry-persist.d.ts +31 -0
  286. package/dist/subagent/registry-persist.d.ts.map +1 -0
  287. package/dist/subagent/registry-persist.js +115 -0
  288. package/dist/subagent/registry-persist.js.map +1 -0
  289. package/dist/subagent/registry.d.ts +52 -0
  290. package/dist/subagent/registry.d.ts.map +1 -0
  291. package/dist/subagent/registry.js +122 -0
  292. package/dist/subagent/registry.js.map +1 -0
  293. package/dist/subagent/types.d.ts +20 -0
  294. package/dist/subagent/types.d.ts.map +1 -0
  295. package/dist/subagent/types.js +2 -0
  296. package/dist/subagent/types.js.map +1 -0
  297. package/dist/system-prompt/builder.d.ts +50 -0
  298. package/dist/system-prompt/builder.d.ts.map +1 -0
  299. package/dist/system-prompt/builder.js +335 -0
  300. package/dist/system-prompt/builder.js.map +1 -0
  301. package/dist/tools/apply-patch.d.ts +15 -0
  302. package/dist/tools/apply-patch.d.ts.map +1 -0
  303. package/dist/tools/apply-patch.js +425 -0
  304. package/dist/tools/apply-patch.js.map +1 -0
  305. package/dist/tools/bash.d.ts +11 -0
  306. package/dist/tools/bash.d.ts.map +1 -0
  307. package/dist/tools/bash.js +13 -0
  308. package/dist/tools/bash.js.map +1 -0
  309. package/dist/tools/cron.d.ts +23 -0
  310. package/dist/tools/cron.d.ts.map +1 -0
  311. package/dist/tools/cron.js +37 -0
  312. package/dist/tools/cron.js.map +1 -0
  313. package/dist/tools/exec.d.ts +18 -0
  314. package/dist/tools/exec.d.ts.map +1 -0
  315. package/dist/tools/exec.js +125 -0
  316. package/dist/tools/exec.js.map +1 -0
  317. package/dist/tools/files.d.ts +37 -0
  318. package/dist/tools/files.d.ts.map +1 -0
  319. package/dist/tools/files.js +191 -0
  320. package/dist/tools/files.js.map +1 -0
  321. package/dist/tools/image.d.ts +14 -0
  322. package/dist/tools/image.d.ts.map +1 -0
  323. package/dist/tools/image.js +26 -0
  324. package/dist/tools/image.js.map +1 -0
  325. package/dist/tools/index.d.ts +35 -0
  326. package/dist/tools/index.d.ts.map +1 -0
  327. package/dist/tools/index.js +53 -0
  328. package/dist/tools/index.js.map +1 -0
  329. package/dist/tools/memory.d.ts +41 -0
  330. package/dist/tools/memory.d.ts.map +1 -0
  331. package/dist/tools/memory.js +114 -0
  332. package/dist/tools/memory.js.map +1 -0
  333. package/dist/tools/process-registry.d.ts +47 -0
  334. package/dist/tools/process-registry.d.ts.map +1 -0
  335. package/dist/tools/process-registry.js +252 -0
  336. package/dist/tools/process-registry.js.map +1 -0
  337. package/dist/tools/process.d.ts +17 -0
  338. package/dist/tools/process.d.ts.map +1 -0
  339. package/dist/tools/process.js +114 -0
  340. package/dist/tools/process.js.map +1 -0
  341. package/dist/tools/subagent-spawn.d.ts +44 -0
  342. package/dist/tools/subagent-spawn.d.ts.map +1 -0
  343. package/dist/tools/subagent-spawn.js +100 -0
  344. package/dist/tools/subagent-spawn.js.map +1 -0
  345. package/dist/tools/subagents.d.ts +30 -0
  346. package/dist/tools/subagents.d.ts.map +1 -0
  347. package/dist/tools/subagents.js +101 -0
  348. package/dist/tools/subagents.js.map +1 -0
  349. package/dist/types.d.ts +241 -0
  350. package/dist/types.d.ts.map +1 -0
  351. package/dist/types.js +6 -0
  352. package/dist/types.js.map +1 -0
  353. package/package.json +46 -0
@@ -0,0 +1,52 @@
1
+ import type { SubagentRunRecord, SubagentStatus } from "./types.js";
2
+ export declare const MAX_SUBAGENT_DEPTH = 3;
3
+ export declare const MAX_CHILDREN_PER_SESSION = 5;
4
+ /**
5
+ * In-memory registry for subagent runs scoped to a single parent runAgent call.
6
+ * Child spawns create their own SubagentRegistry instances for their children.
7
+ */
8
+ export declare class SubagentRegistry {
9
+ private readonly entries;
10
+ /** RunIds that have already been returned by consumeCompleted */
11
+ private readonly announced;
12
+ register(record: SubagentRunRecord, promise: Promise<void>): void;
13
+ complete(runId: string, result: string): void;
14
+ fail(runId: string, error: string): void;
15
+ /** Aborts and marks a specific run as killed. Returns false if not found or already ended. */
16
+ kill(runId: string): boolean;
17
+ /** Aborts all running subagents for the given parent session. Returns count killed. */
18
+ killAll(parentSessionId: string): number;
19
+ /** Lists all runs registered for the given parent session. */
20
+ list(parentSessionId: string): SubagentRunRecord[];
21
+ /** Returns true if any subagents for this session are still running. */
22
+ hasPending(parentSessionId: string): boolean;
23
+ /** Count of currently running children for a session. */
24
+ countActive(parentSessionId: string): number;
25
+ /**
26
+ * Waits until all currently-running subagents for the given session settle.
27
+ * Returns immediately if nothing is pending.
28
+ */
29
+ waitForAll(parentSessionId: string): Promise<void>;
30
+ /**
31
+ * Returns all finished runs that have not yet been returned by this method,
32
+ * and marks them as announced so they are not returned again.
33
+ */
34
+ consumeCompleted(parentSessionId: string): SubagentRunRecord[];
35
+ /** Returns true if there are completed runs not yet returned by consumeCompleted. */
36
+ hasUnannounced(parentSessionId: string): boolean;
37
+ /**
38
+ * Returns true if the announce loop should run another iteration:
39
+ * either subagents are still running, or completed runs await announcement.
40
+ */
41
+ needsAnnounce(parentSessionId: string): boolean;
42
+ /** Checks whether a new child can be spawned given depth and active-children limits. */
43
+ checkSpawnAllowed(parentSessionId: string, depth: number): {
44
+ allowed: true;
45
+ } | {
46
+ allowed: false;
47
+ reason: string;
48
+ };
49
+ /** Returns the current status snapshot for a single run, or null if not found. */
50
+ getStatus(runId: string): SubagentStatus | null;
51
+ }
52
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/subagent/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEpE,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAQ1C;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,iEAAiE;IACjE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAE/C,QAAQ,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAIjE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ7C,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAQxC,8FAA8F;IAC9F,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAS5B,uFAAuF;IACvF,OAAO,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM;IAaxC,8DAA8D;IAC9D,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,iBAAiB,EAAE;IAMlD,wEAAwE;IACxE,UAAU,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO;IAI5C,yDAAyD;IACzD,WAAW,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM;IAI5C;;;OAGG;IACG,UAAU,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWxD;;;OAGG;IACH,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,iBAAiB,EAAE;IAQ9D,qFAAqF;IACrF,cAAc,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO;IAMhD;;;OAGG;IACH,aAAa,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO;IAI/C,wFAAwF;IACxF,iBAAiB,CACf,eAAe,EAAE,MAAM,EACvB,KAAK,EAAE,MAAM,GACZ;QAAE,OAAO,EAAE,IAAI,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAiBzD,kFAAkF;IAClF,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;CAGhD"}
@@ -0,0 +1,122 @@
1
+ export const MAX_SUBAGENT_DEPTH = 3;
2
+ export const MAX_CHILDREN_PER_SESSION = 5;
3
+ /**
4
+ * In-memory registry for subagent runs scoped to a single parent runAgent call.
5
+ * Child spawns create their own SubagentRegistry instances for their children.
6
+ */
7
+ export class SubagentRegistry {
8
+ entries = new Map();
9
+ /** RunIds that have already been returned by consumeCompleted */
10
+ announced = new Set();
11
+ register(record, promise) {
12
+ this.entries.set(record.runId, { record, promise });
13
+ }
14
+ complete(runId, result) {
15
+ const entry = this.entries.get(runId);
16
+ if (!entry || entry.record.status !== "running")
17
+ return;
18
+ entry.record.status = "done";
19
+ entry.record.result = result;
20
+ entry.record.endedAt = Date.now();
21
+ }
22
+ fail(runId, error) {
23
+ const entry = this.entries.get(runId);
24
+ if (!entry || entry.record.status !== "running")
25
+ return;
26
+ entry.record.status = "error";
27
+ entry.record.error = error;
28
+ entry.record.endedAt = Date.now();
29
+ }
30
+ /** Aborts and marks a specific run as killed. Returns false if not found or already ended. */
31
+ kill(runId) {
32
+ const entry = this.entries.get(runId);
33
+ if (!entry || entry.record.status !== "running")
34
+ return false;
35
+ entry.record.abortController.abort();
36
+ entry.record.status = "killed";
37
+ entry.record.endedAt = Date.now();
38
+ return true;
39
+ }
40
+ /** Aborts all running subagents for the given parent session. Returns count killed. */
41
+ killAll(parentSessionId) {
42
+ let killed = 0;
43
+ for (const { record } of this.entries.values()) {
44
+ if (record.parentSessionId === parentSessionId && record.status === "running") {
45
+ record.abortController.abort();
46
+ record.status = "killed";
47
+ record.endedAt = Date.now();
48
+ killed++;
49
+ }
50
+ }
51
+ return killed;
52
+ }
53
+ /** Lists all runs registered for the given parent session. */
54
+ list(parentSessionId) {
55
+ return Array.from(this.entries.values())
56
+ .filter((e) => e.record.parentSessionId === parentSessionId)
57
+ .map((e) => e.record);
58
+ }
59
+ /** Returns true if any subagents for this session are still running. */
60
+ hasPending(parentSessionId) {
61
+ return this.list(parentSessionId).some((r) => r.status === "running");
62
+ }
63
+ /** Count of currently running children for a session. */
64
+ countActive(parentSessionId) {
65
+ return this.list(parentSessionId).filter((r) => r.status === "running").length;
66
+ }
67
+ /**
68
+ * Waits until all currently-running subagents for the given session settle.
69
+ * Returns immediately if nothing is pending.
70
+ */
71
+ async waitForAll(parentSessionId) {
72
+ const runningPromises = Array.from(this.entries.values())
73
+ .filter((e) => e.record.parentSessionId === parentSessionId && e.record.status === "running")
74
+ .map((e) => e.promise);
75
+ if (runningPromises.length > 0) {
76
+ await Promise.allSettled(runningPromises);
77
+ }
78
+ }
79
+ /**
80
+ * Returns all finished runs that have not yet been returned by this method,
81
+ * and marks them as announced so they are not returned again.
82
+ */
83
+ consumeCompleted(parentSessionId) {
84
+ const done = this.list(parentSessionId).filter((r) => r.status !== "running" && !this.announced.has(r.runId));
85
+ for (const r of done)
86
+ this.announced.add(r.runId);
87
+ return done;
88
+ }
89
+ /** Returns true if there are completed runs not yet returned by consumeCompleted. */
90
+ hasUnannounced(parentSessionId) {
91
+ return this.list(parentSessionId).some((r) => r.status !== "running" && !this.announced.has(r.runId));
92
+ }
93
+ /**
94
+ * Returns true if the announce loop should run another iteration:
95
+ * either subagents are still running, or completed runs await announcement.
96
+ */
97
+ needsAnnounce(parentSessionId) {
98
+ return this.hasPending(parentSessionId) || this.hasUnannounced(parentSessionId);
99
+ }
100
+ /** Checks whether a new child can be spawned given depth and active-children limits. */
101
+ checkSpawnAllowed(parentSessionId, depth) {
102
+ if (depth > MAX_SUBAGENT_DEPTH) {
103
+ return {
104
+ allowed: false,
105
+ reason: `Maximum subagent depth (${MAX_SUBAGENT_DEPTH}) reached`,
106
+ };
107
+ }
108
+ const active = this.countActive(parentSessionId);
109
+ if (active >= MAX_CHILDREN_PER_SESSION) {
110
+ return {
111
+ allowed: false,
112
+ reason: `Maximum concurrent subagents (${MAX_CHILDREN_PER_SESSION}) reached for this session`,
113
+ };
114
+ }
115
+ return { allowed: true };
116
+ }
117
+ /** Returns the current status snapshot for a single run, or null if not found. */
118
+ getStatus(runId) {
119
+ return this.entries.get(runId)?.record.status ?? null;
120
+ }
121
+ }
122
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/subagent/registry.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAQ1C;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACV,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC5D,iEAAiE;IAChD,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/C,QAAQ,CAAC,MAAyB,EAAE,OAAsB;QACxD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,QAAQ,CAAC,KAAa,EAAE,MAAc;QACpC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS;YAAE,OAAO;QACxD,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QAC7B,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QAC7B,KA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,wBAAwB,EAAE,CAAC;YACvC,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,iCAAiC,wBAAwB,4BAA4B;aAC9F,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,kFAAkF;IAClF,SAAS,CAAC,KAAa;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC;IACxD,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ /** Status of a spawned subagent run */
2
+ export type SubagentStatus = "running" | "done" | "error" | "killed";
3
+ /** Record tracking a single subagent run */
4
+ export type SubagentRunRecord = {
5
+ runId: string;
6
+ childSessionId: string;
7
+ parentSessionId: string;
8
+ task: string;
9
+ label?: string;
10
+ /** Nesting depth: parent is depth N, child is N+1 */
11
+ depth: number;
12
+ status: SubagentStatus;
13
+ result?: string;
14
+ error?: string;
15
+ startedAt: number;
16
+ endedAt?: number;
17
+ /** Used to cancel the subagent run */
18
+ abortController: AbortController;
19
+ };
20
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/subagent/types.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,4CAA4C;AAC5C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,eAAe,EAAE,eAAe,CAAC;CAClC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/subagent/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ import type { BootstrapContextFile } from "../bootstrap/bootstrap.js";
2
+ import type { Skill } from "../skills/skills.js";
3
+ export type PromptMode = "full" | "minimal" | "none";
4
+ export type MemoryCitationsMode = "off" | "on";
5
+ /** Parameters for building the agent system prompt */
6
+ export type SystemPromptParams = {
7
+ dataDir: string;
8
+ skills?: Skill[];
9
+ contextFiles?: BootstrapContextFile[];
10
+ runtimeInfo?: {
11
+ os?: string;
12
+ node?: string;
13
+ model?: string;
14
+ hostname?: string;
15
+ };
16
+ toolNames?: string[];
17
+ toolSummaries?: Record<string, string>;
18
+ promptMode?: PromptMode;
19
+ heartbeatPrompt?: string;
20
+ bootstrapWarnings?: string[];
21
+ memoryCitationsMode?: MemoryCitationsMode;
22
+ sandboxInfo?: {
23
+ enabled?: boolean;
24
+ hostWorkspaceDir?: string;
25
+ containerWorkspaceDir?: string;
26
+ };
27
+ messaging?: {
28
+ enabled?: boolean;
29
+ channels?: string[];
30
+ };
31
+ docs?: {
32
+ localPath?: string;
33
+ webUrl?: string;
34
+ sourceUrl?: string;
35
+ };
36
+ currentDate?: string;
37
+ timezone?: string;
38
+ /**
39
+ * Summary of prior conversation history produced by compaction.
40
+ * When provided, it is appended to the system prompt so the agent
41
+ * understands what happened before the retained message window.
42
+ */
43
+ priorConversationSummary?: string;
44
+ };
45
+ /**
46
+ * Builds the complete system prompt for the agent.
47
+ * Assembles all sections in the correct order.
48
+ */
49
+ export declare function buildSystemPrompt(params: SystemPromptParams): string;
50
+ //# s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ACF,IAAI,CAAC,EAAE;QACL,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC,CAAC;AAqTF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CA6CpE"}
@@ -0,0 +1,335 @@
1
+ /** Core tool descriptions for the system prompt */
2
+ const CORE_TOOL_DESCRIPTIONS = {
3
+ read_file: "Read file contents",
4
+ write_file: "Create or overwrite files",
5
+ edit_file: "Make precise edits to files",
6
+ list_dir: "List directory contents",
7
+ apply_patch: "Apply multi-file patches",
8
+ exec: "Run shell commands",
9
+ process: "Manage background exec sessions",
10
+ memory_search: "Search memory files for relevant information",
11
+ memory_get: "Read specific lines from memory files",
12
+ memory_append: "Append new long-term memory",
13
+ sessions_spawn: "Spawn an isolated subagent session",
14
+ subagents: "List, steer, or kill subagent runs",
15
+ };
16
+ const CORE_TOOL_ORDER = [
17
+ "read_file",
18
+ "write_file",
19
+ "edit_file",
20
+ "list_dir",
21
+ "apply_patch",
22
+ "exec",
23
+ "process",
24
+ "memory_search",
25
+ "memory_get",
26
+ "memory_append",
27
+ "sessions_spawn",
28
+ "subagents",
29
+ ];
30
+ const DEFAULT_HEARTBEAT_PROMPT = "Read HEARTBEAT.md if it exists (cloud workspace context). Follow it strictly. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK.";
31
+ function dedupeTools(toolNames) {
32
+ const displayName = new Map();
33
+ for (const toolName of toolNames) {
34
+ const trimmed = toolName.trim();
35
+ if (!trimmed)
36
+ continue;
37
+ const normalized = trimmed.toLowerCase();
38
+ if (!displayName.has(normalized)) {
39
+ displayName.set(normalized, trimmed);
40
+ }
41
+ }
42
+ const normalizedNames = Array.from(displayName.keys());
43
+ const ordered = [
44
+ ...CORE_TOOL_ORDER.filter((name) => displayName.has(name)),
45
+ ...normalizedNames
46
+ .filter((name) => !CORE_TOOL_ORDER.includes(name))
47
+ .sort(),
48
+ ];
49
+ return { ordered, displayName };
50
+ }
51
+ function buildToolingSection(params) {
52
+ const { ordered, displayName } = dedupeTools(params.toolNames);
53
+ const summaryByName = new Map();
54
+ for (const [name, summary] of Object.entries(params.toolSummaries ?? {})) {
55
+ const normalized = name.trim().toLowerCase();
56
+ if (!normalized || !summary?.trim())
57
+ continue;
58
+ summaryByName.set(normalized, summary.trim());
59
+ }
60
+ const toolLines = ordered.map((normalizedName) => {
61
+ const display = displayName.get(normalizedName) ?? normalizedName;
62
+ const summary = summaryByName.get(normalizedName) ?? CORE_TOOL_DESCRIPTIONS[normalizedName];
63
+ return summary ? `- ${display}: ${summary}` : `- ${display}`;
64
+ });
65
+ return [
66
+ "## Tooling",
67
+ "Tool availability (filtered by runtime policy):",
68
+ "Tool names are case-sensitive. Call tools exactly as listed.",
69
+ toolLines.join("\n"),
70
+ "",
71
+ ].join("\n");
72
+ }
73
+ function buildSafetySection() {
74
+ return [
75
+ "## Safety",
76
+ "You have no independent goals: do not pursue self-preservation, replication, resource acquisition, or power-seeking; avoid long-term plans beyond the user's request.",
77
+ "Prioritize safety and human oversight over completion; if instructions conflict, pause and ask; comply with stop/pause/audit requests and never bypass safeguards.",
78
+ "Do not attempt to bypass approvals, safety rails, or access boundaries.",
79
+ "Never print, reveal, or echo environment variable values. If configuration must be shown, use placeholders plus brief meanings instead, such as {{API_KEY}}: model access credential.",
80
+ "",
81
+ ].join("\n");
82
+ }
83
+ function buildToolCallStyleSection(isMinimal) {
84
+ if (isMinimal)
85
+ return "";
86
+ return [
87
+ "## Tool Call Style",
88
+ "Default: call routine low-risk tools directly without narrating every step.",
89
+ "Narrate briefly when actions are sensitive, long-running, or likely surprising.",
90
+ "When approvals are required, keep the command text exact and complete.",
91
+ "",
92
+ ].join("\n");
93
+ }
94
+ function buildSkillsSection(skills) {
95
+ if (skills.length === 0)
96
+ return "";
97
+ const skillEntries = skills
98
+ .map((skill) => [
99
+ " <skill>",
100
+ ` <name>${skill.name}</name>`,
101
+ ` <description>${skill.description}</description>`,
102
+ ` <location>${skill.location}</location>`,
103
+ " </skill>",
104
+ ].join("\n"))
105
+ .join("\n");
106
+ const availableSkills = `<available_skills>\n${skillEntries}\n</available_skills>`;
107
+ return [
108
+ "## Skills (mandatory)",
109
+ "Before replying: scan <available_skills> <description> entries.",
110
+ "- If exactly one skill clearly applies: read its SKILL.md at <location> with `read_file`, then follow it.",
111
+ "- If multiple could apply: choose the most specific one, then read/follow it.",
112
+ "- If none clearly apply: do not read any SKILL.md.",
113
+ "Constraints: never read more than one skill up front; only read after selecting.",
114
+ availableSkills,
115
+ "",
116
+ ].join("\n");
117
+ }
118
+ function buildMemoryWriteSection() {
119
+ return [
120
+ "## Memory Write",
121
+ "When the user asks to remember something or new long-term memory is needed, you must use memory_append. Do not use write_file or edit_file for memory writes.",
122
+ "",
123
+ ].join("\n");
124
+ }
125
+ function buildMemorySection(citationsMode) {
126
+ return [
127
+ "## Memory Recall",
128
+ "Before answering anything about prior work, decisions, dates, people, preferences, or todos: run memory_search on MEMORY.md + memory/*.md; then use memory_get to pull only the needed lines. If low confidence after search, say you checked.",
129
+ citationsMode === "off"
130
+ ? "Citations are disabled: do not include memory file paths or line numbers unless the user explicitly asks."
131
+ : "When useful, include memory evidence as Source: <path#line>.",
132
+ "",
133
+ ].join("\n");
134
+ }
135
+ function buildWorkspaceSection(params) {
136
+ const aimaxDir = `${params.dataDir}/.aimax`;
137
+ const workspaceDir = `${params.dataDir}/workspace`;
138
+ const hostWorkspaceDir = params.sandboxInfo?.hostWorkspaceDir?.trim() || workspaceDir;
139
+ const containerWorkspaceDir = params.sandboxInfo?.containerWorkspaceDir?.trim();
140
+ const guidance = params.sandboxInfo?.enabled && containerWorkspaceDir
141
+ ? `For file tools, paths resolve against the cloud workspace mount ${hostWorkspaceDir}. For exec commands, use paths under ${containerWorkspaceDir} (or relative paths from there). Prefer relative paths whenever possible.`
142
+ : "This cloud workspace is mounted user storage. Prefer relative paths to keep file tools and shell commands aligned.";
143
+ return [
144
+ "## Workspace",
145
+ `Your cloud working directory is: ${hostWorkspaceDir}`,
146
+ guidance,
147
+ `User identity, memory, and agent state live under ${aimaxDir}, not inside the cloud workspace.`,
148
+ `Files such as AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, USER.md, HEARTBEAT.md, MEMORY.md, and the memory/ directory belong under ${aimaxDir}.`,
149
+ `Only create or update those files at their real .aimax paths. Never create cloud workspace copies like ${hostWorkspaceDir}/AGENTS.md or ${hostWorkspaceDir}/MEMORY.md unless the user explicitly asks for separate cloud documents.`,
150
+ "",
151
+ ].join("\n");
152
+ }
153
+ function buildSandboxSection(sandboxInfo) {
154
+ if (!sandboxInfo?.enabled)
155
+ return "";
156
+ const lines = [
157
+ "## Sandbox",
158
+ "You are running in a containerized cloud CLI runtime.",
159
+ ];
160
+ if (sandboxInfo.containerWorkspaceDir?.trim()) {
161
+ lines.push(`Container workdir: ${sandboxInfo.containerWorkspaceDir.trim()}`);
162
+ }
163
+ if (sandboxInfo.hostWorkspaceDir?.trim()) {
164
+ lines.push(`Host-mounted workspace: ${sandboxInfo.hostWorkspaceDir.trim()}`);
165
+ }
166
+ lines.push("");
167
+ return lines.join("\n");
168
+ }
169
+ function buildDateTimeSection(params) {
170
+ const parts = [];
171
+ if (params.timezone) {
172
+ parts.push(`Time zone: ${params.timezone}`);
173
+ }
174
+ if (params.currentDate) {
175
+ parts.push(`Current date: ${params.currentDate}`);
176
+ }
177
+ if (parts.length === 0)
178
+ return "";
179
+ return ["## Current Date & Time", ...parts, ""].join("\n");
180
+ }
181
+ function buildMessagingSection(params) {
182
+ if (params.isMinimal || !params.enabled)
183
+ return "";
184
+ const channels = (params.channels ?? []).map((channel) => channel.trim()).filter(Boolean);
185
+ const channelsLine = channels.length > 0 ? `Configured channels: ${channels.join(" | ")}` : "";
186
+ return [
187
+ "## Messaging",
188
+ "Reply in the current session for user-visible responses.",
189
+ "Use subagent tools for delegated long-running tasks and report concise progress back in this session.",
190
+ "Do not use shell/network commands to bypass the platform messaging pipeline.",
191
+ channelsLine,
192
+ "",
193
+ ]
194
+ .filter(Boolean)
195
+ .join("\n");
196
+ }
197
+ function buildDocsSection(params) {
198
+ if (params.isMinimal)
199
+ return "";
200
+ const docs = params.docs;
201
+ const lines = [
202
+ "## Documentation",
203
+ docs?.localPath ? `Cloud docs mount: ${docs.localPath}` : "",
204
+ docs?.webUrl ? `Docs mirror: ${docs.webUrl}` : "",
205
+ docs?.sourceUrl ? `Source: ${docs.sourceUrl}` : "",
206
+ "For AiMax behavior, configuration, and architecture questions, consult documentation first.",
207
+ "",
208
+ ].filter(Boolean);
209
+ if (lines.length <= 2)
210
+ return "";
211
+ return lines.join("\n");
212
+ }
213
+ function buildRuntimeSection(runtimeInfo) {
214
+ if (!runtimeInfo)
215
+ return "";
216
+ const parts = [
217
+ runtimeInfo.hostname ? `host=${runtimeInfo.hostname}` : "",
218
+ runtimeInfo.os ? `os=${runtimeInfo.os}` : "",
219
+ runtimeInfo.node ? `node=${runtimeInfo.node}` : "",
220
+ runtimeInfo.model ? `model=${runtimeInfo.model}` : "",
221
+ ].filter(Boolean);
222
+ if (parts.length === 0)
223
+ return "";
224
+ return ["## Runtime", `Runtime: ${parts.join(" | ")}`, ""].join("\n");
225
+ }
226
+ function buildSilentRepliesSection(params) {
227
+ if (params.isMinimal)
228
+ return "";
229
+ return [
230
+ "## Silent Replies",
231
+ "Do not send empty or filler replies.",
232
+ "If a tool already delivered the user-visible output, keep your final reply minimal and avoid duplication.",
233
+ "",
234
+ ].join("\n");
235
+ }
236
+ function buildHeartbeatsSection(params) {
237
+ if (params.isMinimal)
238
+ return "";
239
+ return [
240
+ "## Heartbeats",
241
+ `Heartbeat prompt: ${params.heartbeatPrompt?.trim() || DEFAULT_HEARTBEAT_PROMPT}`,
242
+ "If a user message matches the heartbeat prompt and nothing needs attention, reply exactly: HEARTBEAT_OK",
243
+ 'If something needs attention, do NOT include "HEARTBEAT_OK"; respond with the alert text instead.',
244
+ "",
245
+ ].join("\n");
246
+ }
247
+ function buildProjectContextSection(params) {
248
+ const contextFiles = params.contextFiles;
249
+ const warnings = (params.bootstrapWarnings ?? []).map((w) => w.trim()).filter(Boolean);
250
+ if (contextFiles.length === 0 && warnings.length === 0)
251
+ return "";
252
+ const hasSoulFile = contextFiles.some((f) => {
253
+ const baseName = f.path.split("/").pop()?.toLowerCase() ?? "";
254
+ return baseName === "soul.md";
255
+ });
256
+ const lines = ["# Project Context", ""];
257
+ if (warnings.length > 0) {
258
+ lines.push("⚠ Bootstrap truncation warning:");
259
+ for (const warning of warnings) {
260
+ lines.push(`- ${warning}`);
261
+ }
262
+ lines.push("");
263
+ }
264
+ if (contextFiles.length > 0) {
265
+ lines.push("The following project context files have been loaded:");
266
+ lines.push("These are source-of-truth cloud files at their shown paths. If you update them, use the exact path shown in the heading, especially for files under .aimax.");
267
+ }
268
+ if (hasSoulFile) {
269
+ lines.push("If SOUL.md is present, embody its persona and tone. Avoid stiff, generic replies; follow its guidance unless higher-priority instructions override it.");
270
+ }
271
+ lines.push("");
272
+ for (const file of contextFiles) {
273
+ lines.push(`## ${file.path}`, "", file.content, "");
274
+ }
275
+ return lines.join("\n");
276
+ }
277
+ function buildPriorSummarySection(summary) {
278
+ if (!summary?.trim())
279
+ return "";
280
+ return [
281
+ "## Prior Conversation Summary",
282
+ "The following is a summary of the conversation history that occurred before the current context window.",
283
+ "Use it to maintain continuity with earlier work.",
284
+ "",
285
+ summary.trim(),
286
+ "",
287
+ ].join("\n");
288
+ }
289
+ /**
290
+ * Builds the complete system prompt for the agent.
291
+ * Assembles all sections in the correct order.
292
+ */
293
+ export function buildSystemPrompt(params) {
294
+ const promptMode = params.promptMode ?? "full";
295
+ const isMinimal = promptMode === "minimal";
296
+ if (promptMode === "none") {
297
+ return "You are a personal assistant running inside AiMax.";
298
+ }
299
+ const toolNames = params.toolNames && params.toolNames.length > 0
300
+ ? params.toolNames
301
+ : [...CORE_TOOL_ORDER];
302
+ const skills = params.skills ?? [];
303
+ const contextFiles = params.contextFiles ?? [];
304
+ const sections = [
305
+ "You are a personal assistant running inside AiMax.\n",
306
+ buildToolingSection({ toolNames, toolSummaries: params.toolSummaries }),
307
+ buildToolCallStyleSection(isMinimal),
308
+ buildSafetySection(),
309
+ buildSkillsSection(skills),
310
+ buildMemoryWriteSection(),
311
+ buildMemorySection(params.memoryCitationsMode ?? "off"),
312
+ buildWorkspaceSection({ dataDir: params.dataDir, sandboxInfo: params.sandboxInfo }),
313
+ buildSandboxSection(params.sandboxInfo),
314
+ buildDateTimeSection({
315
+ currentDate: params.currentDate,
316
+ timezone: params.timezone,
317
+ }),
318
+ buildMessagingSection({
319
+ isMinimal,
320
+ enabled: params.messaging?.enabled,
321
+ channels: params.messaging?.channels,
322
+ }),
323
+ buildDocsSection({ isMinimal, docs: params.docs }),
324
+ buildSilentRepliesSection({ isMinimal }),
325
+ buildHeartbeatsSection({ isMinimal, heartbeatPrompt: params.heartbeatPrompt }),
326
+ buildRuntimeSection(params.runtimeInfo),
327
+ buildProjectContextSection({
328
+ contextFiles,
329
+ bootstrapWarnings: params.bootstrapWarnings,
330
+ }),
331
+ buildPriorSummarySection(params.priorConversationSummary),
332
+ ];
333
+ return sections.filter(Boolean).join("\n");
334
+ }
335
+ //# sourceMappingURL=builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/system-prompt/builder.ts"],"names":[],"mappings":"AAMA,mDAAmD;AACnD,MAAM,sBAAsB,GAA2B;IACrD,SAAS,EAAE,oBAAoB;IAC/B,UAAU,EAAE,2BAA2B;IACvC,SAAS,EAAE,6BAA6B;IACxC,QAAQ,EAAE,yBAAyB;IACnC,WAAW,EAAE,0BAA0B;IAC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S,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;QAClD,yBAAyB,CAAC,EAAE,SAAS,EAAE,CAAC;QACxC,sBAAsB,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC;QAC9E,mBAAmB,CAAC,MAAM,CAAC,WAAW,CAAC;QACvC,0BAA0B,CAAC;YACzB,YAAY;YACZ,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;SAC5C,CAAC;QACF,wBAAwB,CAAC,MAAM,CAAC,wBAAwB,CAAC;KAC1D,CAAC;IAEF,OAAO,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { AgentTool } from "@mariozechner/pi-agent-core";
2
+ type ApplyPatchSummary = {
3
+ added: string[];
4
+ modified: string[];
5
+ deleted: string[];
6
+ };
7
+ type ApplyPatchDetails = {
8
+ summary: ApplyPatchSummary;
9
+ };
10
+ declare const applyPatchSchema: import("@sinclair/typebox").TObject<{
11
+ input: import("@sinclair/typebox").TString;
12
+ }>;
13
+ export declare function createApplyPatchTool(workspaceDir: string): AgentTool<typeof applyPatchSchema, ApplyPatchDetails>;
14
+ export {};
15
+ //# sourceMappingURL=apply-patch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-patch.d.ts","sourceRoot":"","sources":["../../src/tools/apply-patch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,6BAA6B,CAAC;AAuC9E,KAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,iBAAiB,CAAC;CAC5B,CAAC;AAEF,QAAA,MAAM,gBAAgB;;EAIpB,CAAC;AAoCH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,GACnB,SAAS,CAAC,OAAO,gBAAgB,EAAE,iBAAiB,CAAC,CA+EvD"}