@dxos/assistant 0.8.3 → 0.8.4-main.1068cf700f

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 (199) hide show
  1. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  2. package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
  3. package/dist/lib/neutral/chunk-ZPC54VRM.mjs +596 -0
  4. package/dist/lib/neutral/chunk-ZPC54VRM.mjs.map +7 -0
  5. package/dist/lib/neutral/extraction/index.mjs +225 -0
  6. package/dist/lib/neutral/extraction/index.mjs.map +7 -0
  7. package/dist/lib/neutral/index.mjs +929 -0
  8. package/dist/lib/neutral/index.mjs.map +7 -0
  9. package/dist/lib/neutral/meta.json +1 -0
  10. package/dist/lib/neutral/testing/index.mjs +38 -0
  11. package/dist/lib/neutral/testing/index.mjs.map +7 -0
  12. package/dist/types/src/conversation/context.d.ts +138 -0
  13. package/dist/types/src/conversation/context.d.ts.map +1 -0
  14. package/dist/types/src/conversation/context.test.d.ts +2 -0
  15. package/dist/types/src/conversation/context.test.d.ts.map +1 -0
  16. package/dist/types/src/conversation/conversation.d.ts +66 -0
  17. package/dist/types/src/conversation/conversation.d.ts.map +1 -0
  18. package/dist/types/src/conversation/conversation.test.d.ts +2 -0
  19. package/dist/types/src/conversation/conversation.test.d.ts.map +1 -0
  20. package/dist/types/src/conversation/index.d.ts +3 -0
  21. package/dist/types/src/conversation/index.d.ts.map +1 -0
  22. package/dist/types/src/diff.d.ts +17 -0
  23. package/dist/types/src/diff.d.ts.map +1 -0
  24. package/dist/types/src/diff.test.d.ts +2 -0
  25. package/dist/types/src/diff.test.d.ts.map +1 -0
  26. package/dist/types/src/errors.d.ts +67 -0
  27. package/dist/types/src/errors.d.ts.map +1 -0
  28. package/dist/types/src/execution-graph.d.ts +85 -0
  29. package/dist/types/src/execution-graph.d.ts.map +1 -0
  30. package/dist/types/src/execution-graph.test.d.ts +2 -0
  31. package/dist/types/src/execution-graph.test.d.ts.map +1 -0
  32. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +1 -1
  33. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -1
  34. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +279 -140
  35. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -1
  36. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts +1 -1
  37. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -1
  38. package/dist/types/src/extraction/extraction.d.ts +345 -212
  39. package/dist/types/src/extraction/extraction.d.ts.map +1 -1
  40. package/dist/types/src/extraction/quotes.d.ts +3 -3
  41. package/dist/types/src/extraction/quotes.d.ts.map +1 -1
  42. package/dist/types/src/functions/index.d.ts +2 -0
  43. package/dist/types/src/functions/index.d.ts.map +1 -0
  44. package/dist/types/src/functions/services.d.ts +19 -0
  45. package/dist/types/src/functions/services.d.ts.map +1 -0
  46. package/dist/types/src/functions.test.d.ts +2 -0
  47. package/dist/types/src/functions.test.d.ts.map +1 -0
  48. package/dist/types/src/index.d.ts +6 -3
  49. package/dist/types/src/index.d.ts.map +1 -1
  50. package/dist/types/src/session/GenericToolkit.d.ts +107 -0
  51. package/dist/types/src/session/GenericToolkit.d.ts.map +1 -0
  52. package/dist/types/src/session/artifact-diff.d.ts +27 -0
  53. package/dist/types/src/session/artifact-diff.d.ts.map +1 -0
  54. package/dist/types/src/session/error-handling.d.ts +4 -0
  55. package/dist/types/src/session/error-handling.d.ts.map +1 -0
  56. package/dist/types/src/session/format.d.ts +12 -0
  57. package/dist/types/src/session/format.d.ts.map +1 -0
  58. package/dist/types/src/session/format.test.d.ts +2 -0
  59. package/dist/types/src/session/format.test.d.ts.map +1 -0
  60. package/dist/types/src/session/index.d.ts +5 -0
  61. package/dist/types/src/session/index.d.ts.map +1 -1
  62. package/dist/types/src/session/observer.d.ts +23 -0
  63. package/dist/types/src/session/observer.d.ts.map +1 -0
  64. package/dist/types/src/session/session.d.ts +41 -246
  65. package/dist/types/src/session/session.d.ts.map +1 -1
  66. package/dist/types/src/session/toolkit.d.ts +14 -0
  67. package/dist/types/src/session/toolkit.d.ts.map +1 -0
  68. package/dist/types/src/session/version-pin.d.ts +5 -5
  69. package/dist/types/src/session/version-pin.d.ts.map +1 -1
  70. package/dist/types/src/templates/index.d.ts +2 -0
  71. package/dist/types/src/templates/index.d.ts.map +1 -0
  72. package/dist/types/src/templates/system.d.ts +18 -0
  73. package/dist/types/src/templates/system.d.ts.map +1 -0
  74. package/dist/types/src/testing/index.d.ts +1 -2
  75. package/dist/types/src/testing/index.d.ts.map +1 -1
  76. package/dist/types/src/testing/layer.d.ts +22 -0
  77. package/dist/types/src/testing/layer.d.ts.map +1 -0
  78. package/dist/types/src/types/artifact.d.ts +28 -0
  79. package/dist/types/src/types/artifact.d.ts.map +1 -0
  80. package/dist/types/src/types/index.d.ts +2 -0
  81. package/dist/types/src/types/index.d.ts.map +1 -0
  82. package/dist/types/tsconfig.tsbuildinfo +1 -1
  83. package/package.json +58 -38
  84. package/src/conversation/context.test.ts +46 -0
  85. package/src/conversation/context.ts +330 -0
  86. package/src/conversation/conversation.test.ts +65 -0
  87. package/src/conversation/conversation.ts +203 -0
  88. package/src/conversation/index.ts +6 -0
  89. package/src/diff.test.ts +74 -0
  90. package/src/diff.ts +93 -0
  91. package/src/errors.ts +15 -0
  92. package/src/execution-graph.test.ts +740 -0
  93. package/src/execution-graph.ts +509 -0
  94. package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +14 -25
  95. package/src/extraction/extraction-llm-function/extraction-llm-function.ts +48 -51
  96. package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +23 -22
  97. package/src/extraction/extraction-ner-function/extraction-ner-function.ts +43 -41
  98. package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +12 -6
  99. package/src/extraction/extraction-ner-function/named-entity-recognition.ts +3 -1
  100. package/src/extraction/extraction.ts +10 -9
  101. package/src/extraction/quotes.test.ts +3 -3
  102. package/src/extraction/quotes.ts +6 -7
  103. package/src/functions/index.ts +5 -0
  104. package/src/functions/services.ts +187 -0
  105. package/src/functions.conversations.json +1 -0
  106. package/src/functions.test.ts +74 -0
  107. package/src/index.ts +6 -3
  108. package/src/session/GenericToolkit.ts +160 -0
  109. package/src/session/artifact-diff.ts +41 -0
  110. package/src/session/error-handling.ts +41 -0
  111. package/src/session/format.test.ts +124 -0
  112. package/src/session/format.ts +143 -0
  113. package/src/session/index.ts +6 -0
  114. package/src/session/observer.ts +61 -0
  115. package/src/session/session.conversations.json +1 -0
  116. package/src/session/session.test.ts +106 -173
  117. package/src/session/session.ts +181 -495
  118. package/src/session/toolkit.ts +39 -0
  119. package/src/session/version-pin.ts +12 -12
  120. package/src/templates/index.ts +5 -0
  121. package/src/templates/instructions/format.tpl +57 -0
  122. package/src/templates/instructions/system.tpl +48 -0
  123. package/src/templates/system.ts +41 -0
  124. package/src/testing/index.ts +2 -8
  125. package/src/testing/layer.ts +84 -0
  126. package/src/types/artifact.ts +89 -0
  127. package/src/types/index.ts +5 -0
  128. package/src/typings.d.ts +5 -0
  129. package/dist/lib/browser/index.mjs +0 -2158
  130. package/dist/lib/browser/index.mjs.map +0 -7
  131. package/dist/lib/browser/meta.json +0 -1
  132. package/dist/lib/node/index.cjs +0 -2178
  133. package/dist/lib/node/index.cjs.map +0 -7
  134. package/dist/lib/node/meta.json +0 -1
  135. package/dist/lib/node-esm/index.mjs +0 -2160
  136. package/dist/lib/node-esm/index.mjs.map +0 -7
  137. package/dist/lib/node-esm/meta.json +0 -1
  138. package/dist/types/bin/chat.d.ts +0 -2
  139. package/dist/types/bin/chat.d.ts.map +0 -1
  140. package/dist/types/src/blueprint/ai.test.d.ts +0 -2
  141. package/dist/types/src/blueprint/ai.test.d.ts.map +0 -1
  142. package/dist/types/src/blueprint/blueprint.d.ts +0 -55
  143. package/dist/types/src/blueprint/blueprint.d.ts.map +0 -1
  144. package/dist/types/src/blueprint/blueprint.test.d.ts +0 -2
  145. package/dist/types/src/blueprint/blueprint.test.d.ts.map +0 -1
  146. package/dist/types/src/blueprint/index.d.ts +0 -4
  147. package/dist/types/src/blueprint/index.d.ts.map +0 -1
  148. package/dist/types/src/blueprint/logger.d.ts +0 -25
  149. package/dist/types/src/blueprint/logger.d.ts.map +0 -1
  150. package/dist/types/src/blueprint/machine.d.ts +0 -143
  151. package/dist/types/src/blueprint/machine.d.ts.map +0 -1
  152. package/dist/types/src/blueprint/test-data.d.ts +0 -3
  153. package/dist/types/src/blueprint/test-data.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/ai.test.ts +0 -156
  179. package/src/blueprint/blueprint.test.ts +0 -151
  180. package/src/blueprint/blueprint.ts +0 -75
  181. package/src/blueprint/index.ts +0 -7
  182. package/src/blueprint/logger.ts +0 -155
  183. package/src/blueprint/machine.ts +0 -251
  184. package/src/blueprint/test-data.ts +0 -55
  185. package/src/research/exa.ts +0 -100
  186. package/src/research/graph.test.ts +0 -15
  187. package/src/research/graph.ts +0 -337
  188. package/src/research/index.ts +0 -7
  189. package/src/research/instructions-research.tpl +0 -97
  190. package/src/research/research.test.ts +0 -190
  191. package/src/research/research.ts +0 -89
  192. package/src/session/version-pin.test.ts +0 -26
  193. package/src/summarization/summarization.test.ts +0 -221
  194. package/src/testing/exa-search-1748337321991.ts +0 -131
  195. package/src/testing/exa-search-1748337331526.ts +0 -144
  196. package/src/testing/exa-search-1748337344119.ts +0 -133
  197. package/src/typedefs.d.ts +0 -8
  198. package/src/types.ts +0 -8
  199. /package/src/extraction/extraction-llm-function/{instructions.tpl → transcription-instructions.tpl} +0 -0
