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