Use getOrResumeSession instead of getSessionByThread in Telegram switch
handlers so sessions are found after process restart. Cancel in-flight
prompts before confirming a switch. Clear the prompt queue in
Session.switchAgent() before destroying the old agent.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Mark Discord and Slack as "coming soon" in agent-switch docs and chat-commands table since those adapter integrations were reverted. In the rollback path of switchSessionAgent(), attempt agentManager.resume() with the saved fromAgentSessionId before falling back to a fresh spawn, preserving conversation history on rollback when possible.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reset agent-specific ACP state (capabilities, modes, models, config) in
Session.switchAgent() so stale values from the previous agent don't leak
into the new agent's session. Reject pending PermissionGate requests before
destroying the old agent to prevent callers from hanging. Add adapter-level
cleanupSessionState() to finalize DraftManager drafts and destroy
ActivityTracker timers on agent switch.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Send an empty commands array to the adapter after disconnecting the bridge
so stale skill commands from the previous agent don't linger in the UI.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add rollback logic in switchSessionAgent() to re-spawn the old agent
if the new agent fails to spawn, preventing broken session state
- Add in-flight prompt confirmation in Telegram /switch handler so users
are warned before interrupting a running prompt
- Include labelAgent option in context cache key to prevent stale results
when switching between labelAgent=true and labelAgent=false
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add agent:beforeSwitch (blocking) and agent:afterSwitch (fire-and-forget)
to the middleware hooks reference in claude-md.ts; bump hook count to 20.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cherry-pick Discord and Slack adapter plugins from fix/api-channel-flag branch
and add /switch command handling to both:
- Discord: /switch slash command with agent selection buttons (sw: prefix)
- Slack: /openacp-switch slash command with interactive button menu
- Add DiscordPlatformData type to core types
- Fix renderer interface compatibility for renderPlan signature
- Install discord.js and @slack/bolt dependencies
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Documents the /switch command, mid-conversation agent switching behavior,
history label injection, session resume logic, and the agentSwitch.labelHistory
config option. Adds a dedicated feature page and updates chat-commands,
agents, configuration-schema, README, and SUMMARY.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add switchSessionAgent() to OpenACPCore that orchestrates the full agent
switch flow: middleware hooks, bridge disconnect/reconnect, context
injection, and persistence. Update lazyResume to restore switch history
fields (firstAgent, agentSwitchHistory, currentPromptCount) and persist
them in createSession.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When labelAgent option is true, conversation history markdown includes
### [agentName] headers at agent boundaries, making it clear which agent
produced which parts of the conversation during agent switches.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Emit prompt_count_changed after each prompt increment in Session and
wire SessionBridge to persist currentPromptCount to the store so it
survives process restarts.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds agentSwitch.labelHistory boolean config (default true) to control whether conversation history injected during agent switch includes agent name labels. Also registers the field in config-registry for /config toggle support.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add tests verifying that SessionBridge.disconnect() cleanly removes all
listeners from the old agent instance and that connect() can be safely
called again after swapping session.agentInstance, correctly wiring the
new agent. No bridge code changes required — connect() already reads the
current session.agentInstance at call time.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add switchAgent(), findLastSwitchEntry(), firstAgent, and agentSwitchHistory
to Session. Enables in-place agent swapping while preserving session identity.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add agent:beforeSwitch and agent:afterSwitch hook type definitions to
MiddlewarePayloadMap so plugins can intercept agent switch operations.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add AgentSwitchEntry interface and extend SessionRecord with optional
firstAgent, currentPromptCount, and agentSwitchHistory fields. Update
findByAgentSessionId to also search switch history entries.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements the write-side component that captures agent events from
middleware hooks, accumulates them into structured turns (text/thinking
chunk merging, tool call tracking, diff extraction, permission capture),
and writes completed turns to disk via HistoryStore.
Includes 32 tests covering all event types, accumulation rules, edge
cases, multi-turn sequences, and session cleanup.
Adds /outputmode [low|medium|high] for adapter-level config and /outputmode session [low|medium|high|reset] for per-session override. Deprecates /verbosity as an alias that forwards to /outputmode. Prefixes unused verbosity params in adapter.ts with underscore to suppress TS warnings.
- Add OutputModeResolver field to TelegramAdapter; resolve mode per-call in handleToolCall, handleToolUpdate, handleThought, handleText, handlePlan instead of forwarding raw DisplayVerbosity
- Update getOrCreateTracker signature from verbosity: DisplayVerbosity to outputMode: OutputMode; pass tunnelService and sessionContext to ActivityTracker constructor
- Pass content, rawInput, and diffStats through onToolUpdate calls so ActivityTracker receives full update payload
Replace addTool/updateTool/verbosity calls with updateFromSpec(ToolDisplaySpec),
update snapshot field references (entries→specs, hidden→isHidden, visibleCount→totalVisible),
and remove the verbosity config param that was removed from ToolCardStateConfig.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rewrites activity.ts to use ToolStateMap for tool state tracking and
DisplaySpecBuilder for spec-driven rendering, removing all @ts-ignore
suppressions and as-any casts added in Task 7. Updates activity.test.ts
to match the new API (updateFromSpec instead of addTool/updateTool,
onThought takes a text param, ToolCard constructor drops verbosity arg).
Also fixes adapter.ts to pass thought text to onThought().
Replaces the old entries-based renderToolCard implementation with one that
reads from snap.specs (ToolDisplaySpec[]), rendering icon, title, description,
command, outputSummary, outputContent, diffStats, and viewer links per spec.
Fixes splitToolCardText to truncate single sections larger than 4096 chars
instead of passing them through untruncated. Updates formatting-extended tests
to use the new ToolDisplaySpec/specs API.
Replaces ToolCardEntry[]/addTool/updateTool with ToolDisplaySpec[]/updateFromSpec.
Updates primitives/index.ts to export ToolDisplaySpec instead of removed ToolCardEntry.
Adds @ts-ignore suppressions in activity.ts and formatting.ts as temporary bridge until Tasks 8/9.
Implements DisplaySpecBuilder that derives ToolDisplaySpec and ThoughtDisplaySpec
from a ToolEntry + OutputMode. Controls title logic per kind, output inlining
threshold (≤15 lines AND ≤800 chars for high mode only), noise hiding, and
diffStats pass-through. 14 tests, all green.
Implements ToolStateMap for accumulating ACP tool_call/tool_call_update
events with out-of-order delivery support, and ThoughtBuffer for
streaming thought chunk accumulation across turns.
Add OutputMode type as the new standard output mode type (replacing DisplayVerbosity
usage pattern). Maintain DisplayVerbosity as deprecated alias for backward compatibility.
Add outputMode to SessionRecord, channel config schema, and global config schema.
Add migration to auto-migrate displayVerbosity to outputMode in channel configs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Serialize per-session message dispatch to prevent out-of-order event processing
(tool_update arriving before tool_call due to concurrent fire-and-forget dispatch)
- Buffer tool updates that arrive before their tool_call and apply on addTool
- Allow post-finalize tool updates to flush immediately (late completion after seal)
- Track overflow message IDs and edit them instead of only sending once
- Forward tool updates to previous sealed card for late completions
- Count failed/error tools as done in header (Tools N/N ✅)
- Stop deleting thinking indicator messages to reduce Telegram API calls
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove @openacp/usage from builtin plugin lists (plugin was extracted
but registration entries remained, causing silent failures on first boot)
- Guard fs.readdirSync(nodeModulesDir) with existsSync check to prevent
crash when community plugins are registered but node_modules/ missing
- Clean up onboard.ts: remove redundant duplicate imports and local constants
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Combines setup wizard fixes (settingsManager/pluginRegistry passing,
ESM plugin resolution, path centralization) with develop's shell
injection validation and community adapter flow. Adds error handling
and tests for importFromDir.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wrap package.json parsing with descriptive error messages and validate
entry point exists before importing. Add 7 unit tests covering all
resolution paths and error cases.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>