@dxos/assistant 0.8.4-main.c85a9c8dae → 0.8.4-main.cb12b3f963

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 (107) hide show
  1. package/dist/lib/neutral/extraction/index.mjs +29 -50
  2. package/dist/lib/neutral/extraction/index.mjs.map +4 -4
  3. package/dist/lib/neutral/index.mjs +765 -362
  4. package/dist/lib/neutral/index.mjs.map +4 -4
  5. package/dist/lib/neutral/meta.json +1 -1
  6. package/dist/types/src/conversation/context.d.ts +28 -22
  7. package/dist/types/src/conversation/context.d.ts.map +1 -1
  8. package/dist/types/src/conversation/index.d.ts +1 -1
  9. package/dist/types/src/conversation/index.d.ts.map +1 -1
  10. package/dist/types/src/conversation/session.d.ts +78 -0
  11. package/dist/types/src/conversation/session.d.ts.map +1 -0
  12. package/dist/types/src/diff.d.ts.map +1 -1
  13. package/dist/types/src/errors.d.ts +12 -12
  14. package/dist/types/src/errors.d.ts.map +1 -1
  15. package/dist/types/src/execution-graph.d.ts.map +1 -1
  16. package/dist/types/src/extraction/extraction-ner-function/index.d.ts +0 -1
  17. package/dist/types/src/extraction/extraction-ner-function/index.d.ts.map +1 -1
  18. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -1
  19. package/dist/types/src/extraction/extraction.d.ts +867 -153
  20. package/dist/types/src/extraction/extraction.d.ts.map +1 -1
  21. package/dist/types/src/extraction/index.d.ts +0 -1
  22. package/dist/types/src/extraction/index.d.ts.map +1 -1
  23. package/dist/types/src/extraction/quotes.d.ts.map +1 -1
  24. package/dist/types/src/functions/services.d.ts +14 -16
  25. package/dist/types/src/functions/services.d.ts.map +1 -1
  26. package/dist/types/src/index.d.ts +1 -0
  27. package/dist/types/src/index.d.ts.map +1 -1
  28. package/dist/types/src/session/artifact-diff.d.ts.map +1 -1
  29. package/dist/types/src/session/error-handling.d.ts.map +1 -1
  30. package/dist/types/src/session/format.d.ts +6 -3
  31. package/dist/types/src/session/format.d.ts.map +1 -1
  32. package/dist/types/src/session/index.d.ts +1 -1
  33. package/dist/types/src/session/request.d.ts +104 -0
  34. package/dist/types/src/session/request.d.ts.map +1 -0
  35. package/dist/types/src/session/toolkit.d.ts +5 -7
  36. package/dist/types/src/session/toolkit.d.ts.map +1 -1
  37. package/dist/types/src/templates/system.d.ts +1 -2
  38. package/dist/types/src/templates/system.d.ts.map +1 -1
  39. package/dist/types/src/tracing.d.ts +233 -0
  40. package/dist/types/src/tracing.d.ts.map +1 -0
  41. package/dist/types/src/types/artifact.d.ts.map +1 -1
  42. package/dist/types/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +24 -40
  44. package/src/conversation/context.test.ts +19 -13
  45. package/src/conversation/context.ts +128 -55
  46. package/src/conversation/index.ts +1 -1
  47. package/src/conversation/session.ts +334 -0
  48. package/src/diff.test.ts +3 -3
  49. package/src/execution-graph.test.ts +1 -1
  50. package/src/execution-graph.ts +16 -6
  51. package/src/extraction/extraction-ner-function/index.ts +0 -1
  52. package/src/extraction/extraction.ts +36 -8
  53. package/src/extraction/index.ts +0 -1
  54. package/src/functions/services.ts +57 -52
  55. package/src/index.ts +1 -0
  56. package/src/session/format.ts +14 -10
  57. package/src/session/index.ts +1 -1
  58. package/src/session/request.ts +342 -0
  59. package/src/session/toolkit.ts +18 -15
  60. package/src/templates/instructions/system.tpl +50 -2
  61. package/src/templates/system.ts +7 -6
  62. package/src/tracing.ts +57 -0
  63. package/dist/lib/neutral/chunk-BE6SRJ4N.mjs +0 -193
  64. package/dist/lib/neutral/chunk-BE6SRJ4N.mjs.map +0 -7
  65. package/dist/lib/neutral/testing/index.mjs +0 -38
  66. package/dist/lib/neutral/testing/index.mjs.map +0 -7
  67. package/dist/types/src/conversation/conversation.d.ts +0 -66
  68. package/dist/types/src/conversation/conversation.d.ts.map +0 -1
  69. package/dist/types/src/conversation/conversation.test.d.ts +0 -2
  70. package/dist/types/src/conversation/conversation.test.d.ts.map +0 -1
  71. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +0 -4
  72. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +0 -1
  73. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts +0 -2
  74. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts.map +0 -1
  75. package/dist/types/src/extraction/extraction-llm-function/index.d.ts +0 -2
  76. package/dist/types/src/extraction/extraction-llm-function/index.d.ts.map +0 -1
  77. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +0 -355
  78. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +0 -1
  79. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts +0 -2
  80. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts.map +0 -1
  81. package/dist/types/src/functions.test.d.ts +0 -2
  82. package/dist/types/src/functions.test.d.ts.map +0 -1
  83. package/dist/types/src/session/format.test.d.ts +0 -2
  84. package/dist/types/src/session/format.test.d.ts.map +0 -1
  85. package/dist/types/src/session/session.d.ts +0 -61
  86. package/dist/types/src/session/session.d.ts.map +0 -1
  87. package/dist/types/src/session/session.test.d.ts +0 -2
  88. package/dist/types/src/session/session.test.d.ts.map +0 -1
  89. package/dist/types/src/testing/index.d.ts +0 -2
  90. package/dist/types/src/testing/index.d.ts.map +0 -1
  91. package/dist/types/src/testing/layer.d.ts +0 -22
  92. package/dist/types/src/testing/layer.d.ts.map +0 -1
  93. package/src/conversation/conversation.test.ts +0 -65
  94. package/src/conversation/conversation.ts +0 -247
  95. package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +0 -84
  96. package/src/extraction/extraction-llm-function/extraction-llm-function.ts +0 -62
  97. package/src/extraction/extraction-llm-function/index.ts +0 -5
  98. package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +0 -116
  99. package/src/extraction/extraction-ner-function/extraction-ner-function.ts +0 -56
  100. package/src/functions.conversations.json +0 -1
  101. package/src/functions.test.ts +0 -74
  102. package/src/session/format.test.ts +0 -124
  103. package/src/session/session.conversations.json +0 -1
  104. package/src/session/session.test.ts +0 -191
  105. package/src/session/session.ts +0 -251
  106. package/src/testing/index.ts +0 -5
  107. package/src/testing/layer.ts +0 -85
