@dxos/assistant 0.8.2-staging.7ac8446 → 0.8.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 (277) hide show
  1. package/dist/lib/browser/index.mjs +1830 -228
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +1825 -229
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +1831 -228
  8. package/dist/lib/node-esm/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/{src/bin → bin}/chat.d.ts.map +1 -1
  11. package/dist/types/src/blueprint/blueprint.d.ts +79 -0
  12. package/dist/types/src/blueprint/blueprint.d.ts.map +1 -0
  13. package/dist/types/src/blueprint/blueprint.test.d.ts +2 -0
  14. package/dist/types/src/blueprint/blueprint.test.d.ts.map +1 -0
  15. package/dist/types/src/blueprint/index.d.ts +4 -0
  16. package/dist/types/src/blueprint/index.d.ts.map +1 -0
  17. package/dist/types/src/blueprint/logger.d.ts +3 -0
  18. package/dist/types/src/blueprint/logger.d.ts.map +1 -0
  19. package/dist/types/src/blueprint/machine.d.ts +113 -0
  20. package/dist/types/src/blueprint/machine.d.ts.map +1 -0
  21. package/dist/types/src/blueprint/test-data.d.ts +3 -0
  22. package/dist/types/src/blueprint/test-data.d.ts.map +1 -0
  23. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +4 -0
  24. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -0
  25. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts +2 -0
  26. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts.map +1 -0
  27. package/dist/types/src/extraction/extraction-llm-function/index.d.ts +2 -0
  28. package/dist/types/src/extraction/extraction-llm-function/index.d.ts.map +1 -0
  29. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +210 -0
  30. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -0
  31. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts +2 -0
  32. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts.map +1 -0
  33. package/dist/types/src/extraction/extraction-ner-function/index.d.ts +3 -0
  34. package/dist/types/src/extraction/extraction-ner-function/index.d.ts.map +1 -0
  35. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts +14 -0
  36. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -0
  37. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.test.d.ts +2 -0
  38. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.test.d.ts.map +1 -0
  39. package/dist/types/src/extraction/extraction.d.ts +242 -0
  40. package/dist/types/src/extraction/extraction.d.ts.map +1 -0
  41. package/dist/types/src/extraction/index.d.ts +5 -0
  42. package/dist/types/src/extraction/index.d.ts.map +1 -0
  43. package/dist/types/src/extraction/quotes.d.ts +15 -0
  44. package/dist/types/src/extraction/quotes.d.ts.map +1 -0
  45. package/dist/types/src/extraction/quotes.test.d.ts +2 -0
  46. package/dist/types/src/extraction/quotes.test.d.ts.map +1 -0
  47. package/dist/types/src/index.d.ts +4 -3
  48. package/dist/types/src/index.d.ts.map +1 -1
  49. package/dist/types/src/research/exa.d.ts +7 -0
  50. package/dist/types/src/research/exa.d.ts.map +1 -0
  51. package/dist/types/src/research/graph.d.ts +39 -0
  52. package/dist/types/src/research/graph.d.ts.map +1 -0
  53. package/dist/types/src/research/graph.test.d.ts +2 -0
  54. package/dist/types/src/research/graph.test.d.ts.map +1 -0
  55. package/dist/types/src/research/index.d.ts +4 -0
  56. package/dist/types/src/research/index.d.ts.map +1 -0
  57. package/dist/types/src/research/research.d.ts +10 -0
  58. package/dist/types/src/research/research.d.ts.map +1 -0
  59. package/dist/types/src/research/research.test.d.ts +2 -0
  60. package/dist/types/src/research/research.test.d.ts.map +1 -0
  61. package/dist/types/src/session/index.d.ts +1 -0
  62. package/dist/types/src/session/index.d.ts.map +1 -1
  63. package/dist/types/src/session/session.d.ts +80 -35
  64. package/dist/types/src/session/session.d.ts.map +1 -1
  65. package/dist/types/src/session/version-pin.d.ts +21 -0
  66. package/dist/types/src/session/version-pin.d.ts.map +1 -0
  67. package/dist/types/src/session/version-pin.test.d.ts +2 -0
  68. package/dist/types/src/session/version-pin.test.d.ts.map +1 -0
  69. package/dist/types/src/summarization/summarization.test.d.ts +2 -0
  70. package/dist/types/src/summarization/summarization.test.d.ts.map +1 -0
  71. package/dist/types/src/testing/exa-search-1748337321991.d.ts +38 -0
  72. package/dist/types/src/testing/exa-search-1748337321991.d.ts.map +1 -0
  73. package/dist/types/src/testing/exa-search-1748337331526.d.ts +37 -0
  74. package/dist/types/src/testing/exa-search-1748337331526.d.ts.map +1 -0
  75. package/dist/types/src/testing/exa-search-1748337344119.d.ts +58 -0
  76. package/dist/types/src/testing/exa-search-1748337344119.d.ts.map +1 -0
  77. package/dist/types/src/testing/index.d.ts +2 -6
  78. package/dist/types/src/testing/index.d.ts.map +1 -1
  79. package/dist/types/src/types.d.ts +3 -0
  80. package/dist/types/src/types.d.ts.map +1 -0
  81. package/dist/types/tsconfig.tsbuildinfo +1 -1
  82. package/package.json +25 -35
  83. package/src/blueprint/blueprint.test.ts +142 -0
  84. package/src/blueprint/blueprint.ts +95 -0
  85. package/src/blueprint/index.ts +7 -0
  86. package/src/blueprint/logger.ts +66 -0
  87. package/src/blueprint/machine.ts +208 -0
  88. package/src/blueprint/test-data.ts +55 -0
  89. package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +95 -0
  90. package/src/extraction/extraction-llm-function/extraction-llm-function.ts +64 -0
  91. package/src/extraction/extraction-llm-function/index.ts +5 -0
  92. package/src/extraction/extraction-llm-function/instructions.tpl +28 -0
  93. package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +115 -0
  94. package/src/extraction/extraction-ner-function/extraction-ner-function.ts +54 -0
  95. package/src/extraction/extraction-ner-function/index.ts +6 -0
  96. package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +94 -0
  97. package/src/extraction/extraction-ner-function/named-entity-recognition.ts +97 -0
  98. package/src/extraction/extraction.ts +75 -0
  99. package/src/extraction/index.ts +8 -0
  100. package/src/extraction/quotes.test.ts +27 -0
  101. package/src/extraction/quotes.ts +57 -0
  102. package/src/index.ts +4 -3
  103. package/src/research/exa.ts +100 -0
  104. package/src/research/graph.test.ts +15 -0
  105. package/src/research/graph.ts +291 -0
  106. package/src/research/index.ts +7 -0
  107. package/src/research/instructions-research.tpl +97 -0
  108. package/src/research/research.test.ts +189 -0
  109. package/src/research/research.ts +89 -0
  110. package/src/session/index.ts +1 -0
  111. package/src/session/session.test.ts +39 -67
  112. package/src/session/session.ts +328 -155
  113. package/src/session/version-pin.test.ts +26 -0
  114. package/src/session/version-pin.ts +48 -0
  115. package/src/summarization/summarization.test.ts +216 -0
  116. package/src/testing/exa-search-1748337321991.ts +131 -0
  117. package/src/testing/exa-search-1748337331526.ts +144 -0
  118. package/src/testing/exa-search-1748337344119.ts +133 -0
  119. package/src/testing/index.ts +8 -7
  120. package/src/typedefs.d.ts +8 -0
  121. package/src/types.ts +8 -0
  122. package/src/typings.d.ts +8 -0
  123. package/dist/lib/browser/chunk-PND5VR6D.mjs +0 -2315
  124. package/dist/lib/browser/chunk-PND5VR6D.mjs.map +0 -7
  125. package/dist/lib/browser/testing/index.mjs +0 -621
  126. package/dist/lib/browser/testing/index.mjs.map +0 -7
  127. package/dist/lib/node/chunk-IBOBRBDF.cjs +0 -2326
  128. package/dist/lib/node/chunk-IBOBRBDF.cjs.map +0 -7
  129. package/dist/lib/node/testing/index.cjs +0 -637
  130. package/dist/lib/node/testing/index.cjs.map +0 -7
  131. package/dist/lib/node-esm/chunk-DCQJOLSR.mjs +0 -2317
  132. package/dist/lib/node-esm/chunk-DCQJOLSR.mjs.map +0 -7
  133. package/dist/lib/node-esm/testing/index.mjs +0 -622
  134. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  135. package/dist/types/src/ai-service/client.test.d.ts +0 -2
  136. package/dist/types/src/ai-service/client.test.d.ts.map +0 -1
  137. package/dist/types/src/ai-service/defs.d.ts +0 -9
  138. package/dist/types/src/ai-service/defs.d.ts.map +0 -1
  139. package/dist/types/src/ai-service/edge-client.d.ts +0 -19
  140. package/dist/types/src/ai-service/edge-client.d.ts.map +0 -1
  141. package/dist/types/src/ai-service/index.d.ts +0 -10
  142. package/dist/types/src/ai-service/index.d.ts.map +0 -1
  143. package/dist/types/src/ai-service/message-collector.d.ts +0 -88
  144. package/dist/types/src/ai-service/message-collector.d.ts.map +0 -1
  145. package/dist/types/src/ai-service/ollama-client.d.ts +0 -39
  146. package/dist/types/src/ai-service/ollama-client.d.ts.map +0 -1
  147. package/dist/types/src/ai-service/parser.d.ts +0 -138
  148. package/dist/types/src/ai-service/parser.d.ts.map +0 -1
  149. package/dist/types/src/ai-service/service.d.ts +0 -9
  150. package/dist/types/src/ai-service/service.d.ts.map +0 -1
  151. package/dist/types/src/ai-service/stream.d.ts +0 -40
  152. package/dist/types/src/ai-service/stream.d.ts.map +0 -1
  153. package/dist/types/src/ai-service/stream.test.d.ts +0 -2
  154. package/dist/types/src/ai-service/stream.test.d.ts.map +0 -1
  155. package/dist/types/src/ai-service/testing/index.d.ts +0 -3
  156. package/dist/types/src/ai-service/testing/index.d.ts.map +0 -1
  157. package/dist/types/src/ai-service/testing/mock.d.ts +0 -7
  158. package/dist/types/src/ai-service/testing/mock.d.ts.map +0 -1
  159. package/dist/types/src/ai-service/testing/test-stream.d.ts +0 -7
  160. package/dist/types/src/ai-service/testing/test-stream.d.ts.map +0 -1
  161. package/dist/types/src/ai-service/transform.d.ts +0 -27
  162. package/dist/types/src/ai-service/transform.d.ts.map +0 -1
  163. package/dist/types/src/ai-service/types.d.ts +0 -167
  164. package/dist/types/src/ai-service/types.d.ts.map +0 -1
  165. package/dist/types/src/ai-service/util/index.d.ts +0 -2
  166. package/dist/types/src/ai-service/util/index.d.ts.map +0 -1
  167. package/dist/types/src/ai-service/util/sse.d.ts +0 -39
  168. package/dist/types/src/ai-service/util/sse.d.ts.map +0 -1
  169. package/dist/types/src/conversation/conversation.d.ts +0 -80
  170. package/dist/types/src/conversation/conversation.d.ts.map +0 -1
  171. package/dist/types/src/conversation/conversation.test.d.ts +0 -2
  172. package/dist/types/src/conversation/conversation.test.d.ts.map +0 -1
  173. package/dist/types/src/conversation/index.d.ts +0 -2
  174. package/dist/types/src/conversation/index.d.ts.map +0 -1
  175. package/dist/types/src/conversation/types.d.ts +0 -79
  176. package/dist/types/src/conversation/types.d.ts.map +0 -1
  177. package/dist/types/src/cypher/ast.d.ts +0 -56
  178. package/dist/types/src/cypher/ast.d.ts.map +0 -1
  179. package/dist/types/src/cypher/combinators.d.ts +0 -14
  180. package/dist/types/src/cypher/combinators.d.ts.map +0 -1
  181. package/dist/types/src/cypher/combinators.test.d.ts +0 -2
  182. package/dist/types/src/cypher/combinators.test.d.ts.map +0 -1
  183. package/dist/types/src/cypher/echo-data-source.d.ts +0 -16
  184. package/dist/types/src/cypher/echo-data-source.d.ts.map +0 -1
  185. package/dist/types/src/cypher/execution-plan.d.ts +0 -49
  186. package/dist/types/src/cypher/execution-plan.d.ts.map +0 -1
  187. package/dist/types/src/cypher/execution-plan.test.d.ts +0 -2
  188. package/dist/types/src/cypher/execution-plan.test.d.ts.map +0 -1
  189. package/dist/types/src/cypher/index.d.ts +0 -5
  190. package/dist/types/src/cypher/index.d.ts.map +0 -1
  191. package/dist/types/src/cypher/parjs.d.ts +0 -4
  192. package/dist/types/src/cypher/parjs.d.ts.map +0 -1
  193. package/dist/types/src/cypher/parser.d.ts +0 -6
  194. package/dist/types/src/cypher/parser.d.ts.map +0 -1
  195. package/dist/types/src/cypher/query-executor.d.ts +0 -26
  196. package/dist/types/src/cypher/query-executor.d.ts.map +0 -1
  197. package/dist/types/src/cypher/query-executor.test.d.ts +0 -2
  198. package/dist/types/src/cypher/query-executor.test.d.ts.map +0 -1
  199. package/dist/types/src/cypher/schema.d.ts +0 -12
  200. package/dist/types/src/cypher/schema.d.ts.map +0 -1
  201. package/dist/types/src/cypher/schema.test.d.ts +0 -2
  202. package/dist/types/src/cypher/schema.test.d.ts.map +0 -1
  203. package/dist/types/src/testing/artifacts.test.d.ts +0 -1
  204. package/dist/types/src/testing/artifacts.test.d.ts.map +0 -1
  205. package/dist/types/src/testing/data.d.ts +0 -2
  206. package/dist/types/src/testing/data.d.ts.map +0 -1
  207. package/dist/types/src/testing/defs.d.ts +0 -5
  208. package/dist/types/src/testing/defs.d.ts.map +0 -1
  209. package/dist/types/src/testing/logger.d.ts +0 -12
  210. package/dist/types/src/testing/logger.d.ts.map +0 -1
  211. package/dist/types/src/testing/object-extraction.test.d.ts +0 -1
  212. package/dist/types/src/testing/object-extraction.test.d.ts.map +0 -1
  213. package/dist/types/src/testing/ollama.d.ts +0 -6
  214. package/dist/types/src/testing/ollama.d.ts.map +0 -1
  215. package/dist/types/src/testing/query-promts.d.ts +0 -5
  216. package/dist/types/src/testing/query-promts.d.ts.map +0 -1
  217. package/dist/types/src/testing/query.test.d.ts +0 -2
  218. package/dist/types/src/testing/query.test.d.ts.map +0 -1
  219. package/dist/types/src/testing/test-data.d.ts +0 -29
  220. package/dist/types/src/testing/test-data.d.ts.map +0 -1
  221. package/dist/types/src/testing/test-schema.d.ts +0 -50
  222. package/dist/types/src/testing/test-schema.d.ts.map +0 -1
  223. package/dist/types/src/util/index.d.ts +0 -2
  224. package/dist/types/src/util/index.d.ts.map +0 -1
  225. package/dist/types/src/util/trim.d.ts +0 -5
  226. package/dist/types/src/util/trim.d.ts.map +0 -1
  227. package/src/ai-service/client.test.ts +0 -265
  228. package/src/ai-service/defs.ts +0 -39
  229. package/src/ai-service/edge-client.ts +0 -67
  230. package/src/ai-service/index.ts +0 -13
  231. package/src/ai-service/message-collector.ts +0 -84
  232. package/src/ai-service/ollama-client.ts +0 -499
  233. package/src/ai-service/parser.ts +0 -358
  234. package/src/ai-service/service.ts +0 -15
  235. package/src/ai-service/stream.test.ts +0 -125
  236. package/src/ai-service/stream.ts +0 -118
  237. package/src/ai-service/testing/index.ts +0 -6
  238. package/src/ai-service/testing/mock.ts +0 -22
  239. package/src/ai-service/testing/test-stream.ts +0 -93
  240. package/src/ai-service/transform.ts +0 -121
  241. package/src/ai-service/types.ts +0 -103
  242. package/src/ai-service/util/index.ts +0 -5
  243. package/src/ai-service/util/sse.ts +0 -341
  244. package/src/bin/chat.ts +0 -79
  245. package/src/conversation/conversation.test.ts +0 -73
  246. package/src/conversation/conversation.ts +0 -257
  247. package/src/conversation/index.ts +0 -5
  248. package/src/conversation/types.ts +0 -129
  249. package/src/cypher/ast.ts +0 -75
  250. package/src/cypher/combinators.test.ts +0 -137
  251. package/src/cypher/combinators.ts +0 -148
  252. package/src/cypher/echo-data-source.ts +0 -105
  253. package/src/cypher/execution-plan.test.ts +0 -44
  254. package/src/cypher/execution-plan.ts +0 -208
  255. package/src/cypher/index.ts +0 -8
  256. package/src/cypher/parjs-shims.d.ts +0 -10
  257. package/src/cypher/parjs.ts +0 -10
  258. package/src/cypher/parser.ts +0 -19
  259. package/src/cypher/query-executor.test.ts +0 -47
  260. package/src/cypher/query-executor.ts +0 -145
  261. package/src/cypher/schema.test.ts +0 -17
  262. package/src/cypher/schema.ts +0 -86
  263. package/src/testing/artifacts.test.ts +0 -182
  264. package/src/testing/data.ts +0 -13
  265. package/src/testing/defs.ts +0 -9
  266. package/src/testing/logger.ts +0 -129
  267. package/src/testing/object-extraction.test.ts +0 -71
  268. package/src/testing/ollama.ts +0 -15
  269. package/src/testing/query-promts.ts +0 -75
  270. package/src/testing/query.test.ts +0 -91
  271. package/src/testing/test-data.ts +0 -372
  272. package/src/testing/test-schema.ts +0 -80
  273. package/src/util/index.ts +0 -5
  274. package/src/util/trim.ts +0 -15
  275. package/vendor/parjs-browser.mjs +0 -4
  276. package/vendor/parjs-default.mjs +0 -8
  277. /package/dist/types/{src/bin → bin}/chat.d.ts +0 -0
