@dxos/assistant 0.8.4-main.fd6878d → 0.8.4-main.fffef41

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 (122) hide show
  1. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  2. package/dist/lib/browser/extraction/index.mjs +121 -165
  3. package/dist/lib/browser/extraction/index.mjs.map +4 -4
  4. package/dist/lib/browser/index.mjs +1097 -161
  5. package/dist/lib/browser/index.mjs.map +4 -4
  6. package/dist/lib/browser/meta.json +1 -1
  7. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  8. package/dist/lib/node-esm/extraction/index.mjs +121 -165
  9. package/dist/lib/node-esm/extraction/index.mjs.map +4 -4
  10. package/dist/lib/node-esm/index.mjs +1097 -161
  11. package/dist/lib/node-esm/index.mjs.map +4 -4
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/types/src/conversation/context.d.ts +23 -10
  14. package/dist/types/src/conversation/context.d.ts.map +1 -1
  15. package/dist/types/src/conversation/conversation.d.ts +22 -31
  16. package/dist/types/src/conversation/conversation.d.ts.map +1 -1
  17. package/dist/types/src/diff.d.ts +15 -0
  18. package/dist/types/src/diff.d.ts.map +1 -0
  19. package/dist/types/src/diff.test.d.ts +2 -0
  20. package/dist/types/src/diff.test.d.ts.map +1 -0
  21. package/dist/types/src/errors.d.ts +45 -13
  22. package/dist/types/src/errors.d.ts.map +1 -1
  23. package/dist/types/src/execution-graph.d.ts +85 -0
  24. package/dist/types/src/execution-graph.d.ts.map +1 -0
  25. package/dist/types/src/execution-graph.test.d.ts +2 -0
  26. package/dist/types/src/execution-graph.test.d.ts.map +1 -0
  27. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +1 -1
  28. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -1
  29. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +82 -43
  30. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -1
  31. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -1
  32. package/dist/types/src/extraction/extraction.d.ts +262 -225
  33. package/dist/types/src/extraction/extraction.d.ts.map +1 -1
  34. package/dist/types/src/extraction/quotes.d.ts +1 -1
  35. package/dist/types/src/extraction/quotes.d.ts.map +1 -1
  36. package/dist/types/src/functions/services.d.ts +18 -5
  37. package/dist/types/src/functions/services.d.ts.map +1 -1
  38. package/dist/types/src/index.d.ts +3 -1
  39. package/dist/types/src/index.d.ts.map +1 -1
  40. package/dist/types/src/session/GenericToolkit.d.ts +84 -0
  41. package/dist/types/src/session/GenericToolkit.d.ts.map +1 -0
  42. package/dist/types/src/session/artifact-diff.d.ts +2 -2
  43. package/dist/types/src/session/artifact-diff.d.ts.map +1 -1
  44. package/dist/types/src/session/error-handling.d.ts +4 -0
  45. package/dist/types/src/session/error-handling.d.ts.map +1 -0
  46. package/dist/types/src/session/format.d.ts +5 -161
  47. package/dist/types/src/session/format.d.ts.map +1 -1
  48. package/dist/types/src/session/index.d.ts +3 -0
  49. package/dist/types/src/session/index.d.ts.map +1 -1
  50. package/dist/types/src/session/observer.d.ts +22 -0
  51. package/dist/types/src/session/observer.d.ts.map +1 -0
  52. package/dist/types/src/session/session.d.ts +22 -138
  53. package/dist/types/src/session/session.d.ts.map +1 -1
  54. package/dist/types/src/session/toolkit.d.ts +15 -0
  55. package/dist/types/src/session/toolkit.d.ts.map +1 -0
  56. package/dist/types/src/session/version-pin.d.ts +3 -3
  57. package/dist/types/src/session/version-pin.d.ts.map +1 -1
  58. package/dist/types/src/templates/system.d.ts +8 -12
  59. package/dist/types/src/templates/system.d.ts.map +1 -1
  60. package/dist/types/src/types/artifact.d.ts +20 -0
  61. package/dist/types/src/types/artifact.d.ts.map +1 -0
  62. package/dist/types/src/types/index.d.ts +2 -0
  63. package/dist/types/src/types/index.d.ts.map +1 -0
  64. package/dist/types/tsconfig.tsbuildinfo +1 -1
  65. package/package.json +29 -31
  66. package/src/conversation/context.ts +75 -22
  67. package/src/conversation/conversation.ts +80 -77
  68. package/src/diff.test.ts +43 -0
  69. package/src/diff.ts +84 -0
  70. package/src/errors.ts +6 -1
  71. package/src/execution-graph.test.ts +740 -0
  72. package/src/execution-graph.ts +509 -0
  73. package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +9 -9
  74. package/src/extraction/extraction-llm-function/extraction-llm-function.ts +47 -56
  75. package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +16 -16
  76. package/src/extraction/extraction-ner-function/extraction-ner-function.ts +42 -43
  77. package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +12 -6
  78. package/src/extraction/extraction-ner-function/named-entity-recognition.ts +2 -0
  79. package/src/extraction/extraction.ts +7 -6
  80. package/src/extraction/quotes.test.ts +2 -2
  81. package/src/extraction/quotes.ts +3 -3
  82. package/src/functions/services.ts +104 -56
  83. package/src/index.ts +3 -1
  84. package/src/session/GenericToolkit.ts +130 -0
  85. package/src/session/artifact-diff.ts +8 -4
  86. package/src/session/error-handling.ts +41 -0
  87. package/src/session/format.test.ts +5 -4
  88. package/src/session/format.ts +27 -22
  89. package/src/session/index.ts +4 -0
  90. package/src/session/observer.ts +59 -0
  91. package/src/session/session.conversations.json +1 -0
  92. package/src/session/session.test.ts +35 -191
  93. package/src/session/session.ts +119 -185
  94. package/src/session/toolkit.ts +48 -0
  95. package/src/session/version-pin.ts +4 -5
  96. package/src/templates/{format.tpl → instructions/format.tpl} +8 -2
  97. package/src/templates/{system.tpl → instructions/system.tpl} +15 -14
  98. package/src/templates/system.ts +25 -16
  99. package/src/{types.ts → types/artifact.ts} +22 -3
  100. package/src/types/index.ts +5 -0
  101. package/dist/lib/browser/chunk-6WRGDEMH.mjs +0 -89
  102. package/dist/lib/browser/chunk-6WRGDEMH.mjs.map +0 -7
  103. package/dist/lib/browser/chunk-NZGGCEF3.mjs +0 -341
  104. package/dist/lib/browser/chunk-NZGGCEF3.mjs.map +0 -7
  105. package/dist/lib/browser/named-entity-recognition-O46UTCLR.mjs +0 -13
  106. package/dist/lib/node-esm/chunk-3UU5V4FS.mjs +0 -91
  107. package/dist/lib/node-esm/chunk-3UU5V4FS.mjs.map +0 -7
  108. package/dist/lib/node-esm/chunk-XOOPGSGW.mjs +0 -343
  109. package/dist/lib/node-esm/chunk-XOOPGSGW.mjs.map +0 -7
  110. package/dist/lib/node-esm/named-entity-recognition-W4VMRCH6.mjs +0 -14
  111. package/dist/types/src/session/version-pin.test.d.ts +0 -2
  112. package/dist/types/src/session/version-pin.test.d.ts.map +0 -1
  113. package/dist/types/src/summarization/summarization.test.d.ts +0 -2
  114. package/dist/types/src/summarization/summarization.test.d.ts.map +0 -1
  115. package/dist/types/src/types.d.ts +0 -16
  116. package/dist/types/src/types.d.ts.map +0 -1
  117. package/src/session/__snapshots__/session.test.ts.snap +0 -32
  118. package/src/session/version-pin.test.ts +0 -7
  119. package/src/summarization/summarization.test.ts +0 -197
  120. /package/dist/lib/browser/{named-entity-recognition-O46UTCLR.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
  121. /package/dist/lib/node-esm/{named-entity-recognition-W4VMRCH6.mjs.map → chunk-HSLMI22Q.mjs.map} +0 -0
  122. /package/src/extraction/extraction-llm-function/{instructions.tpl → transcription-instructions.tpl} +0 -0
@@ -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;AAIxC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,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,7 +1,20 @@
1
- import { AiTool, type AiToolkit } from '@effect/ai';
2
- import { Layer } from 'effect';
1
+ import * as Tool from '@effect/ai/Tool';
2
+ import type * as Toolkit from '@effect/ai/Toolkit';
3
+ import * as Layer from 'effect/Layer';
3
4
  import { ToolExecutionService, ToolResolverService } from '@dxos/ai';
4
- import { type FunctionDefinition, LocalFunctionExecutionService } from '@dxos/functions';
5
- export declare const makeToolResolverFromFunctions: (functions: FunctionDefinition<any, any>[], toolkit: AiToolkit.Any) => Layer.Layer<ToolResolverService>;
6
- export declare const makeToolExecutionServiceFromFunctions: (functions: FunctionDefinition<any, any>[], toolkit: AiToolkit.AiToolkit<AiTool.Any>, handlersLayer: Layer.Layer<AiTool.ToHandler<AiTool.AiTool<any>>, never, never>) => Layer.Layer<ToolExecutionService, never, LocalFunctionExecutionService>;
5
+ import { DatabaseService } from '@dxos/echo-db';
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 `DatabaseService` in the environment.
17
+ */
18
+ export declare const makeToolResolverFromFunctions: (functions: FunctionDefinition.Any[], toolkit: Toolkit.Toolkit<any>) => Layer.Layer<ToolResolverService, never, DatabaseService>;
19
+ export declare const makeToolExecutionServiceFromFunctions: (toolkit: Toolkit.Toolkit<any>, handlersLayer: Layer.Layer<Tool.Handler<any>, never, never>) => Layer.Layer<ToolExecutionService, never, FunctionInvocationService>;
7
20
  //# sourceMappingURL=services.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../../src/functions/services.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAmB,KAAK,EAAoC,MAAM,QAAQ,CAAC;AAElF,OAAO,EAAuB,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC1F,OAAO,EAAE,KAAK,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAGzF,eAAO,MAAM,6BAA6B,GACxC,WAAW,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EACzC,SAAS,SAAS,CAAC,GAAG,KACrB,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAgBjC,CAAC;AAEF,eAAO,MAAM,qCAAqC,GAChD,WAAW,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EACzC,SAAS,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EACxC,eAAe,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAC7E,KAAK,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,EAAE,6BAA6B,CAiCxE,CAAC"}
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;AAItC,OAAO,EAAuB,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG1F,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAY,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAG1F;;;;;;;;;;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,eAAe,CA8BzD,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,CAoCpE,CAAC"}
@@ -1,7 +1,9 @@
1
1
  export * from './conversation';
2
+ export * from './diff';
3
+ export * from './errors';
4
+ export * from './execution-graph';
2
5
  export * from './functions';
3
6
  export * from './session';
4
7
  export * from './templates';
5
8
  export * from './types';
6
- export * from './errors';
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,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,84 @@
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
+ }, R>>;
74
+ export interface AnyStructSchemaNoContext extends Pipeable.Pipeable {
75
+ readonly [Schema.TypeId]: any;
76
+ readonly make: any;
77
+ readonly Type: any;
78
+ readonly Encoded: any;
79
+ readonly Context: never;
80
+ readonly ast: SchemaAST.AST;
81
+ readonly fields: Schema.Struct.Fields;
82
+ readonly annotations: any;
83
+ }
84
+ //# 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,iBAAiB,CAAC;AAC7C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAEnC;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,KAAK,CAAE,SAAQ,QAAQ,CAAC,QAAQ;IACzF,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC;IAEpD;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAE3C;;OAEG;IACH,QAAQ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AEF;;GAEG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,CAAC,QAAQ,SAAS,aAAa,CAAC,GAAG,CAAC;AAC7D;;GAEG;AACH,GAAG,UAAU,QAAQ,KACpB,cAAc,CACf,sBAAsB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EACzB,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAM/B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,KAAK,IAAI,MAAM,CAC1C,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;CACvC,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"}
@@ -1,6 +1,6 @@
1
- import { Context } from 'effect';
1
+ import * as Context from 'effect/Context';
2
+ import { type ObjectId } from '@dxos/echo/internal';
2
3
  import { type ObjectVersion } from '@dxos/echo-db';
