@spendgraph/tools 0.5.0 → 0.7.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 (258) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +26 -258
  3. package/dist/agents/index.d.ts +1 -0
  4. package/dist/agents/index.js +1 -0
  5. package/dist/agents/moa/design.js +5 -0
  6. package/dist/agents/moa/http.js +1 -0
  7. package/dist/{builtin/write-document/write-document.d.ts → agents/moa/index.d.ts} +7 -2
  8. package/dist/agents/moa/index.js +1 -0
  9. package/dist/{builtin/write-document/commission.d.ts → agents/moa/moa.d.ts} +15 -15
  10. package/dist/agents/moa/moa.js +13 -0
  11. package/dist/{builtin/write-document → agents/moa}/types.d.ts +9 -9
  12. package/dist/agents/moa/types.js +0 -0
  13. package/dist/bogus/ask-mum.d.ts +5 -0
  14. package/dist/bogus/ask-mum.js +1 -0
  15. package/dist/bogus/book-taxi.d.ts +9 -0
  16. package/dist/bogus/book-taxi.js +1 -0
  17. package/dist/bogus/bus.d.ts +8 -0
  18. package/dist/bogus/bus.js +1 -0
  19. package/dist/bogus/calculator.d.ts +14 -0
  20. package/dist/bogus/calculator.js +1 -0
  21. package/dist/bogus/dictionary.d.ts +6 -0
  22. package/dist/bogus/dictionary.js +1 -0
  23. package/dist/bogus/feed-cat.d.ts +8 -0
  24. package/dist/bogus/feed-cat.js +1 -0
  25. package/dist/bogus/football-score.d.ts +6 -0
  26. package/dist/bogus/football-score.js +1 -0
  27. package/dist/bogus/gold-price.d.ts +7 -0
  28. package/dist/bogus/gold-price.js +1 -0
  29. package/dist/bogus/index.d.ts +14 -0
  30. package/dist/bogus/index.js +1 -0
  31. package/dist/bogus/my-calendar.d.ts +6 -0
  32. package/dist/bogus/my-calendar.js +1 -0
  33. package/dist/bogus/my-notes.d.ts +6 -0
  34. package/dist/bogus/my-notes.js +1 -0
  35. package/dist/bogus/my-recipes.d.ts +6 -0
  36. package/dist/bogus/my-recipes.js +1 -0
  37. package/dist/bogus/order-pizza.d.ts +12 -0
  38. package/dist/bogus/order-pizza.js +1 -0
  39. package/dist/bogus/prayer-times.d.ts +6 -0
  40. package/dist/bogus/prayer-times.js +1 -0
  41. package/dist/bogus/receipt.d.ts +8 -0
  42. package/dist/bogus/receipt.js +1 -0
  43. package/dist/builtin/calculate/calculate.d.ts +2 -0
  44. package/dist/builtin/calculate/calculate.js +1 -21
  45. package/dist/builtin/calculate/exact.d.ts +16 -0
  46. package/dist/builtin/calculate/exact.js +1 -0
  47. package/dist/builtin/calculate/index.d.ts +2 -1
  48. package/dist/builtin/calculate/index.js +1 -2
  49. package/dist/builtin/calculate/parse.js +1 -137
  50. package/dist/builtin/clock/clock.js +1 -61
  51. package/dist/builtin/clock/index.js +1 -1
  52. package/dist/builtin/code-exec/code-exec.d.ts +42 -0
  53. package/dist/builtin/code-exec/code-exec.js +1 -0
  54. package/dist/builtin/code-exec/index.d.ts +1 -0
  55. package/dist/builtin/code-exec/index.js +1 -0
  56. package/dist/builtin/date/date.d.ts +1 -1
  57. package/dist/builtin/date/date.js +1 -41
  58. package/dist/builtin/date/index.d.ts +1 -0
  59. package/dist/builtin/date/index.js +1 -2
  60. package/dist/builtin/date/shift.d.ts +1 -1
  61. package/dist/builtin/date/shift.js +1 -47
  62. package/dist/builtin/date/words.d.ts +13 -0
  63. package/dist/builtin/date/words.js +1 -0
  64. package/dist/builtin/decline/decline.d.ts +49 -0
  65. package/dist/builtin/decline/decline.js +1 -0
  66. package/dist/builtin/decline/index.d.ts +1 -0
  67. package/dist/builtin/decline/index.js +1 -0
  68. package/dist/builtin/escalate/escalate.d.ts +19 -0
  69. package/dist/builtin/escalate/escalate.js +1 -20
  70. package/dist/builtin/escalate/index.d.ts +1 -1
  71. package/dist/builtin/escalate/index.js +1 -1
  72. package/dist/builtin/extract/extract.d.ts +25 -0
  73. package/dist/builtin/extract/extract.js +1 -0
  74. package/dist/builtin/extract/index.d.ts +3 -0
  75. package/dist/builtin/extract/index.js +1 -0
  76. package/dist/builtin/extract/kinds.d.ts +6 -0
  77. package/dist/builtin/extract/kinds.js +1 -0
  78. package/dist/builtin/extract/readers.d.ts +7 -0
  79. package/dist/builtin/extract/readers.js +9 -0
  80. package/dist/builtin/finish/finish.d.ts +4 -0
  81. package/dist/builtin/finish/finish.js +1 -26
  82. package/dist/builtin/finish/index.js +1 -1
  83. package/dist/builtin/http/allow.d.ts +2 -0
  84. package/dist/builtin/http/allow.js +1 -37
  85. package/dist/builtin/http/hops.d.ts +10 -0
  86. package/dist/builtin/http/hops.js +1 -0
  87. package/dist/builtin/http/http.d.ts +9 -1
  88. package/dist/builtin/http/http.js +1 -41
  89. package/dist/builtin/http/index.d.ts +2 -0
  90. package/dist/builtin/http/index.js +1 -2
  91. package/dist/builtin/http/retry-after.d.ts +14 -0
  92. package/dist/builtin/http/retry-after.js +1 -0
  93. package/dist/builtin/index.d.ts +11 -6
  94. package/dist/builtin/index.js +1 -11
  95. package/dist/builtin/json/index.d.ts +1 -0
  96. package/dist/builtin/json/index.js +1 -2
  97. package/dist/builtin/json/json.js +1 -37
  98. package/dist/builtin/json/parse.d.ts +15 -0
  99. package/dist/builtin/json/parse.js +1 -0
  100. package/dist/builtin/json/path.js +1 -56
  101. package/dist/builtin/notes/index.d.ts +1 -0
  102. package/dist/builtin/notes/index.js +1 -0
  103. package/dist/builtin/notes/notes.d.ts +45 -0
  104. package/dist/builtin/notes/notes.js +2 -0
  105. package/dist/builtin/openalex/api.d.ts +22 -0
  106. package/dist/builtin/openalex/api.js +1 -0
  107. package/dist/builtin/openalex/index.d.ts +4 -0
  108. package/dist/builtin/openalex/index.js +1 -0
  109. package/dist/builtin/openalex/openalex.d.ts +23 -0
  110. package/dist/builtin/openalex/openalex.js +1 -0
  111. package/dist/builtin/openalex/render.d.ts +2 -0
  112. package/dist/builtin/openalex/render.js +4 -0
  113. package/dist/builtin/polite.d.ts +14 -0
  114. package/dist/builtin/polite.js +1 -0
  115. package/dist/builtin/publish/index.d.ts +1 -0
  116. package/dist/builtin/publish/index.js +1 -0
  117. package/dist/builtin/publish/publish.d.ts +46 -0
  118. package/dist/builtin/publish/publish.js +1 -0
  119. package/dist/builtin/think/index.js +1 -1
  120. package/dist/builtin/think/think.js +1 -12
  121. package/dist/builtin/web-search/index.js +1 -1
  122. package/dist/builtin/web-search/web-search.d.ts +10 -30
  123. package/dist/builtin/web-search/web-search.js +1 -103
  124. package/dist/builtin/wikidata/api.d.ts +40 -0
  125. package/dist/builtin/wikidata/api.js +1 -0
  126. package/dist/builtin/wikidata/index.d.ts +5 -0
  127. package/dist/builtin/wikidata/index.js +1 -0
  128. package/dist/builtin/wikidata/render.d.ts +13 -0
  129. package/dist/builtin/wikidata/render.js +2 -0
  130. package/dist/builtin/wikidata/wikidata.d.ts +21 -0
  131. package/dist/builtin/wikidata/wikidata.js +1 -0
  132. package/dist/bus/args.d.ts +11 -0
  133. package/dist/bus/args.js +1 -0
  134. package/dist/bus/bus.d.ts +23 -1
  135. package/dist/bus/bus.js +1 -49
  136. package/dist/bus/group.d.ts +21 -0
  137. package/dist/bus/group.js +1 -0
  138. package/dist/bus/index.d.ts +4 -0
  139. package/dist/bus/index.js +1 -2
  140. package/dist/bus/invoke.d.ts +1 -1
  141. package/dist/bus/invoke.js +3 -43
  142. package/dist/bus/namespace.d.ts +21 -0
  143. package/dist/bus/namespace.js +1 -0
  144. package/dist/bus/once.d.ts +32 -0
  145. package/dist/bus/once.js +1 -0
  146. package/dist/bus/only.d.ts +29 -0
  147. package/dist/bus/only.js +0 -0
  148. package/dist/bus/options.d.ts +31 -0
  149. package/dist/bus/options.js +0 -1
  150. package/dist/bus/output.d.ts +26 -0
  151. package/dist/bus/output.js +2 -0
  152. package/dist/bus/overlap.js +1 -31
  153. package/dist/bus/score.d.ts +11 -9
  154. package/dist/bus/score.js +1 -12
  155. package/dist/bus/select.d.ts +2 -17
  156. package/dist/bus/select.js +1 -44
  157. package/dist/bus/spent.d.ts +16 -0
  158. package/dist/bus/spent.js +1 -0
  159. package/dist/bus/step.js +1 -11
  160. package/dist/bus/terms.d.ts +25 -0
  161. package/dist/bus/terms.js +1 -0
  162. package/dist/bus/trace.d.ts +14 -1
  163. package/dist/bus/trace.js +1 -22
  164. package/dist/index.d.ts +16 -4
  165. package/dist/index.js +1 -3
  166. package/dist/internals.d.ts +9 -2
  167. package/dist/internals.js +1 -10
  168. package/dist/memories/client.d.ts +91 -0
  169. package/dist/memories/client.js +0 -0
  170. package/dist/memories/context.d.ts +5 -0
  171. package/dist/memories/context.js +1 -0
  172. package/dist/memories/deep-recall/deep-recall.d.ts +67 -0
  173. package/dist/memories/deep-recall/deep-recall.js +1 -0
  174. package/dist/memories/deep-recall/index.d.ts +1 -0
  175. package/dist/memories/deep-recall/index.js +1 -0
  176. package/dist/memories/explore/explore.d.ts +18 -0
  177. package/dist/memories/explore/explore.js +7 -0
  178. package/dist/memories/explore/subgraph.d.ts +12 -0
  179. package/dist/memories/explore/subgraph.js +3 -0
  180. package/dist/memories/index.d.ts +30 -0
  181. package/dist/memories/index.js +1 -0
  182. package/dist/memories/observe/observe.d.ts +7 -0
  183. package/dist/memories/observe/observe.js +1 -0
  184. package/dist/memories/recall/recall.d.ts +42 -0
  185. package/dist/memories/recall/recall.js +1 -0
  186. package/dist/memories/recall/render.d.ts +5 -0
  187. package/dist/memories/recall/render.js +3 -0
  188. package/dist/memories/remember/remember.d.ts +49 -0
  189. package/dist/memories/remember/remember.js +1 -0
  190. package/dist/search/index.d.ts +5 -0
  191. package/dist/search/index.js +1 -0
  192. package/dist/search/retry.d.ts +6 -0
  193. package/dist/search/retry.js +1 -0
  194. package/dist/search/search.d.ts +63 -0
  195. package/dist/search/search.js +1 -0
  196. package/dist/search/searxng/index.d.ts +2 -0
  197. package/dist/search/searxng/index.js +1 -0
  198. package/dist/search/searxng/searxng.d.ts +14 -0
  199. package/dist/search/searxng/searxng.js +5 -0
  200. package/dist/search/searxng/text.d.ts +2 -0
  201. package/dist/search/searxng/text.js +3 -0
  202. package/dist/search/sonar/index.d.ts +2 -0
  203. package/dist/search/sonar/index.js +1 -0
  204. package/dist/search/sonar/reply.js +1 -0
  205. package/dist/search/sonar/sonar.d.ts +13 -0
  206. package/dist/search/sonar/sonar.js +1 -0
  207. package/dist/search/tavily/index.d.ts +4 -0
  208. package/dist/search/tavily/index.js +1 -0
  209. package/dist/search/tavily/reply.d.ts +22 -0
  210. package/dist/search/tavily/reply.js +5 -0
  211. package/dist/search/tavily/tavily.d.ts +14 -0
  212. package/dist/search/tavily/tavily.js +1 -0
  213. package/dist/testing/index.d.ts +2 -0
  214. package/dist/testing/index.js +1 -0
  215. package/dist/testing/replay.d.ts +55 -0
  216. package/dist/testing/replay.js +1 -0
  217. package/dist/testing/store.d.ts +35 -0
  218. package/dist/testing/store.js +4 -0
  219. package/dist/tool/bind.js +1 -64
  220. package/dist/tool/index.js +1 -2
  221. package/dist/tool/tool.d.ts +5 -1
  222. package/dist/tool/tool.js +1 -51
  223. package/dist/types/index.d.ts +1 -1
  224. package/dist/types/index.js +0 -1
  225. package/dist/types/result.d.ts +38 -0
  226. package/dist/types/result.js +0 -1
  227. package/dist/types/tool.d.ts +74 -0
  228. package/dist/types/tool.js +0 -1
  229. package/dist/wire/index.js +1 -3
  230. package/dist/wire/json-schema.js +1 -65
  231. package/dist/wire/markdown.d.ts +5 -3
  232. package/dist/wire/markdown.js +9 -29
  233. package/dist/wire/providers.js +1 -18
  234. package/docs/bogus.mdx +85 -0
  235. package/docs/builtins.mdx +156 -0
  236. package/docs/bus.mdx +90 -0
  237. package/docs/declaring.mdx +85 -0
  238. package/docs/effects.mdx +49 -0
  239. package/docs/overview.mdx +76 -0
  240. package/docs/selecting.mdx +79 -0
  241. package/docs/stored.mdx +83 -0
  242. package/docs/turns.mdx +57 -0
  243. package/package.json +28 -11
  244. package/dist/builtin/deep-recall/deep-recall.d.ts +0 -27
  245. package/dist/builtin/deep-recall/deep-recall.js +0 -45
  246. package/dist/builtin/deep-recall/index.d.ts +0 -1
  247. package/dist/builtin/deep-recall/index.js +0 -1
  248. package/dist/builtin/web-search/reply.js +0 -27
  249. package/dist/builtin/write-document/commission.js +0 -152
  250. package/dist/builtin/write-document/design.js +0 -86
  251. package/dist/builtin/write-document/http.js +0 -71
  252. package/dist/builtin/write-document/index.d.ts +0 -6
  253. package/dist/builtin/write-document/index.js +0 -4
  254. package/dist/builtin/write-document/types.js +0 -1
  255. package/dist/builtin/write-document/write-document.js +0 -142
  256. /package/dist/{builtin/write-document → agents/moa}/design.d.ts +0 -0
  257. /package/dist/{builtin/write-document → agents/moa}/http.d.ts +0 -0
  258. /package/dist/{builtin/web-search → search/sonar}/reply.d.ts +0 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 spendgraph
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -2,281 +2,49 @@
2
2
 
