mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-25 14:53:34 +00:00
* feat: add Codex auth.json token reuse for LLM authentication When LLM_USE_CODEX_AUTH=true, IronClaw reads the Codex CLI's auth.json (default ~/.codex/auth.json) and extracts the API key or OAuth access token. This lets IronClaw piggyback on a Codex login without implementing its own OAuth flow. New env vars: - LLM_USE_CODEX_AUTH: enable Codex auth fallback (default: false) - CODEX_AUTH_PATH: override path to auth.json * fix: handle ChatGPT auth mode correctly Switch base_url to chatgpt.com/backend-api/codex when auth.json contains ChatGPT OAuth tokens. The access_token is a JWT that only works against the private ChatGPT backend, not the public OpenAI API. Refactored codex_auth.rs to return CodexCredentials (token + is_chatgpt_mode) instead of just a string key. * fix: Codex auth takes highest priority over secrets store When LLM_USE_CODEX_AUTH=true, Codex credentials are now loaded before checking env vars or the secrets store overlay. Previously the secrets store key (injected during onboarding) would shadow the Codex token. * feat: Responses API provider for ChatGPT backend - New CodexChatGptProvider speaks the Responses API protocol - Auto-detects model from /models endpoint (gpt-4o -> gpt-5.2-codex) - Adds store=false (required by ChatGPT backend) - Error handling with timeout for HTTP 400 responses - Message format translation: Chat Completions -> Responses API - SSE response parsing for text, tool calls, and usage stats - 7 unit tests for message conversion and SSE parsing * fix: SSE parser uses item_id instead of call_id for tool call deltas The Responses API sends function_call_arguments.delta events with item_id (e.g. fc_...) not call_id (e.g. call_...). The parser now keys pending tool calls by item_id from output_item.added and tracks call_id separately for result matching. * fix: strip empty string values from tool call arguments gpt-5.2-codex fills optional tool parameters with empty strings (e.g. timestamp: ""), which IronClaw's tool validation rejects. Strip them before passing to tool execution. * fix: prevent apiKey mode fallback to ChatGPT token When auth_mode is explicitly 'apiKey' but the key is missing/empty, do not fall through to check for a ChatGPT access_token. This prevents returning credentials with is_chatgpt_mode: true and routing to the wrong LLM provider. * refactor: reuse single reqwest::Client across model discovery and LLM calls Create Client once in with_auto_model, pass &Client to fetch_default_model, and move it into the provider struct. Eliminates the redundant Client::new() that wasted a connection pool. * fix: bump client_version to 1.0.0 to unlock gpt-5.3-codex and gpt-5.4 The /models endpoint gates newer models behind client_version. Version 0.1.0 only returns up to gpt-5.2-codex, while 1.0.0+ also returns gpt-5.3-codex and gpt-5.4. * feat: user-configured LLM_MODEL takes priority over auto-detection Fetch the full model list from /models endpoint. If LLM_MODEL is set, validate it against the supported list and warn with available models if not found. If LLM_MODEL is not set, auto-detect the highest-priority model. Also bumps client_version to 1.0.0 to unlock gpt-5.3/5.4. * fix: add 10s timeout to model discovery HTTP request Prevents startup from blocking indefinitely if chatgpt.com is slow or unreachable. Uses reqwest per-request timeout. * docs: add private API warning for ChatGPT backend endpoint The chatgpt.com/backend-api/codex endpoint is private and undocumented. Add warning in module docs and a runtime log on first use to inform users of potential ToS implications. * feat: implement OAuth 401 token refresh for Codex ChatGPT provider On HTTP 401, if a refresh_token is available, the provider now automatically refreshes the access token via auth.openai.com/oauth/token (same protocol as Codex CLI) and retries the request once. Refreshed tokens are persisted back to auth.json. Changes: - codex_auth: read refresh_token, add refresh_access_token() and persist_refreshed_tokens() - codex_chatgpt: RwLock for api_key, 401 detection + retry in send_request, send_http_request helper - config/llm: thread refresh_token/auth_path through RegistryProviderConfig - llm/mod: pass refresh params to with_auto_model * refactor: lazy model detection via OnceCell, remove block_in_place Model is no longer resolved during provider construction. Instead, resolve_model() uses tokio::sync::OnceCell to lazily fetch from /models on the first LLM call. This eliminates the block_in_place + block_on workaround in create_codex_chatgpt_from_registry. - with_auto_model (async) -> with_lazy_model (sync constructor) - resolve_model() added with OnceCell-based lazy init - build_request_body takes model as parameter - model_name() returns resolved or configured_model as fallback * feat: support multimodal content (images) in Codex ChatGPT provider message_to_input_items now checks content_parts for user messages. ContentPart::Text maps to input_text and ContentPart::ImageUrl maps to input_image, matching the Responses API format used by Codex CLI. Falls back to plain text when content_parts is empty. Also updates client_version to 0.111.0 for /models endpoint. Adds test: test_message_conversion_user_with_image * refactor: move codex_auth module from src/ to src/llm/ codex_auth is only used by the LLM layer (codex_chatgpt provider and config/llm). Moving it under src/llm/ reflects its actual scope. - Remove pub mod codex_auth from lib.rs - Add pub mod codex_auth to llm/mod.rs - Update imports: super::codex_auth, crate::llm::codex_auth * Fix codex provider style issues * Use SecretString throughout codex auth refresh flow * Use SecretString for codex access tokens * Reuse provider client for codex token refresh * Stream Codex SSE responses incrementally * Fix Windows clippy and SQLite test linkage * Trigger checks after regression skip label * Tighten codex auth module handling
282 lines
8.0 KiB
TOML
282 lines
8.0 KiB
TOML
[workspace]
|
|
members = [".", "crates/ironclaw_safety"]
|
|
exclude = [
|
|
"channels-src/discord",
|
|
"channels-src/telegram",
|
|
"channels-src/slack",
|
|
"channels-src/whatsapp",
|
|
"tools-src/github",
|
|
"tools-src/gmail",
|
|
"tools-src/google-calendar",
|
|
"tools-src/google-docs",
|
|
"tools-src/google-drive",
|
|
"tools-src/google-sheets",
|
|
"tools-src/google-slides",
|
|
"tools-src/slack",
|
|
"tools-src/telegram",
|
|
"fuzz",
|
|
"crates/ironclaw_safety/fuzz",
|
|
]
|
|
|
|
[package]
|
|
name = "ironclaw"
|
|
version = "0.18.0"
|
|
edition = "2024"
|
|
rust-version = "1.92"
|
|
description = "Secure personal AI assistant that protects your data and expands its capabilities on the fly"
|
|
authors = ["NEAR AI <[email protected]>"]
|
|
license = "MIT OR Apache-2.0"
|
|
homepage = "https://github.com/nearai/ironclaw"
|
|
repository = "https://github.com/nearai/ironclaw"
|
|
|
|
[package.metadata.wix]
|
|
upgrade-guid = "D0156E61-BA37-451E-8AB9-1A2ECCCFA48F"
|
|
path-guid = "F90B6EA6-87F7-499B-BB19-CF55DE1EB339"
|
|
license = false
|
|
eula = false
|
|
|
|
[dependencies]
|
|
# Async runtime
|
|
tokio = { version = "1", features = ["full"] }
|
|
tokio-stream = { version = "0.1", features = ["sync"] }
|
|
futures = "0.3"
|
|
eventsource-stream = "0.2"
|
|
|
|
# HTTP client
|
|
reqwest = { version = "0.12", default-features = false, features = ["json", "multipart", "rustls-tls-native-roots", "stream"] }
|
|
|
|
# Serialization
|
|
serde = { version = "1", features = ["derive"] }
|
|
serde_json = "1"
|
|
|
|
# Database - PostgreSQL (default, feature-gated)
|
|
deadpool-postgres = { version = "0.14", optional = true }
|
|
tokio-postgres = { version = "0.7", features = ["with-uuid-1", "with-chrono-0_4", "with-serde_json-1"], optional = true }
|
|
postgres-types = { version = "0.2", features = ["with-serde_json-1"], optional = true }
|
|
refinery = { version = "0.8", features = ["tokio-postgres"], optional = true }
|
|
tokio-postgres-rustls = { version = "0.13", optional = true }
|
|
rustls = { version = "0.23", optional = true, default-features = false }
|
|
rustls-native-certs = { version = "0.8", optional = true }
|
|
|
|
# Database - libSQL/Turso (optional embedded database)
|
|
libsql = { version = "0.6", optional = true, default-features = false, features = ["core", "replication", "remote", "tls"] }
|
|
|
|
# Error handling
|
|
thiserror = "2"
|
|
anyhow = "1"
|
|
|
|
# Logging
|
|
tracing = "0.1"
|
|
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
|
|
|
|
# Configuration
|
|
dotenvy = "0.15"
|
|
toml = "0.8"
|
|
|
|
# Core types
|
|
uuid = { version = "1", features = ["v4", "v5", "serde"] }
|
|
chrono = { version = "0.4", features = ["serde"] }
|
|
chrono-tz = "0.10"
|
|
iana-time-zone = "0.1"
|
|
rust_decimal = { version = "1", features = ["serde", "serde-with-str", "maths"] }
|
|
rust_decimal_macros = "1"
|
|
|
|
# Async traits
|
|
async-trait = "0.1"
|
|
|
|
# CLI
|
|
clap = { version = "4", features = ["derive", "env"] }
|
|
|
|
# Terminal
|
|
crossterm = "0.28"
|
|
rustyline = { version = "17", features = ["custom-bindings", "derive", "with-file-history"] }
|
|
termimad = "0.34"
|
|
|
|
# Channel integrations
|
|
axum = { version = "0.8", features = ["ws"] }
|
|
tower = "0.5"
|
|
tower-http = { version = "0.6", features = ["trace", "cors", "set-header"] }
|
|
|
|
# Cron scheduling for routines
|
|
cron = "0.13"
|
|
|
|
# Safety/sanitization
|
|
ironclaw_safety = { path = "crates/ironclaw_safety", version = "0.1.0" }
|
|
regex = "1"
|
|
aho-corasick = "1"
|
|
|
|
# YAML parsing for SKILL.md frontmatter
|
|
serde_yml = "0.0.12"
|
|
|
|
# Filesystem paths
|
|
dirs = "6"
|
|
fs4 = "0.6"
|
|
|
|
# Semantic versioning
|
|
semver = "1"
|
|
|
|
# Secrecy for sensitive values
|
|
secrecy = { version = "0.10", features = ["serde"] }
|
|
|
|
# URL parsing and encoding
|
|
url = "2"
|
|
urlencoding = "2"
|
|
|
|
# Open URLs in browser
|
|
open = "5"
|
|
|
|
# Vector embeddings for semantic search
|
|
# The postgres feature provides ToSql/FromSql for postgres-types (shared by tokio-postgres)
|
|
pgvector = { version = "0.4", features = ["postgres"], optional = true }
|
|
|
|
# WASM sandbox for untrusted tool execution
|
|
wasmtime = { version = "28", features = ["component-model"] }
|
|
wasmtime-wasi = "28" # WASI support for component model
|
|
wasmparser = "0.220" # WASM binary parsing for validation
|
|
|
|
# Cryptography for secrets management
|
|
aes-gcm = "0.10"
|
|
hkdf = "0.12"
|
|
hmac = "0.12"
|
|
sha2 = "0.10"
|
|
blake3 = "1"
|
|
rand = "0.8"
|
|
subtle = "2" # Constant-time comparisons for token validation
|
|
|
|
# Multi-provider LLM support
|
|
rig-core = "0.30"
|
|
|
|
# AWS Bedrock (native Converse API, opt-in via --features bedrock)
|
|
aws-config = { version = "1", features = ["behavior-version-latest"], optional = true }
|
|
aws-sdk-bedrockruntime = { version = "1", optional = true }
|
|
aws-smithy-types = { version = "1", optional = true }
|
|
|
|
# Docker sandbox
|
|
bollard = "0.18"
|
|
|
|
# Archive extraction for WASM extension bundles
|
|
flate2 = "1"
|
|
tar = "0.4"
|
|
|
|
# Document text extraction
|
|
pdf-extract = "0.7"
|
|
zip = { version = "2", default-features = false, features = ["deflate"] }
|
|
|
|
# HTTP proxy for sandboxed network access
|
|
hyper = { version = "1.5", features = ["server", "http1", "http2"] }
|
|
hyper-util = { version = "0.1", features = ["server", "tokio", "http1", "http2"] }
|
|
http-body-util = "0.1"
|
|
bytes = "1"
|
|
base64 = "0.22.1"
|
|
mime_guess = "2.0.5"
|
|
clap_complete = "4.5.0"
|
|
lru = "0.16.3"
|
|
|
|
# HTML to Markdown conversion (feature gated)
|
|
html-to-markdown-rs = { version = "2.3", optional = true }
|
|
readabilityrs = { version = "0.1.2", optional = true }
|
|
ed25519-dalek = { version = "2.2.0", features = ["std"] }
|
|
hex = "0.4.3"
|
|
|
|
# OpenClaw import (feature gated)
|
|
json5 = { version = "0.4", optional = true }
|
|
|
|
# macOS keychain
|
|
[target.'cfg(target_os = "macos")'.dependencies]
|
|
security-framework = "3"
|
|
|
|
# Linux secret-service (GNOME Keyring, KWallet)
|
|
[target.'cfg(target_os = "linux")'.dependencies]
|
|
secret-service = { version = "4", features = ["rt-tokio-crypto-rust"] }
|
|
zbus = "4"
|
|
|
|
[dev-dependencies]
|
|
tokio-test = "0.4"
|
|
tracing-test = "0.2"
|
|
tokio-tungstenite = "0.26"
|
|
testcontainers-modules = { version = "0.11", features = ["postgres"] }
|
|
pretty_assertions = "1"
|
|
tempfile = "3"
|
|
insta = "1.46.3"
|
|
criterion = "0.5"
|
|
|
|
[[bench]]
|
|
name = "safety_check"
|
|
harness = false
|
|
|
|
[[bench]]
|
|
name = "safety_pipeline"
|
|
harness = false
|
|
|
|
[features]
|
|
default = ["postgres", "libsql", "html-to-markdown"]
|
|
postgres = [
|
|
"dep:deadpool-postgres",
|
|
"dep:tokio-postgres",
|
|
"dep:tokio-postgres-rustls",
|
|
"dep:rustls",
|
|
"dep:rustls-native-certs",
|
|
"dep:postgres-types",
|
|
"dep:refinery",
|
|
"dep:pgvector",
|
|
"rust_decimal/db-tokio-postgres",
|
|
]
|
|
libsql = ["dep:libsql"]
|
|
integration = []
|
|
html-to-markdown = ["dep:html-to-markdown-rs", "dep:readabilityrs"]
|
|
bedrock = ["dep:aws-config", "dep:aws-sdk-bedrockruntime", "dep:aws-smithy-types"]
|
|
import = ["dep:json5", "libsql"]
|
|
|
|
[[test]]
|
|
name = "html_to_markdown"
|
|
required-features = ["html-to-markdown"]
|
|
|
|
[profile.release]
|
|
strip = true # Remove debug symbols from release binaries
|
|
|
|
# The profile that 'cargo dist' will build with
|
|
[profile.dist]
|
|
inherits = "release"
|
|
lto = "fat" # Full cross-crate LTO (slow build, better codegen)
|
|
codegen-units = 1 # Single codegen unit for maximum optimization
|
|
|
|
# Config for 'dist'
|
|
[workspace.metadata.dist]
|
|
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
|
|
cargo-dist-version = "0.30.3"
|
|
# Ignore out-of-date generated CI so custom release.yml jobs are allowed
|
|
allow-dirty = ["ci"]
|
|
# CI backends to support
|
|
ci = "github"
|
|
# The installers to generate for each app
|
|
installers = ["shell", "powershell", "npm", "msi"]
|
|
# Publish jobs to run in CI
|
|
publish-jobs = []
|
|
# Target platforms to build apps for (Rust target-triple syntax)
|
|
targets = [
|
|
"aarch64-apple-darwin",
|
|
"aarch64-unknown-linux-gnu",
|
|
"x86_64-apple-darwin",
|
|
"x86_64-unknown-linux-gnu",
|
|
"x86_64-pc-windows-msvc",
|
|
]
|
|
# The archive format to use for windows builds (defaults .zip)
|
|
windows-archive = ".tar.gz"
|
|
# The archive format to use for non-windows builds (defaults .tar.xz)
|
|
unix-archive = ".tar.gz"
|
|
# Which actions to run on pull requests
|
|
pr-run-mode = "skip"
|
|
# Path that installers should place binaries in
|
|
install-path = "CARGO_HOME"
|
|
# Whether to install an updater program
|
|
install-updater = true
|
|
# Cache intermediate build artifacts to speed up the release pipelines
|
|
cache-builds = true
|
|
|
|
[workspace.metadata.dist.github-custom-runners]
|
|
aarch64-unknown-linux-gnu = "ubuntu-24.04-arm"
|
|
x86_64-unknown-linux-gnu = "ubuntu-22.04"
|
|
x86_64-pc-windows-msvc = "windows-2022"
|
|
x86_64-apple-darwin = "macos-15-intel"
|
|
aarch64-apple-darwin = "macos-14"
|