robot_lab 0.0.1 → 0.0.6
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.
- checksums.yaml +4 -4
- data/.github/workflows/deploy-github-pages.yml +9 -9
- data/.irbrc +6 -0
- data/CHANGELOG.md +140 -0
- data/README.md +263 -48
- data/Rakefile +71 -1
- data/docs/api/core/index.md +53 -46
- data/docs/api/core/memory.md +200 -154
- data/docs/api/core/network.md +13 -3
- data/docs/api/core/robot.md +490 -130
- data/docs/api/core/state.md +55 -73
- data/docs/api/core/tool.md +205 -209
- data/docs/api/index.md +7 -28
- data/docs/api/mcp/client.md +119 -48
- data/docs/api/mcp/index.md +75 -60
- data/docs/api/mcp/server.md +120 -136
- data/docs/api/mcp/transports.md +172 -184
- data/docs/api/messages/index.md +35 -20
- data/docs/api/messages/text-message.md +67 -21
- data/docs/api/messages/tool-call-message.md +80 -41
- data/docs/api/messages/tool-result-message.md +119 -50
- data/docs/api/messages/user-message.md +48 -24
- data/docs/api/streaming/context.md +157 -74
- data/docs/api/streaming/events.md +114 -166
- data/docs/api/streaming/index.md +74 -72
- data/docs/architecture/core-concepts.md +360 -116
- data/docs/architecture/index.md +97 -59
- data/docs/architecture/message-flow.md +138 -129
- data/docs/architecture/network-orchestration.md +197 -50
- data/docs/architecture/robot-execution.md +199 -146
- data/docs/architecture/state-management.md +255 -187
- data/docs/concepts.md +311 -49
- data/docs/examples/basic-chat.md +89 -77
- data/docs/examples/index.md +222 -47
- data/docs/examples/mcp-server.md +207 -203
- data/docs/examples/multi-robot-network.md +129 -35
- data/docs/examples/rails-application.md +159 -160
- data/docs/examples/tool-usage.md +295 -204
- data/docs/getting-started/configuration.md +347 -154
- data/docs/getting-started/index.md +1 -1
- data/docs/getting-started/installation.md +22 -13
- data/docs/getting-started/quick-start.md +166 -121
- data/docs/guides/building-robots.md +418 -212
- data/docs/guides/creating-networks.md +143 -24
- data/docs/guides/index.md +0 -5
- data/docs/guides/mcp-integration.md +152 -113
- data/docs/guides/memory.md +220 -164
- data/docs/guides/rails-integration.md +244 -162
- data/docs/guides/streaming.md +137 -187
- data/docs/guides/using-tools.md +259 -212
- data/docs/index.md +46 -41
- data/examples/01_simple_robot.rb +6 -9
- data/examples/02_tools.rb +6 -9
- data/examples/03_network.rb +19 -17
- data/examples/04_mcp.rb +5 -8
- data/examples/05_streaming.rb +5 -8
- data/examples/06_prompt_templates.rb +42 -37
- data/examples/07_network_memory.rb +13 -14
- data/examples/08_llm_config.rb +169 -0
- data/examples/09_chaining.rb +262 -0
- data/examples/10_memory.rb +331 -0
- data/examples/11_network_introspection.rb +253 -0
- data/examples/12_message_bus.rb +74 -0
- data/examples/13_spawn.rb +90 -0
- data/examples/14_rusty_circuit/comic.rb +143 -0
- data/examples/14_rusty_circuit/display.rb +203 -0
- data/examples/14_rusty_circuit/heckler.rb +63 -0
- data/examples/14_rusty_circuit/open_mic.rb +123 -0
- data/examples/14_rusty_circuit/prompts/open_mic_comic.md +20 -0
- data/examples/14_rusty_circuit/prompts/open_mic_heckler.md +23 -0
- data/examples/14_rusty_circuit/prompts/open_mic_scout.md +20 -0
- data/examples/14_rusty_circuit/scout.rb +156 -0
- data/examples/14_rusty_circuit/scout_notes.md +89 -0
- data/examples/14_rusty_circuit/show.log +234 -0
- data/examples/15_memory_network_and_bus/editor_in_chief.rb +24 -0
- data/examples/15_memory_network_and_bus/editorial_pipeline.rb +206 -0
- data/examples/15_memory_network_and_bus/linux_writer.rb +80 -0
- data/examples/15_memory_network_and_bus/os_editor.rb +46 -0
- data/examples/15_memory_network_and_bus/os_writer.rb +46 -0
- data/examples/15_memory_network_and_bus/output/combined_article.md +13 -0
- data/examples/15_memory_network_and_bus/output/final_article.md +15 -0
- data/examples/15_memory_network_and_bus/output/linux_draft.md +5 -0
- data/examples/15_memory_network_and_bus/output/mac_draft.md +7 -0
- data/examples/15_memory_network_and_bus/output/memory.json +13 -0
- data/examples/15_memory_network_and_bus/output/revision_1.md +19 -0
- data/examples/15_memory_network_and_bus/output/revision_2.md +15 -0
- data/examples/15_memory_network_and_bus/output/windows_draft.md +7 -0
- data/examples/15_memory_network_and_bus/prompts/os_advocate.md +13 -0
- data/examples/15_memory_network_and_bus/prompts/os_chief.md +13 -0
- data/examples/15_memory_network_and_bus/prompts/os_editor.md +13 -0
- data/examples/16_writers_room/display.rb +158 -0
- data/examples/16_writers_room/output/.gitignore +2 -0
- data/examples/16_writers_room/output/opus_001.md +263 -0
- data/examples/16_writers_room/output/opus_001_notes.log +470 -0
- data/examples/16_writers_room/prompts/writer.md +37 -0
- data/examples/16_writers_room/room.rb +150 -0
- data/examples/16_writers_room/tools.rb +162 -0
- data/examples/16_writers_room/writer.rb +121 -0
- data/examples/16_writers_room/writers_room.rb +162 -0
- data/examples/README.md +197 -0
- data/examples/prompts/{assistant/system.txt.erb → assistant.md} +3 -0
- data/examples/prompts/{billing/system.txt.erb → billing.md} +3 -0
- data/examples/prompts/{classifier/system.txt.erb → classifier.md} +3 -0
- data/examples/prompts/comedian.md +6 -0
- data/examples/prompts/comedy_critic.md +10 -0
- data/examples/prompts/configurable.md +9 -0
- data/examples/prompts/dispatcher.md +12 -0
- data/examples/prompts/{entity_extractor/system.txt.erb → entity_extractor.md} +3 -0
- data/examples/prompts/{escalation/system.txt.erb → escalation.md} +7 -0
- data/examples/prompts/frontmatter_mcp_test.md +9 -0
- data/examples/prompts/frontmatter_named_test.md +5 -0
- data/examples/prompts/frontmatter_tools_test.md +6 -0
- data/examples/prompts/{general/system.txt.erb → general.md} +3 -0
- data/examples/prompts/{github_assistant/system.txt.erb → github_assistant.md} +8 -0
- data/examples/prompts/{helper/system.txt.erb → helper.md} +3 -0
- data/examples/prompts/{keyword_extractor/system.txt.erb → keyword_extractor.md} +3 -0
- data/examples/prompts/llm_config_demo.md +20 -0
- data/examples/prompts/{order_support/system.txt.erb → order_support.md} +8 -0
- data/examples/prompts/os_advocate.md +13 -0
- data/examples/prompts/os_chief.md +13 -0
- data/examples/prompts/os_editor.md +13 -0
- data/examples/prompts/{product_support/system.txt.erb → product_support.md} +7 -0
- data/examples/prompts/{sentiment_analyzer/system.txt.erb → sentiment_analyzer.md} +3 -0
- data/examples/prompts/{synthesizer/system.txt.erb → synthesizer.md} +3 -0
- data/examples/prompts/{technical/system.txt.erb → technical.md} +3 -0
- data/examples/prompts/{triage/system.txt.erb → triage.md} +6 -0
- data/lib/generators/robot_lab/templates/initializer.rb.tt +0 -13
- data/lib/robot_lab/ask_user.rb +75 -0
- data/lib/robot_lab/config/defaults.yml +121 -0
- data/lib/robot_lab/config.rb +183 -0
- data/lib/robot_lab/error.rb +6 -0
- data/lib/robot_lab/mcp/client.rb +1 -1
- data/lib/robot_lab/memory.rb +10 -34
- data/lib/robot_lab/network.rb +13 -20
- data/lib/robot_lab/robot/bus_messaging.rb +239 -0
- data/lib/robot_lab/robot/mcp_management.rb +88 -0
- data/lib/robot_lab/robot/template_rendering.rb +130 -0
- data/lib/robot_lab/robot.rb +240 -330
- data/lib/robot_lab/robot_message.rb +44 -0
- data/lib/robot_lab/robot_result.rb +1 -0
- data/lib/robot_lab/run_config.rb +184 -0
- data/lib/robot_lab/state_proxy.rb +2 -12
- data/lib/robot_lab/streaming/context.rb +1 -1
- data/lib/robot_lab/task.rb +8 -1
- data/lib/robot_lab/tool.rb +108 -172
- data/lib/robot_lab/tool_config.rb +1 -1
- data/lib/robot_lab/tool_manifest.rb +2 -18
- data/lib/robot_lab/utils.rb +39 -0
- data/lib/robot_lab/version.rb +1 -1
- data/lib/robot_lab.rb +89 -57
- data/mkdocs.yml +0 -11
- metadata +121 -135
- data/docs/api/adapters/anthropic.md +0 -121
- data/docs/api/adapters/gemini.md +0 -133
- data/docs/api/adapters/index.md +0 -104
- data/docs/api/adapters/openai.md +0 -134
- data/docs/api/history/active-record-adapter.md +0 -195
- data/docs/api/history/config.md +0 -191
- data/docs/api/history/index.md +0 -132
- data/docs/api/history/thread-manager.md +0 -144
- data/docs/guides/history.md +0 -359
- data/examples/prompts/assistant/user.txt.erb +0 -1
- data/examples/prompts/billing/user.txt.erb +0 -1
- data/examples/prompts/classifier/user.txt.erb +0 -1
- data/examples/prompts/entity_extractor/user.txt.erb +0 -3
- data/examples/prompts/escalation/user.txt.erb +0 -34
- data/examples/prompts/general/user.txt.erb +0 -1
- data/examples/prompts/github_assistant/user.txt.erb +0 -1
- data/examples/prompts/helper/user.txt.erb +0 -1
- data/examples/prompts/keyword_extractor/user.txt.erb +0 -3
- data/examples/prompts/order_support/user.txt.erb +0 -22
- data/examples/prompts/product_support/user.txt.erb +0 -32
- data/examples/prompts/sentiment_analyzer/user.txt.erb +0 -3
- data/examples/prompts/synthesizer/user.txt.erb +0 -15
- data/examples/prompts/technical/user.txt.erb +0 -1
- data/examples/prompts/triage/user.txt.erb +0 -17
- data/lib/robot_lab/adapters/anthropic.rb +0 -163
- data/lib/robot_lab/adapters/base.rb +0 -85
- data/lib/robot_lab/adapters/gemini.rb +0 -193
- data/lib/robot_lab/adapters/openai.rb +0 -159
- data/lib/robot_lab/adapters/registry.rb +0 -81
- data/lib/robot_lab/configuration.rb +0 -143
- data/lib/robot_lab/errors.rb +0 -70
- data/lib/robot_lab/history/active_record_adapter.rb +0 -146
- data/lib/robot_lab/history/config.rb +0 -115
- data/lib/robot_lab/history/thread_manager.rb +0 -93
- data/lib/robot_lab/robotic_model.rb +0 -324
data/docs/api/core/state.md
CHANGED
|
@@ -1,54 +1,43 @@
|
|
|
1
|
-
# State
|
|
1
|
+
# Memory (State Management)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Memory manages conversation data, results, and runtime state. There is no separate `State` class; `Memory` serves this role.
|
|
4
4
|
|
|
5
|
-
## Class: `RobotLab::
|
|
5
|
+
## Class: `RobotLab::Memory`
|
|
6
6
|
|
|
7
7
|
```ruby
|
|
8
|
-
|
|
9
|
-
message: "Hello",
|
|
8
|
+
memory = RobotLab.create_memory(
|
|
10
9
|
data: { user_id: "123" }
|
|
11
10
|
)
|
|
12
11
|
```
|
|
13
12
|
|
|
14
13
|
## Attributes
|
|
15
14
|
|
|
16
|
-
###
|
|
15
|
+
### session_id
|
|
17
16
|
|
|
18
17
|
```ruby
|
|
19
|
-
|
|
18
|
+
memory.session_id # => String | nil
|
|
20
19
|
```
|
|
21
20
|
|
|
22
|
-
Conversation
|
|
23
|
-
|
|
24
|
-
### memory
|
|
25
|
-
|
|
26
|
-
```ruby
|
|
27
|
-
state.memory # => Memory
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Shared key-value store.
|
|
31
|
-
|
|
32
|
-
## Methods
|
|
21
|
+
Conversation session identifier for persistence.
|
|
33
22
|
|
|
34
23
|
### data
|
|
35
24
|
|
|
36
25
|
```ruby
|
|
37
|
-
|
|
26
|
+
memory.data # => StateProxy
|
|
38
27
|
```
|
|
39
28
|
|
|
40
29
|
Access workflow data as a proxy object.
|
|
41
30
|
|
|
42
31
|
```ruby
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
memory.data[:user_id] # Hash access
|
|
33
|
+
memory.data.user_id # Method access
|
|
34
|
+
memory.data[:status] = "active"
|
|
46
35
|
```
|
|
47
36
|
|
|
48
37
|
### results
|
|
49
38
|
|
|
50
39
|
```ruby
|
|
51
|
-
|
|
40
|
+
memory.results # => Array<RobotResult>
|
|
52
41
|
```
|
|
53
42
|
|
|
54
43
|
All robot execution results.
|
|
@@ -56,15 +45,17 @@ All robot execution results.
|
|
|
56
45
|
### messages
|
|
57
46
|
|
|
58
47
|
```ruby
|
|
59
|
-
|
|
48
|
+
memory.messages # => Array<Message>
|
|
60
49
|
```
|
|
61
50
|
|
|
62
51
|
Formatted conversation messages for LLM.
|
|
63
52
|
|
|
53
|
+
## Methods
|
|
54
|
+
|
|
64
55
|
### append_result
|
|
65
56
|
|
|
66
57
|
```ruby
|
|
67
|
-
|
|
58
|
+
memory.append_result(robot_result)
|
|
68
59
|
```
|
|
69
60
|
|
|
70
61
|
Add a robot result to history.
|
|
@@ -72,7 +63,7 @@ Add a robot result to history.
|
|
|
72
63
|
### set_results
|
|
73
64
|
|
|
74
65
|
```ruby
|
|
75
|
-
|
|
66
|
+
memory.set_results(array_of_results)
|
|
76
67
|
```
|
|
77
68
|
|
|
78
69
|
Replace all results.
|
|
@@ -80,23 +71,23 @@ Replace all results.
|
|
|
80
71
|
### results_from
|
|
81
72
|
|
|
82
73
|
```ruby
|
|
83
|
-
|
|
74
|
+
memory.results_from(5) # => Array<RobotResult>
|
|
84
75
|
```
|
|
85
76
|
|
|
86
77
|
Get results starting at index.
|
|
87
78
|
|
|
88
|
-
###
|
|
79
|
+
### session_id=
|
|
89
80
|
|
|
90
81
|
```ruby
|
|
91
|
-
|
|
82
|
+
memory.session_id = "session_123"
|
|
92
83
|
```
|
|
93
84
|
|
|
94
|
-
Set the
|
|
85
|
+
Set the session identifier.
|
|
95
86
|
|
|
96
87
|
### format_history
|
|
97
88
|
|
|
98
89
|
```ruby
|
|
99
|
-
|
|
90
|
+
memory.format_history # => Array<Message>
|
|
100
91
|
```
|
|
101
92
|
|
|
102
93
|
Format results as conversation history.
|
|
@@ -104,7 +95,7 @@ Format results as conversation history.
|
|
|
104
95
|
### clone
|
|
105
96
|
|
|
106
97
|
```ruby
|
|
107
|
-
|
|
98
|
+
new_memory = memory.clone
|
|
108
99
|
```
|
|
109
100
|
|
|
110
101
|
Create a deep copy.
|
|
@@ -112,7 +103,7 @@ Create a deep copy.
|
|
|
112
103
|
### to_h
|
|
113
104
|
|
|
114
105
|
```ruby
|
|
115
|
-
|
|
106
|
+
memory.to_h # => Hash
|
|
116
107
|
```
|
|
117
108
|
|
|
118
109
|
Hash representation.
|
|
@@ -120,7 +111,7 @@ Hash representation.
|
|
|
120
111
|
### to_json
|
|
121
112
|
|
|
122
113
|
```ruby
|
|
123
|
-
|
|
114
|
+
memory.to_json # => String
|
|
124
115
|
```
|
|
125
116
|
|
|
126
117
|
JSON representation.
|
|
@@ -128,7 +119,7 @@ JSON representation.
|
|
|
128
119
|
### from_hash (class method)
|
|
129
120
|
|
|
130
121
|
```ruby
|
|
131
|
-
|
|
122
|
+
memory = Memory.from_hash(hash)
|
|
132
123
|
```
|
|
133
124
|
|
|
134
125
|
Restore from hash.
|
|
@@ -138,7 +129,7 @@ Restore from hash.
|
|
|
138
129
|
The `data` attribute is a `StateProxy`:
|
|
139
130
|
|
|
140
131
|
```ruby
|
|
141
|
-
proxy =
|
|
132
|
+
proxy = memory.data
|
|
142
133
|
|
|
143
134
|
# Hash-style access
|
|
144
135
|
proxy[:key]
|
|
@@ -160,19 +151,18 @@ proxy.empty?
|
|
|
160
151
|
proxy.size
|
|
161
152
|
```
|
|
162
153
|
|
|
163
|
-
## Creating
|
|
154
|
+
## Creating Memory
|
|
164
155
|
|
|
165
156
|
### Basic
|
|
166
157
|
|
|
167
158
|
```ruby
|
|
168
|
-
|
|
159
|
+
memory = RobotLab.create_memory
|
|
169
160
|
```
|
|
170
161
|
|
|
171
162
|
### With Data
|
|
172
163
|
|
|
173
164
|
```ruby
|
|
174
|
-
|
|
175
|
-
message: "Process order",
|
|
165
|
+
memory = RobotLab.create_memory(
|
|
176
166
|
data: {
|
|
177
167
|
user_id: "user_123",
|
|
178
168
|
order_id: "ord_456"
|
|
@@ -180,25 +170,18 @@ state = RobotLab.create_state(
|
|
|
180
170
|
)
|
|
181
171
|
```
|
|
182
172
|
|
|
183
|
-
### With
|
|
173
|
+
### With Session ID
|
|
184
174
|
|
|
185
175
|
```ruby
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
state = RobotLab.create_state(message: message)
|
|
189
|
-
|
|
190
|
-
# Direct assignment
|
|
191
|
-
state = RobotLab.create_state(message: "Continue")
|
|
192
|
-
state.thread_id = "thread_123"
|
|
176
|
+
memory = RobotLab.create_memory
|
|
177
|
+
memory.session_id = "session_123"
|
|
193
178
|
```
|
|
194
179
|
|
|
195
180
|
### With Existing Results
|
|
196
181
|
|
|
197
182
|
```ruby
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
results: previous_results
|
|
201
|
-
)
|
|
183
|
+
memory = RobotLab.create_memory
|
|
184
|
+
memory.set_results(previous_results)
|
|
202
185
|
```
|
|
203
186
|
|
|
204
187
|
## UserMessage
|
|
@@ -208,13 +191,13 @@ Enhanced message with metadata:
|
|
|
208
191
|
```ruby
|
|
209
192
|
message = UserMessage.new(
|
|
210
193
|
"What's my order status?",
|
|
211
|
-
|
|
194
|
+
session_id: "session_123",
|
|
212
195
|
system_prompt: "Respond in Spanish",
|
|
213
196
|
metadata: { source: "web" }
|
|
214
197
|
)
|
|
215
198
|
|
|
216
199
|
message.content # => "What's my order status?"
|
|
217
|
-
message.
|
|
200
|
+
message.session_id # => "session_123"
|
|
218
201
|
message.system_prompt # => "Respond in Spanish"
|
|
219
202
|
message.metadata # => { source: "web" }
|
|
220
203
|
message.id # => UUID
|
|
@@ -226,48 +209,47 @@ message.created_at # => Time
|
|
|
226
209
|
### Accessing Data
|
|
227
210
|
|
|
228
211
|
```ruby
|
|
229
|
-
|
|
230
|
-
message: "Help",
|
|
212
|
+
memory = RobotLab.create_memory(
|
|
231
213
|
data: { user: { name: "Alice", plan: "pro" } }
|
|
232
214
|
)
|
|
233
215
|
|
|
234
|
-
|
|
235
|
-
|
|
216
|
+
memory.data[:user][:name] # => "Alice"
|
|
217
|
+
memory.data.to_h # => { user: { name: "Alice", plan: "pro" } }
|
|
236
218
|
```
|
|
237
219
|
|
|
238
220
|
### Working with Results
|
|
239
221
|
|
|
240
222
|
```ruby
|
|
241
223
|
# After running network
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
224
|
+
memory.results.size # Number of results
|
|
225
|
+
memory.results.last # Most recent
|
|
226
|
+
memory.results.map(&:robot_name) # ["classifier", "support"]
|
|
245
227
|
```
|
|
246
228
|
|
|
247
|
-
### Using Memory
|
|
229
|
+
### Using Reactive Memory
|
|
248
230
|
|
|
249
231
|
```ruby
|
|
250
|
-
|
|
251
|
-
intent =
|
|
232
|
+
memory.set(:intent, "billing")
|
|
233
|
+
intent = memory.get(:intent)
|
|
252
234
|
|
|
253
|
-
|
|
254
|
-
|
|
235
|
+
memory.subscribe(:status) do |change|
|
|
236
|
+
puts "Status changed to #{change.value} by #{change.writer}"
|
|
237
|
+
end
|
|
255
238
|
```
|
|
256
239
|
|
|
257
240
|
### Serialization
|
|
258
241
|
|
|
259
242
|
```ruby
|
|
260
|
-
# Save
|
|
261
|
-
json =
|
|
262
|
-
File.write("
|
|
243
|
+
# Save memory
|
|
244
|
+
json = memory.to_json
|
|
245
|
+
File.write("memory.json", json)
|
|
263
246
|
|
|
264
|
-
# Restore
|
|
265
|
-
data = JSON.parse(File.read("
|
|
266
|
-
|
|
247
|
+
# Restore memory
|
|
248
|
+
data = JSON.parse(File.read("memory.json"))
|
|
249
|
+
memory = Memory.from_hash(data)
|
|
267
250
|
```
|
|
268
251
|
|
|
269
252
|
## See Also
|
|
270
253
|
|
|
271
254
|
- [State Management Architecture](../../architecture/state-management.md)
|
|
272
255
|
- [Memory](memory.md)
|
|
273
|
-
- [History Guide](../../guides/history.md)
|