Skip to content

Core: rewrite tool-activation.ts + new guard extension generator#186

Closed
SuuBro wants to merge 1 commit intogoal/simplify-t-703f66e2from
goal-goal-simplify-t-703f66e2-coder-1e5dfc12
Closed

Core: rewrite tool-activation.ts + new guard extension generator#186
SuuBro wants to merge 1 commit intogoal/simplify-t-703f66e2from
goal-goal-simplify-t-703f66e2-coder-1e5dfc12

Conversation

@SuuBro
Copy link
Copy Markdown
Owner

@SuuBro SuuBro commented Apr 1, 2026

Implements the core tool-activation.ts rewrite and new tool-guard-extension.ts generator.

Changes

New file: src/server/agent/tool-guard-extension.ts

  • generateToolGuardExtension(sessionId, policies, grantedTools) generates a pi-coding-agent extension that intercepts tool_call events
  • For ask policy tools: blocks execution via REST long-poll to gateway until user grants/denies
  • Uses same env var pattern as MCP proxy extensions (BOBBIT_GATEWAY_URL, BOBBIT_TOKEN)

Modified: src/server/agent/tool-activation.ts

  • Removed: writeToolStubExtensions(), writeLeakedToolStubs(), generateToolStubExtension(), generateMcpStubExtension()
  • Removed: leakedTools from ToolActivationResult and all leaked tool detection logic
  • Modified: resolveGrantPolicy() normalizes old policy values (always-allow→allow, ask-once/always-ask→ask, never-ask→never)
  • Modified: computeEffectiveAllowedTools() now returns tools with allow OR ask policy
  • Modified: writeMcpProxyExtensions() generates proxies for all non-never MCP tools (no stub variants)
  • Added: computeToolPolicies() returns policy+group map for all known tools
  • Added: writeToolGuardExtension() writes guard extension when any ask tools exist

Expected downstream type errors

session-manager.ts and session-setup.ts still import removed functions — those are handled by separate tasks.

🤖 Generated with Bobbit

- Remove stub extension functions: writeToolStubExtensions, writeLeakedToolStubs,
  generateToolStubExtension, generateMcpStubExtension
- Remove leakedTools detection from computeToolActivationArgs
- Add normalizePolicy helpers (isAllowPolicy, isAskPolicy, isNeverPolicy)
- Update resolveGrantPolicy to normalize old policy values
- Update computeEffectiveAllowedTools to include ask tools (not just allow)
- Simplify writeMcpProxyExtensions: no stub variants, only real proxies
- Add computeToolPolicies: returns policy+group for all tools
- Add writeToolGuardExtension: generates guard when ask tools exist
- New tool-guard-extension.ts: generates pi-coding-agent extension that
  intercepts tool_call events and enforces ask policy via REST long-poll

Expected type errors in session-manager.ts and session-setup.ts (those
files still import removed functions — handled by separate tasks).

Co-authored-by: bobbit-ai <bobbit@bobbit.ai>
@SuuBro SuuBro closed this Apr 2, 2026
@SuuBro SuuBro deleted the goal-goal-simplify-t-703f66e2-coder-1e5dfc12 branch April 9, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants