liminal 0.5.2 → 0.5.4

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 (668) hide show
  1. package/Agent.ts +25 -7
  2. package/CHANGELOG.md +19 -0
  3. package/EventBase.ts +13 -0
  4. package/Fiber.ts +67 -0
  5. package/Globals.ts +10 -0
  6. package/Handler.ts +0 -0
  7. package/L/L.ts +12 -0
  8. package/L/_infer.ts +40 -0
  9. package/L/_message.ts +16 -0
  10. package/L/all.ts +11 -0
  11. package/L/assistant.ts +27 -0
  12. package/L/branch.ts +51 -0
  13. package/L/emit.ts +10 -0
  14. package/L/fork.ts +20 -0
  15. package/L/join.ts +9 -0
  16. package/L/model.ts +12 -0
  17. package/L/namespace.ts +11 -0
  18. package/L/rune.ts +19 -0
  19. package/L/self.ts +13 -0
  20. package/L/system.ts +13 -0
  21. package/L/user.ts +13 -0
  22. package/LEvent.ts +58 -0
  23. package/Message.ts +11 -90
  24. package/Model.ts +10 -23
  25. package/Rune.ts +17 -0
  26. package/Runic.ts +22 -0
  27. package/cli/main.ts +1 -24
  28. package/dist/Agent.d.ts +12 -7
  29. package/dist/Agent.js +14 -1
  30. package/dist/Agent.js.map +1 -1
  31. package/dist/EventBase.d.ts +7 -0
  32. package/dist/EventBase.js +14 -0
  33. package/dist/EventBase.js.map +1 -0
  34. package/dist/Fiber.d.ts +24 -0
  35. package/dist/Fiber.js +37 -0
  36. package/dist/Fiber.js.map +1 -0
  37. package/dist/Globals.d.ts +6 -0
  38. package/dist/Globals.js +2 -0
  39. package/dist/Globals.js.map +1 -0
  40. package/dist/Handler.js +2 -0
  41. package/dist/Handler.js.map +1 -0
  42. package/dist/L/L.d.ts +12 -0
  43. package/dist/L/L.js +13 -0
  44. package/dist/L/L.js.map +1 -0
  45. package/dist/L/_infer.d.ts +4 -0
  46. package/dist/L/_infer.js +32 -0
  47. package/dist/L/_infer.js.map +1 -0
  48. package/dist/L/_message.d.ts +6 -0
  49. package/dist/L/_message.js +12 -0
  50. package/dist/L/_message.js.map +1 -0
  51. package/dist/L/all.d.ts +7 -0
  52. package/dist/L/all.js +5 -0
  53. package/dist/L/all.js.map +1 -0
  54. package/dist/L/assistant.d.ts +7 -0
  55. package/dist/L/assistant.js +18 -0
  56. package/dist/L/assistant.js.map +1 -0
  57. package/dist/L/branch.d.ts +11 -0
  58. package/dist/L/branch.js +41 -0
  59. package/dist/L/branch.js.map +1 -0
  60. package/dist/L/emit.d.ts +5 -0
  61. package/dist/L/emit.js +6 -0
  62. package/dist/L/emit.js.map +1 -0
  63. package/dist/L/fork.js +20 -0
  64. package/dist/L/fork.js.map +1 -0
  65. package/dist/L/join.d.ts +5 -0
  66. package/dist/L/join.js +5 -0
  67. package/dist/L/join.js.map +1 -0
  68. package/dist/L/model.d.ts +5 -0
  69. package/dist/L/model.js +8 -0
  70. package/dist/L/model.js.map +1 -0
  71. package/dist/L/namespace.js +12 -0
  72. package/dist/L/namespace.js.map +1 -0
  73. package/dist/L/rune.d.ts +6 -0
  74. package/dist/L/rune.js +11 -0
  75. package/dist/L/rune.js.map +1 -0
  76. package/dist/L/self.d.ts +6 -0
  77. package/dist/L/self.js +7 -0
  78. package/dist/L/self.js.map +1 -0
  79. package/dist/L/system.d.ts +6 -0
  80. package/dist/L/system.js +7 -0
  81. package/dist/L/system.js.map +1 -0
  82. package/dist/L/user.d.ts +6 -0
  83. package/dist/L/user.js +7 -0
  84. package/dist/L/user.js.map +1 -0
  85. package/dist/LEvent.d.ts +31 -0
  86. package/dist/LEvent.js +49 -0
  87. package/dist/LEvent.js.map +1 -0
  88. package/dist/Message.d.ts +12 -81
  89. package/dist/Model.d.ts +4 -20
  90. package/dist/Model.js +6 -0
  91. package/dist/Model.js.map +1 -1
  92. package/dist/Rune.d.ts +11 -0
  93. package/dist/Rune.js +5 -0
  94. package/dist/Rune.js.map +1 -0
  95. package/dist/Runic.d.ts +9 -0
  96. package/dist/Runic.js +18 -0
  97. package/dist/Runic.js.map +1 -0
  98. package/dist/cli/main.d.ts +0 -1
  99. package/dist/cli/main.js +2 -19
  100. package/dist/cli/main.js.map +1 -1
  101. package/dist/index.d.ts +10 -38
  102. package/dist/index.js +10 -38
  103. package/dist/index.js.map +1 -1
  104. package/dist/run.d.ts +3 -0
  105. package/dist/run.js +35 -0
  106. package/dist/run.js.map +1 -0
  107. package/dist/state/Context.d.ts +8 -0
  108. package/dist/state/Context.js +17 -0
  109. package/dist/state/Context.js.map +1 -0
  110. package/dist/state/MessageRegistry.d.ts +8 -0
  111. package/dist/state/MessageRegistry.js +17 -0
  112. package/dist/state/MessageRegistry.js.map +1 -0
  113. package/dist/state/ModelConfig.d.ts +49 -0
  114. package/dist/state/ModelConfig.js +18 -0
  115. package/dist/state/ModelConfig.js.map +1 -0
  116. package/dist/state/ModelRegistry.d.ts +16 -0
  117. package/dist/state/ModelRegistry.js +52 -0
  118. package/dist/state/ModelRegistry.js.map +1 -0
  119. package/dist/state/StateMap.d.ts +8 -0
  120. package/dist/state/StateMap.js +18 -0
  121. package/dist/state/StateMap.js.map +1 -0
  122. package/dist/tsconfig.tsbuildinfo +1 -1
  123. package/index.ts +10 -38
  124. package/package.json +6 -10
  125. package/run.ts +39 -0
  126. package/state/Context.ts +19 -0
  127. package/state/MessageRegistry.ts +21 -0
  128. package/state/ModelConfig.ts +49 -0
  129. package/state/ModelRegistry.ts +65 -0
  130. package/state/StateMap.ts +24 -0
  131. package/tsconfig.json +5 -1
  132. package/Action.ts +0 -29
  133. package/Exec.ts +0 -51
  134. package/L.ts +0 -24
  135. package/LiminalAssertionError.ts +0 -3
  136. package/LiminalConfig.ts +0 -7
  137. package/PathLike.ts +0 -17
  138. package/Scope.ts +0 -152
  139. package/Spec.ts +0 -29
  140. package/Tool.ts +0 -58
  141. package/_.ts +0 -11
  142. package/actions/abort.ts +0 -23
  143. package/actions/actions_common/updateModels.ts +0 -23
  144. package/actions/actions_derived/__snapshots__/declareModel.test.ts.snap +0 -89
  145. package/actions/actions_derived/clear.ts +0 -6
  146. package/actions/actions_derived/declareModel.test.ts +0 -36
  147. package/actions/actions_derived/declareModel.ts +0 -9
  148. package/actions/actions_derived/declareModel.type-test.ts +0 -70
  149. package/actions/actions_derived/messages.test.ts +0 -88
  150. package/actions/actions_derived/messages.ts +0 -18
  151. package/actions/actions_derived/metatype.ts +0 -9
  152. package/actions/actions_derived/readers_derived.ts +0 -15
  153. package/actions/appendMessage.ts +0 -54
  154. package/actions/await.ts +0 -13
  155. package/actions/branch.ts +0 -106
  156. package/actions/catch.ts +0 -42
  157. package/actions/declareArg.ts +0 -14
  158. package/actions/disableTool.ts +0 -26
  159. package/actions/embed.ts +0 -29
  160. package/actions/emit.ts +0 -21
  161. package/actions/enableTool.ts +0 -75
  162. package/actions/enableTool.type-test.ts +0 -118
  163. package/actions/infer.ts +0 -49
  164. package/actions/messages.ts +0 -62
  165. package/actions/pushModel.ts +0 -52
  166. package/actions/scope.ts +0 -13
  167. package/actions/section.ts +0 -105
  168. package/actions/throw.ts +0 -18
  169. package/cli/WriteHandler.ts +0 -35
  170. package/cli/cli_common.ts +0 -4
  171. package/cli/runExec.ts +0 -72
  172. package/dist/Action.d.ts +0 -15
  173. package/dist/Action.js +0 -13
  174. package/dist/Action.js.map +0 -1
  175. package/dist/Exec.d.ts +0 -25
  176. package/dist/Exec.js +0 -19
  177. package/dist/Exec.js.map +0 -1
  178. package/dist/L.d.ts +0 -23
  179. package/dist/L.js +0 -24
  180. package/dist/L.js.map +0 -1
  181. package/dist/LiminalAssertionError.d.ts +0 -3
  182. package/dist/LiminalAssertionError.js +0 -4
  183. package/dist/LiminalAssertionError.js.map +0 -1
  184. package/dist/LiminalConfig.d.ts +0 -6
  185. package/dist/LiminalConfig.js +0 -2
  186. package/dist/LiminalConfig.js.map +0 -1
  187. package/dist/PathLike.d.ts +0 -11
  188. package/dist/PathLike.js +0 -2
  189. package/dist/PathLike.js.map +0 -1
  190. package/dist/Scope.d.ts +0 -42
  191. package/dist/Scope.js +0 -93
  192. package/dist/Scope.js.map +0 -1
  193. package/dist/Spec.d.ts +0 -20
  194. package/dist/Spec.js +0 -2
  195. package/dist/Spec.js.map +0 -1
  196. package/dist/Tool.d.ts +0 -21
  197. package/dist/Tool.js +0 -32
  198. package/dist/Tool.js.map +0 -1
  199. package/dist/_.d.ts +0 -5
  200. package/dist/_.js +0 -7
  201. package/dist/_.js.map +0 -1
  202. package/dist/actions/abort.d.ts +0 -9
  203. package/dist/actions/abort.js +0 -15
  204. package/dist/actions/abort.js.map +0 -1
  205. package/dist/actions/actions_common/updateModels.d.ts +0 -3
  206. package/dist/actions/actions_common/updateModels.js +0 -17
  207. package/dist/actions/actions_common/updateModels.js.map +0 -1
  208. package/dist/actions/actions_derived/clear.d.ts +0 -8
  209. package/dist/actions/actions_derived/clear.js +0 -5
  210. package/dist/actions/actions_derived/clear.js.map +0 -1
  211. package/dist/actions/actions_derived/declareModel.d.ts +0 -5
  212. package/dist/actions/actions_derived/declareModel.js +0 -7
  213. package/dist/actions/actions_derived/declareModel.js.map +0 -1
  214. package/dist/actions/actions_derived/declareModel.test.js +0 -35
  215. package/dist/actions/actions_derived/declareModel.test.js.map +0 -1
  216. package/dist/actions/actions_derived/declareModel.type-test.js +0 -66
  217. package/dist/actions/actions_derived/declareModel.type-test.js.map +0 -1
  218. package/dist/actions/actions_derived/messages.d.ts +0 -6
  219. package/dist/actions/actions_derived/messages.js +0 -15
  220. package/dist/actions/actions_derived/messages.js.map +0 -1
  221. package/dist/actions/actions_derived/messages.test.js +0 -72
  222. package/dist/actions/actions_derived/messages.test.js.map +0 -1
  223. package/dist/actions/actions_derived/metatype.d.ts +0 -9
  224. package/dist/actions/actions_derived/metatype.js +0 -7
  225. package/dist/actions/actions_derived/metatype.js.map +0 -1
  226. package/dist/actions/actions_derived/readers_derived.d.ts +0 -6
  227. package/dist/actions/actions_derived/readers_derived.js +0 -14
  228. package/dist/actions/actions_derived/readers_derived.js.map +0 -1
  229. package/dist/actions/appendMessage.d.ts +0 -14
  230. package/dist/actions/appendMessage.js +0 -41
  231. package/dist/actions/appendMessage.js.map +0 -1
  232. package/dist/actions/await.d.ts +0 -5
  233. package/dist/actions/await.js +0 -10
  234. package/dist/actions/await.js.map +0 -1
  235. package/dist/actions/branch.d.ts +0 -39
  236. package/dist/actions/branch.js +0 -40
  237. package/dist/actions/branch.js.map +0 -1
  238. package/dist/actions/catch.d.ts +0 -10
  239. package/dist/actions/catch.js +0 -27
  240. package/dist/actions/catch.js.map +0 -1
  241. package/dist/actions/declareArg.d.ts +0 -8
  242. package/dist/actions/declareArg.js +0 -10
  243. package/dist/actions/declareArg.js.map +0 -1
  244. package/dist/actions/disableTool.d.ts +0 -10
  245. package/dist/actions/disableTool.js +0 -17
  246. package/dist/actions/disableTool.js.map +0 -1
  247. package/dist/actions/embed.d.ts +0 -9
  248. package/dist/actions/embed.js +0 -24
  249. package/dist/actions/embed.js.map +0 -1
  250. package/dist/actions/emit.d.ts +0 -9
  251. package/dist/actions/emit.js +0 -14
  252. package/dist/actions/emit.js.map +0 -1
  253. package/dist/actions/enableTool.d.ts +0 -20
  254. package/dist/actions/enableTool.js +0 -26
  255. package/dist/actions/enableTool.js.map +0 -1
  256. package/dist/actions/enableTool.type-test.d.ts +0 -1
  257. package/dist/actions/enableTool.type-test.js +0 -30
  258. package/dist/actions/enableTool.type-test.js.map +0 -1
  259. package/dist/actions/infer.d.ts +0 -15
  260. package/dist/actions/infer.js +0 -29
  261. package/dist/actions/infer.js.map +0 -1
  262. package/dist/actions/messages.d.ts +0 -24
  263. package/dist/actions/messages.js +0 -35
  264. package/dist/actions/messages.js.map +0 -1
  265. package/dist/actions/pushModel.d.ts +0 -15
  266. package/dist/actions/pushModel.js +0 -36
  267. package/dist/actions/pushModel.js.map +0 -1
  268. package/dist/actions/scope.d.ts +0 -7
  269. package/dist/actions/scope.js +0 -10
  270. package/dist/actions/scope.js.map +0 -1
  271. package/dist/actions/section.d.ts +0 -23
  272. package/dist/actions/section.js +0 -64
  273. package/dist/actions/section.js.map +0 -1
  274. package/dist/actions/throw.d.ts +0 -9
  275. package/dist/actions/throw.js +0 -13
  276. package/dist/actions/throw.js.map +0 -1
  277. package/dist/cli/WriteHandler.d.ts +0 -9
  278. package/dist/cli/WriteHandler.js +0 -24
  279. package/dist/cli/WriteHandler.js.map +0 -1
  280. package/dist/cli/cli_common.d.ts +0 -4
  281. package/dist/cli/cli_common.js +0 -2
  282. package/dist/cli/cli_common.js.map +0 -1
  283. package/dist/cli/runExec.d.ts +0 -2
  284. package/dist/cli/runExec.js +0 -74
  285. package/dist/cli/runExec.js.map +0 -1
  286. package/dist/events/Aborted.d.ts +0 -4
  287. package/dist/events/Aborted.js +0 -2
  288. package/dist/events/Aborted.js.map +0 -1
  289. package/dist/events/Embedded.d.ts +0 -5
  290. package/dist/events/Embedded.js +0 -2
  291. package/dist/events/Embedded.js.map +0 -1
  292. package/dist/events/EmbeddingRequested.d.ts +0 -4
  293. package/dist/events/EmbeddingRequested.js +0 -2
  294. package/dist/events/EmbeddingRequested.js.map +0 -1
  295. package/dist/events/Emitted.d.ts +0 -4
  296. package/dist/events/Emitted.js +0 -2
  297. package/dist/events/Emitted.js.map +0 -1
  298. package/dist/events/EventBase.d.ts +0 -3
  299. package/dist/events/EventBase.js +0 -2
  300. package/dist/events/EventBase.js.map +0 -1
  301. package/dist/events/EventHandler.d.ts +0 -2
  302. package/dist/events/EventHandler.js +0 -2
  303. package/dist/events/EventHandler.js.map +0 -1
  304. package/dist/events/EventResolved.d.ts +0 -19
  305. package/dist/events/EventResolved.js +0 -2
  306. package/dist/events/EventResolved.js.map +0 -1
  307. package/dist/events/Forked.d.ts +0 -3
  308. package/dist/events/Forked.js +0 -2
  309. package/dist/events/Forked.js.map +0 -1
  310. package/dist/events/InferenceRequested.d.ts +0 -3
  311. package/dist/events/InferenceRequested.js +0 -2
  312. package/dist/events/InferenceRequested.js.map +0 -1
  313. package/dist/events/Inferred.d.ts +0 -5
  314. package/dist/events/Inferred.js +0 -2
  315. package/dist/events/Inferred.js.map +0 -1
  316. package/dist/events/LEvent.d.ts +0 -20
  317. package/dist/events/LEvent.js +0 -2
  318. package/dist/events/LEvent.js.map +0 -1
  319. package/dist/events/MessageAppended.d.ts +0 -5
  320. package/dist/events/MessageAppended.js +0 -2
  321. package/dist/events/MessageAppended.js.map +0 -1
  322. package/dist/events/MessageRemoved.d.ts +0 -5
  323. package/dist/events/MessageRemoved.js +0 -2
  324. package/dist/events/MessageRemoved.js.map +0 -1
  325. package/dist/events/MessagesSet.d.ts +0 -5
  326. package/dist/events/MessagesSet.js +0 -2
  327. package/dist/events/MessagesSet.js.map +0 -1
  328. package/dist/events/ModelPushed.d.ts +0 -7
  329. package/dist/events/ModelPushed.js +0 -2
  330. package/dist/events/ModelPushed.js.map +0 -1
  331. package/dist/events/ModelRemoved.d.ts +0 -7
  332. package/dist/events/ModelRemoved.js +0 -2
  333. package/dist/events/ModelRemoved.js.map +0 -1
  334. package/dist/events/Returned.d.ts +0 -4
  335. package/dist/events/Returned.js +0 -2
  336. package/dist/events/Returned.js.map +0 -1
  337. package/dist/events/SectionCleared.d.ts +0 -5
  338. package/dist/events/SectionCleared.js +0 -2
  339. package/dist/events/SectionCleared.js.map +0 -1
  340. package/dist/events/Sectioned.d.ts +0 -5
  341. package/dist/events/Sectioned.js +0 -2
  342. package/dist/events/Sectioned.js.map +0 -1
  343. package/dist/events/Threw.d.ts +0 -4
  344. package/dist/events/Threw.js +0 -2
  345. package/dist/events/Threw.js.map +0 -1
  346. package/dist/events/ToolCalled.d.ts +0 -6
  347. package/dist/events/ToolCalled.js +0 -2
  348. package/dist/events/ToolCalled.js.map +0 -1
  349. package/dist/events/ToolDisabled.d.ts +0 -5
  350. package/dist/events/ToolDisabled.js +0 -2
  351. package/dist/events/ToolDisabled.js.map +0 -1
  352. package/dist/events/ToolEnabled.d.ts +0 -7
  353. package/dist/events/ToolEnabled.js +0 -2
  354. package/dist/events/ToolEnabled.js.map +0 -1
  355. package/dist/events/isScopeChildEvent.d.ts +0 -6
  356. package/dist/events/isScopeChildEvent.js +0 -9
  357. package/dist/events/isScopeChildEvent.js.map +0 -1
  358. package/dist/events/isScopeDescendantEvent.d.ts +0 -14
  359. package/dist/events/isScopeDescendantEvent.js +0 -12
  360. package/dist/events/isScopeDescendantEvent.js.map +0 -1
  361. package/dist/testing/AgentAssertions.d.ts +0 -9
  362. package/dist/testing/AgentAssertions.js +0 -6
  363. package/dist/testing/AgentAssertions.js.map +0 -1
  364. package/dist/testing/TestEmbeddingModel.d.ts +0 -6
  365. package/dist/testing/TestEmbeddingModel.js +0 -11
  366. package/dist/testing/TestEmbeddingModel.js.map +0 -1
  367. package/dist/testing/TestLanguageModel.d.ts +0 -8
  368. package/dist/testing/TestLanguageModel.js +0 -22
  369. package/dist/testing/TestLanguageModel.js.map +0 -1
  370. package/dist/testing/index.d.ts +0 -4
  371. package/dist/testing/index.js +0 -5
  372. package/dist/testing/index.js.map +0 -1
  373. package/dist/testing/takeFirstAction.d.ts +0 -3
  374. package/dist/testing/takeFirstAction.js +0 -6
  375. package/dist/testing/takeFirstAction.js.map +0 -1
  376. package/dist/types/AssertDiagnostics.d.ts +0 -18
  377. package/dist/types/AssertDiagnostics.js +0 -152
  378. package/dist/types/AssertDiagnostics.js.map +0 -1
  379. package/dist/types/JSONRootType.d.ts +0 -6
  380. package/dist/types/JSONRootType.js +0 -2
  381. package/dist/types/JSONRootType.js.map +0 -1
  382. package/dist/types/JSONType.d.ts +0 -16
  383. package/dist/types/JSONType.js +0 -2
  384. package/dist/types/JSONType.js.map +0 -1
  385. package/dist/types/JSONTypeBase.d.ts +0 -3
  386. package/dist/types/JSONTypeBase.js +0 -2
  387. package/dist/types/JSONTypeBase.js.map +0 -1
  388. package/dist/types/Metatype/MetatypeDescriptor.d.ts +0 -41
  389. package/dist/types/Metatype/MetatypeDescriptor.js +0 -38
  390. package/dist/types/Metatype/MetatypeDescriptor.js.map +0 -1
  391. package/dist/types/Metatype/fromMetatypeDescriptor.d.ts +0 -6
  392. package/dist/types/Metatype/fromMetatypeDescriptor.js +0 -43
  393. package/dist/types/Metatype/fromMetatypeDescriptor.js.map +0 -1
  394. package/dist/types/Type.d.ts +0 -31
  395. package/dist/types/Type.js +0 -5
  396. package/dist/types/Type.js.map +0 -1
  397. package/dist/types/TypeContext.d.ts +0 -7
  398. package/dist/types/TypeContext.js +0 -17
  399. package/dist/types/TypeContext.js.map +0 -1
  400. package/dist/types/TypeLike.d.ts +0 -23
  401. package/dist/types/TypeLike.js +0 -23
  402. package/dist/types/TypeLike.js.map +0 -1
  403. package/dist/types/TypeVisitor.d.ts +0 -14
  404. package/dist/types/TypeVisitor.js +0 -12
  405. package/dist/types/TypeVisitor.js.map +0 -1
  406. package/dist/types/array.d.ts +0 -10
  407. package/dist/types/array.js +0 -9
  408. package/dist/types/array.js.map +0 -1
  409. package/dist/types/boolean.d.ts +0 -6
  410. package/dist/types/boolean.js +0 -3
  411. package/dist/types/boolean.js.map +0 -1
  412. package/dist/types/const.d.ts +0 -8
  413. package/dist/types/const.js +0 -7
  414. package/dist/types/const.js.map +0 -1
  415. package/dist/types/enum.d.ts +0 -8
  416. package/dist/types/enum.js +0 -7
  417. package/dist/types/enum.js.map +0 -1
  418. package/dist/types/factories.d.ts +0 -8
  419. package/dist/types/factories.js +0 -9
  420. package/dist/types/factories.js.map +0 -1
  421. package/dist/types/index.d.ts +0 -2
  422. package/dist/types/index.js +0 -3
  423. package/dist/types/index.js.map +0 -1
  424. package/dist/types/integer.d.ts +0 -6
  425. package/dist/types/integer.js +0 -3
  426. package/dist/types/integer.js.map +0 -1
  427. package/dist/types/intrinsics.d.ts +0 -11
  428. package/dist/types/intrinsics.js +0 -12
  429. package/dist/types/intrinsics.js.map +0 -1
  430. package/dist/types/makeType.d.ts +0 -2
  431. package/dist/types/makeType.js +0 -58
  432. package/dist/types/makeType.js.map +0 -1
  433. package/dist/types/match.d.ts +0 -3
  434. package/dist/types/match.js +0 -11
  435. package/dist/types/match.js.map +0 -1
  436. package/dist/types/non_factories.d.ts +0 -21
  437. package/dist/types/non_factories.js +0 -9
  438. package/dist/types/non_factories.js.map +0 -1
  439. package/dist/types/null.d.ts +0 -7
  440. package/dist/types/null.js +0 -4
  441. package/dist/types/null.js.map +0 -1
  442. package/dist/types/number.d.ts +0 -6
  443. package/dist/types/number.js +0 -3
  444. package/dist/types/number.js.map +0 -1
  445. package/dist/types/object.d.ts +0 -16
  446. package/dist/types/object.js +0 -10
  447. package/dist/types/object.js.map +0 -1
  448. package/dist/types/ref.d.ts +0 -7
  449. package/dist/types/ref.js +0 -5
  450. package/dist/types/ref.js.map +0 -1
  451. package/dist/types/string.d.ts +0 -6
  452. package/dist/types/string.js +0 -3
  453. package/dist/types/string.js.map +0 -1
  454. package/dist/types/toJSON.d.ts +0 -5
  455. package/dist/types/toJSON.js +0 -97
  456. package/dist/types/toJSON.js.map +0 -1
  457. package/dist/types/type_common.d.ts +0 -10
  458. package/dist/types/type_common.js +0 -12
  459. package/dist/types/type_common.js.map +0 -1
  460. package/dist/types/types_derived/option.d.ts +0 -5
  461. package/dist/types/types_derived/option.js +0 -6
  462. package/dist/types/types_derived/option.js.map +0 -1
  463. package/dist/types/types_derived/taggedUnion.d.ts +0 -19
  464. package/dist/types/types_derived/taggedUnion.js +0 -8
  465. package/dist/types/types_derived/taggedUnion.js.map +0 -1
  466. package/dist/types/types_derived/wrapper.d.ts +0 -8
  467. package/dist/types/types_derived/wrapper.js +0 -5
  468. package/dist/types/types_derived/wrapper.js.map +0 -1
  469. package/dist/types/union.d.ts +0 -9
  470. package/dist/types/union.js +0 -9
  471. package/dist/types/union.js.map +0 -1
  472. package/dist/util/ArrayOfLength.d.ts +0 -1
  473. package/dist/util/ArrayOfLength.js +0 -2
  474. package/dist/util/ArrayOfLength.js.map +0 -1
  475. package/dist/util/DeferredOr.d.ts +0 -1
  476. package/dist/util/DeferredOr.js +0 -2
  477. package/dist/util/DeferredOr.js.map +0 -1
  478. package/dist/util/EnsureNarrow.d.ts +0 -2
  479. package/dist/util/EnsureNarrow.js +0 -2
  480. package/dist/util/EnsureNarrow.js.map +0 -1
  481. package/dist/util/EnsureRecord.d.ts +0 -2
  482. package/dist/util/EnsureRecord.js +0 -2
  483. package/dist/util/EnsureRecord.js.map +0 -1
  484. package/dist/util/Expand.d.ts +0 -3
  485. package/dist/util/Expand.js +0 -2
  486. package/dist/util/Expand.js.map +0 -1
  487. package/dist/util/Falsy.d.ts +0 -1
  488. package/dist/util/Falsy.js +0 -2
  489. package/dist/util/Falsy.js.map +0 -1
  490. package/dist/util/FromEntries.d.ts +0 -3
  491. package/dist/util/FromEntries.js +0 -2
  492. package/dist/util/FromEntries.js.map +0 -1
  493. package/dist/util/IteratorLike.d.ts +0 -1
  494. package/dist/util/IteratorLike.js +0 -2
  495. package/dist/util/IteratorLike.js.map +0 -1
  496. package/dist/util/JSONEntry.d.ts +0 -2
  497. package/dist/util/JSONEntry.js +0 -2
  498. package/dist/util/JSONEntry.js.map +0 -1
  499. package/dist/util/JSONKey.d.ts +0 -1
  500. package/dist/util/JSONKey.js +0 -2
  501. package/dist/util/JSONKey.js.map +0 -1
  502. package/dist/util/JSONObject.d.ts +0 -5
  503. package/dist/util/JSONObject.js +0 -2
  504. package/dist/util/JSONObject.js.map +0 -1
  505. package/dist/util/JSONSchemaMemo.d.ts +0 -2
  506. package/dist/util/JSONSchemaMemo.js +0 -13
  507. package/dist/util/JSONSchemaMemo.js.map +0 -1
  508. package/dist/util/JSONValue.d.ts +0 -2
  509. package/dist/util/JSONValue.js +0 -2
  510. package/dist/util/JSONValue.js.map +0 -1
  511. package/dist/util/PromiseOr.d.ts +0 -1
  512. package/dist/util/PromiseOr.js +0 -2
  513. package/dist/util/PromiseOr.js.map +0 -1
  514. package/dist/util/Result.d.ts +0 -7
  515. package/dist/util/Result.js +0 -2
  516. package/dist/util/Result.js.map +0 -1
  517. package/dist/util/Taggable.d.ts +0 -9
  518. package/dist/util/Taggable.js +0 -8
  519. package/dist/util/Taggable.js.map +0 -1
  520. package/dist/util/TupleToRecord.d.ts +0 -5
  521. package/dist/util/TupleToRecord.js +0 -2
  522. package/dist/util/TupleToRecord.js.map +0 -1
  523. package/dist/util/assert.d.ts +0 -1
  524. package/dist/util/assert.js +0 -7
  525. package/dist/util/assert.js.map +0 -1
  526. package/dist/util/dedent.d.ts +0 -1
  527. package/dist/util/dedent.js +0 -5
  528. package/dist/util/dedent.js.map +0 -1
  529. package/dist/util/fixTemplateStrings.d.ts +0 -11
  530. package/dist/util/fixTemplateStrings.js +0 -83
  531. package/dist/util/fixTemplateStrings.js.map +0 -1
  532. package/dist/util/fixTemplateStrings.test.d.ts +0 -1
  533. package/dist/util/fixTemplateStrings.test.js +0 -221
  534. package/dist/util/fixTemplateStrings.test.js.map +0 -1
  535. package/dist/util/isAsyncIterator.d.ts +0 -1
  536. package/dist/util/isAsyncIterator.js +0 -7
  537. package/dist/util/isAsyncIterator.js.map +0 -1
  538. package/dist/util/isIterator.d.ts +0 -1
  539. package/dist/util/isIterator.js +0 -7
  540. package/dist/util/isIterator.js.map +0 -1
  541. package/dist/util/isJSONValue.d.ts +0 -2
  542. package/dist/util/isJSONValue.js +0 -16
  543. package/dist/util/isJSONValue.js.map +0 -1
  544. package/dist/util/isPropertyKey.d.ts +0 -1
  545. package/dist/util/isPropertyKey.js +0 -4
  546. package/dist/util/isPropertyKey.js.map +0 -1
  547. package/dist/util/isTemplateStringsArray.d.ts +0 -1
  548. package/dist/util/isTemplateStringsArray.js +0 -4
  549. package/dist/util/isTemplateStringsArray.js.map +0 -1
  550. package/dist/util/jsonEquals.d.ts +0 -2
  551. package/dist/util/jsonEquals.js +0 -33
  552. package/dist/util/jsonEquals.js.map +0 -1
  553. package/dist/util/nullaryMemo.d.ts +0 -1
  554. package/dist/util/nullaryMemo.js +0 -12
  555. package/dist/util/nullaryMemo.js.map +0 -1
  556. package/dist/util/peekLast.d.ts +0 -1
  557. package/dist/util/peekLast.js +0 -4
  558. package/dist/util/peekLast.js.map +0 -1
  559. package/dist/util/unimplemented.d.ts +0 -1
  560. package/dist/util/unimplemented.js +0 -5
  561. package/dist/util/unimplemented.js.map +0 -1
  562. package/dist/util/unreachable.d.ts +0 -1
  563. package/dist/util/unreachable.js +0 -5
  564. package/dist/util/unreachable.js.map +0 -1
  565. package/dist/util/unwrapDeferred.d.ts +0 -2
  566. package/dist/util/unwrapDeferred.js +0 -4
  567. package/dist/util/unwrapDeferred.js.map +0 -1
  568. package/dist/util/util.d.ts +0 -10
  569. package/dist/util/util.js +0 -11
  570. package/dist/util/util.js.map +0 -1
  571. package/events/Aborted.ts +0 -5
  572. package/events/Embedded.ts +0 -6
  573. package/events/EmbeddingRequested.ts +0 -5
  574. package/events/Emitted.ts +0 -5
  575. package/events/EventBase.ts +0 -3
  576. package/events/EventHandler.ts +0 -3
  577. package/events/EventResolved.ts +0 -30
  578. package/events/Forked.ts +0 -3
  579. package/events/InferenceRequested.ts +0 -3
  580. package/events/Inferred.ts +0 -6
  581. package/events/LEvent.ts +0 -40
  582. package/events/MessageAppended.ts +0 -6
  583. package/events/MessageRemoved.ts +0 -6
  584. package/events/MessagesSet.ts +0 -6
  585. package/events/ModelPushed.ts +0 -10
  586. package/events/ModelRemoved.ts +0 -10
  587. package/events/Returned.ts +0 -5
  588. package/events/SectionCleared.ts +0 -6
  589. package/events/Sectioned.ts +0 -6
  590. package/events/Threw.ts +0 -5
  591. package/events/ToolCalled.ts +0 -7
  592. package/events/ToolDisabled.ts +0 -6
  593. package/events/ToolEnabled.ts +0 -8
  594. package/events/isScopeChildEvent.ts +0 -15
  595. package/events/isScopeDescendantEvent.ts +0 -30
  596. package/testing/AgentAssertions.ts +0 -17
  597. package/testing/TestEmbeddingModel.ts +0 -19
  598. package/testing/TestLanguageModel.ts +0 -33
  599. package/testing/index.ts +0 -4
  600. package/testing/takeFirstAction.ts +0 -8
  601. package/types/AssertDiagnostics.ts +0 -183
  602. package/types/JSONRootType.ts +0 -8
  603. package/types/JSONType.ts +0 -27
  604. package/types/JSONTypeBase.ts +0 -3
  605. package/types/Metatype/MetatypeDescriptor.ts +0 -80
  606. package/types/Metatype/fromMetatypeDescriptor.ts +0 -52
  607. package/types/Type.ts +0 -47
  608. package/types/TypeContext.ts +0 -19
  609. package/types/TypeLike.ts +0 -60
  610. package/types/TypeVisitor.ts +0 -49
  611. package/types/array.ts +0 -20
  612. package/types/boolean.ts +0 -9
  613. package/types/const.ts +0 -17
  614. package/types/enum.ts +0 -14
  615. package/types/factories.ts +0 -8
  616. package/types/index.ts +0 -2
  617. package/types/integer.ts +0 -9
  618. package/types/intrinsics.ts +0 -11
  619. package/types/makeType.ts +0 -72
  620. package/types/match.ts +0 -13
  621. package/types/non_factories.ts +0 -26
  622. package/types/null.ts +0 -10
  623. package/types/number.ts +0 -9
  624. package/types/object.ts +0 -27
  625. package/types/ref.ts +0 -12
  626. package/types/string.ts +0 -9
  627. package/types/toJSON.ts +0 -111
  628. package/types/type_common.ts +0 -21
  629. package/types/types_derived/option.ts +0 -10
  630. package/types/types_derived/taggedUnion.ts +0 -30
  631. package/types/types_derived/wrapper.ts +0 -10
  632. package/types/union.ts +0 -19
  633. package/util/ArrayOfLength.ts +0 -5
  634. package/util/DeferredOr.ts +0 -1
  635. package/util/EnsureNarrow.ts +0 -5
  636. package/util/EnsureRecord.ts +0 -3
  637. package/util/Expand.ts +0 -1
  638. package/util/Falsy.ts +0 -1
  639. package/util/FromEntries.ts +0 -3
  640. package/util/IteratorLike.ts +0 -1
  641. package/util/JSONEntry.ts +0 -3
  642. package/util/JSONKey.ts +0 -1
  643. package/util/JSONObject.ts +0 -6
  644. package/util/JSONSchemaMemo.ts +0 -15
  645. package/util/JSONValue.ts +0 -3
  646. package/util/PromiseOr.ts +0 -1
  647. package/util/Result.ts +0 -7
  648. package/util/Taggable.ts +0 -18
  649. package/util/TupleToRecord.ts +0 -5
  650. package/util/assert.ts +0 -7
  651. package/util/dedent.ts +0 -5
  652. package/util/fixTemplateStrings.test.ts +0 -250
  653. package/util/fixTemplateStrings.ts +0 -99
  654. package/util/isAsyncIterator.ts +0 -6
  655. package/util/isIterator.ts +0 -6
  656. package/util/isJSONValue.ts +0 -20
  657. package/util/isPropertyKey.ts +0 -3
  658. package/util/isTemplateStringsArray.ts +0 -3
  659. package/util/jsonEquals.ts +0 -41
  660. package/util/nullaryMemo.ts +0 -11
  661. package/util/peekLast.ts +0 -3
  662. package/util/unimplemented.ts +0 -5
  663. package/util/unreachable.ts +0 -5
  664. package/util/unwrapDeferred.ts +0 -5
  665. package/util/util.ts +0 -10
  666. /package/dist/{actions/actions_derived/declareModel.test.d.ts → Handler.d.ts} +0 -0
  667. /package/dist/{actions/actions_derived/declareModel.type-test.d.ts → L/fork.d.ts} +0 -0
  668. /package/dist/{actions/actions_derived/messages.test.d.ts → L/namespace.d.ts} +0 -0
