@restatedev/agents 0.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"signals.js","sourceRoot":"","sources":["../src/signals.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAOxE,8EAA8E;AAC9E,MAAM,KAAK,GAAG,CAAC,OAAe,EAAE,GAAW,EAAE,EAAE,CAAC,GAAG,OAAO,IAAI,GAAG,EAAE,CAAC;AAEpE,oDAAoD;AACpD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAiB,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;AAE3F,0GAA0G;AAC1G,MAAM,SAAS,GAAG,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAgBrD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAA6B,UAAa,EAAK,EAAE,CAC5E,OAAO,CACL,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,SAAS,EAAE;IAC3C,KAAK,EAAE,CAAC,GAAW,EAAa,EAAE,CAAC,CAAC;QAClC,MAAM,EAAE,OAAO;QACf,GAAG,EAAE,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC;QAChC,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE;KACzC,CAAC;CACH,CAAC,EACF,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAChB,CAAC;AAEJ;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAuB,EAAE,GAAW;IAC9D,MAAM,SAAS,GAAI,KAAsD,CAAC,SAAS,CAAC,CAAC;IACrF,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,C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GAAiC,EAAE,SAAiB,EAAE,EAAE;YACnF,MAAM,QAAQ,GAAG,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;YACnD,GAAG,CAAC,GAAG,CACL,UAAU,EACV,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAClD,CAAC;QACJ,CAAC,CAAC;KACH;CACF,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restatedev/agents",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Agent frameworks in Restate virtual objects, their state in the object's SQL database: pi, OpenCode, LangGraph, Claude (Anthropic SDK) and DeepSeek Harness",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -103,7 +103,7 @@
103
103
  "@opencode/sdk": "2.0.32",
104
104
  "@opencode/server": "2.0.32",
105
105
  "@restatedev/restate-sdk": "1.18.2",
106
- "@restatedev/sessions": "0.2.0",
106
+ "@restatedev/sessions": "0.3.0",
107
107
  "effect": "4.0.1",
108
108
  "zod": "4.6.5"
109
109
  },
@@ -133,7 +133,7 @@
133
133
  "@opencode/plugin": "2.0.32",
134
134
  "@opencode/sdk": "2.0.32",
135
135
  "@opencode/server": "2.0.32",
136
- "@restatedev/sessions": "^0.2.0",
136
+ "@restatedev/sessions": "^0.3.0",
137
137
  "effect": "4.0.1",
138
138
  "zod": "^4.6.5"
139
139
  },
package/src/calls.ts CHANGED
@@ -19,7 +19,7 @@
19
19
  // terminal error is its result too. Once stored, the model has its result,
20
20
  // and an identical call it makes later is a call of its own.
21
21
  import type * as restate from '@restatedev/sessions';
22
- import { Schema } from '@restatedev/sessions/internal';
22
+ import { Schema, ScopeKey } from '@restatedev/sessions/internal';
23
23
  import { randomUUID } from 'node:crypto';
24
24
 
25
25
  /** A tool's call: the tool, its input as JSON, the ids it was made with (the first is its own), and the attempt that last made it. */
@@ -72,17 +72,11 @@ async function load(ctx: CallsContext, invocation: string): Promise<Calls> {
72
72
  }
73
73
 
74
74
  /** Each attempt's id, and its calls, by its context. */
75
- const attempts = new WeakMap<object, { id: string; calls: Promise<Calls> }>();
75
+ const ATTEMPT = new ScopeKey<{ id: string; calls: Promise<Calls> }>('the calls of an attempt');
76
76
 
77
77
  /** The attempt of `ctx`: its id, and the calls of its invocation. */
