liminal 0.17.0 → 0.17.2

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 (288) hide show
  1. package/Accumulator.ts +103 -0
  2. package/Actor.ts +124 -0
  3. package/Audition.ts +110 -0
  4. package/CHANGELOG.md +4 -208
  5. package/Client.ts +525 -0
  6. package/ClientHandle.ts +50 -0
  7. package/F.ts +12 -0
  8. package/LICENSE +202 -0
  9. package/Method.ts +37 -0
  10. package/Protocol.ts +120 -0
  11. package/Send.ts +12 -0
  12. package/_constants.ts +1 -0
  13. package/_util/Diagnostic.ts +16 -0
  14. package/_util/Mutex.ts +13 -0
  15. package/_util/phantom.ts +1 -0
  16. package/dist/Accumulator.d.ts +22 -0
  17. package/dist/Accumulator.js +37 -0
  18. package/dist/Accumulator.js.map +1 -0
  19. package/dist/Actor.d.ts +29 -0
  20. package/dist/Actor.js +22 -0
  21. package/dist/Actor.js.map +1 -0
  22. package/dist/Audition.d.ts +17 -0
  23. package/dist/Audition.js +29 -0
  24. package/dist/Audition.js.map +1 -0
  25. package/dist/Client.d.ts +46 -0
  26. package/dist/Client.js +228 -0
  27. package/dist/Client.js.map +1 -0
  28. package/dist/ClientHandle.d.ts +17 -0
  29. package/dist/ClientHandle.js +10 -0
  30. package/dist/ClientHandle.js.map +1 -0
  31. package/dist/F.d.ts +4 -0
  32. package/dist/F.js +2 -0
  33. package/dist/F.js.map +1 -0
  34. package/dist/Method.d.ts +22 -0
  35. package/dist/Method.js +4 -0
  36. package/dist/Method.js.map +1 -0
  37. package/dist/Protocol.d.ts +53 -0
  38. package/dist/Protocol.js +37 -0
  39. package/dist/Protocol.js.map +1 -0
  40. package/dist/Send.d.ts +2 -0
  41. package/dist/Send.js +2 -0
  42. package/dist/Send.js.map +1 -0
  43. package/dist/_constants.d.ts +1 -0
  44. package/dist/_constants.js +2 -0
  45. package/dist/_constants.js.map +1 -0
  46. package/dist/_util/Diagnostic.d.ts +5 -0
  47. package/dist/_util/Diagnostic.js +10 -0
  48. package/dist/_util/Diagnostic.js.map +1 -0
  49. package/dist/_util/Mutex.d.ts +7 -0
  50. package/dist/_util/Mutex.js +9 -0
  51. package/dist/_util/Mutex.js.map +1 -0
  52. package/dist/_util/phantom.d.ts +3 -0
  53. package/dist/_util/phantom.js +2 -0
  54. package/dist/_util/phantom.js.map +1 -0
  55. package/dist/errors.d.ts +23 -0
  56. package/dist/errors.js +15 -0
  57. package/dist/errors.js.map +1 -0
  58. package/dist/experimental/BranchLive.d.ts +3 -0
  59. package/dist/experimental/BranchLive.js +5 -0
  60. package/dist/experimental/BranchLive.js.map +1 -0
  61. package/dist/experimental/L/L.d.ts +11 -0
  62. package/dist/experimental/L/L.js +12 -0
  63. package/dist/experimental/L/L.js.map +1 -0
  64. package/dist/experimental/L/append.d.ts +3 -0
  65. package/dist/experimental/L/append.js +4 -0
  66. package/dist/experimental/L/append.js.map +1 -0
  67. package/dist/experimental/L/assistant.d.ts +3 -0
  68. package/dist/experimental/L/assistant.js +13 -0
  69. package/dist/experimental/L/assistant.js.map +1 -0
  70. package/dist/experimental/L/assistantSchema.d.ts +3 -0
  71. package/dist/experimental/L/assistantSchema.js +13 -0
  72. package/dist/experimental/L/assistantSchema.js.map +1 -0
  73. package/dist/experimental/L/assistantStream.d.ts +3 -0
  74. package/dist/experimental/L/assistantStream.js +5 -0
  75. package/dist/experimental/L/assistantStream.js.map +1 -0
  76. package/dist/experimental/L/branch.d.ts +2 -0
  77. package/dist/experimental/L/branch.js +4 -0
  78. package/dist/experimental/L/branch.js.map +1 -0
  79. package/dist/experimental/L/clear.d.ts +3 -0
  80. package/dist/experimental/L/clear.js +7 -0
  81. package/dist/experimental/L/clear.js.map +1 -0
  82. package/dist/experimental/L/history.d.ts +3 -0
  83. package/dist/experimental/L/history.js +4 -0
  84. package/dist/experimental/L/history.js.map +1 -0
  85. package/dist/experimental/L/init.d.ts +3 -0
  86. package/dist/experimental/L/init.js +4 -0
  87. package/dist/experimental/L/init.js.map +1 -0
  88. package/dist/experimental/L/matrix.d.ts +10 -0
  89. package/dist/experimental/L/matrix.js +6 -0
  90. package/dist/experimental/L/matrix.js.map +1 -0
  91. package/dist/experimental/L/system.d.ts +1 -0
  92. package/dist/experimental/L/system.js +4 -0
  93. package/dist/experimental/L/system.js.map +1 -0
  94. package/dist/experimental/L/user.d.ts +1 -0
  95. package/dist/experimental/L/user.js +6 -0
  96. package/dist/experimental/L/user.js.map +1 -0
  97. package/dist/experimental/Loader.d.ts +16 -0
  98. package/dist/experimental/Loader.js +20 -0
  99. package/dist/experimental/Loader.js.map +1 -0
  100. package/dist/experimental/TaggedTemplateFunction.d.ts +11 -0
  101. package/dist/experimental/TaggedTemplateFunction.js +14 -0
  102. package/dist/experimental/TaggedTemplateFunction.js.map +1 -0
  103. package/dist/experimental/Template.d.ts +28 -0
  104. package/dist/experimental/Template.js +60 -0
  105. package/dist/experimental/Template.js.map +1 -0
  106. package/dist/experimental/index.d.ts +4 -0
  107. package/dist/experimental/index.js +5 -0
  108. package/dist/experimental/index.js.map +1 -0
  109. package/dist/index.d.ts +9 -7
  110. package/dist/index.js +9 -7
  111. package/dist/index.js.map +1 -1
  112. package/dist/tsconfig.tsbuildinfo +1 -1
  113. package/errors.ts +22 -0
  114. package/experimental/BranchLive.ts +6 -0
  115. package/experimental/L/L.ts +11 -0
  116. package/experimental/L/append.ts +12 -0
  117. package/experimental/L/assistant.ts +16 -0
  118. package/experimental/L/assistantSchema.ts +18 -0
  119. package/experimental/L/assistantStream.ts +9 -0
  120. package/experimental/L/branch.ts +5 -0
  121. package/experimental/L/clear.ts +7 -0
  122. package/experimental/L/history.ts +4 -0
  123. package/experimental/L/init.ts +4 -0
  124. package/experimental/L/matrix.ts +26 -0
  125. package/experimental/L/system.ts +5 -0
  126. package/experimental/L/user.ts +10 -0
  127. package/experimental/Loader.ts +35 -0
  128. package/experimental/TaggedTemplateFunction.ts +44 -0
  129. package/experimental/Template.ts +85 -0
  130. package/experimental/index.ts +4 -0
  131. package/index.ts +9 -7
  132. package/package.json +17 -30
  133. package/tsconfig.json +9 -0
  134. package/Digest.ts +0 -30
  135. package/Envelope.ts +0 -16
  136. package/F/F.ts +0 -1
  137. package/L/L.ts +0 -20
  138. package/L/append.ts +0 -14
  139. package/L/assistant.ts +0 -30
  140. package/L/assistantSchema.ts +0 -61
  141. package/L/assistantStream.ts +0 -22
  142. package/L/branch.ts +0 -20
  143. package/L/clear.ts +0 -14
  144. package/L/disable.ts +0 -13
  145. package/L/enable.ts +0 -24
  146. package/L/events.ts +0 -11
  147. package/L/json.ts +0 -12
  148. package/L/line.ts +0 -22
  149. package/L/listen.ts +0 -26
  150. package/L/messages.ts +0 -10
  151. package/L/prev.ts +0 -4
  152. package/L/provide.ts +0 -10
  153. package/L/self.ts +0 -5
  154. package/L/send.ts +0 -56
  155. package/L/system.ts +0 -25
  156. package/L/thread.ts +0 -16
  157. package/L/toolkit.ts +0 -14
  158. package/L/user.test.ts +0 -33
  159. package/L/user.ts +0 -32
  160. package/LEvent.ts +0 -33
  161. package/Thread.ts +0 -67
  162. package/dist/Digest.d.ts +0 -17
  163. package/dist/Digest.js +0 -7
  164. package/dist/Digest.js.map +0 -1
  165. package/dist/Envelope.d.ts +0 -13
  166. package/dist/Envelope.js +0 -2
  167. package/dist/Envelope.js.map +0 -1
  168. package/dist/F/F.d.ts +0 -1
  169. package/dist/F/F.js +0 -2
  170. package/dist/F/F.js.map +0 -1
  171. package/dist/L/L.d.ts +0 -20
  172. package/dist/L/L.js +0 -21
  173. package/dist/L/L.js.map +0 -1
  174. package/dist/L/append.d.ts +0 -5
  175. package/dist/L/append.js +0 -10
  176. package/dist/L/append.js.map +0 -1
  177. package/dist/L/assistant.d.ts +0 -6
  178. package/dist/L/assistant.js +0 -26
  179. package/dist/L/assistant.js.map +0 -1
  180. package/dist/L/assistantSchema.d.ts +0 -13
  181. package/dist/L/assistantSchema.js +0 -44
  182. package/dist/L/assistantSchema.js.map +0 -1
  183. package/dist/L/assistantStream.d.ts +0 -7
  184. package/dist/L/assistantStream.js +0 -17
  185. package/dist/L/assistantStream.js.map +0 -1
  186. package/dist/L/branch.d.ts +0 -3
  187. package/dist/L/branch.js +0 -19
  188. package/dist/L/branch.js.map +0 -1
  189. package/dist/L/clear.d.ts +0 -5
  190. package/dist/L/clear.js +0 -12
  191. package/dist/L/clear.js.map +0 -1
  192. package/dist/L/disable.d.ts +0 -4
  193. package/dist/L/disable.js +0 -10
  194. package/dist/L/disable.js.map +0 -1
  195. package/dist/L/enable.d.ts +0 -5
  196. package/dist/L/enable.js +0 -13
  197. package/dist/L/enable.js.map +0 -1
  198. package/dist/L/events.d.ts +0 -5
  199. package/dist/L/events.js +0 -6
  200. package/dist/L/events.js.map +0 -1
  201. package/dist/L/json.d.ts +0 -5
  202. package/dist/L/json.js +0 -8
  203. package/dist/L/json.js.map +0 -1
  204. package/dist/L/line.d.ts +0 -5
  205. package/dist/L/line.js +0 -11
  206. package/dist/L/line.js.map +0 -1
  207. package/dist/L/listen.d.ts +0 -7
  208. package/dist/L/listen.js +0 -14
  209. package/dist/L/listen.js.map +0 -1
  210. package/dist/L/messages.d.ts +0 -5
  211. package/dist/L/messages.js +0 -5
  212. package/dist/L/messages.js.map +0 -1
  213. package/dist/L/prev.d.ts +0 -5
  214. package/dist/L/prev.js +0 -5
  215. package/dist/L/prev.js.map +0 -1
  216. package/dist/L/provide.d.ts +0 -3
  217. package/dist/L/provide.js +0 -4
  218. package/dist/L/provide.js.map +0 -1
  219. package/dist/L/self.d.ts +0 -3
  220. package/dist/L/self.js +0 -4
  221. package/dist/L/self.js.map +0 -1
  222. package/dist/L/send.d.ts +0 -6
  223. package/dist/L/send.js +0 -34
  224. package/dist/L/send.js.map +0 -1
  225. package/dist/L/system.d.ts +0 -5
  226. package/dist/L/system.js +0 -14
  227. package/dist/L/system.js.map +0 -1
  228. package/dist/L/thread.d.ts +0 -3
  229. package/dist/L/thread.js +0 -15
  230. package/dist/L/thread.js.map +0 -1
  231. package/dist/L/toolkit.d.ts +0 -4
  232. package/dist/L/toolkit.js +0 -9
  233. package/dist/L/toolkit.js.map +0 -1
  234. package/dist/L/user.d.ts +0 -6
  235. package/dist/L/user.js +0 -13
  236. package/dist/L/user.js.map +0 -1
  237. package/dist/L/user.test.d.ts +0 -1
  238. package/dist/L/user.test.js.map +0 -1
  239. package/dist/LEvent.d.ts +0 -154
  240. package/dist/LEvent.js +0 -19
  241. package/dist/LEvent.js.map +0 -1
  242. package/dist/Thread.d.ts +0 -52
  243. package/dist/Thread.js +0 -32
  244. package/dist/Thread.js.map +0 -1
  245. package/dist/patterns/Debate.d.ts +0 -1
  246. package/dist/patterns/Debate.js +0 -3
  247. package/dist/patterns/Debate.js.map +0 -1
  248. package/dist/patterns/Model.d.ts +0 -6
  249. package/dist/patterns/Model.js +0 -14
  250. package/dist/patterns/Model.js.map +0 -1
  251. package/dist/patterns/Route.d.ts +0 -3
  252. package/dist/patterns/Route.js +0 -14
  253. package/dist/patterns/Route.js.map +0 -1
  254. package/dist/util/JsonValue.d.ts +0 -8
  255. package/dist/util/JsonValue.js +0 -109
  256. package/dist/util/JsonValue.js.map +0 -1
  257. package/dist/util/NeverTool.d.ts +0 -3
  258. package/dist/util/NeverTool.js +0 -3
  259. package/dist/util/NeverTool.js.map +0 -1
  260. package/dist/util/Taggable.d.ts +0 -6
  261. package/dist/util/Taggable.js +0 -13
  262. package/dist/util/Taggable.js.map +0 -1
  263. package/dist/util/extract.d.ts +0 -3
  264. package/dist/util/extract.js +0 -2
  265. package/dist/util/extract.js.map +0 -1
  266. package/dist/util/messageCodec.d.ts +0 -98
  267. package/dist/util/messageCodec.js +0 -5
  268. package/dist/util/messageCodec.js.map +0 -1
  269. package/dist/util/normalizeRaw.d.ts +0 -4
  270. package/dist/util/normalizeRaw.js +0 -75
  271. package/dist/util/normalizeRaw.js.map +0 -1
  272. package/dist/util/prefix.d.ts +0 -1
  273. package/dist/util/prefix.js +0 -2
  274. package/dist/util/prefix.js.map +0 -1
  275. package/dist/util/raw.d.ts +0 -6
  276. package/dist/util/raw.js +0 -5
  277. package/dist/util/raw.js.map +0 -1
  278. package/patterns/Debate.ts +0 -2
  279. package/patterns/Model.ts +0 -29
  280. package/patterns/Route.ts +0 -25
  281. package/util/JsonValue.ts +0 -144
  282. package/util/NeverTool.ts +0 -10
  283. package/util/Taggable.ts +0 -33
  284. package/util/extract.ts +0 -7
  285. package/util/messageCodec.ts +0 -5
  286. package/util/normalizeRaw.ts +0 -93
  287. package/util/prefix.ts +0 -1
  288. package/util/raw.ts +0 -27
