@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
package/dist/common.js CHANGED
@@ -1,11 +1,11 @@
1
1
  // What the frameworks share: their options (`Configure`, the model), the
2
2
  // ids of an invocation's prompts, the `chat` handler with its turn (status,
3
- // cancellation, publishing for the clients that follow it), and
4
- // the `messages` handler with its `Transcript`.
3
+ // cancellation, publishing for the clients that follow it), and what the
4
+ // conversation of turns (conversation.ts) takes: its notes, window and
5
+ // budget.
5
6
  import * as restate from '@restatedev/sessions';
6
7
  import { cancelCalls, cancelled, definitionOf, Link, ScopeKey } from '@restatedev/sessions/internal';
7
- import { settle } from './calls.js';
8
- import * as log from './log.js';
8
+ import { settleCalls } from './calls.js';
9
9
  import { signals, signalsOf } from './signals.js';
10
10
  /** `value` for the invocation of `ctx`. */
11
11
  export const configured = async (value, ctx) => typeof value === 'function' ? value(ctx) : value;
@@ -21,7 +21,7 @@ export const nextPromptId = (ctx) => {
21
21
  PROMPTS.set(ctx, n);
22
22
  return n === 1 ? ctx.request.id : `${ctx.request.id}:${n}`;
23
23
  };
24
- /** The default model of pi, OpenCode and LangGraph, with OPENAI_API_KEY. */
24
+ /** The default model of pi and LangGraph, with OPENAI_API_KEY. */
25
25
  export const DEFAULT_MODEL = 'openai/gpt-6-sol';
26
26
  /** The default model of Claude agents, with ANTHROPIC_API_KEY. */
27
27
  export const CLAUDE_MODEL = 'anthropic/claude-sonnet-5-5';
@@ -87,6 +87,11 @@ export const messageSerde = {
87
87
  }
88
88
  },
89
89
  };
90
+ /**
91
+ * What an empty answer says, as the model sees it later in the conversation:
92
+ * a provider's API may refuse an empty text (Anthropic's does).
93
+ */
94
+ export const NO_ANSWER = '(no answer)';
90
95
  /**
91
96
  * What a cancelled turn answers, and each tool call it cut off: the model
92
97
  * sees it in the conversation that goes on.
@@ -98,6 +103,38 @@ export const CANCELLED = 'Cancelled: the turn was stopped before it finished.';
98
103
  * conversation that goes on, rather than answer it with the next message.
99
104
  */
100
105
  export const UNANSWERED = "Unanswered: the model's provider refused the request.";
106
+ /**
107
+ * What a turn whose invocation ended without answering it (killed, say)
108
+ * answers, and each tool call it cut off: the next message, or the companion
109
+ * once it finds the invocation gone (`settle`), closes it with this.
110
+ */
111
+ export const ENDED = 'Ended: the turn ended before it finished, and was not answered.';
112
+ /** The result of a tool call a stopped turn cut off once its Restate call had answered: it happened. */
113
+ export const RETURNED_UNRECORDED = "Done, but the turn was stopped before this call's result was recorded: it did happen, so check its effect before doing it again.";
114
+ /**
115
+ * What a stopped turn records as the result of its tool call `callId`, which
116
+ * has none: `text` (cancelled, say), unless the call's Restate call answered
117
+ * (`outcomes` of calls.ts), which the model would take for undone, and do
118
+ * again: then the error it answered with, or {@link RETURNED_UNRECORDED}.
119
+ */
120
+ export function cutOffResult(outcomes, callId, text) {
121
+ if (!outcomes.has(callId))
122
+ return text;
123
+ return outcomes.get(callId) ?? RETURNED_UNRECORDED;
124
+ }
125
+ /** The window by default: the previous turn's tool calls and results stay in view, for a follow-up. */
126
+ export const WINDOW = 1;
127
+ /** How many tokens of the turns before the window the model sees, by default, counted as 4 characters each. */
128
+ export const BUDGET = 32_000;
129
+ /** What a request to summarize earlier turns starts with, before the turns themselves. */
130
+ export const SUMMARIZE = "Summarize the conversation below, for the assistant who carries it on: keep the facts, names, numbers, decisions, the user's preferences, and what is still open. Answer with the summary only.\n\n";
131
+ /** `window`, if it is one: a whole number of turns (0 or more), or `'all'`. */
132
+ export function checkWindow(window) {
133
+ if (window !== 'all' && !(Number.isInteger(window) && window >= 0)) {
134
+ throw new Error(`window must be a number of turns (0 or more) or 'all', not ${JSON.stringify(window)}`);
135
+ }
136
+ return window;
137
+ }
101
138
  /** What stops each turn, by its context: see {@link stopSignalOf}. */
