@dxos/assistant 0.8.4-main.f9ba587 → 0.8.4-main.fcfe5033a5
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/README.md +1 -0
- package/dist/lib/neutral/chunk-2TBLG3XY.mjs +1793 -0
- package/dist/lib/neutral/chunk-2TBLG3XY.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/extraction/index.mjs +219 -0
- package/dist/lib/neutral/extraction/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +537 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/testing/index.mjs +111 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/conversation/context.d.ts +155 -0
- package/dist/types/src/conversation/context.d.ts.map +1 -0
- package/dist/types/src/conversation/context.test.d.ts +2 -0
- package/dist/types/src/conversation/context.test.d.ts.map +1 -0
- package/dist/types/src/conversation/index.d.ts +2 -1
- package/dist/types/src/conversation/index.d.ts.map +1 -1
- package/dist/types/src/conversation/session.d.ts +78 -0
- package/dist/types/src/conversation/session.d.ts.map +1 -0
- package/dist/types/src/conversation/session.test.d.ts.map +1 -0
- package/dist/types/src/diff.d.ts +17 -0
- package/dist/types/src/diff.d.ts.map +1 -0
- package/dist/types/src/diff.test.d.ts +2 -0
- package/dist/types/src/diff.test.d.ts.map +1 -0
- package/dist/types/src/errors.d.ts +67 -0
- package/dist/types/src/errors.d.ts.map +1 -0
- package/dist/types/src/execution-graph.d.ts +85 -0
- package/dist/types/src/execution-graph.d.ts.map +1 -0
- package/dist/types/src/execution-graph.test.d.ts +2 -0
- package/dist/types/src/execution-graph.test.d.ts.map +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 +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 +1066 -215
- 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/index.d.ts +2 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/services.d.ts +17 -0
- package/dist/types/src/functions/services.d.ts.map +1 -0
- package/dist/types/src/functions.test.d.ts +2 -0
- package/dist/types/src/functions.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +7 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/service/AgentService.d.ts +75 -0
- package/dist/types/src/service/AgentService.d.ts.map +1 -0
- package/dist/types/src/service/AgentService.test.d.ts +2 -0
- package/dist/types/src/service/AgentService.test.d.ts.map +1 -0
- package/dist/types/src/service/agent-process.d.ts +21 -0
- package/dist/types/src/service/agent-process.d.ts.map +1 -0
- package/dist/types/src/service/index.d.ts +3 -0
- package/dist/types/src/service/index.d.ts.map +1 -0
- package/dist/types/src/session/artifact-diff.d.ts +27 -0
- package/dist/types/src/session/artifact-diff.d.ts.map +1 -0
- package/dist/types/src/session/error-handling.d.ts +4 -0
- package/dist/types/src/session/error-handling.d.ts.map +1 -0
- package/dist/types/src/session/format.d.ts +16 -0
- package/dist/types/src/session/format.d.ts.map +1 -0
- package/dist/types/src/session/format.test.d.ts +2 -0
- package/dist/types/src/session/format.test.d.ts.map +1 -0
- package/dist/types/src/session/index.d.ts +5 -1
- package/dist/types/src/session/index.d.ts.map +1 -1
- package/dist/types/src/session/observer.d.ts +23 -0
- package/dist/types/src/session/observer.d.ts.map +1 -0
- package/dist/types/src/session/request.d.ts +106 -0
- package/dist/types/src/session/request.d.ts.map +1 -0
- package/dist/types/src/session/request.test.d.ts +2 -0
- package/dist/types/src/session/request.test.d.ts.map +1 -0
- package/dist/types/src/session/session-ollama.test.d.ts +2 -0
- package/dist/types/src/session/session-ollama.test.d.ts.map +1 -0
- 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/session/version-pin.d.ts +5 -5
- 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/system.d.ts +17 -0
- package/dist/types/src/templates/system.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +1 -2
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/layer.d.ts +40 -0
- package/dist/types/src/testing/layer.d.ts.map +1 -0
- package/dist/types/src/tracing.d.ts +223 -0
- package/dist/types/src/tracing.d.ts.map +1 -0
- package/dist/types/src/types/artifact.d.ts +28 -0
- package/dist/types/src/types/artifact.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +60 -29
- package/src/conversation/context.test.ts +52 -0
- package/src/conversation/context.ts +403 -0
- package/src/conversation/index.ts +2 -1
- package/src/conversation/session.test.ts +58 -0
- package/src/conversation/session.ts +300 -0
- package/src/diff.test.ts +74 -0
- package/src/diff.ts +93 -0
- package/src/errors.ts +15 -0
- package/src/execution-graph.test.ts +740 -0
- package/src/execution-graph.ts +509 -0
- 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 +3 -1
- package/src/extraction/extraction.ts +44 -15
- package/src/extraction/index.ts +0 -1
- package/src/extraction/quotes.test.ts +3 -3
- package/src/extraction/quotes.ts +6 -7
- package/src/functions/index.ts +5 -0
- package/src/functions/services.ts +214 -0
- package/src/functions.conversations.json +1 -0
- package/src/functions.test.ts +88 -0
- package/src/index.ts +7 -5
- package/src/service/AgentService.conversations.json +1 -0
- package/src/service/AgentService.test.ts +169 -0
- package/src/service/AgentService.ts +184 -0
- package/src/service/agent-process.ts +364 -0
- package/src/service/index.ts +6 -0
- package/src/session/artifact-diff.ts +41 -0
- package/src/session/error-handling.ts +41 -0
- package/src/session/format.test.ts +132 -0
- package/src/session/format.ts +149 -0
- package/src/session/index.ts +5 -1
- package/src/session/observer.ts +62 -0
- package/src/session/request.conversations.json +1 -0
- package/src/session/request.test.ts +195 -0
- package/src/session/request.ts +344 -0
- package/src/session/session-ollama.test.ts +81 -0
- package/src/session/toolkit.ts +47 -0
- package/src/session/version-pin.ts +12 -12
- package/src/templates/index.ts +5 -0
- package/src/templates/instructions/format.tpl +57 -0
- package/src/templates/instructions/system.tpl +85 -0
- package/src/templates/system.ts +42 -0
- package/src/testing/index.ts +2 -8
- package/src/testing/layer.ts +236 -0
- package/src/tracing.ts +43 -0
- package/src/types/artifact.ts +89 -0
- package/src/types/index.ts +5 -0
- package/src/typings.d.ts +5 -0
- package/dist/lib/browser/index.mjs +0 -2019
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/index.mjs +0 -2021
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/types/bin/chat.d.ts +0 -2
- package/dist/types/bin/chat.d.ts.map +0 -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/dist/types/src/context/binder.d.ts +0 -34
- package/dist/types/src/context/binder.d.ts.map +0 -1
- package/dist/types/src/context/binding.d.ts +0 -38
- package/dist/types/src/context/binding.d.ts.map +0 -1
- package/dist/types/src/context/index.d.ts +0 -3
- package/dist/types/src/context/index.d.ts.map +0 -1
- package/dist/types/src/conversation/conversation.d.ts +0 -44
- package/dist/types/src/conversation/conversation.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 -208
- 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/research/exa.d.ts +0 -7
- package/dist/types/src/research/exa.d.ts.map +0 -1
- package/dist/types/src/research/graph.d.ts +0 -41
- package/dist/types/src/research/graph.d.ts.map +0 -1
- package/dist/types/src/research/graph.test.d.ts +0 -2
- package/dist/types/src/research/graph.test.d.ts.map +0 -1
- package/dist/types/src/research/index.d.ts +0 -4
- package/dist/types/src/research/index.d.ts.map +0 -1
- package/dist/types/src/research/research.d.ts +0 -10
- package/dist/types/src/research/research.d.ts.map +0 -1
- package/dist/types/src/research/research.test.d.ts +0 -2
- package/dist/types/src/research/research.test.d.ts.map +0 -1
- package/dist/types/src/session/session.d.ts +0 -283
- package/dist/types/src/session/session.d.ts.map +0 -1
- package/dist/types/src/session/session.test.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/testing/exa-search-1748337321991.d.ts +0 -38
- package/dist/types/src/testing/exa-search-1748337321991.d.ts.map +0 -1
- package/dist/types/src/testing/exa-search-1748337331526.d.ts +0 -37
- package/dist/types/src/testing/exa-search-1748337331526.d.ts.map +0 -1
- package/dist/types/src/testing/exa-search-1748337344119.d.ts +0 -58
- package/dist/types/src/testing/exa-search-1748337344119.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -3
- package/dist/types/src/types.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
- package/src/context/binder.ts +0 -101
- package/src/context/binding.ts +0 -31
- package/src/context/index.ts +0 -6
- package/src/conversation/conversation.ts +0 -103
- package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +0 -95
- package/src/extraction/extraction-llm-function/extraction-llm-function.ts +0 -66
- package/src/extraction/extraction-llm-function/index.ts +0 -5
- package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +0 -115
- package/src/extraction/extraction-ner-function/extraction-ner-function.ts +0 -54
- package/src/research/exa.ts +0 -100
- package/src/research/graph.test.ts +0 -15
- package/src/research/graph.ts +0 -337
- package/src/research/index.ts +0 -7
- package/src/research/instructions-research.tpl +0 -97
- package/src/research/research.test.ts +0 -190
- package/src/research/research.ts +0 -90
- package/src/session/session.test.ts +0 -275
- package/src/session/session.ts +0 -582
- package/src/session/version-pin.test.ts +0 -26
- package/src/summarization/summarization.test.ts +0 -221
- package/src/testing/exa-search-1748337321991.ts +0 -131
- package/src/testing/exa-search-1748337331526.ts +0 -144
- package/src/testing/exa-search-1748337344119.ts +0 -133
- package/src/typedefs.d.ts +0 -8
- package/src/types.ts +0 -8
- /package/dist/types/src/{session → conversation}/session.test.d.ts +0 -0
- /package/src/extraction/extraction-llm-function/{instructions.tpl → transcription-instructions.tpl} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"research.test.d.ts","sourceRoot":"","sources":["../../../../src/research/research.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
2
|
-
import { type AgentStatus, type AiServiceClient, type GenerateRequest, Message, type ExecutableTool, type ToolId, type ToolResolver } from '@dxos/ai';
|
|
3
|
-
import { type ArtifactDefinition } from '@dxos/artifact';
|
|
4
|
-
import { Event } from '@dxos/async';
|
|
5
|
-
import { ObjectVersion } from '@dxos/echo-db';
|
|
6
|
-
import { type ObjectId } from '@dxos/echo-schema';
|
|
7
|
-
/**
|
|
8
|
-
* Contains message history, tools, current context.
|
|
9
|
-
* Current context means the state of the app, time of day, and other contextual information.
|
|
10
|
-
* It makes requests to the model, its a state machine.
|
|
11
|
-
* It keeps track of the current goal.
|
|
12
|
-
* It manages the context window.
|
|
13
|
-
* Tracks the success criteria of reaching the goal, exposing metrics (stretch)
|
|
14
|
-
* Could be run locally in the app or remotely.
|
|
15
|
-
* Could be personal or shared.
|
|
16
|
-
*/
|
|
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 {
|
|
68
|
-
private readonly _options;
|
|
69
|
-
/** SSE stream parser. */
|
|
70
|
-
private readonly _parser;
|
|
71
|
-
/** Pending messages (incl. the current user request). */
|
|
72
|
-
private _pending;
|
|
73
|
-
/** Current streaming response. */
|
|
74
|
-
private _stream;
|
|
75
|
-
/** Prior history from queue. */
|
|
76
|
-
private _history;
|
|
77
|
-
/**
|
|
78
|
-
* New message.
|
|
79
|
-
*/
|
|
80
|
-
readonly message: Event<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
|
|
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
|
-
}>;
|
|
120
|
-
/**
|
|
121
|
-
* Complete block added to Message.
|
|
122
|
-
*/
|
|
123
|
-
readonly block: Event<{
|
|
124
|
-
pending?: boolean | undefined;
|
|
125
|
-
type: "text";
|
|
126
|
-
text: string;
|
|
127
|
-
disposition?: string | undefined;
|
|
128
|
-
} | {
|
|
129
|
-
pending?: boolean | undefined;
|
|
130
|
-
type: "json";
|
|
131
|
-
disposition?: string | undefined;
|
|
132
|
-
json: string;
|
|
133
|
-
} | {
|
|
134
|
-
pending?: boolean | undefined;
|
|
135
|
-
id?: string | undefined;
|
|
136
|
-
type: "image";
|
|
137
|
-
source?: {
|
|
138
|
-
type: "base64";
|
|
139
|
-
mediaType: string;
|
|
140
|
-
data: string;
|
|
141
|
-
} | undefined;
|
|
142
|
-
} | {
|
|
143
|
-
pending?: boolean | undefined;
|
|
144
|
-
id: string;
|
|
145
|
-
type: "tool_use";
|
|
146
|
-
name: string;
|
|
147
|
-
input: unknown;
|
|
148
|
-
currentStatus?: {
|
|
149
|
-
readonly id: string;
|
|
150
|
-
message: string;
|
|
151
|
-
} | undefined;
|
|
152
|
-
} | {
|
|
153
|
-
pending?: boolean | undefined;
|
|
154
|
-
type: "tool_result";
|
|
155
|
-
toolUseId: string;
|
|
156
|
-
content: string;
|
|
157
|
-
isError?: boolean | undefined;
|
|
158
|
-
}>;
|
|
159
|
-
/**
|
|
160
|
-
* Update partial block (while streaming).
|
|
161
|
-
*/
|
|
162
|
-
readonly update: Event<{
|
|
163
|
-
pending?: boolean | undefined;
|
|
164
|
-
type: "text";
|
|
165
|
-
text: string;
|
|
166
|
-
disposition?: string | undefined;
|
|
167
|
-
} | {
|
|
168
|
-
pending?: boolean | undefined;
|
|
169
|
-
type: "json";
|
|
170
|
-
disposition?: string | undefined;
|
|
171
|
-
json: string;
|
|
172
|
-
} | {
|
|
173
|
-
pending?: boolean | undefined;
|
|
174
|
-
id?: string | undefined;
|
|
175
|
-
type: "image";
|
|
176
|
-
source?: {
|
|
177
|
-
type: "base64";
|
|
178
|
-
mediaType: string;
|
|
179
|
-
data: string;
|
|
180
|
-
} | undefined;
|
|
181
|
-
} | {
|
|
182
|
-
pending?: boolean | undefined;
|
|
183
|
-
id: string;
|
|
184
|
-
type: "tool_use";
|
|
185
|
-
name: string;
|
|
186
|
-
input: unknown;
|
|
187
|
-
currentStatus?: {
|
|
188
|
-
readonly id: string;
|
|
189
|
-
message: string;
|
|
190
|
-
} | undefined;
|
|
191
|
-
} | {
|
|
192
|
-
pending?: boolean | undefined;
|
|
193
|
-
type: "tool_result";
|
|
194
|
-
toolUseId: string;
|
|
195
|
-
content: string;
|
|
196
|
-
isError?: boolean | undefined;
|
|
197
|
-
}>;
|
|
198
|
-
/**
|
|
199
|
-
* Unparsed events from the underlying generation stream.
|
|
200
|
-
*/
|
|
201
|
-
readonly streamEvent: Event<import("@dxos/ai").GenerationStreamEvent>;
|
|
202
|
-
/**
|
|
203
|
-
* User prompt or tool result.
|
|
204
|
-
*/
|
|
205
|
-
readonly userMessage: Event<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
|
|
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
|
-
}>;
|
|
245
|
-
/**
|
|
246
|
-
* Agent self-reporting its status.
|
|
247
|
-
* Triggered by the model.
|
|
248
|
-
*/
|
|
249
|
-
readonly statusReport: Event<AgentStatus>;
|
|
250
|
-
/**
|
|
251
|
-
* Emits when the session is done.
|
|
252
|
-
*/
|
|
253
|
-
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);
|
|
263
|
-
/**
|
|
264
|
-
* Runs the AI model loop interacting with tools and artifacts.
|
|
265
|
-
* @param options - The session options.
|
|
266
|
-
* @returns The messages generated by the session, including the user's prompt.
|
|
267
|
-
*/
|
|
268
|
-
run(options: SessionRunOptions): Promise<Message[]>;
|
|
269
|
-
runStructured<S extends Schema.Schema.AnyNoContext>(schema: S, options: SessionRunOptions): Promise<Schema.Schema.Type<S>>;
|
|
270
|
-
private _formatUserPrompt;
|
|
271
|
-
private _createQueryArtifactsTool;
|
|
272
|
-
private _createRequireTool;
|
|
273
|
-
private _createPlanningTool;
|
|
274
|
-
private _onToolStatusReport;
|
|
275
|
-
abort(): void;
|
|
276
|
-
}
|
|
277
|
-
declare const AIServiecOverloadedError_base: Schema.TaggedErrorClass<AIServiecOverloadedError, "AIServiecOverloadedError", {
|
|
278
|
-
readonly _tag: Schema.tag<"AIServiecOverloadedError">;
|
|
279
|
-
}>;
|
|
280
|
-
export declare class AIServiecOverloadedError extends AIServiecOverloadedError_base {
|
|
281
|
-
}
|
|
282
|
-
export {};
|
|
283
|
-
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/session/session.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session.test.d.ts","sourceRoot":"","sources":["../../../../src/session/session.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version-pin.test.d.ts","sourceRoot":"","sources":["../../../../src/session/version-pin.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"summarization.test.d.ts","sourceRoot":"","sources":["../../../../src/summarization/summarization.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
requestId: string;
|
|
3
|
-
autopromptString: string;
|
|
4
|
-
autoDate: string;
|
|
5
|
-
resolvedSearchType: string;
|
|
6
|
-
results: ({
|
|
7
|
-
id: string;
|
|
8
|
-
title: string;
|
|
9
|
-
url: string;
|
|
10
|
-
publishedDate: string;
|
|
11
|
-
author: string;
|
|
12
|
-
score: number;
|
|
13
|
-
text: string;
|
|
14
|
-
image?: undefined;
|
|
15
|
-
favicon?: undefined;
|
|
16
|
-
} | {
|
|
17
|
-
id: string;
|
|
18
|
-
title: string;
|
|
19
|
-
url: string;
|
|
20
|
-
publishedDate: string;
|
|
21
|
-
author: string;
|
|
22
|
-
score: number;
|
|
23
|
-
text: string;
|
|
24
|
-
image: string;
|
|
25
|
-
favicon: string;
|
|
26
|
-
})[];
|
|
27
|
-
costDollars: {
|
|
28
|
-
total: number;
|
|
29
|
-
search: {
|
|
30
|
-
neural: number;
|
|
31
|
-
};
|
|
32
|
-
contents: {
|
|
33
|
-
text: number;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
export default _default;
|
|
38
|
-
//# sourceMappingURL=exa-search-1748337321991.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exa-search-1748337321991.d.ts","sourceRoot":"","sources":["../../../../src/testing/exa-search-1748337321991.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,wBA8HE"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
requestId: string;
|
|
3
|
-
autopromptString: string;
|
|
4
|
-
resolvedSearchType: string;
|
|
5
|
-
results: ({
|
|
6
|
-
id: string;
|
|
7
|
-
title: string;
|
|
8
|
-
url: string;
|
|
9
|
-
publishedDate: string;
|
|
10
|
-
author: string;
|
|
11
|
-
score: number;
|
|
12
|
-
text: string;
|
|
13
|
-
image: string;
|
|
14
|
-
favicon: string;
|
|
15
|
-
} | {
|
|
16
|
-
id: string;
|
|
17
|
-
title: string;
|
|
18
|
-
url: string;
|
|
19
|
-
publishedDate: string;
|
|
20
|
-
author: string;
|
|
21
|
-
text: string;
|
|
22
|
-
image: string;
|
|
23
|
-
favicon: string;
|
|
24
|
-
score?: undefined;
|
|
25
|
-
})[];
|
|
26
|
-
costDollars: {
|
|
27
|
-
total: number;
|
|
28
|
-
search: {
|
|
29
|
-
neural: number;
|
|
30
|
-
};
|
|
31
|
-
contents: {
|
|
32
|
-
text: number;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export default _default;
|
|
37
|
-
//# sourceMappingURL=exa-search-1748337331526.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exa-search-1748337331526.d.ts","sourceRoot":"","sources":["../../../../src/testing/exa-search-1748337331526.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,wBA2IE"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
requestId: string;
|
|
3
|
-
autopromptString: string;
|
|
4
|
-
autoDate: string;
|
|
5
|
-
resolvedSearchType: string;
|
|
6
|
-
results: ({
|
|
7
|
-
id: string;
|
|
8
|
-
title: string;
|
|
9
|
-
url: string;
|
|
10
|
-
publishedDate: string;
|
|
11
|
-
author: string;
|
|
12
|
-
score: number;
|
|
13
|
-
text: string;
|
|
14
|
-
favicon: string;
|
|
15
|
-
image?: undefined;
|
|
16
|
-
} | {
|
|
17
|
-
id: string;
|
|
18
|
-
title: string;
|
|
19
|
-
url: string;
|
|
20
|
-
publishedDate: string;
|
|
21
|
-
author: string;
|
|
22
|
-
score: number;
|
|
23
|
-
text: string;
|
|
24
|
-
favicon?: undefined;
|
|
25
|
-
image?: undefined;
|
|
26
|
-
} | {
|
|
27
|
-
id: string;
|
|
28
|
-
title: string;
|
|
29
|
-
url: string;
|
|
30
|
-
publishedDate: string;
|
|
31
|
-
author: string;
|
|
32
|
-
score: number;
|
|
33
|
-
text: string;
|
|
34
|
-
image: string;
|
|
35
|
-
favicon: string;
|
|
36
|
-
} | {
|
|
37
|
-
id: string;
|
|
38
|
-
title: string;
|
|
39
|
-
url: string;
|
|
40
|
-
author: string;
|
|
41
|
-
text: string;
|
|
42
|
-
image: string;
|
|
43
|
-
favicon: string;
|
|
44
|
-
publishedDate?: undefined;
|
|
45
|
-
score?: undefined;
|
|
46
|
-
})[];
|
|
47
|
-
costDollars: {
|
|
48
|
-
total: number;
|
|
49
|
-
search: {
|
|
50
|
-
neural: number;
|
|
51
|
-
};
|
|
52
|
-
contents: {
|
|
53
|
-
text: number;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
export default _default;
|
|
58
|
-
//# sourceMappingURL=exa-search-1748337344119.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exa-search-1748337344119.d.ts","sourceRoot":"","sources":["../../../../src/testing/exa-search-1748337344119.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,wBAgIE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,eAAO,MAAM,qBAAqB,GAAI,IAAI,QAAQ,WAA4B,CAAC"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
|
|
7
|
-
import { ToolId } from '@dxos/ai';
|
|
8
|
-
import { Type } from '@dxos/echo';
|
|
9
|
-
import { LabelAnnotation } from '@dxos/echo-schema';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Blueprint schema defines the structure for AI assistant blueprints.
|
|
13
|
-
* Blueprints contain instructions, tools, and artifacts that guide the AI's behavior.
|
|
14
|
-
*/
|
|
15
|
-
export const Blueprint = Schema.Struct({
|
|
16
|
-
/**
|
|
17
|
-
* Global registry ID.
|
|
18
|
-
* NOTE: Once a blueprint has been cloned from the registry, its stored definition may converge,
|
|
19
|
-
* but the `key` property refers to the original registry entry.
|
|
20
|
-
*/
|
|
21
|
-
// TODO(burdon): Create Format type.
|
|
22
|
-
key: Schema.String.annotations({
|
|
23
|
-
description: 'Unique registration key for the blueprint',
|
|
24
|
-
}),
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Human-readable name of the blueprint.
|
|
28
|
-
*/
|
|
29
|
-
name: Schema.String.annotations({
|
|
30
|
-
description: 'Human-readable name of the blueprint',
|
|
31
|
-
}),
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Description of the blueprint's purpose and functionality.
|
|
35
|
-
*/
|
|
36
|
-
description: Schema.optional(Schema.String).annotations({
|
|
37
|
-
description: "Description of the blueprint's purpose and functionality",
|
|
38
|
-
}),
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Instructions that guide the AI assistant's behavior and responses.
|
|
42
|
-
* These are system prompts or guidelines that the AI should follow.
|
|
43
|
-
*/
|
|
44
|
-
instructions: Schema.String.annotations({
|
|
45
|
-
description: "Instructions that guide the AI assistant's behavior and responses",
|
|
46
|
-
}),
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Array of tools that the AI assistant can use when this blueprint is active.
|
|
50
|
-
*/
|
|
51
|
-
tools: Schema.Array(ToolId).annotations({
|
|
52
|
-
description: 'Array of tools that the AI assistant can use when this blueprint is active',
|
|
53
|
-
}),
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Array of artifacts that the AI assistant can create or modify.
|
|
57
|
-
*/
|
|
58
|
-
artifacts: Schema.Array(Schema.String).annotations({
|
|
59
|
-
description: 'Ids of artifact definitions that should be pulled into the blueprint',
|
|
60
|
-
}),
|
|
61
|
-
}).pipe(
|
|
62
|
-
Type.Obj({
|
|
63
|
-
// TODO(burdon): Is this a DXN? Need to create a Format type for these IDs.
|
|
64
|
-
typename: 'dxos.org/type/Blueprint',
|
|
65
|
-
version: '0.1.0',
|
|
66
|
-
}),
|
|
67
|
-
|
|
68
|
-
// TODO(burdon): Move to main API.
|
|
69
|
-
LabelAnnotation.set(['name']),
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* TypeScript type for Blueprint.
|
|
74
|
-
*/
|
|
75
|
-
export interface Blueprint extends Schema.Schema.Type<typeof Blueprint> {}
|
package/src/blueprint/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Blueprint } from './blueprint';
|
|
6
|
-
|
|
7
|
-
export class BlueprintRegistry {
|
|
8
|
-
constructor(private readonly _blueprints: Blueprint[]) {
|
|
9
|
-
this._blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
query(): Blueprint[] {
|
|
13
|
-
return this._blueprints;
|
|
14
|
-
}
|
|
15
|
-
}
|
package/src/context/binder.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { computed, type ReadonlySignal } from '@preact/signals-core';
|
|
6
|
-
import { Array, pipe } from 'effect';
|
|
7
|
-
|
|
8
|
-
import { Obj, type Type, type Ref, type Relation } from '@dxos/echo';
|
|
9
|
-
import { type Queue } from '@dxos/echo-db';
|
|
10
|
-
import { ComplexSet } from '@dxos/util';
|
|
11
|
-
|
|
12
|
-
import { ContextBinding } from './binding';
|
|
13
|
-
import { type Blueprint } from '../blueprint';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Manages bindings of blueprints and objects to a conversation.
|
|
17
|
-
*/
|
|
18
|
-
export class ContextBinder {
|
|
19
|
-
constructor(private readonly _queue: Queue) {}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Reactive query of all bindings.
|
|
23
|
-
*/
|
|
24
|
-
// TODO(burdon): Cache value?
|
|
25
|
-
readonly bindings: ReadonlySignal<Bindings> = computed(() => this._reduce(this._queue.objects));
|
|
26
|
-
|
|
27
|
-
// TODO(burdon): load refs?
|
|
28
|
-
readonly blueprints: ReadonlySignal<Ref.Ref<Blueprint>[]> = computed(() => [...this.bindings.value.blueprints]);
|
|
29
|
-
readonly objects: ReadonlySignal<Ref.Ref<Type.Expando>[]> = computed(() => [...this.bindings.value.objects]);
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Asynchronous query of all bindings.
|
|
33
|
-
*/
|
|
34
|
-
async query(): Promise<Bindings> {
|
|
35
|
-
const queueItems = await this._queue.queryObjects();
|
|
36
|
-
return this._reduce(queueItems);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// TODO(burdon): Pass in Blueprint obj (from registry?) and create reference.
|
|
40
|
-
async bind(props: BindingProps): Promise<void> {
|
|
41
|
-
if (!props.blueprints?.length && !props.objects?.length) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
await this._queue.append([
|
|
46
|
-
Obj.make(ContextBinding, {
|
|
47
|
-
blueprints: {
|
|
48
|
-
added: props.blueprints ?? [],
|
|
49
|
-
removed: [],
|
|
50
|
-
},
|
|
51
|
-
objects: {
|
|
52
|
-
added: props.objects ?? [],
|
|
53
|
-
removed: [],
|
|
54
|
-
},
|
|
55
|
-
}),
|
|
56
|
-
]);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async unbind(props: BindingProps): Promise<void> {
|
|
60
|
-
if (!props.blueprints?.length && !props.objects?.length) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
await this._queue.append([
|
|
65
|
-
Obj.make(ContextBinding, {
|
|
66
|
-
blueprints: {
|
|
67
|
-
added: [],
|
|
68
|
-
removed: props.blueprints ?? [],
|
|
69
|
-
},
|
|
70
|
-
objects: {
|
|
71
|
-
added: [],
|
|
72
|
-
removed: props.objects ?? [],
|
|
73
|
-
},
|
|
74
|
-
}),
|
|
75
|
-
]);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private _reduce(items: (Obj.Any | Relation.Any)[]): Bindings {
|
|
79
|
-
return pipe(
|
|
80
|
-
items,
|
|
81
|
-
Array.filter(Obj.instanceOf(ContextBinding)),
|
|
82
|
-
Array.reduce(new Bindings(), (context, item) => {
|
|
83
|
-
item.blueprints.removed.forEach((item) => context.blueprints.delete(item));
|
|
84
|
-
item.blueprints.added.forEach((item) => context.blueprints.add(item));
|
|
85
|
-
item.objects.removed.forEach((item) => context.objects.delete(item));
|
|
86
|
-
item.objects.added.forEach((item) => context.objects.add(item));
|
|
87
|
-
return context;
|
|
88
|
-
}),
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export type BindingProps = Partial<{
|
|
94
|
-
blueprints: Ref.Ref<Blueprint>[];
|
|
95
|
-
objects: Ref.Ref<Type.Expando>[];
|
|
96
|
-
}>;
|
|
97
|
-
|
|
98
|
-
export class Bindings {
|
|
99
|
-
blueprints = new ComplexSet<Ref.Ref<Blueprint>>((ref) => ref.dxn.toString());
|
|
100
|
-
objects = new ComplexSet<Ref.Ref<Type.Expando>>((ref) => ref.dxn.toString());
|
|
101
|
-
}
|