@@ -0,0 +1,187 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Tool from '@effect/ai/Tool';
6
+ import type * as Toolkit from '@effect/ai/Toolkit';
7
+ import * as Context from 'effect/Context';
8
+ import * as Effect from 'effect/Effect';
9
+ import * as Layer from 'effect/Layer';
10
+ import * as Record from 'effect/Record';
11
+ import * as Schema from 'effect/Schema';
12
+ import type * as SchemaAST from 'effect/SchemaAST';
13
+
14
+ import { AiToolNotFoundError, ToolExecutionService, ToolResolverService } from '@dxos/ai';
15
+ import { todo } from '@dxos/debug';
16
+ import { Type } from '@dxos/echo';
17
+ import { type FunctionDefinition, FunctionInvocationService } from '@dxos/functions';
18
+ import { invariant } from '@dxos/invariant';
19
+
20
+ import { GenericToolkit } from '../session';
21
+ import { RefFromLLM } from '../types';
22
+
23
+ /**
24
+ * Constructs a `ToolResolverService` whose `resolve(id)` looks up tools in the following order:
25
+ * 1. Toolkit: return an existing tool from the provided `toolkit` if one is present under `id`.
26
+ * 2. Functions in DB: query `FunctionType` by `key=id`; if found, deserialize and project to a tool
27
+ * (propagating any `deployedFunctionId` discovered in the object's metadata).
28
+ * 3. Functions passed in: fall back to a matching `FunctionDefinition` from the `functions` array.
29
+ *
30
+ * If none of the above yield a match, the effect fails with `AiToolNotFoundError`.
31
+ *
32
+ * Requires `Database.Service` in the environment.
33
+ */
34
+ export const makeToolResolverFromFunctions = (): Layer.Layer<
35
+ ToolResolverService,
36
+ never,
37
+ GenericToolkit.Provider | FunctionInvocationService
38
+ > => {
39
+ return Layer.effect(
40
+ ToolResolverService,
41
+ Effect.gen(function* () {
42
+ const toolkitProvider = yield* GenericToolkit.Provider;
43
+ const functionInvocationService = yield* FunctionInvocationService;
44
+ return {
45
+ resolve: (id): Effect.Effect<Tool.Any, AiToolNotFoundError> =>
46
+ Effect.gen(function* () {
47
+ const toolkit = toolkitProvider.getToolkit();
48
+
49
+ const tool = toolkit.toolkit.tools[id];
50
+ if (tool) {
51
+ return tool;
52
+ }
53
+
54
+ return yield* functionInvocationService.resolveFunction(id).pipe(
55
+ Effect.map(projectFunctionToTool),
56
+ Effect.catchTag('FunctionNotFound', () => Effect.fail(new AiToolNotFoundError(id))),
57
+ );
58
+ }),
59
+ } satisfies Context.Tag.Service<ToolResolverService>;
60
+ }),
61
+ );
62
+ };
63
+
64
+ export const makeToolExecutionServiceFromFunctions = (): Layer.Layer<
65
+ ToolExecutionService,
66
+ never,
67
+ FunctionInvocationService | GenericToolkit.Provider
68
+ > => {
69
+ return Layer.effect(
70
+ ToolExecutionService,
71
+ Effect.gen(function* () {
72
+ const toolkitProvider = yield* GenericToolkit.Provider;
73
+ const toolkit = toolkitProvider.getToolkit();
74
+
75
+ const toolkitHandler = yield* toolkit.toolkit.pipe(Effect.provide(toolkit.layer));
76
+ invariant(isHandlerLike(toolkitHandler));
77
+ const functionInvocationService = yield* FunctionInvocationService;
78
+
79
+ return {
80
+ handlersFor: (toolkit) => {
81
+ const makeHandler = (tool: Tool.Any): ((params: unknown) => Effect.Effect<unknown, any, any>) => {
82
+ return Effect.fn(`toolFunctionHandler ${tool.name}`)(function* (input: any) {
83
+ if (toolkitHandler.tools[tool.name]) {
84
+ if (Tool.isProviderDefined(tool)) {
85
+ throw new Error('Attempted to call a provider-defined tool');
86
+ }
87
+
88
+ // TODO(wittjosiah): Everything is `never` here.
89
+ const { result } = yield* (toolkitHandler.handle as any)(tool.name, input);
90
+ return result;
91
+ }
92
+
93
+ const { definition: functionDef } = Context.get(FunctionToolAnnotation)(tool.annotations as any);
94
+
95
+ return yield* functionInvocationService
96
+ .invokeFunction(functionDef, input as any)
97
+ .pipe(Effect.catchAllDefect((defect) => Effect.fail(defect)));
98
+ });
99
+ };
100
+
101
+ return toolkit.of(
102
+ Record.map(toolkit.tools, (tool, _name) => (Tool.isUserDefined(tool) ? makeHandler(tool) : null)) as any,
103
+ ) as any;
104
+ },
105
+ };
106
+ }),
107
+ );
108
+ };
109
+
110
+ export const ToolExecutionServices = Layer.mergeAll(
111
+ makeToolResolverFromFunctions(),
112
+ makeToolExecutionServiceFromFunctions(),
113
+ );
114
+
115
+ class FunctionToolAnnotation extends Context.Tag('@dxos/assistant/FunctionToolAnnotation')<
116
+ FunctionToolAnnotation,
117
+ { definition: FunctionDefinition.Any }
118
+ >() {}
119
+
120
+ const toolCache = new WeakMap<FunctionDefinition.Any, Tool.Any>();
121
+
122
+ /**
123
+ * Projects a `FunctionDefinition` into an `AiTool`.
124
+ *
125
+ * @param fn The function definition to project into a tool.
126
+ * @param meta Optional projection metadata.
127
+ * @param meta.deployedFunctionId Backend deployment ID used for remote invocation when present.
128
+ * This is the EDGE service's function deployment identifier (not the ECHO object ID/DXN and not `FunctionDefinition.key`).
129
+ */
130
+ const projectFunctionToTool = (fn: FunctionDefinition.Any): Tool.Any => {
131
+ if (toolCache.has(fn)) {
132
+ return toolCache.get(fn)!;
133
+ }
134
+
135
+ // TODO(burdon): Use and map function.key?
136
+ // TODO(dmaretskyi): Use function key instead.
137
+ const tool = Tool.make(makeToolName(fn.name), {
138
+ description: fn.description,
139
+ parameters: createStructFieldsFromSchema(fn.inputSchema),
140
+ // TODO(dmaretskyi): Include output schema.
141
+ failure: Schema.Any, // TODO(dmaretskyi): Better type for the failure?
142
+ }).annotate(FunctionToolAnnotation, { definition: fn });
143
+ toolCache.set(fn, tool);
144
+ return tool;
145
+ };
146
+
147
+ /**
148
+ * @returns Tool name produced from function name by escaping invalid characters.
149
+ */
150
+ const makeToolName = (name: string) => {
151
+ const toolName = name.toLowerCase().replace(/[^a-zA-Z0-9]/g, '-');
152
+ invariant(toolName.match(/^[a-z_][a-z0-9-_]*$/));
153
+ return toolName;
154
+ };
155
+
156
+ // TODO(dmaretskyi): Factor out.
157
+ const createStructFieldsFromSchema = (schema: Schema.Schema<any, any>): Record<string, Schema.Schema<any, any>> => {
158
+ switch (schema.ast._tag) {
159
+ case 'TypeLiteral':
160
+ return Object.fromEntries(
161
+ schema.ast.propertySignatures.map((prop) => [prop.name, Schema.make(mapSchemaTypeForLLM(prop.type))]),
162
+ );
163
+ case 'VoidKeyword':
164
+ return {};
165
+ default:
166
+ return todo(`Unsupported schema AST: ${schema.ast._tag}`);
167
+ }
168
+ };
169
+
170
+ /**
171
+ * Picks an LLM-friendly schema type for the given schema AST.
172
+ * The picked schema type decodes to the original schema type.
173
+ */
174
+ const mapSchemaTypeForLLM = (ast: SchemaAST.AST): SchemaAST.AST => {
175
+ if (Type.Ref.isRefSchemaAST(ast)) {
176
+ const description = ast.annotations.description
177
+ ? ast.annotations.description + '\n' + RefFromLLM.ast.annotations.description
178
+ : (RefFromLLM.ast.annotations.description as string);
179
+ return RefFromLLM.annotations({ description }).ast;
180
+ }
181
+
182
+ return ast;
183
+ };
184
+
185
+ const isHandlerLike = (value: unknown): value is Toolkit.WithHandler<Record<string, Tool.Any>> => {
186
+ return typeof (value as any).tools === 'object' && typeof (value as any).handle === 'function';
187
+ };
@@ -0,0 +1 @@
1
+ {"conversations":[{"parameters":{"model":"@anthropic/claude-opus-4-0","stream":true,"tools":[{"name":"read-name","description":"Reads the name of an organization.","inputSchema":{"type":"object","required":["org"],"properties":{"org":{"type":"string","description":"The ID of the referenced object. Formats accepted:\n- DXN (dxn:echo:@:01KG7R1ZXWFMWQ4DA1Q6TN1DG4). DXNs can be prepended with an @ symbol for compatibility with in-text references.\n- space ID, object ID tuple (spaceID:objectID)\n- Only object ID that is assumed to be in the current space (01KG7R1ZXWFMWQ4DA1Q6TN1DG4)","examples":["dxn:echo:@:01KG7R1ZXWFMWQ4DA1Q6TN1DG4","@dxn:echo:@:01KG7R1ZXWFMWQ4DA1Q6TN1DG4","BM3FSHFOMJCHCG5QW7JTVKGYABD2GAA7G:01KG7R1ZXWFMWQ4DA1Q6TN1DG4","01KG7R1ZXWFMWQ4DA1Q6TN1DG4"]}},"additionalProperties":false}}]},"prompt":{"content":[{"role":"user","content":"What is the name of the organization? 01JGFJJZ00G0WKQSJGMAKCNT89","options":{"anthropic":{"cacheControl":{"ttl":"5m","type":"ephemeral"}}}}]},"response":[{"type":"response-metadata","id":"msg_01FqHQGxFVdQKeMXjodHavsF","modelId":"claude-opus-4-20250514","timestamp":"1970-01-01T00:00:00.000Z","metadata":{}},{"type":"reasoning-start","id":"0","metadata":{}},{"type":"reasoning-delta","id":"0","delta":"The user is asking for the name of","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" an organization an","metadata":{}},{"type":"reasoning-delta","id":"0","delta":"d has provided what","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" appears to be an","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" object","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" ID: 01JGFJ","metadata":{}},{"type":"reasoning-delta","id":"0","delta":"JZ00G0WK","metadata":{}},{"type":"reasoning-delta","id":"0","delta":"QSJGMAKCNT89","metadata":{}},{"type":"reasoning-delta","id":"0","delta":"\n\nI","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" need to use the read-name function","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" to get the name of this organization.","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" According","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" to the function description, I can","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" pass","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" just","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" the object","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" ID if","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" it's assume","metadata":{}},{"type":"reasoning-delta","id":"0","delta":"d to be in the current space.","metadata":{}},{"type":"reasoning-delta","id":"0","delta":"\n\nLet me call","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" the function with this","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" ID.","metadata":{}},{"type":"reasoning-delta","id":"0","delta":"","metadata":{}},{"type":"reasoning-delta","id":"0","delta":"","metadata":{"anthropic":{"type":"thinking","signature":"EokECkYICxgCKkDkOVtqWk3+YJ1nk31yy/hYUygSTbpQxoD7UKl2RqwyS+tJSV2rou35JEFIl30ogJZiohCBXqY0IZ3YO1SwhWq1EgztHHPI5rGjH4gehN8aDBh3BbEfM6OCraoAQiIwDSGtzFCbT7K+yTBtmtri6uuGvPwNGmRshKURPnFRCjdAf0gj1Jwge4pmIYnlGpRGKvACF4kjtsTHsn8f7ktuuzSEpVNaC6d5VYA6/Fm5ZFaiQPn0/F4fQXy1PNEyo4007gP21Ate8+98CCtlfkOnEE53hElq58doXrVOzpL+uH5b6PBPtM9f1+L9cKjhTPV6djIcewwHTTSJDTM6fr9c82f9u5EDvzNe1QODqlqCiVtNsjWCYOWNZUqILdl0TQ43Hzjf2T+WN6ARHfd3mGVsAtg8vcBM8D4mPvThsTnoswYIeB6Y5aDAA+Xu32jGRmJGclevuy25lJFZG8lAhOXJOdiP88zTG5XCN5ED3GLo2rjKBnQzwGpzg1M0ARKkrNzuLbNZ31uk36ayo+1T381Ld0yIQAX/ZUrLNZ8ovJ1sIHW18hmnyec69+4qWuy//NBWlAfyFOQnQfXM1f2XO5AFBrSILGtHxWM1+KINm1Xh68gHZpjjpyM5g8zl61nDLGxNq3OBugM7NSghygmGPmy2DlxU147cVzOHh7ZXh8fFxBfZlW0YAQ=="}}},{"type":"reasoning-end","id":"0","metadata":{}},{"type":"text-start","id":"1","metadata":{}},{"type":"text-delta","id":"1","delta":"I","metadata":{}},{"type":"text-delta","id":"1","delta":"'ll look","metadata":{}},{"type":"text-delta","id":"1","delta":" up the name of that","metadata":{}},{"type":"text-delta","id":"1","delta":" organization for you.","metadata":{}},{"type":"text-end","id":"1","metadata":{}},{"type":"tool-params-start","id":"toolu_01DdHbHNejZJC4CEjngmNLCf","name":"read-name","providerExecuted":false,"metadata":{}},{"type":"tool-params-delta","id":"toolu_01DdHbHNejZJC4CEjngmNLCf","delta":"","metadata":{}},{"type":"tool-params-delta","id":"toolu_01DdHbHNejZJC4CEjngmNLCf","delta":"{\"or","metadata":{}},{"type":"tool-params-delta","id":"toolu_01DdHbHNejZJC4CEjngmNLCf","delta":"g\": \"01JGFJJ","metadata":{}},{"type":"tool-params-delta","id":"toolu_01DdHbHNejZJC4CEjngmNLCf","delta":"Z00G0WKQ","metadata":{}},{"type":"tool-params-delta","id":"toolu_01DdHbHNejZJC4CEjngmNLCf","delta":"SJGM","metadata":{}},{"type":"tool-params-delta","id":"toolu_01DdHbHNejZJC4CEjngmNLCf","delta":"AKCNT89\"}","metadata":{}},{"type":"tool-params-end","id":"toolu_01DdHbHNejZJC4CEjngmNLCf","metadata":{}},{"type":"tool-call","id":"toolu_01DdHbHNejZJC4CEjngmNLCf","name":"read-name","providerExecuted":false,"metadata":{},"params":{"org":"dxn:echo:@:01JGFJJZ00G0WKQSJGMAKCNT89"}},{"type":"finish","reason":"tool-calls","usage":{"inputTokens":729,"outputTokens":187,"totalTokens":916},"metadata":{"anthropic":{"usage":{"cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":0},"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":729,"output_tokens":8,"server_tool_use":null,"service_tier":"standard"}}}}]},{"parameters":{"model":"@anthropic/claude-opus-4-0","stream":true,"tools":[{"name":"read-name","description":"Reads the name of an organization.","inputSchema":{"type":"object","required":["org"],"properties":{"org":{"type":"string","description":"The ID of the referenced object. Formats accepted:\n- DXN (dxn:echo:@:01KG7R1ZXWFMWQ4DA1Q6TN1DG4). DXNs can be prepended with an @ symbol for compatibility with in-text references.\n- space ID, object ID tuple (spaceID:objectID)\n- Only object ID that is assumed to be in the current space (01KG7R1ZXWFMWQ4DA1Q6TN1DG4)","examples":["dxn:echo:@:01KG7R1ZXWFMWQ4DA1Q6TN1DG4","@dxn:echo:@:01KG7R1ZXWFMWQ4DA1Q6TN1DG4","BM3FSHFOMJCHCG5QW7JTVKGYABD2GAA7G:01KG7R1ZXWFMWQ4DA1Q6TN1DG4","01KG7R1ZXWFMWQ4DA1Q6TN1DG4"]}},"additionalProperties":false}}]},"prompt":{"content":[{"role":"user","content":"What is the name of the organization? 01JGFJJZ00G0WKQSJGMAKCNT89","options":{}},{"role":"assistant","content":[{"type":"reasoning","text":"The user is asking for the name of an organization and has provided what appears to be an object ID: 01JGFJJZ00G0WKQSJGMAKCNT89\n\nI need to use the read-name function to get the name of this organization. According to the function description, I can pass just the object ID if it's assumed to be in the current space.\n\nLet me call the function with this ID.","options":{}},{"type":"text","text":"I'll look up the name of that organization for you.","options":{}},{"type":"tool-call","id":"toolu_01DdHbHNejZJC4CEjngmNLCf","name":"read-name","params":{"org":"01JGFJJZ00G0WKQSJGMAKCNT89"},"providerExecuted":false,"options":{}}],"options":{}},{"role":"tool","content":[{"type":"tool-result","id":"toolu_01DdHbHNejZJC4CEjngmNLCf","name":"read-name","isFailure":false,"result":"BlueYard","providerExecuted":false,"options":{}}],"options":{"anthropic":{"cacheControl":{"ttl":"5m","type":"ephemeral"}}}}]},"response":[{"type":"response-metadata","id":"msg_01X5xvtDymPG7tTUMLZz3eAD","modelId":"claude-opus-4-20250514","timestamp":"1970-01-01T00:00:00.000Z","metadata":{}},{"type":"text-start","id":"0","metadata":{}},{"type":"text-delta","id":"0","delta":"The name of the organization with","metadata":{}},{"type":"text-delta","id":"0","delta":" ID 01JGFJJ","metadata":{}},{"type":"text-delta","id":"0","delta":"Z00G0WKQ","metadata":{}},{"type":"text-delta","id":"0","delta":"SJGMAKCNT89 is","metadata":{}},{"type":"text-delta","id":"0","delta":" **BlueYard**.","metadata":{}},{"type":"text-end","id":"0","metadata":{}},{"type":"finish","reason":"stop","usage":{"inputTokens":801,"outputTokens":39,"totalTokens":840},"metadata":{"anthropic":{"usage":{"cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":0},"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":801,"output_tokens":6,"server_tool_use":null,"service_tier":"standard"}}}}]}]}
@@ -0,0 +1,74 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { describe, it } from '@effect/vitest';
6
+ import * as Effect from 'effect/Effect';
7
+ import * as Schema from 'effect/Schema';
8
+
9
+ import { ConsolePrinter } from '@dxos/ai';
10
+ import { MemoizedAiService } from '@dxos/ai/testing';
11
+ import { AiSession, GenerationObserver, createToolkit } from '@dxos/assistant';
12
+ import { Blueprint } from '@dxos/blueprints';
13
+ import { Database, Obj, Type } from '@dxos/echo';
14
+ import { TestHelpers } from '@dxos/effect/testing';
15
+ import { defineFunction } from '@dxos/functions';
16
+ import { ObjectId } from '@dxos/keys';
17
+ import { Organization } from '@dxos/types';
18
+
19
+ import { AssistantTestLayer } from './testing';
20
+
21
+ ObjectId.dangerouslyDisableRandomness();
22
+
23
+ const readName = defineFunction({
24
+ key: 'dxos.org/function/read-name',
25
+ name: 'Read Name',
26
+ description: 'Reads the name of an organization.',
27
+ inputSchema: Schema.Struct({
28
+ org: Type.Ref(Organization.Organization),
29
+ }),
30
+ outputSchema: Schema.String,
31
+ handler: Effect.fnUntraced(function* ({ data }) {
32
+ const org = yield* Database.load(data.org);
33
+ return org.name ?? '<no org>';
34
+ }),
35
+ });
36
+
37
+ const blueprint = Blueprint.make({
38
+ key: 'dxos.org/blueprint/test',
39
+ name: 'Test blueprint',
40
+ tools: Blueprint.toolDefinitions({ functions: [readName] }),
41
+ });
42
+
43
+ const TestLayer = AssistantTestLayer({
44
+ aiServicePreset: 'edge-remote',
45
+ functions: [readName],
46
+ types: [Organization.Organization],
47
+ });
48
+
49
+ describe('Research', () => {
50
+ it.effect(
51
+ 'call a function with a ref input',
52
+ Effect.fnUntraced(
53
+ function* (_) {
54
+ const org = yield* Database.add(
55
+ Obj.make(Organization.Organization, {
56
+ name: 'BlueYard',
57
+ website: 'https://blueyard.com',
58
+ }),
59
+ );
60
+ yield* Database.flush({ indexes: true });
61
+ yield* new AiSession().run({
62
+ prompt: `What is the name of the organization? ${org.id}`,
63
+ toolkit: yield* createToolkit({
64
+ blueprints: [blueprint],
65
+ }),
66
+ observer: GenerationObserver.fromPrinter(new ConsolePrinter()),
67
+ });
68
+ },
69
+ Effect.provide(TestLayer),
70
+ TestHelpers.provideTestContext,
71
+ ),
72
+ MemoizedAiService.isGenerationEnabled() ? 240_000 : 30_000,
73
+ );
74
+ });
package/src/index.ts CHANGED
@@ -2,8 +2,11 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- export * from './extraction';
6
- export * from './research';
5
+ export * from './conversation';
6
+ export * from './diff';
7
+ export * from './errors';
8
+ export * from './execution-graph';
9
+ export * from './functions';
7
10
  export * from './session';
