Claude Code Process Execution
Relevant source files
The following files were used as context for generating this wiki page:
The Claude Code Process Execution system within ollacc serves as a specialized wrapper designed to bypass local Ollama server installations and interface directly with the Ollama Cloud API. It prepares the necessary environment variables, resolves the target model through a prioritized discovery process, and ultimately executes the claude command-line tool.
This execution flow ensures that the Anthropic SDK is correctly configured to treat https://ollama.com as an OpenAI-compatible endpoint. By managing authentication tokens and model selections, it allows users to leverage cloud-hosted models while maintaining the standard claude command interface.
Sources: README.md:1-26, README.md:143-156
Environment Configuration
Before execution, the system must establish specific environment variables required by the Anthropic SDK. A critical requirement for this integration is the handling of the ANTHROPIC_API_KEY, which must be explicitly set to an empty string to force the SDK to utilize the ANTHROPIC_AUTH_TOKEN.
Required Environment Variables
| Variable | Value/Source | Purpose |
|---|---|---|
ANTHROPIC_BASE_URL | https://ollama.com | Directs the SDK to the Ollama Cloud endpoint. |
ANTHROPIC_AUTH_TOKEN | User's Ollama Cloud API Key | Provides authentication for API requests. |
ANTHROPIC_API_KEY | "" (Empty String) | Prevents the SDK from ignoring the auth token. |
Sources: lib/auth.sh:51-57, README.md:143-151
Execution Workflow
The execution process follows a linear progression from initialization to the final exec call. It involves flag handling, configuration loading, authentication validation, and model resolution.
Process Flow Diagram
The following diagram illustrates the logical flow from the initial ollacc command to the execution of claude.
Model Resolution Logic
The system employs a multi-tiered resolution strategy to determine which model to execute. This ensures the launcher remains functional even if specific external services are unavailable.
- Popular Order Scrape: Attempts to scrape
https://ollama.com/search?c=cloudfor the "Popular" model list. - Catalog Intersection: Intersects the popular list with the user's authenticated catalog fetched from
https://ollama.com/api/tags. - Authenticated Fallback: If scraping fails, it defaults to the order provided by the
/api/tagsendpoint. - Hardcoded Last-Resort: If all network attempts fail, it uses a hardcoded list of known models (e.g.,
kimi-k2.7-code,minimax-m3).
Sources: lib/catalog.sh:22-83
Model Discovery Sequence
This sequence diagram details the interaction between the local launcher and the Ollama Cloud API during model resolution.
Sources: lib/catalog.sh:31-59
Configuration Persistence
System settings are stored in ~/.ollacc/config with restricted permissions (chmod 600). This file is sourced as a bash script during initialization.
Configuration Schema
| Key | Description | File Path |
|---|---|---|
ANTHROPIC_AUTH_TOKEN | The user's private API key. | ~/.ollacc/config |
ANTHROPIC_BASE_URL | The API host (default: https://ollama.com). | ~/.ollacc/config |
OLLAMA_CLAUDE_DEFAULT_MODEL | The user's preferred model slug. | ~/.ollacc/config |
Sources: install.sh:65-71, lib/config.sh:41-76
Configuration Management Snippet
The following function demonstrates how parameters are safely written to the configuration file using bash escaping to prevent injection.
# lib/config.sh:41-45
config_set() {
local key="$1" value="$2" esc_value
esc_value=$(bash_escape "$value")
mkdir -p "$OLLACC_HOME"
touch "$OLLACC_CONFIG"
Sources: lib/config.sh:41-45
Process Handoff
The final stage of execution uses the exec command to replace the shell script process with the claude process. This ensures that signals and process management are handled directly by the Anthropic tool. The command is constructed as:
claude --model <chosen_model> [additional_args]
Any flags passed to ollacc that are not internal management flags (like --key-clear) are forwarded directly to the claude executable.
Sources: README.md:120-130, README.md:156
Summary
Claude Code Process Execution in ollacc is a specialized environment preparation and handoff mechanism. It centralizes authentication, dynamically discovers available cloud models through a tiered fallback system, and configures the environment to facilitate a direct connection between the claude CLI and Ollama Cloud. This architecture removes the necessity for a local Ollama server, streamlining high-concurrency "swarming" operations by offloading model execution entirely to the cloud.