@dxos/assistant 0.8.4-main.84f28bd → 0.8.4-main.b97322e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +623 -811
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +623 -811
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/context/binder.d.ts +4 -4
- package/dist/types/src/context/binder.d.ts.map +1 -1
- package/dist/types/src/context/binding.d.ts +24 -6
- package/dist/types/src/context/binding.d.ts.map +1 -1
- package/dist/types/src/conversation/conversation.d.ts +12 -18
- package/dist/types/src/conversation/conversation.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts +38 -0
- package/dist/types/src/errors.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +127 -33
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts +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 +100 -42
- package/dist/types/src/extraction/extraction.d.ts.map +1 -1
- package/dist/types/src/functions/index.d.ts +2 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/services.d.ts +6 -0
- package/dist/types/src/functions/services.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/research/exa.d.ts +10 -5
- package/dist/types/src/research/exa.d.ts.map +1 -1
- package/dist/types/src/research/graph.d.ts +18 -8
- package/dist/types/src/research/graph.d.ts.map +1 -1
- package/dist/types/src/research/research.d.ts +1 -1
- package/dist/types/src/research/research.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +170 -193
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/dist/types/src/session/version-pin.d.ts +2 -2
- package/dist/types/src/session/version-pin.d.ts.map +1 -1
- package/dist/types/src/templates/index.d.ts +2 -0
- package/dist/types/src/templates/index.d.ts.map +1 -0
- package/dist/types/src/templates/prompt.d.ts +30 -0
- package/dist/types/src/templates/prompt.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +10 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -21
- package/src/context/binder.ts +6 -4
- package/src/context/binding.ts +4 -3
- package/src/conversation/conversation.ts +54 -61
- package/src/errors.ts +10 -0
- package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +6 -18
- package/src/extraction/extraction-llm-function/extraction-llm-function.ts +18 -14
- package/src/extraction/extraction-ner-function/extraction-ner-function.ts +6 -3
- package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +2 -2
- package/src/extraction/extraction-ner-function/named-entity-recognition.ts +1 -1
- package/src/functions/index.ts +5 -0
- package/src/functions/services.ts +139 -0
- package/src/index.ts +2 -2
- package/src/research/exa.ts +56 -59
- package/src/research/graph.test.ts +50 -1
- package/src/research/graph.ts +85 -53
- package/src/research/instructions-research.tpl +1 -0
- package/src/research/research.test.ts +27 -27
- package/src/research/research.ts +50 -53
- package/src/session/__snapshots__/session.test.ts.snap +32 -0
- package/src/session/session.test.ts +90 -55
- package/src/session/session.ts +215 -461
- package/src/session/version-pin.test.ts +2 -21
- package/src/session/version-pin.ts +5 -5
- package/src/summarization/summarization.test.ts +75 -88
- package/src/templates/assistant.tpl +111 -0
- package/src/templates/index.ts +5 -0
- package/src/templates/prompt.ts +45 -0
- package/src/types.ts +40 -1
- package/dist/types/src/blueprint/blueprint.d.ts +0 -41
- package/dist/types/src/blueprint/blueprint.d.ts.map +0 -1
- package/dist/types/src/blueprint/index.d.ts +0 -3
- package/dist/types/src/blueprint/index.d.ts.map +0 -1
- package/dist/types/src/blueprint/registry.d.ts +0 -7
- package/dist/types/src/blueprint/registry.d.ts.map +0 -1
- package/src/blueprint/blueprint.ts +0 -75
- package/src/blueprint/index.ts +0 -6
- package/src/blueprint/registry.ts +0 -15
|
@@ -1,73 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { type
|
|
1
|
+
import { AiLanguageModel, AiToolkit, type AiError, type AiResponse, type AiTool } from '@effect/ai';
|
|
2
|
+
import { Context, Effect, type Schema } from 'effect';
|
|
3
|
+
import { ToolExecutionService, ToolResolverService, type AgentStatus, type AiInputPreprocessingError, type AiToolNotFoundError } from '@dxos/ai';
|
|
4
4
|
import { Event } from '@dxos/async';
|
|
5
|
+
import { type Blueprint } from '@dxos/blueprints';
|
|
5
6
|
import { ObjectVersion } from '@dxos/echo-db';
|
|
6
7
|
import { type ObjectId } from '@dxos/echo-schema';
|
|
8
|
+
import { DataType } from '@dxos/schema';
|
|
9
|
+
import { AiAssistantError } from '../errors';
|
|
10
|
+
export type AiSessionOptions = {};
|
|
11
|
+
export type SessionRunOptions<Tools extends AiTool.Any> = {
|
|
12
|
+
prompt: string;
|
|
13
|
+
history: DataType.Message[];
|
|
14
|
+
systemPrompt?: string;
|
|
15
|
+
toolkit?: AiToolkit.AiToolkit<Tools>;
|
|
16
|
+
blueprints?: Blueprint.Blueprint[];
|
|
17
|
+
};
|
|
7
18
|
/**
|
|
8
19
|
* Contains message history, tools, current context.
|
|
9
20
|
* Current context means the state of the app, time of day, and other contextual information.
|
|
10
21
|
* It makes requests to the model, its a state machine.
|
|
11
22
|
* It keeps track of the current goal.
|
|
12
23
|
* It manages the context window.
|
|
13
|
-
* Tracks the success criteria of reaching the goal, exposing metrics (stretch)
|
|
24
|
+
* Tracks the success criteria of reaching the goal, exposing metrics (stretch).
|
|
14
25
|
* Could be run locally in the app or remotely.
|
|
15
26
|
* Could be personal or shared.
|
|
16
27
|
*/
|
|
17
|
-
|
|
18
|
-
* Resolves artifact ids to their versions.
|
|
19
|
-
* Used to give the model a sense of the changes to the artifacts made by users during the conversation.
|
|
20
|
-
* The artifacts versions are pinned in the history, and whenever the artifact changes in-between assistant's steps,
|
|
21
|
-
* a diff is inserted into the conversation.
|
|
22
|
-
*/
|
|
23
|
-
export type ArtifactDiffResolver = (artifacts: {
|
|
24
|
-
id: ObjectId;
|
|
25
|
-
lastVersion: ObjectVersion;
|
|
26
|
-
}[]) => Promise<Map<ObjectId, {
|
|
27
|
-
version: ObjectVersion;
|
|
28
|
-
diff?: string;
|
|
29
|
-
}>>;
|
|
30
|
-
export type SessionRunOptions = {
|
|
31
|
-
artifacts: ArtifactDefinition[];
|
|
32
|
-
/**
|
|
33
|
-
* Non-artifact specific tools.
|
|
34
|
-
*/
|
|
35
|
-
tools: ToolId[];
|
|
36
|
-
history: Message[];
|
|
37
|
-
prompt: string;
|
|
38
|
-
generationOptions?: Pick<GenerateRequest, 'model'>;
|
|
39
|
-
extensions?: ToolContextExtensions;
|
|
40
|
-
systemPrompt?: string;
|
|
41
|
-
/**
|
|
42
|
-
* Pre-require artifacts.
|
|
43
|
-
*/
|
|
44
|
-
requiredArtifactIds?: string[];
|
|
45
|
-
client: AiServiceClient;
|
|
46
|
-
toolResolver: ToolResolver;
|
|
47
|
-
/**
|
|
48
|
-
* Executable tools that do not go through the tool resolver.
|
|
49
|
-
*/
|
|
50
|
-
executableTools?: ExecutableTool[];
|
|
51
|
-
/**
|
|
52
|
-
* @see ArtifactDiffResolver
|
|
53
|
-
*/
|
|
54
|
-
artifactDiffResolver?: ArtifactDiffResolver;
|
|
55
|
-
};
|
|
56
|
-
type OperationModel = 'planning' | 'importing' | 'configured';
|
|
57
|
-
export type AiSessionOptions = {
|
|
58
|
-
/**
|
|
59
|
-
* Determines the agent's handling of the artifacts definitions:
|
|
60
|
-
*
|
|
61
|
-
* - `planning`: The model will create a plan with required artifacts for each step.
|
|
62
|
-
* - `importing`: The model can query registry and only pull in the artifacts that are required to complete the task.
|
|
63
|
-
* - `configured`: The available artifacts are pre-selected and the model cannot select additional artifacts.
|
|
64
|
-
*/
|
|
65
|
-
operationModel: OperationModel;
|
|
66
|
-
};
|
|
67
|
-
export declare class AISession {
|
|
28
|
+
export declare class AiSession {
|
|
68
29
|
private readonly _options;
|
|
69
|
-
|
|
70
|
-
private readonly _parser;
|
|
30
|
+
private readonly _semaphore;
|
|
71
31
|
/** Pending messages (incl. the current user request). */
|
|
72
32
|
private _pending;
|
|
73
33
|
/** Current streaming response. */
|
|
@@ -77,171 +37,183 @@ export declare class AISession {
|
|
|
77
37
|
/**
|
|
78
38
|
* New message.
|
|
79
39
|
*/
|
|
80
|
-
readonly message: Event<import("@dxos/
|
|
81
|
-
id: string;
|
|
82
|
-
content: ({
|
|
83
|
-
pending?: boolean | undefined;
|
|
84
|
-
type: "text";
|
|
85
|
-
text: string;
|
|
86
|
-
disposition?: string | undefined;
|
|
87
|
-
} | {
|
|
88
|
-
pending?: boolean | undefined;
|
|
89
|
-
type: "json";
|
|
90
|
-
disposition?: string | undefined;
|
|
91
|
-
json: string;
|
|
92
|
-
} | {
|
|
93
|
-
pending?: boolean | undefined;
|
|
94
|
-
id?: string | undefined;
|
|
95
|
-
type: "image";
|
|
96
|
-
source?: {
|
|
97
|
-
type: "base64";
|
|
98
|
-
mediaType: string;
|
|
99
|
-
data: string;
|
|
100
|
-
} | undefined;
|
|
101
|
-
} | {
|
|
102
|
-
pending?: boolean | undefined;
|
|
103
|
-
id: string;
|
|
104
|
-
type: "tool_use";
|
|
105
|
-
name: string;
|
|
106
|
-
input: unknown;
|
|
107
|
-
currentStatus?: {
|
|
108
|
-
readonly id: string;
|
|
109
|
-
message: string;
|
|
110
|
-
} | undefined;
|
|
111
|
-
} | {
|
|
112
|
-
pending?: boolean | undefined;
|
|
113
|
-
type: "tool_result";
|
|
114
|
-
toolUseId: string;
|
|
115
|
-
content: string;
|
|
116
|
-
isError?: boolean | undefined;
|
|
117
|
-
})[];
|
|
118
|
-
role: "user" | "assistant";
|
|
119
|
-
}>;
|
|
40
|
+
readonly message: Event<import("@dxos/schema").Message>;
|
|
120
41
|
/**
|
|
121
42
|
* Complete block added to Message.
|
|
122
43
|
*/
|
|
123
44
|
readonly block: Event<{
|
|
45
|
+
version: unknown;
|
|
46
|
+
_tag: "anchor";
|
|
124
47
|
pending?: boolean | undefined;
|
|
125
|
-
|
|
126
|
-
text: string;
|
|
127
|
-
disposition?: string | undefined;
|
|
48
|
+
objectId: string;
|
|
128
49
|
} | {
|
|
50
|
+
name?: string | undefined;
|
|
51
|
+
_tag: "file";
|
|
129
52
|
pending?: boolean | undefined;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
json: string;
|
|
53
|
+
url: string;
|
|
54
|
+
mediaType?: string | undefined;
|
|
133
55
|
} | {
|
|
134
|
-
pending?: boolean | undefined;
|
|
135
56
|
id?: string | undefined;
|
|
136
|
-
type: "image";
|
|
137
57
|
source?: {
|
|
138
58
|
type: "base64";
|
|
139
59
|
mediaType: string;
|
|
140
60
|
data: string;
|
|
61
|
+
} | {
|
|
62
|
+
type: "http";
|
|
63
|
+
url: string;
|
|
141
64
|
} | undefined;
|
|
65
|
+
_tag: "image";
|
|
66
|
+
pending?: boolean | undefined;
|
|
67
|
+
} | {
|
|
68
|
+
_tag: "json";
|
|
69
|
+
pending?: boolean | undefined;
|
|
70
|
+
data: string;
|
|
71
|
+
disposition?: string | undefined;
|
|
72
|
+
} | {
|
|
73
|
+
text: string;
|
|
74
|
+
_tag: "proposal";
|
|
75
|
+
pending?: boolean | undefined;
|
|
76
|
+
} | {
|
|
77
|
+
_tag: "reasoning";
|
|
78
|
+
pending?: boolean | undefined;
|
|
79
|
+
reasoningText?: string | undefined;
|
|
80
|
+
redactedText?: string | undefined;
|
|
81
|
+
signature?: string | undefined;
|
|
142
82
|
} | {
|
|
83
|
+
reference: import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").Expando>;
|
|
84
|
+
_tag: "reference";
|
|
143
85
|
pending?: boolean | undefined;
|
|
144
|
-
|
|
145
|
-
|
|
86
|
+
} | {
|
|
87
|
+
_tag: "select";
|
|
88
|
+
pending?: boolean | undefined;
|
|
89
|
+
options: readonly string[];
|
|
90
|
+
} | {
|
|
91
|
+
_tag: "status";
|
|
92
|
+
pending?: boolean | undefined;
|
|
93
|
+
statusText: string;
|
|
94
|
+
} | {
|
|
95
|
+
text: string;
|
|
96
|
+
_tag: "suggest";
|
|
97
|
+
pending?: boolean | undefined;
|
|
98
|
+
} | {
|
|
99
|
+
text: string;
|
|
100
|
+
_tag: "text";
|
|
101
|
+
pending?: boolean | undefined;
|
|
102
|
+
disposition?: string | undefined;
|
|
103
|
+
mimeType?: string | undefined;
|
|
104
|
+
} | {
|
|
146
105
|
name: string;
|
|
147
106
|
input: unknown;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
} | undefined;
|
|
107
|
+
_tag: "toolCall";
|
|
108
|
+
pending?: boolean | undefined;
|
|
109
|
+
toolCallId: string;
|
|
152
110
|
} | {
|
|
111
|
+
_tag: "toolList";
|
|
153
112
|
pending?: boolean | undefined;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
113
|
+
} | {
|
|
114
|
+
name: string;
|
|
115
|
+
_tag: "toolResult";
|
|
116
|
+
pending?: boolean | undefined;
|
|
117
|
+
toolCallId: string;
|
|
118
|
+
result: unknown;
|
|
119
|
+
} | {
|
|
120
|
+
text: string;
|
|
121
|
+
_tag: "transcript";
|
|
122
|
+
pending?: boolean | undefined;
|
|
123
|
+
started: string;
|
|
158
124
|
}>;
|
|
159
125
|
/**
|
|
160
126
|
* Update partial block (while streaming).
|
|
161
127
|
*/
|
|
162
128
|
readonly update: Event<{
|
|
129
|
+
version: unknown;
|
|
130
|
+
_tag: "anchor";
|
|
163
131
|
pending?: boolean | undefined;
|
|
164
|
-
|
|
165
|
-
text: string;
|
|
166
|
-
disposition?: string | undefined;
|
|
132
|
+
objectId: string;
|
|
167
133
|
} | {
|
|
134
|
+
name?: string | undefined;
|
|
135
|
+
_tag: "file";
|
|
168
136
|
pending?: boolean | undefined;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
json: string;
|
|
137
|
+
url: string;
|
|
138
|
+
mediaType?: string | undefined;
|
|
172
139
|
} | {
|
|
173
|
-
pending?: boolean | undefined;
|
|
174
140
|
id?: string | undefined;
|
|
175
|
-
type: "image";
|
|
176
141
|
source?: {
|
|
177
142
|
type: "base64";
|
|
178
143
|
mediaType: string;
|
|
179
144
|
data: string;
|
|
145
|
+
} | {
|
|
146
|
+
type: "http";
|
|
147
|
+
url: string;
|
|
180
148
|
} | undefined;
|
|
149
|
+
_tag: "image";
|
|
150
|
+
pending?: boolean | undefined;
|
|
151
|
+
} | {
|
|
152
|
+
_tag: "json";
|
|
153
|
+
pending?: boolean | undefined;
|
|
154
|
+
data: string;
|
|
155
|
+
disposition?: string | undefined;
|
|
156
|
+
} | {
|
|
157
|
+
text: string;
|
|
158
|
+
_tag: "proposal";
|
|
159
|
+
pending?: boolean | undefined;
|
|
160
|
+
} | {
|
|
161
|
+
_tag: "reasoning";
|
|
162
|
+
pending?: boolean | undefined;
|
|
163
|
+
reasoningText?: string | undefined;
|
|
164
|
+
redactedText?: string | undefined;
|
|
165
|
+
signature?: string | undefined;
|
|
166
|
+
} | {
|
|
167
|
+
reference: import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").Expando>;
|
|
168
|
+
_tag: "reference";
|
|
169
|
+
pending?: boolean | undefined;
|
|
170
|
+
} | {
|
|
171
|
+
_tag: "select";
|
|
172
|
+
pending?: boolean | undefined;
|
|
173
|
+
options: readonly string[];
|
|
181
174
|
} | {
|
|
175
|
+
_tag: "status";
|
|
182
176
|
pending?: boolean | undefined;
|
|
183
|
-
|
|
184
|
-
|
|
177
|
+
statusText: string;
|
|
178
|
+
} | {
|
|
179
|
+
text: string;
|
|
180
|
+
_tag: "suggest";
|
|
181
|
+
pending?: boolean | undefined;
|
|
182
|
+
} | {
|
|
183
|
+
text: string;
|
|
184
|
+
_tag: "text";
|
|
185
|
+
pending?: boolean | undefined;
|
|
186
|
+
disposition?: string | undefined;
|
|
187
|
+
mimeType?: string | undefined;
|
|
188
|
+
} | {
|
|
185
189
|
name: string;
|
|
186
190
|
input: unknown;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
+
_tag: "toolCall";
|
|
192
|
+
pending?: boolean | undefined;
|
|
193
|
+
toolCallId: string;
|
|
194
|
+
} | {
|
|
195
|
+
_tag: "toolList";
|
|
196
|
+
pending?: boolean | undefined;
|
|
191
197
|
} | {
|
|
198
|
+
name: string;
|
|
199
|
+
_tag: "toolResult";
|
|
192
200
|
pending?: boolean | undefined;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
201
|
+
toolCallId: string;
|
|
202
|
+
result: unknown;
|
|
203
|
+
} | {
|
|
204
|
+
text: string;
|
|
205
|
+
_tag: "transcript";
|
|
206
|
+
pending?: boolean | undefined;
|
|
207
|
+
started: string;
|
|
197
208
|
}>;
|
|
198
209
|
/**
|
|
199
210
|
* Unparsed events from the underlying generation stream.
|
|
200
211
|
*/
|
|
201
|
-
readonly streamEvent: Event<
|
|
212
|
+
readonly streamEvent: Event<AiResponse.TextPart | AiResponse.ReasoningPart | AiResponse.RedactedReasoningPart | AiResponse.ToolCallPart | AiResponse.MetadataPart | AiResponse.FinishPart>;
|
|
202
213
|
/**
|
|
203
214
|
* User prompt or tool result.
|
|
204
215
|
*/
|
|
205
|
-
readonly userMessage: Event<import("@dxos/
|
|
206
|
-
id: string;
|
|
207
|
-
role: "user" | "assistant";
|
|
208
|
-
content: ({
|
|
209
|
-
pending?: boolean | undefined;
|
|
210
|
-
type: "text";
|
|
211
|
-
disposition?: string | undefined;
|
|
212
|
-
text: string;
|
|
213
|
-
} | {
|
|
214
|
-
pending?: boolean | undefined;
|
|
215
|
-
type: "json";
|
|
216
|
-
disposition?: string | undefined;
|
|
217
|
-
json: string;
|
|
218
|
-
} | {
|
|
219
|
-
pending?: boolean | undefined;
|
|
220
|
-
id?: string | undefined;
|
|
221
|
-
type: "image";
|
|
222
|
-
source?: {
|
|
223
|
-
type: "base64";
|
|
224
|
-
mediaType: string;
|
|
225
|
-
data: string;
|
|
226
|
-
} | undefined;
|
|
227
|
-
} | {
|
|
228
|
-
pending?: boolean | undefined;
|
|
229
|
-
id: string;
|
|
230
|
-
name: string;
|
|
231
|
-
type: "tool_use";
|
|
232
|
-
input: unknown;
|
|
233
|
-
currentStatus?: {
|
|
234
|
-
readonly id: string;
|
|
235
|
-
message: string;
|
|
236
|
-
} | undefined;
|
|
237
|
-
} | {
|
|
238
|
-
pending?: boolean | undefined;
|
|
239
|
-
type: "tool_result";
|
|
240
|
-
content: string;
|
|
241
|
-
toolUseId: string;
|
|
242
|
-
isError?: boolean | undefined;
|
|
243
|
-
})[];
|
|
244
|
-
}>;
|
|
216
|
+
readonly userMessage: Event<import("@dxos/schema").Message>;
|
|
245
217
|
/**
|
|
246
218
|
* Agent self-reporting its status.
|
|
247
219
|
* Triggered by the model.
|
|
@@ -251,33 +223,38 @@ export declare class AISession {
|
|
|
251
223
|
* Emits when the session is done.
|
|
252
224
|
*/
|
|
253
225
|
readonly done: Event<void>;
|
|
254
|
-
|
|
255
|
-
* Emits when the tool reports its status.
|
|
256
|
-
* Triggered by the tool execution function.
|
|
257
|
-
*/
|
|
258
|
-
readonly toolStatusReport: Event<{
|
|
259
|
-
message: Message;
|
|
260
|
-
status: AgentStatus;
|
|
261
|
-
}>;
|
|
262
|
-
constructor(_options: AiSessionOptions);
|
|
226
|
+
constructor(_options?: AiSessionOptions);
|
|
263
227
|
/**
|
|
264
228
|
* Runs the AI model loop interacting with tools and artifacts.
|
|
265
229
|
* @param options - The session options.
|
|
266
230
|
* @returns The messages generated by the session, including the user's prompt.
|
|
267
231
|
*/
|
|
268
|
-
run(options: SessionRunOptions)
|
|
269
|
-
runStructured<S extends Schema.Schema.AnyNoContext>(schema: S, options: SessionRunOptions): Promise<Schema.Schema.Type<S>>;
|
|
232
|
+
run: <Tools extends AiTool.Any>(options: SessionRunOptions<Tools>) => Effect.Effect<DataType.Message[], AiAssistantError | AiInputPreprocessingError | AiToolNotFoundError | AiError.AiError, AiLanguageModel.AiLanguageModel | ToolResolverService | ToolExecutionService | AiTool.ToHandler<Tools>>;
|
|
233
|
+
runStructured<S extends Schema.Schema.AnyNoContext>(schema: S, options: SessionRunOptions<AiTool.Any>): Promise<Schema.Schema.Type<S>>;
|
|
270
234
|
private _formatUserPrompt;
|
|
271
|
-
private _createQueryArtifactsTool;
|
|
272
|
-
private _createRequireTool;
|
|
273
|
-
private _createPlanningTool;
|
|
274
|
-
private _onToolStatusReport;
|
|
275
235
|
abort(): void;
|
|
276
236
|
}
|
|
277
|
-
declare const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
237
|
+
declare const ArtifactDiffResolver_base: Context.TagClass<ArtifactDiffResolver, "ArtifactDiffResolver", ArtifactDiffResolver.Service>;
|
|
238
|
+
/**
|
|
239
|
+
* Resolves artifact ids to their versions.
|
|
240
|
+
* Used to give the model a sense of the changes to the artifacts made by users during the conversation.
|
|
241
|
+
* The artifacts versions are pinned in the history, and whenever the artifact changes in-between assistant's steps,
|
|
242
|
+
* a diff is inserted into the conversation.
|
|
243
|
+
*
|
|
244
|
+
* Can be optionally provided to the session run call.
|
|
245
|
+
*/
|
|
246
|
+
export declare class ArtifactDiffResolver extends ArtifactDiffResolver_base {
|
|
247
|
+
}
|
|
248
|
+
export declare namespace ArtifactDiffResolver {
|
|
249
|
+
type Service = {
|
|
250
|
+
resolve: (artifacts: {
|
|
251
|
+
id: ObjectId;
|
|
252
|
+
lastVersion: ObjectVersion;
|
|
253
|
+
}[]) => Promise<Map<ObjectId, {
|
|
254
|
+
version: ObjectVersion;
|
|
255
|
+
diff?: string;
|
|
256
|
+
}>>;
|
|
257
|
+
};
|
|
281
258
|
}
|
|
282
259
|
export {};
|
|
283
260
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/session/session.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/session/session.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
|
-
import { type MessageContentBlock } from '@dxos/ai';
|
|
3
2
|
import { type ObjectVersion } from '@dxos/echo-db';
|
|
4
3
|
import { type BaseEchoObject } from '@dxos/echo-schema';
|
|
4
|
+
import { type ContentBlock } from '@dxos/schema';
|
|
5
5
|
declare const VersionPinSchema: Schema.Struct<{
|
|
6
6
|
objectId: import("@dxos/keys").ObjectIdClass;
|
|
7
7
|
version: Schema.Schema<ObjectVersion, ObjectVersion, never>;
|
|
@@ -15,7 +15,7 @@ export interface VersionPin extends Schema.Schema.Type<typeof VersionPinSchema>
|
|
|
15
15
|
export declare const VersionPin: typeof VersionPinSchema & {
|
|
16
16
|
DISPOSITION: 'version-pin';
|
|
17
17
|
fromObject: (object: BaseEchoObject) => VersionPin;
|
|
18
|
-
createBlock: (pin: VersionPin) =>
|
|
18
|
+
createBlock: (pin: VersionPin) => ContentBlock.Any;
|
|
19
19
|
};
|
|
20
20
|
export {};
|
|
21
21
|
//# sourceMappingURL=version-pin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-pin.d.ts","sourceRoot":"","sources":["../../../../src/session/version-pin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"version-pin.d.ts","sourceRoot":"","sources":["../../../../src/session/version-pin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAKjD,QAAA,MAAM,gBAAgB;;;EAKpB,CAAC;AAEH;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC;CAAG;AAElF,eAAO,MAAM,UAAU,EAAE,OAAO,gBAAgB,GAAG;IACjD,WAAW,EAAE,aAAa,CAAC;IAC3B,UAAU,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,UAAU,CAAC;IACnD,WAAW,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,YAAY,CAAC,GAAG,CAAC;CAiBpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/templates/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type AssociatedArtifact } from '@dxos/blueprints';
|
|
2
|
+
/**
|
|
3
|
+
* Type for assistant prompt variables.
|
|
4
|
+
*/
|
|
5
|
+
export type AssistantPromptOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Instructions for each artifact.
|
|
8
|
+
*/
|
|
9
|
+
artifacts?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Associated artifact to include in the prompt.
|
|
12
|
+
* @deprecated
|
|
13
|
+
*/
|
|
14
|
+
artifact?: AssociatedArtifact;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to include suggestions in the prompt.
|
|
17
|
+
*/
|
|
18
|
+
suggestions?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Additional instructions to include in the prompt.
|
|
21
|
+
*/
|
|
22
|
+
instructions?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Emit chain-of-thought inside <cot> tag.
|
|
25
|
+
* Should be `false` for models with built-in reasoning: Claude, deepseek, o1.
|
|
26
|
+
*/
|
|
27
|
+
cot?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export declare const createSystemPrompt: (options: AssistantPromptOptions) => string;
|
|
30
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../src/templates/prompt.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,kBAAkB,EAAY,MAAM,kBAAkB,CAAC;AAIrE;;GAEG;AAEH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IAEH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAErB;;;OAGG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAE9B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,SAAS,sBAAsB,WAEjE,CAAC"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
1
2
|
import { type ObjectId } from '@dxos/echo-schema';
|
|
3
|
+
import { DXN, type SpaceId } from '@dxos/keys';
|
|
2
4
|
export declare const createArtifactElement: (id: ObjectId) => string;
|
|
5
|
+
/**
|
|
6
|
+
* A model-friendly way to reference an object.
|
|
7
|
+
* Supports vairous formats that will be normalized to a DXN.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ArtifactId: Schema.Schema<string> & {
|
|
10
|
+
toDXN: (reference: ArtifactId, owningSpaceId?: SpaceId) => DXN;
|
|
11
|
+
};
|
|
12
|
+
export type ArtifactId = Schema.Schema.Type<typeof ArtifactId>;
|
|
3
13
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAmB,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAEhE,eAAO,MAAM,qBAAqB,GAAI,IAAI,QAAQ,WAA4B,CAAC;AAE/E;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG;IAC/C,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,aAAa,CAAC,EAAE,OAAO,KAAK,GAAG,CAAC;CA4BhE,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC"}
|