Repository navigation
feat(context): ctx.minder.call and minder_scopes for AI tools - #58
Merged
Merged
Conversation
Add the minder.api capability to the platform context: an AI tool can call a plugin-callable Minder route as the invoking user, for the scopes it declares in the new AI_TOOLS field minder_scopes (from MINDER_SCOPES). check_plugin rejects unknown scopes; check_plugin_warnings warns when a tool's action calls ctx.minder.call without minder_scopes (an error in a later release). The unbound, fake and T4 callback contexts implement it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Driven by session |
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.
Summary
An AI tool can now call Minder's own API through the platform context, scoped to what it declares.
await ctx.minder.call(route, *, method="GET", query=None, json=None): calls a plugin-callable Minder route as the invoking user and returns the parsed JSON answer.minder.api(CAP_MINDER_API, added toHOST_CAPABILITIES).MinderAPIprotocol;PlatformContextgainsminder.CapabilityUnavailable),FakePlatformContextand the T4CallbackPlatformContext.{"route", "method", "query", "body"}. T4 posts them to/v1/plugin-callbacks/minder.api, andminder.apiis inREMOTE_CAPABILITIES.Errors use the existing classes, and the reason says which case applies:
CapabilityDenied: not a tool call, route not plugin-callable, the token lacks the route's scope, deadline passed, or refused.CapabilityInvalid: Minder rejected the arguments.CapabilityUnavailable: unreachable, or past the deadline mid-call.minder_scopesonAI_TOOLSentries (AIToolSpec): each scope must come from the newcontext.MINDER_SCOPESlist:kb.searchkb.read_passageconversation.read_currentuser.profile.basicticket.create_internalkb.documents.ingestcheck_pluginfails on a value that is not a list, or on an unknown scope.check_plugin_warningswarns when a tool's action method callsctx.minder.callwithout declaringminder_scopes. This is a warning for now and becomes an error in a later release, the same rollouteffecthad. The check reads the action method's own body only, not the helpers it calls.FakePlatformContext(minder_results={(method, route): value-or-callable}): any other route raisesCapabilityDenied.for_plugingrantsminder.apiwhen a tool declaresminder_scopes.README (tool fields, the
ctxtable, errors, the fake) and CHANGELOG "Unreleased".Compatibility
PlatformContextimplementation must add aminderattribute to keep passingisinstance(ctx, PlatformContext).Validation
black --check src tests examples: clean.flake8 --max-line-length=100 --extend-ignore=E203,W503 src tests examples: clean.mypy src(strict): no issues.pytest tests: 1188 passed.New tests cover:
minder.apicall;minder.api;minder_scopesvalidation errors;ctx.minder.callis used without scopes, and no warning once scopes are declared;🤖 Generated with Claude Code