3
- import { type ObjectId } from '@dxos/echo-schema';
4
4
  declare const ArtifactDiffResolver_base: Context.TagClass<ArtifactDiffResolver, "@dxos/assistant/ArtifactDiffResolver", ArtifactDiffResolver.Service>;
5
5
  /**
6
6
  * Resolves artifact ids to their versions.
@@ -1 +1 @@
1
- {"version":3,"file":"artifact-diff.d.ts","sourceRoot":"","sources":["../../../../src/session/artifact-diff.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;;AAElD;;;;;;;GAOG;AAGH,qBAAa,oBAAqB,SAAQ,yBAGvC;CAAG;AAEN,yBAAiB,oBAAoB,CAAC;IACpC,KAAY,OAAO,GAAG;QACpB,OAAO,EAAE,CAAC,SAAS,EAAE;YAAE,EAAE,EAAE,QAAQ,CAAC;YAAC,WAAW,EAAE,aAAa,CAAA;SAAE,EAAE,KAAK,OAAO,CAC7E,GAAG,CACD,QAAQ,EACR;YACE,OAAO,EAAE,aAAa,CAAC;YACvB,IAAI,CAAC,EAAE,MAAM,CAAC;SACf,CACF,CACF,CAAC;KACH,CAAC;CACH"}
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,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;;AAEnD;;;;;;;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"}
@@ -1,168 +1,12 @@
1
- import { Effect } from 'effect';
2
- import { type SessionRunParams } from './session';
1
+ import * as Effect from 'effect/Effect';
2
+ import { Message } from '@dxos/types';
3
+ import { type AiSessionRunError, type AiSessionRunParams } from './session';
3
4
  /**
4
5
  * Formats the system prompt.
5
6
  */
