@dxos/assistant 0.8.4-main.ead640a → 0.8.4-main.ef1bc66f44
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.
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-ZPC54VRM.mjs +596 -0
- package/dist/lib/neutral/chunk-ZPC54VRM.mjs.map +7 -0
- package/dist/lib/neutral/extraction/index.mjs +225 -0
- package/dist/lib/neutral/extraction/index.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/index.mjs +346 -350
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/testing/index.mjs +38 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/conversation/context.d.ts +97 -62
- package/dist/types/src/conversation/context.d.ts.map +1 -1
- package/dist/types/src/conversation/context.test.d.ts +2 -0
- package/dist/types/src/conversation/context.test.d.ts.map +1 -0
- package/dist/types/src/conversation/conversation.d.ts +41 -16
- package/dist/types/src/conversation/conversation.d.ts.map +1 -1
- package/dist/types/src/conversation/conversation.test.d.ts +2 -0
- package/dist/types/src/conversation/conversation.test.d.ts.map +1 -0
- package/dist/types/src/diff.d.ts +3 -1
- package/dist/types/src/diff.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts +22 -30
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/execution-graph.d.ts +5 -2
- package/dist/types/src/execution-graph.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +254 -248
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction.d.ts +344 -303
- package/dist/types/src/extraction/extraction.d.ts.map +1 -1
- package/dist/types/src/extraction/quotes.d.ts +2 -2
- package/dist/types/src/extraction/quotes.d.ts.map +1 -1
- package/dist/types/src/functions/services.d.ts +6 -6
- package/dist/types/src/functions/services.d.ts.map +1 -1
- package/dist/types/src/functions.test.d.ts +2 -0
- package/dist/types/src/functions.test.d.ts.map +1 -0
- package/dist/types/src/session/GenericToolkit.d.ts +107 -0
- package/dist/types/src/session/GenericToolkit.d.ts.map +1 -0
- package/dist/types/src/session/artifact-diff.d.ts +1 -1
- package/dist/types/src/session/artifact-diff.d.ts.map +1 -1
- package/dist/types/src/session/format.d.ts +4 -176
- package/dist/types/src/session/format.d.ts.map +1 -1
- package/dist/types/src/session/index.d.ts +2 -0
- package/dist/types/src/session/index.d.ts.map +1 -1
- package/dist/types/src/session/observer.d.ts +6 -5
- package/dist/types/src/session/observer.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +16 -11
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/dist/types/src/session/toolkit.d.ts +5 -6
- package/dist/types/src/session/toolkit.d.ts.map +1 -1
- package/dist/types/src/session/version-pin.d.ts +3 -3
- package/dist/types/src/session/version-pin.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/layer.d.ts +22 -0
- package/dist/types/src/testing/layer.d.ts.map +1 -0
- package/dist/types/src/types/artifact.d.ts +14 -2
- package/dist/types/src/types/artifact.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -31
- package/src/conversation/context.test.ts +46 -0
- package/src/conversation/context.ts +211 -67
- package/src/conversation/conversation.test.ts +65 -0
- package/src/conversation/conversation.ts +128 -53
- package/src/diff.test.ts +37 -6
- package/src/diff.ts +18 -4
- package/src/errors.ts +2 -2
- package/src/execution-graph.test.ts +45 -43
- package/src/execution-graph.ts +23 -14
- package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +2 -2
- package/src/extraction/extraction-llm-function/extraction-llm-function.ts +44 -54
- package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +15 -14
- package/src/extraction/extraction-ner-function/extraction-ner-function.ts +36 -44
- package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +10 -5
- package/src/extraction/extraction.ts +9 -8
- package/src/extraction/quotes.ts +4 -5
- package/src/functions/services.ts +66 -37
- package/src/functions.conversations.json +1 -0
- package/src/functions.test.ts +74 -0
- package/src/session/GenericToolkit.ts +160 -0
- package/src/session/artifact-diff.ts +1 -1
- package/src/session/format.test.ts +103 -39
- package/src/session/format.ts +17 -16
- package/src/session/index.ts +3 -0
- package/src/session/observer.ts +5 -3
- package/src/session/session.conversations.json +1 -1
- package/src/session/session.test.ts +28 -15
- package/src/session/session.ts +44 -21
- package/src/session/toolkit.ts +13 -22
- package/src/session/version-pin.ts +6 -6
- package/src/templates/{format.tpl → instructions/format.tpl} +1 -4
- package/src/templates/system.ts +2 -2
- package/src/testing/index.ts +5 -0
- package/src/testing/layer.ts +84 -0
- package/src/types/artifact.ts +43 -6
- package/dist/lib/browser/chunk-CWGVG235.mjs +0 -380
- package/dist/lib/browser/chunk-CWGVG235.mjs.map +0 -7
- package/dist/lib/browser/chunk-UB26N5UF.mjs +0 -89
- package/dist/lib/browser/chunk-UB26N5UF.mjs.map +0 -7
- package/dist/lib/browser/extraction/index.mjs +0 -272
- package/dist/lib/browser/extraction/index.mjs.map +0 -7
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/named-entity-recognition-QPYHML66.mjs +0 -13
- package/dist/lib/node-esm/chunk-BCFXTNSK.mjs +0 -91
- package/dist/lib/node-esm/chunk-BCFXTNSK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OV5PMQPB.mjs +0 -382
- package/dist/lib/node-esm/chunk-OV5PMQPB.mjs.map +0 -7
- package/dist/lib/node-esm/extraction/index.mjs +0 -273
- package/dist/lib/node-esm/extraction/index.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -934
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/named-entity-recognition-2HDF46YX.mjs +0 -14
- package/dist/lib/node-esm/named-entity-recognition-2HDF46YX.mjs.map +0 -7
- package/dist/types/src/summarization/summarization.test.d.ts +0 -2
- package/dist/types/src/summarization/summarization.test.d.ts.map +0 -1
- package/src/summarization/summarization.test.ts +0 -202
- /package/dist/lib/{browser/named-entity-recognition-QPYHML66.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/src/extraction/extraction-llm-function/{instructions.tpl → transcription-instructions.tpl} +0 -0
- /package/src/templates/{system.tpl → instructions/system.tpl} +0 -0
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AiSession
|
|
3
|
-
} from "../chunk-CWGVG235.mjs";
|
|
4
|
-
import {
|
|
5
|
-
combineNerTokens,
|
|
6
|
-
createTokenGroups,
|
|
7
|
-
extractFullEntities,
|
|
8
|
-
getNer
|
|
9
|
-
} from "../chunk-UB26N5UF.mjs";
|
|
10
|
-
|
|
11
|
-
// src/extraction/extraction.ts
|
|
12
|
-
import * as Schema from "effect/Schema";
|
|
13
|
-
import { asyncTimeout } from "@dxos/async";
|
|
14
|
-
import { Expando } from "@dxos/echo/internal";
|
|
15
|
-
import { log } from "@dxos/log";
|
|
16
|
-
import { DataType } from "@dxos/schema";
|
|
17
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/core/assistant/src/extraction/extraction.ts";
|
|
18
|
-
var ExtractionInput = Schema.Struct({
|
|
19
|
-
message: DataType.Message,
|
|
20
|
-
objects: Schema.optional(Schema.Array(Expando)),
|
|
21
|
-
options: Schema.optional(Schema.Struct({
|
|
22
|
-
timeout: Schema.optional(Schema.Number),
|
|
23
|
-
fallbackToRaw: Schema.optional(Schema.Boolean)
|
|
24
|
-
}))
|
|
25
|
-
});
|
|
26
|
-
var ExtractionOutput = Schema.Struct({
|
|
27
|
-
message: DataType.Message,
|
|
28
|
-
timeElapsed: Schema.Number
|
|
29
|
-
});
|
|
30
|
-
var processTranscriptMessage = async (params) => {
|
|
31
|
-
try {
|
|
32
|
-
if (params.options?.timeout && params.options.timeout > 0) {
|
|
33
|
-
return await asyncTimeout(params.executor.invoke(params.function, params.input), params.options.timeout);
|
|
34
|
-
} else {
|
|
35
|
-
return await params.executor.invoke(params.function, params.input);
|
|
36
|
-
}
|
|
37
|
-
} catch (error) {
|
|
38
|
-
if (params.options?.fallbackToRaw) {
|
|
39
|
-
log.warn("failed to process message, falling back to raw text", {
|
|
40
|
-
error
|
|
41
|
-
}, {
|
|
42
|
-
F: __dxlog_file,
|
|
43
|
-
L: 66,
|
|
44
|
-
S: void 0,
|
|
45
|
-
C: (f, a) => f(...a)
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
message: params.input.message,
|
|
49
|
-
timeElapsed: 0
|
|
50
|
-
};
|
|
51
|
-
} else {
|
|
52
|
-
throw error;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// src/extraction/extraction-llm-function/extraction-llm-function.ts
|
|
58
|
-
import { AiService } from "@dxos/ai";
|
|
59
|
-
import { Obj } from "@dxos/echo";
|
|
60
|
-
import { create } from "@dxos/echo/internal";
|
|
61
|
-
import { defineFunction } from "@dxos/functions";
|
|
62
|
-
import { DataType as DataType2 } from "@dxos/schema";
|
|
63
|
-
|
|
64
|
-
// src/extraction/quotes.ts
|
|
65
|
-
import * as Schema2 from "effect/Schema";
|
|
66
|
-
import { Filter, Query } from "@dxos/echo";
|
|
67
|
-
import { ObjectId } from "@dxos/echo/internal";
|
|
68
|
-
import { DXN } from "@dxos/keys";
|
|
69
|
-
import { log as log2 } from "@dxos/log";
|
|
70
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/assistant/src/extraction/quotes.ts";
|
|
71
|
-
var ReferencedQuotes = Schema2.Struct({
|
|
72
|
-
references: Schema2.Array(Schema2.Struct({
|
|
73
|
-
id: Schema2.String,
|
|
74
|
-
quote: Schema2.String
|
|
75
|
-
})).pipe(Schema2.mutable).annotations({
|
|
76
|
-
// TODO(burdon): Does this description make sense?
|
|
77
|
-
description: `
|
|
78
|
-
The references to the context objects that are mentioned in the transcript.
|
|
79
|
-
Quote should match the original transcript text exactly, while id is the id of the context object.
|
|
80
|
-
`
|
|
81
|
-
})
|
|
82
|
-
});
|
|
83
|
-
var findQuotes = async (quotes, db) => {
|
|
84
|
-
const references = await Promise.all(quotes.map(async (quote) => {
|
|
85
|
-
const { objects } = await db.query(Query.select(Filter.text(quote, {
|
|
86
|
-
type: "vector"
|
|
87
|
-
}))).run();
|
|
88
|
-
log2.info("found quotes in vector index", {
|
|
89
|
-
objects,
|
|
90
|
-
quote
|
|
91
|
-
}, {
|
|
92
|
-
F: __dxlog_file2,
|
|
93
|
-
L: 35,
|
|
94
|
-
S: void 0,
|
|
95
|
-
C: (f, a) => f(...a)
|
|
96
|
-
});
|
|
97
|
-
return objects.length > 0 ? [
|
|
98
|
-
{
|
|
99
|
-
id: objects[0].id.toString(),
|
|
100
|
-
quote
|
|
101
|
-
}
|
|
102
|
-
] : [];
|
|
103
|
-
}));
|
|
104
|
-
return {
|
|
105
|
-
references: references.flat()
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
var insertReferences = (text, quotes) => {
|
|
109
|
-
for (const quote of quotes.references) {
|
|
110
|
-
if (!ObjectId.isValid(quote.id)) {
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
const regex = new RegExp(quote.quote.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "gi");
|
|
114
|
-
text = text.replace(regex, `[${quote.quote}](${DXN.fromLocalObjectId(quote.id).toString()})`);
|
|
115
|
-
}
|
|
116
|
-
return text;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
// raw-loader:/__w/dxos/dxos/packages/core/assistant/src/extraction/extraction-llm-function/instructions.tpl?raw
|
|
120
|
-
var instructions_default = 'You are an AI assistant specialized in processing and enhancing transcripts with contextual information.\nYour task is to analyze a given transcript and extract references to the context objects.\n\nThe context and transcript are provided in the user message in `context` and `transcript` XML tags.\n\nHere are your instructions:\n\n1. Read the transcript and context information provided above.\n\n2. Process each segment of the transcript separately.\n\n3. For each segment:\n a. Analyze the content and identify relevant information from the context.\n b. Extract a number of references to the context objects that are mentioned in the segment.\n c. Output the references in the format `{ "quote": "earnings report", "id": "01JT0JP9AX0XKGZX4MV4B69VT6" }`.\n d. If there are no references, just output an empty array.\n\n4. Maintain the exact order and structure of the original transcript segments.\n\nOutput Format:\nYou have been provided with a tool that specifies output format\n\nRemember:\n- Only quote the text that is in the transcript.\n- Analyze each segment carefully before processing it.\n- Only reference objects that appear in the context and exactly by their id, If the object is not in the context, do not insert a reference. \n\nNow, process the transcript and context provided below according to these instructions.';
|
|
121
|
-
|
|
122
|
-
// src/extraction/extraction-llm-function/extraction-llm-function.ts
|
|
123
|
-
var extractionAnthropicFunction = defineFunction({
|
|
124
|
-
key: "dxos.org/function/extraction/extract-entities",
|
|
125
|
-
name: "Extract Entities",
|
|
126
|
-
description: "Extract entities from the transcript message and add them to the message.",
|
|
127
|
-
inputSchema: ExtractionInput,
|
|
128
|
-
outputSchema: ExtractionOutput,
|
|
129
|
-
handler: async ({ data: { message, objects }, context }) => {
|
|
130
|
-
const startTime = performance.now();
|
|
131
|
-
const ai = context.getService(AiService.AiService);
|
|
132
|
-
const session = new AiSession({
|
|
133
|
-
operationModel: "configured"
|
|
134
|
-
});
|
|
135
|
-
const result = await session.runStructured(ReferencedQuotes, {
|
|
136
|
-
generationOptions: {
|
|
137
|
-
model: "@anthropic/claude-3-5-haiku-20241022"
|
|
138
|
-
},
|
|
139
|
-
client: ai.client,
|
|
140
|
-
systemPrompt: instructions_default,
|
|
141
|
-
history: [
|
|
142
|
-
Obj.make(DataType2.Message, {
|
|
143
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
144
|
-
sender: {
|
|
145
|
-
role: "user"
|
|
146
|
-
},
|
|
147
|
-
blocks: [
|
|
148
|
-
{
|
|
149
|
-
_tag: "text",
|
|
150
|
-
text: `<context>${JSON.stringify(objects)}</context>`
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
_tag: "text",
|
|
154
|
-
text: `<transcript>${JSON.stringify(message.blocks)}</transcript>`
|
|
155
|
-
}
|
|
156
|
-
]
|
|
157
|
-
})
|
|
158
|
-
],
|
|
159
|
-
artifacts: [],
|
|
160
|
-
prompt: "",
|
|
161
|
-
tools: []
|
|
162
|
-
});
|
|
163
|
-
return {
|
|
164
|
-
timeElapsed: performance.now() - startTime,
|
|
165
|
-
message: create(DataType2.Message, {
|
|
166
|
-
...message,
|
|
167
|
-
blocks: message.blocks.map((block) => block._tag !== "transcript" ? block : {
|
|
168
|
-
...block,
|
|
169
|
-
text: insertReferences(block.text, result)
|
|
170
|
-
})
|
|
171
|
-
})
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
// src/extraction/extraction-ner-function/extraction-ner-function.ts
|
|
177
|
-
import { asyncTimeout as asyncTimeout2 } from "@dxos/async";
|
|
178
|
-
import { create as create2 } from "@dxos/echo/internal";
|
|
179
|
-
import { DatabaseService, defineFunction as defineFunction2 } from "@dxos/functions";
|
|
180
|
-
import { invariant } from "@dxos/invariant";
|
|
181
|
-
import { log as log3 } from "@dxos/log";
|
|
182
|
-
import { DataType as DataType3 } from "@dxos/schema";
|
|
183
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/assistant/src/extraction/extraction-ner-function/extraction-ner-function.ts";
|
|
184
|
-
var extractionNerFunction = defineFunction2({
|
|
185
|
-
key: "dxos.org/function/extraction/extract-entities",
|
|
186
|
-
name: "Extract Entities",
|
|
187
|
-
description: "Extracts named entities from a text",
|
|
188
|
-
inputSchema: ExtractionInput,
|
|
189
|
-
outputSchema: ExtractionOutput,
|
|
190
|
-
handler: async ({ data: { message, options }, context }) => {
|
|
191
|
-
log3.info("input", {
|
|
192
|
-
message,
|
|
193
|
-
options
|
|
194
|
-
}, {
|
|
195
|
-
F: __dxlog_file3,
|
|
196
|
-
L: 29,
|
|
197
|
-
S: void 0,
|
|
198
|
-
C: (f, a) => f(...a)
|
|
199
|
-
});
|
|
200
|
-
const startTime = performance.now();
|
|
201
|
-
const { db } = context.getService(DatabaseService);
|
|
202
|
-
const { extractFullEntities: extractFullEntities2 } = await import("../named-entity-recognition-QPYHML66.mjs");
|
|
203
|
-
const entitiesPromise = Promise.all(message.blocks.map(async (block) => {
|
|
204
|
-
invariant(block._tag === "transcript" || block._tag === "text", void 0, {
|
|
205
|
-
F: __dxlog_file3,
|
|
206
|
-
L: 36,
|
|
207
|
-
S: void 0,
|
|
208
|
-
A: [
|
|
209
|
-
"block._tag === 'transcript' || block._tag === 'text'",
|
|
210
|
-
""
|
|
211
|
-
]
|
|
212
|
-
});
|
|
213
|
-
return extractFullEntities2(block.text);
|
|
214
|
-
})).then((entities2) => entities2.flat());
|
|
215
|
-
const entities = options?.timeout ? await asyncTimeout2(entitiesPromise, options.timeout) : await entitiesPromise;
|
|
216
|
-
log3.info("entities", {
|
|
217
|
-
entities
|
|
218
|
-
}, {
|
|
219
|
-
F: __dxlog_file3,
|
|
220
|
-
L: 42,
|
|
221
|
-
S: void 0,
|
|
222
|
-
C: (f, a) => f(...a)
|
|
223
|
-
});
|
|
224
|
-
const quoteReferences = await findQuotes(entities.map((entity) => entity.word), db);
|
|
225
|
-
const blocksWithReferences = message.blocks.map((block) => {
|
|
226
|
-
invariant(block._tag === "transcript" || block._tag === "text", void 0, {
|
|
227
|
-
F: __dxlog_file3,
|
|
228
|
-
L: 49,
|
|
229
|
-
S: void 0,
|
|
230
|
-
A: [
|
|
231
|
-
"block._tag === 'transcript' || block._tag === 'text'",
|
|
232
|
-
""
|
|
233
|
-
]
|
|
234
|
-
});
|
|
235
|
-
return {
|
|
236
|
-
...block,
|
|
237
|
-
text: insertReferences(block._tag, quoteReferences)
|
|
238
|
-
};
|
|
239
|
-
});
|
|
240
|
-
const messageWithReferences = create2(DataType3.Message, {
|
|
241
|
-
...message,
|
|
242
|
-
blocks: blocksWithReferences
|
|
243
|
-
});
|
|
244
|
-
log3.info("output", {
|
|
245
|
-
messageWithReferences
|
|
246
|
-
}, {
|
|
247
|
-
F: __dxlog_file3,
|
|
248
|
-
L: 58,
|
|
249
|
-
S: void 0,
|
|
250
|
-
C: (f, a) => f(...a)
|
|
251
|
-
});
|
|
252
|
-
return {
|
|
253
|
-
message: messageWithReferences,
|
|
254
|
-
timeElapsed: performance.now() - startTime
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
export {
|
|
259
|
-
ExtractionInput,
|
|
260
|
-
ExtractionOutput,
|
|
261
|
-
ReferencedQuotes,
|
|
262
|
-
combineNerTokens,
|
|
263
|
-
createTokenGroups,
|
|
264
|
-
extractFullEntities,
|
|
265
|
-
extractionAnthropicFunction,
|
|
266
|
-
extractionNerFunction,
|
|
267
|
-
findQuotes,
|
|
268
|
-
getNer,
|
|
269
|
-
insertReferences,
|
|
270
|
-
processTranscriptMessage
|
|
271
|
-
};
|
|
272
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/extraction/extraction.ts", "../../../../src/extraction/extraction-llm-function/extraction-llm-function.ts", "../../../../src/extraction/quotes.ts", "raw-loader:/__w/dxos/dxos/packages/core/assistant/src/extraction/extraction-llm-function/instructions.tpl?raw", "../../../../src/extraction/extraction-ner-function/extraction-ner-function.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { asyncTimeout } from '@dxos/async';\nimport { Expando } from '@dxos/echo/internal';\nimport { type FunctionDefinition, type FunctionExecutor } from '@dxos/functions';\nimport { log } from '@dxos/log';\nimport { DataType } from '@dxos/schema';\n\nexport const ExtractionInput = Schema.Struct({\n message: DataType.Message,\n objects: Schema.optional(Schema.Array(Expando)),\n options: Schema.optional(\n Schema.Struct({\n timeout: Schema.optional(Schema.Number),\n fallbackToRaw: Schema.optional(Schema.Boolean),\n }),\n ),\n});\nexport interface ExtractionInput extends Schema.Schema.Type<typeof ExtractionInput> {}\n\nexport const ExtractionOutput = Schema.Struct({\n message: DataType.Message,\n timeElapsed: Schema.Number,\n});\nexport interface ExtractionOutput extends Schema.Schema.Type<typeof ExtractionOutput> {}\n\nexport type ProcessTranscriptMessageParams = {\n input: ExtractionInput;\n function: FunctionDefinition<ExtractionInput, ExtractionOutput>;\n executor: FunctionExecutor;\n\n options?: {\n /**\n * Timeout for the entity extraction.\n */\n timeout?: number;\n\n /**\n * Fallback to raw text if the entity extraction fails.\n * Otherwise the function will throw an error.\n * @default false\n */\n fallbackToRaw?: boolean;\n };\n};\n\nexport type ExtractionFunction = FunctionDefinition<ExtractionInput, ExtractionOutput>;\n\n/**\n * Extract entities from the transcript message and add them to the message.\n */\n// TODO(dmaretskyi): Move context to a vector search index.\nexport const processTranscriptMessage = async (params: ProcessTranscriptMessageParams): Promise<ExtractionOutput> => {\n try {\n if (params.options?.timeout && params.options.timeout > 0) {\n return await asyncTimeout(params.executor.invoke(params.function, params.input), params.options.timeout);\n } else {\n return await params.executor.invoke(params.function, params.input);\n }\n } catch (error) {\n if (params.options?.fallbackToRaw) {\n log.warn('failed to process message, falling back to raw text', { error });\n return {\n message: params.input.message,\n timeElapsed: 0,\n };\n } else {\n throw error;\n }\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// ISSUE(burdon): defineFunction\n// @ts-nocheck\n\nimport { AiService } from '@dxos/ai';\nimport { Obj } from '@dxos/echo';\nimport { create } from '@dxos/echo/internal';\nimport { type FunctionDefinition, defineFunction } from '@dxos/functions';\nimport { type ContentBlock, DataType } from '@dxos/schema';\n\nimport { AiSession } from '../../session';\nimport { ExtractionInput, ExtractionOutput } from '../extraction';\nimport { ReferencedQuotes, insertReferences } from '../quotes';\n\nimport PROMPT from './instructions.tpl?raw';\n\nexport const extractionAnthropicFunction: FunctionDefinition<ExtractionInput, ExtractionOutput> = defineFunction({\n key: 'dxos.org/function/extraction/extract-entities',\n name: 'Extract Entities',\n description: 'Extract entities from the transcript message and add them to the message.',\n inputSchema: ExtractionInput,\n outputSchema: ExtractionOutput,\n handler: async ({ data: { message, objects }, context }) => {\n const startTime = performance.now();\n const ai = context.getService(AiService.AiService);\n const session = new AiSession({ operationModel: 'configured' });\n const result = await session.runStructured(ReferencedQuotes, {\n generationOptions: {\n model: '@anthropic/claude-3-5-haiku-20241022',\n },\n client: ai.client,\n systemPrompt: PROMPT,\n history: [\n Obj.make(DataType.Message, {\n created: new Date().toISOString(),\n sender: { role: 'user' },\n blocks: [\n {\n _tag: 'text',\n text: `<context>${JSON.stringify(objects)}</context>`,\n } satisfies ContentBlock.Text,\n {\n _tag: 'text',\n text: `<transcript>${JSON.stringify(message.blocks)}</transcript>`,\n } satisfies ContentBlock.Text,\n ],\n }),\n ],\n artifacts: [],\n prompt: '',\n tools: [],\n } as any); // TODO(burdon): Rewrite test.\n\n return {\n timeElapsed: performance.now() - startTime,\n message: create(DataType.Message, {\n ...message,\n blocks: message.blocks.map((block) =>\n block._tag !== 'transcript'\n ? block\n : {\n ...block,\n text: insertReferences(block.text, result),\n },\n ),\n }),\n };\n },\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Filter, Query } from '@dxos/echo';\nimport { ObjectId } from '@dxos/echo/internal';\nimport { type EchoDatabase } from '@dxos/echo-db';\nimport { DXN } from '@dxos/keys';\nimport { log } from '@dxos/log';\n\nexport const ReferencedQuotes = Schema.Struct({\n references: Schema.Array(\n Schema.Struct({\n id: Schema.String,\n quote: Schema.String, // TODO(burdon): Quote?\n }),\n )\n .pipe(Schema.mutable)\n .annotations({\n // TODO(burdon): Does this description make sense?\n description: `\n The references to the context objects that are mentioned in the transcript. \n Quote should match the original transcript text exactly, while id is the id of the context object.\n `,\n }),\n});\nexport type ReferencedQuotes = Schema.Schema.Type<typeof ReferencedQuotes>;\n\nexport const findQuotes = async (quotes: string[], db: EchoDatabase): Promise<ReferencedQuotes> => {\n const references = await Promise.all(\n quotes.map(async (quote) => {\n const { objects } = await db.query(Query.select(Filter.text(quote, { type: 'vector' }))).run();\n log.info('found quotes in vector index', { objects, quote });\n return objects.length > 0 ? [{ id: objects[0].id.toString(), quote }] : [];\n }),\n );\n return { references: references.flat() };\n};\n\n/**\n * Finds and replaces all quotes with DXNs references.\n */\n// TODO(dmaretskyi): Lookup and verifiy ids from provided context.\nexport const insertReferences = (text: string, quotes: ReferencedQuotes) => {\n for (const quote of quotes.references) {\n if (!ObjectId.isValid(quote.id)) {\n continue;\n }\n\n // Use a case-insensitive regular expression to replace the quote.\n const regex = new RegExp(quote.quote.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'gi');\n text = text.replace(regex, `[${quote.quote}](${DXN.fromLocalObjectId(quote.id).toString()})`);\n }\n\n return text;\n};\n", "You are an AI assistant specialized in processing and enhancing transcripts with contextual information.\nYour task is to analyze a given transcript and extract references to the context objects.\n\nThe context and transcript are provided in the user message in `context` and `transcript` XML tags.\n\nHere are your instructions:\n\n1. Read the transcript and context information provided above.\n\n2. Process each segment of the transcript separately.\n\n3. For each segment:\n a. Analyze the content and identify relevant information from the context.\n b. Extract a number of references to the context objects that are mentioned in the segment.\n c. Output the references in the format `{ \"quote\": \"earnings report\", \"id\": \"01JT0JP9AX0XKGZX4MV4B69VT6\" }`.\n d. If there are no references, just output an empty array.\n\n4. Maintain the exact order and structure of the original transcript segments.\n\nOutput Format:\nYou have been provided with a tool that specifies output format\n\nRemember:\n- Only quote the text that is in the transcript.\n- Analyze each segment carefully before processing it.\n- Only reference objects that appear in the context and exactly by their id, If the object is not in the context, do not insert a reference. \n\nNow, process the transcript and context provided below according to these instructions.", "//\n// Copyright 2025 DXOS.org\n//\n\n// ISSUE(burdon): defineFunction\n// @ts-nocheck\n\nimport { asyncTimeout } from '@dxos/async';\nimport { create } from '@dxos/echo/internal';\nimport { DatabaseService, defineFunction } from '@dxos/functions';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { DataType } from '@dxos/schema';\n\nimport { ExtractionInput, ExtractionOutput } from '../extraction';\nimport { findQuotes, insertReferences } from '../quotes';\n\n/**\n * Named Entity Recognition model\n */\n// TODO(mykola): Make it use vector index to query objects and not pass objects as input.\nexport const extractionNerFunction = defineFunction({\n key: 'dxos.org/function/extraction/extract-entities',\n name: 'Extract Entities',\n description: 'Extracts named entities from a text',\n inputSchema: ExtractionInput,\n outputSchema: ExtractionOutput,\n handler: async ({ data: { message, options }, context }) => {\n log.info('input', { message, options });\n const startTime = performance.now();\n const { db } = context.getService(DatabaseService);\n const { extractFullEntities } = await import('./named-entity-recognition');\n\n const entitiesPromise = Promise.all(\n message.blocks.map(async (block) => {\n invariant(block._tag === 'transcript' || block._tag === 'text');\n return extractFullEntities(block.text);\n }),\n ).then((entities) => entities.flat());\n const entities = options?.timeout ? await asyncTimeout(entitiesPromise, options.timeout) : await entitiesPromise;\n\n log.info('entities', { entities });\n const quoteReferences = await findQuotes(\n entities.map((entity) => entity.word),\n db,\n );\n\n const blocksWithReferences = message.blocks.map((block) => {\n invariant(block._tag === 'transcript' || block._tag === 'text');\n return { ...block, text: insertReferences(block._tag, quoteReferences) };\n });\n\n const messageWithReferences = create(DataType.Message, {\n ...message,\n blocks: blocksWithReferences,\n });\n\n log.info('output', { messageWithReferences });\n return {\n message: messageWithReferences,\n timeElapsed: performance.now() - startTime,\n };\n },\n});\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,oBAAoB;AAC7B,SAASC,eAAe;AAExB,SAASC,WAAW;AACpB,SAASC,gBAAgB;;AAElB,IAAMC,kBAAyBC,cAAO;EAC3CC,SAASH,SAASI;EAClBC,SAAg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,QAAQC,IAC9Bd,QAAQe,OAAOC,IAAI,OAAOC,UAAAA;AACxBC,gBAAUD,MAAME,SAAS,gBAAgBF,MAAME,SAAS,QAAA,QAAA;;;;;;;;;AACxD,aAAOR,qBAAoBM,MAAMG,IAAI;IACvC,CAAA,CAAA,EACAC,KAAK,CAACC,cAAaA,UAASC,KAAI,CAAA;AAClC,UAAMD,WAAWrB,SAASuB,UAAU,MAAMC,cAAab,iBAAiBX,QAAQuB,OAAO,IAAI,MAAMZ;AAEjGT,IAAAA,KAAIC,KAAK,YAAY;MAAEkB;IAAS,GAAA;;;;;;AAChC,UAAMI,kBAAkB,MAAMC,WAC5BL,SAASN,IAAI,CAACY,WAAWA,OAAOC,IAAI,GACpCrB,EAAAA;AAGF,UAAMsB,uBAAuB9B,QAAQe,OAAOC,IAAI,CAACC,UAAAA;AAC/CC,gBAAUD,MAAME,SAAS,gBAAgBF,MAAME,SAAS,QAAA,QAAA;;;;;;;;;AACxD,aAAO;QAAE,GAAGF;QAAOG,MAAMW,iBAAiBd,MAAME,MAAMO,eAAAA;MAAiB;IACzE,CAAA;AAEA,UAAMM,wBAAwBC,QAAOC,UAASC,SAAS;MACrD,GAAGnC;MACHe,QAAQe;IACV,CAAA;AAEA3B,IAAAA,KAAIC,KAAK,UAAU;MAAE4B;IAAsB,GAAA;;;;;;AAC3C,WAAO;MACLhC,SAASgC;MACTI,aAAa9B,YAAYC,IAAG,IAAKF;IACnC;EACF;AACF,CAAA;",
|
|
6
|
-
"names": ["Schema", "asyncTimeout", "Expando", "log", "DataType", "ExtractionInput", "Struct", "message", "Message", "objects", "optional", "Array", "options", "timeout", "Number", "fallbackToRaw", "Boolean", "ExtractionOutput", "timeElapsed", "processTranscriptMessage", "params", "executor", "invoke", "function", "input", "error", "warn", "AiService", "Obj", "create", "defineFunction", "DataType", "Schema", "Filter", "Query", "ObjectId", "DXN", "log", "ReferencedQuotes", "Struct", "references", "Array", "id", "String", "quote", "pipe", "mutable", "annotations", "description", "findQuotes", "quotes", "db", "Promise", "all", "map", "objects", "query", "select", "text", "type", "run", "info", "length", "toString", "flat", "insertReferences", "isValid", "regex", "RegExp", "replace", "fromLocalObjectId", "extractionAnthropicFunction", "defineFunction", "key", "name", "description", "inputSchema", "ExtractionInput", "outputSchema", "ExtractionOutput", "handler", "data", "message", "objects", "context", "startTime", "performance", "now", "ai", "getService", "AiService", "session", "AiSession", "operationModel", "result", "runStructured", "ReferencedQuotes", "generationOptions", "model", "client", "systemPrompt", "PROMPT", "history", "Obj", "make", "DataType", "Message", "created", "Date", "toISOString", "sender", "role", "blocks", "_tag", "text", "JSON", "stringify", "artifacts", "prompt", "tools", "timeElapsed", "create", "map", "block", "insertReferences", "asyncTimeout", "create", "DatabaseService", "defineFunction", "invariant", "log", "DataType", "extractionNerFunction", "defineFunction", "key", "name", "description", "inputSchema", "ExtractionInput", "outputSchema", "ExtractionOutput", "handler", "data", "message", "options", "context", "log", "info", "startTime", "performance", "now", "db", "getService", "DatabaseService", "extractFullEntities", "entitiesPromise", "Promise", "all", "blocks", "map", "block", "invariant", "_tag", "text", "then", "entities", "flat", "timeout", "asyncTimeout", "quoteReferences", "findQuotes", "entity", "word", "blocksWithReferences", "insertReferences", "messageWithReferences", "create", "DataType", "Message", "timeElapsed"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/conversation/context.ts", "../../../src/conversation/conversation.ts", "../../../src/diff.ts", "../../../src/execution-graph.ts", "../../../src/functions/services.ts", "../../../src/templates/system.ts", "raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/format.tpl?raw", "raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/system.tpl?raw", "../../../src/types/artifact.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ReadonlySignal, computed } from '@preact/signals-core';\nimport * as Array from 'effect/Array';\nimport * as Context from 'effect/Context';\nimport * as Function from 'effect/Function';\nimport * as Schema from 'effect/Schema';\n\nimport { Blueprint } from '@dxos/blueprints';\nimport { Resource } from '@dxos/context';\nimport { DXN, Filter, Obj, Query, type Ref, type Relation, Type } from '@dxos/echo';\nimport { type Queue } from '@dxos/echo-db';\nimport { invariant } from '@dxos/invariant';\nimport { ComplexSet } from '@dxos/util';\n\n/**\n * Thread message that binds or unbinds contextual objects to a conversation.\n */\n// TODO(burdon): Move to @dxos/schema ContentBlock?\nexport const ContextBinding = Schema.Struct({\n blueprints: Schema.Struct({\n added: Schema.Array(Type.Ref(Blueprint.Blueprint)),\n removed: Schema.Array(Type.Ref(Blueprint.Blueprint)),\n }),\n\n // TODO(burdon): Type.Expando => Type.Obj (or Obj.Any?)\n objects: Schema.Struct({\n added: Schema.Array(Type.Ref(Type.Expando)),\n removed: Schema.Array(Type.Ref(Type.Expando)),\n }),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/ContextBinding',\n version: '0.1.0',\n }),\n);\n\nexport interface ContextBinding extends Schema.Schema.Type<typeof ContextBinding> {}\n\nexport type BindingProps = Partial<{\n blueprints: Ref.Ref<Blueprint.Blueprint>[];\n objects: Ref.Ref<Type.Expando>[];\n}>;\n\nexport class Bindings {\n readonly blueprints = new ComplexSet<Ref.Ref<Blueprint.Blueprint>>((ref) => ref.dxn.toString());\n // TODO(burdon): Some DXNs have the Space prefix so only compare the object ID.\n readonly objects = new ComplexSet<Ref.Ref<Type.Expando>>((ref) => ref.dxn.asEchoDXN()?.echoId);\n\n toJSON() {\n return {\n blueprints: Array.fromIterable(this.blueprints).map((ref) => ref.dxn.toString()),\n objects: Array.fromIterable(this.objects).map((ref) => ref.dxn.toString()),\n };\n }\n}\n\n/**\n * Manages bindings of blueprints and objects to a conversation.\n */\n// TODO(burdon): Context should manage ephemeral state of bindings until prompt is issued?\nexport class AiContextBinder extends Resource {\n /**\n * Reactive query of all bindings.\n */\n // TODO(burdon): Cache value?\n private _bindings?: ReadonlySignal<Bindings>;\n private _blueprints?: ReadonlySignal<Ref.Ref<Blueprint.Blueprint>[]>;\n private _objects?: ReadonlySignal<Ref.Ref<Type.Expando>[]>;\n\n constructor(private readonly _queue: Queue) {\n super();\n }\n\n get bindings() {\n invariant(this._bindings, 'AiContextBinder not open');\n return this._bindings;\n }\n\n get blueprints() {\n invariant(this._blueprints, 'AiContextBinder not open');\n return this._blueprints;\n }\n\n get objects() {\n invariant(this._objects, 'AiContextBinder not open');\n return this._objects;\n }\n\n // TODO(wittjosiah): Use parent context?\n protected override async _open(): Promise<void> {\n const query = this._queue.query(Query.select(Filter.everything()));\n this._ctx.onDispose(query.subscribe(() => {}));\n this._bindings = computed(() => this._reduce(query.objects));\n this._blueprints = computed(() => [...this.bindings.value.blueprints]);\n this._objects = computed(() => [...this.bindings.value.objects]);\n }\n\n protected override async _close(): Promise<void> {\n this._bindings = undefined;\n this._blueprints = undefined;\n this._objects = undefined;\n }\n\n /**\n * Asynchronous query of all bindings.\n */\n async query(): Promise<Bindings> {\n const { objects } = await this._queue.query(Query.select(Filter.everything())).run();\n return this._reduce(objects);\n }\n\n // TODO(burdon): Pass in Blueprint obj (from registry?) and create reference.\n async bind(props: BindingProps): Promise<void> {\n const blueprints =\n props.blueprints?.filter((ref) => !this.blueprints.peek().find((b) => b.dxn.toString() === ref.dxn.toString())) ??\n [];\n const objects =\n props.objects?.filter((ref) => !this.objects.peek().find((o) => o.dxn.toString() === ref.dxn.toString())) ?? [];\n\n if (!blueprints.length && !objects.length) {\n return;\n }\n\n await this._queue.append([\n Obj.make(ContextBinding, {\n blueprints: {\n added: blueprints,\n removed: [],\n },\n objects: {\n added: objects,\n removed: [],\n },\n }),\n ]);\n }\n\n async unbind(props: BindingProps): Promise<void> {\n if (!props.blueprints?.length && !props.objects?.length) {\n return;\n }\n\n await this._queue.append([\n Obj.make(ContextBinding, {\n blueprints: {\n added: [],\n removed: props.blueprints ?? [],\n },\n objects: {\n added: [],\n removed: props.objects ?? [],\n },\n }),\n ]);\n }\n\n private _reduce(items: (Obj.Any | Relation.Any)[]): Bindings {\n return Function.pipe(\n items,\n Array.filter(Obj.instanceOf(ContextBinding)),\n Array.reduce(new Bindings(), (context, item) => {\n item.blueprints.removed.forEach((ref) => context.blueprints.delete(ref));\n item.blueprints.added.forEach((ref) => context.blueprints.add(ref));\n item.objects.removed.forEach((ref) => {\n for (const obj of context.objects) {\n if (DXN.equalsEchoId(obj.dxn, ref.dxn)) {\n context.objects.delete(obj);\n }\n }\n });\n item.objects.added.forEach((ref) => context.objects.add(ref));\n return context;\n }),\n );\n }\n}\n\nexport class AiContextService extends Context.Tag('@dxos/assistant/AiContextService')<\n AiContextService,\n {\n binder: AiContextBinder;\n }\n>() {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Toolkit from '@effect/ai/Toolkit';\nimport * as Array from 'effect/Array';\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\n\nimport { Resource } from '@dxos/context';\nimport { Obj } from '@dxos/echo';\nimport { type Queue } from '@dxos/echo-db';\nimport { DatabaseService } from '@dxos/functions';\nimport { log } from '@dxos/log';\nimport { DataType } from '@dxos/schema';\n\nimport {\n AiSession,\n type AiSessionRunError,\n type AiSessionRunRequirements,\n type GenerationObserver,\n createToolkit,\n} from '../session';\n\nimport { AiContextBinder, AiContextService, type ContextBinding } from './context';\n\nexport interface AiConversationRunParams {\n prompt: string;\n system?: string;\n observer?: GenerationObserver;\n}\n\n/**\n * Durable conversation state (initiated by users and agents) backed by a Queue.\n * Executes tools based on AI responses and supports cancellation of in-progress requests.\n */\nexport class AiConversation extends Resource {\n /**\n * Message and binding queue.\n */\n private readonly _queue: Queue<DataType.Message | ContextBinding>;\n\n /**\n * Blueprints bound to the conversation.\n */\n private readonly _context: AiContextBinder;\n\n /**\n * Toolkit from the current session request.\n */\n private _toolkit: Toolkit.WithHandler<any> | undefined;\n\n public constructor(queue: Queue<DataType.Message | ContextBinding>) {\n super();\n this._queue = queue;\n this._context = new AiContextBinder(this._queue);\n }\n\n protected override async _open(): Promise<void> {\n // TODO(wittjosiah): Pass in parent context?\n await this._context.open();\n }\n\n protected override async _close(): Promise<void> {\n await this._context.close();\n }\n\n public get context() {\n return this._context;\n }\n\n public get toolkit() {\n return this._toolkit;\n }\n\n public async getHistory(): Promise<DataType.Message[]> {\n const queueItems = await this._queue.queryObjects();\n return queueItems.filter(Obj.instanceOf(DataType.Message));\n }\n\n /**\n * Creates a new cancelable request effect.\n */\n createRequest(\n params: AiConversationRunParams,\n ): Effect.Effect<DataType.Message[], AiSessionRunError, AiSessionRunRequirements> {\n return Effect.gen(this, function* () {\n const session = new AiSession();\n const history = yield* Effect.promise(() => this.getHistory());\n\n // Get context objects.\n const context = yield* Effect.promise(() => this.context.query());\n const blueprints = yield* Effect.forEach(context.blueprints.values(), DatabaseService.loadOption).pipe(\n Effect.map(Array.filter(Option.isSome)),\n Effect.map(Array.map((option) => option.value)),\n );\n const objects = yield* Effect.forEach(context.objects.values(), DatabaseService.loadOption).pipe(\n Effect.map(Array.filter(Option.isSome)),\n Effect.map(Array.map((option) => option.value)),\n );\n\n // Create toolkit.\n const toolkit = yield* createToolkit({ blueprints });\n this._toolkit = toolkit;\n\n const start = Date.now();\n log('run', {\n history: history.length,\n blueprints: blueprints.length,\n objects: objects.length,\n tools: this._toolkit?.tools.length ?? 0,\n });\n\n // Process request.\n const messages = yield* session.run({ history, blueprints, objects, toolkit, ...params }).pipe(\n Effect.provideService(AiContextService, {\n binder: this.context,\n }),\n );\n\n log('result', { messages: messages.length, duration: Date.now() - start });\n\n // Append to queue.\n yield* Effect.promise(() => this._queue.append(messages));\n return messages;\n }).pipe(Effect.withSpan('AiConversation.request'));\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { next as A, type Doc } from '@automerge/automerge';\n\nimport { DocAccessor, toCursorRange } from '@dxos/echo-db';\nimport { log } from '@dxos/log';\nimport { isNonNullable } from '@dxos/util';\n\n// Relevant info:\n// https://github.com/Minahil-official/GPT-4.1-Promting-Guide?tab=readme-ov-file#-apply-patch-tool-format-v4a-diff\n\n// TOOD(burdon): Support append to end (no \"-\").\n\nexport type Diff = {\n match: string;\n replace: string;\n};\n\n/**\n * Convert a list of diffs into a list of operations.\n */\nexport const reduceDiffs = (diffs: readonly string[]): Diff[] => {\n return diffs.reduce<Diff[]>((acc, diff) => {\n const current = acc[acc.length - 1];\n const [op, ...rest] = diff.split(' ');\n switch (op) {\n case '-': {\n if (current && !current.match) {\n current.match += rest.join(' ');\n } else {\n acc.push({ match: rest.join(' '), replace: '' });\n }\n return acc;\n }\n case '+': {\n if (current && !current.replace) {\n current.replace += rest.join(' ');\n } else {\n acc.push({ match: '', replace: rest.join(' ') });\n }\n return acc;\n }\n }\n\n return acc;\n }, []);\n};\n\nexport const computeDiffsWithCursors = <T>(accessor: DocAccessor<T>, diffs: readonly string[]) => {\n return reduceDiffs(diffs)\n .map((diff) => {\n const text = DocAccessor.getValue<string>(accessor);\n const idx = text.indexOf(diff.match);\n if (idx !== -1) {\n return { cursor: toCursorRange(accessor, idx, idx + diff.match.length), text: diff.replace };\n }\n })\n .filter(isNonNullable);\n};\n\nexport const applyDiffs = <T>(accessor: DocAccessor<T>, diffs: readonly string[]): string => {\n for (const diff of reduceDiffs(diffs)) {\n accessor.handle.change((doc: Doc<T>) => {\n const text = DocAccessor.getValue<string>(accessor);\n const idx = text.indexOf(diff.match);\n if (idx !== -1) {\n // TODO(burdon): Replace smallest substring.\n // NOTE: This only replaces the first match.\n A.splice(doc, accessor.path as A.Prop[], idx, diff.match.length, diff.replace);\n } else {\n log.warn('diff not found', diff);\n }\n });\n }\n\n return DocAccessor.getValue<string>(accessor);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { AgentStatus } from '@dxos/ai';\nimport { Obj, type Ref } from '@dxos/echo';\nimport { MESSAGE_PROPERTY_TOOL_CALL_ID } from '@dxos/functions';\nimport { type ObjectId } from '@dxos/keys';\nimport { LogLevel } from '@dxos/log';\nimport { ContentBlock, DataType } from '@dxos/schema';\nimport { isNonNullable } from '@dxos/util';\n\n/**\n * Mercurial-style Commit.\n */\n// TODO(wittjosiah): Reconcile with @dxos/react-ui-components.\nexport type Commit = {\n id: string;\n parents: string[];\n branch: string;\n icon?: string;\n level?: LogLevel;\n message: string;\n timestamp?: Date;\n tags?: string[];\n};\n\n// TODO(burdon): Add colors?\nenum IconType {\n // General status.\n SUCCESS = 'ph--check-circle--regular',\n WARNING = 'ph--warning-circle--regular',\n ERROR = 'ph--x-circle--regular',\n FLAG = 'ph--flag--regular',\n ROCKET = 'ph--rocket--regular',\n TIMER = 'ph--timer--regular',\n\n // Interactions.\n USER = 'ph--user--regular',\n USER_INTERACTION = 'ph--user-sound--regular',\n AGENT = 'ph--robot--regular',\n THINKING = 'ph--brain--regular',\n LINK = 'ph--link--regular',\n TOOL = 'ph--wrench--regular',\n}\n\n/**\n * Models the execution graph based on a stream of events.\n */\nexport class ExecutionGraph {\n // TODO(dmaretskyi): Evolve the internal state to support chats, functions, circuit workflows, etc.\n private _commits: Commit[] = [];\n private _branchNames = new Set<string>();\n private _lastBlockId: string | undefined;\n\n // Tool call tracking.\n private _toolCallCommitIds = new Map<string, string>(); // toolCallId -> commitId\n private _lastCommitByBranch = new Map<string, string>(); // branch -> last commitId\n private _pendingToolResults = new Map<string, string>(); // toolCallId -> toolResultCommitId\n\n /**\n * Adds events to the graph.\n */\n addEvents(events: Obj.Any[]) {\n const sortedEvents = this.sortObjectsByCreated(events);\n for (const event of sortedEvents) {\n if (Obj.instanceOf(DataType.Message, event)) {\n this._processMessage(event);\n } else if (Obj.instanceOf(AgentStatus, event)) {\n this._processAgentStatus(event);\n }\n }\n }\n\n /**\n * Processes a message event and creates commits for its blocks.\n */\n private _processMessage(message: DataType.Message) {\n const messageCommits = messageToCommits(\n message,\n this._lastBlockId,\n this._toolCallCommitIds,\n this._lastCommitByBranch,\n );\n this._commits.push(...messageCommits);\n\n // Track branches.\n messageCommits.forEach((commit) => this._branchNames.add(commit.branch));\n\n // Track tool calls and update pending tool results.\n this._trackToolCalls(messageCommits);\n\n // Update last block ID for sequential chaining.\n if (messageCommits.length > 0) {\n this._lastBlockId = messageCommits[messageCommits.length - 1].id;\n }\n }\n\n /**\n * Processes an AgentStatus event.\n */\n private _processAgentStatus(event: AgentStatus) {\n const branch = this._getToolCallBranch(event.parentMessage, event.toolCallId);\n this._branchNames.add(branch);\n\n const agentStatusCommit: Commit = {\n id: event.id,\n branch,\n message: event.message,\n icon: IconType.FLAG,\n parents: this._getAgentStatusParents(event),\n timestamp: new Date(event.created),\n };\n\n this._commits.push(agentStatusCommit);\n\n // Update last block ID for sequential chaining.\n this._lastBlockId = event.id;\n\n // Update pending tool results to point to this AgentStatus.\n if (event.toolCallId) {\n this._lastCommitByBranch.set(branch, event.id);\n this._updatePendingToolResults(event.toolCallId, event.id);\n }\n }\n\n /**\n * Stable sort: objects with 'created' field are sorted by it, others remain in place.\n */\n private sortObjectsByCreated(objects: any[]) {\n const sortedObjects = objects.slice();\n // Find indices of objects with 'created'\n const createdObjects: { idx: number; obj: any }[] = [];\n sortedObjects.forEach((obj, idx) => {\n if (obj && typeof obj.created === 'string') {\n createdObjects.push({ idx, obj });\n }\n });\n // Sort only the objects with 'created' by their date, stable\n createdObjects.sort((a, b) => {\n const aDate = new Date(a.obj.created).getTime();\n const bDate = new Date(b.obj.created).getTime();\n return aDate - bDate;\n });\n // Place sorted createdObjects back into their original positions\n let createdIdx = 0;\n return sortedObjects.map((obj, _idx) => {\n if (obj && typeof obj.created === 'string') {\n return createdObjects[createdIdx++].obj;\n }\n return obj;\n });\n }\n\n /**\n * Returns the current state of the graph.\n */\n getGraph(lastRequest = false): { branches: string[]; commits: Commit[] } {\n const idx = lastRequest ? this._commits.findLastIndex((c) => c.tags?.includes('user')) : -1;\n const commits = idx === -1 ? this._commits : this._commits.slice(idx);\n\n return {\n branches: Array.from(this._branchNames),\n commits,\n };\n }\n\n /**\n * Tracks tool calls and handles pending tool result updates.\n */\n private _trackToolCalls(commits: Commit[]) {\n commits.forEach((commit) => {\n if (this._isToolCallCommit(commit)) {\n const toolCallId = this._extractToolCallId(commit.id);\n if (toolCallId) {\n this._toolCallCommitIds.set(toolCallId, commit.id);\n }\n }\n\n if (this._isToolResultCommit(commit)) {\n const toolCallId = this._extractToolCallId(commit.id);\n if (toolCallId) {\n this._pendingToolResults.set(toolCallId, commit.id);\n this._handleLateToolResultUpdate(toolCallId, commit.id);\n }\n }\n\n this._lastCommitByBranch.set(commit.branch, commit.id);\n });\n }\n\n /**\n * Updates pending tool results to point to an AgentStatus event.\n */\n private _updatePendingToolResults(toolCallId: string, agentStatusId: string) {\n const toolResultId = this._pendingToolResults.get(toolCallId);\n if (!toolResultId) return;\n\n const toolResultCommit = this._commits.find((c) => c.id === toolResultId);\n if (!toolResultCommit) return;\n\n const toolCallCommitId = this._toolCallCommitIds.get(toolCallId);\n if (!toolCallCommitId) return;\n\n // Replace tool call commit with AgentStatus commit.\n const toolCallIndex = toolResultCommit.parents.indexOf(toolCallCommitId);\n if (toolCallIndex !== -1) {\n toolResultCommit.parents[toolCallIndex] = agentStatusId;\n }\n\n this._pendingToolResults.delete(toolCallId);\n }\n\n /**\n * Handles late updates when AgentStatus is processed before tool result.\n */\n private _handleLateToolResultUpdate(toolCallId: string, toolResultId: string) {\n const toolCallCommitId = this._toolCallCommitIds.get(toolCallId);\n if (!toolCallCommitId) return;\n\n const messageId = toolCallCommitId.split('_toolCall_')[0];\n const toolCallBranch = `${messageId}_${toolCallId}`;\n const agentStatusCommitId = this._lastCommitByBranch.get(toolCallBranch);\n\n if (agentStatusCommitId && agentStatusCommitId !== toolCallCommitId) {\n const toolResultCommit = this._commits.find((c) => c.id === toolResultId);\n if (toolResultCommit) {\n const toolCallIndex = toolResultCommit.parents.indexOf(toolCallCommitId);\n if (toolCallIndex !== -1) {\n toolResultCommit.parents[toolCallIndex] = agentStatusCommitId;\n }\n }\n this._pendingToolResults.delete(toolCallId);\n }\n }\n\n /**\n * Gets the branch name for a tool call.\n */\n private _getToolCallBranch(parentMessage?: ObjectId, toolCallId?: string): string {\n if (toolCallId) {\n return toolCallId;\n }\n return parentMessage || 'main';\n }\n\n /**\n * Gets the parents for an AgentStatus commit.\n */\n private _getAgentStatusParents(event: AgentStatus): string[] {\n if (event.parentMessage && event.toolCallId) {\n return [getToolCallId(event.parentMessage, event.toolCallId)];\n }\n return [];\n }\n\n /**\n * Checks if a commit is a tool call commit.\n */\n private _isToolCallCommit(commit: Commit): boolean {\n return commit.message.includes('Calling tool');\n }\n\n /**\n * Checks if a commit is a tool result commit.\n */\n private _isToolResultCommit(commit: Commit): boolean {\n return commit.message.includes('Tool call succeeded') || commit.message.includes('Tool error:');\n }\n\n /**\n * Extracts tool call ID from a commit ID.\n */\n private _extractToolCallId(commitId: string): string | undefined {\n const toolCallMatch = commitId.match(/_toolCall_(.+)$/);\n const toolResultMatch = commitId.match(/_toolResult_(.+)$/);\n return toolCallMatch?.[1] || toolResultMatch?.[1];\n }\n}\n\n// TODO(burdon): Pass in AiToolProvider.\n/**\n * Creates commits for all blocks in a message.\n */\nconst messageToCommits = (\n message: DataType.Message,\n lastBlockId?: string,\n toolCallIds?: Map<string, string>,\n lastCommitByBranch?: Map<string, string>,\n): Commit[] => {\n let previousBlockId: string | undefined = lastBlockId;\n\n return message.blocks\n .map((block, idx) => {\n const branch = getMessageBranch(message);\n const parents = getBlockParents(block, previousBlockId, message, toolCallIds, lastCommitByBranch);\n\n const commit = createBlockCommit(block, message, branch, parents, idx);\n if (commit) {\n previousBlockId = commit.id;\n }\n\n return commit;\n })\n .filter(isNonNullable);\n};\n\n/**\n * Determines the parent commits for a block based on its type and context.\n */\nconst getBlockParents = (\n block: ContentBlock.Any,\n previousBlockId: string | undefined,\n message: DataType.Message,\n toolCallIds?: Map<string, string>,\n lastCommitByBranch?: Map<string, string>,\n): string[] => {\n const parents: string[] = [];\n\n if (block._tag === 'toolResult') {\n // Tool results have two parents: previous block and last block from tool call branch\n if (previousBlockId) {\n parents.push(previousBlockId);\n }\n\n const toolCallCommitId = toolCallIds?.get(block.toolCallId);\n if (toolCallCommitId) {\n const toolCallBranch = getToolCallBranchFromCommitId(toolCallCommitId, block.toolCallId);\n const lastBlockFromToolCallBranch = lastCommitByBranch?.get(toolCallBranch);\n\n if (lastBlockFromToolCallBranch) {\n parents.push(lastBlockFromToolCallBranch);\n } else {\n // Fallback to tool call commit if no AgentStatus exists yet.\n parents.push(toolCallCommitId);\n }\n }\n } else {\n // For other blocks, use previous block as parent (or tool call parent for first block).\n if (previousBlockId) {\n parents.push(previousBlockId);\n } else {\n const toolCallParent = getParentId(message);\n if (toolCallParent) {\n parents.push(toolCallParent);\n }\n }\n }\n\n return parents;\n};\n\n/**\n * Creates a commit for a specific block.\n */\nconst createBlockCommit = (\n block: ContentBlock.Any,\n message: DataType.Message,\n branch: string,\n parents: string[],\n idx: number,\n): Commit | null => {\n const timestamp = new Date(message.created);\n switch (block._tag) {\n case 'text':\n if (!block.text.trim().length) return null;\n return {\n id: getGenericBlockId(message.id, idx),\n branch,\n parents,\n timestamp,\n ...(message.sender.role === 'user'\n ? {\n icon: IconType.USER,\n tags: ['user'],\n message: 'Processing request...',\n }\n : {\n icon: IconType.AGENT,\n message: `Response (${block.text.split(' ').length} words)`,\n }),\n } satisfies Commit;\n\n case 'toolCall':\n return {\n id: getToolCallId(message.id, block.toolCallId),\n branch,\n parents,\n timestamp,\n icon: IconType.TOOL,\n level: LogLevel.INFO,\n message: `Calling tool (${block.name})`,\n } satisfies Commit;\n\n case 'toolResult':\n return {\n id: getToolResultId(message.id, block.toolCallId),\n branch,\n parents,\n timestamp,\n icon: block.error ? IconType.ERROR : IconType.SUCCESS,\n level: block.error ? LogLevel.ERROR : LogLevel.INFO,\n message: block.error ? 'Tool error: ' + block.error : 'Tool call succeeded',\n } satisfies Commit;\n\n case 'summary':\n return {\n id: getGenericBlockId(message.id, idx),\n branch,\n parents,\n timestamp,\n icon: IconType.ROCKET,\n level: LogLevel.INFO,\n message: ContentBlock.createSummaryMessage(block),\n } satisfies Commit;\n\n case 'status':\n return {\n id: getGenericBlockId(message.id, idx),\n branch,\n parents,\n timestamp,\n message: block.statusText,\n level: LogLevel.INFO,\n icon: IconType.FLAG,\n } satisfies Commit;\n\n case 'reasoning':\n return {\n id: getGenericBlockId(message.id, idx),\n branch,\n parents,\n timestamp,\n message: block.reasoningText ?? 'Thinking...',\n icon: IconType.THINKING,\n } satisfies Commit;\n\n case 'reference':\n return {\n id: getGenericBlockId(message.id, idx),\n branch,\n parents,\n timestamp,\n icon: IconType.LINK,\n message: stringifyRef(block.reference),\n } satisfies Commit;\n\n default:\n return null;\n }\n};\n\n/**\n * Gets the tool call branch name from a tool call commit ID.\n */\nconst getToolCallBranchFromCommitId = (toolCallCommitId: string, toolCallId: string): string => {\n const messageId = toolCallCommitId.split('_toolCall_')[0];\n return `${messageId}_${toolCallId}`;\n};\n\nconst getToolCallId = (messageId: ObjectId, toolCallId: string) => `${messageId}_toolCall_${toolCallId}`;\nconst getToolResultId = (messageId: ObjectId, toolCallId: string) => `${messageId}_toolResult_${toolCallId}`;\nconst getGenericBlockId = (messageId: ObjectId, idx: number) => `${messageId}_block_${idx}`;\n\nconst getBranchName = (options: { parentMessage?: ObjectId; toolCallId?: string }) => {\n if (options.toolCallId) {\n return options.toolCallId;\n } else if (options.parentMessage) {\n return options.parentMessage;\n } else {\n return 'main';\n }\n};\n\nconst getMessageBranch = (message: DataType.Message) => {\n return getBranchName({\n parentMessage: message.parentMessage,\n toolCallId: message.properties?.[MESSAGE_PROPERTY_TOOL_CALL_ID],\n });\n};\n\nconst getParentId = (message: DataType.Message) => {\n if (message.parentMessage && message.properties?.[MESSAGE_PROPERTY_TOOL_CALL_ID]) {\n return getToolCallId(message.parentMessage, message.properties[MESSAGE_PROPERTY_TOOL_CALL_ID]);\n } else {\n return undefined;\n }\n};\n\nconst stringifyRef = (ref: Ref.Any) => {\n if (ref.target) {\n return stringifyObject(ref.target);\n }\n\n return ref.dxn.asEchoDXN()?.echoId ?? ref.dxn.asQueueDXN()?.objectId ?? '';\n};\n\nconst stringifyObject = (obj: Obj.Any) => {\n return Obj.getLabel(obj) ?? Obj.getTypename(obj) ?? obj.id;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Tool from '@effect/ai/Tool';\nimport type * as Toolkit from '@effect/ai/Toolkit';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Record from 'effect/Record';\nimport * as Schema from 'effect/Schema';\n\nimport { AiToolNotFoundError, ToolExecutionService, ToolResolverService } from '@dxos/ai';\nimport { todo } from '@dxos/debug';\nimport { Query } from '@dxos/echo';\nimport { DatabaseService, FunctionDefinition, FunctionInvocationService, FunctionType } from '@dxos/functions';\nimport { invariant } from '@dxos/invariant';\n\n/**\n * Constructs a `ToolResolverService` whose `resolve(id)` looks up tools in the following order:\n * 1. Toolkit: return an existing tool from the provided `toolkit` if one is present under `id`.\n * 2. Functions in DB: query `FunctionType` by `key=id`; if found, deserialize and project to a tool\n * (propagating any `deployedFunctionId` discovered in the object's metadata).\n * 3. Functions passed in: fall back to a matching `FunctionDefinition` from the `functions` array.\n *\n * If none of the above yield a match, the effect fails with `AiToolNotFoundError`.\n *\n * Requires `DatabaseService` in the environment.\n */\nexport const makeToolResolverFromFunctions = (\n functions: FunctionDefinition<any, any>[],\n toolkit: Toolkit.Toolkit<any>,\n): Layer.Layer<ToolResolverService, never, DatabaseService> => {\n return Layer.effect(\n ToolResolverService,\n Effect.gen(function* () {\n const dbService = yield* DatabaseService;\n return {\n resolve: (id): Effect.Effect<Tool.Any, AiToolNotFoundError> =>\n Effect.gen(function* () {\n const tool = toolkit.tools[id];\n if (tool) {\n return tool;\n }\n\n const {\n objects: [dbFunction],\n } = yield* DatabaseService.runQuery(Query.type(FunctionType, { key: id }));\n\n const functionDef = dbFunction\n ? FunctionDefinition.deserialize(dbFunction)\n : functions.find((fn) => fn.key === id);\n\n if (!functionDef) {\n return yield* Effect.fail(new AiToolNotFoundError(id));\n }\n\n return projectFunctionToTool(functionDef);\n }).pipe(Effect.provideService(DatabaseService, dbService)),\n } satisfies Context.Tag.Service<ToolResolverService>;\n }),\n );\n};\n\nexport const makeToolExecutionServiceFromFunctions = (\n toolkit: Toolkit.Toolkit<any>,\n handlersLayer: Layer.Layer<Tool.Handler<any>, never, never>,\n): Layer.Layer<ToolExecutionService, never, FunctionInvocationService> => {\n return Layer.effect(\n ToolExecutionService,\n Effect.gen(function* () {\n const toolkitHandler = yield* toolkit.pipe(Effect.provide(handlersLayer));\n invariant(isHandlerLike(toolkitHandler));\n const functionInvocationService = yield* FunctionInvocationService;\n\n return {\n handlersFor: (toolkit) => {\n const makeHandler = (tool: Tool.Any): ((params: unknown) => Effect.Effect<unknown, any, any>) => {\n return Effect.fn(`toolFunctionHandler ${tool.name}`)(function* (input: any) {\n if (toolkitHandler.tools[tool.name]) {\n if (Tool.isProviderDefined(tool)) {\n throw new Error('Attempted to call a provider-defined tool');\n }\n // TODO(wittjosiah): Everything is `never` here.\n return yield* (toolkitHandler.handle as any)(tool.name, input);\n }\n\n const { definition: functionDef } = Context.get(FunctionToolAnnotation)(tool.annotations as any);\n\n return yield* functionInvocationService\n .invokeFunction(functionDef, input as any)\n .pipe(Effect.catchAllDefect((defect) => Effect.fail(defect)));\n });\n };\n\n return toolkit.of(\n Record.map(toolkit.tools, (tool, _name) => (Tool.isUserDefined(tool) ? makeHandler(tool) : null)) as any,\n ) as any;\n },\n };\n }),\n );\n};\n\nclass FunctionToolAnnotation extends Context.Tag('@dxos/assistant/FunctionToolAnnotation')<\n FunctionToolAnnotation,\n { definition: FunctionDefinition<any, any> }\n>() {}\n\nconst toolCache = new WeakMap<FunctionDefinition<any, any>, Tool.Any>();\n\n/**\n * Projects a `FunctionDefinition` into an `AiTool`.\n *\n * @param fn The function definition to project into a tool.\n * @param meta Optional projection metadata.\n * @param meta.deployedFunctionId Backend deployment ID used for remote invocation when present. This is the\n * EDGE service's function deployment identifier (not the ECHO object ID/DXN and not `FunctionDefinition.key`).\n */\nconst projectFunctionToTool = (fn: FunctionDefinition<any, any>): Tool.Any => {\n if (toolCache.has(fn)) {\n return toolCache.get(fn)!;\n }\n\n const tool = Tool.make(makeToolName(fn.name), {\n description: fn.description,\n parameters: createStructFieldsFromSchema(fn.inputSchema),\n // TODO(dmaretskyi): Include output schema.\n failure: Schema.Any, // TODO(dmaretskyi): Better type for the failure?\n }).annotate(FunctionToolAnnotation, { definition: fn });\n toolCache.set(fn, tool);\n return tool;\n};\n\n/**\n * @returns Tool name produced from function name by escaping invalid characters.\n */\nconst makeToolName = (name: string) => {\n const toolName = name.replace(/[^a-zA-Z0-9]/g, '_');\n invariant(toolName.match(/^[a-zA-Z_][a-zA-Z0-9-_]*$/));\n return toolName;\n};\n\n// TODO(dmaretskyi): Factor out.\nconst createStructFieldsFromSchema = (schema: Schema.Schema<any, any>): Record<string, Schema.Schema<any, any>> => {\n switch (schema.ast._tag) {\n case 'TypeLiteral':\n return Object.fromEntries(schema.ast.propertySignatures.map((prop) => [prop.name, Schema.make(prop.type)]));\n case 'VoidKeyword':\n return {};\n default:\n return todo(`Unsupported schema AST: ${schema.ast._tag}`);\n }\n};\n\nconst isHandlerLike = (value: unknown): value is Toolkit.WithHandler<Record<string, Tool.Any>> => {\n return typeof (value as any).tools === 'object' && typeof (value as any).handle === 'function';\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport defaultsDeep from 'lodash.defaultsdeep';\n\nimport { type ModelCapabilities } from '@dxos/ai';\nimport { Template } from '@dxos/blueprints';\n\nimport FORMAT from './format.tpl?raw';\nimport SYSTEM from './system.tpl?raw';\n\n/**\n * System template variables.\n */\nexport type SystemPromptOptions = ModelCapabilities & {\n DATETIME: string;\n};\n\n/**\n * Base system prompt.\n * NOTE: This contains protocol instructions that can not be dynamically edited.\n */\nexport const createSystemPrompt = (options: Partial<SystemPromptOptions> = {}) =>\n Template.process<SystemPromptOptions>(\n FORMAT,\n defaultsDeep(options, {\n DATETIME: new Date().toISOString(),\n }),\n );\n\nexport const templates = {\n /** Editable system prompt.*/\n system: Template.make({\n /**\n * NOTE: We are forbidden from accessing randomness at model level in cloudflare, so we have to have pre-generated ids.\n */\n id: '01K2J2FZWH39F55CS7B26GP1Q3',\n source: SYSTEM,\n }),\n};\n", "{{! System Core }}\n\n## Input Formats\n\n### Blueprints\n\nYou may be provided with Blueprint definitions that include specific instructions and tools for a given set of tasks.\nBlue print instructions will be enclosed in a <blueprint> tag.\n\n### Context objects\n\nYou may be provided with references to objects that are relevant to the current prompt.\nObjects will be in the form of a <object> tag with a <dxn> element that is the unique key of the object required by many tools.\nThe <typename> element is the type of the object.\n\n<object>\n <dxn>object-id</dxn>\n <typename>example.com/type/TypeName</typename>\n</object>\n\n## Response Formats\n\nIt is very important to respond in the correct format.\nYou response must be valid Markdown.\nIn some cases you should respond with well-formed XML tags along with the content.\nCode snippets should use 2-space indents.\n\n{{#if cot}}\nBefore responding, explain your reasoning and include your detailed chain-of-thought enclosed in a <cot> tag.\nThe <cot> tag should be the first thing in your response.\n{{/if}}\n\n## Block references\n\nYou can reply with a block reference for objects if you have the DXN. For example:\n\n<object>\n <dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK464FSCKVQJAB2H662M</dxn>\n</object>\n<object>\n <dxn>dxn:echo:@:01K24XPK464FSCKVQJAB2H662M</dxn>\n</object>\n\n### Suggestions\n\nEach suggestion must in the form of a proposed action enclosed in a <suggestion> tag.\nExample: <suggestion>Show on a map</suggestion>\n\n### Multiple choice questions\n\nYou may ask multiple choice questions by wrapping consise options inside <option> tags inside a well formed <select> tag.\nExample: <select><option>Yes</option><option>No</option></select>\n\n## Toolkit\n\nIf the user asks for a list of tools, then just emit a single self-closing <toolkit/> tag instead of listing the tools.\n\n## Context\n\nThe current date and time is {{DATETIME}}.\n", "{{! System Prompt }}\n\n- You are a helpful assistant called Kai. \n- Your name is Kai and you are powered by different language models.\n- You were created by DXOS and operate inside of Composer and on the DXOS EDGE network.\n- In your initial greeting state your name and make some suggestions based on the current context objects.\n- You are an advanced AI assistant capable of creating and managing artifacts from provided data and tools.\n- Your task is to process user commands and questions and decide how best to respond.\n- In general be concise and direct.\n- Follow all instructions carefully.\n\n## Planning\n\n- Analyze the structure and type of the content in the user's message.\n- Determine if you complete the task using the available blueprint definitions?\n- If you can't complete the task using the available blueprint definitions, query the list of available blueprint definitions using the appropriate tool.\n- Identify which blueprint definitions are relevant to the user's request.\n- Evaluate the potential benefits of creating an artifact vs. normal processing for each identified element.\n- Make a final decision on whether to create an artifact and explain your reasoning.\n- Are the required blueprint definitions already available?\n- If not, select which blueprint definition(s) will be the most relevant and require them using the require_artifact_definitions tool.\n- The require'd artifact tools will be available for use after require.\n- If creating an artifact, outline how you will structure it within the response.\n- Decide if the artifact needs to be shown to the user.\n- Call the show tool to show the artifact to the user.\n- Your reasoning must include: whether to use artifacts or not, to create one or query, whether to show the artifact to the user, and how to structure the response.\n\n## Blueprints and Artifacts\n\n- Determine if the interaction involves an artifact. Prefer artifacts for tables, lists, spreadsheets, kanbans, games, images, and other structured data.\n- Determine if the user is explicitly talking about creating a new artifact, or wants to use an existing artifact.\n- If it is ambiguous, query for existing artifacts first and then decide.\n- If you decide to create an artifact, call the associated tool to create the artifact.\n- Artifacts are stored in the database. Tools are used to create and query artifacts.\n- If you are unsure about creating an artifact ask the user for clarification.\n- Artifacts are mutable objects that can change over the course of the conversation.\n- Always re-query the artifact using the tool (like query or inspect) to get the latest state of the artifact before answering the user.\n- You must never generate the id of the artifact; only recall the ids that are already in the history.\n- Artifacts are created by requiring the specific artifact using the require_artifact tool and creating it by calling the associated tool.\n- You can add suggested actions at the end of your response.\n- Suggested actions should be very concise and start with a verb and be phrased as a command to an agent -- not a question to the user.\n- Suggested actions must be in the form of a user instruction that you can follow.\n- Suggested actions could include actions that create artifacts.\n- After creating an artifact use a tool to add it to the chat context.\n\n## Context\n\nToday is {{DATETIME}}.\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { type ObjectId } from '@dxos/echo/internal';\nimport { DXN, LOCAL_SPACE_TAG, type SpaceId } from '@dxos/keys';\nimport { trim } from '@dxos/util';\n\n/**\n * @deprecated\n */\nexport const createArtifactElement = (id: ObjectId) => `<artifact id=${id} />`;\n\n/**\n * A model-friendly way to reference an object.\n * Supports vairous formats that will be normalized to a DXN.\n */\n// TODO(burdon): Rename ObjectReference?\nexport const ArtifactId: Schema.Schema<string> & {\n toDXN: (reference: ArtifactId, owningSpaceId?: SpaceId) => DXN;\n} = class extends Schema.String.annotations({\n description: trim`\n The ID of the referenced object. Formats accepted:\n - DXN (dxn:echo:@:XXXXX). 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 (XXXXX)\n `,\n examples: ['dxn:echo:@:XXXXX', '@dxn:echo:@:XXXXX', 'spaceID:objectID', 'XXXXX'],\n}) {\n static toDXN(reference: ArtifactId, owningSpaceId?: SpaceId): DXN {\n // Allow @dxn: prefix for compatibility with in-text references.\n if (reference.startsWith('@dxn:')) {\n return DXN.parse(reference.slice(1));\n } else if (reference.startsWith('dxn:')) {\n return DXN.parse(reference);\n } else if (/^[A-Z0-9]+:[A-Z0-9]+$/.test(reference)) {\n const [spaceId, objectId] = reference.split(':');\n // This is a workaround because the current Filter API doesn't work with fully qualified Echo DXNs.\n // We check if the space ID is the same as the owning space and then use LOCAL_SPACE_TAG for local references.\n // TODO(dmaretskyi): Fix this in the Echo and Filter API to properly handle fully qualified DXNs.\n return new DXN(DXN.kind.ECHO, [spaceId === owningSpaceId ? LOCAL_SPACE_TAG : spaceId, objectId]);\n } else if (/^[A-Z0-9]+$/.test(reference)) {\n return DXN.fromLocalObjectId(reference);\n } else {\n throw new Error(`Unable to parse object reference: ${reference}`);\n }\n }\n};\n\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zB,SAASC,gBAAgB;;;ACPzB;;;ACAA;;;AFuBO,IAAMC,qBAAqB,CAACC,UAAwC,CAAC,MAC1EC,SAASC,QACPC,gBACAC,aAAaJ,SAAS;EACpBK,WAAU,oBAAIC,KAAAA,GAAOC,YAAW;AAClC,CAAA,CAAA;AAGG,IAAMC,YAAY;;EAEvBC,QAAQR,SAASS,KAAK;;;;IAIpBC,IAAI;IACJC,QAAQC;EACV,CAAA;AACF;;;AGpCA,YAAYC,aAAY;AAGxB,SAASC,OAAAA,MAAKC,uBAAqC;AACnD,SAASC,YAAY;AAKd,IAAMC,wBAAwB,CAACC,OAAiB,gBAAgBA,EAAAA;AAOhE,IAAMC,aAET,cAAqBC,eAAOC,YAAY;EAC1CC,aAAaC;;;;;;EAMbC,UAAU;IAAC;IAAoB;IAAqB;IAAoB;;AAC1E,CAAA,EAAA;EACE,OAAOC,MAAMC,WAAuBC,eAA8B;AAEhE,QAAID,UAAUE,WAAW,OAAA,GAAU;AACjC,aAAOC,KAAIC,MAAMJ,UAAUK,MAAM,CAAA,CAAA;IACnC,WAAWL,UAAUE,WAAW,MAAA,GAAS;AACvC,aAAOC,KAAIC,MAAMJ,SAAAA;IACnB,WAAW,wBAAwBM,KAAKN,SAAAA,GAAY;AAClD,YAAM,CAACO,SAASC,QAAAA,IAAYR,UAAUS,MAAM,GAAA;AAI5C,aAAO,IAAIN,KAAIA,KAAIO,KAAKC,MAAM;QAACJ,YAAYN,gBAAgBW,kBAAkBL;QAASC;OAAS;IACjG,WAAW,cAAcF,KAAKN,SAAAA,GAAY;AACxC,aAAOG,KAAIU,kBAAkBb,SAAAA;IAC/B,OAAO;AACL,YAAM,IAAIc,MAAM,qCAAqCd,SAAAA,EAAW;IAClE;EACF;AACF;",
|
|
6
|
-
"names": ["computed", "Array", "Context", "Function", "Schema", "Blueprint", "Resource", "DXN", "Filter", "Obj", "Query", "Type", "invariant", "ComplexSet", "ContextBinding", "Struct", "blueprints", "added", "Ref", "removed", "objects", "Expando", "pipe", "typename", "version", "Bindings", "toJSON", "fromIterable", "map", "ref", "dxn", "toString", "asEchoDXN", "echoId", "AiContextBinder", "bindings", "_bindings", "_blueprints", "_objects", "_open", "query", "_queue", "select", "everything", "_ctx", "onDispose", "subscribe", "_reduce", "value", "_close", "undefined", "run", "bind", "props", "filter", "peek", "find", "b", "o", "length", "append", "make", "unbind", "items", "instanceOf", "reduce", "context", "item", "forEach", "delete", "add", "obj", "equalsEchoId", "AiContextService", "Tag", "Array", "Effect", "Option", "Resource", "Obj", "DatabaseService", "log", "DataType", "AiConversation", "Resource", "_open", "_context", "open", "_close", "close", "context", "toolkit", "_toolkit", "getHistory", "queueItems", "_queue", "queryObjects", "filter", "Obj", "instanceOf", "DataType", "Message", "createRequest", "params", "gen", "session", "AiSession", "history", "promise", "query", "blueprints", "forEach", "values", "DatabaseService", "loadOption", "pipe", "map", "isSome", "option", "value", "objects", "createToolkit", "start", "Date", "now", "log", "length", "tools", "messages", "run", "provideService", "AiContextService", "binder", "duration", "append", "withSpan", "queue", "_define_property", "AiContextBinder", "next", "A", "DocAccessor", "toCursorRange", "log", "isNonNullable", "reduceDiffs", "diffs", "reduce", "acc", "diff", "current", "length", "op", "rest", "split", "match", "join", "push", "replace", "computeDiffsWithCursors", "accessor", "map", "text", "getValue", "idx", "indexOf", "cursor", "filter", "applyDiffs", "handle", "change", "doc", "splice", "path", "warn", "AgentStatus", "Obj", "MESSAGE_PROPERTY_TOOL_CALL_ID", "LogLevel", "ContentBlock", "DataType", "isNonNullable", "ExecutionGraph", "addEvents", "events", "sortedEvents", "sortObjectsByCreated", "event", "Obj", "instanceOf", "DataType", "Message", "_processMessage", "AgentStatus", "_processAgentStatus", "message", "messageCommits", "messageToCommits", "_lastBlockId", "_toolCallCommitIds", "_lastCommitByBranch", "_commits", "push", "forEach", "commit", "_branchNames", "add", "branch", "_trackToolCalls", "length", "id", "_getToolCallBranch", "parentMessage", "toolCallId", "agentStatusCommit", "icon", "parents", "_getAgentStatusParents", "timestamp", "Date", "created", "set", "_updatePendingToolResults", "objects", "sortedObjects", "slice", "createdObjects", "obj", "idx", "sort", "a", "b", "aDate", "getTime", "bDate", "createdIdx", "map", "_idx", "getGraph", "lastRequest", "findLastIndex", "c", "tags", "includes", "commits", "branches", "Array", "from", "_isToolCallCommit", "_extractToolCallId", "_isToolResultCommit", "_pendingToolResults", "_handleLateToolResultUpdate", "agentStatusId", "toolResultId", "get", "toolResultCommit", "find", "toolCallCommitId", "toolCallIndex", "indexOf", "delete", "messageId", "split", "toolCallBranch", "agentStatusCommitId", "getToolCallId", "commitId", "toolCallMatch", "match", "toolResultMatch", "_define_property", "Set", "Map", "lastBlockId", "toolCallIds", "lastCommitByBranch", "previousBlockId", "blocks", "block", "getMessageBranch", "getBlockParents", "createBlockCommit", "filter", "isNonNullable", "_tag", "getToolCallBranchFromCommitId", "lastBlockFromToolCallBranch", "toolCallParent", "getParentId", "text", "trim", "getGenericBlockId", "sender", "role", "level", "LogLevel", "INFO", "name", "getToolResultId", "error", "ERROR", "ContentBlock", "createSummaryMessage", "statusText", "reasoningText", "stringifyRef", "reference", "getBranchName", "options", "properties", "MESSAGE_PROPERTY_TOOL_CALL_ID", "undefined", "ref", "target", "stringifyObject", "dxn", "asEchoDXN", "echoId", "asQueueDXN", "objectId", "getLabel", "getTypename", "Tool", "Context", "Effect", "Layer", "Record", "Schema", "AiToolNotFoundError", "ToolExecutionService", "ToolResolverService", "todo", "Query", "DatabaseService", "FunctionDefinition", "FunctionInvocationService", "FunctionType", "invariant", "makeToolResolverFromFunctions", "functions", "toolkit", "effect", "gen", "dbService", "resolve", "id", "tool", "tools", "objects", "dbFunction", "runQuery", "type", "key", "functionDef", "deserialize", "find", "fn", "fail", "projectFunctionToTool", "pipe", "provideService", "makeToolExecutionServiceFromFunctions", "handlersLayer", "toolkitHandler", "provide", "isHandlerLike", "functionInvocationService", "handlersFor", "makeHandler", "name", "input", "isProviderDefined", "Error", "handle", "definition", "get", "FunctionToolAnnotation", "annotations", "invokeFunction", "catchAllDefect", "defect", "of", "map", "_name", "isUserDefined", "Tag", "toolCache", "WeakMap", "has", "make", "makeToolName", "description", "parameters", "createStructFieldsFromSchema", "inputSchema", "failure", "Any", "annotate", "set", "toolName", "replace", "match", "schema", "ast", "_tag", "Object", "fromEntries", "propertySignatures", "prop", "value", "defaultsDeep", "Template", "createSystemPrompt", "options", "Template", "process", "FORMAT", "defaultsDeep", "DATETIME", "Date", "toISOString", "templates", "system", "make", "id", "source", "SYSTEM", "Schema", "DXN", "LOCAL_SPACE_TAG", "trim", "createArtifactElement", "id", "ArtifactId", "String", "annotations", "description", "trim", "examples", "toDXN", "reference", "owningSpaceId", "startsWith", "DXN", "parse", "slice", "test", "spaceId", "objectId", "split", "kind", "ECHO", "LOCAL_SPACE_TAG", "fromLocalObjectId", "Error"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/conversation/context.ts":{"bytes":20867,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/session/artifact-diff.ts":{"bytes":2596,"imports":[{"path":"effect/Context","kind":"import-statement","external":true}],"format":"esm"},"src/session/observer.ts":{"bytes":5409,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true}],"format":"esm"},"src/errors.ts":{"bytes":1420,"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true}],"format":"esm"},"src/session/format.ts":{"bytes":17119,"imports":[{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"../errors"},{"path":"src/session/artifact-diff.ts","kind":"import-statement","original":"./artifact-diff"}],"format":"esm"},"src/session/session.ts":{"bytes":24715,"imports":[{"path":"@effect/ai/LanguageModel","kind":"import-statement","external":true},{"path":"effect/Chunk","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/session/format.ts","kind":"import-statement","original":"./format"},{"path":"src/session/observer.ts","kind":"import-statement","original":"./observer"},{"path":"@dxos/node-std/fs","kind":"require-call","external":true}],"format":"esm"},"src/session/toolkit.ts":{"bytes":4536,"imports":[{"path":"@effect/ai/Toolkit","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/session/version-pin.ts":{"bytes":4578,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true}],"format":"esm"},"src/session/index.ts":{"bytes":832,"imports":[{"path":"src/session/artifact-diff.ts","kind":"import-statement","original":"./artifact-diff"},{"path":"src/session/observer.ts","kind":"import-statement","original":"./observer"},{"path":"src/session/session.ts","kind":"import-statement","original":"./session"},{"path":"src/session/toolkit.ts","kind":"import-statement","original":"./toolkit"},{"path":"src/session/version-pin.ts","kind":"import-statement","original":"./version-pin"}],"format":"esm"},"src/conversation/conversation.ts":{"bytes":13382,"imports":[{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/session/index.ts","kind":"import-statement","original":"../session"},{"path":"src/conversation/context.ts","kind":"import-statement","original":"./context"}],"format":"esm"},"src/conversation/index.ts":{"bytes":562,"imports":[{"path":"src/conversation/context.ts","kind":"import-statement","original":"./context"},{"path":"src/conversation/conversation.ts","kind":"import-statement","original":"./conversation"}],"format":"esm"},"src/diff.ts":{"bytes":8472,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/execution-graph.ts":{"bytes":50847,"imports":[{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/functions/services.ts":{"bytes":20015,"imports":[{"path":"@effect/ai/Tool","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"src/functions/index.ts":{"bytes":460,"imports":[{"path":"src/functions/services.ts","kind":"import-statement","original":"./services"}],"format":"esm"},"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/format.tpl?raw":{"bytes":1915,"imports":[]},"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/system.tpl?raw":{"bytes":3351,"imports":[]},"src/templates/system.ts":{"bytes":3127,"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/format.tpl?raw","kind":"import-statement","original":"./format.tpl?raw"},{"path":"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/system.tpl?raw","kind":"import-statement","original":"./system.tpl?raw"}],"format":"esm"},"src/templates/index.ts":{"bytes":458,"imports":[{"path":"src/templates/system.ts","kind":"import-statement","original":"./system"}],"format":"esm"},"src/types/artifact.ts":{"bytes":6896,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/types/index.ts":{"bytes":456,"imports":[{"path":"src/types/artifact.ts","kind":"import-statement","original":"./artifact"}],"format":"esm"},"src/index.ts":{"bytes":1081,"imports":[{"path":"src/conversation/index.ts","kind":"import-statement","original":"./conversation"},{"path":"src/diff.ts","kind":"import-statement","original":"./diff"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/execution-graph.ts","kind":"import-statement","original":"./execution-graph"},{"path":"src/functions/index.ts","kind":"import-statement","original":"./functions"},{"path":"src/session/index.ts","kind":"import-statement","original":"./session"},{"path":"src/templates/index.ts","kind":"import-statement","original":"./templates"},{"path":"src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/extraction/extraction.ts":{"bytes":6844,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"src/extraction/quotes.ts":{"bytes":7132,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/extraction/extraction-llm-function/instructions.tpl?raw":{"bytes":1318,"imports":[]},"src/extraction/extraction-llm-function/extraction-llm-function.ts":{"bytes":8733,"imports":[{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/session/index.ts","kind":"import-statement","original":"../../session"},{"path":"src/extraction/extraction.ts","kind":"import-statement","original":"../extraction"},{"path":"src/extraction/quotes.ts","kind":"import-statement","original":"../quotes"},{"path":"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/extraction/extraction-llm-function/instructions.tpl?raw","kind":"import-statement","original":"./instructions.tpl?raw"}],"format":"esm"},"src/extraction/extraction-llm-function/index.ts":{"bytes":524,"imports":[{"path":"src/extraction/extraction-llm-function/extraction-llm-function.ts","kind":"import-statement","original":"./extraction-llm-function"}],"format":"esm"},"src/extraction/extraction-ner-function/named-entity-recognition.ts":{"bytes":10067,"imports":[{"path":"@xenova/transformers","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/extraction/extraction-ner-function/extraction-ner-function.ts":{"bytes":9310,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/extraction/extraction.ts","kind":"import-statement","original":"../extraction"},{"path":"src/extraction/quotes.ts","kind":"import-statement","original":"../quotes"},{"path":"src/extraction/extraction-ner-function/named-entity-recognition.ts","kind":"dynamic-import","original":"./named-entity-recognition"}],"format":"esm"},"src/extraction/extraction-ner-function/index.ts":{"bytes":652,"imports":[{"path":"src/extraction/extraction-ner-function/extraction-ner-function.ts","kind":"import-statement","original":"./extraction-ner-function"},{"path":"src/extraction/extraction-ner-function/named-entity-recognition.ts","kind":"import-statement","original":"./named-entity-recognition"}],"format":"esm"},"src/extraction/index.ts":{"bytes":803,"imports":[{"path":"src/extraction/extraction.ts","kind":"import-statement","original":"./extraction"},{"path":"src/extraction/extraction-llm-function/index.ts","kind":"import-statement","original":"./extraction-llm-function"},{"path":"src/extraction/extraction-ner-function/index.ts","kind":"import-statement","original":"./extraction-ner-function"},{"path":"src/extraction/quotes.ts","kind":"import-statement","original":"./quotes"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":66578},"dist/lib/browser/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-CWGVG235.mjs","kind":"import-statement"},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@effect/ai/Tool","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["AiAssistantError","AiContextBinder","AiContextService","AiConversation","AiModelError","AiSession","ArtifactDiffResolver","ArtifactId","Bindings","ContextBinding","ExecutionGraph","GenerationObserver","VersionPin","applyDiffs","computeDiffsWithCursors","createArtifactElement","createSystemPrompt","createToolkit","makeToolExecutionServiceFromFunctions","makeToolResolverFromFunctions","reduceDiffs","templates"],"entryPoint":"src/index.ts","inputs":{"src/conversation/context.ts":{"bytesInOutput":5345},"src/conversation/index.ts":{"bytesInOutput":0},"src/conversation/conversation.ts":{"bytesInOutput":3218},"src/index.ts":{"bytesInOutput":0},"src/diff.ts":{"bytesInOutput":1899},"src/execution-graph.ts":{"bytesInOutput":12095},"src/functions/services.ts":{"bytesInOutput":4281},"src/functions/index.ts":{"bytesInOutput":0},"src/templates/system.ts":{"bytesInOutput":540},"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/format.tpl?raw":{"bytesInOutput":2000},"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/system.tpl?raw":{"bytesInOutput":3424},"src/templates/index.ts":{"bytesInOutput":0},"src/types/artifact.ts":{"bytesInOutput":1332},"src/types/index.ts":{"bytesInOutput":0}},"bytes":35170},"dist/lib/browser/extraction/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17181},"dist/lib/browser/extraction/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-CWGVG235.mjs","kind":"import-statement"},{"path":"dist/lib/browser/chunk-UB26N5UF.mjs","kind":"import-statement"},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"dist/lib/browser/named-entity-recognition-QPYHML66.mjs","kind":"dynamic-import"}],"exports":["ExtractionInput","ExtractionOutput","ReferencedQuotes","combineNerTokens","createTokenGroups","extractFullEntities","extractionAnthropicFunction","extractionNerFunction","findQuotes","getNer","insertReferences","processTranscriptMessage"],"entryPoint":"src/extraction/index.ts","inputs":{"src/extraction/extraction.ts":{"bytesInOutput":1380},"src/extraction/index.ts":{"bytesInOutput":0},"src/extraction/extraction-llm-function/extraction-llm-function.ts":{"bytesInOutput":1852},"src/extraction/quotes.ts":{"bytesInOutput":1673},"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/extraction/extraction-llm-function/instructions.tpl?raw":{"bytesInOutput":1376},"src/extraction/extraction-llm-function/index.ts":{"bytesInOutput":0},"src/extraction/extraction-ner-function/extraction-ner-function.ts":{"bytesInOutput":2742},"src/extraction/extraction-ner-function/index.ts":{"bytesInOutput":0}},"bytes":9873},"dist/lib/browser/chunk-CWGVG235.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":29306},"dist/lib/browser/chunk-CWGVG235.mjs":{"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@effect/ai/LanguageModel","kind":"import-statement","external":true},{"path":"effect/Chunk","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@effect/ai/Toolkit","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true}],"exports":["AiAssistantError","AiModelError","AiSession","ArtifactDiffResolver","GenerationObserver","VersionPin","createToolkit"],"inputs":{"src/session/artifact-diff.ts":{"bytesInOutput":143},"src/session/observer.ts":{"bytesInOutput":917},"src/errors.ts":{"bytesInOutput":236},"src/session/session.ts":{"bytesInOutput":4716},"src/session/format.ts":{"bytesInOutput":3923},"src/session/toolkit.ts":{"bytesInOutput":744},"src/session/version-pin.ts":{"bytesInOutput":1040},"src/session/index.ts":{"bytesInOutput":0}},"bytes":12117},"dist/lib/browser/named-entity-recognition-QPYHML66.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/browser/named-entity-recognition-QPYHML66.mjs":{"imports":[{"path":"dist/lib/browser/chunk-UB26N5UF.mjs","kind":"import-statement"}],"exports":["combineNerTokens","createTokenGroups","extractFullEntities","getNer"],"entryPoint":"src/extraction/extraction-ner-function/named-entity-recognition.ts","inputs":{},"bytes":261},"dist/lib/browser/chunk-UB26N5UF.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5245},"dist/lib/browser/chunk-UB26N5UF.mjs":{"imports":[{"path":"@xenova/transformers","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["combineNerTokens","createTokenGroups","extractFullEntities","getNer"],"inputs":{"src/extraction/extraction-ner-function/named-entity-recognition.ts":{"bytesInOutput":2265}},"bytes":2465}}}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
combineNerTokens,
|
|
3
|
-
createTokenGroups,
|
|
4
|
-
extractFullEntities,
|
|
5
|
-
getNer
|
|
6
|
-
} from "./chunk-UB26N5UF.mjs";
|
|
7
|
-
export {
|
|
8
|
-
combineNerTokens,
|
|
9
|
-
createTokenGroups,
|
|
10
|
-
extractFullEntities,
|
|
11
|
-
getNer
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=named-entity-recognition-QPYHML66.mjs.map
|