3
3
  Declare a tool once, offer the right few, and record what was called.
4
4
 
5
- ```sh
5
+ ```bash
6
6
  npm install @spendgraph/tools
7
7
  ```
8
8
 
9
- Three things are exported. Everything else hangs off what they return.
10
-
11
9
  ```ts
12
- import { tool, toolbus, currentTime } from "@spendgraph/tools";
13
- ```
14
-
15
- ## Declaring one
10
+ import { calculate, tool, toolbus } from "@spendgraph/tools";
16
11
 
17
- A description the model reads and a function you wrote, in one object. Splitting
18
- them — a schema here, a handler there, matched by string — is how a rename
19
- becomes a runtime failure mid-loop.
20
-
21
- ```ts
22
12
  const lookup = tool({
23
13
  name: "lookup_contract",
24
14
  description: "Finds a contract clause by its reference, such as MSA 2.4.",
25
- args: [
26
- { name: "ref", type: "string", required: true },
27
- { name: "limit", type: "number", required: false },
28
- { name: "mode", type: "enum", required: false, options: ["fast", "thorough"] },
29
- ] as const,
30
- run: ({ ref, limit, mode }) => search(ref, limit ?? 5, mode ?? "fast"),
15
+ args: [{ name: "ref", type: "string", required: true }] as const,
16
+ run: ({ ref }) => search(ref),
31
17
  });
32
- ```
33
-
34
- **Write `as const` and the handler types itself.** `ref` arrives a string,
35
- `limit` a number, `mode` narrowed to its two options, and the optional ones
36
- optional. Rename an argument and the handler stops compiling — rather than being
37
- handed `undefined` halfway through an agent loop.
38
-
39
- The description is the biggest lever on whether the model calls it correctly, and
40
- worth iterating on more than the code is.
41
-
42
- Every check `tool` makes is something a provider either rejects opaquely or
43
- accepts and behaves oddly about — a name a provider will not take, an enum with
44
- no options, a blank option the model can legally pick and you cannot act on.
45
- They fire at import, not on the first loop in production.
46
-
47
- ## What a tool does
48
-
49
- ```ts
50
- tool({
51
- name: "issue_refund",
52
- description: "Refund a charge to the original card.",
53
- effect: "destructive",
54
- args,
55
- run,
56
- });
57
- ```
58
-
59
- Without it `issue_refund` and `lookup_clause` are the same thing to a bus: two
60
- names with schemas. Nothing can tell what is safe to retry, safe to run twice,
61
- or worth asking a person about first.
62
-
63
- | | |
64
- | --- | --- |
65
- | `readonly` | no effect outside the process |
66
- | `idempotent` | has an effect, but twice is the same as once |
67
- | `destructive` | neither, so never retry it on its own |
68
-
69
- Three values, not a taxonomy — anything finer does not get filled in
70
- accurately.
71
18
 
72
- **There is no default, and unset is not `readonly`.** A default would quietly
73
- label every tool written before this existed as safe, which is the one mistake
74
- that matters here. Unset means nobody has said.
75
-
76
- ```ts
77
- bus.effectOf("issue_refund") // "destructive", or undefined if it never said
78
- bus.destructive() // ["issue_refund"]
79
- bus.unannotated() // ["send_email"]
19
+ const bus = toolbus([lookup, calculate()], { limit: 6 });
20
+ const turn = bus.trace(question);
80
21
  ```
81
22
 
82
- `destructive()` returns only the tools that said so, so a gate built on it alone
83
- lets an unlabelled one through. `unannotated()` is how you find those — assert
84
- it is empty in a test and a new tool cannot join the bus unlabelled.
85
-
86
- It rides along on `declarations()` and survives `select()`, which is where a
87
- gate reads it. Every provider shape drops it: no API has a field for it, and an
88
- unknown key is rejected or ignored.
89
-
90
- Two builtins leave it unset on purpose. `http_request` is a GET or a POST
91
- depending on an argument, and one label cannot be true of both; `escalate` runs
92
- your `onEscalate`, and paging someone twice is not the same as paging them once.
93
-
94
- ## The bus
23
+ ## What you get
95
24
 
96
- ```ts
97
- const bus = toolbus([lookup, currentTime()], { limit: 6 });
98
- ```
99
-
100
- Holding them in one place is what makes selection possible. Fifty tools at
101
- roughly 150 tokens of declaration each is 7.5k tokens on every call before the
102
- user has said anything, so past a point you stop sending all of them.
25
+ - **A description and a handler in one object**, so a rename is a compile error
26
+ rather than an `undefined` mid-loop.
27
+ - **A shortlist, not a catalogue.** Fifty tools is 7.5k tokens before the user
28
+ has said anything, and more tools makes a model worse at picking.
29
+ - **Effects**, so a gate can refuse what it must not retry — and name the tools
30
+ nobody labelled.
31
+ - **Twenty-two builtins and twelve mocks**, none registered for you. Four of them
32
+ are one memory set, with an in-process store for testing it offline.
103
33
 
104
- ```ts
105
- bus.select(query) // the working set for one request
106
- bus.anthropic(decls?) // declarations, per provider
107
- bus.openai(decls?)
108
- bus.markdown(decls?) // for a model with no tools API
109
- await bus.invoke(name, args)
110
- bus.missing(["refund"]) // names something expects that this bus lacks
111
- bus.usage()
112
- ```
113
-
114
- `limit` is an accuracy budget, not a token one: more tools in front of a model
115
- makes it worse at picking the right one regardless of context length. Measured
116
- shortlists cluster around five to eight. Pinned tools count against it.
117
-
118
- Selection is keyword and usage, deliberately — no embedding provider, no extra
119
- call, no latency. It is also the baseline that says what embeddings would buy.
120
-
121
- `missing` catches a silent failure: a prompt edited to expect a `refund` tool,
122
- deployed against a bus without one, does not error. The agent is never offered it
123
- and answers anyway.
124
-
125
- ## One turn
126
-
127
- ```ts
128
- const turn = bus.trace(query);
129
-
130
- const reply = await llm.call(messages, { tools: turn });
131
- await turn.invoke(call.name, call.args);
132
-
133
- turn.record(); // { offeredTools, steps }
134
- ```
135
-
136
- A turn is selected once and remembers what it offered. Which tools were offered
137
- is recorded as well as which were called: without it a record cannot tell "chose
138
- not to" from "was never offered", which are opposite bugs.
139
-
140
- It plugs straight into `@spendgraph/prompt` — `call` and `invoke` take anything
141
- that hands out a turn, and neither package imports the other.
142
-
143
- ```ts
144
- await prompt.call(values, ({ messages, turn }) => llm.call(messages, { tools: turn }), {
145
- tools: bus,
146
- });
147
- ```
148
-
149
- ## Builtins
150
-
151
- Eight, each a factory, none registered for you — this package's own advice is
152
- that more tools in front of a model makes it worse at picking, so they are opt-in
153
- one at a time.
154
-
155
- ```ts
156
- import { calculate, currentTime, escalate, finish, think, httpRequest } from "@spendgraph/tools";
157
-
158
- const bus = toolbus([
159
- calculate(),
160
- think(),
161
- finish(),
162
- currentTime({ defaultTimeZone: "Europe/London" }),
163
- escalate({ onEscalate: (r) => pager.page(r) }),
164
- httpRequest({ allow: [".example.com"], headers: { authorization: `Bearer ${key}` } }),
165
- ]);
166
- ```
34
+ ## Docs
167
35
 
168
36
  | | |
169
37
  | --- | --- |
170
- | `calculate()` | arithmetic, **parsed not evaluated** |
171
- | `think()` | a scratchpad that does nothing |
172
- | `finish()` | the model says it is done, and what the answer is |
173
- | `currentTime()` | the clock a model does not have |
174
- | `escalate()` | hand back to a person; `pinned` by default |
175
- | `dateMath()` | add, subtract and difference, in whole units |
176
- | `jsonQuery()` | one value out of a JSON document, by path |
177
- | `httpRequest()` | a GET or POST to hosts you named |
178
- | `writeDocument()` | a document agent that returns a rendered file |
179
-
180
- **`calculate`** parses the expression — numbers, `+ - * / % ^`, brackets, and
181
- `sqrt abs round floor ceil ln log` — and refuses everything else. `eval` on model
182
- output is arbitrary code execution with extra steps.
183
-
184
- **`think`** returns `"noted"` and changes nothing. That is the point: the thought
185
- lands in the steps instead of in the reply, and a model given room to plan before
186
- a multi-step sequence uses the tools better.
187
-
188
- **`finish`** gives a loop a real stop condition. Without it a run ends when the
189
- model goes quiet, which is indistinguishable from it losing the thread. Read the
190
- result with `isFinished(result)` and `answerOf(result)`.
191
-
192
- **`current_time`** is the clock a model does not have. Asked for today's date it
193
- will otherwise produce its training cutoff, confidently. A wrong IANA zone throws
194
- rather than falling back, because a confidently wrong time is the failure this
195
- exists to stop.
196
-
197
- **`escalate`** is `pinned: true`, because a refusal route lost to a similarity
198
- score is exactly the failure `pinned` exists for — the one turn that needs it is
199
- the turn where nothing else fit. Without an `onEscalate` it records the request
200
- and reports `delivered: false`, rather than letting the model believe a person
201
- was reached.
202
-
203
- **`dateMath`** is what `current_time` leads to: the clock says when now is, this
204
- works out what follows. Calendar months clamp rather than overflow — a month
205
- after 31 January is 28 February, not 3 March, which is what `setMonth` gives and
206
- what every billing system disagrees with. `difference` counts boundaries crossed
207
- rather than dividing elapsed milliseconds, because a month is not 30 days and a
208
- year is not 365.
209
-
210
- **`jsonQuery`** reads one value out of a document by path — `invoices[0].total`,
211
- or `invoices[*].total` for every element. After a wildcard the rest of the path
212
- keeps applying to each element, so `invoices[*].lines[0].sku` is the first line
213
- of every invoice, not the lines of the first. A path that matches nothing comes
214
- back `found: false` rather than `null`, which a model would otherwise read as the
215
- answer.
216
-
217
- **`httpRequest`** takes a **required** allowlist and has no default. It is https
218
- only, refuses private, loopback, link-local and `.internal`/`.local` hosts even
219
- if you list them, and sets headers itself so a credential is never something the
220
- model can redirect. `"api.example.com"` matches that host; `".example.com"`
221
- matches it and any subdomain. If the guard feels heavy, that is the correct
222
- amount of heavy: this is the one builtin that can exfiltrate.
223
-
224
- ## `write_document`
225
-
226
- ```ts
227
- toolbus([
228
- writeDocument({
229
- apiKey: env.MOA_API_KEY,
230
- design: {
231
- name: "Northwind",
232
- fonts: { heading: "Söhne" },
233
- palette: { accent: "#E11D48" },
234
- rules: ["Never set body text below 11pt."],
235
- },
236
- }),
237
- ]);
238
- ```
239
-
240
- Commissions a Moa agent to write and render a real file — `.pdf`, `.pptx`,
241
- `.docx`, `.md` — and hands back where to download it. Everything else in this
242
- package answers a question; this one produces the document somebody opens.
243
-
244
- Style is the deployment's business and content is the model's. `design` is laid
245
- over `DEFAULT_DESIGN`: named fields win, `rules` accumulate, and the merged
246
- guide is rendered into the task as a `<design>` block along with the craft that
247
- belongs to the format asked for — a deck gets "one idea per slide, the title is
248
- the claim", a PDF gets "nothing straddles a page break". The model may pass
249
- `design_notes` to bend the guide for one document; it cannot replace it.
250
-
251
- A rendered document is minutes, so the wait defaults to ten of them and
252
- long-polls rather than tight-polls. When even that runs out the result comes
253
- back `status: "running"` with the `taskId`, because the money is already spent
254
- and a lost id makes the model commission it twice. Stop the turn and the task is
255
- cancelled server-side.
256
-
257
- It is the one builtin marked `destructive`, and not because it breaks anything:
258
- a second call is a second bill and a second set of files, so it is never safe to
259
- retry on its own.
260
-
261
- ## Examples
262
-
263
- Eight of them under [`examples/`](./examples), all runnable with no API key and
264
- no network — tools are local code; the model only decides which to call.
265
-
266
- ```sh
267
- npm run build
268
- node examples/02-select/01-shortlist.mjs
269
- ```
270
-
271
- ## Subpaths
272
-
273
- | | |
274
- | --- | --- |
275
- | `@spendgraph/tools/wire` | `toAnthropic` · `toOpenAI` · `toJsonSchema` · `toMarkdown` |
276
- | `@spendgraph/tools/internals` | `selectTools` · `score` · `invokeTool` · `newTrace` · `toStep` · `warnOnOverlap` |
277
-
278
- A bus already wires all of `internals`; reach for it to build your own.
38
+ | [Overview](https://spendgraph.locusgraph.com/docs/tools/overview) | A tool, a bus, and a turn |
39
+ | [Declaring a tool](https://spendgraph.locusgraph.com/docs/tools/declaring) | Args, as const, and what is checked at import |
40
+ | [A stored tool](https://spendgraph.locusgraph.com/docs/tools/stored) | Wording in the dashboard, handler in code |
41
+ | [Effects](https://spendgraph.locusgraph.com/docs/tools/effects) | What running one does to the world outside |
42
+ | [The bus](https://spendgraph.locusgraph.com/docs/tools/bus) | Holds, picks, converts, runs and nests |
43
+ | [Selecting](https://spendgraph.locusgraph.com/docs/tools/selecting) | The shortlist, and why it is a shortlist |
44
+ | [A turn](https://spendgraph.locusgraph.com/docs/tools/turns) | Offered, called, and what the rollout keeps |
45
+ | [Builtins](https://spendgraph.locusgraph.com/docs/tools/builtins) | Sixteen factories, none registered for you |
46
+ | [Bogus tools](https://spendgraph.locusgraph.com/docs/tools/bogus) | Twelve mocks for testing the pipeline, not the provider |
279
47
 
280
48
  ## License
281
49
 
282
- MIT
50
+ Apache-2.0
@@ -0,0 +1 @@
1
+ export { type ArtifactFormat, DEFAULT_DESIGN, type DesignGuide, MoaAbortedError, type MoaClient, MoaTimeoutError, mergeDesign, renderDesign, type WriteDocumentOptions, writeDocument, } from "./moa/index.js";
@@ -0,0 +1 @@
1
+ import{DEFAULT_DESIGN as o,MoaAbortedError as t,MoaTimeoutError as D,mergeDesign as i,renderDesign as m,writeDocument as n}from"./moa/index.js";export{o as DEFAULT_DESIGN,t as MoaAbortedError,D as MoaTimeoutError,i as mergeDesign,m as renderDesign,n as writeDocument};
@@ -0,0 +1,5 @@
1
+ const c={name:"Spendgraph house style",fonts:{heading:"Inter",body:"Inter",mono:"JetBrains Mono"},palette:{primary:"#0F172A",accent:"#2563EB",text:"#111827",muted:"#64748B",surface:"#FFFFFF"},layout:"A4 portrait, 20mm margins, a single text column at 60-75 characters, a 4pt spacing scale, and one heading scale used consistently (28/20/16/12). Whitespace is the design.",charts:"One message per figure, stated in its caption. Label series directly where there are three or fewer. No 3D, no gradients, no gridline heavier than the data, no pie chart past three slices, and axes that start at zero unless the caption says why not.",tone:"Plain and specific. Lead with the finding, then the evidence. No filler adjectives, no throat-clearing, no sentence that survives being deleted.",rules:["A cover carrying the title, date and author, and no other ornament.","Every number traceable to something in the source material; invent nothing.","Tables for anything being compared; prose for anything being argued.","No stock imagery, no clip art, no placeholder text in the finished file.","Page numbers on every page after the cover."]},d={pdf:"Cover, then contents if it runs past four pages, then the body. Figures captioned and referenced from the text. Nothing straddles a page break: no orphan heading, no split table row.",pptx:"16:9. One idea per slide, and the title is that idea as a sentence \u2014 a claim, not a label. At most six lines of body per slide, one figure per slide at most, and everything you cut goes into the speaker notes. Close on decisions and next steps, not on 'thank you'.",docx:"Real Word styles for headings rather than manual bold, a table-of-contents field rather than a typed list, a header row on every table, and captions on figures.",md:"A title heading, ATX headings throughout, tables for comparisons, fenced code with a language tag, and no HTML."};function i(e,t){return e?t?{...e,...t}:e:t}function h(e,t){return t?{...e,...t,fonts:i(e.fonts,t.fonts),palette:i(e.palette,t.palette),rules:[...e.rules??[],...t.rules??[]]}:e}const a=(e,t)=>t?[`${e}: ${t}`]:[];function p(e,t,o){const{fonts:r,palette:n}=e;return[...a("Style",e.name),...a("Typefaces",[r?.heading&&`headings ${r.heading}`,r?.body&&`body ${r.body}`,r?.mono&&`code ${r.mono}`].filter(Boolean).join(", ")||void 0),...a("Palette",[n?.primary&&`primary ${n.primary}`,n?.accent&&`accent ${n.accent}`,n?.text&&`text ${n.text}`,n?.muted&&`muted ${n.muted}`,n?.surface&&`surface ${n.surface}`].filter(Boolean).join(", ")||void 0),...a("Layout",e.layout),...a("Figures",e.charts),...a("Voice",e.tone),...a("Logo",e.logoUrl),`Format craft (.${t}): ${d[t]}`,...e.rules?.length?[`Rules:
2
+ ${e.rules.map(s=>`- ${s}`).join(`
3
+ `)}`]:[],...o?.trim()?[`Overrides for this document, which win over everything above:
4
+ ${o.trim()}`]:[]].join(`
5
+ `)}export{c as DEFAULT_DESIGN,h as mergeDesign,p as renderDesign};
@@ -0,0 +1 @@
1
+ const f="https://api.fnmoa.com",M=6e4,_=500;class c extends Error{status;detail;constructor(t,s,n){super(n?`${t}: ${n}`:t),this.name="MoaApiError",this.status=s,this.detail=n}}function T(e){const t=e.cause;return t?.code??t?.message??e.message}function m(e,t){const s=new AbortController,n=()=>s.abort();let r=!1;const o=setTimeout(()=>{r=!0,n()},e);return t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n(),{signal:s.signal,expired:()=>r,release:()=>{clearTimeout(o),t?.removeEventListener("abort",n)}}}function $(e={}){const t=e.fetch??globalThis.fetch.bind(globalThis),s=(e.baseUrl??f).replace(/\/+$/,"");return async function(r,o={}){const u=o.timeoutMs??e.timeoutMs??6e4,i=o.method??"GET",d=`${s}${r}`,{signal:E,expired:h,release:b}=m(u,o.signal);try{const a=await t(d,{method:i,signal:E,headers:{...e.apiKey?{authorization:`Bearer ${e.apiKey}`}:{},...o.body===void 0?{}:{"content-type":"application/json"}},...o.body===void 0?{}:{body:JSON.stringify(o.body)}}).catch(l=>{throw o.signal?.aborted?l:h()?new c(`Moa did not answer ${i} ${r}`,504,`${u}ms`):new c(`Moa is unreachable at ${d}`,0,T(l))});if(!a.ok)throw new c(`Moa returned ${a.status} for ${i} ${r}`,a.status,(await a.text()).slice(0,500));return a.status===204?void 0:await a.json()}finally{b()}}}export{f as MOA_BASE_URL,c as MoaApiError,$ as createRequest};
@@ -1,6 +1,6 @@
1
- import { type CommissionClient } from "./commission.js";
2
1
  import { type DesignGuide } from "./design.js";
3
2
  import type { AbortSignalLike } from "./http.js";
3
+ import { type MoaClient } from "./moa.js";
4
4
  import type { ArtifactFormat } from "./types.js";
5
5
  export interface WriteDocumentOptions {
6
6
  /** Moa key. Required, and read from here rather than the environment. */
@@ -25,7 +25,7 @@ export interface WriteDocumentOptions {
25
25
  /** Longest write-up handed back. Default 4000 characters. */
26
26
  maxChars?: number;
27
27
  /** Injected for tests, and for anyone fronting Moa with their own transport. */
28
- client?: CommissionClient;
28
+ client?: MoaClient;
29
29
  /** Injected for tests. */
30
30
  fetch?: typeof fetch;
31
31
  }
@@ -67,3 +67,8 @@ export declare function writeDocument(opts: WriteDocumentOptions): import("../..
67
67
  readonly required: false;
68
68
  readonly description: string;
69
69
  }]>>;
70
+ export { DEFAULT_DESIGN, type DesignGuide, mergeDesign, renderDesign } from "./design.js";
71
+ export { MOA_BASE_URL, MoaApiError, type MoaClientConfig } from "./http.js";
72
+ export type { MoaClient, PollOptions } from "./moa.js";
73
+ export { createMoaClient, INTERACTIVE_TIMEOUT_MS, MoaAbortedError, MoaTimeoutError, pollUntilDone, } from "./moa.js";
74
+ export type { ArtifactFormat, MoaArtifact, MoaInput, MoaResult, MoaStatus, } from "./types.js";
@@ -0,0 +1 @@
1
+ import{tool as f}from"../../tool/index.js";import{DEFAULT_DESIGN as l,mergeDesign as h,renderDesign as g}from"./design.js";import{createMoaClient as p,MoaAbortedError as w,MoaTimeoutError as y,pollUntilDone as M}from"./moa.js";const _=["pdf","pptx","docx","md"],E=6e5,x=2e3,T=4e3;function A(e,r){return`Commissions a document agent to write and render a finished file \u2014 ${e.map(t=>`.${t}`).join(", ")} \u2014 and hands back where to download it. Use it when the answer has to be a document somebody opens: a report, a deck, a proposal, a one-pager. Not for text you can simply write in your reply. It runs for minutes and it costs money, so brief it once and brief it fully \u2014 the agent cannot see this conversation, so every fact, figure and quote it must use goes in \`source\`. Design is already settled by ${r.name??"the house style"}; use \`design_notes\` only for what this one document must do differently.`}function U(e,r,t,d){const i=(e.artifacts??[]).map(o=>({name:o.name,format:o.format,url:o.url,mime:o.mime,sizeBytes:o.sizeBytes,...d&&o.data?{data:o.data}:{}}));return{taskId:e.id,sessionId:e.sessionId,status:"done",style:r,documents:i,delivered:i.length>0,writeUp:e.output?.slice(0,t),truncated:(e.output?.length??0)>t,turns:e.numTurns,costMicroUsd:e.costUsd===void 0?void 0:Math.round(e.costUsd*1e6)}}function b(e,r,t){return{taskId:e,status:"running",style:r,documents:[],delivered:!1,note:`Still rendering after ${Math.round(t.timeoutMs/1e3)}s. The task is not lost \u2014 say so rather than commissioning it again.`}}function L(e){if(!e.client&&!e.apiKey?.trim())throw new Error("writeDocument needs a Moa apiKey; it will not read one from the process.");const r=e.formats?.length?e.formats:_,t=h(l,e.design),d=e.maxChars??T,i=e.client??p({apiKey:e.apiKey,baseUrl:e.baseUrl,...e.fetch?{fetch:e.fetch}:{}});return f({name:"write_document",description:A(r,t),effect:"destructive",args:[{name:"brief",type:"text",required:!0,maxLength:8e3,description:"What to produce, who reads it, what it must cover and how long it runs. Write it as you would brief a person who knows the craft and nothing about this account."},{name:"format",type:"enum",required:!0,options:["pdf","pptx","docx","md"],description:"pptx for anything presented, pdf for anything sent, docx for anything edited."},{name:"source",type:"text",required:!1,maxLength:4e4,description:"The material it must build from \u2014 figures, findings, quotes, an outline \u2014 verbatim. Anything missing here the agent will either omit or invent."},{name:"design_notes",type:"text",required:!1,maxLength:2e3,description:"How this one document departs from the house style, in plain words. Leave it empty unless the user asked for something specific."},{name:"session_id",type:"string",required:!1,description:"Continue an earlier write_document instead of starting over \u2014 take it from that result's sessionId. Use it to revise a document or to recast one into another format."}],run:async({brief:o,format:s,source:u,design_notes:m,session_id:c})=>{if(!r.includes(s))throw new Error(`write_document was asked for .${s}, which this deployment does not produce (${r.map(n=>`.${n}`).join(", ")}).`);const a=await i.create({task:o,context:u,design:g(t,s,m),artifacts:[s],...c?{sessionId:c}:{}});try{const n=await M(i,a,{timeoutMs:e.timeoutMs??E,settleMs:x,expectArtifacts:!0,...e.signal?{signal:e.signal}:{}});if(n.status==="failed")throw new Error(`write_document: Moa task ${a} failed: ${n.error??"no reason given"}`);return U(n,t.name,d,e.includeData===!0)}catch(n){if(n instanceof w&&e.cancelOnAbort!==!1&&await i.cancel?.(a).catch(()=>{}),n instanceof y)return b(a,t.name,n);throw n}}})}import{DEFAULT_DESIGN as $,mergeDesign as q,renderDesign as C}from"./design.js";import{MOA_BASE_URL as O,MoaApiError as R}from"./http.js";import{createMoaClient as N,INTERACTIVE_TIMEOUT_MS as B,MoaAbortedError as j,MoaTimeoutError as z,pollUntilDone as G}from"./moa.js";export{$ as DEFAULT_DESIGN,B as INTERACTIVE_TIMEOUT_MS,O as MOA_BASE_URL,j as MoaAbortedError,R as MoaApiError,z as MoaTimeoutError,N as createMoaClient,q as mergeDesign,G as pollUntilDone,C as renderDesign,L as writeDocument};
@@ -1,5 +1,5 @@
1
1
  import { type AbortSignalLike, type MoaClientConfig } from "./http.js";
