agency-lang 0.18.1 → 0.19.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 (327) hide show
  1. package/dist/lib/agents/agency-agent/agent.agency +1 -1
  2. package/dist/lib/agents/agency-agent/agent.js +12 -15
  3. package/dist/lib/agents/agency-agent/brains/brain.js +3 -3
  4. package/dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency +2 -1
  5. package/dist/lib/agents/agency-agent/brains/coordinator/coordinator.js +63 -89
  6. package/dist/lib/agents/agency-agent/brains/coordinator/lib/announce.js +16 -22
  7. package/dist/lib/agents/agency-agent/brains/coordinator/lib/budgets.js +31 -42
  8. package/dist/lib/agents/agency-agent/brains/coordinator/prompts/codeSample.js +9 -9
  9. package/dist/lib/agents/agency-agent/brains/coordinator/prompts/main-large.md +3 -0
  10. package/dist/lib/agents/agency-agent/brains/coordinator/prompts/main-small.md +2 -0
  11. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/brainstorm.js +46 -67
  12. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/code.agency +1 -1
  13. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/code.js +118 -171
  14. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/explorer.js +10 -13
  15. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/oracle.js +10 -13
  16. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/research.js +10 -13
  17. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/review.js +40 -58
  18. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/rewrite.js +16 -22
  19. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/supervisor.js +82 -121
  20. package/dist/lib/agents/agency-agent/brains/coordinator/subagents/writing.js +10 -13
  21. package/dist/lib/agents/agency-agent/brains/registry.js +16 -22
  22. package/dist/lib/agents/agency-agent/brains/simple/simple.js +22 -31
  23. package/dist/lib/agents/agency-agent/images/images.js +3 -3
  24. package/dist/lib/agents/agency-agent/lib/agentName.js +10 -13
  25. package/dist/lib/agents/agency-agent/lib/args.agency +1 -1
  26. package/dist/lib/agents/agency-agent/lib/args.js +17 -23
  27. package/dist/lib/agents/agency-agent/lib/attachments.js +16 -22
  28. package/dist/lib/agents/agency-agent/lib/budget.js +10 -13
  29. package/dist/lib/agents/agency-agent/lib/capabilities.agency +4 -0
  30. package/dist/lib/agents/agency-agent/lib/capabilities.js +74 -104
  31. package/dist/lib/agents/agency-agent/lib/capabilitiesUi.js +58 -85
  32. package/dist/lib/agents/agency-agent/lib/commandPalette.js +16 -22
  33. package/dist/lib/agents/agency-agent/lib/config.js +10 -13
  34. package/dist/lib/agents/agency-agent/lib/grounding.js +16 -22
  35. package/dist/lib/agents/agency-agent/lib/header.js +46 -67
  36. package/dist/lib/agents/agency-agent/lib/images.agency +19 -1
  37. package/dist/lib/agents/agency-agent/lib/images.js +192 -25
  38. package/dist/lib/agents/agency-agent/lib/mcp.js +40 -58
  39. package/dist/lib/agents/agency-agent/lib/modelFilters.js +10 -13
  40. package/dist/lib/agents/agency-agent/lib/models.js +69 -98
  41. package/dist/lib/agents/agency-agent/lib/policy.agency +3 -3
  42. package/dist/lib/agents/agency-agent/lib/policy.js +57 -72
  43. package/dist/lib/agents/agency-agent/lib/projectContext.js +16 -22
  44. package/dist/lib/agents/agency-agent/lib/repl.agency +2 -4
  45. package/dist/lib/agents/agency-agent/lib/repl.js +85 -124
  46. package/dist/lib/agents/agency-agent/lib/resolution.js +46 -67
  47. package/dist/lib/agents/agency-agent/lib/resume.js +52 -76
  48. package/dist/lib/agents/agency-agent/lib/search.js +100 -148
  49. package/dist/lib/agents/agency-agent/lib/session.js +46 -67
  50. package/dist/lib/agents/agency-agent/lib/sessionTitle.js +35 -49
  51. package/dist/lib/agents/agency-agent/lib/sessions.js +65 -94
  52. package/dist/lib/agents/agency-agent/lib/settings.js +40 -58
  53. package/dist/lib/agents/agency-agent/lib/slots.js +22 -31
  54. package/dist/lib/agents/agency-agent/lib/trace.js +76 -112
  55. package/dist/lib/agents/agency-agent/lib/transcript.js +22 -31
  56. package/dist/lib/agents/agency-agent/lib/turn.js +70 -103
  57. package/dist/lib/agents/agency-agent/lib/utils/renderLLMCallResponse.js +10 -13
  58. package/dist/lib/agents/agency-agent/lib/utils.js +52 -76
  59. package/dist/lib/agents/agency-agent/shared.agency +33 -5
  60. package/dist/lib/agents/agency-agent/shared.js +306 -241
  61. package/dist/lib/agents/eval/goalJudge.js +5 -5
  62. package/dist/lib/agents/eval/judge.js +5 -5
  63. package/dist/lib/agents/eval/judgePairwise.js +5 -5
  64. package/dist/lib/agents/eval/rubricJudge.js +5 -5
  65. package/dist/lib/agents/optimize/gepaReflect.js +5 -5
  66. package/dist/lib/agents/optimize/mutatePrompt.js +5 -5
  67. package/dist/lib/agents/policy/agent.js +60 -86
  68. package/dist/lib/agents/review/agent.js +6 -6
  69. package/dist/lib/backends/typescriptBuilder.js +18 -3
  70. package/dist/lib/backends/typescriptGenerator/typeToString.js +8 -6
  71. package/dist/lib/backends/typescriptGenerator/typeToZodSchema.d.ts +1 -1
  72. package/dist/lib/backends/typescriptGenerator/typeToZodSchema.js +7 -2
  73. package/dist/lib/backends/typescriptGenerator/validationDescriptor.js +27 -14
  74. package/dist/lib/cli/local.d.ts +16 -1
  75. package/dist/lib/cli/local.js +178 -10
  76. package/dist/lib/cli/localFlag.d.ts +4 -3
  77. package/dist/lib/cli/localFlag.js +11 -4
  78. package/dist/lib/cli/localServe.d.ts +111 -0
  79. package/dist/lib/cli/localServe.js +380 -0
  80. package/dist/lib/cli/mlxServer.d.ts +23 -0
  81. package/dist/lib/cli/mlxServer.js +164 -0
  82. package/dist/lib/cli/precompile.js +5 -1
  83. package/dist/lib/cli/serveLog.d.ts +59 -0
  84. package/dist/lib/cli/serveLog.js +174 -0
  85. package/dist/lib/cli/test.d.ts +3 -0
  86. package/dist/lib/cli/test.js +22 -2
  87. package/dist/lib/compiler/initDepGraph.d.ts +5 -0
  88. package/dist/lib/compiler/initDepGraph.js +56 -4
  89. package/dist/lib/config.d.ts +24 -0
  90. package/dist/lib/config.js +8 -0
  91. package/dist/lib/importPaths.js +17 -1
  92. package/dist/lib/importResolutionError.d.ts +21 -0
  93. package/dist/lib/importResolutionError.js +32 -0
  94. package/dist/lib/parsers/parsers.js +9 -9
  95. package/dist/lib/preprocessors/importResolver.d.ts +2 -12
  96. package/dist/lib/preprocessors/importResolver.js +13 -16
  97. package/dist/lib/runtime/agencyFunction.js +4 -2
  98. package/dist/lib/runtime/builtinPolicies.js +14 -0
  99. package/dist/lib/runtime/call.js +2 -2
  100. package/dist/lib/runtime/index.d.ts +2 -2
  101. package/dist/lib/runtime/index.js +2 -2
  102. package/dist/lib/runtime/interruptResponse.d.ts +2 -2
  103. package/dist/lib/runtime/interruptResponse.js +2 -2
  104. package/dist/lib/runtime/ipc.js +1 -2
  105. package/dist/lib/runtime/llmRetry.js +1 -1
  106. package/dist/lib/runtime/prompt.d.ts +0 -6
  107. package/dist/lib/runtime/prompt.js +19 -28
  108. package/dist/lib/runtime/result.d.ts +24 -2
  109. package/dist/lib/runtime/result.js +82 -6
  110. package/dist/lib/runtime/toolBlockDiagnostics.d.ts +1 -1
  111. package/dist/lib/runtime/toolBlockDiagnostics.js +4 -4
  112. package/dist/lib/runtime/validateChain.d.ts +7 -0
  113. package/dist/lib/runtime/validateChain.js +28 -2
  114. package/dist/lib/statelogClient.d.ts +1 -1
  115. package/dist/lib/stdlib/agency.d.ts +3 -3
  116. package/dist/lib/stdlib/agency.js +7 -7
  117. package/dist/lib/stdlib/approvedPath.d.ts +13 -0
  118. package/dist/lib/stdlib/approvedPath.js +26 -0
  119. package/dist/lib/stdlib/aws/client.js +1 -3
  120. package/dist/lib/stdlib/aws/credentials.js +2 -4
  121. package/dist/lib/stdlib/aws/endpoints.js +3 -7
  122. package/dist/lib/stdlib/aws/errors.js +1 -2
  123. package/dist/lib/stdlib/aws/s3.js +5 -11
  124. package/dist/lib/stdlib/contained.d.ts +13 -1
  125. package/dist/lib/stdlib/contained.js +35 -5
  126. package/dist/lib/stdlib/http.js +1 -2
  127. package/dist/lib/stdlib/hubClient.d.ts +75 -0
  128. package/dist/lib/stdlib/hubClient.js +223 -0
  129. package/dist/lib/stdlib/hubDownload.d.ts +47 -0
  130. package/dist/lib/stdlib/hubDownload.js +384 -0
  131. package/dist/lib/stdlib/localModels.d.ts +74 -54
  132. package/dist/lib/stdlib/localModels.js +372 -340
  133. package/dist/lib/stdlib/mcp.js +1 -1
  134. package/dist/lib/stdlib/mlxModelRecord.d.ts +26 -0
  135. package/dist/lib/stdlib/mlxModelRecord.js +60 -0
  136. package/dist/lib/stdlib/mlxServerModels.d.ts +10 -0
  137. package/dist/lib/stdlib/mlxServerModels.js +32 -0
  138. package/dist/lib/stdlib/modelBackend.d.ts +46 -0
  139. package/dist/lib/stdlib/modelBackend.js +184 -0
  140. package/dist/lib/stdlib/modelCatalog.d.ts +43 -0
  141. package/dist/lib/stdlib/modelCatalog.js +380 -0
  142. package/dist/lib/stdlib/modelVerify.d.ts +9 -0
  143. package/dist/lib/stdlib/modelVerify.js +55 -0
  144. package/dist/lib/stdlib/objectBytes.js +2 -4
  145. package/dist/lib/stdlib/ocr.d.ts +33 -0
  146. package/dist/lib/stdlib/ocr.js +106 -0
  147. package/dist/lib/stdlib/thread.d.ts +9 -0
  148. package/dist/lib/stdlib/thread.js +36 -1
  149. package/dist/lib/stdlib/threads.js +1 -1
  150. package/dist/lib/stdlib/visionOcr.jxa +50 -0
  151. package/dist/lib/symbolTable.js +30 -14
  152. package/dist/lib/templates/backends/typescriptGenerator/functionCatchFailure.d.ts +1 -1
  153. package/dist/lib/templates/backends/typescriptGenerator/functionCatchFailure.js +6 -9
  154. package/dist/lib/templates/backends/typescriptGenerator/imports.d.ts +1 -1
  155. package/dist/lib/templates/backends/typescriptGenerator/imports.js +3 -3
  156. package/dist/lib/templates/backends/typescriptGenerator/interruptAssignment.d.ts +1 -1
  157. package/dist/lib/templates/backends/typescriptGenerator/interruptAssignment.js +4 -4
  158. package/dist/lib/templates/backends/typescriptGenerator/interruptReturn.d.ts +1 -1
  159. package/dist/lib/templates/backends/typescriptGenerator/interruptReturn.js +4 -4
  160. package/dist/lib/testFormat/schema.d.ts +15 -0
  161. package/dist/lib/testFormat/schema.js +10 -0
  162. package/dist/lib/typeChecker/assignability.js +2 -2
  163. package/dist/lib/typeChecker/builtinGenerics.d.ts +12 -0
  164. package/dist/lib/typeChecker/builtinGenerics.js +4 -2
  165. package/dist/lib/typeChecker/builtins.js +17 -2
  166. package/dist/lib/typeChecker/dataShape.d.ts +10 -0
  167. package/dist/lib/typeChecker/dataShape.js +21 -0
  168. package/dist/lib/typeChecker/diagnosticExplanations.js +64 -0
  169. package/dist/lib/typeChecker/diagnostics.d.ts +37 -2
  170. package/dist/lib/typeChecker/diagnostics.js +37 -2
  171. package/dist/lib/typeChecker/flowBuilder.d.ts +7 -5
  172. package/dist/lib/typeChecker/flowBuilder.js +76 -23
  173. package/dist/lib/typeChecker/index.js +8 -0
  174. package/dist/lib/typeChecker/inference.js +1 -1
  175. package/dist/lib/typeChecker/paramRedeclaration.d.ts +15 -0
  176. package/dist/lib/typeChecker/paramRedeclaration.js +38 -0
  177. package/dist/lib/typeChecker/resultUnion.js +18 -2
  178. package/dist/lib/typeChecker/scopes.js +8 -1
  179. package/dist/lib/typeChecker/staticInitRules.d.ts +8 -1
  180. package/dist/lib/typeChecker/staticInitRules.js +16 -0
  181. package/dist/lib/typeChecker/synthesizer.js +37 -7
  182. package/dist/lib/typeChecker/typeKey.js +1 -1
  183. package/dist/lib/typeChecker/typeWalker.js +2 -2
  184. package/dist/lib/typeChecker/utils.d.ts +1 -1
  185. package/dist/lib/typeChecker/utils.js +41 -2
  186. package/dist/lib/typeChecker/validate.d.ts +5 -0
  187. package/dist/lib/typeChecker/validate.js +14 -0
  188. package/dist/lib/typeChecker/validateStaticInit.js +5 -10
  189. package/dist/lib/typeChecker/validation.d.ts +4 -3
  190. package/dist/lib/typeChecker/validation.js +6 -5
  191. package/dist/lib/typeChecker/valueArgReferences.d.ts +17 -0
  192. package/dist/lib/typeChecker/valueArgReferences.js +215 -0
  193. package/dist/lib/typeChecker/valueParamSubstitution.js +2 -2
  194. package/dist/lib/types/typeHints.d.ts +3 -1
  195. package/dist/lib/utils/formatType.js +8 -4
  196. package/dist/lib/utils/termcolors.d.ts +7 -1
  197. package/dist/lib/utils/termcolors.js +6 -0
  198. package/dist/scripts/agency.js +94 -9
  199. package/package.json +2 -2
  200. package/stdlib/agency/eval.js +22 -31
  201. package/stdlib/agency/local.agency +73 -16
  202. package/stdlib/agency/local.js +619 -126
  203. package/stdlib/agency.agency +34 -27
  204. package/stdlib/agency.js +411 -800
  205. package/stdlib/agent.js +36 -51
  206. package/stdlib/agents/agency/coding.agency +5 -4
  207. package/stdlib/agents/agency/coding.js +66 -82
  208. package/stdlib/agents/agency/expert.js +22 -31
  209. package/stdlib/agents/agency/researcher.js +22 -31
  210. package/stdlib/agents/agency/review.js +41 -58
  211. package/stdlib/agents/agency/verifier.js +28 -40
  212. package/stdlib/agents/coding.agency +2 -0
  213. package/stdlib/agents/coding.js +47 -40
  214. package/stdlib/agents/composable/promptRewriter.js +10 -13
  215. package/stdlib/agents/composable/researcher.js +16 -22
  216. package/stdlib/agents/composable/utils.js +12 -15
  217. package/stdlib/agents/data.js +22 -31
  218. package/stdlib/agents/expert.js +22 -31
  219. package/stdlib/agents/explorer.js +22 -31
  220. package/stdlib/agents/lib/expertGuidance.js +17 -23
  221. package/stdlib/agents/lib/feedback.js +45 -63
  222. package/stdlib/agents/lib/search.js +34 -49
  223. package/stdlib/agents/lib/shared.js +22 -31
  224. package/stdlib/agents/lib/toolkits.agency +64 -0
  225. package/stdlib/agents/lib/toolkits.js +320 -113
  226. package/stdlib/agents/oracle.js +22 -31
  227. package/stdlib/agents/planner.agency +2 -2
  228. package/stdlib/agents/planner.js +97 -145
  229. package/stdlib/agents/researcher.js +35 -49
  230. package/stdlib/agents/review.agency +4 -3
  231. package/stdlib/agents/review.js +45 -37
  232. package/stdlib/agents/skills/coding/gh-pr-and-issues.md +100 -93
  233. package/stdlib/agents/skills/coding/gh-repos-and-releases.md +2 -2
  234. package/stdlib/agents/typescript/review.js +23 -31
  235. package/stdlib/agents/verifier.js +29 -41
  236. package/stdlib/agents/writing/review.js +59 -85
  237. package/stdlib/agents/writing/rewrite.js +18 -23
  238. package/stdlib/args.js +10 -13
  239. package/stdlib/array.js +82 -121
  240. package/stdlib/auth/keyring.js +34 -46
  241. package/stdlib/auth/oauth.js +34 -46
  242. package/stdlib/aws/s3.js +52 -70
  243. package/stdlib/calendar.js +50 -68
  244. package/stdlib/capabilities.js +3 -3
  245. package/stdlib/clipboard.js +20 -26
  246. package/stdlib/concurrency.js +16 -22
  247. package/stdlib/data/connector.js +34 -49
  248. package/stdlib/data/finance/dbnomics.js +32 -43
  249. package/stdlib/data/finance/edgar.js +53 -73
  250. package/stdlib/data/finance/fred.js +74 -103
  251. package/stdlib/data/news/gdelt.js +31 -42
  252. package/stdlib/data/people/littlesis.js +127 -180
  253. package/stdlib/data/social/bluesky.js +94 -132
  254. package/stdlib/data/tech/hackernews.js +142 -201
  255. package/stdlib/data/tech/yc.js +126 -179
  256. package/stdlib/data/usaspending.js +79 -111
  257. package/stdlib/data/wikidata.js +110 -157
  258. package/stdlib/date.js +106 -157
  259. package/stdlib/docs/agent/index.md +2 -0
  260. package/stdlib/docs/cli/local.md +106 -12
  261. package/stdlib/docs/diagnostics/checking.md +88 -0
  262. package/stdlib/docs/diagnostics/index.md +9 -2
  263. package/stdlib/docs/diagnostics/names.md +10 -0
  264. package/stdlib/docs/diagnostics/static-init.md +15 -0
  265. package/stdlib/docs/diagnostics/tools.md +2 -2
  266. package/stdlib/docs/guide/error-handling.md +60 -5
  267. package/stdlib/docs/guide/guards.md +6 -4
  268. package/stdlib/docs/guide/using-local-models.md +108 -2
  269. package/stdlib/docs/stdlib/agency/local.md +134 -32
  270. package/stdlib/docs/stdlib/agents/coding.md +2 -2
  271. package/stdlib/docs/stdlib/agents/lib/toolkits.md +46 -13
  272. package/stdlib/docs/stdlib/agents/review.md +3 -2
  273. package/stdlib/docs/stdlib/github.md +53 -50
  274. package/stdlib/docs/stdlib/ocr.md +192 -0
  275. package/stdlib/docs/stdlib/policy.md +6 -7
  276. package/stdlib/docs/stdlib/supervise.md +2 -2
  277. package/stdlib/docs/stdlib/thread.md +70 -24
  278. package/stdlib/docs/stdlib/toolbox.md +3 -3
  279. package/stdlib/fs.js +52 -70
  280. package/stdlib/git.js +154 -211
  281. package/stdlib/github.agency +3 -0
  282. package/stdlib/github.js +149 -203
  283. package/stdlib/http.js +28 -37
  284. package/stdlib/image.js +10 -13
  285. package/stdlib/index.js +198 -291
  286. package/stdlib/llm.agency +2 -2
  287. package/stdlib/llm.js +65 -91
  288. package/stdlib/markdown.js +36 -50
  289. package/stdlib/math.js +35 -49
  290. package/stdlib/mcp.js +34 -49
  291. package/stdlib/memory.js +68 -95
  292. package/stdlib/messaging/email.js +28 -37
  293. package/stdlib/messaging/imessage.js +12 -15
  294. package/stdlib/messaging/sms.js +12 -15
  295. package/stdlib/notes/apple.js +75 -101
  296. package/stdlib/object.js +52 -76
  297. package/stdlib/ocr.agency +158 -0
  298. package/stdlib/ocr.js +1153 -0
  299. package/stdlib/path.js +46 -67
  300. package/stdlib/policy.agency +16 -24
  301. package/stdlib/policy.js +170 -262
  302. package/stdlib/safeBash/actions.js +31 -42
  303. package/stdlib/safeBash.js +295 -414
  304. package/stdlib/shell.js +62 -86
  305. package/stdlib/skills.js +198 -281
  306. package/stdlib/speech.js +42 -57
  307. package/stdlib/spill.js +65 -91
  308. package/stdlib/statelog.js +52 -76
  309. package/stdlib/strategy.js +46 -67
  310. package/stdlib/supervise.js +11 -13
  311. package/stdlib/syntax.js +28 -40
  312. package/stdlib/system.js +94 -133
  313. package/stdlib/tag.js +40 -58
  314. package/stdlib/thread.agency +54 -0
  315. package/stdlib/thread.js +554 -186
  316. package/stdlib/toolbox.agency +21 -37
  317. package/stdlib/toolbox.js +415 -757
  318. package/stdlib/ui/chart.js +28 -40
  319. package/stdlib/ui/cli.js +58 -85
  320. package/stdlib/ui/layout.js +112 -166
  321. package/stdlib/ui/table.js +46 -67
  322. package/stdlib/ui.js +340 -508
  323. package/stdlib/validation.js +83 -121
  324. package/stdlib/weather.js +24 -33
  325. package/stdlib/web/browser.js +12 -15
  326. package/stdlib/web/search.js +20 -26
  327. package/stdlib/wikipedia.js +28 -37