@@ -1,167 +0,0 @@
1
- import { Schema as S } from 'effect';
2
- import { Message, type MessageContentBlock } from '@dxos/artifact';
3
- import { ObjectId } from '@dxos/echo-schema';
4
- export declare const createArtifactElement: (id: ObjectId) => string;
5
- export declare const LLMModel: S.Literal<["@anthropic/claude-3-5-haiku-20241022", "@anthropic/claude-3-5-sonnet-20241022", "@anthropic/claude-3-7-sonnet-20250219", "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", "@hf/nousresearch/hermes-2-pro-mistral-7b", "@ollama/llama-3-1-nemotron-70b-instruct", "@ollama/llama-3-1-nemotron-mini-4b-instruct", "@ollama/llama-3-2-3b", "llama3.2:1b", "llama3:70b", "deepseek-r1:latest"]>;
6
- export type LLMModel = S.Schema.Type<typeof LLMModel>;
7
- export declare const ToolTypes: Readonly<{
8
- TextToImage: "text_to_image";
9
- }>;
10
- /**
11
- * Client GPT request.
12
- */
13
- export declare const GenerateRequest: S.Struct<{
14
- spaceId: S.optional<S.Schema<import("@dxos/keys").SpaceId, string, never>>;
15
- threadId: S.optional<import("@dxos/echo-schema").ObjectIdClass>;
16
- /**
17
- * Preferred model or system default.
18
- */
19
- model: S.optional<S.Literal<["@anthropic/claude-3-5-haiku-20241022", "@anthropic/claude-3-5-sonnet-20241022", "@anthropic/claude-3-7-sonnet-20250219", "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", "@hf/nousresearch/hermes-2-pro-mistral-7b", "@ollama/llama-3-1-nemotron-70b-instruct", "@ollama/llama-3-1-nemotron-mini-4b-instruct", "@ollama/llama-3-2-3b", "llama3.2:1b", "llama3:70b", "deepseek-r1:latest"]>>;
20
- /**
21
- * Tools available for the LLM.
22
- */
23
- tools: S.optional<S.mutable<S.Array$<S.Struct<{
24
- name: typeof S.String;
25
- namespace: S.optional<typeof S.String>;
26
- function: S.optional<typeof S.String>;
27
- type: S.optional<typeof S.String>;
28
- caption: S.optional<typeof S.String>;
29
- description: S.optional<typeof S.String>;
30
- parameters: S.optional<S.Schema<import("@dxos/echo-schema").JsonSchemaType, import("@dxos/echo-schema").JsonSchemaType, never>>;
31
- options: S.optional<typeof S.Any>;
32
- }>>>>;
33
- /**
34
- * System instructions to the LLM.
35
- */
36
- systemPrompt: S.optional<typeof S.String>;
37
- /**
38
- * History of messages to include in the context window.
39
- */
40
- history: S.optional<S.Array$<import("@dxos/echo-schema").EchoObjectSchema<S.Struct<{
41
- id: import("@dxos/echo-schema").ObjectIdClass;
42
- spaceId: S.optional<S.Schema<import("@dxos/keys").SpaceId, string, never>>;
43
- threadId: S.optional<import("@dxos/echo-schema").ObjectIdClass>;
44
- foreignId: S.optional<typeof S.String>;
45
- role: S.refine<"user" | "assistant", S.Schema<string, string, never>>;
46
- content: S.mutable<S.Array$<S.Union<[S.mutable<S.extend<S.Struct<{
47
- pending: S.optional<typeof S.Boolean>;
48
- }>, S.Struct<{
49
- type: S.Literal<["text"]>;
50
- disposition: S.optional<typeof S.String>;
51
- text: typeof S.String;
52
- }>>>, S.mutable<S.extend<S.Struct<{
53
- pending: S.optional<typeof S.Boolean>;
54
- }>, S.Struct<{
55
- type: S.Literal<["json"]>;
56
- disposition: S.optional<typeof S.String>;
57
- json: typeof S.String;
58
- }>>>, S.mutable<S.extend<S.Struct<{
59
- pending: S.optional<typeof S.Boolean>;
60
- }>, S.Struct<{
61
- type: S.Literal<["image"]>;
62
- id: S.optional<typeof S.String>;
63
- source: S.optional<S.mutable<S.Struct<{
64
- type: S.Literal<["base64"]>;
65
- mediaType: typeof S.String;
66
- data: typeof S.String;
67
- }>>>;
68
- }>>>, S.mutable<S.extend<S.Struct<{
69
- pending: S.optional<typeof S.Boolean>;
70
- }>, S.Struct<{
71
- type: S.Literal<["tool_use"]>;
72
- id: typeof S.String;
73
- name: typeof S.String;
74
- input: typeof S.Unknown;
75
- }>>>, S.mutable<S.extend<S.Struct<{
76
- pending: S.optional<typeof S.Boolean>;
77
- }>, S.Struct<{
78
- type: S.Literal<["tool_result"]>;
79
- toolUseId: typeof S.String;
80
- content: typeof S.String;
81
- isError: S.optional<typeof S.Boolean>;
82
- }>>>]>>>;
83
- }>>>>;
84
- /**
85
- * Current request.
86
- */
87
- prompt: S.optional<import("@dxos/echo-schema").EchoObjectSchema<S.Struct<{
88
- id: import("@dxos/echo-schema").ObjectIdClass;
89
- spaceId: S.optional<S.Schema<import("@dxos/keys").SpaceId, string, never>>;
90
- threadId: S.optional<import("@dxos/echo-schema").ObjectIdClass>;
91
- foreignId: S.optional<typeof S.String>;
92
- role: S.refine<"user" | "assistant", S.Schema<string, string, never>>;
93
- content: S.mutable<S.Array$<S.Union<[S.mutable<S.extend<S.Struct<{
94
- pending: S.optional<typeof S.Boolean>;
95
- }>, S.Struct<{
96
- type: S.Literal<["text"]>;
97
- disposition: S.optional<typeof S.String>;
98
- text: typeof S.String;
99
- }>>>, S.mutable<S.extend<S.Struct<{
100
- pending: S.optional<typeof S.Boolean>;
101
- }>, S.Struct<{
102
- type: S.Literal<["json"]>;
103
- disposition: S.optional<typeof S.String>;
104
- json: typeof S.String;
105
- }>>>, S.mutable<S.extend<S.Struct<{
106
- pending: S.optional<typeof S.Boolean>;
107
- }>, S.Struct<{
108
- type: S.Literal<["image"]>;
109
- id: S.optional<typeof S.String>;
110
- source: S.optional<S.mutable<S.Struct<{
111
- type: S.Literal<["base64"]>;
112
- mediaType: typeof S.String;
113
- data: typeof S.String;
114
- }>>>;
115
- }>>>, S.mutable<S.extend<S.Struct<{
116
- pending: S.optional<typeof S.Boolean>;
117
- }>, S.Struct<{
118
- type: S.Literal<["tool_use"]>;
119
- id: typeof S.String;
120
- name: typeof S.String;
121
- input: typeof S.Unknown;
122
- }>>>, S.mutable<S.extend<S.Struct<{
123
- pending: S.optional<typeof S.Boolean>;
124
- }>, S.Struct<{
125
- type: S.Literal<["tool_result"]>;
126
- toolUseId: typeof S.String;
127
- content: typeof S.String;
128
- isError: S.optional<typeof S.Boolean>;
129
- }>>>]>>>;
130
- }>>>;
131
- }>;
132
- export type GenerateRequest = S.Schema.Type<typeof GenerateRequest>;
133
- /**
134
- * Server-Sent Events (SSE) stream from the AI service.
135
- * https://docs.anthropic.com/en/api/streaming
136
- * https://platform.openai.com/docs/api-reference/streaming
137
- * https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events
138
- */
139
- export type GenerationStreamEvent = {
140
- type: 'message_start';
141
- message: Omit<Message, 'spaceId' | 'threadId'>;
142
- } | {
143
- type: 'message_delta';
144
- delta: {
145
- stopReason: 'tool_use' | 'end_turn';
146
- };
147
- } | {
148
- type: 'message_stop';
149
- } | {
150
- type: 'content_block_start';
151
- index: number;
152
- content: MessageContentBlock;
153
- } | {
154
- type: 'content_block_delta';
155
- index: number;
156
- delta: {
157
- type: 'text_delta';
158
- text: string;
159
- } | {
160
- type: 'input_json_delta';
161
- partial_json: string;
162
- };
163
- } | {
164
- type: 'content_block_stop';
165
- index: number;
166
- };
167
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/ai-service/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAQ,OAAO,EAAE,KAAK,mBAAmB,EAAiB,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,eAAO,MAAM,qBAAqB,OAAQ,QAAQ,WAA4B,CAAC;AAE/E,eAAO,MAAM,QAAQ,wYAA8D,CAAC;AAEpF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEtD,eAAO,MAAM,SAAS;;EAIpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe;;;IAI1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E,kBAAkB,CAAC;QACzB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACP,GACD;IACE,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './sse';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ai-service/util/index.ts"],"names":[],"mappings":"AAIA,cAAc,OAAO,CAAC"}
@@ -1,39 +0,0 @@
1
- /**
2
- * Server sent events (SSE) iterator.
3
- * @param response
4
- * @param controller
5
- */
6
- export declare function iterSSEMessages(response: Response, controller: AbortController): AsyncGenerator<ServerSentEvent, void, unknown>;
7
- export type ServerSentEvent = {
8
- event: string | null;
9
- data: string;
10
- raw: string[];
11
- };
12
- /** This is an internal helper function that's just used for testing */
13
- export declare const _decodeChunks: (chunks: string[]) => string[];
14
- /**
15
- * Most browsers don't yet have async iterable support for ReadableStream,
16
- * and Node has a very different way of reading bytes from its "ReadableStream".
17
- *
18
- * This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
19
- */
20
- export declare function readableStreamAsyncIterable<T>(stream: any): AsyncIterableIterator<T>;
21
- export type Bytes = string | ArrayBuffer | Uint8Array | Buffer | null | undefined;
22
- /**
23
- * A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
24
- * reading lines from text.
25
- *
26
- * https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
27
- */
28
- export declare class LineDecoder {
29
- static NEWLINE_CHARS: Set<string>;
30
- static NEWLINE_REGEXP: RegExp;
31
- buffer: string[];
32
- trailingCR: boolean;
33
- textDecoder: any;
34
- constructor();
35
- decode(chunk: Bytes): string[];
36
- decodeText(bytes: Bytes): string;
37
- flush(): string[];
38
- }
39
- //# sourceMappingURL=sse.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../../../../src/ai-service/util/sse.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAuB,eAAe,CACpC,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,eAAe,GAC1B,cAAc,CAAC,eAAe,EAAE,IAAI,EAAE,OAAO,CAAC,CAyBhD;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AA8HF,uEAAuE;AACvE,eAAO,MAAM,aAAa,WAAY,MAAM,EAAE,KAAG,MAAM,EAQtD,CAAC;AAWF;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,qBAAqB,CAAC,CAAC,CAAC,CA6BpF;AAED,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAElF;;;;;GAKG;AACH,qBAAa,WAAW;IAEtB,MAAM,CAAC,aAAa,cAAyB;IAC7C,MAAM,CAAC,cAAc,SAAkB;IAEvC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,GAAG,CAAC;;IAOjB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE;IA0C9B,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM;IAuChC,KAAK,IAAI,MAAM,EAAE;CAUlB"}
@@ -1,80 +0,0 @@
1
- import { type Tool, Message } from '@dxos/artifact';
2
- import { ObjectId } from '@dxos/echo-schema';
3
- import { type SpaceId } from '@dxos/keys';
4
- import { type AIServiceClient, type GenerationStreamEvent, type LLMModel } from '../ai-service';
5
- export type CreateLLMConversationParams = {
6
- model: LLMModel;
7
- spaceId?: SpaceId;
8
- threadId?: ObjectId;
9
- /**
10
- * System prompt that specifies instructions for the LLM.
11
- */
12
- system?: string;
13
- tools: Tool[];
14
- history?: Message[];
15
- client: AIServiceClient;
16
- logger?: (event: ConversationEvent) => void;
17
- };
18
- export type ConversationEvent = {
19
- type: 'message';
20
- message: Message;
21
- } | GenerationStreamEvent;
22
- export declare const runLLM: (params: CreateLLMConversationParams) => Promise<{
23
- result: any;
24
- history: {
25
- readonly id: string;
26
- spaceId?: SpaceId | undefined;
27
- threadId?: string | undefined;
28
- foreignId?: string | undefined;
29
- role: "user" | "assistant";
30
- content: ({
31
- pending?: boolean | undefined;
32
- type: "text";
33
- disposition?: string | undefined;
34
- text: string;
35
- } | {
36
- pending?: boolean | undefined;
37
- type: "json";
38
- disposition?: string | undefined;
39
- json: string;
40
- } | {
41
- pending?: boolean | undefined;
42
- type: "image";
43
- id?: string | undefined;
44
- source?: {
45
- type: "base64";
46
- mediaType: string;
47
- data: string;
48
- } | undefined;
49
- } | {
50
- pending?: boolean | undefined;
51
- name: string;
52
- type: "tool_use";
53
- id: string;
54
- input: unknown;
55
- } | {
56
- pending?: boolean | undefined;
57
- type: "tool_result";
58
- content: string;
59
- toolUseId: string;
60
- isError?: boolean | undefined;
61
- })[];
62
- }[];
63
- }>;
64
- export declare const isToolUse: (message: Message, { onlyToolNames }?: {
65
- onlyToolNames?: string[];
66
- }) => boolean;
67
- export type RunToolsOptions = {
68
- message: Message;
69
- tools: Tool[];
70
- extensions?: ToolContextExtensions;
71
- };
72
- export type RunToolsResult = {
73
- type: 'continue';
74
- message: Message;
75
- } | {
76
- type: 'break';
77
- result: unknown;
78
- };
79
- export declare const runTools: ({ message, tools, extensions }: RunToolsOptions) => Promise<RunToolsResult>;
80
- //# sourceMappingURL=conversation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../src/conversation/conversation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,IAAI,EAAc,OAAO,EA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CAAC;CACjB,CAAC;AAEN,eAAO,MAAM,QAAQ,mCAA0C,eAAe,KAAG,OAAO,CAAC,cAAc,CAqFtG,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=conversation.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"conversation.test.d.ts","sourceRoot":"","sources":["../../../../src/conversation/conversation.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export * from './conversation';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/conversation/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC"}
@@ -1,79 +0,0 @@
1
- import { Schema as S } from 'effect';
2
- import { type Message, type MessageContentBlock } from '@dxos/artifact';
3
- import { JsonSchemaType, ObjectId } from '@dxos/echo-schema';
4
- import type { SpaceId } from '@dxos/keys';
5
- export declare const createUserMessage: (spaceId: SpaceId, threadId: ObjectId, text: string) => Message;
6
- /**
7
- * @deprecated Use {@link LLMTool} instead.
8
- */
9
- export declare const ToolDefinition: S.Struct<{
10
- name: typeof S.String;
11
- description: typeof S.String;
12
- parameters: S.Schema<JsonSchemaType, JsonSchemaType, never>;
13
- execute: typeof S.Any;
14
- }>;
15
- /**
16
- * @deprecated Use {@link LLMTool} instead.
17
- */
18
- export type ToolDefinition = {
19
- name: string;
20
- description: string;
21
- parameters: JsonSchemaType;
22
- execute: (params: unknown, context: ToolExecutionContext) => Promise<ToolResult>;
23
- };
24
- declare global {
25
- /**
26
- * Extensions to the tool execution context.
27
- *
28
- * Different modules can extend this definition to add their own properties.
29
- *
30
- * @example
31
- * ```ts
32
- * declare global {
33
- * interface ToolContextExtensions {
34
- * chess: {
35
- * board: string;
36
- * };
37
- * }
38
- * }
39
- * ```
40
- *
41
- * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#global-augmentation
42
- */
43
- interface ToolContextExtensions {
44
- }
45
- }
46
- export type ToolExecutionContext = {
47
- extensions: ToolContextExtensions;
48
- };
49
- export type ToolResult = {
50
- kind: 'success';
51
- result: unknown;
52
- extractContentBlocks?: MessageContentBlock[];
53
- } | {
54
- kind: 'error';
55
- message: string;
56
- } | {
57
- kind: 'break';
58
- result: unknown;
59
- };
60
- export declare const ToolResult: Readonly<{
61
- /**
62
- * The tool execution was successful.
63
- * Gives the result back to the LLM.
64
- */
65
- Success: (result: unknown, extractContentBlocks?: MessageContentBlock[]) => ToolResult;
66
- Error: (message: string) => ToolResult;
67
- /**
68
- * Stop the conversation and return the result.
69
- */
70
- Break: (result: unknown) => ToolResult;
71
- }>;
72
- export type DefineToolParams<Params extends S.Schema.AnyNoContext> = {
73
- name: string;
74
- description: string;
75
- schema: Params;
76
- execute: (params: S.Schema.Type<Params>, context: ToolExecutionContext) => Promise<ToolResult>;
77
- };
78
- export declare const defineTool: <Params extends S.Schema.AnyNoContext>({ name, description, schema, execute, }: DefineToolParams<Params>) => ToolDefinition;
79
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/conversation/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAgB,cAAc,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,eAAO,MAAM,iBAAiB,YAAa,OAAO,YAAY,QAAQ,QAAQ,MAAM,KAAG,OAMrF,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;EAKzB,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,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}
@@ -1,56 +0,0 @@
1
- export interface AstNode<Kind extends string> {
2
- astKind: Kind;
3
- }
4
- export interface Identifier extends AstNode<'Identifier'> {
5
- name: string;
6
- }
7
- export interface Property {
8
- key: Identifier;
9
- value: StringLiteral;
10
- }
11
- export interface Properties extends AstNode<'Properties'> {
12
- properties: Property[];
13
- }
14
- export interface NodePattern extends AstNode<'NodePattern'> {
15
- variable: Identifier | null;
16
- label: Identifier;
17
- properties: Properties | null;
18
- }
19
- export interface RelationshipPattern extends AstNode<'RelationshipPattern'> {
20
- variable: Identifier | null;
21
- label: Identifier;
22
- properties: Properties | null;
23
- }
24
- export interface GraphPatternConnector extends AstNode<'GraphPatternConnector'> {
25
- direction: '-' | '->' | '<-';
26
- }
27
- export interface GraphPattern extends AstNode<'GraphPattern'> {
28
- segments: (NodePattern | RelationshipPattern)[] & {
29
- separators: GraphPatternConnector[];
30
- };
31
- }
32
- export interface MatchClause extends AstNode<'MatchClause'> {
33
- pattern: GraphPattern;
34
- }
35
- export interface StringLiteral extends AstNode<'StringLiteral'> {
36
- value: string;
37
- }
38
- export interface MemberExpression extends AstNode<'MemberExpression'> {
39
- path: Identifier[];
40
- }
41
- export interface EqualsPredicate extends AstNode<'EqualsPredicate'> {
42
- left: MemberExpression;
43
- right: StringLiteral;
44
- }
45
- export interface WhereClause extends AstNode<'WhereClause'> {
46
- predicates: EqualsPredicate[];
47
- }
48
- export interface ReturnClause extends AstNode<'ReturnClause'> {
49
- fields: MemberExpression[];
50
- }
51
- export interface CypherQuery extends AstNode<'CypherQuery'> {
52
- matchClause: MatchClause;
53
- whereClause: WhereClause | null;
54
- returnClause: ReturnClause;
55
- }
56
- //# sourceMappingURL=ast.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../../../src/cypher/ast.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,OAAO,CAAC,IAAI,SAAS,MAAM;IAC1C,OAAO,EAAE,IAAI,CAAC;CACf;A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AAgB,SAAQ,OAAO,CAAC,iBAAiB,CAAC;IACjE,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,aAAa,CAAC;IACzD,UAAU,EAAE,eAAe,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,YAAa,SAAQ,OAAO,CAAC,cAAc,CAAC;IAC3D,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,aAAa,CAAC;IACzD,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,YAAY,EAAE,YAAY,CAAC;CAC5B"}
@@ -1,14 +0,0 @@
1
- import type { CypherQuery, GraphPattern, Identifier, MatchClause, NodePattern, Properties, Property, RelationshipPattern, ReturnClause, WhereClause } from './ast';
2
- import { Parjser } from './parjs';
3
- export declare const identifier: Parjser<Identifier>;
4
- export declare const label: Parjser<Identifier>;
5
- export declare const property: Parjser<Property>;
6
- export declare const properties: Parjser<Properties>;
7
- export declare const nodePattern: Parjser<NodePattern>;
8
- export declare const relationshipPattern: Parjser<RelationshipPattern>;
9
- export declare const graphPattern: Parjser<GraphPattern>;
10
- export declare const matchClause: Parjser<MatchClause>;
11
- export declare const whereClause: Parjser<WhereClause>;
12
- export declare const returnClause: Parjser<ReturnClause>;
13
- export declare const cypherQuery: Parjser<CypherQuery>;
14
- //# sourceMappingURL=combinators.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"combinators.d.ts","sourceRoot":"","sources":["../../../../src/cypher/combinators.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,WAAW,EAEX,YAAY,EAEZ,UAAU,EACV,WAAW,EAEX,WAAW,EACX,UAAU,EACV,QAAQ,EACR,mBAAmB,EACnB,YAAY,EAEZ,WAAW,EACZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,OAAO,EAA2B,MAAM,SAAS,CAAC;AAgB3D,eAAO,MAAM,UAAU,qBAEtB,CAAC;AAUF,eAAO,MAAM,KAAK,qBAAwD,CAAC;AAC3E,eAAO,MAAM,QAAQ,mBAGpB,CAAC;AACF,eAAO,MAAM,UAAU,qBAItB,CAAC;AACF,eAAO,MAAM,WAAW,sBAQvB,CAAC;AAEF,eAAO,MAAM,mBAAmB,8BAa/B,CAAC;AAOF,eAAO,MAAM,YAAY,uBAIxB,CAAC;AAEF,eAAO,MAAM,WAAW,sBAIvB,CAAC;AAYF,eAAO,MAAM,WAAW,sBAOvB,CAAC;AAEF,eAAO,MAAM,YAAY,uBAaxB,CAAC;AAEF,eAAO,MAAM,WAAW,sBAUvB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=combinators.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"combinators.test.d.ts","sourceRoot":"","sources":["../../../../src/cypher/combinators.test.ts"],"names":[],"mappings":""}
@@ -1,16 +0,0 @@
1
- import { type EchoDatabase } from '@dxos/echo-db';
2
- import type { DataSource, Node, Relationship } from './query-executor';
3
- export declare class EchoDataSource implements DataSource {
4
- private readonly _db;
5
- constructor(_db: EchoDatabase);
6
- getNodes({ label }: {
7
- label?: string;
8
- }): Promise<Node[]>;
9
- getRelationships({ label }: {
10
- label?: string;
11
- }): Promise<Relationship[]>;
12
- private _getAllSchema;
13
- private _objectToNode;
14
- private _projectRefRelationship;
15
- }
16
- //# sourceMappingURL=echo-data-source.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"echo-data-source.d.ts","sourceRoot":"","sources":["../../../../src/cypher/echo-data-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,YAAY,EAAmC,MAAM,eAAe,CAAC;AAKnF,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGvE,qBAAa,cAAe,YAAW,UAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAGxC,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAiBxD,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;YA+BhE,aAAa;IAQ3B,OAAO,CAAC,aAAa;YAUP,uBAAuB;CAqBtC"}
@@ -1,49 +0,0 @@
1
- import type { JsonPath } from '@dxos/echo-schema';
2
- import type { ParsedQuery } from './parser';
3
- export type VariableName = string & {
4
- __VariableName: never;
5
- };
6
- export type ExecutionPlanStep = {
7
- type: 'NodeScan';
8
- label: string;
9
- into: VariableName;
10
- } | {
11
- type: 'FilterByLabel';
12
- variable: VariableName;
13
- label: string;
14
- } | {
15
- type: 'FilterByProperty';
16
- variable: VariableName;
17
- property: JsonPath;
18
- value: unknown;
19
- } | {
20
- /**
21
- * Scans (anchor)-[relationshipInto:label]->(nodeInto).
22
- */
23
- type: 'RelationshipScan';
24
- label: string;
25
- anchor: VariableName;
26
- relationshipInto: VariableName;
27
- nodeInto: VariableName;
28
- /**
29
- * `in`: (anchor)<-[relationshipInto:label]-(nodeInto)
30
- * `out`: (anchor)-[relationshipInto:label]->(nodeInto)
31
- * `both`: (anchor)-[relationshipInto:label]-(nodeInto)
32
- */
33
- direction: 'in' | 'out' | 'both';
34
- } | {
35
- type: 'ProduceResults';
36
- fields: {
37
- name: string;
38
- variable: VariableName;
39
- path: JsonPath;
40
- }[];
41
- };
42
- export type ExecutionPlan = {
43
- steps: ExecutionPlanStep[];
44
- output: {
45
- fields: string[];
46
- };
47
- };
48
- export declare const createExecutionPlan: (query: ParsedQuery) => ExecutionPlan;
49
- //# sourceMappingURL=execution-plan.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"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WAAW,KAAG,aAExD,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=execution-plan.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execution-plan.test.d.ts","sourceRoot":"","sources":["../../../../src/cypher/execution-plan.test.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- export * from './parser';
2
- export * from './query-executor';
3
- export * from './schema';
4
- export * from './echo-data-source';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cypher/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { Parjser } from 'parjs';
2
- import { parjsCombinators, parjs } from '#parjs';
3
- export { type Parjser, parjsCombinators, parjs };
4
- //# sourceMappingURL=parjs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parjs.d.ts","sourceRoot":"","sources":["../../../../src/cypher/parjs.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEjD,OAAO,EAAE,KAAK,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC"}
@@ -1,6 +0,0 @@
1
- import type { CypherQuery } from './ast';
2
- export type ParsedQuery = {
3
- ast: CypherQuery;
4
- };
5
- export declare const parseCypherQuery: (query: string) => ParsedQuery;
6
- //# sourceMappingURL=parser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../../src/cypher/parser.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAGzC,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,WAAW,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAW,MAAM,KAAG,WAOhD,CAAC"}
@@ -1,26 +0,0 @@
1
- import { type ExecutionPlan } from './execution-plan';
2
- export interface DataSource {
3
- getNodes: (params: {
4
- label?: string;
5
- }) => Promise<Node[]>;
6
- getRelationships: (params: {
7
- label?: string;
8
- }) => Promise<Relationship[]>;
9
- }
10
- export type Node = {
11
- id: string;
12
- kind: 'node';
13
- label: string;
14
- properties: Record<string, unknown>;
15
- };
16
- export type Relationship = {
17
- id: string;
18
- kind: 'relationship';
19
- label: string;
20
- properties: Record<string, unknown>;
21
- source: Node;
22
- target: Node;
23
- };
24
- export declare const executeQueryPlan: (dataSource: DataSource, plan: ExecutionPlan) => Promise<Record<string, unknown>[]>;
25
- export declare const executeQuery: (dataSource: DataSource, query: string) => Promise<Record<string, unknown>[]>;
26
- //# sourceMappingURL=query-executor.d.ts.map