@dxos/assistant 0.8.3-main.672df60 → 0.8.3-staging.0fa589b
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 +149 -60
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +155 -65
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +149 -60
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/blueprint/ai.test.d.ts +2 -0
- package/dist/types/src/blueprint/ai.test.d.ts.map +1 -0
- package/dist/types/src/blueprint/blueprint.d.ts +16 -12
- package/dist/types/src/blueprint/blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprint/logger.d.ts +16 -3
- package/dist/types/src/blueprint/logger.d.ts.map +1 -1
- package/dist/types/src/blueprint/machine.d.ts +37 -16
- 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 +5 -4
- 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 +29 -20
- package/src/blueprint/ai.test.ts +156 -0
- package/src/blueprint/blueprint.test.ts +22 -20
- package/src/blueprint/blueprint.ts +18 -14
- package/src/blueprint/logger.ts +49 -3
- package/src/blueprint/machine.ts +69 -32
- 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 +7 -9
- package/src/research/research.test.ts +9 -8
- package/src/research/research.ts +2 -2
- 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
|
});
|
|
@@ -1625,13 +1629,13 @@ var preprocessSchema = (schema) => {
|
|
|
1625
1629
|
})
|
|
1626
1630
|
})) : identity);
|
|
1627
1631
|
};
|
|
1628
|
-
var createGraphWriterTool = ({ db, queue,
|
|
1632
|
+
var createGraphWriterTool = ({ db, queue, schema, onDone = async (x) => x }) => {
|
|
1629
1633
|
return createTool3("graph", {
|
|
1630
1634
|
name: "writer",
|
|
1631
1635
|
description: "Write to the local graph database",
|
|
1632
|
-
schema: createExtractionSchema(
|
|
1636
|
+
schema: createExtractionSchema(schema),
|
|
1633
1637
|
execute: async (input) => {
|
|
1634
|
-
const data = await sanitizeObjects(
|
|
1638
|
+
const data = await sanitizeObjects(schema, input, db, queue);
|
|
1635
1639
|
return ToolResult3.Success(await onDone(data));
|
|
1636
1640
|
}
|
|
1637
1641
|
});
|
|
@@ -1700,7 +1704,7 @@ var researchFn = defineFunction3({
|
|
|
1700
1704
|
}));
|
|
1701
1705
|
const graphWriteTool = createGraphWriterTool({
|
|
1702
1706
|
db,
|
|
1703
|
-
|
|
1707
|
+
schema: DataTypes
|
|
1704
1708
|
});
|
|
1705
1709
|
log8.info("graphWriteTool", {
|
|
1706
1710
|
schema: graphWriteTool.parameters
|
|
@@ -1732,19 +1736,18 @@ 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 { Obj, Type } from "@dxos/echo";
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
id: ObjectId4,
|
|
1739
|
+
import { Key, Obj as Obj3, Type } from "@dxos/echo";
|
|
1740
|
+
var BlueprintStep = Schema8.Struct({
|
|
1741
|
+
id: Key.ObjectId,
|
|
1739
1742
|
instructions: Schema8.String,
|
|
1740
|
-
tools: Schema8.Array(Schema8.String)
|
|
1743
|
+
tools: Schema8.optional(Schema8.Array(Schema8.String))
|
|
1741
1744
|
});
|
|
1742
|
-
var
|
|
1743
|
-
steps: Schema8.Array(
|
|
1745
|
+
var BlueprintDefinition = Schema8.Struct({
|
|
1746
|
+
steps: Schema8.Array(BlueprintStep.pipe(Schema8.omit("id")))
|
|
1744
1747
|
});
|
|
1745
1748
|
var Blueprint = Schema8.Struct({
|
|
1746
1749
|
name: Schema8.optional(Schema8.String),
|
|
1747
|
-
steps: Schema8.Array(
|
|
1750
|
+
steps: Schema8.Array(BlueprintStep)
|
|
1748
1751
|
}).pipe(Type.Obj({
|
|
1749
1752
|
typename: "dxos.org/type/Blueprint",
|
|
1750
1753
|
version: "0.1.0"
|
|
@@ -1757,14 +1760,14 @@ var Blueprint = Schema8.Struct({
|
|
|
1757
1760
|
}
|
|
1758
1761
|
step(instructions, options) {
|
|
1759
1762
|
this._steps.push({
|
|
1760
|
-
id:
|
|
1763
|
+
id: Key.ObjectId.random(),
|
|
1761
1764
|
instructions,
|
|
1762
1765
|
tools: options?.tools ?? []
|
|
1763
1766
|
});
|
|
1764
1767
|
return this;
|
|
1765
1768
|
}
|
|
1766
1769
|
build() {
|
|
1767
|
-
return
|
|
1770
|
+
return Obj3.make(Blueprint, {
|
|
1768
1771
|
steps: this._steps
|
|
1769
1772
|
});
|
|
1770
1773
|
}
|
|
@@ -1791,10 +1794,20 @@ var BlueprintParser;
|
|
|
1791
1794
|
import { Match, Schema as Schema9 } from "effect";
|
|
1792
1795
|
import { createTool as createTool4, Message as Message3, ToolResult as ToolResult4 } from "@dxos/ai";
|
|
1793
1796
|
import { Event as Event2 } from "@dxos/async";
|
|
1794
|
-
import {
|
|
1797
|
+
import { Key as Key2, Obj as Obj4 } from "@dxos/echo";
|
|
1795
1798
|
import { log as log9 } from "@dxos/log";
|
|
1796
1799
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1797
1800
|
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/assistant/src/blueprint/machine.ts";
|
|
1801
|
+
var SYSTEM_PROMPT = `
|
|
1802
|
+
You are a smart Rule-Following Agent.
|
|
1803
|
+
Rule-Following Agent executes the command that the user sent in the last message.
|
|
1804
|
+
After doing the work, the Rule-Following Agent calls report tool.
|
|
1805
|
+
If the Rule-Following agent believes that no action is needed, it calls the report tool with "skipped" status.
|
|
1806
|
+
If the Rule-Following Agent is unable to perform the task, it calls the report tool with "bail" status.
|
|
1807
|
+
Rule-Following Agent explains the reason it is unable to perform the task before bailing.
|
|
1808
|
+
The Rule-Following Agent can express creativity and imagination in the way it performs the task.
|
|
1809
|
+
The Rule-Following Agent precisely follows the instructions.
|
|
1810
|
+
`;
|
|
1798
1811
|
var INITIAL_STATE = {
|
|
1799
1812
|
state: "working",
|
|
1800
1813
|
history: [],
|
|
@@ -1810,39 +1823,69 @@ var BlueprintMachine = class {
|
|
|
1810
1823
|
this.stepComplete = new Event2();
|
|
1811
1824
|
this.message = new Event2();
|
|
1812
1825
|
this.block = new Event2();
|
|
1813
|
-
this.
|
|
1826
|
+
this._state = structuredClone(INITIAL_STATE);
|
|
1827
|
+
}
|
|
1828
|
+
get state() {
|
|
1829
|
+
return this._state;
|
|
1830
|
+
}
|
|
1831
|
+
setLogger(logger) {
|
|
1832
|
+
this.logger = logger;
|
|
1833
|
+
return this;
|
|
1814
1834
|
}
|
|
1815
1835
|
async runToCompletion(options) {
|
|
1816
|
-
|
|
1836
|
+
const invocationId = Key2.ObjectId.random();
|
|
1837
|
+
log9.info("runToCompletion", {
|
|
1838
|
+
invocationId,
|
|
1839
|
+
options
|
|
1840
|
+
}, {
|
|
1817
1841
|
F: __dxlog_file9,
|
|
1818
|
-
L:
|
|
1842
|
+
L: 107,
|
|
1819
1843
|
S: this,
|
|
1820
1844
|
C: (f, a) => f(...a)
|
|
1821
1845
|
});
|
|
1822
1846
|
this.begin.emit();
|
|
1847
|
+
this.logger?.log({
|
|
1848
|
+
type: "begin",
|
|
1849
|
+
invocationId
|
|
1850
|
+
});
|
|
1823
1851
|
let firstStep = true;
|
|
1824
|
-
while (this.
|
|
1852
|
+
while (this._state.state !== "done") {
|
|
1825
1853
|
const input = firstStep ? options.input : void 0;
|
|
1826
1854
|
firstStep = false;
|
|
1827
|
-
this.
|
|
1855
|
+
this._state = await this._execStep(invocationId, this._state, {
|
|
1828
1856
|
input,
|
|
1829
|
-
|
|
1857
|
+
aiClient: options.aiClient
|
|
1858
|
+
});
|
|
1859
|
+
const step = this.blueprint.steps.find((step2) => step2.id === this._state.trace.at(-1)?.stepId);
|
|
1860
|
+
this.stepComplete.emit(step);
|
|
1861
|
+
this.logger?.log({
|
|
1862
|
+
type: "step-complete",
|
|
1863
|
+
invocationId,
|
|
1864
|
+
step
|
|
1830
1865
|
});
|
|
1831
|
-
|
|
1832
|
-
if (this.state.state === "bail") {
|
|
1866
|
+
if (this._state.state === "bail") {
|
|
1833
1867
|
throw new Error("Agent unable to follow the blueprint");
|
|
1834
1868
|
}
|
|
1835
1869
|
}
|
|
1836
1870
|
this.end.emit();
|
|
1871
|
+
this.logger?.log({
|
|
1872
|
+
type: "end",
|
|
1873
|
+
invocationId
|
|
1874
|
+
});
|
|
1837
1875
|
}
|
|
1838
|
-
async _execStep(state, options) {
|
|
1839
|
-
const prevStep = this.blueprint.steps.findIndex((step) => step.id === this.
|
|
1876
|
+
async _execStep(invocationId, state, options) {
|
|
1877
|
+
const prevStep = this.blueprint.steps.findIndex((step) => step.id === this._state.trace.at(-1)?.stepId);
|
|
1840
1878
|
if (prevStep === this.blueprint.steps.length - 1) {
|
|
1841
1879
|
throw new Error("Done execution blueprint");
|
|
1842
1880
|
}
|
|
1843
1881
|
const nextStep = this.blueprint.steps[prevStep + 1];
|
|
1844
1882
|
const onLastStep = prevStep === this.blueprint.steps.length - 2;
|
|
1845
1883
|
this.stepStart.emit(nextStep);
|
|
1884
|
+
this.logger?.log({
|
|
1885
|
+
type: "step-start",
|
|
1886
|
+
invocationId,
|
|
1887
|
+
step: nextStep
|
|
1888
|
+
});
|
|
1846
1889
|
const ReportSchema = Schema9.Struct({
|
|
1847
1890
|
status: Schema9.Literal("done", "bailed", "skipped").annotations({
|
|
1848
1891
|
description: "The status of the task completion"
|
|
@@ -1853,7 +1896,7 @@ var BlueprintMachine = class {
|
|
|
1853
1896
|
});
|
|
1854
1897
|
const report = createTool4("system", {
|
|
1855
1898
|
name: "report",
|
|
1856
|
-
description: "This tool reports that the agent has completed the task or is unable to do so",
|
|
1899
|
+
description: "This tool reports that the agent has completed the task or is unable to do so.",
|
|
1857
1900
|
schema: ReportSchema,
|
|
1858
1901
|
execute: async (input) => ToolResult4.Break(input)
|
|
1859
1902
|
});
|
|
@@ -1864,26 +1907,24 @@ var BlueprintMachine = class {
|
|
|
1864
1907
|
session.message.pipeInto(this.message);
|
|
1865
1908
|
session.block.pipeInto(this.block);
|
|
1866
1909
|
const inputMessages = options.input ? [
|
|
1867
|
-
|
|
1910
|
+
Obj4.make(Message3, {
|
|
1868
1911
|
role: "user",
|
|
1869
1912
|
content: [
|
|
1870
1913
|
taggedDataBlock("input", options.input)
|
|
1871
1914
|
]
|
|
1872
1915
|
})
|
|
1873
1916
|
] : [];
|
|
1874
|
-
inputMessages.forEach((message) =>
|
|
1875
|
-
|
|
1917
|
+
inputMessages.forEach((message) => {
|
|
1918
|
+
this.message.emit(message);
|
|
1919
|
+
this.logger?.log({
|
|
1920
|
+
type: "message",
|
|
1921
|
+
invocationId,
|
|
1922
|
+
message
|
|
1923
|
+
});
|
|
1924
|
+
});
|
|
1925
|
+
const tools = nextStep.tools?.map((tool) => this.registry.get(tool)).filter(isNonNullable2) ?? [];
|
|
1876
1926
|
const messages = await session.run({
|
|
1877
|
-
systemPrompt:
|
|
1878
|
-
You are a smart Rule-Following Agent.
|
|
1879
|
-
Rule-Following Agent executes the command that the user sent in the last message.
|
|
1880
|
-
After doing the work, the Rule-Following Agent calls report tool.
|
|
1881
|
-
If the Rule-Following agent believes that no action is needed, it calls the report tool with "skipped" status.
|
|
1882
|
-
If the Rule-Following Agent is unable to perform the task, it calls the report tool with "bail" status.
|
|
1883
|
-
Rule-Following Agent explains the reason it is unable to perform the task before bailing.
|
|
1884
|
-
The Rule-Following Agent can express creativity and imagination in the way it performs the task.
|
|
1885
|
-
The Rule-Following Agent precisely follows the instructions.
|
|
1886
|
-
`,
|
|
1927
|
+
systemPrompt: SYSTEM_PROMPT,
|
|
1887
1928
|
history: [
|
|
1888
1929
|
...state.history,
|
|
1889
1930
|
...inputMessages
|
|
@@ -1893,7 +1934,7 @@ var BlueprintMachine = class {
|
|
|
1893
1934
|
report
|
|
1894
1935
|
],
|
|
1895
1936
|
artifacts: [],
|
|
1896
|
-
client: options.
|
|
1937
|
+
client: options.aiClient,
|
|
1897
1938
|
prompt: nextStep.instructions
|
|
1898
1939
|
});
|
|
1899
1940
|
const { messages: trimmedHistory, call: lastBlock } = popLastToolCall(messages);
|
|
@@ -1954,8 +1995,12 @@ import { signal } from "@preact/signals-core";
|
|
|
1954
1995
|
import chalk from "chalk";
|
|
1955
1996
|
import { ConsolePrinter as ConsolePrinter2 } from "@dxos/ai";
|
|
1956
1997
|
import { combine } from "@dxos/async";
|
|
1998
|
+
import { log as log10 } from "@dxos/log";
|
|
1957
1999
|
chalk.level = 2;
|
|
1958
|
-
var
|
|
2000
|
+
var DEFAULT_LOGGER = {
|
|
2001
|
+
log: log10.info
|
|
2002
|
+
};
|
|
2003
|
+
var BufferedLogger = class {
|
|
1959
2004
|
constructor() {
|
|
1960
2005
|
this._messages = signal([]);
|
|
1961
2006
|
}
|
|
@@ -1972,6 +2017,49 @@ var Logger = class {
|
|
|
1972
2017
|
];
|
|
1973
2018
|
}
|
|
1974
2019
|
};
|
|
2020
|
+
var BlueprintLoggerAdapter = class {
|
|
2021
|
+
constructor(logger = DEFAULT_LOGGER) {
|
|
2022
|
+
this.logger = logger;
|
|
2023
|
+
}
|
|
2024
|
+
log(event) {
|
|
2025
|
+
switch (event.type) {
|
|
2026
|
+
case "begin":
|
|
2027
|
+
this.logger.log("begin", {
|
|
2028
|
+
invocationId: event.invocationId
|
|
2029
|
+
});
|
|
2030
|
+
break;
|
|
2031
|
+
case "end":
|
|
2032
|
+
this.logger.log("end", {
|
|
2033
|
+
invocationId: event.invocationId
|
|
2034
|
+
});
|
|
2035
|
+
break;
|
|
2036
|
+
case "step-start":
|
|
2037
|
+
this.logger.log("step-start", {
|
|
2038
|
+
invocationId: event.invocationId,
|
|
2039
|
+
step: event.step
|
|
2040
|
+
});
|
|
2041
|
+
break;
|
|
2042
|
+
case "step-complete":
|
|
2043
|
+
this.logger.log("step-complete", {
|
|
2044
|
+
invocationId: event.invocationId,
|
|
2045
|
+
step: event.step
|
|
2046
|
+
});
|
|
2047
|
+
break;
|
|
2048
|
+
case "message":
|
|
2049
|
+
this.logger.log("message", {
|
|
2050
|
+
invocationId: event.invocationId,
|
|
2051
|
+
message: event.message
|
|
2052
|
+
});
|
|
2053
|
+
break;
|
|
2054
|
+
case "block":
|
|
2055
|
+
this.logger.log("block", {
|
|
2056
|
+
invocationId: event.invocationId,
|
|
2057
|
+
block: event.block
|
|
2058
|
+
});
|
|
2059
|
+
break;
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
};
|
|
1975
2063
|
var setLogger = (machine, logger) => {
|
|
1976
2064
|
return combine(machine.begin.on(() => {
|
|
1977
2065
|
logger.log("Starting...");
|
|
@@ -2034,13 +2122,14 @@ export {
|
|
|
2034
2122
|
AISession,
|
|
2035
2123
|
Blueprint,
|
|
2036
2124
|
BlueprintBuilder,
|
|
2125
|
+
BlueprintDefinition,
|
|
2126
|
+
BlueprintLoggerAdapter,
|
|
2037
2127
|
BlueprintMachine,
|
|
2038
2128
|
BlueprintParser,
|
|
2039
|
-
|
|
2040
|
-
|
|
2129
|
+
BlueprintStep,
|
|
2130
|
+
BufferedLogger,
|
|
2041
2131
|
ExtractionInput,
|
|
2042
2132
|
ExtractionOutput,
|
|
2043
|
-
Logger,
|
|
2044
2133
|
ReferencedQuotes,
|
|
2045
2134
|
Subgraph,
|
|
2046
2135
|
VersionPin,
|