@@ -0,0 +1,334 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import type { Registry } from '@effect-atom/atom-react';
6
+ import * as Array from 'effect/Array';
7
+ import * as Context from 'effect/Context';
8
+ import * as Effect from 'effect/Effect';
9
+ import * as Either from 'effect/Either';
10
+ import { pipe } from 'effect/Function';
11
+ import * as Layer from 'effect/Layer';
12
+ import * as Record from 'effect/Record';
13
+ import * as Runtime from 'effect/Runtime';
14
+
15
+ import { type OpaqueToolkit, type ToolExecutionService, type ToolResolverService } from '@dxos/ai';
16
+ import { type Blueprint, type OperationRegistry, Operation, Trace } from '@dxos/compute';
17
+ import { Resource } from '@dxos/context';
18
+ import { Database, Feed, Filter, Obj } from '@dxos/echo';
19
+ import { acquireReleaseResource } from '@dxos/effect';
20
+ import { invariant } from '@dxos/invariant';
21
+ import { log } from '@dxos/log';
22
+ import { McpToolkit } from '@dxos/mcp-client';
23
+ import { Message, type ContentBlock } from '@dxos/types';
24
+
25
+ import { ToolExecutionServices } from '../functions';
26
+ import {
27
+ AiRequest,
28
+ type AiRequestRunError,
29
+ type AiRequestRunRequirements,
30
+ type GenerationObserver,
31
+ createToolkit,
32
+ formatSystemPrompt,
33
+ } from '../session';
34
+ import { McpServerError } from '../tracing';
35
+ import { AiContextBinder, AiContextService } from './context';
36
+
37
+ export interface McpServerConfig {
38
+ url: string;
39
+ protocol: 'sse' | 'http';
40
+ apiKey?: string;
41
+ }
42
+
43
+ export interface AiSessionRunProps<R = never> {
44
+ prompt: string | ContentBlock.Any[];
45
+ system?: string;
46
+ observer?: GenerationObserver;
47
+ toolkit?: OpaqueToolkit.OpaqueToolkit<R>;
48
+
49
+ /**
50
+ * Space-level MCP servers to connect alongside blueprint-defined ones.
51
+ */
52
+ mcpServers?: readonly McpServerConfig[];
53
+ }
54
+
55
+ export type AiSessionOptions = {
56
+ feed: Feed.Feed;
57
+ runtime: Runtime.Runtime<Feed.FeedService>;
58
+ registry?: Registry.Registry;
59
+ };
60
+
61
+ // TODO(dmaretskyi): Take from model characteristics. opus has 200k max tokens.
62
+ /**
63
+ * Summarization threshold in tokens.
64
+ */
65
+ const SUMMARY_THRESHOLD = 80_000;
66
+
67
+ /**
68
+ * Durable conversation state (initiated by users and agents) backed by a Feed.
69
+ * Executes tools based on AI responses and supports cancellation of in-progress requests.
70
+ */
71
+ export class AiSession extends Resource {
72
+ /**
73
+ * Blueprints and objects bound to the session.
74
+ */
75
+ private readonly _binder: AiContextBinder;
76
+ private readonly _feed: Feed.Feed;
77
+ private readonly _runtime: Runtime.Runtime<Feed.FeedService>;
78
+
79
+ public constructor(options: AiSessionOptions) {
80
+ super();
81
+ this._feed = options.feed;
82
+ this._runtime = options.runtime;
83
+ invariant(this._feed);
84
+ invariant(this._runtime);
85
+ this._binder = new AiContextBinder({ feed: this._feed, runtime: this._runtime, registry: options.registry });
86
+ }
87
+
88
+ protected override async _open(): Promise<void> {
89
+ await this._binder.open(this._ctx);
90
+ }
91
+
92
+ public get feed() {
93
+ return this._feed;
94
+ }
95
+
96
+ public get context() {
97
+ return this._binder;
98
+ }
99
+
100
+ public async getHistory(): Promise<Message.Message[]> {
101
+ const queryResult = await Runtime.runPromise(this._runtime)(Feed.query(this._feed, Filter.type(Message.Message)));
102
+ const items = await queryResult.run();
103
+ return items.filter(Obj.instanceOf(Message.Message));
104
+ }
105
+
106
+ getTools(): Effect.Effect<
107
+ Record<string, import('@effect/ai/Tool').Any>,
108
+ never,
109
+ ToolExecutionService | ToolResolverService
110
+ > {
111
+ return Effect.gen(this, function* () {
112
+ const toolkit = yield* createToolkit({ blueprints: this.context.getBlueprints() });
113
+ return toolkit.toolkit.tools;
114
+ }).pipe(Effect.orDie);
115
+ }
116
+
117
+ /**
118
+ * Not provided by default, since users might want to override them.
119
+ */
120
+ makeToolExecutionServices(): Layer.Layer<
121
+ ToolExecutionService | ToolResolverService,
122
+ never,
123
+ OpaqueToolkit.OpaqueToolkitProvider | Operation.Service | OperationRegistry.Service
124
+ > {
125
+ return ToolExecutionServices.pipe(
126
+ Layer.provide(Operation.withInvocationOptions({ conversation: Obj.getDXN(this._feed).toString() })),
127
+ );
128
+ }
129
+ /**
130
+ * Creates a new cancelable request effect.
131
+ */
132
+ public createRequest<R = never>(
133
+ params: AiSessionRunProps<R>,
134
+ ): Effect.Effect<Message.Message[], AiRequestRunError, AiRequestRunRequirements | R> {
135
+ return Effect.gen(this, function* () {
136
+ const history = yield* Effect.promise(() => this.getHistory());
137
+ const blueprints = this.context.getBlueprints();
138
+ const objects = this.context.getObjects();
139
+
140
+ log('run', {
141
+ history: history.length,
142
+ blueprints: blueprints.length,
143
+ objects: objects.length,
144
+ });
145
+
146
+ const request = new AiRequest({
147
+ summarizationThreshold: SUMMARY_THRESHOLD,
148
+ observer: params.observer,
149
+ onOutput: (message) =>
150
+ Effect.promise(() => Runtime.runPromise(this._runtime)(Feed.append(this._feed, [message]))),
151
+ });
152
+
153
+ yield* request.begin({
154
+ history,
155
+ blueprints,
156
+ objects,
157
+ prompt: params.prompt,
158
+ system: params.system,
159
+ });
160
+
161
+ // Turn loop: recompute toolkit and system prompt between turns to pick up dynamically enabled blueprints.
162
+ do {
163
+ yield* Effect.promise(() => this.context.sync());
164
+ const currentBlueprints = this.context.getBlueprints();
165
+ const mcps = yield* connectMcpServers(currentBlueprints, params.mcpServers);
166
+ const toolkit = yield* createToolkit({
167
+ toolkit: params.toolkit,
168
+ blueprints: currentBlueprints,
169
+ opaqueToolkits: mcps,
170
+ });
171
+
172
+ log('toolkit', { tools: Record.keys(toolkit.toolkit.tools) });
173
+ const system = yield* formatSystemPrompt({
174
+ system: params.system,
175
+ blueprints: currentBlueprints,
176
+ objects: this.context.getObjects(),
177
+ }).pipe(Effect.orDie);
178
+
179
+ const { done } = yield* request.runAgentTurn({ system, toolkit });
180
+ if (done) {
181
+ break;
182
+ }
183
+
184
+ yield* request.runTools({ toolkit });
185
+ } while (true);
186
+
187
+ log('result', {
188
+ messages: request.pending.length,
189
+ duration: request.duration,
190
+ toolCalls: request.toolCalls,
191
+ });
192
+
193
+ return [...request.pending];
194
+ }).pipe(
195
+ Effect.provide(
196
+ Layer.mergeAll(
197
+ Layer.succeed(AiContextService, {
198
+ binder: this.context,
199
+ }),
200
+ Layer.succeed(AiSessionService, this),
201
+ Operation.withInvocationOptions({ conversation: Obj.getDXN(this._feed).toString() }),
202
+ ),
203
+ ),
204
+ Effect.withSpan('AiSession.createRequest'),
205
+ );
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Gives access to the ai session.
211
+ */
212
+ export class AiSessionService extends Context.Tag('@dxos/assistant/AiSessionService')<AiSessionService, AiSession>() {
213
+ /**
214
+ * Create a new session layer from options.
215
+ */
216
+ static layer = (options: AiSessionOptions): Layer.Layer<AiSessionService | AiContextService> =>
217
+ aiContextFromSession.pipe(
218
+ Layer.provideMerge(
219
+ Layer.scoped(
220
+ AiSessionService,
221
+ Effect.gen(function* () {
222
+ const session = yield* acquireReleaseResource(() => new AiSession(options));
223
+ return session;
224
+ }),
225
+ ),
226
+ ),
227
+ );
228
+
229
+ /**
230
+ * Create a new session with a new feed.
231
+ */
232
+ static layerNewFeed = (
233
+ options?: Omit<AiSessionOptions, 'feed' | 'runtime'>,
234
+ ): Layer.Layer<AiSessionService | AiContextService, never, Database.Service | Feed.FeedService> =>
235
+ Layer.unwrapScoped(
236
+ Effect.gen(function* () {
237
+ const feed = Feed.make();
238
+ yield* Database.add(feed);
239
+ const runtime = yield* Effect.runtime<Feed.FeedService>();
240
+ return AiSessionService.layer({
241
+ ...options,
242
+ feed,
243
+ runtime,
244
+ });
245
+ }),
246
+ );
247
+
248
+ /**
249
+ * Run a prompt in the current session.
250
+ */
251
+ static run = <R = never>(
252
+ params: AiSessionRunProps<R>,
253
+ ): Effect.Effect<Message.Message[], AiRequestRunError, AiRequestRunRequirements | AiSessionService | R> =>
254
+ Effect.gen(function* () {
255
+ const session = yield* AiSessionService;
256
+ return yield* session.createRequest(params);
257
+ });
258
+ }
259
+
260
+ const aiContextFromSession = Layer.effect(
261
+ AiContextService,
262
+ Effect.gen(function* () {
263
+ const session = yield* AiSessionService;
264
+ return {
265
+ binder: session.context,
266
+ };
267
+ }),
268
+ );
269
+
270
+ const connectMcpServers = (
271
+ blueprints: readonly Blueprint.Blueprint[],
272
+ spaceMcpServers: readonly McpServerConfig[] = [],
273
+ ): Effect.Effect<OpaqueToolkit.OpaqueToolkit[], never, Trace.TraceService> => {
274
+ const blueprintServers: McpToolkit.McpToolkitOptions[] = pipe(
275
+ blueprints,
276
+ Array.flatMap((_) => _.mcpServers ?? []),
277
+ Array.map(({ url, protocol }) => ({ url, kind: protocol })),
278
+ );
279
+ const spaceServers: McpToolkit.McpToolkitOptions[] = spaceMcpServers.map(({ url, protocol, apiKey }) => ({
280
+ url,
281
+ kind: protocol,
282
+ apiKey,
283
+ }));
284
+ const allServers = [...blueprintServers, ...spaceServers];
285
+
286
+ return pipe(
287
+ allServers,
288
+ Effect.forEach((options) =>
289
+ McpToolkit.make(options).pipe(
290
+ // NOTE: Type-inference fails here without explicit void return.
291
+ Effect.tap((toolkit): void =>
292
+ log.info('Connected to MCP server', { url: options.url, tools: Object.keys(toolkit.toolkit.tools).length }),
293
+ ),
294
+ // Surface typed connection failures via ephemeral trace + warn log, then drop the server.
295
+ Effect.tapError((error) =>
296
+ Effect.gen(function* () {
297
+ log.warn('Failed to connect to MCP server', {
298
+ url: error.url,
299
+ kind: error.kind,
300
+ message: error.message,
301
+ });
302
+ yield* Trace.write(McpServerError, {
303
+ url: error.url,
304
+ kind: error.kind,
305
+ message: error.message,
306
+ });
307
+ }),
308
+ ),
309
+ // Catch unexpected defects too (e.g. malformed tool schemas) so a single broken
310
+ // server can never abort the whole turn — surface them through the same channel.
311
+ Effect.catchAllDefect((defect) =>
312
+ Effect.gen(function* () {
313
+ const message = defect instanceof Error ? defect.message : String(defect);
314
+ log.warn('Unexpected MCP defect', { url: options.url, message });
315
+ yield* Trace.write(McpServerError, {
316
+ url: options.url,
317
+ kind: options.kind,
318
+ message: `Unexpected MCP failure: ${message}`,
319
+ });
320
+ return yield* Effect.fail(
321
+ new McpToolkit.McpConnectionError({
322
+ url: options.url,
323
+ kind: options.kind,
324
+ message,
325
+ }),
326
+ );
327
+ }),
328
+ ),
329
+ Effect.either,
330
+ ),
331
+ ),
332
+ Effect.map(Array.filterMap((_) => Either.getRight(_))),
333
+ );
334
+ };
package/src/diff.test.ts CHANGED
@@ -31,7 +31,7 @@ describe('diff', () => {
31
31
  But not this one.
32
32
  `;
33
33
 
34
- const text = db.add(Text.make(document));
34
+ const text = db.add(Text.make({ content: document }));
35
35
  const accessor = createDocAccessor(text, ['content']);
36
36
  const result = applyDiffs(accessor, [
37
37
  `- There'z a typo in this sentence.`,
@@ -53,7 +53,7 @@ describe('diff', () => {
53
53
 
54
54
  const document = '# Shopping list';
55
55
 
56
- const text = db.add(Text.make(document));
56
+ const text = db.add(Text.make({ content: document }));
57
57
  const accessor = createDocAccessor(text, ['content']);
58
58
  const result = applyDiffs(accessor, ['- # Shopping list', '+ # Shopping list\n- Milk']);
59
59
 
@@ -65,7 +65,7 @@ describe('diff', () => {
65
65
  const { db, graph } = await builder.createDatabase();
66
66
  await graph.schemaRegistry.register([Text.Text]);
67
67
 
68
- const text = db.add(Text.make(''));
68
+ const text = db.add(Text.make({ content: '' }));
69
69
  const accessor = createDocAccessor(text, ['content']);
70
70
  const result = applyDiffs(accessor, ['+ # Shopping list']);
71
71
 
@@ -71,7 +71,7 @@ describe('ExecutionGraph', () => {
71
71
  blocks: [
72
72
  {
73
73
  _tag: 'text',
74
- text: '{"id":"01K6AXZKK79H4E54RKP1YZDARK","@type":"dxn:type:dxos.org/type/Organization:0.1.0","@meta":{"keys":[]},"name":"Blue Yard","website":"https://blueyard.com"}',
74
+ text: '{"id":"01K6AXZKK79H4E54RKP1YZDARK","@type":"dxn:type:org.dxos.type.organization:0.1.0","@meta":{"keys":[]},"name":"Blue Yard","website":"https://blueyard.com"}',
75
75
  },
76
76
  ],
77
77
  properties: {},
@@ -40,7 +40,7 @@ enum IconType {
40
40
  // Interactions.
41
41
  USER = 'ph--user--regular',
42
42
  USER_INTERACTION = 'ph--user-sound--regular',
43
- AGENT = 'ph--robot--regular',
43
+ AGENT = 'ph--drone--regular',
44
44
  THINKING = 'ph--brain--regular',
45
45
  LINK = 'ph--link--regular',
46
46
  TOOL = 'ph--wrench--regular',
@@ -199,13 +199,19 @@ export class ExecutionGraph {
199
199
  */
200
200
  private _updatePendingToolResults(toolCallId: string, agentStatusId: string) {
201
201
  const toolResultId = this._pendingToolResults.get(toolCallId);
202
- if (!toolResultId) return;
202
+ if (!toolResultId) {
203
+ return;
204
+ }
203
205
 
204
206
  const toolResultCommit = this._commits.find((c) => c.id === toolResultId);
205
- if (!toolResultCommit) return;
207
+ if (!toolResultCommit) {
208
+ return;
209
+ }
206
210
 
207
211
  const toolCallCommitId = this._toolCallCommitIds.get(toolCallId);
208
- if (!toolCallCommitId) return;
212
+ if (!toolCallCommitId) {
213
+ return;
214
+ }
209
215
 
210
216
  // Replace tool call commit with AgentStatus commit.
211
217
  const toolCallIndex = toolResultCommit.parents.indexOf(toolCallCommitId);
@@ -221,7 +227,9 @@ export class ExecutionGraph {
221
227
  */
222
228
  private _handleLateToolResultUpdate(toolCallId: string, toolResultId: string) {
223
229
  const toolCallCommitId = this._toolCallCommitIds.get(toolCallId);
224
- if (!toolCallCommitId) return;
230
+ if (!toolCallCommitId) {
231
+ return;
232
+ }
225
233
 
226
234
  const messageId = toolCallCommitId.split('_toolCall_')[0];
227
235
  const toolCallBranch = `${messageId}_${toolCallId}`;
@@ -372,7 +380,9 @@ const createBlockCommit = (
372
380
  const timestamp = new Date(message.created);
373
381
  switch (block._tag) {
374
382
  case 'text':
375
- if (!block.text.trim().length) return null;
383
+ if (!block.text.trim().length) {
384
+ return null;
385
+ }
376
386
  return {
377
387
  id: getGenericBlockId(message.id, idx),
378
388
  branch,
@@ -2,5 +2,4 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './extraction-ner-function';
6
5
  export * from './named-entity-recognition';
@@ -4,10 +4,8 @@
4
4
 
5
5
  import * as Schema from 'effect/Schema';
6
6
 
7
- import { asyncTimeout } from '@dxos/async';
7
+ import { Operation } from '@dxos/compute';
8
8
  import { Obj } from '@dxos/echo';
9
- import { type FunctionDefinition } from '@dxos/functions';
10
- import { type FunctionExecutor } from '@dxos/functions-runtime';
11
9
  import { log } from '@dxos/log';
12
10
  import { Message } from '@dxos/types';
13
11
 
@@ -31,8 +29,7 @@ export interface ExtractionOutput extends Schema.Schema.Type<typeof ExtractionOu
31
29
 
32
30
  export type ProcessTranscriptMessageProps = {
33
31
  input: ExtractionInput;
34
- function: FunctionDefinition<ExtractionInput, ExtractionOutput>;
35
- executor: FunctionExecutor;
32
+ function: Operation.Definition<ExtractionInput, ExtractionOutput>;
36
33
 
37
34
  options?: {
38
35
  /**
@@ -49,7 +46,35 @@ export type ProcessTranscriptMessageProps = {
49
46
  };
50
47
  };
51
48
 
52
- export type ExtractionFunction = FunctionDefinition<ExtractionInput, ExtractionOutput>;
49
+ export type ExtractionFunction = Operation.Definition<ExtractionInput, ExtractionOutput>;
50
+
51
+ /**
52
+ * Placeholder for Anthropic-based entity extraction.
53
+ * Implementation is currently disabled pending restoration of extraction logic.
54
+ */
55
+ export const extractionAnthropicFunction = Operation.make({
56
+ meta: {
57
+ key: 'org.dxos.function.extraction.anthropic',
58
+ name: 'Entity Extraction (Anthropic)',
59
+ description: 'Extract entities from transcript using Anthropic LLM.',
60
+ },
61
+ input: ExtractionInput,
62
+ output: ExtractionOutput,
63
+ });
64
+
65
+ /**
66
+ * Placeholder for NER-based entity extraction.
67
+ * Implementation is currently disabled pending restoration of extraction logic.
68
+ */
69
+ export const extractionNerFunction = Operation.make({
70
+ meta: {
71
+ key: 'org.dxos.function.extraction.ner',
72
+ name: 'Entity Extraction (NER)',
73
+ description: 'Extract entities from transcript using Named Entity Recognition.',
74
+ },
75
+ input: ExtractionInput,
76
+ output: ExtractionOutput,
77
+ });
53
78
 
54
79
  /**
55
80
  * Extract entities from the transcript message and add them to the message.
@@ -58,9 +83,9 @@ export type ExtractionFunction = FunctionDefinition<ExtractionInput, ExtractionO
58
83
  export const processTranscriptMessage = async (params: ProcessTranscriptMessageProps): Promise<ExtractionOutput> => {
59
84
  try {
60
85
  if (params.options?.timeout && params.options.timeout > 0) {
61
- return await asyncTimeout(params.executor.invoke(params.function, params.input), params.options.timeout);
86
+ // return await asyncTimeout(params.executor.invoke(params.function, params.input), params.options.timeout);
62
87
  } else {
63
- return await params.executor.invoke(params.function, params.input);
88
+ // return await params.executor.invoke(params.function, params.input);
64
89
  }
65
90
  } catch (error) {
66
91
  if (params.options?.fallbackToRaw) {
@@ -73,4 +98,7 @@ export const processTranscriptMessage = async (params: ProcessTranscriptMessageP
73
98
  throw error;
74
99
  }
75
100
  }
101
+
102
+ // TODO(dmaretskyi): Restore extraction logic.
103
+ return { message: params.input.message, timeElapsed: 0 };
76
104
  };
@@ -3,6 +3,5 @@
3
3
  //
4
4
 
5
5
  export * from './extraction';
6
- export * from './extraction-llm-function';
7
6
  export * from './extraction-ner-function';
8
7
  export * from './quotes';