bub 0.6.0a2__tar.gz → 0.6.1__tar.gz

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 (146) hide show
  1. {bub-0.6.0a2 → bub-0.6.1}/PKG-INFO +29 -42
  2. bub-0.6.1/README.md +70 -0
  3. {bub-0.6.0a2 → bub-0.6.1}/pyproject.toml +1 -1
  4. {bub-0.6.0a2 → bub-0.6.1}/src/bub/_version.py +2 -2
  5. bub-0.6.1/src/bub/application.py +35 -0
  6. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/agent.py +48 -48
  7. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/cli.py +29 -1
  8. bub-0.6.1/src/bub/builtin/codemode/__init__.py +103 -0
  9. bub-0.6.1/src/bub/builtin/commands.py +8 -0
  10. bub-0.6.1/src/bub/builtin/context.py +8 -0
  11. bub-0.6.1/src/bub/builtin/environment.py +25 -0
  12. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/hook_impl.py +26 -39
  13. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/model.py +31 -1
  14. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/settings.py +20 -0
  15. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/shell_manager.py +7 -3
  16. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/store.py +1 -1
  17. bub-0.6.1/src/bub/builtin/subagents.py +833 -0
  18. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/tools.py +81 -82
  19. {bub-0.6.0a2 → bub-0.6.1}/src/bub/channels/cli/__init__.py +103 -20
  20. {bub-0.6.0a2 → bub-0.6.1}/src/bub/channels/cli/terminal_output.py +8 -6
  21. {bub-0.6.0a2 → bub-0.6.1}/src/bub/channels/manager.py +82 -11
  22. {bub-0.6.0a2 → bub-0.6.1}/src/bub/core/__init__.py +2 -0
  23. {bub-0.6.0a2 → bub-0.6.1}/src/bub/core/agent.py +96 -43
  24. bub-0.6.1/src/bub/core/codemode/__init__.py +306 -0
  25. {bub-0.6.0a2/src/bub/builtin → bub-0.6.1/src/bub/core}/codemode/republic_bridge.py +32 -22
  26. bub-0.6.0a2/src/bub/builtin/codemode/code_runner.py → bub-0.6.1/src/bub/core/codemode/runner.py +3 -3
  27. bub-0.6.0a2/src/bub/builtin/codemode/__init__.py → bub-0.6.1/src/bub/core/codemode/stub.py +5 -202
  28. {bub-0.6.0a2 → bub-0.6.1}/src/bub/core/context.py +1 -1
  29. {bub-0.6.0a2 → bub-0.6.1}/src/bub/core/events.py +44 -11
  30. {bub-0.6.0a2 → bub-0.6.1}/src/bub/core/model.py +1 -1
  31. {bub-0.6.0a2 → bub-0.6.1}/src/bub/core/system_prompt.py +7 -7
  32. {bub-0.6.0a2 → bub-0.6.1}/src/bub/core/tape.py +13 -3
  33. {bub-0.6.0a2 → bub-0.6.1}/src/bub/core/tools.py +84 -38
  34. {bub-0.6.0a2 → bub-0.6.1}/src/bub/environment.py +125 -4
  35. {bub-0.6.0a2 → bub-0.6.1}/src/bub/framework.py +136 -12
  36. bub-0.6.1/src/bub/hooks/agent.py +142 -0
  37. {bub-0.6.0a2 → bub-0.6.1}/src/bub/hooks/interception.py +8 -0
  38. {bub-0.6.0a2 → bub-0.6.1}/src/bub/hooks/specs.py +7 -1
  39. bub-0.6.1/src/bub/inquirer.py +96 -0
  40. bub-0.6.1/src/bub/program_status.py +36 -0
  41. bub-0.6.1/src/bub/sidecars.py +8 -0
  42. bub-0.6.1/src/bub/store.py +8 -0
  43. {bub-0.6.0a2 → bub-0.6.1}/src/bub/streaming.py +9 -2
  44. bub-0.6.1/src/bub/tape.py +8 -0
  45. bub-0.6.1/src/bub/tools.py +8 -0
  46. {bub-0.6.0a2 → bub-0.6.1}/src/bub/utils.py +1 -1
  47. {bub-0.6.0a2 → bub-0.6.1}/tests/model_fakes.py +4 -5
  48. {bub-0.6.0a2 → bub-0.6.1}/tests/test_agent_hooks.py +1 -1
  49. bub-0.6.1/tests/test_agent_plugins.py +146 -0
  50. {bub-0.6.0a2 → bub-0.6.1}/tests/test_builtin_agent.py +8 -10
  51. {bub-0.6.0a2 → bub-0.6.1}/tests/test_builtin_cli.py +135 -17
  52. {bub-0.6.0a2 → bub-0.6.1}/tests/test_builtin_hook_impl.py +35 -14
  53. {bub-0.6.0a2 → bub-0.6.1}/tests/test_builtin_tools.py +44 -34
  54. {bub-0.6.0a2 → bub-0.6.1}/tests/test_channels.py +159 -46
  55. {bub-0.6.0a2 → bub-0.6.1}/tests/test_codemode.py +4 -6
  56. bub-0.6.1/tests/test_compat_aliases.py +39 -0
  57. {bub-0.6.0a2 → bub-0.6.1}/tests/test_core_agent.py +100 -2
  58. {bub-0.6.0a2 → bub-0.6.1}/tests/test_core_agent_step.py +89 -2
  59. bub-0.6.1/tests/test_core_codemode.py +141 -0
  60. {bub-0.6.0a2 → bub-0.6.1}/tests/test_environment.py +13 -2
  61. bub-0.6.1/tests/test_file_tape_store_search.py +86 -0
  62. {bub-0.6.0a2 → bub-0.6.1}/tests/test_framework.py +72 -0
  63. {bub-0.6.0a2 → bub-0.6.1}/tests/test_install_scripts.py +3 -3
  64. bub-0.6.1/tests/test_program_status.py +97 -0
  65. {bub-0.6.0a2 → bub-0.6.1}/tests/test_sdk_isolation.py +3 -1
  66. {bub-0.6.0a2 → bub-0.6.1}/tests/test_settings.py +72 -0
  67. {bub-0.6.0a2 → bub-0.6.1}/tests/test_shell_manager.py +26 -0
  68. {bub-0.6.0a2 → bub-0.6.1}/tests/test_spill.py +22 -38
  69. bub-0.6.1/tests/test_subagent_tool.py +560 -0
  70. {bub-0.6.0a2 → bub-0.6.1}/tests/test_tool_loading.py +31 -3
  71. {bub-0.6.0a2 → bub-0.6.1}/tests/test_tools.py +16 -21
  72. {bub-0.6.0a2 → bub-0.6.1}/tests/test_tracing.py +3 -1
  73. bub-0.6.1/tests/tool_fakes.py +10 -0
  74. bub-0.6.0a2/README.md +0 -83
  75. bub-0.6.0a2/src/bub/builtin/environment.py +0 -148
  76. bub-0.6.0a2/src/bub/inquirer.py +0 -86
  77. bub-0.6.0a2/tests/test_subagent_tool.py +0 -152
  78. {bub-0.6.0a2 → bub-0.6.1}/.gitignore +0 -0
  79. {bub-0.6.0a2 → bub-0.6.1}/LICENSE +0 -0
  80. {bub-0.6.0a2 → bub-0.6.1}/src/bub/__init__.py +0 -0
  81. {bub-0.6.0a2 → bub-0.6.1}/src/bub/__main__.py +0 -0
  82. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/__init__.py +0 -0
  83. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/archive.py +0 -0
  84. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/auth.py +0 -0
  85. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/onboarding.py +0 -0
  86. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/spill.py +0 -0
  87. {bub-0.6.0a2 → bub-0.6.1}/src/bub/builtin/steering.py +0 -0
  88. {bub-0.6.0a2 → bub-0.6.1}/src/bub/channels/__init__.py +0 -0
  89. {bub-0.6.0a2 → bub-0.6.1}/src/bub/channels/admission.py +0 -0
  90. {bub-0.6.0a2 → bub-0.6.1}/src/bub/channels/base.py +0 -0
  91. {bub-0.6.0a2 → bub-0.6.1}/src/bub/channels/cli/ansi_bridge.py +0 -0
  92. {bub-0.6.0a2 → bub-0.6.1}/src/bub/channels/cli/renderer.py +0 -0
  93. {bub-0.6.0a2 → bub-0.6.1}/src/bub/channels/cli/writers.py +0 -0
  94. {bub-0.6.0a2 → bub-0.6.1}/src/bub/channels/contracts.py +0 -0
  95. {bub-0.6.0a2 → bub-0.6.1}/src/bub/channels/handler.py +0 -0
  96. {bub-0.6.0a2 → bub-0.6.1}/src/bub/channels/message.py +0 -0
  97. {bub-0.6.0a2 → bub-0.6.1}/src/bub/channels/telegram.py +0 -0
  98. {bub-0.6.0a2 → bub-0.6.1}/src/bub/configure.py +0 -0
  99. /bub-0.6.0a2/src/bub/builtin/codemode/code_runner_child.py → /bub-0.6.1/src/bub/core/codemode/runner_child.py +0 -0
  100. {bub-0.6.0a2 → bub-0.6.1}/src/bub/core/commands.py +0 -0
  101. {bub-0.6.0a2 → bub-0.6.1}/src/bub/core/recorder.py +0 -0
  102. {bub-0.6.0a2 → bub-0.6.1}/src/bub/core/sidecars.py +0 -0
  103. {bub-0.6.0a2 → bub-0.6.1}/src/bub/core/store.py +0 -0
  104. {bub-0.6.0a2 → bub-0.6.1}/src/bub/envelope.py +0 -0
  105. {bub-0.6.0a2 → bub-0.6.1}/src/bub/errors.py +0 -0
  106. {bub-0.6.0a2 → bub-0.6.1}/src/bub/gateway_installer.py +0 -0
  107. {bub-0.6.0a2 → bub-0.6.1}/src/bub/hooks/__init__.py +0 -0
  108. {bub-0.6.0a2 → bub-0.6.1}/src/bub/hooks/runtime.py +0 -0
  109. {bub-0.6.0a2 → bub-0.6.1}/src/bub/model_selection.py +0 -0
  110. {bub-0.6.0a2 → bub-0.6.1}/src/bub/prompt.py +0 -0
  111. {bub-0.6.0a2 → bub-0.6.1}/src/bub/skills.py +0 -0
  112. {bub-0.6.0a2 → bub-0.6.1}/src/bub/tracing.py +0 -0
  113. {bub-0.6.0a2 → bub-0.6.1}/src/bub/turn.py +0 -0
  114. {bub-0.6.0a2 → bub-0.6.1}/src/skills/README.md +0 -0
  115. {bub-0.6.0a2 → bub-0.6.1}/src/skills/gh/SKILL.md +0 -0
  116. {bub-0.6.0a2 → bub-0.6.1}/src/skills/skill-creator/SKILL.md +0 -0
  117. {bub-0.6.0a2 → bub-0.6.1}/src/skills/skill-creator/license.txt +0 -0
  118. {bub-0.6.0a2 → bub-0.6.1}/src/skills/skill-creator/scripts/init_skill.py +0 -0
  119. {bub-0.6.0a2 → bub-0.6.1}/src/skills/skill-creator/scripts/quick_validate.py +0 -0
  120. {bub-0.6.0a2 → bub-0.6.1}/src/skills/telegram/SKILL.md +0 -0
  121. {bub-0.6.0a2 → bub-0.6.1}/src/skills/telegram/scripts/telegram_edit.py +0 -0
  122. {bub-0.6.0a2 → bub-0.6.1}/src/skills/telegram/scripts/telegram_rich.py +0 -0
  123. {bub-0.6.0a2 → bub-0.6.1}/src/skills/telegram/scripts/telegram_send.py +0 -0
  124. {bub-0.6.0a2 → bub-0.6.1}/tests/__init__.py +0 -0
  125. {bub-0.6.0a2 → bub-0.6.1}/tests/conftest.py +0 -0
  126. {bub-0.6.0a2 → bub-0.6.1}/tests/test_builtin_codex.py +0 -0
  127. {bub-0.6.0a2 → bub-0.6.1}/tests/test_cli_help.py +0 -0
  128. {bub-0.6.0a2 → bub-0.6.1}/tests/test_cli_main.py +0 -0
  129. {bub-0.6.0a2 → bub-0.6.1}/tests/test_cli_renderer.py +0 -0
  130. {bub-0.6.0a2 → bub-0.6.1}/tests/test_configure.py +0 -0
  131. {bub-0.6.0a2 → bub-0.6.1}/tests/test_core_boundary.py +0 -0
  132. {bub-0.6.0a2 → bub-0.6.1}/tests/test_envelope.py +0 -0
  133. {bub-0.6.0a2 → bub-0.6.1}/tests/test_errors.py +0 -0
  134. {bub-0.6.0a2 → bub-0.6.1}/tests/test_file_tape_store_entry_ids.py +0 -0
  135. {bub-0.6.0a2 → bub-0.6.1}/tests/test_fork_store_merge_back.py +0 -0
  136. {bub-0.6.0a2 → bub-0.6.1}/tests/test_gateway_installer.py +0 -0
  137. {bub-0.6.0a2 → bub-0.6.1}/tests/test_hook_runtime.py +0 -0
  138. {bub-0.6.0a2 → bub-0.6.1}/tests/test_image_message.py +0 -0
  139. {bub-0.6.0a2 → bub-0.6.1}/tests/test_onboarding.py +0 -0
  140. {bub-0.6.0a2 → bub-0.6.1}/tests/test_otlp.py +0 -0
  141. {bub-0.6.0a2 → bub-0.6.1}/tests/test_provider_messages.py +0 -0
  142. {bub-0.6.0a2 → bub-0.6.1}/tests/test_session_settings.py +0 -0
  143. {bub-0.6.0a2 → bub-0.6.1}/tests/test_skills.py +0 -0
  144. {bub-0.6.0a2 → bub-0.6.1}/tests/test_tape.py +0 -0
  145. {bub-0.6.0a2 → bub-0.6.1}/tests/test_tape_search_output.py +0 -0
  146. {bub-0.6.0a2 → bub-0.6.1}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: bub