11
+ export * from './templates';
8
12
  export * from './types';
9
- export * from './blueprint';
@@ -0,0 +1,160 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import type * as Tool from '@effect/ai/Tool';
6
+ import * as Toolkit from '@effect/ai/Toolkit';
7
+ import * as Context from 'effect/Context';
8
+ import * as Effect from 'effect/Effect';
9
+ import * as Layer from 'effect/Layer';
10
+ import * as Pipeable from 'effect/Pipeable';
11
+ import type * as Schema from 'effect/Schema';
12
+ import type * as SchemaAST from 'effect/SchemaAST';
13
+
14
+ /**
15
+ * Unique identifier for generic toolkit instances.
16
+ */
17
+ export const TypeId = '~@dxos/assistant/GenericToolkit';
18
+
19
+ /**
20
+ * Type-level representation of the generic toolkit identifier.
21
+ */
22
+ export type TypeId = typeof TypeId;
23
+
24
+ /**
25
+ * Type-safe way to define toolkits where we don't know specific types of tools,
26
+ * and we want to bundle definition and handlers together.
27
+ *
28
+ * Usefull for plugin-based systems, where tools are dynamically added.
29
+ *
30
+ * @param TR requirements type to the tool invocation.
31
+ * @param E failure type to the handlers layer.
32
+ * @param R requirements type to the handlers layer.
33
+ */
34
+ export interface GenericToolkit<TR = never, E = never, R = never> extends Pipeable.Pipeable {
35
+ readonly [TypeId]: TypeId;
36
+
37
+ /**
38
+ * Toolkit definition.
39
+ */
40
+ readonly toolkit: Toolkit.Toolkit<GenericTools<TR>>;
41
+
42
+ /**
43
+ * Handlers layer.
44
+ */
45
+ readonly layer: Layer.Layer<unknown, E, R>;
46
+
47
+ /**
48
+ * Handlers effect.
49
+ */
50
+ readonly handlers: Effect.Effect<Toolkit.WithHandler<GenericTools<TR>>, E, R>;
51
+ }
52
+
53
+ /**
54
+ * Generic constraint.
55
+ *
56
+ * NOTE: Only use in place of `T extends PortableToolkit.Any`. Not suitable for standalone use.
57
+ */
58
+ export interface Any {
59
+ readonly [TypeId]: TypeId;
60
+ readonly toolkit: Toolkit.Toolkit<any>;
61
+ readonly layer: Layer.Layer<unknown, any, any>;
62
+ }
63
+
64
+ export type InvocationRequirements<T extends Any> = T extends GenericToolkit<infer TR, infer _E, infer _R> ? TR : never;
65
+ export type Failure<T extends Any> = T extends GenericToolkit<infer _TR, infer E, infer _R> ? E : never;
66
+ export type Requirements<T extends Any> = T extends GenericToolkit<infer _TR, infer _E, infer R> ? R : never;
67
+
68
+ /**
69
+ * Creates a portable toolkit from toolkit definition and handlers layer.
70
+ */
71
+ export const make = <Tools extends Record<string, Tool.Any>, E, R>(
72
+ toolkit: Toolkit.Toolkit<Tools>,
73
+ layer: Layer.Layer<Tool.HandlersFor<Tools>, E, R>,
74
+ ): GenericToolkit<E, R> => {
75
+ return {
76
+ [TypeId]: TypeId,
77
+ toolkit: toolkit as any,
78
+ layer: layer as any,
79
+ handlers: toolkit.pipe(Effect.provide(layer)) as any,
80
+ pipe() {
81
+ // eslint-disable-next-line prefer-rest-params
82
+ return Pipeable.pipeArguments(this, arguments);
83
+ },
84
+ };
85
+ };
86
+
87
+ /**
88
+ * Empty generic toolkit.
89
+ */
90
+ export const empty = make(Toolkit.empty, Layer.empty);
91
+
92
+ /**
93
+ * Merges multiple portable toolkits into a single portable toolkit.
94
+ */
95
+ export const merge = <const Toolkits extends ReadonlyArray<Any>>(
96
+ /**
97
+ * The toolkits to merge together.
98
+ */
99
+ ...toolkits: Toolkits
100
+ ): GenericToolkit<
101
+ InvocationRequirements<Toolkits[number]>,
102
+ Failure<Toolkits[number]>,
103
+ Requirements<Toolkits[number]>
104
+ > => {
105
+ return make(
106
+ Toolkit.merge(...toolkits.map((t) => t.toolkit)),
107
+ Layer.mergeAll(...(toolkits.map((t) => t.layer) as any)),
108
+ ) as any;
109
+ };
110
+
111
+ /**
112
+ * Generic tools type where we cannot statically enumerate individual tools.
113
+ */
114
+ export type GenericTools<R = never> = Record<
115
+ string,
116
+ Tool.Tool<
117
+ string,
118
+ {
119
+ readonly parameters: AnyStructSchemaNoContext;
120
+ readonly success: Schema.Schema.AnyNoContext;
121
+ readonly failure: typeof Schema.Never;
122
+ readonly failureMode: Tool.FailureMode;
123
+ },
124
+ R
125
+ >
126
+ >;
127
+
128
+ export interface AnyStructSchemaNoContext extends Pipeable.Pipeable {
129
+ readonly [Schema.TypeId]: any;
130
+ readonly make: any;
131
+ readonly Type: any;
132
+ readonly Encoded: any;
133
+ readonly Context: never;
134
+ readonly ast: SchemaAST.AST;
135
+ readonly fields: Schema.Struct.Fields;
136
+ readonly annotations: any;
137
+ }
138
+
139
+ /**
140
+ * Provides a generic toolkit to the agent.
141
+ */
142
+ export class Provider extends Context.Tag('@dxos/assistant/GenericToolkit.Provider')<
143
+ Provider,
144
+ {
145
+ readonly getToolkit: () => GenericToolkit;
146
+ }
147
+ >() {}
148
+
149
+ /**
150
+ * Layer for providing a generic toolkit to the agent.
151
+ */
152
+ export const providerLayer = (toolkit: GenericToolkit) =>
153
+ Layer.succeed(Provider, {
154
+ getToolkit: () => toolkit,
155
+ });
156
+
157
+ /**
158
+ * Layer for providing an empty generic toolkit to the agent.
159
+ */
160
+ export const providerEmpty = providerLayer(empty);
@@ -0,0 +1,41 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Context from 'effect/Context';
6
+
7
+ import { type ObjectVersion } from '@dxos/echo-db';
8
+ import { type ObjectId } from '@dxos/keys';
9
+
10
+ /**
11
+ * Resolves artifact ids to their versions.
12
+ * Used to give the model a sense of the changes to the artifacts made by users during the conversation.
13
+ * The artifacts versions are pinned in the history, and whenever the artifact changes in-between assistant's steps,
14
+ * a diff is inserted into the conversation.
15
+ *
16
+ * Can be optionally provided to the session run call.
17
+ */
18
+ // TODO(dmaretskyi): Convert to Context.Reference
19
+ export class ArtifactDiffResolver extends Context.Tag('@dxos/assistant/ArtifactDiffResolver')<
20
+ ArtifactDiffResolver,
21
+ ArtifactDiffResolver.Service
22
+ >() {}
23
+
24
+ export namespace ArtifactDiffResolver {
25
+ export type Service = {
26
+ resolve: (
27
+ artifacts: {
28
+ id: ObjectId;
29
+ lastVersion: ObjectVersion;
30
+ }[],
31
+ ) => Promise<
32
+ Map<
33
+ ObjectId,
34
+ {
35
+ version: ObjectVersion;
36
+ diff?: string;
37
+ }
38
+ >
39
+ >;
40
+ };
41
+ }
@@ -0,0 +1,41 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as AiError from '@effect/ai/AiError';
6
+ import * as HttpClientError from '@effect/platform/HttpClientError';
7
+ import * as Effect from 'effect/Effect';
8
+ import * as Schema from 'effect/Schema';
9
+
10
+ import { AiModelError } from '../errors';
11
+
12
+ const AnthropicErrorResponse = Schema.Struct({
13
+ type: Schema.Literal('error'),
14
+ error: Schema.Struct({
15
+ type: Schema.String,
16
+ message: Schema.String,
17
+ }),
18
+ });
19
+
20
+ // TODO(dmaretskyi): Needs rework
21
+ export const mapAiError = (err: AiError.AiError): Effect.Effect<AiError.AiError> =>
22
+ Effect.gen(function* () {
23
+ const cause = err.cause;
24
+ if (HttpClientError.isHttpClientError(cause) && cause.reason === 'StatusCode') {
25
+ const body = yield* cause.response.json.pipe(
26
+ Effect.flatMap(Schema.decodeUnknown(AnthropicErrorResponse, { exact: false })),
27
+ );
28
+
29
+ const parsedCause = new AiModelError({
30
+ message: body.error.message,
31
+ context: { model: 'anthropic', type: body.error.type },
32
+ });
33
+ return AiError.UnknownError.make({
34
+ description: body.error.message,
35
+ module: err.module,
36
+ method: err.method,
37
+ cause: parsedCause,
38
+ });
39
+ }
40
+ return err;
41
+ }).pipe(Effect.catchAll(() => Effect.succeed(err)));
@@ -0,0 +1,124 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { describe, expect, it } from '@effect/vitest';
6
+ import * as Effect from 'effect/Effect';
7
+ import * as Schema from 'effect/Schema';
8
+
9
+ import { Blueprint, Template } from '@dxos/blueprints';
10
+ import { Database, Obj, Query } from '@dxos/echo';
11
+ import { TestHelpers } from '@dxos/effect/testing';
12
+ import { defineFunction } from '@dxos/functions';
13
+ import { Text } from '@dxos/schema';
14
+ import { Organization } from '@dxos/types';
15
+ import { trim } from '@dxos/util';
16
+
17
+ import { createSystemPrompt } from '../templates/system';
18
+ import { AssistantTestLayer } from '../testing';
19
+
20
+ import { formatSystemPrompt } from './format';
21
+
22
+ const organizationListFunction = defineFunction({
23
+ key: 'dxos.org/function/organization-list',
24
+ name: 'Organization List',
25
+ description: 'List organizations',
26
+ inputSchema: Schema.Struct({}),
27
+ outputSchema: Schema.Array(Schema.String),
28
+ handler: Effect.fnUntraced(function* () {
29
+ const organizations = yield* Database.runQuery(Query.type(Organization.Organization));
30
+ return organizations.map((organization) => organization.name);
31
+ }),
32
+ });
33
+
34
+ const TestLayer = AssistantTestLayer({
35
+ types: [Text.Text, Organization.Organization, Blueprint.Blueprint],
36
+ functions: [organizationListFunction],
37
+ });
38
+
39
+ describe('format', () => {
40
+ it.effect(
41
+ 'should format',
42
+ Effect.fnUntraced(
43
+ function* (_) {
44
+ const { db } = yield* Database.Service;
45
+ const object = db.add(
46
+ Obj.make(Organization.Organization, {
47
+ name: 'Test',
48
+ website: 'https://www.test.com',
49
+ }),
50
+ );
51
+
52
+ const blueprint = db.add(
53
+ Blueprint.make({
54
+ key: 'example.com/blueprint/test',
55
+ name: 'Test',
56
+ instructions: Template.make({
57
+ source: trim`
58
+ Test
59
+ This is the test blueprint.
60
+ `,
61
+ }),
62
+ }),
63
+ );
64
+
65
+ const output = yield* formatSystemPrompt({
66
+ system: createSystemPrompt({}),
67
+ blueprints: [blueprint],
68
+ objects: [object],
69
+ });
70
+
71
+ console.log(output);
72
+ },
73
+ Effect.provide(TestLayer),
74
+ TestHelpers.provideTestContext,
75
+ ),
76
+ );
77
+
78
+ it.effect(
79
+ 'should format with function input',
80
+ Effect.fnUntraced(
81
+ function* (_) {
82
+ const { db } = yield* Database.Service;
83
+ const object = db.add(
84
+ Obj.make(Organization.Organization, {
85
+ name: 'Test Org',
86
+ website: 'https://www.test.com',
87
+ }),
88
+ );
89
+
90
+ const blueprint = db.add(
91
+ Blueprint.make({
92
+ key: 'example.com/blueprint/test',
93
+ name: 'Test',
94
+ instructions: Template.make({
95
+ source: trim`
96
+ Organization List:
97
+ {{#each organizations}}
98
+ - {{this}}
99
+ {{/each}}
100
+ `,
101
+ inputs: [
102
+ {
103
+ name: 'organizations',
104
+ kind: 'function',
105
+ function: organizationListFunction.key,
106
+ },
107
+ ],
108
+ }),
109
+ }),
110
+ );
111
+
112
+ const output = yield* formatSystemPrompt({
113
+ system: createSystemPrompt({}),
114
+ blueprints: [blueprint],
115
+ objects: [object],
116
+ });
117
+
118
+ expect(output).to.include('Test Org');
119
+ },
120
+ Effect.provide(TestLayer),
121
+ TestHelpers.provideTestContext,
122
+ ),
123
+ );
124
+ });