@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.
Files changed (101) hide show
  1. package/README.md +79 -24
  2. package/dist/calls.d.ts +20 -1
  3. package/dist/calls.d.ts.map +1 -1
  4. package/dist/calls.js +46 -7
  5. package/dist/calls.js.map +1 -1
  6. package/dist/claude/index.d.ts +11 -11
  7. package/dist/claude/index.d.ts.map +1 -1
  8. package/dist/claude/index.js +12 -6
  9. package/dist/claude/index.js.map +1 -1
  10. package/dist/client.d.ts +1 -1
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/common.d.ts +62 -23
  13. package/dist/common.d.ts.map +1 -1
  14. package/dist/common.js +67 -38
  15. package/dist/common.js.map +1 -1
  16. package/dist/{signals.d.ts → companion.d.ts} +106 -43
  17. package/dist/companion.d.ts.map +1 -0
  18. package/dist/companion.js +463 -0
  19. package/dist/companion.js.map +1 -0
  20. package/dist/conversation.d.ts +103 -5
  21. package/dist/conversation.d.ts.map +1 -1
  22. package/dist/conversation.js +295 -75
  23. package/dist/conversation.js.map +1 -1
  24. package/dist/deepseek/index.d.ts +11 -11
  25. package/dist/deepseek/index.d.ts.map +1 -1
  26. package/dist/deepseek/index.js +26 -26
  27. package/dist/deepseek/index.js.map +1 -1
  28. package/dist/index.d.ts +8 -4
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +7 -3
  31. package/dist/index.js.map +1 -1
  32. package/dist/langgraph/checkpointer.d.ts +3 -1
  33. package/dist/langgraph/checkpointer.d.ts.map +1 -1
  34. package/dist/langgraph/checkpointer.js +15 -6
  35. package/dist/langgraph/checkpointer.js.map +1 -1
  36. package/dist/langgraph/graph.d.ts.map +1 -1
  37. package/dist/langgraph/graph.js +32 -13
  38. package/dist/langgraph/graph.js.map +1 -1
  39. package/dist/langgraph/index.d.ts +11 -11
  40. package/dist/langgraph/index.d.ts.map +1 -1
  41. package/dist/langgraph/index.js +19 -13
  42. package/dist/langgraph/index.js.map +1 -1
  43. package/dist/langgraph/nodes.d.ts +2 -1
  44. package/dist/langgraph/nodes.d.ts.map +1 -1
  45. package/dist/langgraph/nodes.js +23 -20
  46. package/dist/langgraph/nodes.js.map +1 -1
  47. package/dist/object.d.ts +24 -22
  48. package/dist/object.d.ts.map +1 -1
  49. package/dist/object.js +14 -11
  50. package/dist/object.js.map +1 -1
  51. package/dist/opencode/index.d.ts +11 -11
  52. package/dist/opencode/index.d.ts.map +1 -1
  53. package/dist/opencode/index.js +25 -27
  54. package/dist/opencode/index.js.map +1 -1
  55. package/dist/pi/index.d.ts +13 -13
  56. package/dist/pi/index.d.ts.map +1 -1
  57. package/dist/pi/index.js +18 -20
  58. package/dist/pi/index.js.map +1 -1
  59. package/dist/pi/storage.d.ts +7 -0
  60. package/dist/pi/storage.d.ts.map +1 -1
  61. package/dist/pi/storage.js +12 -0
  62. package/dist/pi/storage.js.map +1 -1
  63. package/dist/steering.d.ts +2 -1
  64. package/dist/steering.d.ts.map +1 -1
  65. package/dist/steering.js +2 -2
  66. package/dist/steering.js.map +1 -1
  67. package/dist/tools.d.ts +21 -0
  68. package/dist/tools.d.ts.map +1 -1
  69. package/dist/tools.js +54 -14
  70. package/dist/tools.js.map +1 -1
  71. package/dist/webhook.js +1 -1
  72. package/dist/webhook.js.map +1 -1
  73. package/package.json +90 -84
  74. package/src/calls.ts +52 -11
  75. package/src/claude/README.md +4 -2
  76. package/src/claude/index.ts +12 -7
  77. package/src/client.ts +1 -1
  78. package/src/common.ts +99 -40
  79. package/src/companion.ts +674 -0
  80. package/src/conversation.ts +353 -101
  81. package/src/deepseek/README.md +7 -1
  82. package/src/deepseek/index.ts +25 -24
  83. package/src/index.ts +10 -4
  84. package/src/langgraph/README.md +8 -5
  85. package/src/langgraph/checkpointer.ts +26 -15
  86. package/src/langgraph/graph.ts +30 -16
  87. package/src/langgraph/index.ts +24 -17
  88. package/src/langgraph/nodes.ts +24 -20
  89. package/src/object.ts +43 -40
  90. package/src/opencode/README.md +5 -2
  91. package/src/opencode/index.ts +26 -27
  92. package/src/pi/README.md +6 -1
  93. package/src/pi/index.ts +25 -19
  94. package/src/pi/storage.ts +13 -0
  95. package/src/steering.ts +8 -7
  96. package/src/tools.ts +60 -18
  97. package/src/webhook.ts +1 -1
  98. package/dist/signals.d.ts.map +0 -1
  99. package/dist/signals.js +0 -383
  100. package/dist/signals.js.map +0 -1
  101. package/src/signals.ts +0 -590
