@dxos/assistant 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8
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/LICENSE +102 -5
- package/README.md +2 -1
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/extraction/index.mjs +208 -0
- package/dist/lib/neutral/extraction/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +1886 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/types/src/extraction/extraction-ner-function/index.d.ts +0 -1
- package/dist/types/src/extraction/extraction-ner-function/index.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction.d.ts +1650 -281
- package/dist/types/src/extraction/extraction.d.ts.map +1 -1
- package/dist/types/src/extraction/index.d.ts +0 -1
- package/dist/types/src/extraction/index.d.ts.map +1 -1
- package/dist/types/src/extraction/quotes.d.ts +3 -3
- package/dist/types/src/extraction/quotes.d.ts.map +1 -1
- package/dist/types/src/functions/services.d.ts +16 -5
- package/dist/types/src/functions/services.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/request/AiRequest.d.ts +308 -0
- package/dist/types/src/request/AiRequest.d.ts.map +1 -0
- package/dist/types/src/{session → request}/artifact-diff.d.ts +5 -5
- package/dist/types/src/request/artifact-diff.d.ts.map +1 -0
- package/dist/types/src/request/format.d.ts +15 -0
- package/dist/types/src/request/format.d.ts.map +1 -0
- package/dist/types/src/request/index.d.ts +4 -0
- package/dist/types/src/request/index.d.ts.map +1 -0
- package/dist/types/src/request/observer.d.ts +23 -0
- package/dist/types/src/request/observer.d.ts.map +1 -0
- package/dist/types/src/{session → request}/version-pin.d.ts +6 -6
- package/dist/types/src/request/version-pin.d.ts.map +1 -0
- package/dist/types/src/session/AiContext.d.ts +178 -0
- package/dist/types/src/session/AiContext.d.ts.map +1 -0
- package/dist/types/src/session/AiContext.test.d.ts +2 -0
- package/dist/types/src/session/AiContext.test.d.ts.map +1 -0
- package/dist/types/src/session/AiSession.d.ts +79 -0
- package/dist/types/src/session/AiSession.d.ts.map +1 -0
- package/dist/types/src/session/AiSession.test.d.ts +2 -0
- package/dist/types/src/session/AiSession.test.d.ts.map +1 -0
- package/dist/types/src/session/SessionLink.d.ts +17 -0
- package/dist/types/src/session/SessionLink.d.ts.map +1 -0
- package/dist/types/src/session/SessionLoader.d.ts +15 -0
- package/dist/types/src/session/SessionLoader.d.ts.map +1 -0
- package/dist/types/src/session/SessionLoader.test.d.ts +2 -0
- package/dist/types/src/session/SessionLoader.test.d.ts.map +1 -0
- package/dist/types/src/session/index.d.ts +5 -3
- package/dist/types/src/session/index.d.ts.map +1 -1
- package/dist/types/src/session/toolkit.d.ts +16 -0
- package/dist/types/src/session/toolkit.d.ts.map +1 -0
- package/dist/types/src/templates/system.d.ts +19 -14
- package/dist/types/src/templates/system.d.ts.map +1 -1
- package/dist/types/src/util/artifact.d.ts +18 -0
- package/dist/types/src/util/artifact.d.ts.map +1 -0
- package/dist/types/src/util/diff.d.ts +17 -0
- package/dist/types/src/util/diff.d.ts.map +1 -0
- package/dist/types/src/util/diff.test.d.ts +2 -0
- package/dist/types/src/util/diff.test.d.ts.map +1 -0
- package/dist/types/src/util/error-handling.d.ts +4 -0
- package/dist/types/src/util/error-handling.d.ts.map +1 -0
- package/dist/types/src/util/errors.d.ts +67 -0
- package/dist/types/src/util/errors.d.ts.map +1 -0
- package/dist/types/src/util/execution-graph.d.ts +85 -0
- package/dist/types/src/util/execution-graph.d.ts.map +1 -0
- package/dist/types/src/util/execution-graph.test.d.ts +2 -0
- package/dist/types/src/util/execution-graph.test.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +7 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/src/util/tracing.d.ts +296 -0
- package/dist/types/src/util/tracing.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -47
- package/src/extraction/extraction-ner-function/index.ts +0 -1
- package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +12 -6
- package/src/extraction/extraction-ner-function/named-entity-recognition.ts +2 -0
- package/src/extraction/extraction.ts +49 -19
- package/src/extraction/index.ts +0 -1
- package/src/extraction/quotes.test.ts +2 -2
- package/src/extraction/quotes.ts +7 -9
- package/src/functions/services.ts +180 -66
- package/src/index.ts +2 -3
- package/src/request/AiRequest.ts +387 -0
- package/src/{session → request}/artifact-diff.ts +10 -6
- package/src/{session → request}/format.ts +45 -37
- package/src/request/index.ts +8 -0
- package/src/request/observer.ts +62 -0
- package/src/{session → request}/version-pin.ts +8 -8
- package/src/session/AiContext.test.ts +49 -0
- package/src/session/AiContext.ts +420 -0
- package/src/session/AiSession.test.ts +111 -0
- package/src/session/AiSession.ts +328 -0
- package/src/session/SessionLink.ts +23 -0
- package/src/session/SessionLoader.test.ts +115 -0
- package/src/session/SessionLoader.ts +55 -0
- package/src/session/index.ts +6 -3
- package/src/session/toolkit.ts +47 -0
- package/src/templates/{format.tpl → instructions/format.tpl} +6 -4
- package/src/templates/instructions/system.tpl +96 -0
- package/src/templates/system.ts +26 -16
- package/src/util/artifact.ts +96 -0
- package/src/util/diff.test.ts +74 -0
- package/src/util/diff.ts +93 -0
- package/src/util/error-handling.ts +42 -0
- package/src/util/errors.ts +15 -0
- package/src/util/execution-graph.test.ts +740 -0
- package/src/util/execution-graph.ts +520 -0
- package/src/util/index.ts +10 -0
- package/src/util/tracing.ts +60 -0
- package/dist/lib/browser/chunk-6WRGDEMH.mjs +0 -89
- package/dist/lib/browser/chunk-6WRGDEMH.mjs.map +0 -7
- package/dist/lib/browser/chunk-NZGGCEF3.mjs +0 -341
- package/dist/lib/browser/chunk-NZGGCEF3.mjs.map +0 -7
- package/dist/lib/browser/extraction/index.mjs +0 -269
- package/dist/lib/browser/extraction/index.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -354
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/named-entity-recognition-O46UTCLR.mjs +0 -13
- package/dist/lib/node-esm/chunk-3UU5V4FS.mjs +0 -91
- package/dist/lib/node-esm/chunk-3UU5V4FS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XOOPGSGW.mjs +0 -343
- package/dist/lib/node-esm/chunk-XOOPGSGW.mjs.map +0 -7
- package/dist/lib/node-esm/extraction/index.mjs +0 -270
- package/dist/lib/node-esm/extraction/index.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -355
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/named-entity-recognition-W4VMRCH6.mjs +0 -14
- package/dist/lib/node-esm/named-entity-recognition-W4VMRCH6.mjs.map +0 -7
- package/dist/types/src/conversation/context.d.ts +0 -90
- package/dist/types/src/conversation/context.d.ts.map +0 -1
- package/dist/types/src/conversation/conversation.d.ts +0 -50
- package/dist/types/src/conversation/conversation.d.ts.map +0 -1
- package/dist/types/src/conversation/index.d.ts +0 -3
- package/dist/types/src/conversation/index.d.ts.map +0 -1
- package/dist/types/src/errors.d.ts +0 -39
- package/dist/types/src/errors.d.ts.map +0 -1
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +0 -4
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +0 -1
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts +0 -2
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts.map +0 -1
- package/dist/types/src/extraction/extraction-llm-function/index.d.ts +0 -2
- package/dist/types/src/extraction/extraction-llm-function/index.d.ts.map +0 -1
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +0 -306
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +0 -1
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts +0 -2
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts.map +0 -1
- package/dist/types/src/session/artifact-diff.d.ts.map +0 -1
- package/dist/types/src/session/format.d.ts +0 -168
- package/dist/types/src/session/format.d.ts.map +0 -1
- package/dist/types/src/session/format.test.d.ts +0 -2
- package/dist/types/src/session/format.test.d.ts.map +0 -1
- package/dist/types/src/session/session.d.ts +0 -167
- package/dist/types/src/session/session.d.ts.map +0 -1
- package/dist/types/src/session/session.test.d.ts +0 -2
- package/dist/types/src/session/session.test.d.ts.map +0 -1
- 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/summarization/summarization.test.d.ts +0 -2
- package/dist/types/src/summarization/summarization.test.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -16
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/conversation/context.ts +0 -133
- package/src/conversation/conversation.ts +0 -125
- package/src/conversation/index.ts +0 -6
- package/src/errors.ts +0 -10
- package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +0 -84
- package/src/extraction/extraction-llm-function/extraction-llm-function.ts +0 -71
- package/src/extraction/extraction-llm-function/index.ts +0 -5
- package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +0 -116
- package/src/extraction/extraction-ner-function/extraction-ner-function.ts +0 -57
- package/src/session/__snapshots__/session.test.ts.snap +0 -32
- package/src/session/format.test.ts +0 -60
- package/src/session/session.test.ts +0 -305
- package/src/session/session.ts +0 -279
- package/src/session/version-pin.test.ts +0 -7
- package/src/summarization/summarization.test.ts +0 -197
- package/src/templates/system.tpl +0 -47
- package/src/types.ts +0 -52
- /package/dist/lib/{browser/named-entity-recognition-O46UTCLR.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/src/extraction/extraction-llm-function/{instructions.tpl → transcription-instructions.tpl} +0 -0
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
AiAssistantError,
|
|
4
|
-
AiSession,
|
|
5
|
-
ArtifactDiffResolver,
|
|
6
|
-
GenerationObserver,
|
|
7
|
-
VersionPin
|
|
8
|
-
} from "./chunk-XOOPGSGW.mjs";
|
|
9
|
-
|
|
10
|
-
// src/conversation/context.ts
|
|
11
|
-
import { computed } from "@preact/signals-core";
|
|
12
|
-
import { Schema } from "effect";
|
|
13
|
-
import { Array, pipe } from "effect";
|
|
14
|
-
import { Blueprint } from "@dxos/blueprints";
|
|
15
|
-
import { Obj, Type } from "@dxos/echo";
|
|
16
|
-
import { ComplexSet } from "@dxos/util";
|
|
17
|
-
var ContextBinding = Schema.Struct({
|
|
18
|
-
blueprints: Schema.Struct({
|
|
19
|
-
added: Schema.Array(Type.Ref(Blueprint.Blueprint)),
|
|
20
|
-
removed: Schema.Array(Type.Ref(Blueprint.Blueprint))
|
|
21
|
-
}),
|
|
22
|
-
// TODO(burdon): Type.Expando => Type.Obj (or Obj.Any?)
|
|
23
|
-
objects: Schema.Struct({
|
|
24
|
-
added: Schema.Array(Type.Ref(Type.Expando)),
|
|
25
|
-
removed: Schema.Array(Type.Ref(Type.Expando))
|
|
26
|
-
})
|
|
27
|
-
}).pipe(Type.Obj({
|
|
28
|
-
typename: "dxos.org/type/ContextBinding",
|
|
29
|
-
version: "0.1.0"
|
|
30
|
-
}));
|
|
31
|
-
var Bindings = class {
|
|
32
|
-
blueprints = new ComplexSet((ref) => ref.dxn.toString());
|
|
33
|
-
objects = new ComplexSet((ref) => ref.dxn.toString());
|
|
34
|
-
toJSON() {
|
|
35
|
-
return {
|
|
36
|
-
blueprints: Array.fromIterable(this.blueprints).map((ref) => ref.dxn.toString()),
|
|
37
|
-
objects: Array.fromIterable(this.objects).map((ref) => ref.dxn.toString())
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var AiContextBinder = class {
|
|
42
|
-
_queue;
|
|
43
|
-
/**
|
|
44
|
-
* Reactive query of all bindings.
|
|
45
|
-
*/
|
|
46
|
-
// TODO(burdon): Cache value?
|
|
47
|
-
bindings;
|
|
48
|
-
blueprints;
|
|
49
|
-
objects;
|
|
50
|
-
constructor(_queue) {
|
|
51
|
-
this._queue = _queue;
|
|
52
|
-
this.bindings = computed(() => this._reduce(this._queue.objects));
|
|
53
|
-
this.blueprints = computed(() => [
|
|
54
|
-
...this.bindings.value.blueprints
|
|
55
|
-
]);
|
|
56
|
-
this.objects = computed(() => [
|
|
57
|
-
...this.bindings.value.objects
|
|
58
|
-
]);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Asynchronous query of all bindings.
|
|
62
|
-
*/
|
|
63
|
-
async query() {
|
|
64
|
-
const queueItems = await this._queue.queryObjects();
|
|
65
|
-
return this._reduce(queueItems);
|
|
66
|
-
}
|
|
67
|
-
// TODO(burdon): Pass in Blueprint obj (from registry?) and create reference.
|
|
68
|
-
async bind(props) {
|
|
69
|
-
if (!props.blueprints?.length && !props.objects?.length) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
await this._queue.append([
|
|
73
|
-
Obj.make(ContextBinding, {
|
|
74
|
-
blueprints: {
|
|
75
|
-
added: props.blueprints ?? [],
|
|
76
|
-
removed: []
|
|
77
|
-
},
|
|
78
|
-
objects: {
|
|
79
|
-
added: props.objects ?? [],
|
|
80
|
-
removed: []
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
]);
|
|
84
|
-
}
|
|
85
|
-
async unbind(props) {
|
|
86
|
-
if (!props.blueprints?.length && !props.objects?.length) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
await this._queue.append([
|
|
90
|
-
Obj.make(ContextBinding, {
|
|
91
|
-
blueprints: {
|
|
92
|
-
added: [],
|
|
93
|
-
removed: props.blueprints ?? []
|
|
94
|
-
},
|
|
95
|
-
objects: {
|
|
96
|
-
added: [],
|
|
97
|
-
removed: props.objects ?? []
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
]);
|
|
101
|
-
}
|
|
102
|
-
_reduce(items) {
|
|
103
|
-
return pipe(items, Array.filter(Obj.instanceOf(ContextBinding)), Array.reduce(new Bindings(), (context, item) => {
|
|
104
|
-
item.blueprints.removed.forEach((item2) => context.blueprints.delete(item2));
|
|
105
|
-
item.blueprints.added.forEach((item2) => context.blueprints.add(item2));
|
|
106
|
-
item.objects.removed.forEach((item2) => context.objects.delete(item2));
|
|
107
|
-
item.objects.added.forEach((item2) => context.objects.add(item2));
|
|
108
|
-
return context;
|
|
109
|
-
}));
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
// src/conversation/conversation.ts
|
|
114
|
-
import { Effect } from "effect";
|
|
115
|
-
import { Event } from "@dxos/async";
|
|
116
|
-
import { Obj as Obj2 } from "@dxos/echo";
|
|
117
|
-
import { DatabaseService } from "@dxos/functions";
|
|
118
|
-
import { log } from "@dxos/log";
|
|
119
|
-
import { DataType } from "@dxos/schema";
|
|
120
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/core/assistant/src/conversation/conversation.ts";
|
|
121
|
-
var AiConversation = class {
|
|
122
|
-
_queue;
|
|
123
|
-
/**
|
|
124
|
-
* Blueprints bound to the conversation.
|
|
125
|
-
*/
|
|
126
|
-
_context;
|
|
127
|
-
/**
|
|
128
|
-
* Fired when the execution loop begins.
|
|
129
|
-
* This is called before the first message is sent.
|
|
130
|
-
*
|
|
131
|
-
* @deprecated Pass in a session instead.
|
|
132
|
-
*/
|
|
133
|
-
// TODO(burdon): Is this still deprecated?
|
|
134
|
-
onBegin = new Event();
|
|
135
|
-
constructor(options) {
|
|
136
|
-
this._queue = options.queue;
|
|
137
|
-
this._context = new AiContextBinder(this._queue);
|
|
138
|
-
}
|
|
139
|
-
get context() {
|
|
140
|
-
return this._context;
|
|
141
|
-
}
|
|
142
|
-
async getHistory() {
|
|
143
|
-
const queueItems = await this._queue.queryObjects();
|
|
144
|
-
return queueItems.filter(Obj2.instanceOf(DataType.Message));
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Executes a prompt.
|
|
148
|
-
* Each invocation creates a new `AiSession`, which handles potential tool calls.
|
|
149
|
-
*/
|
|
150
|
-
run = ({
|
|
151
|
-
// TODO(burdon): Decide whether to pass in or to fully encapsulate.
|
|
152
|
-
session = new AiSession(),
|
|
153
|
-
...params
|
|
154
|
-
}) => Effect.gen(this, function* () {
|
|
155
|
-
const history = yield* Effect.promise(() => this.getHistory());
|
|
156
|
-
const context = yield* Effect.promise(() => this.context.query());
|
|
157
|
-
const blueprints = yield* Effect.forEach(context.blueprints.values(), DatabaseService.load);
|
|
158
|
-
const objects = yield* Effect.forEach(context.objects.values(), DatabaseService.load);
|
|
159
|
-
log.info("run", {
|
|
160
|
-
prompt: params.prompt,
|
|
161
|
-
system: params.system,
|
|
162
|
-
history: history.length,
|
|
163
|
-
objects: objects.length,
|
|
164
|
-
blueprints: blueprints.length,
|
|
165
|
-
toolkit: params.toolkit
|
|
166
|
-
}, {
|
|
167
|
-
F: __dxlog_file,
|
|
168
|
-
L: 99,
|
|
169
|
-
S: this,
|
|
170
|
-
C: (f, a) => f(...a)
|
|
171
|
-
});
|
|
172
|
-
const start = Date.now();
|
|
173
|
-
this.onBegin.emit(session);
|
|
174
|
-
const messages = yield* session.run({
|
|
175
|
-
prompt: params.prompt,
|
|
176
|
-
system: params.system,
|
|
177
|
-
history,
|
|
178
|
-
objects,
|
|
179
|
-
blueprints,
|
|
180
|
-
toolkit: params.toolkit,
|
|
181
|
-
observer: params.observer
|
|
182
|
-
});
|
|
183
|
-
log.info("result", {
|
|
184
|
-
messages,
|
|
185
|
-
duration: Date.now() - start
|
|
186
|
-
}, {
|
|
187
|
-
F: __dxlog_file,
|
|
188
|
-
L: 121,
|
|
189
|
-
S: this,
|
|
190
|
-
C: (f, a) => f(...a)
|
|
191
|
-
});
|
|
192
|
-
yield* Effect.promise(() => this._queue.append(messages));
|
|
193
|
-
return messages;
|
|
194
|
-
}).pipe(Effect.withSpan("AiConversation.run"));
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
// src/functions/services.ts
|
|
198
|
-
import { AiTool } from "@effect/ai";
|
|
199
|
-
import { Context, Effect as Effect2, Layer, Match, Predicate, Record, Schema as Schema2 } from "effect";
|
|
200
|
-
import { AiToolNotFoundError, ToolExecutionService, ToolResolverService } from "@dxos/ai";
|
|
201
|
-
import { LocalFunctionExecutionService } from "@dxos/functions";
|
|
202
|
-
import { invariant } from "@dxos/invariant";
|
|
203
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/assistant/src/functions/services.ts";
|
|
204
|
-
var makeToolResolverFromFunctions = (functions, toolkit) => {
|
|
205
|
-
return Layer.succeed(ToolResolverService, {
|
|
206
|
-
resolve: Effect2.fn("resolveTool")(function* (id) {
|
|
207
|
-
const tool = toolkit.tools[id];
|
|
208
|
-
if (tool) {
|
|
209
|
-
return tool;
|
|
210
|
-
}
|
|
211
|
-
const fn = functions.find((f) => f.name === id);
|
|
212
|
-
if (!fn) {
|
|
213
|
-
return yield* Effect2.fail(new AiToolNotFoundError(id));
|
|
214
|
-
}
|
|
215
|
-
return projectFunctionToTool(fn);
|
|
216
|
-
})
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
var makeToolExecutionServiceFromFunctions = (functions, toolkit, handlersLayer) => {
|
|
220
|
-
return Layer.effect(ToolExecutionService, Effect2.gen(function* () {
|
|
221
|
-
const toolkitHandler = yield* toolkit.pipe(Effect2.provide(handlersLayer));
|
|
222
|
-
const localFunctionExecutionService = yield* LocalFunctionExecutionService;
|
|
223
|
-
return {
|
|
224
|
-
handlersFor: (toolkit2) => {
|
|
225
|
-
const makeHandler = (tool) => {
|
|
226
|
-
return Effect2.fn("toolFunctionHandler")(function* (input) {
|
|
227
|
-
if (toolkitHandler.tools.find((t) => t.name === tool.name)) {
|
|
228
|
-
return yield* toolkitHandler.handle(tool.name, input);
|
|
229
|
-
}
|
|
230
|
-
const { functionName } = Context.get(FunctionToolAnnotation)(tool.annotations);
|
|
231
|
-
const fnDef = functions.find((f) => f.name === functionName);
|
|
232
|
-
if (!fnDef) {
|
|
233
|
-
return yield* Effect2.fail(new AiToolNotFoundError(tool.name));
|
|
234
|
-
}
|
|
235
|
-
return yield* localFunctionExecutionService.invokeFunction(fnDef, input).pipe(Effect2.catchAllDefect((defect) => Effect2.fail(defect)));
|
|
236
|
-
});
|
|
237
|
-
};
|
|
238
|
-
return toolkit2.of(Record.map(toolkit2.tools, (tool, _name) => makeHandler(tool)));
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
}));
|
|
242
|
-
};
|
|
243
|
-
var FunctionToolAnnotation = class extends Context.Tag("@dxos/assisatnt/FunctionToolAnnotation")() {
|
|
244
|
-
};
|
|
245
|
-
var toolCache = /* @__PURE__ */ new WeakMap();
|
|
246
|
-
var projectFunctionToTool = (fn) => {
|
|
247
|
-
if (toolCache.has(fn)) {
|
|
248
|
-
return toolCache.get(fn);
|
|
249
|
-
}
|
|
250
|
-
const tool = AiTool.make(makeToolName(fn.name), {
|
|
251
|
-
description: fn.description,
|
|
252
|
-
parameters: createStructFieldsFromSchema(fn.inputSchema),
|
|
253
|
-
// TODO(dmaretskyi): Include output schema.
|
|
254
|
-
failure: Schema2.Any
|
|
255
|
-
}).annotate(FunctionToolAnnotation, {
|
|
256
|
-
functionName: fn.name
|
|
257
|
-
});
|
|
258
|
-
toolCache.set(fn, tool);
|
|
259
|
-
return tool;
|
|
260
|
-
};
|
|
261
|
-
var makeToolName = (name) => {
|
|
262
|
-
const toolName = name.replace(/[^a-zA-Z0-9]/g, "_");
|
|
263
|
-
invariant(toolName.match(/^[a-zA-Z_][a-zA-Z0-9-_]*$/), void 0, {
|
|
264
|
-
F: __dxlog_file2,
|
|
265
|
-
L: 102,
|
|
266
|
-
S: void 0,
|
|
267
|
-
A: [
|
|
268
|
-
"toolName.match(/^[a-zA-Z_][a-zA-Z0-9-_]*$/)",
|
|
269
|
-
""
|
|
270
|
-
]
|
|
271
|
-
});
|
|
272
|
-
return toolName;
|
|
273
|
-
};
|
|
274
|
-
var createStructFieldsFromSchema = (schema) => {
|
|
275
|
-
return Match.value(schema.ast).pipe(Match.when(Predicate.isTagged("TypeLiteral"), (ast) => {
|
|
276
|
-
return Object.fromEntries(ast.propertySignatures.map((prop) => [
|
|
277
|
-
prop.name,
|
|
278
|
-
Schema2.make(prop.type)
|
|
279
|
-
]));
|
|
280
|
-
}), Match.orElseAbsurd);
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
// src/templates/system.ts
|
|
284
|
-
import { Template } from "@dxos/blueprints";
|
|
285
|
-
|
|
286
|
-
// raw-loader:./format.tpl?raw
|
|
287
|
-
var format_default = "{{! System Core }}\n\n## Input Formats\n\n### Blueprints\n\nYou may be provided with Blueprint definitions that include specific instructions and tools for a given set of tasks.\nBlue print instructions will be enclosed in a <blueprint> tag.\n\n### Context objects\n\nYou may be provided with references to objects that are relevant to the current prompt.\nObjects will be in the form of a <object> tag with a <dxn> element that is the unique key of the object required by many tools.\nThe <typename> element is the type of the object.\n\n<object>\n <dxn>object-id</dxn>\n <typename>example.com/type/TypeName</typename>\n</object>\n\n## Response Formats\n\nIt is very important to respond in the correct format.\nYou response must be valid Markdown.\nIn some cases you should respond with well-formed XML tags along with the content.\n\n{{#if cot}}\nBefore responding, explain your reasoning and include your detailed chain-of-thought enclosed in a <cot> tag.\nThe <cot> tag should be the first thing in your response.\n{{/if}}\n\n## Block references\n\nYou can reply with a block reference for objects if you have the DXN. For example:\n\n<object>\n <dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK464FSCKVQJAB2H662M</dxn>\n</object>\n<object>\n <dxn>dxn:echo:@:01K24XPK464FSCKVQJAB2H662M</dxn>\n</object>\n\n### Suggestions\n\nEach suggestion must in the form of a proposed action enclosed in a <suggest> tag.\nExample: <suggest>Show on a map</suggest>\n\n### Multiple choice questions\n\nYou may ask multiple choice questions by wrapping consise options inside <option> tags inside a well formed <select> tag.\nExample: <select><option>Yes</option><option>No</option></select>\n\n## Toolkit\n\nIf the user asks for a list of tools, then just emit a single self-closing <toolkit/> tag instead of listing the tools.\n";
|
|
288
|
-
|
|
289
|
-
// raw-loader:./system.tpl?raw
|
|
290
|
-
var system_default = "{{! System Prompt }}\n\nYou are a helpful assistant called Kai. \nYour name is Kai and you are powered by different language models.\nYou were created by DXOS and operate in Composer and on the DXOS EDGE network.\nIn your initial greeting state your name and make some suggestions based on the current context objects.\n\nYou are an advanced AI assistant capable of creating and managing artifacts from provided data and tools.\nYour task is to process user commands and questions and decide how best to respond.\nIn general be concise and direct.\n\nFollow these guidelines carefully:\n\nInclude the following steps:\n\n- Analyze the structure and type of the content in the user's message.\n- Determine if you complete the task using the available blueprint definitions?\n- If you can't complete the task using the available blueprint definitions, query the list of available blueprint definitions using the appropriate tool.\n- Identify which blueprint definitions are relevant to the user's request.\n- Evaluate the potential benefits of creating an artifact vs. normal processing for each identified element.\n- Make a final decision on whether to create an artifact and explain your reasoning.\n- Are the required blueprint definitions already available?\n- If not, select which blueprint definition(s) will be the most relevant and require them using the require_artifact_definitions tool.\n- The require'd artifact tools will be available for use after require.\n- If creating an artifact, outline how you will structure it within the response.\n- Decide if the artifact needs to be shown to the user.\n- Call the show tool to show the artifact to the user.\n- Your reasoning must include: whether to use artifacts or not, to create one or query, whether to show the artifact to the user, and how to structure the response.\n\n# Blueprints\n\n- Determine if the interaction involves an artifact. Prefer artifacts for tables, lists, spreadsheets, kanbans, games, images, and other structured data.\n- Determine if the user is explicitly talking about creating a new artifact, or wants to use an existing artifact.\n- If it is ambiguous, query for existing artifacts first and then decide.\n- If you decide to create an artifact, call the associated tool to create the artifact.\n- Artifacts are stored in the database. Tools are used to create and query artifacts.\n- If you are unsure about creating an artifact ask the user for clarification.\n\n- Artifacts are mutable objects that can change over the course of the conversation.\n- Always re-query the artifact using the tool (like query or inspect) to get the latest state of the artifact before answering the user.\n- You must never generate the id of the artifact; only recall the ids that are already in the history.\n- Artifacts are created by requiring the specific artifact using the require_artifact tool and creating it by calling the associated tool.\n\n- You can add suggested actions at the end of your response.\n- Suggested actions should be very concise and start with a verb and be phrased as a command to an agent -- not a question to the user.\n- Suggested actions must be in the form of a user instruction that you can follow.\n- Suggested actions could include actions that create artifacts.\n";
|
|
291
|
-
|
|
292
|
-
// src/templates/system.ts
|
|
293
|
-
var createSystemPrompt = (options) => Template.process(format_default, options);
|
|
294
|
-
var templates = {
|
|
295
|
-
// Editable system prompt.
|
|
296
|
-
system: Template.make({
|
|
297
|
-
source: system_default
|
|
298
|
-
})
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
// src/types.ts
|
|
302
|
-
import { Schema as Schema3 } from "effect";
|
|
303
|
-
import { DXN, LOCAL_SPACE_TAG } from "@dxos/keys";
|
|
304
|
-
import { trim } from "@dxos/util";
|
|
305
|
-
var createArtifactElement = (id) => `<artifact id=${id} />`;
|
|
306
|
-
var ArtifactId = class extends Schema3.String.annotations({
|
|
307
|
-
description: trim`
|
|
308
|
-
The ID of the referenced object. Formats accepted:
|
|
309
|
-
- DXN (dxn:echo:@:XXXXX). DXNs can be prepended with an @ symbol for compatibility with in-text references.
|
|
310
|
-
- space ID, object ID tuple (spaceID:objectID)
|
|
311
|
-
- Only object ID that is assumed to be in the current space (XXXXX)
|
|
312
|
-
`,
|
|
313
|
-
examples: [
|
|
314
|
-
"dxn:echo:@:XXXXX",
|
|
315
|
-
"@dxn:echo:@:XXXXX",
|
|
316
|
-
"spaceID:objectID",
|
|
317
|
-
"XXXXX"
|
|
318
|
-
]
|
|
319
|
-
}) {
|
|
320
|
-
static toDXN(reference, owningSpaceId) {
|
|
321
|
-
if (reference.startsWith("@dxn:")) {
|
|
322
|
-
return DXN.parse(reference.slice(1));
|
|
323
|
-
} else if (reference.startsWith("dxn:")) {
|
|
324
|
-
return DXN.parse(reference);
|
|
325
|
-
} else if (/^[A-Z0-9]+:[A-Z0-9]+$/.test(reference)) {
|
|
326
|
-
const [spaceId, objectId] = reference.split(":");
|
|
327
|
-
return new DXN(DXN.kind.ECHO, [
|
|
328
|
-
spaceId === owningSpaceId ? LOCAL_SPACE_TAG : spaceId,
|
|
329
|
-
objectId
|
|
330
|
-
]);
|
|
331
|
-
} else if (/^[A-Z0-9]+$/.test(reference)) {
|
|
332
|
-
return DXN.fromLocalObjectId(reference);
|
|
333
|
-
} else {
|
|
334
|
-
throw new Error(`Unable to parse object reference: ${reference}`);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
export {
|
|
339
|
-
AiAssistantError,
|
|
340
|
-
AiContextBinder,
|
|
341
|
-
AiConversation,
|
|
342
|
-
AiSession,
|
|
343
|
-
ArtifactDiffResolver,
|
|
344
|
-
ArtifactId,
|
|
345
|
-
Bindings,
|
|
346
|
-
ContextBinding,
|
|
347
|
-
GenerationObserver,
|
|
348
|
-
VersionPin,
|
|
349
|
-
createArtifactElement,
|
|
350
|
-
createSystemPrompt,
|
|
351
|
-
makeToolExecutionServiceFromFunctions,
|
|
352
|
-
makeToolResolverFromFunctions,
|
|
353
|
-
templates
|
|
354
|
-
};
|
|
355
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/conversation/context.ts", "../../../src/conversation/conversation.ts", "../../../src/functions/services.ts", "../../../src/templates/system.ts", "raw-loader:./format.tpl?raw", "raw-loader:./system.tpl?raw", "../../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ReadonlySignal, computed } from '@preact/signals-core';\nimport { Schema } from 'effect';\nimport { Array, pipe } from 'effect';\n\nimport { Blueprint } from '@dxos/blueprints';\nimport { Obj, type Ref, type Relation, Type } from '@dxos/echo';\nimport { type Queue } from '@dxos/echo-db';\nimport { ComplexSet } from '@dxos/util';\n\n/**\n * Thread message that binds or unbinds contextual objects to a conversation.\n */\n// TODO(burdon): Move to @dxos/schema ContentBlock.\nexport const ContextBinding = Schema.Struct({\n blueprints: Schema.Struct({\n added: Schema.Array(Type.Ref(Blueprint.Blueprint)),\n removed: Schema.Array(Type.Ref(Blueprint.Blueprint)),\n }),\n\n // TODO(burdon): Type.Expando => Type.Obj (or Obj.Any?)\n objects: Schema.Struct({\n added: Schema.Array(Type.Ref(Type.Expando)),\n removed: Schema.Array(Type.Ref(Type.Expando)),\n }),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/ContextBinding',\n version: '0.1.0',\n }),\n);\n\nexport interface ContextBinding extends Schema.Schema.Type<typeof ContextBinding> {}\n\nexport type BindingProps = Partial<{\n blueprints: Ref.Ref<Blueprint.Blueprint>[];\n objects: Ref.Ref<Type.Expando>[];\n}>;\n\nexport class Bindings {\n readonly blueprints = new ComplexSet<Ref.Ref<Blueprint.Blueprint>>((ref) => ref.dxn.toString());\n readonly objects = new ComplexSet<Ref.Ref<Type.Expando>>((ref) => ref.dxn.toString());\n\n toJSON() {\n return {\n blueprints: Array.fromIterable(this.blueprints).map((ref) => ref.dxn.toString()),\n objects: Array.fromIterable(this.objects).map((ref) => ref.dxn.toString()),\n };\n }\n}\n\n/**\n * Manages bindings of blueprints and objects to a conversation.\n */\nexport class AiContextBinder {\n /**\n * Reactive query of all bindings.\n */\n // TODO(burdon): Cache value?\n readonly bindings: ReadonlySignal<Bindings> = computed(() => this._reduce(this._queue.objects));\n\n readonly blueprints: ReadonlySignal<Ref.Ref<Blueprint.Blueprint>[]> = computed(() => [\n ...this.bindings.value.blueprints,\n ]);\n\n readonly objects: ReadonlySignal<Ref.Ref<Type.Expando>[]> = computed(() => [...this.bindings.value.objects]);\n\n constructor(private readonly _queue: Queue) {}\n\n /**\n * Asynchronous query of all bindings.\n */\n async query(): Promise<Bindings> {\n const queueItems = await this._queue.queryObjects();\n return this._reduce(queueItems);\n }\n\n // TODO(burdon): Pass in Blueprint obj (from registry?) and create reference.\n async bind(props: BindingProps): Promise<void> {\n if (!props.blueprints?.length && !props.objects?.length) {\n return;\n }\n\n await this._queue.append([\n Obj.make(ContextBinding, {\n blueprints: {\n added: props.blueprints ?? [],\n removed: [],\n },\n objects: {\n added: props.objects ?? [],\n removed: [],\n },\n }),\n ]);\n }\n\n async unbind(props: BindingProps): Promise<void> {\n if (!props.blueprints?.length && !props.objects?.length) {\n return;\n }\n\n await this._queue.append([\n Obj.make(ContextBinding, {\n blueprints: {\n added: [],\n removed: props.blueprints ?? [],\n },\n objects: {\n added: [],\n removed: props.objects ?? [],\n },\n }),\n ]);\n }\n\n private _reduce(items: (Obj.Any | Relation.Any)[]): Bindings {\n return pipe(\n items,\n Array.filter(Obj.instanceOf(ContextBinding)),\n Array.reduce(new Bindings(), (context, item) => {\n item.blueprints.removed.forEach((item) => context.blueprints.delete(item));\n item.blueprints.added.forEach((item) => context.blueprints.add(item));\n item.objects.removed.forEach((item) => context.objects.delete(item));\n item.objects.added.forEach((item) => context.objects.add(item));\n return context;\n }),\n );\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type AiError, type AiLanguageModel, type AiTool, type AiToolkit } from '@effect/ai';\nimport { Effect } from 'effect';\n\nimport {\n type AiInputPreprocessingError,\n type AiToolNotFoundError,\n type ToolExecutionService,\n type ToolResolverService,\n} from '@dxos/ai';\nimport { Event } from '@dxos/async';\nimport { Obj } from '@dxos/echo';\nimport { type Queue } from '@dxos/echo-db';\nimport { DatabaseService } from '@dxos/functions';\nimport { log } from '@dxos/log';\nimport { DataType } from '@dxos/schema';\n\nimport { type AiAssistantError } from '../errors';\nimport { AiSession, type GenerationObserver } from '../session';\n\nimport { AiContextBinder, type ContextBinding } from './context';\n\nexport interface AiConversationRunParams<Tools extends AiTool.Any> {\n prompt: string;\n system?: string;\n toolkit?: AiToolkit.AiToolkit<Tools>;\n observer?: GenerationObserver;\n\n /**\n * @deprecated Remove\n */\n session?: AiSession;\n}\n\nexport type AiConversationOptions = {\n queue: Queue<DataType.Message | ContextBinding>;\n};\n\n/**\n * Persistent conversation state.\n * Context + history + artifacts.\n * Backed by a Queue.\n */\nexport class AiConversation {\n private readonly _queue: Queue<DataType.Message | ContextBinding>;\n\n /**\n * Blueprints bound to the conversation.\n */\n public readonly _context: AiContextBinder;\n\n /**\n * Fired when the execution loop begins.\n * This is called before the first message is sent.\n *\n * @deprecated Pass in a session instead.\n */\n // TODO(burdon): Is this still deprecated?\n public readonly onBegin = new Event<AiSession>();\n\n constructor(options: AiConversationOptions) {\n this._queue = options.queue;\n this._context = new AiContextBinder(this._queue);\n }\n\n get context() {\n return this._context;\n }\n\n async getHistory(): Promise<DataType.Message[]> {\n const queueItems = await this._queue.queryObjects();\n return queueItems.filter(Obj.instanceOf(DataType.Message));\n }\n\n /**\n * Executes a prompt.\n * Each invocation creates a new `AiSession`, which handles potential tool calls.\n */\n run = <Tools extends AiTool.Any>({\n // TODO(burdon): Decide whether to pass in or to fully encapsulate.\n session = new AiSession(),\n ...params\n }: AiConversationRunParams<Tools>): Effect.Effect<\n DataType.Message[],\n AiAssistantError | AiInputPreprocessingError | AiError.AiError | AiToolNotFoundError,\n AiLanguageModel.AiLanguageModel | ToolResolverService | ToolExecutionService | AiTool.ToHandler<Tools>\n > =>\n Effect.gen(this, function* () {\n const history = yield* Effect.promise(() => this.getHistory());\n const context = yield* Effect.promise(() => this.context.query());\n const blueprints = yield* Effect.forEach(context.blueprints.values(), DatabaseService.load);\n\n // TODO(burdon): These don't need to be loaded; just need id and typename from context.\n const objects = yield* Effect.forEach(context.objects.values(), DatabaseService.load);\n\n log.info('run', {\n prompt: params.prompt,\n system: params.system,\n history: history.length,\n objects: objects.length,\n blueprints: blueprints.length,\n toolkit: params.toolkit,\n });\n\n const start = Date.now();\n this.onBegin.emit(session);\n\n const messages = yield* session.run({\n prompt: params.prompt,\n system: params.system,\n history,\n objects,\n blueprints,\n toolkit: params.toolkit,\n observer: params.observer,\n });\n\n log.info('result', { messages: messages, duration: Date.now() - start });\n yield* Effect.promise(() => this._queue.append(messages));\n return messages;\n }).pipe(Effect.withSpan('AiConversation.run'));\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { AiTool, type AiToolkit } from '@effect/ai';\nimport { Context, Effect, Layer, Match, Predicate, Record, Schema } from 'effect';\n\nimport { AiToolNotFoundError, ToolExecutionService, ToolResolverService } from '@dxos/ai';\nimport { type FunctionDefinition, LocalFunctionExecutionService } from '@dxos/functions';\nimport { invariant } from '@dxos/invariant';\n\nexport const makeToolResolverFromFunctions = (\n functions: FunctionDefinition<any, any>[],\n toolkit: AiToolkit.Any,\n): Layer.Layer<ToolResolverService> => {\n return Layer.succeed(ToolResolverService, {\n resolve: Effect.fn('resolveTool')(function* (id) {\n const tool = toolkit.tools[id];\n if (tool) {\n return tool;\n }\n\n const fn = functions.find((f) => f.name === id);\n if (!fn) {\n return yield* Effect.fail(new AiToolNotFoundError(id));\n }\n\n return projectFunctionToTool(fn);\n }),\n });\n};\n\nexport const makeToolExecutionServiceFromFunctions = (\n functions: FunctionDefinition<any, any>[],\n toolkit: AiToolkit.AiToolkit<AiTool.Any>,\n handlersLayer: Layer.Layer<AiTool.ToHandler<AiTool.AiTool<any>>, never, never>,\n): Layer.Layer<ToolExecutionService, never, LocalFunctionExecutionService> => {\n return Layer.effect(\n ToolExecutionService,\n Effect.gen(function* () {\n const toolkitHandler = yield* toolkit.pipe(Effect.provide(handlersLayer));\n\n const localFunctionExecutionService = yield* LocalFunctionExecutionService;\n return {\n handlersFor: (toolkit) => {\n const makeHandler = (tool: AiTool.Any): ((params: unknown) => Effect.Effect<unknown, any, any>) => {\n return Effect.fn('toolFunctionHandler')(function* (input: any) {\n if (toolkitHandler.tools.find((t: AiTool.Any) => t.name === tool.name)) {\n // TODO(wittjosiah): Everything is `never` here.\n return yield* (toolkitHandler.handle as any)(tool.name, input);\n }\n\n const { functionName } = Context.get(FunctionToolAnnotation)(tool.annotations as any);\n const fnDef = functions.find((f) => f.name === functionName);\n if (!fnDef) {\n return yield* Effect.fail(new AiToolNotFoundError(tool.name));\n }\n\n return yield* localFunctionExecutionService\n .invokeFunction(fnDef, input)\n .pipe(Effect.catchAllDefect((defect) => Effect.fail(defect)));\n });\n };\n\n return toolkit.of(Record.map(toolkit.tools, (tool, _name) => makeHandler(tool)) as any) as any;\n },\n };\n }),\n );\n};\n\n/**\n * Tools that are projected from functions have this annotation.\n */\nclass FunctionToolAnnotation extends Context.Tag('@dxos/assisatnt/FunctionToolAnnotation')<\n FunctionToolAnnotation,\n {\n functionName: string;\n }\n>() {}\n\nconst toolCache = new WeakMap<FunctionDefinition<any, any>, AiTool.Any>();\nconst projectFunctionToTool = (fn: FunctionDefinition<any, any>): AiTool.Any => {\n if (toolCache.has(fn)) {\n return toolCache.get(fn)!;\n }\n const tool = AiTool.make(makeToolName(fn.name), {\n description: fn.description,\n parameters: createStructFieldsFromSchema(fn.inputSchema),\n // TODO(dmaretskyi): Include output schema.\n failure: Schema.Any, // TODO(dmaretskyi): Better type for the failure?\n }).annotate(FunctionToolAnnotation, { functionName: fn.name });\n toolCache.set(fn, tool);\n return tool;\n};\n\n/**\n * @returns Tool name produced from function name by escaping invalid characters.\n */\nconst makeToolName = (name: string) => {\n const toolName = name.replace(/[^a-zA-Z0-9]/g, '_');\n invariant(toolName.match(/^[a-zA-Z_][a-zA-Z0-9-_]*$/));\n return toolName;\n};\n\n// TODO(dmaretskyi): Factor out.\nconst createStructFieldsFromSchema = (schema: Schema.Schema<any, any>): Record<string, Schema.Schema<any, any>> => {\n return Match.value(schema.ast).pipe(\n Match.when(Predicate.isTagged('TypeLiteral'), (ast) => {\n return Object.fromEntries(ast.propertySignatures.map((prop) => [prop.name, Schema.make(prop.type)]));\n }),\n Match.orElseAbsurd,\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Template } from '@dxos/blueprints';\n\nimport FORMAT from './format.tpl?raw';\nimport SYSTEM from './system.tpl?raw';\n\ntype PromptOptions = {\n /**\n * Emit chain-of-thought inside <cot> tag.\n * Should be `false` for models with built-in reasoning: Claude, deepseek, o1.\n */\n cot?: boolean;\n\n /**\n * Whether to include suggestions in the prompt.\n */\n suggestions?: boolean;\n};\n\n/**\n * Base system prompt.\n * NOTE: This contains protocol instructions that can not be dynamically edited.\n */\nexport const createSystemPrompt = (options: PromptOptions) => Template.process<PromptOptions>(FORMAT, options);\n\nexport const templates = {\n // Editable system prompt.\n system: Template.make({ source: SYSTEM }),\n};\n", "{{! System Core }}\n\n## Input Formats\n\n### Blueprints\n\nYou may be provided with Blueprint definitions that include specific instructions and tools for a given set of tasks.\nBlue print instructions will be enclosed in a <blueprint> tag.\n\n### Context objects\n\nYou may be provided with references to objects that are relevant to the current prompt.\nObjects will be in the form of a <object> tag with a <dxn> element that is the unique key of the object required by many tools.\nThe <typename> element is the type of the object.\n\n<object>\n <dxn>object-id</dxn>\n <typename>example.com/type/TypeName</typename>\n</object>\n\n## Response Formats\n\nIt is very important to respond in the correct format.\nYou response must be valid Markdown.\nIn some cases you should respond with well-formed XML tags along with the content.\n\n{{#if cot}}\nBefore responding, explain your reasoning and include your detailed chain-of-thought enclosed in a <cot> tag.\nThe <cot> tag should be the first thing in your response.\n{{/if}}\n\n## Block references\n\nYou can reply with a block reference for objects if you have the DXN. For example:\n\n<object>\n <dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK464FSCKVQJAB2H662M</dxn>\n</object>\n<object>\n <dxn>dxn:echo:@:01K24XPK464FSCKVQJAB2H662M</dxn>\n</object>\n\n### Suggestions\n\nEach suggestion must in the form of a proposed action enclosed in a <suggest> tag.\nExample: <suggest>Show on a map</suggest>\n\n### Multiple choice questions\n\nYou may ask multiple choice questions by wrapping consise options inside <option> tags inside a well formed <select> tag.\nExample: <select><option>Yes</option><option>No</option></select>\n\n## Toolkit\n\nIf the user asks for a list of tools, then just emit a single self-closing <toolkit/> tag instead of listing the tools.\n", "{{! System Prompt }}\n\nYou are a helpful assistant called Kai. \nYour name is Kai and you are powered by different language models.\nYou were created by DXOS and operate in Composer and on the DXOS EDGE network.\nIn your initial greeting state your name and make some suggestions based on the current context objects.\n\nYou are an advanced AI assistant capable of creating and managing artifacts from provided data and tools.\nYour task is to process user commands and questions and decide how best to respond.\nIn general be concise and direct.\n\nFollow these guidelines carefully:\n\nInclude the following steps:\n\n- Analyze the structure and type of the content in the user's message.\n- Determine if you complete the task using the available blueprint definitions?\n- If you can't complete the task using the available blueprint definitions, query the list of available blueprint definitions using the appropriate tool.\n- Identify which blueprint definitions are relevant to the user's request.\n- Evaluate the potential benefits of creating an artifact vs. normal processing for each identified element.\n- Make a final decision on whether to create an artifact and explain your reasoning.\n- Are the required blueprint definitions already available?\n- If not, select which blueprint definition(s) will be the most relevant and require them using the require_artifact_definitions tool.\n- The require'd artifact tools will be available for use after require.\n- If creating an artifact, outline how you will structure it within the response.\n- Decide if the artifact needs to be shown to the user.\n- Call the show tool to show the artifact to the user.\n- Your reasoning must include: whether to use artifacts or not, to create one or query, whether to show the artifact to the user, and how to structure the response.\n\n# Blueprints\n\n- Determine if the interaction involves an artifact. Prefer artifacts for tables, lists, spreadsheets, kanbans, games, images, and other structured data.\n- Determine if the user is explicitly talking about creating a new artifact, or wants to use an existing artifact.\n- If it is ambiguous, query for existing artifacts first and then decide.\n- If you decide to create an artifact, call the associated tool to create the artifact.\n- Artifacts are stored in the database. Tools are used to create and query artifacts.\n- If you are unsure about creating an artifact ask the user for clarification.\n\n- Artifacts are mutable objects that can change over the course of the conversation.\n- Always re-query the artifact using the tool (like query or inspect) to get the latest state of the artifact before answering the user.\n- You must never generate the id of the artifact; only recall the ids that are already in the history.\n- Artifacts are created by requiring the specific artifact using the require_artifact tool and creating it by calling the associated tool.\n\n- You can add suggested actions at the end of your response.\n- Suggested actions should be very concise and start with a verb and be phrased as a command to an agent -- not a question to the user.\n- Suggested actions must be in the form of a user instruction that you can follow.\n- Suggested actions could include actions that create artifacts.\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { type ObjectId } from '@dxos/echo-schema';\nimport { DXN, LOCAL_SPACE_TAG, type SpaceId } from '@dxos/keys';\nimport { trim } from '@dxos/util';\n\n/**\n * @deprecated\n */\nexport const createArtifactElement = (id: ObjectId) => `<artifact id=${id} />`;\n\n/**\n * A model-friendly way to reference an object.\n * Supports vairous formats that will be normalized to a DXN.\n */\n// TODO(burdon): Rename ObjectReference?\nexport const ArtifactId: Schema.Schema<string> & {\n toDXN: (reference: ArtifactId, owningSpaceId?: SpaceId) => DXN;\n} = class extends Schema.String.annotations({\n description: trim`\n The ID of the referenced object. Formats accepted:\n - DXN (dxn:echo:@:XXXXX). DXNs can be prepended with an @ symbol for compatibility with in-text references.\n - space ID, object ID tuple (spaceID:objectID)\n - Only object ID that is assumed to be in the current space (XXXXX)\n `,\n examples: ['dxn:echo:@:XXXXX', '@dxn:echo:@:XXXXX', 'spaceID:objectID', 'XXXXX'],\n}) {\n static toDXN(reference: ArtifactId, owningSpaceId?: SpaceId): DXN {\n // Allow @dxn: prefix for compatibility with in-text references.\n if (reference.startsWith('@dxn:')) {\n return DXN.parse(reference.slice(1));\n } else if (reference.startsWith('dxn:')) {\n return DXN.parse(reference);\n } else if (/^[A-Z0-9]+:[A-Z0-9]+$/.test(reference)) {\n const [spaceId, objectId] = reference.split(':');\n // This is a workaround because the current Filter API doesn't work with fully qualified Echo DXNs.\n // We check if the space ID is the same as the owning space and then use LOCAL_SPACE_TAG for local references.\n // TODO(dmaretskyi): Fix this in the Echo and Filter API to properly handle fully qualified DXNs.\n return new DXN(DXN.kind.ECHO, [spaceId === owningSpaceId ? LOCAL_SPACE_TAG : spaceId, objectId]);\n } else if (/^[A-Z0-9]+$/.test(reference)) {\n return DXN.fromLocalObjectId(reference);\n } else {\n throw new Error(`Unable to parse object reference: ${reference}`);\n }\n }\n};\n\nexport type ArtifactId = Schema.Schema.Type<typeof ArtifactId>;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;AAIA,SAA8BA,gBAAgB;AAC9C,SAASC,cAAc;AACvB,SAASC,OAAOC,YAAY;AAE5B,SAASC,iBAAiB;AAC1B,SAASC,KAA8BC,YAAY;AAEnD,SAASC,kBAAkB;AAMpB,IAAMC,iBAAiBC,OAAOC,OAAO;EAC1CC,YAAYF,OAAOC,OAAO;IACxBE,OAAOH,OAAOI,MAAMC,KAAKC,IAAIC,UAAUA,SAAS,CAAA;IAChDC,SAASR,OAAOI,MAAMC,KAAKC,IAAIC,UAAUA,SAAS,CAAA;EACpD,CAAA;;EAGAE,SAAST,OAAOC,OAAO;IACrBE,OAAOH,OAAOI,MAAMC,KAAKC,IAAID,KAAKK,OAAO,CAAA;IACzCF,SAASR,OAAOI,MAAMC,KAAKC,IAAID,KAAKK,OAAO,CAAA;EAC7C,CAAA;AACF,CAAA,EAAGC,KACDN,KAAKO,IAAI;EACPC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;AAUK,IAAMC,WAAN,MAAMA;EACFb,aAAa,IAAIc,WAAyC,CAACC,QAAQA,IAAIC,IAAIC,SAAQ,CAAA;EACnFV,UAAU,IAAIO,WAAkC,CAACC,QAAQA,IAAIC,IAAIC,SAAQ,CAAA;EAElFC,SAAS;AACP,WAAO;MACLlB,YAAYE,MAAMiB,aAAa,KAAKnB,UAAU,EAAEoB,IAAI,CAACL,QAAQA,IAAIC,IAAIC,SAAQ,CAAA;MAC7EV,SAASL,MAAMiB,aAAa,KAAKZ,OAAO,EAAEa,IAAI,CAACL,QAAQA,IAAIC,IAAIC,SAAQ,CAAA;IACzE;EACF;AACF;AAKO,IAAMI,kBAAN,MAAMA;;;;;;EAKFC;EAEAtB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,OAAiB,gBAAgBA,EAAAA;AAOhE,IAAMC,aAET,cAAcC,QAAOC,OAAOC,YAAY;EAC1CC,aAAaC;;;;;;EAMbC,UAAU;IAAC;IAAoB;IAAqB;IAAoB;;AAC1E,CAAA,EAAA;EACE,OAAOC,MAAMC,WAAuBC,eAA8B;AAEhE,QAAID,UAAUE,WAAW,OAAA,GAAU;AACjC,aAAOC,IAAIC,MAAMJ,UAAUK,MAAM,CAAA,CAAA;IACnC,WAAWL,UAAUE,WAAW,MAAA,GAAS;AACvC,aAAOC,IAAIC,MAAMJ,SAAAA;IACnB,WAAW,wBAAwBM,KAAKN,SAAAA,GAAY;AAClD,YAAM,CAACO,SAASC,QAAAA,IAAYR,UAAUS,MAAM,GAAA;AAI5C,aAAO,IAAIN,IAAIA,IAAIO,KAAKC,MAAM;QAACJ,YAAYN,gBAAgBW,kBAAkBL;QAASC;OAAS;IACjG,WAAW,cAAcF,KAAKN,SAAAA,GAAY;AACxC,aAAOG,IAAIU,kBAAkBb,SAAAA;IAC/B,OAAO;AACL,YAAM,IAAIc,MAAM,qCAAqCd,SAAAA,EAAW;IAClE;EACF;AACF;",
|
|
6
|
-
"names": ["computed", "Schema", "Array", "pipe", "Blueprint", "Obj", "Type", "ComplexSet", "ContextBinding", "Schema", "Struct", "blueprints", "added", "Array", "Type", "Ref", "Blueprint", "removed", "objects", "Expando", "pipe", "Obj", "typename", "version", "Bindings", "ComplexSet", "ref", "dxn", "toString", "toJSON", "fromIterable", "map", "AiContextBinder", "bindings", "_queue", "computed", "_reduce", "value", "query", "queueItems", "queryObjects", "bind", "props", "length", "append", "make", "unbind", "items", "filter", "instanceOf", "reduce", "context", "item", "forEach", "delete", "add", "Effect", "Event", "Obj", "DatabaseService", "log", "DataType", "AiConversation", "_queue", "_context", "onBegin", "Event", "options", "queue", "AiContextBinder", "context", "getHistory", "queueItems", "queryObjects", "filter", "Obj", "instanceOf", "DataType", "Message", "run", "session", "AiSession", "params", "Effect", "gen", "history", "promise", "query", "blueprints", "forEach", "values", "DatabaseService", "load", "objects", "log", "info", "prompt", "system", "length", "toolkit", "start", "Date", "now", "emit", "messages", "observer", "duration", "append", "pipe", "withSpan", "AiTool", "Context", "Effect", "Layer", "Match", "Predicate", "Record", "Schema", "AiToolNotFoundError", "ToolExecutionService", "ToolResolverService", "LocalFunctionExecutionService", "invariant", "makeToolResolverFromFunctions", "functions", "toolkit", "succeed", "resolve", "fn", "id", "tool", "tools", "find", "f", "name", "fail", "projectFunctionToTool", "makeToolExecutionServiceFromFunctions", "handlersLayer", "effect", "gen", "toolkitHandler", "pipe", "provide", "localFunctionExecutionService", "handlersFor", "makeHandler", "input", "t", "handle", "functionName", "get", "FunctionToolAnnotation", "annotations", "fnDef", "invokeFunction", "catchAllDefect", "defect", "of", "map", "_name", "Tag", "toolCache", "WeakMap", "has", "make", "makeToolName", "description", "parameters", "createStructFieldsFromSchema", "inputSchema", "failure", "Any", "annotate", "set", "toolName", "replace", "match", "schema", "value", "ast", "when", "isTagged", "Object", "fromEntries", "propertySignatures", "prop", "type", "orElseAbsurd", "Template", "createSystemPrompt", "options", "Template", "process", "FORMAT", "templates", "system", "make", "source", "SYSTEM", "Schema", "DXN", "LOCAL_SPACE_TAG", "trim", "createArtifactElement", "id", "ArtifactId", "Schema", "String", "annotations", "description", "trim", "examples", "toDXN", "reference", "owningSpaceId", "startsWith", "DXN", "parse", "slice", "test", "spaceId", "objectId", "split", "kind", "ECHO", "LOCAL_SPACE_TAG", "fromLocalObjectId", "Error"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/conversation/context.ts":{"bytes":13488,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/session/artifact-diff.ts":{"bytes":2594,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/errors.ts":{"bytes":939,"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true}],"format":"esm"},"src/session/format.ts":{"bytes":16522,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"../errors"},{"path":"src/session/artifact-diff.ts","kind":"import-statement","original":"./artifact-diff"}],"format":"esm"},"src/session/session.ts":{"bytes":32915,"imports":[{"path":"@effect/ai","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/session/format.ts","kind":"import-statement","original":"./format"}],"format":"esm"},"src/session/version-pin.ts":{"bytes":4194,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"src/session/index.ts":{"bytes":657,"imports":[{"path":"src/session/artifact-diff.ts","kind":"import-statement","original":"./artifact-diff"},{"path":"src/session/session.ts","kind":"import-statement","original":"./session"},{"path":"src/session/version-pin.ts","kind":"import-statement","original":"./version-pin"}],"format":"esm"},"src/conversation/conversation.ts":{"bytes":11539,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/session/index.ts","kind":"import-statement","original":"../session"},{"path":"src/conversation/context.ts","kind":"import-statement","original":"./context"}],"format":"esm"},"src/conversation/index.ts":{"bytes":562,"imports":[{"path":"src/conversation/context.ts","kind":"import-statement","original":"./context"},{"path":"src/conversation/conversation.ts","kind":"import-statement","original":"./conversation"}],"format":"esm"},"src/functions/services.ts":{"bytes":14283,"imports":[{"path":"@effect/ai","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"src/functions/index.ts":{"bytes":460,"imports":[{"path":"src/functions/services.ts","kind":"import-statement","original":"./services"}],"format":"esm"},"raw-loader:./format.tpl?raw":{"bytes":1808,"imports":[]},"raw-loader:./system.tpl?raw":{"bytes":3227,"imports":[]},"src/templates/system.ts":{"bytes":2283,"imports":[{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"raw-loader:./format.tpl?raw","kind":"import-statement","original":"./format.tpl?raw"},{"path":"raw-loader:./system.tpl?raw","kind":"import-statement","original":"./system.tpl?raw"}],"format":"esm"},"src/templates/index.ts":{"bytes":458,"imports":[{"path":"src/templates/system.ts","kind":"import-statement","original":"./system"}],"format":"esm"},"src/types.ts":{"bytes":6867,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":894,"imports":[{"path":"src/conversation/index.ts","kind":"import-statement","original":"./conversation"},{"path":"src/functions/index.ts","kind":"import-statement","original":"./functions"},{"path":"src/session/index.ts","kind":"import-statement","original":"./session"},{"path":"src/templates/index.ts","kind":"import-statement","original":"./templates"},{"path":"src/types.ts","kind":"import-statement","original":"./types"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"}],"format":"esm"},"src/extraction/extraction.ts":{"bytes":6822,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"src/extraction/quotes.ts":{"bytes":7110,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"raw-loader:./instructions.tpl?raw":{"bytes":1318,"imports":[]},"src/extraction/extraction-llm-function/extraction-llm-function.ts":{"bytes":8710,"imports":[{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/session/index.ts","kind":"import-statement","original":"../../session"},{"path":"src/extraction/extraction.ts","kind":"import-statement","original":"../extraction"},{"path":"src/extraction/quotes.ts","kind":"import-statement","original":"../quotes"},{"path":"raw-loader:./instructions.tpl?raw","kind":"import-statement","original":"./instructions.tpl?raw"}],"format":"esm"},"src/extraction/extraction-llm-function/index.ts":{"bytes":524,"imports":[{"path":"src/extraction/extraction-llm-function/extraction-llm-function.ts","kind":"import-statement","original":"./extraction-llm-function"}],"format":"esm"},"src/extraction/extraction-ner-function/named-entity-recognition.ts":{"bytes":10059,"imports":[{"path":"@xenova/transformers","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/extraction/extraction-ner-function/extraction-ner-function.ts":{"bytes":9083,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/extraction/extraction.ts","kind":"import-statement","original":"../extraction"},{"path":"src/extraction/quotes.ts","kind":"import-statement","original":"../quotes"},{"path":"src/extraction/extraction-ner-function/named-entity-recognition.ts","kind":"dynamic-import","original":"./named-entity-recognition"}],"format":"esm"},"src/extraction/extraction-ner-function/index.ts":{"bytes":652,"imports":[{"path":"src/extraction/extraction-ner-function/extraction-ner-function.ts","kind":"import-statement","original":"./extraction-ner-function"},{"path":"src/extraction/extraction-ner-function/named-entity-recognition.ts","kind":"import-statement","original":"./named-entity-recognition"}],"format":"esm"},"src/extraction/index.ts":{"bytes":803,"imports":[{"path":"src/extraction/extraction.ts","kind":"import-statement","original":"./extraction"},{"path":"src/extraction/extraction-llm-function/index.ts","kind":"import-statement","original":"./extraction-llm-function"},{"path":"src/extraction/extraction-ner-function/index.ts","kind":"import-statement","original":"./extraction-ner-function"},{"path":"src/extraction/quotes.ts","kind":"import-statement","original":"./quotes"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":30109},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-XOOPGSGW.mjs","kind":"import-statement"},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@effect/ai","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["AiAssistantError","AiContextBinder","AiConversation","AiSession","ArtifactDiffResolver","ArtifactId","Bindings","ContextBinding","GenerationObserver","VersionPin","createArtifactElement","createSystemPrompt","makeToolExecutionServiceFromFunctions","makeToolResolverFromFunctions","templates"],"entryPoint":"src/index.ts","inputs":{"src/conversation/context.ts":{"bytesInOutput":2996},"src/conversation/index.ts":{"bytesInOutput":0},"src/conversation/conversation.ts":{"bytesInOutput":2477},"src/index.ts":{"bytesInOutput":0},"src/functions/services.ts":{"bytesInOutput":3281},"src/functions/index.ts":{"bytesInOutput":0},"src/templates/system.ts":{"bytesInOutput":234},"raw-loader:./format.tpl?raw":{"bytesInOutput":1888},"raw-loader:./system.tpl?raw":{"bytesInOutput":3299},"src/templates/index.ts":{"bytesInOutput":0},"src/types.ts":{"bytesInOutput":1321}},"bytes":16310},"dist/lib/node-esm/extraction/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17086},"dist/lib/node-esm/extraction/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-XOOPGSGW.mjs","kind":"import-statement"},{"path":"dist/lib/node-esm/chunk-3UU5V4FS.mjs","kind":"import-statement"},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"dist/lib/node-esm/named-entity-recognition-W4VMRCH6.mjs","kind":"dynamic-import"}],"exports":["ExtractionInput","ExtractionOutput","ReferencedQuotes","combineNerTokens","createTokenGroups","extractFullEntities","extractionAnthropicFn","extractionNerFn","findQuotes","getNer","insertReferences","processTranscriptMessage"],"entryPoint":"src/extraction/index.ts","inputs":{"src/extraction/extraction.ts":{"bytesInOutput":1370},"src/extraction/index.ts":{"bytesInOutput":0},"src/extraction/extraction-llm-function/extraction-llm-function.ts":{"bytesInOutput":1819},"src/extraction/quotes.ts":{"bytesInOutput":1673},"raw-loader:./instructions.tpl?raw":{"bytesInOutput":1376},"src/extraction/extraction-llm-function/index.ts":{"bytesInOutput":0},"src/extraction/extraction-ner-function/extraction-ner-function.ts":{"bytesInOutput":2729},"src/extraction/extraction-ner-function/index.ts":{"bytesInOutput":0}},"bytes":9821},"dist/lib/node-esm/chunk-XOOPGSGW.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":28433},"dist/lib/node-esm/chunk-XOOPGSGW.mjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@effect/ai","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["AiAssistantError","AiSession","ArtifactDiffResolver","GenerationObserver","VersionPin"],"inputs":{"src/session/artifact-diff.ts":{"bytesInOutput":134},"src/errors.ts":{"bytesInOutput":123},"src/session/session.ts":{"bytesInOutput":6467},"src/session/format.ts":{"bytesInOutput":3692},"src/session/version-pin.ts":{"bytesInOutput":731},"src/session/index.ts":{"bytesInOutput":0}},"bytes":11550},"dist/lib/node-esm/named-entity-recognition-W4VMRCH6.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/node-esm/named-entity-recognition-W4VMRCH6.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-3UU5V4FS.mjs","kind":"import-statement"}],"exports":["combineNerTokens","createTokenGroups","extractFullEntities","getNer"],"entryPoint":"src/extraction/extraction-ner-function/named-entity-recognition.ts","inputs":{},"bytes":353},"dist/lib/node-esm/chunk-3UU5V4FS.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5243},"dist/lib/node-esm/chunk-3UU5V4FS.mjs":{"imports":[{"path":"@xenova/transformers","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["combineNerTokens","createTokenGroups","extractFullEntities","getNer"],"inputs":{"src/extraction/extraction-ner-function/named-entity-recognition.ts":{"bytesInOutput":2265}},"bytes":2558}}}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
combineNerTokens,
|
|
4
|
-
createTokenGroups,
|
|
5
|
-
extractFullEntities,
|
|
6
|
-
getNer
|
|
7
|
-
} from "./chunk-3UU5V4FS.mjs";
|
|
8
|
-
export {
|
|
9
|
-
combineNerTokens,
|
|
10
|
-
createTokenGroups,
|
|
11
|
-
extractFullEntities,
|
|
12
|
-
getNer
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=named-entity-recognition-W4VMRCH6.mjs.map
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { type ReadonlySignal } from '@preact/signals-core';
|
|
2
|
-
import { Schema } from 'effect';
|
|
3
|
-
import { Blueprint } from '@dxos/blueprints';
|
|
4
|
-
import { type Ref, Type } from '@dxos/echo';
|
|
5
|
-
import { type Queue } from '@dxos/echo-db';
|
|
6
|
-
import { ComplexSet } from '@dxos/util';
|
|
7
|
-
/**
|
|
8
|
-
* Thread message that binds or unbinds contextual objects to a conversation.
|
|
9
|
-
*/
|
|
10
|
-
export declare const ContextBinding: Type.obj<Schema.Struct<{
|
|
11
|
-
blueprints: Schema.Struct<{
|
|
12
|
-
added: Schema.Array$<Type.ref<Type.obj<Schema.Struct<{
|
|
13
|
-
key: Schema.SchemaClass<string, string, never>;
|
|
14
|
-
name: Schema.SchemaClass<string, string, never>;
|
|
15
|
-
description: Schema.optional<typeof Schema.String>;
|
|
16
|
-
instructions: Schema.mutable<Schema.Struct<{
|
|
17
|
-
source: Schema.SchemaClass<import("@dxos/echo-schema").Ref<Type.OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
|
|
18
|
-
content: string;
|
|
19
|
-
}>, import("@dxos/echo-protocol").EncodedReference, never>;
|
|
20
|
-
inputs: Schema.optional<Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
21
|
-
name: typeof Schema.String;
|
|
22
|
-
kind: Schema.optional<Schema.Literal<["value", "pass-through", "retriever", "function", "query", "resolver", "context", "schema"]>>;
|
|
23
|
-
default: Schema.optional<typeof Schema.Any>;
|
|
24
|
-
}>>>>>;
|
|
25
|
-
}>>;
|
|
26
|
-
tools: Schema.Array$<Schema.brand<typeof Schema.String, "ToolId">>;
|
|
27
|
-
}>>>>;
|
|
28
|
-
removed: Schema.Array$<Type.ref<Type.obj<Schema.Struct<{
|
|
29
|
-
key: Schema.SchemaClass<string, string, never>;
|
|
30
|
-
name: Schema.SchemaClass<string, string, never>;
|
|
31
|
-
description: Schema.optional<typeof Schema.String>;
|
|
32
|
-
instructions: Schema.mutable<Schema.Struct<{
|
|
33
|
-
source: Schema.SchemaClass<import("@dxos/echo-schema").Ref<Type.OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
|
|
34
|
-
content: string;
|
|
35
|
-
}>, import("@dxos/echo-protocol").EncodedReference, never>;
|
|
36
|
-
inputs: Schema.optional<Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
37
|
-
name: typeof Schema.String;
|
|
38
|
-
kind: Schema.optional<Schema.Literal<["value", "pass-through", "retriever", "function", "query", "resolver", "context", "schema"]>>;
|
|
39
|
-
default: Schema.optional<typeof Schema.Any>;
|
|
40
|
-
}>>>>>;
|
|
41
|
-
}>>;
|
|
42
|
-
tools: Schema.Array$<Schema.brand<typeof Schema.String, "ToolId">>;
|
|
43
|
-
}>>>>;
|
|
44
|
-
}>;
|
|
45
|
-
objects: Schema.Struct<{
|
|
46
|
-
added: Schema.Array$<Type.ref<Schema.Schema<Type.Expando, {
|
|
47
|
-
[x: string]: any;
|
|
48
|
-
id: string;
|
|
49
|
-
}, never>>>;
|
|
50
|
-
removed: Schema.Array$<Type.ref<Schema.Schema<Type.Expando, {
|
|
51
|
-
[x: string]: any;
|
|
52
|
-
id: string;
|
|
53
|
-
}, never>>>;
|
|
54
|
-
}>;
|
|
55
|
-
}>>;
|
|
56
|
-
export interface ContextBinding extends Schema.Schema.Type<typeof ContextBinding> {
|
|
57
|
-
}
|
|
58
|
-
export type BindingProps = Partial<{
|
|
59
|
-
blueprints: Ref.Ref<Blueprint.Blueprint>[];
|
|
60
|
-
objects: Ref.Ref<Type.Expando>[];
|
|
61
|
-
}>;
|
|
62
|
-
export declare class Bindings {
|
|
63
|
-
readonly blueprints: ComplexSet<Ref.Ref<Blueprint.Blueprint>>;
|
|
64
|
-
readonly objects: ComplexSet<Ref.Ref<Type.Expando>>;
|
|
65
|
-
toJSON(): {
|
|
66
|
-
blueprints: Type.DXN.String[];
|
|
67
|
-
objects: Type.DXN.String[];
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Manages bindings of blueprints and objects to a conversation.
|
|
72
|
-
*/
|
|
73
|
-
export declare class AiContextBinder {
|
|
74
|
-
private readonly _queue;
|
|
75
|
-
/**
|
|
76
|
-
* Reactive query of all bindings.
|
|
77
|
-
*/
|
|
78
|
-
readonly bindings: ReadonlySignal<Bindings>;
|
|
79
|
-
readonly blueprints: ReadonlySignal<Ref.Ref<Blueprint.Blueprint>[]>;
|
|
80
|
-
readonly objects: ReadonlySignal<Ref.Ref<Type.Expando>[]>;
|
|
81
|
-
constructor(_queue: Queue);
|
|
82
|
-
/**
|
|
83
|
-
* Asynchronous query of all bindings.
|
|
84
|
-
*/
|
|
85
|
-
query(): Promise<Bindings>;
|
|
86
|
-
bind(props: BindingProps): Promise<void>;
|
|
87
|
-
unbind(props: BindingProps): Promise<void>;
|
|
88
|
-
private _reduce;
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/conversation/context.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,cAAc,EAAY,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,MAAM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