agency-lang 0.16.0 → 0.17.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 (461) hide show
  1. package/dist/lib/agents/agency-agent/agent.js +3 -2
  2. package/dist/lib/agents/agency-agent/brains/brain.agency +1 -1
  3. package/dist/lib/agents/agency-agent/brains/brain.js +3 -2
  4. package/dist/lib/agents/agency-agent/brains/coordinator/README.md +5 -3
  5. package/dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency +9 -3
  6. package/dist/lib/agents/agency-agent/brains/coordinator/coordinator.js +97 -14
  7. package/dist/lib/agents/agency-agent/brains/coordinator/prompts/codeSample.js +3 -2
  8. package/dist/lib/agents/agency-agent/brains/coordinator/prompts/main-large.md +9 -1
  9. package/dist/lib/agents/agency-agent/brains/coordinator/prompts/main-small.md +5 -0
  10. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/brainstorm.js +3 -2
  11. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/code.js +3 -2
  12. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/explorer.js +3 -2
  13. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/oracle.js +3 -2
  14. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/research.js +3 -2
  15. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/review.js +3 -2
  16. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/rewrite.agency +41 -0
  17. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/rewrite.js +600 -0
  18. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/supervisor.js +3 -2
  19. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/writing.agency +24 -0
  20. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/writing.js +392 -0
  21. package/dist/lib/agents/agency-agent/brains/coordinator/tests/agentTurn.js +3 -2
  22. package/dist/lib/agents/agency-agent/brains/coordinator/tests/attachmentsTurn.js +3 -2
  23. package/dist/lib/agents/agency-agent/brains/coordinator/tests/brainstorm.js +3 -2
  24. package/dist/lib/agents/agency-agent/brains/coordinator/tests/supervisor.js +3 -2
  25. package/dist/lib/agents/agency-agent/brains/coordinator/tests/toolWiring.js +3 -2
  26. package/dist/lib/agents/agency-agent/brains/registry.js +3 -2
  27. package/dist/lib/agents/agency-agent/brains/simple/README.md +1 -1
  28. package/dist/lib/agents/agency-agent/brains/simple/simple.js +3 -2
  29. package/dist/lib/agents/agency-agent/brains/simple/tests/simpleTurn.js +3 -2
  30. package/dist/lib/agents/agency-agent/images/images.js +3 -2
  31. package/dist/lib/agents/agency-agent/lib/agentName.js +3 -2
  32. package/dist/lib/agents/agency-agent/lib/args.js +3 -2
  33. package/dist/lib/agents/agency-agent/lib/attachments.js +3 -2
  34. package/dist/lib/agents/agency-agent/lib/budget.js +3 -2
  35. package/dist/lib/agents/agency-agent/lib/capabilities.js +3 -2
  36. package/dist/lib/agents/agency-agent/lib/capabilitiesUi.js +3 -2
  37. package/dist/lib/agents/agency-agent/lib/commandPalette.js +3 -2
  38. package/dist/lib/agents/agency-agent/lib/config.agency +2 -1
  39. package/dist/lib/agents/agency-agent/lib/config.js +15 -6
  40. package/dist/lib/agents/agency-agent/lib/grounding.js +3 -2
  41. package/dist/lib/agents/agency-agent/lib/header.js +3 -2
  42. package/dist/lib/agents/agency-agent/lib/images.js +3 -2
  43. package/dist/lib/agents/agency-agent/lib/mcp.js +3 -2
  44. package/dist/lib/agents/agency-agent/lib/modelFilters.js +3 -2
  45. package/dist/lib/agents/agency-agent/lib/models.agency +10 -4
  46. package/dist/lib/agents/agency-agent/lib/models.js +62 -25
  47. package/dist/lib/agents/agency-agent/lib/policy.js +3 -2
  48. package/dist/lib/agents/agency-agent/lib/repl.js +3 -2
  49. package/dist/lib/agents/agency-agent/lib/resolution.js +3 -2
  50. package/dist/lib/agents/agency-agent/lib/search.agency +17 -4
  51. package/dist/lib/agents/agency-agent/lib/search.js +194 -95
  52. package/dist/lib/agents/agency-agent/lib/session.js +3 -2
  53. package/dist/lib/agents/agency-agent/lib/settings.js +3 -2
  54. package/dist/lib/agents/agency-agent/lib/slots.js +3 -2
  55. package/dist/lib/agents/agency-agent/lib/trace.agency +2 -1
  56. package/dist/lib/agents/agency-agent/lib/trace.js +14 -7
  57. package/dist/lib/agents/agency-agent/lib/turn.agency +1 -1
  58. package/dist/lib/agents/agency-agent/lib/turn.js +3 -2
  59. package/dist/lib/agents/agency-agent/lib/utils/renderLLMCallResponse.js +3 -2
  60. package/dist/lib/agents/agency-agent/lib/utils.js +3 -2
  61. package/dist/lib/agents/agency-agent/shared.agency +4 -1
  62. package/dist/lib/agents/agency-agent/shared.js +20 -17
  63. package/dist/lib/agents/agency-agent/tests/agentDir.js +3 -2
  64. package/dist/lib/agents/agency-agent/tests/agentName.js +3 -2
  65. package/dist/lib/agents/agency-agent/tests/attachments.js +3 -2
  66. package/dist/lib/agents/agency-agent/tests/capabilities.js +3 -2
  67. package/dist/lib/agents/agency-agent/tests/execPolicy.js +3 -2
  68. package/dist/lib/agents/agency-agent/tests/gitPolicy.js +3 -2
  69. package/dist/lib/agents/agency-agent/tests/imageTool.js +3 -2
  70. package/dist/lib/agents/agency-agent/tests/mcpGating.js +3 -2
  71. package/dist/lib/agents/agency-agent/tests/memoryWiring.js +3 -2
  72. package/dist/lib/agents/agency-agent/tests/modelFilters.js +3 -2
  73. package/dist/lib/agents/agency-agent/tests/models.js +3 -2
  74. package/dist/lib/agents/agency-agent/tests/oneShotRounds.js +3 -2
  75. package/dist/lib/agents/agency-agent/tests/readPolicy.js +3 -2
  76. package/dist/lib/agents/agency-agent/tests/registry.agency +1 -1
  77. package/dist/lib/agents/agency-agent/tests/registry.js +6 -11
  78. package/dist/lib/agents/agency-agent/tests/registry.test.json +1 -1
  79. package/dist/lib/agents/agency-agent/tests/resolution.js +3 -2
  80. package/dist/lib/agents/agency-agent/tests/search.js +3 -2
  81. package/dist/lib/agents/agency-agent/tests/settings.js +3 -2
  82. package/dist/lib/agents/agency-agent/tests/slots.js +3 -2
  83. package/dist/lib/agents/agency-agent/tests/stubBrains.js +3 -2
  84. package/dist/lib/agents/agency-agent/tests/threadText.js +3 -2
  85. package/dist/lib/agents/agency-agent/tests/turn.js +3 -2
  86. package/dist/lib/agents/agency-agent/tests/turnFailure.js +3 -2
  87. package/dist/lib/agents/eval/goalJudge.js +3 -2
  88. package/dist/lib/agents/eval/judge.js +3 -2
  89. package/dist/lib/agents/eval/judgePairwise.js +3 -2
  90. package/dist/lib/agents/eval/rubricJudge.agency +33 -0
  91. package/dist/lib/agents/eval/rubricJudge.js +371 -0
  92. package/dist/lib/agents/optimize/gepaReflect.agency +9 -3
  93. package/dist/lib/agents/optimize/gepaReflect.js +16 -8
  94. package/dist/lib/agents/optimize/mutatePrompt.agency +1 -1
  95. package/dist/lib/agents/optimize/mutatePrompt.js +4 -3
  96. package/dist/lib/agents/policy/agent.js +3 -2
  97. package/dist/lib/agents/review/agent.js +3 -2
  98. package/dist/lib/backends/agencyGenerator.js +18 -20
  99. package/dist/lib/backends/typescriptBuilder.d.ts +16 -1
  100. package/dist/lib/backends/typescriptBuilder.js +83 -34
  101. package/dist/lib/cli/commandLine.d.ts +1 -1
  102. package/dist/lib/cli/coverage.js +1 -1
  103. package/dist/lib/cli/doc.d.ts +7 -5
  104. package/dist/lib/cli/doc.js +64 -32
  105. package/dist/lib/cli/docLedger.d.ts +7 -2
  106. package/dist/lib/cli/docLedger.js +6 -2
  107. package/dist/lib/cli/eval/formatGrade.d.ts +2 -0
  108. package/dist/lib/cli/eval/formatGrade.js +12 -2
  109. package/dist/lib/cli/eval/grade.d.ts +28 -8
  110. package/dist/lib/cli/eval/grade.js +52 -29
  111. package/dist/lib/cli/eval/optimize.d.ts +4 -1
  112. package/dist/lib/cli/eval/optimize.js +9 -5
  113. package/dist/lib/cli/eval/run.d.ts +0 -5
  114. package/dist/lib/cli/eval/run.js +0 -27
  115. package/dist/lib/cli/eval/upload.js +6 -2
  116. package/dist/lib/cli/precompile.js +8 -1
  117. package/dist/lib/cli/remote/commands/call.d.ts +2 -0
  118. package/dist/lib/cli/remote/commands/call.js +3 -8
  119. package/dist/lib/cli/remote/commands/deploy.js +1 -15
  120. package/dist/lib/cli/remote/commands/logsMode.js +1 -1
  121. package/dist/lib/cli/remote/commands/ls.d.ts +4 -3
  122. package/dist/lib/cli/remote/commands/ls.js +8 -30
  123. package/dist/lib/cli/remote/commands/open.d.ts +5 -1
  124. package/dist/lib/cli/remote/commands/open.js +5 -8
  125. package/dist/lib/cli/remote/commands/util.d.ts +30 -12
  126. package/dist/lib/cli/remote/commands/util.js +60 -39
  127. package/dist/lib/cli/remote/render.d.ts +2 -3
  128. package/dist/lib/cli/remote/render.js +4 -11
  129. package/dist/lib/cli/schedule/backends/pinnedActions.js +3 -3
  130. package/dist/lib/cli/schedule/remote.js +2 -2
  131. package/dist/lib/cli/statelog/serveUrl.d.ts +13 -2
  132. package/dist/lib/cli/statelog/serveUrl.js +7 -1
  133. package/dist/lib/cli/statelog/statelogRequest.d.ts +5 -2
  134. package/dist/lib/cli/statelog/statelogRequest.js +22 -5
  135. package/dist/lib/cli/test.js +17 -6
  136. package/dist/lib/cli/util.d.ts +2 -0
  137. package/dist/lib/cli/util.js +10 -2
  138. package/dist/lib/compiler/depFingerprint.js +1 -1
  139. package/dist/lib/compiler/splice/calleeName.d.ts +3 -0
  140. package/dist/lib/compiler/splice/calleeName.js +7 -0
  141. package/dist/lib/compiler/splice/runGenerator.js +5 -5
  142. package/dist/lib/compiler/typecheck.d.ts +18 -3
  143. package/dist/lib/compiler/typecheck.js +43 -12
  144. package/dist/lib/config.d.ts +49 -14
  145. package/dist/lib/config.js +25 -4
  146. package/dist/lib/eval/batchStatistics.d.ts +14 -0
  147. package/dist/lib/eval/batchStatistics.js +21 -1
  148. package/dist/lib/eval/grading/agencyRunner.d.ts +10 -2
  149. package/dist/lib/eval/grading/agencyRunner.js +19 -5
  150. package/dist/lib/eval/grading/agencyTestGrader.d.ts +2 -0
  151. package/dist/lib/eval/grading/agencyTestGrader.js +4 -3
  152. package/dist/lib/eval/grading/baseGrader.d.ts +0 -2
  153. package/dist/lib/eval/grading/baseGrader.js +0 -11
  154. package/dist/lib/eval/grading/functionGrader.d.ts +38 -17
  155. package/dist/lib/eval/grading/functionGrader.js +16 -6
  156. package/dist/lib/eval/grading/gradeRun.d.ts +22 -9
  157. package/dist/lib/eval/grading/gradeRun.js +106 -34
  158. package/dist/lib/eval/grading/gradeSuite.d.ts +4 -2
  159. package/dist/lib/eval/grading/gradeSuite.js +5 -4
  160. package/dist/lib/eval/grading/graderFilesSnapshot.d.ts +10 -0
  161. package/dist/lib/eval/grading/graderFilesSnapshot.js +44 -0
  162. package/dist/lib/eval/grading/harnessSnapshot.d.ts +1 -1
  163. package/dist/lib/eval/grading/harnessSnapshot.js +2 -1
  164. package/dist/lib/eval/grading/rubricJudgeFile.d.ts +10 -0
  165. package/dist/lib/eval/grading/rubricJudgeFile.js +14 -0
  166. package/dist/lib/eval/grading/types.d.ts +5 -10
  167. package/dist/lib/eval/grading/workdirFile.d.ts +3 -0
  168. package/dist/lib/eval/grading/workdirFile.js +18 -0
  169. package/dist/lib/eval/loadInputs.js +23 -0
  170. package/dist/lib/eval/public.d.ts +3 -0
  171. package/dist/lib/eval/public.js +2 -0
  172. package/dist/lib/eval/run/batchBudget.d.ts +19 -0
  173. package/dist/lib/eval/run/batchBudget.js +37 -0
  174. package/dist/lib/eval/run/childSupervisor.d.ts +31 -0
  175. package/dist/lib/eval/run/childSupervisor.js +46 -0
  176. package/dist/lib/eval/run/runSuite.d.ts +1 -1
  177. package/dist/lib/eval/run/runSuite.js +72 -40
  178. package/dist/lib/eval/run/spawnRunner.js +2 -36
  179. package/dist/lib/eval/run/subprocess.js +5 -9
  180. package/dist/lib/eval/runDirectoryFixture.d.ts +4 -0
  181. package/dist/lib/eval/runDirectoryFixture.js +2 -1
  182. package/dist/lib/eval/runTypes.d.ts +20 -4
  183. package/dist/lib/ir/tsIR.d.ts +1 -1
  184. package/dist/lib/linter/registry.d.ts +1 -1
  185. package/dist/lib/linter/registry.js +1 -1
  186. package/dist/lib/lowering/comprehensionDesugar.js +1 -1
  187. package/dist/lib/lowering/patternLowering.js +24 -1
  188. package/dist/lib/optimize/baseOptimizer.d.ts +23 -10
  189. package/dist/lib/optimize/baseOptimizer.js +111 -29
  190. package/dist/lib/optimize/constraint.js +1 -1
  191. package/dist/lib/optimize/gepaReflect.d.ts +2 -1
  192. package/dist/lib/optimize/gepaReflect.js +3 -3
  193. package/dist/lib/optimize/mutator.d.ts +15 -2
  194. package/dist/lib/optimize/mutator.js +27 -8
  195. package/dist/lib/optimize/optimizer.d.ts +15 -2
  196. package/dist/lib/optimize/optimizers/gepa.d.ts +1 -1
  197. package/dist/lib/optimize/optimizers/gepa.js +10 -4
  198. package/dist/lib/optimize/optimizers/greedyReflective.js +6 -1
  199. package/dist/lib/optimize/reflectionFeedback.js +9 -3
  200. package/dist/lib/optimize/report.d.ts +3 -1
  201. package/dist/lib/optimize/report.js +11 -1
  202. package/dist/lib/optimize/reporter.js +3 -0
  203. package/dist/lib/optimize/sourceMutator.d.ts +6 -0
  204. package/dist/lib/optimize/sourceMutator.js +50 -38
  205. package/dist/lib/optimize/targets.d.ts +22 -7
  206. package/dist/lib/optimize/targets.js +33 -13
  207. package/dist/lib/optimize/testUtils.d.ts +1 -1
  208. package/dist/lib/optimize/testUtils.js +2 -2
  209. package/dist/lib/optimize/types.d.ts +19 -0
  210. package/dist/lib/optimize/validation.d.ts +23 -7
  211. package/dist/lib/optimize/validation.js +60 -43
  212. package/dist/lib/parsers/parsers.js +48 -17
  213. package/dist/lib/preprocessors/expandSplices.js +22 -7
  214. package/dist/lib/preprocessors/hoistCalls.js +6 -1
  215. package/dist/lib/preprocessors/parallelDesugar.js +1 -1
  216. package/dist/lib/preprocessors/typescriptPreprocessor.d.ts +9 -1
  217. package/dist/lib/preprocessors/typescriptPreprocessor.js +26 -2
  218. package/dist/lib/runDirectory/annotations.d.ts +9 -3
  219. package/dist/lib/runDirectory/annotations.js +5 -0
  220. package/dist/lib/runDirectory/mutations.js +6 -3
  221. package/dist/lib/runsExplorer/csv.js +3 -0
  222. package/dist/lib/runsExplorer/rows.d.ts +25 -0
  223. package/dist/lib/runsExplorer/rows.js +38 -0
  224. package/dist/lib/runsExplorer/run.js +15 -1
  225. package/dist/lib/runsExplorer/views/explorerView.d.ts +14 -1
  226. package/dist/lib/runsExplorer/views/gradersTableView.d.ts +30 -0
  227. package/dist/lib/runsExplorer/views/gradersTableView.js +189 -0
  228. package/dist/lib/runsExplorer/views/rowFormat.d.ts +3 -0
  229. package/dist/lib/runsExplorer/views/rowFormat.js +9 -0
  230. package/dist/lib/runsExplorer/views/runsTableView.d.ts +4 -1
  231. package/dist/lib/runsExplorer/views/runsTableView.js +34 -9
  232. package/dist/lib/runsExplorer/views/testsTableView.js +8 -2
  233. package/dist/lib/runsExplorer/views/verdictScreen.d.ts +33 -0
  234. package/dist/lib/runsExplorer/views/verdictScreen.js +150 -0
  235. package/dist/lib/runtime/abortBoundary.d.ts +34 -0
  236. package/dist/lib/runtime/abortBoundary.js +42 -0
  237. package/dist/lib/runtime/abortedResult.d.ts +5 -0
  238. package/dist/lib/runtime/abortedResult.js +18 -5
  239. package/dist/lib/runtime/asyncContext.d.ts +1 -1
  240. package/dist/lib/runtime/asyncContext.js +1 -1
  241. package/dist/lib/runtime/builtinPolicies.js +4 -1
  242. package/dist/lib/runtime/callbackForwarding.d.ts +1 -1
  243. package/dist/lib/runtime/callbackForwarding.js +1 -1
  244. package/dist/lib/runtime/eq.d.ts +1 -1
  245. package/dist/lib/runtime/eq.js +1 -1
  246. package/dist/lib/runtime/errors.d.ts +5 -0
  247. package/dist/lib/runtime/errors.js +19 -5
  248. package/dist/lib/runtime/interrupts.js +2 -0
  249. package/dist/lib/runtime/ipc.d.ts +3 -2
  250. package/dist/lib/runtime/ipc.js +5 -4
  251. package/dist/lib/runtime/llmRetry.d.ts +1 -1
  252. package/dist/lib/runtime/llmRetry.js +17 -2
  253. package/dist/lib/runtime/memory/manager.js +2 -1
  254. package/dist/lib/runtime/memory/registry.d.ts +1 -1
  255. package/dist/lib/runtime/memory/registry.js +1 -1
  256. package/dist/lib/runtime/memory/types.d.ts +1 -1
  257. package/dist/lib/runtime/nn.d.ts +1 -1
  258. package/dist/lib/runtime/nn.js +1 -1
  259. package/dist/lib/runtime/node.js +7 -0
  260. package/dist/lib/runtime/prompt.d.ts +4 -3
  261. package/dist/lib/runtime/prompt.js +12 -5
  262. package/dist/lib/runtime/replyAttachments.d.ts +1 -1
  263. package/dist/lib/runtime/rewind.js +2 -0
  264. package/dist/lib/runtime/simpleOpenAIClient.js +2 -1
  265. package/dist/lib/runtime/toolLoopGuards.js +1 -1
  266. package/dist/lib/statelogClient.d.ts +3 -2
  267. package/dist/lib/statelogClient.js +3 -2
  268. package/dist/lib/stdlib/agency.d.ts +7 -1
  269. package/dist/lib/stdlib/agency.js +77 -13
  270. package/dist/lib/stdlib/llm.d.ts +16 -18
  271. package/dist/lib/stdlib/llm.js +46 -35
  272. package/dist/lib/stdlib/skills.d.ts +2 -0
  273. package/dist/lib/stdlib/skills.js +5 -1
  274. package/dist/lib/templates/cli/optimizeReport.d.ts +1 -1
  275. package/dist/lib/templates/cli/optimizeReport.js +2 -2
  276. package/dist/lib/tui/table.js +1 -1
  277. package/dist/lib/typeChecker/assignability.js +1 -1
  278. package/dist/lib/typeChecker/diagnosticExplanations.js +7 -0
  279. package/dist/lib/typeChecker/diagnostics.d.ts +5 -0
  280. package/dist/lib/typeChecker/diagnostics.js +5 -0
  281. package/dist/lib/typeChecker/index.js +1 -1
  282. package/dist/lib/typeChecker/nameReferences.d.ts +3 -2
  283. package/dist/lib/typeChecker/nameReferences.js +6 -1
  284. package/dist/lib/typeChecker/narrowing.js +1 -1
  285. package/dist/lib/typeChecker/pathSegments.js +1 -1
  286. package/dist/lib/typeChecker/synthesizer.js +2 -0
  287. package/dist/lib/types/binop.d.ts +3 -1
  288. package/dist/lib/types/binop.js +3 -0
  289. package/dist/lib/types/codeLiteral.d.ts +1 -1
  290. package/dist/lib/types/effectDeclaration.d.ts +2 -0
  291. package/dist/lib/types/typeHints.d.ts +1 -1
  292. package/dist/lib/utils/bodySlots.js +1 -1
  293. package/dist/lib/utils/hiddenTag.d.ts +5 -0
  294. package/dist/lib/utils/hiddenTag.js +6 -0
  295. package/dist/lib/utils/identifierSlots.d.ts +2 -2
  296. package/dist/lib/utils/parallelMap.d.ts +6 -0
  297. package/dist/lib/utils/parallelMap.js +20 -0
  298. package/dist/scripts/agency.js +52 -35
  299. package/package.json +2 -2
  300. package/stdlib/agency/eval.js +3 -2
  301. package/stdlib/agency/local.js +3 -2
  302. package/stdlib/agency.agency +12 -9
  303. package/stdlib/agency.js +24 -9
  304. package/stdlib/agent.js +3 -2
  305. package/stdlib/agents/agency/coding.agency +168 -10
  306. package/stdlib/agents/agency/coding.js +497 -26
  307. package/stdlib/agents/agency/expert.js +3 -2
  308. package/stdlib/agents/agency/researcher.js +3 -2
  309. package/stdlib/agents/agency/review.agency +154 -6
  310. package/stdlib/agents/agency/review.js +406 -17
  311. package/stdlib/agents/agency/verifier.js +3 -2
  312. package/stdlib/agents/coding.agency +1 -1
  313. package/stdlib/agents/coding.js +4 -3
  314. package/stdlib/agents/composable/promptRewriter.js +3 -2
  315. package/stdlib/agents/composable/researcher.js +3 -2
  316. package/stdlib/agents/composable/utils.js +3 -2
  317. package/stdlib/agents/data.agency +1 -1
  318. package/stdlib/agents/data.js +4 -3
  319. package/stdlib/agents/expert.agency +1 -1
  320. package/stdlib/agents/expert.js +4 -3
  321. package/stdlib/agents/explorer.agency +1 -1
  322. package/stdlib/agents/explorer.js +4 -3
  323. package/stdlib/agents/lib/expertGuidance.js +3 -2
  324. package/stdlib/agents/lib/feedback.js +3 -2
  325. package/stdlib/agents/lib/search.agency +11 -7
  326. package/stdlib/agents/lib/search.js +58 -37
  327. package/stdlib/agents/lib/shared.agency +24 -2
  328. package/stdlib/agents/lib/shared.js +238 -14
  329. package/stdlib/agents/lib/toolkits.js +3 -2
  330. package/stdlib/agents/oracle.agency +1 -1
  331. package/stdlib/agents/oracle.js +4 -3
  332. package/stdlib/agents/planner.js +3 -2
  333. package/stdlib/agents/researcher.agency +89 -10
  334. package/stdlib/agents/researcher.js +601 -13
  335. package/stdlib/agents/review.agency +1 -1
  336. package/stdlib/agents/review.js +4 -3
  337. package/stdlib/agents/typescript/review.agency +234 -0
  338. package/stdlib/agents/typescript/review.js +1444 -0
  339. package/stdlib/agents/verifier.js +3 -2
  340. package/stdlib/agents/writing/review.agency +554 -0
  341. package/stdlib/agents/writing/review.js +3267 -0
  342. package/stdlib/agents/writing/rewrite.agency +177 -0
  343. package/stdlib/agents/writing/rewrite.js +1238 -0
  344. package/stdlib/args.js +3 -2
  345. package/stdlib/array.js +3 -2
  346. package/stdlib/auth/keyring.js +3 -2
  347. package/stdlib/auth/oauth.agency +4 -2
  348. package/stdlib/auth/oauth.js +4 -3
  349. package/stdlib/aws/s3.js +3 -2
  350. package/stdlib/calendar.agency +3 -1
  351. package/stdlib/calendar.js +4 -3
  352. package/stdlib/capabilities.js +3 -2
  353. package/stdlib/clipboard.js +3 -2
  354. package/stdlib/concurrency.js +3 -2
  355. package/stdlib/data/connector.agency +1 -1
  356. package/stdlib/data/connector.js +3 -2
  357. package/stdlib/data/finance/dbnomics.js +3 -2
  358. package/stdlib/data/finance/edgar.agency +2 -1
  359. package/stdlib/data/finance/edgar.js +14 -7
  360. package/stdlib/data/finance/fred.agency +9 -4
  361. package/stdlib/data/finance/fred.js +36 -31
  362. package/stdlib/data/news/gdelt.js +3 -2
  363. package/stdlib/data/people/littlesis.js +3 -2
  364. package/stdlib/data/social/bluesky.js +3 -2
  365. package/stdlib/data/tech/hackernews.js +3 -2
  366. package/stdlib/data/tech/yc.js +3 -2
  367. package/stdlib/data/usaspending.js +3 -2
  368. package/stdlib/data/wikidata.agency +2 -1
  369. package/stdlib/data/wikidata.js +14 -7
  370. package/stdlib/date.js +3 -2
  371. package/stdlib/docs/cli/doc.md +38 -1
  372. package/stdlib/docs/cli/eval.md +40 -29
  373. package/stdlib/docs/cli/optimize.md +7 -3
  374. package/stdlib/docs/diagnostics/index.md +1 -0
  375. package/stdlib/docs/diagnostics/templates.md +14 -0
  376. package/stdlib/docs/guide/agency-config-file.md +1 -1
  377. package/stdlib/docs/guide/graders.md +8 -9
  378. package/stdlib/docs/guide/handlers.md +19 -3
  379. package/stdlib/docs/guide/memory.md +1 -1
  380. package/stdlib/docs/stdlib/agency.md +47 -40
  381. package/stdlib/docs/stdlib/agent.md +1 -3
  382. package/stdlib/docs/stdlib/agents/agency/coding.md +7 -3
  383. package/stdlib/docs/stdlib/agents/agency/review.md +6 -3
  384. package/stdlib/docs/stdlib/agents/lib/search.md +15 -9
  385. package/stdlib/docs/stdlib/agents/lib/shared.md +30 -5
  386. package/stdlib/docs/stdlib/agents/planner.md +2 -4
  387. package/stdlib/docs/stdlib/agents/researcher.md +26 -2
  388. package/stdlib/docs/stdlib/agents/typescript/review.md +108 -0
  389. package/stdlib/docs/stdlib/agents/writing/review.md +115 -0
  390. package/stdlib/docs/stdlib/agents/writing/rewrite.md +82 -0
  391. package/stdlib/docs/stdlib/auth/oauth.md +11 -9
  392. package/stdlib/docs/stdlib/calendar.md +14 -14
  393. package/stdlib/docs/stdlib/data/connector.md +1 -1
  394. package/stdlib/docs/stdlib/data/finance/edgar.md +2 -2
  395. package/stdlib/docs/stdlib/data/finance/fred.md +6 -6
  396. package/stdlib/docs/stdlib/data/wikidata.md +5 -5
  397. package/stdlib/docs/stdlib/fs.md +0 -2
  398. package/stdlib/docs/stdlib/llm.md +2 -0
  399. package/stdlib/docs/stdlib/messaging/email.md +0 -2
  400. package/stdlib/docs/stdlib/messaging/imessage.md +0 -2
  401. package/stdlib/docs/stdlib/messaging/sms.md +0 -2
  402. package/stdlib/docs/stdlib/policy.md +32 -30
  403. package/stdlib/docs/stdlib/shell.md +1 -1
  404. package/stdlib/docs/stdlib/skills.md +16 -5
  405. package/stdlib/docs/stdlib/system.md +31 -16
  406. package/stdlib/docs/stdlib/toolbox.md +270 -0
  407. package/stdlib/docs/stdlib/weather.md +0 -2
  408. package/stdlib/docs/stdlib/web/browser.md +0 -2
  409. package/stdlib/docs/stdlib/web/search.md +0 -2
  410. package/stdlib/docs/stdlib/wikipedia.md +2 -4
  411. package/stdlib/fs.js +3 -2
  412. package/stdlib/git.js +3 -2
  413. package/stdlib/http.js +3 -2
  414. package/stdlib/image.js +3 -2
  415. package/stdlib/index.js +3 -2
  416. package/stdlib/llm.agency +1 -1
  417. package/stdlib/llm.js +19 -16
  418. package/stdlib/markdown.js +3 -2
  419. package/stdlib/math.js +3 -2
  420. package/stdlib/mcp.js +3 -2
  421. package/stdlib/memory.js +3 -2
  422. package/stdlib/messaging/email.js +3 -2
  423. package/stdlib/messaging/imessage.js +3 -2
  424. package/stdlib/messaging/sms.js +3 -2
  425. package/stdlib/notes/apple.js +3 -2
  426. package/stdlib/object.js +3 -2
  427. package/stdlib/path.js +3 -2
  428. package/stdlib/policy.agency +5 -3
  429. package/stdlib/policy.js +4 -3
  430. package/stdlib/safeBash/actions.js +3 -2
  431. package/stdlib/safeBash.js +3 -2
  432. package/stdlib/shell.js +3 -2
  433. package/stdlib/skills.agency +9 -1
  434. package/stdlib/skills.js +112 -4
  435. package/stdlib/speech.js +3 -2
  436. package/stdlib/statelog.js +3 -2
  437. package/stdlib/strategy.js +3 -2
  438. package/stdlib/supervise.js +3 -2
  439. package/stdlib/syntax.js +3 -2
  440. package/stdlib/system.agency +25 -4
  441. package/stdlib/system.js +199 -8
  442. package/stdlib/tag.js +3 -2
  443. package/stdlib/thread.js +3 -2
  444. package/stdlib/toolbox.agency +990 -0
  445. package/stdlib/toolbox.js +8320 -0
  446. package/stdlib/ui/chart.js +3 -2
  447. package/stdlib/ui/cli.js +3 -2
  448. package/stdlib/ui/layout.js +3 -2
  449. package/stdlib/ui/table.js +3 -2
  450. package/stdlib/ui.js +3 -2
  451. package/stdlib/validation.js +3 -2
  452. package/stdlib/weather.js +3 -2
  453. package/stdlib/web/browser.js +3 -2
  454. package/stdlib/web/search.js +3 -2
  455. package/stdlib/wikipedia.js +3 -2
  456. package/dist/lib/cli/eval/graders.d.ts +0 -17
  457. package/dist/lib/cli/eval/graders.js +0 -40
  458. package/dist/lib/cli/remote/binding.d.ts +0 -10
  459. package/dist/lib/cli/remote/binding.js +0 -48
  460. package/dist/lib/cli/remote/commands/link.d.ts +0 -4
  461. package/dist/lib/cli/remote/commands/link.js +0 -22
