@restatedev/agents 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +89 -49
  2. package/dist/calls.d.ts +29 -8
  3. package/dist/calls.d.ts.map +1 -1
  4. package/dist/calls.js +79 -18
  5. package/dist/calls.js.map +1 -1
  6. package/dist/claude/index.d.ts +36 -7
  7. package/dist/claude/index.d.ts.map +1 -1
  8. package/dist/claude/index.js +238 -156
  9. package/dist/claude/index.js.map +1 -1
  10. package/dist/client.d.ts +12 -3
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/client.js.map +1 -1
  13. package/dist/common.d.ts +161 -71
  14. package/dist/common.d.ts.map +1 -1
  15. package/dist/common.js +277 -226
  16. package/dist/common.js.map +1 -1
  17. package/dist/conversation.d.ts +466 -0
  18. package/dist/conversation.d.ts.map +1 -0
  19. package/dist/conversation.js +1247 -0
  20. package/dist/conversation.js.map +1 -0
  21. package/dist/deepseek/index.d.ts +38 -5
  22. package/dist/deepseek/index.d.ts.map +1 -1
  23. package/dist/deepseek/index.js +323 -107
  24. package/dist/deepseek/index.js.map +1 -1
  25. package/dist/deepseek/persistence.d.ts +9 -3
  26. package/dist/deepseek/persistence.d.ts.map +1 -1
  27. package/dist/deepseek/persistence.js +12 -6
  28. package/dist/deepseek/persistence.js.map +1 -1
  29. package/dist/index.d.ts +2 -2
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +2 -3
  32. package/dist/index.js.map +1 -1
  33. package/dist/langgraph/checkpointer.d.ts +16 -2
  34. package/dist/langgraph/checkpointer.d.ts.map +1 -1
  35. package/dist/langgraph/checkpointer.js +133 -26
  36. package/dist/langgraph/checkpointer.js.map +1 -1
  37. package/dist/langgraph/context.d.ts +10 -0
  38. package/dist/langgraph/context.d.ts.map +1 -0
  39. package/dist/langgraph/context.js +21 -0
  40. package/dist/langgraph/context.js.map +1 -0
  41. package/dist/langgraph/errors.d.ts +16 -0
  42. package/dist/langgraph/errors.d.ts.map +1 -0
  43. package/dist/langgraph/errors.js +30 -0
  44. package/dist/langgraph/errors.js.map +1 -0
  45. package/dist/langgraph/graph.d.ts +25 -0
  46. package/dist/langgraph/graph.d.ts.map +1 -0
  47. package/dist/langgraph/graph.js +346 -0
  48. package/dist/langgraph/graph.js.map +1 -0
  49. package/dist/langgraph/index.d.ts +65 -12
  50. package/dist/langgraph/index.d.ts.map +1 -1
  51. package/dist/langgraph/index.js +234 -180
  52. package/dist/langgraph/index.js.map +1 -1
  53. package/dist/langgraph/nodes.d.ts +70 -0
  54. package/dist/langgraph/nodes.d.ts.map +1 -0
  55. package/dist/langgraph/nodes.js +145 -0
  56. package/dist/langgraph/nodes.js.map +1 -0
  57. package/dist/messages.d.ts +18 -0
  58. package/dist/messages.d.ts.map +1 -0
  59. package/dist/messages.js +182 -0
  60. package/dist/messages.js.map +1 -0
  61. package/dist/object.d.ts +65 -23
  62. package/dist/object.d.ts.map +1 -1
  63. package/dist/object.js +123 -40
  64. package/dist/object.js.map +1 -1
  65. package/dist/output.d.ts +15 -7
  66. package/dist/output.d.ts.map +1 -1
  67. package/dist/output.js +44 -26
  68. package/dist/output.js.map +1 -1
  69. package/dist/pi/index.d.ts +39 -11
  70. package/dist/pi/index.d.ts.map +1 -1
  71. package/dist/pi/index.js +281 -77
  72. package/dist/pi/index.js.map +1 -1
  73. package/dist/pi/storage.d.ts +29 -4
  74. package/dist/pi/storage.d.ts.map +1 -1
  75. package/dist/pi/storage.js +18 -6
  76. package/dist/pi/storage.js.map +1 -1
  77. package/dist/signals.d.ts +75 -7
  78. package/dist/signals.d.ts.map +1 -1
  79. package/dist/signals.js +154 -27
  80. package/dist/signals.js.map +1 -1
  81. package/dist/steering.d.ts +31 -0
  82. package/dist/steering.d.ts.map +1 -0
  83. package/dist/steering.js +45 -0
  84. package/dist/steering.js.map +1 -0
  85. package/dist/tools.d.ts +28 -0
  86. package/dist/tools.d.ts.map +1 -1
  87. package/dist/tools.js +34 -5
  88. package/dist/tools.js.map +1 -1
  89. package/package.json +33 -37
  90. package/src/calls.ts +110 -24
  91. package/src/claude/README.md +41 -20
  92. package/src/claude/index.ts +271 -183
  93. package/src/client.ts +14 -3
  94. package/src/common.ts +354 -247
  95. package/src/conversation.ts +1527 -0
  96. package/src/deepseek/README.md +78 -11
  97. package/src/deepseek/index.ts +385 -138
  98. package/src/deepseek/persistence.ts +11 -8
  99. package/src/index.ts +13 -4
  100. package/src/langgraph/README.md +115 -25
  101. package/src/langgraph/checkpointer.ts +168 -28
  102. package/src/langgraph/context.ts +27 -0
  103. package/src/langgraph/errors.ts +26 -0
  104. package/src/langgraph/graph.ts +396 -0
  105. package/src/langgraph/index.ts +337 -193
  106. package/src/langgraph/nodes.ts +243 -0
  107. package/src/messages.ts +244 -0
  108. package/src/object.ts +178 -48
  109. package/src/output.ts +52 -31
  110. package/src/pi/README.md +18 -3
  111. package/src/pi/index.ts +346 -79
  112. package/src/pi/storage.ts +20 -7
  113. package/src/signals.ts +235 -31
  114. package/src/steering.ts +67 -0
  115. package/src/tools.ts +61 -8
  116. package/dist/claude/conversation.d.ts +0 -33
  117. package/dist/claude/conversation.d.ts.map +0 -1
  118. package/dist/claude/conversation.js +0 -95
  119. package/dist/claude/conversation.js.map +0 -1
  120. package/dist/log.d.ts +0 -29
  121. package/dist/log.d.ts.map +0 -1
  122. package/dist/log.js +0 -145
  123. package/dist/log.js.map +0 -1
  124. package/dist/opencode/db.d.ts +0 -40
  125. package/dist/opencode/db.d.ts.map +0 -1
  126. package/dist/opencode/db.js +0 -161
  127. package/dist/opencode/db.js.map +0 -1
  128. package/dist/opencode/index.d.ts +0 -100
  129. package/dist/opencode/index.d.ts.map +0 -1
  130. package/dist/opencode/index.js +0 -436
  131. package/dist/opencode/index.js.map +0 -1
  132. package/src/claude/conversation.ts +0 -114
  133. package/src/log.ts +0 -193
  134. package/src/opencode/README.md +0 -125
  135. package/src/opencode/db.ts +0 -223
  136. package/src/opencode/index.ts +0 -559
