@restatedev/agents 0.6.0 → 0.8.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 +41 -14
- package/dist/agentlib/agent.d.ts +32 -0
- package/dist/agentlib/agent.d.ts.map +1 -0
- package/dist/agentlib/agent.js +172 -0
- package/dist/agentlib/agent.js.map +1 -0
- package/dist/agentlib/index.d.ts +5 -0
- package/dist/agentlib/index.d.ts.map +1 -0
- package/dist/agentlib/index.js +15 -0
- package/dist/agentlib/index.js.map +1 -0
- package/dist/agentlib/messages.d.ts +39 -0
- package/dist/agentlib/messages.d.ts.map +1 -0
- package/dist/agentlib/messages.js +177 -0
- package/dist/agentlib/messages.js.map +1 -0
- package/dist/agentlib/model.d.ts +29 -0
- package/dist/agentlib/model.d.ts.map +1 -0
- package/dist/agentlib/model.js +131 -0
- package/dist/agentlib/model.js.map +1 -0
- package/dist/agentlib/options.d.ts +58 -0
- package/dist/agentlib/options.d.ts.map +1 -0
- package/dist/agentlib/options.js +2 -0
- package/dist/agentlib/options.js.map +1 -0
- package/dist/agentlib/runtime.d.ts +37 -0
- package/dist/agentlib/runtime.d.ts.map +1 -0
- package/dist/agentlib/runtime.js +216 -0
- package/dist/agentlib/runtime.js.map +1 -0
- package/dist/agentlib/state.d.ts +114 -0
- package/dist/agentlib/state.d.ts.map +1 -0
- package/dist/agentlib/state.js +52 -0
- package/dist/agentlib/state.js.map +1 -0
- package/dist/agentlib/steering.d.ts +23 -0
- package/dist/agentlib/steering.d.ts.map +1 -0
- package/dist/agentlib/steering.js +48 -0
- package/dist/agentlib/steering.js.map +1 -0
- package/dist/agentlib/tools.d.ts +33 -0
- package/dist/agentlib/tools.d.ts.map +1 -0
- package/dist/agentlib/tools.js +243 -0
- package/dist/agentlib/tools.js.map +1 -0
- package/dist/agentlib/turn.d.ts +82 -0
- package/dist/agentlib/turn.d.ts.map +1 -0
- package/dist/agentlib/turn.js +253 -0
- package/dist/agentlib/turn.js.map +1 -0
- package/dist/claude/index.d.ts.map +1 -1
- package/dist/claude/index.js +3 -0
- package/dist/claude/index.js.map +1 -1
- package/dist/common.d.ts +8 -0
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +12 -0
- package/dist/common.js.map +1 -1
- package/dist/companion.d.ts +2 -1
- package/dist/companion.d.ts.map +1 -1
- package/dist/companion.js.map +1 -1
- package/dist/deepseek/index.d.ts +2 -6
- package/dist/deepseek/index.d.ts.map +1 -1
- package/dist/deepseek/index.js +6 -14
- package/dist/deepseek/index.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/langgraph/checkpointer.d.ts +1 -1
- package/dist/langgraph/checkpointer.d.ts.map +1 -1
- package/dist/langgraph/checkpointer.js +14 -5
- package/dist/langgraph/checkpointer.js.map +1 -1
- package/dist/opencode/index.d.ts.map +1 -1
- package/dist/opencode/index.js +11 -18
- package/dist/opencode/index.js.map +1 -1
- package/dist/pi/index.d.ts +2 -2
- package/dist/pi/index.d.ts.map +1 -1
- package/dist/pi/index.js +2 -3
- 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/tools.d.ts +53 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +32 -15
- package/dist/tools.js.map +1 -1
- package/package.json +115 -85
- package/src/agentlib/README.md +229 -0
- package/src/agentlib/agent.ts +214 -0
- package/src/agentlib/index.ts +16 -0
- package/src/agentlib/messages.ts +207 -0
- package/src/agentlib/model.ts +150 -0
- package/src/agentlib/options.ts +62 -0
- package/src/agentlib/runtime.ts +252 -0
- package/src/agentlib/state.ts +93 -0
- package/src/agentlib/steering.ts +53 -0
- package/src/agentlib/tools.ts +353 -0
- package/src/agentlib/turn.ts +302 -0
- package/src/claude/index.ts +3 -0
- package/src/common.ts +15 -0
- package/src/companion.ts +2 -1
- package/src/deepseek/index.ts +8 -18
- package/src/index.ts +6 -4
- package/src/langgraph/checkpointer.ts +25 -14
- package/src/opencode/index.ts +12 -17
- package/src/pi/index.ts +9 -4
- package/src/pi/storage.ts +13 -0
- package/src/tools.ts +118 -52
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,yEAAyE;AACzE,2EAA2E;AAC3E,qEAAqE;AACrE,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAC9D,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,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE5D,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,KAA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,EAA4D,EACnE,EAAE;IACpB,mGAAmG;IACnG,MAAM,SAAS,GAAG,aAAa,CAAC,QAAQ,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC;IACrE,OAAO,IAAI,CACT,UAAU,IAAI,EAAE,EAChB,KAAK,EACL,QAAQ,EACR,KAAK,EAAE,EAAE,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE,EAAE,CACpC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,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,EACrG,EAAE,MAAM,EAAE,QAAQ,EAAE,CACrB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;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.
|
|
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.8.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; and agentlib, journaled",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"default": "./dist/index.js"
|
|
21
21
|
},
|
|
22
|
+
"./agentlib": {
|
|
23
|
+
"types": "./dist/agentlib/index.d.ts",
|
|
24
|
+
"default": "./dist/agentlib/index.js"
|
|
25
|
+
},
|
|
22
26
|
"./claude": {
|
|
23
27
|
"types": "./dist/claude/index.d.ts",
|
|
24
28
|
"default": "./dist/claude/index.js"
|
|
@@ -58,97 +62,114 @@
|
|
|
58
62
|
"@standard-schema/spec": "1.1.0"
|
|
59
63
|
},
|
|
60
64
|
"devDependencies": {
|
|
65
|
+
"@ai-sdk/anthropic": "4.0.14",
|
|
66
|
+
"@ai-sdk/openai": "4.0.13",
|
|
61
67
|
"@ai-sdk/provider": "3.0.8",
|
|
62
|
-
"@anthropic-ai/sdk": "
|
|
63
|
-
"@deepseek-ai/cordis": "4.0
|
|
64
|
-
"@deepseek-ai/cordis-plugin-loader": "1.0
|
|
65
|
-
"@deepseek-ai/dsh-agent": "0.2.
|
|
66
|
-
"@deepseek-ai/dsh-agent-loop": "0.2.
|
|
67
|
-
"@deepseek-ai/dsh-anonymous-user-id": "0.2.
|
|
68
|
-
"@deepseek-ai/dsh-atomic-write": "0.2.
|
|
69
|
-
"@deepseek-ai/dsh-attachment": "0.2.
|
|
70
|
-
"@deepseek-ai/dsh-authorization": "0.2.
|
|
71
|
-
"@deepseek-ai/dsh-commands": "0.2.
|
|
72
|
-
"@deepseek-ai/dsh-compaction": "0.2.
|
|
73
|
-
"@deepseek-ai/dsh-compaction-basic": "0.2.
|
|
74
|
-
"@deepseek-ai/dsh-compaction-tool-result-pruner": "0.2.
|
|
75
|
-
"@deepseek-ai/dsh-credentials": "0.2.
|
|
76
|
-
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.
|
|
77
|
-
"@deepseek-ai/dsh-fs": "0.2.
|
|
78
|
-
"@deepseek-ai/dsh-home-paths": "0.2.
|
|
79
|
-
"@deepseek-ai/dsh-launch-environment": "0.2.
|
|
80
|
-
"@deepseek-ai/dsh-llm": "0.2.
|
|
81
|
-
"@deepseek-ai/dsh-llm-deepseek": "0.2.
|
|
82
|
-
"@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.
|
|
83
|
-
"@deepseek-ai/dsh-llm-pi-ai": "0.2.
|
|
84
|
-
"@deepseek-ai/dsh-ptc-runtime": "0.2.
|
|
85
|
-
"@deepseek-ai/dsh-sandbox": "0.2.
|
|
86
|
-
"@deepseek-ai/dsh-sandbox-policy": "0.2.
|
|
87
|
-
"@deepseek-ai/dsh-scope": "0.2.
|
|
88
|
-
"@deepseek-ai/dsh-session": "0.2.
|
|
89
|
-
"@deepseek-ai/dsh-session-checkpoint-policy": "0.2.
|
|
90
|
-
"@deepseek-ai/dsh-session-persistence": "0.2.
|
|
91
|
-
"@deepseek-ai/dsh-session-projection": "0.2.
|
|
92
|
-
"@deepseek-ai/dsh-system-prompt": "0.2.
|
|
93
|
-
"@deepseek-ai/dsh-timeout": "0.2.
|
|
94
|
-
"@deepseek-ai/dsh-token-meter": "0.2.
|
|
95
|
-
"@deepseek-ai/dsh-
|
|
96
|
-
"@deepseek-ai/dsh-
|
|
97
|
-
"@
|
|
98
|
-
"@earendil-works/
|
|
99
|
-
"@earendil-works/pi-
|
|
100
|
-
"@
|
|
101
|
-
"@
|
|
102
|
-
"@langchain/
|
|
103
|
-
"@langchain/
|
|
104
|
-
"@langchain/langgraph
|
|
105
|
-
"@langchain/
|
|
106
|
-
"@
|
|
107
|
-
"@
|
|
108
|
-
"@opencode/
|
|
109
|
-
"@opencode/
|
|
68
|
+
"@anthropic-ai/sdk": "1.8.0",
|
|
69
|
+
"@deepseek-ai/cordis": "4.1.0",
|
|
70
|
+
"@deepseek-ai/cordis-plugin-loader": "1.1.0",
|
|
71
|
+
"@deepseek-ai/dsh-agent": "0.2.2-rc.2",
|
|
72
|
+
"@deepseek-ai/dsh-agent-loop": "0.2.2-rc.2",
|
|
73
|
+
"@deepseek-ai/dsh-anonymous-user-id": "0.2.2-rc.2",
|
|
74
|
+
"@deepseek-ai/dsh-atomic-write": "0.2.2-rc.2",
|
|
75
|
+
"@deepseek-ai/dsh-attachment": "0.2.2-rc.2",
|
|
76
|
+
"@deepseek-ai/dsh-authorization": "0.2.2-rc.2",
|
|
77
|
+
"@deepseek-ai/dsh-commands": "0.2.2-rc.2",
|
|
78
|
+
"@deepseek-ai/dsh-compaction": "0.2.2-rc.2",
|
|
79
|
+
"@deepseek-ai/dsh-compaction-basic": "0.2.2-rc.2",
|
|
80
|
+
"@deepseek-ai/dsh-compaction-tool-result-pruner": "0.2.2-rc.2",
|
|
81
|
+
"@deepseek-ai/dsh-credentials": "0.2.2-rc.2",
|
|
82
|
+
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.2-rc.2",
|
|
83
|
+
"@deepseek-ai/dsh-fs": "0.2.2-rc.2",
|
|
84
|
+
"@deepseek-ai/dsh-home-paths": "0.2.2-rc.2",
|
|
85
|
+
"@deepseek-ai/dsh-launch-environment": "0.2.2-rc.2",
|
|
86
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.2",
|
|
87
|
+
"@deepseek-ai/dsh-llm-deepseek": "0.2.2-rc.2",
|
|
88
|
+
"@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.2-rc.2",
|
|
89
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.2.2-rc.2",
|
|
90
|
+
"@deepseek-ai/dsh-ptc-runtime": "0.2.2-rc.2",
|
|
91
|
+
"@deepseek-ai/dsh-sandbox": "0.2.2-rc.2",
|
|
92
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.2",
|
|
93
|
+
"@deepseek-ai/dsh-scope": "0.2.2-rc.2",
|
|
94
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.2",
|
|
95
|
+
"@deepseek-ai/dsh-session-checkpoint-policy": "0.2.2-rc.2",
|
|
96
|
+
"@deepseek-ai/dsh-session-persistence": "0.2.2-rc.2",
|
|
97
|
+
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.2",
|
|
98
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.2",
|
|
99
|
+
"@deepseek-ai/dsh-timeout": "0.2.2-rc.2",
|
|
100
|
+
"@deepseek-ai/dsh-token-meter": "0.2.2-rc.2",
|
|
101
|
+
"@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.2",
|
|
102
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.2",
|
|
103
|
+
"@deepseek-ai/dsh-user-approval": "0.2.2-rc.2",
|
|
104
|
+
"@earendil-works/chord": "1.5.2",
|
|
105
|
+
"@earendil-works/pi-ai": "1.5.2",
|
|
106
|
+
"@earendil-works/pi-durable": "1.5.2",
|
|
107
|
+
"@earendil-works/pi-schema": "1.5.2",
|
|
108
|
+
"@langchain/anthropic": "1.6.4",
|
|
109
|
+
"@langchain/core": "1.4.0",
|
|
110
|
+
"@langchain/langgraph": "1.7.3",
|
|
111
|
+
"@langchain/langgraph-checkpoint": "1.2.2",
|
|
112
|
+
"@langchain/langgraph-checkpoint-validation": "1.2.0",
|
|
113
|
+
"@langchain/openai": "1.8.4",
|
|
114
|
+
"@opencode/core": "2.2.7",
|
|
115
|
+
"@opencode/plugin": "2.2.7",
|
|
116
|
+
"@opencode/sdk": "2.2.7",
|
|
117
|
+
"@opencode/server": "2.2.7",
|
|
118
|
+
"@restatedev/agentlib": "0.1.0",
|
|
110
119
|
"@restatedev/restate-sdk": "1.18.2",
|
|
111
|
-
"@restatedev/
|
|
120
|
+
"@restatedev/restate-sdk-gen": "1.18.2",
|
|
121
|
+
"@restatedev/sessions": "0.8.0",
|
|
112
122
|
"effect": "4.1.0",
|
|
113
|
-
"zod": "4.6.
|
|
123
|
+
"zod": "4.6.7"
|
|
114
124
|
},
|
|
115
125
|
"peerDependencies": {
|
|
116
|
-
"@
|
|
117
|
-
"@
|
|
118
|
-
"@
|
|
119
|
-
"@deepseek-ai/
|
|
120
|
-
"@deepseek-ai/dsh-
|
|
121
|
-
"@deepseek-ai/dsh-
|
|
122
|
-
"@deepseek-ai/dsh-
|
|
123
|
-
"@deepseek-ai/dsh-compaction
|
|
124
|
-
"@deepseek-ai/dsh-
|
|
125
|
-
"@deepseek-ai/dsh-
|
|
126
|
-
"@deepseek-ai/dsh-llm
|
|
127
|
-
"@deepseek-ai/dsh-
|
|
128
|
-
"@deepseek-ai/dsh-
|
|
129
|
-
"@deepseek-ai/dsh-session
|
|
130
|
-
"@deepseek-ai/dsh-session-
|
|
131
|
-
"@deepseek-ai/dsh-
|
|
132
|
-
"@deepseek-ai/dsh-
|
|
133
|
-
"@deepseek-ai/dsh-
|
|
134
|
-
"@deepseek-ai/dsh-
|
|
135
|
-
"@
|
|
136
|
-
"@
|
|
137
|
-
"@
|
|
138
|
-
"@
|
|
139
|
-
"@
|
|
140
|
-
"@
|
|
141
|
-
"@langchain/
|
|
142
|
-
"@langchain/
|
|
143
|
-
"@
|
|
144
|
-
"@
|
|
145
|
-
"@
|
|
146
|
-
"@opencode/
|
|
147
|
-
"@
|
|
126
|
+
"@ai-sdk/anthropic": "^4.0.14",
|
|
127
|
+
"@ai-sdk/openai": "^4.0.13",
|
|
128
|
+
"@anthropic-ai/sdk": "^1.8.0",
|
|
129
|
+
"@deepseek-ai/cordis": "~4.1.0",
|
|
130
|
+
"@deepseek-ai/dsh-agent": "0.2.2-rc.2",
|
|
131
|
+
"@deepseek-ai/dsh-agent-loop": "0.2.2-rc.2",
|
|
132
|
+
"@deepseek-ai/dsh-commands": "0.2.2-rc.2",
|
|
133
|
+
"@deepseek-ai/dsh-compaction": "0.2.2-rc.2",
|
|
134
|
+
"@deepseek-ai/dsh-compaction-basic": "0.2.2-rc.2",
|
|
135
|
+
"@deepseek-ai/dsh-compaction-tool-result-pruner": "0.2.2-rc.2",
|
|
136
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.2",
|
|
137
|
+
"@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.2-rc.2",
|
|
138
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.2.2-rc.2",
|
|
139
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.2",
|
|
140
|
+
"@deepseek-ai/dsh-session-checkpoint-policy": "0.2.2-rc.2",
|
|
141
|
+
"@deepseek-ai/dsh-session-persistence": "0.2.2-rc.2",
|
|
142
|
+
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.2",
|
|
143
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.2",
|
|
144
|
+
"@deepseek-ai/dsh-token-meter": "0.2.2-rc.2",
|
|
145
|
+
"@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.2",
|
|
146
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.2",
|
|
147
|
+
"@deepseek-ai/dsh-user-approval": "0.2.2-rc.2",
|
|
148
|
+
"@earendil-works/chord": "~1.5.2",
|
|
149
|
+
"@earendil-works/pi-ai": "~1.5.2",
|
|
150
|
+
"@earendil-works/pi-durable": "~1.5.2",
|
|
151
|
+
"@langchain/anthropic": "^1.6.4",
|
|
152
|
+
"@langchain/core": "^1.4.0",
|
|
153
|
+
"@langchain/langgraph": "^1.7.3",
|
|
154
|
+
"@langchain/langgraph-checkpoint": "^1.2.2",
|
|
155
|
+
"@langchain/openai": "^1.8.4",
|
|
156
|
+
"@opencode/core": "2.2.7",
|
|
157
|
+
"@opencode/plugin": "2.2.7",
|
|
158
|
+
"@opencode/sdk": "2.2.7",
|
|
159
|
+
"@opencode/server": "2.2.7",
|
|
160
|
+
"@restatedev/agentlib": "~0.1.0",
|
|
161
|
+
"@restatedev/restate-sdk-gen": "1.18.2",
|
|
162
|
+
"@restatedev/sessions": "^0.8.0",
|
|
148
163
|
"effect": "4.1.0",
|
|
149
|
-
"zod": "^4.6.
|
|
164
|
+
"zod": "^4.6.7"
|
|
150
165
|
},
|
|
151
166
|
"peerDependenciesMeta": {
|
|
167
|
+
"@ai-sdk/anthropic": {
|
|
168
|
+
"optional": true
|
|
169
|
+
},
|
|
170
|
+
"@ai-sdk/openai": {
|
|
171
|
+
"optional": true
|
|
172
|
+
},
|
|
152
173
|
"@anthropic-ai/sdk": {
|
|
153
174
|
"optional": true
|
|
154
175
|
},
|
|
@@ -200,6 +221,9 @@
|
|
|
200
221
|
"@deepseek-ai/dsh-token-meter": {
|
|
201
222
|
"optional": true
|
|
202
223
|
},
|
|
224
|
+
"@deepseek-ai/dsh-tool-executor-native": {
|
|
225
|
+
"optional": true
|
|
226
|
+
},
|
|
203
227
|
"@deepseek-ai/dsh-tools": {
|
|
204
228
|
"optional": true
|
|
205
229
|
},
|
|
@@ -242,6 +266,12 @@
|
|
|
242
266
|
"@opencode/server": {
|
|
243
267
|
"optional": true
|
|
244
268
|
},
|
|
269
|
+
"@restatedev/agentlib": {
|
|
270
|
+
"optional": true
|
|
271
|
+
},
|
|
272
|
+
"@restatedev/restate-sdk-gen": {
|
|
273
|
+
"optional": true
|
|
274
|
+
},
|
|
245
275
|
"effect": {
|
|
246
276
|
"optional": true
|
|
247
277
|
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# agentlib
|
|
2
|
+
|
|
3
|
+
[agentlib](https://github.com/restatedev/agentlib) (`@restatedev/agentlib`)
|
|
4
|
+
is Restate's own agent library: an agent's loop as an operation of Restate's
|
|
5
|
+
generator SDK (`@restatedev/restate-sdk-gen`), with its tools, steering,
|
|
6
|
+
interruption, approvals, guardrails, compaction and limits. Restate journals
|
|
7
|
+
each model call and tool call it makes, and replays them.
|
|
8
|
+
|
|
9
|
+
Unlike the other frameworks here, an agentlib agent runs on the classic
|
|
10
|
+
Restate SDK, not in a session object: a virtual object whose `chat` handler
|
|
11
|
+
is journaled, and replayed after a crash, so that a model call or a tool
|
|
12
|
+
call that finished is not made again. Its conversation is in the object's
|
|
13
|
+
key/value state, not in a SQL database. It has the handlers and views of
|
|
14
|
+
every agent (`chat`, `messages`, `status`, `steer`, `stop`, `clear`, `sync`,
|
|
15
|
+
`signal`, `pending`, `notifications`, `watch`) and their companion, so that
|
|
16
|
+
a client (`@restatedev/agents/client`, `follow`) follows it as it follows
|
|
17
|
+
any other.
|
|
18
|
+
|
|
19
|
+
## Use
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { serve, tool } from '@restatedev/agents';
|
|
23
|
+
import * as agentlib from '@restatedev/agents/agentlib';
|
|
24
|
+
import { z } from 'zod';
|
|
25
|
+
|
|
26
|
+
const weather = tool({
|
|
27
|
+
name: 'get_weather',
|
|
28
|
+
description: 'The current weather in a city.',
|
|
29
|
+
input: z.object({ city: z.string() }),
|
|
30
|
+
run: ({ city }) => `Sunny and 21°C in ${city}`,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const assistant = agentlib.agent({
|
|
34
|
+
name: 'assistant',
|
|
35
|
+
system: 'Answer briefly.',
|
|
36
|
+
tools: [weather],
|
|
37
|
+
});
|
|
38
|
+
await serve(assistant);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The same `weather` works in an agent of any framework here; agentlib's own
|
|
42
|
+
tools work too, beside it.
|
|
43
|
+
|
|
44
|
+
See [`examples/basic/agentlib.ts`](../../../examples/basic/agentlib.ts),
|
|
45
|
+
with a transfer that waits for an approval.
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npm install @restatedev/agents @restatedev/agentlib@0.1.0 @restatedev/restate-sdk-gen@1.18.2 \
|
|
49
|
+
@restatedev/restate-sdk@1.18.2 @ai-sdk/openai # or @ai-sdk/anthropic
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
| Option | What |
|
|
53
|
+
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
54
|
+
| `model` | `openai/model-id` or `anthropic/model-id` (with `@ai-sdk/openai` or `@ai-sdk/anthropic`), or else `MODEL`, or else `openai/gpt-6-sol`; or a model of agentlib (`aiModel` of `@restatedev/agentlib/provider` for any provider of the AI SDK, `journaledModel` for one of your own) |
|
|
55
|
+
| `system` | The instructions (the system prompt): a text, or agentlib's function of the run's context that gives one |
|
|
56
|
+
| `tools` | The tools of `@restatedev/agents` (`tool()`, `call`, `send`, `workflow`, `signal`, `subagent`), as every agent takes them, and agentlib's own (`asyncTool`, `serviceTool`, `agentTool`, `handoff`, MCP's...) by the name the model calls them: `[weather, { transfer: asyncTool(...) }]` |
|
|
57
|
+
| `approval` | The tools of `@restatedev/agents` that wait for a person's approval before they run: their names, or a function of a call ([Approvals and signals](#approvals-and-signals)) |
|
|
58
|
+
| `history` | How the conversation the model gets stays short from turn to turn: `{ maxMessages, maxChars, retainMessages, model }`, or `false` ([A long conversation](#a-long-conversation)) |
|
|
59
|
+
| `output` | A zod schema: the answer as data, which `chat` answers with |
|
|
60
|
+
| `description` | What it is, for the UI, and for a parent's model: `subagent(agent)` tells it |
|
|
61
|
+
| `background` | It works unwatched (a subagent, say): its turn tells its companion at its end only, and takes no steered messages |
|
|
62
|
+
| `options` | Options of the object, beside the ones set here (its `retryPolicy`, as every agent's; its state preloads only `meta` and `taken`) |
|
|
63
|
+
|
|
64
|
+
Every other option of agentlib's `agent()` goes to it as it is:
|
|
65
|
+
`maxSteps`, `maxToolCalls`, `maxOutputTokens`, `compaction`,
|
|
66
|
+
`contextWindow`, `toolResults`, `skills`, `finalize`, and the guardrails
|
|
67
|
+
`beforeRun`, `beforeStep`, `beforeTool`, `afterTool` and `afterRun`.
|
|
68
|
+
|
|
69
|
+
## Tools
|
|
70
|
+
|
|
71
|
+
An agentlib agent takes the tools of `@restatedev/agents`, as every agent
|
|
72
|
+
does, and makes each agentlib's own, its calls the generator SDK's on the
|
|
73
|
+
classic SDK's context of its invocation:
|
|
74
|
+
|
|
75
|
+
| Tool | In an agentlib agent |
|
|
76
|
+
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| `call(target, handler, …)` | A call of the handler, by its typed definition (a session object's, an agent's, or any of the classic SDK's): journaled, so a crash replays its answer; stopping the turn cancels it |
|
|
78
|
+
| `send(target, handler, …)` | A send, journaled: made once |
|
|
79
|
+
| `workflow(target, …)` | A run of the workflow, to its end: a workflow of its own per tool call, unless `key` gives its id; stopping the turn cancels it |
|
|
80
|
+
| `signal(name, …)` | A wait for the signal, which `pending` lists and `signal` resolves |
|
|
81
|
+
| `subagent(agent)` | A task for an agent of any framework (a pi agent, another agentlib agent...), at its key `<this key>.<task name>`: the same name continues the task; stopping the turn stops the sub-agent's turn |
|
|
82
|
+
| `tool({ name, description, input, run })` | `run`, as a journaled step (agentlib's `asyncTool` is one too): a crash replays its result, and an error that is no terminal error fails the attempt, which Restate retries |
|
|
83
|
+
|
|
84
|
+
As in every agent, arguments that do not fit a tool's `input` are the
|
|
85
|
+
model's to fix, and a terminal error (the tool's own, or a handler's it
|
|
86
|
+
calls) is the tool's answer, which the model sees. A `tool()`'s `run` gets
|
|
87
|
+
`ctx.key` and `ctx.request`, its `callId` and `idempotencyKey`, but no
|
|
88
|
+
`ctx.db` (an agentlib agent has no SQL database) and no `ctx.rpc` or
|
|
89
|
+
`ctx.send`: its calls are Restate's tools above, or agentlib's own. A
|
|
90
|
+
`tool()` that reaches for them fails the turn, saying so. A `key` given
|
|
91
|
+
as a function gets that context too, as a journaled step.
|
|
92
|
+
|
|
93
|
+
An agent of another framework hands an agentlib agent a task with
|
|
94
|
+
`subagent(assistant)`, as any agent; `deliver` and `webhook` send it
|
|
95
|
+
messages as they send any agent's.
|
|
96
|
+
|
|
97
|
+
agentlib's own `serviceTool`, and the generator SDK's typed `client`, take
|
|
98
|
+
the generator SDK's descriptors (`iface`, `service`, `object`), which a
|
|
99
|
+
definition of the classic SDK (a session object, an agent) is not: for
|
|
100
|
+
those, `call` and `subagent` above.
|
|
101
|
+
|
|
102
|
+
## Through crashes
|
|
103
|
+
|
|
104
|
+
A crash, a restart, a deployment or a suspension replays `chat`'s journal:
|
|
105
|
+
each model call (`aiModel` journals it, as a `run`) and each tool call that
|
|
106
|
+
finished returns what it returned, without being made again, and the run
|
|
107
|
+
goes on from where it got to. A tool's own I/O is journaled as agentlib
|
|
108
|
+
journals it (`asyncTool`'s `execute` is a `run`, with `callId` for an
|
|
109
|
+
idempotency key). [`e2e/agentlib.ts`](../../../e2e/agentlib.ts) kills the
|
|
110
|
+
service mid-turn and checks that the model was asked once per step.
|
|
111
|
+
|
|
112
|
+
agentlib saves a turn's messages when its run ends; until then, `messages`
|
|
113
|
+
shows the turn as it goes: its message, its tool calls with their results,
|
|
114
|
+
and the messages steered to it. Once the turn ends, its messages are as the
|
|
115
|
+
run saved them (the model's text beside its tool calls, and its answer,
|
|
116
|
+
come then), under the same ids.
|
|
117
|
+
|
|
118
|
+
## Approvals and signals
|
|
119
|
+
|
|
120
|
+
`approval` names the tools of `@restatedev/agents` whose calls wait for a
|
|
121
|
+
person's approval before they run (or is a function of a call, `{ name,
|
|
122
|
+
args }`, that says whether it does), as the DeepSeek Harness's option does:
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
agentlib.agent({ name: 'assistant', tools: [weather, transfer], approval: ['transfer'] });
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Such a call waits for the signal `approval`, as do agentlib's own tools
|
|
129
|
+
with `needsApproval`, its `humanApprovalTool`, and a tool's
|
|
130
|
+
`context.approve`: `pending` lists the wait, with the tool and its input,
|
|
131
|
+
and `signal` approves it (`true`, `{"approved": true}`, or a text such as
|
|
132
|
+
`approved`, `yes` or `ok`) or denies it (anything else), and the model is
|
|
133
|
+
told it was denied.
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
curl localhost:8080/assistant/alice/pending
|
|
137
|
+
# [{"id": "inv_1f…:assistant:approval:call_01:0", "name": "approval", "input": {"tool": "transfer", "input": {"to": "Bob", "euros": 50}}, "since": "…"}]
|
|
138
|
+
curl localhost:8080/assistant/alice/signal --json '{"name": "approval", "value": "approved"}'
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Steering and stopping
|
|
142
|
+
|
|
143
|
+
A message sent to `steer` while a turn runs reaches the run as agentlib's
|
|
144
|
+
steering (`controls.steering`) at the turn's next publish (a tool call's
|
|
145
|
+
start or end): agentlib places it after the current round of tool calls,
|
|
146
|
+
and the model answers it in the same turn. One that comes too late (the
|
|
147
|
+
model writes its final answer) is answered as a turn of its own, after the
|
|
148
|
+
turn. `stop` cancels the turn's invocation, as for every agent: the run
|
|
149
|
+
ends cancelled, with its open tool calls, and the next turn's model sees
|
|
150
|
+
the turn's message, the messages steered to it that it took, and that it
|
|
151
|
+
ended `Cancelled: …` (not its tool calls, whose results may be missing).
|
|
152
|
+
|
|
153
|
+
## Models
|
|
154
|
+
|
|
155
|
+
`openai/…` and `anthropic/…` are agentlib's `aiModel` on the AI SDK's
|
|
156
|
+
provider (`@ai-sdk/openai`, on OpenAI's Responses API, and
|
|
157
|
+
`@ai-sdk/anthropic`), loaded when the first message comes. Any other
|
|
158
|
+
provider of the AI SDK works as a model you give:
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
import { aiModel } from '@restatedev/agentlib/provider';
|
|
162
|
+
import { google } from '@ai-sdk/google';
|
|
163
|
+
|
|
164
|
+
agentlib.agent({ name: 'assistant', model: aiModel({ model: google('<model-id>') }) });
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
A provider's refusal that a retry does not change (a missing or wrong API
|
|
168
|
+
key, an unknown model, a request it rejects: an answer 4xx) ends the message
|
|
169
|
+
with HTTP 424, as for every agent, and the conversation shows it unanswered.
|
|
170
|
+
Any other failure of a model by name (an outage, a rate limit) fails the attempt, and Restate retries it, as
|
|
171
|
+
for every agent: the model has no retry limit of its own. A model you give
|
|
172
|
+
retries as you set it (`aiModel`'s `retry`; agentlib's default is 3
|
|
173
|
+
attempts, then the message fails, `Failed: …`). agentlib 0.1.0 asks
|
|
174
|
+
Anthropic for strict tools, which it refuses with bounded numbers (agentlib's
|
|
175
|
+
own `read_tool_result` has them): an `anthropic/…` model is sent the tools'
|
|
176
|
+
schemas without their numbers' bounds, which the tools still check.
|
|
177
|
+
|
|
178
|
+
## A long conversation
|
|
179
|
+
|
|
180
|
+
The model gets the conversation as agentlib's `LazyStateConversation` keeps
|
|
181
|
+
it: at a turn's start, once its messages since the last summary pass 64
|
|
182
|
+
(or 64 000 characters), the earliest are summarized by the agent's model,
|
|
183
|
+
and the latest 12 stay as they are, from a message of the user's on. The
|
|
184
|
+
summary is kept, and the turns after build on it, so the model's input
|
|
185
|
+
stays bounded, and so does what each turn loads. `history` sets it:
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
agentlib.agent({
|
|
189
|
+
name: 'assistant',
|
|
190
|
+
history: { maxMessages: 200, maxChars: 200_000, retainMessages: 40 },
|
|
191
|
+
});
|
|
192
|
+
agentlib.agent({ name: 'assistant', history: false }); // the whole conversation, every turn
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
`history`'s `model` summarizes with another model than the agent's (a
|
|
196
|
+
cheaper one, say). `messages` keeps every turn as it was said, whatever
|
|
197
|
+
the model gets. Within a turn, agentlib's own `compaction` and
|
|
198
|
+
`contextWindow` keep a long run within the model's window.
|
|
199
|
+
|
|
200
|
+
## State
|
|
201
|
+
|
|
202
|
+
The conversation is in the object's state: the model's, in chunks of 32
|
|
203
|
+
(`t/<n>`) with its count and summary (`t/meta`), and the messages as
|
|
204
|
+
clients read them, one key each (`c/<id>`), beside `meta`. An invocation
|
|
205
|
+
starts with `meta`, `taken` and `t/meta` alone, and reads the rest as it
|
|
206
|
+
needs it: `messages`, a page; `chat`, the messages since the summary. Each
|
|
207
|
+
read is journaled with what it read, as any state read of a journaled
|
|
208
|
+
handler is: a turn's journal has the conversation it loaded.
|
|
209
|
+
|
|
210
|
+
## Not here
|
|
211
|
+
|
|
212
|
+
- **`window`, `budget`, `summarize`, `schema`** (the conversation of turns,
|
|
213
|
+
and tables of your own): there is no SQL database; `history` keeps a
|
|
214
|
+
long conversation short ([A long conversation](#a-long-conversation)).
|
|
215
|
+
- **`ctx.db`, `ctx.rpc` and `ctx.send` in a `tool()`**: see [Tools](#tools).
|
|
216
|
+
- **A killed turn** (out of retries, or killed by an operator) is closed by
|
|
217
|
+
the next message, `Ended: …`, not by the companion as it finds it gone.
|
|
218
|
+
|
|
219
|
+
## Packages
|
|
220
|
+
|
|
221
|
+
`@restatedev/agentlib` (0.1.x) and `@restatedev/restate-sdk-gen`
|
|
222
|
+
(1.18.2, the SDK @restatedev/sessions pins) are optional peer
|
|
223
|
+
dependencies, as are `@ai-sdk/openai` and `@ai-sdk/anthropic`. agentlib
|
|
224
|
+
runs on the copy of `@restatedev/restate-sdk` it finds, which must be
|
|
225
|
+
@restatedev/sessions' own (1.18.2): install `@restatedev/restate-sdk@1.18.2`
|
|
226
|
+
with it, as above, and npm installs one for all of them. On two copies (npm
|
|
227
|
+
puts a newer SDK beside sessions' own for agentlib, without it), an agent
|
|
228
|
+
refuses to start, saying so; `@restatedev/agents` asks for no SDK of its
|
|
229
|
+
own, so a project of another framework keeps whichever SDK it has.
|