102
139
  const TURN = new ScopeKey('stopSignalOf');
103
140
  /**
@@ -121,50 +158,86 @@ export class AttemptEnded extends Error {
121
158
  * answers nothing).
122
159
  */
123
160
  export const stopSignalOf = (ctx) => TURN.get(ctx);
124
- /** An agent's own, on its definition. */
161
+ /** An agent's settings, on its definition. */
125
162
  const AGENT = new Link('an agent');
126
- /** What a framework's `messages` view clears beside the agent's database: see {@link alsoClearing}. */
127
- const CLEARS = new Link('alsoClearing');
128
- /**
129
- * The `messages` view `view` of a framework that keeps a conversation apart
130
- * (OpenCode, in a database of its own): `clear` empties it too, as an agent
131
- * with this view is cleared.
132
- */
133
- export const alsoClearing = (view, clear) => {
134
- return CLEARS.on(view, clear);
135
- };
136
- /**
137
- * `definition` is an agent's: whether it runs in the background, and its
138
- * `messages` view, whose clearing (`alsoClearing`) its `clear` does too.
139
- */
140
- export const isAgent = (definition, { background = false, messages = undefined }) => {
141
- return AGENT.on(definition, { background, clear: messages && CLEARS.of(messages) });
163
+ /** The items of a framework's `messages` view on the conversation of turns. */
164
+ export const ITEMS = new Link('restate-agents.items');
165
+ /** `definition` is an agent's, with these settings: its framework's items, if it is on the conversation of turns. */
166
+ export const isAgent = (definition, { background = false, items = undefined, window = WINDOW, budget = BUDGET, summarize = undefined, }) => {
167
+ return AGENT.on(definition, {
168
+ background,
169
+ items,
170
+ window,
171
+ budget,
172
+ summarize,
173
+ });
142
174
  };
143
- /** The agent of `ctx`'s own (see {@link isAgent}). */
175
+ /** The settings of the agent of `ctx`, if it is one. */
144
176
  const agentOf = (ctx) => {
145
177
  const definition = definitionOf(ctx);
146
178
  return definition && AGENT.of(definition);
147
179
  };
148
- /** Clear what the agent of `ctx` keeps beside its database. */
149
- export const cleared = async (ctx) => agentOf(ctx)?.clear?.(ctx);
180
+ /** The settings of the agent of `ctx`: the defaults, for an object that is no agent. */
181
+ export const settingsOf = (ctx) => agentOf(ctx) ?? { background: false, window: WINDOW, budget: BUDGET };
150
182
  /** Whether the agent of `ctx` runs in the background. */
151
183
  const unfollowed = (ctx) => agentOf(ctx)?.background === true;
152
184
  /** The `signals` object of the agent of `ctx`. */
153
185
  const signalsOfAgent = (ctx) => ctx.rpc(signals, signalsOf(ctx));
154
186
  /**
155
- * The conversation of `ctx` changed (see `watch` in object.ts): its log takes
156
- * the change (while a framework answers: {@link transcribing}), its revision
157
- * increases, and the clients that follow it read it again. It is a call to
158
- * Restate, so it also sends what the handler wrote before, for them to read.
187
+ * The messages steered to a `chat` turn that it has not taken yet, as the
188
+ * companion last published them. The companion answers them to every
189
+ * `publish`, which a turn makes at each tool call's start and end: so the
190
+ * turn knows of them without a call of its own, and finds them at its next
191
+ * step (`takeSteers`). The newest revision wins, as tool calls that run at
192
+ * once publish at once.
159
193
  */
160
- const publish = async (ctx) => {
161
- const read = READING.get(ctx);
162
- if (read)
163
- await logged(ctx, read);
164
- await signalsOfAgent(ctx).publish();
194
+ export class Inbox {
195
+ revision = -1;
196
+ messages = [];
197
+ #listeners = new Set();
198
+ /** Keep what `publish` answered, if it is newer than what is kept, and tell the listeners if it lists messages. */
199
+ saw(published) {
200
+ if (typeof published !== 'object' || published === null)
201
+ return;
202
+ const revision = published.revision ?? -1;
203
+ if (revision <= this.revision)
204
+ return;
205
+ this.revision = revision;
206
+ this.messages = [...(published.steering ?? [])];
207
+ if (this.messages.length > 0)
208
+ for (const listener of this.#listeners)
209
+ listener();
210
+ }
211
+ /**
212
+ * Call `listener` after each publish that lists messages, until the
213
+ * returned function is called: for a framework that takes steered
214
+ * messages through an inbox of its own (pi's, DeepSeek's), handed to it as
215
+ * they come.
216
+ */
217
+ listen(listener) {
218
+ this.#listeners.add(listener);
219
+ return () => this.#listeners.delete(listener);
220
+ }
221
+ }
222
+ const INBOX = new ScopeKey('inbox');
223
+ /** The inbox of the `chat` turn running on `ctx`, if it takes steered messages: none outside one. */
224
+ export const inboxOf = (ctx) => INBOX.get(ctx);
225
+ /**
226
+ * The conversation of `ctx` changed (see `watch` in object.ts): its revision
227
+ * increases, and the clients that follow it read it again; while a framework
228
+ * answers ({@link answering}), the calls whose results it stored are
229
+ * forgotten first. It is a call to Restate, so it also sends what the
230
+ * handler wrote before, for them to read.
231
+ */
232
+ export const publish = async (ctx) => {
233
+ const stored = ANSWERING.get(ctx);
234
+ if (stored)
235
+ await settled(ctx, stored);
236
+ const published = await signalsOfAgent(ctx).publish();
237
+ INBOX.get(ctx)?.saw(published);
165
238
  };
166
239
  /** A step of a turn of `ctx`: {@link publish} it, unless the agent runs in the background, which publishes the turn's end only. */
167
- const stepped = async (ctx) => {
240
+ export const stepped = async (ctx) => {
168
241
  if (!unfollowed(ctx))
169
242
  await publish(ctx);
170
243
  };
@@ -177,16 +250,56 @@ const stepped = async (ctx) => {
177
250
  export async function toolCallStarted(ctx) {
178
251
  if (!unfollowed(ctx))
179
252
  return publish(ctx);
180
- const read = READING.get(ctx);
181
- if (read) {
182
- const transcript = await read();
183
- await settle(ctx, (id, failed) => transcript.answered(id, failed));
184
- }
253
+ const stored = ANSWERING.get(ctx);
254
+ if (stored)
255
+ await settled(ctx, stored);
185
256
  }
186
257
  /** A tool call of the turn of `ctx` (a `chat` handler's) ended: {@link publish} it, unless the agent runs in the background. */
187
258
  export async function toolCallEnded(ctx) {
188
259
  await stepped(ctx);
189
260
  }
261
+ /** What the attempt's turn has stored, while it answers (see {@link answering}). */
262
+ const ANSWERING = new ScopeKey('answering');
263
+ /** The attempt's latest settling of calls: one after another, as parallel tool calls publish at once. */
264
+ const SETTLING = new ScopeKey('settling');
265
+ /** Forget the calls whose results the conversation stored (calls.ts), after any settling before. */
266
+ function settled(ctx, stored) {
267
+ const settle = () => settleCalls(ctx, stored);
268
+ const done = (SETTLING.get(ctx) ?? Promise.resolve()).then(settle, settle);
269
+ SETTLING.set(ctx, done);
270
+ return done;
271
+ }
272
+ /**
273
+ * Run `work`, a framework's turn on the conversation of turns, forgetting
274
+ * the calls whose results it stores as it goes: each publish while it runs
275
+ * (a tool call's start and end), and its end, forget the Restate calls of
276
+ * the tool calls whose results `stored` says are stored (calls.ts).
277
+ */
278
+ export async function answering(ctx, stored, work) {
279
+ const outer = ANSWERING.get(ctx);
280
+ ANSWERING.set(ctx, stored);
281
+ let failed = false;
282
+ try {
283
+ return await work();
284
+ }
285
+ catch (error) {
286
+ failed = !(error instanceof restate.TerminalError);
287
+ throw error;
288
+ }
289
+ finally {
290
+ try {
291
+ // A failed attempt stores nothing more: its retry runs again.
292
+ if (!failed)
293
+ await settled(ctx, stored);
294
+ }
295
+ finally {
296
+ if (outer)
297
+ ANSWERING.set(ctx, outer);
298
+ else
299
+ ANSWERING.delete(ctx);
300
+ }
301
+ }
302
+ }
190
303
  /** A promise that rejects with `signal`'s reason once it aborts. */
191
304
  export const aborted = (signal) => new Promise((_, reject) => {
192
305
  if (signal.aborted)
@@ -194,6 +307,10 @@ export const aborted = (signal) => new Promise((_, reject) => {
194
307
  else
195
308
  signal.addEventListener('abort', () => reject(signal.reason), { once: true });
196
309
  });
310
+ /** What makes a `chat` handler (`chatHandler`): its answer, and whether it takes steered messages. */
311
+ const CHAT = new Link('restate-agents.chat');
312
+ /** The answer of `entry`, a handler that `chatHandler` made, and whether it takes steered messages. */
313
+ export const chatOf = (entry) => CHAT.of(entry);
197
314
  /**
198
315
  * `answer` as a chat handler, which takes its message as plain text or as a
199
316
  * JSON string, so that both of these work:
@@ -201,7 +318,7 @@ export const aborted = (signal) => new Promise((_, reject) => {
201
318
  * curl localhost:8080/assistant/alice/chat -d 'Hi'
202
319
  * curl localhost:8080/assistant/alice/chat --json '"Hi"'
203
320
  *
204
- * While it answers, the object's `status` says so (its {@link Turn}). Its
321
+ * While it answers, the object's `status` says so (its {@link Answering}). Its
205
322
  * invocation's cancellation (Restate's, explicit: `cancelled(ctx)` of
206
323
  * @restatedev/sessions/internal) aborts {@link stopSignalOf} its
207
324
  * context, whenever it comes, and cancels the calls its tools made
@@ -212,62 +329,86 @@ export const aborted = (signal) => new Promise((_, reject) => {
212
329
  *
213
330
  * It publishes when it starts and ends ({@link publish}), for the clients
214
331
  * that follow the conversation.
332
+ *
333
+ * As the `chat` handler of an agent, it also answers each message sent to
334
+ * the agent's `steer` view that no turn took, as a turn of its own (the
335
+ * private `steered` handler). With `steers` (a framework's integration says
336
+ * so), its turns take steered messages at their steps (`takeSteers`).
215
337
  */
216
- export const chatHandler = (answer) => ({
338
+ export const chatHandler = (answer, { steers = false } = {}) => CHAT.on({
217
339
  input: messageSerde,
218
340
  accept: '*/*',
219
341
  explicitCancellation: true,
220
- handler: async (ctx, text) => {
221
- const invocationId = ctx.request.id;
222
- // The companion knows the turn from here to its close: `status` and `stop` ask it.
223
- await ctx.rpc(signals, signalsOf(ctx)).start({ invocationId, since: new Date().toISOString() });
224
- await stepped(ctx);
225
- // The log takes the turn's last change, then the companion closes the
226
- // turn, which publishes it: one revision. The close is a call the turn
227
- // waits for, so that it is done before the turn ends (see `awaitTurn`).
228
- const end = async () => {
229
- const read = READING.get(ctx);
230
- if (read)
231
- await logged(ctx, read);
232
- await signalsOfAgent(ctx).close(invocationId);
233
- };
234
- const turn = new AbortController();
235
- TURN.set(ctx, turn.signal);
236
- void (async () => {
237
- await cancelled(ctx);
238
- turn.abort(new restate.CancelledError());
239
- await cancelCalls(ctx);
240
- })().catch(() => { });
241
- // The attempt ends before the turn does: its work stops (a model's
242
- // request, say), rather than run on for an attempt that can store nothing.
243
- const attempt = ctx.request.attemptCompletedSignal;
244
- const attemptEnded = () => turn.abort(new AttemptEnded());
245
- attempt.addEventListener('abort', attemptEnded, { once: true });
246
- let answered;
247
- try {
248
- answered = await answer(ctx, text);
249
- // Cancelled once answered: the answer stands.
250
- }
251
- catch (error) {
252
- if (error instanceof restate.TerminalError) {
253
- await end();
254
- throw error;
255
- }
256
- // Any other error fails the attempt, and Restate retries the turn.
257
- const terminal = refusalOf(ctx, error);
258
- if (!terminal)
259
- throw error;
342
+ handler: (ctx, text) => chatTurn(ctx, text, answer, steers),
343
+ }, { answer, steers });
344
+ /**
345
+ * Answer `text` as a turn of the agent of `ctx`, with `answer`: the body of a
346
+ * `chat` handler ({@link chatHandler}), and of `steered`. With `steers`, the
347
+ * turn takes the messages steered to it at its steps (unless the agent runs
348
+ * in the background).
349
+ */
350
+ export async function chatTurn(ctx, text, answer, steers = false) {
351
+ const invocationId = ctx.request.id;
352
+ // The companion knows the turn from here to its close: `status` and `stop` ask it.
353
+ // An agent on the conversation of turns has `settle`: the companion sends it
354
+ // this turn, should its invocation be gone without closing it.
355
+ const settles = agentOf(ctx)?.items !== undefined;
356
+ const steering = !unfollowed(ctx) && (typeof steers === 'function' ? await steers(ctx) : steers);
357
+ // Before the first publish, which may answer messages steered to the turn already (a retried attempt's).
358
+ if (steering)
359
+ INBOX.set(ctx, new Inbox());
360
+ await ctx.rpc(signals, signalsOf(ctx)).start({
361
+ invocationId,
362
+ since: new Date().toISOString(),
363
+ ...(settles ? { settles } : {}),
364
+ ...(steering ? { steers: steering } : {}),
365
+ });
366
+ await stepped(ctx);
367
+ // The log takes the turn's last change, then the companion closes the
368
+ // turn, which publishes it: one revision. The close is a call the turn
369
+ // waits for, so that it is done before the turn ends (see `awaitTurn`).
370
+ const end = async () => {
371
+ const stored = ANSWERING.get(ctx);
372
+ if (stored)
373
+ await settled(ctx, stored);
374
+ await signalsOfAgent(ctx).close(invocationId);
375
+ };
376
+ const turn = new AbortController();
377
+ TURN.set(ctx, turn.signal);
378
+ void (async () => {
379
+ await cancelled(ctx);
380
+ turn.abort(new restate.CancelledError());
381
+ await cancelCalls(ctx);
382
+ })().catch(() => { });
383
+ // The attempt ends before the turn does: its work stops (a model's
384
+ // request, say), rather than run on for an attempt that can store nothing.
385
+ const attempt = ctx.request.attemptCompletedSignal;
386
+ const attemptEnded = () => turn.abort(new AttemptEnded());
387
+ attempt.addEventListener('abort', attemptEnded, { once: true });
388
+ let answered;
389
+ try {
390
+ answered = await answer(ctx, text);
391
+ // Cancelled once answered: the answer stands.
392
+ }
393
+ catch (error) {
394
+ if (error instanceof restate.TerminalError) {
260
395
  await end();
261
- throw terminal;
262
- }
263
- finally {
264
- // An attempt's signal aborts at every attempt's end, the turn's too.
265
- attempt.removeEventListener('abort', attemptEnded);
396
+ throw error;
266
397
  }
398
+ // Any other error fails the attempt, and Restate retries the turn.
399
+ const terminal = refusalOf(ctx, error);
400
+ if (!terminal)
401
+ throw error;
267
402
  await end();
268
- return answered;
269
- },
270
- });
403
+ throw terminal;
404
+ }
405
+ finally {
406
+ // An attempt's signal aborts at every attempt's end, the turn's too.
407
+ attempt.removeEventListener('abort', attemptEnded);
408
+ }
409
+ await end();
410
+ return answered;
411
+ }
271
412
  /** A tool's error, which fails the attempt (Restate retries it): the error `cause` of tool `tool`. */
272
413
  export class ToolError extends Error {
273
414
  tool;
@@ -327,121 +468,22 @@ export function refusal(error) {
327
468
  });
328
469
  }
329
470
  /**
330
- * A prompt's stored answer, as the prompt returns it: {@link UNANSWERED},
331
- * stored as its provider refused it, fails as the prompt did then
332
- * ({@link REFUSED}), also in a retry after a crash right after it was stored.
333
- */
334
- export function storedAnswer(answer) {
335
- if (answer !== UNANSWERED)
336
- return answer;
337
- throw new restate.TerminalError(`the model's provider refused the request: ${CHECK_MODEL}`, { errorCode: REFUSED });
338
- }
339
- /**
340
- * A conversation as `messages` gives it, built from a framework's transcript:
341
- * each message is started by `say`, a tool call goes to the assistant's
342
- * message, and its result to its call. Messages without parts are left out.
343
- *
344
- * A message, once given out by `messages()`, is never changed: a change
345
- * makes a new one in its place. So a framework can keep its transcript and
346
- * add to it as its conversation grows, and the log stores only the messages
347
- * that are not the ones it stored last (see log.ts).
348
- */
349
- export class Transcript {
350
- #messages = [];
351
- /** The message of each tool call, by the call's id: its index. */
352
- #calls = new Map();
353
- /** A new message of `role`, with `text` if there is any. */
354
- say(role, text = '') {
355
- this.#messages.push({ role, parts: text.trim() ? [{ type: 'text', text }] : [] });
356
- }
357
- /** Tool call `id` of the assistant's message. */
358
- call(id, name, input) {
359
- if (this.#messages.at(-1)?.role !== 'assistant')
360
- this.say('assistant');
361
- const at = this.#messages.length - 1;
362
- this.#change(at, (parts) => [...parts, { type: 'tool', id, name, input }]);
363
- this.#calls.set(id, at);
364
- }
365
- /** The output of tool call `id`; an error's if the framework says so, or it is a tool's `Error: <message>`. */
366
- result(id, output, error = false) {
367
- const at = this.#calls.get(id);
368
- if (at === undefined)
369
- return;
370
- const failed = error || output.startsWith('Error: ');
371
- this.#change(at, (parts) => parts.map((p) => (p.type === 'tool' && p.id === id ? { ...p, output, ...(failed ? { error: true } : {}) } : p)));
372
- }
373
- /**
374
- * Whether tool call `id` has its output: not an error's, unless it is
375
- * `failed`, the error the call answered with.
376
- */
377
- answered(id, failed) {
378
- const at = this.#calls.get(id);
379
- return (at !== undefined &&
380
- this.#messages[at].parts.some((p) => p.type === 'tool' && p.id === id && p.output !== undefined && (!p.error || p.output === failed)));
381
- }
382
- /** Its messages, in order: those with parts. */
383
- messages() {
384
- return this.#messages.filter((m) => m.parts.length > 0);
385
- }
386
- /** Message `at` with its parts as `change` makes them: a new message, in its place. */
387
- #change(at, change) {
388
- const message = this.#messages[at];
389
- this.#messages[at] = { ...message, parts: change(message.parts) };
390
- }
391
- }
392
- /** The transcript of the attempt's turn, while it answers. */
393
- const READING = new ScopeKey('transcribing');
394
- /** The attempt's log writes, one after another: tool calls in parallel publish at once. */
395
- const WRITING = new ScopeKey('the log');
396
- /** The log of the conversation of `ctx` takes its transcript as `read` gives it. */
397
- function logged(ctx, read) {
398
- const write = async () => {
399
- const transcript = await read();
400
- await log.sync(ctx, transcript.messages());
401
- // The calls whose results the framework stored are made: see calls.ts.
402
- await settle(ctx, (id, failed) => transcript.answered(id, failed));
403
- };
404
- const done = (WRITING.get(ctx) ?? Promise.resolve()).then(write, write);
405
- WRITING.set(ctx, done);
406
- return done;
407
- }
408
- /**
409
- * Run `work`, a framework's turn (or a compaction, a reset), with `read`
410
- * giving the framework's transcript as it stands, from the framework as
411
- * `work` holds it open: each publish meanwhile (a tool call's start and end)
412
- * takes it into the conversation's log, and so does `work`'s end, before the
413
- * framework closes. `messages` and `sync` read the log.
471
+ * A prompt's stored answer, as the prompt returns it, by how its turn ended
472
+ * (`status`): a turn refused ({@link UNANSWERED}) fails with
473
+ * {@link REFUSED}, one failed for good with its error, one cancelled with
474
+ * the cancellation, one another invocation ended with its note; so that a
475
+ * retry after a crash right after the close fails as the prompt did.
414
476
  */
415
- export async function transcribing(ctx, read, work) {
416
- const outer = READING.get(ctx);
417
- READING.set(ctx, read);
418
- let failed = false;
419
- try {
420
- return await work();
421
- }
422
- catch (error) {
423
- failed = !(error instanceof restate.TerminalError);
424
- throw error;
425
- }
426
- finally {
427
- try {
428
- // A failed attempt stores nothing more: its retry runs again.
429
- if (!failed)
430
- await logged(ctx, read);
431
- }
432
- finally {
433
- if (outer)
434
- READING.set(ctx, outer);
435
- else
436
- READING.delete(ctx);
437
- }
477
+ export function storedAnswer(answer, status = 'answered') {
478
+ if (status === 'refused') {
479
+ throw new restate.TerminalError(`the model's provider refused the request: ${CHECK_MODEL}`, { errorCode: REFUSED });
438
480
  }
481
+ if (status === 'cancelled')
482
+ throw new restate.CancelledError();
483
+ if (status === 'failed')
484
+ throw new restate.TerminalError(answer.replace(/^Error: /, ''));
485
+ if (status === 'ended')
486
+ throw new restate.TerminalError(answer);
487
+ return answer;
439
488
  }
440
- /**
441
- * The handler of an agent's conversation as clients read it, from its log:
442
- * a page of it (`{limit, before}`), or what is new or changed since a cursor
443
- * (`{cursor}`). It is a view: it answers while a message is answered, with
444
- * what was stored so far, and stores nothing.
445
- */
446
- export const messagesHandler = () => async (ctx, request) => log.page(ctx.db, request ?? {});
447
489
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,4EAA4E;AAC5E,gEAAgE;AAChE,gDAAgD;AAChD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAA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