effect-assistant 0.0.0-stage → 0.2.0
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 +21 -0
- package/README.md +22 -2
- package/dist/AppEvent.d.ts +111 -0
- package/dist/AppEvent.d.ts.map +1 -0
- package/dist/AppEvent.js +71 -0
- package/dist/AppEvent.js.map +1 -0
- package/dist/Assistant.d.ts +403 -0
- package/dist/Assistant.d.ts.map +1 -0
- package/dist/Assistant.js +126 -0
- package/dist/Assistant.js.map +1 -0
- package/dist/AssistantActivity.d.ts +85 -0
- package/dist/AssistantActivity.d.ts.map +1 -0
- package/dist/AssistantActivity.js +105 -0
- package/dist/AssistantActivity.js.map +1 -0
- package/dist/AssistantEngine.d.ts +116 -0
- package/dist/AssistantEngine.d.ts.map +1 -0
- package/dist/AssistantEngine.js +255 -0
- package/dist/AssistantEngine.js.map +1 -0
- package/dist/AssistantEvent.d.ts +551 -0
- package/dist/AssistantEvent.d.ts.map +1 -0
- package/dist/AssistantEvent.js +473 -0
- package/dist/AssistantEvent.js.map +1 -0
- package/dist/AssistantLoop.d.ts +173 -0
- package/dist/AssistantLoop.d.ts.map +1 -0
- package/dist/AssistantLoop.js +111 -0
- package/dist/AssistantLoop.js.map +1 -0
- package/dist/AssistantToolCall.d.ts +32 -0
- package/dist/AssistantToolCall.d.ts.map +1 -0
- package/dist/AssistantToolCall.js +37 -0
- package/dist/AssistantToolCall.js.map +1 -0
- package/dist/Block.d.ts +69 -0
- package/dist/Block.d.ts.map +1 -0
- package/dist/Block.js +39 -0
- package/dist/Block.js.map +1 -0
- package/dist/BlockKit.d.ts +180 -0
- package/dist/BlockKit.d.ts.map +1 -0
- package/dist/BlockKit.js +148 -0
- package/dist/BlockKit.js.map +1 -0
- package/dist/ChatId.d.ts +31 -0
- package/dist/ChatId.d.ts.map +1 -0
- package/dist/ChatId.js +36 -0
- package/dist/ChatId.js.map +1 -0
- package/dist/ChatLog.d.ts +109 -0
- package/dist/ChatLog.d.ts.map +1 -0
- package/dist/ChatLog.js +177 -0
- package/dist/ChatLog.js.map +1 -0
- package/dist/ChatView.d.ts +408 -0
- package/dist/ChatView.d.ts.map +1 -0
- package/dist/ChatView.js +443 -0
- package/dist/ChatView.js.map +1 -0
- package/dist/Chats.d.ts +110 -0
- package/dist/Chats.d.ts.map +1 -0
- package/dist/Chats.js +98 -0
- package/dist/Chats.js.map +1 -0
- package/dist/Compaction.d.ts +105 -0
- package/dist/Compaction.d.ts.map +1 -0
- package/dist/Compaction.js +126 -0
- package/dist/Compaction.js.map +1 -0
- package/dist/CurrentChat.d.ts +40 -0
- package/dist/CurrentChat.d.ts.map +1 -0
- package/dist/CurrentChat.js +33 -0
- package/dist/CurrentChat.js.map +1 -0
- package/dist/InputId.d.ts +38 -0
- package/dist/InputId.d.ts.map +1 -0
- package/dist/InputId.js +43 -0
- package/dist/InputId.js.map +1 -0
- package/dist/Instructions.d.ts +56 -0
- package/dist/Instructions.d.ts.map +1 -0
- package/dist/Instructions.js +50 -0
- package/dist/Instructions.js.map +1 -0
- package/dist/Memory.d.ts +190 -0
- package/dist/Memory.d.ts.map +1 -0
- package/dist/Memory.js +216 -0
- package/dist/Memory.js.map +1 -0
- package/dist/RunId.d.ts +41 -0
- package/dist/RunId.d.ts.map +1 -0
- package/dist/RunId.js +46 -0
- package/dist/RunId.js.map +1 -0
- package/dist/Skill.d.ts +72 -0
- package/dist/Skill.d.ts.map +1 -0
- package/dist/Skill.js +58 -0
- package/dist/Skill.js.map +1 -0
- package/dist/Specialist.d.ts +267 -0
- package/dist/Specialist.d.ts.map +1 -0
- package/dist/Specialist.js +119 -0
- package/dist/Specialist.js.map +1 -0
- package/dist/ToolDiscovery.d.ts +107 -0
- package/dist/ToolDiscovery.d.ts.map +1 -0
- package/dist/ToolDiscovery.js +140 -0
- package/dist/ToolDiscovery.js.map +1 -0
- package/dist/ToolFailure.d.ts +66 -0
- package/dist/ToolFailure.d.ts.map +1 -0
- package/dist/ToolFailure.js +79 -0
- package/dist/ToolFailure.js.map +1 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +24 -0
- package/dist/internal/chat.js +177 -0
- package/dist/internal/chat.js.map +1 -0
- package/dist/internal/events.d.ts +46 -0
- package/dist/internal/events.d.ts.map +1 -0
- package/dist/internal/events.js +65 -0
- package/dist/internal/events.js.map +1 -0
- package/dist/internal/history.js +147 -0
- package/dist/internal/history.js.map +1 -0
- package/dist/internal/instructions.js +11 -0
- package/dist/internal/instructions.js.map +1 -0
- package/dist/internal/loop.d.ts +73 -0
- package/dist/internal/loop.d.ts.map +1 -0
- package/dist/internal/loop.js +131 -0
- package/dist/internal/loop.js.map +1 -0
- package/dist/internal/schema.js +14 -0
- package/dist/internal/schema.js.map +1 -0
- package/dist/internal/skills.js +28 -0
- package/dist/internal/skills.js.map +1 -0
- package/dist/internal/specialists.js +272 -0
- package/dist/internal/specialists.js.map +1 -0
- package/dist/internal/telemetry.js +85 -0
- package/dist/internal/telemetry.js.map +1 -0
- package/dist/internal/toolkit.d.ts +62 -0
- package/dist/internal/toolkit.d.ts.map +1 -0
- package/dist/internal/toolkit.js +108 -0
- package/dist/internal/toolkit.js.map +1 -0
- package/dist/internal/tools.js +113 -0
- package/dist/internal/tools.js.map +1 -0
- package/dist/internal/turns.d.ts +64 -0
- package/dist/internal/turns.d.ts.map +1 -0
- package/dist/internal/turns.js +214 -0
- package/dist/internal/turns.js.map +1 -0
- package/dist/internal/uuid.js +45 -0
- package/dist/internal/uuid.js.map +1 -0
- package/dist/internal/writer.d.ts +12 -0
- package/dist/internal/writer.d.ts.map +1 -0
- package/package.json +52 -3
- package/src/AppEvent.ts +134 -0
- package/src/Assistant.ts +589 -0
- package/src/AssistantActivity.ts +150 -0
- package/src/AssistantEngine.ts +343 -0
- package/src/AssistantEvent.ts +569 -0
- package/src/AssistantLoop.ts +209 -0
- package/src/AssistantToolCall.ts +40 -0
- package/src/Block.ts +84 -0
- package/src/BlockKit.ts +298 -0
- package/src/ChatId.ts +36 -0
- package/src/ChatLog.ts +247 -0
- package/src/ChatView.ts +587 -0
- package/src/Chats.ts +122 -0
- package/src/Compaction.ts +207 -0
- package/src/CurrentChat.ts +47 -0
- package/src/InputId.ts +43 -0
- package/src/Instructions.ts +72 -0
- package/src/Memory.ts +276 -0
- package/src/RunId.ts +46 -0
- package/src/Skill.ts +91 -0
- package/src/Specialist.ts +355 -0
- package/src/ToolDiscovery.ts +179 -0
- package/src/ToolFailure.ts +74 -0
- package/src/index.ts +120 -0
- package/src/internal/chat.ts +323 -0
- package/src/internal/events.ts +100 -0
- package/src/internal/history.ts +294 -0
- package/src/internal/instructions.ts +9 -0
- package/src/internal/loop.ts +274 -0
- package/src/internal/schema.ts +25 -0
- package/src/internal/skills.ts +37 -0
- package/src/internal/specialists.ts +410 -0
- package/src/internal/telemetry.ts +125 -0
- package/src/internal/toolkit.ts +188 -0
- package/src/internal/tools.ts +159 -0
- package/src/internal/turns.ts +410 -0
- package/src/internal/uuid.ts +50 -0
- package/src/internal/writer.ts +12 -0
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
import { ChatId } from "./ChatId.js";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as Response from "effect/ai/Response";
|
|
4
|
+
declare namespace AssistantEvent_d_exports {
|
|
5
|
+
export { AnyEntry, AppTag, AssistantEvent, AssistantMessage, Attachment, BlockAnswer, BlocksClosed, ChatDeleted, Entry, Input, MessageBlock, ModelOutput, ModelPart, SpecialistFinished, SpecialistStarted, StoredAppEvent, ToolCallPart, ToolOutcome, ToolResult, ToolStarted, TurnCompleted, TurnFailed, TurnStarted, UserInput, UserMessage, assistantTexts, attachmentLine, formatSize, isInput, isLibraryEvent, isTurnEnd, isUserInput, isWaking, maxAttachments, textWithAttachments };
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Schema for a file the user attached to a message, kept by reference.
|
|
9
|
+
*
|
|
10
|
+
* The file itself is stored elsewhere, so the log never holds its bytes.
|
|
11
|
+
*
|
|
12
|
+
* @category schemas
|
|
13
|
+
* @since 0.1.0
|
|
14
|
+
*/
|
|
15
|
+
export declare const Attachment: Schema.Struct<{
|
|
16
|
+
readonly fileId: Schema.String;
|
|
17
|
+
readonly name: Schema.String;
|
|
18
|
+
readonly mediaType: Schema.String;
|
|
19
|
+
/** In bytes. */
|
|
20
|
+
readonly size: Schema.Finite;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* The maximum number of files one message can carry.
|
|
24
|
+
*
|
|
25
|
+
* Each attached file is a line in every prompt after the message.
|
|
26
|
+
*
|
|
27
|
+
* @category utils
|
|
28
|
+
* @since 0.1.0
|
|
29
|
+
*/
|
|
30
|
+
export declare const maxAttachments = 10;
|
|
31
|
+
/**
|
|
32
|
+
* Represents a file the user attached to a message.
|
|
33
|
+
*
|
|
34
|
+
* @category models
|
|
35
|
+
* @since 0.1.0
|
|
36
|
+
*/
|
|
37
|
+
export type Attachment = typeof Attachment.Type;
|
|
38
|
+
/**
|
|
39
|
+
* Formats a byte count for people and the model, such as `2.1 MB`.
|
|
40
|
+
*
|
|
41
|
+
* @category utils
|
|
42
|
+
* @since 0.1.0
|
|
43
|
+
*/
|
|
44
|
+
export declare const formatSize: (bytes: number) => string;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the line the model reads for an attachment.
|
|
47
|
+
*
|
|
48
|
+
* The line names the file and never holds its content.
|
|
49
|
+
*
|
|
50
|
+
* @category utils
|
|
51
|
+
* @since 0.1.0
|
|
52
|
+
*/
|
|
53
|
+
export declare const attachmentLine: (attachment: Attachment) => string;
|
|
54
|
+
/**
|
|
55
|
+
* Returns a message's text followed by a line for each attached file.
|
|
56
|
+
*
|
|
57
|
+
* @category utils
|
|
58
|
+
* @since 0.1.0
|
|
59
|
+
*/
|
|
60
|
+
export declare const textWithAttachments: (text: string, attachments: ReadonlyArray<Attachment> | undefined) => string;
|
|
61
|
+
declare const UserMessage_base: Schema.Class<UserMessage, Schema.TaggedStruct<"UserMessage", {
|
|
62
|
+
readonly id: Schema.withConstructorDefault<Schema.brand<Schema.String, "~effect-assistant/InputId">>;
|
|
63
|
+
readonly text: Schema.String;
|
|
64
|
+
readonly attachments: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
65
|
+
readonly fileId: Schema.String;
|
|
66
|
+
readonly name: Schema.String;
|
|
67
|
+
readonly mediaType: Schema.String;
|
|
68
|
+
/** In bytes. */
|
|
69
|
+
readonly size: Schema.Finite;
|
|
70
|
+
}>>>;
|
|
71
|
+
}>, {}>;
|
|
72
|
+
/**
|
|
73
|
+
* Represents text the user typed, and the files they attached.
|
|
74
|
+
*
|
|
75
|
+
* `id` defaults to a new one. Pass the client's own id so that a retried send stores the message
|
|
76
|
+
* once.
|
|
77
|
+
*
|
|
78
|
+
* @category schemas
|
|
79
|
+
* @since 0.1.0
|
|
80
|
+
*/
|
|
81
|
+
export declare class UserMessage extends UserMessage_base {}
|
|
82
|
+
declare const BlockAnswer_base: Schema.Class<BlockAnswer, Schema.TaggedStruct<"BlockAnswer", {
|
|
83
|
+
readonly id: Schema.brand<Schema.String, "~effect-assistant/InputId">;
|
|
84
|
+
readonly messageId: Schema.String;
|
|
85
|
+
readonly kind: Schema.String;
|
|
86
|
+
readonly value: Schema.Unknown;
|
|
87
|
+
}>, {}>;
|
|
88
|
+
/**
|
|
89
|
+
* Represents the user's answer to a block.
|
|
90
|
+
*
|
|
91
|
+
* It holds the id of the message the block was on, and the value in the block's answer schema
|
|
92
|
+
* (in its JSON form). A chat UI shows it inside the block rather than as a message.
|
|
93
|
+
*
|
|
94
|
+
* @category schemas
|
|
95
|
+
* @since 0.1.0
|
|
96
|
+
*/
|
|
97
|
+
export declare class BlockAnswer extends BlockAnswer_base {}
|
|
98
|
+
declare const SpecialistFinished_base: Schema.Class<SpecialistFinished, Schema.TaggedStruct<"SpecialistFinished", {
|
|
99
|
+
readonly id: Schema.brand<Schema.String, "~effect-assistant/InputId">;
|
|
100
|
+
readonly runId: Schema.brand<Schema.TemplateLiteral<readonly ["run:", Schema.String]>, "~effect-assistant/RunId">;
|
|
101
|
+
readonly specialist: Schema.String;
|
|
102
|
+
/** Which brief this answers: 1 for the first, then one more per follow-up. */
|
|
103
|
+
readonly brief: Schema.Int;
|
|
104
|
+
readonly goal: Schema.String;
|
|
105
|
+
readonly status: Schema.Literals<readonly ["answered", "failed", "stopped", "cut_off"]>;
|
|
106
|
+
readonly report: Schema.optional<Schema.String>;
|
|
107
|
+
readonly error: Schema.optional<Schema.String>;
|
|
108
|
+
}>, {}>;
|
|
109
|
+
/**
|
|
110
|
+
* Represents a specialist run that finished working on a brief.
|
|
111
|
+
*
|
|
112
|
+
* Unless the assistant stopped the run, it is an input, and a turn reads its report and decides
|
|
113
|
+
* what to tell the user. Its id is fixed per run and brief, so it is stored once.
|
|
114
|
+
*
|
|
115
|
+
* @category schemas
|
|
116
|
+
* @since 0.1.0
|
|
117
|
+
*/
|
|
118
|
+
export declare class SpecialistFinished extends SpecialistFinished_base {}
|
|
119
|
+
/**
|
|
120
|
+
* Schema for every input `Assistant.submit` accepts.
|
|
121
|
+
*
|
|
122
|
+
* @category schemas
|
|
123
|
+
* @since 0.1.0
|
|
124
|
+
*/
|
|
125
|
+
export declare const Input: Schema.Union<readonly [typeof UserMessage, typeof BlockAnswer, typeof SpecialistFinished]>;
|
|
126
|
+
/**
|
|
127
|
+
* Represents an input to an assistant.
|
|
128
|
+
*
|
|
129
|
+
* @category models
|
|
130
|
+
* @since 0.1.0
|
|
131
|
+
*/
|
|
132
|
+
export type Input = typeof Input.Type;
|
|
133
|
+
/**
|
|
134
|
+
* Schema for the inputs from the chat's user, which are messages and block answers.
|
|
135
|
+
*
|
|
136
|
+
* A turn owes each one a reply. It is also what a chat client usually may submit, since the app's
|
|
137
|
+
* events come from the server.
|
|
138
|
+
*
|
|
139
|
+
* @category schemas
|
|
140
|
+
* @since 0.1.0
|
|
141
|
+
*/
|
|
142
|
+
export declare const UserInput: Schema.Union<readonly [typeof UserMessage, typeof BlockAnswer]>;
|
|
143
|
+
/**
|
|
144
|
+
* Represents an input from the chat's user.
|
|
145
|
+
*
|
|
146
|
+
* @category models
|
|
147
|
+
* @since 0.1.0
|
|
148
|
+
*/
|
|
149
|
+
export type UserInput = typeof UserInput.Type;
|
|
150
|
+
declare const MessageBlock_base: Schema.Class<MessageBlock, Schema.Struct<{
|
|
151
|
+
readonly kind: Schema.String;
|
|
152
|
+
readonly props: Schema.Unknown;
|
|
153
|
+
}>, {}>;
|
|
154
|
+
/**
|
|
155
|
+
* Represents the UI shown with a message, as a block kind from the assistant's `BlockKit` and its
|
|
156
|
+
* props.
|
|
157
|
+
*
|
|
158
|
+
* @category schemas
|
|
159
|
+
* @since 0.1.0
|
|
160
|
+
*/
|
|
161
|
+
export declare class MessageBlock extends MessageBlock_base {}
|
|
162
|
+
declare const AssistantMessage_base: Schema.Class<AssistantMessage, Schema.TaggedStruct<"AssistantMessage", {
|
|
163
|
+
readonly id: Schema.String;
|
|
164
|
+
readonly text: Schema.String;
|
|
165
|
+
readonly block: Schema.optional<typeof MessageBlock>;
|
|
166
|
+
/** Earlier messages whose block the user answered by typing instead. Their blocks close. */
|
|
167
|
+
readonly closes: Schema.optional<Schema.$Array<Schema.String>>;
|
|
168
|
+
}>, {}>;
|
|
169
|
+
/**
|
|
170
|
+
* Represents a message the assistant sent the user with `send_user_message`, optionally with a
|
|
171
|
+
* block.
|
|
172
|
+
*
|
|
173
|
+
* @category schemas
|
|
174
|
+
* @since 0.1.0
|
|
175
|
+
*/
|
|
176
|
+
export declare class AssistantMessage extends AssistantMessage_base {}
|
|
177
|
+
/**
|
|
178
|
+
* Schema for a tool call the model made.
|
|
179
|
+
*
|
|
180
|
+
* It is `effect/ai`'s tool call part (`Response.ToolCallPart`) for any tool, with its params in
|
|
181
|
+
* JSON, as the model wrote them.
|
|
182
|
+
*
|
|
183
|
+
* @category schemas
|
|
184
|
+
* @since 0.1.0
|
|
185
|
+
*/
|
|
186
|
+
export declare const ToolCallPart: Schema.Struct<{
|
|
187
|
+
readonly type: Schema.Literal<"tool-call">;
|
|
188
|
+
readonly id: Schema.String;
|
|
189
|
+
readonly params: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
190
|
+
readonly providerExecuted: Schema.withDecodingDefaultKey<Schema.Boolean>;
|
|
191
|
+
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>;
|
|
192
|
+
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>;
|
|
193
|
+
readonly name: Schema.String;
|
|
194
|
+
}>;
|
|
195
|
+
/**
|
|
196
|
+
* Represents a tool call the model made.
|
|
197
|
+
*
|
|
198
|
+
* @category models
|
|
199
|
+
* @since 0.1.0
|
|
200
|
+
*/
|
|
201
|
+
export type ToolCallPart = typeof ToolCallPart.Type;
|
|
202
|
+
/**
|
|
203
|
+
* Schema for what the log keeps of a model call.
|
|
204
|
+
*
|
|
205
|
+
* It uses `effect/ai`'s response parts for text, reasoning (with the provider's metadata, such as
|
|
206
|
+
* a thinking block's signature), and tool calls.
|
|
207
|
+
*
|
|
208
|
+
* @category schemas
|
|
209
|
+
* @since 0.1.0
|
|
210
|
+
*/
|
|
211
|
+
export declare const ModelPart: Schema.Union<readonly [Schema.Struct<{
|
|
212
|
+
readonly type: Schema.tag<"text">;
|
|
213
|
+
readonly text: Schema.String;
|
|
214
|
+
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>;
|
|
215
|
+
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>;
|
|
216
|
+
}>, Schema.Struct<{
|
|
217
|
+
readonly type: Schema.tag<"reasoning">;
|
|
218
|
+
readonly text: Schema.String;
|
|
219
|
+
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>;
|
|
220
|
+
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>;
|
|
221
|
+
}>, Schema.Struct<{
|
|
222
|
+
readonly type: Schema.Literal<"tool-call">;
|
|
223
|
+
readonly id: Schema.String;
|
|
224
|
+
readonly params: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
225
|
+
readonly providerExecuted: Schema.withDecodingDefaultKey<Schema.Boolean>;
|
|
226
|
+
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>;
|
|
227
|
+
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>;
|
|
228
|
+
readonly name: Schema.String;
|
|
229
|
+
}>]>;
|
|
230
|
+
/**
|
|
231
|
+
* Represents a part of a model call's output.
|
|
232
|
+
*
|
|
233
|
+
* @category models
|
|
234
|
+
* @since 0.1.0
|
|
235
|
+
*/
|
|
236
|
+
export type ModelPart = typeof ModelPart.Type;
|
|
237
|
+
declare const ModelOutput_base: Schema.Class<ModelOutput, Schema.TaggedStruct<"ModelOutput", {
|
|
238
|
+
readonly parts: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
239
|
+
readonly type: Schema.tag<"text">;
|
|
240
|
+
readonly text: Schema.String;
|
|
241
|
+
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>;
|
|
242
|
+
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>;
|
|
243
|
+
}>, Schema.Struct<{
|
|
244
|
+
readonly type: Schema.tag<"reasoning">;
|
|
245
|
+
readonly text: Schema.String;
|
|
246
|
+
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>;
|
|
247
|
+
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>;
|
|
248
|
+
}>, Schema.Struct<{
|
|
249
|
+
readonly type: Schema.Literal<"tool-call">;
|
|
250
|
+
readonly id: Schema.String;
|
|
251
|
+
readonly params: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
252
|
+
readonly providerExecuted: Schema.withDecodingDefaultKey<Schema.Boolean>;
|
|
253
|
+
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>;
|
|
254
|
+
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>;
|
|
255
|
+
readonly name: Schema.String;
|
|
256
|
+
}>]>>;
|
|
257
|
+
/**
|
|
258
|
+
* The last entry the model had read when it wrote this. Inputs after it
|
|
259
|
+
* arrived while the model was working. A turn has handled what its
|
|
260
|
+
* outputs had read.
|
|
261
|
+
*/
|
|
262
|
+
readonly seenThroughSeq: Schema.optional<Schema.Int>;
|
|
263
|
+
/** The model that wrote it, as the provider's id for it or the name the context gave it. */
|
|
264
|
+
readonly model: Schema.optional<Schema.String>;
|
|
265
|
+
/** The provider's id for the response, when it gives one. */
|
|
266
|
+
readonly responseId: Schema.optional<Schema.String>;
|
|
267
|
+
/** The call's token usage, with input (including the cache's reads and writes) and output. */
|
|
268
|
+
readonly usage: Schema.optional<typeof Response.Usage>;
|
|
269
|
+
/** How long the call took, in milliseconds. */
|
|
270
|
+
readonly durationMillis: Schema.optional<Schema.Finite>;
|
|
271
|
+
}>, {}>;
|
|
272
|
+
/**
|
|
273
|
+
* Represents what one model call wrote, as response parts for text, reasoning, and tool calls.
|
|
274
|
+
*
|
|
275
|
+
* `Prompt.fromResponseParts` turns the parts into history.
|
|
276
|
+
*
|
|
277
|
+
* @category schemas
|
|
278
|
+
* @since 0.1.0
|
|
279
|
+
*/
|
|
280
|
+
export declare class ModelOutput extends ModelOutput_base {}
|
|
281
|
+
declare const ToolStarted_base: Schema.Class<ToolStarted, Schema.TaggedStruct<"ToolStarted", {
|
|
282
|
+
readonly callId: Schema.String;
|
|
283
|
+
readonly tool: Schema.String;
|
|
284
|
+
}>, {}>;
|
|
285
|
+
/**
|
|
286
|
+
* Represents a tool call that is about to run.
|
|
287
|
+
*
|
|
288
|
+
* It is stored before the tool runs, so after a crash the log says which calls may have done
|
|
289
|
+
* something. Those calls run again with the same call id (see `AssistantToolCall`).
|
|
290
|
+
*
|
|
291
|
+
* @category schemas
|
|
292
|
+
* @since 0.1.0
|
|
293
|
+
*/
|
|
294
|
+
export declare class ToolStarted extends ToolStarted_base {}
|
|
295
|
+
/**
|
|
296
|
+
* Schema for how a tool call went, either `"success"` or `"failure"`, which the model reads as an
|
|
297
|
+
* error.
|
|
298
|
+
*
|
|
299
|
+
* @category schemas
|
|
300
|
+
* @since 0.1.0
|
|
301
|
+
*/
|
|
302
|
+
export declare const ToolOutcome: Schema.Literals<readonly ["success", "failure"]>;
|
|
303
|
+
/**
|
|
304
|
+
* Represents how a tool call went.
|
|
305
|
+
*
|
|
306
|
+
* @category models
|
|
307
|
+
* @since 0.1.0
|
|
308
|
+
*/
|
|
309
|
+
export type ToolOutcome = typeof ToolOutcome.Type;
|
|
310
|
+
declare const ToolResult_base: Schema.Class<ToolResult, Schema.TaggedStruct<"ToolResult", {
|
|
311
|
+
readonly callId: Schema.String;
|
|
312
|
+
readonly tool: Schema.String;
|
|
313
|
+
readonly outcome: Schema.Literals<readonly ["success", "failure"]>;
|
|
314
|
+
readonly result: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
315
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
316
|
+
}>, {}>;
|
|
317
|
+
/**
|
|
318
|
+
* Represents the result of one tool call, as the model reads it.
|
|
319
|
+
*
|
|
320
|
+
* It holds the tool's success or failure in its encoded (JSON) form, and which of the two it is. A
|
|
321
|
+
* failure includes its reason when it has one, which is a `ToolFailure`'s `reason` or the
|
|
322
|
+
* failure's tag.
|
|
323
|
+
*
|
|
324
|
+
* @category schemas
|
|
325
|
+
* @since 0.1.0
|
|
326
|
+
*/
|
|
327
|
+
export declare class ToolResult extends ToolResult_base {}
|
|
328
|
+
declare const TurnStarted_base: Schema.Class<TurnStarted, Schema.TaggedStruct<"TurnStarted", {
|
|
329
|
+
/** The assistant that runs it. */
|
|
330
|
+
readonly assistant: Schema.String;
|
|
331
|
+
/**
|
|
332
|
+
* The id of the turn's trace, when a tracer records it (not Effect's own, which exports nothing).
|
|
333
|
+
*/
|
|
334
|
+
readonly traceId: Schema.optional<Schema.String>;
|
|
335
|
+
}>, {}>;
|
|
336
|
+
/**
|
|
337
|
+
* Represents the start of a turn.
|
|
338
|
+
*
|
|
339
|
+
* @category schemas
|
|
340
|
+
* @since 0.1.0
|
|
341
|
+
*/
|
|
342
|
+
export declare class TurnStarted extends TurnStarted_base {}
|
|
343
|
+
declare const TurnCompleted_base: Schema.Class<TurnCompleted, Schema.TaggedStruct<"TurnCompleted", {
|
|
344
|
+
readonly throughSeq: Schema.Int;
|
|
345
|
+
}>, {}>;
|
|
346
|
+
/**
|
|
347
|
+
* Represents a turn that finished.
|
|
348
|
+
*
|
|
349
|
+
* `throughSeq` is the last entry the turn read. Inputs after it still need a turn.
|
|
350
|
+
*
|
|
351
|
+
* @category schemas
|
|
352
|
+
* @since 0.1.0
|
|
353
|
+
*/
|
|
354
|
+
export declare class TurnCompleted extends TurnCompleted_base {}
|
|
355
|
+
declare const TurnFailed_base: Schema.Class<TurnFailed, Schema.TaggedStruct<"TurnFailed", {
|
|
356
|
+
readonly throughSeq: Schema.Int;
|
|
357
|
+
readonly message: Schema.String;
|
|
358
|
+
}>, {}>;
|
|
359
|
+
/**
|
|
360
|
+
* Represents a turn that failed.
|
|
361
|
+
*
|
|
362
|
+
* `throughSeq` covers everything stored when the turn failed, so a failing input isn't retried
|
|
363
|
+
* forever.
|
|
364
|
+
*
|
|
365
|
+
* @category schemas
|
|
366
|
+
* @since 0.1.0
|
|
367
|
+
*/
|
|
368
|
+
export declare class TurnFailed extends TurnFailed_base {}
|
|
369
|
+
declare const SpecialistStarted_base: Schema.Class<SpecialistStarted, Schema.TaggedStruct<"SpecialistStarted", {
|
|
370
|
+
readonly runId: Schema.brand<Schema.TemplateLiteral<readonly ["run:", Schema.String]>, "~effect-assistant/RunId">;
|
|
371
|
+
readonly specialist: Schema.String;
|
|
372
|
+
/** The goal it's working on. */
|
|
373
|
+
readonly goal: Schema.String;
|
|
374
|
+
}>, {}>;
|
|
375
|
+
/**
|
|
376
|
+
* Represents a specialist run that started working, either spawned or continued by a follow-up
|
|
377
|
+
* message.
|
|
378
|
+
*
|
|
379
|
+
* The model doesn't see it, since the call that started the run says so, and the run's report
|
|
380
|
+
* arrives as a {@link SpecialistFinished}.
|
|
381
|
+
*
|
|
382
|
+
* @category schemas
|
|
383
|
+
* @since 0.1.0
|
|
384
|
+
*/
|
|
385
|
+
export declare class SpecialistStarted extends SpecialistStarted_base {}
|
|
386
|
+
declare const ChatDeleted_base: Schema.Class<ChatDeleted, Schema.TaggedStruct<"ChatDeleted", {}>, {}>;
|
|
387
|
+
/**
|
|
388
|
+
* Represents the deletion of a chat.
|
|
389
|
+
*
|
|
390
|
+
* The chat stores nothing after it, the work running in the chat stopped, and its subscribers'
|
|
391
|
+
* streams end here. Its log stays.
|
|
392
|
+
*
|
|
393
|
+
* @category schemas
|
|
394
|
+
* @since 0.1.0
|
|
395
|
+
*/
|
|
396
|
+
export declare class ChatDeleted extends ChatDeleted_base {}
|
|
397
|
+
declare const BlocksClosed_base: Schema.Class<BlocksClosed, Schema.TaggedStruct<"BlocksClosed", {
|
|
398
|
+
readonly messageIds: Schema.$Array<Schema.String>;
|
|
399
|
+
}>, {}>;
|
|
400
|
+
/**
|
|
401
|
+
* Represents blocks that closed without an answer, like the ones `BlockKit.closeStale` closes
|
|
402
|
+
* from a turn once the user moved on.
|
|
403
|
+
*
|
|
404
|
+
* The model doesn't see it.
|
|
405
|
+
*
|
|
406
|
+
* @category schemas
|
|
407
|
+
* @since 0.1.0
|
|
408
|
+
*/
|
|
409
|
+
export declare class BlocksClosed extends BlocksClosed_base {}
|
|
410
|
+
/**
|
|
411
|
+
* Schema for every event the library defines.
|
|
412
|
+
*
|
|
413
|
+
* @category schemas
|
|
414
|
+
* @since 0.1.0
|
|
415
|
+
*/
|
|
416
|
+
export declare const AssistantEvent: Schema.Union<readonly [typeof UserMessage, typeof BlockAnswer, typeof AssistantMessage, typeof ModelOutput, typeof ToolStarted, typeof ToolResult, typeof TurnStarted, typeof TurnCompleted, typeof TurnFailed, typeof SpecialistStarted, typeof SpecialistFinished, typeof BlocksClosed, typeof ChatDeleted]>;
|
|
417
|
+
/**
|
|
418
|
+
* Represents an event the library defines.
|
|
419
|
+
*
|
|
420
|
+
* @category models
|
|
421
|
+
* @since 0.1.0
|
|
422
|
+
*/
|
|
423
|
+
export type AssistantEvent = typeof AssistantEvent.Type;
|
|
424
|
+
/**
|
|
425
|
+
* Schema for the tag of one of the application's own events.
|
|
426
|
+
*
|
|
427
|
+
* It accepts any tag but the library's, and it is branded, so narrowing an entry's event to one
|
|
428
|
+
* of the library's events (`Predicate.isTagged(event, "UserMessage")`) never leaves an app event
|
|
429
|
+
* in.
|
|
430
|
+
*
|
|
431
|
+
* @category schemas
|
|
432
|
+
* @since 0.1.0
|
|
433
|
+
*/
|
|
434
|
+
export declare const AppTag: Schema.brand<Schema.String, "~effect-assistant/AppTag">;
|
|
435
|
+
/**
|
|
436
|
+
* Schema for one of the application's own events as it is stored, with its `_tag` and its fields
|
|
437
|
+
* in JSON.
|
|
438
|
+
*
|
|
439
|
+
* An assistant made with `events: [AppEvent.make(Summary)]` decodes it to a `Summary` in
|
|
440
|
+
* `CurrentChat`'s `entries` and in its `subscribe`.
|
|
441
|
+
*
|
|
442
|
+
* @category schemas
|
|
443
|
+
* @since 0.1.0
|
|
444
|
+
*/
|
|
445
|
+
export declare const StoredAppEvent: Schema.StructWithRest<Schema.Struct<{
|
|
446
|
+
readonly _tag: Schema.brand<Schema.String, "~effect-assistant/AppTag">;
|
|
447
|
+
}>, readonly [Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
|
|
448
|
+
/**
|
|
449
|
+
* Represents one of the application's own events, as it is stored.
|
|
450
|
+
*
|
|
451
|
+
* @category models
|
|
452
|
+
* @since 0.1.0
|
|
453
|
+
*/
|
|
454
|
+
export type StoredAppEvent = typeof StoredAppEvent.Type;
|
|
455
|
+
/**
|
|
456
|
+
* Returns whether an event is one of the library's, not one of the app's own.
|
|
457
|
+
*
|
|
458
|
+
* @category guards
|
|
459
|
+
* @since 0.1.0
|
|
460
|
+
*/
|
|
461
|
+
export declare const isLibraryEvent: (event: {
|
|
462
|
+
readonly _tag: string;
|
|
463
|
+
}) => event is AssistantEvent;
|
|
464
|
+
/**
|
|
465
|
+
* Represents a chat's entry with any event in it, either the library's or the application's own
|
|
466
|
+
* (decoded or not).
|
|
467
|
+
*
|
|
468
|
+
* The folds over a chat take this type, so a client's typed entries fit too.
|
|
469
|
+
*
|
|
470
|
+
* @category models
|
|
471
|
+
* @since 0.1.0
|
|
472
|
+
*/
|
|
473
|
+
export interface AnyEntry {
|
|
474
|
+
readonly chatId: ChatId;
|
|
475
|
+
readonly seq: number;
|
|
476
|
+
readonly at: number;
|
|
477
|
+
readonly event: {
|
|
478
|
+
readonly _tag: string;
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Schema for a stored event with its position in the chat.
|
|
483
|
+
*
|
|
484
|
+
* `seq` starts at 1 and has no gaps. `at` is the time the event was stored, in epoch
|
|
485
|
+
* milliseconds.
|
|
486
|
+
*
|
|
487
|
+
* @category schemas
|
|
488
|
+
* @since 0.1.0
|
|
489
|
+
*/
|
|
490
|
+
export declare const Entry: Schema.Struct<{
|
|
491
|
+
readonly chatId: Schema.brand<Schema.TemplateLiteral<readonly ["chat:", Schema.String]>, "~effect-assistant/ChatId">;
|
|
492
|
+
readonly seq: Schema.Int;
|
|
493
|
+
readonly at: Schema.Finite;
|
|
494
|
+
readonly event: Schema.Union<readonly [Schema.Union<readonly [typeof UserMessage, typeof BlockAnswer, typeof AssistantMessage, typeof ModelOutput, typeof ToolStarted, typeof ToolResult, typeof TurnStarted, typeof TurnCompleted, typeof TurnFailed, typeof SpecialistStarted, typeof SpecialistFinished, typeof BlocksClosed, typeof ChatDeleted]>, Schema.StructWithRest<Schema.Struct<{
|
|
495
|
+
readonly _tag: Schema.brand<Schema.String, "~effect-assistant/AppTag">;
|
|
496
|
+
}>, readonly [Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>]>;
|
|
497
|
+
}>;
|
|
498
|
+
/**
|
|
499
|
+
* Represents a stored event with its position in the chat.
|
|
500
|
+
*
|
|
501
|
+
* @category models
|
|
502
|
+
* @since 0.1.0
|
|
503
|
+
*/
|
|
504
|
+
export type Entry = typeof Entry.Type;
|
|
505
|
+
/**
|
|
506
|
+
* Returns whether an event is one of the library's inputs, which are a user message, a block
|
|
507
|
+
* answer, or a finished specialist run.
|
|
508
|
+
*
|
|
509
|
+
* The application's events that wake a turn are inputs too, but only their assistant knows which
|
|
510
|
+
* (see `AppEvent`).
|
|
511
|
+
*
|
|
512
|
+
* @category guards
|
|
513
|
+
* @since 0.1.0
|
|
514
|
+
*/
|
|
515
|
+
export declare const isInput: (event: {
|
|
516
|
+
readonly _tag: string;
|
|
517
|
+
}) => event is Input;
|
|
518
|
+
/**
|
|
519
|
+
* Returns whether an input starts a turn, which every input does except a run the assistant
|
|
520
|
+
* stopped itself.
|
|
521
|
+
*
|
|
522
|
+
* @category guards
|
|
523
|
+
* @since 0.1.0
|
|
524
|
+
*/
|
|
525
|
+
export declare const isWaking: (input: Input) => boolean;
|
|
526
|
+
/**
|
|
527
|
+
* Returns whether an input came from the chat's user, and so is owed a reply.
|
|
528
|
+
*
|
|
529
|
+
* @category guards
|
|
530
|
+
* @since 0.1.0
|
|
531
|
+
*/
|
|
532
|
+
export declare const isUserInput: (input: Input) => input is UserInput;
|
|
533
|
+
/**
|
|
534
|
+
* Returns whether an event ends a turn, and so says how far the assistant has read.
|
|
535
|
+
*
|
|
536
|
+
* @category guards
|
|
537
|
+
* @since 0.1.0
|
|
538
|
+
*/
|
|
539
|
+
export declare const isTurnEnd: (event: {
|
|
540
|
+
readonly _tag: string;
|
|
541
|
+
}) => event is TurnCompleted | TurnFailed;
|
|
542
|
+
/**
|
|
543
|
+
* Returns the text of every message the user was shown, in order.
|
|
544
|
+
*
|
|
545
|
+
* @category utils
|
|
546
|
+
* @since 0.1.0
|
|
547
|
+
*/
|
|
548
|
+
export declare const assistantTexts: (entries: ReadonlyArray<AnyEntry>) => ReadonlyArray<string>;
|
|
549
|
+
//#endregion
|
|
550
|
+
export { AssistantEvent_d_exports };
|
|
551
|
+
//# sourceMappingURL=AssistantEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssistantEvent.d.ts","names":[],"sources":["../src/AssistantEvent.ts"],"mappings":";;;;;;;;;;;;;;qBAyBa,YAAU,OAAA;;;;;;;;;;;;;;;qBAgBV;;;;;;;YAQD,oBAAoB,WAAW;;;;;;;qBAQ9B,aAAU;;;;;;;;;qBAiBV,iBAAc,YAAgB;;;;;;;qBAS9B,sBAAmB,cAAgB,aAAe,cAAc;;;;;;;;;;;;;;;;;;;;;qBAchE,oBAAoB;;;;;;;;;;;;;;;;qBAepB,oBAAoB;;;;;;;;;;;;;;;;;;;;;qBAgBpB,2BAA2B;;;;;;;qBAkB3B,OAAK,OAAA,uBAAA,oBAAA,oBAAA;;;;;;;YAQN,eAAe,MAAM;;;;;;;;;;qBAWpB,WAAS,OAAA,uBAAA,oBAAA;;;;;;;YAQV,mBAAmB,UAAU;;;;;;;;;;;;qBAS5B,qBAAqB;;;;;;;;;;;;;;;qBAYrB,yBAAyB;;;;;;;;;;qBAiBzB,cAAY,OAAA;;;;;;;;;;;;;;;YAWb,sBAAsB,aAAa;;;;;;;;;;qBAWlC,WAAS,OAAA,gBAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;YAQV,mBAAmB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAU5B,oBAAoB;;;;;;;;;;;;;;qBA2BpB,oBAAoB;;;;;;;;qBAYpB,aAAW,OAAA;;;;;;;YAQZ,qBAAqB,YAAY;;;;;;;;;;;;;;;;;;qBAYhC,mBAAmB;;;;;;;;;;;;;;;qBAcnB,oBAAoB;;;;;;;;;;;;qBAiBpB,sBAAsB;;;;;;;;;;;;;;qBAatB,mBAAmB;;;;;;;;;;;;;;;;;qBAenB,0BAA0B;;;;;;;;;;;qBAgB1B,oBAAoB;;;;;;;;;;;;;qBAWpB,qBAAqB;;;;;;;qBAUrB,gBAAc,OAAA,uBAAA,oBAAA,oBAAA,yBAAA,oBAAA,oBAAA,mBAAA,oBAAA,sBAAA,mBAAA,0BAAA,2BAAA,qBAAA;;;;;;;YAsBf,wBAAwB,eAAe;;;;;;;;;;;qBAgBtC,QAAM,OAAA,MAAA,OAAA;;;;;;;;;;;qBAYN,gBAAc,OAAA,eAAA,OAAA;;cAE2F,OAAA,QAAA,OAAA,QAAA,OAAA,MAAA,OAAA,MAAA,OAAA;;;;;;;YAQ1G,wBAAwB,eAAe;;;;;;;qBAQtC,iBAAc;WAAsB;MAAiB,SAAS;;;;;;;;;;iBAW1D;WACN,QAAQ;WACR;WACA;WACA;aAAkB;;;;;;;;;;;;qBAYhB,OAAK,OAAA;;;;;;;;;;;;;;YAaN,eAAe,MAAM;;;;;;;;;;;qBAYpB,UAAO;WAAsB;MAAiB,SAAS;;;;;;;;qBAYvD,WAAQ,OAAW;;;;;;;qBASnB,cAAW,OAAW,UAAQ,SAAS;;;;;;;qBASvC,YAAS;WAAsB;MAAiB,SAAS,gBAAgB;;;;;;;qBASzE,iBAAc,SAAa,cAAc,cAAY"}
|