Skip to content

AI Module

Slug: ai

Current architecture

AI Tools uses a connection-and-slot model. The top half of Settings manages CLI/API connections; the bottom half assigns ordered targets to Terminal, Summary, Dreaming, Analysis, and Assistant. See AI Tools for user workflows and CLI Provider development for the contract.

SlotPurposeConnection types
TerminalInteractive task terminalCLI only
SummaryShort execution summaryCLI / API
DreamingInsights and knowledge captureCLI / API
AnalysisProject analysisCLI / API
AssistantTower-owned multi-turn chatCLI / API

Built-in CLI providers are Claude Code, Codex CLI, and Gemini CLI. The API runtime supports OpenAI, OpenAI Compatible, Anthropic, and Google. Targets use a stable connectionId + modelId, not a provider name as an instance identifier.

Execution semantics

  • A slot uses only its explicit primary and ordered fallback targets.
  • Key or target fallback is allowed only before the first content, tool call, or side effect. Once activity starts, the target is locked.
  • Terminal may fall back before creating a new session. The successful connection/model snapshot is stored on TaskExecution and reused for resume.
  • API keys round-robin only among enabled, healthy keys. 401, 403, and 429 may rotate a key only before activity.
  • Attempt telemetry stores target, model, duration, and redacted error code, never prompts, keys, or sensitive header/query values.

Boundaries

LayerLocationResponsibility
Public CLI contractpackages/ai-sdkManifest v1, adapters, process specs, events, and config schema types
Private host runtimepackages/ai-runtimeControlled processes, API adapters, fallback, plugin validation, models.dev snapshot
Built-in providerspackages/ai-provider-*Claude/Codex/Gemini arguments, parsing, and MCP/Hooks/Skills integration
Application servicessrc/lib/aiConnections, slot resolution, Assistant sessions/tools, and auditing

All workspace packages remain private@0.1.0. That internal contract version is independent of the Tower application version; SDK and Provider packages are not yet published independently.

Security

  • Each CLI owns its login, token, and base URL. Tower handles discovery, Hello probes, process launch, and integration status.
  • API keys are plaintext in local SQLite. The UI masks them by default but permits reveal, copy, and edit; logs and errors are redacted.
  • Third-party CLI plugins are trusted local Node.js code, not an OS sandbox. Tower validates exact versions, integrity, static manifests/schemas, and declared permissions before enablement.
  • Adapters return structured process specs. The host disables shell execution by default and owns deadlines, cancellation, and process-tree cleanup.

Public npm publication, an external organization/scope, arbitrary API adapter plugins, and OS-level plugin sandboxing remain future work.