Skip to main content

Module extensions

Module extensions 

Source
Expand description

Extensions: code that registers tools and commands with a session and handles its events, as pi’s extension runner (core/extensions in pi v1.0.0) runs them.

This is the part of pi’s ExtensionAPI that the built-in extensions use. The wasm host in yapi-ext implements Extension for loaded packages with the same contract. Each session gets its own extension instances. A replaced session receives session_shutdown before its successor starts.

Modules§

codemode
What other parts of a session know about the codemode tool, which yapi-ext implements: its name, schema and prompt text, and how to tell the genuine tool from another extension’s tool of the same name.
discovery
Which files load as extensions: pi’s extension entry rules (core/extensions/loader.ts in pi v1.0.0).
tool_search
The tool_search tool: a BM25 ranker over the metadata of tools that are not declared to the model (codemode and deferred exposure), which activates the matches for the next model call. Port of extensions/tool-search in pi v1.0.0.

Structs§

BashOperations
pi’s BashOperations: operations a user_bash handler returned to run a ! command with.
Command
A slash command an extension registered.
Context
What an extension can reach while handling an event or command.
CustomOptions
The options of pi’s custom: how a custom component is shown.
DialogOptions
pi’s ExtensionUIDialogOptions: when a dialog closes on its own.
EventPolicy
The pi.events channels an extension may send to, and hear from, extensions whose grants differ from its own. Each pattern is an exact channel, a prefix ending in *, or * for every channel.
Grants
What an extension may reach. The default grants everything, as pi does.
Loadout
pi’s ToolLoadout: the tools a loadout hook sees.
LoadoutChanges
pi’s ToolLoadoutChanges: what a loadout hook changes.
NoUi
The UI of print and JSON modes: nothing is shown.
RemoteComponent
A pi-tui component that lives in an extension runtime.
Renderers
What an extension draws in the transcript.
ResolvedCommand
pi’s ResolvedCommand: an extension command with the name it is invoked by.
Shortcut
A key an extension binds with pi’s registerShortcut.
ShortcutBinding
An extension shortcut the interactive mode honors.
TerminalState
What extensions see of the terminal.
ToolInfo
pi’s ToolInfo: a tool as extensions see it.
ToolRenderers
pi’s renderCall, renderResult and renderShell: how an extension draws one of its tools.
Tools
The session’s tools, shared with its extensions.
WorkingIndicator
pi’s WorkingIndicatorOptions: the animation shown while the agent works.

Enums§

Mode
pi’s ExtensionMode: the mode a session runs in.
ModelUpdate
A provider’s new models from a refresh.
NotifyKind
How a notification is shown.
Placement
pi’s WidgetPlacement: where a widget goes.
SessionAction
A session change an extension command asks for, one of pi’s ExtensionCommandContextActions.
Widget
What a widget shows.

Constants§

CAPABILITIES
The capabilities a manifest grants, in the order yapi lists them. Each but all gives one grant, and all gives every grant, running processes included. none, which grants nothing, stands alone.
RESERVED_ACTIONS
pi’s RESERVED_KEYBINDINGS_FOR_EXTENSION_CONFLICTS: actions whose keys extensions may not take.

Traits§

ComponentHost
The extension runtime side of components: renders them and delivers input to them.
Extension
An extension. Every hook has a no-op default.
ExtensionUi
pi’s ExtensionUIContext as a mode implements it. Dialogs a mode cannot show resolve as cancelled. Everything else does nothing by default.

Functions§

builtin_source
pi’s source info for a built-in extension named name.
builtins
The built-in extensions each session starts with.
delivers
Whether an event on channel from an extension with sender’s grants and policy reaches one with receiver’s: always between identical grants, since neither gains anything, and otherwise when the sender may send the channel and the receiver may hear it.
receives
Whether an extension with grants hears pi event kind. The provider request events carry the request’s body and headers, credentials included, which only the network grant may read.
resolve_shortcuts
pi’s getShortcuts: the shortcuts of extensions in load order, given the keys bound to each built-in action. A key a reserved action uses is refused. Another built-in key, or one an earlier extension took, goes to the later extension. Returns the bindings and pi’s warnings, each with the path of the extension it concerns.
tool_granted
Whether grants allow running tool. The built-in bash, grep and find run processes, and the other built-in tools need file access. Any other tool, including one an extension registers under a built-in name, may reach anything, so it needs every grant.

Type Aliases§

ModelList
A provider’s new models from a refresh, or why it failed.
SessionActions
How a mode carries out SessionActions: whether an extension cancelled the change, or why it failed.
Setup
pi’s newSession setup: runs with the replacement session once it is built, before its extensions start.