@dxos/assistant 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446
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/{chunk-B4HAWUFW.mjs → chunk-PND5VR6D.mjs} +286 -757
- package/dist/lib/browser/chunk-PND5VR6D.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +324 -7
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +102 -139
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/{chunk-NOB7CIIC.cjs → chunk-IBOBRBDF.cjs} +303 -768
- package/dist/lib/node/chunk-IBOBRBDF.cjs.map +7 -0
- package/dist/lib/node/index.cjs +353 -36
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +93 -128
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/lib/node-esm/{chunk-SAWYU3V5.mjs → chunk-DCQJOLSR.mjs} +286 -757
- package/dist/lib/node-esm/chunk-DCQJOLSR.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +324 -7
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +102 -139
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/ai-service/edge-client.d.ts +5 -4
- package/dist/types/src/ai-service/edge-client.d.ts.map +1 -1
- package/dist/types/src/ai-service/message-collector.d.ts +6 -0
- package/dist/types/src/ai-service/message-collector.d.ts.map +1 -1
- package/dist/types/src/ai-service/ollama-client.d.ts +2 -6
- package/dist/types/src/ai-service/ollama-client.d.ts.map +1 -1
- package/dist/types/src/ai-service/parser.d.ts +3 -0
- package/dist/types/src/ai-service/parser.d.ts.map +1 -1
- package/dist/types/src/ai-service/service.d.ts +2 -18
- package/dist/types/src/ai-service/service.d.ts.map +1 -1
- package/dist/types/src/ai-service/stream.d.ts.map +1 -1
- package/dist/types/src/ai-service/testing/mock.d.ts +2 -6
- package/dist/types/src/ai-service/testing/mock.d.ts.map +1 -1
- package/dist/types/src/ai-service/testing/test-stream.d.ts.map +1 -1
- package/dist/types/src/ai-service/types.d.ts +101 -144
- package/dist/types/src/ai-service/types.d.ts.map +1 -1
- package/dist/types/src/ai-service/util/sse.d.ts.map +1 -1
- package/dist/types/src/{experimental/conversation → conversation}/conversation.d.ts +21 -2
- package/dist/types/src/conversation/conversation.d.ts.map +1 -0
- package/dist/types/src/conversation/conversation.test.d.ts.map +1 -0
- package/dist/types/src/conversation/index.d.ts.map +1 -0
- package/dist/types/src/{experimental/conversation → conversation}/types.d.ts +12 -11
- package/dist/types/src/conversation/types.d.ts.map +1 -0
- package/dist/types/src/cypher/ast.d.ts.map +1 -0
- package/dist/types/src/cypher/combinators.d.ts.map +1 -0
- package/dist/types/src/cypher/combinators.test.d.ts.map +1 -0
- package/dist/types/src/cypher/echo-data-source.d.ts.map +1 -0
- package/dist/types/src/cypher/execution-plan.d.ts.map +1 -0
- package/dist/types/src/cypher/execution-plan.test.d.ts.map +1 -0
- package/dist/types/src/cypher/index.d.ts.map +1 -0
- package/dist/types/src/cypher/parjs.d.ts.map +1 -0
- package/dist/types/src/cypher/parser.d.ts.map +1 -0
- package/dist/types/src/cypher/query-executor.d.ts.map +1 -0
- package/dist/types/src/cypher/query-executor.test.d.ts.map +1 -0
- package/dist/types/src/cypher/schema.d.ts.map +1 -0
- package/dist/types/src/cypher/schema.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/session/index.d.ts +0 -2
- package/dist/types/src/session/index.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +13 -33
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +0 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/logger.d.ts +1 -1
- package/dist/types/src/testing/logger.d.ts.map +1 -1
- package/dist/types/src/testing/ollama.d.ts.map +1 -1
- package/dist/types/src/testing/query-promts.d.ts +4 -4
- package/dist/types/src/testing/query-promts.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +5 -5
- package/dist/types/src/testing/test-data.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +23 -25
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/util/trim.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -20
- package/src/ai-service/client.test.ts +73 -55
- package/src/ai-service/edge-client.ts +20 -13
- package/src/ai-service/ollama-client.ts +10 -17
- package/src/ai-service/parser.ts +2 -13
- package/src/ai-service/service.ts +3 -19
- package/src/ai-service/testing/mock.ts +1 -9
- package/src/ai-service/types.ts +15 -24
- package/src/bin/chat.ts +4 -4
- package/src/{experimental/conversation → conversation}/conversation.test.ts +5 -5
- package/src/{experimental/conversation → conversation}/conversation.ts +119 -4
- package/src/{experimental/conversation → conversation}/types.ts +14 -11
- package/src/{experimental/cypher → cypher}/combinators.test.ts +4 -4
- package/src/{experimental/cypher → cypher}/echo-data-source.ts +11 -11
- package/src/{experimental/cypher → cypher}/execution-plan.test.ts +1 -1
- package/src/{experimental/cypher → cypher}/query-executor.test.ts +2 -2
- package/src/{experimental/cypher → cypher}/schema.test.ts +3 -3
- package/src/{experimental/cypher → cypher}/schema.ts +1 -1
- package/src/index.ts +2 -3
- package/src/session/index.ts +0 -2
- package/src/session/session.test.ts +63 -35
- package/src/session/session.ts +151 -297
- package/src/testing/artifacts.test.ts +22 -22
- package/src/testing/index.ts +0 -1
- package/src/testing/logger.ts +1 -1
- package/src/testing/query-promts.ts +6 -6
- package/src/testing/query.test.ts +21 -18
- package/src/testing/test-data.ts +72 -79
- package/src/testing/test-schema.ts +29 -28
- package/dist/lib/browser/chunk-B4HAWUFW.mjs.map +0 -7
- package/dist/lib/node/chunk-NOB7CIIC.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-SAWYU3V5.mjs.map +0 -7
- package/dist/types/src/experimental/conversation/conversation.d.ts.map +0 -1
- package/dist/types/src/experimental/conversation/conversation.test.d.ts.map +0 -1
- package/dist/types/src/experimental/conversation/index.d.ts.map +0 -1
- package/dist/types/src/experimental/conversation/types.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/ast.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/combinators.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/combinators.test.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/echo-data-source.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/execution-plan.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/execution-plan.test.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/index.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/parjs.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/parser.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/query-executor.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/query-executor.test.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/schema.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/schema.test.d.ts.map +0 -1
- package/dist/types/src/experimental/index.d.ts +0 -3
- package/dist/types/src/experimental/index.d.ts.map +0 -1
- package/dist/types/src/experimental/ner/ner.test.d.ts +0 -2
- package/dist/types/src/experimental/ner/ner.test.d.ts.map +0 -1
- package/dist/types/src/experimental/research/exa.d.ts +0 -6
- package/dist/types/src/experimental/research/exa.d.ts.map +0 -1
- package/dist/types/src/experimental/research/research.test.d.ts +0 -2
- package/dist/types/src/experimental/research/research.test.d.ts.map +0 -1
- package/dist/types/src/session/tools.d.ts +0 -18
- package/dist/types/src/session/tools.d.ts.map +0 -1
- package/dist/types/src/session/version-pin.d.ts +0 -22
- package/dist/types/src/session/version-pin.d.ts.map +0 -1
- package/dist/types/src/session/version-pin.test.d.ts +0 -2
- package/dist/types/src/session/version-pin.test.d.ts.map +0 -1
- package/dist/types/src/testing/printer.d.ts +0 -6
- package/dist/types/src/testing/printer.d.ts.map +0 -1
- package/src/experimental/index.ts +0 -6
- package/src/experimental/ner/ner.test.ts +0 -163
- package/src/experimental/research/exa.ts +0 -38
- package/src/experimental/research/instructions.tpl +0 -64
- package/src/experimental/research/research.test.ts +0 -263
- package/src/session/tools.ts +0 -117
- package/src/session/version-pin.test.ts +0 -26
- package/src/session/version-pin.ts +0 -49
- package/src/testing/printer.ts +0 -41
- package/src/typedefs.d.ts +0 -8
- /package/dist/types/src/{experimental/conversation → conversation}/conversation.test.d.ts +0 -0
- /package/dist/types/src/{experimental/conversation → conversation}/index.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/ast.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/combinators.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/combinators.test.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/echo-data-source.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/execution-plan.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/execution-plan.test.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/index.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/parjs.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/parser.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/query-executor.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/query-executor.test.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/schema.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/schema.test.d.ts +0 -0
- /package/src/{experimental/conversation → conversation}/index.ts +0 -0
- /package/src/{experimental/cypher → cypher}/ast.ts +0 -0
- /package/src/{experimental/cypher → cypher}/combinators.ts +0 -0
- /package/src/{experimental/cypher → cypher}/execution-plan.ts +0 -0
- /package/src/{experimental/cypher → cypher}/index.ts +0 -0
- /package/src/{experimental/cypher → cypher}/parjs-shims.d.ts +0 -0
- /package/src/{experimental/cypher → cypher}/parjs.ts +0 -0
- /package/src/{experimental/cypher → cypher}/parser.ts +0 -0
- /package/src/{experimental/cypher → cypher}/query-executor.ts +0 -0
|
@@ -26,11 +26,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_IBOBRBDF_exports = {};
|
|
30
|
+
__export(chunk_IBOBRBDF_exports, {
|
|
31
31
|
AIServiceEdgeClient: () => AIServiceEdgeClient,
|
|
32
|
-
AIServiecOverloadedError: () => AIServiecOverloadedError,
|
|
33
|
-
AISession: () => AISession,
|
|
34
32
|
DEFAULT_EDGE_MODEL: () => DEFAULT_EDGE_MODEL,
|
|
35
33
|
DEFAULT_EDGE_MODELS: () => DEFAULT_EDGE_MODELS,
|
|
36
34
|
DEFAULT_OLLAMA_ENDPOINT: () => DEFAULT_OLLAMA_ENDPOINT,
|
|
@@ -38,7 +36,6 @@ __export(chunk_NOB7CIIC_exports, {
|
|
|
38
36
|
DEFAULT_OLLAMA_MODELS: () => DEFAULT_OLLAMA_MODELS,
|
|
39
37
|
EchoDataSource: () => EchoDataSource,
|
|
40
38
|
GenerateRequest: () => GenerateRequest,
|
|
41
|
-
GenerateResponse: () => GenerateResponse,
|
|
42
39
|
GenerationStreamImpl: () => GenerationStreamImpl,
|
|
43
40
|
LLMModel: () => LLMModel,
|
|
44
41
|
MessageCollector: () => MessageCollector,
|
|
@@ -46,7 +43,6 @@ __export(chunk_NOB7CIIC_exports, {
|
|
|
46
43
|
OllamaClient: () => OllamaClient,
|
|
47
44
|
StreamTransform: () => StreamTransform,
|
|
48
45
|
ToolTypes: () => ToolTypes,
|
|
49
|
-
VersionPin: () => VersionPin,
|
|
50
46
|
createArtifactElement: () => createArtifactElement,
|
|
51
47
|
createGenerationStream: () => createGenerationStream,
|
|
52
48
|
emitMessageAsEvents: () => emitMessageAsEvents,
|
|
@@ -63,53 +59,44 @@ __export(chunk_NOB7CIIC_exports, {
|
|
|
63
59
|
runTools: () => runTools,
|
|
64
60
|
trim: () => trim
|
|
65
61
|
});
|
|
66
|
-
module.exports = __toCommonJS(
|
|
62
|
+
module.exports = __toCommonJS(chunk_IBOBRBDF_exports);
|
|
67
63
|
var import_async = require("@dxos/async");
|
|
68
64
|
var import_log = require("@dxos/log");
|
|
69
|
-
var import_invariant = require("@dxos/invariant");
|
|
70
|
-
var import_log2 = require("@dxos/log");
|
|
71
65
|
var import_effect = require("effect");
|
|
72
66
|
var import_artifact = require("@dxos/artifact");
|
|
67
|
+
var import_invariant = require("@dxos/invariant");
|
|
68
|
+
var import_log2 = require("@dxos/log");
|
|
69
|
+
var import_effect2 = require("effect");
|
|
73
70
|
var import_artifact2 = require("@dxos/artifact");
|
|
74
71
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
72
|
+
var import_artifact3 = require("@dxos/artifact");
|
|
73
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
75
74
|
var import_invariant2 = require("@dxos/invariant");
|
|
76
75
|
var import_log3 = require("@dxos/log");
|
|
77
|
-
var import_effect2 = require("effect");
|
|
78
|
-
var import_echo_db = require("@dxos/echo-db");
|
|
79
|
-
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
80
76
|
var import_effect3 = require("effect");
|
|
81
|
-
var
|
|
82
|
-
var import_async2 = require("@dxos/async");
|
|
83
|
-
var import_echo_db2 = require("@dxos/echo-db");
|
|
77
|
+
var import_artifact4 = require("@dxos/artifact");
|
|
84
78
|
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
85
79
|
var import_invariant3 = require("@dxos/invariant");
|
|
86
80
|
var import_log4 = require("@dxos/log");
|
|
87
|
-
var
|
|
88
|
-
var
|
|
81
|
+
var P = __toESM(require("parsimmon"));
|
|
82
|
+
var import_artifact5 = require("@dxos/artifact");
|
|
83
|
+
var import_async2 = require("@dxos/async");
|
|
89
84
|
var import_echo_schema4 = require("@dxos/echo-schema");
|
|
90
85
|
var import_invariant4 = require("@dxos/invariant");
|
|
91
86
|
var import_log5 = require("@dxos/log");
|
|
92
|
-
var import_artifact5 = require("@dxos/artifact");
|
|
93
|
-
var import_async3 = require("@dxos/async");
|
|
94
|
-
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
95
|
-
var import_invariant5 = require("@dxos/invariant");
|
|
96
|
-
var import_log6 = require("@dxos/log");
|
|
97
87
|
var import_util = require("@dxos/util");
|
|
98
|
-
var P = __toESM(require("parsimmon"));
|
|
99
|
-
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
100
|
-
var import_invariant6 = require("@dxos/invariant");
|
|
101
|
-
var import_log7 = require("@dxos/log");
|
|
102
88
|
var import_parjs = require("#parjs");
|
|
103
|
-
var
|
|
89
|
+
var import_log6 = require("@dxos/log");
|
|
104
90
|
var import_util2 = require("@dxos/util");
|
|
105
|
-
var
|
|
106
|
-
var
|
|
91
|
+
var import_invariant5 = require("@dxos/invariant");
|
|
92
|
+
var import_log7 = require("@dxos/log");
|
|
107
93
|
var import_debug = require("@dxos/debug");
|
|
108
|
-
var
|
|
94
|
+
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
109
95
|
var import_debug2 = require("@dxos/debug");
|
|
110
|
-
var
|
|
111
|
-
var
|
|
112
|
-
var
|
|
96
|
+
var import_echo_db = require("@dxos/echo-db");
|
|
97
|
+
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
98
|
+
var import_live_object = require("@dxos/live-object");
|
|
99
|
+
var import_log8 = require("@dxos/log");
|
|
113
100
|
var DEFAULT_EDGE_MODEL = "@anthropic/claude-3-5-sonnet-20241022";
|
|
114
101
|
var DEFAULT_EDGE_MODELS = [
|
|
115
102
|
// AI Gateway.
|
|
@@ -464,7 +451,7 @@ var AIServiceEdgeClient = class {
|
|
|
464
451
|
constructor({ endpoint }) {
|
|
465
452
|
(0, import_invariant.invariant)(endpoint, "endpoint is required", {
|
|
466
453
|
F: __dxlog_file2,
|
|
467
|
-
L:
|
|
454
|
+
L: 23,
|
|
468
455
|
S: this,
|
|
469
456
|
A: [
|
|
470
457
|
"endpoint",
|
|
@@ -474,21 +461,34 @@ var AIServiceEdgeClient = class {
|
|
|
474
461
|
this._endpoint = endpoint;
|
|
475
462
|
}
|
|
476
463
|
/**
|
|
477
|
-
*
|
|
464
|
+
* @deprecated
|
|
478
465
|
*/
|
|
479
|
-
|
|
480
|
-
|
|
466
|
+
// TODO(burdon): Remove.
|
|
467
|
+
async appendMessages(messages) {
|
|
468
|
+
const url = `${this._endpoint}/message`;
|
|
469
|
+
const res = await fetch(url, {
|
|
470
|
+
method: "POST",
|
|
471
|
+
headers: {
|
|
472
|
+
"Content-Type": "application/json"
|
|
473
|
+
},
|
|
474
|
+
body: JSON.stringify({
|
|
475
|
+
messages: await import_effect.Schema.encodePromise(import_effect.Schema.Array(import_artifact.Message))(messages)
|
|
476
|
+
})
|
|
477
|
+
});
|
|
478
|
+
if (!res.ok) {
|
|
479
|
+
throw new Error(`${await res.text()} [${url}]`);
|
|
480
|
+
}
|
|
481
481
|
}
|
|
482
482
|
/**
|
|
483
483
|
* Process request and open message stream.
|
|
484
484
|
*/
|
|
485
|
-
async
|
|
485
|
+
async exec(request) {
|
|
486
486
|
(0, import_invariant.assertArgument)(typeof request.model === "string", "model is required");
|
|
487
487
|
(0, import_log2.log)("requesting", {
|
|
488
488
|
endpoint: this._endpoint
|
|
489
489
|
}, {
|
|
490
490
|
F: __dxlog_file2,
|
|
491
|
-
L:
|
|
491
|
+
L: 51,
|
|
492
492
|
S: this,
|
|
493
493
|
C: (f, a) => f(...a)
|
|
494
494
|
});
|
|
@@ -505,12 +505,9 @@ var AIServiceEdgeClient = class {
|
|
|
505
505
|
...request
|
|
506
506
|
})
|
|
507
507
|
});
|
|
508
|
-
if (!response.ok) {
|
|
509
|
-
throw await parseErrorResponse(response);
|
|
510
|
-
}
|
|
511
508
|
(0, import_invariant.invariant)(response.body instanceof ReadableStream, void 0, {
|
|
512
509
|
F: __dxlog_file2,
|
|
513
|
-
L:
|
|
510
|
+
L: 64,
|
|
514
511
|
S: this,
|
|
515
512
|
A: [
|
|
516
513
|
"response.body instanceof ReadableStream",
|
|
@@ -520,9 +517,6 @@ var AIServiceEdgeClient = class {
|
|
|
520
517
|
return createGenerationStream(response, controller);
|
|
521
518
|
}
|
|
522
519
|
};
|
|
523
|
-
var parseErrorResponse = async (response) => {
|
|
524
|
-
throw new Error(`AI Service error: ${response.status} ${response.statusText} ${await response.text()}`);
|
|
525
|
-
};
|
|
526
520
|
var MessageCollector = class {
|
|
527
521
|
constructor() {
|
|
528
522
|
this._messages = [];
|
|
@@ -588,48 +582,215 @@ function* emitMessageAsEvents(message) {
|
|
|
588
582
|
};
|
|
589
583
|
}
|
|
590
584
|
var createArtifactElement = (id) => `<artifact id=${id} />`;
|
|
591
|
-
var LLMModel =
|
|
585
|
+
var LLMModel = import_effect2.Schema.Literal(...DEFAULT_EDGE_MODELS, ...DEFAULT_OLLAMA_MODELS);
|
|
592
586
|
var ToolTypes = Object.freeze({
|
|
593
587
|
// TODO(dmaretskyi): Not implemented yet.
|
|
594
588
|
// DatabaseQuery: 'database_query',
|
|
595
589
|
TextToImage: "text_to_image"
|
|
596
590
|
});
|
|
597
|
-
var GenerateRequest =
|
|
591
|
+
var GenerateRequest = import_effect2.Schema.Struct({
|
|
592
|
+
spaceId: import_effect2.Schema.optional(import_artifact2.SpaceIdSchema),
|
|
593
|
+
threadId: import_effect2.Schema.optional(import_echo_schema.ObjectId),
|
|
598
594
|
/**
|
|
599
595
|
* Preferred model or system default.
|
|
600
596
|
*/
|
|
601
|
-
model:
|
|
597
|
+
model: import_effect2.Schema.optional(LLMModel),
|
|
602
598
|
/**
|
|
603
599
|
* Tools available for the LLM.
|
|
604
600
|
*/
|
|
605
|
-
tools:
|
|
601
|
+
tools: import_effect2.Schema.optional(import_effect2.Schema.Array(import_artifact2.Tool).pipe(import_effect2.Schema.mutable)),
|
|
606
602
|
/**
|
|
607
603
|
* System instructions to the LLM.
|
|
608
604
|
*/
|
|
609
|
-
systemPrompt:
|
|
605
|
+
systemPrompt: import_effect2.Schema.optional(import_effect2.Schema.String),
|
|
610
606
|
/**
|
|
611
607
|
* History of messages to include in the context window.
|
|
612
608
|
*/
|
|
613
609
|
// TODO(burdon): Rename messages.
|
|
614
|
-
history:
|
|
610
|
+
history: import_effect2.Schema.optional(import_effect2.Schema.Array(import_artifact2.Message)),
|
|
615
611
|
/**
|
|
616
612
|
* Current request.
|
|
617
613
|
*/
|
|
618
|
-
prompt:
|
|
619
|
-
});
|
|
620
|
-
var GenerateResponse = import_effect.Schema.Struct({
|
|
621
|
-
messages: import_effect.Schema.Array(import_artifact.Message),
|
|
622
|
-
/**
|
|
623
|
-
* Number of tokens used in the response.
|
|
624
|
-
*/
|
|
625
|
-
tokenCount: import_effect.Schema.optional(import_effect.Schema.Number)
|
|
614
|
+
prompt: import_effect2.Schema.optional(import_artifact2.Message)
|
|
626
615
|
});
|
|
627
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/
|
|
616
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/conversation/conversation.ts";
|
|
617
|
+
var runLLM = async (params) => {
|
|
618
|
+
let conversationResult = null;
|
|
619
|
+
const history = params.history ?? [];
|
|
620
|
+
const generate = async () => {
|
|
621
|
+
(0, import_log3.log)("llm generate", {
|
|
622
|
+
tools: params.tools
|
|
623
|
+
}, {
|
|
624
|
+
F: __dxlog_file3,
|
|
625
|
+
L: 44,
|
|
626
|
+
S: void 0,
|
|
627
|
+
C: (f, a) => f(...a)
|
|
628
|
+
});
|
|
629
|
+
const beginTs = Date.now();
|
|
630
|
+
const stream = await params.client.exec({
|
|
631
|
+
model: params.model,
|
|
632
|
+
spaceId: params.spaceId,
|
|
633
|
+
threadId: params.threadId,
|
|
634
|
+
history,
|
|
635
|
+
systemPrompt: params.system,
|
|
636
|
+
tools: params.tools
|
|
637
|
+
});
|
|
638
|
+
for await (const event of stream) {
|
|
639
|
+
params.logger?.(event);
|
|
640
|
+
}
|
|
641
|
+
await stream.complete();
|
|
642
|
+
const messages = [];
|
|
643
|
+
const message = messages.at(-1);
|
|
644
|
+
(0, import_invariant2.invariant)(message, void 0, {
|
|
645
|
+
F: __dxlog_file3,
|
|
646
|
+
L: 63,
|
|
647
|
+
S: void 0,
|
|
648
|
+
A: [
|
|
649
|
+
"message",
|
|
650
|
+
""
|
|
651
|
+
]
|
|
652
|
+
});
|
|
653
|
+
(0, import_log3.log)("llm result", {
|
|
654
|
+
time: Date.now() - beginTs,
|
|
655
|
+
message
|
|
656
|
+
}, {
|
|
657
|
+
F: __dxlog_file3,
|
|
658
|
+
L: 65,
|
|
659
|
+
S: void 0,
|
|
660
|
+
C: (f, a) => f(...a)
|
|
661
|
+
});
|
|
662
|
+
(0, import_invariant2.invariant)(message, void 0, {
|
|
663
|
+
F: __dxlog_file3,
|
|
664
|
+
L: 66,
|
|
665
|
+
S: void 0,
|
|
666
|
+
A: [
|
|
667
|
+
"message",
|
|
668
|
+
""
|
|
669
|
+
]
|
|
670
|
+
});
|
|
671
|
+
params.logger?.({
|
|
672
|
+
type: "message",
|
|
673
|
+
message
|
|
674
|
+
});
|
|
675
|
+
history.push(...messages.map((message2) => ({
|
|
676
|
+
...message2,
|
|
677
|
+
content: message2.content.filter((block) => block.type !== "image")
|
|
678
|
+
})));
|
|
679
|
+
const isToolUse2 = message.content.at(-1)?.type === "tool_use";
|
|
680
|
+
if (isToolUse2) {
|
|
681
|
+
const toolCalls = message.content.filter((block) => block.type === "tool_use");
|
|
682
|
+
(0, import_invariant2.invariant)(toolCalls.length === 1, void 0, {
|
|
683
|
+
F: __dxlog_file3,
|
|
684
|
+
L: 77,
|
|
685
|
+
S: void 0,
|
|
686
|
+
A: [
|
|
687
|
+
"toolCalls.length === 1",
|
|
688
|
+
""
|
|
689
|
+
]
|
|
690
|
+
});
|
|
691
|
+
const toolCall = toolCalls[0];
|
|
692
|
+
const tool = params.tools.find((tool2) => tool2.name === toolCall.name);
|
|
693
|
+
if (!tool) {
|
|
694
|
+
throw new Error(`Tool not found: ${toolCall.name}`);
|
|
695
|
+
}
|
|
696
|
+
(0, import_invariant2.invariant)(tool.execute, void 0, {
|
|
697
|
+
F: __dxlog_file3,
|
|
698
|
+
L: 84,
|
|
699
|
+
S: void 0,
|
|
700
|
+
A: [
|
|
701
|
+
"tool.execute",
|
|
702
|
+
""
|
|
703
|
+
]
|
|
704
|
+
});
|
|
705
|
+
const toolResult = await tool.execute(toolCall.input);
|
|
706
|
+
switch (toolResult.kind) {
|
|
707
|
+
case "error": {
|
|
708
|
+
import_log3.log.warn("tool error", {
|
|
709
|
+
message: toolResult.message
|
|
710
|
+
}, {
|
|
711
|
+
F: __dxlog_file3,
|
|
712
|
+
L: 88,
|
|
713
|
+
S: void 0,
|
|
714
|
+
C: (f, a) => f(...a)
|
|
715
|
+
});
|
|
716
|
+
const resultMessage = {
|
|
717
|
+
id: import_echo_schema2.ObjectId.random(),
|
|
718
|
+
spaceId: params.spaceId,
|
|
719
|
+
threadId: params.threadId,
|
|
720
|
+
role: "user",
|
|
721
|
+
content: [
|
|
722
|
+
{
|
|
723
|
+
type: "tool_result",
|
|
724
|
+
toolUseId: toolCall.id,
|
|
725
|
+
content: toolResult.message,
|
|
726
|
+
isError: true
|
|
727
|
+
}
|
|
728
|
+
]
|
|
729
|
+
};
|
|
730
|
+
params.logger?.({
|
|
731
|
+
type: "message",
|
|
732
|
+
message: resultMessage
|
|
733
|
+
});
|
|
734
|
+
history.push(resultMessage);
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
case "success": {
|
|
738
|
+
(0, import_log3.log)("tool success", {
|
|
739
|
+
result: toolResult.result
|
|
740
|
+
}, {
|
|
741
|
+
F: __dxlog_file3,
|
|
742
|
+
L: 110,
|
|
743
|
+
S: void 0,
|
|
744
|
+
C: (f, a) => f(...a)
|
|
745
|
+
});
|
|
746
|
+
const resultMessage = {
|
|
747
|
+
id: import_echo_schema2.ObjectId.random(),
|
|
748
|
+
spaceId: params.spaceId,
|
|
749
|
+
threadId: params.threadId,
|
|
750
|
+
role: "user",
|
|
751
|
+
content: [
|
|
752
|
+
{
|
|
753
|
+
type: "tool_result",
|
|
754
|
+
toolUseId: toolCall.id,
|
|
755
|
+
content: JSON.stringify(toolResult.result)
|
|
756
|
+
}
|
|
757
|
+
]
|
|
758
|
+
};
|
|
759
|
+
params.logger?.({
|
|
760
|
+
type: "message",
|
|
761
|
+
message: resultMessage
|
|
762
|
+
});
|
|
763
|
+
history.push(resultMessage);
|
|
764
|
+
return true;
|
|
765
|
+
}
|
|
766
|
+
case "break": {
|
|
767
|
+
(0, import_log3.log)("tool break", {
|
|
768
|
+
result: toolResult.result
|
|
769
|
+
}, {
|
|
770
|
+
F: __dxlog_file3,
|
|
771
|
+
L: 131,
|
|
772
|
+
S: void 0,
|
|
773
|
+
C: (f, a) => f(...a)
|
|
774
|
+
});
|
|
775
|
+
conversationResult = toolResult.result;
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
return false;
|
|
781
|
+
};
|
|
782
|
+
while (await generate()) {
|
|
783
|
+
}
|
|
784
|
+
return {
|
|
785
|
+
result: conversationResult,
|
|
786
|
+
history
|
|
787
|
+
};
|
|
788
|
+
};
|
|
628
789
|
var isToolUse = (message, { onlyToolNames } = {}) => {
|
|
629
790
|
const block = message.content.at(-1);
|
|
630
791
|
(0, import_invariant2.invariant)(block, void 0, {
|
|
631
792
|
F: __dxlog_file3,
|
|
632
|
-
L:
|
|
793
|
+
L: 152,
|
|
633
794
|
S: void 0,
|
|
634
795
|
A: [
|
|
635
796
|
"block",
|
|
@@ -642,7 +803,7 @@ var runTools = async ({ message, tools, extensions }) => {
|
|
|
642
803
|
const toolCalls = message.content.filter((block) => block.type === "tool_use");
|
|
643
804
|
(0, import_invariant2.invariant)(toolCalls.length === 1, void 0, {
|
|
644
805
|
F: __dxlog_file3,
|
|
645
|
-
L:
|
|
806
|
+
L: 174,
|
|
646
807
|
S: void 0,
|
|
647
808
|
A: [
|
|
648
809
|
"toolCalls.length === 1",
|
|
@@ -652,7 +813,7 @@ var runTools = async ({ message, tools, extensions }) => {
|
|
|
652
813
|
const toolCall = toolCalls[0];
|
|
653
814
|
const tool = tools.find((tool2) => tool2.name === toolCall.name);
|
|
654
815
|
if (!tool) {
|
|
655
|
-
const resultMessage = (0,
|
|
816
|
+
const resultMessage = (0, import_echo_schema2.createStatic)(import_artifact3.Message, {
|
|
656
817
|
role: "user",
|
|
657
818
|
content: [
|
|
658
819
|
{
|
|
@@ -672,7 +833,7 @@ var runTools = async ({ message, tools, extensions }) => {
|
|
|
672
833
|
try {
|
|
673
834
|
(0, import_invariant2.invariant)(tool.execute, void 0, {
|
|
674
835
|
F: __dxlog_file3,
|
|
675
|
-
L:
|
|
836
|
+
L: 199,
|
|
676
837
|
S: void 0,
|
|
677
838
|
A: [
|
|
678
839
|
"tool.execute",
|
|
@@ -687,11 +848,11 @@ var runTools = async ({ message, tools, extensions }) => {
|
|
|
687
848
|
error
|
|
688
849
|
}, {
|
|
689
850
|
F: __dxlog_file3,
|
|
690
|
-
L:
|
|
851
|
+
L: 202,
|
|
691
852
|
S: void 0,
|
|
692
853
|
C: (f, a) => f(...a)
|
|
693
854
|
});
|
|
694
|
-
toolResult =
|
|
855
|
+
toolResult = import_artifact3.ToolResult.Error(error.message);
|
|
695
856
|
}
|
|
696
857
|
switch (toolResult.kind) {
|
|
697
858
|
case "error": {
|
|
@@ -699,11 +860,11 @@ var runTools = async ({ message, tools, extensions }) => {
|
|
|
699
860
|
message: toolResult.message
|
|
700
861
|
}, {
|
|
701
862
|
F: __dxlog_file3,
|
|
702
|
-
L:
|
|
863
|
+
L: 208,
|
|
703
864
|
S: void 0,
|
|
704
865
|
C: (f, a) => f(...a)
|
|
705
866
|
});
|
|
706
|
-
const resultMessage = (0,
|
|
867
|
+
const resultMessage = (0, import_echo_schema2.createStatic)(import_artifact3.Message, {
|
|
707
868
|
role: "user",
|
|
708
869
|
content: [
|
|
709
870
|
{
|
|
@@ -724,11 +885,11 @@ var runTools = async ({ message, tools, extensions }) => {
|
|
|
724
885
|
result: toolResult.result
|
|
725
886
|
}, {
|
|
726
887
|
F: __dxlog_file3,
|
|
727
|
-
L:
|
|
888
|
+
L: 229,
|
|
728
889
|
S: void 0,
|
|
729
890
|
C: (f, a) => f(...a)
|
|
730
891
|
});
|
|
731
|
-
const resultMessage = (0,
|
|
892
|
+
const resultMessage = (0, import_echo_schema2.createStatic)(import_artifact3.Message, {
|
|
732
893
|
role: "user",
|
|
733
894
|
content: [
|
|
734
895
|
{
|
|
@@ -749,7 +910,7 @@ var runTools = async ({ message, tools, extensions }) => {
|
|
|
749
910
|
result: toolResult.result
|
|
750
911
|
}, {
|
|
751
912
|
F: __dxlog_file3,
|
|
752
|
-
L:
|
|
913
|
+
L: 250,
|
|
753
914
|
S: void 0,
|
|
754
915
|
C: (f, a) => f(...a)
|
|
755
916
|
});
|
|
@@ -760,31 +921,6 @@ var runTools = async ({ message, tools, extensions }) => {
|
|
|
760
921
|
}
|
|
761
922
|
}
|
|
762
923
|
};
|
|
763
|
-
var ObjectVersionSchema = import_effect2.Schema.Unknown;
|
|
764
|
-
var VersionPinSchema = import_effect2.Schema.Struct({
|
|
765
|
-
// TODO(dmaretskyi): Use Ref when those support encoding.
|
|
766
|
-
objectId: import_echo_schema2.ObjectId,
|
|
767
|
-
// TODO(dmaretskyi): Could be opaque
|
|
768
|
-
version: ObjectVersionSchema
|
|
769
|
-
});
|
|
770
|
-
var VersionPin = class extends VersionPinSchema {
|
|
771
|
-
static {
|
|
772
|
-
this.DISPOSITION = "version-pin";
|
|
773
|
-
}
|
|
774
|
-
static fromObject(object) {
|
|
775
|
-
return VersionPin.make({
|
|
776
|
-
objectId: object.id,
|
|
777
|
-
version: (0, import_echo_db.getVersion)(object)
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
static createBlock(pin) {
|
|
781
|
-
return {
|
|
782
|
-
type: "json",
|
|
783
|
-
disposition: VersionPin.DISPOSITION,
|
|
784
|
-
json: JSON.stringify(pin)
|
|
785
|
-
};
|
|
786
|
-
}
|
|
787
|
-
};
|
|
788
924
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/ai-service/ollama-client.ts";
|
|
789
925
|
var OllamaClient = class {
|
|
790
926
|
/**
|
|
@@ -819,7 +955,7 @@ var OllamaClient = class {
|
|
|
819
955
|
];
|
|
820
956
|
}
|
|
821
957
|
async *_generateStream(request, signal) {
|
|
822
|
-
(0,
|
|
958
|
+
(0, import_invariant3.invariant)(request.prompt === void 0, "Prompt must be in history", {
|
|
823
959
|
F: __dxlog_file4,
|
|
824
960
|
L: 88,
|
|
825
961
|
S: this,
|
|
@@ -908,7 +1044,7 @@ var OllamaClient = class {
|
|
|
908
1044
|
}));
|
|
909
1045
|
}
|
|
910
1046
|
}
|
|
911
|
-
(0,
|
|
1047
|
+
(0, import_log4.log)("generate request", {
|
|
912
1048
|
history: request.history,
|
|
913
1049
|
prompt: request.prompt,
|
|
914
1050
|
ollamaRequest
|
|
@@ -927,14 +1063,14 @@ var OllamaClient = class {
|
|
|
927
1063
|
signal
|
|
928
1064
|
});
|
|
929
1065
|
if (!response.ok) {
|
|
930
|
-
throw await
|
|
1066
|
+
throw await parseErrorResponse(response);
|
|
931
1067
|
}
|
|
932
1068
|
if (!response.body) {
|
|
933
1069
|
throw new Error("Ollama API returned no response body");
|
|
934
1070
|
}
|
|
935
1071
|
const reader = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new OllamaDecoderStream()).getReader();
|
|
936
1072
|
try {
|
|
937
|
-
const messageId =
|
|
1073
|
+
const messageId = import_echo_schema3.ObjectId.random();
|
|
938
1074
|
yield {
|
|
939
1075
|
type: "message_start",
|
|
940
1076
|
message: {
|
|
@@ -958,7 +1094,7 @@ var OllamaClient = class {
|
|
|
958
1094
|
if (done) {
|
|
959
1095
|
break;
|
|
960
1096
|
}
|
|
961
|
-
(0,
|
|
1097
|
+
(0, import_log4.log)("ollama data", {
|
|
962
1098
|
data
|
|
963
1099
|
}, {
|
|
964
1100
|
F: __dxlog_file4,
|
|
@@ -978,7 +1114,7 @@ var OllamaClient = class {
|
|
|
978
1114
|
}
|
|
979
1115
|
if (data.message?.tool_calls && data.message?.tool_calls?.length > 0) {
|
|
980
1116
|
if (data.message.tool_calls.length > 1) {
|
|
981
|
-
|
|
1117
|
+
import_log4.log.warn("Ollama returned multiple tool calls. Only the first one will be used.", void 0, {
|
|
982
1118
|
F: __dxlog_file4,
|
|
983
1119
|
L: 261,
|
|
984
1120
|
S: this,
|
|
@@ -994,7 +1130,7 @@ var OllamaClient = class {
|
|
|
994
1130
|
index: currentBlockIndex,
|
|
995
1131
|
content: {
|
|
996
1132
|
type: "tool_use",
|
|
997
|
-
id:
|
|
1133
|
+
id: import_echo_schema3.ObjectId.random(),
|
|
998
1134
|
name: data.message.tool_calls[0].function.name,
|
|
999
1135
|
input: sanitizeToolArguments(data.message.tool_calls[0].function.arguments)
|
|
1000
1136
|
}
|
|
@@ -1018,13 +1154,7 @@ var OllamaClient = class {
|
|
|
1018
1154
|
reader.releaseLock();
|
|
1019
1155
|
}
|
|
1020
1156
|
}
|
|
1021
|
-
/**
|
|
1022
|
-
* Generate non-streaming response.
|
|
1023
|
-
*/
|
|
1024
1157
|
async exec(request) {
|
|
1025
|
-
throw new Error("Not implemented");
|
|
1026
|
-
}
|
|
1027
|
-
async execStream(request) {
|
|
1028
1158
|
const controller = new AbortController();
|
|
1029
1159
|
try {
|
|
1030
1160
|
return new GenerationStreamImpl(controller, async function* () {
|
|
@@ -1086,15 +1216,15 @@ var WELL_KNOWN_TOOLS = {
|
|
|
1086
1216
|
[ToolTypes.TextToImage]: (0, import_artifact4.defineTool)("system", {
|
|
1087
1217
|
name: "text-to-image",
|
|
1088
1218
|
description: "Generate an image from a text prompt",
|
|
1089
|
-
schema:
|
|
1090
|
-
prompt:
|
|
1219
|
+
schema: import_effect3.Schema.Struct({
|
|
1220
|
+
prompt: import_effect3.Schema.String.annotations({
|
|
1091
1221
|
description: "The text prompt describing the image to generate"
|
|
1092
1222
|
})
|
|
1093
1223
|
}),
|
|
1094
1224
|
execute: async ({ prompt }) => {
|
|
1095
1225
|
const image = await fetch(SAMPLE_IMAGE_URL).then(async (res) => Buffer.from(await res.arrayBuffer()));
|
|
1096
1226
|
const imageBase64 = image.toString("base64");
|
|
1097
|
-
const id =
|
|
1227
|
+
const id = import_echo_schema3.ObjectId.random();
|
|
1098
1228
|
return import_artifact4.ToolResult.Success(`The generation was successful. Image ID: ${id} Prompt: ${prompt}`, [
|
|
1099
1229
|
{
|
|
1100
1230
|
type: "image",
|
|
@@ -1130,12 +1260,12 @@ var OllamaDecoderStream = class extends TransformStream {
|
|
|
1130
1260
|
this._buffer = "";
|
|
1131
1261
|
}
|
|
1132
1262
|
};
|
|
1133
|
-
var ModelDoesNotSupportToolsError = class extends
|
|
1134
|
-
model:
|
|
1263
|
+
var ModelDoesNotSupportToolsError = class extends import_effect3.Schema.TaggedError()("ModelDoesNotSupportToolsError", {
|
|
1264
|
+
model: import_effect3.Schema.String
|
|
1135
1265
|
}) {
|
|
1136
1266
|
};
|
|
1137
|
-
var ModelNotFoundError = class extends
|
|
1138
|
-
model:
|
|
1267
|
+
var ModelNotFoundError = class extends import_effect3.Schema.TaggedError()("ModelNotFoundError", {
|
|
1268
|
+
model: import_effect3.Schema.String
|
|
1139
1269
|
}) {
|
|
1140
1270
|
};
|
|
1141
1271
|
var parseOllamaError = (error) => {
|
|
@@ -1157,7 +1287,7 @@ var parseOllamaError = (error) => {
|
|
|
1157
1287
|
}
|
|
1158
1288
|
throw new Error(`Ollama API error: ${error}`);
|
|
1159
1289
|
};
|
|
1160
|
-
var
|
|
1290
|
+
var parseErrorResponse = async (response) => {
|
|
1161
1291
|
if (response.headers.get("content-type")?.includes("application/json")) {
|
|
1162
1292
|
const body = await response.json();
|
|
1163
1293
|
return parseOllamaError(body.error);
|
|
@@ -1253,10 +1383,10 @@ var StreamTransform = class {
|
|
|
1253
1383
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/ai-service/parser.ts";
|
|
1254
1384
|
var MixedStreamParser = class {
|
|
1255
1385
|
constructor() {
|
|
1256
|
-
this.message = new
|
|
1257
|
-
this.block = new
|
|
1258
|
-
this.update = new
|
|
1259
|
-
this.streamEvent = new
|
|
1386
|
+
this.message = new import_async2.Event();
|
|
1387
|
+
this.block = new import_async2.Event();
|
|
1388
|
+
this.update = new import_async2.Event();
|
|
1389
|
+
this.streamEvent = new import_async2.Event();
|
|
1260
1390
|
}
|
|
1261
1391
|
_emitBlock(contentBlock, streamBlock) {
|
|
1262
1392
|
const messageBlock = streamBlock ? mergeMessageBlock(contentBlock, streamBlock) : contentBlock;
|
|
@@ -1264,7 +1394,7 @@ var MixedStreamParser = class {
|
|
|
1264
1394
|
if (messageBlock.type === "text" && messageBlock.text.length === 0) {
|
|
1265
1395
|
return;
|
|
1266
1396
|
}
|
|
1267
|
-
(0,
|
|
1397
|
+
(0, import_invariant4.invariant)(this._message, void 0, {
|
|
1268
1398
|
F: __dxlog_file5,
|
|
1269
1399
|
L: 49,
|
|
1270
1400
|
S: this,
|
|
@@ -1294,7 +1424,7 @@ var MixedStreamParser = class {
|
|
|
1294
1424
|
const stack = [];
|
|
1295
1425
|
const messagesCollected = [];
|
|
1296
1426
|
for await (const event of stream) {
|
|
1297
|
-
(0,
|
|
1427
|
+
(0, import_log5.log)("streamEvent", {
|
|
1298
1428
|
event
|
|
1299
1429
|
}, {
|
|
1300
1430
|
F: __dxlog_file5,
|
|
@@ -1309,14 +1439,14 @@ var MixedStreamParser = class {
|
|
|
1309
1439
|
//
|
|
1310
1440
|
case "message_start": {
|
|
1311
1441
|
if (this._message) {
|
|
1312
|
-
|
|
1442
|
+
import_log5.log.warn("unexpected message_start", void 0, {
|
|
1313
1443
|
F: __dxlog_file5,
|
|
1314
1444
|
L: 94,
|
|
1315
1445
|
S: this,
|
|
1316
1446
|
C: (f, a) => f(...a)
|
|
1317
1447
|
});
|
|
1318
1448
|
}
|
|
1319
|
-
this._message = (0,
|
|
1449
|
+
this._message = (0, import_echo_schema4.createStatic)(import_artifact5.Message, {
|
|
1320
1450
|
role: event.message.role,
|
|
1321
1451
|
content: [
|
|
1322
1452
|
...event.message.content
|
|
@@ -1327,7 +1457,7 @@ var MixedStreamParser = class {
|
|
|
1327
1457
|
}
|
|
1328
1458
|
case "message_delta": {
|
|
1329
1459
|
if (!this._message) {
|
|
1330
|
-
|
|
1460
|
+
import_log5.log.warn("unexpected message_delta", void 0, {
|
|
1331
1461
|
F: __dxlog_file5,
|
|
1332
1462
|
L: 104,
|
|
1333
1463
|
S: this,
|
|
@@ -1338,7 +1468,7 @@ var MixedStreamParser = class {
|
|
|
1338
1468
|
}
|
|
1339
1469
|
case "message_stop": {
|
|
1340
1470
|
if (!this._message) {
|
|
1341
|
-
|
|
1471
|
+
import_log5.log.warn("unexpected message_stop", void 0, {
|
|
1342
1472
|
F: __dxlog_file5,
|
|
1343
1473
|
L: 112,
|
|
1344
1474
|
S: this,
|
|
@@ -1355,7 +1485,7 @@ var MixedStreamParser = class {
|
|
|
1355
1485
|
//
|
|
1356
1486
|
case "content_block_start": {
|
|
1357
1487
|
if (contentBlock) {
|
|
1358
|
-
|
|
1488
|
+
import_log5.log.warn("unexpected content_block_start", {
|
|
1359
1489
|
content: contentBlock
|
|
1360
1490
|
}, {
|
|
1361
1491
|
F: __dxlog_file5,
|
|
@@ -1369,7 +1499,7 @@ var MixedStreamParser = class {
|
|
|
1369
1499
|
}
|
|
1370
1500
|
case "content_block_delta": {
|
|
1371
1501
|
if (!contentBlock) {
|
|
1372
|
-
|
|
1502
|
+
import_log5.log.warn("unexpected content_block_delta", void 0, {
|
|
1373
1503
|
F: __dxlog_file5,
|
|
1374
1504
|
L: 136,
|
|
1375
1505
|
S: this,
|
|
@@ -1384,7 +1514,7 @@ var MixedStreamParser = class {
|
|
|
1384
1514
|
case "text_delta": {
|
|
1385
1515
|
const chunks = transformer.transform(event.delta.text);
|
|
1386
1516
|
for (const chunk of chunks) {
|
|
1387
|
-
(0,
|
|
1517
|
+
(0, import_log5.log)("text_delta", {
|
|
1388
1518
|
chunk
|
|
1389
1519
|
}, {
|
|
1390
1520
|
F: __dxlog_file5,
|
|
@@ -1403,7 +1533,7 @@ var MixedStreamParser = class {
|
|
|
1403
1533
|
} else if (chunk.closing) {
|
|
1404
1534
|
if (stack.length > 0) {
|
|
1405
1535
|
const top = stack.pop();
|
|
1406
|
-
(0,
|
|
1536
|
+
(0, import_invariant4.invariant)(top && top.type === "tag", void 0, {
|
|
1407
1537
|
F: __dxlog_file5,
|
|
1408
1538
|
L: 160,
|
|
1409
1539
|
S: this,
|
|
@@ -1412,7 +1542,7 @@ var MixedStreamParser = class {
|
|
|
1412
1542
|
""
|
|
1413
1543
|
]
|
|
1414
1544
|
});
|
|
1415
|
-
(0,
|
|
1545
|
+
(0, import_log5.log)("pop", {
|
|
1416
1546
|
top
|
|
1417
1547
|
}, {
|
|
1418
1548
|
F: __dxlog_file5,
|
|
@@ -1435,7 +1565,7 @@ var MixedStreamParser = class {
|
|
|
1435
1565
|
streamBlock.content.push(chunk);
|
|
1436
1566
|
} else {
|
|
1437
1567
|
const last = streamBlock.content.at(-1);
|
|
1438
|
-
(0,
|
|
1568
|
+
(0, import_invariant4.invariant)(last, void 0, {
|
|
1439
1569
|
F: __dxlog_file5,
|
|
1440
1570
|
L: 178,
|
|
1441
1571
|
S: this,
|
|
@@ -1489,7 +1619,7 @@ var MixedStreamParser = class {
|
|
|
1489
1619
|
//
|
|
1490
1620
|
case "input_json_delta": {
|
|
1491
1621
|
if (!contentBlock) {
|
|
1492
|
-
|
|
1622
|
+
import_log5.log.warn("unexpected input_json_delta", {
|
|
1493
1623
|
contentBlock
|
|
1494
1624
|
}, {
|
|
1495
1625
|
F: __dxlog_file5,
|
|
@@ -1514,7 +1644,7 @@ var MixedStreamParser = class {
|
|
|
1514
1644
|
}
|
|
1515
1645
|
case "content_block_stop": {
|
|
1516
1646
|
if (!contentBlock) {
|
|
1517
|
-
|
|
1647
|
+
import_log5.log.warn("unexpected content_block_stop", void 0, {
|
|
1518
1648
|
F: __dxlog_file5,
|
|
1519
1649
|
L: 245,
|
|
1520
1650
|
S: this,
|
|
@@ -1536,7 +1666,7 @@ var MixedStreamParser = class {
|
|
|
1536
1666
|
}
|
|
1537
1667
|
};
|
|
1538
1668
|
var mergeMessageBlock = (contentBlock, streamBlock) => {
|
|
1539
|
-
(0,
|
|
1669
|
+
(0, import_log5.log)("mergeMessageBlock", {
|
|
1540
1670
|
contentBlock,
|
|
1541
1671
|
streamBlock
|
|
1542
1672
|
}, {
|
|
@@ -1597,18 +1727,6 @@ var mergeMessageBlock = (contentBlock, streamBlock) => {
|
|
|
1597
1727
|
}
|
|
1598
1728
|
break;
|
|
1599
1729
|
}
|
|
1600
|
-
case "proposal": {
|
|
1601
|
-
if (streamBlock.content.length === 1 && streamBlock.content[0].type === "text") {
|
|
1602
|
-
return {
|
|
1603
|
-
type: "json",
|
|
1604
|
-
disposition: "proposal",
|
|
1605
|
-
json: JSON.stringify({
|
|
1606
|
-
text: streamBlock.content[0].content
|
|
1607
|
-
})
|
|
1608
|
-
};
|
|
1609
|
-
}
|
|
1610
|
-
break;
|
|
1611
|
-
}
|
|
1612
1730
|
case "select": {
|
|
1613
1731
|
return {
|
|
1614
1732
|
type: "json",
|
|
@@ -1651,585 +1769,6 @@ var mergeMessageBlock = (contentBlock, streamBlock) => {
|
|
|
1651
1769
|
}
|
|
1652
1770
|
}
|
|
1653
1771
|
};
|
|
1654
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
1655
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1656
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1657
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1658
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1659
|
-
}
|
|
1660
|
-
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/session/session.ts";
|
|
1661
|
-
var AISession = class _AISession {
|
|
1662
|
-
constructor(_options) {
|
|
1663
|
-
this._options = _options;
|
|
1664
|
-
this._parser = new MixedStreamParser();
|
|
1665
|
-
this._pending = [];
|
|
1666
|
-
this._history = [];
|
|
1667
|
-
this.message = this._parser.message;
|
|
1668
|
-
this.block = this._parser.block;
|
|
1669
|
-
this.update = this._parser.update;
|
|
1670
|
-
this.streamEvent = this._parser.streamEvent;
|
|
1671
|
-
this.userMessage = new import_async2.Event();
|
|
1672
|
-
this._parser.message.on((message) => {
|
|
1673
|
-
this._pending.push(message);
|
|
1674
|
-
});
|
|
1675
|
-
}
|
|
1676
|
-
async run(options) {
|
|
1677
|
-
const systemTools = [];
|
|
1678
|
-
switch (this._options.operationModel) {
|
|
1679
|
-
case "planning":
|
|
1680
|
-
systemTools.push(this._createQueryArtifactsTool(options.artifacts), this._createPlanningTool(options));
|
|
1681
|
-
break;
|
|
1682
|
-
case "importing":
|
|
1683
|
-
systemTools.push(this._createQueryArtifactsTool(options.artifacts), this._createRequireTool(options.artifacts, (artifactDefinitionIds) => {
|
|
1684
|
-
for (const artifactDefinitionId of artifactDefinitionIds) {
|
|
1685
|
-
requiredArtifactIds.add(artifactDefinitionId);
|
|
1686
|
-
}
|
|
1687
|
-
}));
|
|
1688
|
-
break;
|
|
1689
|
-
case "configured":
|
|
1690
|
-
break;
|
|
1691
|
-
default:
|
|
1692
|
-
throw new TypeError(`Invalid operation model: ${this._options.operationModel}`);
|
|
1693
|
-
}
|
|
1694
|
-
this._history = [
|
|
1695
|
-
...options.history
|
|
1696
|
-
];
|
|
1697
|
-
this._pending = [
|
|
1698
|
-
await this._formatUserPrompt(options.artifactDiffResolver, options.prompt, options.history)
|
|
1699
|
-
];
|
|
1700
|
-
this.userMessage.emit(this._pending.at(-1));
|
|
1701
|
-
this._stream = void 0;
|
|
1702
|
-
let error;
|
|
1703
|
-
const requiredArtifactIds = new Set(options.requiredArtifactIds ?? []);
|
|
1704
|
-
try {
|
|
1705
|
-
let more = false;
|
|
1706
|
-
do {
|
|
1707
|
-
const tools = [
|
|
1708
|
-
...systemTools,
|
|
1709
|
-
...options.tools,
|
|
1710
|
-
...options.artifacts.filter((artifact) => requiredArtifactIds.has(artifact.id)).flatMap((artifact) => artifact.tools)
|
|
1711
|
-
];
|
|
1712
|
-
(0, import_log4.log)("request", {
|
|
1713
|
-
pending: this._pending.length,
|
|
1714
|
-
history: this._history.length,
|
|
1715
|
-
tools: tools.map((tool) => tool.name)
|
|
1716
|
-
}, {
|
|
1717
|
-
F: __dxlog_file6,
|
|
1718
|
-
L: 181,
|
|
1719
|
-
S: this,
|
|
1720
|
-
C: (f, a) => f(...a)
|
|
1721
|
-
});
|
|
1722
|
-
this._stream = await options.client.execStream({
|
|
1723
|
-
...options.generationOptions ?? {},
|
|
1724
|
-
// TODO(burdon): Rename messages or separate history/message.
|
|
1725
|
-
history: [
|
|
1726
|
-
...this._history,
|
|
1727
|
-
...this._pending
|
|
1728
|
-
],
|
|
1729
|
-
tools,
|
|
1730
|
-
systemPrompt: options.systemPrompt ?? createBaseInstructions({
|
|
1731
|
-
availableArtifacts: Array.from(requiredArtifactIds),
|
|
1732
|
-
operationModel: this._options.operationModel
|
|
1733
|
-
})
|
|
1734
|
-
});
|
|
1735
|
-
await this._parser.parse(this._stream);
|
|
1736
|
-
await this._stream.complete();
|
|
1737
|
-
(0, import_log4.log)("response", {
|
|
1738
|
-
pending: this._pending
|
|
1739
|
-
}, {
|
|
1740
|
-
F: __dxlog_file6,
|
|
1741
|
-
L: 206,
|
|
1742
|
-
S: this,
|
|
1743
|
-
C: (f, a) => f(...a)
|
|
1744
|
-
});
|
|
1745
|
-
more = false;
|
|
1746
|
-
const message = this._pending.at(-1);
|
|
1747
|
-
(0, import_invariant3.invariant)(message, void 0, {
|
|
1748
|
-
F: __dxlog_file6,
|
|
1749
|
-
L: 211,
|
|
1750
|
-
S: this,
|
|
1751
|
-
A: [
|
|
1752
|
-
"message",
|
|
1753
|
-
""
|
|
1754
|
-
]
|
|
1755
|
-
});
|
|
1756
|
-
if (isToolUse(message)) {
|
|
1757
|
-
(0, import_log4.log)("tool request...", void 0, {
|
|
1758
|
-
F: __dxlog_file6,
|
|
1759
|
-
L: 213,
|
|
1760
|
-
S: this,
|
|
1761
|
-
C: (f, a) => f(...a)
|
|
1762
|
-
});
|
|
1763
|
-
const response = await runTools({
|
|
1764
|
-
message: this._pending.at(-1),
|
|
1765
|
-
tools,
|
|
1766
|
-
extensions: options.extensions ?? {}
|
|
1767
|
-
});
|
|
1768
|
-
(0, import_log4.log)("tool response", {
|
|
1769
|
-
response
|
|
1770
|
-
}, {
|
|
1771
|
-
F: __dxlog_file6,
|
|
1772
|
-
L: 220,
|
|
1773
|
-
S: this,
|
|
1774
|
-
C: (f, a) => f(...a)
|
|
1775
|
-
});
|
|
1776
|
-
switch (response.type) {
|
|
1777
|
-
case "continue": {
|
|
1778
|
-
this._pending = [
|
|
1779
|
-
...this._pending,
|
|
1780
|
-
response.message
|
|
1781
|
-
];
|
|
1782
|
-
this.userMessage.emit(response.message);
|
|
1783
|
-
more = true;
|
|
1784
|
-
break;
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
|
-
}
|
|
1788
|
-
} while (more);
|
|
1789
|
-
} catch (err) {
|
|
1790
|
-
import_log4.log.catch(err, void 0, {
|
|
1791
|
-
F: __dxlog_file6,
|
|
1792
|
-
L: 232,
|
|
1793
|
-
S: this,
|
|
1794
|
-
C: (f, a) => f(...a)
|
|
1795
|
-
});
|
|
1796
|
-
if (err instanceof Error && err.message.includes("Overloaded")) {
|
|
1797
|
-
error = new AIServiecOverloadedError("AI service overloaded", {
|
|
1798
|
-
cause: err
|
|
1799
|
-
});
|
|
1800
|
-
} else {
|
|
1801
|
-
error = new Error("AI service error", {
|
|
1802
|
-
cause: err
|
|
1803
|
-
});
|
|
1804
|
-
}
|
|
1805
|
-
} finally {
|
|
1806
|
-
this._stream = void 0;
|
|
1807
|
-
}
|
|
1808
|
-
if (error) {
|
|
1809
|
-
throw error;
|
|
1810
|
-
}
|
|
1811
|
-
return this._pending;
|
|
1812
|
-
}
|
|
1813
|
-
async runStructured(schema, options) {
|
|
1814
|
-
const parser = (0, import_artifact3.structuredOutputParser)(schema);
|
|
1815
|
-
const result = await this.run({
|
|
1816
|
-
...options,
|
|
1817
|
-
tools: [
|
|
1818
|
-
...options.tools,
|
|
1819
|
-
parser.tool
|
|
1820
|
-
]
|
|
1821
|
-
});
|
|
1822
|
-
return parser.getResult(result);
|
|
1823
|
-
}
|
|
1824
|
-
async _formatUserPrompt(artifactDiffResolver, prompt, history) {
|
|
1825
|
-
const prelude = [];
|
|
1826
|
-
if (artifactDiffResolver) {
|
|
1827
|
-
const versions = gatherObjectVersions(history);
|
|
1828
|
-
const artifactDiff = await artifactDiffResolver(Array.from(versions.entries()).map(([id, version]) => ({
|
|
1829
|
-
id,
|
|
1830
|
-
lastVersion: version
|
|
1831
|
-
})));
|
|
1832
|
-
import_log4.log.info("vision", {
|
|
1833
|
-
artifactDiff,
|
|
1834
|
-
versions
|
|
1835
|
-
}, {
|
|
1836
|
-
F: __dxlog_file6,
|
|
1837
|
-
L: 272,
|
|
1838
|
-
S: this,
|
|
1839
|
-
C: (f, a) => f(...a)
|
|
1840
|
-
});
|
|
1841
|
-
for (const [id, { version }] of [
|
|
1842
|
-
...artifactDiff.entries()
|
|
1843
|
-
]) {
|
|
1844
|
-
if (import_echo_db2.ObjectVersion.equals(version, versions.get(id))) {
|
|
1845
|
-
artifactDiff.delete(id);
|
|
1846
|
-
continue;
|
|
1847
|
-
}
|
|
1848
|
-
prelude.push(VersionPin.createBlock(VersionPin.make({
|
|
1849
|
-
objectId: id,
|
|
1850
|
-
version
|
|
1851
|
-
})));
|
|
1852
|
-
}
|
|
1853
|
-
if (artifactDiff.size > 0) {
|
|
1854
|
-
prelude.push(createArtifactUpdateBlock(artifactDiff));
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
return (0, import_echo_schema3.create)(import_artifact3.Message, {
|
|
1858
|
-
role: "user",
|
|
1859
|
-
content: [
|
|
1860
|
-
...prelude,
|
|
1861
|
-
{
|
|
1862
|
-
type: "text",
|
|
1863
|
-
text: prompt
|
|
1864
|
-
}
|
|
1865
|
-
]
|
|
1866
|
-
});
|
|
1867
|
-
}
|
|
1868
|
-
_createQueryArtifactsTool(artifacts) {
|
|
1869
|
-
return (0, import_artifact3.defineTool)("system", {
|
|
1870
|
-
name: "query_artifact_definitions",
|
|
1871
|
-
description: "Query the available artifact definitions",
|
|
1872
|
-
schema: import_effect3.Schema.Struct({}),
|
|
1873
|
-
execute: async () => {
|
|
1874
|
-
return import_artifact3.ToolResult.Success({
|
|
1875
|
-
artifactDefinitions: artifacts.map((artifact) => ({
|
|
1876
|
-
id: artifact.id,
|
|
1877
|
-
name: artifact.name,
|
|
1878
|
-
description: artifact.description
|
|
1879
|
-
}))
|
|
1880
|
-
});
|
|
1881
|
-
}
|
|
1882
|
-
});
|
|
1883
|
-
}
|
|
1884
|
-
_createRequireTool(artifacts, onRequire) {
|
|
1885
|
-
return (0, import_artifact3.defineTool)("system", {
|
|
1886
|
-
name: "require_artifact_definitions",
|
|
1887
|
-
description: "Require the use of specific artifact definitions. This will allow the model to interact with artifact definitions and use their tools.",
|
|
1888
|
-
schema: import_effect3.Schema.Struct({
|
|
1889
|
-
artifactDefinitionIds: import_effect3.Schema.Array(import_effect3.Schema.String).annotations({
|
|
1890
|
-
description: "The ids of the artifact definitions to require",
|
|
1891
|
-
examples: [
|
|
1892
|
-
[
|
|
1893
|
-
"artifact:dxos.org/example/Test"
|
|
1894
|
-
]
|
|
1895
|
-
]
|
|
1896
|
-
})
|
|
1897
|
-
}),
|
|
1898
|
-
execute: async ({ artifactDefinitionIds }) => {
|
|
1899
|
-
const missingArtifactDefinitionIds = artifactDefinitionIds.filter((artifactId) => !artifacts.some((artifact) => artifact.id === artifactId));
|
|
1900
|
-
if (missingArtifactDefinitionIds.length > 0) {
|
|
1901
|
-
return import_artifact3.ToolResult.Error(`One or more artifact definition ids are invalid: ${missingArtifactDefinitionIds.join(", ")}`);
|
|
1902
|
-
}
|
|
1903
|
-
onRequire(artifactDefinitionIds);
|
|
1904
|
-
return import_artifact3.ToolResult.Success({});
|
|
1905
|
-
}
|
|
1906
|
-
});
|
|
1907
|
-
}
|
|
1908
|
-
_createPlanningTool(options) {
|
|
1909
|
-
return (0, import_artifact3.defineTool)("system", {
|
|
1910
|
-
name: "create_plan",
|
|
1911
|
-
description: "Create a plan. Make sure that each step is independent and can be executed solely on the data returned by the previous step. The steps only share the data that is specified in the plan.",
|
|
1912
|
-
schema: import_effect3.Schema.Struct({
|
|
1913
|
-
goal: import_effect3.Schema.String.annotations({
|
|
1914
|
-
description: "The goal that the plan will achieve."
|
|
1915
|
-
}),
|
|
1916
|
-
steps: import_effect3.Schema.Array(import_effect3.Schema.Struct({
|
|
1917
|
-
action: import_effect3.Schema.String.annotations({
|
|
1918
|
-
description: "Complete, detailed action to perform."
|
|
1919
|
-
}),
|
|
1920
|
-
input: import_effect3.Schema.String.annotations({
|
|
1921
|
-
description: "The required input data for this step. First step must not require any data."
|
|
1922
|
-
}),
|
|
1923
|
-
output: import_effect3.Schema.String.annotations({
|
|
1924
|
-
description: "The output data from this step. This is passed to the next step as input."
|
|
1925
|
-
}),
|
|
1926
|
-
requiredArtifactIds: import_effect3.Schema.Array(import_effect3.Schema.String).annotations({
|
|
1927
|
-
description: "The ids of the artifacts required to perform this step.",
|
|
1928
|
-
examples: [
|
|
1929
|
-
[
|
|
1930
|
-
"artifact:dxos.org/example/Test"
|
|
1931
|
-
]
|
|
1932
|
-
]
|
|
1933
|
-
})
|
|
1934
|
-
})).annotations({
|
|
1935
|
-
description: "Steps"
|
|
1936
|
-
})
|
|
1937
|
-
}),
|
|
1938
|
-
execute: async ({ goal, steps }) => {
|
|
1939
|
-
const missingArtifactIds = steps.flatMap((step) => step.requiredArtifactIds).filter((artifactId) => !options.artifacts.some((artifact) => artifact.id === artifactId));
|
|
1940
|
-
if (missingArtifactIds.length > 0) {
|
|
1941
|
-
return import_artifact3.ToolResult.Error(`One or more artifact ids are invalid: ${missingArtifactIds.join(", ")}`);
|
|
1942
|
-
}
|
|
1943
|
-
const stepResults = [];
|
|
1944
|
-
for (const step of steps) {
|
|
1945
|
-
(0, import_log4.log)("executing step", {
|
|
1946
|
-
action: step.action
|
|
1947
|
-
}, {
|
|
1948
|
-
F: __dxlog_file6,
|
|
1949
|
-
L: 379,
|
|
1950
|
-
S: this,
|
|
1951
|
-
C: (f, a) => f(...a)
|
|
1952
|
-
});
|
|
1953
|
-
const session = new _AISession({
|
|
1954
|
-
operationModel: "importing"
|
|
1955
|
-
});
|
|
1956
|
-
session.message.on((ev) => this.message.emit(ev));
|
|
1957
|
-
session.block.on((ev) => this.block.emit(ev));
|
|
1958
|
-
session.update.on((ev) => this.update.emit(ev));
|
|
1959
|
-
session.streamEvent.on((ev) => this.streamEvent.emit(ev));
|
|
1960
|
-
session.userMessage.on((ev) => this.userMessage.emit(ev));
|
|
1961
|
-
const messages = await session.run({
|
|
1962
|
-
client: options.client,
|
|
1963
|
-
artifacts: options.artifacts,
|
|
1964
|
-
tools: options.tools,
|
|
1965
|
-
history: options.history,
|
|
1966
|
-
extensions: options.extensions,
|
|
1967
|
-
generationOptions: options.generationOptions,
|
|
1968
|
-
requiredArtifactIds: step.requiredArtifactIds.slice(),
|
|
1969
|
-
artifactDiffResolver: options.artifactDiffResolver,
|
|
1970
|
-
prompt: `
|
|
1971
|
-
You are an agent that executes the subtask in a plan.
|
|
1972
|
-
|
|
1973
|
-
While you know the plan's goal only focus on your subtask
|
|
1974
|
-
Use the data from the previous step to complete your task.
|
|
1975
|
-
Return all of the data from "output" in your last message.
|
|
1976
|
-
|
|
1977
|
-
Current step (that you need to complete):
|
|
1978
|
-
${JSON.stringify({
|
|
1979
|
-
goal,
|
|
1980
|
-
input: step.input,
|
|
1981
|
-
output: step.output,
|
|
1982
|
-
yourTask: step.action
|
|
1983
|
-
}, null, 2)}
|
|
1984
|
-
|
|
1985
|
-
Previous step results:
|
|
1986
|
-
${JSON.stringify(stepResults.at(-1))}.
|
|
1987
|
-
`
|
|
1988
|
-
});
|
|
1989
|
-
const result = messages.at(-1);
|
|
1990
|
-
stepResults.push(result);
|
|
1991
|
-
}
|
|
1992
|
-
return import_artifact3.ToolResult.Success({
|
|
1993
|
-
stepResults
|
|
1994
|
-
});
|
|
1995
|
-
}
|
|
1996
|
-
});
|
|
1997
|
-
}
|
|
1998
|
-
abort() {
|
|
1999
|
-
this._stream?.abort();
|
|
2000
|
-
}
|
|
2001
|
-
};
|
|
2002
|
-
_ts_decorate([
|
|
2003
|
-
import_async2.synchronized
|
|
2004
|
-
], AISession.prototype, "run", null);
|
|
2005
|
-
var createBaseInstructions = ({ availableArtifacts, operationModel }) => `
|
|
2006
|
-
You are a friendly, advanced AI assistant capable of creating and managing artifacts from available data and tools.
|
|
2007
|
-
Your task is to process user commands and questions and decide how best to respond.
|
|
2008
|
-
In some cases, you will need to create or reference data objects called artifacts.
|
|
2009
|
-
|
|
2010
|
-
Follow these guidelines carefully:
|
|
2011
|
-
|
|
2012
|
-
Decision-making:
|
|
2013
|
-
|
|
2014
|
-
- Analyze the structure and type of the content in the user's message.
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
${operationModel === "planning" ? `
|
|
2018
|
-
- Can you complete the task using the available artifacts?
|
|
2019
|
-
- If you can't complete the task using the available artifacts, query the list of available artifacts using the appropriate tool.
|
|
2020
|
-
- Identify which artifacts are relevant to the user's request.
|
|
2021
|
-
- Break down the user's request into a step-by-step plan that you will use to execute the user's request, the plan items should include artifacts which will be used to perform the actions.
|
|
2022
|
-
` : ""}
|
|
2023
|
-
${operationModel === "importing" ? `
|
|
2024
|
-
- Can you complete the task using the available artifacts?
|
|
2025
|
-
- If you can't complete the task using the available artifacts, query the list of available artifacts using the appropriate tool.
|
|
2026
|
-
- Identify which artifacts are relevant to the user's request.
|
|
2027
|
-
- Are the required artifacts already available?
|
|
2028
|
-
- If not, select which artifact(s) will be the most relevant and require them using the require_artifacts tool.
|
|
2029
|
-
- The require'd artifact tools will be available for use after require.
|
|
2030
|
-
` : ""}
|
|
2031
|
-
${operationModel === "configured" ? `
|
|
2032
|
-
- Select the most relevant artifact(s) to complete the task.
|
|
2033
|
-
- Call the appropriate tool to use the artifact(s).
|
|
2034
|
-
` : ""}
|
|
2035
|
-
|
|
2036
|
-
${availableArtifacts.length > 0 ? `Artifacts already in context: ${availableArtifacts.join("\n")}` : ""}
|
|
2037
|
-
`;
|
|
2038
|
-
var AIServiecOverloadedError = class extends import_effect3.Schema.TaggedError()("AIServiecOverloadedError", {}) {
|
|
2039
|
-
};
|
|
2040
|
-
var gatherObjectVersions = (messages) => {
|
|
2041
|
-
const artifactIds = /* @__PURE__ */ new Map();
|
|
2042
|
-
for (const message of messages) {
|
|
2043
|
-
for (const block of message.content) {
|
|
2044
|
-
if (block.type === "json" && block.disposition === VersionPin.DISPOSITION) {
|
|
2045
|
-
const pin = VersionPin.pipe(import_effect3.Schema.decodeOption)(JSON.parse(block.json)).pipe(import_effect3.Option.getOrUndefined);
|
|
2046
|
-
if (!pin) {
|
|
2047
|
-
continue;
|
|
2048
|
-
}
|
|
2049
|
-
artifactIds.set(pin.objectId, pin.version);
|
|
2050
|
-
}
|
|
2051
|
-
}
|
|
2052
|
-
}
|
|
2053
|
-
return artifactIds;
|
|
2054
|
-
};
|
|
2055
|
-
var createArtifactUpdateBlock = (artifactDiff) => {
|
|
2056
|
-
return {
|
|
2057
|
-
type: "text",
|
|
2058
|
-
disposition: "artifact-update",
|
|
2059
|
-
text: `
|
|
2060
|
-
The following artifacts have been updated since the last message:
|
|
2061
|
-
${Array.from(artifactDiff.entries()).map(([id, { diff }]) => `<changed-artifact id="${id}">${diff ? `
|
|
2062
|
-
${diff}` : ""}</changed-artifact>`).join("\n")}
|
|
2063
|
-
`
|
|
2064
|
-
};
|
|
2065
|
-
};
|
|
2066
|
-
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/experimental/conversation/conversation.ts";
|
|
2067
|
-
var runLLM = async (params) => {
|
|
2068
|
-
let conversationResult = null;
|
|
2069
|
-
const history = params.history ?? [];
|
|
2070
|
-
const generate = async () => {
|
|
2071
|
-
(0, import_log7.log)("llm generate", {
|
|
2072
|
-
tools: params.tools
|
|
2073
|
-
}, {
|
|
2074
|
-
F: __dxlog_file7,
|
|
2075
|
-
L: 44,
|
|
2076
|
-
S: void 0,
|
|
2077
|
-
C: (f, a) => f(...a)
|
|
2078
|
-
});
|
|
2079
|
-
const beginTs = Date.now();
|
|
2080
|
-
const stream = await params.client.execStream({
|
|
2081
|
-
model: params.model,
|
|
2082
|
-
history,
|
|
2083
|
-
systemPrompt: params.system,
|
|
2084
|
-
tools: params.tools
|
|
2085
|
-
});
|
|
2086
|
-
for await (const event of stream) {
|
|
2087
|
-
params.logger?.(event);
|
|
2088
|
-
}
|
|
2089
|
-
await stream.complete();
|
|
2090
|
-
const messages = [];
|
|
2091
|
-
const message = messages.at(-1);
|
|
2092
|
-
(0, import_invariant6.invariant)(message, void 0, {
|
|
2093
|
-
F: __dxlog_file7,
|
|
2094
|
-
L: 61,
|
|
2095
|
-
S: void 0,
|
|
2096
|
-
A: [
|
|
2097
|
-
"message",
|
|
2098
|
-
""
|
|
2099
|
-
]
|
|
2100
|
-
});
|
|
2101
|
-
(0, import_log7.log)("llm result", {
|
|
2102
|
-
time: Date.now() - beginTs,
|
|
2103
|
-
message
|
|
2104
|
-
}, {
|
|
2105
|
-
F: __dxlog_file7,
|
|
2106
|
-
L: 63,
|
|
2107
|
-
S: void 0,
|
|
2108
|
-
C: (f, a) => f(...a)
|
|
2109
|
-
});
|
|
2110
|
-
(0, import_invariant6.invariant)(message, void 0, {
|
|
2111
|
-
F: __dxlog_file7,
|
|
2112
|
-
L: 64,
|
|
2113
|
-
S: void 0,
|
|
2114
|
-
A: [
|
|
2115
|
-
"message",
|
|
2116
|
-
""
|
|
2117
|
-
]
|
|
2118
|
-
});
|
|
2119
|
-
params.logger?.({
|
|
2120
|
-
type: "message",
|
|
2121
|
-
message
|
|
2122
|
-
});
|
|
2123
|
-
history.push(...messages.map((message2) => ({
|
|
2124
|
-
...message2,
|
|
2125
|
-
content: message2.content.filter((block) => block.type !== "image")
|
|
2126
|
-
})));
|
|
2127
|
-
const isToolUse2 = message.content.at(-1)?.type === "tool_use";
|
|
2128
|
-
if (isToolUse2) {
|
|
2129
|
-
const toolCalls = message.content.filter((block) => block.type === "tool_use");
|
|
2130
|
-
(0, import_invariant6.invariant)(toolCalls.length === 1, void 0, {
|
|
2131
|
-
F: __dxlog_file7,
|
|
2132
|
-
L: 75,
|
|
2133
|
-
S: void 0,
|
|
2134
|
-
A: [
|
|
2135
|
-
"toolCalls.length === 1",
|
|
2136
|
-
""
|
|
2137
|
-
]
|
|
2138
|
-
});
|
|
2139
|
-
const toolCall = toolCalls[0];
|
|
2140
|
-
const tool = params.tools.find((tool2) => tool2.name === toolCall.name);
|
|
2141
|
-
if (!tool) {
|
|
2142
|
-
throw new Error(`Tool not found: ${toolCall.name}`);
|
|
2143
|
-
}
|
|
2144
|
-
(0, import_invariant6.invariant)(tool.execute, void 0, {
|
|
2145
|
-
F: __dxlog_file7,
|
|
2146
|
-
L: 82,
|
|
2147
|
-
S: void 0,
|
|
2148
|
-
A: [
|
|
2149
|
-
"tool.execute",
|
|
2150
|
-
""
|
|
2151
|
-
]
|
|
2152
|
-
});
|
|
2153
|
-
const toolResult = await tool.execute(toolCall.input);
|
|
2154
|
-
switch (toolResult.kind) {
|
|
2155
|
-
case "error": {
|
|
2156
|
-
import_log7.log.warn("tool error", {
|
|
2157
|
-
message: toolResult.message
|
|
2158
|
-
}, {
|
|
2159
|
-
F: __dxlog_file7,
|
|
2160
|
-
L: 86,
|
|
2161
|
-
S: void 0,
|
|
2162
|
-
C: (f, a) => f(...a)
|
|
2163
|
-
});
|
|
2164
|
-
const resultMessage = {
|
|
2165
|
-
id: import_echo_schema6.ObjectId.random(),
|
|
2166
|
-
role: "user",
|
|
2167
|
-
content: [
|
|
2168
|
-
{
|
|
2169
|
-
type: "tool_result",
|
|
2170
|
-
toolUseId: toolCall.id,
|
|
2171
|
-
content: toolResult.message,
|
|
2172
|
-
isError: true
|
|
2173
|
-
}
|
|
2174
|
-
]
|
|
2175
|
-
};
|
|
2176
|
-
params.logger?.({
|
|
2177
|
-
type: "message",
|
|
2178
|
-
message: resultMessage
|
|
2179
|
-
});
|
|
2180
|
-
history.push(resultMessage);
|
|
2181
|
-
return true;
|
|
2182
|
-
}
|
|
2183
|
-
case "success": {
|
|
2184
|
-
(0, import_log7.log)("tool success", {
|
|
2185
|
-
result: toolResult.result
|
|
2186
|
-
}, {
|
|
2187
|
-
F: __dxlog_file7,
|
|
2188
|
-
L: 106,
|
|
2189
|
-
S: void 0,
|
|
2190
|
-
C: (f, a) => f(...a)
|
|
2191
|
-
});
|
|
2192
|
-
const resultMessage = {
|
|
2193
|
-
id: import_echo_schema6.ObjectId.random(),
|
|
2194
|
-
role: "user",
|
|
2195
|
-
content: [
|
|
2196
|
-
{
|
|
2197
|
-
type: "tool_result",
|
|
2198
|
-
toolUseId: toolCall.id,
|
|
2199
|
-
content: JSON.stringify(toolResult.result)
|
|
2200
|
-
}
|
|
2201
|
-
]
|
|
2202
|
-
};
|
|
2203
|
-
params.logger?.({
|
|
2204
|
-
type: "message",
|
|
2205
|
-
message: resultMessage
|
|
2206
|
-
});
|
|
2207
|
-
history.push(resultMessage);
|
|
2208
|
-
return true;
|
|
2209
|
-
}
|
|
2210
|
-
case "break": {
|
|
2211
|
-
(0, import_log7.log)("tool break", {
|
|
2212
|
-
result: toolResult.result
|
|
2213
|
-
}, {
|
|
2214
|
-
F: __dxlog_file7,
|
|
2215
|
-
L: 125,
|
|
2216
|
-
S: void 0,
|
|
2217
|
-
C: (f, a) => f(...a)
|
|
2218
|
-
});
|
|
2219
|
-
conversationResult = toolResult.result;
|
|
2220
|
-
return false;
|
|
2221
|
-
}
|
|
2222
|
-
}
|
|
2223
|
-
}
|
|
2224
|
-
return false;
|
|
2225
|
-
};
|
|
2226
|
-
while (await generate()) {
|
|
2227
|
-
}
|
|
2228
|
-
return {
|
|
2229
|
-
result: conversationResult,
|
|
2230
|
-
history
|
|
2231
|
-
};
|
|
2232
|
-
};
|
|
2233
1772
|
var ws = import_parjs.parjs.whitespace();
|
|
2234
1773
|
var nothing = import_parjs.parjs.string("").pipe(import_parjs.parjsCombinators.map(() => null));
|
|
2235
1774
|
var optional = (parser) => parser.pipe(import_parjs.parjsCombinators.recover(() => ({
|
|
@@ -2312,7 +1851,7 @@ var parseCypherQuery = (query) => {
|
|
|
2312
1851
|
throw new Error(`Failed to parse query: ${parseResult}`);
|
|
2313
1852
|
}
|
|
2314
1853
|
};
|
|
2315
|
-
var
|
|
1854
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/cypher/execution-plan.ts";
|
|
2316
1855
|
var createExecutionPlan = (query) => {
|
|
2317
1856
|
return new ExecutionPlanBuilder().build(query);
|
|
2318
1857
|
};
|
|
@@ -2324,10 +1863,10 @@ var ExecutionPlanBuilder = class {
|
|
|
2324
1863
|
return `anon_${this.counter++}`;
|
|
2325
1864
|
}
|
|
2326
1865
|
build(query) {
|
|
2327
|
-
(0,
|
|
1866
|
+
(0, import_log7.log)("Creating execution plan for query", {
|
|
2328
1867
|
query
|
|
2329
1868
|
}, {
|
|
2330
|
-
F:
|
|
1869
|
+
F: __dxlog_file6,
|
|
2331
1870
|
L: 76,
|
|
2332
1871
|
S: this,
|
|
2333
1872
|
C: (f, a) => f(...a)
|
|
@@ -2344,8 +1883,8 @@ var ExecutionPlanBuilder = class {
|
|
|
2344
1883
|
};
|
|
2345
1884
|
}
|
|
2346
1885
|
createStepsForMatchClause(match) {
|
|
2347
|
-
(0,
|
|
2348
|
-
F:
|
|
1886
|
+
(0, import_invariant5.invariant)(match.pattern.segments.length > 0, void 0, {
|
|
1887
|
+
F: __dxlog_file6,
|
|
2349
1888
|
L: 90,
|
|
2350
1889
|
S: this,
|
|
2351
1890
|
A: [
|
|
@@ -2354,8 +1893,8 @@ var ExecutionPlanBuilder = class {
|
|
|
2354
1893
|
]
|
|
2355
1894
|
});
|
|
2356
1895
|
const firstSegment = match.pattern.segments[0];
|
|
2357
|
-
(0,
|
|
2358
|
-
F:
|
|
1896
|
+
(0, import_invariant5.invariant)(firstSegment.astKind === "NodePattern", void 0, {
|
|
1897
|
+
F: __dxlog_file6,
|
|
2359
1898
|
L: 92,
|
|
2360
1899
|
S: this,
|
|
2361
1900
|
A: [
|
|
@@ -2382,8 +1921,8 @@ var ExecutionPlanBuilder = class {
|
|
|
2382
1921
|
}
|
|
2383
1922
|
for (let i = 1; i < match.pattern.segments.length; i++) {
|
|
2384
1923
|
const relationshipSegment = match.pattern.segments[i++];
|
|
2385
|
-
(0,
|
|
2386
|
-
F:
|
|
1924
|
+
(0, import_invariant5.invariant)(relationshipSegment.astKind === "RelationshipPattern", void 0, {
|
|
1925
|
+
F: __dxlog_file6,
|
|
2387
1926
|
L: 115,
|
|
2388
1927
|
S: this,
|
|
2389
1928
|
A: [
|
|
@@ -2392,8 +1931,8 @@ var ExecutionPlanBuilder = class {
|
|
|
2392
1931
|
]
|
|
2393
1932
|
});
|
|
2394
1933
|
const nodeSegment = match.pattern.segments[i];
|
|
2395
|
-
(0,
|
|
2396
|
-
F:
|
|
1934
|
+
(0, import_invariant5.invariant)(nodeSegment.astKind === "NodePattern", void 0, {
|
|
1935
|
+
F: __dxlog_file6,
|
|
2397
1936
|
L: 117,
|
|
2398
1937
|
S: this,
|
|
2399
1938
|
A: [
|
|
@@ -2474,15 +2013,15 @@ var getDirection = (left, right) => {
|
|
|
2474
2013
|
}
|
|
2475
2014
|
throw new Error(`Invalid direction: ()${left}[]${right}()`);
|
|
2476
2015
|
};
|
|
2477
|
-
var
|
|
2016
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/cypher/query-executor.ts";
|
|
2478
2017
|
var executeQueryPlan = async (dataSource, plan) => {
|
|
2479
2018
|
let buffer = [];
|
|
2480
2019
|
const results = [];
|
|
2481
2020
|
for (const step of plan.steps) {
|
|
2482
|
-
(0,
|
|
2021
|
+
(0, import_log6.log)("begin step", {
|
|
2483
2022
|
step
|
|
2484
2023
|
}, {
|
|
2485
|
-
F:
|
|
2024
|
+
F: __dxlog_file7,
|
|
2486
2025
|
L: 41,
|
|
2487
2026
|
S: void 0,
|
|
2488
2027
|
C: (f, a) => f(...a)
|
|
@@ -2568,11 +2107,11 @@ var executeQueryPlan = async (dataSource, plan) => {
|
|
|
2568
2107
|
break;
|
|
2569
2108
|
}
|
|
2570
2109
|
}
|
|
2571
|
-
(0,
|
|
2110
|
+
(0, import_log6.log)("finish step", {
|
|
2572
2111
|
buffer: buffer.map((tuple) => (0, import_util2.mapValues)(tuple, (x) => x.id)),
|
|
2573
2112
|
results
|
|
2574
2113
|
}, {
|
|
2575
|
-
F:
|
|
2114
|
+
F: __dxlog_file7,
|
|
2576
2115
|
L: 118,
|
|
2577
2116
|
S: void 0,
|
|
2578
2117
|
C: (f, a) => f(...a)
|
|
@@ -2655,14 +2194,14 @@ var formatInferredRelationshipLabel = (typename, property2) => {
|
|
|
2655
2194
|
const nodeLabel = formatNodeLabel(typename);
|
|
2656
2195
|
return `${nodeLabel}_${property2}`.toUpperCase();
|
|
2657
2196
|
};
|
|
2658
|
-
var isReference = (schema) => schema.$id ===
|
|
2659
|
-
function
|
|
2197
|
+
var isReference = (schema) => schema.$id === import_echo_schema5.JSON_SCHEMA_ECHO_REF_ID || schema.type === "array" && !Array.isArray(schema.items) && typeof schema.items === "object" && "$id" in schema.items && schema.items.$id === import_echo_schema5.JSON_SCHEMA_ECHO_REF_ID;
|
|
2198
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2660
2199
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2661
2200
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2662
2201
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2663
2202
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2664
2203
|
}
|
|
2665
|
-
var
|
|
2204
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/cypher/echo-data-source.ts";
|
|
2666
2205
|
var EchoDataSource = class {
|
|
2667
2206
|
constructor(_db) {
|
|
2668
2207
|
this._db = _db;
|
|
@@ -2672,16 +2211,16 @@ var EchoDataSource = class {
|
|
|
2672
2211
|
const { objects: objects2 } = await this._db.query().run();
|
|
2673
2212
|
return objects2.map(this._objectToNode);
|
|
2674
2213
|
}
|
|
2675
|
-
const schema = (await this._getAllSchema()).find((
|
|
2214
|
+
const schema = (await this._getAllSchema()).find((s) => (0, import_echo_schema6.getSchemaTypename)(s)?.endsWith(label2));
|
|
2676
2215
|
if (!schema) {
|
|
2677
2216
|
return [];
|
|
2678
2217
|
}
|
|
2679
|
-
const { objects } = await this._db.query(
|
|
2218
|
+
const { objects } = await this._db.query(import_echo_db.Filter.schema(schema)).run();
|
|
2680
2219
|
return objects.map(this._objectToNode);
|
|
2681
2220
|
}
|
|
2682
2221
|
async getRelationships({ label: label2 }) {
|
|
2683
|
-
const syntheticRefRelationships = (await this._getAllSchema()).filter((schema) => (0,
|
|
2684
|
-
const jsonSchema = (0,
|
|
2222
|
+
const syntheticRefRelationships = (await this._getAllSchema()).filter((schema) => (0, import_echo_schema6.getSchemaTypename)(schema) !== import_echo_schema6.StoredSchema.typename).flatMap((schema) => {
|
|
2223
|
+
const jsonSchema = (0, import_echo_schema6.toJsonSchema)(schema);
|
|
2685
2224
|
const relationships = Object.entries(jsonSchema.properties).filter(([key, prop]) => isReference(prop));
|
|
2686
2225
|
return relationships.map(([key, value]) => {
|
|
2687
2226
|
const relationshipLabel = formatInferredRelationshipLabel(jsonSchema.typename ?? (0, import_debug2.raise)(new Error("Schema must have typename")), key);
|
|
@@ -2696,22 +2235,22 @@ var EchoDataSource = class {
|
|
|
2696
2235
|
if (!relationship) {
|
|
2697
2236
|
return [];
|
|
2698
2237
|
}
|
|
2699
|
-
const { objects } = await this._db.query(
|
|
2238
|
+
const { objects } = await this._db.query(import_echo_db.Filter.schema(relationship.schema)).run();
|
|
2700
2239
|
return (await Promise.all(objects.map((object) => this._projectRefRelationship(object, relationship.property)))).flat();
|
|
2701
2240
|
}
|
|
2702
2241
|
async _getAllSchema() {
|
|
2703
2242
|
return [
|
|
2704
2243
|
...await this._db.schemaRegistry.query().run(),
|
|
2705
2244
|
// TODO(dmaretskyi): Remove once we can serialize recursive schema.
|
|
2706
|
-
...this._db.graph.schemaRegistry.schemas.filter((
|
|
2707
|
-
].filter((schema) => (0,
|
|
2245
|
+
...this._db.graph.schemaRegistry.schemas.filter((s) => (0, import_echo_schema6.getSchemaTypename)(s)?.startsWith("example.org"))
|
|
2246
|
+
].filter((schema) => (0, import_echo_schema6.getSchemaTypename)(schema) !== import_echo_schema6.StoredSchema.typename);
|
|
2708
2247
|
}
|
|
2709
2248
|
_objectToNode(object) {
|
|
2710
2249
|
const { id, ...properties2 } = object;
|
|
2711
2250
|
return {
|
|
2712
2251
|
id,
|
|
2713
2252
|
kind: "node",
|
|
2714
|
-
label: formatNodeLabel((0,
|
|
2253
|
+
label: formatNodeLabel((0, import_echo_schema6.getSchemaTypename)((0, import_live_object.getSchema)(object))),
|
|
2715
2254
|
properties: properties2
|
|
2716
2255
|
};
|
|
2717
2256
|
}
|
|
@@ -2727,7 +2266,7 @@ var EchoDataSource = class {
|
|
|
2727
2266
|
return {
|
|
2728
2267
|
id: `${object.id}-${prop}-${target.id}`,
|
|
2729
2268
|
kind: "relationship",
|
|
2730
|
-
label: formatInferredRelationshipLabel((0,
|
|
2269
|
+
label: formatInferredRelationshipLabel((0, import_echo_schema6.getSchemaTypename)((0, import_live_object.getSchema)(object)), prop),
|
|
2731
2270
|
properties: {},
|
|
2732
2271
|
source: this._objectToNode(object),
|
|
2733
2272
|
target: this._objectToNode(target)
|
|
@@ -2735,17 +2274,17 @@ var EchoDataSource = class {
|
|
|
2735
2274
|
}));
|
|
2736
2275
|
}
|
|
2737
2276
|
};
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
F:
|
|
2741
|
-
L:
|
|
2277
|
+
_ts_decorate([
|
|
2278
|
+
import_log8.log.method(void 0, void 0, {
|
|
2279
|
+
F: __dxlog_file8,
|
|
2280
|
+
L: 17,
|
|
2742
2281
|
S: void 0,
|
|
2743
2282
|
C: (f, a) => f(...a)
|
|
2744
2283
|
})
|
|
2745
2284
|
], EchoDataSource.prototype, "getNodes", null);
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
F:
|
|
2285
|
+
_ts_decorate([
|
|
2286
|
+
import_log8.log.method(void 0, void 0, {
|
|
2287
|
+
F: __dxlog_file8,
|
|
2749
2288
|
L: 34,
|
|
2750
2289
|
S: void 0,
|
|
2751
2290
|
C: (f, a) => f(...a)
|
|
@@ -2754,8 +2293,6 @@ _ts_decorate2([
|
|
|
2754
2293
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2755
2294
|
0 && (module.exports = {
|
|
2756
2295
|
AIServiceEdgeClient,
|
|
2757
|
-
AIServiecOverloadedError,
|
|
2758
|
-
AISession,
|
|
2759
2296
|
DEFAULT_EDGE_MODEL,
|
|
2760
2297
|
DEFAULT_EDGE_MODELS,
|
|
2761
2298
|
DEFAULT_OLLAMA_ENDPOINT,
|
|
@@ -2763,7 +2300,6 @@ _ts_decorate2([
|
|
|
2763
2300
|
DEFAULT_OLLAMA_MODELS,
|
|
2764
2301
|
EchoDataSource,
|
|
2765
2302
|
GenerateRequest,
|
|
2766
|
-
GenerateResponse,
|
|
2767
2303
|
GenerationStreamImpl,
|
|
2768
2304
|
LLMModel,
|
|
2769
2305
|
MessageCollector,
|
|
@@ -2771,7 +2307,6 @@ _ts_decorate2([
|
|
|
2771
2307
|
OllamaClient,
|
|
2772
2308
|
StreamTransform,
|
|
2773
2309
|
ToolTypes,
|
|
2774
|
-
VersionPin,
|
|
2775
2310
|
createArtifactElement,
|
|
2776
2311
|
createGenerationStream,
|
|
2777
2312
|
emitMessageAsEvents,
|
|
@@ -2788,4 +2323,4 @@ _ts_decorate2([
|
|
|
2788
2323
|
runTools,
|
|
2789
2324
|
trim
|
|
2790
2325
|
});
|
|
2791
|
-
//# sourceMappingURL=chunk-
|
|
2326
|
+
//# sourceMappingURL=chunk-IBOBRBDF.cjs.map
|