@restatedev/agents 0.5.0 → 0.7.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.
- package/README.md +79 -24
- package/dist/calls.d.ts +20 -1
- package/dist/calls.d.ts.map +1 -1
- package/dist/calls.js +46 -7
- package/dist/calls.js.map +1 -1
- package/dist/claude/index.d.ts +11 -11
- package/dist/claude/index.d.ts.map +1 -1
- package/dist/claude/index.js +12 -6
- package/dist/claude/index.js.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/common.d.ts +62 -23
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +67 -38
- package/dist/common.js.map +1 -1
- package/dist/{signals.d.ts → companion.d.ts} +106 -43
- package/dist/companion.d.ts.map +1 -0
- package/dist/companion.js +463 -0
- package/dist/companion.js.map +1 -0
- package/dist/conversation.d.ts +103 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +295 -75
- package/dist/conversation.js.map +1 -1
- package/dist/deepseek/index.d.ts +11 -11
- package/dist/deepseek/index.d.ts.map +1 -1
- package/dist/deepseek/index.js +26 -26
- package/dist/deepseek/index.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/langgraph/checkpointer.d.ts +3 -1
- package/dist/langgraph/checkpointer.d.ts.map +1 -1
- package/dist/langgraph/checkpointer.js +15 -6
- package/dist/langgraph/checkpointer.js.map +1 -1
- package/dist/langgraph/graph.d.ts.map +1 -1
- package/dist/langgraph/graph.js +32 -13
- package/dist/langgraph/graph.js.map +1 -1
- package/dist/langgraph/index.d.ts +11 -11
- package/dist/langgraph/index.d.ts.map +1 -1
- package/dist/langgraph/index.js +19 -13
- package/dist/langgraph/index.js.map +1 -1
- package/dist/langgraph/nodes.d.ts +2 -1
- package/dist/langgraph/nodes.d.ts.map +1 -1
- package/dist/langgraph/nodes.js +23 -20
- package/dist/langgraph/nodes.js.map +1 -1
- package/dist/object.d.ts +24 -22
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +14 -11
- package/dist/object.js.map +1 -1
- package/dist/opencode/index.d.ts +11 -11
- package/dist/opencode/index.d.ts.map +1 -1
- package/dist/opencode/index.js +25 -27
- package/dist/opencode/index.js.map +1 -1
- package/dist/pi/index.d.ts +13 -13
- package/dist/pi/index.d.ts.map +1 -1
- package/dist/pi/index.js +18 -20
- package/dist/pi/index.js.map +1 -1
- package/dist/pi/storage.d.ts +7 -0
- package/dist/pi/storage.d.ts.map +1 -1
- package/dist/pi/storage.js +12 -0
- package/dist/pi/storage.js.map +1 -1
- package/dist/steering.d.ts +2 -1
- package/dist/steering.d.ts.map +1 -1
- package/dist/steering.js +2 -2
- package/dist/steering.js.map +1 -1
- package/dist/tools.d.ts +21 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +54 -14
- package/dist/tools.js.map +1 -1
- package/dist/webhook.js +1 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +90 -84
- package/src/calls.ts +52 -11
- package/src/claude/README.md +4 -2
- package/src/claude/index.ts +12 -7
- package/src/client.ts +1 -1
- package/src/common.ts +99 -40
- package/src/companion.ts +674 -0
- package/src/conversation.ts +353 -101
- package/src/deepseek/README.md +7 -1
- package/src/deepseek/index.ts +25 -24
- package/src/index.ts +10 -4
- package/src/langgraph/README.md +8 -5
- package/src/langgraph/checkpointer.ts +26 -15
- package/src/langgraph/graph.ts +30 -16
- package/src/langgraph/index.ts +24 -17
- package/src/langgraph/nodes.ts +24 -20
- package/src/object.ts +43 -40
- package/src/opencode/README.md +5 -2
- package/src/opencode/index.ts +26 -27
- package/src/pi/README.md +6 -1
- package/src/pi/index.ts +25 -19
- package/src/pi/storage.ts +13 -0
- package/src/steering.ts +8 -7
- package/src/tools.ts +60 -18
- package/src/webhook.ts +1 -1
- package/dist/signals.d.ts.map +0 -1
- package/dist/signals.js +0 -383
- package/dist/signals.js.map +0 -1
- package/src/signals.ts +0 -590
package/src/tools.ts
CHANGED
|
@@ -6,11 +6,15 @@
|
|
|
6
6
|
// A tool runs with the agent's context, and with the id of the model's tool
|
|
7
7
|
// call: Restate calls carry an idempotency key made of the invocation id and
|
|
8
8
|
// that id, so a tool call run again after a crash makes the same call, once.
|
|
9
|
+
// A workflow's `run` is the exception: it runs once per workflow id, and
|
|
10
|
+
// Restate refuses a second call of it whatever its idempotency key, so the
|
|
11
|
+
// tool waits for the run by its invocation id ({@link runWorkflow}).
|
|
9
12
|
import * as restate from '@restatedev/sessions';
|
|
13
|
+
import { attach, start } from '@restatedev/sessions/internal';
|
|
10
14
|
import { z } from 'zod';
|
|
11
15
|
import { stopSignalOf, type Configure, configured, ToolError } from './common.ts';
|
|
12
16
|
import { callOf } from './calls.ts';
|
|
13
|
-
import {
|
|
17
|
+
import { companionHere, NoCompanion } from './companion.ts';
|
|
14
18
|
|
|
15
19
|
const TOOL = Symbol.for('restate-agents.tool');
|
|
16
20
|
|
|
@@ -100,6 +104,9 @@ export const tool = <S extends z.ZodObject>(options: {
|
|
|
100
104
|
const turn = stopSignalOf(ctx);
|
|
101
105
|
if (turn?.aborted) throw turn.reason;
|
|
102
106
|
if (error instanceof restate.CancelledError) throw error;
|
|
107
|
+
// An object without a companion, waiting for a signal: a programming error, which fails the turn once,
|
|
108
|
+
// rather than an answer for the model to act on.
|
|
109
|
+
if (error instanceof NoCompanion) throw error;
|
|
103
110
|
// A terminal error is the tool's answer, which the model can act on; any
|
|
104
111
|
// other error fails the attempt, which Restate retries.
|
|
105
112
|
if (error instanceof restate.TerminalError) return `Error: ${error.message}`;
|
|
@@ -142,18 +149,43 @@ type Target<M = unknown> =
|
|
|
142
149
|
/** Whether a target is keyed: a virtual object (key) or a workflow (id). */
|
|
143
150
|
const keyed = (target: Target) => 'object' in target || 'workflow' in target;
|
|
144
151
|
|
|
145
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Call `method` of `service`, with JSON in and out, once per tool call (see
|
|
154
|
+
* {@link ToolContext}): the call's idempotency key makes the call a new
|
|
155
|
+
* attempt makes again (after a crash, or a suspension) the one the first
|
|
156
|
+
* made, whose result it gets. A workflow's `run` runs instead ({@link runWorkflow}).
|
|
157
|
+
*/
|
|
146
158
|
const invoke = (
|
|
147
159
|
{ ctx, idempotencyKey }: ToolContext,
|
|
148
|
-
target: { service: string; method: string; key?: string; parameter: unknown },
|
|
160
|
+
target: { service: string; method: string; key?: string; parameter: unknown; workflow?: boolean },
|
|
149
161
|
) =>
|
|
150
|
-
|
|
151
|
-
service: target.service,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
target.workflow && target.method === 'run'
|
|
163
|
+
? runWorkflow(ctx, { service: target.service, key: target.key!, input: target.parameter })
|
|
164
|
+
: ctx.rpc({
|
|
165
|
+
service: target.service,
|
|
166
|
+
handler: target.method,
|
|
167
|
+
key: target.key,
|
|
168
|
+
input: target.parameter,
|
|
169
|
+
idempotencyKey,
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Run workflow `service` (its `run` handler) with id `key` and `input` to its
|
|
174
|
+
* end, and resolve to its result: a call of it, whose result it does not wait
|
|
175
|
+
* for, then a wait for the run by the call's invocation id. A workflow's
|
|
176
|
+
* `run` runs once per id: Restate refuses a second call of it, whatever the
|
|
177
|
+
* call's idempotency key, but that call's invocation id is the run's. So a
|
|
178
|
+
* new attempt (after a crash, or a suspension while the run went on) that
|
|
179
|
+
* makes the call again waits for the run an earlier attempt started, and
|
|
180
|
+
* only the first starts one; and a fixed id that ran before gets its run's
|
|
181
|
+
* result. It is a call, not a send: stopping the turn cancels the run, as it
|
|
182
|
+
* cancels the turn's other calls (`cancelCalls`). The Python SDK's
|
|
183
|
+
* `run_workflow` sends instead, and so leaves the run going.
|
|
184
|
+
*/
|
|
185
|
+
export const runWorkflow = async (
|
|
186
|
+
ctx: restate.SessionContext,
|
|
187
|
+
{ service, key, input }: { service: string; key: string; input: unknown },
|
|
188
|
+
): Promise<unknown> => attach(ctx, await start(ctx, { service, handler: 'run', key, input }));
|
|
157
189
|
|
|
158
190
|
interface TargetOptions<S extends z.ZodObject | undefined> {
|
|
159
191
|
/** The tool's name, for the model; by default the handler's, such as `orders_status`. */
|
|
@@ -212,7 +244,12 @@ export const call = <M, S extends z.ZodObject | undefined = undefined>(
|
|
|
212
244
|
input: inputOf(target, options),
|
|
213
245
|
run: async (input, context) =>
|
|
214
246
|
once(`${target.name}/${handler}`, input, context, async (c) =>
|
|
215
|
-
invoke(c, {
|
|
247
|
+
invoke(c, {
|
|
248
|
+
service: target.name,
|
|
249
|
+
method: handler,
|
|
250
|
+
workflow: 'workflow' in target,
|
|
251
|
+
...(await split(target, options, input, c.ctx)),
|
|
252
|
+
}),
|
|
216
253
|
),
|
|
217
254
|
});
|
|
218
255
|
|
|
@@ -241,6 +278,9 @@ export const send = <M, S extends z.ZodObject | undefined = undefined>(
|
|
|
241
278
|
* A tool that runs the workflow `target` (its `run` handler) to the end, and
|
|
242
279
|
* answers with its result. Each tool call is a workflow of its own, with an
|
|
243
280
|
* id made of the agent's key and the tool call's id, unless `key` gives one.
|
|
281
|
+
* A tool call made again (after a crash, or a suspension while the workflow
|
|
282
|
+
* ran) waits for the run it started, and a `key` that ran before gets that
|
|
283
|
+
* run's result ({@link runWorkflow}).
|
|
244
284
|
*/
|
|
245
285
|
export const workflow = <S extends z.ZodObject | undefined = undefined>(
|
|
246
286
|
target: restate.WorkflowDefinition<string, { run: unknown }>,
|
|
@@ -252,11 +292,10 @@ export const workflow = <S extends z.ZodObject | undefined = undefined>(
|
|
|
252
292
|
input: z.object(options.input?.shape ?? {}),
|
|
253
293
|
run: async (input, context) =>
|
|
254
294
|
once(target.name, input, context, async (c) =>
|
|
255
|
-
|
|
295
|
+
runWorkflow(c.ctx, {
|
|
256
296
|
service: target.name,
|
|
257
|
-
method: 'run',
|
|
258
297
|
key: options.key === undefined ? `${c.ctx.key}-${c.callId}` : await configured(options.key, c.ctx),
|
|
259
|
-
|
|
298
|
+
input: options.input ? input : undefined,
|
|
260
299
|
}),
|
|
261
300
|
),
|
|
262
301
|
});
|
|
@@ -348,20 +387,23 @@ export const signal = (name: string, options: { description: string; input?: z.Z
|
|
|
348
387
|
* `pending` shows `input` if `shown`. `rejoin` and `approval` are
|
|
349
388
|
* {@link callOf}'s.
|
|
350
389
|
*/
|
|
351
|
-
const wait = (
|
|
390
|
+
const wait = async (
|
|
352
391
|
toolCall: ToolCall,
|
|
353
392
|
name: string,
|
|
354
393
|
input: unknown,
|
|
355
394
|
{ shown, rejoin, approval }: { shown: boolean; rejoin?: boolean; approval?: boolean },
|
|
356
|
-
): Promise<unknown> =>
|
|
357
|
-
once(
|
|
395
|
+
): Promise<unknown> => {
|
|
396
|
+
// Before the call is recorded: an object without a companion fails the turn, once (`NoCompanion`).
|
|
397
|
+
const companion = companionHere(toolCall.ctx, 'a wait for a signal');
|
|
398
|
+
return once(
|
|
358
399
|
`signal/${name}`,
|
|
359
400
|
input,
|
|
360
401
|
toolCall,
|
|
361
402
|
async ({ ctx, idempotencyKey: id }) =>
|
|
362
|
-
ctx.rpc(
|
|
403
|
+
ctx.rpc(companion, ctx.key, { idempotencyKey: id }).wait({ id, name, ...(shown ? { input } : {}) }),
|
|
363
404
|
{ rejoin, approval },
|
|
364
405
|
);
|
|
406
|
+
};
|
|
365
407
|
|
|
366
408
|
/**
|
|
367
409
|
* Wait for the signal `name` to the agent, for the model's tool call
|
package/src/webhook.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// The other system posts to Restate's ingress, at `/<name>/webhook`.
|
|
17
17
|
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
18
18
|
import { sdk as restate } from '@restatedev/sessions/internal';
|
|
19
|
-
import { deliver, hasCompanion } from './
|
|
19
|
+
import { deliver, hasCompanion } from './companion.ts';
|
|
20
20
|
|
|
21
21
|
/** How a webhook is signed: the HMAC-SHA256 of its body with `secret`, in hex, in the request's `header`. */
|
|
22
22
|
export interface WebhookAuth {
|
package/dist/signals.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../src/signals.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAiB,GAAG,IAAI,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,gGAAgG;AAChG,KAAK,YAAY,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE;YAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,CAAC;AAKlH,oDAAoD;AACpD,eAAO,MAAM,SAAS,QAAS,YAAY,WAA+C,CAAC;AAK3F;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,kDAAkD;IAClD,MAAM,EAAE,OAAO,OAAO,CAAC;IACvB,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAC;IACZ,8BAA8B;IAC9B,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,cAAc,CAAC,KAAG,CAQvE,CAAC;AAEJ;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAK3E;AAED,4EAA4E;AAC5E,eAAO,MAAM,YAAY,UAAW,MAAM,YAAsC,CAAC;AAEjF;;;;;;;GAOG;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AAC,aAAa,CAAC,KAAK,CAAC,6BAA4C,MAAM;;;;;;;mBAwBX,MAAM;;;;;;;;;;;;;;;kBAoNb,MAAM;mBAAa,MAAM;;;EAkB5G,CAAC"}
|
package/dist/signals.js
DELETED
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
import { Link, needing, sdk as restate } from '@restatedev/sessions/internal';
|
|
2
|
-
/** The key of the signals of agent `service`'s key `key`: `<agent>:<key>`. */
|
|
3
|
-
const keyOf = (service, key) => `${service}:${key}`;
|
|
4
|
-
/** The key of the signals of the agent of `ctx`. */
|
|
5
|
-
export const signalsOf = (ctx) => keyOf(ctx.request.target.service, ctx.key);
|
|
6
|
-
/** How an object of @restatedev/agents (`sessionObject()`, every `agent()`) reaches its companion, for one of its keys. */
|
|
7
|
-
const COMPANION = new Link('restate-agents.companion');
|
|
8
|
-
/**
|
|
9
|
-
* `definition`, pointing to its companion: what `sessionObject()` returns.
|
|
10
|
-
* `serve` serves its `signals` object beside it.
|
|
11
|
-
*/
|
|
12
|
-
export const withCompanion = (definition) => needing(COMPANION.on(definition, (key) => ({
|
|
13
|
-
object: signals,
|
|
14
|
-
key: keyOf(definition.name, key),
|
|
15
|
-
agent: { service: definition.name, key },
|
|
16
|
-
})), () => [signals]);
|
|
17
|
-
/**
|
|
18
|
-
* The companion of `agent`'s key `key`: for anyone holding an agent (an
|
|
19
|
-
* `sessionObject()` or `agent()` of @restatedev/agents) to reach what it is doing.
|
|
20
|
-
*/
|
|
21
|
-
export function companionOf(agent, key) {
|
|
22
|
-
const companion = COMPANION.of(agent);
|
|
23
|
-
if (!companion)
|
|
24
|
-
throw new Error(`${agent.name} is not an agent of @restatedev/agents (a sessionObject() or an agent())`);
|
|
25
|
-
return companion(key);
|
|
26
|
-
}
|
|
27
|
-
/** Whether `agent` is an object of @restatedev/agents, with a companion. */
|
|
28
|
-
export const hasCompanion = (agent) => COMPANION.of(agent) !== undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Deliver `text` to `agent`'s key `key`, from any handler: a message of its
|
|
31
|
-
* own (as `chat`), which it answers after the messages before it. It is
|
|
32
|
-
* sent, not awaited: `opts` may give it an idempotency key, so that it is
|
|
33
|
-
* delivered once.
|
|
34
|
-
*
|
|
35
|
-
* deliver(ctx, triage, 'ENG-1', 'The issue was closed', { idempotencyKey: delivery });
|
|
36
|
-
*/
|
|
37
|
-
export function deliver(ctx, agent, key, text, { idempotencyKey } = {}) {
|
|
38
|
-
companionOf(agent, key); // an agent of @restatedev/agents, with a `chat` handler
|
|
39
|
-
const message = { service: agent.name, handler: 'chat', key, input: text, idempotencyKey };
|
|
40
|
-
// A session object's handler, or one of the SDK's.
|
|
41
|
-
if ('send' in ctx)
|
|
42
|
-
ctx.send(message);
|
|
43
|
-
else {
|
|
44
|
-
ctx.genericSend({
|
|
45
|
-
service: agent.name,
|
|
46
|
-
method: 'chat',
|
|
47
|
-
key,
|
|
48
|
-
parameter: text,
|
|
49
|
-
inputSerde: restate.serde.json,
|
|
50
|
-
idempotencyKey,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* How many messages a turn takes by `steer`, at most: past them, each is
|
|
56
|
-
* answered as a turn of its own. The companion counts each message it holds
|
|
57
|
-
* for the turn, taken or not, until the turn ends: so a turn that someone
|
|
58
|
-
* steers on and on stays within bounds, and so does what the companion holds
|
|
59
|
-
* for it.
|
|
60
|
-
*/
|
|
61
|
-
export const STEERS = 16;
|
|
62
|
-
/** The messages of `inbox` steered to the turn being answered (`answering`) that it has not taken yet, oldest first. */
|
|
63
|
-
const waitingIn = (inbox, answering) => answering ? inbox.filter((m) => m.turn === answering.invocationId && m.text !== undefined) : [];
|
|
64
|
-
/** `turn` as `status` shows it: without what only the companion reads. */
|
|
65
|
-
const shown = (turn) => turn ? { invocationId: turn.invocationId, since: turn.since } : null;
|
|
66
|
-
/** Increase the revision, and answer each `watch` waiting for it: the new revision. */
|
|
67
|
-
async function publish(ctx) {
|
|
68
|
-
const revision = ((await ctx.get('revision')) ?? 0) + 1;
|
|
69
|
-
ctx.set('revision', revision);
|
|
70
|
-
for (const { awakeable } of (await ctx.get('watching')) ?? [])
|
|
71
|
-
ctx.resolveAwakeable(awakeable, { revision });
|
|
72
|
-
ctx.clear('watching');
|
|
73
|
-
return { revision };
|
|
74
|
-
}
|
|
75
|
-
/** Keep `inbox`, or forget it once it is empty. */
|
|
76
|
-
const setInbox = (ctx, inbox) => inbox.length > 0 ? ctx.set('inbox', inbox) : ctx.clear('inbox');
|
|
77
|
-
/** How long one `awaitTurn` waits for its turn to end, before a new one takes over. */
|
|
78
|
-
const WATCH = { hours: 1 };
|
|
79
|
-
/**
|
|
80
|
-
* `turn` (an invocation id) is over: forget it, if the agent answers it, and
|
|
81
|
-
* its tools' waits, which no one waits for any more, ending their `wait`s (a
|
|
82
|
-
* turn that ends as it should has none left, but a killed one leaves them).
|
|
83
|
-
* It publishes the change, for the clients that follow the conversation: a
|
|
84
|
-
* turn's own close (its last change), or the close of one that never closed
|
|
85
|
-
* itself. A close again changes nothing, and publishes nothing.
|
|
86
|
-
*
|
|
87
|
-
* If the turn's invocation is `gone` and the turn did not close itself, its
|
|
88
|
-
* agent is sent `settle`, which closes the turn in its conversation too, if
|
|
89
|
-
* it said, as it started the turn, that it `settles`.
|
|
90
|
-
*
|
|
91
|
-
* The messages steered to the turn are forgotten here: each that it did not
|
|
92
|
-
* take was queued as a turn of its own as it was sent (`steer`), and is
|
|
93
|
-
* answered as one.
|
|
94
|
-
*/
|
|
95
|
-
async function closed(ctx, turn, gone = false) {
|
|
96
|
-
const started = await ctx.get('turn');
|
|
97
|
-
const answering = started?.invocationId === turn;
|
|
98
|
-
if (answering) {
|
|
99
|
-
ctx.clear('turn');
|
|
100
|
-
if (gone && started?.settles) {
|
|
101
|
-
const at = ctx.key.indexOf(':');
|
|
102
|
-
ctx.genericSend({
|
|
103
|
-
service: ctx.key.slice(0, at),
|
|
104
|
-
method: 'settle',
|
|
105
|
-
key: ctx.key.slice(at + 1),
|
|
106
|
-
parameter: turn,
|
|
107
|
-
inputSerde: restate.serde.json,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const inbox = (await ctx.get('inbox')) ?? [];
|
|
112
|
-
const dropped = inbox.some((m) => m.turn === turn);
|
|
113
|
-
if (dropped)
|
|
114
|
-
setInbox(ctx, inbox.filter((m) => m.turn !== turn));
|
|
115
|
-
const waiting = (await ctx.get('waiting')) ?? [];
|
|
116
|
-
// A wait's id starts with the invocation id of the turn whose tool waits.
|
|
117
|
-
const ofTurn = (id) => id.startsWith(`${turn}:`);
|
|
118
|
-
const over = waiting.filter((w) => ofTurn(w.id));
|
|
119
|
-
const left = waiting.filter((w) => !ofTurn(w.id));
|
|
120
|
-
for (const w of over)
|
|
121
|
-
ctx.rejectAwakeable(w.awakeable, 'its turn is over');
|
|
122
|
-
if (over.length > 0)
|
|
123
|
-
ctx.set('waiting', left);
|
|
124
|
-
if (answering || over.length > 0 || dropped)
|
|
125
|
-
await publish(ctx);
|
|
126
|
-
}
|
|
127
|
-
/** A handler that the agents' own handlers call, which clients cannot (through Restate's ingress). */
|
|
128
|
-
const internal = (fn) => restate.handlers.object.exclusive({ ingressPrivate: true }, fn);
|
|
129
|
-
/**
|
|
130
|
-
* The signals of every agent, keyed `<agent>:<key>` ({@link signalsOf}).
|
|
131
|
-
* `serve` serves it beside the agents; the handlers marked `@internal` are
|
|
132
|
-
* called by the agents' own handlers, and Restate's ingress refuses them.
|
|
133
|
-
*/
|
|
134
|
-
export const signals = restate.object({
|
|
135
|
-
name: 'signals',
|
|
136
|
-
handlers: {
|
|
137
|
-
/** Wait for the signal `name`, as wait `id` (for `input`), and return its value. */
|
|
138
|
-
wait: restate.handlers.object.shared(async (ctx, wait) => {
|
|
139
|
-
const { id, promise } = ctx.awakeable();
|
|
140
|
-
const since = new Date(await ctx.date.now()).toISOString();
|
|
141
|
-
ctx.objectSendClient(signals, ctx.key).listen({ ...wait, since, awakeable: id });
|
|
142
|
-
try {
|
|
143
|
-
return await promise;
|
|
144
|
-
}
|
|
145
|
-
catch (error) {
|
|
146
|
-
// The agent's invocation was cancelled: no one waits any more.
|
|
147
|
-
if (error instanceof restate.CancelledError)
|
|
148
|
-
ctx.objectSendClient(signals, ctx.key).forget(wait.id);
|
|
149
|
-
throw error;
|
|
150
|
-
}
|
|
151
|
-
}),
|
|
152
|
-
/** Resolve the wait `id`, or else the oldest wait for `name`, with `value`. */
|
|
153
|
-
resolve: async (ctx, { id, name, value = null, keep = false }) => {
|
|
154
|
-
if (id === undefined && name === undefined)
|
|
155
|
-
throw new restate.TerminalError('a signal needs an id or a name');
|
|
156
|
-
const waiting = (await ctx.get('waiting')) ?? [];
|
|
157
|
-
const at = waiting.findIndex((w) => (id === undefined ? w.name === name : w.id === id));
|
|
158
|
-
if (at < 0) {
|
|
159
|
-
if (keep && name !== undefined && id === undefined) {
|
|
160
|
-
const kept = (await ctx.get('kept')) ?? {};
|
|
161
|
-
ctx.set('kept', { ...kept, [name]: [...(kept[name] ?? []), value] });
|
|
162
|
-
}
|
|
163
|
-
return { resolved: null };
|
|
164
|
-
}
|
|
165
|
-
const [wait] = waiting.splice(at, 1);
|
|
166
|
-
ctx.resolveAwakeable(wait.awakeable, value);
|
|
167
|
-
ctx.set('waiting', waiting);
|
|
168
|
-
await publish(ctx);
|
|
169
|
-
return { resolved: wait.id };
|
|
170
|
-
},
|
|
171
|
-
/** The waits, oldest first. */
|
|
172
|
-
pending: restate.handlers.object.shared(async (ctx) => ((await ctx.get('waiting')) ?? []).map(({ id, name, input, since }) => ({ id, name, input, since }))),
|
|
173
|
-
/** @internal A wait: resolved now with a signal kept for it, or else when one comes. */
|
|
174
|
-
listen: internal(async (ctx, wait) => {
|
|
175
|
-
const kept = (await ctx.get('kept')) ?? {};
|
|
176
|
-
const [value, ...rest] = kept[wait.name] ?? [];
|
|
177
|
-
if (kept[wait.name]?.length) {
|
|
178
|
-
ctx.resolveAwakeable(wait.awakeable, value);
|
|
179
|
-
ctx.set('kept', { ...kept, [wait.name]: rest });
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
ctx.set('waiting', [...((await ctx.get('waiting')) ?? []), wait]);
|
|
183
|
-
await publish(ctx);
|
|
184
|
-
}),
|
|
185
|
-
/**
|
|
186
|
-
* @internal The agent's `chat` started answering `turn`: the same
|
|
187
|
-
* invocation again (a retry) keeps when it started. A turn before it that
|
|
188
|
-
* never closed itself (its invocation was killed) closes now, if its
|
|
189
|
-
* `awaitTurn` did not close it yet. `awaitTurn` watches the new turn, so
|
|
190
|
-
* that it closes even if no turn comes after it.
|
|
191
|
-
*/
|
|
192
|
-
start: internal(async (ctx, turn) => {
|
|
193
|
-
const before = (await ctx.get('turn'))?.invocationId;
|
|
194
|
-
if (before === turn.invocationId)
|
|
195
|
-
return;
|
|
196
|
-
if (before !== undefined)
|
|
197
|
-
await closed(ctx, before, true);
|
|
198
|
-
ctx.set('turn', turn);
|
|
199
|
-
ctx.objectSendClient(signals, ctx.key).awaitTurn(turn.invocationId);
|
|
200
|
-
}),
|
|
201
|
-
/**
|
|
202
|
-
* @internal Wait for `turn` to end, without holding a process, and close
|
|
203
|
-
* it if it failed: its waits end, and `status` no longer says the agent
|
|
204
|
-
* answers it. A turn that never closed itself failed: it was killed, ran
|
|
205
|
-
* out of retries, or was lost. A turn that ends as it should, or is
|
|
206
|
-
* cancelled, closed itself already: its `close` is a call it waits for
|
|
207
|
-
* before it ends, so this `close` comes second, and changes nothing.
|
|
208
|
-
*
|
|
209
|
-
* It waits {@link WATCH} at most: a turn still answered then gets a new
|
|
210
|
-
* watch, which runs on the deployment of the day, rather than this one
|
|
211
|
-
* waiting for weeks on the one it started on (a turn that waits for an
|
|
212
|
-
* approval, say). A cancelled watch (an operator's) rejects the race
|
|
213
|
-
* itself, before either side's `map`: it closes nothing.
|
|
214
|
-
*/
|
|
215
|
-
awaitTurn: restate.handlers.object.shared(
|
|
216
|
-
// It leaves nothing behind once done: a turn has one at a time.
|
|
217
|
-
{ ingressPrivate: true, journalRetention: 0, idempotencyRetention: 0 }, async (ctx, turn) => {
|
|
218
|
-
const ended = await restate.RestatePromise.race([
|
|
219
|
-
// `map` gets the turn's failure too: a killed turn's (a TerminalError).
|
|
220
|
-
ctx
|
|
221
|
-
.invocation(restate.InvocationIdParser.fromString(turn))
|
|
222
|
-
.attach()
|
|
223
|
-
.map((_answer, failure) => ({ failed: failure !== undefined })),
|
|
224
|
-
ctx.sleep(WATCH).map(() => null),
|
|
225
|
-
]);
|
|
226
|
-
if (ended?.failed)
|
|
227
|
-
ctx.objectSendClient(signals, ctx.key).ended(turn);
|
|
228
|
-
else if (ended === null && (await ctx.get('turn'))?.invocationId === turn) {
|
|
229
|
-
ctx.objectSendClient(signals, ctx.key).awaitTurn(turn);
|
|
230
|
-
}
|
|
231
|
-
}),
|
|
232
|
-
/**
|
|
233
|
-
* What the agent does: the message it answers, if any, the waits of its
|
|
234
|
-
* tools, and the messages steered to it that it has not taken yet.
|
|
235
|
-
*/
|
|
236
|
-
status: restate.handlers.object.shared(async (ctx) => {
|
|
237
|
-
const answering = await ctx.get('turn');
|
|
238
|
-
const status = {
|
|
239
|
-
answering: shown(answering),
|
|
240
|
-
waiting: ((await ctx.get('waiting')) ?? []).map(({ id, name, input, since }) => ({ id, name, input, since })),
|
|
241
|
-
};
|
|
242
|
-
const steering = waitingIn((await ctx.get('inbox')) ?? [], answering).map(({ id, since }) => ({ id, since }));
|
|
243
|
-
return steering.length > 0 ? { ...status, steering } : status;
|
|
244
|
-
}),
|
|
245
|
-
/**
|
|
246
|
-
* The revision, once there is one newer than `revision`, or at the
|
|
247
|
-
* timeout (50 s by default, at most 60 s), whichever comes first. It
|
|
248
|
-
* waits in Restate, holding no process; a caller that retries it with the
|
|
249
|
-
* same idempotency key joins the same wait.
|
|
250
|
-
*/
|
|
251
|
-
watch: restate.handlers.object.shared(async (ctx, { revision, timeoutSeconds = 50 }) => {
|
|
252
|
-
const { id, promise } = ctx.awakeable();
|
|
253
|
-
ctx.objectSendClient(signals, ctx.key).subscribe({ revision, awakeable: id });
|
|
254
|
-
const timeout = ctx.sleep({ seconds: Math.min(Math.max(timeoutSeconds, 0), 60) }).map(() => null);
|
|
255
|
-
const changed = await restate.RestatePromise.race([promise, timeout]);
|
|
256
|
-
if (changed)
|
|
257
|
-
return changed;
|
|
258
|
-
ctx.objectSendClient(signals, ctx.key).unsubscribe(id);
|
|
259
|
-
return { revision: (await ctx.get('revision')) ?? 0 };
|
|
260
|
-
}),
|
|
261
|
-
/** @internal The message `turn` (an invocation id) is answered, or its turn ended otherwise: see {@link closed}. */
|
|
262
|
-
close: internal(async (ctx, turn) => closed(ctx, turn)),
|
|
263
|
-
/**
|
|
264
|
-
* @internal The invocation of `turn` failed (killed, out of retries): if
|
|
265
|
-
* the turn did not close itself, its agent closes it too (see {@link closed}).
|
|
266
|
-
*/
|
|
267
|
-
ended: internal(async (ctx, turn) => closed(ctx, turn, true)),
|
|
268
|
-
/**
|
|
269
|
-
* @internal The agent forgot its conversation (`clear`): forget its
|
|
270
|
-
* waits, kept signals and steered messages, and publish the change. Each
|
|
271
|
-
* steered message was queued as a turn of its own as it was sent, before
|
|
272
|
-
* the `clear`.
|
|
273
|
-
*/
|
|
274
|
-
reset: restate.handlers.object.exclusive({ ingressPrivate: true }, async (ctx) => {
|
|
275
|
-
ctx.clear('waiting');
|
|
276
|
-
ctx.clear('kept');
|
|
277
|
-
ctx.clear('inbox');
|
|
278
|
-
await publish(ctx);
|
|
279
|
-
}),
|
|
280
|
-
/** @internal Forget wait `id`, whose agent no longer waits. */
|
|
281
|
-
forget: internal(async (ctx, id) => {
|
|
282
|
-
const waiting = (await ctx.get('waiting')) ?? [];
|
|
283
|
-
ctx.set('waiting', waiting.filter((w) => w.id !== id));
|
|
284
|
-
await publish(ctx);
|
|
285
|
-
}),
|
|
286
|
-
/**
|
|
287
|
-
* @internal The conversation changed: increase its revision, and answer
|
|
288
|
-
* the `watch`es. It answers the new revision, and the messages steered
|
|
289
|
-
* to the turn being answered that it has not taken yet, if any: a turn
|
|
290
|
-
* publishes at each tool call's start and end, so it learns of them at
|
|
291
|
-
* no cost of its own.
|
|
292
|
-
*/
|
|
293
|
-
publish: restate.handlers.object.exclusive({ ingressPrivate: true }, async (ctx) => {
|
|
294
|
-
const published = await publish(ctx);
|
|
295
|
-
const inbox = (await ctx.get('inbox')) ?? [];
|
|
296
|
-
// Only then is the turn read: a turn that nobody steers costs one read more, of the empty inbox.
|
|
297
|
-
if (inbox.some((m) => m.text !== undefined)) {
|
|
298
|
-
const steering = waitingIn(inbox, await ctx.get('turn')).map(({ id, text }) => ({ id, text: text }));
|
|
299
|
-
if (steering.length > 0)
|
|
300
|
-
published.steering = steering;
|
|
301
|
-
}
|
|
302
|
-
return published;
|
|
303
|
-
}),
|
|
304
|
-
/**
|
|
305
|
-
* @internal Take a message steered to the agent (its `steer` view): for
|
|
306
|
-
* the turn being answered, or as a turn of its own.
|
|
307
|
-
*
|
|
308
|
-
* The message is always sent to the agent's private `steered` handler at
|
|
309
|
-
* once, which keeps its place in the key's queue, in order with the
|
|
310
|
-
* messages sent after it: once the turn being answered ends, `steered`
|
|
311
|
-
* answers the message as a turn of its own, unless that turn took it. A
|
|
312
|
-
* turn that takes steered messages (`Started.steers`) also finds it
|
|
313
|
-
* here, at its next step, through `publish`, until it takes it (`taken`)
|
|
314
|
-
* or ends.
|
|
315
|
-
*/
|
|
316
|
-
steer: internal(async (ctx, { id, text }) => {
|
|
317
|
-
const at = ctx.key.indexOf(':');
|
|
318
|
-
ctx.genericSend({
|
|
319
|
-
service: ctx.key.slice(0, at),
|
|
320
|
-
method: 'steered',
|
|
321
|
-
key: ctx.key.slice(at + 1),
|
|
322
|
-
parameter: { id, text },
|
|
323
|
-
inputSerde: restate.serde.json,
|
|
324
|
-
idempotencyKey: `steer:${id}`,
|
|
325
|
-
});
|
|
326
|
-
const answering = await ctx.get('turn');
|
|
327
|
-
if (!answering?.steers)
|
|
328
|
-
return { id, turn: null };
|
|
329
|
-
const turn = answering.invocationId;
|
|
330
|
-
const inbox = (await ctx.get('inbox')) ?? [];
|
|
331
|
-
if (inbox.some((m) => m.id === id))
|
|
332
|
-
return { id, turn };
|
|
333
|
-
// Taken or not: the turn has room for so many in all.
|
|
334
|
-
if (inbox.filter((m) => m.turn === turn).length >= STEERS)
|
|
335
|
-
return { id, turn: null };
|
|
336
|
-
const since = new Date(await ctx.date.now()).toISOString();
|
|
337
|
-
ctx.set('inbox', [...inbox, { id, since, turn, text }]);
|
|
338
|
-
await publish(ctx);
|
|
339
|
-
return { id, turn };
|
|
340
|
-
}),
|
|
341
|
-
/**
|
|
342
|
-
* @internal Mark the steered messages `ids` taken, which their turn has
|
|
343
|
-
* stored, and publish the change, if any. The turn sends it with the
|
|
344
|
-
* transaction that stores them, so it comes once they are stored, and
|
|
345
|
-
* once only. Each is kept without its text until the turn ends, as one
|
|
346
|
-
* of its {@link STEERS}; one already forgotten (its turn closed first)
|
|
347
|
-
* is left so.
|
|
348
|
-
*/
|
|
349
|
-
taken: internal(async (ctx, ids) => {
|
|
350
|
-
const inbox = (await ctx.get('inbox')) ?? [];
|
|
351
|
-
let changed = false;
|
|
352
|
-
const marked = inbox.map((m) => {
|
|
353
|
-
if (m.text === undefined || !ids.includes(m.id))
|
|
354
|
-
return m;
|
|
355
|
-
changed = true;
|
|
356
|
-
return { id: m.id, since: m.since, turn: m.turn };
|
|
357
|
-
});
|
|
358
|
-
if (!changed)
|
|
359
|
-
return;
|
|
360
|
-
setInbox(ctx, marked);
|
|
361
|
-
await publish(ctx);
|
|
362
|
-
}),
|
|
363
|
-
/** The conversation's revision. */
|
|
364
|
-
notifications: restate.handlers.object.shared(async (ctx) => ({
|
|
365
|
-
revision: (await ctx.get('revision')) ?? 0,
|
|
366
|
-
})),
|
|
367
|
-
/** @internal Answer `awakeable` once there is a revision newer than `revision`: at once, if there is. */
|
|
368
|
-
subscribe: internal(async (ctx, watch) => {
|
|
369
|
-
const revision = (await ctx.get('revision')) ?? 0;
|
|
370
|
-
if (revision > watch.revision) {
|
|
371
|
-
ctx.resolveAwakeable(watch.awakeable, { revision });
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
ctx.set('watching', [...((await ctx.get('watching')) ?? []), watch]);
|
|
375
|
-
}),
|
|
376
|
-
/** @internal Forget the `watch` of `awakeable`, which no longer waits. */
|
|
377
|
-
unsubscribe: internal(async (ctx, awakeable) => {
|
|
378
|
-
const watching = (await ctx.get('watching')) ?? [];
|
|
379
|
-
ctx.set('watching', watching.filter((w) => w.awakeable !== awakeable));
|
|
380
|
-
}),
|
|
381
|
-
},
|
|
382
|
-
});
|
|
383
|
-
//# sourceMappingURL=signals.js.map
|
package/dist/signals.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signals.js","sourceRoot":"","sources":["../src/signals.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAO9E,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,2HAA2H;AAC3H,MAAM,SAAS,GAAG,IAAI,IAAI,CAA6B,0BAA0B,CAAC,CAAC;AAgBnF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAA6B,UAAa,EAAK,EAAE,CAC5E,OAAO,CACL,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACjC,MAAM,EAAE,OAAO;IACf,GAAG,EA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