# Runtime API Reference

The main local runtime API is defined by `flow/runtime/src/trpc/app-router.ts` and the shared
contracts exported from `flow/contracts/src/api-contract.ts`.

This API is used by the Matrix shell, the Flow plugin, and plugin-backed runtime features such as
Chat. For the exhaustive current procedure list, use the [generated inventory](generated/inventory.md).

## Configuration

- `runtime.getConfig`
- `runtime.saveConfig`
- `runtime.getProjectContextDocuments`
- `runtime.saveProjectContextDocument`

## Cline

- `runtime.saveClineProviderSettings`
- `runtime.addClineProvider`
- `runtime.updateClineProvider`
- `runtime.getClineProviderCatalog`
- `runtime.getClineProviderModels`
- `runtime.runClineProviderOAuthLogin`
- `runtime.startClineDeviceAuth`
- `runtime.completeClineDeviceAuth`
- `runtime.getClineAccountProfile`
- `runtime.getClineAccountBalance`
- `runtime.getClineAccountOrganizations`
- `runtime.switchClineAccount`
- `runtime.getClineKanbanAccess`
- `runtime.getClineMcpSettings`
- `runtime.saveClineMcpSettings`
- `runtime.getClineMcpAuthStatuses`
- `runtime.runClineMcpServerOAuth`
- `runtime.getClineSlashCommands`

## Task Sessions

- `runtime.startTaskSession`
- `runtime.stopTaskSession`
- `runtime.sendTaskSessionInput`
- `runtime.getTaskChatMessages`
- `runtime.sendTaskChatMessage`
- `runtime.reloadTaskChatSession`
- `runtime.abortTaskChatTurn`
- `runtime.cancelTaskChatTurn`
- `runtime.startShellSession`

## Chat Plugin

- `runtime.listChatConversations`
- `runtime.createChatConversation`
- `runtime.getChatConversation`
- `runtime.updateChatConversation`
- `runtime.deleteChatConversation`
- `runtime.archiveChatConversation`
- `runtime.listChatMessages`
- `runtime.sendChatMessage`
- `runtime.stopChatGeneration`
- `runtime.regenerateChatResponse`
- `runtime.getChatSettings`
- `runtime.saveChatSettings`
- `runtime.resetChatSettings`
- `runtime.listChatModels`
- `runtime.getChatAiHealth`
- `runtime.resolveChatToolApproval`

## Research Plugin

- `runtime.createResearchSession`
- `runtime.getResearchSession`
- `runtime.listResearchSessions`
- `runtime.getResearchContextPack`
- `runtime.linkResearchSession`
- `runtime.exportResearchSession`
- `runtime.getResearchProviderHealth`
- `runtime.getResearchProviderPreference`
- `runtime.saveResearchProviderPreference`
- `runtime.listResearchArtifacts`
- `runtime.startResearchJob`
- `runtime.queueResearchJob`
- `runtime.cancelResearchJob`

## Social Studio

- `runtime.getSocialStudioWorkspace`
- `runtime.saveSocialStudioWorkspace`
- `runtime.ingestSocialStudioDirectory`
- `runtime.analyzeSocialStudioMedia`
- `runtime.runSocialStudioResearch`
- `runtime.buildSocialStudioPlan`
- `runtime.buildSocialStudioExportPack`
- `runtime.importSocialStudioAnalytics`
- `runtime.buildSocialStudioAutomationRule`

## Workspace And Git

- `runtime.getGitSummary`
- `runtime.runGitSyncAction`
- `runtime.checkoutGitBranch`
- `runtime.discardGitChanges`
- `runtime.getChanges`
- `runtime.ensureWorktree`
- `runtime.deleteWorktree`
- `runtime.getTaskContext`
- `runtime.searchFiles`
- `runtime.getState`
- `runtime.saveState`
- `runtime.notifyStateUpdated`
- `runtime.getWorkspaceChanges`
- `runtime.getGitLog`
- `runtime.getGitRefs`
- `runtime.getCommitDiff`

## Projects

- `projects.list`
- `projects.add`
- `projects.remove`
- `projects.pickDirectory`
- `projects.listDirectoryContents`
- `projects.createDirectory`
- `projects.setupAndroidStorage`

## Hooks And Utilities

- `hooks.ingest`
- `runtime.runCommand`
- `runtime.openFile`
- `runtime.resetAllState`
- `runtime.getUpdateStatus`
- `runtime.runUpdateNow`
- `runtime.getFeaturebaseToken`

## Streams

Runtime state stream messages include snapshots, workspace state updates, task session updates,
project updates, workspace metadata updates, task-ready-for-review events, task chat messages, chat
conversation updates, chat generation updates, tool-approval updates, MCP auth updates, Cline
context updates, and runtime errors.

Terminal websocket messages include resize, stop, output acknowledgements, restore completion,
state, restore, exit, and error messages.

## See Also

- [APIs and contracts](apis-and-contracts.md)
- [ZoneGaze Social Studio plugin](../plugins/zonegaze-social-studio.md)
- [CLI reference](cli.md)
- [Configuration reference](configuration.md)
- [Generated inventory](generated/inventory.md)
- [Generated source reference](generated/source/README.md)