3
- Version: 0.6.0a2
3
+ Version: 0.6.1
4
4
  Summary: A tiny agent runtime, composable with plugins.
5
5
  Project-URL: Homepage, https://bub.build
6
6
  Project-URL: Repository, https://github.com/bubbuild/bub
@@ -21,7 +21,7 @@ Requires-Dist: pydantic>=2.12.5
21
21
  Requires-Dist: republic>=0.6.0a1
22
22
  Requires-Dist: typing-extensions>=4.15.0
23
23
  Provides-Extra: app
24
- Requires-Dist: aiohttp>=3.14.3; extra == 'app'
24
+ Requires-Dist: aiohttp>=3.14.4; extra == 'app'
25
25
  Requires-Dist: httpx[socks]>=0.28.1; extra == 'app'
26
26
  Requires-Dist: inquirer-textual>=0.8.0; extra == 'app'
27
27
  Requires-Dist: pluggy>=1.6.0; extra == 'app'
@@ -33,7 +33,7 @@ Requires-Dist: rapidfuzz>=3.14.5; extra == 'app'
33
33
  Requires-Dist: rich>=14.3.4; extra == 'app'
34
34
  Requires-Dist: typer>=0.24.1; extra == 'app'
35
35
  Provides-Extra: logfire
36
- Requires-Dist: aiohttp>=3.14.3; extra == 'logfire'
36
+ Requires-Dist: aiohttp>=3.14.4; extra == 'logfire'
37
37
  Requires-Dist: httpx[socks]>=0.28.1; extra == 'logfire'
