@dxos/assistant 0.8.3-main.7f5a14c → 0.8.3
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/browser/index.mjs +49 -28
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +53 -32
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +49 -28
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/blueprint/blueprint.d.ts +3 -2
- package/dist/types/src/blueprint/blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprint/machine.d.ts +10 -4
- package/dist/types/src/blueprint/machine.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 +31 -33
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction.d.ts +104 -100
- package/dist/types/src/extraction/extraction.d.ts.map +1 -1
- package/dist/types/src/extraction/quotes.d.ts.map +1 -1
- package/dist/types/src/research/graph.d.ts +3 -2
- package/dist/types/src/research/graph.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +6 -6
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/blueprint/ai.test.ts +1 -1
- package/src/blueprint/blueprint.test.ts +5 -5
- package/src/blueprint/logger.ts +6 -6
- package/src/blueprint/machine.ts +23 -18
- package/src/blueprint/test-data.ts +4 -4
- package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +2 -2
- package/src/extraction/extraction-llm-function/extraction-llm-function.ts +2 -1
- package/src/extraction/quotes.ts +2 -1
- package/src/research/graph.ts +3 -5
- package/src/research/research.test.ts +8 -7
- package/src/research/research.ts +1 -1
- package/src/session/session.test.ts +10 -10
- package/src/session/session.ts +4 -3
- package/src/summarization/summarization.test.ts +17 -12
|
@@ -46,6 +46,7 @@ var processTranscriptMessage = async (params) => {
|
|
|
46
46
|
|
|
47
47
|
// packages/core/assistant/src/extraction/extraction-llm-function/extraction-llm-function.ts
|
|
48
48
|
import { Message as Message2 } from "@dxos/ai";
|
|
49
|
+
import { Obj as Obj2 } from "@dxos/echo";
|
|
49
50
|
import { create as create2 } from "@dxos/echo-schema";
|
|
50
51
|
import { AiService, defineFunction } from "@dxos/functions";
|
|
51
52
|
import { DataType as DataType2 } from "@dxos/schema";
|
|
@@ -57,6 +58,7 @@ var instructions_default = 'You are an AI assistant specialized in processing an
|
|
|
57
58
|
import { Option, Schema as Schema3 } from "effect";
|
|
58
59
|
import { AgentStatusReport, isToolUse, runTools, structuredOutputParser, Message, MixedStreamParser, ToolResult, createTool } from "@dxos/ai";
|
|
59
60
|
import { Event, synchronized } from "@dxos/async";
|
|
61
|
+
import { Obj } from "@dxos/echo";
|
|
60
62
|
import { ObjectVersion } from "@dxos/echo-db";
|
|
61
63
|
import { create } from "@dxos/echo-schema";
|
|
62
64
|
import { invariant } from "@dxos/invariant";
|
|
@@ -166,7 +168,7 @@ var AISession = class _AISession {
|
|
|
166
168
|
tools: tools.map((tool) => tool.name)
|
|
167
169
|
}, {
|
|
168
170
|
F: __dxlog_file2,
|
|
169
|
-
L:
|
|
171
|
+
L: 201,
|
|
170
172
|
S: this,
|
|
171
173
|
C: (f, a) => f(...a)
|
|
172
174
|
});
|
|
@@ -189,7 +191,7 @@ var AISession = class _AISession {
|
|
|
189
191
|
pending: this._pending
|
|
190
192
|
}, {
|
|
191
193
|
F: __dxlog_file2,
|
|
192
|
-
L:
|
|
194
|
+
L: 226,
|
|
193
195
|
S: this,
|
|
194
196
|
C: (f, a) => f(...a)
|
|
195
197
|
});
|
|
@@ -197,7 +199,7 @@ var AISession = class _AISession {
|
|
|
197
199
|
const message = this._pending.at(-1);
|
|
198
200
|
invariant(message, void 0, {
|
|
199
201
|
F: __dxlog_file2,
|
|
200
|
-
L:
|
|
202
|
+
L: 231,
|
|
201
203
|
S: this,
|
|
202
204
|
A: [
|
|
203
205
|
"message",
|
|
@@ -207,7 +209,7 @@ var AISession = class _AISession {
|
|
|
207
209
|
if (isToolUse(message)) {
|
|
208
210
|
log2("tool request...", void 0, {
|
|
209
211
|
F: __dxlog_file2,
|
|
210
|
-
L:
|
|
212
|
+
L: 233,
|
|
211
213
|
S: this,
|
|
212
214
|
C: (f, a) => f(...a)
|
|
213
215
|
});
|
|
@@ -221,7 +223,7 @@ var AISession = class _AISession {
|
|
|
221
223
|
response
|
|
222
224
|
}, {
|
|
223
225
|
F: __dxlog_file2,
|
|
224
|
-
L:
|
|
226
|
+
L: 241,
|
|
225
227
|
S: this,
|
|
226
228
|
C: (f, a) => f(...a)
|
|
227
229
|
});
|
|
@@ -241,7 +243,7 @@ var AISession = class _AISession {
|
|
|
241
243
|
} catch (err) {
|
|
242
244
|
log2.catch(err, void 0, {
|
|
243
245
|
F: __dxlog_file2,
|
|
244
|
-
L:
|
|
246
|
+
L: 253,
|
|
245
247
|
S: this,
|
|
246
248
|
C: (f, a) => f(...a)
|
|
247
249
|
});
|
|
@@ -286,7 +288,7 @@ var AISession = class _AISession {
|
|
|
286
288
|
versions
|
|
287
289
|
}, {
|
|
288
290
|
F: __dxlog_file2,
|
|
289
|
-
L:
|
|
291
|
+
L: 296,
|
|
290
292
|
S: this,
|
|
291
293
|
C: (f, a) => f(...a)
|
|
292
294
|
});
|
|
@@ -306,7 +308,7 @@ var AISession = class _AISession {
|
|
|
306
308
|
prelude.push(createArtifactUpdateBlock(artifactDiff));
|
|
307
309
|
}
|
|
308
310
|
}
|
|
309
|
-
return
|
|
311
|
+
return Obj.make(Message, {
|
|
310
312
|
role: "user",
|
|
311
313
|
content: [
|
|
312
314
|
...prelude,
|
|
@@ -398,7 +400,7 @@ var AISession = class _AISession {
|
|
|
398
400
|
action: step.action
|
|
399
401
|
}, {
|
|
400
402
|
F: __dxlog_file2,
|
|
401
|
-
L:
|
|
403
|
+
L: 403,
|
|
402
404
|
S: this,
|
|
403
405
|
C: (f, a) => f(...a)
|
|
404
406
|
});
|
|
@@ -524,7 +526,8 @@ ${diff}` : ""}</changed-artifact>`).join("\n")}
|
|
|
524
526
|
|
|
525
527
|
// packages/core/assistant/src/extraction/quotes.ts
|
|
526
528
|
import { Schema as Schema4 } from "effect";
|
|
527
|
-
import {
|
|
529
|
+
import { Query, Filter } from "@dxos/echo";
|
|
530
|
+
import { ObjectId as ObjectId2 } from "@dxos/echo-schema";
|
|
528
531
|
import { DXN } from "@dxos/keys";
|
|
529
532
|
import { log as log3 } from "@dxos/log";
|
|
530
533
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/assistant/src/extraction/quotes.ts";
|
|
@@ -550,7 +553,7 @@ var findQuotes = async (quotes, db) => {
|
|
|
550
553
|
quote
|
|
551
554
|
}, {
|
|
552
555
|
F: __dxlog_file3,
|
|
553
|
-
L:
|
|
556
|
+
L: 35,
|
|
554
557
|
S: void 0,
|
|
555
558
|
C: (f, a) => f(...a)
|
|
556
559
|
});
|
|
@@ -594,7 +597,7 @@ var extractionAnthropicFn = defineFunction({
|
|
|
594
597
|
client: ai.client,
|
|
595
598
|
systemPrompt: instructions_default,
|
|
596
599
|
history: [
|
|
597
|
-
|
|
600
|
+
Obj2.make(Message2, {
|
|
598
601
|
role: "user",
|
|
599
602
|
content: [
|
|
600
603
|
{
|
|
@@ -1393,8 +1396,9 @@ import { DataTypes } from "@dxos/schema";
|
|
|
1393
1396
|
// packages/core/assistant/src/research/graph.ts
|
|
1394
1397
|
import { Schema as Schema6, identity, Option as Option2, SchemaAST } from "effect";
|
|
1395
1398
|
import { createTool as createTool3, ToolResult as ToolResult3 } from "@dxos/ai";
|
|
1399
|
+
import { Query as Query2, Filter as Filter2 } from "@dxos/echo";
|
|
1396
1400
|
import { isEncodedReference } from "@dxos/echo-protocol";
|
|
1397
|
-
import { EntityKind, getSchemaTypename, getTypeAnnotation, getTypeIdentifierAnnotation, create as create4,
|
|
1401
|
+
import { EntityKind, getSchemaTypename, getTypeAnnotation, getTypeIdentifierAnnotation, create as create4, getEntityKind, getSchemaDXN, ObjectId as ObjectId3, ReferenceAnnotationId, RelationSourceDXNId, RelationTargetDXNId, RelationSourceId, RelationTargetId } from "@dxos/echo-schema";
|
|
1398
1402
|
import { mapAst } from "@dxos/effect";
|
|
1399
1403
|
import { DXN as DXN2 } from "@dxos/keys";
|
|
1400
1404
|
import { log as log7 } from "@dxos/log";
|
|
@@ -1519,7 +1523,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
|
|
|
1519
1523
|
source: data2.source
|
|
1520
1524
|
}, {
|
|
1521
1525
|
F: __dxlog_file7,
|
|
1522
|
-
L:
|
|
1526
|
+
L: 214,
|
|
1523
1527
|
S: void 0,
|
|
1524
1528
|
C: (f, a) => f(...a)
|
|
1525
1529
|
});
|
|
@@ -1530,7 +1534,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
|
|
|
1530
1534
|
target: data2.target
|
|
1531
1535
|
}, {
|
|
1532
1536
|
F: __dxlog_file7,
|
|
1533
|
-
L:
|
|
1537
|
+
L: 218,
|
|
1534
1538
|
S: void 0,
|
|
1535
1539
|
C: (f, a) => f(...a)
|
|
1536
1540
|
});
|
|
@@ -1559,7 +1563,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
|
|
|
1559
1563
|
existingIds
|
|
1560
1564
|
}, {
|
|
1561
1565
|
F: __dxlog_file7,
|
|
1562
|
-
L:
|
|
1566
|
+
L: 239,
|
|
1563
1567
|
S: void 0,
|
|
1564
1568
|
C: (f, a) => f(...a)
|
|
1565
1569
|
});
|
|
@@ -1732,7 +1736,7 @@ var createArtifactElement = (id) => `<artifact id=${id} />`;
|
|
|
1732
1736
|
|
|
1733
1737
|
// packages/core/assistant/src/blueprint/blueprint.ts
|
|
1734
1738
|
import { Schema as Schema8 } from "effect";
|
|
1735
|
-
import { Key, Obj, Type } from "@dxos/echo";
|
|
1739
|
+
import { Key, Obj as Obj3, Type } from "@dxos/echo";
|
|
1736
1740
|
var BlueprintStep = Schema8.Struct({
|
|
1737
1741
|
id: Key.ObjectId,
|
|
1738
1742
|
instructions: Schema8.String,
|
|
@@ -1763,7 +1767,7 @@ var Blueprint = Schema8.Struct({
|
|
|
1763
1767
|
return this;
|
|
1764
1768
|
}
|
|
1765
1769
|
build() {
|
|
1766
|
-
return
|
|
1770
|
+
return Obj3.make(Blueprint, {
|
|
1767
1771
|
steps: this._steps
|
|
1768
1772
|
});
|
|
1769
1773
|
}
|
|
@@ -1790,7 +1794,7 @@ var BlueprintParser;
|
|
|
1790
1794
|
import { Match, Schema as Schema9 } from "effect";
|
|
1791
1795
|
import { createTool as createTool4, Message as Message3, ToolResult as ToolResult4 } from "@dxos/ai";
|
|
1792
1796
|
import { Event as Event2 } from "@dxos/async";
|
|
1793
|
-
import {
|
|
1797
|
+
import { Key as Key2, Obj as Obj4 } from "@dxos/echo";
|
|
1794
1798
|
import { log as log9 } from "@dxos/log";
|
|
1795
1799
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1796
1800
|
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/assistant/src/blueprint/machine.ts";
|
|
@@ -1829,21 +1833,26 @@ var BlueprintMachine = class {
|
|
|
1829
1833
|
return this;
|
|
1830
1834
|
}
|
|
1831
1835
|
async runToCompletion(options) {
|
|
1832
|
-
|
|
1836
|
+
const invocationId = Key2.ObjectId.random();
|
|
1837
|
+
log9.info("runToCompletion", {
|
|
1838
|
+
invocationId,
|
|
1839
|
+
options
|
|
1840
|
+
}, {
|
|
1833
1841
|
F: __dxlog_file9,
|
|
1834
|
-
L:
|
|
1842
|
+
L: 107,
|
|
1835
1843
|
S: this,
|
|
1836
1844
|
C: (f, a) => f(...a)
|
|
1837
1845
|
});
|
|
1838
1846
|
this.begin.emit();
|
|
1839
1847
|
this.logger?.log({
|
|
1840
|
-
type: "begin"
|
|
1848
|
+
type: "begin",
|
|
1849
|
+
invocationId
|
|
1841
1850
|
});
|
|
1842
1851
|
let firstStep = true;
|
|
1843
1852
|
while (this._state.state !== "done") {
|
|
1844
1853
|
const input = firstStep ? options.input : void 0;
|
|
1845
1854
|
firstStep = false;
|
|
1846
|
-
this._state = await this._execStep(this._state, {
|
|
1855
|
+
this._state = await this._execStep(invocationId, this._state, {
|
|
1847
1856
|
input,
|
|
1848
1857
|
aiClient: options.aiClient
|
|
1849
1858
|
});
|
|
@@ -1851,6 +1860,7 @@ var BlueprintMachine = class {
|
|
|
1851
1860
|
this.stepComplete.emit(step);
|
|
1852
1861
|
this.logger?.log({
|
|
1853
1862
|
type: "step-complete",
|
|
1863
|
+
invocationId,
|
|
1854
1864
|
step
|
|
1855
1865
|
});
|
|
1856
1866
|
if (this._state.state === "bail") {
|
|
@@ -1859,10 +1869,11 @@ var BlueprintMachine = class {
|
|
|
1859
1869
|
}
|
|
1860
1870
|
this.end.emit();
|
|
1861
1871
|
this.logger?.log({
|
|
1862
|
-
type: "end"
|
|
1872
|
+
type: "end",
|
|
1873
|
+
invocationId
|
|
1863
1874
|
});
|
|
1864
1875
|
}
|
|
1865
|
-
async _execStep(state, options) {
|
|
1876
|
+
async _execStep(invocationId, state, options) {
|
|
1866
1877
|
const prevStep = this.blueprint.steps.findIndex((step) => step.id === this._state.trace.at(-1)?.stepId);
|
|
1867
1878
|
if (prevStep === this.blueprint.steps.length - 1) {
|
|
1868
1879
|
throw new Error("Done execution blueprint");
|
|
@@ -1872,6 +1883,7 @@ var BlueprintMachine = class {
|
|
|
1872
1883
|
this.stepStart.emit(nextStep);
|
|
1873
1884
|
this.logger?.log({
|
|
1874
1885
|
type: "step-start",
|
|
1886
|
+
invocationId,
|
|
1875
1887
|
step: nextStep
|
|
1876
1888
|
});
|
|
1877
1889
|
const ReportSchema = Schema9.Struct({
|
|
@@ -1895,7 +1907,7 @@ var BlueprintMachine = class {
|
|
|
1895
1907
|
session.message.pipeInto(this.message);
|
|
1896
1908
|
session.block.pipeInto(this.block);
|
|
1897
1909
|
const inputMessages = options.input ? [
|
|
1898
|
-
|
|
1910
|
+
Obj4.make(Message3, {
|
|
1899
1911
|
role: "user",
|
|
1900
1912
|
content: [
|
|
1901
1913
|
taggedDataBlock("input", options.input)
|
|
@@ -1906,6 +1918,7 @@ var BlueprintMachine = class {
|
|
|
1906
1918
|
this.message.emit(message);
|
|
1907
1919
|
this.logger?.log({
|
|
1908
1920
|
type: "message",
|
|
1921
|
+
invocationId,
|
|
1909
1922
|
message
|
|
1910
1923
|
});
|
|
1911
1924
|
});
|
|
@@ -2011,28 +2024,36 @@ var BlueprintLoggerAdapter = class {
|
|
|
2011
2024
|
log(event) {
|
|
2012
2025
|
switch (event.type) {
|
|
2013
2026
|
case "begin":
|
|
2014
|
-
this.logger.log("begin"
|
|
2027
|
+
this.logger.log("begin", {
|
|
2028
|
+
invocationId: event.invocationId
|
|
2029
|
+
});
|
|
2015
2030
|
break;
|
|
2016
2031
|
case "end":
|
|
2017
|
-
this.logger.log("end"
|
|
2032
|
+
this.logger.log("end", {
|
|
2033
|
+
invocationId: event.invocationId
|
|
2034
|
+
});
|
|
2018
2035
|
break;
|
|
2019
2036
|
case "step-start":
|
|
2020
2037
|
this.logger.log("step-start", {
|
|
2038
|
+
invocationId: event.invocationId,
|
|
2021
2039
|
step: event.step
|
|
2022
2040
|
});
|
|
2023
2041
|
break;
|
|
2024
2042
|
case "step-complete":
|
|
2025
2043
|
this.logger.log("step-complete", {
|
|
2044
|
+
invocationId: event.invocationId,
|
|
2026
2045
|
step: event.step
|
|
2027
2046
|
});
|
|
2028
2047
|
break;
|
|
2029
2048
|
case "message":
|
|
2030
2049
|
this.logger.log("message", {
|
|
2050
|
+
invocationId: event.invocationId,
|
|
2031
2051
|
message: event.message
|
|
2032
2052
|
});
|
|
2033
2053
|
break;
|
|
2034
2054
|
case "block":
|
|
2035
2055
|
this.logger.log("block", {
|
|
2056
|
+
invocationId: event.invocationId,
|
|
2036
2057
|
block: event.block
|
|
2037
2058
|
});
|
|
2038
2059
|
break;
|