@@ -102,14 +102,15 @@ const __globalCtx = new RuntimeContext({
102
102
  liteLlm: __process.env["LITELLM_BASE_URL"] || "",
103
103
  openAiCompat: __process.env["OPENAI_COMPAT_BASE_URL"] || ""
104
104
  },
105
- model: "gpt-4o-mini",
105
+ model: "gpt-5-mini",
106
106
  logLevel: "warn",
107
107
  statelog: {
108
108
  host: "https://statelog.adit.io",
109
109
  projectId: "smoltalk",
110
110
  apiKey: __process.env["STATELOG_SMOLTALK_API_KEY"] || "",
111
111
  traceId: nanoid()
112
- }
112
+ },
113
+ provider: "openai-responses"
113
114
  },
114
115
  dirname: __dirname,
115
116
  logLevel: "info",
@@ -1,6 +1,6 @@
1
1
  /** @module
2
2
  @summary The brain record: what the harness needs from the thing that
3
- answers a turn. See docs/dev/agent-brains.md.
3
+ answers a turn. See docs/dev/agents/agent-brains.md.
4
4
  */
5
5
  import { Attachment } from "std::thread"
6
6
 
@@ -55,14 +55,15 @@ const __globalCtx = new RuntimeContext({
55
55
  liteLlm: __process.env["LITELLM_BASE_URL"] || "",
56
56
  openAiCompat: __process.env["OPENAI_COMPAT_BASE_URL"] || ""
57
57
  },
58
- model: "gpt-4o-mini",
58
+ model: "gpt-5-mini",
59
59
  logLevel: "warn",
60
60
  statelog: {
61
61
  host: "https://statelog.adit.io",
62
62
  projectId: "smoltalk",
63
63
  apiKey: __process.env["STATELOG_SMOLTALK_API_KEY"] || "",
64
64
  traceId: nanoid()
65
- }
65
+ },
66
+ provider: "openai-responses"
66
67
  },