6
- export declare const formatSystemPrompt: ({ system, blueprints, objects, }: Pick<SessionRunParams<any>, "system" | "blueprints" | "objects">) => Effect.Effect<string, never, never>;
7
+ export declare const formatSystemPrompt: ({ system, blueprints, objects, }: Pick<AiSessionRunParams<any>, "system" | "blueprints" | "objects">) => Effect.Effect<string, never, never>;
7
8
  /**
8
9
  * Formats the user prompt.
9
10
  */
10
- export declare const formatUserPrompt: ({ prompt, history }: Pick<SessionRunParams<any>, "prompt" | "history">) => Effect.Effect<import("@dxos/live-object").Live<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
11
- id: string;
12
- parentMessage?: string | undefined;
13
- created: string;
14
- sender: {
15
- name?: string | undefined;
16
- contact?: import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
17
- fields?: {
18
- readonly value: string;
19
- readonly category?: string | undefined;
20
- readonly label: string;
21
- }[] | undefined;
22
- image?: string | undefined;
23
- fullName?: string | undefined;
24
- preferredName?: string | undefined;
25
- nickname?: string | undefined;
26
- organization?: import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
27
- id: string;
28
- name?: string | undefined;
29
- description?: string | undefined;
30
- status?: "prospect" | "qualified" | "active" | "commit" | "reject" | undefined;
31
- image?: string | undefined;
32
- website?: string | undefined;
33
- }> | undefined;
34
- jobTitle?: string | undefined;
35
- department?: string | undefined;
36
- notes?: string | undefined;
37
- emails?: {
38
- readonly value: string;
39
- readonly label?: string | undefined;
40
- }[] | undefined;
41
- identities?: {
42
- readonly value: string;
43
- readonly label?: string | undefined;
44
- }[] | undefined;
45
- phoneNumbers?: {
46
- readonly value: string;
47
- readonly label?: string | undefined;
48
- }[] | undefined;
49
- addresses?: {
50
- readonly value: {
51
- readonly street?: string | undefined;
52
- readonly extended?: string | undefined;
53
- readonly locality?: string | undefined;
54
- readonly region?: string | undefined;
55
- readonly postalCode?: string | undefined;
56
- readonly postOfficeBoxNumber?: string | undefined;
57
- readonly country?: string | undefined;
58
- };
59
- readonly label?: string | undefined;
60
- }[] | undefined;
61
- urls?: {
62
- readonly value: string;
63
- readonly label?: string | undefined;
64
- }[] | undefined;
65
- birthday?: string | undefined;
66
- }> | undefined;
67
- identityDid?: string | undefined;
68
- identityKey?: string | undefined;
69
- email?: string | undefined;
70
- role?: "user" | "assistant" | undefined;
71
- };
72
- blocks: ({
73
- version: unknown;
74
- _tag: "anchor";
75
- pending?: boolean | undefined;
76
- objectId: string;
77
- } | {
78
- name?: string | undefined;
79
- _tag: "file";
80
- pending?: boolean | undefined;
81
- url: string;
82
- mediaType?: string | undefined;
83
- } | {
84
- source?: {
85
- mediaType: string;
86
- type: "base64";
87
- data: string;
88
- } | {
89
- url: string;
90
- type: "http";
91
- } | undefined;
92
- id?: string | undefined;
93
- _tag: "image";
94
- pending?: boolean | undefined;
95
- } | {
96
- _tag: "json";
97
- pending?: boolean | undefined;
98
- data: string;
99
- disposition?: string | undefined;
100
- } | {
101
- text: string;
102
- _tag: "proposal";
103
- pending?: boolean | undefined;
104
- } | {
105
- _tag: "reasoning";
106
- pending?: boolean | undefined;
107
- reasoningText?: string | undefined;
108
- redactedText?: string | undefined;
109
- signature?: string | undefined;
110
- } | {
111
- reference: import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").Expando>;
112
- _tag: "reference";
113
- pending?: boolean | undefined;
114
- } | {
115
- _tag: "select";
116
- pending?: boolean | undefined;
117
- options: readonly string[];
118
- } | {
119
- _tag: "status";
120
- pending?: boolean | undefined;
121
- statusText: string;
122
- } | {
123
- text: string;
124
- _tag: "suggest";
125
- pending?: boolean | undefined;
126
- } | {
127
- text: string;
128
- _tag: "text";
129
- pending?: boolean | undefined;
130
- disposition?: string | undefined;
131
- mimeType?: string | undefined;
132
- } | {
133
- _tag: "toolkit";
134
- pending?: boolean | undefined;
135
- } | {
136
- name: string;
137
- _tag: "toolCall";
138
- pending?: boolean | undefined;
139
- toolCallId: string;
140
- input: unknown;
141
- } | {
142
- name: string;
143
- _tag: "toolResult";
144
- pending?: boolean | undefined;
145
- toolCallId: string;
146
- result: unknown;
147
- error?: string | undefined;
148
- } | {
149
- text: string;
150
- _tag: "transcript";
151
- pending?: boolean | undefined;
152
- started: string;
153
- })[];
154
- properties?: {
155
- [x: string]: any;
156
- } | undefined;
157
- }>, {
158
- #code: "AI_ASSISTANT_ERROR";
159
- #context: Record<string, unknown>;
160
- readonly name: "AI_ASSISTANT_ERROR";
161
- readonly code: "AI_ASSISTANT_ERROR";
162
- readonly _tag: "AI_ASSISTANT_ERROR";
163
- readonly context: Record<string, unknown>;
164
- message: string;
165
- stack?: string;
166
- cause?: unknown;
167
- }, never>;
11
+ export declare const formatUserPrompt: ({ prompt, history, }: Pick<AiSessionRunParams<any>, "prompt" | "history">) => Effect.Effect<Message.Message, AiSessionRunError>;
168
12
  //# sourceMappingURL=format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../src/session/format.ts"],"names":[],"mappings":"AAIA,OAAO,EAAS,MAAM,EAAgB,MAAM,QAAQ,CAAC;AAcrD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD;;GAEG;AAEH,eAAO,MAAM,kBAAkB,GAAI,kCAIhC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAC,wCAsC/D,CAAC;AAEL;;GAEG;AAGH,eAAO,MAAM,gBAAgB,GAAI,qBAA0B,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAoCxG,CAAC"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../src/session/format.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AASxC,OAAO,EAAqB,OAAO,EAAE,MAAM,aAAa,CAAC;AAMzD,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE5E;;GAEG;AAEH,eAAO,MAAM,kBAAkB,GAAI,kCAIhC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAC,wCAsCjE,CAAC;AAEL;;GAEG;AAGH,eAAO,MAAM,gBAAgB,GAAI,sBAG9B,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAoCrG,CAAC"}
