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/streaming/index.md
CHANGED
|
@@ -1,108 +1,110 @@
|
|
|
1
1
|
# Streaming
|
|
2
2
|
|
|
3
|
-
Real-time
|
|
3
|
+
Real-time event streaming during robot and network execution.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The streaming system provides structured event publishing during LLM execution. Events are emitted for run lifecycle, content deltas (token streaming), tool calls, and metadata updates. The system supports nested contexts for network-level orchestration where multiple robots execute within a single run.
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
|
-
|
|
11
|
-
case event
|
|
12
|
-
when
|
|
13
|
-
print event
|
|
14
|
-
when
|
|
15
|
-
puts "\nCalling tool: #{event.name}"
|
|
16
|
-
when :complete
|
|
10
|
+
publish = ->(event) {
|
|
11
|
+
case event[:event]
|
|
12
|
+
when "text.delta"
|
|
13
|
+
print event[:data][:delta]
|
|
14
|
+
when "run.completed"
|
|
17
15
|
puts "\nDone!"
|
|
18
16
|
end
|
|
19
|
-
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
context = RobotLab::Streaming::Context.new(
|
|
20
|
+
run_id: SecureRandom.uuid,
|
|
21
|
+
message_id: SecureRandom.uuid,
|
|
22
|
+
scope: "robot",
|
|
23
|
+
publish: publish
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
context.publish_event(event: "text.delta", data: { delta: "Hello" })
|
|
20
27
|
```
|
|
21
28
|
|
|
22
29
|
## Components
|
|
23
30
|
|
|
24
31
|
| Component | Description |
|
|
25
32
|
|-----------|-------------|
|
|
26
|
-
| [Context](context.md) |
|
|
27
|
-
| [Events](events.md) | Event
|
|
28
|
-
|
|
29
|
-
## Quick Start
|
|
33
|
+
| [Context](context.md) | Manages streaming state, sequencing, and event publishing |
|
|
34
|
+
| [Events](events.md) | Event type constants and classification helpers |
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
Also used internally:
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
end
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### With Network
|
|
40
|
-
|
|
41
|
-
```ruby
|
|
42
|
-
network.run(state: state) do |event|
|
|
43
|
-
case event.type
|
|
44
|
-
when :robot_start
|
|
45
|
-
puts "Robot #{event.robot_name} starting..."
|
|
46
|
-
when :text_delta
|
|
47
|
-
print event.text
|
|
48
|
-
when :robot_complete
|
|
49
|
-
puts "\nRobot #{event.robot_name} complete"
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
```
|
|
38
|
+
| Component | Description |
|
|
39
|
+
|-----------|-------------|
|
|
40
|
+
| `SequenceCounter` | Thread-safe monotonic counter for event ordering |
|
|
53
41
|
|
|
54
|
-
## Event
|
|
42
|
+
## Event Categories
|
|
55
43
|
|
|
56
|
-
|
|
|
57
|
-
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
| `:error` | Error occurred |
|
|
44
|
+
| Category | Events | Description |
|
|
45
|
+
|----------|--------|-------------|
|
|
46
|
+
| Lifecycle | `run.started`, `run.completed`, `run.failed`, `run.interrupted` | Run-level state changes |
|
|
47
|
+
| Steps | `step.started`, `step.completed`, `step.failed` | Durable execution steps |
|
|
48
|
+
| Parts | `part.created`, `part.completed`, `part.failed` | Message composition parts |
|
|
49
|
+
| Deltas | `text.delta`, `tool_call.arguments.delta`, `reasoning.delta`, `data.delta` | Token-level content streaming |
|
|
50
|
+
| HITL | `hitl.requested`, `hitl.resolved` | Human-in-the-loop events |
|
|
51
|
+
| Metadata | `usage.updated`, `metadata.updated` | Token usage and metadata |
|
|
52
|
+
| Terminal | `stream.ended` | End of stream signal |
|
|
66
53
|
|
|
67
|
-
##
|
|
54
|
+
## Event Structure
|
|
68
55
|
|
|
69
|
-
|
|
56
|
+
Each published event is a hash with the following shape:
|
|
70
57
|
|
|
71
58
|
```ruby
|
|
72
|
-
|
|
73
|
-
|
|
59
|
+
{
|
|
60
|
+
event: "text.delta", # Event type string
|
|
61
|
+
data: { # Event payload (merged with context info)
|
|
62
|
+
delta: "Hello", # Custom data
|
|
63
|
+
run_id: "run_123", # Injected by context
|
|
64
|
+
message_id: "msg_456", # Injected by context
|
|
65
|
+
scope: "robot" # Injected by context
|
|
66
|
+
},
|
|
67
|
+
timestamp: 1707900000000, # Millisecond Unix timestamp
|
|
68
|
+
sequence_number: 1, # Monotonically increasing
|
|
69
|
+
id: "publish-1:text.delta" # Unique event ID
|
|
74
70
|
}
|
|
75
|
-
|
|
76
|
-
robot.run(state: state, streaming: callback)
|
|
77
71
|
```
|
|
78
72
|
|
|
79
|
-
|
|
73
|
+
## Quick Start
|
|
74
|
+
|
|
75
|
+
### Publishing Events
|
|
80
76
|
|
|
81
77
|
```ruby
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
context = RobotLab::Streaming::Context.new(
|
|
79
|
+
run_id: "run_123",
|
|
80
|
+
message_id: "msg_456",
|
|
81
|
+
scope: "network",
|
|
82
|
+
publish: ->(event) { broadcast(event) }
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
context.publish_event(event: "run.started", data: { robot_name: "assistant" })
|
|
86
|
+
context.publish_event(event: "text.delta", data: { delta: "Hello " })
|
|
87
|
+
context.publish_event(event: "text.delta", data: { delta: "world!" })
|
|
88
|
+
context.publish_event(event: "run.completed", data: {})
|
|
85
89
|
```
|
|
86
90
|
|
|
87
|
-
###
|
|
91
|
+
### Nested Contexts for Networks
|
|
88
92
|
|
|
89
93
|
```ruby
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
robot.run(state: state, streaming: StreamHandler.new)
|
|
94
|
+
# Parent context for the network run
|
|
95
|
+
network_context = RobotLab::Streaming::Context.new(
|
|
96
|
+
run_id: "network_run_1",
|
|
97
|
+
message_id: "msg_1",
|
|
98
|
+
scope: "network",
|
|
99
|
+
publish: ->(event) { stream_to_client(event) }
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# Child context for each robot (shares the sequence counter)
|
|
103
|
+
robot_context = network_context.create_child_context("robot_run_1")
|
|
104
|
+
robot_context.publish_event(event: "text.delta", data: { delta: "Response" })
|
|
102
105
|
```
|
|
103
106
|
|
|
104
107
|
## See Also
|
|
105
108
|
|
|
106
|
-
- [
|
|
107
|
-
- [
|
|
108
|
-
- [Network](../core/network.md)
|
|
109
|
+
- [Context](context.md)
|
|
110
|
+
- [Events](events.md)
|