38
38
  Requires-Dist: inquirer-textual>=0.8.0; extra == 'logfire'
39
39
  Requires-Dist: logfire>=4.32.0; extra == 'logfire'
@@ -63,70 +63,57 @@ Description-Content-Type: text/markdown
63
63
  <img alt="Bub logo" src="https://raw.githubusercontent.com/bubbuild/bub/refs/heads/main/website/src/assets/bub-logo.png" width="200">
64
64
  </picture>
65
65
 
66
- <p><strong>A tiny agent runtime, composable with plugins.</strong></p>
66
+ <p><strong>Build your Bub.</strong></p>
67
67
 
68
68
  [Website](https://bub.build) · [Docs](https://bub.build/docs/getting-started/) · [Hub](https://hub.bub.build)
69
69
 
70
70
  </div>
71
71
 
72
- Bub is a small Python runtime for building agents in shared environments. It started in group chats, where multiple humans and agents had to work in the same conversation without hidden state, hand-wavy memory, or framework-specific magic.
72
+ Put an agent in your own Python program, or customize the Bub application. The application uses the same agent kernel and adds configuration, plugins, and channel integration.
73
73
 
74
- Built on [agents.md](https://agents.md/) and [Agent Skills](https://agentskills.io/), Bub stays intentionally small. Every turn stage is a [pluggy](https://pluggy.readthedocs.io/) hook, builtins are replaceable, and the same runtime drives CLI, Telegram, and any channel you add.
74
+ ## Build your own agent
75
75
 
76
- ## Quick Start
76
+ Use `bub.core.Agent` to choose your model, tools, instructions, and conversation storage. The base `bub` package installs the kernel's dependencies.
77
77
 
78
- macOS and Linux:
78
+ In a Python 3.12+ project:
79
79
 
80
80
  ```bash
81
- curl -fsSL https://bub.build/install.sh | bash
81
+ uv add bub
82
82
  ```
83
83
 
84
- Windows PowerShell:
84
+ Run your first agent with the [SDK guide](https://bub.build/docs/sdk/), then [serve it with FastAPI](https://bub.build/docs/sdk/web-service/) when you need an HTTP endpoint.
85
85
 
86
- ```powershell
87
- powershell -ExecutionPolicy ByPass -c "irm https://bub.build/install.ps1 | iex"
88
- ```
86
+ You can also embed `BubAgent` to reuse the application's settings and plugin hooks in your service. This uses `bub[app]`; [Reuse the Bub app](https://bub.build/docs/integrations/reuse-app/) explains the integration choices and their requirements.
89
87
 
90
- Then:
88
+ ## Customize the Bub app
91
89
 
92
- ```bash
93
- bub chat # interactive session
94
- bub run "summarize this repo" # one-shot task
95
- bub gateway # channel listener mode
96
- ```
90
+ Start a conversation, then add tools, skills, plugins, or channels for the work you want Bub to do.
97
91
 
98
- See [Getting Started](https://bub.build/docs/getting-started/) for installer presets and source installs, and [Configure](https://bub.build/docs/operate/configure/) for model and runtime settings.
92
+ Install on macOS or Linux:
99
93
 
100
- ## Why Bub
94
+ ```bash
95
+ curl -fsSL https://bub.build/install.sh | bash
96
+ ```
101
97
 
102
- - **Composable by design.** Every turn stage is a plugin hook. Override one stage or replace the whole flow without forking the runtime.
103
- - **Tape context.** Context is rebuilt from append-only records, not carried around as mutable session state. Easier to inspect, replay, and hand off.
104
- - **One runtime across surfaces.** The same inbound pipeline runs across CLI, Telegram, and custom channels. Adapters change the surface, not the runtime model.
105
- - **Batteries included.** CLI, Telegram, tools, skills, and model execution ship with the core runtime. Use the defaults first, replace them later.
106
- - **Operator equivalence.** Humans and agents work inside the same runtime boundaries, with the same evidence trail and handoff model.
107
- - **Embeddable Python SDK.** `pip install bub` installs only `bub.core`, which exposes the agent loop on its own (the CLI, channels and plugins come with `bub[app]`) — bring your own model, tools, prompts, and tape store, with no settings or plugins required.
98
+ On Windows:
108
99
 
109
- ## How It Works
100
+ ```powershell
101
+ powershell -ExecutionPolicy ByPass -c "irm https://bub.build/install.ps1 | iex"
102
+ ```
110
103
 
111
- Every inbound message goes through one turn pipeline. Each stage is a hook.
104
+ Follow the prompts to choose plugins and configure your model, then start a conversation:
112
105
 
113
- ```
114
- resolve_session → load_state → build_prompt → run_model
115
- ↓
116
- dispatch_outbound ← render_outbound ← save_state
106
+ ```bash
107
+ bub chat
117
108
  ```
118
109
 
119
- Builtins are registered first and external plugins load after them, so later plugins take precedence. There are no framework-only shortcuts.
110
+ [Run your first conversation](https://bub.build/docs/getting-started/quickstart/#cli) walks through a task in your workspace. To customize the Bub app, see [tools](https://bub.build/docs/app/tools/), [plugins](https://bub.build/docs/app/plugins/), and [packaging](https://bub.build/docs/app/distribution/). For `uv tool install` and other setup options, see [Install Bub](https://bub.build/docs/getting-started/install/#app-install).
120
111
 
121
- ## Docs
112
+ ## Documentation
122
113
 
123
- - [Getting Started](https://bub.build/docs/getting-started/) — install Bub and run the first turn
124
- - [Concepts](https://bub.build/docs/concepts/) — the mental model behind the runtime
125
- - [Python SDK](https://bub.build/docs/build/sdk/) — embed Bub's agent loop in your own application
126
- - [Build](https://bub.build/docs/build/) — write plugins, override hooks, ship tools and skills
127
- - [Bub Hub](https://hub.bub.build) — browse community plugins, skills, and distributions
128
- - [Channels](https://bub.build/docs/operate/channels/) — run Bub in CLI, Telegram, or your own channel
129
- - [Deployment](https://bub.build/docs/operate/deploy/) — Docker, environment, upgrades
114
+ - [Choose a starting point](https://bub.build/docs/getting-started/)
115
+ - [Shared concepts and capabilities](https://bub.build/docs/concepts/agent/)
116
+ - [API and application reference](https://bub.build/docs/reference/python-api/)
130
117
 
131
118
  ## Background
132
119
 
bub-0.6.1/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # Bub
2
+
3
+ <div align="center">
4
+
5
+ <picture>
6
+ <source srcset="https://raw.githubusercontent.com/bubbuild/bub/refs/heads/main/website/src/assets/bub-logo-dark.png" media="(prefers-color-scheme: dark)">
7
+ <img alt="Bub logo" src="https://raw.githubusercontent.com/bubbuild/bub/refs/heads/main/website/src/assets/bub-logo.png" width="200">
8
+ </picture>
9
+
10
+ <p><strong>Build your Bub.</strong></p>
11
+
12
+ [Website](https://bub.build) · [Docs](https://bub.build/docs/getting-started/) · [Hub](https://hub.bub.build)
13
+
14
+ </div>
15
+
16
+ Put an agent in your own Python program, or customize the Bub application. The application uses the same agent kernel and adds configuration, plugins, and channel integration.
17
+
18
+ ## Build your own agent
19
+
20
+ Use `bub.core.Agent` to choose your model, tools, instructions, and conversation storage. The base `bub` package installs the kernel's dependencies.
21
+
22
+ In a Python 3.12+ project:
23
+
24
+ ```bash
25
+ uv add bub
26
+ ```
27
+
28
+ Run your first agent with the [SDK guide](https://bub.build/docs/sdk/), then [serve it with FastAPI](https://bub.build/docs/sdk/web-service/) when you need an HTTP endpoint.
29
+
30
+ You can also embed `BubAgent` to reuse the application's settings and plugin hooks in your service. This uses `bub[app]`; [Reuse the Bub app](https://bub.build/docs/integrations/reuse-app/) explains the integration choices and their requirements.
31
+
32
+ ## Customize the Bub app
33
+
34
+ Start a conversation, then add tools, skills, plugins, or channels for the work you want Bub to do.
35
+
36
+ Install on macOS or Linux:
37
+
38
+ ```bash
39
+ curl -fsSL https://bub.build/install.sh | bash
40
+ ```
41
+
42
+ On Windows:
43
+
44
+ ```powershell
45
+ powershell -ExecutionPolicy ByPass -c "irm https://bub.build/install.ps1 | iex"
46
+ ```
47
+
48
+ Follow the prompts to choose plugins and configure your model, then start a conversation:
49
+
50
+ ```bash
51
+ bub chat
52
+ ```
53
+
54
+ [Run your first conversation](https://bub.build/docs/getting-started/quickstart/#cli) walks through a task in your workspace. To customize the Bub app, see [tools](https://bub.build/docs/app/tools/), [plugins](https://bub.build/docs/app/plugins/), and [packaging](https://bub.build/docs/app/distribution/). For `uv tool install` and other setup options, see [Install Bub](https://bub.build/docs/getting-started/install/#app-install).
55
+
56
+ ## Documentation
57
+
58
+ - [Choose a starting point](https://bub.build/docs/getting-started/)
59
+ - [Shared concepts and capabilities](https://bub.build/docs/concepts/agent/)
60
+ - [API and application reference](https://bub.build/docs/reference/python-api/)
61
+
62
+ ## Background
63
+
64
+ - [Why We Rewrote Bub](https://bub.build/posts/why-rewrite-bub/)
65
+ - [Socialized Evaluation and Agent Partnership](https://bub.build/posts/socialized-evaluation/)
66
+ - [Context from Tape](https://tape.systems)
67
+
68
+ ## License
69
+
70
+ [Apache-2.0](https://github.com/bubbuild/bub/blob/main/LICENSE)
@@ -47,7 +47,7 @@ app = [
47
47
  "prompt-toolkit>=3.0.52",
48
48
  "python-telegram-bot>=22.7",
49
49
  "rapidfuzz>=3.14.5",
50
- "aiohttp>=3.14.3",
50
+ "aiohttp>=3.14.4",
51
51
  "httpx[socks]>=0.28.1",
52
52
  ]
53
53
  trace = [
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.6.0a2'
22
- __version_tuple__ = version_tuple = (0, 6, 0, 'a2')
21
+ __version__ = version = '0.6.1'
22
+ __version_tuple__ = version_tuple = (0, 6, 1)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -0,0 +1,35 @@
1
+ """CLI, channel work and prompt events published by the application."""
2
+
3
+ from contextvars import ContextVar
4
+ from dataclasses import dataclass
5
+ from typing import Literal
6
+
7
+ from bub.core.events import Event, EventBus
8
+
9
+ type Outcome = Literal["succeeded", "failed", "cancelled"]
10
+ type PromptKind = Literal["question", "permission", "auth"]
11
+
12
+ cli_events: ContextVar[EventBus | None] = ContextVar("cli_events", default=None)
13
+ """The event bus of the application running the current CLI command, if any."""
14
+
15
+
16
+ @dataclass(frozen=True)
17
+ class CommandChanged(Event):
18
+ """A CLI invocation started (None) or finished with an outcome."""
19
+
20
+ outcome: Outcome | None = None
21
+
22
+
23
+ @dataclass(frozen=True)
24
+ class WorkChanged(Event):
25
+ """A channel work snapshot, optionally including the message outcome that caused it."""
26
+
27
+ busy: bool
28
+ completed: Outcome | None = None
29
+
30
+
31
+ @dataclass(frozen=True)
32
+ class PromptChanged(Event):
33
+ """A modal prompt opened (kind) or closed (None)."""
34
+
35
+ kind: PromptKind | None
@@ -2,7 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import asyncio
6
5
  import re
7
6
  from collections.abc import Collection
8
7
  from pathlib import Path
@@ -11,12 +10,12 @@ import bub.core as core
11
10
  from bub.builtin.settings import load_settings
12
11
  from bub.core.store import AsyncTapeStore, TapeStore
13
12
  from bub.core.tape import Tape, session_tape_name
14
- from bub.core.tools import REGISTRY, Tool, model_tools
15
- from bub.envelope import field_of
13
+ from bub.core.tools import Tool, model_tools
16
14
  from bub.framework import BubFramework
15
+ from bub.hooks.agent import AgentPlugins
17
16
  from bub.prompt import LegacyPrompt, UserContent, prompt_text, to_content
18
17
  from bub.skills import discover_skills, render_skills_prompt
19
- from bub.streaming import AsyncStreamEvents, StreamState
18
+ from bub.streaming import AsyncStreamEvents
20
19
  from bub.turn import TurnState
21
20
  from bub.utils import workspace_from_state
22
21
 
@@ -27,11 +26,13 @@ ALLOWED_SKILLS_STATE_KEY = "allowed_skills"
27
26
  class BubAgent(core.Agent):
28
27
  """Bub's agent: the core loop configured by settings and the framework's hooks.
29
28
 
30
- Adds commands, skills, code mode, deferred tools, steering and the
31
- ``continue_prompt`` hook to :class:`bub.core.Agent`. System prompt sections, in
32
- order: the framework's ``system_prompt`` hooks, code mode, deferred tools, skills,
33
- then sections added with ``system_prompt.add``. The framework's interception
34
- hooks handle events before handlers added with ``events.on``.
29
+ Adds commands, skills, code mode and deferred tools to :class:`bub.core.Agent`, and
30
+ connects the framework's agent-loop hooks through :class:`AgentPlugins`. A run that
31
+ started subagents does not end before their results arrive. System prompt
32
+ sections, in order: a subagent's profile instructions, code mode, deferred tools, skills,
33
+ subagent profiles, the framework's ``system_prompt`` hooks, then sections added with
34
+ ``system_prompt.add``. The framework's hooks handle
35
+ events before handlers added with ``events.on``.
35
36
 
36
37
  One instance serves any number of sessions: per-turn choices (model, allowed tools
37
38
  and skills) live in the turn state.
@@ -53,8 +54,8 @@ class BubAgent(core.Agent):
53
54
  Args:
54
55
  framework: Configured hook runtime supplying prompts, tape context,
55
56
  interception hooks, and optional shared resources.
56
- tools: Tools available to this instance. None snapshots the global
57
- registry; an empty collection disables tools.
57
+ tools: Tools available to this instance. None uses the framework's
58
+ ``provide_tools`` tools; an empty collection disables tools.
58
59
  tape_store: Explicit store, preferred over the framework's active store.
59
60
  Create the agent inside ``framework.running()`` to use the latter.
60
61
  Without either, the agent uses an in-memory store.
@@ -69,17 +70,28 @@ class BubAgent(core.Agent):
69
70
  self.settings = load_settings()
70
71
  self.framework = framework
71
72
  self.skill_dirs = skill_dirs
73
+ self.plugins = AgentPlugins(framework)
72
74
  super().__init__(
73
75
  store=framework.get_tape_store() if tape_store is None else tape_store,
74
- tools=REGISTRY.values() if tools is None else tools,
75
- system_prompt=[self._hook_prompt, self._code_mode_prompt, self._deferred_tools_prompt, self._skills_prompt],
76
+ tools=() if tools is None else tools,
77
+ system_prompt=[
78
+ self._subagent_instructions_prompt,
79
+ self._code_mode_prompt,
80
+ self._deferred_tools_prompt,
81
+ self._skills_prompt,
82
+ self._subagent_profiles_prompt,
83
+ ],
76
84
  context=framework.build_tape_context(),
77
85
  sidecars=framework.get_tape_sidecars(),
78
86
  max_steps=self.settings.max_steps,
79
87
  name="bub",
80
88
  command_prefix=self.settings.command_prefix if command_prefix is None else command_prefix,
81
89
  )
82
- framework.get_agent_hooks().subscribe(self.events)
90
+ self.plugins.attach(self, tools=tools is None)
91
+ from bub.builtin.subagents import deliver_subagent_results
92
+
93
+ # After the plugins' steering handler, so steered messages are seen first.
94
+ self.events.on(core.MessagesPending, deliver_subagent_results)
83
95
 
84
96
  async def run_stream(
85
97
  self,
@@ -91,6 +103,7 @@ class BubAgent(core.Agent):
91
103
  allowed_skills: Collection[str] | None = None,
92
104
  allowed_tools: Collection[str] | None = None,
93
105
  reasoning_effort: str | None = None,
106
+ fork_from: Tape | None = None,
94
107
  ) -> AsyncStreamEvents:
95
108
  """Prepare a turn and return its stream; await this method before iterating.
96
109
 
@@ -110,6 +123,8 @@ class BubAgent(core.Agent):
110
123
  None allows all instance tools and an empty collection allows none.
111
124
  Command execution uses the instance's tools directly.
112
125
  reasoning_effort: Per-turn override of the value in state.
126
+ fork_from: An open tape, such as a running turn's, to start from instead of the
127
+ session's tape. The turn sees what that tape holds and its fork is discarded.
113
128
 
114
129
  Loads the turn state and starts the turn with :meth:`start` on the session's tape.
115
130
  Consume the stream to completion to finish execution and tape merging. A
@@ -138,9 +153,9 @@ class BubAgent(core.Agent):
138
153
  model=self.settings.chat_model(
139
154
  state.get("model") if model is None else model, reasoning_effort=state.get("reasoning_effort")
140
155
  ),
141
- tape=session_tape_name(session_id, workspace_from_state(state)),
156
+ tape=session_tape_name(session_id, workspace_from_state(state)) if fork_from is None else fork_from,
142
157
  state=state,
143
- merge_back=not session_id.startswith("temp/"),
158
+ merge_back=fork_from is None and not session_id.startswith("temp/"),
144
159
  metadata=metadata,
145
160
  )
146
161
 
@@ -178,27 +193,6 @@ class BubAgent(core.Agent):
178
193
  direct.extend(deferred[name] for name in await loaded_tool_names(tape) if name in deferred)
179
194
  return model_tools(direct)
180
195
 
181
- async def pending_messages(self, tape: Tape) -> list[list[UserContent]]:
182
- state = tape.context.state
183
- steering_inbox = self.framework.get_steering_inbox()
184
- envelopes = await steering_inbox.drain_messages(state) if steering_inbox else []
185
- return list(
186
- await asyncio.gather(*[
187
- self.framework.build_prompt(message, session_id=field_of(message, "session_id"), state=state)
188
- for message in envelopes
189
- ])
190
- )
191
-
192
- def has_pending_messages(self, tape: Tape) -> bool:
193
- steering_inbox = self.framework.get_steering_inbox()
194
- return bool(steering_inbox and steering_inbox.message_count(tape.context.state) > 0)
195
-
196
- async def continue_prompt(
197
- self, tape: Tape, prompt: list[UserContent] | None, state: StreamState
198
- ) -> list[UserContent] | None:
199
- continuation = await self.framework.continue_prompt(prompt=prompt, tape=tape, state=state)
200
- return None if continuation is None else [continuation]
201
-
202
196
  def _turn_tools(self, state: TurnState) -> list[Tool]:
203
197
  """Return the tools allowed in this turn, direct and deferred alike."""
204
198
  from bub.builtin.tools import ALLOWED_TOOLS_STATE_KEY
@@ -224,20 +218,11 @@ class BubAgent(core.Agent):
224
218
  code_tools = [tool for tool in direct_tools if tool.exposure in ("auto", "code")]
225
219
  return [tool for tool in tools if tool.exposure == "direct"], code_tools
226
220
 
227
- def _hook_prompt(self, context: core.PromptContext) -> str:
228
- return self.framework.get_system_prompt(prompt=context.prompt, state=context.state)
229
-
230
221
  @staticmethod
231
222
  def _code_mode_prompt(context: core.PromptContext) -> str | None:
232
- from bub.builtin.codemode import CODE_TOOLS_STATE_KEY, render_code_mode_prompt, write_tool_stub
223
+ from bub.builtin.codemode import CODE_MODE
233
224
 
234
- state = context.state
235
- if (code_tools := state.get(CODE_TOOLS_STATE_KEY)) is None:
236
- return None
237
- stub_path = write_tool_stub(
238
- code_tools, session_id=str(state.get("session_id", "")), workspace=workspace_from_state(state)
239
- )
240
- return render_code_mode_prompt(stub_path)
225
+ return CODE_MODE.prompt(context)
241
226
 
242
227
  def _deferred_tools_prompt(self, context: core.PromptContext) -> str:
243
228
  from bub.builtin.tools import render_deferred_tools_prompt
@@ -245,6 +230,21 @@ class BubAgent(core.Agent):
245
230
  tools, _ = self._split_code_mode(context.state)
246
231
  return render_deferred_tools_prompt(_deferred_tools(tools))
247
232
 
233
+ @staticmethod
234
+ def _subagent_instructions_prompt(context: core.PromptContext) -> str | None:
235
+ from bub.builtin.subagents import SUBAGENT_INSTRUCTIONS_STATE_KEY
236
+
237
+ return context.state.get(SUBAGENT_INSTRUCTIONS_STATE_KEY)
238
+
239
+ @staticmethod
240
+ def _subagent_profiles_prompt(context: core.PromptContext) -> str:
241
+ """List subagent profiles when the run may start subagents."""
242
+ from bub.builtin.subagents import SUBAGENT_TOOL_NAME, discover_subagent_profiles, render_profiles_prompt
243
+
244
+ if not any(tool.name == SUBAGENT_TOOL_NAME for tool in context.tools):
245
+ return ""
246
+ return render_profiles_prompt(list(discover_subagent_profiles(workspace_from_state(context.state)).values()))
247
+
248
248
  def _skills_prompt(self, context: core.PromptContext) -> str:
249
249
  allowed = context.state.get(ALLOWED_SKILLS_STATE_KEY)
250
250
  return self._load_skills_prompt(
@@ -77,6 +77,34 @@ def list_hooks(ctx: typer.Context) -> None:
77
77
  typer.echo(f"{hook_name}: {', '.join(adapter_names)}")
78
78
 
79
79
 
80
+ def list_plugins(
81
+ ctx: typer.Context,
82
+ names: list[str] = typer.Argument(default_factory=list, help="Plugin names to show; all plugins if omitted."),
83
+ version_only: bool = typer.Option(False, "--version-only", help="Print only the version of each plugin."),
84
+ ) -> None:
85
+ """Show the loaded plugins and their versions."""
86
+ framework = ctx.ensure_object(BubFramework)
87
+ report = framework.plugin_report()
88
+ if missing := [name for name in names if name not in report]:
89
+ typer.echo(f"Unknown plugin: {', '.join(missing)}", err=True)
90
+ raise typer.Exit(1)
91
+ rows = [(name, report[name]) for name in names or report]
92
+ if version_only:
93
+ for _, status in rows:
94
+ typer.echo(status.version or "-")
95
+ return
96
+ if not rows:
97
+ typer.echo("(no plugins)")
98
+ return
99
+ width = max(len(name) for name, _ in rows)
100
+ for name, status in rows:
101
+ source = f"{status.distribution} {status.version}" if status.distribution else "-"
102
+ line = f"{name:<{width}} {source}"
103
+ if not status.is_success:
104
+ line += f" (failed: {status.detail})"
105
+ typer.echo(line)
106
+
107
+
80
108
  def gateway(
81
109
  ctx: typer.Context,
82
110
  enable_channels: list[str] = typer.Option([], "--enable-channel", help="Channels to enable for CLI (default: all)"),
@@ -173,7 +201,7 @@ def onboard(
173
201
  enabled_channels = str(config_data.get("enabled_channels", "")).strip()
174
202
  if not enabled_channels or not is_gateway_service_supported():
175
203
  return
176
- if not bub_inquirer.ask_confirm("Install gateway as a background service?", default=False):
204
+ if not bub_inquirer.ask_confirm("Install gateway as a background service?", default=False, kind="permission"):
177
205
  return
178
206
 
179
207
  try:
@@ -0,0 +1,103 @@
1
+ """Bub's code mode: :class:`bub.core.codemode.CodeMode` wired to session settings, environments and models.
2
+
3
+ ``BubAgent`` chooses the code-callable tools of each turn and stores them in the turn
4
+ state under ``CODE_TOOLS_STATE_KEY``; the ``code_mode`` command switches it per session.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import hashlib
10
+ from collections.abc import Iterable, Mapping
11
+ from pathlib import Path
12
+ from typing import Any
13
+
14
+ from bub.builtin.environment import environment_from_state
15
+ from bub.builtin.settings import set_session_setting
16
+ from bub.core.codemode import (
17
+ DEFAULT_RUN_CODE_TIMEOUT_SECONDS,
18
+ MEDIA_TOOLS,
19
+ RUN_CODE_TOOL_NAME,
20
+ CodeMode,
21
+ attach_audio,
22
+ attach_image,
23
+ attach_video,
24
+ render_code_mode_prompt,
25
+ render_tool_stub,
26
+ write_stub,
27
+ )
28
+ from bub.core.tools import Tool, ToolContext, tool
29
+ from bub.turn import TurnState
30
+ from bub.utils import workspace_from_state
31
+
32
+ __all__ = [
33
+ "CODE_MODE",
34
+ "CODE_MODE_STATE_KEY",
35
+ "CODE_TOOLS_STATE_KEY",
36
+ "DEFAULT_RUN_CODE_TIMEOUT_SECONDS",
37
+ "RUN_CODE_TOOL_NAME",
38
+ "attach_audio",
39
+ "attach_image",
40
+ "attach_video",
41
+ "render_code_mode_prompt",
42
+ "render_tool_stub",
43
+ "run_code",
44
+ "set_code_mode",
45
+ "write_tool_stub",
46
+ ]
47
+
48
+ CODE_MODE_STATE_KEY = "code_mode"
49
+ CODE_TOOLS_STATE_KEY = "_runtime_code_tools"
50
+
51
+
52
+ def _resolve_model(spec: str | None, context: ToolContext) -> tuple[str, Mapping[str, Any]]:
53
+ """Resolve a spec, or the session's model, with Bub's settings: fallbacks, credentials and API bases."""
54
+ agent = context.state.get("_runtime_agent")
55
+ settings = getattr(agent, "settings", None)
56
+ if settings is None:
57
+ raise ValueError("Republic models need a running Bub agent.")
58
+ candidate = settings.model_candidates(spec or context.state.get("model") or settings.model)[0]
59
+ client_kwargs = settings.model_client_kwargs(candidate.provider_name or candidate.provider)
60
+ return f"{candidate.provider}:{candidate.model_id}", client_kwargs
61
+
62
+
63
+ def _stub_dir(session_id: str, workspace: Path) -> Path:
64
+ import bub
65
+
66
+ return bub.home / "codemode" / hashlib.sha256(f"{workspace}\0{session_id}".encode()).hexdigest()[:16]
67
+
68
+
69
+ def _state_stub_dir(state: TurnState) -> Path:
70
+ return _stub_dir(str(state.get("session_id", "")), workspace_from_state(state))
71
+
72
+
73
+ def write_tool_stub(tools: Iterable[Tool], *, session_id: str, workspace: Path) -> Path:
74
+ """Write the tool stub under Bub home; the path stays stable while the session's tool set is unchanged."""
75
+ return write_stub(render_tool_stub(tools), _stub_dir(session_id, workspace))
76
+
77
+
78
+ CODE_MODE = CodeMode(
79
+ lambda state: state.get(CODE_TOOLS_STATE_KEY),
80
+ environment=environment_from_state,
81
+ models=_resolve_model,
82
+ stub_dir=_state_stub_dir,
83
+ # The media tools are among TOOLS, so turns select them like any other tool.
84
+ media_tools=False,
85
+ )
86
+ """Code mode of Bub's agents."""
87
+
88
+ run_code = CODE_MODE.run_code
89
+
90
+
91
+ @tool(name="code_mode", context=True, exposure="command")
92
+ async def set_code_mode(enable: bool, *, context: ToolContext) -> str:
93
+ """Enable or disable code mode for THIS session. Invoke as the `,code_mode enable=true` command.
94
+
95
+ In code mode the model calls `direct` tools directly and every other tool from
96
+ Python through `run_code`. Takes effect on the NEXT turn and persists across restarts.
97
+ """
98
+ await set_session_setting(context, CODE_MODE_STATE_KEY, enable)
99
+ return f"Session code mode {'enabled' if enable else 'disabled'} (applies from the next turn)."
100
+
101
+
102
+ TOOLS: tuple[Tool, ...] = (run_code, *MEDIA_TOOLS, set_code_mode)
103
+ """Code mode tools the builtin plugin provides."""
@@ -0,0 +1,8 @@
1
+ """Compatibility alias for :mod:`bub.core.commands`."""
2
+
3
+ import sys
4
+
5
+ from bub.core import commands as _module
6
+ from bub.core.commands import * # noqa: F403
7
+
8
+ sys.modules[__name__] = _module
@@ -0,0 +1,8 @@
1
+ """Compatibility alias for :mod:`bub.core.context`."""
2
+
3
+ import sys
4
+
5
+ from bub.core import context as _module
6
+ from bub.core.context import * # noqa: F403
7
+
8
+ sys.modules[__name__] = _module
@@ -0,0 +1,25 @@
1
+ """Bub's builtin environment provider: the session's environment from turn state."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import TYPE_CHECKING
7
+
8
+ from bub.environment import ENVIRONMENT_STATE_KEY, Environment, LocalEnvironment
9
+
10
+ if TYPE_CHECKING:
11
+ from bub.turn import TurnState
12
+
13
+
14
+ def environment_from_state(state: TurnState) -> Environment:
15
+ """Return the session's environment, or a host environment for the state's workspace when none was provided.
16
+
17
+ The fallback covers tools run outside a framework turn, for example by SDK callers or tests.
18
+ """
19
+ environment = state.get(ENVIRONMENT_STATE_KEY)
20
+ if isinstance(environment, Environment):
21
+ return environment
22
+ workspace = state.get("_runtime_workspace")
23
+ if workspace is not None and not isinstance(workspace, str | Path):
24
+ raise TypeError("runtime workspace must be a filesystem path")
25
+ return LocalEnvironment(workspace)