@@ -1,4 +1,7 @@
1
1
  export * from './artifact-diff';
2
+ export * from './observer';
2
3
  export * from './session';
4
+ export * from './toolkit';
3
5
  export * from './version-pin';
6
+ export * as GenericToolkit from './GenericToolkit';
4
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,iBAAiB,CAAC;AAChC,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,22 @@
1
+ import * as Effect from 'effect/Effect';
2
+ import { type AiParser, type ConsolePrinter } from '@dxos/ai';
3
+ import { type Message } from '@dxos/types';
4
+ /**
5
+ * Live observer of the generation process.
6
+ */
7
+ export interface GenerationObserver extends AiParser.ParseResponseCallbacks {
8
+ /**
9
+ * Complete messages fired during the session, both from the model and from the user.
10
+ * This message will contain all message blocks emitted through the `onBlock` callback.
11
+ */
12
+ onMessage: (message: Message.Message) => Effect.Effect<void>;
13
+ }
14
+ export declare const GenerationObserver: Readonly<{
15
+ make: ({ onBegin, onPart, onBlock, onEnd, onMessage, }?: Partial<GenerationObserver>) => GenerationObserver;
16
+ noop: () => GenerationObserver;
17
+ /**
18
+ * Debug printer to be used in unit-tests and browser devtools.
19
+ */
20
+ fromPrinter: (printer: ConsolePrinter) => GenerationObserver;
21
+ }>;
22
+ //# 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,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,kBAAmB,SAAQ,QAAQ,CAAC,sBAAsB;IACzE;;;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,53 +1,28 @@
1
- import { type AiError, AiLanguageModel, type AiResponse, type AiTool, AiToolkit } from '@effect/ai';
2
- import { Effect, Option, Queue, type Schema } from 'effect';
3
- import { type AiInputPreprocessingError, type AiToolNotFoundError, type ConsolePrinter, ToolExecutionService, ToolResolverService } from '@dxos/ai';
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';
4
8
  import { type Blueprint } from '@dxos/blueprints';