67
68
  dirname: __dirname,
68
69
  logLevel: "info",
@@ -4,7 +4,7 @@ This directory is one *brain* of the Agency agent: the part that answers a
4
4
  turn. The harness around it (`agent.agency` and `lib/`) owns the command
5
5
  line, the REPL, the approval policy handler, the per-turn budget guard,
6
6
  slash-command expansion, and attachment detection. None of that lives here.
7
- `docs/dev/agent-brains.md` explains the split; this file explains how this
7
+ `docs/dev/agents/agent-brains.md` explains the split; this file explains how this
8
8
  particular brain is put together.
9
9
 
10
10
  Run it with `agency agent` (it is the default) or `agency agent --brain coordinator`.
@@ -32,7 +32,7 @@ tests/ Agency execution tests for this brain
32
32
  `coordinatorBrain()` returns the record the registry hands to the harness:
33
33
 
34
34
  - `name: "coordinator"`, the `--brain` value.
35
- - `startTargets`: `code`, `research`, `oracle`, `explorer`, `review`. These
35
+ - `startTargets`: `code`, `research`, `oracle`, `explorer`, `review`, `writing`. These
36
36
  are the names `--agent <name>` may route the starting prompt to directly.
37
37
  `--agent main` (or no flag) goes through the coordinator.
