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.
Files changed (172) 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 +551 -0
  20. package/dist/AssistantEvent.d.ts.map +1 -0
  21. package/dist/AssistantEvent.js +473 -0
  22. package/dist/AssistantEvent.js.map +1 -0
  23. package/dist/AssistantLoop.d.ts +173 -0
  24. package/dist/AssistantLoop.d.ts.map +1 -0
  25. package/dist/AssistantLoop.js +111 -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 +180 -0
  36. package/dist/BlockKit.d.ts.map +1 -0
  37. package/dist/BlockKit.js +148 -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 +408 -0
  48. package/dist/ChatView.d.ts.map +1 -0
  49. package/dist/ChatView.js +443 -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 +126 -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/InputId.d.ts +38 -0
  64. package/dist/InputId.d.ts.map +1 -0
  65. package/dist/InputId.js +43 -0
  66. package/dist/InputId.js.map +1 -0
  67. package/dist/Instructions.d.ts +56 -0
  68. package/dist/Instructions.d.ts.map +1 -0
  69. package/dist/Instructions.js +50 -0
  70. package/dist/Instructions.js.map +1 -0
  71. package/dist/Memory.d.ts +190 -0
  72. package/dist/Memory.d.ts.map +1 -0
  73. package/dist/Memory.js +216 -0
  74. package/dist/Memory.js.map +1 -0
  75. package/dist/RunId.d.ts +41 -0
  76. package/dist/RunId.d.ts.map +1 -0
  77. package/dist/RunId.js +46 -0
  78. package/dist/RunId.js.map +1 -0
  79. package/dist/Skill.d.ts +72 -0
  80. package/dist/Skill.d.ts.map +1 -0
  81. package/dist/Skill.js +58 -0
  82. package/dist/Skill.js.map +1 -0
  83. package/dist/Specialist.d.ts +267 -0
  84. package/dist/Specialist.d.ts.map +1 -0
  85. package/dist/Specialist.js +119 -0
  86. package/dist/Specialist.js.map +1 -0
  87. package/dist/ToolDiscovery.d.ts +107 -0
  88. package/dist/ToolDiscovery.d.ts.map +1 -0
  89. package/dist/ToolDiscovery.js +140 -0
  90. package/dist/ToolDiscovery.js.map +1 -0
  91. package/dist/ToolFailure.d.ts +66 -0
  92. package/dist/ToolFailure.d.ts.map +1 -0
  93. package/dist/ToolFailure.js +79 -0
  94. package/dist/ToolFailure.js.map +1 -0
  95. package/dist/_virtual/_rolldown/runtime.js +13 -0
  96. package/dist/index.d.ts +24 -0
  97. package/dist/index.js +24 -0
  98. package/dist/internal/chat.js +177 -0
  99. package/dist/internal/chat.js.map +1 -0
  100. package/dist/internal/events.d.ts +46 -0
  101. package/dist/internal/events.d.ts.map +1 -0
  102. package/dist/internal/events.js +65 -0
  103. package/dist/internal/events.js.map +1 -0
  104. package/dist/internal/history.js +147 -0
  105. package/dist/internal/history.js.map +1 -0
  106. package/dist/internal/instructions.js +11 -0
  107. package/dist/internal/instructions.js.map +1 -0
  108. package/dist/internal/loop.d.ts +73 -0
  109. package/dist/internal/loop.d.ts.map +1 -0
  110. package/dist/internal/loop.js +131 -0
  111. package/dist/internal/loop.js.map +1 -0
  112. package/dist/internal/schema.js +14 -0
  113. package/dist/internal/schema.js.map +1 -0
  114. package/dist/internal/skills.js +28 -0
  115. package/dist/internal/skills.js.map +1 -0
  116. package/dist/internal/specialists.js +272 -0
  117. package/dist/internal/specialists.js.map +1 -0
  118. package/dist/internal/telemetry.js +85 -0
  119. package/dist/internal/telemetry.js.map +1 -0
  120. package/dist/internal/toolkit.d.ts +62 -0
  121. package/dist/internal/toolkit.d.ts.map +1 -0
  122. package/dist/internal/toolkit.js +108 -0
  123. package/dist/internal/toolkit.js.map +1 -0
  124. package/dist/internal/tools.js +113 -0
  125. package/dist/internal/tools.js.map +1 -0
  126. package/dist/internal/turns.d.ts +64 -0
  127. package/dist/internal/turns.d.ts.map +1 -0
  128. package/dist/internal/turns.js +214 -0
  129. package/dist/internal/turns.js.map +1 -0
  130. package/dist/internal/uuid.js +45 -0
  131. package/dist/internal/uuid.js.map +1 -0
  132. package/dist/internal/writer.d.ts +12 -0
  133. package/dist/internal/writer.d.ts.map +1 -0
  134. package/package.json +52 -3
  135. package/src/AppEvent.ts +134 -0
  136. package/src/Assistant.ts +589 -0
  137. package/src/AssistantActivity.ts +150 -0
  138. package/src/AssistantEngine.ts +343 -0
  139. package/src/AssistantEvent.ts +569 -0
  140. package/src/AssistantLoop.ts +209 -0
  141. package/src/AssistantToolCall.ts +40 -0
  142. package/src/Block.ts +84 -0
  143. package/src/BlockKit.ts +298 -0
  144. package/src/ChatId.ts +36 -0
  145. package/src/ChatLog.ts +247 -0
  146. package/src/ChatView.ts +587 -0
  147. package/src/Chats.ts +122 -0
  148. package/src/Compaction.ts +207 -0
  149. package/src/CurrentChat.ts +47 -0
  150. package/src/InputId.ts +43 -0
  151. package/src/Instructions.ts +72 -0
  152. package/src/Memory.ts +276 -0
  153. package/src/RunId.ts +46 -0
  154. package/src/Skill.ts +91 -0
  155. package/src/Specialist.ts +355 -0
  156. package/src/ToolDiscovery.ts +179 -0
  157. package/src/ToolFailure.ts +74 -0
  158. package/src/index.ts +120 -0
  159. package/src/internal/chat.ts +323 -0
  160. package/src/internal/events.ts +100 -0
  161. package/src/internal/history.ts +294 -0
  162. package/src/internal/instructions.ts +9 -0
  163. package/src/internal/loop.ts +274 -0
  164. package/src/internal/schema.ts +25 -0
  165. package/src/internal/skills.ts +37 -0
  166. package/src/internal/specialists.ts +410 -0
  167. package/src/internal/telemetry.ts +125 -0
  168. package/src/internal/toolkit.ts +188 -0
  169. package/src/internal/tools.ts +159 -0
  170. package/src/internal/turns.ts +410 -0
  171. package/src/internal/uuid.ts +50 -0
  172. package/src/internal/writer.ts +12 -0
