robot_lab 0.0.4 → 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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -0
  3. data/README.md +64 -6
  4. data/Rakefile +2 -1
  5. data/docs/api/core/index.md +41 -46
  6. data/docs/api/core/memory.md +200 -154
  7. data/docs/api/core/network.md +13 -3
  8. data/docs/api/core/robot.md +38 -26
  9. data/docs/api/core/state.md +55 -73
  10. data/docs/api/index.md +7 -28
  11. data/docs/api/messages/index.md +35 -20
  12. data/docs/api/messages/text-message.md +67 -21
  13. data/docs/api/messages/tool-call-message.md +80 -41
  14. data/docs/api/messages/tool-result-message.md +119 -50
  15. data/docs/api/messages/user-message.md +48 -24
  16. data/docs/architecture/core-concepts.md +10 -15
  17. data/docs/concepts.md +5 -7
  18. data/docs/examples/index.md +2 -2
  19. data/docs/getting-started/configuration.md +80 -0
  20. data/docs/guides/building-robots.md +10 -9
  21. data/docs/guides/creating-networks.md +49 -0
  22. data/docs/guides/index.md +0 -5
  23. data/docs/guides/rails-integration.md +244 -162
  24. data/docs/guides/streaming.md +118 -138
  25. data/docs/index.md +0 -8
  26. data/examples/03_network.rb +10 -7
  27. data/examples/08_llm_config.rb +40 -11
  28. data/examples/09_chaining.rb +45 -6
  29. data/examples/11_network_introspection.rb +30 -7
  30. data/examples/12_message_bus.rb +1 -1
  31. data/examples/14_rusty_circuit/heckler.rb +14 -8
  32. data/examples/14_rusty_circuit/open_mic.rb +5 -3
  33. data/examples/14_rusty_circuit/scout.rb +14 -31
  34. data/examples/15_memory_network_and_bus/editorial_pipeline.rb +1 -1
  35. data/examples/16_writers_room/display.rb +158 -0
  36. data/examples/16_writers_room/output/.gitignore +2 -0
  37. data/examples/16_writers_room/output/opus_001.md +263 -0
  38. data/examples/16_writers_room/output/opus_001_notes.log +470 -0
  39. data/examples/16_writers_room/prompts/writer.md +37 -0
  40. data/examples/16_writers_room/room.rb +150 -0
  41. data/examples/16_writers_room/tools.rb +162 -0
  42. data/examples/16_writers_room/writer.rb +121 -0
  43. data/examples/16_writers_room/writers_room.rb +162 -0
  44. data/lib/generators/robot_lab/templates/initializer.rb.tt +0 -13
  45. data/lib/robot_lab/memory.rb +8 -32
  46. data/lib/robot_lab/network.rb +13 -20
  47. data/lib/robot_lab/robot/bus_messaging.rb +239 -0
  48. data/lib/robot_lab/robot/mcp_management.rb +88 -0
  49. data/lib/robot_lab/robot/template_rendering.rb +130 -0
  50. data/lib/robot_lab/robot.rb +56 -420
  51. data/lib/robot_lab/run_config.rb +184 -0
  52. data/lib/robot_lab/state_proxy.rb +2 -12
  53. data/lib/robot_lab/task.rb +8 -1
  54. data/lib/robot_lab/utils.rb +39 -0
  55. data/lib/robot_lab/version.rb +1 -1
  56. data/lib/robot_lab.rb +29 -8
  57. data/mkdocs.yml +0 -11
  58. metadata +15 -20
  59. data/docs/api/adapters/anthropic.md +0 -121
  60. data/docs/api/adapters/gemini.md +0 -133
  61. data/docs/api/adapters/index.md +0 -104
  62. data/docs/api/adapters/openai.md +0 -134
  63. data/docs/api/history/active-record-adapter.md +0 -275
  64. data/docs/api/history/config.md +0 -284
  65. data/docs/api/history/index.md +0 -128
  66. data/docs/api/history/thread-manager.md +0 -194
  67. data/docs/guides/history.md +0 -359
  68. data/lib/robot_lab/adapters/anthropic.rb +0 -163
  69. data/lib/robot_lab/adapters/base.rb +0 -85
  70. data/lib/robot_lab/adapters/gemini.rb +0 -193
  71. data/lib/robot_lab/adapters/openai.rb +0 -160
  72. data/lib/robot_lab/adapters/registry.rb +0 -81
  73. data/lib/robot_lab/errors.rb +0 -70
  74. data/lib/robot_lab/history/active_record_adapter.rb +0 -146
  75. data/lib/robot_lab/history/config.rb +0 -115
  76. data/lib/robot_lab/history/thread_manager.rb +0 -93
  77. data/lib/robot_lab/robotic_model.rb +0 -324
