fix: Subagent permissions - #16
Open
webbrain-one wants to merge 1 commit into
Open
webbrain-one wants to merge 1 commit into
webbrain-one wants to merge 1 commit into
Conversation
Respects tool restrictions defined in agent frontmatter. Closes assagman#12
There was a problem hiding this comment.
Pull request overview
Adds a permission-pattern matching utility intended to support restricting which MCP tools are visible/usable per agent (as requested in issue #12), by providing allow/deny glob-style filtering helpers for catalog tools.
Changes:
- Added
matchesPermission,isToolAllowed, andfilterToolsByPermissionshelpers for glob-style tool ID permission checks. - Re-exported the permission-filter helpers from the package entrypoint (
src/index.ts).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/permission-filter.ts | Introduces glob-based allow/deny evaluation and a catalog-tool filter helper. |
| src/index.ts | Exposes the new permission-filter utilities to consumers via public exports. |
Suppressed comments (1)
src/permission-filter.ts:48
- Permission matching/precedence (deny over allow, wildcard behavior, exact match, default allow-all when allow list is empty) is core security behavior but currently has no unit tests. Add focused tests to prevent regressions, especially for patterns like
context7*,*search, and mixed allow/deny lists.
export function isToolAllowed(toolId: string, permissions: PermissionPatterns): boolean {
const { allow, deny } = permissions;
// Check deny first - if denied, tool is not allowed
if (deny && deny.length > 0) {
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // Provides on-demand access to MCP server tools through search and execute | ||
|
|
||
| export { ToolboxPlugin, ToolboxPlugin as default } from "./plugin"; | ||
| export { filterToolsByPermissions, isToolAllowed } from "./permission-filter"; |
Comment on lines
+3
to
+9
| /** | ||
| * Permission pattern format matching OpenCode agent frontmatter | ||
| */ | ||
| export interface PermissionPatterns { | ||
| allow?: string[]; | ||
| deny?: string[]; | ||
| } |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #12