liminal 0.5.1 → 0.5.3

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 (673) hide show
  1. package/Agent.ts +28 -0
  2. package/CHANGELOG.md +16 -0
  3. package/Fiber.ts +117 -0
  4. package/Globals.ts +10 -0
  5. package/Handler.ts +0 -0
  6. package/L/L.ts +13 -0
  7. package/L/_infer.ts +35 -0
  8. package/L/_message.ts +18 -0
  9. package/L/all.ts +11 -0
  10. package/L/assistant.ts +34 -0
  11. package/L/branch.ts +45 -0
  12. package/L/emit.ts +11 -0
  13. package/L/fork.ts +18 -0
  14. package/L/join.ts +9 -0
  15. package/L/model.ts +11 -0
  16. package/L/namespace.ts +11 -0
  17. package/L/rune.ts +19 -0
  18. package/L/self.ts +13 -0
  19. package/L/state.ts +20 -0
  20. package/L/system.ts +13 -0
  21. package/L/user.ts +13 -0
  22. package/LEvent.ts +35 -0
  23. package/Message.ts +11 -90
  24. package/Model.ts +10 -17
  25. package/Rune.ts +17 -0
  26. package/Runic.ts +22 -0
  27. package/cli/main.ts +1 -19
  28. package/dist/Agent.d.ts +12 -0
  29. package/dist/Agent.js +16 -0
  30. package/dist/Agent.js.map +1 -0
  31. package/dist/Fiber.d.ts +38 -0
  32. package/dist/Fiber.js +79 -0
  33. package/dist/Fiber.js.map +1 -0
  34. package/dist/Globals.d.ts +7 -0
  35. package/dist/Globals.js +2 -0
  36. package/dist/Globals.js.map +1 -0
  37. package/dist/Handler.js +2 -0
  38. package/dist/Handler.js.map +1 -0
  39. package/dist/L/L.d.ts +13 -0
  40. package/dist/L/L.js +14 -0
  41. package/dist/L/L.js.map +1 -0
  42. package/dist/L/_infer.d.ts +4 -0
  43. package/dist/L/_infer.js +29 -0
  44. package/dist/L/_infer.js.map +1 -0
  45. package/dist/L/_message.d.ts +6 -0
  46. package/dist/L/_message.js +14 -0
  47. package/dist/L/_message.js.map +1 -0
  48. package/dist/L/all.d.ts +7 -0
  49. package/dist/L/all.js +5 -0
  50. package/dist/L/all.js.map +1 -0
  51. package/dist/L/assistant.d.ts +7 -0
  52. package/dist/L/assistant.js +23 -0
  53. package/dist/L/assistant.js.map +1 -0
  54. package/dist/L/branch.d.ts +11 -0
  55. package/dist/L/branch.js +32 -0
  56. package/dist/L/branch.js.map +1 -0
  57. package/dist/L/emit.d.ts +5 -0
  58. package/dist/L/emit.js +7 -0
  59. package/dist/L/emit.js.map +1 -0
  60. package/dist/L/fork.d.ts +7 -0
  61. package/dist/L/fork.js +11 -0
  62. package/dist/L/fork.js.map +1 -0
  63. package/dist/L/join.d.ts +5 -0
  64. package/dist/L/join.js +5 -0
  65. package/dist/L/join.js.map +1 -0
  66. package/dist/L/model.d.ts +5 -0
  67. package/dist/L/model.js +7 -0
  68. package/dist/L/model.js.map +1 -0
  69. package/dist/L/namespace.js +12 -0
  70. package/dist/L/namespace.js.map +1 -0
  71. package/dist/L/rune.d.ts +6 -0
  72. package/dist/L/rune.js +11 -0
  73. package/dist/L/rune.js.map +1 -0
  74. package/dist/L/self.d.ts +6 -0
  75. package/dist/L/self.js +7 -0
  76. package/dist/L/self.js.map +1 -0
  77. package/dist/L/state.d.ts +7 -0
  78. package/dist/L/state.js +14 -0
  79. package/dist/L/state.js.map +1 -0
  80. package/dist/L/system.d.ts +6 -0
  81. package/dist/L/system.js +7 -0
  82. package/dist/L/system.js.map +1 -0
  83. package/dist/L/user.d.ts +6 -0
  84. package/dist/L/user.js +7 -0
  85. package/dist/L/user.js.map +1 -0
  86. package/dist/LEvent.d.ts +28 -0
  87. package/dist/LEvent.js +5 -0
  88. package/dist/LEvent.js.map +1 -0
  89. package/dist/Message.d.ts +12 -81
  90. package/dist/Model.d.ts +4 -15
  91. package/dist/Model.js +6 -0
  92. package/dist/Model.js.map +1 -1
  93. package/dist/Rune.d.ts +11 -0
  94. package/dist/Rune.js +5 -0
  95. package/dist/Rune.js.map +1 -0
  96. package/dist/Runic.d.ts +9 -0
  97. package/dist/Runic.js +18 -0
  98. package/dist/Runic.js.map +1 -0
  99. package/dist/cli/main.d.ts +0 -1
  100. package/dist/cli/main.js +2 -14
  101. package/dist/cli/main.js.map +1 -1
  102. package/dist/index.d.ts +10 -40
  103. package/dist/index.js +10 -40
  104. package/dist/index.js.map +1 -1
  105. package/dist/state/Counter.d.ts +6 -0
  106. package/dist/state/Counter.js +13 -0
  107. package/dist/state/Counter.js.map +1 -0
  108. package/dist/state/DefaultStateMap.d.ts +4 -0
  109. package/dist/state/DefaultStateMap.js +14 -0
  110. package/dist/state/DefaultStateMap.js.map +1 -0
  111. package/dist/state/MessageRegistry.d.ts +7 -0
  112. package/dist/state/MessageRegistry.js +14 -0
  113. package/dist/state/MessageRegistry.js.map +1 -0
  114. package/dist/state/ModelConfig.d.ts +49 -0
  115. package/dist/state/ModelConfig.js +18 -0
  116. package/dist/state/ModelConfig.js.map +1 -0
  117. package/dist/state/ModelRegistry.d.ts +15 -0
  118. package/dist/state/ModelRegistry.js +43 -0
  119. package/dist/state/ModelRegistry.js.map +1 -0
  120. package/dist/state/StateMap.d.ts +7 -0
  121. package/dist/state/StateMap.js +10 -0
  122. package/dist/state/StateMap.js.map +1 -0
  123. package/dist/tsconfig.tsbuildinfo +1 -1
  124. package/index.ts +10 -40
  125. package/package.json +6 -9
  126. package/state/Counter.ts +11 -0
  127. package/state/DefaultStateMap.ts +14 -0
  128. package/state/MessageRegistry.ts +17 -0
  129. package/state/ModelConfig.ts +49 -0
  130. package/state/ModelRegistry.ts +55 -0
  131. package/state/StateMap.ts +15 -0
  132. package/tsconfig.json +5 -1
  133. package/Action.ts +0 -29
  134. package/Actor.ts +0 -20
  135. package/Exec.ts +0 -63
  136. package/L.ts +0 -27
  137. package/LiminalAssertionError.ts +0 -3
  138. package/LiminalConfig.ts +0 -7
  139. package/PathLike.ts +0 -19
  140. package/Scope.ts +0 -133
  141. package/Spec.ts +0 -29
  142. package/Tool.ts +0 -58
  143. package/_.ts +0 -11
  144. package/actions/abort.ts +0 -23
  145. package/actions/actions_common/updateModels.ts +0 -23
  146. package/actions/actions_derived/__snapshots__/declareModel.test.ts.snap +0 -89
  147. package/actions/actions_derived/clear.ts +0 -6
  148. package/actions/actions_derived/declareModel.test.ts +0 -33
  149. package/actions/actions_derived/declareModel.ts +0 -9
  150. package/actions/actions_derived/declareModel.type-test.ts +0 -70
  151. package/actions/actions_derived/getMessages.ts +0 -9
  152. package/actions/actions_derived/messages.test.ts +0 -88
  153. package/actions/actions_derived/messages.ts +0 -19
  154. package/actions/actions_derived/metatype.ts +0 -9
  155. package/actions/appendMessage.ts +0 -30
  156. package/actions/await.ts +0 -13
  157. package/actions/branch.ts +0 -108
  158. package/actions/catch.ts +0 -42
  159. package/actions/declareArg.ts +0 -14
  160. package/actions/disableTool.ts +0 -26
  161. package/actions/embed.ts +0 -28
  162. package/actions/emit.ts +0 -21
  163. package/actions/enableTool.ts +0 -75
  164. package/actions/enableTool.type-test.ts +0 -118
  165. package/actions/getScope.ts +0 -11
  166. package/actions/getSignal.ts +0 -10
  167. package/actions/getTools.ts +0 -11
  168. package/actions/infer.ts +0 -37
  169. package/actions/pushModel.ts +0 -32
  170. package/actions/removeMessage.ts +0 -22
  171. package/actions/removeModel.ts +0 -31
  172. package/actions/setMessages.ts +0 -66
  173. package/actions/throw.ts +0 -18
  174. package/cli/WriteHandler.ts +0 -35
  175. package/cli/cli_common.ts +0 -3
  176. package/cli/runExec.ts +0 -68
  177. package/dist/Action.d.ts +0 -15
  178. package/dist/Action.js +0 -13
  179. package/dist/Action.js.map +0 -1
  180. package/dist/Actor.d.ts +0 -14
  181. package/dist/Actor.js +0 -2
  182. package/dist/Actor.js.map +0 -1
  183. package/dist/Exec.d.ts +0 -27
  184. package/dist/Exec.js +0 -22
  185. package/dist/Exec.js.map +0 -1
  186. package/dist/L.d.ts +0 -26
  187. package/dist/L.js +0 -27
  188. package/dist/L.js.map +0 -1
  189. package/dist/LiminalAssertionError.d.ts +0 -3
  190. package/dist/LiminalAssertionError.js +0 -4
  191. package/dist/LiminalAssertionError.js.map +0 -1
  192. package/dist/LiminalConfig.d.ts +0 -6
  193. package/dist/LiminalConfig.js +0 -2
  194. package/dist/LiminalConfig.js.map +0 -1
  195. package/dist/PathLike.d.ts +0 -14
  196. package/dist/PathLike.js +0 -2
  197. package/dist/PathLike.js.map +0 -1
  198. package/dist/Scope.d.ts +0 -36
  199. package/dist/Scope.js +0 -90
  200. package/dist/Scope.js.map +0 -1
  201. package/dist/Spec.d.ts +0 -20
  202. package/dist/Spec.js +0 -2
  203. package/dist/Spec.js.map +0 -1
  204. package/dist/Tool.d.ts +0 -21
  205. package/dist/Tool.js +0 -32
  206. package/dist/Tool.js.map +0 -1
  207. package/dist/_.d.ts +0 -5
  208. package/dist/_.js +0 -7
  209. package/dist/_.js.map +0 -1
  210. package/dist/actions/abort.d.ts +0 -9
  211. package/dist/actions/abort.js +0 -15
  212. package/dist/actions/abort.js.map +0 -1
  213. package/dist/actions/actions_common/updateModels.d.ts +0 -3
  214. package/dist/actions/actions_common/updateModels.js +0 -17
  215. package/dist/actions/actions_common/updateModels.js.map +0 -1
  216. package/dist/actions/actions_derived/clear.d.ts +0 -8
  217. package/dist/actions/actions_derived/clear.js +0 -5
  218. package/dist/actions/actions_derived/clear.js.map +0 -1
  219. package/dist/actions/actions_derived/declareModel.d.ts +0 -5
  220. package/dist/actions/actions_derived/declareModel.js +0 -7
  221. package/dist/actions/actions_derived/declareModel.js.map +0 -1
  222. package/dist/actions/actions_derived/declareModel.test.js +0 -32
  223. package/dist/actions/actions_derived/declareModel.test.js.map +0 -1
  224. package/dist/actions/actions_derived/declareModel.type-test.js +0 -66
  225. package/dist/actions/actions_derived/declareModel.type-test.js.map +0 -1
  226. package/dist/actions/actions_derived/getMessages.d.ts +0 -3
  227. package/dist/actions/actions_derived/getMessages.js +0 -8
  228. package/dist/actions/actions_derived/getMessages.js.map +0 -1
  229. package/dist/actions/actions_derived/messages.d.ts +0 -6
  230. package/dist/actions/actions_derived/messages.js +0 -15
  231. package/dist/actions/actions_derived/messages.js.map +0 -1
  232. package/dist/actions/actions_derived/messages.test.d.ts +0 -1
  233. package/dist/actions/actions_derived/messages.test.js +0 -72
  234. package/dist/actions/actions_derived/messages.test.js.map +0 -1
  235. package/dist/actions/actions_derived/metatype.d.ts +0 -9
  236. package/dist/actions/actions_derived/metatype.js +0 -7
  237. package/dist/actions/actions_derived/metatype.js.map +0 -1
  238. package/dist/actions/appendMessage.d.ts +0 -10
  239. package/dist/actions/appendMessage.js +0 -20
  240. package/dist/actions/appendMessage.js.map +0 -1
  241. package/dist/actions/await.d.ts +0 -5
  242. package/dist/actions/await.js +0 -10
  243. package/dist/actions/await.js.map +0 -1
  244. package/dist/actions/branch.d.ts +0 -35
  245. package/dist/actions/branch.js +0 -40
  246. package/dist/actions/branch.js.map +0 -1
  247. package/dist/actions/catch.d.ts +0 -10
  248. package/dist/actions/catch.js +0 -27
  249. package/dist/actions/catch.js.map +0 -1
  250. package/dist/actions/declareArg.d.ts +0 -8
  251. package/dist/actions/declareArg.js +0 -10
  252. package/dist/actions/declareArg.js.map +0 -1
  253. package/dist/actions/disableTool.d.ts +0 -10
  254. package/dist/actions/disableTool.js +0 -17
  255. package/dist/actions/disableTool.js.map +0 -1
  256. package/dist/actions/embed.d.ts +0 -9
  257. package/dist/actions/embed.js +0 -23
  258. package/dist/actions/embed.js.map +0 -1
  259. package/dist/actions/emit.d.ts +0 -9
  260. package/dist/actions/emit.js +0 -14
  261. package/dist/actions/emit.js.map +0 -1
  262. package/dist/actions/enableTool.d.ts +0 -20
  263. package/dist/actions/enableTool.js +0 -26
  264. package/dist/actions/enableTool.js.map +0 -1
  265. package/dist/actions/enableTool.type-test.d.ts +0 -1
  266. package/dist/actions/enableTool.type-test.js +0 -30
  267. package/dist/actions/enableTool.type-test.js.map +0 -1
  268. package/dist/actions/getScope.d.ts +0 -5
  269. package/dist/actions/getScope.js +0 -8
  270. package/dist/actions/getScope.js.map +0 -1
  271. package/dist/actions/getSignal.d.ts +0 -4
  272. package/dist/actions/getSignal.js +0 -8
  273. package/dist/actions/getSignal.js.map +0 -1
  274. package/dist/actions/getTools.d.ts +0 -5
  275. package/dist/actions/getTools.js +0 -8
  276. package/dist/actions/getTools.js.map +0 -1
  277. package/dist/actions/infer.d.ts +0 -13
  278. package/dist/actions/infer.js +0 -21
  279. package/dist/actions/infer.js.map +0 -1
  280. package/dist/actions/pushModel.d.ts +0 -11
  281. package/dist/actions/pushModel.js +0 -21
  282. package/dist/actions/pushModel.js.map +0 -1
  283. package/dist/actions/removeMessage.d.ts +0 -9
  284. package/dist/actions/removeMessage.js +0 -17
  285. package/dist/actions/removeMessage.js.map +0 -1
  286. package/dist/actions/removeModel.d.ts +0 -10
  287. package/dist/actions/removeModel.js +0 -20
  288. package/dist/actions/removeModel.js.map +0 -1
  289. package/dist/actions/setMessages.d.ts +0 -16
  290. package/dist/actions/setMessages.js +0 -31
  291. package/dist/actions/setMessages.js.map +0 -1
  292. package/dist/actions/throw.d.ts +0 -9
  293. package/dist/actions/throw.js +0 -13
  294. package/dist/actions/throw.js.map +0 -1
  295. package/dist/cli/WriteHandler.d.ts +0 -9
  296. package/dist/cli/WriteHandler.js +0 -24
  297. package/dist/cli/WriteHandler.js.map +0 -1
  298. package/dist/cli/cli_common.d.ts +0 -3
  299. package/dist/cli/cli_common.js +0 -2
  300. package/dist/cli/cli_common.js.map +0 -1
  301. package/dist/cli/runExec.d.ts +0 -2
  302. package/dist/cli/runExec.js +0 -69
  303. package/dist/cli/runExec.js.map +0 -1
  304. package/dist/events/Aborted.d.ts +0 -4
  305. package/dist/events/Aborted.js +0 -2
  306. package/dist/events/Aborted.js.map +0 -1
  307. package/dist/events/Embedded.d.ts +0 -5
  308. package/dist/events/Embedded.js +0 -2
  309. package/dist/events/Embedded.js.map +0 -1
  310. package/dist/events/EmbeddingRequested.d.ts +0 -4
  311. package/dist/events/EmbeddingRequested.js +0 -2
  312. package/dist/events/EmbeddingRequested.js.map +0 -1
  313. package/dist/events/Emitted.d.ts +0 -4
  314. package/dist/events/Emitted.js +0 -2
  315. package/dist/events/Emitted.js.map +0 -1
  316. package/dist/events/EventBase.d.ts +0 -3
  317. package/dist/events/EventBase.js +0 -2
  318. package/dist/events/EventBase.js.map +0 -1
  319. package/dist/events/EventHandler.d.ts +0 -2
  320. package/dist/events/EventHandler.js +0 -2
  321. package/dist/events/EventHandler.js.map +0 -1
  322. package/dist/events/EventResolved.d.ts +0 -19
  323. package/dist/events/EventResolved.js +0 -2
  324. package/dist/events/EventResolved.js.map +0 -1
  325. package/dist/events/Forked.d.ts +0 -3
  326. package/dist/events/Forked.js +0 -2
  327. package/dist/events/Forked.js.map +0 -1
  328. package/dist/events/InferenceRequested.d.ts +0 -3
  329. package/dist/events/InferenceRequested.js +0 -2
  330. package/dist/events/InferenceRequested.js.map +0 -1
  331. package/dist/events/Inferred.d.ts +0 -5
  332. package/dist/events/Inferred.js +0 -2
  333. package/dist/events/Inferred.js.map +0 -1
  334. package/dist/events/LEvent.d.ts +0 -18
  335. package/dist/events/LEvent.js +0 -2
  336. package/dist/events/LEvent.js.map +0 -1
  337. package/dist/events/MessageAppended.d.ts +0 -5
  338. package/dist/events/MessageAppended.js +0 -2
  339. package/dist/events/MessageAppended.js.map +0 -1
  340. package/dist/events/MessageRemoved.d.ts +0 -5
  341. package/dist/events/MessageRemoved.js +0 -2
  342. package/dist/events/MessageRemoved.js.map +0 -1
  343. package/dist/events/MessagesSet.d.ts +0 -5
  344. package/dist/events/MessagesSet.js +0 -2
  345. package/dist/events/MessagesSet.js.map +0 -1
  346. package/dist/events/ModelPushed.d.ts +0 -7
  347. package/dist/events/ModelPushed.js +0 -2
  348. package/dist/events/ModelPushed.js.map +0 -1
  349. package/dist/events/ModelRemoved.d.ts +0 -7
  350. package/dist/events/ModelRemoved.js +0 -2
  351. package/dist/events/ModelRemoved.js.map +0 -1
  352. package/dist/events/Returned.d.ts +0 -4
  353. package/dist/events/Returned.js +0 -2
  354. package/dist/events/Returned.js.map +0 -1
  355. package/dist/events/Threw.d.ts +0 -4
  356. package/dist/events/Threw.js +0 -2
  357. package/dist/events/Threw.js.map +0 -1
  358. package/dist/events/ToolCalled.d.ts +0 -6
  359. package/dist/events/ToolCalled.js +0 -2
  360. package/dist/events/ToolCalled.js.map +0 -1
  361. package/dist/events/ToolDisabled.d.ts +0 -5
  362. package/dist/events/ToolDisabled.js +0 -2
  363. package/dist/events/ToolDisabled.js.map +0 -1
  364. package/dist/events/ToolEnabled.d.ts +0 -7
  365. package/dist/events/ToolEnabled.js +0 -2
  366. package/dist/events/ToolEnabled.js.map +0 -1
  367. package/dist/events/isScopeChildEvent.d.ts +0 -6
  368. package/dist/events/isScopeChildEvent.js +0 -9
  369. package/dist/events/isScopeChildEvent.js.map +0 -1
  370. package/dist/events/isScopeDescendantEvent.d.ts +0 -14
  371. package/dist/events/isScopeDescendantEvent.js +0 -12
  372. package/dist/events/isScopeDescendantEvent.js.map +0 -1
  373. package/dist/testing/ActorAssertions.d.ts +0 -9
  374. package/dist/testing/ActorAssertions.js +0 -6
  375. package/dist/testing/ActorAssertions.js.map +0 -1
  376. package/dist/testing/TestEmbeddingModel.d.ts +0 -6
  377. package/dist/testing/TestEmbeddingModel.js +0 -10
  378. package/dist/testing/TestEmbeddingModel.js.map +0 -1
  379. package/dist/testing/TestLanguageModel.d.ts +0 -8
  380. package/dist/testing/TestLanguageModel.js +0 -21
  381. package/dist/testing/TestLanguageModel.js.map +0 -1
  382. package/dist/testing/index.d.ts +0 -4
  383. package/dist/testing/index.js +0 -5
  384. package/dist/testing/index.js.map +0 -1
  385. package/dist/testing/takeFirstAction.d.ts +0 -3
  386. package/dist/testing/takeFirstAction.js +0 -6
  387. package/dist/testing/takeFirstAction.js.map +0 -1
  388. package/dist/types/AssertDiagnostics.d.ts +0 -18
  389. package/dist/types/AssertDiagnostics.js +0 -152
  390. package/dist/types/AssertDiagnostics.js.map +0 -1
  391. package/dist/types/JSONRootType.d.ts +0 -6
  392. package/dist/types/JSONRootType.js +0 -2
  393. package/dist/types/JSONRootType.js.map +0 -1
  394. package/dist/types/JSONType.d.ts +0 -16
  395. package/dist/types/JSONType.js +0 -2
  396. package/dist/types/JSONType.js.map +0 -1
  397. package/dist/types/JSONTypeBase.d.ts +0 -3
  398. package/dist/types/JSONTypeBase.js +0 -2
  399. package/dist/types/JSONTypeBase.js.map +0 -1
  400. package/dist/types/Metatype/MetatypeDescriptor.d.ts +0 -41
  401. package/dist/types/Metatype/MetatypeDescriptor.js +0 -38
  402. package/dist/types/Metatype/MetatypeDescriptor.js.map +0 -1
  403. package/dist/types/Metatype/fromMetatypeDescriptor.d.ts +0 -6
  404. package/dist/types/Metatype/fromMetatypeDescriptor.js +0 -43
  405. package/dist/types/Metatype/fromMetatypeDescriptor.js.map +0 -1
  406. package/dist/types/Type.d.ts +0 -30
  407. package/dist/types/Type.js +0 -5
  408. package/dist/types/Type.js.map +0 -1
  409. package/dist/types/TypeContext.d.ts +0 -7
  410. package/dist/types/TypeContext.js +0 -17
  411. package/dist/types/TypeContext.js.map +0 -1
  412. package/dist/types/TypeLike.d.ts +0 -23
  413. package/dist/types/TypeLike.js +0 -23
  414. package/dist/types/TypeLike.js.map +0 -1
  415. package/dist/types/TypeVisitor.d.ts +0 -14
  416. package/dist/types/TypeVisitor.js +0 -12
  417. package/dist/types/TypeVisitor.js.map +0 -1
  418. package/dist/types/array.d.ts +0 -10
  419. package/dist/types/array.js +0 -9
  420. package/dist/types/array.js.map +0 -1
  421. package/dist/types/boolean.d.ts +0 -6
  422. package/dist/types/boolean.js +0 -3
  423. package/dist/types/boolean.js.map +0 -1
  424. package/dist/types/const.d.ts +0 -8
  425. package/dist/types/const.js +0 -7
  426. package/dist/types/const.js.map +0 -1
  427. package/dist/types/declareType.d.ts +0 -2
  428. package/dist/types/declareType.js +0 -57
  429. package/dist/types/declareType.js.map +0 -1
  430. package/dist/types/enum.d.ts +0 -8
  431. package/dist/types/enum.js +0 -7
  432. package/dist/types/enum.js.map +0 -1
  433. package/dist/types/factories.d.ts +0 -8
  434. package/dist/types/factories.js +0 -9
  435. package/dist/types/factories.js.map +0 -1
  436. package/dist/types/index.d.ts +0 -2
  437. package/dist/types/index.js +0 -3
  438. package/dist/types/index.js.map +0 -1
  439. package/dist/types/integer.d.ts +0 -6
  440. package/dist/types/integer.js +0 -3
  441. package/dist/types/integer.js.map +0 -1
  442. package/dist/types/intrinsics.d.ts +0 -11
  443. package/dist/types/intrinsics.js +0 -12
  444. package/dist/types/intrinsics.js.map +0 -1
  445. package/dist/types/match.d.ts +0 -3
  446. package/dist/types/match.js +0 -11
  447. package/dist/types/match.js.map +0 -1
  448. package/dist/types/non_factories.d.ts +0 -21
  449. package/dist/types/non_factories.js +0 -9
  450. package/dist/types/non_factories.js.map +0 -1
  451. package/dist/types/null.d.ts +0 -7
  452. package/dist/types/null.js +0 -4
  453. package/dist/types/null.js.map +0 -1
  454. package/dist/types/number.d.ts +0 -6
  455. package/dist/types/number.js +0 -3
  456. package/dist/types/number.js.map +0 -1
  457. package/dist/types/object.d.ts +0 -16
  458. package/dist/types/object.js +0 -10
  459. package/dist/types/object.js.map +0 -1
  460. package/dist/types/ref.d.ts +0 -7
  461. package/dist/types/ref.js +0 -5
  462. package/dist/types/ref.js.map +0 -1
  463. package/dist/types/string.d.ts +0 -6
  464. package/dist/types/string.js +0 -3
  465. package/dist/types/string.js.map +0 -1
  466. package/dist/types/toJSON.d.ts +0 -5
  467. package/dist/types/toJSON.js +0 -97
  468. package/dist/types/toJSON.js.map +0 -1
  469. package/dist/types/type_common.d.ts +0 -10
  470. package/dist/types/type_common.js +0 -12
  471. package/dist/types/type_common.js.map +0 -1
  472. package/dist/types/types_derived/option.d.ts +0 -5
  473. package/dist/types/types_derived/option.js +0 -6
  474. package/dist/types/types_derived/option.js.map +0 -1
  475. package/dist/types/types_derived/taggedUnion.d.ts +0 -19
  476. package/dist/types/types_derived/taggedUnion.js +0 -8
  477. package/dist/types/types_derived/taggedUnion.js.map +0 -1
  478. package/dist/types/types_derived/wrapper.d.ts +0 -8
  479. package/dist/types/types_derived/wrapper.js +0 -5
  480. package/dist/types/types_derived/wrapper.js.map +0 -1
  481. package/dist/types/union.d.ts +0 -9
  482. package/dist/types/union.js +0 -9
  483. package/dist/types/union.js.map +0 -1
  484. package/dist/util/ArrayOfLength.d.ts +0 -1
  485. package/dist/util/ArrayOfLength.js +0 -2
  486. package/dist/util/ArrayOfLength.js.map +0 -1
  487. package/dist/util/DeferredOr.d.ts +0 -1
  488. package/dist/util/DeferredOr.js +0 -2
  489. package/dist/util/DeferredOr.js.map +0 -1
  490. package/dist/util/EnsureNarrow.d.ts +0 -2
  491. package/dist/util/EnsureNarrow.js +0 -2
  492. package/dist/util/EnsureNarrow.js.map +0 -1
  493. package/dist/util/EnsureRecord.d.ts +0 -2
  494. package/dist/util/EnsureRecord.js +0 -2
  495. package/dist/util/EnsureRecord.js.map +0 -1
  496. package/dist/util/Expand.d.ts +0 -3
  497. package/dist/util/Expand.js +0 -2
  498. package/dist/util/Expand.js.map +0 -1
  499. package/dist/util/Falsy.d.ts +0 -1
  500. package/dist/util/Falsy.js +0 -2
  501. package/dist/util/Falsy.js.map +0 -1
  502. package/dist/util/FromEntries.d.ts +0 -3
  503. package/dist/util/FromEntries.js +0 -2
  504. package/dist/util/FromEntries.js.map +0 -1
  505. package/dist/util/IteratorLike.d.ts +0 -1
  506. package/dist/util/IteratorLike.js +0 -2
  507. package/dist/util/IteratorLike.js.map +0 -1
  508. package/dist/util/JSONEntry.d.ts +0 -2
  509. package/dist/util/JSONEntry.js +0 -2
  510. package/dist/util/JSONEntry.js.map +0 -1
  511. package/dist/util/JSONKey.d.ts +0 -1
  512. package/dist/util/JSONKey.js +0 -2
  513. package/dist/util/JSONKey.js.map +0 -1
  514. package/dist/util/JSONObject.d.ts +0 -5
  515. package/dist/util/JSONObject.js +0 -2
  516. package/dist/util/JSONObject.js.map +0 -1
  517. package/dist/util/JSONSchemaMemo.d.ts +0 -2
  518. package/dist/util/JSONSchemaMemo.js +0 -13
  519. package/dist/util/JSONSchemaMemo.js.map +0 -1
  520. package/dist/util/JSONValue.d.ts +0 -2
  521. package/dist/util/JSONValue.js +0 -2
  522. package/dist/util/JSONValue.js.map +0 -1
  523. package/dist/util/PromiseOr.d.ts +0 -1
  524. package/dist/util/PromiseOr.js +0 -2
  525. package/dist/util/PromiseOr.js.map +0 -1
  526. package/dist/util/Result.d.ts +0 -7
  527. package/dist/util/Result.js +0 -2
  528. package/dist/util/Result.js.map +0 -1
  529. package/dist/util/Taggable.d.ts +0 -9
  530. package/dist/util/Taggable.js +0 -8
  531. package/dist/util/Taggable.js.map +0 -1
  532. package/dist/util/TupleToRecord.d.ts +0 -5
  533. package/dist/util/TupleToRecord.js +0 -2
  534. package/dist/util/TupleToRecord.js.map +0 -1
  535. package/dist/util/assert.d.ts +0 -1
  536. package/dist/util/assert.js +0 -7
  537. package/dist/util/assert.js.map +0 -1
  538. package/dist/util/dedent.d.ts +0 -1
  539. package/dist/util/dedent.js +0 -5
  540. package/dist/util/dedent.js.map +0 -1
  541. package/dist/util/fixTemplateStrings.d.ts +0 -11
  542. package/dist/util/fixTemplateStrings.js +0 -83
  543. package/dist/util/fixTemplateStrings.js.map +0 -1
  544. package/dist/util/fixTemplateStrings.test.d.ts +0 -1
  545. package/dist/util/fixTemplateStrings.test.js +0 -221
  546. package/dist/util/fixTemplateStrings.test.js.map +0 -1
  547. package/dist/util/isAsyncIterator.d.ts +0 -1
  548. package/dist/util/isAsyncIterator.js +0 -7
  549. package/dist/util/isAsyncIterator.js.map +0 -1
  550. package/dist/util/isIterator.d.ts +0 -1
  551. package/dist/util/isIterator.js +0 -7
  552. package/dist/util/isIterator.js.map +0 -1
  553. package/dist/util/isJSONValue.d.ts +0 -2
  554. package/dist/util/isJSONValue.js +0 -16
  555. package/dist/util/isJSONValue.js.map +0 -1
  556. package/dist/util/isPropertyKey.d.ts +0 -1
  557. package/dist/util/isPropertyKey.js +0 -4
  558. package/dist/util/isPropertyKey.js.map +0 -1
  559. package/dist/util/isTemplateStringsArray.d.ts +0 -1
  560. package/dist/util/isTemplateStringsArray.js +0 -4
  561. package/dist/util/isTemplateStringsArray.js.map +0 -1
  562. package/dist/util/jsonEquals.d.ts +0 -2
  563. package/dist/util/jsonEquals.js +0 -33
  564. package/dist/util/jsonEquals.js.map +0 -1
  565. package/dist/util/nullaryMemo.d.ts +0 -1
  566. package/dist/util/nullaryMemo.js +0 -12
  567. package/dist/util/nullaryMemo.js.map +0 -1
  568. package/dist/util/unimplemented.d.ts +0 -1
  569. package/dist/util/unimplemented.js +0 -5
  570. package/dist/util/unimplemented.js.map +0 -1
  571. package/dist/util/unreachable.d.ts +0 -1
  572. package/dist/util/unreachable.js +0 -5
  573. package/dist/util/unreachable.js.map +0 -1
  574. package/dist/util/unwrapDeferred.d.ts +0 -2
  575. package/dist/util/unwrapDeferred.js +0 -4
  576. package/dist/util/unwrapDeferred.js.map +0 -1
  577. package/dist/util/util.d.ts +0 -10
  578. package/dist/util/util.js +0 -11
  579. package/dist/util/util.js.map +0 -1
  580. package/events/Aborted.ts +0 -5
  581. package/events/Embedded.ts +0 -6
  582. package/events/EmbeddingRequested.ts +0 -5
  583. package/events/Emitted.ts +0 -5
  584. package/events/EventBase.ts +0 -3
  585. package/events/EventHandler.ts +0 -3
  586. package/events/EventResolved.ts +0 -30
  587. package/events/Forked.ts +0 -3
  588. package/events/InferenceRequested.ts +0 -3
  589. package/events/Inferred.ts +0 -6
  590. package/events/LEvent.ts +0 -36
  591. package/events/MessageAppended.ts +0 -6
  592. package/events/MessageRemoved.ts +0 -6
  593. package/events/MessagesSet.ts +0 -6
  594. package/events/ModelPushed.ts +0 -10
  595. package/events/ModelRemoved.ts +0 -10
  596. package/events/Returned.ts +0 -5
  597. package/events/Threw.ts +0 -5
  598. package/events/ToolCalled.ts +0 -7
  599. package/events/ToolDisabled.ts +0 -6
  600. package/events/ToolEnabled.ts +0 -8
  601. package/events/isScopeChildEvent.ts +0 -15
  602. package/events/isScopeDescendantEvent.ts +0 -30
  603. package/testing/ActorAssertions.ts +0 -19
  604. package/testing/TestEmbeddingModel.ts +0 -18
  605. package/testing/TestLanguageModel.ts +0 -32
  606. package/testing/index.ts +0 -4
  607. package/testing/takeFirstAction.ts +0 -8
  608. package/types/AssertDiagnostics.ts +0 -183
  609. package/types/JSONRootType.ts +0 -8
  610. package/types/JSONType.ts +0 -27
  611. package/types/JSONTypeBase.ts +0 -3
  612. package/types/Metatype/MetatypeDescriptor.ts +0 -80
  613. package/types/Metatype/fromMetatypeDescriptor.ts +0 -52
  614. package/types/Type.ts +0 -46
  615. package/types/TypeContext.ts +0 -19
  616. package/types/TypeLike.ts +0 -60
  617. package/types/TypeVisitor.ts +0 -49
  618. package/types/array.ts +0 -20
  619. package/types/boolean.ts +0 -9
  620. package/types/const.ts +0 -17
  621. package/types/declareType.ts +0 -71
  622. package/types/enum.ts +0 -14
  623. package/types/factories.ts +0 -8
  624. package/types/index.ts +0 -2
  625. package/types/integer.ts +0 -9
  626. package/types/intrinsics.ts +0 -11
  627. package/types/match.ts +0 -13
  628. package/types/non_factories.ts +0 -26
  629. package/types/null.ts +0 -10
  630. package/types/number.ts +0 -9
  631. package/types/object.ts +0 -27
  632. package/types/ref.ts +0 -12
  633. package/types/string.ts +0 -9
  634. package/types/toJSON.ts +0 -111
  635. package/types/type_common.ts +0 -21
  636. package/types/types_derived/option.ts +0 -10
  637. package/types/types_derived/taggedUnion.ts +0 -30
  638. package/types/types_derived/wrapper.ts +0 -10
  639. package/types/union.ts +0 -19
  640. package/util/ArrayOfLength.ts +0 -5
  641. package/util/DeferredOr.ts +0 -1
  642. package/util/EnsureNarrow.ts +0 -5
  643. package/util/EnsureRecord.ts +0 -3
  644. package/util/Expand.ts +0 -1
  645. package/util/Falsy.ts +0 -1
  646. package/util/FromEntries.ts +0 -3
  647. package/util/IteratorLike.ts +0 -1
  648. package/util/JSONEntry.ts +0 -3
  649. package/util/JSONKey.ts +0 -1
  650. package/util/JSONObject.ts +0 -6
  651. package/util/JSONSchemaMemo.ts +0 -15
  652. package/util/JSONValue.ts +0 -3
  653. package/util/PromiseOr.ts +0 -1
  654. package/util/Result.ts +0 -7
  655. package/util/Taggable.ts +0 -18
  656. package/util/TupleToRecord.ts +0 -5
  657. package/util/assert.ts +0 -7
  658. package/util/dedent.ts +0 -5
  659. package/util/fixTemplateStrings.test.ts +0 -250
  660. package/util/fixTemplateStrings.ts +0 -99
  661. package/util/isAsyncIterator.ts +0 -6
  662. package/util/isIterator.ts +0 -6
  663. package/util/isJSONValue.ts +0 -20
  664. package/util/isPropertyKey.ts +0 -3
  665. package/util/isTemplateStringsArray.ts +0 -3
  666. package/util/jsonEquals.ts +0 -41
  667. package/util/nullaryMemo.ts +0 -11
  668. package/util/unimplemented.ts +0 -5
  669. package/util/unreachable.ts +0 -5
  670. package/util/unwrapDeferred.ts +0 -5
  671. package/util/util.ts +0 -10
  672. /package/dist/{actions/actions_derived/declareModel.test.d.ts → Handler.d.ts} +0 -0
  673. /package/dist/{actions/actions_derived/declareModel.type-test.d.ts → L/namespace.d.ts} +0 -0