2
- import type { CommissionInput, CommissionResult } from "./types.js";
2
+ import type { MoaInput, MoaResult } from "./types.js";
3
3
  /**
4
4
  * Moa's task surface — fire, then await.
5
5
  *
@@ -7,40 +7,40 @@ import type { CommissionInput, CommissionResult } from "./types.js";
7
7
  * (or use {@link pollUntilDone}) to long-poll, so one call is awaited rather
8
8
  * than a loop tight-polling. `cancel()` is optional so a test stub stays small.
9
9
  */
10
- export interface CommissionClient {
11
- create(input: CommissionInput): Promise<string>;
10
+ export interface MoaClient {
11
+ create(input: MoaInput): Promise<string>;
12
12
  get(id: string, opts?: {
13
13
  waitMs?: number;
14
14
  signal?: AbortSignalLike;
15
- }): Promise<CommissionResult>;
15
+ }): Promise<MoaResult>;
16
16
  cancel?(id: string): Promise<void>;
17
17
  }
18
18
  /**
19
- * HTTP {@link CommissionClient} over Moa's task API (`POST /tasks` → `GET /tasks/:id`).
19
+ * HTTP {@link MoaClient} over Moa's task API (`POST /tasks` → `GET /tasks/:id`).
20
20
  *
21
21
  * The request body carries the ask as prose — Moa's artifact pipeline is
22
22
  * prompt-driven and `POST /tasks` strips unknown fields, so context, design and
23
23
  * deliverables are blocks on the task rather than parameters beside it.
24
24
  */
