robot_lab 0.0.1 → 0.0.4
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 +90 -0
- data/README.md +203 -46
- data/Rakefile +70 -1
- data/docs/api/core/index.md +12 -0
- data/docs/api/core/robot.md +478 -130
- data/docs/api/core/tool.md +205 -209
- data/docs/api/history/active-record-adapter.md +174 -94
- data/docs/api/history/config.md +186 -93
- data/docs/api/history/index.md +57 -61
- data/docs/api/history/thread-manager.md +123 -73
- 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/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 +361 -112
- 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 +312 -48
- 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 +275 -162
- 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 +417 -212
- data/docs/guides/creating-networks.md +94 -24
- data/docs/guides/mcp-integration.md +152 -113
- data/docs/guides/memory.md +220 -164
- data/docs/guides/streaming.md +80 -110
- data/docs/guides/using-tools.md +259 -212
- data/docs/index.md +50 -37
- data/examples/01_simple_robot.rb +6 -9
- data/examples/02_tools.rb +6 -9
- data/examples/03_network.rb +13 -14
- 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 +140 -0
- data/examples/09_chaining.rb +223 -0
- data/examples/10_memory.rb +331 -0
- data/examples/11_network_introspection.rb +230 -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 +57 -0
- data/examples/14_rusty_circuit/open_mic.rb +121 -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 +173 -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/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 +1 -1
- data/lib/robot_lab/adapters/openai.rb +2 -1
- 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 +2 -2
- data/lib/robot_lab/robot.rb +523 -249
- data/lib/robot_lab/robot_message.rb +44 -0
- data/lib/robot_lab/robot_result.rb +1 -0
- data/lib/robot_lab/robotic_model.rb +1 -1
- data/lib/robot_lab/streaming/context.rb +1 -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/version.rb +1 -1
- data/lib/robot_lab.rb +66 -55
- metadata +107 -116
- 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/configuration.rb +0 -143
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)
|