78
- function attemptOf(ctx: CallsContext) {
79
- let attempt = attempts.get(ctx);
80
- if (!attempt) {
81
- const calls = load(ctx, ctx.request.id);
82
- attempt = { id: randomUUID(), calls };
83
- attempts.set(ctx, attempt);
84
- }
85
- return attempt;
78
+ function attemptOf(ctx: restate.SessionContext) {
79
+ return ATTEMPT.of(ctx, () => ({ id: randomUUID(), calls: load(ctx, ctx.request.id) }));
86
80
  }
87
81
 
88
82
  /**
@@ -91,7 +85,7 @@ function attemptOf(ctx: CallsContext) {
91
85
  * the same tool and input (made again under a new id), or else a new one.
92
86
  * `run(id)` makes it with its own id, and stores that it answered.
93
87
  */
94
- export async function callOf(ctx: CallsContext, tool: string, input: unknown, callId: string) {
88
+ export async function callOf(ctx: restate.SessionContext, tool: string, input: unknown, callId: string) {
95
89
  const attempt = attemptOf(ctx);
96
90
  const state = await attempt.calls;
97
91
  const json = JSON.stringify(input);
@@ -129,7 +123,7 @@ export async function callOf(ctx: CallsContext, tool: string, input: unknown, ca
129
123
  * otherwise take one an earlier attempt made, and the model has the result
130
124
  * of.
131
125
  */
132
- export async function settle(ctx: CallsContext, stored: (id: string, failed?: string) => boolean) {
126
+ export async function settle(ctx: restate.SessionContext, stored: (id: string, failed?: string) => boolean) {
133
127
  const state = await attemptOf(ctx).calls;
134
128
  const kept = state.calls.filter((c) => !c.done || !stored(c.ids.at(-1)!, c.failed));
135
129
  if (kept.length === state.calls.length) return;
@@ -24,7 +24,7 @@
24
24
  // - A reply cut off at `maxTokens`, or declined, ends the prompt: its tool
25
25
  // calls do not run, and the handler fails with a terminal error.
26
26
  import * as restate from '@restatedev/sessions';
27
- import type { Database } from '@restatedev/sessions';
27
+ import { ScopeKey } from '@restatedev/sessions/internal';
28
28
  import Anthropic from '@anthropic-ai/sdk';
29
29
  import type { BetaRunnableTool, BetaToolRunContext } from '@anthropic-ai/sdk/lib/tools/BetaRunnableTool';
30
30
  import {
@@ -40,7 +40,7 @@ import {
40
40
  modelIdOf,
41
41
  modelOf,
42
42
  nextPromptId,
43
- refusal,
43
+ refusalOf,
44
44
  stopSignalOf,
45
45
  storedAnswer,
46
46
  toolCallEnded,
@@ -66,7 +66,7 @@ export const callId = (context?: BetaToolRunContext) => {
66
66
  * to the model as the tool's result, so each one is kept, for `check()` to
67
67
  * throw once the tools ran.
68
68
  */
69
- function failing(tools: BetaRunnableTool[]) {
69
+ function failing(ctx: restate.SessionContext, tools: BetaRunnableTool[]) {
70
70
  let failure: unknown;
71
71
  return {
72
72
  tools: tools.map((tool): BetaRunnableTool => ({
@@ -75,7 +75,7 @@ function failing(tools: BetaRunnableTool[]) {
75
75
  try {
76
76
  return await tool.run(args, context);
77
77
  } catch (e) {
78
- fromTool(e);
78
+ fromTool(ctx, e);
79
79
  failure ??= e;
80
80
  throw e;
81
81
  }
@@ -114,7 +114,7 @@ async function run(
114
114
  id: string,
115
115
  signal?: AbortSignal,
116
116
  ) {
117
- const { tools, check } = failing(all);
117
+ const { tools, check } = failing(ctx, all);
118
118
  const runner = client.beta.messages.toolRunner(
119
119
  {
120
120
  model,
@@ -219,14 +219,14 @@ export interface Options<O extends z.ZodObject | undefined = z.ZodObject | undef
219
219
  output?: O;
220
220
  }
221
221
 
222
- /** The client of the agents without one of their own, made when first used. */
223
- let shared: Anthropic | undefined;
222
+ /** The client of an agent without one of its own, on the context of the turn it answers. */
223
+ const CLIENT = new ScopeKey<Anthropic>('the Anthropic client');
224
224
 
225
225
  /** {@link prompt}, answering with the agent's text. */
226
226
  const promptText = (ctx: restate.SessionContext, text: string, options: Options): Promise<string> =>
227
227
  transcribing(
228
228
  ctx,
229
- () => transcribe(ctx.db),
229
+ () => transcribe(ctx),
230
230
  () => answerOnce(ctx, text, options),
231
231
  );
232
232
 
@@ -236,7 +236,7 @@ const answerOnce = async (
236
236
  { model: named, system, tools = [], client, maxTokens = 16_000, effort }: Options,
237
237
  ): Promise<string> => {
238
238
  const agent = {
239
- client: client ?? (shared ??= new Anthropic()),
239
+ client: client ?? CLIENT.of(ctx, () => new Anthropic()),
240
240
  model: modelIdOf(modelOf(named, CLAUDE_MODEL), 'anthropic'),
241
241
  maxTokens,
242
242
  effort,
@@ -278,7 +278,7 @@ const answerOnce = async (
278
278
  }
279
279
  // Refused for good (a wrong API key): the prompt ends unanswered, and
280
280
  // fails as terminal. An earlier one's, this one goes on.
281
- const refused = refusal(error);
281
+ const refused = refusalOf(ctx, error);
282
282
  if (!refused) throw error;
283
283
  await conversation.close(pending, UNANSWERED);
284
284
  if (pending === id) throw refused;
@@ -325,12 +325,12 @@ export const messages = () => messagesHandler();
325
325
  * attempt), as far as it was read: the conversation only grows, so each
326
326
  * read adds the messages stored since.
327
327
  */
328
- const transcripts = new WeakMap<Database, { seq: number; transcript: Transcript }>();
328
+ const TRANSCRIPT = new ScopeKey<{ seq: number; transcript: Transcript }>('the transcript');
329
329
 
330
- /** The conversation in `db`, as `messages` gives it. */
331
- const transcribe = async (db: Database): Promise<Transcript> => {
332
- const read = transcripts.get(db) ?? { seq: 0, transcript: new Transcript() };
333
- transcripts.set(db, read);
330
+ /** The conversation in the database of `ctx`, as `messages` gives it. */
331
+ const transcribe = async (ctx: restate.SessionContext): Promise<Transcript> => {
332
+ const { db } = ctx;
333
+ const read = TRANSCRIPT.of(ctx, () => ({ seq: 0, transcript: new Transcript() }));
334
334
  const { transcript } = read;
335
335
  for (const [seq, m] of await (await Conversation.open(db)).since(read.seq)) {
336
336
  read.seq = seq;
package/src/common.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  // cancellation, publishing for the clients that follow it), and
4
4
  // the `messages` handler with its `Transcript`.
5
5
  import * as restate from '@restatedev/sessions';
6
- import { cancelCalls, cancelled } from '@restatedev/sessions/internal';
6
+ import { cancelCalls, cancelled, definitionOf, Link, ScopeKey } from '@restatedev/sessions/internal';
7
7
  import { settle } from './calls.ts';
8
8
  import * as log from './log.ts';
9
9
  import type { Said } from './log.ts';
@@ -23,7 +23,7 @@ export const configured = async <T>(value: Configure<T>, ctx: restate.SessionCon
23
23
  typeof value === 'function' ? (value as (ctx: restate.SessionContext) => T | Promise<T>)(ctx) : value;
24
24
 
25
25
  /** The prompts each invocation made so far, by its context. */
26
- const prompts = new WeakMap<object, number>();
26
+ const PROMPTS = new ScopeKey<number>('nextPromptId');
27
27
 
28
28
  /**
29
29
  * The id of the next prompt of the invocation of `ctx`: the invocation's id,
@@ -31,8 +31,8 @@ const prompts = new WeakMap<object, number>();
31
31
  * order, so each gets the same id again, and its answer.
32
32
  */
33
33
  export const nextPromptId = (ctx: restate.SessionContext) => {
34
- const n = (prompts.get(ctx) ?? 0) + 1;
35
- prompts.set(ctx, n);
34
+ const n = (PROMPTS.get(ctx) ?? 0) + 1;
35
+ PROMPTS.set(ctx, n);
36
36
  return n === 1 ? ctx.request.id : `${ctx.request.id}:${n}`;
37
37
  };
38
38
 
@@ -133,7 +133,7 @@ export interface Turn {
133
133
  }
134
134
 
135
135
  /** What stops each turn, by its context: see {@link stopSignalOf}. */
136
- const turns = new WeakMap<object, AbortSignal>();
136
+ const TURN = new ScopeKey<AbortSignal>('stopSignalOf');
137
137
 
138
138
  /**
139
139
  * Why a turn stopped when its attempt ended before it did: Restate suspended
@@ -156,42 +156,54 @@ export class AttemptEnded extends Error {
156
156
  * {@link AttemptEnded} once the attempt ends first (the work stops, and
157
157
  * answers nothing).
158
158
  */
159
- export const stopSignalOf = (ctx: object): AbortSignal | undefined => turns.get(ctx);
159
+ export const stopSignalOf = (ctx: restate.SessionContext): AbortSignal | undefined => TURN.get(ctx);
160
160
 
161
- /** The agents that run in the background (`background: true`): no one follows them as they work. */
162
- const background = new Set<string>();
161
+ /** What `clear` also empties, beside the agent's database. */
162
+ type Clear = (ctx: restate.SessionContext) => Promise<void>;
163
163
 
164
- /** Agent `name` runs in the background: see `background` in object.ts. */
165
- export const inBackground = (name: string) => void background.add(name);
164
+ /** An agent's own: whether it runs in the background (`background: true`: no one follows it as it works), and what its `clear` also empties. */
165
+ interface Agent {
166
+ background: boolean;
167
+ clear?: Clear;
168
+ }
166
169
 
167
- /** What each agent clears beside its database, by its object's name: see {@link onClear}. */
168
- const clearing = new Map<string, (ctx: restate.SessionContext) => Promise<void>>();
170
+ /** An agent's own, on its definition. */
171
+ const AGENT = new Link<Agent>('an agent');
169
172
 
170
173
  /** What a framework's `messages` view clears beside the agent's database: see {@link alsoClearing}. */
171
- const viewsClearing = new WeakMap<object, (ctx: restate.SessionContext) => Promise<void>>();
174
+ const CLEARS = new Link<Clear>('alsoClearing');
172
175
 
173
176
  /**
174
177
  * The `messages` view `view` of a framework that keeps a conversation apart
175
178
  * (OpenCode, in a database of its own): `clear` empties it too, as an agent
176
179
  * with this view is cleared.
177
180
  */
178
- export const alsoClearing = <V extends object>(view: V, clear: (ctx: restate.SessionContext) => Promise<void>) => {
179
- viewsClearing.set(view, clear);
180
- return view;
181
+ export const alsoClearing = <V extends object>(view: V, clear: Clear) => {
182
+ return CLEARS.on(view, clear);
181
183
  };
182
184
 
183
- /** When the agent `name`, whose `messages` view is `view`, is cleared, clear what that view keeps apart too. */
184
- export const onClear = (name: string, view: object | undefined) => {
185
- const clear = view === undefined ? undefined : viewsClearing.get(view);
186
- if (clear === undefined) clearing.delete(name);
187
- else clearing.set(name, clear);
185
+ /**
186
+ * `definition` is an agent's: whether it runs in the background, and its
187
+ * `messages` view, whose clearing (`alsoClearing`) its `clear` does too.
188
+ */
189
+ export const isAgent = <D extends object>(
190
+ definition: D,
191
+ { background = false, messages = undefined as object | undefined },
192
+ ) => {
193
+ return AGENT.on(definition, { background, clear: messages && CLEARS.of(messages) });
188
194
  };
189
195
 
190
- /** Clear what the agent of `ctx` keeps beside its database ({@link onClear}). */
191
- export const cleared = async (ctx: restate.SessionContext) => clearing.get(ctx.request.target.service)?.(ctx);
196
+ /** The agent of `ctx`'s own (see {@link isAgent}). */
197
+ const agentOf = (ctx: restate.SessionContext) => {
198
+ const definition = definitionOf(ctx);
199
+ return definition && AGENT.of(definition);
200
+ };
201
+
202
+ /** Clear what the agent of `ctx` keeps beside its database. */
203
+ export const cleared = async (ctx: restate.SessionContext) => agentOf(ctx)?.clear?.(ctx);
192
204
 
193
205
  /** Whether the agent of `ctx` runs in the background. */
194
- const unfollowed = (ctx: restate.SessionContext) => background.has(ctx.request.target.service);
206
+ const unfollowed = (ctx: restate.SessionContext) => agentOf(ctx)?.background === true;
195
207
 
196
208
  /** The `signals` object of the agent of `ctx`. */
197
209
  const signalsOfAgent = (ctx: restate.SessionContext) => ctx.rpc(signals, signalsOf(ctx));
@@ -203,7 +215,7 @@ const signalsOfAgent = (ctx: restate.SessionContext) => ctx.rpc(signals, signals
203
215
  * Restate, so it also sends what the handler wrote before, for them to read.
204
216
  */
205
217
  const publish = async (ctx: restate.SessionContext) => {
206
- const read = reading.get(ctx);
218
+ const read = READING.get(ctx);
207
219
  if (read) await logged(ctx, read);
208
220
  await signalsOfAgent(ctx).publish();
209
221
  };
@@ -221,7 +233,7 @@ const stepped = async (ctx: restate.SessionContext) => {
221
233
  */
222
234
  export async function toolCallStarted(ctx: restate.SessionContext) {
223
235
  if (!unfollowed(ctx)) return publish(ctx);
224
- const read = reading.get(ctx);
236
+ const read = READING.get(ctx);
225
237
  if (read) {
226
238
  const transcript = await read();
227
239
  await settle(ctx, (id, failed) => transcript.answered(id, failed));
@@ -272,12 +284,12 @@ export const chatHandler = <A = string>(answer: (ctx: restate.SessionContext, me
272
284
  // turn, which publishes it: one revision. The close is a call the turn
273
285
  // waits for, so that it is done before the turn ends (see `awaitTurn`).
274
286
  const end = async () => {
275
- const read = reading.get(ctx);
287
+ const read = READING.get(ctx);
276
288
  if (read) await logged(ctx, read);
277
289
  await signalsOfAgent(ctx).close(invocationId);
278
290
  };
279
291
  const turn = new AbortController();
280
- turns.set(ctx, turn.signal);
292
+ TURN.set(ctx, turn.signal);
281
293
  void (async () => {
282
294
  await cancelled(ctx);
283
295
  turn.abort(new restate.CancelledError());
@@ -298,7 +310,7 @@ export const chatHandler = <A = string>(answer: (ctx: restate.SessionContext, me
298
310
  throw error;
299
311
  }
300
312
  // Any other error fails the attempt, and Restate retries the turn.
301
- const terminal = refusal(error);
313
+ const terminal = refusalOf(ctx, error);
302
314
  if (!terminal) throw error;
303
315
  await end();
304
316
  throw terminal;
@@ -321,21 +333,26 @@ export class ToolError extends Error {
321
333
  }
322
334
  }
323
335
 
324
- /** The errors a framework's own tools (not `tool()`'s) failed with: see {@link fromTool}. */
325
- const toolErrors = new WeakSet<object>();
336
+ /** The errors the attempt's framework tools (not `tool()`'s) failed with: see {@link fromTool}. */
337
+ const TOOL_ERRORS = new ScopeKey<WeakSet<object>>('fromTool');
326
338
 
327
339
  /**
328
- * `error` is a tool's: a framework's own tool (Claude's, LangChain's...)
329
- * that failed, whose error is never taken for the model's provider refusing
330
- * (a tool that calls a model API may fail as one does). `tool()`'s are
331
- * {@link ToolError}s.
340
+ * `error` is a tool's, in the attempt of `ctx`: a framework's own tool
341
+ * (Claude's, LangChain's...) that failed, whose error is never taken for
342
+ * the model's provider refusing (a tool that calls a model API may fail as
343
+ * one does). `tool()`'s are {@link ToolError}s.
332
344
  */
333
- export function fromTool(error: unknown) {
334
- if (typeof error === 'object' && error !== null) toolErrors.add(error);
345
+ export function fromTool(ctx: restate.SessionContext, error: unknown) {
346
+ if (typeof error === 'object' && error !== null) TOOL_ERRORS.of(ctx, () => new WeakSet()).add(error);
335
347
  }
336
348
 
337
349
  /** The Anthropic SDK's errors of a request that fails again however often it is made. */
338
- const FOR_GOOD = new Set(['AuthenticationError', 'PermissionDeniedError', 'NotFoundError', 'BadRequestError']);
350
+ const FOR_GOOD: ReadonlySet<string> = new Set([
351
+ 'AuthenticationError',
352
+ 'PermissionDeniedError',
353
+ 'NotFoundError',
354
+ 'BadRequestError',
355
+ ]);
339
356
 
340
357
  /**
341
358
  * Whether `error` is a model provider's refusal that a retry does not change:
@@ -343,14 +360,19 @@ const FOR_GOOD = new Set(['AuthenticationError', 'PermissionDeniedError', 'NotFo
343
360
  * (a tool's, an overloaded provider's) fail the attempt, and Restate retries.
344
361
  */
345
362
  function refused(error: unknown) {
346
- if (error instanceof ToolError || (typeof error === 'object' && error !== null && toolErrors.has(error)))
347
- return false;
363
+ if (error instanceof ToolError) return false;
348
364
  if (error instanceof Error && FOR_GOOD.has(error.constructor.name)) return true;
349
365
  return /API key not found|no API key|Could not resolve authentication method|Provider is not configured|"code":"(AUTH|MISSING_CREDENTIAL)"/i.test(
350
366
  String(error),
351
367
  );
352
368
  }
353
369
 
370
+ /** {@link refusal}, but not of an error a framework's tool failed with in the attempt of `ctx` ({@link fromTool}). */
371
+ export function refusalOf(ctx: restate.SessionContext, error: unknown): restate.TerminalError | undefined {
372
+ const failedTool = typeof error === 'object' && error !== null && TOOL_ERRORS.get(ctx)?.has(error);
373
+ return failedTool ? undefined : refusal(error);
374
+ }
375
+
354
376
  /**
355
377
  * `error` as a terminal error ({@link REFUSED}), if a retry does not change
356
378
  * it: a model the agent cannot take, or its provider's refusal.
@@ -492,22 +514,22 @@ export class Transcript {
492
514
  */
493
515
  export type Read = () => Promise<Transcript>;
494
516
 
495
- /** The transcript of the turn of each context, while it answers. */
496
- const reading = new WeakMap<object, Read>();
517
+ /** The transcript of the attempt's turn, while it answers. */
518
+ const READING = new ScopeKey<Read>('transcribing');
497
519
 
498
- /** The log writes of each context, one after another: tool calls in parallel publish at once. */
499
- const writing = new WeakMap<object, Promise<void>>();
520
+ /** The attempt's log writes, one after another: tool calls in parallel publish at once. */
521
+ const WRITING = new ScopeKey<Promise<void>>('the log');
500
522
 
501
523
  /** The log of the conversation of `ctx` takes its transcript as `read` gives it. */
502
524
  function logged(ctx: restate.SessionContext, read: Read): Promise<void> {
503
525
  const write = async () => {
504
526
  const transcript = await read();
505
- await log.sync(ctx.db, transcript.messages());
527
+ await log.sync(ctx, transcript.messages());
506
528
  // The calls whose results the framework stored are made: see calls.ts.
507
529
  await settle(ctx, (id, failed) => transcript.answered(id, failed));
508
530
  };
509
- const done = (writing.get(ctx) ?? Promise.resolve()).then(write, write);
510
- writing.set(ctx, done);
531
+ const done = (WRITING.get(ctx) ?? Promise.resolve()).then(write, write);
532
+ WRITING.set(ctx, done);
511
533
  return done;
512
534
  }
513
535
 
@@ -519,8 +541,8 @@ function logged(ctx: restate.SessionContext, read: Read): Promise<void> {
519
541
  * framework closes. `messages` and `sync` read the log.
520
542
  */
521
543
  export async function transcribing<T>(ctx: restate.SessionContext, read: Read, work: () => Promise<T>): Promise<T> {
522
- const outer = reading.get(ctx);
523
- reading.set(ctx, read);
544
+ const outer = READING.get(ctx);
545
+ READING.set(ctx, read);
524
546
  let failed = false;
525
547
  try {
526
548
  return await work();
@@ -532,8 +554,8 @@ export async function transcribing<T>(ctx: restate.SessionContext, read: Read, w
532
554
  // A failed attempt stores nothing more: its retry runs again.
533
555
  if (!failed) await logged(ctx, read);
534
556
  } finally {
535
- if (outer) reading.set(ctx, outer);
536
- else reading.delete(ctx);
557
+ if (outer) READING.set(ctx, outer);
558
+ else READING.delete(ctx);
537
559
  }
538
560
  }
539
561
  }
@@ -383,7 +383,7 @@ const tracked = (
383
383
  await toolCallEnded(ctx);
384
384
  return result;
385
385
  } catch (error) {
386
- fromTool(error);
386
+ fromTool(ctx, error);
387
387
  fail(error);
388
388
  throw error;
389
389
  }
@@ -28,8 +28,6 @@
28
28
  import * as restate from '@restatedev/sessions';
29
29
  import type { Database } from '@restatedev/sessions';
30
30
  import type { RunnableConfig } from '@langchain/core/runnables';
31
- import type { ChatAnthropic } from '@langchain/anthropic';
32
- import type { ChatOpenAI } from '@langchain/openai';
33
31
  import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
34
32
  import { AIMessage, type BaseMessage, HumanMessage, SystemMessage, ToolMessage } from '@langchain/core/messages';
35
33
  import { type StructuredToolInterface, tool, ToolInputParsingException } from '@langchain/core/tools';
@@ -47,7 +45,7 @@ import {
47
45
  modelOf,
48
46
  nextPromptId,
49
47
  providerOf,
50
- refusal,
48
+ refusalOf,
51
49
  stopSignalOf,
52
50
  storedAnswer,
53
51
  toolCallEnded,
@@ -89,7 +87,7 @@ function toolsNode(ctx: restate.SessionContext, tools: StructuredToolInterface[]
89
87
  const { promise: failure, reject: failed } = Promise.withResolvers<never>();
90
88
  failure.catch(() => {});
91
89
  const node = new ToolNode(
92
- tools.map((t) => failing(t, failed)),
90
+ tools.map((t) => failing(ctx, t, failed)),
93
91
  { handleToolErrors: true },
94
92
  );
95
93
  const ran: { messages: BaseMessage[] } = await Promise.race([node.invoke(state, config), failure]);
@@ -99,7 +97,11 @@ function toolsNode(ctx: restate.SessionContext, tools: StructuredToolInterface[]
99
97
  }
100
98
 
101
99
  /** `t`, its errors given to `failed`, but for its input's (arguments that do not fit) and LangGraph's interrupts. */
102
- const failing = (t: StructuredToolInterface, failed: (error: unknown) => void): StructuredToolInterface =>
100
+ const failing = (
101
+ ctx: restate.SessionContext,
102
+ t: StructuredToolInterface,
103
+ failed: (error: unknown) => void,
104
+ ): StructuredToolInterface =>
103
105
  Object.create(t, {
104
106
  invoke: {
105
107
  value: async (...args: Parameters<StructuredToolInterface['invoke']>) => {
@@ -107,7 +109,7 @@ const failing = (t: StructuredToolInterface, failed: (error: unknown) => void):
107
109
  return await t.invoke(...args);
108
110
  } catch (error) {
109
111
  if (!(error instanceof ToolInputParsingException) && !isGraphInterrupt(error)) {
110
- fromTool(error);
112
+ fromTool(ctx, error);
111
113
  failed(error);
112
114
  }
113
115
  throw error;
@@ -128,22 +130,19 @@ const providerOfModel = (named: string) => {
128
130
 
129
131
  /**
130
132
  * The chat model `provider/model-id` names: OpenAI's or Anthropic's, through
131
- * LangChain's integration of the provider, loaded once, when a model of it is
132
- * first used: only that one need be installed.
133
+ * LangChain's integration of the provider, loaded when a model of it is
134
+ * used (Node loads a module once): only that one need be installed.
133
135
  */
134
136
  const chatModel = async (named: string): Promise<BaseChatModel> => {
135
137
  const [provider, id] = providerOfModel(named);
136
138
  if (provider === 'openai') {
137
- openai ??= integration('@langchain/openai', () => import('@langchain/openai'));
138
- return new (await openai).ChatOpenAI({ model: id });
139
+ const { ChatOpenAI } = await integration('@langchain/openai', () => import('@langchain/openai'));
140
+ return new ChatOpenAI({ model: id });
139
141
  }
140
- anthropic ??= integration('@langchain/anthropic', () => import('@langchain/anthropic'));
141
- return new (await anthropic).ChatAnthropic({ model: id });
142
+ const { ChatAnthropic } = await integration('@langchain/anthropic', () => import('@langchain/anthropic'));
143
+ return new ChatAnthropic({ model: id });
142
144
  };
143
145
 
144
- let openai: Promise<{ ChatOpenAI: typeof ChatOpenAI }> | undefined;
145
- let anthropic: Promise<{ ChatAnthropic: typeof ChatAnthropic }> | undefined;
146
-
147
146
  /** The integration `name`, which its user installs beside @restatedev/agents. */
148
147
  async function integration<T>(name: string, load: () => Promise<T>): Promise<T> {
149
148
  try {
@@ -249,7 +248,7 @@ const answerOnce = async (
249
248
  }
250
249
  // Refused for good (a wrong API key): the run ends unanswered, and
251
250
  // fails as terminal. An earlier prompt's, this one goes on.
252
- const refused = refusal(error);
251
+ const refused = refusalOf(ctx, error);
253
252
  if (!refused) throw error;
254
253
  await close(app, config, UNANSWERED);
255
254
  if (!interrupted || last === id) throw refused;
package/src/log.ts CHANGED
@@ -14,8 +14,8 @@
14
14
  // got to: the next conversation's ids and cursors go on from there (its
15
15
  // start, a row of `restate_agent_log_start`), so a client following it reads
16
16
  // on, and drops the messages before `first`.
17
- import type { Database, DatabaseReader, DatabaseWriter } from '@restatedev/sessions';
18
- import { Schema } from '@restatedev/sessions/internal';
17
+ import type { DatabaseReader, DatabaseWriter, SessionContext } from '@restatedev/sessions';
18
+ import { Schema, ScopeKey } from '@restatedev/sessions/internal';
19
19
  import type { ChatMessage, Messages, MessagesRequest } from './common.ts';
20
20
 
21
21
  const TABLE = 'restate_agent_log';
@@ -73,16 +73,16 @@ interface Head {
73
73
  }
74
74
 
75
75
  /**
76
- * The head of each session (`ctx.db`, one per attempt), as its last `sync`
77
- * stored it: the next compares the transcript with it, rather than read the
78
- * whole log again at each step.
76
+ * The log's head, as the attempt's last `sync` stored it: the next compares
77
+ * the transcript with it, rather than read the whole log again at each step.
79
78
  */
80
- const heads = new WeakMap<Database, Head>();
79
+ const HEAD = new ScopeKey<Head>('the log');
81
80
 
82
- /** The log's head in `db`: as this session stored it last, or else as the log has it. */
83
- async function headOf(db: Database): Promise<Head> {
84
- const cached = heads.get(db);
81
+ /** The log's head in the attempt of `ctx`: as it stored it last, or else as the log has it. */
82
+ async function headOf(ctx: SessionContext): Promise<Head> {
83
+ const cached = HEAD.get(ctx);
85
84
  if (cached) return cached;
85
+ const { db } = ctx;
86
86
  const rows = (await db.values(`SELECT id, message FROM ${TABLE} WHERE position IS NOT NULL ORDER BY position`)).map(
87
87
  ([id, json]) => ({ id: Number(id), message: JSON.parse(String(json)) as Said, json: String(json) }),
88
88
  );
@@ -98,9 +98,10 @@ async function headOf(db: Database): Promise<Head> {
98
98
  * Store the transcript's `messages`, in order, in the log: those that
99
99
  * changed since the last time, in one transaction.
100
100
  */
101
- export async function sync(db: Database, messages: Said[]) {
101
+ export async function sync(ctx: SessionContext, messages: Said[]) {
102
+ const { db } = ctx;
102
103
  await SCHEMA.ensure(db);
103
- const head = await headOf(db);
104
+ const head = await headOf(ctx);
104
105
  // A message the transcript did not change is the one stored (see Transcript in common.ts):
105
106
  // only the others are compared, as JSON.
106
107
  const jsons: string[] = [];
@@ -134,10 +135,10 @@ export async function sync(db: Database, messages: Said[]) {
134
135
  });
135
136
  } catch (error) {
136
137
  // Rolled back: the log is as it was, which the next sync reads again.
137
- heads.delete(db);
138
+ HEAD.delete(ctx);
138
139
  throw error;
139
140
  }
140
- heads.set(db, { rows, seq, next: id });
141
+ HEAD.set(ctx, { rows, seq, next: id });
141
142
  }
142
143
 
143
144
  /**