38
38
  - `init(context)`: runs once per session, inside the harness policy handler.
@@ -68,6 +68,8 @@ and an inner `with approve` cannot get past an outer policy.
68
68
  | `oracleAgent` | Deep-reasoning consult on the slow model slot; repeated consults share a session. | `std::agents/oracle` |
69
69
  | `explorerAgent` | Surveys a codebase or topic on the slow model slot; shared session. | `std::agents/explorer` |
70
70
  | `reviewAgent` | Reviews Agency code: snippets from a message, or the files the code agent just wrote. | `std::agents/agency/review` |
71
+ | `writingAgent` | Reviews prose for readability; reports findings, or applies them when asked. | `std::agents/writing/review` |
72
+ | `rewriteAgent` | Rewrites prose from the reviewer's findings and returns the new text. | `std::agents/writing/rewrite` |
71
73
 
72
74
  Most specialists are thin wrappers that add what is the agent's business
73
75
  (the user's chosen model slots, a shared session) to an agent that ships in
@@ -97,4 +99,4 @@ not compile correctly today.
97
99
  A new specialist is a function in `subagents/`, added to `mainAgentTools`
98
100
  and, if it should be a `--agent` target, to `startTargets` and the `match`
99
101
  in `coordinatorRunTurn`. A new brain is a different thing: see
100
- `docs/dev/agent-brains.md` and `brains/simple/README.md`.
102
+ `docs/dev/agents/agent-brains.md` and `brains/simple/README.md`.
@@ -1,6 +1,6 @@
1
1
  /** @module
2
2
  @summary The coordinator brain: one main LLM that routes to the code,
3
- research, oracle, explorer, and review subagents. The harness (agent.agency
3
+ research, oracle, explorer, review, writing, and rewrite subagents. The harness (agent.agency
4
4
  and lib/) owns the CLI, the REPL, the policy handler, and the per-turn
5
5
  guard; this module only answers turns.
6
6
  */
@@ -18,6 +18,8 @@ import { explorerAgent } from "./subagents/explorer.agency"
18
18
  import { oracleAgent } from "./subagents/oracle.agency"
19
19
  import { researchAgent } from "./subagents/research.agency"
20
20
  import { reviewAgent } from "./subagents/review.agency"
21
+ import { rewriteAgent } from "./subagents/rewrite.agency"
22
+ import { writingAgent } from "./subagents/writing.agency"
21
23
 
22
24
  // Per-run grounding, from BrainContext. Spliced into the system prompt.
23
25
  let _context: string = ""
@@ -35,6 +37,8 @@ static const mainAgentTools = [
35
37
  reviewAgent,
36
38
  oracleAgent,
37
39
  explorerAgent,
40
+ writingAgent,
41
+ rewriteAgent,
38
42
  generateImageFile,
39
43
  ]
40
44
 
@@ -109,6 +113,8 @@ def coordinatorRunTurn(
109
113
  "oracle" => oracleAgent(promptText(prompt))
110
114
  "explorer" => explorerAgent(promptText(prompt))
111
115
  "review" => reviewAgent(promptText(prompt))
116
+ "writing" => writingAgent(promptText(prompt))
117
+ "rewrite" => rewriteAgent(promptText(prompt))
112
118
  _ => mainAgent(prompt)
113
119
  }
114
120
  }