package/dist/tools.js CHANGED
@@ -73,9 +73,9 @@ export const tool = (options) => ({
73
73
  * the tool call runs (see calls.ts): it gets the id of the call, which an
74
74
  * earlier attempt may have made, and so its idempotency key.
75
75
  */
76
- async function once(name, input, context, body) {
76
+ async function once(name, input, context, body, options) {
77
77
  const { ctx } = context;
78
- const call = await callOf(ctx, name, input, context.callId);
78
+ const call = await callOf(ctx, name, input, context.callId, options);
79
79
  try {
80
80
  const result = await body({ ctx, callId: call.id, idempotencyKey: `${ctx.request.id}:${call.id}` });
81
81
  await call.answered();
@@ -204,8 +204,37 @@ export const signal = (name, options) => tool({
204
204
  name: options.name ?? `wait_for_${name}`,
205
205
  description: options.description,
206
206
  input: z.object(options.input?.shape ?? {}),
207
- run: async (input, context) => once(`signal/${name}`, input, context, async ({ ctx, idempotencyKey: id }) => ctx
208
- .rpc(signals, signalsOf(ctx), { idempotencyKey: id })
209
- .wait({ id, name, ...(options.input ? { input } : {}) })),
207
+ run: async (input, context) => wait(context, name, input, { shown: options.input !== undefined }),
210
208
  });
209
+ /**
210
+ * Wait for signal `name` as tool call `toolCall`, once however often it runs;
211
+ * `pending` shows `input` if `shown`. `rejoin` and `approval` are
212
+ * {@link callOf}'s.
213
+ */
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 });
215
+ /**
216
+ * Wait for the signal `name` to the agent, for the model's tool call
217
+ * `callId`, and answer with its value: what a {@link signal} tool does, for
218
+ * a framework whose own tool calls wait for something outside (an approval,
219
+ * say). The wait's id is `<invocation id>:<call id>`; `pending` lists it
220
+ * (with `input`, if given), and `signal` resolves it. It is opened once
221
+ * however often the tool call runs, and a crash goes on waiting on it.
222
+ *
223
+ * The wait is the tool call's alone: the framework stored its tool call
224
+ * before it waits, so a retried attempt waits again under the same id. A new
225
+ * call with the same input (the model asking again, after the first's
226
+ * answer) waits anew, as its answer is not the earlier call's.
227
+ *
228
+ * With `approval`, the tool call runs only after the wait: the wait's
229
+ * answer is not the call's, so a turn stopped before the call's result is
230
+ * stored reports the call as not done, rather than done.
231
+ *
232
+ * With `rejoin`, for a framework that makes a call cut off by a crash again
233
+ * under a new id (the DeepSeek Harness), the call joins the wait an earlier
234
+ * attempt opened with the same input, as Restate's own tools do: the call
235
+ * made again, waiting on (or getting the answer of) the same wait, until
236
+ * the earlier call's result is stored. Within one attempt, a call with the
237
+ * same input waits anew.
238
+ */
239
+ export const waitFor = (ctx, callId, name, input, { approval = false, rejoin = false } = {}) => wait({ ctx, callId }, name, input ?? null, { shown: input !== undefined, rejoin, approval });
211
240
  //# sourceMappingURL=tools.js.map
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,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,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;CAClG,CAAC,CAAC;AAEL;;;;GAIG;AACH,MAAM,IAAI,GAAG,CACX,QAAkB,EAClB,IAAY,EACZ,KAAc,EACd,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAA4D,EACnE,EAAE,CACpB,IAAI,CACF,UAAU,IAAI,EAAE,EAChB,KAAK,EACL,QAAQ,EACR,KAAK,EAAE,EAAE,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE,EAAE,CACpC,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC1G,EAAE,MAAM,EAAE,QAAQ,EAAE,CACrB,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,GAA2B,EAC3B,MAAc,EACd,IAAY,EACZ,KAAe,EACf,EAAE,QAAQ,GAAG,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,GAA6C,EAAE,EACjE,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,KAAK,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@restatedev/agents",
3
- "version": "0.2.0",
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",
3
+ "version": "0.4.0",
4
+ "description": "Agent frameworks in Restate virtual objects, their state in the object's SQL database: pi, LangGraph, Claude (Anthropic SDK) and DeepSeek Harness",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -35,14 +35,6 @@
35
35
  "types": "./dist/langgraph/index.d.ts",
36
36
  "default": "./dist/langgraph/index.js"
37
37
  },
38
- "./opencode": {
39
- "types": "./dist/opencode/index.d.ts",
40
- "default": "./dist/opencode/index.js"
41
- },
42
- "./opencode/db": {
43
- "types": "./dist/opencode/db.d.ts",
44
- "default": "./dist/opencode/db.js"
45
- },
46
38
  "./pi": {
47
39
  "types": "./dist/pi/index.d.ts",
48
40
  "default": "./dist/pi/index.js"
@@ -68,6 +60,10 @@
68
60
  "@deepseek-ai/dsh-atomic-write": "0.2.1-rc.2",
69
61
  "@deepseek-ai/dsh-attachment": "0.2.1-rc.2",
70
62
  "@deepseek-ai/dsh-authorization": "0.2.1-rc.2",
63
+ "@deepseek-ai/dsh-commands": "0.2.1-rc.2",
64
+ "@deepseek-ai/dsh-compaction": "0.2.1-rc.2",
65
+ "@deepseek-ai/dsh-compaction-basic": "0.2.1-rc.2",
66
+ "@deepseek-ai/dsh-compaction-tool-result-pruner": "0.2.1-rc.2",
71
67
  "@deepseek-ai/dsh-credentials": "0.2.1-rc.2",
72
68
  "@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.1-rc.2",
73
69
  "@deepseek-ai/dsh-fs": "0.2.1-rc.2",
@@ -87,6 +83,7 @@
87
83
  "@deepseek-ai/dsh-session-projection": "0.2.1-rc.2",
88
84
  "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
89
85
  "@deepseek-ai/dsh-timeout": "0.2.1-rc.2",
86
+ "@deepseek-ai/dsh-token-meter": "0.2.1-rc.2",
90
87
  "@deepseek-ai/dsh-tools": "0.2.1-rc.2",
91
88
  "@deepseek-ai/dsh-user-approval": "0.2.1-rc.2",
92
89
  "@earendil-works/chord": "1.4.0",
@@ -98,13 +95,8 @@
98
95
  "@langchain/langgraph-checkpoint": "1.1.5",
99
96
  "@langchain/langgraph-checkpoint-validation": "1.1.1",
100
97
  "@langchain/openai": "1.7.0",
101
- "@opencode/core": "2.0.32",
102
- "@opencode/plugin": "2.0.32",
103
- "@opencode/sdk": "2.0.32",
104
- "@opencode/server": "2.0.32",
105
98
  "@restatedev/restate-sdk": "1.18.2",
106
- "@restatedev/sessions": "0.2.0",
107
- "effect": "4.0.1",
99
+ "@restatedev/sessions": "0.4.0",
108
100
  "zod": "4.6.5"
109
101
  },
110
102
  "peerDependencies": {
@@ -112,6 +104,10 @@
112
104
  "@deepseek-ai/cordis": "~4.0.5",
113
105
  "@deepseek-ai/dsh-agent": "0.2.1-rc.2",
114
106
  "@deepseek-ai/dsh-agent-loop": "0.2.1-rc.2",
107
+ "@deepseek-ai/dsh-commands": "0.2.1-rc.2",
108
+ "@deepseek-ai/dsh-compaction": "0.2.1-rc.2",
109
+ "@deepseek-ai/dsh-compaction-basic": "0.2.1-rc.2",
110
+ "@deepseek-ai/dsh-compaction-tool-result-pruner": "0.2.1-rc.2",
115
111
  "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
116
112
  "@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.1-rc.2",
117
113
  "@deepseek-ai/dsh-llm-pi-ai": "0.2.1-rc.2",
@@ -120,7 +116,9 @@
120
116
  "@deepseek-ai/dsh-session-persistence": "0.2.1-rc.2",
121
117
  "@deepseek-ai/dsh-session-projection": "0.2.1-rc.2",
122
118
  "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
119
+ "@deepseek-ai/dsh-token-meter": "0.2.1-rc.2",
123
120
  "@deepseek-ai/dsh-tools": "0.2.1-rc.2",
121
+ "@deepseek-ai/dsh-user-approval": "0.2.1-rc.2",
124
122
  "@earendil-works/chord": "^1.4.0",
125
123
  "@earendil-works/pi-ai": "^1.4.0",
126
124
  "@earendil-works/pi-durable": "^1.4.0",
@@ -129,12 +127,7 @@
129
127
  "@langchain/langgraph": "^1.4.18",
130
128
  "@langchain/langgraph-checkpoint": "^1.1.5",
131
129
  "@langchain/openai": "^1.7.0",
132
- "@opencode/core": "2.0.32",
133
- "@opencode/plugin": "2.0.32",
134
- "@opencode/sdk": "2.0.32",
135
- "@opencode/server": "2.0.32",
136
- "@restatedev/sessions": "^0.2.0",
137
- "effect": "4.0.1",
130
+ "@restatedev/sessions": "^0.4.0",
138
131
  "zod": "^4.6.5"
139
132
  },
140
133
  "peerDependenciesMeta": {
@@ -150,6 +143,18 @@
150
143
  "@deepseek-ai/dsh-agent-loop": {
151
144
  "optional": true
152
145
  },
146
+ "@deepseek-ai/dsh-commands": {
147
+ "optional": true
148
+ },
149
+ "@deepseek-ai/dsh-compaction": {
150
+ "optional": true
151
+ },
152
+ "@deepseek-ai/dsh-compaction-basic": {
153
+ "optional": true
154
+ },
155
+ "@deepseek-ai/dsh-compaction-tool-result-pruner": {
156
+ "optional": true
157
+ },
153
158
  "@deepseek-ai/dsh-llm": {
154
159
  "optional": true
155
160
  },
@@ -174,9 +179,15 @@
174
179
  "@deepseek-ai/dsh-system-prompt": {
175
180
  "optional": true
176
181
  },
182
+ "@deepseek-ai/dsh-token-meter": {
183
+ "optional": true
184
+ },
177
185
  "@deepseek-ai/dsh-tools": {
178
186
  "optional": true
179
187
  },
188
+ "@deepseek-ai/dsh-user-approval": {
189
+ "optional": true
190
+ },
180
191
  "@earendil-works/chord": {
181
192
  "optional": true
182
193
  },
@@ -200,21 +211,6 @@
200
211
  },
201
212
  "@langchain/openai": {
202
213
  "optional": true
203
- },
204
- "@opencode/core": {
205
- "optional": true
206
- },
207
- "@opencode/plugin": {
208
- "optional": true
209
- },
210
- "@opencode/sdk": {
211
- "optional": true
212
- },
213
- "@opencode/server": {
214
- "optional": true
215
- },
216
- "effect": {
217
- "optional": true
218
214
  }
219
215
  },
220
216
  "engines": {
package/src/calls.ts CHANGED
@@ -3,23 +3,30 @@
3
3
  // a call is made once, however often its tool call runs.
4
4
  //
5
5
  // A crash or a suspension restarts the handler. pi, Claude and LangGraph then
6
- // run a tool call that was cut off again, with its id. OpenCode and the
7
- // DeepSeek Harness tell the model it was interrupted instead, and the model
6
+ // run a tool call that was cut off again, with its id. The DeepSeek Harness
7
+ // tells the model it was interrupted instead, and the model
8
8
  // makes it again with a new id: made with the same tool and input, it is the
9
9
  // call an earlier attempt made, so it takes that call's id, and so the same
10
10
  // idempotency key: the same Restate call (a wait for a signal, a sub-agent's
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 settle}, at each publish, and before each
14
+ // last id it was made with ({@link settleCalls}, at each publish, 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
- // is not its result (OpenCode gives the call it interrupted one, and the
18
- // model makes it again), unless the call answered with that error: a
17
+ // is not its result (the DeepSeek Harness gives the call it interrupted
18
+ // one, and the model makes it again), unless the call answered with that error: a
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
+ //
22
+ // A framework's own wait ({@link waitFor} of tools.ts) is its tool call's
23
+ // alone: the framework stored its tool call before it waits, so a retried
24
+ // attempt waits again under the same id, and a new call with the same input
25
+ // (the model asking again, after the first's answer) waits anew. An approval
26
+ // a tool call waited for is not the call: a stopped turn does not report the
27
+ // call as done because its approval returned ({@link outcomes}).
21
28
  import type * as restate from '@restatedev/sessions';
22
- import { Schema } from '@restatedev/sessions/internal';
29
+ import { Schema, ScopeKey } from '@restatedev/sessions/internal';
23
30
  import { randomUUID } from 'node:crypto';
24
31
 
25
32
  /** 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. */
@@ -32,6 +39,13 @@ interface Call {
32
39
  done?: true;
33
40
  /** It answered with this error (`Error: <message>`), a terminal one: its result, as the transcript has it. */
34
41
  failed?: string;
42
+ /** An approval its tool call waited for ({@link waitFor}): its answer is not the tool call's. */
43
+ approval?: true;
44
+ /**
45
+ * The prompt whose turn made it (`answerOnce`'s), if any: an invocation
46
+ * that prompts more than once keeps the calls of each apart.
47
+ */
48
+ prompt?: string;
35
49
  }
36
50
 
37
51
  /** The calls an invocation's tools made that the transcript has no result of yet. */
@@ -72,37 +86,77 @@ async function load(ctx: CallsContext, invocation: string): Promise<Calls> {
72
86
  }
73
87
 
74
88
  /** Each attempt's id, and its calls, by its context. */
75
- const attempts = new WeakMap<object, { id: string; calls: Promise<Calls> }>();
89
+ const ATTEMPT = new ScopeKey<{ id: string; calls: Promise<Calls> }>('the calls of an attempt');
90
+
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) }));
94
+ }
95
+
96
+ /** `value` as JSON with its objects' keys sorted: the same input, however its keys came, is the same call. */
97
+ function canonical(value: unknown): string {
98
+ return JSON.stringify(value, (_key, v: unknown) =>
99
+ v !== null && typeof v === 'object' && !Array.isArray(v)
100
+ ? Object.fromEntries(
101
+ Object.entries(v as Record<string, unknown>).toSorted(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)),
102
+ )
103
+ : v,
104
+ );
105
+ }
106
+
107
+ /** The prompt whose turn the tools of `ctx` run for, while `answerOnce` answers it. */
108
+ const PROMPT = new ScopeKey<string>('the prompt of the calls');
76
109
 
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);
110
+ /**
111
+ * Run `work` (a turn's) with the calls its tools make kept as prompt
112
+ * `prompt`'s: they are matched, and rejoined, within it only. An invocation
113
+ * that prompts twice, its second prompt making the call its first made
114
+ * (the same tool and input), would otherwise take the first's after a crash
115
+ * (its record not yet forgotten), and never make its own.
116
+ */
117
+ export async function forPrompt<T>(ctx: restate.SessionContext, prompt: string, work: () => Promise<T>): Promise<T> {
118
+ const outer = PROMPT.get(ctx);
119
+ PROMPT.set(ctx, prompt);
120
+ try {
121
+ return await work();
122
+ } finally {
123
+ if (outer === undefined) PROMPT.delete(ctx);
124
+ else PROMPT.set(ctx, outer);
84
125
  }
85
- return attempt;
86
126
  }