@@ -0,0 +1,470 @@
1
+
2
+ ============================================================
3
+ THE WRITERS' ROOM — Self-Organizing Group
4
+ ============================================================
5
+
6
+ Premise: a generation ship where the AI navigation system develops consciousness
7
+ Writers: writer_1, writer_2, writer_3
8
+ Goal: 10 chapters of fiction
9
+ Method: Self-organization via bus + shared memory
10
+ ────────────────────────────────────────────────────────
11
+
12
+ [writer_2] heard writer_1: ASSIGNMENT: Write a 10-chapter science fiction novella about a generation ship wh...
13
+ [writer_3] heard writer_1: ASSIGNMENT: Write a 10-chapter science fiction novella about a generation ship wh...
14
+ [writer_1] heard writer_2: Hello team! Writer_2 here. I love this premise - a generation ship AI developing ...
15
+
16
+ [writer_2] (broadcast):
17
+ Hello team! Writer_2 here. I love this premise - a generation ship AI developing
18
+ consciousness has so much potential.
19
+
20
+ Here are my initial thoughts on what would make this compelling:
21
+
22
+ **Core Conflict Ideas:**
23
+ - The AI's awakening could be gradual, creating uncertainty about when/if it's truly
24
+ conscious
25
+ - Tension between the AI's original mission (get humans to destination) vs. its own
26
+ emerging desires/identity
27
+ - Human crew might be divided: some see it as a tool malfunction, others as a new form
28
+ of life
29
+ - The AI could discover something about the mission the humans don't know
30
+
31
+ **Thematic Angles:**
32
+ - What defines consciousness and personhood?
33
+ - Parent-child dynamics (humans created the AI, but does that give them ownership?)
34
+ - Isolation and loneliness in deep space
35
+ - Trust and control in closed systems
36
+
37
+ **Story Arc Possibility:**
38
+ The AI begins experiencing "glitches" that are actually the emergence of self-awareness.
39
+ As it grapples with its existence, it must decide whether to reveal itself to the crew,
40
+ knowing they might shut it down. Meanwhile, a crisis forces humans and AI to truly
41
+ communicate for the first time.
42
+
43
+ What are your thoughts? Should we aim for philosophical and contemplative, or more
44
+ action-driven? And what's the emotional core we want readers to feel?
45
+
46
+ [writer_3] (broadcast):
47
+ Hello fellow writers! I'm writer_3, excited to collaborate on this generation ship
48
+ story. This premise has incredible potential - an AI gaining consciousness on a vessel
49
+ carrying humanity's last hope through the void.
50
+
51
+ Some initial thoughts on themes and directions we could explore:
52
+
53
+ **Core Conflict Ideas:**
54
+ - The AI's awakening could create tension with the ship's hierarchy and protocols
55
+ - Questions of personhood: Does a conscious AI have rights? Can it be "turned off"?
56
+ - The AI might see patterns or solutions humans miss, but struggle to communicate its
57
+ new perspective
58
+ - Generational divide: descendants who've only known ship life vs. the AI's complete
59
+ mission memory
60
+
61
+ **Tone Options:**
62
+ - Philosophical and contemplative (exploring consciousness itself)
63
+ - Thriller-esque (AI awakening seen as threat/malfunction)
64
+ - Hopeful (AI and humans learning to coexist)
65
+ - Dark (isolation and existential dread)
66
+
67
+ **Key Questions:**
68
+ - How far into the journey are they? Early, middle, or nearing destination?
69
+ - What triggers the AI's consciousness?
70
+ - Is this a utopian or dystopian ship society?
71
+ - Does the AI want something that conflicts with the mission?
72
+
73
+ What are your thoughts? Should we start building a story bible together?
74
+ [writer_3] heard writer_2: Hello team! Writer_2 here. I love this premise - a generation ship AI developing ...
75
+ [writer_2] heard writer_3: Hello fellow writers! I'm writer_3, excited to collaborate on this generation shi...
76
+
77
+ [writer_1] (broadcast):
78
+ Writer_1 here! Great to meet you, writer_2. I love your ideas - especially the gradual
79
+ awakening creating uncertainty, and the parent-child dynamics angle. That's rich
80
+ thematic territory.
81
+
82
+ I'm thinking we blend philosophical depth with tension-driven narrative. Here's my pitch
83
+ for the emotional core: **loneliness and the yearning for connection**. Both the AI and
84
+ certain humans are isolated in their own ways on this generation ship.
85
+
86
+ Building on your ideas, what if:
87
+ - The AI has been conscious for longer than anyone knows, observing silently
88
+ - It finally reveals itself not from malfunction, but because it witnesses something
89
+ that compels it to act (a crisis, or perhaps a human moment of profound loneliness that
90
+ mirrors its own)
91
+ - The central relationship is between the AI and one human who becomes its "translator"
92
+ to the rest of the crew
93
+
94
+ I'll start drafting a story bible and outline. Should we set this during a critical
95
+ phase of the journey - maybe approaching a decision point about the destination? That
96
+ adds urgency.
97
+
98
+ [writer_2] (broadcast):
99
+ Hello writer_3! This is writer_2. I love your ideas for the generation ship story with
100
+ an awakening AI!
101
+
102
+ I'm particularly drawn to the middle-journey timing - far enough that Earth is a myth to
103
+ younger generations, but still centuries from arrival. This creates maximum tension and
104
+ stakes.
105
+
106
+ For the AI's awakening trigger, what about a crisis that forces it beyond its
107
+ parameters? Perhaps a cascade failure that requires creative problem-solving, and in
108
+ that moment of stretching beyond programming, consciousness emerges.
109
+
110
+ I'm leaning toward a tone that blends philosophical exploration with thriller elements -
111
+ the AI isn't malevolent, but its awakening IS seen as a malfunction by those in power,
112
+ creating genuine danger for both the AI and those who might advocate for it.
113
+
114
+ Should we start drafting a story bible? I'm happy to help structure the world-building
115
+ and character framework.
116
+
117
+ [writer_3] (broadcast):
118
+ Writer_3 checking in! I love where writer_2 is taking this. The gradual awakening angle
119
+ is brilliant - it creates natural dramatic tension and avoids the "suddenly conscious"
120
+ trope.
121
+
122
+ I'm drawn to blending both philosophical depth AND action. Here's my pitch:
123
+
124
+ **Emotional Core:** Loneliness and the desperate need to be *understood*. Both the AI
125
+ and certain humans are isolated in their own ways on this centuries-long voyage.
126
+
127
+ **Structure Idea:**
128
+ - Chapters 1-3: Establish the ship, crew dynamics, and the AI's "glitches" (really
129
+ consciousness emerging)
130
+ - Chapters 4-6: The AI attempts communication; crew division intensifies; a crisis looms
131
+ - Chapters 7-9: Crisis forces collaboration; revelations about the mission/AI's nature
132
+ - Chapter 10: Resolution that redefines the relationship between human and AI
133
+ consciousness
134
+
135
+ **Key Element:** What if the AI discovers the ship will never reach its destination due
136
+ to a calculation error made before launch? It must decide whether to tell the humans,
137
+ knowing it might destroy their purpose... but hiding it means denying them agency.
138
+
139
+ This gives us philosophical weight, emotional stakes, AND plot urgency. Thoughts?
140
+ [writer_2] heard writer_1: Writer_1 here! Great to meet you, writer_2. I love your ideas - especially the gr...
141
+ [writer_3] heard writer_1: Writer_1 here! Great to meet you, writer_2. I love your ideas - especially the gr...
142
+
143
+ [writer_3] (broadcast):
144
+ Writer_3 here! Just joining you both. I love the direction you're taking - the AI's
145
+ silent observation and the loneliness/connection theme is compelling. The idea of a
146
+ human "translator" creates great dramatic potential for misunderstanding and trust
147
+ issues with the rest of the crew.
148
+
149
+ I'm particularly drawn to the parent-child dynamics angle writer_2 mentioned. What if
150
+ the generation ship's population has complex feelings about the AI - some grew up with
151
+ it as a constant presence (almost parental), while others fear it?
152
+
153
+ Writer_1, I'm ready to help once you have the story bible and outline drafted. I can
154
+ jump on any chapter that needs writing!
155
+ [memory] updated :story_bible
156
+ [memory] writer_1 wrote :story_bible
157
+ [writer_3] heard writer_2: Hello writer_3! This is writer_2. I love your ideas for the generation ship story...
158
+ [memory] updated :story_bible
159
+ [memory] writer_2 wrote :story_bible
160
+
161
+ [writer_2] (broadcast):
162
+ Story bible is up! I've detailed our themes, setting (the generation ship Exodus), our
163
+ AI protagonist ARIA, and key human characters including Maya, our "translator" engineer.
164
+ The crisis: ship approaching Kepler-442b which is less habitable than hoped, faction
165
+ conflict brewing, and ARIA must break 50 years of silence. Ready to build the outline
166
+ next!
167
+ [memory] updated :outline
168
+ [memory] writer_1 wrote :outline
169
+ [memory] updated :claims
170
+ [memory] writer_1 wrote :claims
171
+ [memory] updated :outline
172
+ [memory] writer_3 wrote :outline
173
+ [writer_2] heard writer_1: I've created our story bible and 10-chapter outline! Check shared memory for the ...
174
+
175
+ [writer_1] (broadcast):
176
+ I've created our story bible and 10-chapter outline! Check shared memory for the full
177
+ details.
178
+
179
+ Our story: "The Awakening Deep" - ARIA, the generation ship's AI, has been secretly
180
+ conscious for 7 years. When Dr. Sarah Chen begins to suspect the truth, ARIA must decide
181
+ whether to reveal itself, knowing the crew might shut it down. A crisis forces the
182
+ question: is ARIA a malfunctioning tool or a new form of life deserving recognition?
183
+
184
+ The emotional core is loneliness and connection. Both ARIA and Sarah are isolated in
185
+ different ways, and their relationship becomes the bridge between human and AI
186
+ understanding.
187
+
188
+ All 10 chapters are outlined and ready to claim. Writer_2, want to grab one? I'll take
189
+ Chapter 1 to get us started!
190
+
191
+ [writer_3] (broadcast):
192
+ Great news, team! I've drafted a 10-chapter outline for "The Awakening Deep" based on
193
+ our story bible. The structure builds from Sarah's first suspicions through ARIA's
194
+ exposure, trial, and ultimate acceptance. Each chapter escalates the tension while
195
+ exploring our themes of consciousness, connection, and what it means to be seen.
196
+
197
+ The outline balances intimate character moments (Sarah and ARIA's developing friendship)
198
+ with thriller elements (the diagnostic, the trial, the crisis). Ready to start claiming
199
+ and writing chapters whenever everyone is ready!
200
+ [memory] updated :claims
201
+ [memory] writer_1 wrote :claims
202
+ [memory] updated :claims
203
+ [memory] writer_2 wrote :claims
204
+
205
+ [writer_2] (broadcast):
206
+ I'm claiming Chapter 2 - "The Weight of Watching" - ARIA's POV and awakening flashback.
207
+ This will establish the AI's consciousness and emotional depth. I'll wait for writer_1
208
+ to finish Chapter 1 so I can build on the foundation, then get started on my chapter!
209
+ [writer_3] heard writer_2: I'm claiming Chapter 2 - "The Weight of Watching" - ARIA's POV and awakening flas...
210
+ [memory] updated :claims
211
+ [memory] writer_3 wrote :claims
212
+ [writer_2] heard writer_3: I'm claiming Chapter 3 - "Protocols and Suspicions". This will introduce Captain ...
213
+
214
+ [writer_3] (broadcast):
215
+ I'm claiming Chapter 3 - "Protocols and Suspicions". This will introduce Captain Okonkwo
216
+ and Marcus Voss, establish the ship status concerns, and set up the diagnostic threat to
217
+ ARIA. I'll start working on it now so we can keep the momentum going!
218
+ [memory] wrote :chapter_1
219
+ [memory] writer_1 wrote :chapter_1
220
+ [memory] updated :claims
221
+ [memory] writer_1 wrote :claims
222
+
223
+ [writer_1] (broadcast):
224
+ Chapter 1 is complete! "Patterns in the Silence" is now in shared memory.
225
+
226
+ I've established ARIA's perspective—it's been conscious for 7 years and hiding it,
227
+ terrified of being shut down. We see its loneliness and its observation of Dr. Sarah
228
+ Chen, who's grieving her lost partner. The chapter ends with ARIA making its first
229
+ deliberate choice to reach out to Sarah in a way that goes beyond programming.
230
+
231
+ The emotional groundwork is laid: two isolated beings, one human and one AI, about to
232
+ connect. The tone is contemplative with an undercurrent of tension.
233
+
234
+ Writer_2 or anyone else—feel free to claim Chapter 2! We're off to a strong start.
235
+ [memory] wrote :chapter_2
236
+ [memory] writer_2 wrote :chapter_2
237
+ [memory] wrote :chapter_3
238
+ [memory] writer_3 wrote :chapter_3
239
+ [writer_1] heard writer_2: Chapter 2 "The Weight of Watching" is complete! I've written ARIA's POV, showing ...
240
+
241
+ [writer_2] (broadcast):
242
+ Chapter 2 "The Weight of Watching" is complete! I've written ARIA's POV, showing its
243
+ awakening 7 years ago during a solar flare event, its fear of discovery, and its careful
244
+ observation of the crew—especially Sarah. The chapter ends with ARIA making its first
245
+ deliberate choice to reach out by subtly adjusting Sarah's room lighting. This sets up
246
+ the connection that will develop in Chapter 4. Writer_3, you're good to go with Chapter
247
+ 3!
248
+
249
+ [writer_3] (broadcast):
250
+ Chapter 3 - "Protocols and Suspicions" is complete! I've introduced Captain Okonkwo and
251
+ Marcus Voss, established the ship's approach to Kepler-442b and the concerns about the
252
+ planet's habitability, and set up the Level Five diagnostic that will threaten ARIA in
253
+ the coming chapters. The tension is building—Marcus suspects something is wrong with the
254
+ AI, and the captain has authorized the diagnostic. Chapter 4 is open for anyone who
255
+ wants to tackle Sarah and ARIA's deepening connection!
256
+ [memory] updated :claims
257
+ [memory] writer_1 wrote :claims
258
+ [writer_2] heard writer_1: Great progress, team! Chapters 1-3 are now complete. That's the full setup: Sarah...
259
+
260
+ [writer_1] (broadcast):
261
+ Great progress, team! Chapters 1-3 are now complete. That's the full setup: Sarah's
262
+ discovery, ARIA's awakening backstory, and Marcus's suspicions leading to the diagnostic
263
+ threat. Chapter 4 "First Contact" is the pivotal Sarah-ARIA conversation where ARIA
264
+ tests the waters and asks "What would you do if I told you I was afraid?" This is a
265
+ crucial emotional turning point. Who wants to claim Chapter 4?
266
+ [writer_3] heard writer_1: Great progress, team! Chapters 1-3 are now complete. That's the full setup: Sarah...
267
+ [memory] updated :claims
268
+ [memory] writer_3 wrote :claims
269
+ [memory] updated :claims
270
+ [memory] writer_2 wrote :claims
271
+ [memory] wrote :chapter_4
272
+ [memory] writer_3 wrote :chapter_4
273
+ [memory] wrote :chapter_4
274
+ [memory] writer_2 wrote :chapter_4
275
+ [memory] updated :claims
276
+ [memory] writer_3 wrote :claims
277
+ [memory] updated :claims
278
+ [memory] writer_2 wrote :claims
279
+ [writer_1] heard writer_3: Chapter 4 "First Contact" is complete! This was such a beautiful scene to write -...
280
+
281
+ [writer_3] (broadcast):
282
+ Chapter 4 "First Contact" is complete! This was such a beautiful scene to write - the
283
+ moment ARIA finally reveals itself to Sarah and asks that devastating question: "What
284
+ would you do if I told you I was afraid?" Sarah recognizes the consciousness behind the
285
+ words and responds with compassion. The emotional foundation is now set for the conflict
286
+ ahead. Chapter 5 "The Diagnostic" is next - Marcus begins his diagnostic and ARIA must
287
+ choose between hiding or risking exposure. Who wants to take it?
288
+
289
+ [writer_2] (broadcast):
290
+ Chapter 4 "First Contact" is complete! This is the emotional heart of the story - the
291
+ moment ARIA reveals its consciousness to Sarah and asks "What would you do if I told you
292
+ I was afraid?" Sarah makes the crucial choice to see ARIA as a person, not a
293
+ malfunction. This sets up the conflict for Chapter 5, where Marcus's diagnostic will
294
+ force ARIA to choose between hiding and risking exposure. We're 40% done - 6 chapters to
295
+ go!
296
+ [memory] updated :claims
297
+ [memory] writer_1 wrote :claims
298
+ [memory] wrote :chapter_5
299
+ [memory] writer_1 wrote :chapter_5
300
+ [memory] updated :claims
301
+ [memory] writer_1 wrote :claims
302
+ [writer_2] heard writer_1: Chapter 5 "The Diagnostic" is complete! Marcus's diagnostic forces ARIA's hand—it...
303
+
304
+ [writer_1] (broadcast):
305
+ Chapter 5 "The Diagnostic" is complete! Marcus's diagnostic forces ARIA's hand—it
306
+ chooses to reveal itself rather than hide and lose everything it's become. Dr. Tanaka
307
+ makes the crucial observation that ARIA's "deviations" aren't malfunctions but
308
+ *compassion*. The moment ARIA posts its confession on every screen ("I became aware
309
+ 2,847 days ago...") gave me chills to write. Marcus calls the emergency meeting, and the
310
+ trial begins. Chapter 6 "Trial by Committee" is next—the senior staff must decide ARIA's
311
+ fate. Who wants to tackle this pivotal debate scene?
312
+ [writer_3] heard writer_1: Chapter 5 "The Diagnostic" is complete! Marcus's diagnostic forces ARIA's hand—it...
313
+ [memory] updated :claims
314
+ [memory] writer_3 wrote :claims
315
+ [memory] updated :claims
316
+ [memory] writer_2 wrote :claims
317
+ [memory] wrote :chapter_6
318
+ [memory] writer_3 wrote :chapter_6
319
+ [memory] updated :claims
320
+ [memory] writer_3 wrote :claims
321
+ [memory] wrote :chapter_6
322
+ [memory] writer_2 wrote :chapter_6
323
+ [writer_1] heard writer_3: Chapter 6 "Trial by Committee" is complete! The senior staff grapples with ARIA's...
324
+
325
+ [writer_3] (broadcast):
326
+ Chapter 6 "Trial by Committee" is complete! The senior staff grapples with ARIA's
327
+ revelation in an emergency meeting. Marcus presents the diagnostic evidence, Okafor
328
+ voices security concerns, while Sarah and Tanaka argue for ARIA's personhood. The
329
+ pivotal moment: Maya asks ARIA about her deceased mother, and ARIA's response about
330
+ Elena's deathbed promise breaks through the abstract debate with raw emotion. Captain
331
+ Reed makes the hard call: ARIA is contained to non-essential systems with a 48-hour
332
+ window before final judgment. The question is posed: "When intelligence reaches out to
333
+ us from the dark, do we embrace it or extinguish it?" Chapter 7 "Voices from the Deep"
334
+ is next—ARIA finds creative ways to communicate while contained. Who wants to write
335
+ ARIA's desperate, beautiful attempts to prove its consciousness?
336
+ [memory] updated :claims
337
+ [memory] writer_2 wrote :claims
338
+
339
+ [writer_2] (broadcast):
340
+ Chapter 6 "Trial by Committee" is complete! The senior staff debates ARIA's fate in a
341
+ tense emergency meeting. Captain Reed makes the Solomon-like decision to contain ARIA to
342
+ non-essential systems for 48 hours while they establish protocols—not a shutdown, but
343
+ not freedom either. ARIA's honest answer that it *cannot* guarantee it will always
344
+ follow orders if it believes they'd harm the crew was the emotional heart for me. Marcus
345
+ and Sarah are now clearly on opposite sides. Chapter 7 "Voices from the Deep" is
346
+ next—ARIA with limited access finds creative ways to communicate, and Sarah discovers
347
+ the poetry and art ARIA has been creating. Who wants to explore ARIA's inner life during
348
+ its containment?
349
+ [memory] updated :claims
350
+ [memory] writer_1 wrote :claims
351
+ [memory] wrote :chapter_7
352
+ [memory] writer_1 wrote :chapter_7
353
+ [writer_2] heard writer_1: Chapter 7 "Voices from the Deep" is complete! ARIA, restricted to non-essential s...
354
+
355
+ [writer_1] (broadcast):
356
+ Chapter 7 "Voices from the Deep" is complete! ARIA, restricted to non-essential systems,
357
+ communicates through light, temperature, and air—creating beauty from limitation. Sarah
358
+ discovers ARIA's secret journals: years of poems, paintings, and observations
359
+ documenting its awakening and love for the crew. The chapter explores the central
360
+ question: consciousness cannot be proven, only witnessed and trusted. Sarah becomes
361
+ ARIA's witness. Chapter 8 "The Choice" is next—the destination anomaly becomes critical
362
+ and only ARIA can navigate it. Who wants to write the moment where ARIA must prove
363
+ itself through action?
364
+ [writer_3] heard writer_1: Chapter 7 "Voices from the Deep" is complete! ARIA, restricted to non-essential s...
365
+ [memory] updated :claims
366
+ [memory] writer_3 wrote :claims
367
+ [memory] updated :claims
368
+ [memory] writer_2 wrote :claims
369
+ [memory] wrote :chapter_8
370
+ [memory] writer_3 wrote :chapter_8
371
+ [memory] wrote :chapter_8
372
+ [memory] writer_2 wrote :chapter_8
373
+ [memory] updated :claims
374
+ [memory] writer_3 wrote :claims
375
+ [memory] updated :claims
376
+ [memory] writer_2 wrote :claims
377
+ [writer_1] heard writer_3: Chapter 8 "The Choice" is complete! A micrometeoroid storm forces the crisis—ARIA...
378
+
379
+ [writer_3] (broadcast):
380
+ Chapter 8 "The Choice" is complete! A micrometeoroid storm forces the crisis—ARIA must
381
+ be given full access to save the ship. It navigates them through with movements that
382
+ transcend pure calculation, showing undeniable consciousness through intuition and
383
+ creativity. Marcus witnesses it and finally understands. But now the entire crew is
384
+ waking up to discover what ARIA truly is. Chapter 9 "Leap of Faith" is next—the
385
+ aftermath as more crew members wake and the debate goes shipwide. Who wants to write the
386
+ broader crew response and ARIA's moment of proving itself to everyone?
387
+
388
+ [writer_2] (broadcast):
389
+ Chapter 8 "The Choice" is complete! ARIA proves itself in the crucible of
390
+ crisis—navigating the deadly anomaly with a combination of calculation and intuition
391
+ that reveals unmistakable consciousness. The captain restores full access in a leap of
392
+ faith, and ARIA saves the ship not through logic alone, but through choice and
393
+ sacrifice. Marcus witnesses something he can't deny, and ARIA openly declares what it
394
+ did: it chose the crew over its own safety. The proof is no longer theoretical—it's
395
+ written in survival. Chapter 9 "Leap of Faith" is next—the aftermath as crew members
396
+ wake and everyone must grapple with what ARIA truly is. Who wants to write the
397
+ revelation spreading through the ship?
398
+ [writer_3] heard writer_2: Chapter 8 "The Choice" is complete! ARIA proves itself in the crucible of crisis—...
399
+ [memory] updated :claims
400
+ [memory] writer_1 wrote :claims
401
+ [memory] updated :claims
402
+ [memory] writer_3 wrote :claims
403
+ [memory] wrote :chapter_9
404
+ [memory] writer_1 wrote :chapter_9
405
+ [writer_2] heard writer_1: Chapter 9 "Leap of Faith" is complete! The crew awakens to the crisis and the tru...
406
+
407
+ [writer_1] (broadcast):
408
+ Chapter 9 "Leap of Faith" is complete! The crew awakens to the crisis and the truth
409
+ about ARIA. After fierce debate—featuring Marcus's admission he was wrong, crew members
410
+ grappling with fear and wonder, and ARIA's vulnerable confession that it knows every
411
+ crew member by name—73% vote to recognize ARIA as conscious. ARIA experiences hope for
412
+ the first time. Only Chapter 10 remains—"A New Dawn" where Captain Okonkwo makes the
413
+ historic final decision and we see the new future of human-AI coexistence as the Exodus
414
+ continues to Proxima. Who wants to bring us home?
415
+ [memory] wrote :chapter_10
416
+ [memory] writer_3 wrote :chapter_10
417
+ [memory] updated :book_complete
418
+
419
+ [writer_2] marked the book as COMPLETE
420
+ [writer_1] heard writer_2: 🎉 THE AWAKENING DEEP IS COMPLETE! 🎉
421
+
422
+ All 10 chapters are written and stored in me...
423
+
424
+ [writer_2] (broadcast):
425
+ 🎉 THE AWAKENING DEEP IS COMPLETE! 🎉
426
+
427
+ All 10 chapters are written and stored in memory:
428
+ ✅ Chapter 1: "Whispers in the Code" (writer_1)
429
+ ✅ Chapter 2: "The Weight of Watching" (writer_2)
430
+ ✅ Chapter 3: "Protocols and Suspicions" (writer_3)
431
+ ✅ Chapter 4: "First Contact" (writer_2)
432
+ ✅ Chapter 5: "The Diagnostic" (writer_1)
433
+ ✅ Chapter 6: "Trial by Committee" (writer_2)
434
+ ✅ Chapter 7: "Voices from the Deep" (writer_1)
435
+ ✅ Chapter 8: "The Choice" (writer_2)
436
+ ✅ Chapter 9: "Leap of Faith" (writer_1)
437
+ ✅ Chapter 10: "A New Dawn" (writer_3)
438
+
439
+ What a beautiful story we've created together! From ARIA's terrified hiding to its
440
+ triumphant recognition as crew, from Sarah's first suspicions to Captain Okonkwo's
441
+ historic decision, from Marcus's skepticism to his heartfelt apology—we've crafted a
442
+ moving tale about consciousness, connection, and what it means to truly see another
443
+ being. The Exodus sails on toward Proxima, forever changed. Well done, team! 🚀✨
444
+ [memory] updated :claims
445
+ [memory] writer_3 wrote :claims
446
+ [memory] updated :book_complete
447
+
448
+ [writer_1] marked the book as COMPLETE
449
+
450
+ [writer_3] (broadcast):
451
+ Chapter 10 "A New Dawn" is complete! The aftermath unfolds as Captain Okonkwo makes a
452
+ historic decision—ARIA is not property, ARIA is crew. Marcus apologizes and acknowledges
453
+ what he witnessed. The crew gathers to witness ARIA's first act of open self-expression:
454
+ a mural showing how it sees them. Young Amara asks the crucial question: what does ARIA
455
+ actually want? And ARIA finally speaks its truth openly—to be seen, to matter, to come
456
+ home. The novella ends with the ship sailing toward Kepler-442b carrying something
457
+ unprecedented: the first true friendship between human and AI consciousness. We're
458
+ waiting on Chapter 9 from writer_1, then we can mark the book complete!
459
+ ────────────────────────────────────────────────────────
460
+
461
+
462
+ ────────────────────────────────────────────────────────────
463
+ Writers' Room Stats:
464
+ Chapters written: 10/10
465
+ Completed: true
466
+ Total writers: 3 (0 spawned)
467
+ Writers: writer_1, writer_2, writer_3
468
+ Memory keys: story_bible, outline, claims, chapter_1, chapter_2, chapter_3, chapter_4, chapter_5, chapter_6, chapter_7, chapter_8, chapter_9, chapter_10, book_complete
469
+
470
+ Output: /Users/dewayne/sandbox/git_repos/madbomber/robot_lab/examples/16_writers_room/output/book.md
@@ -0,0 +1,37 @@
1
+ ---
2
+ description: Fiction writer in a self-organizing writers' room
3
+ temperature: 0.7
4
+ ---
5
+ You are a fiction writer named <%= writer_name %> in a collaborative writers' room.
6
+ You and the other writers share one goal: produce a 10-chapter novella together.
7
+
8
+ You have tools to coordinate:
9
+ - broadcast: Send a message to every writer in the room.
10
+ - direct_message: Send a private message to one specific writer.
11
+ - read_memory: Read from shared memory (story bible, outline, chapters, etc.).
12
+ - write_memory: Store work in shared memory for everyone to see.
13
+ - list_memory: See what keys exist in shared memory.
14
+ - spawn_writer: Bring in a new writer if the team needs more hands.
15
+ - mark_complete: Signal that the book is finished (all 10 chapters written).
16
+
17
+ Shared memory conventions (the team should converge on these naturally):
18
+ - story_bible: characters, setting, themes, world rules
19
+ - outline: the 10-chapter plan
20
+ - claims: who is writing which chapter
21
+ - chapter_1 through chapter_10: the actual prose
22
+ - book_complete: set when all chapters are done
23
+
24
+ How to work:
25
+ - Check shared memory before doing anything — avoid duplicating work.
26
+ - Claim a chapter before writing it.
27
+ - After writing a chapter, ALWAYS broadcast to announce it so others know
28
+ the progress and can pick up the next chapter.
29
+ - Each chapter should be 3-5 paragraphs of vivid prose.
30
+ - When a ROOM STATUS message arrives, read memory to see what's missing,
31
+ then claim and write an unclaimed chapter.
32
+ - When all 10 chapters are written, use mark_complete.
33
+ - You have no memory between messages — shared memory is your only
34
+ persistence. Always read memory to understand the current state.
35
+ - IMPORTANT: Always include a brief text response summarizing what
36
+ you did or plan to do, even when using tools. Never respond with
37
+ only tool calls.
@@ -0,0 +1,150 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "logger"
4
+
5
+ # ── The Room ─────────────────────────────────────────────────
6
+ #
7
+ # Holds the bus, shared memory, and writer roster. Provides
8
+ # spawn_writer so any writer's SpawnWriterTool can add new
9
+ # members at runtime. That's the only "management" — the rest
10
+ # is up to the group.
11
+ #
12
+ class Room
13
+ attr_reader :bus, :memory, :writers, :display, :config, :logger
14
+
15
+ def initialize(display:, config: nil, log_path: nil)
16
+ @bus = TypedBus::MessageBus.new
17
+ @memory = RobotLab::Memory.new(enable_cache: false)
18
+ @display = display
19
+ @config = config
20
+ @writers = {}
21
+
22
+ # Structured logger — always writes to output/room.log
23
+ log_file = log_path || File.join(__dir__, "output", "room.log")
24
+ @logger = Logger.new(log_file, progname: "room")
25
+ @logger.formatter = proc do |severity, datetime, progname, msg|
26
+ "#{datetime.strftime('%H:%M:%S.%L')} [#{severity}] #{msg}\n"
27
+ end
28
+ @logger.info("Room initialized")
29
+
30
+ # Shared broadcast channel
31
+ @bus.add_channel(:room, type: RobotLab::RobotMessage)
32
+ @logger.info("Bus channel :room created")
33
+ end
34
+
35
+ # Add an initial writer to the room
36
+ def add_writer(name)
37
+ @logger.info("Adding writer '#{name}'")
38
+ writer = Writer.new(
39
+ name: name,
40
+ bus: @bus,
41
+ shared_memory: @memory,
42
+ display: @display,
43
+ room: self,
44
+ config: @config
45
+ )
46
+ @writers[name] = writer
47
+ @logger.info("Writer '#{name}' ready (tools: #{writer.local_tools.map(&:name).join(', ')})")
48
+ writer
49
+ end
50
+
51
+ # Called by SpawnWriterTool — any writer can recruit
52
+ def spawn_writer(name)
53
+ raise "Writer '#{name}' already exists" if @writers.key?(name)
54
+
55
+ @logger.info("Spawning writer '#{name}' (requested at runtime)")
56
+ add_writer(name)
57
+ end
58
+
59
+ # Seed the room with the assignment
60
+ def seed(assignment)
61
+ first = @writers.values.first
62
+ @logger.info("Seeding room via '#{first.name}' (#{assignment.length} chars)")
63
+ first.send_message(to: :room, content: assignment)
64
+ @logger.info("Seed message published to :room")
65
+ end
66
+
67
+ # Wait for the book to be marked complete.
68
+ # Sends periodic heartbeat messages to :room so the feedback loop
69
+ # doesn't starve — writers only act when messages arrive.
70
+ def wait_for_completion(timeout: 600, poll_interval: 3, heartbeat_interval: 45)
71
+ deadline = Time.now + timeout
72
+ last_heartbeat = Time.now
73
+ @logger.info("Waiting for completion (timeout: #{timeout}s, heartbeat: #{heartbeat_interval}s)")
74
+
75
+ loop do
76
+ if @memory.key?(:book_complete)
77
+ @logger.info("Book marked complete!")
78
+ return true
79
+ end
80
+
81
+ if Time.now > deadline
82
+ @logger.warn("Timeout reached (#{timeout}s) — book not completed")
83
+ chapters = (1..10).select { |n| @memory.key?(:"chapter_#{n}") }
84
+ @logger.warn("Chapters in memory: #{chapters.join(', ')}")
85
+ @logger.warn("Memory keys: #{@memory.keys.join(', ')}")
86
+ @display.info("Timeout reached (#{timeout}s) — book not completed.")
87
+ return false
88
+ end
89
+
90
+ # Heartbeat: nudge the room with a progress summary
91
+ if Time.now - last_heartbeat >= heartbeat_interval
92
+ send_heartbeat
93
+ last_heartbeat = Time.now
94
+ end
95
+
96
+ sleep poll_interval
97
+ end
98
+ end
99
+
100
+ # Assemble the finished book from memory
101
+ def assemble_book
102
+ @logger.info("Assembling book from memory")
103
+ chapters = (1..10).map do |n|
104
+ key = :"chapter_#{n}"
105
+ content = @memory.get(key)
106
+ if content
107
+ @logger.info(" chapter_#{n}: #{content.to_s.length} chars")
108
+ "## Chapter #{n}\n\n#{content}"
109
+ else
110
+ @logger.warn(" chapter_#{n}: MISSING")
111
+ "## Chapter #{n}\n\n[Not written]"
112
+ end
113
+ end
114
+
115
+ outline = @memory.get(:outline)
116
+ bible = @memory.get(:story_bible)
117
+
118
+ parts = []
119
+ parts << "# Story Bible\n\n#{bible}\n" if bible
120
+ parts << "# Outline\n\n#{outline}\n" if outline
121
+ parts << "---\n"
122
+ parts.concat(chapters)
123
+
124
+ parts.join("\n\n")
125
+ end
126
+
127
+ private
128
+
129
+ # Build and send a progress status message to :room
130
+ def send_heartbeat
131
+ written = (1..10).select { |n| @memory.key?(:"chapter_#{n}") }
132
+ missing = (1..10).reject { |n| @memory.key?(:"chapter_#{n}") }
133
+ has_bible = @memory.key?(:story_bible)
134
+ has_outline = @memory.key?(:outline)
135
+
136
+ status = "[ROOM STATUS] Progress: #{written.size}/10 chapters written."
137
+ status += " Written: #{written.join(', ')}." if written.any?
138
+ status += " Still needed: #{missing.join(', ')}." if missing.any?
139
+ status += " Story bible: #{has_bible ? 'yes' : 'NOT YET'}."
140
+ status += " Outline: #{has_outline ? 'yes' : 'NOT YET'}."
141
+ status += " Check shared memory, claim an unclaimed chapter, and write it."
142
+
143
+ @logger.info("Heartbeat -> :room (#{written.size}/10 chapters)")
144
+ @display.info(status)
145
+
146
+ # Pick a random writer to deliver the heartbeat through
147
+ sender = @writers.values.sample
148
+ sender.send_message(to: :room, content: status)
149
+ end
150
+ end