5
9
  import { Obj } from '@dxos/echo';
6
- import { type ContentBlock, DataType } from '@dxos/schema';
10
+ import { TracingService } from '@dxos/functions';
11
+ import { Message } from '@dxos/types';
7
12
  import { type AiAssistantError } from '../errors';
8
- export type AiSessionOptions = {};
9
- /**
10
- * Live observer of the generation process.
11
- */
12
- export interface GenerationObserver {
13
- /**
14
- * Unparsed content block parts from the model.
15
- */
16
- onPart: (part: AiResponse.Part) => Effect.Effect<void>;
17
- /**
18
- * Parsed content blocks from the model.
19
- * NOTE: Use block.pending to determine if the block was completed.
20
- * For each block this will be called 0..n times with a pending block and then once with the final state of the block.
21
- *
22
- * Example:
23
- * 1. { pending: true, text: "Hello"}
24
- * 2. { pending: true, text: "Hello, I am a"}
25
- * 3. { pending: false, text: "Hello, I am a helpful assistant!"}
26
- */
27
- onBlock: (block: ContentBlock.Any) => Effect.Effect<void>;
28
- /**
29
- * Complete messages fired during the session, both from the model and from the user.
30
- * This message will contain all message blocks emitted through the `onBlock` callback.
31
- */
32
- onMessage: (message: DataType.Message) => Effect.Effect<void>;
33
- }
34
- export declare const GenerationObserver: Readonly<{
35
- make: ({ onPart, onBlock, onMessage, }?: Partial<GenerationObserver>) => GenerationObserver;
36
- noop: () => GenerationObserver;
37
- /**
38
- * Debug printer to be used in unit-tests and browser devtools.
39
- */
40
- fromPrinter: (printer: ConsolePrinter) => GenerationObserver;
41
- }>;
42
- export type SessionRunParams<Tools extends AiTool.Any> = {
13
+ import { GenerationObserver } from './observer';
14
+ export type AiSessionRunError = AiError.AiError | PromptPreprocessingError | AiToolNotFoundError | AiAssistantError;
15
+ export type AiSessionRunRequirements = LanguageModel.LanguageModel | ToolExecutionService | ToolResolverService | TracingService;
16
+ export type AiSessionRunParams<Tools extends Record<string, Tool.Any>> = {
43
17
  prompt: string;
44
18
  system?: string;
45
- history?: DataType.Message[];
19
+ history?: Message.Message[];
46
20
  objects?: Obj.Any[];
47
21
  blueprints?: Blueprint.Blueprint[];
48
- toolkit?: AiToolkit.AiToolkit<Tools>;
22
+ toolkit?: Toolkit.WithHandler<Tools>;
49
23
  observer?: GenerationObserver;
50
24
  };
25
+ export type AiSessionOptions = {};
51
26
  /**
52
27
  * Contains message history, tools, current context.
53
28
  * Current context means the state of the app, time of day, and other contextual information.
@@ -60,108 +35,17 @@ export type SessionRunParams<Tools extends AiTool.Any> = {
60
35
  */
61
36
  export declare class AiSession {
62
37
  private readonly _options;
63
- /** Complete messages fired during the session, both from the model and from the user. */
64
- readonly messageQueue: Queue.Queue<import("@dxos/schema").Message>;
65
- /**
66
- * Blocks streaming from the model during the session.
67
- * @deprecated Use `observer.onBlock` instead.
68
- */
69
- readonly blockQueue: Queue.Queue<Option.Option<{
70
- version: unknown;
71
- _tag: "anchor";
72
- pending?: boolean | undefined;
73
- objectId: string;
74
- } | {
75
- name?: string | undefined;
76
- _tag: "file";
77
- pending?: boolean | undefined;
78
- url: string;
79
- mediaType?: string | undefined;
80
- } | {
81
- source?: {
82
- mediaType: string;
83
- type: "base64";
84
- data: string;
85
- } | {
86
- url: string;
87
- type: "http";
88
- } | undefined;
89
- id?: string | undefined;
90
- _tag: "image";
91
- pending?: boolean | undefined;
92
- } | {
93
- _tag: "json";
94
- pending?: boolean | undefined;
95
- data: string;
96
- disposition?: string | undefined;
97
- } | {
98
- text: string;
99
- _tag: "proposal";
100
- pending?: boolean | undefined;
101
- } | {
102
- _tag: "reasoning";
103
- pending?: boolean | undefined;
104
- reasoningText?: string | undefined;
105
- redactedText?: string | undefined;
106
- signature?: string | undefined;
107
- } | {
108
- reference: import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").Expando>;
109
- _tag: "reference";
110
- pending?: boolean | undefined;
111
- } | {
112
- _tag: "select";
113
- pending?: boolean | undefined;
114
- options: readonly string[];
115
- } | {
116
- _tag: "status";
117
- pending?: boolean | undefined;
118
- statusText: string;
119
- } | {
120
- text: string;
121
- _tag: "suggest";
122
- pending?: boolean | undefined;
123
- } | {
124
- text: string;
125
- _tag: "text";
126
- pending?: boolean | undefined;
127
- disposition?: string | undefined;
128
- mimeType?: string | undefined;
129
- } | {
130
- _tag: "toolkit";
131
- pending?: boolean | undefined;
132
- } | {
133
- name: string;
134
- _tag: "toolCall";
135
- pending?: boolean | undefined;
136
- toolCallId: string;
137
- input: unknown;
138
- } | {
139
- name: string;
140
- _tag: "toolResult";
141
- pending?: boolean | undefined;
142
- toolCallId: string;
143
- result: unknown;
144
- error?: string | undefined;
145
- } | {
146
- text: string;
147
- _tag: "transcript";
148
- pending?: boolean | undefined;
149
- started: string;
150
- }>>;
151
- /** Unparsed events from the underlying generation stream. */
152
- readonly eventQueue: Queue.Queue<AiResponse.TextPart | AiResponse.ReasoningPart | AiResponse.RedactedReasoningPart | AiResponse.ToolCallPart | AiResponse.MetadataPart | AiResponse.FinishPart>;
153
38
  /** Prevents concurrent execution of session. */
154
39
  private readonly _semaphore;
155
- /** Pending messages (incl. the current user request). */
156
- private _pending;
157
- /** Prior history from queue. */
40
+ /** Message history from queue. */
158
41
  private _history;
42
+ /** Pending messages for this session (incl. the current prompt). */
43
+ private _pending;
159
44
  constructor(_options?: AiSessionOptions);
45
+ run: <Tools extends Record<string, Tool.Any>>({ prompt, system: systemTemplate, history, objects, blueprints, toolkit, observer, }: AiSessionRunParams<Tools>) => Effect.Effect<Message.Message[], AiSessionRunError, AiSessionRunRequirements>;
160
46
  /**
161
- * Runs the AI model loop interacting with tools and artifacts.
162
- * @returns The messages generated by the session, including the user's prompt.
47
+ * @deprecated
163
48
  */
164
- run: <Tools extends AiTool.Any>(params: SessionRunParams<Tools>) => Effect.Effect<DataType.Message[], AiAssistantError | AiInputPreprocessingError | AiToolNotFoundError | AiError.AiError, AiLanguageModel.AiLanguageModel | ToolResolverService | ToolExecutionService | AiTool.ToHandler<Tools>>;
165
- runStructured<S extends Schema.Schema.AnyNoContext>(_schema: S, _options: SessionRunParams<AiTool.Any>): Promise<Schema.Schema.Type<S>>;
49
+ runStructured<S extends Schema.Schema.AnyNoContext>(_schema: S, _options: AiSessionRunParams<any>): Promise<Schema.Schema.Type<S>>;
166
50
  }
167
51
  //# sourceMappingURL=session.d.ts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
2
+ import * as Toolkit from '@effect/ai/Toolkit';
3
+ import * as Effect from 'effect/Effect';
4
+ import { type AiToolNotFoundError, ToolExecutionService, type ToolId, ToolResolverService } from '@dxos/ai';
5
+ import { type Blueprint } from '@dxos/blueprints';
6
+ export type ToolkitParams<Tools extends Record<string, Tool.Any>> = {
7
+ toolkit?: Toolkit.Toolkit<Tools>;
8
+ toolIds?: ToolId[];
9
+ blueprints?: Blueprint.Blueprint[];
10
+ };
11
+ /**
12
+ * Build a combined toolkit from the blueprint tools and the provided toolkit.
13
+ */
14
+ export declare const createToolkit: <Tools extends Record<string, Tool.Any> = {}>({ toolkit: toolkitParam, toolIds, blueprints, }: ToolkitParams<Tools>) => Effect.Effect<Toolkit.WithHandler<any>, AiToolNotFoundError, ToolResolverService | ToolExecutionService | Tool.HandlersFor<Tools>>;
15
+ //# sourceMappingURL=toolkit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolkit.d.ts","sourceRoot":"","sources":["../../../../src/session/toolkit.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAE9C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,KAAK,mBAAmB,EAAE,oBAAoB,EAAE,KAAK,MAAM,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC5G,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI;IAClE,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,iDAIxE,aAAa,CAAC,KAAK,CAAC,KAAG,MAAM,CAAC,MAAM,CACrC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,EACxB,mBAAmB,EACnB,mBAAmB,GAAG,oBAAoB,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAkBlE,CAAC"}
@@ -1,7 +1,7 @@
1
- import { Schema } from 'effect';
1
+ import * as Schema from 'effect/Schema';
2
+ import { type AnyEchoObject } from '@dxos/echo/internal';
2
3
  import { type ObjectVersion } from '@dxos/echo-db';
3
- import { type AnyEchoObject } from '@dxos/echo-schema';
4
- import { type ContentBlock } from '@dxos/schema';
4
+ import { type ContentBlock } from '@dxos/types';
5
5
  declare const VersionPinSchema: Schema.Struct<{
6
6
  objectId: import("@dxos/keys").ObjectIdClass;
7
7
  version: Schema.Schema<ObjectVersion, ObjectVersion, never>;