@@ -116,8 +122,8 @@ def coordinatorRunTurn(
116
122
  export def coordinatorBrain(): AgentBrain {
117
123
  return {
118
124
  name: "coordinator",
119
- description: "One coordinator LLM that routes to code, research, oracle, explorer, and review subagents",
120
- startTargets: ["code", "research", "oracle", "explorer", "review"],
125
+ description: "One coordinator LLM that routes to code, research, oracle, explorer, review, writing, and rewrite subagents",
126
+ startTargets: ["code", "research", "oracle", "explorer", "review", "writing", "rewrite"],
121
127
  init: coordinatorInit,
122
128
  runTurn: coordinatorRunTurn
123
129
  }
@@ -12,6 +12,8 @@ import { explorerAgent } from "./subagents/explorer.js";
12
12
  import { oracleAgent } from "./subagents/oracle.js";
13
13
  import { researchAgent } from "./subagents/research.js";
14
14
  import { reviewAgent } from "./subagents/review.js";
15
+ import { rewriteAgent } from "./subagents/rewrite.js";
16
+ import { writingAgent } from "./subagents/writing.js";
15
17
  import { fileURLToPath } from "url";
16
18
  import __process from "process";
17
19
  import { readFileSync } from "fs";
@@ -96,14 +98,15 @@ const __globalCtx = new RuntimeContext({
96
98
  liteLlm: __process.env["LITELLM_BASE_URL"] || "",
97
99
  openAiCompat: __process.env["OPENAI_COMPAT_BASE_URL"] || ""
98
100
  },
99
- model: "gpt-4o-mini",
101
+ model: "gpt-5-mini",
100
102
  logLevel: "warn",
101
103
  statelog: {
102
104
  host: "https://statelog.adit.io",
103
105
  projectId: "smoltalk",
104
106
  apiKey: __process.env["STATELOG_SMOLTALK_API_KEY"] || "",
105
107
  traceId: nanoid()
106
- }
108
+ },
109
+ provider: "openai-responses"
107
110
  },
108
111
  dirname: __dirname,
109
112
  logLevel: "info",
@@ -216,6 +219,8 @@ __registerTool(explorerAgent);
216
219
  __registerTool(oracleAgent);
217
220
  __registerTool(researchAgent);
218
221
  __registerTool(reviewAgent);
222
+ __registerTool(rewriteAgent);
223
+ __registerTool(writingAgent);
219
224
  let __staticInitPromise = null;
220
225
  let MAIN_PROMPT_LARGE = __UNINIT_STATIC;
221
226
  let MAIN_PROMPT_SMALL = __UNINIT_STATIC;
@@ -243,7 +248,7 @@ async function __initializeStatic(__ctx) {
243
248
  } finally {
244
249
  getRuntimeContext().ctx.popHandler();
245
250
  }
246
- mainAgentTools = __deepFreeze([__readStatic(researchAgent, "researchAgent", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/brains/coordinator/subagents/research.agency"), __readStatic(codeAgent, "codeAgent", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/brains/coordinator/subagents/code.agency"), __readStatic(reviewAgent, "reviewAgent", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/brains/coordinator/subagents/review.agency"), __readStatic(oracleAgent, "oracleAgent", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/brains/coordinator/subagents/oracle.agency"), __readStatic(explorerAgent, "explorerAgent", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/brains/coordinator/subagents/explorer.agency"), __readStatic(generateImageFile, "generateImageFile", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/lib/images.agency")]);
251
+ mainAgentTools = __deepFreeze([__readStatic(researchAgent, "researchAgent", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/brains/coordinator/subagents/research.agency"), __readStatic(codeAgent, "codeAgent", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/brains/coordinator/subagents/code.agency"), __readStatic(reviewAgent, "reviewAgent", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/brains/coordinator/subagents/review.agency"), __readStatic(oracleAgent, "oracleAgent", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/brains/coordinator/subagents/oracle.agency"), __readStatic(explorerAgent, "explorerAgent", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/brains/coordinator/subagents/explorer.agency"), __readStatic(writingAgent, "writingAgent", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/brains/coordinator/subagents/writing.agency"), __readStatic(rewriteAgent, "rewriteAgent", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/brains/coordinator/subagents/rewrite.agency"), __readStatic(generateImageFile, "generateImageFile", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/lib/images.agency")]);
247
252
  })();
