@restatedev/agents 0.3.0 → 0.4.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 (136) hide show
  1. package/README.md +89 -49
  2. package/dist/calls.d.ts +29 -5
  3. package/dist/calls.d.ts.map +1 -1
  4. package/dist/calls.js +77 -10
  5. package/dist/calls.js.map +1 -1
  6. package/dist/claude/index.d.ts +36 -7
  7. package/dist/claude/index.d.ts.map +1 -1
  8. package/dist/claude/index.js +232 -151
  9. package/dist/claude/index.js.map +1 -1
  10. package/dist/client.d.ts +12 -3
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/client.js.map +1 -1
  13. package/dist/common.d.ts +151 -70
  14. package/dist/common.d.ts.map +1 -1
  15. package/dist/common.js +246 -204
  16. package/dist/common.js.map +1 -1
  17. package/dist/conversation.d.ts +466 -0
  18. package/dist/conversation.d.ts.map +1 -0
  19. package/dist/conversation.js +1247 -0
  20. package/dist/conversation.js.map +1 -0
  21. package/dist/deepseek/index.d.ts +38 -5
  22. package/dist/deepseek/index.d.ts.map +1 -1
  23. package/dist/deepseek/index.js +322 -106
  24. package/dist/deepseek/index.js.map +1 -1
  25. package/dist/deepseek/persistence.d.ts +9 -3
  26. package/dist/deepseek/persistence.d.ts.map +1 -1
  27. package/dist/deepseek/persistence.js +12 -6
  28. package/dist/deepseek/persistence.js.map +1 -1
  29. package/dist/index.d.ts +2 -2
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +2 -3
  32. package/dist/index.js.map +1 -1
  33. package/dist/langgraph/checkpointer.d.ts +16 -2
  34. package/dist/langgraph/checkpointer.d.ts.map +1 -1
  35. package/dist/langgraph/checkpointer.js +133 -26
  36. package/dist/langgraph/checkpointer.js.map +1 -1
  37. package/dist/langgraph/context.d.ts +10 -0
  38. package/dist/langgraph/context.d.ts.map +1 -0
  39. package/dist/langgraph/context.js +21 -0
  40. package/dist/langgraph/context.js.map +1 -0
  41. package/dist/langgraph/errors.d.ts +16 -0
  42. package/dist/langgraph/errors.d.ts.map +1 -0
  43. package/dist/langgraph/errors.js +30 -0
  44. package/dist/langgraph/errors.js.map +1 -0
  45. package/dist/langgraph/graph.d.ts +25 -0
  46. package/dist/langgraph/graph.d.ts.map +1 -0
  47. package/dist/langgraph/graph.js +346 -0
  48. package/dist/langgraph/graph.js.map +1 -0
  49. package/dist/langgraph/index.d.ts +65 -12
  50. package/dist/langgraph/index.d.ts.map +1 -1
  51. package/dist/langgraph/index.js +227 -171
  52. package/dist/langgraph/index.js.map +1 -1
  53. package/dist/langgraph/nodes.d.ts +70 -0
  54. package/dist/langgraph/nodes.d.ts.map +1 -0
  55. package/dist/langgraph/nodes.js +145 -0
  56. package/dist/langgraph/nodes.js.map +1 -0
  57. package/dist/messages.d.ts +18 -0
  58. package/dist/messages.d.ts.map +1 -0
  59. package/dist/messages.js +182 -0
  60. package/dist/messages.js.map +1 -0
  61. package/dist/object.d.ts +65 -23
  62. package/dist/object.d.ts.map +1 -1
  63. package/dist/object.js +121 -35
  64. package/dist/object.js.map +1 -1
  65. package/dist/output.d.ts +15 -7
  66. package/dist/output.d.ts.map +1 -1
  67. package/dist/output.js +44 -26
  68. package/dist/output.js.map +1 -1
  69. package/dist/pi/index.d.ts +39 -11
  70. package/dist/pi/index.d.ts.map +1 -1
  71. package/dist/pi/index.js +281 -77
  72. package/dist/pi/index.js.map +1 -1
  73. package/dist/pi/storage.d.ts +29 -4
  74. package/dist/pi/storage.d.ts.map +1 -1
  75. package/dist/pi/storage.js +18 -6
  76. package/dist/pi/storage.js.map +1 -1
  77. package/dist/signals.d.ts +74 -4
  78. package/dist/signals.d.ts.map +1 -1
  79. package/dist/signals.js +144 -15
  80. package/dist/signals.js.map +1 -1
  81. package/dist/steering.d.ts +31 -0
  82. package/dist/steering.d.ts.map +1 -0
  83. package/dist/steering.js +45 -0
  84. package/dist/steering.js.map +1 -0
  85. package/dist/tools.d.ts +28 -0
  86. package/dist/tools.d.ts.map +1 -1
  87. package/dist/tools.js +34 -5
  88. package/dist/tools.js.map +1 -1
  89. package/package.json +33 -37
  90. package/src/calls.ts +107 -15
  91. package/src/claude/README.md +41 -20
  92. package/src/claude/index.ts +266 -178
  93. package/src/client.ts +14 -3
  94. package/src/common.ts +317 -232
  95. package/src/conversation.ts +1527 -0
  96. package/src/deepseek/README.md +78 -11
  97. package/src/deepseek/index.ts +384 -137
  98. package/src/deepseek/persistence.ts +11 -8
  99. package/src/index.ts +13 -4
  100. package/src/langgraph/README.md +115 -25
  101. package/src/langgraph/checkpointer.ts +168 -28
  102. package/src/langgraph/context.ts +27 -0
  103. package/src/langgraph/errors.ts +26 -0
  104. package/src/langgraph/graph.ts +396 -0
  105. package/src/langgraph/index.ts +326 -181
  106. package/src/langgraph/nodes.ts +243 -0
  107. package/src/messages.ts +244 -0
  108. package/src/object.ts +167 -38
  109. package/src/output.ts +52 -31
  110. package/src/pi/README.md +18 -3
  111. package/src/pi/index.ts +346 -78
  112. package/src/pi/storage.ts +20 -7
  113. package/src/signals.ts +225 -19
  114. package/src/steering.ts +67 -0
  115. package/src/tools.ts +61 -8
  116. package/dist/claude/conversation.d.ts +0 -33
  117. package/dist/claude/conversation.d.ts.map +0 -1
  118. package/dist/claude/conversation.js +0 -95
  119. package/dist/claude/conversation.js.map +0 -1
  120. package/dist/log.d.ts +0 -29
  121. package/dist/log.d.ts.map +0 -1
  122. package/dist/log.js +0 -146
  123. package/dist/log.js.map +0 -1
  124. package/dist/opencode/db.d.ts +0 -40
  125. package/dist/opencode/db.d.ts.map +0 -1
  126. package/dist/opencode/db.js +0 -161
  127. package/dist/opencode/db.js.map +0 -1
  128. package/dist/opencode/index.d.ts +0 -100
  129. package/dist/opencode/index.d.ts.map +0 -1
  130. package/dist/opencode/index.js +0 -436
  131. package/dist/opencode/index.js.map +0 -1
  132. package/src/claude/conversation.ts +0 -114
  133. package/src/log.ts +0 -194
  134. package/src/opencode/README.md +0 -125
  135. package/src/opencode/db.ts +0 -223
  136. package/src/opencode/index.ts +0 -559
