@dxos/assistant 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8

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 (183) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +2 -1
  3. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  4. package/dist/lib/neutral/extraction/index.mjs +208 -0
  5. package/dist/lib/neutral/extraction/index.mjs.map +7 -0
  6. package/dist/lib/neutral/index.mjs +1886 -0
  7. package/dist/lib/neutral/index.mjs.map +7 -0
  8. package/dist/lib/neutral/meta.json +1 -0
  9. package/dist/types/src/extraction/extraction-ner-function/index.d.ts +0 -1
  10. package/dist/types/src/extraction/extraction-ner-function/index.d.ts.map +1 -1
  11. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -1
  12. package/dist/types/src/extraction/extraction.d.ts +1650 -281
  13. package/dist/types/src/extraction/extraction.d.ts.map +1 -1
  14. package/dist/types/src/extraction/index.d.ts +0 -1
  15. package/dist/types/src/extraction/index.d.ts.map +1 -1
  16. package/dist/types/src/extraction/quotes.d.ts +3 -3
  17. package/dist/types/src/extraction/quotes.d.ts.map +1 -1
  18. package/dist/types/src/functions/services.d.ts +16 -5
  19. package/dist/types/src/functions/services.d.ts.map +1 -1
  20. package/dist/types/src/index.d.ts +2 -3
  21. package/dist/types/src/index.d.ts.map +1 -1
  22. package/dist/types/src/request/AiRequest.d.ts +308 -0
  23. package/dist/types/src/request/AiRequest.d.ts.map +1 -0
  24. package/dist/types/src/{session → request}/artifact-diff.d.ts +5 -5
  25. package/dist/types/src/request/artifact-diff.d.ts.map +1 -0
  26. package/dist/types/src/request/format.d.ts +15 -0
  27. package/dist/types/src/request/format.d.ts.map +1 -0
  28. package/dist/types/src/request/index.d.ts +4 -0
  29. package/dist/types/src/request/index.d.ts.map +1 -0
  30. package/dist/types/src/request/observer.d.ts +23 -0
  31. package/dist/types/src/request/observer.d.ts.map +1 -0
  32. package/dist/types/src/{session → request}/version-pin.d.ts +6 -6
  33. package/dist/types/src/request/version-pin.d.ts.map +1 -0
  34. package/dist/types/src/session/AiContext.d.ts +178 -0
  35. package/dist/types/src/session/AiContext.d.ts.map +1 -0
  36. package/dist/types/src/session/AiContext.test.d.ts +2 -0
  37. package/dist/types/src/session/AiContext.test.d.ts.map +1 -0
  38. package/dist/types/src/session/AiSession.d.ts +79 -0
  39. package/dist/types/src/session/AiSession.d.ts.map +1 -0
  40. package/dist/types/src/session/AiSession.test.d.ts +2 -0
  41. package/dist/types/src/session/AiSession.test.d.ts.map +1 -0
  42. package/dist/types/src/session/SessionLink.d.ts +17 -0
  43. package/dist/types/src/session/SessionLink.d.ts.map +1 -0
  44. package/dist/types/src/session/SessionLoader.d.ts +15 -0
  45. package/dist/types/src/session/SessionLoader.d.ts.map +1 -0
  46. package/dist/types/src/session/SessionLoader.test.d.ts +2 -0
  47. package/dist/types/src/session/SessionLoader.test.d.ts.map +1 -0
  48. package/dist/types/src/session/index.d.ts +5 -3
  49. package/dist/types/src/session/index.d.ts.map +1 -1
  50. package/dist/types/src/session/toolkit.d.ts +16 -0
  51. package/dist/types/src/session/toolkit.d.ts.map +1 -0
  52. package/dist/types/src/templates/system.d.ts +19 -14
  53. package/dist/types/src/templates/system.d.ts.map +1 -1
  54. package/dist/types/src/util/artifact.d.ts +18 -0
  55. package/dist/types/src/util/artifact.d.ts.map +1 -0
  56. package/dist/types/src/util/diff.d.ts +17 -0
  57. package/dist/types/src/util/diff.d.ts.map +1 -0
  58. package/dist/types/src/util/diff.test.d.ts +2 -0
  59. package/dist/types/src/util/diff.test.d.ts.map +1 -0
  60. package/dist/types/src/util/error-handling.d.ts +4 -0
  61. package/dist/types/src/util/error-handling.d.ts.map +1 -0
  62. package/dist/types/src/util/errors.d.ts +67 -0
  63. package/dist/types/src/util/errors.d.ts.map +1 -0
  64. package/dist/types/src/util/execution-graph.d.ts +85 -0
  65. package/dist/types/src/util/execution-graph.d.ts.map +1 -0
  66. package/dist/types/src/util/execution-graph.test.d.ts +2 -0
  67. package/dist/types/src/util/execution-graph.test.d.ts.map +1 -0
  68. package/dist/types/src/util/index.d.ts +7 -0
  69. package/dist/types/src/util/index.d.ts.map +1 -0
  70. package/dist/types/src/util/tracing.d.ts +296 -0
  71. package/dist/types/src/util/tracing.d.ts.map +1 -0
  72. package/dist/types/tsconfig.tsbuildinfo +1 -1
  73. package/package.json +37 -47
  74. package/src/extraction/extraction-ner-function/index.ts +0 -1
  75. package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +12 -6
  76. package/src/extraction/extraction-ner-function/named-entity-recognition.ts +2 -0
  77. package/src/extraction/extraction.ts +49 -19
  78. package/src/extraction/index.ts +0 -1
  79. package/src/extraction/quotes.test.ts +2 -2
  80. package/src/extraction/quotes.ts +7 -9
  81. package/src/functions/services.ts +180 -66
  82. package/src/index.ts +2 -3
  83. package/src/request/AiRequest.ts +387 -0
  84. package/src/{session → request}/artifact-diff.ts +10 -6
  85. package/src/{session → request}/format.ts +45 -37
  86. package/src/request/index.ts +8 -0
  87. package/src/request/observer.ts +62 -0
  88. package/src/{session → request}/version-pin.ts +8 -8
  89. package/src/session/AiContext.test.ts +49 -0
  90. package/src/session/AiContext.ts +420 -0
  91. package/src/session/AiSession.test.ts +111 -0
  92. package/src/session/AiSession.ts +328 -0
  93. package/src/session/SessionLink.ts +23 -0
  94. package/src/session/SessionLoader.test.ts +115 -0
  95. package/src/session/SessionLoader.ts +55 -0
  96. package/src/session/index.ts +6 -3
  97. package/src/session/toolkit.ts +47 -0
  98. package/src/templates/{format.tpl → instructions/format.tpl} +6 -4
  99. package/src/templates/instructions/system.tpl +96 -0
  100. package/src/templates/system.ts +26 -16
  101. package/src/util/artifact.ts +96 -0
  102. package/src/util/diff.test.ts +74 -0
  103. package/src/util/diff.ts +93 -0
  104. package/src/util/error-handling.ts +42 -0
  105. package/src/util/errors.ts +15 -0
  106. package/src/util/execution-graph.test.ts +740 -0
  107. package/src/util/execution-graph.ts +520 -0
  108. package/src/util/index.ts +10 -0
  109. package/src/util/tracing.ts +60 -0
  110. package/dist/lib/browser/chunk-6WRGDEMH.mjs +0 -89
  111. package/dist/lib/browser/chunk-6WRGDEMH.mjs.map +0 -7
  112. package/dist/lib/browser/chunk-NZGGCEF3.mjs +0 -341
  113. package/dist/lib/browser/chunk-NZGGCEF3.mjs.map +0 -7
  114. package/dist/lib/browser/extraction/index.mjs +0 -269
  115. package/dist/lib/browser/extraction/index.mjs.map +0 -7
  116. package/dist/lib/browser/index.mjs +0 -354
  117. package/dist/lib/browser/index.mjs.map +0 -7
  118. package/dist/lib/browser/meta.json +0 -1
  119. package/dist/lib/browser/named-entity-recognition-O46UTCLR.mjs +0 -13
  120. package/dist/lib/node-esm/chunk-3UU5V4FS.mjs +0 -91
  121. package/dist/lib/node-esm/chunk-3UU5V4FS.mjs.map +0 -7
  122. package/dist/lib/node-esm/chunk-XOOPGSGW.mjs +0 -343
  123. package/dist/lib/node-esm/chunk-XOOPGSGW.mjs.map +0 -7
  124. package/dist/lib/node-esm/extraction/index.mjs +0 -270
  125. package/dist/lib/node-esm/extraction/index.mjs.map +0 -7
  126. package/dist/lib/node-esm/index.mjs +0 -355
  127. package/dist/lib/node-esm/index.mjs.map +0 -7
  128. package/dist/lib/node-esm/meta.json +0 -1
  129. package/dist/lib/node-esm/named-entity-recognition-W4VMRCH6.mjs +0 -14
  130. package/dist/lib/node-esm/named-entity-recognition-W4VMRCH6.mjs.map +0 -7
  131. package/dist/types/src/conversation/context.d.ts +0 -90
  132. package/dist/types/src/conversation/context.d.ts.map +0 -1
  133. package/dist/types/src/conversation/conversation.d.ts +0 -50
  134. package/dist/types/src/conversation/conversation.d.ts.map +0 -1
  135. package/dist/types/src/conversation/index.d.ts +0 -3
  136. package/dist/types/src/conversation/index.d.ts.map +0 -1
  137. package/dist/types/src/errors.d.ts +0 -39
  138. package/dist/types/src/errors.d.ts.map +0 -1
  139. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +0 -4
  140. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +0 -1
  141. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts +0 -2
  142. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts.map +0 -1
  143. package/dist/types/src/extraction/extraction-llm-function/index.d.ts +0 -2
  144. package/dist/types/src/extraction/extraction-llm-function/index.d.ts.map +0 -1
  145. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +0 -306
  146. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +0 -1
  147. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts +0 -2
  148. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts.map +0 -1
  149. package/dist/types/src/session/artifact-diff.d.ts.map +0 -1
  150. package/dist/types/src/session/format.d.ts +0 -168
  151. package/dist/types/src/session/format.d.ts.map +0 -1
  152. package/dist/types/src/session/format.test.d.ts +0 -2
  153. package/dist/types/src/session/format.test.d.ts.map +0 -1
  154. package/dist/types/src/session/session.d.ts +0 -167
  155. package/dist/types/src/session/session.d.ts.map +0 -1
  156. package/dist/types/src/session/session.test.d.ts +0 -2
  157. package/dist/types/src/session/session.test.d.ts.map +0 -1
  158. package/dist/types/src/session/version-pin.d.ts.map +0 -1
  159. package/dist/types/src/session/version-pin.test.d.ts +0 -2
  160. package/dist/types/src/session/version-pin.test.d.ts.map +0 -1
  161. package/dist/types/src/summarization/summarization.test.d.ts +0 -2
  162. package/dist/types/src/summarization/summarization.test.d.ts.map +0 -1
  163. package/dist/types/src/types.d.ts +0 -16
  164. package/dist/types/src/types.d.ts.map +0 -1
  165. package/src/conversation/context.ts +0 -133
  166. package/src/conversation/conversation.ts +0 -125
  167. package/src/conversation/index.ts +0 -6
  168. package/src/errors.ts +0 -10
  169. package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +0 -84
  170. package/src/extraction/extraction-llm-function/extraction-llm-function.ts +0 -71
  171. package/src/extraction/extraction-llm-function/index.ts +0 -5
  172. package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +0 -116
  173. package/src/extraction/extraction-ner-function/extraction-ner-function.ts +0 -57
  174. package/src/session/__snapshots__/session.test.ts.snap +0 -32
  175. package/src/session/format.test.ts +0 -60
  176. package/src/session/session.test.ts +0 -305
  177. package/src/session/session.ts +0 -279
  178. package/src/session/version-pin.test.ts +0 -7
  179. package/src/summarization/summarization.test.ts +0 -197
  180. package/src/templates/system.tpl +0 -47
  181. package/src/types.ts +0 -52
  182. /package/dist/lib/{browser/named-entity-recognition-O46UTCLR.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
  183. /package/src/extraction/extraction-llm-function/{instructions.tpl → transcription-instructions.tpl} +0 -0
@@ -0,0 +1,178 @@
1
+ import { Atom, Registry as AtomRegistry } from '@effect-atom/atom-react';
2
+ import * as Context from 'effect/Context';
3
+ import * as Effect from 'effect/Effect';
4
+ import * as Runtime from 'effect/Runtime';
5
+ import * as Schema from 'effect/Schema';
6
+ import { Blueprint } from '@dxos/compute';
7
+ import { Resource } from '@dxos/context';
8
+ import { Feed, Obj, Ref, Type } from '@dxos/echo';
9
+ import { type URI } from '@dxos/keys';
10
+ import { ComplexSet } from '@dxos/util';
11
+ /**
12
+ * Thread message that binds or unbinds contextual objects to a conversation.
13
+ */
14
+ export declare const Binding: Type.Obj<{
15
+ readonly blueprints: {
16
+ readonly added: readonly import("@dxos/echo/internal").Ref<{
17
+ readonly name: string;
18
+ readonly description?: string | undefined;
19
+ readonly instructions: {
20
+ readonly source: import("@dxos/echo/internal").Ref<{
21
+ readonly name?: string | undefined;
22
+ readonly content: string;
23
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
24
+ readonly inputs?: readonly {
25
+ readonly name: string;
26
+ readonly kind: "operation" | "value";
27
+ readonly default?: any;
28
+ readonly operation?: string | undefined;
29
+ }[] | undefined;
30
+ };
31
+ readonly tools: readonly (string & import("effect/Brand").Brand<"ToolId">)[];
32
+ readonly agentCanEnable?: boolean | undefined;
33
+ readonly mcpServers?: readonly {
34
+ readonly name?: string | undefined;
35
+ readonly url: string;
36
+ readonly protocol: "http" | "sse";
37
+ readonly apiKey?: string | undefined;
38
+ }[] | undefined;
39
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>[];
40
+ readonly removed: readonly import("@dxos/echo/internal").Ref<{
41
+ readonly name: string;
42
+ readonly description?: string | undefined;
43
+ readonly instructions: {
44
+ readonly source: import("@dxos/echo/internal").Ref<{
45
+ readonly name?: string | undefined;
46
+ readonly content: string;
47
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
48
+ readonly inputs?: readonly {
49
+ readonly name: string;
50
+ readonly kind: "operation" | "value";
51
+ readonly default?: any;
52
+ readonly operation?: string | undefined;
53
+ }[] | undefined;
54
+ };
55
+ readonly tools: readonly (string & import("effect/Brand").Brand<"ToolId">)[];
56
+ readonly agentCanEnable?: boolean | undefined;
57
+ readonly mcpServers?: readonly {
58
+ readonly name?: string | undefined;
59
+ readonly url: string;
60
+ readonly protocol: "http" | "sse";
61
+ readonly apiKey?: string | undefined;
62
+ }[] | undefined;
63
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>[];
64
+ };
65
+ readonly objects: {
66
+ readonly added: readonly import("@dxos/echo/internal").Ref<Obj.Unknown>[];
67
+ readonly removed: readonly import("@dxos/echo/internal").Ref<Obj.Unknown>[];
68
+ };
69
+ }, Schema.Struct.Fields>;
70
+ export type Binding = Type.InstanceType<typeof Binding>;
71
+ export type BindingProps = Partial<{
72
+ blueprints: Ref.Ref<Blueprint.Blueprint>[];
73
+ objects: Ref.Ref<Obj.Unknown>[];
74
+ }>;
75
+ export declare class Bindings {
76
+ readonly blueprints: ComplexSet<Ref.Ref<{
77
+ readonly name: string;
78
+ readonly description?: string | undefined;
79
+ readonly instructions: {
80
+ readonly source: import("@dxos/echo/internal").Ref<{
81
+ readonly name?: string | undefined;
82
+ readonly content: string;
83
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
84
+ readonly inputs?: readonly {
85
+ readonly name: string;
86
+ readonly kind: "operation" | "value";
87
+ readonly default?: any;
88
+ readonly operation?: string | undefined;
89
+ }[] | undefined;
90
+ };
91
+ readonly tools: readonly (string & import("effect/Brand").Brand<"ToolId">)[];
92
+ readonly agentCanEnable?: boolean | undefined;
93
+ readonly mcpServers?: readonly {
94
+ readonly name?: string | undefined;
95
+ readonly url: string;
96
+ readonly protocol: "http" | "sse";
97
+ readonly apiKey?: string | undefined;
98
+ }[] | undefined;
99
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object>>>;
100
+ readonly objects: ComplexSet<Ref.Ref<Obj.Unknown>>;
101
+ toJSON(): {
102
+ blueprints: URI.URI[];
103
+ objects: URI.URI[];
104
+ };
105
+ }
106
+ export type BinderOptions = {
107
+ feed: Feed.Feed;
108
+ runtime: Runtime.Runtime<Feed.FeedService>;
109
+ /** @effect-atom/atom-react Registry for reactive state management. */
110
+ registry?: AtomRegistry.Registry;
111
+ };
112
+ /**
113
+ * Manages bindings of blueprints and objects to a conversation.
114
+ */
115
+ export declare class Binder extends Resource {
116
+ #private;
117
+ private readonly _blueprints;
118
+ private readonly _objects;
119
+ private readonly _registry;
120
+ private readonly _feed;
121
+ private readonly _runtime;
122
+ constructor(options: BinderOptions);
123
+ /**
124
+ * Returns the blueprints atom for subscription.
125
+ */
126
+ get blueprints(): Atom.Atom<Blueprint.Blueprint[]>;
127
+ /**
128
+ * Returns the objects atom for subscription.
129
+ */
130
+ get objects(): Atom.Atom<Obj.Unknown[]>;
131
+ /**
132
+ * Gets the current blueprints value.
133
+ */
134
+ getBlueprints(): Blueprint.Blueprint[];
135
+ /**
136
+ * Gets the current objects value.
137
+ */
138
+ getObjects(): Obj.Unknown[];
139
+ /**
140
+ * Subscribe to changes in blueprints.
141
+ */
142
+ subscribeBlueprints(cb: (blueprints: Blueprint.Blueprint[]) => void): () => void;
143
+ /**
144
+ * Subscribe to changes in objects.
145
+ */
146
+ subscribeObjects(cb: (objects: Obj.Unknown[]) => void): () => void;
147
+ protected _open(): Promise<void>;
148
+ /**
149
+ * Re-reads bindings from the feed to pick up changes made by other processes.
150
+ */
151
+ sync(): Promise<void>;
152
+ private _updateBindings;
153
+ protected _close(): Promise<void>;
154
+ bind({ blueprints, objects }: BindingProps): Promise<void>;
155
+ unbind({ blueprints, objects }: BindingProps): Promise<void>;
156
+ /**
157
+ * Process bindings to filter duplicates and determine next state.
158
+ */
159
+ private _processBindings;
160
+ /**
161
+ * Reduce results into sets of blueprints and objects.
162
+ */
163
+ private _reduce;
164
+ /**
165
+ * Merge resolved items into the current set, adding only items not already present (by DXN).
166
+ */
167
+ private _mergeInto;
168
+ private _resolve;
169
+ }
170
+ declare const Service_base: Context.TagClass<Service, "@dxos/assistant/AiContextService", {
171
+ binder: Binder;
172
+ }>;
173
+ export declare class Service extends Service_base {
174
+ static bindContext: ({ blueprints, objects }: BindingProps) => Effect.Effect<void, never, Service>;
175
+ static findObjects: <T extends Type.AnyObj>(type: T) => Effect.Effect<Type.InstanceType<T>[], never, Service>;
176
+ }
177
+ export {};
178
+ //# sourceMappingURL=AiContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiContext.d.ts","sourceRoot":"","sources":["../../../../src/session/AiContext.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,OAAO,MAAM,gBA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I,CAAC,CAsCjE;IAED;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA+BxB;;OAEG;IACH,OAAO,CAAC,OAAO;IA0Bf;;OAEG;IACH,OAAO,CAAC,UAAU;YAkBJ,QAAQ;CAmBvB;;YAKW,MAAM;;AAHlB,qBAAa,OAAQ,SAAQ,YAK1B;IACD,MAAM,CAAC,WAAW,4BAA6B,YAAY,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAI5F;IAEL,MAAM,CAAC,WAAW,GAAI,CAAC,SAAS,IAAI,CAAC,MAAM,QAAQ,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAK1G;CACH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AiContext.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiContext.test.d.ts","sourceRoot":"","sources":["../../../../src/session/AiContext.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,79 @@
1
+ import { type Registry as AtomRegistry } from '@effect-atom/atom-react';
2
+ import * as Context from 'effect/Context';
3
+ import * as Effect from 'effect/Effect';
4
+ import * as Layer from 'effect/Layer';
5
+ import * as Runtime from 'effect/Runtime';
6
+ import { type OpaqueToolkit, type ToolExecutionService, type ToolResolverService } from '@dxos/ai';
7
+ import { McpServer, Operation } from '@dxos/compute';
8
+ import { Resource } from '@dxos/context';
9
+ import { Database, Feed, Registry } from '@dxos/echo';
10
+ import { Message, type ContentBlock } from '@dxos/types';
11
+ import { AiRequest, type GenerationObserver } from '../request';
12
+ import * as AiContext from './AiContext';
13
+ export type RunProps<R = never> = {
14
+ prompt: string | ContentBlock.Any[];
15
+ system?: string;
16
+ observer?: GenerationObserver;
17
+ toolkit?: OpaqueToolkit.OpaqueToolkit<R>;
18
+ /**
19
+ * Space-level MCP servers to connect alongside blueprint-defined ones.
20
+ */
21
+ mcpServers?: readonly McpServer.McpServer[];
22
+ };
23
+ export type Options = {
24
+ feed: Feed.Feed;
25
+ runtime: Runtime.Runtime<Feed.FeedService>;
26
+ /** @effect-atom/atom-react Registry for reactive state. */
27
+ registry?: AtomRegistry.Registry;
28
+ };
29
+ /**
30
+ * Durable conversation state (initiated by users and agents) backed by a Feed.
31
+ * Executes tools based on AI responses and supports cancellation of in-progress requests.
32
+ */
33
+ export declare class Session extends Resource {
34
+ /**
35
+ * Blueprints and objects bound to the session.
36
+ */
37
+ private readonly _binder;
38
+ private readonly _feed;
39
+ private readonly _runtime;
40
+ private readonly _sessionLoader;
41
+ constructor(options: Options);
42
+ protected _open(): Promise<void>;
43
+ get feed(): {
44
+ readonly name?: string | undefined;
45
+ readonly kind?: string | undefined;
46
+ readonly namespace?: "data" | "trace" | undefined;
47
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object>;
48
+ get context(): AiContext.Binder;
49
+ getHistory(): Promise<Message.Message[]>;
50
+ getTools(): Effect.Effect<Record<string, import('@effect/ai/Tool').Any>, never, ToolExecutionService | ToolResolverService>;
51
+ /**
52
+ * Not provided by default, since users might want to override them.
53
+ */
54
+ makeToolExecutionServices(): Layer.Layer<ToolExecutionService | ToolResolverService, never, OpaqueToolkit.OpaqueToolkitProvider | Operation.Service | Registry.Service>;
55
+ /**
56
+ * Creates a new cancelable request effect.
57
+ */
58
+ createRequest<R = never>(params: RunProps<R>): Effect.Effect<Message.Message[], AiRequest.RunError, AiRequest.RunRequirements | R>;
59
+ }
60
+ declare const Service_base: Context.TagClass<Service, "@dxos/assistant/AiSessionService", Session>;
61
+ /**
62
+ * Gives access to the ai session.
63
+ */
64
+ export declare class Service extends Service_base {
65
+ /**
66
+ * Create a new session layer from options.
67
+ */
68
+ static layer: (options: Options) => Layer.Layer<Service | AiContext.Service>;
69
+ /**
70
+ * Create a new session with a new feed.
71
+ */
72
+ static layerNewFeed: (options?: Omit<Options, 'feed' | 'runtime'>) => Layer.Layer<Service | AiContext.Service, never, Database.Service | Feed.FeedService>;
73
+ /**
74
+ * Run a prompt in the current session.
75
+ */
76
+ static run: <R = never>(params: RunProps<R>) => Effect.Effect<Message.Message[], AiRequest.RunError, AiRequest.RunRequirements | Service | R>;
77
+ }
78
+ export {};
79
+ //# sourceMappingURL=AiSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiSession.d.ts","sourceRoot":"","sources":["../../../../src/session/AiSession.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,QAAQ,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAExE,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACnG,OAAO,EAAkB,SAAS,EAAE,SAAS,EAAS,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAe,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKnE,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,SAAS,EAAE,KAAK,kBAAkB,EAAsB,MAAM,YAAY,CAAC;AAEpF,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAIzC,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,KAAK,IAAI;IAChC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC,GAAG,EAAE,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B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,CAAC,CAAC,CAAC,GAClB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,eAAe,GAAG,CAAC,CAAC,CAwErF;CACF;;AAED;;GAEG;AACH,qBAAa,OAAQ,SAAQ,YAAmE;IAC9F;;OAEG;IACH,MAAM,CAAC,KAAK,YAAa,OAAO,KAAG,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAWvE;IAEJ;;OAEG;IACH,MAAM,CAAC,YAAY,aACP,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC,KAC1C,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,CAOnF;IAEJ;;OAEG;IACH,MAAM,CAAC,GAAG,GAAI,CAAC,GAAG,KAAK,UACb,QAAQ,CAAC,CAAC,CAAC,KAClB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,eAAe,GAAG,OAAO,GAAG,CAAC,CAAC,CAI3F;CACN"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AiSession.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiSession.test.d.ts","sourceRoot":"","sources":["../../../../src/session/AiSession.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import * as Schema from 'effect/Schema';
2
+ import { Obj, Type } from '@dxos/echo';
3
+ /**
4
+ * Feed-level record that links this session to a point in another session's history.
5
+ * When present in a feed, the messages from the referenced feed up to and including
6
+ * `messageId` are prepended to the conversation history before each turn.
7
+ */
8
+ export declare const SessionLink: Type.Obj<{
9
+ readonly feedRef: import("@dxos/echo/internal").Ref<{
10
+ readonly name?: string | undefined;
11
+ readonly kind?: string | undefined;
12
+ readonly namespace?: "data" | "trace" | undefined;
13
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
14
+ readonly messageId: string;
15
+ }, Schema.Struct.Fields>;
16
+ export type SessionLink = Type.InstanceType<typeof SessionLink>;
17
+ //# sourceMappingURL=SessionLink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionLink.d.ts","sourceRoot":"","sources":["../../../../src/session/SessionLink.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAa,GAAG,EAAO,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,WAAW;;;;;;;wBAKgD,CAAC;AAEzE,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import * as Effect from 'effect/Effect';
2
+ import { Feed } from '@dxos/echo';
3
+ import { Message } from '@dxos/types';
4
+ /**
5
+ * Loads and reifies conversation history by resolving SessionLink feed records.
6
+ */
7
+ export declare class SessionLoader {
8
+ /**
9
+ * Prepends linked history to `messages` when the feed contains a SessionLink.
10
+ * Queries the feed for any SessionLink record; if found, loads messages from
11
+ * the referenced feed up to and including `messageId` and prepends them.
12
+ */
13
+ reifyHistory(feed: Feed.Feed, messages: Message.Message[]): Effect.Effect<Message.Message[], never, Feed.FeedService>;
14
+ }
15
+ //# sourceMappingURL=SessionLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionLoader.d.ts","sourceRoot":"","sources":["../../../../src/session/SessionLoader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,IAAI,EAAe,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAItC;;GAEG;AACH,qBAAa,aAAa;IACxB;;;;OAIG;IACH,YAAY,CACV,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,GAC1B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CA8B3D;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=SessionLoader.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionLoader.test.d.ts","sourceRoot":"","sources":["../../../../src/session/SessionLoader.test.ts"],"names":[],"mappings":""}
@@ -1,4 +1,6 @@
1
- export * from './artifact-diff';
2
- export * from './session';
3
- export * from './version-pin';
1
+ export * from './toolkit';
2
+ export * as AiContext from './AiContext';
3
+ export * as AiSession from './AiSession';
4
+ export { SessionLoader } from './SessionLoader';
5
+ export * as SessionLink from './SessionLink';
4
6
  //# 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,WAAW,CAAC;AAE1B,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC"}
@@ -0,0 +1,16 @@
1
+ import * as Effect from 'effect/Effect';
2
+ import { type AiToolNotFoundError, OpaqueToolkit, ToolExecutionService, ToolResolverService } from '@dxos/ai';
3
+ import { type Blueprint } from '@dxos/compute';
4
+ export type CreateToolkitProps = {
5
+ toolkit?: OpaqueToolkit.Any;
6
+ blueprints?: readonly Blueprint.Blueprint[];
7
+ /**
8
+ * Self-contained with handlers toolkits.
9
+ */
10
+ opaqueToolkits?: readonly OpaqueToolkit.Any[];
11
+ };
12
+ /**
13
+ * Build a combined toolkit from the blueprint tools and the provided toolkit.
14
+ */
15
+ export declare const createToolkit: ({ toolkit: toolkitProp, blueprints, opaqueToolkits, }: CreateToolkitProps) => Effect.Effect<OpaqueToolkit.OpaqueToolkit, AiToolNotFoundError, ToolResolverService | ToolExecutionService>;
16
+ //# sourceMappingURL=toolkit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolkit.d.ts","sourceRoot":"","sources":["../../../../src/session/toolkit.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,KAAK,mBAAmB,EAAE,aAAa,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC9G,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,SAAS,CAAC,SAAS,EAAE,CAAC;IAC5C;;OAEG;IACH,cAAc,CAAC,EAAE,SAAS,aAAa,CAAC,GAAG,EAAE,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,0DAIvB,kBAAkB,KAAG,MAAM,CAAC,MAAM,CACnC,aAAa,CAAC,aAAa,EAC3B,mBAAmB,EACnB,mBAAmB,GAAG,oBAAoB,CAeuE,CAAC"}
@@ -1,22 +1,27 @@
1
- import { Template } from '@dxos/blueprints';
2
- type PromptOptions = {
3
- /**
4
- * Emit chain-of-thought inside <cot> tag.
5
- * Should be `false` for models with built-in reasoning: Claude, deepseek, o1.
6
- */
7
- cot?: boolean;
8
- /**
9
- * Whether to include suggestions in the prompt.
10
- */
11
- suggestions?: boolean;
1
+ import { type ModelCapabilities } from '@dxos/ai';
2
+ /**
3
+ * System template variables.
4
+ */
5
+ export type SystemPromptOptions = ModelCapabilities & {
6
+ DATETIME: string;
12
7
  };
13
8
  /**
14
9
  * Base system prompt.
15
10
  * NOTE: This contains protocol instructions that can not be dynamically edited.
16
11
  */
17
- export declare const createSystemPrompt: (options: PromptOptions) => string;
12
+ export declare const createSystemPrompt: (options?: Partial<SystemPromptOptions>) => string;
18
13
  export declare const templates: {
19
- system: Template.Template;
14
+ system: {
15
+ readonly source: import("@dxos/echo/internal").Ref<{
16
+ readonly name?: string | undefined;
17
+ readonly content: string;
18
+ } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & import("@dxos/echo/Obj").Unknown>;
19
+ readonly inputs?: readonly {
20
+ readonly name: string;
21
+ readonly kind: "operation" | "value";
22
+ readonly default?: any;
23
+ readonly operation?: string | undefined;
24
+ }[] | undefined;
25
+ };
20
26
  };
21
- export {};
22
27
  //# sourceMappingURL=system.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../../../src/templates/system.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAK5C,KAAK,aAAa,GAAG;IACnB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,aAAa,WAAqD,CAAC;AAE/G,eAAO,MAAM,SAAS;;CAGrB,CAAC"}
1
+ {"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../../../src/templates/system.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAMlD;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG;IACpD,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,aAAa,OAAO,CAAC,mBAAmB,CAAC,WAMrE,CAAC;AAOJ,eAAO,MAAM,SAAS;IACpB,MAAM;;;;;;;;;;;;CAIP,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type * as Effect from 'effect/Effect';
2
+ import * as Schema from 'effect/Schema';
3
+ import { Database, type Err, Obj, Ref, type Type } from '@dxos/echo';
4
+ import { EID, EntityId, SpaceId } from '@dxos/keys';
5
+ /**
6
+ * @deprecated
7
+ */
8
+ export declare const createArtifactElement: (id: EntityId) => string;
9
+ type ArtifactURI = Schema.Schema.Type<typeof ArtifactURI>;
10
+ /**
11
+ * Schema that decodes ECHO reference object from an LLM-friendly input.
12
+ */
13
+ export declare const RefFromLLM: Schema.transform<Schema.Schema<string, string, never> & {
14
+ toEchoURI: (reference: ArtifactURI, owningSpaceId?: SpaceId) => EID.EID;
15
+ resolve: <S extends Type.AnyEntity>(schema: S, ref: ArtifactURI) => Effect.Effect<Type.InstanceType<S>, Err.EntityNotFoundError, Database.Service>;
16
+ }, Ref.RefSchema<Obj.Unknown>>;
17
+ export {};
18
+ //# sourceMappingURL=artifact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact.d.ts","sourceRoot":"","sources":["../../../../src/util/artifact.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGpD;;GAEG;AACH,eAAO,MAAM,qBAAqB,OAAQ,QAAQ,WAA4B,CAAC;AAqE/E,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,WAAW,CAAC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,UAAU;eAjEV,CAAC,SAAS,EAAE,WAAW,EAAE,aAAa,CAAC,EAAE,OAAO,KAAK,GAAG,CAAC,GAAG;aAC9D,CAAC,CAAC,SAAS,IAAI,CAAC,SAAS,EAChC,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,WAAW,KACb,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,mBAAmB,EAAE,QAAQ,CAAC,OAAO,CAAC;8BAmEnF,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { DocAccessor } from '@dxos/echo-client';
2
+ export type Diff = {
3
+ match: string;
4
+ replace: string;
5
+ };
6
+ /**
7
+ * Convert a list of diffs into a list of operations.
8
+ */
9
+ export declare const reduceDiffs: (diffs: readonly string[]) => Diff[];
10
+ export declare const computeDiffsWithCursors: <T>(accessor: DocAccessor<T>, diffs: readonly string[]) => {
11
+ cursor: string;
12
+ text: string;
13
+ }[];
14
+ export declare const applyDiffs: <T>(accessor: DocAccessor<T>, diffs: readonly string[], { errorOnNotFound }?: {
15
+ errorOnNotFound?: boolean;
16
+ }) => string;
17
+ //# sourceMappingURL=diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../../src/util/diff.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAiB,MAAM,mBAAmB,CAAC;AAc/D,MAAM,MAAM,IAAI,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,UAAW,SAAS,MAAM,EAAE,KAAG,IAAI,EA0B1D,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,CAAC,YAAY,WAAW,CAAC,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE;;;GAU5F,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,CAAC,YAChB,WAAW,CAAC,CAAC,CAAC,SACjB,SAAS,MAAM,EAAE,wBACK;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,KACzD,MAoBF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=diff.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.test.d.ts","sourceRoot":"","sources":["../../../../src/util/diff.test.ts"],"names":[],"mappings":""}
@@ -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/util/error-handling.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAE9C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAcxC,eAAO,MAAM,UAAU,QAAS,OAAO,CAAC,OAAO,KAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAqB1B,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { BaseError } from '@dxos/errors';
2
+ declare const AiModelError_base: {
3
+ new (options?: import("@dxos/errors").BaseErrorOptions): {
4
+ cause?: unknown;
5
+ stack?: string;
6
+ name: "AiModelError";
7
+ context: Record<string, unknown>;
8
+ readonly message: string;
9
+ readonly _tag: "AiModelError";
10
+ };
11
+ isError(error: unknown): error is Error;
12
+ name: "AiModelError";
13
+ is(error: unknown): error is BaseError;
14
+ wrap(options?: Omit<import("@dxos/errors").BaseErrorOptions, 'cause'> & {
15
+ ifTypeDiffers?: boolean;
16
+ }): (error: unknown) => {
17
+ cause?: unknown;
18
+ stack?: string;
19
+ name: "AiModelError";
20
+ context: Record<string, unknown>;
21
+ readonly message: string;
22
+ readonly _tag: "AiModelError";
23
+ };
24
+ extend<Name extends string = string>(name: Name, message?: string): any;
25
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
26
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
27
+ stackTraceLimit: number;
28
+ };
29
+ /**
30
+ * Generic error from AI model.
31
+ */
32
+ export declare class AiModelError extends AiModelError_base {
33
+ }
34
+ declare const AiAssistantError_base: {
35
+ new (options?: import("@dxos/errors").BaseErrorOptions): {
36
+ cause?: unknown;
37
+ stack?: string;
38
+ name: "AiAssistantError";
39
+ context: Record<string, unknown>;
40
+ readonly message: string;
41
+ readonly _tag: "AiAssistantError";
42
+ };
43
+ isError(error: unknown): error is Error;
44
+ name: "AiAssistantError";
45
+ is(error: unknown): error is BaseError;
46
+ wrap(options?: Omit<import("@dxos/errors").BaseErrorOptions, 'cause'> & {
47
+ ifTypeDiffers?: boolean;
48
+ }): (error: unknown) => {
49
+ cause?: unknown;
50
+ stack?: string;
51
+ name: "AiAssistantError";
52
+ context: Record<string, unknown>;
53
+ readonly message: string;
54
+ readonly _tag: "AiAssistantError";
55
+ };
56
+ extend<Name extends string = string>(name: Name, message?: string): any;
57
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
58
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
59
+ stackTraceLimit: number;
60
+ };
61
+ /**
62
+ * Generic error for AI agent execution.
63
+ */
64
+ export declare class AiAssistantError extends AiAssistantError_base {
65
+ }
66
+ export {};
67
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/util/errors.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzC;;GAEG;AACH,qBAAa,YAAa,SAAQ,iBAAkD;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvF;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,qBAA0D;CAAG"}
@@ -0,0 +1,85 @@
1
+ import { type Entity } from '@dxos/echo';
2
+ import { LogLevel } from '@dxos/log';
3
+ import { ContentBlock } from '@dxos/types';
4
+ /**
5
+ * Mercurial-style Commit.
6
+ */
7
+ export type Commit = {
8
+ id: string;
9
+ parents: string[];
10
+ branch: string;
11
+ icon?: string;
12
+ level?: LogLevel;
13
+ message: string;
14
+ timestamp?: Date;
15
+ tags?: string[];
16
+ };
17
+ /**
18
+ * Models the execution graph based on a stream of events.
19
+ */
20
+ export declare class ExecutionGraph {
21
+ private readonly _skipBlocks;
22
+ private _commits;
23
+ private _branchNames;
24
+ private _lastBlockId;
25
+ private _toolCallCommitIds;
26
+ private _lastCommitByBranch;
27
+ private _pendingToolResults;
28
+ constructor(_skipBlocks?: ContentBlock.Any['_tag'][]);
29
+ /**
30
+ * Adds events to the graph.
31
+ */
32
+ addEvents(events: Entity.Unknown[]): void;
33
+ /**
34
+ * Processes a message event and creates commits for its blocks.
35
+ */
36
+ private _processMessage;
37
+ /**
38
+ * Processes an AgentStatus event.
39
+ */
40
+ private _processAgentStatus;
41
+ /**
42
+ * Stable sort: objects with 'created' field are sorted by it, others remain in place.
43
+ */
44
+ private sortObjectsByCreated;
45
+ /**
46
+ * Returns the current state of the graph.
47
+ */
48
+ getGraph(lastRequest?: boolean): {
49
+ branches: string[];
50
+ commits: Commit[];
51
+ };
52
+ /**
53
+ * Tracks tool calls and handles pending tool result updates.
54
+ */
55
+ private _trackToolCalls;
56
+ /**
57
+ * Updates pending tool results to point to an AgentStatus event.
58
+ */
59
+ private _updatePendingToolResults;
60
+ /**
61
+ * Handles late updates when AgentStatus is processed before tool result.
62
+ */
63
+ private _handleLateToolResultUpdate;
64
+ /**
65
+ * Gets the branch name for a tool call.
66
+ */
67
+ private _getToolCallBranch;
68
+ /**
69
+ * Gets the parents for an AgentStatus commit.
70
+ */
71
+ private _getAgentStatusParents;
72
+ /**
73
+ * Checks if a commit is a tool call commit.
74
+ */
75
+ private _isToolCallCommit;
76
+ /**
77
+ * Checks if a commit is a tool result commit.
78
+ */
79
+ private _isToolResultCommit;
80
+ /**
81
+ * Extracts tool call ID from a commit ID.
82
+ */
83
+ private _extractToolCallId;
84
+ }
85
+ //# sourceMappingURL=execution-graph.d.ts.map