The server imports omp's own modules from the installed package, so it does not reimplement a protocol, the encryption, or the session-file format, and it always speaks the same version as the sessions it shows.
src/omp/modules.ts loads every module once and checks at startup that each export this app uses exists, naming the omp version and the missing export when one does not.
It finds the package through omp on PATH, or OMP_PACKAGE_DIR when set; with a Bun global install that is ~/.bun/install/global/node_modules/@oh-my-pi/pi-coding-agent.
bun run omp-release checks a new omp release against these modules and the files listed below; the omp release skill says how to read its report.
Paid Cursor fallback is an external OMP runtime change, preserved in patches/omp-18.12.3-paid-cursor-fallback.patch with its regression tests.
Its base is upstream tag v18.12.3, commit 53a0377db6845e0dae606146130766ec92d407fd; do not apply it to another release without porting and verifying it.
From a clean checkout of that release, check and apply the patch:
git apply --check /absolute/path/to/omp-agents/patches/omp-18.12.3-paid-cursor-fallback.patch
git apply /absolute/path/to/omp-agents/patches/omp-18.12.3-paid-cursor-fallback.patchBuild and install both patched packages, @oh-my-pi/pi-ai and @oh-my-pi/pi-coding-agent, including the CLI bundle and SDK sources and declarations.
The dashboard does not apply this patch at startup, and installing or upgrading stock OMP removes the runtime changes.
The routing policy describes the opt-in retry.paidFallback setting and its billing limits.
Paths in this document that start with pi-coding-agent/, pi-ai/, pi-catalog/, pi-tui/, pi-utils/, or omp-stats/ are inside that install, in @oh-my-pi/.
They are not in this repository.
The main ones:
- Collab:
pi-coding-agent/src/collab/registry.ts,protocol.ts,crypto.ts, andrelay-client.ts. - Session files:
pi-coding-agent/src/session/session-listing.tsandsession-loader.ts.appendCustomMessageEntryinpi-coding-agent/src/session/session-manager.tsgives acustom_messageentry the timestamp of the message it records, which#persistMessageEndinagent-session.tspasses. - Interrupted turns:
pi-coding-agent/src/session/exit-diagnostics.ts(createInterruptedTurnAbortMessage), whichendsMidTurninsrc/omp/sessions.tsuses to refuse forking a session that ended mid-turn. It checks the branch from the leaf thatresolveSessionLeafIdinpi-coding-agent/src/session/session-entries.tsreturns, as omp's load does, since a latemodel_usageentry is written last but points back at the leaf withactiveLeafId. - Images:
pi-coding-agent/src/session/blob-store.ts, which moves a prompt's image out of the session file intoblob:sha256:<hash>, andgetBlobsDirinpi-utils/src/dirs.ts;src/transcript.tsand the/api/imageroute read them. - Provider requests:
emitBeforeProviderRequestinpi-coding-agent/src/extensibility/extensions/runner.tshands each provider's request body to the extensions in load order, with the request's model asctx.model, andtemplates/omp/agent/extensions/request-log.tsrecords it. The providers call it throughonPayload;pi-ai/src/providers/anthropic.tsstill edits the body after the hook to withhold kill-switched fields and to fit server-side compaction, Bedrock, and Vertex, and compaction, branch summaries, and titles never reach the hook.pi-coding-agent/src/cli/gc-cli.tskeeps a blob while any session file holds itsblob:sha256:reference, andputSyncinblob-store.tsrefreshes a reused blob's time so a reference not yet written to disk survivesomp gc. - Documents:
convertBufferWithMarkitinpi-coding-agent/src/utils/markit.ts, the converter behind omp'sreadof a PDF, Word, PowerPoint, Excel, or EPUB file, whichsrc/omp/documents.tscalls forPUT /api/attachment/document. - RPC:
pi-coding-agent/src/modes/rpc/rpc-client.ts,rpc-frame.ts, and the frame types inrpc-types.ts.RpcClientdropsextension_ui_requestandsession_info_updateframes, sosrc/omp/rpc.tsreads them from its own copy of omp's stdout (UNROUTED_FRAMES); see Dashboard sessions.RpcClient'sspawnoption may return any process withpid,exited,stdin,stdout,peekStderr, andkill(RpcAgentProcess);start()waits for omp'sreadyline, sendsnegotiate_protocolwhen it offers protocol 2, thenset_host_tools, and a stdout that ends makes it callkill; see Session keepers. omp answersnegotiate_protocolagain whenever it is sent (rpc-mode.ts), andRpcFrameDecoderthrows on a chunk sequence that does not start at index 0 or that another frame interrupts; omp writes a frame over 1 MB as such a sequence.get_statereportsisStreaming,isCompacting, andhasPendingAsyncWork(AgentSession.hasPendingAsyncWork, a running background job whose result will start the agent again), andget_subagentsreturnsRpcSubagentSnapshots with the fields of a subagent lifecycle frame.agent_endcarriesisTerminal: falsewhile an async delivery remains, such as a background job, so a turn that started one stays running until the job delivers. omp's eval kernels and subagents spawn with Bun'sdetached, as session leaders of their own (pi-coding-agent/src/eval/kernel-base.ts,task/executor.ts), and its background jobs lead process groups of their own, so only a walk of the process tree finds them, and only while omp runs.get_available_modelsreturns omp's wholeModelobjects, withname,contextWindow,api,identity, andserviceTiers;get_stateaddsfastModeEnabledandfastModeActive, andsetFastModesendsset_fast_mode.RpcClient.promptresolves with the request id once omp admitted the prompt, andonPromptResultdelivers that prompt'sprompt_result(rpc-prompt-results.ts); see Dashboard sessions. Host tools:RpcClient'scustomToolsoption (RpcClientCustomTool), whichstart()sends asset_host_tools, so a new process for the same session gets them again, andsetCustomTools, which replaces them for a session the server attached to;pi-coding-agent/src/modes/rpc/host-tools.tsruns them as strict tools, sendinghost_tool_calland waiting onhost_tool_resultor its ownhost_tool_cancel, anddefaultLoadModeForToolNameinpi-coding-agent/src/tools/essential-tools.tsmakes one withoutloadMode: "essential"only discoverable. A host tool stays registered throughnewSession,switchSession, and/movein one process, since omp buildsSessionToolsonce perAgentSession(pi-coding-agent/src/session/session-tools.ts). Extensions:omp -e <file>(pi-coding-agent/src/main.ts,additionalExtensionPaths) loads inrpc-uimode too;pi-coding-agent/src/discovery/omp-extension-roots.tsdedupes by path only, so the same extension at two paths loads twice. - Service tiers:
serviceTierFamilyandshouldSendServiceTierinpi-ai/src/types.ts, whichfastAvailableinsrc/omp/models.tscalls to decide, assetFastModeinpi-coding-agent/src/session/model-controls.tsdoes, whether/fastcan turn on for the live model. - Settings and discovery:
pi-coding-agent/src/config/settings.ts,pi-coding-agent/src/discovery/index.ts, andpi-coding-agent/src/task/discovery.ts. - Credentials:
pi-coding-agent/src/session/auth-broker-config.ts(discoverAuthStorage) andpi-ai/src/registry/oauth/index.ts(getOAuthProviders).connectedProvidersinsrc/omp/models.tskeeps the/loginproviders that have a credential, as omp's RPCget_login_providersmarks themauthenticated. It opens the credential store on each call and closes it, so a login in a terminal counts at the next call. Settings › Providers runs omp's own/loginand/logoutthroughsrc/omp/providers.ts:AuthStorage.oauth.login(pi-ai/src/auth-storage.ts) withcaptureBrowserSessionfrompi-coding-agent/src/utils/browser-session.tsfor a cookie sign-in,formatLoginIdentityfrompi-coding-agent/src/cli/oauth-terminal.ts,ModelRegistry.refreshProviderfrompi-coding-agent/src/config/model-registry.tsafterwards, asomp logindoes, andtoLogoutAccountsandlogoutCredentialfrompi-coding-agent/src/slash-commands/helpers/logout.ts. - Model selectors:
parseRetryFallbackSelectorinpi-coding-agent/src/session/retry-fallback-chains.ts, which onlyreadSelectorinsrc/omp/config.tscalls.readSelectorreads a selector against theprovider/idof the listed models, so a:levelsplits off only after an id thatomp modelslists, and returns the selector's provider, id, and suffix.resolveSelectorkeeps the read only when its model is listed, androutedSelectorsnames every selector of the routing: each role's, and each fallback chain's key and entries. - Model roles:
pi-coding-agent/src/config/model-resolver.ts(expandRoleAlias,resolveRoleChain), whose@rolealiasesresolveRolesinsrc/omp/models.tsfollows forGET /api/models/roles.modelEntriesreads each of theroutedSelectorswithreadSelectorand maps it to a listed model withresolveProviderModelReference, which follows retired variant ids such asgrok-4.7-highand dotted spellings such asclaude-fable-5.1. - Side answers:
streamSimpleinpi-ai/src/stream.ts, withresolveRoleSelectioninpi-coding-agent/src/config/model-resolver.tsandModelRegistry'srefresh,getAvailable,getApiKey, andresolverinpi-coding-agent/src/config/model-registry.ts, whichanswerDiscussioninsrc/omp/discussion.tsuses to answer Ask about this with one model call outside every session; see Ask about this. It reads thesmolanddefaultroles from the user's settings (Settings.loadReadOnlywithHOMEas its directory), so a project'smodelRolesdo not apply, and it loads no extension's custom provider. - MCP:
pi-coding-agent/src/mcp/json-rpc.ts(callMCP),config.ts(loadAllMCPConfigs),client.ts(connectToServer,listTools,disconnectServer),oauth-credentials.ts(removeManagedMcpOAuthCredentials),oauth-discovery.ts(discoverOAuthEndpoints),oauth-flow.ts(MCPOAuthFlow), andconfig-writer.ts(addMCPServer,updateMCPServer,removeMCPServer,setMcpServerEnabled,validateServerName,readMCPConfigFile), whichsrc/omp/mcp.tswraps for the tickets page, Settings › Integrations, and Settings › MCP servers. The MCP sign-ins and sign-outs read and write omp's credential store through the samediscoverAuthStorage, opened and closed on each call.pi-coding-agent/src/commands/token.tsusesrefreshStoredManagedMcpOAuthCredentialfromoauth-credentials.tsto refresh a managed token and persist its rotated refresh token before printing the access token. - Completions:
pi-tui/src/autocomplete.ts, and the skills and slash commands inpi-coding-agent/src/extensibility/. - Paths:
pi-utils/src/dirs.ts, which names omp's sessions directory, andgetWorktreesDir, its directory of isolation sandboxes. - Isolation sandboxes:
ISOLATION_OWNER_FILEandhasLiveIsolationOwnerinpi-coding-agent/src/task/isolation-ownership.ts, the markerensureIsolationintask/worktree.tswrites and the check of its process id and start time, andstopRetainedMountinpi-coding-agent/src/cli/worktree-cli.ts, the teardownomp worktree clearruns on a retained mount, whichsrc/omp/isolation.tshands the sweep; see Isolation sandboxes. - Daemon brokers:
collectReportsandscopeClientinpi-coding-agent/src/cli/ps-data.ts, whatomp pslists without starting a broker and the client whosestopends one generation of a service,TERMINAL_STATESinpi-tui/src/apps/ps-data.ts, the states with no process behind them, andcanonicalProjectDirinpi-coding-agent/src/launch/paths.ts, the directory a project's broker is keyed by, whichsrc/omp/daemons.tshands the process watch; see Session processes. - Request usage:
omp-stats/src/aggregator.ts(getDashboardStats,getToolDashboardStats,getTimeRangeConfig),rollup.ts(getProviderTimeSeries),live.ts(statsLive), anddb.ts(initDb).src/omp/stats.tsreads omp-stats' database and starts its live sync on its first read, which the provider check makes at startup.pi-catalog/src/models.tsprovidesgetBundledModelandcalculateCost, whichlistPriceinsrc/omp/stats.tsuses to price Claude Code and Codex requests.pi-catalog/src/types.tsdefines their model and usage arguments, including Anthropic's cache-write lifetimes. - Request context:
buildSessionContextinpi-coding-agent/src/session/session-context.ts, the messages a request on a branch sends,Tokenizerinpi-agent-core/src/tokenizer.ts, andresolveModelTokenizerinpi-catalog/src/model-tokenizer.ts, whichsrc/omp/context-index.tsuses to count each request's context sources;getStatsDbPathinpi-utils/src/dirs.tsplaces its index beside omp-stats' database. - Request errors:
is402BillingCapBodyinpi-ai/src/error/rate-limit.ts, the test omp's credential rotation applies to a 402, whichcreditRunsinsrc/omp/stats.tsuses to tell a provider out of prepaid credits from a 402 that asks for a smaller request.classifyMessage,is,Flag.UsageLimit, andFlag.Transientinpi-ai/src/error/flags.ts, andextractRetryHintinpi-utils/src/fetch-retry.ts, tell a turn that a usage limit or a transient connection or provider fault ended, and the wait a limit's error names, forturnFailureOfinsrc/omp/turn-failure.ts; see Dashboard sessions. - Updates:
getLatestReleaseinpi-coding-agent/src/cli/update-cli.ts, thestartup.checkUpdateandupdate.channelreaders inpi-coding-agent/src/modes/settings.ts, andclassifyModelinpi-catalog/src/identity/index.ts, whichsrc/omp/release.tsandsrc/omp/model-updates.tsuse; see Notifications.