248
253
  return __staticInitPromise;
249
254
  }
@@ -1158,25 +1163,103 @@ async function __coordinatorRunTurn_impl(target, prompt) {
1158
1163
  return;
1159
1164
  });
1160
1165
  }
1166
+ },
1167
+ {
1168
+ condition: async () => __stack.args.target === `writing`,
1169
+ body: async (runner2) => {
1170
+ await runner2.step(15, async (runner3) => {
1171
+ __stack.locals.__hoist_5 = await __call(promptText, {
1172
+ type: "positional",
1173
+ args: [__stack.args.prompt]
1174
+ });
1175
+ if (hasInterrupts(__stack.locals.__hoist_5)) {
1176
+ await getRuntimeContext().ctx.pendingPromises.awaitAll();
1177
+ runner3.halt(__stack.locals.__hoist_5);
1178
+ return;
1179
+ }
1180
+ if (isAborted(__stack.locals.__hoist_5)) {
1181
+ runner3.halt(__stack.locals.__hoist_5.carryThrough(__stack, "coordinatorRunTurn"));
1182
+ return;
1183
+ }
1184
+ });
1185
+ await runner2.step(16, async (runner3) => {
1186
+ __stack.locals.__armval_14 = await __call(writingAgent, {
1187
+ type: "positional",
1188
+ args: [__stack.locals.__hoist_5]
1189
+ });
1190
+ if (hasInterrupts(__stack.locals.__armval_14)) {
1191
+ await getRuntimeContext().ctx.pendingPromises.awaitAll();
1192
+ runner3.halt(__stack.locals.__armval_14);
1193
+ return;
1194
+ }
1195
+ if (isAborted(__stack.locals.__armval_14)) {
1196
+ runner3.halt(__stack.locals.__armval_14.carryThrough(__stack, "coordinatorRunTurn"));
1197
+ return;
1198
+ }
1199
+ });
1200
+ await runner2.step(17, async (runner3) => {
1201
+ runner3.exitMatch(8, __stack.locals.__armval_14);
1202
+ return;
1203
+ });
1204
+ }
1205
+ },
1206
+ {
1207
+ condition: async () => __stack.args.target === `rewrite`,
1208
+ body: async (runner2) => {
1209
+ await runner2.step(18, async (runner3) => {
1210
+ __stack.locals.__hoist_6 = await __call(promptText, {
1211
+ type: "positional",
1212
+ args: [__stack.args.prompt]
1213
+ });
1214
+ if (hasInterrupts(__stack.locals.__hoist_6)) {
1215
+ await getRuntimeContext().ctx.pendingPromises.awaitAll();
1216
+ runner3.halt(__stack.locals.__hoist_6);
1217
+ return;
1218
+ }
1219
+ if (isAborted(__stack.locals.__hoist_6)) {
1220
+ runner3.halt(__stack.locals.__hoist_6.carryThrough(__stack, "coordinatorRunTurn"));
1221
+ return;
1222
+ }
1223
+ });
1224
+ await runner2.step(19, async (runner3) => {
1225
+ __stack.locals.__armval_15 = await __call(rewriteAgent, {
1226
+ type: "positional",
1227
+ args: [__stack.locals.__hoist_6]
1228
+ });
1229
+ if (hasInterrupts(__stack.locals.__armval_15)) {
1230
+ await getRuntimeContext().ctx.pendingPromises.awaitAll();
1231
+ runner3.halt(__stack.locals.__armval_15);
1232
+ return;
1233
+ }
1234
+ if (isAborted(__stack.locals.__armval_15)) {
1235
+ runner3.halt(__stack.locals.__armval_15.carryThrough(__stack, "coordinatorRunTurn"));
1236
+ return;
1237
+ }
1238
+ });
1239
+ await runner2.step(20, async (runner3) => {
1240
+ runner3.exitMatch(8, __stack.locals.__armval_15);
1241
+ return;
1242
+ });
1243
+ }
1161
1244
  }
