@dxos/assistant 0.8.4-main.84f28bd → 0.8.4-main.9735255

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 (198) hide show
  1. package/dist/lib/browser/chunk-7CDDG6LL.mjs +578 -0
  2. package/dist/lib/browser/chunk-7CDDG6LL.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  4. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  5. package/dist/lib/browser/extraction/index.mjs +225 -0
  6. package/dist/lib/browser/extraction/index.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +723 -1892
  8. package/dist/lib/browser/index.mjs.map +4 -4
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/testing/index.mjs +32 -0
  11. package/dist/lib/browser/testing/index.mjs.map +7 -0
  12. package/dist/lib/node-esm/chunk-CC7ER6Q3.mjs +579 -0
  13. package/dist/lib/node-esm/chunk-CC7ER6Q3.mjs.map +7 -0
  14. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  15. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  16. package/dist/lib/node-esm/extraction/index.mjs +226 -0
  17. package/dist/lib/node-esm/extraction/index.mjs.map +7 -0
  18. package/dist/lib/node-esm/index.mjs +723 -1893
  19. package/dist/lib/node-esm/index.mjs.map +4 -4
  20. package/dist/lib/node-esm/meta.json +1 -1
  21. package/dist/lib/node-esm/testing/index.mjs +33 -0
  22. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  23. package/dist/types/src/conversation/context.d.ts +129 -0
  24. package/dist/types/src/conversation/context.d.ts.map +1 -0
  25. package/dist/types/src/conversation/context.test.d.ts +2 -0
  26. package/dist/types/src/conversation/context.test.d.ts.map +1 -0
  27. package/dist/types/src/conversation/conversation.d.ts +29 -32
  28. package/dist/types/src/conversation/conversation.d.ts.map +1 -1
  29. package/dist/types/src/conversation/conversation.test.d.ts +2 -0
  30. package/dist/types/src/conversation/conversation.test.d.ts.map +1 -0
  31. package/dist/types/src/conversation/index.d.ts +1 -0
  32. package/dist/types/src/conversation/index.d.ts.map +1 -1
  33. package/dist/types/src/diff.d.ts +15 -0
  34. package/dist/types/src/diff.d.ts.map +1 -0
  35. package/dist/types/src/diff.test.d.ts +2 -0
  36. package/dist/types/src/diff.test.d.ts.map +1 -0
  37. package/dist/types/src/errors.d.ts +67 -0
  38. package/dist/types/src/errors.d.ts.map +1 -0
  39. package/dist/types/src/execution-graph.d.ts +85 -0
  40. package/dist/types/src/execution-graph.d.ts.map +1 -0
  41. package/dist/types/src/execution-graph.test.d.ts +2 -0
  42. package/dist/types/src/execution-graph.test.d.ts.map +1 -0
  43. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +1 -1
  44. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -1
  45. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +279 -140
  46. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -1
  47. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts +1 -1
  48. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -1
  49. package/dist/types/src/extraction/extraction.d.ts +345 -212
  50. package/dist/types/src/extraction/extraction.d.ts.map +1 -1
  51. package/dist/types/src/extraction/quotes.d.ts +3 -3
  52. package/dist/types/src/extraction/quotes.d.ts.map +1 -1
  53. package/dist/types/src/functions/index.d.ts +2 -0
  54. package/dist/types/src/functions/index.d.ts.map +1 -0
  55. package/dist/types/src/functions/services.d.ts +20 -0
  56. package/dist/types/src/functions/services.d.ts.map +1 -0
  57. package/dist/types/src/functions.test.d.ts +2 -0
  58. package/dist/types/src/functions.test.d.ts.map +1 -0
  59. package/dist/types/src/index.d.ts +5 -5
  60. package/dist/types/src/index.d.ts.map +1 -1
  61. package/dist/types/src/session/GenericToolkit.d.ts +85 -0
  62. package/dist/types/src/session/GenericToolkit.d.ts.map +1 -0
  63. package/dist/types/src/session/artifact-diff.d.ts +27 -0
  64. package/dist/types/src/session/artifact-diff.d.ts.map +1 -0
  65. package/dist/types/src/session/error-handling.d.ts +4 -0
  66. package/dist/types/src/session/error-handling.d.ts.map +1 -0
  67. package/dist/types/src/session/format.d.ts +12 -0
  68. package/dist/types/src/session/format.d.ts.map +1 -0
  69. package/dist/types/src/session/format.test.d.ts +2 -0
  70. package/dist/types/src/session/format.test.d.ts.map +1 -0
  71. package/dist/types/src/session/index.d.ts +4 -0
  72. package/dist/types/src/session/index.d.ts.map +1 -1
  73. package/dist/types/src/session/observer.d.ts +23 -0
  74. package/dist/types/src/session/observer.d.ts.map +1 -0
  75. package/dist/types/src/session/session.d.ts +41 -268
  76. package/dist/types/src/session/session.d.ts.map +1 -1
  77. package/dist/types/src/session/toolkit.d.ts +14 -0
  78. package/dist/types/src/session/toolkit.d.ts.map +1 -0
  79. package/dist/types/src/session/version-pin.d.ts +5 -5
  80. package/dist/types/src/session/version-pin.d.ts.map +1 -1
  81. package/dist/types/src/templates/index.d.ts +2 -0
  82. package/dist/types/src/templates/index.d.ts.map +1 -0
  83. package/dist/types/src/templates/system.d.ts +18 -0
  84. package/dist/types/src/templates/system.d.ts.map +1 -0
  85. package/dist/types/src/testing/index.d.ts +1 -2
  86. package/dist/types/src/testing/index.d.ts.map +1 -1
  87. package/dist/types/src/testing/layer.d.ts +21 -0
  88. package/dist/types/src/testing/layer.d.ts.map +1 -0
  89. package/dist/types/src/types/artifact.d.ts +28 -0
  90. package/dist/types/src/types/artifact.d.ts.map +1 -0
  91. package/dist/types/src/types/index.d.ts +2 -0
  92. package/dist/types/src/types/index.d.ts.map +1 -0
  93. package/dist/types/tsconfig.tsbuildinfo +1 -1
  94. package/package.json +58 -27
  95. package/src/conversation/context.test.ts +46 -0
  96. package/src/conversation/context.ts +303 -0
  97. package/src/conversation/conversation.test.ts +65 -0
  98. package/src/conversation/conversation.ts +98 -76
  99. package/src/conversation/index.ts +1 -0
  100. package/src/diff.test.ts +43 -0
  101. package/src/diff.ts +84 -0
  102. package/src/errors.ts +15 -0
  103. package/src/execution-graph.test.ts +740 -0
  104. package/src/execution-graph.ts +509 -0
  105. package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +14 -25
  106. package/src/extraction/extraction-llm-function/extraction-llm-function.ts +48 -52
  107. package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +22 -21
  108. package/src/extraction/extraction-ner-function/extraction-ner-function.ts +43 -41
  109. package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +12 -6
  110. package/src/extraction/extraction-ner-function/named-entity-recognition.ts +3 -1
  111. package/src/extraction/extraction.ts +10 -9
  112. package/src/extraction/quotes.test.ts +3 -3
  113. package/src/extraction/quotes.ts +6 -7
  114. package/src/functions/index.ts +5 -0
  115. package/src/functions/services.ts +180 -0
  116. package/src/functions.conversations.json +1 -0
  117. package/src/functions.test.ts +74 -0
  118. package/src/index.ts +5 -5
  119. package/src/session/GenericToolkit.ts +131 -0
  120. package/src/session/artifact-diff.ts +41 -0
  121. package/src/session/error-handling.ts +41 -0
  122. package/src/session/format.test.ts +124 -0
  123. package/src/session/format.ts +143 -0
  124. package/src/session/index.ts +5 -0
  125. package/src/session/observer.ts +61 -0
  126. package/src/session/session.conversations.json +1 -0
  127. package/src/session/session.test.ts +83 -215
  128. package/src/session/session.ts +181 -529
  129. package/src/session/toolkit.ts +39 -0
  130. package/src/session/version-pin.ts +12 -12
  131. package/src/templates/index.ts +5 -0
  132. package/src/templates/instructions/format.tpl +61 -0
  133. package/src/templates/instructions/system.tpl +48 -0
  134. package/src/templates/system.ts +41 -0
  135. package/src/testing/index.ts +2 -8
  136. package/src/testing/layer.ts +78 -0
  137. package/src/types/artifact.ts +82 -0
  138. package/src/types/index.ts +5 -0
  139. package/src/typings.d.ts +5 -0
  140. package/dist/types/bin/chat.d.ts +0 -2
  141. package/dist/types/bin/chat.d.ts.map +0 -1
  142. package/dist/types/src/blueprint/blueprint.d.ts +0 -41
  143. package/dist/types/src/blueprint/blueprint.d.ts.map +0 -1
  144. package/dist/types/src/blueprint/index.d.ts +0 -3
  145. package/dist/types/src/blueprint/index.d.ts.map +0 -1
  146. package/dist/types/src/blueprint/registry.d.ts +0 -7
  147. package/dist/types/src/blueprint/registry.d.ts.map +0 -1
  148. package/dist/types/src/context/binder.d.ts +0 -34
  149. package/dist/types/src/context/binder.d.ts.map +0 -1
  150. package/dist/types/src/context/binding.d.ts +0 -38
  151. package/dist/types/src/context/binding.d.ts.map +0 -1
  152. package/dist/types/src/context/index.d.ts +0 -3
  153. package/dist/types/src/context/index.d.ts.map +0 -1
  154. package/dist/types/src/research/exa.d.ts +0 -7
  155. package/dist/types/src/research/exa.d.ts.map +0 -1
  156. package/dist/types/src/research/graph.d.ts +0 -41
  157. package/dist/types/src/research/graph.d.ts.map +0 -1
  158. package/dist/types/src/research/graph.test.d.ts +0 -2
  159. package/dist/types/src/research/graph.test.d.ts.map +0 -1
  160. package/dist/types/src/research/index.d.ts +0 -4
  161. package/dist/types/src/research/index.d.ts.map +0 -1
  162. package/dist/types/src/research/research.d.ts +0 -10
  163. package/dist/types/src/research/research.d.ts.map +0 -1
  164. package/dist/types/src/research/research.test.d.ts +0 -2
  165. package/dist/types/src/research/research.test.d.ts.map +0 -1
  166. package/dist/types/src/session/version-pin.test.d.ts +0 -2
  167. package/dist/types/src/session/version-pin.test.d.ts.map +0 -1
  168. package/dist/types/src/summarization/summarization.test.d.ts +0 -2
  169. package/dist/types/src/summarization/summarization.test.d.ts.map +0 -1
  170. package/dist/types/src/testing/exa-search-1748337321991.d.ts +0 -38
  171. package/dist/types/src/testing/exa-search-1748337321991.d.ts.map +0 -1
  172. package/dist/types/src/testing/exa-search-1748337331526.d.ts +0 -37
  173. package/dist/types/src/testing/exa-search-1748337331526.d.ts.map +0 -1
  174. package/dist/types/src/testing/exa-search-1748337344119.d.ts +0 -58
  175. package/dist/types/src/testing/exa-search-1748337344119.d.ts.map +0 -1
  176. package/dist/types/src/types.d.ts +0 -3
  177. package/dist/types/src/types.d.ts.map +0 -1
  178. package/src/blueprint/blueprint.ts +0 -75
  179. package/src/blueprint/index.ts +0 -6
  180. package/src/blueprint/registry.ts +0 -15
  181. package/src/context/binder.ts +0 -101
  182. package/src/context/binding.ts +0 -31
  183. package/src/context/index.ts +0 -6
  184. package/src/research/exa.ts +0 -100
  185. package/src/research/graph.test.ts +0 -15
  186. package/src/research/graph.ts +0 -337
  187. package/src/research/index.ts +0 -7
  188. package/src/research/instructions-research.tpl +0 -97
  189. package/src/research/research.test.ts +0 -190
  190. package/src/research/research.ts +0 -90
  191. package/src/session/version-pin.test.ts +0 -26
  192. package/src/summarization/summarization.test.ts +0 -221
  193. package/src/testing/exa-search-1748337321991.ts +0 -131
  194. package/src/testing/exa-search-1748337331526.ts +0 -144
  195. package/src/testing/exa-search-1748337344119.ts +0 -133
  196. package/src/typedefs.d.ts +0 -8
  197. package/src/types.ts +0 -8
  198. /package/src/extraction/extraction-llm-function/{instructions.tpl → transcription-instructions.tpl} +0 -0