@@ -1,183 +0,0 @@
1
- import { assert } from "../util/assert.ts"
2
- import { isJSONValue } from "../util/isJSONValue.ts"
3
- import { jsonEquals } from "../util/jsonEquals.ts"
4
- import type { JSONKey } from "../util/JSONKey.ts"
5
- import type { JSONValue } from "../util/JSONValue.ts"
6
- import type { JSONType } from "./JSONType.ts"
7
- import type { Type } from "./Type.ts"
8
- import { TypeVisitor } from "./TypeVisitor.ts"
9
-
10
- export type AssertDiagnostics = Array<Diagnostic>
11
-
12
- export type Diagnostic = ReturnType<typeof Diagnostic>
13
- export function Diagnostic(path: AssertPath, type: Type, error: unknown) {
14
- return {
15
- path,
16
- type,
17
- error,
18
- message,
19
- formatPath,
20
- }
21
-
22
- function message() {
23
- return error instanceof Error ? error.message : JSON.stringify(error)
24
- }
25
-
26
- function formatPath() {
27
- let formatted = ""
28
- for (let i = 0; i < path.length; i++) {
29
- const key = path[i]!
30
- if (typeof key === "string") {
31
- try {
32
- const int = parseInt(key)
33
- if (Number.isInteger(int)) {
34
- formatted += `[${int}]`
35
- } else {
36
- formatted += `.${key}`
37
- }
38
- } catch (_e: unknown) {
39
- formatted += `.${key}`
40
- }
41
- } else {
42
- formatted += `[${key}]`
43
- }
44
- }
45
- return formatted
46
- }
47
- }
48
-
49
- export type AssertPath = Array<JSONKey>
50
-
51
- // Possibly: `nullUnionFieldsAsOptional?: boolean`
52
- export interface AssertDiagnosticsConfig {}
53
-
54
- export function AssertDiagnostics<T extends JSONValue, J extends JSONType>(
55
- config: AssertDiagnosticsConfig,
56
- type: Type<T, J>,
57
- value: unknown,
58
- ): Array<Diagnostic> {
59
- const state = ValueVisitorState()
60
- visit([config, false], type)(value, state)
61
- return state.diagnostics
62
- }
63
-
64
- type ValueVisitorState = ReturnType<typeof ValueVisitorState>
65
- function ValueVisitorState(
66
- diagnostics: Array<Diagnostic> = [],
67
- path: Array<number | string> = [],
68
- ) {
69
- return {
70
- diagnostics,
71
- path,
72
- next,
73
- }
74
-
75
- function next(key?: JSONKey) {
76
- return ValueVisitorState(diagnostics, [...path, ...key !== undefined ? [key] : []])
77
- }
78
- }
79
-
80
- const visit: TypeVisitor<AssertDiagnosticsConfig, (value: unknown, vState: ValueVisitorState) => void> = TypeVisitor(
81
- {
82
- hook(next, tState, type) {
83
- return (value, vState) => {
84
- try {
85
- next(tState, type)(value, vState)
86
- } catch (error) {
87
- vState.diagnostics.push(Diagnostic(vState.path, type, error))
88
- }
89
- }
90
- },
91
- null() {
92
- return (value) => {
93
- assert(value === null)
94
- }
95
- },
96
- boolean() {
97
- return (value) => {
98
- assert(typeof value === "boolean")
99
- }
100
- },
101
- integer() {
102
- return (value) => {
103
- assert(typeof value === "number" && Number.isInteger(value))
104
- }
105
- },
106
- number() {
107
- return (value) => {
108
- assert(typeof value === "number")
109
- }
110
- },
111
- string() {
112
- return (value) => {
113
- assert(typeof value === "string")
114
- }
115
- },
116
- const(_tState, _type, _valueType, value_) {
117
- return (value) => {
118
- assert(isJSONValue(value) && jsonEquals(value_, value))
119
- }
120
- },
121
- _array(tState, _type, element) {
122
- const visitElement = visit(tState, element)
123
- return (value, vState) => {
124
- assert(Array.isArray(value))
125
- value.forEach((e, i) => visitElement(e, vState.next(i)))
126
- }
127
- },
128
- enum(_tState, _type, ...values) {
129
- return (value) => {
130
- assert(typeof value == "string")
131
- assert(values.includes(value))
132
- }
133
- },
134
- _union(tState, _type, ...members) {
135
- return (value, vState) => {
136
- assert(members.some((member) => {
137
- const memberState = vState.next()
138
- visit(tState, member)(value, memberState)
139
- return !memberState.diagnostics.length
140
- }))
141
- }
142
- },
143
- _object(tState, _type, fields) {
144
- return (value, vState) => {
145
- assert(typeof value === "object" && value !== null)
146
- if (Array.isArray(fields)) {
147
- fields.forEach((v, i) => {
148
- visitField(tState, vState, value, i, v)
149
- })
150
- } else {
151
- Object.entries(fields).forEach(([k, v]) => {
152
- visitField(tState, vState, value, k, v)
153
- })
154
- }
155
- }
156
- },
157
- ref(tState, _type, getType) {
158
- return (value, vState) => {
159
- visit(tState, getType())(value, vState)
160
- }
161
- },
162
- },
163
- )
164
-
165
- function visitField(
166
- tState: AssertDiagnosticsConfig,
167
- vState: ValueVisitorState,
168
- value: object,
169
- key: JSONKey,
170
- type: Type,
171
- ) {
172
- assert(key in value)
173
- const childValue = value[key as never]
174
- assert(childValue !== undefined)
175
- visit(tState, type)(childValue, vState.next(key))
176
- }
177
-
178
- // TODO: serialize signature
179
- export function formatAssertDiagnostics(diagnostics: AssertDiagnostics) {
180
- return diagnostics
181
- .map((diagnostic) => `Error "${diagnostic.message()}"; encountered at ${diagnostic.formatPath()}`)
182
- .join("\n")
183
- }
@@ -1,8 +0,0 @@
1
- import type { JSONIdentifiedType, JSONType } from "./JSONType.ts"
2
-
3
- export const JSONSchema$schema = "http://json-schema.org/draft-07/schema#"
4
-
5
- export type JSONRootType<J extends JSONType> = J & {
6
- $schema: typeof JSONSchema$schema
7
- $defs: Record<string, JSONIdentifiedType | undefined>
8
- }
package/types/JSONType.ts DELETED
@@ -1,27 +0,0 @@
1
- import type { JSONArrayType } from "./array.ts"
2
- import type { JSONBooleanType } from "./boolean.ts"
3
- import type { JSONConstType } from "./const.ts"
4
- import type { JSONEnumType } from "./enum.ts"
5
- import type { JSONIntegerType } from "./integer.ts"
6
- import type { JSONNullType } from "./null.ts"
7
- import type { JSONNumberType } from "./number.ts"
8
- import type { JSONObjectType } from "./object.ts"
9
- import type { JSONRefType } from "./ref.ts"
10
- import type { JSONStringType } from "./string.ts"
11
- import type { JSONUnionType } from "./union.ts"
12
-
13
- export type JSONIdentifiedType = JSONArrayType | JSONObjectType | JSONUnionType
14
-
15
- export type JSONAnonymousType =
16
- | JSONNullType
17
- | JSONBooleanType
18
- | JSONIntegerType
19
- | JSONNumberType
20
- | JSONStringType
21
- | JSONEnumType
22
-
23
- export type ConstableType = JSONAnonymousType | JSONIdentifiedType
24
-
25
- export type JSONRootableType = ConstableType | JSONConstType
26
-
27
- export type JSONType = JSONRootableType | JSONRefType
@@ -1,3 +0,0 @@
1
- export interface JSONTypeBase {
2
- description?: string
3
- }
@@ -1,80 +0,0 @@
1
- import { array } from "../array.ts"
2
- import { enum as enum_ } from "../enum.ts"
3
- import { type JSONObjectType, object } from "../object.ts"
4
- import { ref } from "../ref.ts"
5
- import { string } from "../string.ts"
6
- import type { Type } from "../Type.ts"
7
- import { taggedUnion } from "../types_derived/taggedUnion.ts"
8
- import type { JSONUnionType } from "../union.ts"
9
-
10
- export type MetatypeRootDescriptor = {
11
- type: "record"
12
- value: {
13
- description: string
14
- fields: Array<{
15
- description: string
16
- key: string
17
- value: MetatypeDescriptor
18
- }>
19
- }
20
- }
21
-
22
- const recordFields = {
23
- description: string,
24
- fields: array({
25
- description: string,
26
- key: string,
27
- value: ref(() => MetatypeDescriptor),
28
- }),
29
- }
30
-
31
- export const MetatypeRootDescriptor: Type<MetatypeRootDescriptor, JSONObjectType> = object({
32
- type: "record",
33
- value: recordFields,
34
- })
35
-
36
- export type MetatypeDescriptor = MetatypeRootDescriptor | {
37
- type: "atom"
38
- value: {
39
- description: string
40
- atomType: "boolean" | "integer" | "number" | "string"
41
- }
42
- } | {
43
- type: "enum"
44
- value: {
45
- description: string
46
- variants: Array<string>
47
- }
48
- } | {
49
- type: "array"
50
- value: {
51
- description: string
52
- items: MetatypeDescriptor
53
- }
54
- } | {
55
- type: "union"
56
- value: {
57
- description: string
58
- members: Array<MetatypeDescriptor>
59
- }
60
- }
61
-
62
- export const MetatypeDescriptor: Type<MetatypeDescriptor, JSONUnionType> = taggedUnion({
63
- atom: {
64
- description: string,
65
- atomType: enum_("boolean", "integer", "number", "string"),
66
- },
67
- enum: {
68
- description: string,
69
- variants: array(string),
70
- },
71
- array: {
72
- description: string,
73
- items: ref(() => MetatypeDescriptor),
74
- },
75
- record: recordFields,
76
- union: {
77
- description: string,
78
- members: array(ref(() => MetatypeDescriptor)),
79
- },
80
- })
@@ -1,52 +0,0 @@
1
- import type { JSONObject } from "../../util/JSONObject.ts"
2
- import { array } from "../array.ts"
3
- import { boolean } from "../boolean.ts"
4
- import { enum as enum_ } from "../enum.ts"
5
- import { integer } from "../integer.ts"
6
- import { number } from "../number.ts"
7
- import { type JSONObjectType, object } from "../object.ts"
8
- import { string } from "../string.ts"
9
- import type { Type } from "../Type.ts"
10
- import { union } from "../union.ts"
11
- import type { MetatypeDescriptor, MetatypeRootDescriptor } from "./MetatypeDescriptor.ts"
12
-
13
- export function fromMetatypeRootDescriptor(descriptor: MetatypeRootDescriptor): Type<JSONObject, JSONObjectType> {
14
- return fromMetatypeDescriptor(descriptor) as never
15
- }
16
-
17
- export function fromMetatypeDescriptor(descriptor: MetatypeDescriptor): Type {
18
- return make(descriptor)(descriptor.value.description)
19
- }
20
-
21
- function make(descriptor: MetatypeDescriptor): Type {
22
- switch (descriptor.type) {
23
- case "atom": {
24
- switch (descriptor.value.atomType) {
25
- case "boolean":
26
- return boolean
27
- case "integer":
28
- return integer
29
- case "number":
30
- return number
31
- case "string":
32
- return string
33
- }
34
- }
35
- case "array": {
36
- return array(fromMetatypeDescriptor(descriptor.value.items))
37
- }
38
- case "enum": {
39
- return enum_(...descriptor.value.variants)
40
- }
41
- case "record": {
42
- return object(Object.fromEntries(descriptor.value.fields.map(({
43
- key,
44
- value,
45
- description,
46
- }) => [key, fromMetatypeDescriptor(value)(description)])))
47
- }
48
- case "union": {
49
- return union(...descriptor.value.members.map(fromMetatypeDescriptor))
50
- }
51
- }
52
- }
package/types/Type.ts DELETED
@@ -1,47 +0,0 @@
1
- import type { StandardSchemaV1 } from "@standard-schema/spec"
2
- import type { Action } from "../Action.ts"
3
- import type { InferenceRequested } from "../events/InferenceRequested.ts"
4
- import type { Inferred } from "../events/Inferred.ts"
5
- import type { Spec } from "../Spec.ts"
6
- import type { Falsy } from "../util/Falsy.ts"
7
- import type { JSONValue } from "../util/JSONValue.ts"
8
- import type { Taggable } from "../util/Taggable.ts"
9
- import type { JSONRootType } from "./JSONRootType.ts"
10
- import type { JSONType } from "./JSONType.ts"
11
- import type { JSONObjectType } from "./object.ts"
12
-
13
- export interface Type<T extends JSONValue = JSONValue, J extends JSONType = JSONType>
14
- extends Taggable<Array<string | Falsy>>, TypeMembers<T, J>
15
- {
16
- T: T
17
- J: J
18
-
19
- [Symbol.iterator]: J extends JSONObjectType ? () => Iterator<
20
- Action<
21
- "infer",
22
- Spec.Make<{
23
- Event: InferenceRequested | Inferred
24
- }>
25
- >,
26
- T
27
- >
28
- : never
29
- }
30
-
31
- export interface TypeMembers<T extends JSONValue, J extends JSONType> extends StandardSchemaV1<T> {
32
- [TypeKey]: true
33
- declaration: () => Type<T, J> | ((...args: any) => Type<T, J>)
34
- args?: Array<any>
35
- descriptions: Array<string>
36
- trace: string | undefined
37
- description(): string
38
- toJSON(): JSONRootType<J>
39
- assert(value: unknown): T
40
- }
41
-
42
- export type TypeKey = typeof TypeKey
43
- export const TypeKey = Symbol.for("Liminal/Type")
44
-
45
- export function isType(value: unknown): value is Type {
46
- return typeof value === "function" && TypeKey in value
47
- }
@@ -1,19 +0,0 @@
1
- import type { Type } from "./Type.js"
2
-
3
- export class TypeContext {
4
- root: Type
5
- ids: Map<Type, string>
6
- constructor(root: Type, ids: Map<Type, string> = new Map()) {
7
- this.root = root
8
- this.ids = ids
9
- }
10
-
11
- id(type: Type): string {
12
- let id = this.ids.get(type)
13
- if (id === undefined) {
14
- id = this.ids.size.toString()
15
- this.ids.set(type, id)
16
- }
17
- return id
18
- }
19
- }
package/types/TypeLike.ts DELETED
@@ -1,60 +0,0 @@
1
- import type { Falsy } from "../util/Falsy.ts"
2
- import type { JSONKey } from "../util/JSONKey.ts"
3
- import { const as const_, type JSONConstType } from "./const.ts"
4
- import { type JSONNullType, null as null_ } from "./null.ts"
5
- import { _object, type JSONObjectType } from "./object.ts"
6
- import { type JSONStringType, string } from "./string.ts"
7
- import { isType, type Type } from "./Type.ts"
8
-
9
- export type TypeLike = Type | TypeLikes | string | Falsy
10
- export type TypeLikes = TypeLikeArray | TypeLikeRecord
11
-
12
- export type TypeLikeArray = Array<TypeLike>
13
- export type TypeLikeRecord = {
14
- [key: JSONKey]: TypeLike
15
- }
16
-
17
- export type NormalizeTypeLikesT<F extends TypeLikes> =
18
- & {
19
- -readonly [K in keyof F as F extends TypeLikeArray ? K extends `${number}` ? K : never : K]: NormalizeTypeLikeT<
20
- Extract<F[K], TypeLike>
21
- >
22
- }
23
- & {}
24
-
25
- export type NormalizeTypeLikeT<V extends TypeLike> = V extends TypeLikes ? NormalizeTypeLikesT<V>
26
- : V extends string ? V
27
- : V extends Type<infer T> ? T
28
- : null
29
-
30
- export type NormalizeTypeLikesJ<F extends TypeLikes> =
31
- & {
32
- -readonly [K in keyof F as F extends TypeLikeArray ? K extends `${number}` ? K : never : K]: NormalizeTypeLikeJ<
33
- Extract<F[K], TypeLike>
34
- >
35
- }
36
- & {}
37
-
38
- export type NormalizeTypeLikeJ<V extends TypeLike> = V extends TypeLikes ? JSONObjectType<NormalizeTypeLikesJ<V>>
39
- : V extends string ? JSONConstType<JSONStringType, V>
40
- : V extends Type<any, infer J> ? J
41
- : JSONNullType
42
-
43
- export function normalizeTypeLikes(fields: TypeLikes): Type {
44
- return (Array.isArray(fields)
45
- ? _object(fields.map(normalizeTypeLike))
46
- : _object(Object.fromEntries(Object.entries(fields).map(([k, v]) => [k, normalizeTypeLike(v)]))))
47
- }
48
-
49
- export function normalizeTypeLike(value: TypeLike): Type {
50
- if (!value) {
51
- return null_
52
- }
53
- if (typeof value === "string") {
54
- return const_(string, value)
55
- }
56
- if (isType(value)) {
57
- return value
58
- }
59
- return normalizeTypeLikes(value)
60
- }
@@ -1,49 +0,0 @@
1
- import type { Type } from "./Type.ts"
2
- import { type IntrinsicTypes, typeName } from "./type_common.ts"
3
-
4
- export type VisitorArms<S, R> =
5
- & {
6
- hook?: (
7
- next: (state: S, type: Type) => R,
8
- state: S,
9
- type: Type,
10
- ) => R
11
- }
12
- & (
13
- | (
14
- & IntrinsicVisitorArms<S, R>
15
- & { fallback?: never }
16
- )
17
- | (
18
- & Partial<IntrinsicVisitorArms<S, R>>
19
- & { fallback: () => R }
20
- )
21
- )
22
-
23
- export type IntrinsicVisitorArms<S, R> = {
24
- [K in keyof IntrinsicTypes]: (
25
- state: S,
26
- ...args: IntrinsicTypes[K] extends Type ? [IntrinsicTypes[K]]
27
- : IntrinsicTypes[K] extends (...args: infer A) => infer T ? [T, ...A]
28
- : never
29
- ) => R
30
- }
31
-
32
- export type TypeVisitor<S, R> = (state: S, type: Type) => R
33
-
34
- export function TypeVisitor<S, R>(arms: VisitorArms<S, R>): (state: S, type: Type) => R {
35
- const { hook } = arms
36
- if (hook) {
37
- return (state, type) => hook(next, state, type)
38
- }
39
-
40
- return next
41
-
42
- function next(state: S, type: Type): R {
43
- return (arms[typeName(type)] as any ?? arms.fallback)(
44
- state,
45
- type,
46
- ...(type.args ?? []),
47
- )
48
- }
49
- }
package/types/array.ts DELETED
@@ -1,20 +0,0 @@
1
- import type { JSONType } from "./JSONType.ts"
2
- import type { JSONTypeBase } from "./JSONTypeBase.ts"
3
- import { makeType } from "./makeType.ts"
4
- import type { Type } from "./Type.ts"
5
- import { normalizeTypeLike, type NormalizeTypeLikeJ, type NormalizeTypeLikeT, type TypeLike } from "./TypeLike.ts"
6
-
7
- export function array<const F extends TypeLike>(
8
- element: F,
9
- ): Type<Array<NormalizeTypeLikeT<F>>, JSONArrayType<NormalizeTypeLikeJ<F>>> {
10
- return _array(normalizeTypeLike(element)) as never
11
- }
12
-
13
- export function _array(element: Type): Type {
14
- return makeType(() => _array, [element])
15
- }
16
-
17
- export interface JSONArrayType<E extends JSONType = any> extends JSONTypeBase {
18
- type: "array"
19
- items: E
20
- }
package/types/boolean.ts DELETED
@@ -1,9 +0,0 @@
1
- import type { JSONTypeBase } from "./JSONTypeBase.ts"
2
- import { makeType } from "./makeType.ts"
3
- import type { Type } from "./Type.ts"
4
-
5
- export const boolean: Type<boolean, JSONBooleanType> = makeType(() => boolean)
6
-
7
- export interface JSONBooleanType extends JSONTypeBase {
8
- type: "boolean"
9
- }
package/types/const.ts DELETED
@@ -1,17 +0,0 @@
1
- import type { JSONValue } from "../util/JSONValue.ts"
2
- import type { ConstableType } from "./JSONType.ts"
3
- import { makeType } from "./makeType.ts"
4
- import type { Type } from "./Type.ts"
5
-
6
- function const_<T extends JSONValue, J extends ConstableType, const V extends T>(
7
- type: Type<T, J>,
8
- value: V,
9
- ): Type<V, JSONConstType<J, V>> {
10
- return makeType(() => const_<T, J, V>, [type, value])
11
- }
12
- Object.defineProperty(const_, "name", { value: "const" })
13
- export { const_ as const }
14
-
15
- export type JSONConstType<J extends ConstableType = any, V extends JSONValue = JSONValue> = J & {
16
- const: V
17
- }
package/types/enum.ts DELETED
@@ -1,14 +0,0 @@
1
- import type { JSONTypeBase } from "./JSONTypeBase.ts"
2
- import { makeType } from "./makeType.ts"
3
- import type { Type } from "./Type.ts"
4
-
5
- export { enum_ as enum }
6
- function enum_<A extends Array<string>>(...values: A): Type<A[number], JSONEnumType<A[number]>> {
7
- return makeType(() => enum_<A>, values)
8
- }
9
- Object.defineProperty(enum_, "name", { value: "enum" })
10
-
11
- export interface JSONEnumType<K extends string = string> extends JSONTypeBase {
12
- type: "string"
13
- enum: Array<K>
14
- }
@@ -1,8 +0,0 @@
1
- export { array } from "./array.ts"
2
- export { boolean, const, enum, integer, null, number, ref, string } from "./intrinsics.ts"
3
- export { MetatypeDescriptor, MetatypeRootDescriptor } from "./Metatype/MetatypeDescriptor.ts"
4
- export { object } from "./object.ts"
5
- export { option } from "./types_derived/option.ts"
6
- export { taggedUnion } from "./types_derived/taggedUnion.ts"
7
- export { wrapper } from "./types_derived/wrapper.ts"
8
- export { union } from "./union.ts"
package/types/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from "./factories.ts"
2
- export * from "./non_factories.ts"
package/types/integer.ts DELETED
@@ -1,9 +0,0 @@
1
- import type { JSONTypeBase } from "./JSONTypeBase.ts"
2
- import { makeType } from "./makeType.ts"
3
- import type { Type } from "./Type.ts"
4
-
5
- export const integer: Type<number, JSONIntegerType> = makeType(() => integer)
6
-
7
- export interface JSONIntegerType extends JSONTypeBase {
8
- type: "integer"
9
- }
@@ -1,11 +0,0 @@
1
- export { _array } from "./array.ts"
2
- export { boolean } from "./boolean.ts"
3
- export { const } from "./const.ts"
4
- export { enum } from "./enum.ts"
5
- export { integer } from "./integer.ts"
6
- export { null } from "./null.ts"
7
- export { number } from "./number.ts"
8
- export { _object } from "./object.ts"
9
- export { ref } from "./ref.ts"
10
- export { string } from "./string.ts"
11
- export { _union } from "./union.ts"