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