@@ -1,75 +0,0 @@
1
- const LEADING_SPACE_RE = /^([ \t]*)/;
2
- const INDENTATION_RE = /^\n([ \t]+)/;
3
- const ESCAPE_SEQ_RE = /\\([`${\\]|\n)/g;
4
- const LAST_INDENTATION_RE = /\n[ \t]+$/;
5
- export const normalizeRaw = (strings, values) => {
6
- const fixedStrings = normalizeTemplateStrings(strings);
7
- const rawArr = fixedStrings.raw;
8
- const valuesLength = values.length;
9
- const resultParts = new Array(Math.max(1, rawArr.length * 2 - 1));
10
- let resultIndex = 0;
11
- for (let i = 0; i < rawArr.length; i++) {
12
- const str = rawArr[i] || "";
13
- resultParts[resultIndex++] = str;
14
- // Only process values for non-final segments.
15
- if (i < valuesLength) {
16
- const value = String(values[i]);
17
- // If value has line breaks, we should indent it.
18
- if (value.includes("\n")) {
19
- const lastNewlineIndex = str.lastIndexOf("\n");
20
- if (lastNewlineIndex !== -1) {
21
- // Extract the indentation after the last newline.
22
- const textAfterLastNewline = str.substring(lastNewlineIndex + 1);
23
- const leadingSpaceMatch = LEADING_SPACE_RE.exec(textAfterLastNewline);
24
- const indentationToApply = leadingSpaceMatch && leadingSpaceMatch[1] ? leadingSpaceMatch[1] : "";
25
- if (indentationToApply) {
26
- // Split the value into lines once.
27
- const lines = value.split("\n");
28
- const linesLength = lines.length;
29
- // First line doesn't need indentation.
30
- resultParts[resultIndex++] = lines[0];
31
- // Apply indentation to subsequent lines.
32
- for (let j = 1; j < linesLength; j++) {
33
- resultParts[resultIndex++] = "\n" + indentationToApply + lines[j];
34
- }
35
- continue;
36
- }
37
- }
38
- }
39
- // For simple values or when no indentation is needed.
40
- resultParts[resultIndex++] = value;
41
- }
42
- }
43
- // Combine all parts at once
44
- return resultParts.slice(0, resultIndex).join("");
45
- };
46
- export const normalizeTemplateStrings = (template) => {
47
- const leadingIndentMatch = INDENTATION_RE.exec(template.raw[0]);
48
- const indentation = leadingIndentMatch?.[1];
49
- const rawLength = template.raw.length;
50
- const raw = new Array(rawLength);
51
- for (let i = 0; i < rawLength; i++) {
52
- let str = template.raw[i];
53
- // Only perform common indentation replacements if needed.
54
- if (indentation) {
55
- // Remove leading newline and indentation in the first segment.
56
- if (i === 0) {
57
- str = str.slice(indentation.length + 1);
58
- }
59
- // Use a simple string replacement with a regular expression for better performance.
60
- str = str.replaceAll(`\n${indentation}`, "\n");
61
- }
62
- // Replace common escape sequences in a single pass.
63
- str = str.replace(ESCAPE_SEQ_RE, (_match, char) => {
64
- // Keep the escaped newline replacement separate for clarity.
65
- return char === "\n" ? "" : char;
66
- });
67
- // Handle trailing spaces only for the last segment.
68
- if (indentation && i === rawLength - 1) {
69
- str = str.replace(LAST_INDENTATION_RE, "");
70
- }
71
- raw[i] = str;
72
- }
73
- return { raw };
74
- };
75
- //# sourceMappingURL=normalizeRaw.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizeRaw.js","sourceRoot":"","sources":["../../util/normalizeRaw.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,WAAW,CAAA;AACpC,MAAM,cAAc,GAAG,aAAa,CAAA;AACpC,MAAM,aAAa,GAAG,iBAAiB,CAAA;AACvC,MAAM,mBAAmB,GAAG,WAAW,CAAA;AAEvC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAA6B,EAAE,MAAsB,EAAU,EAAE;IAC5F,MAAM,YAAY,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAA;IACtD,MAAM,MA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KAAK,CAAC,EAAE,CAAC;gBACZ,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;YACzC,CAAC;YACD,oFAAoF;YACpF,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,KAAK,WAAW,EAAE,EAAE,IAAI,CAAC,CAAA;QAChD,CAAC;QAED,oDAAoD;QACpD,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;YAChD,6DAA6D;YAC7D,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;QAClC,CAAC,CAAC,CAAA;QAEF,oDAAoD;QACpD,IAAI,WAAW,IAAI,CAAC,KAAK,SAAS,GAAG,CAAC,EAAE,CAAC;YACvC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAA;QAC5C,CAAC;QAED,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;IACd,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,CAAA;AAChB,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- export declare const prefix: <K extends string>(key: K) => `liminal/${K}`;
@@ -1,2 +0,0 @@
1
- export const prefix = (key) => `liminal/${key}`;
2
- //# sourceMappingURL=prefix.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prefix.js","sourceRoot":"","sources":["../../util/prefix.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,CAAmB,GAAM,EAAE,EAAE,CAAC,WAAW,GAAG,EAAW,CAAA"}
@@ -1,6 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import type { ExtractE, ExtractR } from "./extract.ts";
3
- export type TemplateStringsArrayLike = {
4
- raw: readonly string[] | ArrayLike<string>;
5
- };
6
- export declare const raw: <Substitutions extends Array<unknown>>(template: TemplateStringsArrayLike, ...substitutions: Substitutions) => Effect.Effect<string, ExtractE<Substitutions[number]>, ExtractR<Substitutions[number]>>;
package/dist/util/raw.js DELETED
@@ -1,5 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- export const raw = Effect.fnUntraced(function* (template, ...substitutions) {
3
- return String.raw(template, ...yield* Effect.all(substitutions.map((v) => Effect.isEffect(v) ? v : Effect.succeed(v))));
4
- });
5
- //# sourceMappingURL=raw.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"raw.js","sourceRoot":"","sources":["../../util/raw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAQvC,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAC5C,QAAkC,EAClC,GAAG,aAA4B;IAQ/B,OAAO,MAAM,CAAC,GAAG,CACf,QAAQ,EACR,GAAG,KAAK,CAAC,CAAE,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAIxF,CACH,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- // TODO: utilize `Entity` and `Relation`
2
- export {}
package/patterns/Model.ts DELETED
@@ -1,29 +0,0 @@
1
- import type { AiError } from "@effect/ai/AiError"
2
- import type { AiLanguageModel } from "@effect/ai/AiLanguageModel"
3
- import type { AiModel } from "@effect/ai/AiModel"
4
- import * as Effect from "effect/Effect"
5
- import * as L from "../L/L.ts"
6
- import type { Thread } from "../Thread.ts"
7
-
8
- export const coalesce: <E, R, M extends Array<AiModel<any, any>>>(
9
- effect: Effect.Effect<any, E, R>,
10
- models: M,
11
- ) => Effect.Effect<
12
- string,
13
- AiError | E,
14
- Thread | AiLanguageModel | ([M[number]] extends [AiModel<any, infer R>] ? R : never)
15
- > = Effect.fn(
16
- function*(effect, models) {
17
- const all = yield* Effect.all(models.map((model) => effect.pipe(Effect.provide(model)))) as Effect.Effect<
18
- Array<unknown>
19
- >
20
- yield* L.user`
21
- Coalesce the following items into a single item:
22
-
23
- ---
24
-
25
- ${all.map((item) => JSON.stringify(item, null, 2)).join("\n\n---")}
26
- `
27
- return yield* L.assistant
28
- },
29
- )
package/patterns/Route.ts DELETED
@@ -1,25 +0,0 @@
1
- import * as Effect from "effect/Effect"
2
- import * as Schema from "effect/Schema"
3
- import * as L from "../L/L.ts"
4
- import { Thread } from "../Thread.ts"
5
-
6
- export const byDescription: <R extends Record<string, Effect.All.EffectAny>>(routes: R) => Effect.Effect<
7
- Effect.Effect.Success<R[keyof R]>,
8
- ([R[keyof R]] extends [never] ? never : Effect.Effect.Error<R[keyof R]>),
9
- ([R[keyof R]] extends [never] ? never : Effect.Effect.Context<R[keyof R]>) | Thread
10
- > = Effect.fnUntraced(function*(routes) {
11
- const descriptions = Object.keys(routes)
12
- const description = yield* L.line(
13
- L.user`
14
- Which of the following descriptions best matches the current conversation?
15
-
16
- - ${descriptions.join("\n -")}
17
- `,
18
- L.assistantSchema(Schema.Literal(...descriptions)),
19
- ).pipe(
20
- L.provide(
21
- L.branch,
22
- ),
23
- )
24
- return yield* routes[description]!
25
- })
package/util/JsonValue.ts DELETED
@@ -1,144 +0,0 @@
1
- import * as Effect from "effect/Effect"
2
- import { pipe } from "effect/Function"
3
- import * as Option from "effect/Option"
4
- import * as Schema from "effect/Schema"
5
- import * as SchemaAST from "effect/SchemaAST"
6
-
7
- export type JsonValue = null | boolean | number | string | JsonValueArray | JsonValueObject
8
-
9
- export type JsonValueArray = Array<JsonValue> | ReadonlyArray<JsonValue>
10
-
11
- export type JsonValueObject = { [key: string]: JsonValue }
12
-
13
- export const encodeJsonc: <A, I extends JsonValue>(
14
- schema: Schema.Schema<A, I>,
15
- ) => (value: A) => Effect.Effect<string> = (schema) => {
16
- const encoder = encodeAst(SchemaAST.encodedBoundAST(schema.ast))
17
- return (value) => encoder(value, new EncodeJsoncContext(0))
18
- }
19
-
20
- class EncodeJsoncContext {
21
- readonly depth: number
22
- readonly indentation: string
23
- readonly childIndentation: string
24
- constructor(depth: number) {
25
- this.depth = depth
26
- this.indentation = " ".repeat(depth * 2)
27
- this.childIndentation = " ".repeat((depth + 1) * 2)
28
- }
29
-
30
- next = () => new EncodeJsoncContext(this.depth + 1)
31
-
32
- comment = (type: SchemaAST.AST): string =>
33
- Option.match(SchemaAST.getDescriptionAnnotation(type), {
34
- onSome: (v) => {
35
- v = v.trim()
36
- if (v) {
37
- return `// ${v}\n${this.childIndentation}`
38
- }
39
- return ""
40
- },
41
- onNone: () => "",
42
- })
43
- }
44
-
45
- const encodeAst = (
46
- ast: SchemaAST.AST,
47
- refinement?: SchemaAST.Refinement,
48
- ): (value: unknown, ctx: EncodeJsoncContext) => Effect.Effect<string> => {
49
- switch (ast._tag) {
50
- case "TypeLiteral": {
51
- return Effect.fnUntraced(function*(value, ctx) {
52
- const props = yield* Effect.all(
53
- ast.propertySignatures.map(
54
- Effect.fnUntraced(function*({ name, type }) {
55
- if (typeof name === "symbol") throw 0
56
- const child = yield* encodeAst(type)((value as never)[name], ctx.next())
57
- return `${ctx.comment(refinement ?? type)}${name}: ${child}`
58
- }),
59
- ),
60
- ).pipe(
61
- Effect.map((v) => v.join(`,\n${ctx.childIndentation}`)),
62
- )
63
- return `{\n${ctx.childIndentation}${props}\n${ctx.indentation}}`
64
- })
65
- }
66
- case "StringKeyword": {
67
- return (value) => Effect.succeed(`"${value}"`)
68
- }
69
- case "BooleanKeyword":
70
- case "NumberKeyword": {
71
- return (value) => Effect.succeed(String(value))
72
- }
73
- case "Refinement": {
74
- return encodeAst(ast.from, refinement ?? ast)
75
- }
76
- case "UnknownKeyword":
77
- case "AnyKeyword": {
78
- return (value, ctx) =>
79
- Effect.succeed(
80
- JSON
81
- .stringify(value, null, 2)
82
- .split("\n")
83
- .map((line, i) => i ? ctx.indentation.concat(line) : line)
84
- .join("\n"),
85
- )
86
- }
87
- case "Union": {
88
- const { types } = ast
89
- const guards = types.map((ast) =>
90
- pipe(
91
- ast,
92
- Schema.make,
93
- Schema.is,
94
- )
95
- )
96
- return (value, ctx) => {
97
- for (let i = 0; i < types.length; i++) {
98
- const guard = guards[i]!
99
- if (guard(value)) {
100
- return encodeAst(types[i]!)(value, ctx)
101
- }
102
- }
103
- throw 0
104
- }
105
- }
106
- case "Literal": {
107
- const { literal } = ast
108
- const v = (() => {
109
- switch (typeof literal) {
110
- case "boolean":
111
- case "number": {
112
- return String(literal)
113
- }
114
- case "string": {
115
- return `"${literal}"`
116
- }
117
- }
118
- if (literal === null) {
119
- return "null"
120
- }
121
- console.log({ literal })
122
- throw 0
123
- })()
124
- return () => Effect.succeed(v)
125
- }
126
- case "TupleType": {
127
- const { elements, rest } = ast
128
- return (value, ctx) =>
129
- Effect.all((elements.length ? elements : rest).map(
130
- Effect.fnUntraced(function*(element, i) {
131
- const child = yield* encodeAst(element.type)((value as never)[i]!, ctx.next())
132
- return `${ctx.comment(refinement ?? element.type)}${child}`
133
- }),
134
- )).pipe(
135
- Effect.map((v) => `[\n${ctx.childIndentation}${v.join(`,\n${ctx.childIndentation}`)}\n${ctx.indentation}]`),
136
- )
137
- }
138
- case "Suspend": {
139
- return encodeAst(ast.f())
140
- }
141
- }
142
- console.log({ ast })
143
- throw 0
144
- }
package/util/NeverTool.ts DELETED
@@ -1,10 +0,0 @@
1
- import * as AiTool from "@effect/ai/AiTool"
2
- import * as Schema from "effect/Schema"
3
-
4
- export type NeverTool = AiTool.AiTool<
5
- string,
6
- AiTool.AnyStructSchema,
7
- Schema.Schema.Any,
8
- Schema.Schema.Any,
9
- never
10
- >
package/util/Taggable.ts DELETED
@@ -1,33 +0,0 @@
1
- import * as Effect from "effect/Effect"
2
- import { YieldWrap } from "effect/Utils"
3
- import type { ExtractE, ExtractR } from "./extract.ts"
4
- import { raw, type TemplateStringsArrayLike } from "./raw.ts"
5
-
6
- export type TaggableArg0 = TemplateStringsArrayLike | string | Effect.Effect<string, any, any>
7
- export type TaggableArgRest<E0 extends TaggableArg0> = E0 extends TemplateStringsArrayLike ? Array<unknown> : []
8
-
9
- export const normalize = Effect.fnUntraced(function*<
10
- A0 extends TaggableArg0,
11
- ARest extends TaggableArgRest<A0>,
12
- >(
13
- a0: A0,
14
- ...aRest: ARest
15
- ): Generator<
16
- YieldWrap<
17
- Effect.Effect<
18
- string,
19
- ExtractE<A0 | ARest[number]>,
20
- ExtractR<A0 | ARest[number]>
21
- >
22
- >,
23
- string,
24
- never
25
- > {
26
- if (Effect.isEffect(a0)) {
27
- return yield* a0
28
- }
29
- if (typeof a0 === "string") {
30
- return a0
31
- }
32
- return yield* raw(a0, ...aRest)
33
- })
package/util/extract.ts DELETED
@@ -1,7 +0,0 @@
1
- import * as Effect from "effect/Effect"
2
-
3
- export type ExtractE<T> = [Extract<T, Effect.Effect<any, any, any>>] extends [never] ? never
4
- : Effect.Effect.Error<Extract<T, Effect.Effect<any, any, any>>>
5
-
6
- export type ExtractR<T> = [Extract<T, Effect.Effect<any, any, any>>] extends [never] ? never
7
- : Effect.Effect.Context<Extract<T, Effect.Effect<any, any, any>>>
@@ -1,5 +0,0 @@
1
- import { Message } from "@effect/ai/AiInput"
2
- import * as Schema from "effect/Schema"
3
-
4
- export const decode = Schema.decode(Message)
5
- export const encode = Schema.encode(Message)
@@ -1,93 +0,0 @@
1
- const LEADING_SPACE_RE = /^([ \t]*)/
2
- const INDENTATION_RE = /^\n([ \t]+)/
3
- const ESCAPE_SEQ_RE = /\\([`${\\]|\n)/g
4
- const LAST_INDENTATION_RE = /\n[ \t]+$/
5
-
6
- export const normalizeRaw = (strings: TemplateStringsArray, values: Array<unknown>): string => {
7
- const fixedStrings = normalizeTemplateStrings(strings)
8
- const rawArr = fixedStrings.raw
9
- const valuesLength = values.length
10
-
11
- const resultParts = new Array(Math.max(1, rawArr.length * 2 - 1))
12
- let resultIndex = 0
13
-
14
- for (let i = 0; i < rawArr.length; i++) {
15
- const str = rawArr[i] || ""
16
- resultParts[resultIndex++] = str
17
-
18
- // Only process values for non-final segments.
19
- if (i < valuesLength) {
20
- const value = String(values[i])
21
-
22
- // If value has line breaks, we should indent it.
23
- if (value.includes("\n")) {
24
- const lastNewlineIndex = str.lastIndexOf("\n")
25
-
26
- if (lastNewlineIndex !== -1) {
27
- // Extract the indentation after the last newline.
28
- const textAfterLastNewline = str.substring(lastNewlineIndex + 1)
29
- const leadingSpaceMatch = LEADING_SPACE_RE.exec(textAfterLastNewline)
30
- const indentationToApply = leadingSpaceMatch && leadingSpaceMatch[1] ? leadingSpaceMatch[1] : ""
31
-
32
- if (indentationToApply) {
33
- // Split the value into lines once.
34
- const lines = value.split("\n")
35
- const linesLength = lines.length
36
-
37
- // First line doesn't need indentation.
38
- resultParts[resultIndex++] = lines[0]
39
-
40
- // Apply indentation to subsequent lines.
41
- for (let j = 1; j < linesLength; j++) {
42
- resultParts[resultIndex++] = "\n" + indentationToApply + lines[j]
43
- }
44
- continue
45
- }
46
- }
47
- }
48
- // For simple values or when no indentation is needed.
49
- resultParts[resultIndex++] = value
50
- }
51
- }
52
-
53
- // Combine all parts at once
54
- return resultParts.slice(0, resultIndex).join("")
55
- }
56
-
57
- export const normalizeTemplateStrings = (template: TemplateStringsArray): {
58
- readonly raw: ReadonlyArray<string>
59
- } => {
60
- const leadingIndentMatch = INDENTATION_RE.exec(template.raw[0]!)
61
- const indentation = leadingIndentMatch?.[1]
62
-
63
- const rawLength = template.raw.length
64
- const raw = new Array(rawLength)
65
-
66
- for (let i = 0; i < rawLength; i++) {
67
- let str = template.raw[i]!
68
- // Only perform common indentation replacements if needed.
69
- if (indentation) {
70
- // Remove leading newline and indentation in the first segment.
71
- if (i === 0) {
72
- str = str.slice(indentation.length + 1)
73
- }
74
- // Use a simple string replacement with a regular expression for better performance.
75
- str = str.replaceAll(`\n${indentation}`, "\n")
76
- }
77
-
78
- // Replace common escape sequences in a single pass.
79
- str = str.replace(ESCAPE_SEQ_RE, (_match, char) => {
80
- // Keep the escaped newline replacement separate for clarity.
81
- return char === "\n" ? "" : char
82
- })
83
-
84
- // Handle trailing spaces only for the last segment.
85
- if (indentation && i === rawLength - 1) {
86
- str = str.replace(LAST_INDENTATION_RE, "")
87
- }
88
-
89
- raw[i] = str
90
- }
91
-
92
- return { raw }
93
- }
package/util/prefix.ts DELETED
@@ -1 +0,0 @@
1
- export const prefix = <K extends string>(key: K) => `liminal/${key}` as const
package/util/raw.ts DELETED
@@ -1,27 +0,0 @@
1
- import * as Effect from "effect/Effect"
2
- import type { YieldWrap } from "effect/Utils"
3
- import type { ExtractE, ExtractR } from "./extract.ts"
4
-
5
- export type TemplateStringsArrayLike = {
6
- raw: readonly string[] | ArrayLike<string>
7
- }
8
-
9
- export const raw = Effect.fnUntraced(function*<Substitutions extends Array<unknown>>(
10
- template: TemplateStringsArrayLike,
11
- ...substitutions: Substitutions
12
- ): Generator<
13
- YieldWrap<
14
- Effect.Effect<Array<string>, ExtractE<Substitutions[number]>, ExtractR<Substitutions[number]>>
15
- >,
16
- string,
17
- never
18
- > {
19
- return String.raw(
20
- template,
21
- ...yield* (Effect.all(substitutions.map((v) => Effect.isEffect(v) ? v : Effect.succeed(v))) as Effect.Effect<
22
- Array<string>,
23
- ExtractE<Substitutions[number]>,
24
- ExtractR<Substitutions[number]>
25
- >),
26
- )
27
- })