Add ergonomic Pax plugin primitives (`PluginHost.warn()`, `KeySlot`, `OAuthSignIn.for_run()`, `Command.subcommands()`)
Closes #15754
Why we make these changes
Auditing Pax's 25 built-in plugins in #15754 surfaced four high-frequency patterns repeated across 8–14 plugins each, often requiring imports from internal modules (ui.rendering.theme, config.credential_store). Adding four small additive helpers to the public plugin surface removes that boilerplate and fixes logfire.py's missing markup=False on shutdown timeout warnings.
New public surface
PluginHost.warn(message: str)andPluginHost.info(message: str)inpydantic_ai_pax.pluginsKeySlot(account, *, default_name, service, setup)with.storage_account,.load(),.resolve(),.save(ref),.clear(),async .choose(dialogs, *, label=None, check=...), and.note(*, unset='')inpydantic_ai_pax.plugins.keys— third-party slots validateaccountand store under a dedicatedplugin-key-<account>namespace (isolated from provider logins and built-ins viabuiltin_key_slot), discovered byapi_keys.key_users()so/keysrefuses to rename keys in use and surfacessetupin save and rename errors;/keys forget SLOTclears orphaned or corrupt third-party slotsis_signed_in(method)andsign_in_subcommands(method)inpydantic_ai_pax.plugins.sign_inandOAuthSignIn.for_run(build)inpydantic_ai_pax.mcpCommand.subcommands(name, description, handlers, *, default=None, usage=None, **options)(CommandOptions,SubcommandHandler) andawait Command.run(args)inpydantic_ai_pax.commands(plus read-onlyGrainPlugin.command)
User-visible behavior
# Before (repeated across 8–14 built-ins):
self.host.console.print(msg, style=theme.color(theme.WARNING), markup=False)
# After:
self.host.warn(msg)
Adopted across built-in plugins (coder, compaction, day_ai, github, google_workspace, grain, hooks, linear, logfire, logfire_mcp, notion, ordinal, posthog, pylon, sandbox, slack, web, and plugins/sign_in.py) and documented in src/pydantic_ai_pax/PLUGINS.md and src/pydantic_ai_pax/docs/reference.md.
Verification
tests/pax/test_plugins.py::test_host_warn_and_info_print_themed_text_with_markup_disabledtests/pax/test_plugin_keys.py::test_key_slot_lifecycle_and_notes,test_orphaned_third_party_key_slot_can_be_forgotten_through_keys_command,test_key_slot_isolates_namespace_and_validates_accounttests/pax/test_sign_in.py::test_warn_if_signed_out_reuses_the_off_loop_check,test_the_shared_commandtests/pax/test_mcp_tokens.py::test_oauth_sign_in_for_runtests/pax/test_command_edges.py::test_command_subcommands_dispatch_completion_and_validation
What changes for existing users
Existing behavior is preserved except that corrupt saved-key errors for Notion ("key selection"), PostHog and Pylon ("key reference"), and Slack ("The saved Slack connection is invalid") now share KeySlot's unified The saved <Service> key choice is invalid. wording, /pylon subcommand completion now uses Commands.get_completions's substring matching consistently with every other command, and /keys forget SLOT clears an orphaned third-party plugin key slot.