@@ -0,0 +1,408 @@
1
+ import { AnyEntry, AssistantEvent_d_exports } from "./AssistantEvent.js";
2
+ import * as Schema from "effect/Schema";
3
+ import * as Stream from "effect/Stream";
4
+ declare namespace ChatView_d_exports {
5
+ export { Activity, AssistantMessage, Block, BlockStatus, Definition, Message, Options, SpecialistWorking, Update, UpdatesOptions, UserMessage, View, apply, empty, fromEntries, isIdle, updates };
6
+ }
7
+ /**
8
+ * Schema for the status of a block. A block is `"open"` while it accepts an answer, `"answered"`
9
+ * once the user has used it, and `"closed"` when it closed without an answer because the user
10
+ * answered in words or moved on.
11
+ *
12
+ * @category schemas
13
+ * @since 0.1.0
14
+ */
15
+ export declare const BlockStatus: Schema.Literals<readonly ["open", "answered", "closed"]>;
16
+ /**
17
+ * The status of a block.
18
+ *
19
+ * @category models
20
+ * @since 0.1.0
21
+ */
22
+ export type BlockStatus = typeof BlockStatus.Type;
23
+ /**
24
+ * Schema for a block on an assistant's message. It holds the block's kind, its props (JSON, as
25
+ * the block's props schema encodes them), its status, and the user's answer (JSON, as the block's
26
+ * answer schema encodes it).
27
+ *
28
+ * @category schemas
29
+ * @since 0.1.0
30
+ */
31
+ export declare const Block: Schema.Struct<{
32
+ readonly kind: Schema.String;
33
+ readonly props: Schema.Codec<Schema.Json, Schema.Json, never, never>;
34
+ readonly status: Schema.Literals<readonly ["open", "answered", "closed"]>;
35
+ readonly answer: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
36
+ }>;
37
+ /**
38
+ * Represents a block on an assistant's message.
39
+ *
40
+ * @category models
41
+ * @since 0.1.0
42
+ */
43
+ export type Block = typeof Block.Type;
44
+ /**
45
+ * Schema for a message the user sent. `at` is when it was stored, in epoch
46
+ * milliseconds.
47
+ *
48
+ * @category schemas
49
+ * @since 0.1.0
50
+ */
51
+ export declare const UserMessage: Schema.TaggedStruct<"UserMessage", {
52
+ readonly id: Schema.brand<Schema.String, "~effect-assistant/InputId">;
53
+ readonly text: Schema.String;
54
+ readonly attachments: Schema.optional<Schema.$Array<Schema.Struct<{
55
+ readonly fileId: Schema.String;
56
+ readonly name: Schema.String;
57
+ readonly mediaType: Schema.String;
58
+ readonly size: Schema.Finite;
59
+ }>>>;
60
+ readonly at: Schema.Finite;
61
+ }>;
62
+ /**
63
+ * Represents a message the user sent.
64
+ *
65
+ * @category models
66
+ * @since 0.1.0
67
+ */
68
+ export type UserMessage = typeof UserMessage.Type;
69
+ /**
70
+ * Schema for a message the assistant sent the user, including its block if it has one.
71
+ *
72
+ * @category schemas
73
+ * @since 0.1.0
74
+ */
75
+ export declare const AssistantMessage: Schema.TaggedStruct<"AssistantMessage", {
76
+ readonly id: Schema.String;
77
+ readonly text: Schema.String;
78
+ readonly at: Schema.Finite;
79
+ readonly block: Schema.optional<Schema.Struct<{
80
+ readonly kind: Schema.String;
81
+ readonly props: Schema.Codec<Schema.Json, Schema.Json, never, never>;
82
+ readonly status: Schema.Literals<readonly ["open", "answered", "closed"]>;
83
+ readonly answer: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
84
+ }>>;
85
+ }>;
86
+ /**
87
+ * Represents a message the assistant sent the user.
88
+ *
89
+ * @category models
90
+ * @since 0.1.0
91
+ */
92
+ export type AssistantMessage = typeof AssistantMessage.Type;
93
+ /**
94
+ * Schema for a message in the chat, sent by either the user or the assistant.
95
+ *
96
+ * @category schemas
97
+ * @since 0.1.0
98
+ */
99
+ export declare const Message: Schema.Union<readonly [Schema.TaggedStruct<"UserMessage", {
100
+ readonly id: Schema.brand<Schema.String, "~effect-assistant/InputId">;
101
+ readonly text: Schema.String;
102
+ readonly attachments: Schema.optional<Schema.$Array<Schema.Struct<{
103
+ readonly fileId: Schema.String;
104
+ readonly name: Schema.String;
105
+ readonly mediaType: Schema.String;
106
+ readonly size: Schema.Finite;
107
+ }>>>;
108
+ readonly at: Schema.Finite;
109
+ }>, Schema.TaggedStruct<"AssistantMessage", {
110
+ readonly id: Schema.String;
111
+ readonly text: Schema.String;
112
+ readonly at: Schema.Finite;
113
+ readonly block: Schema.optional<Schema.Struct<{
114
+ readonly kind: Schema.String;
115
+ readonly props: Schema.Codec<Schema.Json, Schema.Json, never, never>;
116
+ readonly status: Schema.Literals<readonly ["open", "answered", "closed"]>;
117
+ readonly answer: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
118
+ }>>;
119
+ }>]>;
120
+ /**
121
+ * Represents a message in the chat.
122
+ *
123
+ * @category models
124
+ * @since 0.1.0
125
+ */
126
+ export type Message = typeof Message.Type;
127
+ /**
128
+ * Schema for a specialist that is working for the assistant. It holds the specialist's name and
129
+ * when it started, in epoch milliseconds.
130
+ *
131
+ * @category schemas
132
+ * @since 0.1.0
133
+ */
134
+ export declare const SpecialistWorking: Schema.Struct<{
135
+ readonly specialist: Schema.String;
136
+ readonly since: Schema.Finite;
137
+ }>;
138
+ /**
139
+ * Represents a specialist that is working for the assistant.
140
+ *
141
+ * @category models
142
+ * @since 0.1.0
143
+ */
144
+ export type SpecialistWorking = typeof SpecialistWorking.Type;
145
+ /**
146
+ * Schema for what is working in the chat.
147
+ *
148
+ * `working` is true while the assistant runs a turn, or when a turn is about to start for
149
+ * something that arrived. `specialists` lists the specialists that are working. When the chat is
150
+ * idle, nothing is working, even if a workflow is waiting on a timer or on the user.
151
+ *
152
+ * @category schemas
153
+ * @since 0.1.0
154
+ */
155
+ export declare const Activity: Schema.Struct<{
156
+ readonly working: Schema.Boolean;
157
+ readonly specialists: Schema.$Array<Schema.Struct<{
158
+ readonly specialist: Schema.String;
159
+ readonly since: Schema.Finite;
160
+ }>>;
161
+ }>;
162
+ /**
163
+ * Represents what is working in the chat.
164
+ *
165
+ * @category models
166
+ * @since 0.1.0
167
+ */
168
+ export type Activity = typeof Activity.Type;
169
+ /**
170
+ * Schema for a chat as its user sees it. It holds the chat's messages, what is working in it,
171
+ * whether the last turn failed, and whether the chat was deleted. `seq` is the position in the
172
+ * chat's log that the view is up to.
173
+ *
174
+ * @category schemas
175
+ * @since 0.1.0
176
+ */
177
+ export declare const View: Schema.Struct<{
178
+ readonly seq: Schema.Int;
179
+ readonly messages: Schema.$Array<Schema.Union<readonly [Schema.TaggedStruct<"UserMessage", {
180
+ readonly id: Schema.brand<Schema.String, "~effect-assistant/InputId">;
181
+ readonly text: Schema.String;
182
+ readonly attachments: Schema.optional<Schema.$Array<Schema.Struct<{
183
+ readonly fileId: Schema.String;
184
+ readonly name: Schema.String;
185
+ readonly mediaType: Schema.String;
186
+ readonly size: Schema.Finite;
187
+ }>>>;
188
+ readonly at: Schema.Finite;
189
+ }>, Schema.TaggedStruct<"AssistantMessage", {
190
+ readonly id: Schema.String;
191
+ readonly text: Schema.String;
192
+ readonly at: Schema.Finite;
193
+ readonly block: Schema.optional<Schema.Struct<{
194
+ readonly kind: Schema.String;
195
+ readonly props: Schema.Codec<Schema.Json, Schema.Json, never, never>;
196
+ readonly status: Schema.Literals<readonly ["open", "answered", "closed"]>;
197
+ readonly answer: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
198
+ }>>;
199
+ }>]>>;
200
+ readonly activity: Schema.Struct<{
201
+ readonly working: Schema.Boolean;
202
+ readonly specialists: Schema.$Array<Schema.Struct<{
203
+ readonly specialist: Schema.String;
204
+ readonly since: Schema.Finite;
205
+ }>>;
206
+ }>;
207
+ /** Whether the last turn failed with no message after it. */
208
+ readonly failed: Schema.Boolean;
209
+ /** Whether the chat was deleted. A deleted chat accepts nothing more, and its stream ends. */
210
+ readonly deleted: Schema.Boolean;
211
+ }>;
212
+ /**
213
+ * Represents a chat as its user sees it.
214
+ *
215
+ * @category models
216
+ * @since 0.1.0
217
+ */
218
+ export type View = typeof View.Type;
219
+ /**
220
+ * Schema for a change to a chat's view.
221
+ *
222
+ * An update holds each message that is new or changed (for example, a block answered or
223
+ * closed), in full. It also holds the current activity, whether the last turn failed,
224
+ * and whether the chat was deleted. `seq` is the position in the chat's log that the update is up
225
+ * to.
226
+ *
227
+ * @category schemas
228
+ * @since 0.1.0
229
+ */
230
+ export declare const Update: Schema.Struct<{
231
+ readonly seq: Schema.Int;
232
+ readonly messages: Schema.$Array<Schema.Union<readonly [Schema.TaggedStruct<"UserMessage", {
233
+ readonly id: Schema.brand<Schema.String, "~effect-assistant/InputId">;
234
+ readonly text: Schema.String;
235
+ readonly attachments: Schema.optional<Schema.$Array<Schema.Struct<{
236
+ readonly fileId: Schema.String;
237
+ readonly name: Schema.String;
238
+ readonly mediaType: Schema.String;
239
+ readonly size: Schema.Finite;
240
+ }>>>;
241
+ readonly at: Schema.Finite;
242
+ }>, Schema.TaggedStruct<"AssistantMessage", {
243
+ readonly id: Schema.String;
244
+ readonly text: Schema.String;
245
+ readonly at: Schema.Finite;
246
+ readonly block: Schema.optional<Schema.Struct<{
247
+ readonly kind: Schema.String;
248
+ readonly props: Schema.Codec<Schema.Json, Schema.Json, never, never>;
249
+ readonly status: Schema.Literals<readonly ["open", "answered", "closed"]>;
250
+ readonly answer: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
251
+ }>>;
252
+ }>]>>;
253
+ readonly activity: Schema.Struct<{
254
+ readonly working: Schema.Boolean;
255
+ readonly specialists: Schema.$Array<Schema.Struct<{
256
+ readonly specialist: Schema.String;
257
+ readonly since: Schema.Finite;
258
+ }>>;
259
+ }>;
260
+ readonly failed: Schema.Boolean;
261
+ readonly deleted: Schema.Boolean;
262
+ }>;
263
+ /**
264
+ * Represents a change to a chat's view.
265
+ *
266
+ * @category models
267
+ * @since 0.1.0
268
+ */
269
+ export type Update = typeof Update.Type;
270
+ /**
271
+ * The view of a chat before anything has happened in it, with no messages and nothing working.
272
+ * Use it as the starting point when folding updates with {@link apply}.
273
+ *
274
+ * @category constructors
275
+ * @since 0.1.0
276
+ */
277
+ export declare const empty: View;
278
+ /**
279
+ * Returns the view after applying an update.
280
+ *
281
+ * **Details**
282
+ *
283
+ * Each message in the update replaces the message with the same id, in place, and new messages
284
+ * are added after the rest. The update's activity, `failed`, and `deleted` replace the view's.
285
+ * Applying an update twice changes nothing, so a client that resubscribes from the start can fold
286
+ * again and get the same view.
287
+ *
288
+ * @category combinators
289
+ * @since 0.1.0
290
+ */
291
+ export declare const apply: (view: View, update: Update) => View;
292
+ /**
293
+ * Returns whether nothing is working in the chat: no turn is running or about to start, and no
294
+ * specialist is working.
295
+ *
296
+ * @category guards
297
+ * @since 0.1.0
298
+ */
299
+ export declare const isIdle: (view: View) => boolean;
300
+ /**
301
+ * Represents the options for building a view from a chat's log.
302
+ *
303
+ * @category models
304
+ * @since 0.1.0
305
+ */
306
+ export interface Options {
307
+ /**
308
+ * The tags of the app's events that wake a turn. After such an event, the view shows a turn as
309
+ * about to start. Defaults to none.
310
+ */
311
+ readonly wakes?: ReadonlySet<string> | undefined;
312
+ }
313
+ /**
314
+ * Returns a chat's view, built from the entries of its log.
315
+ *
316
+ * **When to use**
317
+ *
318
+ * Use it in server-side code, for example to return a whole chat at once. A client gets the view
319
+ * as a stream from {@link updates} instead.
320
+ *
321
+ * **Example** (Building a chat's view from its log)
322
+ *
323
+ * ```ts
324
+ * import { type ChatId, ChatLog, ChatView } from "effect-assistant"
325
+ * import * as Effect from "effect/Effect"
326
+ *
327
+ * const viewOf = (chatId: ChatId.ChatId) =>
328
+ * ChatLog.ChatLog.use((log) => log.read(chatId)).pipe(
329
+ * Effect.map((entries) => ChatView.fromEntries(entries))
330
+ * )
331
+ * ```
332
+ *
333
+ * @see {@link updates} for a stream of changes instead of a whole view
334
+ *
335
+ * @category constructors
336
+ * @since 0.1.0
337
+ */
338
+ export declare const fromEntries: (entries: ReadonlyArray<AnyEntry>, options?: Options) => View;
339
+ /**
340
+ * Represents an assistant's definition as {@link updates} reads it: the app's events it
341
+ * registered, and whether each one wakes a turn. An assistant made with `Assistant.make` fits it.
342
+ *
343
+ * @category models
344
+ * @since 0.1.0
345
+ */
346
+ export interface Definition {
347
+ readonly events: ReadonlyArray<{
348
+ readonly tag: string;
349
+ readonly wakes: boolean;
350
+ }>;
351
+ }
352
+ /**
353
+ * Represents the options accepted by {@link updates}.
354
+ *
355
+ * @category models
356
+ * @since 0.1.0
357
+ */
358
+ export interface UpdatesOptions {
359
+ /**
360
+ * The `seq` up to which the client already has the view. The result contains only the updates
361
+ * after it. Defaults to `0`, every update.
362
+ */
363
+ readonly after?: number | undefined;
364
+ }
365
+ /**
366
+ * Returns the stream of view updates that a chat's entries produce, for a chat client.
367
+ *
368
+ * **Details**
369
+ *
370
+ * The entries must stream from the start of the chat's log, as `assistant.subscribe(chatId)` does
371
+ * without `after`. The fold reads every entry, because a message's view depends on earlier
372
+ * entries: a block is answered or closed later. `after` only skips
373
+ * emitting the updates up to that `seq`, so a client that has the view up to a `seq` receives only
374
+ * what changed since. Pass `after` here, not to `subscribe`: a subscription that starts after a
375
+ * `seq` gives the fold an incomplete log, and the updates it produces are wrong.
376
+ *
377
+ * The definition tells the fold which of the app's events wake a turn, so the view shows a turn as
378
+ * about to start after one. Each chunk of entries becomes one update; the stored entries, for
379
+ * example, arrive as one chunk.
380
+ *
381
+ * **Example** (Streaming a chat's view to a client)
382
+ *
383
+ * ```ts
384
+ * import { Assistant, type ChatId, ChatView } from "effect-assistant"
385
+ * import * as Stream from "effect/Stream"
386
+ *
387
+ * const MyAssistant = Assistant.make("my-assistant")
388
+ *
389
+ * const watch = (chatId: ChatId.ChatId, after: number) =>
390
+ * Stream.unwrap(
391
+ * MyAssistant.useSync((assistant) =>
392
+ * assistant.subscribe(chatId).pipe(ChatView.updates(MyAssistant, { after }))
393
+ * )
394
+ * )
395
+ * ```
396
+ *
397
+ * @see {@link apply} for folding the updates into a view on the client
398
+ *
399
+ * @category utils
400
+ * @since 0.1.0
401
+ */
402
+ export declare const updates: {
403
+ (definition: Definition, options?: UpdatesOptions): <E, R>(entries: Stream.Stream<AnyEntry, E, R>) => Stream.Stream<Update, E, R>;
404
+ <E, R>(entries: Stream.Stream<AnyEntry, E, R>, definition: Definition, options?: UpdatesOptions): Stream.Stream<Update, E, R>;
405
+ };
406
+ //#endregion
407
+ export { ChatView_d_exports };
408
+ //# sourceMappingURL=ChatView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatView.d.ts","names":[],"sources":["../src/ChatView.ts"],"mappings":";;;;;;;;;;;;;;qBA+Ba,aAAW,OAAA;;;;;;;YAQZ,qBAAqB,YAAY;;;;;;;;;qBAUhC,OAAK,OAAA;;;;;;;;;;;;YAaN,eAAe,MAAM;;;;;;;;qBASpB,aAAW,OAAA;;;;;;;;;;;;;;;;;YAaZ,qBAAqB,YAAY;;;;;;;qBAQhC,kBAAgB,OAAA;;;;;;;;;;;;;;;;;YAajB,0BAA0B,iBAAiB;;;;;;;qBAQ1C,SAAO,OAAA,gBAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;YAQR,iBAAiB,QAAQ;;;;;;;;qBASxB,mBAAiB,OAAA;;;;;;;;;;YAWlB,2BAA2B,kBAAkB;;;;;;;;;;;qBAY5C,UAAQ,OAAA;;;;;;;;;;;;;YAWT,kBAAkB,SAAS;;;;;;;;;qBAU1B,MAAI,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAgBL,cAAc,KAAK;;;;;;;;;;;;qBAalB,QAAM,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAcP,gBAAgB,OAAO;;;;;;;;qBAStB,OAAO;;;;;;;;;;;;;;qBAqBP,QAAK,MAAU,MAAI,QAAU,WAAS;;;;;;;;qBAuBtC,SAAM,MAAU;;;;;;;iBAQZ;;;;;WAKN,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA4BN,cAAW,SAAa,cAAc,WAAwB,UAAY,YAAU;;;;;;;;iBAoLhF;WACN,QAAQ;aAAyB;aAAsB;;;;;;;;;iBASjD;;;;;WAKN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA2CE;GAET,YAAY,YACZ,UAAU,kBACR,GAAG,GAAG,SAAS,OAAO,OAAO,UAAyB,GAAG,OAAO,OAAO,OAAO,QAAQ,GAAG;GAC5F,GAAG,GACF,SAAS,OAAO,OAAO,UAAyB,GAAG,IACnD,YAAY,YACZ,UAAU,iBACT,OAAO,OAAO,QAAQ,GAAG"}