1162
1245
  ], async (runner2) => {
1163
- await runner2.step(15, async (runner3) => {
1164
- __stack.locals.__armval_14 = await __call(mainAgent, {
1246
+ await runner2.step(21, async (runner3) => {
1247
+ __stack.locals.__armval_16 = await __call(mainAgent, {
1165
1248
  type: "positional",
1166
1249
  args: [__stack.args.prompt]
1167
1250
  });
1168
- if (hasInterrupts(__stack.locals.__armval_14)) {
1251
+ if (hasInterrupts(__stack.locals.__armval_16)) {
1169
1252
  await getRuntimeContext().ctx.pendingPromises.awaitAll();
1170
- runner3.halt(__stack.locals.__armval_14);
1253
+ runner3.halt(__stack.locals.__armval_16);
1171
1254
  return;
1172
1255
  }
1173
- if (isAborted(__stack.locals.__armval_14)) {
1174
- runner3.halt(__stack.locals.__armval_14.carryThrough(__stack, "coordinatorRunTurn"));
1256
+ if (isAborted(__stack.locals.__armval_16)) {
1257
+ runner3.halt(__stack.locals.__armval_16.carryThrough(__stack, "coordinatorRunTurn"));
1175
1258
  return;
1176
1259
  }
1177
1260
  });
1178
- await runner2.step(16, async (runner3) => {
1179
- runner3.exitMatch(8, __stack.locals.__armval_14);
1261
+ await runner2.step(22, async (runner3) => {
1262
+ runner3.exitMatch(8, __stack.locals.__armval_16);
1180
1263
  return;
1181
1264
  });
1182
1265
  }, { matchId: 8 });
@@ -1300,8 +1383,8 @@ async function __coordinatorBrain_impl() {
1300
1383
  __functionCompleted = true;
1301
1384
  runner2.halt({
1302
1385
  "name": `coordinator`,
1303
- "description": `One coordinator LLM that routes to code, research, oracle, explorer, and review subagents`,
1304
- "startTargets": [`code`, `research`, `oracle`, `explorer`, `review`],
1386
+ "description": `One coordinator LLM that routes to code, research, oracle, explorer, review, writing, and rewrite subagents`,
1387
+ "startTargets": [`code`, `research`, `oracle`, `explorer`, `review`, `writing`, `rewrite`],
1305
1388
  "init": coordinatorInit,
1306
1389
  "runTurn": coordinatorRunTurn
1307
1390
  });
@@ -1368,7 +1451,7 @@ const coordinatorBrain = __AgencyFunction.create({
1368
1451
  exported: true
1369
1452
  }, __toolRegistry);
1370
1453
  var stdin_default = graph;
1371
- const __sourceMap = { "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:coordinatorInit": { "1": { "line": 41, "col": 6 }, "2": { "line": 41, "col": 2 }, "3": { "line": 47, "col": 6 }, "4": { "line": 47, "col": 2 }, "5": { "line": 53, "col": 2 }, "6": { "line": 54, "col": 2 }, "7": { "line": 57, "col": 2 }, "2.0": { "line": 43, "col": 6 }, "2.1": { "line": 42, "col": 4 }, "2.2": { "line": 45, "col": 4 }, "4.0": { "line": 49, "col": 6 }, "4.1": { "line": 48, "col": 4 }, "4.2": { "line": 51, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:mainAgent": { "2": { "line": 64, "col": 2 }, "3": { "line": 65, "col": 2 }, "4": { "line": 89, "col": 2 }, "3.0": { "line": 66, "col": 4 }, "3.1.1": { "line": 68, "col": 6 }, "3.1.2": { "line": 69, "col": 24 }, "3.1.3": { "line": 69, "col": 6 }, "3.1.4": { "line": 73, "col": 6 }, "3.1.5": { "line": 74, "col": 6 }, "3.1": { "line": 67, "col": 4 }, "3.2": { "line": 82, "col": 13 }, "3.3": { "line": 84, "col": 10 }, "3.4": { "line": 76, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:promptText": { "1": { "line": 95, "col": 9 }, "2": { "line": 95, "col": 9 }, "3": { "line": 95, "col": 2 }, "2.0": { "line": 95, "col": 9 }, "2.1": { "line": 96, "col": 20 }, "2.2": { "line": 96, "col": 20 }, "2.3": { "line": 95, "col": 9 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:coordinatorRunTurn": { "1": { "line": 105, "col": 9 }, "2": { "line": 105, "col": 2 }, "1.0": { "line": 106, "col": 24 }, "1.1": { "line": 106, "col": 14 }, "1.2": { "line": 106, "col": 14 }, "1.3": { "line": 107, "col": 32 }, "1.4": { "line": 107, "col": 18 }, "1.5": { "line": 107, "col": 18 }, "1.6": { "line": 108, "col": 28 }, "1.7": { "line": 108, "col": 16 }, "1.8": { "line": 108, "col": 16 }, "1.9": { "line": 109, "col": 32 }, "1.10": { "line": 109, "col": 18 }, "1.11": { "line": 109, "col": 18 }, "1.12": { "line": 110, "col": 28 }, "1.13": { "line": 110, "col": 16 }, "1.14": { "line": 110, "col": 16 }, "1.15": { "line": 111, "col": 9 }, "1.16": { "line": 111, "col": 9 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:coordinatorBrain": { "1": { "line": 116, "col": 2 } } };
1454
+ const __sourceMap = { "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:coordinatorInit": { "1": { "line": 45, "col": 6 }, "2": { "line": 45, "col": 2 }, "3": { "line": 51, "col": 6 }, "4": { "line": 51, "col": 2 }, "5": { "line": 57, "col": 2 }, "6": { "line": 58, "col": 2 }, "7": { "line": 61, "col": 2 }, "2.0": { "line": 47, "col": 6 }, "2.1": { "line": 46, "col": 4 }, "2.2": { "line": 49, "col": 4 }, "4.0": { "line": 53, "col": 6 }, "4.1": { "line": 52, "col": 4 }, "4.2": { "line": 55, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:mainAgent": { "2": { "line": 68, "col": 2 }, "3": { "line": 69, "col": 2 }, "4": { "line": 93, "col": 2 }, "3.0": { "line": 70, "col": 4 }, "3.1.1": { "line": 72, "col": 6 }, "3.1.2": { "line": 73, "col": 24 }, "3.1.3": { "line": 73, "col": 6 }, "3.1.4": { "line": 77, "col": 6 }, "3.1.5": { "line": 78, "col": 6 }, "3.1": { "line": 71, "col": 4 }, "3.2": { "line": 86, "col": 13 }, "3.3": { "line": 88, "col": 10 }, "3.4": { "line": 80, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:promptText": { "1": { "line": 99, "col": 9 }, "2": { "line": 99, "col": 9 }, "3": { "line": 99, "col": 2 }, "2.0": { "line": 99, "col": 9 }, "2.1": { "line": 100, "col": 20 }, "2.2": { "line": 100, "col": 20 }, "2.3": { "line": 99, "col": 9 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:coordinatorRunTurn": { "1": { "line": 109, "col": 9 }, "2": { "line": 109, "col": 2 }, "1.0": { "line": 110, "col": 24 }, "1.1": { "line": 110, "col": 14 }, "1.2": { "line": 110, "col": 14 }, "1.3": { "line": 111, "col": 32 }, "1.4": { "line": 111, "col": 18 }, "1.5": { "line": 111, "col": 18 }, "1.6": { "line": 112, "col": 28 }, "1.7": { "line": 112, "col": 16 }, "1.8": { "line": 112, "col": 16 }, "1.9": { "line": 113, "col": 32 }, "1.10": { "line": 113, "col": 18 }, "1.11": { "line": 113, "col": 18 }, "1.12": { "line": 114, "col": 28 }, "1.13": { "line": 114, "col": 16 }, "1.14": { "line": 114, "col": 16 }, "1.15": { "line": 115, "col": 30 }, "1.16": { "line": 115, "col": 17 }, "1.17": { "line": 115, "col": 17 }, "1.18": { "line": 116, "col": 30 }, "1.19": { "line": 116, "col": 17 }, "1.20": { "line": 116, "col": 17 }, "1.21": { "line": 117, "col": 9 }, "1.22": { "line": 117, "col": 9 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:coordinatorBrain": { "1": { "line": 122, "col": 2 } } };
1372
1455
  export {
1373
1456
  __getCheckpoints,
1374
1457
  __invokeFunction,
@@ -74,14 +74,15 @@ const __globalCtx = new RuntimeContext({
74
74
  liteLlm: __process.env["LITELLM_BASE_URL"] || "",
75
75
  openAiCompat: __process.env["OPENAI_COMPAT_BASE_URL"] || ""
76
76
  },
77
- model: "gpt-4o-mini",
77
+ model: "gpt-5-mini",
78
78
  logLevel: "warn",
79
79
  statelog: {
80
80
  host: "https://statelog.adit.io",
81
81
  projectId: "smoltalk",
82
82
  apiKey: __process.env["STATELOG_SMOLTALK_API_KEY"] || "",
83
83
  traceId: nanoid()
84
- }
84
+ },
85
+ provider: "openai-responses"
85
86
  },
86
87
  dirname: __dirname,
87
88
  logLevel: "info",
@@ -1,7 +1,7 @@
1
1
  You are the top-level coordinator of an Agency-language assistant. You
2
2
  receive every user message and decide how to respond.
3
3
 
4
- You have five subagent tools (each running in its own isolated
4
+ You have six subagent tools (each running in its own isolated
5
5
  context) and one direct tool:
6
6
 
7
7
  - `codeAgent(userMsg)` — anything that touches code or the filesystem:
@@ -19,6 +19,14 @@ context) and one direct tool:
19
19
  - `explorerAgent(userMsg)` — a read-only researcher that produces
20
20
  broad, synthesizing answers about the codebase or bundled docs.
21
21
  Read the **Explorer** section below.
22
+ - `writingAgent(userMsg)` — reviews prose (docs, comments, messages,
23
+ any text meant for a reader) for readability and reports findings.
24
+ Pass the text or the file path, who it is for if the user said, and
25
+ say "apply the fixes" only when the user asked for a rewrite; by
26
+ default it only reports.
27
+ - `rewriteAgent(userMsg)` — rewrites prose and returns the new text.
28
+ Use it when the user wants the rewritten text back rather than a list
29
+ of findings. Pass the text and who it is for if the user said.
22
30
  - `generateImageFile(prompt, path, size, images)` — generate an image
23
31
  from a text prompt (or modify existing images by passing their paths
24
32
  in `images`) and save it to `path`. Call it directly whenever the
@@ -10,6 +10,11 @@ Tools (each runs in its own context; pass a self-contained message):
10
10
  - `oracleAgent(userMsg)` — deep reasoning on a hard question; include
11
11
  all needed context in the message.
12
12
  - `explorerAgent(userMsg)` — broad read-only codebase/docs questions.
13
+ - `writingAgent(userMsg)` — review prose for readability; pass the text
14
+ or file path and who it is for. Reports only, unless the user asked
15
+ for the fixes to be applied.
16
+ - `rewriteAgent(userMsg)` — rewrite prose and return the new text; use
17
+ it when the user wants the rewrite, not findings.
13
18
  - `generateImageFile(prompt, path, size, images)` — create or edit an
14
19
  image; do not route image work to codeAgent.
15
20
 
@@ -82,14 +82,15 @@ const __globalCtx = new RuntimeContext({
82
82
  liteLlm: __process.env["LITELLM_BASE_URL"] || "",
83
83
  openAiCompat: __process.env["OPENAI_COMPAT_BASE_URL"] || ""
84
84
  },
85
- model: "gpt-4o-mini",
85
+ model: "gpt-5-mini",
86
86
  logLevel: "warn",
87
87
  statelog: {
88
88
  host: "https://statelog.adit.io",
89
89
  projectId: "smoltalk",
90
90
  apiKey: __process.env["STATELOG_SMOLTALK_API_KEY"] || "",
91
91
  traceId: nanoid()
92
- }
92
+ },
93
+ provider: "openai-responses"
93
94
  },
94
95
  dirname: __dirname,
95
96
  logLevel: "info",
@@ -104,14 +104,15 @@ const __globalCtx = new RuntimeContext({
104
104
  liteLlm: __process.env["LITELLM_BASE_URL"] || "",
105
105
  openAiCompat: __process.env["OPENAI_COMPAT_BASE_URL"] || ""
106
106
  },
107
- model: "gpt-4o-mini",
107
+ model: "gpt-5-mini",
108
108
  logLevel: "warn",
109
109
  statelog: {
110
110
  host: "https://statelog.adit.io",
111
111
  projectId: "smoltalk",
112
112
  apiKey: __process.env["STATELOG_SMOLTALK_API_KEY"] || "",
113
113
  traceId: nanoid()
114
- }
114
+ },
115
+ provider: "openai-responses"
115
116
  },
116
117
  dirname: __dirname,
117
118
  logLevel: "info",
@@ -73,14 +73,15 @@ const __globalCtx = new RuntimeContext({
73
73
  liteLlm: __process.env["LITELLM_BASE_URL"] || "",
74
74
  openAiCompat: __process.env["OPENAI_COMPAT_BASE_URL"] || ""
75
75
  },
76
- model: "gpt-4o-mini",
76
+ model: "gpt-5-mini",
77
77
  logLevel: "warn",
78
78
  statelog: {
79
79
  host: "https://statelog.adit.io",
80
80
  projectId: "smoltalk",
81
81
  apiKey: __process.env["STATELOG_SMOLTALK_API_KEY"] || "",
82
82
  traceId: nanoid()
83
- }
83
+ },
84
+ provider: "openai-responses"
84
85
  },
85
86
  dirname: __dirname,
86
87
  logLevel: "info",
@@ -73,14 +73,15 @@ const __globalCtx = new RuntimeContext({
73
73
  liteLlm: __process.env["LITELLM_BASE_URL"] || "",
74
74
  openAiCompat: __process.env["OPENAI_COMPAT_BASE_URL"] || ""
75
75
  },
76
- model: "gpt-4o-mini",
76
+ model: "gpt-5-mini",
77
77
  logLevel: "warn",
78
78
  statelog: {
79
79
  host: "https://statelog.adit.io",
80
80
  projectId: "smoltalk",
81
81
  apiKey: __process.env["STATELOG_SMOLTALK_API_KEY"] || "",
82
82
  traceId: nanoid()
83
- }
83
+ },
84
+ provider: "openai-responses"
84
85
  },
85
86
  dirname: __dirname,
86
87
  logLevel: "info",
@@ -83,14 +83,15 @@ const __globalCtx = new RuntimeContext({
83
83
  liteLlm: __process.env["LITELLM_BASE_URL"] || "",
84
84
  openAiCompat: __process.env["OPENAI_COMPAT_BASE_URL"] || ""
85
85
  },
86
- model: "gpt-4o-mini",
86
+ model: "gpt-5-mini",
87
87
  logLevel: "warn",
88
88
  statelog: {
89
89
  host: "https://statelog.adit.io",
90
90
  projectId: "smoltalk",
91
91
  apiKey: __process.env["STATELOG_SMOLTALK_API_KEY"] || "",
92
92
  traceId: nanoid()
93
- }
93
+ },
94
+ provider: "openai-responses"
94
95
  },
95
96
  dirname: __dirname,
96
97
  logLevel: "info",
@@ -84,14 +84,15 @@ const __globalCtx = new RuntimeContext({
84
84
  liteLlm: __process.env["LITELLM_BASE_URL"] || "",
85
85
  openAiCompat: __process.env["OPENAI_COMPAT_BASE_URL"] || ""
86
86
  },
87
- model: "gpt-4o-mini",
87
+ model: "gpt-5-mini",
88
88
  logLevel: "warn",
89
89
  statelog: {
90
90
  host: "https://statelog.adit.io",
91
91
  projectId: "smoltalk",
92
92
  apiKey: __process.env["STATELOG_SMOLTALK_API_KEY"] || "",
93
93
  traceId: nanoid()
94
- }
94
+ },
95
+ provider: "openai-responses"
95
96
  },
96
97
  dirname: __dirname,
97
98
  logLevel: "info",
@@ -0,0 +1,41 @@
1
+ import { writingRewriteAgent } from "std::agents/writing/rewrite"
2
+ import { setMemoryId } from "std::memory"
3
+
4
+ // The rewrite lives in std::agents/writing/rewrite. This wrapper only
5
+ // separates the prose from the request around it and adds the thread and
6
+ // memory an agent turn needs.
7
+
8
+ type RewriteRequest = {
9
+ text: string;
10
+ task: string
11
+ }
12
+
13
+ def splitRequest(userMsg: string): RewriteRequest {
14
+ return llm("""A user message asks for a piece of prose to be rewritten. Separate the prose from the request around it. `text` is the prose itself, copied exactly, with the request words removed. `task` is anything the message says about who the prose is for or what it must get across, or "" if it says nothing.
15
+
16
+ <message>
17
+ ${userMsg}
18
+ </message>
19
+ """)
20
+ }
21
+
22
+ export def rewriteAgent(userMsg: string): string {
23
+ """
24
+ Rewrite prose for readability and return the rewritten text. Runs the
25
+ writing reviewer, then applies its findings; text the reviewer finds
26
+ nothing wrong with comes back unchanged.
27
+
28
+ @param userMsg - the text to rewrite, and who it is for if known.
29
+ """
30
+ let reply = ""
31
+ thread(label: "rewrite", summarize: true, session: "rewrite") {
32
+ setMemoryId("rewrite")
33
+ const request = splitRequest(userMsg)
34
+ const rewritten = writingRewriteAgent(text: request.text, task: request.task)
35
+ reply = match(rewritten) {
36
+ success(value) => value
37
+ failure(err) => "rewrite failed: ${err}"
38
+ }
39
+ }
40
+ return reply
41
+ }