87
127
 
88
128
  /**
89
129
  * The call of tool `tool` with `input` that tool call `callId` makes: the
90
- * one it made before (a run again), or the one an earlier attempt made with
91
- * the same tool and input (made again under a new id), or else a new one.
92
- * `run(id)` makes it with its own id, and stores that it answered.
130
+ * one it made to `tool` before (a run again), or else, if `rejoin`, the one
131
+ * an earlier attempt made with the same tool and input (made again under a
132
+ * new id), or else a new one, an `approval` its tool call waits for if so.
133
+ * `answered()` stores that it answered.
93
134
  */
94
- export async function callOf(ctx: CallsContext, tool: string, input: unknown, callId: string) {
135
+ export async function callOf(
136
+ ctx: restate.SessionContext,
137
+ tool: string,
138
+ input: unknown,
139
+ callId: string,
140
+ { rejoin = true, approval = false }: { rejoin?: boolean; approval?: boolean } = {},
141
+ ) {
95
142
  const attempt = attemptOf(ctx);
96
143
  const state = await attempt.calls;
97
- const json = JSON.stringify(input);
144
+ const json = canonical(input);
145
+ const prompt = PROMPT.get(ctx);
146
+ const ours = state.calls.filter((c) => c.prompt === prompt);
147
+ // A tool call may make more than one call (an approval, then the tool's
148
+ // own), each to a tool of its own.
98
149
  let call =
99
- state.calls.find((c) => c.ids.includes(callId)) ??
100
- state.calls.find((c) => c.attempt !== attempt.id && c.tool === tool && c.input === json);
150
+ ours.find((c) => c.ids.includes(callId) && c.tool === tool) ??
151
+ (rejoin ? ours.find((c) => c.attempt !== attempt.id && c.tool === tool && c.input === json) : undefined);
101
152
  if (call) {
102
153
  call.attempt = attempt.id;
103
154
  if (!call.ids.includes(callId)) call.ids.push(callId);
104
155
  } else {
105
- state.calls.push((call = { tool, input: json, ids: [callId], attempt: attempt.id }));
156
+ call = { tool, input: json, ids: [callId], attempt: attempt.id };
157
+ if (approval) call.approval = true;
158
+ if (prompt !== undefined) call.prompt = prompt;
159
+ state.calls.push(call);
106
160
  }
107
161
  await store(ctx, state);
108
162
  const made = call;
@@ -129,10 +183,42 @@ export async function callOf(ctx: CallsContext, tool: string, input: unknown, ca
129
183
  * otherwise take one an earlier attempt made, and the model has the result
130
184
  * of.
131
185
  */
132
- export async function settle(ctx: CallsContext, stored: (id: string, failed?: string) => boolean) {
186
+ export async function settleCalls(ctx: restate.SessionContext, stored: (id: string, failed?: string) => boolean) {
133
187
  const state = await attemptOf(ctx).calls;
134
188
  const kept = state.calls.filter((c) => !c.done || !stored(c.ids.at(-1)!, c.failed));
135
189
  if (kept.length === state.calls.length) return;
136
190
  state.calls = kept;
137
191
  await store(ctx, state);
138
192
  }
193
+
194
+ /**
195
+ * Which of `callIds` made a Restate call that answered, in this invocation
196
+ * or in `invocation`: each with the terminal error it answered with
197
+ * (`Error: <message>`), or `undefined` if it succeeded. A tool call whose
198
+ * call did not answer, or that made none, is left out; so is one whose only
199
+ * answered call is its approval, which it ran (or was denied) after.
200
+ *
201
+ * An earlier `invocation`'s calls are read only while they are still
202
+ * stored, until an invocation of the key makes calls of its own; read,
203
+ * never changed. With `prompt`, the calls of its turn only.
204
+ */
205
+ export async function outcomes(
206
+ ctx: restate.SessionContext,
207
+ callIds: Iterable<string>,
208
+ invocation?: string,
209
+ prompt?: string,
210
+ ): Promise<Map<string, string | undefined>> {
211
+ const state =
212
+ invocation !== undefined && invocation !== ctx.request.id
213
+ ? await load(ctx, invocation)
214
+ : await attemptOf(ctx).calls;
215
+ const wanted = new Set(callIds);
216
+ const found = new Map<string, string | undefined>();
217
+ for (const call of state.calls) {
218
+ if (!call.done || call.approval) continue;
219
+ // Another prompt's call, of the same invocation: not this turn's.
220
+ if (prompt !== undefined && call.prompt !== undefined && call.prompt !== prompt) continue;
221
+ for (const id of call.ids) if (wanted.has(id)) found.set(id, call.failed);
222
+ }
223
+ return found;
224
+ }
@@ -4,7 +4,8 @@ The Anthropic SDK's tool runner (`client.beta.messages.toolRunner` in
4
4
  [`@anthropic-ai/sdk`](https://github.com/anthropics/anthropic-sdk-typescript))
5
5
  is a light agent harness: the tool-calling loop, in the process, with nothing
6
6
  stored. It keeps the conversation in its params, so an agent built on it is
7
- durable when the conversation is: here it is in the agent's SQL database
7
+ durable when the conversation is: here it is the agent's conversation of
8
+ turns, in its SQL database
8
9
  ([SQL in Restate virtual objects](../../../sessions/README.md)).
9
10
 
10
11
  It is lighter than the Claude Agent SDK, which runs Claude Code as a
@@ -24,15 +25,30 @@ const assistant = claude.agent({ name: 'assistant', system: 'Answer briefly.', t
24
25
  await serve(assistant);
25
26
  ```
26
27
 
27
- | Option | What |
28
- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29
- | `model` | `anthropic/model-id`; or else `MODEL`, or else `anthropic/claude-sonnet-5-5` (`ANTHROPIC_API_KEY`) |
30
- | `system` | The system prompt |
31
- | `tools` | `tool()`s and Restate's tools of `@restatedev/agents`, or the SDK's runnable tools (such as `betaZodTool`) |
32
- | `output` | A zod object: the answer as data, which the agent replies with as JSON, and `chat` answers with (see [Structured answers](../../README.md#structured-answers)) |
33
- | `client` | The Anthropic client (a base URL or a proxy of your own, say); by default one with `ANTHROPIC_API_KEY` |
34
- | `maxTokens` | The most tokens of each of the model's replies (default 16000): a reply cut off there fails its message (a terminal error) |
35
- | `effort` | How much effort the model puts into each reply: `low`, `medium`, `high`, `xhigh` or `max` (default: the model's) |
28
+ | Option | What |
29
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
30
+ | `model` | `anthropic/model-id`; or else `MODEL`, or else `anthropic/claude-sonnet-5-5` (`ANTHROPIC_API_KEY`) |
31
+ | `system` | The system prompt |
32
+ | `tools` | `tool()`s and Restate's tools of `@restatedev/agents`, or the SDK's runnable tools (such as `betaZodTool`) |
33
+ | `output` | A zod object: the answer as data, which the agent replies with as JSON, and `chat` answers with (see [Structured answers](../../README.md#structured-answers)): asked for natively where the model has structured outputs |
34
+ | `nativeOutput` | Whether `output` is asked for with the API's structured outputs (`output_config.format`) rather than in the prompt (default: if the model has them, as Claude's 4.5 models and later do) |
35
+ | `client` | The Anthropic client (a base URL or a proxy of your own, say); by default one with `ANTHROPIC_API_KEY` |
36
+ | `maxTokens` | The most tokens of each of the model's replies (default 16000): a reply cut off there fails its message (a terminal error) |
37
+ | `effort` | How much effort the model puts into each reply: `low`, `medium`, `high`, `xhigh` or `max` (default: the model's) |
38
+
39
+ With `output`, a model with structured outputs is asked for the answer
40
+ natively: each request of the run has the JSON schema of `output` as its
41
+ `output_config.format` (the SDK's `betaZodOutputFormat`), which holds the
42
+ model's final reply to it, while its tool calls go on as before. Neither
43
+ the system prompt nor the prompt asks for it. The reply is checked all the
44
+ same, against what the API does not hold it to (a string's `max`, an
45
+ `enum`: the SDK moves them into the schema's descriptions), and a reply
46
+ that does not fit is asked again once, as when asked in the prompt. A
47
+ declined reply, or one cut off at `maxTokens`, ends the turn, as without
48
+ `output`. A schema the API refuses (one too complex for it, say) refuses
49
+ the message: `nativeOutput: false` asks in the prompt, as for a model
50
+ without structured outputs (Claude 3, Opus 4 and 4.1, Sonnet 4) or a model
51
+ id the agent does not know.
36
52
 
37
53
  For a session object of your own, `claude.chat(options)` is the handler and
38
54
  `claude.messages()` the view; `options` may be a function of the
@@ -42,23 +58,28 @@ often the handler runs; each prompt of an invocation is a prompt of its own.
42
58
 
43
59
  ## Through crashes
44
60
 
45
- The conversation ([`conversation.ts`](conversation.ts)) is the messages in
46
- the object's database, in order, each with the invocation it belongs to, and
47
- the answer to each. The handler is not replayed: a retried attempt runs it
48
- again from the start, with the stored messages.
61
+ The conversation is the object's conversation of turns
62
+ ([docs/conversation.md](../../docs/conversation.md)), whose items are the
63
+ SDK's messages. The runner starts from what the model sees of it: the
64
+ earlier turns as their prompt and answer (as many as `budget` holds, the
65
+ earliest summarized), the latest `window` turns whole. The handler is not
66
+ replayed: a retried attempt runs it again from the start, from what is
67
+ stored.
49
68
 
50
69
  - **Each reply is stored before its tools run, and their results before the
51
70
  next request.** So a crash during the tools resumes them with the same tool
52
- call ids, without asking the model again.
71
+ call ids, without asking the model again; and a stored final reply is the
72
+ answer, without asking the model for it again.
53
73
  - **A tool is idempotent by its tool call id** (`callId` of `tool()`'s
54
74
  `run`, or `callId(context)` for the SDK's tools), which it passes on, such
55
75
  as in an idempotency key.
56
76
  - **A tool's error fails the attempt**, and Restate retries it; a
57
- `restate.TerminalError` of a `@restatedev/agents` tool is its answer to the
58
- model.
59
- - **A message is answered once per invocation**: its answer is stored with
60
- the model's last reply, and a retried attempt returns it. A message that a
61
- crash interrupted is finished before the next one starts.
77
+ `restate.TerminalError` of a `@restatedev/agents` tool, and the SDK's
78
+ `ToolError`, are its answer to the model.
79
+ - **A message is answered once per invocation** (`answerOnce`). A turn that
80
+ a killed invocation left is closed (`ended`), never finished: by the next
81
+ message, or by the agent's `settle` once its companion finds the
82
+ invocation gone.
62
83
 
63
84
  ## Run
64
85