package/dist/tools.js 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, configured, ToolError } from './common.js';
12
16
  import { callOf } from './calls.js';
13
- import { signals, signalsOf } from './signals.js';
17
+ import { companionHere, NoCompanion } from './companion.js';
14
18
  const TOOL = Symbol.for('restate-agents.tool');
15
19
  /** The JSON schema of `t`'s input, which a framework offers the model. */
16
20
  export const jsonSchemaOf = (t) => z.toJSONSchema(t.input);
@@ -60,6 +64,10 @@ export const tool = (options) => ({
60
64
  throw turn.reason;
61
65
  if (error instanceof restate.CancelledError)
62
66
  throw error;
67
+ // An object without a companion, waiting for a signal: a programming error, which fails the turn once,
68
+ // rather than an answer for the model to act on.
69
+ if (error instanceof NoCompanion)
70
+ throw error;
63
71
  // A terminal error is the tool's answer, which the model can act on; any
64
72
  // other error fails the attempt, which Restate retries.
65
73
  if (error instanceof restate.TerminalError)
@@ -91,14 +99,35 @@ async function once(name, input, context, body, options) {
91
99
  }
92
100
  /** Whether a target is keyed: a virtual object (key) or a workflow (id). */
93
101
  const keyed = (target) => 'object' in target || 'workflow' in target;
94
- /** Call `method` of `service`, with JSON in and out, once per tool call (see {@link ToolContext}). */
95
- const invoke = ({ ctx, idempotencyKey }, target) => ctx.rpc({
96
- service: target.service,
97
- handler: target.method,
98
- key: target.key,
99
- input: target.parameter,
100
- idempotencyKey,
101
- });
102
+ /**
103
+ * Call `method` of `service`, with JSON in and out, once per tool call (see
104
+ * {@link ToolContext}): the call's idempotency key makes the call a new
105
+ * attempt makes again (after a crash, or a suspension) the one the first
106
+ * made, whose result it gets. A workflow's `run` runs instead ({@link runWorkflow}).
107
+ */
108
+ const invoke = ({ ctx, idempotencyKey }, target) => target.workflow && target.method === 'run'
109
+ ? runWorkflow(ctx, { service: target.service, key: target.key, input: target.parameter })
110
+ : ctx.rpc({
111
+ service: target.service,
112
+ handler: target.method,
113
+ key: target.key,
114
+ input: target.parameter,
115
+ idempotencyKey,
116
+ });
117
+ /**
118
+ * Run workflow `service` (its `run` handler) with id `key` and `input` to its
119
+ * end, and resolve to its result: a call of it, whose result it does not wait
120
+ * for, then a wait for the run by the call's invocation id. A workflow's
121
+ * `run` runs once per id: Restate refuses a second call of it, whatever the
122
+ * call's idempotency key, but that call's invocation id is the run's. So a
123
+ * new attempt (after a crash, or a suspension while the run went on) that
124
+ * makes the call again waits for the run an earlier attempt started, and
125
+ * only the first starts one; and a fixed id that ran before gets its run's
126
+ * result. It is a call, not a send: stopping the turn cancels the run, as it
127
+ * cancels the turn's other calls (`cancelCalls`). The Python SDK's
128
+ * `run_workflow` sends instead, and so leaves the run going.
129
+ */
130
+ export const runWorkflow = async (ctx, { service, key, input }) => attach(ctx, await start(ctx, { service, handler: 'run', key, input }));
102
131
  /** The tool's input: the handler's, and the key if the model chooses it. */
103
132
  function inputOf(target, { input, key }) {
104
133
  const shape = input?.shape ?? {};
@@ -130,7 +159,12 @@ export const call = (target, handler, options) => tool({
130
159
  name: options.name ?? `${target.name}_${handler}`,
131
160
  description: options.description,
132
161
  input: inputOf(target, options),
133
- run: async (input, context) => once(`${target.name}/${handler}`, input, context, async (c) => invoke(c, { service: target.name, method: handler, ...(await split(target, options, input, c.ctx)) })),
162
+ run: async (input, context) => once(`${target.name}/${handler}`, input, context, async (c) => invoke(c, {
163
+ service: target.name,
164
+ method: handler,
165
+ workflow: 'workflow' in target,
166
+ ...(await split(target, options, input, c.ctx)),
167
+ })),
134
168
  });
135
169
  /**
136
170
  * A tool that sends to `handler` of `target`, without waiting for it: a
@@ -150,16 +184,18 @@ export const send = (target, handler, options) => tool({
150
184
  * A tool that runs the workflow `target` (its `run` handler) to the end, and
151
185
  * answers with its result. Each tool call is a workflow of its own, with an
152
186
  * id made of the agent's key and the tool call's id, unless `key` gives one.
187
+ * A tool call made again (after a crash, or a suspension while the workflow
188
+ * ran) waits for the run it started, and a `key` that ran before gets that
189
+ * run's result ({@link runWorkflow}).
153
190
  */
154
191
  export const workflow = (target, options) => tool({
155
192
  name: options.name ?? target.name,
156
193
  description: options.description,
157
194
  input: z.object(options.input?.shape ?? {}),
158
- run: async (input, context) => once(target.name, input, context, async (c) => invoke(c, {
195
+ run: async (input, context) => once(target.name, input, context, async (c) => runWorkflow(c.ctx, {
159
196
  service: target.name,
160
- method: 'run',
161
197
  key: options.key === undefined ? `${c.ctx.key}-${c.callId}` : await configured(options.key, c.ctx),
162
- parameter: options.input ? input : undefined,
198
+ input: options.input ? input : undefined,
163
199
  })),
164
200
  });
165
201
  export function subagent(agent, { description = agent.description, name: toolName = agent.name, handler, } = {}) {
@@ -211,7 +247,11 @@ export const signal = (name, options) => tool({
211
247
  * `pending` shows `input` if `shown`. `rejoin` and `approval` are
212
248
  * {@link callOf}'s.
213
249
  */
214
- const wait = (toolCall, name, input, { shown, rejoin, approval }) => once(`signal/${name}`, input, toolCall, async ({ ctx, idempotencyKey: id }) => ctx.rpc(signals, signalsOf(ctx), { idempotencyKey: id }).wait({ id, name, ...(shown ? { input } : {}) }), { rejoin, approval });
250
+ const wait = async (toolCall, name, input, { shown, rejoin, approval }) => {
251
+ // Before the call is recorded: an object without a companion fails the turn, once (`NoCompanion`).
252
+ const companion = companionHere(toolCall.ctx, 'a wait for a signal');
253
+ return once(`signal/${name}`, input, toolCall, async ({ ctx, idempotencyKey: id }) => ctx.rpc(companion, ctx.key, { idempotencyKey: id }).wait({ id, name, ...(shown ? { input } : {}) }), { rejoin, approval });
254
+ };
215
255
  /**
216
256
  * Wait for the signal `name` to the agent, for the model's tool call
217
257
  * `callId`, and answer with its value: what a {@link signal} tool does, for
package/dist/tools.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,wEAAwE;AACxE,sCAAsC;AACtC,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAkB,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AAmC/C,0EAA0E;AAC1E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAO,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAA4B,CAAC;AAE5F,wEAAwE;AACxE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,IAAI,IAAI,KAAK,CAAC;AAEtH,qFAAqF;AACrF,MAAM,IAAI,GAAG,CAAC,KAAc,EAAE,EAAE,CAC9B,OAA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
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 './signals.js';
19
+ import { deliver, hasCompanion } from './companion.js';
20
20
  /**
21
21
  * The message an agent gets for a webhook's delivery: its body, as JSON, in
22
22
  * a `<webhook>` element that says which webhook, and which delivery.
@@ -1 +1 @@
1
- {"version":3,"file":"webhook.js","sourceRoot":"","sources":["../src/webhook.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,qEAAqE;AACrE,2EAA2E;AAC3E,yEAAyE;AACzE,sBAAsB;AACtB,EAAE;AACF,6BAA6B;AAC7B,sBAAsB;AACtB,wFAAwF;AACxF,4CAA4C;AAC5C,uBAAuB;AACvB,0CAA0C;AAC1C,QAAQ;AACR,iCAAiC;AACjC,EAAE;AACF,qEAAqE;AACrE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAoDrD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,QAAgB,EAAE,KAAc,EAAE,EAAE,CAC/E,kBAAkB,IAAI,eAAe,QAAQ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,cAAc,CAAC;AAEnG,8EAA8E;AAC9E,MAAM,MAAM,GAAG,CAAC,IAAgB,EAAE,SAA6B,EAAE,MAAc,EAAE,EAAE;IACjF,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IACpE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS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,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;gBACvC,IAAI,EAAE,KAAK,SAAS;oBAAE,OAAO;gBAC7B,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBAC9E,KAAK,MAAM,KAAK,IAAI,KAAK;oBAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,cAAc,EAAE,WAAW,IAAI,IAAI,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC9G,CAAC,CACF;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restatedev/agents",
3
- "version": "0.5.0",
3
+ "version": "0.7.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": {
@@ -59,94 +59,97 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@ai-sdk/provider": "3.0.8",
62
- "@anthropic-ai/sdk": "0.133.0",
63
- "@deepseek-ai/cordis": "4.0.5",
64
- "@deepseek-ai/cordis-plugin-loader": "1.0.6",
65
- "@deepseek-ai/dsh-agent": "0.2.1-rc.2",
66
- "@deepseek-ai/dsh-agent-loop": "0.2.1-rc.2",
67
- "@deepseek-ai/dsh-anonymous-user-id": "0.2.1-rc.2",
68
- "@deepseek-ai/dsh-atomic-write": "0.2.1-rc.2",
69
- "@deepseek-ai/dsh-attachment": "0.2.1-rc.2",
70
- "@deepseek-ai/dsh-authorization": "0.2.1-rc.2",
71
- "@deepseek-ai/dsh-commands": "0.2.1-rc.2",
72
- "@deepseek-ai/dsh-compaction": "0.2.1-rc.2",
73
- "@deepseek-ai/dsh-compaction-basic": "0.2.1-rc.2",
74
- "@deepseek-ai/dsh-compaction-tool-result-pruner": "0.2.1-rc.2",
75
- "@deepseek-ai/dsh-credentials": "0.2.1-rc.2",
76
- "@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.1-rc.2",
77
- "@deepseek-ai/dsh-fs": "0.2.1-rc.2",
78
- "@deepseek-ai/dsh-home-paths": "0.2.1-rc.2",
79
- "@deepseek-ai/dsh-launch-environment": "0.2.1-rc.2",
80
- "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
81
- "@deepseek-ai/dsh-llm-deepseek": "0.2.1-rc.2",
82
- "@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.1-rc.2",
83
- "@deepseek-ai/dsh-llm-pi-ai": "0.2.1-rc.2",
84
- "@deepseek-ai/dsh-ptc-runtime": "0.2.1-rc.2",
85
- "@deepseek-ai/dsh-sandbox": "0.2.1-rc.2",
86
- "@deepseek-ai/dsh-sandbox-policy": "0.2.1-rc.2",
87
- "@deepseek-ai/dsh-scope": "0.2.1-rc.2",
88
- "@deepseek-ai/dsh-session": "0.2.1-rc.2",
89
- "@deepseek-ai/dsh-session-checkpoint-policy": "0.2.1-rc.2",
90
- "@deepseek-ai/dsh-session-persistence": "0.2.1-rc.2",
91
- "@deepseek-ai/dsh-session-projection": "0.2.1-rc.2",
92
- "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
93
- "@deepseek-ai/dsh-timeout": "0.2.1-rc.2",
94
- "@deepseek-ai/dsh-token-meter": "0.2.1-rc.2",
95
- "@deepseek-ai/dsh-tools": "0.2.1-rc.2",
96
- "@deepseek-ai/dsh-user-approval": "0.2.1-rc.2",
97
- "@earendil-works/chord": "1.4.0",
98
- "@earendil-works/pi-ai": "1.4.0",
99
- "@earendil-works/pi-durable": "1.4.0",
100
- "@langchain/anthropic": "1.5.11",
101
- "@langchain/core": "1.2.12",
102
- "@langchain/langgraph": "1.4.18",
103
- "@langchain/langgraph-checkpoint": "1.1.5",
104
- "@langchain/langgraph-checkpoint-validation": "1.1.1",
105
- "@langchain/openai": "1.7.0",
106
- "@opencode/core": "2.2.6",
107
- "@opencode/plugin": "2.2.6",
108
- "@opencode/sdk": "2.2.6",
109
- "@opencode/server": "2.2.6",
62
+ "@anthropic-ai/sdk": "1.8.0",
63
+ "@deepseek-ai/cordis": "4.1.0",
64
+ "@deepseek-ai/cordis-plugin-loader": "1.1.0",
65
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.2",
66
+ "@deepseek-ai/dsh-agent-loop": "0.2.2-rc.2",
67
+ "@deepseek-ai/dsh-anonymous-user-id": "0.2.2-rc.2",
68
+ "@deepseek-ai/dsh-atomic-write": "0.2.2-rc.2",
69
+ "@deepseek-ai/dsh-attachment": "0.2.2-rc.2",
70
+ "@deepseek-ai/dsh-authorization": "0.2.2-rc.2",
71
+ "@deepseek-ai/dsh-commands": "0.2.2-rc.2",
72
+ "@deepseek-ai/dsh-compaction": "0.2.2-rc.2",
73
+ "@deepseek-ai/dsh-compaction-basic": "0.2.2-rc.2",
74
+ "@deepseek-ai/dsh-compaction-tool-result-pruner": "0.2.2-rc.2",
75
+ "@deepseek-ai/dsh-credentials": "0.2.2-rc.2",
76
+ "@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.2-rc.2",
77
+ "@deepseek-ai/dsh-fs": "0.2.2-rc.2",
78
+ "@deepseek-ai/dsh-home-paths": "0.2.2-rc.2",
79
+ "@deepseek-ai/dsh-launch-environment": "0.2.2-rc.2",
80
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.2",
81
+ "@deepseek-ai/dsh-llm-deepseek": "0.2.2-rc.2",
82
+ "@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.2-rc.2",
83
+ "@deepseek-ai/dsh-llm-pi-ai": "0.2.2-rc.2",
84
+ "@deepseek-ai/dsh-ptc-runtime": "0.2.2-rc.2",
85
+ "@deepseek-ai/dsh-sandbox": "0.2.2-rc.2",
86
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.2",
87
+ "@deepseek-ai/dsh-scope": "0.2.2-rc.2",
88
+ "@deepseek-ai/dsh-session": "0.2.2-rc.2",
89
+ "@deepseek-ai/dsh-session-checkpoint-policy": "0.2.2-rc.2",
90
+ "@deepseek-ai/dsh-session-persistence": "0.2.2-rc.2",
91
+ "@deepseek-ai/dsh-session-projection": "0.2.2-rc.2",
92
+ "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.2",
93
+ "@deepseek-ai/dsh-timeout": "0.2.2-rc.2",
94
+ "@deepseek-ai/dsh-token-meter": "0.2.2-rc.2",
95
+ "@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.2",
96
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.2",
97
+ "@deepseek-ai/dsh-user-approval": "0.2.2-rc.2",
98
+ "@earendil-works/chord": "1.5.2",
99
+ "@earendil-works/pi-ai": "1.5.2",
100
+ "@earendil-works/pi-durable": "1.5.2",
101
+ "@earendil-works/pi-schema": "1.5.2",
102
+ "@langchain/anthropic": "1.6.4",
103
+ "@langchain/core": "1.4.0",
104
+ "@langchain/langgraph": "1.7.3",
105
+ "@langchain/langgraph-checkpoint": "1.2.2",
106
+ "@langchain/langgraph-checkpoint-validation": "1.2.0",
107
+ "@langchain/openai": "1.8.4",
108
+ "@opencode/core": "2.2.7",
109
+ "@opencode/plugin": "2.2.7",
110
+ "@opencode/sdk": "2.2.7",
111
+ "@opencode/server": "2.2.7",
110
112
  "@restatedev/restate-sdk": "1.18.2",
111
- "@restatedev/sessions": "0.5.0",
113
+ "@restatedev/sessions": "0.7.0",
112
114
  "effect": "4.1.0",
113
- "zod": "4.6.5"
115
+ "zod": "4.6.7"
114
116
  },
115
117
  "peerDependencies": {
116
- "@anthropic-ai/sdk": "^0.133.0",
117
- "@deepseek-ai/cordis": "~4.0.5",
118
- "@deepseek-ai/dsh-agent": "0.2.1-rc.2",
119
- "@deepseek-ai/dsh-agent-loop": "0.2.1-rc.2",
120
- "@deepseek-ai/dsh-commands": "0.2.1-rc.2",
121
- "@deepseek-ai/dsh-compaction": "0.2.1-rc.2",
122
- "@deepseek-ai/dsh-compaction-basic": "0.2.1-rc.2",
123
- "@deepseek-ai/dsh-compaction-tool-result-pruner": "0.2.1-rc.2",
124
- "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
125
- "@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.1-rc.2",
126
- "@deepseek-ai/dsh-llm-pi-ai": "0.2.1-rc.2",
127
- "@deepseek-ai/dsh-session": "0.2.1-rc.2",
128
- "@deepseek-ai/dsh-session-checkpoint-policy": "0.2.1-rc.2",
129
- "@deepseek-ai/dsh-session-persistence": "0.2.1-rc.2",
130
- "@deepseek-ai/dsh-session-projection": "0.2.1-rc.2",
131
- "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
132
- "@deepseek-ai/dsh-token-meter": "0.2.1-rc.2",
133
- "@deepseek-ai/dsh-tools": "0.2.1-rc.2",
134
- "@deepseek-ai/dsh-user-approval": "0.2.1-rc.2",
135
- "@earendil-works/chord": "^1.4.0",
136
- "@earendil-works/pi-ai": "^1.4.0",
137
- "@earendil-works/pi-durable": "^1.4.0",
138
- "@langchain/anthropic": "^1.5.11",
139
- "@langchain/core": "^1.2.12",
140
- "@langchain/langgraph": "^1.4.18",
141
- "@langchain/langgraph-checkpoint": "^1.1.5",
142
- "@langchain/openai": "^1.7.0",
143
- "@opencode/core": "2.2.6",
144
- "@opencode/plugin": "2.2.6",
145
- "@opencode/sdk": "2.2.6",
146
- "@opencode/server": "2.2.6",
147
- "@restatedev/sessions": "^0.5.0",
118
+ "@anthropic-ai/sdk": "^1.8.0",
119
+ "@deepseek-ai/cordis": "~4.1.0",
120
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.2",
121
+ "@deepseek-ai/dsh-agent-loop": "0.2.2-rc.2",
122
+ "@deepseek-ai/dsh-commands": "0.2.2-rc.2",
123
+ "@deepseek-ai/dsh-compaction": "0.2.2-rc.2",
124
+ "@deepseek-ai/dsh-compaction-basic": "0.2.2-rc.2",
125
+ "@deepseek-ai/dsh-compaction-tool-result-pruner": "0.2.2-rc.2",
126
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.2",
127
+ "@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.2-rc.2",
128
+ "@deepseek-ai/dsh-llm-pi-ai": "0.2.2-rc.2",
129
+ "@deepseek-ai/dsh-session": "0.2.2-rc.2",
130
+ "@deepseek-ai/dsh-session-checkpoint-policy": "0.2.2-rc.2",
131
+ "@deepseek-ai/dsh-session-persistence": "0.2.2-rc.2",
132
+ "@deepseek-ai/dsh-session-projection": "0.2.2-rc.2",
133
+ "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.2",
134
+ "@deepseek-ai/dsh-token-meter": "0.2.2-rc.2",
135
+ "@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.2",
136
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.2",
137
+ "@deepseek-ai/dsh-user-approval": "0.2.2-rc.2",
138
+ "@earendil-works/chord": "~1.5.2",
139
+ "@earendil-works/pi-ai": "~1.5.2",
140
+ "@earendil-works/pi-durable": "~1.5.2",
141
+ "@langchain/anthropic": "^1.6.4",
142
+ "@langchain/core": "^1.4.0",
143
+ "@langchain/langgraph": "^1.7.3",
144
+ "@langchain/langgraph-checkpoint": "^1.2.2",
145
+ "@langchain/openai": "^1.8.4",
146
+ "@opencode/core": "2.2.7",
147
+ "@opencode/plugin": "2.2.7",
148
+ "@opencode/sdk": "2.2.7",
149
+ "@opencode/server": "2.2.7",
150
+ "@restatedev/sessions": "^0.7.0",
148
151
  "effect": "4.1.0",
149
- "zod": "^4.6.5"
152
+ "zod": "^4.6.7"
150
153
  },
151
154
  "peerDependenciesMeta": {
152
155
  "@anthropic-ai/sdk": {
@@ -200,6 +203,9 @@
200
203
  "@deepseek-ai/dsh-token-meter": {
201
204
  "optional": true
202
205
  },
206
+ "@deepseek-ai/dsh-tool-executor-native": {
207
+ "optional": true
208
+ },
203
209
  "@deepseek-ai/dsh-tools": {
204
210
  "optional": true
205
211
  },
package/src/calls.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  // task), which it waits for again, or whose answer it gets.
12
12
  //
13
13
  // A call is kept until the framework's transcript has its result under the
14
- // last id it was made with ({@link settleCalls}, at each publish, and before each
14
+ // last id it was made with ({@link settleCalls}, after each commit of steps, and before each
15
15
  // tool call): one that answered just before a crash, whose result the
16
16
  // framework had not stored, is made again as the same call. An error there
17
17
  // is not its result (the DeepSeek Harness gives the call it interrupted
@@ -54,8 +54,11 @@ interface Calls {
54
54
  calls: Call[];
55
55
  }
56
56
 
57
- /** The table of the {@link Calls}: one row, of the invocation whose calls they are. */
58
- const SCHEMA = new Schema('restate-agents.calls', [
57
+ /**
58
+ * The table of the {@link Calls}: one row, of the invocation whose calls they are. `answerOnce` applies it with
59
+ * the conversation's, in one commit, as a key's first turn starts.
60
+ */
61
+ export const SCHEMA = new Schema('restate-agents.calls', [
59
62
  `CREATE TABLE restate_agent_calls (
60
63
  row INTEGER PRIMARY KEY CHECK (row = 0),
61
64
  invocation TEXT NOT NULL,
@@ -66,8 +69,33 @@ const SCHEMA = new Schema('restate-agents.calls', [
66
69
  /** What the calls need of a handler's context. */
67
70
  type CallsContext = Pick<restate.SessionContext, 'db' | 'request'>;
68
71
 
69
- /** Store `calls`, committed before the call they record is made. */
70
- async function store(ctx: CallsContext, { invocation, calls }: Calls) {
72
+ /** What writes the rows the conversation of the attempt's turn holds back, by its context. */
73
+ const HELD = new ScopeKey<() => Promise<void>>('the held rows of the conversation');
74
+
75
+ /**
76
+ * Have {@link flushHeld} write, with `flush`, the rows that the conversation
77
+ * of the attempt's turn holds back (`Conversation.hold`): `answerOnce` does.
78
+ */
79
+ export const holding = (ctx: restate.SessionContext, flush: () => Promise<void>) => HELD.set(ctx, flush);
80
+
81
+ /**
82
+ * Write the rows that the conversation of the attempt's turn holds back, if
83
+ * any (see `Conversation.hold`). Call it before what another party sees, or
84
+ * what outlives the attempt: a publish, a Restate call, send or wait. A held
85
+ * row is lost in a crash, and the retried attempt makes it again; what was
86
+ * seen or called must not depend on it.
87
+ */
88
+ export async function flushHeld(ctx: restate.SessionContext) {
89
+ await HELD.get(ctx)?.();
90
+ }
91
+
92
+ /**
93
+ * Store `calls`, committed before the call they record is made. The rows the
94
+ * conversation holds back are written first: the call outlives the attempt,
95
+ * and what led to it must too.
96
+ */
97
+ async function store(ctx: restate.SessionContext, { invocation, calls }: Calls) {
98
+ await flushHeld(ctx);
71
99
  await ctx.db.execute('INSERT OR REPLACE INTO restate_agent_calls (row, invocation, calls) VALUES (0, ?, ?)', [
72
100
  invocation,
73
101
  JSON.stringify(calls),
@@ -85,12 +113,25 @@ async function load(ctx: CallsContext, invocation: string): Promise<Calls> {
85
113
  : { invocation, calls: [] };
86
114
  }
87
115
 
88
- /** Each attempt's id, and its calls, by its context. */
89
- const ATTEMPT = new ScopeKey<{ id: string; calls: Promise<Calls> }>('the calls of an attempt');
116
+ /** Each attempt's id, and its calls, by its context, once they are being read. */
117
+ const ATTEMPT = new ScopeKey<{ id: string; calls?: Promise<Calls> }>('the calls of an attempt');
90
118
 
91
- /** The attempt of `ctx`: its id, and the calls of its invocation (loaded once, shared by calls made at once). */
92
- function attemptOf(ctx: restate.SessionContext) {
93
- return ATTEMPT.of(ctx, () => ({ id: randomUUID(), calls: load(ctx, ctx.request.id) }));
119
+ /**
120
+ * The attempt of `ctx`: its id, and the calls of its invocation (loaded once,
121
+ * shared by calls made at once). A load that fails (its schema's commit
122
+ * cancelled, say) is not kept: the next asks again, so that a stopped turn's
123
+ * close reads the calls as stored, rather than fail on the load it found.
124
+ */
125
+ function attemptOf(ctx: restate.SessionContext): { id: string; calls: Promise<Calls> } {
126
+ const attempt = ATTEMPT.of(ctx, () => ({ id: randomUUID() }));
127
+ if (attempt.calls === undefined) {
128
+ const calls = load(ctx, ctx.request.id);
129
+ attempt.calls = calls;
130
+ calls.catch(() => {
131
+ if (attempt.calls === calls) attempt.calls = undefined;
132
+ });
133
+ }
134
+ return attempt as { id: string; calls: Promise<Calls> };
94
135
  }
95
136
 
96
137
  /** `value` as JSON with its objects' keys sorted: the same input, however its keys came, is the same call. */
@@ -178,7 +219,7 @@ export async function callOf(
178
219
  * Forget the calls that answered whose result the framework stored: those
179
220
  * of which `stored(id, failed)` is true for the last id they were made with,
180
221
  * `failed` the error that answered the call, if one did. Called
181
- * at each publish, and before each tool call, with the transcript as the
222
+ * after each commit of steps, and before each tool call, with the transcript as the
182
223
  * framework stored it: also in an attempt that made no call yet, which would
183
224
  * otherwise take one an earlier attempt made, and the model has the result
184
225
  * of.
@@ -68,8 +68,10 @@ stored.
68
68
 
69
69
  - **Each reply is stored before its tools run, and their results before the
70
70
  next request.** So a crash during the tools resumes them with the same tool
71
- call ids, without asking the model again; and a stored final reply is the
72
- answer, without asking the model for it again.
71
+ call ids, without asking the model again. The final reply, which no tool
72
+ waits for, is stored with the turn's answer, in one commit: a crash before
73
+ it asks the model again. A paused reply (`pause_turn`, a server tool's long
74
+ turn) is stored before the model goes on from it.
73
75
  - **A tool is idempotent by its tool call id** (`callId` of `tool()`'s
74
76
  `run`, or `callId(context)` for the SDK's tools), which it passes on, such
75
77
  as in an idempotency key.
@@ -46,10 +46,9 @@ import {
46
46
  modelIdOf,
47
47
  modelOf,
48
48
  RETURNED_UNRECORDED,
49
+ toolCallStarted,
49
50
  stopSignalOf,
50
51
  type Summarize,
51
- toolCallEnded,
52
- toolCallStarted,
53
52
  NO_ANSWER,
54
53
  } from '../common.ts';
55
54
  import { answerOnce, type Items, type Parsed, type Run } from '../conversation.ts';
@@ -192,9 +191,9 @@ interface Agent {
192
191
 
193
192
  /**
194
193
  * The run of `agent` on the conversation: from the stored turn on, each
195
- * reply stored before its tools run, and their results after; each round of
196
- * tool calls published as it starts and ends (for the clients that follow
197
- * the conversation). At each step (before a request that follows the
194
+ * reply with tool calls stored before its tools run, and their results
195
+ * after; each such write published as it commits, by the conversation (for
196
+ * the clients that follow it), and the final reply stored with the answer. At each step (before a request that follows the
198
197
  * prompt or the tools' results), it takes the messages steered to the turn
199
198
  * (`takeSteers`): the request then goes out from the conversation's
200
199
  * history, which has them after the tools' results.
@@ -219,6 +218,9 @@ const runOf =
219
218
  ...(system === undefined ? {} : { system }),
220
219
  tools,
221
220
  messages: sendable(conversation.history()),
221
+ // The conversation is the session's: each request carries all of it, as stored, and no message thread
222
+ // of the API's holds a copy that a crash or a steered message would leave behind.
223
+ thread: false,
222
224
  },
223
225
  { signal: stopSignalOf(ctx) },
224
226
  );
@@ -240,7 +242,6 @@ const runOf =
240
242
  await turn.append(results);
241
243
  runner.pushMessages(results);
242
244
  }
243
- await toolCallEnded(ctx);
244
245
  await step();
245
246
  }
246
247
  let paused = false;
@@ -252,17 +253,21 @@ const runOf =
252
253
  // Paused (a server tool's long turn): a step of the turn, not a reply to
253
254
  // end it with, and the model goes on from it.
254
255
  if (message.stop_reason === 'pause_turn') {
256
+ // Stored before the model goes on: a crash in a server tool's long turn goes on from it, rather than
257
+ // ask the whole of it again.
255
258
  await turn.append(said);
259
+ await conversation.flush();
256
260
  paused = true;
257
261
  break;
258
262
  }
263
+ // A reply with tool calls commits, and is published, before its tools run; the final reply commits with
264
+ // the turn's answer.
259
265
  await turn.appendReply([said]);
260
266
  if (!message.content.some((c) => c.type === 'tool_use')) return textOf(message.content);
261
267
  await toolCallStarted(ctx);
262
268
  const results = await runner.generateToolResponse();
263
269
  check();
264
270
  if (results) await turn.append(results);
265
- await toolCallEnded(ctx);
266
271
  await step();
267
272
  }
268
273
  if (!paused) throw new Error('the tool runner ended without a reply');
package/src/client.ts CHANGED
@@ -16,7 +16,7 @@ import * as clients from '@restatedev/restate-sdk-clients';
16
16
  import type { VirtualObjectDefinition } from '@restatedev/restate-sdk-core';
17
17
  import type { Answering, ChatMessage, Messages, MessagesRequest, Part } from './common.ts';
18
18
  import type { Status, Stopped, Synced, SyncRequest } from './object.ts';
19
- import type { Notifications, Resolved, Signal, Steered, Steering, Waiting, Watch } from './signals.ts';
19
+ import type { Notifications, Resolved, Signal, Steered, Steering, Waiting, Watch } from './companion.ts';
20
20
 
21
21
  export type {
22
22
  Answering,