@@ -0,0 +1,466 @@
1
+ import * as restate from '@restatedev/sessions';
2
+ import type { Database, DatabaseReader, DatabaseWriter, Transaction } from '@restatedev/sessions';
3
+ import { Schema } from '@restatedev/sessions/internal';
4
+ import { type Check, type Window } from './common.ts';
5
+ /** The transcript: one row per turn. */
6
+ export declare const TURNS = "restate_agent_turns";
7
+ /** The trajectories: the items of each turn but its prompt. */
8
+ export declare const STEPS = "restate_agent_items";
9
+ /** Where the conversation starts: its first position, the last `seq` given, and the summary of the earliest turns. */
10
+ export declare const START = "restate_agent_conversation_start";
11
+ /** The Python SDK's snapshots, which this package does not take (docs/plan.md, D3): created, never written. */
12
+ export declare const SNAPSHOTS = "restate_agent_snapshots";
13
+ /**
14
+ * The messages steered to a turn that it took ({@link Turn.steer}): which
15
+ * items of the trajectories they are, by position, and their ids, each
16
+ * stored once.
17
+ */
18
+ export declare const STEERED = "restate_agent_steers";
19
+ /** The conversation's tables: the Python SDK's, step for step, so that both SDKs read each other's. */
20
+ export declare const SCHEMA: Schema;
21
+ /**
22
+ * How a turn ended: answered by its run, or closed: stopped, failed for
23
+ * good, refused by the model's provider, or ended by another invocation once
24
+ * its own was gone ({@link ENDED}).
25
+ */
26
+ export type Status = 'answered' | 'cancelled' | 'failed' | 'refused' | 'ended';
27
+ /** A tool call an item makes. */
28
+ export interface Call {
29
+ id: string;
30
+ name: string;
31
+ input: unknown;
32
+ }
33
+ /** A tool call's result an item holds: an error if `error`, or if its output starts with `Error: `. */
34
+ export interface Result {
35
+ id: string;
36
+ output: string;
37
+ error?: boolean;
38
+ }
39
+ /** Whether `result` is an error: marked as one, or `Error: <message>`. */
40
+ export declare const failed: (result: Result) => boolean;
41
+ /** What an item is, as {@link Items.read} reads it. */
42
+ export interface Parsed {
43
+ /** The role and text of a message; none for any other item. */
44
+ said?: ['user' | 'assistant', string];
45
+ calls?: Call[];
46
+ results?: Result[];
47
+ }
48
+ /** A framework's items: how the core stores, reads and makes them. */
49
+ export interface Items<I> {
50
+ /** `item` as it is stored: its JSON, most often. */
51
+ dump(item: I): string;
52
+ /**
53
+ * The item `dump` stored as `stored`. It throws for a row it cannot read
54
+ * (another framework's), which {@link loadItem} makes a terminal error.
55
+ */
56
+ load(stored: string): I;
57
+ /** The item of a prompt (the user's message). */
58
+ prompt(text: string): I;
59
+ /** The item of an assistant's message of `text`, from `agent` if known: it closes a run, and is an earlier turn's answer as the model sees it. */
60
+ reply(text: string, agent?: string): I;
61
+ /** The items that give each call its result, as text: they close a run's cut-off calls. */
62
+ results(results: [Call, string][]): I[];
63
+ /** What `item` says, and the tool calls and results it holds. */
64
+ read(item: I): Parsed;
65
+ /** The summary of the earliest turns in the framework's own form; by default a user's message and "Understood." */
66
+ summary?(text: string): I[];
67
+ /**
68
+ * The item of the message `steerId` steered to a turn, with `text`, to
69
+ * tell it apart from a prompt in the framework's runs (LangGraph's has
70
+ * the id `steer:<steerId>`); by default, a prompt's item.
71
+ */
72
+ steered?(text: string, steerId: string): I;
73
+ }
74
+ /** What the user's message with the summary of the earliest turns starts with. */
75
+ export declare const SUMMARY = "A summary of our conversation so far:\n\n";
76
+ /** The items that give the model `summary`, of the earliest turns: `items.summary`'s, if it has one. */
77
+ export declare const summaryItems: <I>(items: Items<I>, summary: string) => I[];
78
+ /** The item of the message `steerId` steered to a turn, with `text`: `items.steered`'s, if it has one. */
79
+ export declare const steeredItem: <I>(items: Items<I>, text: string, steerId: string) => I;
80
+ /** An item of the conversation, with what it is part of. */
81
+ export interface Entry<I> {
82
+ /** Its position: the conversation is ordered by it. */
83
+ n: number;
84
+ item: I;
85
+ /** The id of the prompt it is, if it is one: it starts a turn. */
86
+ prompt?: string;
87
+ /** On a prompt: its turn's answer, once it has one. */
88
+ answer?: string;
89
+ /** The id of the model's reply it is part of: the position of the reply's first item. */
90
+ reply?: number;
91
+ /** The agent that gave the reply; on a prompt, the agent the conversation is with after its turn. */
92
+ agent?: string;
93
+ /** What `item` is, read once (`Items.read`), as the conversation loads or appends it. */
94
+ parsed?: Parsed;
95
+ /** The position of its turn's prompt. */
96
+ turn?: number;
97
+ /** On a prompt: the framework's state as of its turn's end, if it carries one. */
98
+ carried?: string;
99
+ /** On a prompt: how its turn ended, once it did. */
100
+ status?: Status;
101
+ /** On a prompt: the position of its turn's answer, its last message of the assistant. */
102
+ answeredAt?: number;
103
+ /** On a prompt: the `seq` given as its turn was answered. */
104
+ answeredSeq?: number;
105
+ /** On a prompt: when its turn's row was stored, in Unix milliseconds. */
106
+ askedAt?: number;
107
+ /** The id of the steered message it is, if it is one: a message of the user that its turn took at a step. */
108
+ steer?: string;
109
+ /**
110
+ * On a prompt of the transcript: the messages steered to its turn that it
111
+ * took, in order, which the model sees between its message and its answer
112
+ * once the turn is before the window.
113
+ */
114
+ steers?: Entry<I>[];
115
+ }
116
+ /** Where a conversation starts: its first position, the last `seq` given, and the summary of the earliest turns. */
117
+ export interface Start {
118
+ n: number;
119
+ seq: number;
120
+ summary?: string;
121
+ /** The position of the first turn after the summary: those before it are the summary, as the model sees them. */
122
+ summarized?: number;
123
+ }
124
+ /** Where the conversation in `db` starts, as `clear`, drops and summaries left it. */
125
+ export declare function startOf(db: DatabaseReader): Promise<Start>;
126
+ /** The last position of `db`'s rows (none if it has none), and the last `seq` they have (or 0). */
127
+ export declare function lastOf(db: DatabaseReader): Promise<[last: number | undefined, seq: number]>;
128
+ /** Where the next conversation starts, past the positions and `seq` of the one in `db`. */
129
+ export declare function nextStart(db: DatabaseReader): Promise<Start>;
130
+ /** Store `start` as where the conversation starts: in the transaction of `clear` that emptied it, say. */
131
+ export declare function restart(tx: DatabaseWriter, start: Start): Promise<void>;
132
+ /** The stored answer of prompt `promptId`, and how its turn ended, if it has one: one read, of the turn's row. */
133
+ export declare function answerIn(db: DatabaseReader, promptId: string): Promise<{
134
+ answer: string;
135
+ status: Status;
136
+ } | undefined>;
137
+ /** The index in `turns` (prompts, in order) of the first turn in `window` (see {@link Walk}). */
138
+ export declare function windowStart<I>(turns: readonly Entry<I>[], window: Window): number;
139
+ /** Runs its bodies one after another: writes that come at once (parallel tool calls') each get positions of their own. */
140
+ declare class Lock {
141
+ #private;
142
+ run<T>(body: () => Promise<T>): Promise<T>;
143
+ }
144
+ /** What a conversation and its turns share: the database, the next position and `seq`, and the writes' lock. */
145
+ declare class Ledger<I> {
146
+ /** The latest turn, if loaded whole: the only one that may be written. */
147
+ latest: Turn<I> | undefined;
148
+ /** Whether {@link Conversation.seal} closed the conversation to writes. */
149
+ closed: boolean;
150
+ readonly lock: Lock;
151
+ /** The ids of the tool calls made in the loaded turns. */
152
+ readonly ids: Set<string>;
153
+ /** Whether a call's id an earlier call has was logged: once is enough. */
154
+ warned: boolean;
155
+ readonly db: Database;
156
+ readonly items: Items<I>;
157
+ start: Start;
158
+ /** The turns' prompts, in order: the latest is the latest turn's. */
159
+ readonly transcript: Entry<I>[];
160
+ /** The next position to give. */
161
+ next: number;
162
+ /** The last `seq` given. */
163
+ seq: number;
164
+ constructor(db: Database, items: Items<I>, start: Start, transcript: Entry<I>[], next: number, seq: number);
165
+ /** Note a tool call's id, and log one that an earlier call has (once). */
166
+ called(callId: string): void;
167
+ checkOpen(): void;
168
+ /** The agent and the framework's state that the latest answered turn left. */
169
+ carried(): [agent: string | undefined, carried: string | undefined];
170
+ }
171
+ /**
172
+ * One turn of the conversation: its prompt, and what its run stored to
173
+ * answer it. A turn's rows are read and written here, and only here: its
174
+ * open tool calls, its replies and its final reply are this turn's, never
175
+ * another's. Only the latest turn, while it has no answer, can be written:
176
+ * by its own run, or by whoever closes it ({@link Turn.close}), once its run
177
+ * is gone.
178
+ */
179
+ export declare class Turn<I> {
180
+ #private;
181
+ /** The turn's row: its prompt, and once it has them, its status, answer and what it carried. */
182
+ readonly prompt: Entry<I>;
183
+ /**
184
+ * What the model is told after the turn's prompt, where it reads it last
185
+ * (`output`'s ask for JSON), and never stored: the conversation keeps the
186
+ * prompt as it was asked. `history()` adds it to the prompt; a framework
187
+ * that keeps its own history adds it to the prompt it is given.
188
+ */
189
+ reminder: string | undefined;
190
+ constructor(ledger: Ledger<I>, prompt: Entry<I>, items?: Entry<I>[]);
191
+ /** The turn's id: its prompt's. */
192
+ get id(): string;
193
+ /** The turn's position: its prompt's, the id of its user's message. */
194
+ get n(): number;
195
+ /** How the turn ended, or none while it is being answered. */
196
+ get status(): Status | undefined;
197
+ /** The turn's answer, once it has one: the run's, or the note that closed it. */
198
+ get answer(): string | undefined;
199
+ /** The turn's entries, in order: its prompt, then its items. */
200
+ get entries(): readonly Entry<I>[];
201
+ /** The turn's items, in order: the model's replies, the tool calls' results... */
202
+ get items(): readonly Entry<I>[];
203
+ /** The ids of the model's replies in the turn, in order. */
204
+ replies(): number[];
205
+ /** The id of the model's reply the turn ends with, if it ends with one. */
206
+ lastReply(): number | undefined;
207
+ /** The entries of the model's reply `reply`, in order: they follow one another, from position `reply`. */
208
+ replyEntries(reply: number): readonly Entry<I>[];
209
+ /** The agent that gave the model's reply `reply`. */
210
+ agentOf(reply: number): string | undefined;
211
+ /** The text of the model's reply the turn ends with, if it ends the run: text, and no tool calls. */
212
+ finalReply(): string | undefined;
213
+ /** The turn's tool calls without a result, in the order they were made. */
214
+ openCalls(): Call[];
215
+ /**
216
+ * The turn's latest message of the user that asks for its answer: its
217
+ * prompt, or the message that asked again ({@link askAgain}). A framework
218
+ * that runs from a message of its own runs from this one. A steered
219
+ * message ({@link steer}) is not one: the model reads it within the run,
220
+ * which goes on from the same ask.
221
+ */
222
+ latestAsk(): Entry<I>;
223
+ /** The messages steered to the turn that it took, in order. */
224
+ steered(): Entry<I>[];
225
+ /** Whether the turn's tool call `callId` has a result. */
226
+ hasResult(callId: string): boolean;
227
+ /** Whether tool call `callId` has its result: not an error, unless it is `failed`, its own. */
228
+ stored(callId: string, failedWith?: string): boolean;
229
+ /** Append `items` (a tool's results, say) to the turn, in one transaction; appends at once are each stored after the ones before. */
230
+ append(...items: I[]): Promise<void>;
231
+ /** Append the model's reply, of `items` (given by `agent`), to the turn, and return its id. */
232
+ appendReply(items: I[], agent?: string): Promise<number>;
233
+ /**
234
+ * Ask the model again within the turn, with `text`: a message of the user
235
+ * that is a step of the turn, not a turn of its own (the transcript, and
236
+ * the summary view, have the turn's prompt and its answer).
237
+ */
238
+ askAgain(text: string): Promise<void>;
239
+ /**
240
+ * Store the steered `messages` that the turn has not taken yet as steps of
241
+ * the turn, and return their items. Each is stored once, by its id, as a
242
+ * message of the user (as `Items.steered` makes it) after the turn's steps
243
+ * before: the model reads it in its next request, and in every turn's
244
+ * history after, between the turn's message and its answer. `taken` adds
245
+ * what goes out with the transaction that stores them (the companion's
246
+ * `taken`), which commits once.
247
+ *
248
+ * `going` tells whether the turn still goes on: once it has the ledger, a
249
+ * turn that stopped meanwhile takes none, which are then answered as turns
250
+ * of their own. A store under way finishes even if the turn stops: the
251
+ * turn then closes after it, at the positions after its messages, and the
252
+ * messages are its own (stopped with it).
253
+ */
254
+ steer(messages: readonly {
255
+ id: string;
256
+ text: string;
257
+ }[], taken: (tx: Transaction, ids: string[]) => void, going: () => boolean): Promise<I[]>;
258
+ /**
259
+ * Keep what the turn carries to the turns after it, stored with its
260
+ * answer: `agent`, the agent the conversation is with (by default, its
261
+ * latest reply's, else the previous turn's); `state`, the framework's own,
262
+ * as text (by default, the previous turn's).
263
+ */
264
+ carry({ agent, state }: {
265
+ agent?: string;
266
+ state?: string;
267
+ }): void;
268
+ /**
269
+ * Drop the turn's reply `reply`, and what came after it, to ask the model
270
+ * again: one range delete. The positions are given again, so the new
271
+ * reply's messages take the dropped ones' ids; the `seq` is kept, so that
272
+ * a client's cursor still sees them. A steered message after the reply is
273
+ * dropped too: it is no longer the turn's, so the agent's `steered`
274
+ * answers it as a turn of its own.
275
+ */
276
+ drop(reply: number): Promise<void>;
277
+ /**
278
+ * Store the turn's `answer`, how it ended (`status`) and what it carries,
279
+ * in one update of its row. The answer's message is the assistant's
280
+ * message the turn ends with; a turn that ends otherwise gets `answer` as
281
+ * its reply first, and an empty answer gets none.
282
+ */
283
+ answered(answer: string, status?: Status): Promise<void>;
284
+ /**
285
+ * Close the turn (stopped, refused, failed, or ended once its invocation is
286
+ * gone) with `note`. Each tool call without a result gets one: the error
287
+ * its Restate call answered with, a note that it did happen if it
288
+ * answered, or else `note` ({@link cutOffResult}). Then `note` is the
289
+ * turn's last message, and its answer. The calls' outcomes are those of the
290
+ * invocation that made the turn's prompt: this one, or an earlier one whose
291
+ * calls are still stored. A turn with its answer has nothing to close.
292
+ */
293
+ close(ctx: restate.SessionContext, status: Status, note: string): Promise<void>;
294
+ /** Whether the turn's run can write it: the latest, without an answer, not being closed, of a conversation not sealed. */
295
+ get writable(): boolean;
296
+ /**
297
+ * Copy a framework's own messages into the turn, in `tx`, a transaction of
298
+ * the framework's own store (its write of these messages): the rows commit
299
+ * with it, so the copy is made once, however often the attempt crashes.
300
+ * Each of `items` is a reply of the model (`reply`, from `agent`), a
301
+ * message steered to the turn that its framework placed (`steer`, its id:
302
+ * stored once, in the steered messages' table too), or another item (a
303
+ * tool's result). For a framework that keeps its own history. It cannot wait for the turn's other writes inside `tx`, which
304
+ * holds the database: it takes its positions, and adds its entries, at
305
+ * once, so that a close after it sees them and writes after them. A turn
306
+ * being closed (or closed) takes no copy: its close says how it ended.
307
+ * Whether it copied.
308
+ */
309
+ copyIn(tx: DatabaseWriter, items: {
310
+ item: I;
311
+ reply?: boolean;
312
+ agent?: string;
313
+ steer?: string;
314
+ }[]): Promise<boolean>;
315
+ }
316
+ /** How many turns of the transcript a load reads at a time, from the latest back. */
317
+ export declare const PAGE = 64;
318
+ /**
319
+ * The item stored as `stored`, or a terminal error: a retry would read the
320
+ * same row again. A row that `items` cannot read was stored by an agent of
321
+ * another framework under the same name, or by another version of this one.
322
+ */
323
+ export declare function loadItem<I>(items: Items<I>, stored: string): I;
324
+ /**
325
+ * Whether a turn took the steered message `steerId`, in a database that may
326
+ * not have the conversation yet (the agent's `steered` asks, which may be
327
+ * the key's first handler).
328
+ */
329
+ export declare function steerStored(db: DatabaseReader, steerId: string): Promise<boolean>;
330
+ /**
331
+ * The conversation in the key's database, loaded once and kept in step with
332
+ * it: the transcript, every turn's prompt and answer, as far back as a turn
333
+ * needs it; and the window, the latest turns whole ({@link Turn}). Only the
334
+ * latest turn is written; the conversation composes the turns into what the
335
+ * model gets ({@link history}), until {@link seal} closes it.
336
+ *
337
+ * Tool calls and their results are matched by the call's id, within a turn:
338
+ * each call's id must be its own, as model providers make them. A call whose
339
+ * id an earlier call has is logged, as its result may be taken for the
340
+ * other's.
341
+ */
342
+ export declare class Conversation<I> {
343
+ #private;
344
+ readonly items: Items<I>;
345
+ readonly budget: number;
346
+ /** How many of the latest answered turns are loaded whole: the window's size. */
347
+ readonly size: Window;
348
+ readonly db: Database;
349
+ constructor(db: Database, items: Items<I>, entries: Entry<I>[], { start, transcript, last, seq, budget, window, }?: {
350
+ start?: Start;
351
+ transcript?: Entry<I>[];
352
+ last?: number;
353
+ seq?: number;
354
+ budget?: number;
355
+ window?: Window;
356
+ });
357
+ /**
358
+ * Load the conversation from `db`: the transcript, and the window's turns
359
+ * whole (the latest also while it has no answer). The transcript is read
360
+ * from the latest turn back, in pages, until it holds the window and the
361
+ * turns before it that `budget` holds, or the summary's start; with
362
+ * `complete`, from the summary's start whatever the budget (to summarize
363
+ * it).
364
+ */
365
+ static load<I>(db: Database, items: Items<I>, window?: Window, budget?: number, { complete }?: {
366
+ complete?: boolean;
367
+ }): Promise<Conversation<I>>;
368
+ /** The turns' prompts, in order, from the first the load read. Each has its turn's status, answer and what it carried. */
369
+ get transcript(): readonly Entry<I>[];
370
+ /** The window's turns, whole, in order: the last of them is the latest turn. */
371
+ get turns(): readonly Turn<I>[];
372
+ /** The latest turn: the one being answered, during a run. */
373
+ get turn(): Turn<I>;
374
+ /** The latest turn if it is being answered: it has no answer yet. */
375
+ running(): Turn<I> | undefined;
376
+ /** The window's turns, flat, in order: each prompt, then its turn's items. */
377
+ get entries(): Entry<I>[];
378
+ /** The summary of the turns before the transcript, if they have one (and the transcript is after them). */
379
+ get summary(): string | undefined;
380
+ /** Whether {@link seal} closed the conversation to writes. */
381
+ get closed(): boolean;
382
+ /** The answer of the turn of prompt `promptId`, if the transcript has it and it has one. */
383
+ answerOf(promptId: string): string | undefined;
384
+ /** The agent the conversation is with, and the framework's state, as the latest answered turn left them. */
385
+ carried(): [agent: string | undefined, carried: string | undefined];
386
+ /** Whether a turn of the window holds the result of tool call `callId`: the model was given it. */
387
+ knowsResult(callId: string): boolean;
388
+ /** The position of the window's first turn: the turns before it are in the transcript only. */
389
+ window(): number;
390
+ /** The turns before the window that {@link history} gives the model: the latest that `budget` holds. */
391
+ earlier(): Entry<I>[];
392
+ /** Whether the turns before the next turn's window outgrow `budget`: then they are summarized. */
393
+ overflowing(): boolean;
394
+ /**
395
+ * The turns to summarize, and the position of the first turn after them,
396
+ * if any are to be: the turns before the next turn's window but the latest
397
+ * that half the `budget` holds, which stay as they are.
398
+ */
399
+ toSummarize(): [Entry<I>[], number] | undefined;
400
+ /**
401
+ * The items the model gets, in order, the one place where turns are made
402
+ * one flat list: the summary of the earliest turns, if they have one; the
403
+ * turns before the window, as their prompts, the messages steered to them
404
+ * and their answers, as many of the latest as `budget` holds; then the
405
+ * window's turns, whole.
406
+ */
407
+ history(): I[];
408
+ /** Start the turn of prompt `promptId`, with `text`, and return it: the latest turn now. */
409
+ ask(promptId: string, text: string): Promise<Turn<I>>;
410
+ /**
411
+ * Close the conversation to writes, once those under way are stored: for
412
+ * a stopped run, which (unwinding, or a promise of it left behind) stores
413
+ * nothing more once its turn is closed.
414
+ */
415
+ seal(): Promise<void>;
416
+ }
417
+ /**
418
+ * A framework's run: from the conversation, whose latest turn
419
+ * (`conversation.turn`) is the one to answer (just asked, or left unfinished
420
+ * by an earlier attempt), to its answer. It reads what the model gets from
421
+ * the conversation (`history()`), and stores each step in the turn as it
422
+ * goes. A tool's error fails the attempt.
423
+ */
424
+ export type Run<I> = (conversation: Conversation<I>) => Promise<string>;
425
+ /** The id of the invocation that made prompt `promptId` (see `nextPromptId`). */
426
+ export declare const invocationOf: (promptId: string) => string;
427
+ /**
428
+ * Answer the prompt `text` with a framework's `run`, once. The prompt's id is
429
+ * the invocation's (`nextPromptId`), so a retried attempt returns the stored
430
+ * answer (reading only it), or goes on with the turn. A turn an earlier
431
+ * invocation left without an answer is closed first ({@link ENDED}): that
432
+ * invocation is gone. `items` must be the agent's `messages` view's, if it
433
+ * has one: one framework per agent.
434
+ *
435
+ * `window` and `budget` are the agent's unless given; with `ownHistory`
436
+ * (the framework keeps the model's history itself), none: only the latest
437
+ * turns are read, and the agent's `summarize` is not for it. With `check`, the
438
+ * answer is checked: a message it returns asks the model again with it,
439
+ * once, as a step of the turn ({@link Turn.askAgain}), and the turn's answer
440
+ * is the reply to that. With `reminder`, the model is told it after the
441
+ * prompt ({@link Turn.reminder}), which is stored as it was asked.
442
+ */
443
+ export declare function answerOnce<I>(ctx: restate.SessionContext, text: string, items: Items<I>, run: Run<I>, options?: {
444
+ window?: Window;
445
+ budget?: number;
446
+ check?: Check;
447
+ reminder?: string;
448
+ ownHistory?: boolean;
449
+ }): Promise<string>;
450
+ /**
451
+ * Close the latest turn (`ended`) if invocation `invocationId` made it and
452
+ * left it without an answer: the companion has this done when it finds the
453
+ * turn's invocation gone. A turn with its answer (closed by a newer turn
454
+ * first, say) is left as it is. Whether it closed the turn.
455
+ */
456
+ export declare function settle<I>(ctx: restate.SessionContext, items: Items<I>, invocationId: string): Promise<boolean>;
457
+ /**
458
+ * Summarize the turns before the window that outgrow the agent's budget,
459
+ * with the agent's `summarize`. The summary, of the earlier summary and those
460
+ * turns, takes their place in what the model sees; the turns stay stored,
461
+ * and `messages` shows them as before. A summary that fails is logged, and
462
+ * tried again after the next turn. Whether it summarized.
463
+ */
464
+ export declare function compact<I>(ctx: restate.SessionContext, items: Items<I>): Promise<boolean>;
465
+ export {};
466
+ //# sourceMappingURL=conversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"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