#22283: Plugins: expose resolveMainSessionKey in runtime system
channel: bluebubbles
size: XS
Cluster:
Plugin Enhancements and Fixes
## Summary
The `PluginRuntime["system"]` type is missing `resolveMainSessionKey`, which extensions need to resolve the primary session key from config (e.g. to bridge transcripts or correlate sessions across channels).
Several existing test mocks already reference this property on the system object (`subagent-registry.announce-loop-guard.test.ts`, `tools-invoke-http.test.ts`, `status.e2e.test.ts`), confirming it is expected at runtime but not currently provided by the implementation.
**Changes:**
- Add `ResolveMainSessionKey` type alias to `src/plugins/runtime/types.ts`
- Add `resolveMainSessionKey` to `PluginRuntime["system"]` type
- Wire existing `resolveMainSessionKey` from `config/sessions/main-session.js` into `createRuntimeSystem()`
- Update bluebubbles monitor test mock to include the new field
## Test plan
- [x] `pnpm build` passes
- [x] `pnpm vitest --run src/plugins/runtime/` — 2 tests pass
- [x] `pnpm vitest --run extensions/bluebubbles/src/monitor.test.ts` — 60 tests pass
- [x] `pnpm vitest --run src/agents/subagent-registry.announce-loop-guard.test.ts` — 4 tests pass
- [x] Format check passes (`pnpm format:check`)
- [x] Only pre-existing TS error remains (discord `send.components.test.ts`)
🤖 AI-assisted PR (reviewed and tested manually)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR exposes `resolveMainSessionKey` in the plugin runtime system, making it available to extensions that need to resolve the primary session key from config. The change addresses a gap where test mocks already referenced this property but the actual runtime implementation was missing it.
The implementation is straightforward and consistent:
- Adds proper type alias following existing pattern in `src/plugins/runtime/types.ts:76-77`
- Wires the function from `src/config/sessions/main-session.ts:11` into the runtime system at `src/plugins/runtime/index.ts:59,264`
- Updates the bluebubbles test mock to include the new field at `extensions/bluebubbles/src/monitor.test.ts:100-102`
The changes align with several existing test mocks that were already expecting this function (`subagent-registry.announce-loop-guard.test.ts:24`, `tools-invoke-http.test.ts:15`, `status.e2e.test.ts:92`), confirming this was an intended but missing part of the runtime API.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The change is a simple, non-breaking addition that fills a gap in the plugin runtime API. All modified files follow existing patterns, the implementation correctly imports and wires an existing function, and tests confirm the change works as expected. No logic changes or refactoring occurred.
- No files require special attention
<sub>Last reviewed commit: a50fe6f</sub>
<!-- greptile_other_comments_section -->
<sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#19464: feat(plugins): expose requestHeartbeatNow on plugin runtime
by AustinEral · 2026-02-17
77.2%
#16044: plugin-sdk: expose onAgentEvent + onSessionTranscriptUpdate via Plu...
by scifantastic · 2026-02-14
74.2%
#23525: fix: include sessionKey in session_start/session_end hook context
by p697 · 2026-02-22
73.1%
#2556: fix(plugin-install): handle existing plugins and filter workspace deps
by longmaba · 2026-01-27
72.2%
#21271: fix(commands): pass channel/capabilities/shell/os to runtime in com...
by evansantos · 2026-02-19
71.6%
#16867: plugin-sdk: export PluginLogger type for plugin use
by fsdwen · 2026-02-15
71.1%
#5525: Add plugin hook to resolve canonical RoomKey for session identity a...
by peteclt92 · 2026-01-31
70.9%
#13176: fix: resolve llm-task module import for global installs
by striking · 2026-02-10
70.5%
#19422: fix: pass session context to plugin tool hooks in toToolDefinitions
by namabile · 2026-02-17
70.5%
#13109: fix(plugins): inject globalThis.require for CJS interop in jiti-loa...
by mcaxtr · 2026-02-10
70.4%