@@ -52,7 +52,7 @@ def oneShotAgent(target: string, prompt: string): string {
52
52
  if (result is success(r)) {
53
53
  reply = r
54
54
  } else if (result is failure(f)) {
55
- reply = formatTurnFailure("${f.error}")
55
+ reply = formatTurnFailure(f)
56
56
  }
57
57
  }
58
58
  evalOutput(reply)
@@ -60,7 +60,7 @@ import {
60
60
  __registerGlobalsInit,
61
61
  __registerCallbacksInit,
62
62
  registerModuleFingerprint as __registerModuleFingerprint,
63
- failure,
63
+ runtimeFailure,
64
64
  isSuccess,
65
65
  isFailure,
66
66
  stampFailureBoundary,
@@ -126,8 +126,8 @@ const graph = __globalCtx.graph;
126
126
  function approve(value) {
127
127
  return { type: "approve", value };
128
128
  }
129
- function reject(value) {
130
- return { type: "reject", value };
129
+ function reject(reason) {
130
+ return { type: "reject", value: reason };
131
131
  }
132
132
  function propagate() {
133
133
  return { type: "propagate" };
@@ -423,7 +423,7 @@ async function __oneShotAgent_impl(target, prompt) {
423
423
  await runner5.step(1, async (runner6) => {
424
424
  __stack.locals.reply = await __call(formatTurnFailure, {
425
425
  type: "positional",
426
- args: [`${__bstack.locals.f.error}`]
426
+ args: [__bstack.locals.f]
427
427
  });
428
428
  if (hasInterrupts(__stack.locals.reply)) {
429
429
  await getRuntimeContext().ctx.pendingPromises.awaitAll();
@@ -506,15 +506,12 @@ async function __oneShotAgent_impl(target, prompt) {
506
506
  functionName: "oneShotAgent"
507
507
  });
508
508
  }
509
- return failure(
510
- __error instanceof Error ? __error.message : String(__error),
511
- {
512
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
513
- destructiveRan: __self.__destructiveRan,
514
- functionName: "oneShotAgent",
515
- args: __stack.args
516
- }
517
- );
509
+ return runtimeFailure(__error, {
510
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
511
+ destructiveRan: __self.__destructiveRan,
512
+ functionName: "oneShotAgent",
513
+ args: __stack.args
514
+ });
518
515
  } finally {
519
516
  __stateStack()?.pop();
520
517
  if (__functionCompleted) {
@@ -1643,7 +1640,7 @@ Session cost: ${__stack.locals.roundedCost}`]
1643
1640
  }
1644
1641
  return {
1645
1642
  messages: __threads(),
1646
- data: failure(__error instanceof Error ? __error.message : String(__error), { functionName: "main" })
1643
+ data: runtimeFailure(__error, { functionName: "main" })
1647
1644
  };
1648
1645
  }
1649
1646
  });
@@ -1680,7 +1677,7 @@ Agent crashed: ${__error.message}`);
1680
1677
  }
1681
1678
  var stdin_default = graph;
1682
1679
  const __sourceMap = { "dist/lib/agents/agency-agent/agent.agency:oneShotAgent": { "1": { "line": 41, "col": 2 }, "2": { "line": 45, "col": 2 }, "3": { "line": 46, "col": 2 }, "4": { "line": 47, "col": 2 }, "5": { "line": 57, "col": 2 }, "6": { "line": 58, "col": 2 } }, "dist/lib/agents/agency-agent/agent.agency:__block_0": { "4.0": { "line": 48, "col": 4 }, "4.1": { "line": 51, "col": 18 }, "4.2.0": { "line": 51, "col": 4 }, "4.2.1": { "line": 52, "col": 6 }, "4.2.2": { "line": 53, "col": 25 }, "4.2.3.0": { "line": 53, "col": 11 }, "4.2.3.1": { "line": 54, "col": 6 }, "4.2.3": { "line": 53, "col": 11 }, "4.2": { "line": 51, "col": 4 } }, "dist/lib/agents/agency-agent/agent.agency:main": { "2": { "line": 68, "col": 2 }, "3": { "line": 76, "col": 2 }, "4": { "line": 79, "col": 2 }, "6": { "line": 86, "col": 2 }, "7": { "line": 90, "col": 2 }, "8": { "line": 96, "col": 63 }, "9": { "line": 96, "col": 2 }, "10": { "line": 97, "col": 2 }, "11": { "line": 98, "col": 2 }, "12": { "line": 104, "col": 2 }, "13": { "line": 109, "col": 2 }, "14": { "line": 110, "col": 2 }, "15": { "line": 111, "col": 2 }, "16": { "line": 115, "col": 2 }, "17": { "line": 116, "col": 2 }, "18": { "line": 119, "col": 15 }, "19": { "line": 119, "col": 2 }, "20": { "line": 122, "col": 2 }, "21": { "line": 123, "col": 2 }, "22": { "line": 124, "col": 2 }, "23": { "line": 125, "col": 2 }, "24": { "line": 138, "col": 2 }, "25": { "line": 142, "col": 2 }, "26": { "line": 146, "col": 15 }, "27": { "line": 146, "col": 2 }, "28": { "line": 148, "col": 2 }, "29": { "line": 152, "col": 2 }, "30": { "line": 155, "col": 2 }, "31": { "line": 156, "col": 2 }, "33": { "line": 162, "col": 2 }, "34": { "line": 163, "col": 2 }, "35": { "line": 169, "col": 14 }, "36": { "line": 169, "col": 2 }, "37": { "line": 175, "col": 2 }, "39": { "line": 187, "col": 2 }, "40": { "line": 196, "col": 2 }, "3.0": { "line": 77, "col": 4 }, "4.0": { "line": 80, "col": 4 }, "6.0": { "line": 87, "col": 4 }, "6.1": { "line": 88, "col": 4 }, "11.0": { "line": 99, "col": 22 }, "11.2": { "line": 99, "col": 4 }, "11.3": { "line": 100, "col": 10 }, "11.4": { "line": 100, "col": 4 }, "11.5": { "line": 101, "col": 4 }, "11.6": { "line": 102, "col": 4 }, "23.0": { "line": 126, "col": 4 }, "23.1": { "line": 128, "col": 6 }, "23.2": { "line": 127, "col": 4 }, "23.3": { "line": 132, "col": 4 }, "23.4": { "line": 133, "col": 4 }, "23.5": { "line": 135, "col": 4 }, "31.0": { "line": 157, "col": 4 }, "34.0": { "line": 164, "col": 4 }, "37.0": { "line": 177, "col": 6 }, "37.1": { "line": 176, "col": 4 }, "37.2": { "line": 181, "col": 4 }, "39.0": { "line": 188, "col": 4 }, "39.1": { "line": 189, "col": 20 }, "39.2": { "line": 189, "col": 4 }, "39.3": { "line": 191, "col": 6 }, "39.4": { "line": 190, "col": 4 }, "40.0": { "line": 197, "col": 4 }, "40.1.0": { "line": 199, "col": 6 }, "40.1.1.0": { "line": 201, "col": 8 }, "40.1.1": { "line": 200, "col": 6 }, "40.1.2": { "line": 203, "col": 6 }, "40.1": { "line": 198, "col": 4 }, "40.2": { "line": 205, "col": 10 }, "40.3": { "line": 205, "col": 4 }, "40.5": { "line": 206, "col": 28 }, "40.6": { "line": 206, "col": 4 }, "40.7": { "line": 207, "col": 10 }, "40.8": { "line": 207, "col": 4 }, "40.9": { "line": 209, "col": 4 }, "40.10": { "line": 210, "col": 4 }, "40.11": { "line": 211, "col": 10 }, "40.12": { "line": 211, "col": 4 }, "40.13": { "line": 212, "col": 4 } }, "dist/lib/agents/agency-agent/agent.agency:__block_1": {}, "dist/lib/agents/agency-agent/agent.agency:__block_2": { "40.13.0": { "line": 213, "col": 6 } } };
1683
- __registerModuleFingerprint("dist/lib/agents/agency-agent/agent.agency", "e3d680c4c0e63d334fea5de26f09958da25d6b813e8382b46e761c613b67028b", import.meta.url);
1680
+ __registerModuleFingerprint("dist/lib/agents/agency-agent/agent.agency", "54e48be8365083a20f0224bcd479cc8d1519a808d43fbad162c19948613e33a1", import.meta.url);
1684
1681
  export {
1685
1682
  __getCheckpoints,
1686
1683
  __invokeFunction,
@@ -76,8 +76,8 @@ const graph = __globalCtx.graph;
76
76
  function approve(value) {
77
77
  return { type: "approve", value };
78
78
  }
79
- function reject(value) {
80
- return { type: "reject", value };
79
+ function reject(reason) {
80
+ return { type: "reject", value: reason };
81
81
  }
82
82
  function propagate() {
83
83
  return { type: "propagate" };
@@ -176,7 +176,7 @@ const BrainContext = z.object({ "interactive": z.boolean(), "grounding": z.strin
176
176
  const AgentBrain = z.object({ "name": z.string(), "description": z.string(), "session": z.string(), "startTargets": z.array(z.string()), "init": z.string(), "runTurn": z.string() });
177
177
  var stdin_default = graph;
178
178
  const __sourceMap = {};
179
- __registerModuleFingerprint("dist/lib/agents/agency-agent/brains/brain.agency", "7ba76067983debee248c86b1b867d720994d01c83bed4f8889fcde947edfefce", import.meta.url);
179
+ __registerModuleFingerprint("dist/lib/agents/agency-agent/brains/brain.agency", "3f61515fc79421600a5d3fa34afb0233c858cbb7df13e23b46298fff10fb75c8", import.meta.url);
180
180
  export {
181
181
  AgentBrain,
182
182
  BrainContext,
@@ -10,7 +10,7 @@ import { edit } from "std::fs"
10
10
  import { setMemoryId } from "std::memory"
11
11
  import { Attachment, systemMessage } from "std::thread"
12
12
 
13
- import { generateImageFile } from "../../lib/images.agency"
13
+ import { generateImageFile, viewImageFile } from "../../lib/images.agency"
14
14
  import { getMcpTools } from "../../lib/mcp.agency"
15
15
  import { getCapabilities, getSlowModel, getSlowProvider } from "../../shared.agency"
16
16
  import { AgentBrain, BrainContext } from "../brain.agency"
@@ -49,6 +49,7 @@ static const mainAgentTools = [
49
49
  writingAgent,
50
50
  rewriteAgent,
51
51
  generateImageFile,
52
+ viewImageFile,
52
53
  ...readOnlyFileTools(),
53
54
  edit.partial(useAgentCwd: true),
54
55
  ]
@@ -4,7 +4,7 @@ import { now, elapsedTime } from "agency-lang/stdlib/date.js";
4
4
  import { edit } from "agency-lang/stdlib/fs.js";
5
5
  import { setMemoryId } from "agency-lang/stdlib/memory.js";
6
6
  import { systemMessage, Attachment } from "agency-lang/stdlib/thread.js";
7
- import { generateImageFile } from "../../lib/images.js";
7
+ import { generateImageFile, viewImageFile } from "../../lib/images.js";
8
8
  import { getMcpTools } from "../../lib/mcp.js";
9
9
  import { getCapabilities, getSlowModel, getSlowProvider } from "../../shared.js";
10
10
  import { AgentBrain, BrainContext } from "../brain.js";
@@ -53,7 +53,7 @@ import {
53
53
  __registerGlobalsInit,
54
54
  __registerCallbacksInit,
55
55
  registerModuleFingerprint as __registerModuleFingerprint,
56
- failure,
56
+ runtimeFailure,
57
57
  isSuccess,
58
58
  isFailure,
59
59
  stampFailureBoundary,
@@ -121,8 +121,8 @@ const graph = __globalCtx.graph;
121
121
  function approve(value) {
122
122
  return { type: "approve", value };
123
123
  }
124
- function reject(value) {
125
- return { type: "reject", value };
124
+ function reject(reason) {
125
+ return { type: "reject", value: reason };
126
126
  }
127
127
  function propagate() {
128
128
  return { type: "propagate" };
@@ -214,6 +214,7 @@ __registerTool(setMemoryId);
214
214
  __registerTool(systemMessage);
215
215
  __registerTool(Attachment);
216
216
  __registerTool(generateImageFile);
217
+ __registerTool(viewImageFile);
217
218
  __registerTool(getMcpTools);
218
219
  __registerTool(getCapabilities);
219
220
  __registerTool(getSlowModel);
@@ -255,7 +256,7 @@ async function __initializeStatic(__ctx) {
255
256
  } finally {
256
257
  getRuntimeContext().ctx.popHandler();
257
258
  }
258
- 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"), ...await __call(readOnlyFileTools, {
259
+ 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"), __readStatic(viewImageFile, "viewImageFile", "/Users/adityabhargava/agency-lang/packages/agency-lang/dist/lib/agents/agency-agent/lib/images.agency"), ...await __call(readOnlyFileTools, {
259
260
  type: "positional",
260
261
  args: []
261
262
  }), await __callMethod(__readStatic(edit, "edit", "/Users/adityabhargava/agency-lang/packages/agency-lang/stdlib/fs.agency"), "partial", {
@@ -475,15 +476,12 @@ async function __coordinatorInit_impl(context) {
475
476
  functionName: "coordinatorInit"
476
477
  });
477
478
  }
478
- return failure(
479
- __error instanceof Error ? __error.message : String(__error),
480
- {
481
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
482
- destructiveRan: __self.__destructiveRan,
483
- functionName: "coordinatorInit",
484
- args: __stack.args
485
- }
486
- );
479
+ return runtimeFailure(__error, {
480
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
481
+ destructiveRan: __self.__destructiveRan,
482
+ functionName: "coordinatorInit",
483
+ args: __stack.args
484
+ });
487
485
  } finally {
488
486
  __stateStack()?.pop();
489
487
  if (__functionCompleted) {
@@ -787,15 +785,12 @@ async function __mainAgent_impl(prompt) {
787
785
  functionName: "mainAgent"
788
786
  });
789
787
  }
790
- return failure(
791
- __error instanceof Error ? __error.message : String(__error),
792
- {
793
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
794
- destructiveRan: __self.__destructiveRan,
795
- functionName: "mainAgent",
796
- args: __stack.args
797
- }
798
- );
788
+ return runtimeFailure(__error, {
789
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
790
+ destructiveRan: __self.__destructiveRan,
791
+ functionName: "mainAgent",
792
+ args: __stack.args
793
+ });
799
794
  } finally {
800
795
  __stateStack()?.pop();
801
796
  if (__functionCompleted) {
@@ -938,15 +933,12 @@ async function __promptText_impl(prompt) {
938
933
  functionName: "promptText"
939
934
  });
940
935
  }
941
- return failure(
942
- __error instanceof Error ? __error.message : String(__error),
943
- {
944
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
945
- destructiveRan: __self.__destructiveRan,
946
- functionName: "promptText",
947
- args: __stack.args
948
- }
949
- );
936
+ return runtimeFailure(__error, {
937
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
938
+ destructiveRan: __self.__destructiveRan,
939
+ functionName: "promptText",
940
+ args: __stack.args
941
+ });
950
942
  } finally {
951
943
  __stateStack()?.pop();
952
944
  if (__functionCompleted) {
@@ -1084,15 +1076,12 @@ async function __replyText_impl(name, result) {
1084
1076
  functionName: "replyText"
1085
1077
  });
1086
1078
  }
1087
- return failure(
1088
- __error instanceof Error ? __error.message : String(__error),
1089
- {
1090
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
1091
- destructiveRan: __self.__destructiveRan,
1092
- functionName: "replyText",
1093
- args: __stack.args
1094
- }
1095
- );
1079
+ return runtimeFailure(__error, {
1080
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
1081
+ destructiveRan: __self.__destructiveRan,
1082
+ functionName: "replyText",
1083
+ args: __stack.args
1084
+ });
1096
1085
  } finally {
1097
1086
  __stateStack()?.pop();
1098
1087
  if (__functionCompleted) {
@@ -1128,7 +1117,7 @@ const replyText = __AgencyFunction.create({
1128
1117
  toolDefinition: {
1129
1118
  name: "replyText",
1130
1119
  description: "No description provided.",
1131
- schema: z.object({ "name": z.string(), "result": z.union([z.object({ __type: z.literal("resultType"), success: z.literal(true), value: z.string() }), z.object({ __type: z.literal("resultType"), success: z.literal(false), error: z.any() })]) })
1120
+ schema: z.object({ "name": z.string(), "result": z.union([z.object({ __type: z.literal("resultType"), success: z.literal(true), value: z.string() }), z.object({ __type: z.literal("resultType"), success: z.literal(false), error: z.string(), data: z.record(z.any()) })]) })
1132
1121
  },
1133
1122
  exported: false
1134
1123
  }, __toolRegistry);
@@ -1225,15 +1214,12 @@ async function __researchTurn_impl(userMsg) {
1225
1214
  functionName: "researchTurn"
1226
1215
  });
1227
1216
  }
1228
- return failure(
1229
- __error instanceof Error ? __error.message : String(__error),
1230
- {
1231
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
1232
- destructiveRan: __self.__destructiveRan,
1233
- functionName: "researchTurn",
1234
- args: __stack.args
1235
- }
1236
- );
1217
+ return runtimeFailure(__error, {
1218
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
1219
+ destructiveRan: __self.__destructiveRan,
1220
+ functionName: "researchTurn",
1221
+ args: __stack.args
1222
+ });
1237
1223
  } finally {
1238
1224
  __stateStack()?.pop();
1239
1225
  if (__functionCompleted) {
@@ -1376,15 +1362,12 @@ async function __oracleTurn_impl(userMsg) {
1376
1362
  functionName: "oracleTurn"
1377
1363
  });
1378
1364
  }
1379
- return failure(
1380
- __error instanceof Error ? __error.message : String(__error),
1381
- {
1382
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
1383
- destructiveRan: __self.__destructiveRan,
1384
- functionName: "oracleTurn",
1385
- args: __stack.args
1386
- }
1387
- );
1365
+ return runtimeFailure(__error, {
1366
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
1367
+ destructiveRan: __self.__destructiveRan,
1368
+ functionName: "oracleTurn",
1369
+ args: __stack.args
1370
+ });
1388
1371
  } finally {
1389
1372
  __stateStack()?.pop();
1390
1373
  if (__functionCompleted) {
@@ -1527,15 +1510,12 @@ async function __explorerTurn_impl(userMsg) {
1527
1510
  functionName: "explorerTurn"
1528
1511
  });
1529
1512
  }
1530
- return failure(
1531
- __error instanceof Error ? __error.message : String(__error),
1532
- {
1533
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
1534
- destructiveRan: __self.__destructiveRan,
1535
- functionName: "explorerTurn",
1536
- args: __stack.args
1537
- }
1538
- );
1513
+ return runtimeFailure(__error, {
1514
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
1515
+ destructiveRan: __self.__destructiveRan,
1516
+ functionName: "explorerTurn",
1517
+ args: __stack.args
1518
+ });
1539
1519
  } finally {
1540
1520
  __stateStack()?.pop();
1541
1521
  if (__functionCompleted) {
@@ -1944,15 +1924,12 @@ async function __coordinatorRunTurn_impl(target, prompt) {
1944
1924
  functionName: "coordinatorRunTurn"
1945
1925
  });
1946
1926
  }
1947
- return failure(
1948
- __error instanceof Error ? __error.message : String(__error),
1949
- {
1950
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
1951
- destructiveRan: __self.__destructiveRan,
1952
- functionName: "coordinatorRunTurn",
1953
- args: __stack.args
1954
- }
1955
- );
1927
+ return runtimeFailure(__error, {
1928
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
1929
+ destructiveRan: __self.__destructiveRan,
1930
+ functionName: "coordinatorRunTurn",
1931
+ args: __stack.args
1932
+ });
1956
1933
  } finally {
1957
1934
  __stateStack()?.pop();
1958
1935
  if (__functionCompleted) {
@@ -2067,15 +2044,12 @@ async function __coordinatorBrain_impl() {
2067
2044
  functionName: "coordinatorBrain"
2068
2045
  });
2069
2046
  }
2070
- return failure(
2071
- __error instanceof Error ? __error.message : String(__error),
2072
- {
2073
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
2074
- destructiveRan: __self.__destructiveRan,
2075
- functionName: "coordinatorBrain",
2076
- args: __stack.args
2077
- }
2078
- );
2047
+ return runtimeFailure(__error, {
2048
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
2049
+ destructiveRan: __self.__destructiveRan,
2050
+ functionName: "coordinatorBrain",
2051
+ args: __stack.args
2052
+ });
2079
2053
  } finally {
2080
2054
  __stateStack()?.pop();
2081
2055
  if (__functionCompleted) {
@@ -2102,8 +2076,8 @@ const coordinatorBrain = __AgencyFunction.create({
2102
2076
  exported: true
2103
2077
  }, __toolRegistry);
2104
2078
  var stdin_default = graph;
2105
- const __sourceMap = { "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:coordinatorInit": { "1": { "line": 56, "col": 6 }, "2": { "line": 56, "col": 2 }, "3": { "line": 62, "col": 6 }, "4": { "line": 62, "col": 2 }, "5": { "line": 68, "col": 2 }, "6": { "line": 69, "col": 2 }, "7": { "line": 72, "col": 2 }, "2.0": { "line": 58, "col": 6 }, "2.1": { "line": 57, "col": 4 }, "2.2": { "line": 60, "col": 4 }, "4.0": { "line": 64, "col": 6 }, "4.1": { "line": 63, "col": 4 }, "4.2": { "line": 66, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:mainAgent": { "2": { "line": 79, "col": 2 }, "3": { "line": 80, "col": 2 }, "4": { "line": 111, "col": 2 }, "3.0": { "line": 81, "col": 4 }, "3.1.1": { "line": 83, "col": 6 }, "3.1.2": { "line": 84, "col": 24 }, "3.1.3": { "line": 84, "col": 6 }, "3.1.4": { "line": 88, "col": 6 }, "3.1.5": { "line": 89, "col": 6 }, "3.1": { "line": 82, "col": 4 }, "3.3": { "line": 99, "col": 11 }, "3.4": { "line": 101, "col": 8 }, "3.5": { "line": 95, "col": 4 }, "3.6": { "line": 104, "col": 4 }, "3.7.0": { "line": 106, "col": 6 }, "3.7.1": { "line": 107, "col": 6 }, "3.7": { "line": 105, "col": 4 }, "3.8": { "line": 109, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:promptText": { "1": { "line": 117, "col": 9 }, "2": { "line": 117, "col": 9 }, "3": { "line": 117, "col": 2 }, "2.0": { "line": 117, "col": 9 }, "2.1": { "line": 118, "col": 20 }, "2.2": { "line": 118, "col": 20 }, "2.3": { "line": 117, "col": 9 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:replyText": { "1": { "line": 125, "col": 6 }, "2": { "line": 125, "col": 2 }, "3": { "line": 128, "col": 2 }, "2.0": { "line": 126, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:researchTurn": { "1": { "line": 132, "col": 37 }, "2": { "line": 132, "col": 2 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:oracleTurn": { "1": { "line": 140, "col": 2 }, "2": { "line": 141, "col": 2 }, "3": { "line": 144, "col": 2 }, "2.0": { "line": 142, "col": 36 }, "2.1": { "line": 142, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:explorerTurn": { "1": { "line": 148, "col": 2 }, "2": { "line": 149, "col": 2 }, "3": { "line": 152, "col": 2 }, "2.0": { "line": 150, "col": 38 }, "2.1": { "line": 150, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:coordinatorRunTurn": { "1": { "line": 159, "col": 9 }, "2": { "line": 159, "col": 2 }, "1.0": { "line": 160, "col": 24 }, "1.1": { "line": 160, "col": 14 }, "1.2": { "line": 160, "col": 14 }, "1.3": { "line": 161, "col": 31 }, "1.4": { "line": 161, "col": 18 }, "1.5": { "line": 161, "col": 18 }, "1.6": { "line": 162, "col": 27 }, "1.7": { "line": 162, "col": 16 }, "1.8": { "line": 162, "col": 16 }, "1.9": { "line": 163, "col": 31 }, "1.10": { "line": 163, "col": 18 }, "1.11": { "line": 163, "col": 18 }, "1.12": { "line": 164, "col": 28 }, "1.13": { "line": 164, "col": 16 }, "1.14": { "line": 164, "col": 16 }, "1.15": { "line": 165, "col": 30 }, "1.16": { "line": 165, "col": 17 }, "1.17": { "line": 165, "col": 17 }, "1.18": { "line": 166, "col": 30 }, "1.19": { "line": 166, "col": 17 }, "1.20": { "line": 166, "col": 17 }, "1.21": { "line": 167, "col": 9 }, "1.22": { "line": 167, "col": 9 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:coordinatorBrain": { "1": { "line": 172, "col": 2 } } };
2106
- __registerModuleFingerprint("dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency", "cd36a19aceea96dcdc72c74f3ea12a84c11f939155ddd06d8678f66a830a365f", import.meta.url);
2079
+ const __sourceMap = { "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:coordinatorInit": { "1": { "line": 57, "col": 6 }, "2": { "line": 57, "col": 2 }, "3": { "line": 63, "col": 6 }, "4": { "line": 63, "col": 2 }, "5": { "line": 69, "col": 2 }, "6": { "line": 70, "col": 2 }, "7": { "line": 73, "col": 2 }, "2.0": { "line": 59, "col": 6 }, "2.1": { "line": 58, "col": 4 }, "2.2": { "line": 61, "col": 4 }, "4.0": { "line": 65, "col": 6 }, "4.1": { "line": 64, "col": 4 }, "4.2": { "line": 67, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:mainAgent": { "2": { "line": 80, "col": 2 }, "3": { "line": 81, "col": 2 }, "4": { "line": 112, "col": 2 }, "3.0": { "line": 82, "col": 4 }, "3.1.1": { "line": 84, "col": 6 }, "3.1.2": { "line": 85, "col": 24 }, "3.1.3": { "line": 85, "col": 6 }, "3.1.4": { "line": 89, "col": 6 }, "3.1.5": { "line": 90, "col": 6 }, "3.1": { "line": 83, "col": 4 }, "3.3": { "line": 100, "col": 11 }, "3.4": { "line": 102, "col": 8 }, "3.5": { "line": 96, "col": 4 }, "3.6": { "line": 105, "col": 4 }, "3.7.0": { "line": 107, "col": 6 }, "3.7.1": { "line": 108, "col": 6 }, "3.7": { "line": 106, "col": 4 }, "3.8": { "line": 110, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:promptText": { "1": { "line": 118, "col": 9 }, "2": { "line": 118, "col": 9 }, "3": { "line": 118, "col": 2 }, "2.0": { "line": 118, "col": 9 }, "2.1": { "line": 119, "col": 20 }, "2.2": { "line": 119, "col": 20 }, "2.3": { "line": 118, "col": 9 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:replyText": { "1": { "line": 126, "col": 6 }, "2": { "line": 126, "col": 2 }, "3": { "line": 129, "col": 2 }, "2.0": { "line": 127, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:researchTurn": { "1": { "line": 133, "col": 37 }, "2": { "line": 133, "col": 2 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:oracleTurn": { "1": { "line": 141, "col": 2 }, "2": { "line": 142, "col": 2 }, "3": { "line": 145, "col": 2 }, "2.0": { "line": 143, "col": 36 }, "2.1": { "line": 143, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:explorerTurn": { "1": { "line": 149, "col": 2 }, "2": { "line": 150, "col": 2 }, "3": { "line": 153, "col": 2 }, "2.0": { "line": 151, "col": 38 }, "2.1": { "line": 151, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:coordinatorRunTurn": { "1": { "line": 160, "col": 9 }, "2": { "line": 160, "col": 2 }, "1.0": { "line": 161, "col": 24 }, "1.1": { "line": 161, "col": 14 }, "1.2": { "line": 161, "col": 14 }, "1.3": { "line": 162, "col": 31 }, "1.4": { "line": 162, "col": 18 }, "1.5": { "line": 162, "col": 18 }, "1.6": { "line": 163, "col": 27 }, "1.7": { "line": 163, "col": 16 }, "1.8": { "line": 163, "col": 16 }, "1.9": { "line": 164, "col": 31 }, "1.10": { "line": 164, "col": 18 }, "1.11": { "line": 164, "col": 18 }, "1.12": { "line": 165, "col": 28 }, "1.13": { "line": 165, "col": 16 }, "1.14": { "line": 165, "col": 16 }, "1.15": { "line": 166, "col": 30 }, "1.16": { "line": 166, "col": 17 }, "1.17": { "line": 166, "col": 17 }, "1.18": { "line": 167, "col": 30 }, "1.19": { "line": 167, "col": 17 }, "1.20": { "line": 167, "col": 17 }, "1.21": { "line": 168, "col": 9 }, "1.22": { "line": 168, "col": 9 } }, "dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency:coordinatorBrain": { "1": { "line": 173, "col": 2 } } };
2080
+ __registerModuleFingerprint("dist/lib/agents/agency-agent/brains/coordinator/coordinator.agency", "51fae42c747cbc264d1d2d4bf4c318959d496a1336bd87b630753b61a0429790", import.meta.url);
2107
2081
  export {
2108
2082
  __getCheckpoints,
2109
2083
  __invokeFunction,
@@ -32,7 +32,7 @@ import {
32
32
  __registerGlobalsInit,
33
33
  __registerCallbacksInit,
34
34
  registerModuleFingerprint as __registerModuleFingerprint,
35
- failure,
35
+ runtimeFailure,
36
36
  isFailure,
37
37
  stampFailureBoundary,
38
38
  __nn,
@@ -94,8 +94,8 @@ const graph = __globalCtx.graph;
94
94
  function approve(value) {
95
95
  return { type: "approve", value };
96
96
  }
97
- function reject(value) {
98
- return { type: "reject", value };
97
+ function reject(reason) {
98
+ return { type: "reject", value: reason };
99
99
  }
100
100
  function propagate() {
101
101
  return { type: "propagate" };
@@ -324,15 +324,12 @@ async function __announce_impl(agentName, userMsg) {
324
324
  functionName: "announce"
325
325
  });
326
326
  }
327
- return failure(
328
- __error instanceof Error ? __error.message : String(__error),
329
- {
330
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
331
- destructiveRan: __self.__destructiveRan,
332
- functionName: "announce",
333
- args: __stack.args
334
- }
335
- );
327
+ return runtimeFailure(__error, {
328
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
329
+ destructiveRan: __self.__destructiveRan,
330
+ functionName: "announce",
331
+ args: __stack.args
332
+ });
336
333
  } finally {
337
334
  __stateStack()?.pop();
338
335
  if (__functionCompleted) {
@@ -468,15 +465,12 @@ async function __stripControlChars_impl(text) {
468
465
  functionName: "stripControlChars"
469
466
  });
470
467
  }
471
- return failure(
472
- __error instanceof Error ? __error.message : String(__error),
473
- {
474
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
475
- destructiveRan: __self.__destructiveRan,
476
- functionName: "stripControlChars",
477
- args: __stack.args
478
- }
479
- );
468
+ return runtimeFailure(__error, {
469
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
470
+ destructiveRan: __self.__destructiveRan,
471
+ functionName: "stripControlChars",
472
+ args: __stack.args
473
+ });
480
474
  } finally {
481
475
  __stateStack()?.pop();
482
476
  if (__functionCompleted) {
@@ -511,7 +505,7 @@ const stripControlChars = __AgencyFunction.create({
511
505
  }, __toolRegistry);
512
506
  var stdin_default = graph;
513
507
  const __sourceMap = { "dist/lib/agents/agency-agent/brains/coordinator/lib/announce.agency:announce": { "1": { "line": 11, "col": 31 }, "2": { "line": 11, "col": 2 }, "3": { "line": 12, "col": 2 }, "4": { "line": 15, "col": 8 }, "5": { "line": 15, "col": 2 }, "3.0": { "line": 13, "col": 11 }, "3.1": { "line": 13, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/lib/announce.agency:stripControlChars": { "1": { "line": 21, "col": 2 }, "2": { "line": 22, "col": 20 }, "3": { "line": 22, "col": 2 }, "4": { "line": 27, "col": 2 }, "3.0.0": { "line": 24, "col": 6 }, "3.0": { "line": 23, "col": 4 } } };
514
- __registerModuleFingerprint("dist/lib/agents/agency-agent/brains/coordinator/lib/announce.agency", "9e49c274c1bb5075dac5f22307759a05a3d1ca56053f1e723a108ceb0ba612d6", import.meta.url);
508
+ __registerModuleFingerprint("dist/lib/agents/agency-agent/brains/coordinator/lib/announce.agency", "155f4481fbf4cad6842b4fcad4e7c9b7b5cf01e20f9c860826e5f5fb0c6a7f6a", import.meta.url);
515
509
  export {
516
510
  __getCheckpoints,
517
511
  __invokeFunction,
@@ -35,6 +35,7 @@ import {
35
35
  registerModuleFingerprint as __registerModuleFingerprint,
36
36
  success,
37
37
  failure,
38
+ runtimeFailure,
38
39
  isFailure,
39
40
  stampFailureBoundary,
40
41
  __eq,
@@ -95,8 +96,8 @@ const graph = __globalCtx.graph;
95
96
  function approve(value) {
96
97
  return { type: "approve", value };
97
98
  }
98
- function reject(value) {
99
- return { type: "reject", value };
99
+ function reject(reason) {
100
+ return { type: "reject", value: reason };
100
101
  }
101
102
  function propagate() {
102
103
  return { type: "propagate" };
@@ -284,15 +285,12 @@ async function __timeBudget_impl(maxSeconds, fallback) {
284
285
  functionName: "timeBudget"
285
286
  });
286
287
  }
287
- return failure(
288
- __error instanceof Error ? __error.message : String(__error),
289
- {
290
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
291
- destructiveRan: __self.__destructiveRan,
292
- functionName: "timeBudget",
293
- args: __stack.args
294
- }
295
- );
288
+ return runtimeFailure(__error, {
289
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
290
+ destructiveRan: __self.__destructiveRan,
291
+ functionName: "timeBudget",
292
+ args: __stack.args
293
+ });
296
294
  } finally {
297
295
  __stateStack()?.pop();
298
296
  if (__functionCompleted) {
@@ -413,15 +411,12 @@ async function __costBudget_impl(maxDollars, fallback) {
413
411
  functionName: "costBudget"
414
412
  });
415
413
  }
416
- return failure(
417
- __error instanceof Error ? __error.message : String(__error),
418
- {
419
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
420
- destructiveRan: __self.__destructiveRan,
421
- functionName: "costBudget",
422
- args: __stack.args
423
- }
424
- );
414
+ return runtimeFailure(__error, {
415
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
416
+ destructiveRan: __self.__destructiveRan,
417
+ functionName: "costBudget",
418
+ args: __stack.args
419
+ });
425
420
  } finally {
426
421
  __stateStack()?.pop();
427
422
  if (__functionCompleted) {
@@ -563,15 +558,12 @@ async function __describeTrip_impl(trip) {
563
558
  functionName: "describeTrip"
564
559
  });
565
560
  }
566
- return failure(
567
- __error instanceof Error ? __error.message : String(__error),
568
- {
569
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
570
- destructiveRan: __self.__destructiveRan,
571
- functionName: "describeTrip",
572
- args: __stack.args
573
- }
574
- );
561
+ return runtimeFailure(__error, {
562
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
563
+ destructiveRan: __self.__destructiveRan,
564
+ functionName: "describeTrip",
565
+ args: __stack.args
566
+ });
575
567
  } finally {
576
568
  __stateStack()?.pop();
577
569
  if (__functionCompleted) {
@@ -716,7 +708,7 @@ async function __budgeted_impl(label, block) {
716
708
  });
717
709
  await runner2.step(1, async (runner3) => {
718
710
  __functionCompleted = true;
719
- runner3.halt(failure(__stack.locals.__hoist_0, { checkpoint: getRuntimeContext().ctx.getResultCheckpoint(), functionName: "budgeted", args: __stack.args }));
711
+ runner3.halt(failure(__stack.locals.__hoist_0, null, { checkpoint: getRuntimeContext().ctx.getResultCheckpoint(), functionName: "budgeted", args: __stack.args }));
720
712
  return;
721
713
  });
722
714
  }
@@ -740,7 +732,7 @@ async function __budgeted_impl(label, block) {
740
732
  body: async (runner2) => {
741
733
  await runner2.step(0, async (runner3) => {
742
734
  __functionCompleted = true;
743
- runner3.halt(failure(`${__stack.locals.result.error}`, { checkpoint: getRuntimeContext().ctx.getResultCheckpoint(), functionName: "budgeted", args: __stack.args }));
735
+ runner3.halt(failure(`${__stack.locals.result.error}`, null, { checkpoint: getRuntimeContext().ctx.getResultCheckpoint(), functionName: "budgeted", args: __stack.args }));
744
736
  return;
745
737
  });
746
738
  }
@@ -752,7 +744,7 @@ async function __budgeted_impl(label, block) {
752
744
  body: async (runner2) => {
753
745
  await runner2.step(0, async (runner3) => {
754
746
  __functionCompleted = true;
755
- runner3.halt(failure(`it returned no answer`, { checkpoint: getRuntimeContext().ctx.getResultCheckpoint(), functionName: "budgeted", args: __stack.args }));
747
+ runner3.halt(failure(`it returned no answer`, null, { checkpoint: getRuntimeContext().ctx.getResultCheckpoint(), functionName: "budgeted", args: __stack.args }));
756
748
  return;
757
749
  });
758
750
  }
@@ -789,15 +781,12 @@ async function __budgeted_impl(label, block) {
789
781
  functionName: "budgeted"
790
782
  });
791
783
  }
792
- return failure(
793
- __error instanceof Error ? __error.message : String(__error),
794
- {
795
- checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
796
- destructiveRan: __self.__destructiveRan,
797
- functionName: "budgeted",
798
- args: __stack.args
799
- }
800
- );
784
+ return runtimeFailure(__error, {
785
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
786
+ destructiveRan: __self.__destructiveRan,
787
+ functionName: "budgeted",
788
+ args: __stack.args
789
+ });
801
790
  } finally {
802
791
  __stateStack()?.pop();
803
792
  if (__functionCompleted) {
@@ -846,7 +835,7 @@ const budgeted = __AgencyFunction.create({
846
835
  }, __toolRegistry);
847
836
  var stdin_default = graph;
848
837
  const __sourceMap = { "dist/lib/agents/agency-agent/brains/coordinator/lib/budgets.agency:timeBudget": { "1": { "line": 9, "col": 2 }, "2": { "line": 12, "col": 2 }, "1.0": { "line": 10, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/lib/budgets.agency:costBudget": { "1": { "line": 17, "col": 2 } }, "dist/lib/agents/agency-agent/brains/coordinator/lib/budgets.agency:describeTrip": { "1": { "line": 21, "col": 2 }, "2": { "line": 24, "col": 2 }, "1.0": { "line": 22, "col": 33 }, "1.1": { "line": 22, "col": 4 } }, "dist/lib/agents/agency-agent/brains/coordinator/lib/budgets.agency:budgeted": { "1": { "line": 38, "col": 2 }, "2": { "line": 39, "col": 2 }, "3": { "line": 40, "col": 2 }, "4": { "line": 49, "col": 2 }, "5": { "line": 52, "col": 6 }, "6": { "line": 52, "col": 2 }, "7": { "line": 55, "col": 2 }, "8": { "line": 58, "col": 2 }, "3.0": { "line": 41, "col": 4 }, "4.0": { "line": 50, "col": 19 }, "4.1": { "line": 50, "col": 4 }, "6.0": { "line": 53, "col": 4 }, "7.0": { "line": 56, "col": 4 } } };
849
- __registerModuleFingerprint("dist/lib/agents/agency-agent/brains/coordinator/lib/budgets.agency", "87eebf3b56d4eab390b34b92fd9304e23ea125f84b4cdb5c93212f4e82a5b755", import.meta.url);
838
+ __registerModuleFingerprint("dist/lib/agents/agency-agent/brains/coordinator/lib/budgets.agency", "13760f7485ecdb8baa4977e6a24a5e09d8c279ca2dc4cb7547a8e5056532622c", import.meta.url);
850
839
  export {
851
840
  __getCheckpoints,
852
841
  __invokeFunction,