package/actions/abort.ts DELETED
@@ -1,23 +0,0 @@
1
- import { Action } from "../Action.ts"
2
- import type { Aborted } from "../events/Aborted.ts"
3
- import type { Spec } from "../Spec.ts"
4
- import type { EnsureNarrow } from "../util/EnsureNarrow.ts"
5
-
6
- export interface abort<V> extends Action<"abort", Spec.Make<{ Event: Aborted<V> }>> {}
7
-
8
- export function* abort<V>(reason: V, ...[_error]: EnsureNarrow<V>): Generator<
9
- abort<V>,
10
- never
11
- > {
12
- return (yield (Action("abort", (scope) => {
13
- scope.event({
14
- type: "aborted",
15
- reason,
16
- })
17
- scope.controller.abort(reason)
18
- return {
19
- ...scope,
20
- nextArg: undefined,
21
- }
22
- }))) as never
23
- }
@@ -1,23 +0,0 @@
1
- import type { EmbeddingModel, LanguageModel, Model } from "../../Model.ts"
2
- import type { Scope } from "../../Scope.ts"
3
- import { unreachable } from "../../util/unreachable.ts"
4
-
5
- export function applyToModels<M extends Model>(
6
- scope: Scope,
7
- model: M,
8
- f: (initial: Set<M>) => Set<M>,
9
- ): Pick<Scope, "languageModels" | "embeddingModels"> {
10
- const initial: Set<M> = (model.type === "language" ? scope.languageModels : scope.embeddingModels) as never
11
- const models = f(new Set(initial))
12
- return model.type === "language"
13
- ? {
14
- languageModels: models as Set<LanguageModel>,
15
- embeddingModels: scope.embeddingModels,
16
- }
17
- : model.type === "embedding"
18
- ? {
19
- languageModels: scope.languageModels,
20
- embeddingModels: models as Set<EmbeddingModel>,
21
- }
22
- : unreachable()
23
- }
@@ -1,89 +0,0 @@
1
- // Bun Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Model generates the expected event sequence 1`] = `
4
- "[
5
- {
6
- "scope": [],
7
- "index": 0,
8
- "type": "model_pushed",
9
- "modelKey": "secondary",
10
- "modelType": "language"
11
- },
12
- {
13
- "scope": [
14
- "fork-key"
15
- ],
16
- "index": 0,
17
- "type": "forked"
18
- },
19
- {
20
- "scope": [
21
- "fork-key"
22
- ],
23
- "index": 0,
24
- "type": "model_pushed",
25
- "modelKey": "child_a",
26
- "modelType": "language"
27
- },
28
- {
29
- "scope": [
30
- "fork-key"
31
- ],
32
- "index": 0,
33
- "type": "model_pushed",
34
- "modelKey": "child_b",
35
- "modelType": "embedding"
36
- },
37
- {
38
- "scope": [
39
- "fork-key"
40
- ],
41
- "index": 0,
42
- "type": "model_removed",
43
- "modelKey": "child_a",
44
- "modelType": "language"
45
- },
46
- {
47
- "scope": [
48
- "fork-key"
49
- ],
50
- "index": 0,
51
- "type": "model_removed",
52
- "modelKey": "child_b",
53
- "modelType": "embedding"
54
- },
55
- {
56
- "scope": [
57
- "fork-key"
58
- ],
59
- "index": 0,
60
- "type": "returned"
61
- },
62
- {
63
- "scope": [],
64
- "index": 0,
65
- "type": "model_pushed",
66
- "modelKey": "tertiary",
67
- "modelType": "embedding"
68
- },
69
- {
70
- "scope": [],
71
- "index": 0,
72
- "type": "model_removed",
73
- "modelKey": "secondary",
74
- "modelType": "language"
75
- },
76
- {
77
- "scope": [],
78
- "index": 0,
79
- "type": "model_removed",
80
- "modelKey": "tertiary",
81
- "modelType": "embedding"
82
- },
83
- {
84
- "scope": [],
85
- "index": 0,
86
- "type": "returned"
87
- }
88
- ]"
89
- `;
@@ -1,6 +0,0 @@
1
- import { setMessages } from "../../actions/setMessages.ts"
2
- import type { MessagesSet } from "../../events/MessagesSet.ts"
3
-
4
- export function clear() {
5
- return setMessages(() => [])
6
- }
@@ -1,33 +0,0 @@
1
- import { describe, expect, it } from "bun:test"
2
- import type { LEvent } from "../../events/LEvent.ts"
3
- import { Exec } from "../../Exec.ts"
4
- import * as L from "../../L.ts"
5
- import { TestEmbeddingModel } from "../../testing/TestEmbeddingModel.ts"
6
- import { TestLanguageModel } from "../../testing/TestLanguageModel.ts"
7
-
8
- describe("Model", () => {
9
- it("generates the expected event sequence", async () => {
10
- const events: Array<LEvent> = []
11
- await Exec(function*() {
12
- const a = yield* L.declareModel("secondary")
13
- yield* L.branch("fork-key", function*() {
14
- const b = yield* L.declareModel("child_a")
15
- const c = yield* L.declareModel("child_b")
16
- yield* b
17
- yield* c
18
- })
19
- const c = yield* L.declareModel("tertiary")
20
- yield* a
21
- yield* c
22
- }, {
23
- default: TestLanguageModel(),
24
- args: {
25
- secondary: TestLanguageModel(),
26
- child_a: TestLanguageModel(),
27
- child_b: TestEmbeddingModel(),
28
- tertiary: TestEmbeddingModel(),
29
- },
30
- })((event) => events.push(event))
31
- expect(JSON.stringify(events, null, 2)).toMatchSnapshot()
32
- })
33
- })
@@ -1,9 +0,0 @@
1
- import type { Model } from "../../Model.ts"
2
- import type { JSONKey } from "../../util/JSONKey.ts"
3
- import { declareArg } from "../declareArg.ts"
4
- import { pushModel } from "../pushModel.ts"
5
-
6
- export function* declareModel<K extends JSONKey>(key: K) {
7
- const model = yield* declareArg(key)<Model>()
8
- return yield* pushModel(key, model)
9
- }
@@ -1,70 +0,0 @@
1
- // import type { RunEmbed, RunInfer } from "../../adapters.ts"
2
- // import type { ChildEvent } from "../../events/ChildEvent.ts"
3
- // import type { EmbeddingModelSetEvent } from "../../events/EmbeddingModelSetEvent.ts"
4
- // import type { LanguageModelSetEvent } from "../../events/LanguageModelSetEvent.ts"
5
- // import * as L from "../../L.ts"
6
- // import { ActorAssertions } from "../../testing/ActorAssertions.ts"
7
- // import { declareEmbeddingModel } from "./declareEmbeddingModel.ts"
8
- // import { declareLanguageModel } from "./declareLanguageModel.ts"
9
-
10
- // const languageModel = declareLanguageModel("A")
11
- // ActorAssertions(languageModel).assertSpec<{
12
- // Entry: ["A", RunInfer]
13
- // Event: LanguageModelSetEvent<"A">
14
- // Throw: never
15
- // Child: never
16
- // }>()
17
-
18
- // const embeddingModel = declareEmbeddingModel("B")
19
- // ActorAssertions(embeddingModel).assertSpec<{
20
- // Entry: ["B", RunEmbed]
21
- // Event: EmbeddingModelSetEvent<"B">
22
- // Throw: never
23
- // Child: never
24
- // }>()
25
-
26
- // function* both() {
27
- // yield* languageModel
28
- // yield* embeddingModel
29
- // }
30
-
31
- // ActorAssertions(both).assertSpec<{
32
- // Entry: ["A", RunInfer] | ["B", RunEmbed]
33
- // Event: LanguageModelSetEvent<"A"> | EmbeddingModelSetEvent<"B">
34
- // Throw: never
35
- // Child: never
36
- // }>()
37
-
38
- // function* parent() {
39
- // yield* L.branch("fork-key", {
40
- // *key() {
41
- // yield* both()
42
- // },
43
- // })
44
- // yield* declareLanguageModel("C")
45
- // yield* declareEmbeddingModel("D")
46
- // }
47
-
48
- // ActorAssertions(parent).assertSpec<{
49
- // Entry:
50
- // | ["A", RunInfer]
51
- // | ["B", RunEmbed]
52
- // | ["C", RunInfer]
53
- // | ["D", RunEmbed]
54
- // Event:
55
- // | ChildEvent<
56
- // "branch",
57
- // "fork-key",
58
- // ChildEvent<
59
- // "branch_arm",
60
- // "key",
61
- // LanguageModelSetEvent<"A"> | EmbeddingModelSetEvent<"B">,
62
- // void
63
- // >,
64
- // { key: void }
65
- // >
66
- // | LanguageModelSetEvent<"C">
67
- // | EmbeddingModelSetEvent<"D">
68
- // Throw: never
69
- // Child: never
70
- // }>()
@@ -1,9 +0,0 @@
1
- import { Action } from "../../Action.ts"
2
- import type { Message } from "../../Message.ts"
3
-
4
- export function* getMessages(): Generator<Action<"get_messages">, Array<Message>> {
5
- return yield Action("get_messages", (scope) => ({
6
- ...scope,
7
- nextArg: [...scope.messages],
8
- }))
9
- }
@@ -1,88 +0,0 @@
1
- // import { describe, expect, test } from "bun:test"
2
- // import * as L from "../L.ts"
3
- // import { takeFirstAction } from "../testing/takeFirstAction.ts"
4
-
5
- // describe("message templates", () => {
6
- // test("system messages with indentation", async () => {
7
- // // Create a system message with indented multiline content
8
- // const messageGenerator = L.system`
9
- // Hello, I am an AI assistant.
10
- // I can help with the following:
11
- // - Code generation
12
- // - Answering questions
13
- // - General assistance
14
- // `
15
-
16
- // const action = await takeFirstAction(messageGenerator)
17
-
18
- // expect(action?.message.content).toBe(
19
- // "Hello, I am an AI assistant.\nI can help with the following:\n - Code generation\n - Answering questions\n - General assistance",
20
- // )
21
- // })
22
-
23
- // test("user messages with substitution", async () => {
24
- // const name = "John"
25
- // const messageGenerator = L.user`Hello, my name is ${name}.`
26
-
27
- // const action = await takeFirstAction(messageGenerator)
28
-
29
- // expect(action?.message.content).toBe("Hello, my name is John.")
30
- // })
31
-
32
- // test("user messages with multiline substitution and indentation", async () => {
33
- // const codeBlock = "function example() {\n console.log('Hello');\n}"
34
-
35
- // const messageGenerator = L.user`
36
- // Here's my code:
37
- // ${codeBlock}
38
- // Can you help me understand it?
39
- // `
40
-
41
- // const action = await takeFirstAction(messageGenerator)
42
-
43
- // // The code block should get indentation applied to lines after the first
44
- // expect(action?.message.content).toBe(
45
- // "Here's my code:\n function example() {\n console.log('Hello');\n }\nCan you help me understand it?",
46
- // )
47
- // })
48
-
49
- // test("assistant messages with multiline substitution", async () => {
50
- // const explanation =
51
- // "1. First, we declare a function\n2. Then we log a message\n3. The function doesn't return anything"
52
-
53
- // const messageGenerator = L.assistant`
54
- // Let me explain:
55
- // ${explanation}
56
- // Does that help?
57
- // `
58
-
59
- // const action = await takeFirstAction(messageGenerator)
60
-
61
- // // The explanation lines should get indentation
62
- // expect(action?.message.content).toBe(
63
- // "Let me explain:\n 1. First, we declare a function\n 2. Then we log a message\n 3. The function doesn't return anything\nDoes that help?",
64
- // )
65
- // })
66
-
67
- // test("preserves code indentation", async () => {
68
- // const code = `if (condition) {
69
- // // This is indented once
70
- // if (nestedCondition) {
71
- // // This is indented twice
72
- // }
73
- // }`
74
-
75
- // const messageGenerator = L.user`
76
- // My code:
77
- // ${code}
78
- // `
79
-
80
- // const action = await takeFirstAction(messageGenerator)
81
-
82
- // // The code's internal indentation structure should be preserved
83
- // // while getting additional indentation from the template
84
- // expect(action?.message.content).toBe(
85
- // "My code:\n if (condition) {\n // This is indented once\n if (nestedCondition) {\n // This is indented twice\n }\n }",
86
- // )
87
- // })
88
- // })
@@ -1,19 +0,0 @@
1
- import type { MessageRemoved } from "../../events/MessageRemoved.ts"
2
- import type { AssistantContent, UserContent } from "../../Message.ts"
3
- import { normalizeTaggableArgs, type TaggableArgs } from "../../util/Taggable.ts"
4
- import { appendMessage } from "../appendMessage.ts"
5
-
6
- export function user(...args: TaggableArgs<[content: UserContent]>) {
7
- const [content] = normalizeTaggableArgs(...args)
8
- return appendMessage("user", content)
9
- }
10
-
11
- export function system(...args: TaggableArgs<[content: string]>) {
12
- const [content] = normalizeTaggableArgs(...args)
13
- return appendMessage("system", content)
14
- }
15
-
16
- export function assistant(...args: TaggableArgs<[content: AssistantContent]>) {
17
- const [content] = normalizeTaggableArgs(...args)
18
- return appendMessage("assistant", content)
19
- }
@@ -1,9 +0,0 @@
1
- import { fromMetatypeRootDescriptor } from "../../types/Metatype/fromMetatypeDescriptor.ts"
2
- import { MetatypeRootDescriptor } from "../../types/Metatype/MetatypeDescriptor.ts"
3
- import type { Falsy } from "../../util/Falsy.ts"
4
- import type { TaggableArgs } from "../../util/Taggable.ts"
5
-
6
- export function* metatype(...args: TaggableArgs<[...description: Array<string | Falsy>]>) {
7
- const descriptor = yield* MetatypeRootDescriptor(args.map((e) => typeof e === "string").join("\n"))
8
- return fromMetatypeRootDescriptor(descriptor)
9
- }
@@ -1,30 +0,0 @@
1
- import { Action } from "../Action.ts"
2
- import type { MessageAppended } from "../events/MessageAppended.ts"
3
- import type { Message, MessageContents, MessageRole, Messages } from "../Message.ts"
4
- import type { Spec } from "../Spec.ts"
5
- import { removeMessage } from "./removeMessage.ts"
6
-
7
- export interface appendMessage<M extends Message>
8
- extends Action<"append_message", Spec.Make<{ Event: MessageAppended<M> }>>
9
- {}
10
-
11
- export function* appendMessage<R extends MessageRole>(
12
- role: R,
13
- content: MessageContents[R],
14
- ): Generator<appendMessage<Messages[R]>, Generator<removeMessage, void>> {
15
- return yield Action("append_message", (scope) => {
16
- const message = {
17
- role,
18
- content,
19
- } as Messages[R] // <-- why isn't this inferred?
20
- scope.event({
21
- type: "message_appended",
22
- message,
23
- })
24
- return {
25
- ...scope,
26
- nextArg: removeMessage(message),
27
- messages: new Set([...scope.messages, message]),
28
- }
29
- })
30
- }
package/actions/await.ts DELETED
@@ -1,13 +0,0 @@
1
- import { Action } from "../Action.ts"
2
-
3
- export interface await_<_T> extends Action<"await", never> {}
4
-
5
- function* await_<T>(value: T): Generator<await_<Awaited<T>>, Awaited<T>> {
6
- return yield Action("await", async (scope) => ({
7
- ...scope,
8
- nextArg: await value,
9
- }))
10
- }
11
- Object.defineProperty(await_, "name", { value: "await" })
12
-
13
- export { await_ as await }
package/actions/branch.ts DELETED
@@ -1,108 +0,0 @@
1
- import { Action } from "../Action.ts"
2
- import type {
3
- Actor,
4
- ActorLike,
5
- ActorLikeArray,
6
- ActorLikeRecord,
7
- ActorLikesT,
8
- ActorLikeT,
9
- ActorLikeY,
10
- } from "../Actor.ts"
11
- import type { ActorLikes } from "../Actor.ts"
12
- import type { Spec } from "../Spec.ts"
13
- import type { JSONKey } from "../util/JSONKey.ts"
14
- import { unwrapDeferred } from "../util/unwrapDeferred.ts"
15
-
16
- export function branch<
17
- K extends JSONKey,
18
- Y extends Action,
19
- T,
20
- >(
21
- key: K,
22
- actorLike: ActorLike<Y, T>,
23
- ): Generator<
24
- Action<
25
- "branch",
26
- Spec.Make<{
27
- Child: [Y[""]] extends [never] ? never : [K, Y[""]]
28
- Entry: Y[""]["Entry"]
29
- Value: T
30
- }>
31
- >,
32
- T
33
- >
34
- export function branch<K extends JSONKey, const A extends ActorLikeArray>(name: K, actorLikeArray: A): Generator<
35
- Action<
36
- "branch",
37
- Spec.Make<{
38
- Child: [
39
- K,
40
- {
41
- [L in keyof A]: Spec.Make<{
42
- Child: [L, ActorLikeY<A[L]>[""]]
43
- Entry: ActorLikeY<A[L]>[""]["Entry"]
44
- Value: ActorLikeT<A[L]>
45
- }>
46
- }[keyof A],
47
- ]
48
- Entry: ActorLikeY<A[number]>[""]["Entry"]
49
- }>
50
- >,
51
- ActorLikesT<A>
52
- >
53
- export function branch<K extends JSONKey, A extends ActorLikeRecord>(name: K, actorLikeRecord: A): Generator<
54
- Action<
55
- "branch",
56
- Spec.Make<{
57
- Child: [
58
- K,
59
- {
60
- [L in Exclude<keyof A, symbol>]: Spec.Make<{
61
- Child: [L, ActorLikeY<A[L]>[""]]
62
- Entry: ActorLikeY<A[L]>[""]["Entry"]
63
- Value: ActorLikeT<A[L]>
64
- }>
65
- }[Exclude<keyof A, symbol>],
66
- ]
67
- Entry: ActorLikeY<A[keyof A]>[""]["Entry"]
68
- }>
69
- >,
70
- ActorLikesT<A>
71
- >
72
- export function* branch(key: JSONKey, implementation: ActorLike | ActorLikes): Generator<Action<"branch">, any> {
73
- return yield Action("branch", async (scope) => {
74
- if (typeof implementation === "function") {
75
- const branchScope = scope.fork("branch", [key])
76
- const actor = unwrapDeferred(implementation as ActorLike)
77
- const { value } = await branchScope.reduce(actor)
78
- branchScope.event({
79
- type: "returned",
80
- value,
81
- })
82
- return {
83
- ...scope,
84
- nextArg: value,
85
- }
86
- }
87
- const armKeys = Array.isArray(implementation)
88
- ? Array.from({ length: implementation.length }, (_0, i) => i)
89
- : Reflect.ownKeys(implementation) as Array<string>
90
- const values = await Promise.all(armKeys.map(async (armKey) => {
91
- const branchArmScope = scope.fork("branch_arm", [key, armKey])
92
- const actor = unwrapDeferred(implementation[armKey as never]) as Actor
93
- const { value } = await branchArmScope.reduce(actor)
94
- branchArmScope.event({
95
- type: "returned",
96
- value,
97
- })
98
- return value
99
- }))
100
- const value = Array.isArray(implementation)
101
- ? values
102
- : Object.fromEntries(armKeys.map((key, i) => [key, values[i]]))
103
- return {
104
- ...scope,
105
- nextArg: value,
106
- }
107
- })
108
- }
package/actions/catch.ts DELETED
@@ -1,42 +0,0 @@
1
- import { Action } from "../Action.ts"
2
- import type { ActorLike } from "../Actor.ts"
3
- import type { Spec } from "../Spec.ts"
4
- import type { JSONKey } from "../util/JSONKey.ts"
5
- import type { Result } from "../util/Result.ts"
6
- import { unwrapDeferred } from "../util/unwrapDeferred.ts"
7
-
8
- export { catch_ as catch }
9
- function* catch_<K extends JSONKey, Y extends Action, T>(
10
- key: K,
11
- actorLike: ActorLike<Y, T>,
12
- ): Generator<
13
- Action<
14
- "catch",
15
- Spec.Make<{
16
- Child: [K, Y[""]]
17
- Value: T
18
- }>
19
- >,
20
- Result<T, Y[""]["Throw"]>
21
- > {
22
- return yield Action("catch", async (scope) => {
23
- const catchScope = scope.fork("catch", [key])
24
- try {
25
- const { value } = await catchScope.reduce(unwrapDeferred(actorLike))
26
- catchScope.event({
27
- type: "returned",
28
- value,
29
- })
30
- return {
31
- ...scope,
32
- nextArg: { value },
33
- }
34
- } catch (thrown: unknown) {
35
- return {
36
- ...scope,
37
- nextArg: { thrown },
38
- }
39
- }
40
- })
41
- }
42
- Object.defineProperty(catch_, "name", { value: "catch" })
@@ -1,14 +0,0 @@
1
- import { Action } from "../Action.ts"
2
- import type { Spec } from "../Spec.ts"
3
- import type { JSONKey } from "../util/JSONKey.ts"
4
-
5
- export interface declareArg<K extends JSONKey, T> extends Action<"declare_arg", Spec.Make<{ Entry: [K, T] }>> {}
6
-
7
- export function declareArg<K extends JSONKey>(key: K): <T>() => Generator<declareArg<K, T>, T> {
8
- return function*() {
9
- return yield Action("declare_arg", (scope) => ({
10
- ...scope,
11
- nextArg: scope.args?.[key],
12
- }))
13
- }
14
- }
@@ -1,26 +0,0 @@
1
- import { Action } from "../Action.ts"
2
- import type { ToolDisabled } from "../events/ToolDisabled.ts"
3
- import type { Spec } from "../Spec.ts"
4
- import type { Tool } from "../Tool.ts"
5
- import type { JSONKey } from "../util/JSONKey.ts"
6
-
7
- export interface disableTool<K extends JSONKey> extends Action<"disable_tool", Spec.Make<{ Event: ToolDisabled<K> }>> {}
8
-
9
- export function* disableTool<K extends JSONKey>(tool: Tool<K>): Generator<
10
- disableTool<K>,
11
- void
12
- > {
13
- yield Action("disable_tool", (scope) => {
14
- scope.event({
15
- type: "tool_disabled",
16
- tool: tool.toolKey,
17
- })
18
- const tools = new Set(scope.tools)
19
- tools.delete(tool)
20
- return {
21
- ...scope,
22
- tools,
23
- nextArg: undefined,
24
- }
25
- })
26
- }
package/actions/embed.ts DELETED
@@ -1,28 +0,0 @@
1
- import { Action } from "../Action.ts"
2
- import type { Embedded } from "../events/Embedded.ts"
3
- import type { EmbeddingRequested } from "../events/EmbeddingRequested.ts"
4
- import type { Spec } from "../Spec.ts"
5
- import { assert } from "../util/assert.ts"
6
-
7
- export interface embed extends Action<"embed", Spec.Make<{ Event: EmbeddingRequested | Embedded }>> {}
8
-
9
- export function* embed(value: string): Generator<embed, Array<number>> {
10
- return yield Action("embed", async (scope) => {
11
- const model = scope.embeddingModels.values().next().value
12
- assert(model)
13
- scope.event({
14
- type: "embedding_requested",
15
- value,
16
- })
17
- const embedding = await model.embed(value)
18
- scope.event({
19
- type: "embedded",
20
- value,
21
- embedding,
22
- })
23
- return {
24
- ...scope,
25
- nextArg: scope.value,
26
- }
27
- })
28
- }
package/actions/emit.ts DELETED
@@ -1,21 +0,0 @@
1
- import { Action } from "../Action.ts"
2
- import type { Emitted } from "../events/Emitted.ts"
3
- import type { Spec } from "../Spec.ts"
4
- import type { JSONValue } from "../util/JSONValue.ts"
5
-
6
- export interface emit<V extends JSONValue> extends Action<"emit", Spec.Make<{ Event: Emitted<V> }>> {}
7
-
8
- export function* emit<V extends JSONValue = never>(
9
- value: V = undefined as never,
10
- ): Generator<emit<V>, void> {
11
- return yield Action("emit", (scope) => {
12
- scope.event({
13
- type: "emitted",
14
- value,
15
- })
16
- return {
17
- ...scope,
18
- nextArg: undefined,
19
- }
20
- }) as never
21
- }