25
- export declare function createCommissionClient(config?: MoaClientConfig): CommissionClient;
25
+ export declare function createMoaClient(config?: MoaClientConfig): MoaClient;
26
26
  /** The sane ceiling for a chat-bound call. A rendered document wants minutes, not this. */
27
27
  export declare const INTERACTIVE_TIMEOUT_MS = 30000;
28
28
  /** Thrown by {@link pollUntilDone} when the caller's abort signal fires. */
29
- export declare class CommissionAbortedError extends Error {
30
- readonly commissionId: string;
31
- constructor(commissionId: string);
29
+ export declare class MoaAbortedError extends Error {
30
+ readonly taskId: string;
31
+ constructor(taskId: string);
32
32
  }
33
33
  /** Thrown when the wait ran out. The task itself is still running server-side. */
34
- export declare class CommissionTimeoutError extends Error {
35
- readonly commissionId: string;
34
+ export declare class MoaTimeoutError extends Error {
35
+ readonly taskId: string;
36
36
  readonly timeoutMs: number;
37
- constructor(commissionId: string, timeoutMs: number);
37
+ constructor(taskId: string, timeoutMs: number);
38
38
  }
39
39
  export interface PollOptions {
40
40
  timeoutMs?: number;
41
41
  pollIntervalMs?: number;
42
42
  /**
43
- * Stops the wait and throws {@link CommissionAbortedError}, cutting the held
43
+ * Stops the wait and throws {@link MoaAbortedError}, cutting the held
44
44
  * long-poll with it. The task keeps running — cancelling it is the caller's call.
45
45
  */
46
46
  signal?: AbortSignalLike;
@@ -52,5 +52,5 @@ export interface PollOptions {
52
52
  /** Keep settling while a done task carries no artifacts. Set it when files were asked for. */
53
53
  expectArtifacts?: boolean;
54
54
  }
55
- /** Wait for a commission to settle, long-polling rather than tight-polling. */
56
- export declare function pollUntilDone(client: CommissionClient, id: string, opts?: PollOptions): Promise<CommissionResult>;
55
+ /** Wait for a Moa task to settle, long-polling rather than tight-polling. */
56
+ export declare function pollUntilDone(client: MoaClient, id: string, opts?: PollOptions): Promise<MoaResult>;