@@ -1,5 +1,5 @@
1
- import { Schema } from 'effect';
2
- import { type EchoDatabase } from '@dxos/echo-db';
1
+ import * as Schema from 'effect/Schema';
2
+ import { type Database } from '@dxos/echo';
3
3
  export declare const ReferencedQuotes: Schema.Struct<{
4
4
  references: Schema.mutable<Schema.Array$<Schema.Struct<{
5
5
  id: typeof Schema.String;
@@ -7,7 +7,7 @@ export declare const ReferencedQuotes: Schema.Struct<{
7
7
  }>>>;
8
8
  }>;
9
9
  export type ReferencedQuotes = Schema.Schema.Type<typeof ReferencedQuotes>;
10
- export declare const findQuotes: (quotes: string[], db: EchoDatabase) => Promise<ReferencedQuotes>;
10
+ export declare const findQuotes: (quotes: string[], db: Database.Database) => Promise<ReferencedQuotes>;
11
11
  /**
12
12
  * Finds and replaces all quotes with DXNs references.
13
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"quotes.d.ts","sourceRoot":"","sources":["../../../../src/extraction/quotes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAKlD,eAAO,MAAM,gBAAgB;;;;;EAe3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE3E,eAAO,MAAM,UAAU,GAAU,QAAQ,MAAM,EAAE,EAAE,IAAI,YAAY,KAAG,OAAO,CAAC,gBAAgB,CAS7F,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,QAAQ,gBAAgB,WAYtE,CAAC"}
1
+ {"version":3,"file":"quotes.d.ts","sourceRoot":"","sources":["../../../../src/extraction/quotes.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAK1D,eAAO,MAAM,gBAAgB;;;;;EAe3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE3E,eAAO,MAAM,UAAU,GAAU,QAAQ,MAAM,EAAE,EAAE,IAAI,QAAQ,CAAC,QAAQ,KAAG,OAAO,CAAC,gBAAgB,CASlG,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,QAAQ,gBAAgB,WAYtE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './services';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/functions/index.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,20 @@
1
+ import * as Tool from '@effect/ai/Tool';
2
+ import type * as Toolkit from '@effect/ai/Toolkit';
3
+ import * as Layer from 'effect/Layer';
4
+ import { ToolExecutionService, ToolResolverService } from '@dxos/ai';
5
+ import { Database } from '@dxos/echo';
6
+ import { FunctionDefinition, FunctionInvocationService } from '@dxos/functions';
7
+ /**
8
+ * Constructs a `ToolResolverService` whose `resolve(id)` looks up tools in the following order:
9
+ * 1. Toolkit: return an existing tool from the provided `toolkit` if one is present under `id`.
10
+ * 2. Functions in DB: query `FunctionType` by `key=id`; if found, deserialize and project to a tool
11
+ * (propagating any `deployedFunctionId` discovered in the object's metadata).
12
+ * 3. Functions passed in: fall back to a matching `FunctionDefinition` from the `functions` array.
13
+ *
14
+ * If none of the above yield a match, the effect fails with `AiToolNotFoundError`.
15
+ *
16
+ * Requires `Database.Service` in the environment.
17
+ */
18
+ export declare const makeToolResolverFromFunctions: (functions: FunctionDefinition.Any[], toolkit: Toolkit.Toolkit<any>) => Layer.Layer<ToolResolverService, never, Database.Service>;
19
+ export declare const makeToolExecutionServiceFromFunctions: (toolkit: Toolkit.Toolkit<any>, handlersLayer: Layer.Layer<Tool.Handler<any>, never, never>) => Layer.Layer<ToolExecutionService, never, FunctionInvocationService>;
20
+ //# sourceMappingURL=services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../../src/functions/services.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAGnD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAKtC,OAAO,EAAuB,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG1F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAY,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAK1F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,6BAA6B,GACxC,WAAW,kBAAkB,CAAC,GAAG,EAAE,EACnC,SAAS,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAC5B,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,EAAE,QAAQ,CAAC,OAAO,CA8B1D,CAAC;AAEF,eAAO,MAAM,qCAAqC,GAChD,SAAS,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAC7B,eAAe,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAC1D,KAAK,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,EAAE,yBAAyB,CAqCpE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=functions.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.test.d.ts","sourceRoot":"","sources":["../../../src/functions.test.ts"],"names":[],"mappings":""}
@@ -1,9 +1,9 @@
1
- export * from './blueprint';
2
- export * from './context';
3
1
  export * from './conversation';
4
- export * from './extraction';
5
- export * from './research';
2
+ export * from './diff';
3
+ export * from './errors';
4
+ export * from './execution-graph';
5
+ export * from './functions';
6
6
  export * from './session';
7
+ export * from './templates';
7
8
  export * from './types';
8
- export * from './conversation';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,85 @@
1
+ import type * as Tool from '@effect/ai/Tool';
2
+ import * as Toolkit from '@effect/ai/Toolkit';
3
+ import * as Effect from 'effect/Effect';
4
+ import * as Layer from 'effect/Layer';
5
+ import * as Pipeable from 'effect/Pipeable';
6
+ import type * as Schema from 'effect/Schema';
7
+ import type * as SchemaAST from 'effect/SchemaAST';
8
+ /**
9
+ * Unique identifier for generic toolkit instances.
10
+ */
11
+ export declare const TypeId = "~@dxos/assistant/GenericToolkit";
12
+ /**
13
+ * Type-level representation of the generic toolkit identifier.
14
+ */
15
+ export type TypeId = typeof TypeId;
16
+ /**
17
+ * Type-safe way to define toolkits where we don't know specific types of tools,
18
+ * and we want to bundle definition and handlers together.
19
+ *
20
+ * Usefull for plugin-based systems, where tools are dynamically added.
21
+ *
22
+ * @param TR requirements type to the tool invocation.
23
+ * @param E failure type to the handlers layer.
24
+ * @param R requirements type to the handlers layer.
25
+ */
26
+ export interface GenericToolkit<TR = never, E = never, R = never> extends Pipeable.Pipeable {
27
+ readonly [TypeId]: TypeId;
28
+ /**
29
+ * Toolkit definition.
30
+ */
31
+ readonly toolkit: Toolkit.Toolkit<GenericTools<TR>>;
32
+ /**
33
+ * Handlers layer.
34
+ */
35
+ readonly layer: Layer.Layer<unknown, E, R>;
36
+ /**
37
+ * Handlers effect.
38
+ */
39
+ readonly handlers: Effect.Effect<Toolkit.WithHandler<GenericTools<TR>>, E, R>;
40
+ }
41
+ /**
42
+ * Generic constraint.
43
+ *
44
+ * NOTE: Only use in place of `T extends PortableToolkit.Any`. Not suitable for standalone use.
45
+ */
46
+ export interface Any {
47
+ readonly [TypeId]: TypeId;
48
+ readonly toolkit: Toolkit.Toolkit<any>;
49
+ readonly layer: Layer.Layer<unknown, any, any>;
50
+ }
51
+ export type InvocationRequirements<T extends Any> = T extends GenericToolkit<infer TR, infer _E, infer _R> ? TR : never;
52
+ export type Failure<T extends Any> = T extends GenericToolkit<infer _TR, infer E, infer _R> ? E : never;
53
+ export type Requirements<T extends Any> = T extends GenericToolkit<infer _TR, infer _E, infer R> ? R : never;
54
+ /**
55
+ * Creates a portable toolkit from toolkit definition and handlers layer.
56
+ */
57
+ export declare const make: <Tools extends Record<string, Tool.Any>, E, R>(toolkit: Toolkit.Toolkit<Tools>, layer: Layer.Layer<Tool.HandlersFor<Tools>, E, R>) => GenericToolkit<E, R>;
58
+ /**
59
+ * Merges multiple portable toolkits into a single portable toolkit.
60
+ */
61
+ export declare const merge: <const Toolkits extends ReadonlyArray<Any>>(
62
+ /**
63
+ * The toolkits to merge together.
64
+ */
65
+ ...toolkits: Toolkits) => GenericToolkit<InvocationRequirements<Toolkits[number]>, Failure<Toolkits[number]>, Requirements<Toolkits[number]>>;
66
+ /**
67
+ * Generic tools type where we cannot statically enumerate individual tools.
68
+ */
69
+ export type GenericTools<R = never> = Record<string, Tool.Tool<string, {
70
+ readonly parameters: AnyStructSchemaNoContext;
71
+ readonly success: Schema.Schema.AnyNoContext;
72
+ readonly failure: typeof Schema.Never;
73
+ readonly failureMode: Tool.FailureMode;
74
+ }, R>>;
75
+ export interface AnyStructSchemaNoContext extends Pipeable.Pipeable {
76
+ readonly [Schema.TypeId]: any;
77
+ readonly make: any;
78
+ readonly Type: any;
79
+ readonly Encoded: any;
80
+ readonly Context: never;
81
+ readonly ast: SchemaAST.AST;
82
+ readonly fields: Schema.Struct.Fields;
83
+ readonly annotations: any;
84
+ }
85
+ //# sourceMappingURL=GenericToolkit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenericToolkit.d.ts","sourceRoot":"","sources":["../../../../src/session/GenericToolkit.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,IAAI,MAAM,i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MAAM,EACN,IAAI,CAAC,IAAI,CACP,MAAM,EACN;IACE,QAAQ,CAAC,UAAU,EAAE,wBAAwB,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAC,KAAK,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC;CACxC,EACD,CAAC,CACF,CACF,CAAC;AAEF,MAAM,WAAW,wBAAyB,SAAQ,QAAQ,CAAC,QAAQ;IACjE,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC;IACnB,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC;IACnB,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC;CAC3B"}
@@ -0,0 +1,27 @@
1
+ import * as Context from 'effect/Context';
2
+ import { type ObjectVersion } from '@dxos/echo-db';
3
+ import { type ObjectId } from '@dxos/keys';
4
+ declare const ArtifactDiffResolver_base: Context.TagClass<ArtifactDiffResolver, "@dxos/assistant/ArtifactDiffResolver", ArtifactDiffResolver.Service>;
5
+ /**
6
+ * Resolves artifact ids to their versions.
7
+ * Used to give the model a sense of the changes to the artifacts made by users during the conversation.
8
+ * The artifacts versions are pinned in the history, and whenever the artifact changes in-between assistant's steps,
9
+ * a diff is inserted into the conversation.
10
+ *
11
+ * Can be optionally provided to the session run call.
12
+ */
13
+ export declare class ArtifactDiffResolver extends ArtifactDiffResolver_base {
14
+ }
15
+ export declare namespace ArtifactDiffResolver {
16
+ type Service = {
17
+ resolve: (artifacts: {
18
+ id: ObjectId;
19
+ lastVersion: ObjectVersion;
20
+ }[]) => Promise<Map<ObjectId, {
21
+ version: ObjectVersion;
22
+ diff?: string;
23
+ }>>;
24
+ };
25
+ }
26
+ export {};
27
+ //# sourceMappingURL=artifact-diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-diff.d.ts","sourceRoot":"","sources":["../../../../src/session/artifact-diff.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;;AAE3C;;;;;;;GAOG;AAEH,qBAAa,oBAAqB,SAAQ,yBAGvC;CAAG;AAEN,yBAAiB,oBAAoB,CAAC;IACpC,KAAY,OAAO,GAAG;QACpB,OAAO,EAAE,CACP,SAAS,EAAE;YACT,EAAE,EAAE,QAAQ,CAAC;YACb,WAAW,EAAE,aAAa,CAAC;SAC5B,EAAE,KACA,OAAO,CACV,GAAG,CACD,QAAQ,EACR;YACE,OAAO,EAAE,aAAa,CAAC;YACvB,IAAI,CAAC,EAAE,MAAM,CAAC;SACf,CACF,CACF,CAAC;KACH,CAAC;CACH"}
@@ -0,0 +1,4 @@
1
+ import * as AiError from '@effect/ai/AiError';
2
+ import * as Effect from 'effect/Effect';
3
+ export declare const mapAiError: (err: AiError.AiError) => Effect.Effect<AiError.AiError>;
4
+ //# sourceMappingURL=error-handling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../../../src/session/error-handling.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAE9C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAcxC,eAAO,MAAM,UAAU,GAAI,KAAK,OAAO,CAAC,OAAO,KAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAoB1B,CAAC"}
@@ -0,0 +1,12 @@
1
+ import * as Effect from 'effect/Effect';
2
+ import { Message } from '@dxos/types';
3
+ import { type AiSessionRunError, type AiSessionRunProps } from './session';
4
+ /**
5
+ * Formats the system prompt.
6
+ */
7
+ export declare const formatSystemPrompt: ({ system, blueprints, objects, }: Pick<AiSessionRunProps<any>, "system" | "blueprints" | "objects">) => Effect.Effect<string, import("@dxos/echo/Err").ObjectNotFoundError | import("@dxos/functions").FunctionNotFoundError, import("@dxos/functions").FunctionInvocationService | import("@dxos/functions").TracingService>;
8
+ /**
9
+ * Formats the user prompt.
10
+ */
11
+ export declare const formatUserPrompt: ({ prompt, history, }: Pick<AiSessionRunProps<any>, "prompt" | "history">) => Effect.Effect<Message.Message, AiSessionRunError>;
12
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../src/session/format.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AASxC,OAAO,EAAqB,OAAO,EAAE,MAAM,aAAa,CAAC;AAMzD,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE3E;;GAEG;AAEH,eAAO,MAAM,kBAAkB,GAAI,kCAIhC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAC,0NAsChE,CAAC;AAEL;;GAEG;AAGH,eAAO,MAAM,gBAAgB,GAAI,sBAG9B,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAoCpG,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=format.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.test.d.ts","sourceRoot":"","sources":["../../../../src/session/format.test.ts"],"names":[],"mappings":""}
@@ -1,3 +1,7 @@
1
+ export * from './artifact-diff';
2
+ export * from './observer';
1
3
  export * from './session';
4
+ export * from './toolkit';
2
5
  export * from './version-pin';
6
+ export * as GenericToolkit from './GenericToolkit';
3
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/session/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/session/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAE9B,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type * as Tool from '@effect/ai/Tool';
2
+ import * as Effect from 'effect/Effect';
3
+ import { type AiParser, type ConsolePrinter } from '@dxos/ai';
4
+ import { type Message } from '@dxos/types';
5
+ /**
6
+ * Live observer of the generation process.
7
+ */
8
+ export interface GenerationObserver<Tools extends Record<string, Tool.Any> = any> extends AiParser.ParseResponseCallbacks<Tools> {
9
+ /**
10
+ * Complete messages fired during the session, both from the model and from the user.
11
+ * This message will contain all message blocks emitted through the `onBlock` callback.
12
+ */
13
+ onMessage: (message: Message.Message) => Effect.Effect<void>;
14
+ }
15
+ export declare const GenerationObserver: Readonly<{
16
+ make: ({ onBegin, onPart, onBlock, onEnd, onMessage, }?: Partial<GenerationObserver>) => GenerationObserver;
17
+ noop: () => GenerationObserver<any>;
18
+ /**
19
+ * Debug printer to be used in unit-tests and browser devtools.
20
+ */
21
+ fromPrinter: (printer: ConsolePrinter) => GenerationObserver<any>;
22
+ }>;
23
+ //# sourceMappingURL=observer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observer.d.ts","sourceRoot":"","sources":["../../../../src/session/observer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAC9E,SAAQ,QAAQ,CAAC,sBAAsB,CAAC,KAAK,CAAC;IAC9C;;;OAGG;IACH,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CAC9D;AAED,eAAO,MAAM,kBAAkB;6DAO1B,OAAO,CAAC,kBAAkB,CAAC,KAAQ,kBAAkB;;IAUxD;;OAEG;2BACoB,cAAc;EAiBrC,CAAC"}
@@ -1,283 +1,56 @@
1
- import { Schema } from 'effect';
2
- import { type AgentStatus, type AiServiceClient, type GenerateRequest, Message, type ExecutableTool, type ToolId, type ToolResolver } from '@dxos/ai';
3
- import { type ArtifactDefinition } from '@dxos/artifact';
4
- import { Event } from '@dxos/async';
5
- import { ObjectVersion } from '@dxos/echo-db';
6
- import { type ObjectId } from '@dxos/echo-schema';
1
+ import type * as AiError from '@effect/ai/AiError';
2
+ import * as LanguageModel from '@effect/ai/LanguageModel';
3
+ import type * as Tool from '@effect/ai/Tool';
4
+ import type * as Toolkit from '@effect/ai/Toolkit';
5
+ import * as Effect from 'effect/Effect';
6
+ import type * as Schema from 'effect/Schema';
7
+ import { type AiToolNotFoundError, type PromptPreprocessingError, type ToolExecutionService, type ToolResolverService } from '@dxos/ai';
8
+ import { type Blueprint } from '@dxos/blueprints';
9
+ import { Obj } from '@dxos/echo';
10
+ import { type FunctionInvocationService, TracingService } from '@dxos/functions';
11
+ import { Message } from '@dxos/types';
12
+ import { type AiAssistantError } from '../errors';
13
+ import { GenerationObserver } from './observer';
14
+ export type AiSessionRunError = AiError.AiError | PromptPreprocessingError | AiToolNotFoundError | AiAssistantError;
15
+ export type AiSessionRunRequirements = LanguageModel.LanguageModel | ToolExecutionService | ToolResolverService | TracingService | FunctionInvocationService;
16
+ export type AiSessionOptions = {};
17
+ export type AiSessionRunProps<Tools extends Record<string, Tool.Any>> = {
18
+ prompt: string;
19
+ system?: string;
20
+ history?: Message.Message[];
21
+ objects?: Obj.Unknown[];
22
+ blueprints?: readonly Blueprint.Blueprint[];
23
+ toolkit?: Toolkit.WithHandler<Tools>;
24
+ observer?: GenerationObserver<Tools>;
25
+ };
7
26
  /**
8
27
  * Contains message history, tools, current context.
9
28
  * Current context means the state of the app, time of day, and other contextual information.
10
29
  * It makes requests to the model, its a state machine.
11
30
  * It keeps track of the current goal.
12
31
  * It manages the context window.
13
- * Tracks the success criteria of reaching the goal, exposing metrics (stretch)
32
+ * Tracks the success criteria of reaching the goal, exposing metrics (stretch).
14
33
  * Could be run locally in the app or remotely.
15
34
  * Could be personal or shared.
16
35
  */
17
- /**
18
- * Resolves artifact ids to their versions.
19
- * Used to give the model a sense of the changes to the artifacts made by users during the conversation.
20
- * The artifacts versions are pinned in the history, and whenever the artifact changes in-between assistant's steps,
21
- * a diff is inserted into the conversation.
22
- */
23
- export type ArtifactDiffResolver = (artifacts: {
24
- id: ObjectId;
25
- lastVersion: ObjectVersion;
26
- }[]) => Promise<Map<ObjectId, {
27
- version: ObjectVersion;
28
- diff?: string;
29
- }>>;
30
- export type SessionRunOptions = {
31
- artifacts: ArtifactDefinition[];
32
- /**
33
- * Non-artifact specific tools.
34
- */
35
- tools: ToolId[];
36
- history: Message[];
37
- prompt: string;
38
- generationOptions?: Pick<GenerateRequest, 'model'>;
39
- extensions?: ToolContextExtensions;
40
- systemPrompt?: string;
41
- /**
42
- * Pre-require artifacts.
43
- */
44
- requiredArtifactIds?: string[];
45
- client: AiServiceClient;
46
- toolResolver: ToolResolver;
47
- /**
48
- * Executable tools that do not go through the tool resolver.
49
- */
50
- executableTools?: ExecutableTool[];
51
- /**
52
- * @see ArtifactDiffResolver
53
- */
54
- artifactDiffResolver?: ArtifactDiffResolver;
55
- };
56
- type OperationModel = 'planning' | 'importing' | 'configured';
57
- export type AiSessionOptions = {
58
- /**
59
- * Determines the agent's handling of the artifacts definitions:
60
- *
61
- * - `planning`: The model will create a plan with required artifacts for each step.
62
- * - `importing`: The model can query registry and only pull in the artifacts that are required to complete the task.
63
- * - `configured`: The available artifacts are pre-selected and the model cannot select additional artifacts.
64
- */
65
- operationModel: OperationModel;
66
- };
67
- export declare class AISession {
36
+ export declare class AiSession {
68
37
  private readonly _options;
69
- /** SSE stream parser. */
70
- private readonly _parser;
71
- /** Pending messages (incl. the current user request). */
72
- private _pending;
73
- /** Current streaming response. */
74
- private _stream;
75
- /** Prior history from queue. */
38
+ /** Prevents concurrent execution of session. */
39
+ private readonly _semaphore;
40
+ /** Message history from queue. */
76
41
  private _history;
42
+ /** Pending messages for this session (incl. the current prompt). */
43
+ private _pending;
44
+ private _started;
45
+ private _ended;
46
+ private _toolCalls;
47
+ constructor(_options?: AiSessionOptions);
48
+ get duration(): number;
49
+ get toolCalls(): number;
50
+ run: <Tools extends Record<string, Tool.Any>>({ prompt, system: systemTemplate, history, objects, blueprints, toolkit, observer, }: AiSessionRunProps<Tools>) => Effect.Effect<Message.Message[], AiSessionRunError, AiSessionRunRequirements>;
77
51
  /**
78
- * New message.
79
- */
80
- readonly message: Event<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
81
- id: string;
82
- content: ({
83
- pending?: boolean | undefined;
84
- type: "text";
85
- text: string;
86
- disposition?: string | undefined;
87
- } | {
88
- pending?: boolean | undefined;
89
- type: "json";
90
- disposition?: string | undefined;
91
- json: string;
92
- } | {
93
- pending?: boolean | undefined;
94
- id?: string | undefined;
95
- type: "image";
96
- source?: {
97
- type: "base64";
98
- mediaType: string;
99
- data: string;
100
- } | undefined;
101
- } | {
102
- pending?: boolean | undefined;
103
- id: string;
104
- type: "tool_use";
105
- name: string;
106
- input: unknown;
107
- currentStatus?: {
108
- readonly id: string;
109
- message: string;
110
- } | undefined;
111
- } | {
112
- pending?: boolean | undefined;
113
- type: "tool_result";
114
- toolUseId: string;
115
- content: string;
116
- isError?: boolean | undefined;
117
- })[];
118
- role: "user" | "assistant";
119
- }>;
120
- /**
121
- * Complete block added to Message.
122
- */
123
- readonly block: Event<{
124
- pending?: boolean | undefined;
125
- type: "text";
126
- text: string;
127
- disposition?: string | undefined;
128
- } | {
129
- pending?: boolean | undefined;
130
- type: "json";
131
- disposition?: string | undefined;
132
- json: string;
133
- } | {
134
- pending?: boolean | undefined;
135
- id?: string | undefined;
136
- type: "image";
137
- source?: {
138
- type: "base64";
139
- mediaType: string;
140
- data: string;
141
- } | undefined;
142
- } | {
143
- pending?: boolean | undefined;
144
- id: string;
145
- type: "tool_use";
146
- name: string;
147
- input: unknown;
148
- currentStatus?: {
149
- readonly id: string;
150
- message: string;
151
- } | undefined;
152
- } | {
153
- pending?: boolean | undefined;
154
- type: "tool_result";
155
- toolUseId: string;
156
- content: string;
157
- isError?: boolean | undefined;
158
- }>;
159
- /**
160
- * Update partial block (while streaming).
161
- */
162
- readonly update: Event<{
163
- pending?: boolean | undefined;
164
- type: "text";
165
- text: string;
166
- disposition?: string | undefined;
167
- } | {
168
- pending?: boolean | undefined;
169
- type: "json";
170
- disposition?: string | undefined;
171
- json: string;
172
- } | {
173
- pending?: boolean | undefined;
174
- id?: string | undefined;
175
- type: "image";
176
- source?: {
177
- type: "base64";
178
- mediaType: string;
179
- data: string;
180
- } | undefined;
181
- } | {
182
- pending?: boolean | undefined;
183
- id: string;
184
- type: "tool_use";
185
- name: string;
186
- input: unknown;
187
- currentStatus?: {
188
- readonly id: string;
189
- message: string;
190
- } | undefined;
191
- } | {
192
- pending?: boolean | undefined;
193
- type: "tool_result";
194
- toolUseId: string;
195
- content: string;
196
- isError?: boolean | undefined;
197
- }>;
198
- /**
199
- * Unparsed events from the underlying generation stream.
200
- */
201
- readonly streamEvent: Event<import("@dxos/ai").GenerationStreamEvent>;
202
- /**
203
- * User prompt or tool result.
204
- */
205
- readonly userMessage: Event<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
206
- id: string;
207
- role: "user" | "assistant";
208
- content: ({
209
- pending?: boolean | undefined;
210
- type: "text";
211
- disposition?: string | undefined;
212
- text: string;
213
- } | {
214
- pending?: boolean | undefined;
215
- type: "json";
216
- disposition?: string | undefined;
217
- json: string;
218
- } | {
219
- pending?: boolean | undefined;
220
- id?: string | undefined;
221
- type: "image";
222
- source?: {
223
- type: "base64";
224
- mediaType: string;
225
- data: string;
226
- } | undefined;
227
- } | {
228
- pending?: boolean | undefined;
229
- id: string;
230
- name: string;
231
- type: "tool_use";
232
- input: unknown;
233
- currentStatus?: {
234
- readonly id: string;
235
- message: string;
236
- } | undefined;
237
- } | {
238
- pending?: boolean | undefined;
239
- type: "tool_result";
240
- content: string;
241
- toolUseId: string;
242
- isError?: boolean | undefined;
243
- })[];
244
- }>;
245
- /**
246
- * Agent self-reporting its status.
247
- * Triggered by the model.
248
- */
249
- readonly statusReport: Event<AgentStatus>;
250
- /**
251
- * Emits when the session is done.
252
- */
253
- readonly done: Event<void>;
254
- /**
255
- * Emits when the tool reports its status.
256
- * Triggered by the tool execution function.
257
- */
258
- readonly toolStatusReport: Event<{
259
- message: Message;
260
- status: AgentStatus;
261
- }>;
262
- constructor(_options: AiSessionOptions);
263
- /**
264
- * Runs the AI model loop interacting with tools and artifacts.
265
- * @param options - The session options.
266
- * @returns The messages generated by the session, including the user's prompt.
52
+ * @deprecated
267
53
  */
268
- run(options: SessionRunOptions): Promise<Message[]>;
269
- runStructured<S extends Schema.Schema.AnyNoContext>(schema: S, options: SessionRunOptions): Promise<Schema.Schema.Type<S>>;
270
- private _formatUserPrompt;
271
- private _createQueryArtifactsTool;
272
- private _createRequireTool;
273
- private _createPlanningTool;
274
- private _onToolStatusReport;
275
- abort(): void;
276
- }
277
- declare const AIServiecOverloadedError_base: Schema.TaggedErrorClass<AIServiecOverloadedError, "AIServiecOverloadedError", {
278
- readonly _tag: Schema.tag<"AIServiecOverloadedError">;
279
- }>;
280
- export declare class AIServiecOverloadedError extends AIServiecOverloadedError_base {
54
+ runStructured<S extends Schema.Schema.AnyNoContext>(_schema: S, _options: AiSessionRunProps<any>): Promise<Schema.Schema.Type<S>>;
281
55
  }
282
- export {};
283
56
  //# sourceMappingURL=session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/session/session.ts"],"names":[],"mappings":"AAIA,OAAO,EAAuB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErD,OAAO,EAIL,KAAK,WAAW,EAEhB,KAAK,eAAe,EAEpB,KAAK,eAAe,EACpB,OAAO,EAKP,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAgB,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAU,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAM1D;;;;;;;;;GASG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,SAAS,EAAE;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,WAAW,EAAE,aAAa,CAAA;CAAE,EAAE,KAAK,OAAO,CACvG,GAAG,CACD,QAAQ,EACR;IACE,OAAO,EAAE,aAAa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