Commit Graph

6022 Commits

Author SHA1 Message Date
Artur Do Lago ed332849ba feat(auth): add proactive OAuth token refresh
- Add Auth.refreshToken() to refresh a specific provider's token
- Add Auth.refreshAllExpiring() to refresh all tokens expiring within 10 min
- Add Auth.status() to get token validity info for all providers
- Add Auth.isExpiringSoon() and Auth.isExpired() helpers
- Call refreshAllExpiring() during provider initialization

Supported providers: anthropic, openai
Note: google/antigravity uses plugin-handled custom flow

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:30:39 +01:00
Artur Do Lago 8cbec1055a fix(provider): add topP 0.95 for Claude thinking models via Antigravity
- Add topP: 0.95 to antigravity Claude thinking model definitions
- Add topP check in transform.ts for claude+thinking models
- Wrap plugin fetch to remove x-goog-api-key header (conflicts with OAuth)
- Add createEffect to properly initialize agent selection on load
- Update CLAUDE.md with binary update process documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:30:39 +01:00
Artur Do Lago 8acc1f46f2 fix(tui): add favorites support to model selector
Add favorite property to model store and favorite() method required
by dialog-model.tsx after upstream merge.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:27:57 +01:00
Artur Do Lago b145c26d65 fix(provider): remove redundant google-antigravity, keep auth passthrough
The google-antigravity provider was redundant - the opencode-antigravity-auth
plugin already handles OAuth, request transformation, and API calls through
the standard 'google' provider.

Testing confirmed google/gemini-2.5-flash works via the plugin:
  bun run ./src/index.ts run --model google/gemini-2.5-flash "Say hello"

Changes:
- Remove google-antigravity custom loader and provider definition
- Remove antigravity.ts token refresh helper (unused)
- Keep auth OAuth passthrough for extra fields like projectId, email

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:27:57 +01:00
Artur Do Lago 9755f3f7ca fix(gateway): fix Telegram message API format and agent routing
- Fix API message format: use `parts` array instead of `content`
- Add `agent` parameter to route messages to correct persona
- Add `x-opencode-directory` header for proper session handling
- Same fixes as WhatsApp gateway

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:27:57 +01:00
Artur Do Lago 3d0322904d fix(provider): persist model selection and add google-antigravity provider
- Fix model selection not persisting across restarts by saving/loading
  the model field in model.json (was only saving recent and variant)
- Call save() on every model change, not just when adding to recents
- Add google-antigravity provider for free Gemini access via OAuth
- Create antigravity.ts helper for token refresh via antigravity proxy
- Provider inherits all Google models but marks them as free (cost: 0)
- Auto-refresh tokens with 5-minute buffer before expiry

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:27:57 +01:00
Artur Do Lago ffd8ad8ab3 feat(gateway): simplify WhatsApp to Zee-only channel
- WhatsApp is exclusively Zee's channel using GLM 4.7 via Z.ai (cerebras)
- Remove persona detection patterns (Stanley/Johny use Telegram instead)
- Fix API message format: use `parts` array instead of `content`
- Add `agent` parameter to route messages to correct persona
- Add `x-opencode-directory` header for proper session handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:27:57 +01:00
Artur Do Lago 827356d06f fix(gateway): save WhatsApp QR code as PNG file for reliable scanning
Terminal QR codes can be distorted by font size/line height. Save QR as
PNG file that can be opened with an image viewer for reliable scanning.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:27:24 +01:00
Artur Do Lago cc24425a97 refactor(cli): rename opencode references to agent-core for global installation
Update CLI to use agent-core naming consistently so it can be installed
and run globally without confusion with upstream opencode project.

- Update yargs scriptName to agent-core
- Add AGENT_CORE env var (keep OPENCODE for backwards compat)
- Update build to output agent-core binary
- Update bin shim to find both agent-core-* and opencode-* packages
- Update all command descriptions to use agent-core

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:27:24 +01:00
Artur Do Lago 74455ea5e2 fix(web): update workspace dependency from opencode to agent-core
The web package still referenced the old "opencode" workspace name,
causing bun install to fail with "Workspace dependency not found".

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:58 +01:00
Artur Do Lago 862a3c1961 feat(gateway): add WhatsApp gateway for remote access
- New WhatsApp gateway using whatsapp-web.js
- QR code authentication on first run
- Session persistence across restarts
- Intent-based persona routing (same as Telegram)
- Phone number allowlist support
- Integrated into daemon with --whatsapp flag

Usage:
  opencode daemon --whatsapp --port 4567

Note: Requires whatsapp-web.js and qrcode-terminal packages.
Dynamic imports allow graceful failure if not installed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:58 +01:00
Artur Do Lago 5b08669ddd fix(tui): load todos directly from storage for startup check
sync.data.todo is only populated when sessions are opened, so the
startup check was always finding zero todos. Now uses Todo.get()
to read directly from storage for each session.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:58 +01:00
Artur Do Lago 38fd95f15b feat(tui): add startup check for pending todos across sessions
Phase 0.3 completion:
- Show toast on TUI startup if any sessions have incomplete todos
- Display count: "◐ N pending todos in M sessions"
- Update roadmap: mark Phase 0 as Complete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:58 +01:00
Artur Do Lago 40670f7cff feat(tui): improve prompt hint for incomplete todos
- Filter out cancelled todos (consistency with other implementations)
- Update display to use ◐ symbol: "◐ N pending · task..."
- Mark Phase 0.2 TUI Integration as complete in roadmap

The prompt hint was already implemented, this commit improves it
for consistency with the session list indicator.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:58 +01:00
Artur Do Lago 1b815538be feat(tui): add toast notification for incomplete todos when switching sessions
When switching between sessions in the TUI:
- Shows toast warning with count of incomplete todos
- Session list displays ◐{count} indicator for sessions with pending work

This helps users track unfinished tasks across sessions.

Updates roadmap Phase 0.2 TUI Integration status.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:58 +01:00
Artur Do Lago fe0f8ecf64 refactor(ui): replace emojis with sober UTF-8 unicode symbols
Replace all emoji characters with standard Unicode symbols that render
correctly in terminals with UTF-8 support.

Persona icons:
- Zee: 🧠💜🤖 → ★ (U+2605 Black Star)
- Stanley: 📈 → ♦ (U+2666 Black Diamond)
- Johny: 📚🎓🧠 → ◎ (U+25CE Bullseye)

Status indicators:
- Working: ↻ → ⟳ (wider rotating arrow)
- Pending: ◔ → ◐ (wider half circle)
- Completed: ✓ → ✔ (heavier check)
- Hold mode: ◆ → ▣ (square with inner square)
- Release mode: ◇ → ▢ (rounded square)

Other changes:
- Status headers: 🔺📊 → ◆◈
- Calendar indicator: 📅 → ▦
- Make persona parameter required in createSessionPane()
- Fix keybind conflicts: mode_toggle → <leader>h,
  messages_toggle_conceal → <leader>/, tips_toggle → <leader>?
- Add persistent hold/release indicator in prompt

All symbols are in the Basic Multilingual Plane (BMP) for maximum
terminal compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:58 +01:00
Artur Do Lago da2d7beac8 fix(tui): don't fallback to first provider when agents loading
When using the placeholder agent (before real agents load), return
undefined instead of falling back to the first provider's model.
This prevents showing google-vertex-anthropic models before the
agent's configured model loads.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:58 +01:00
Artur Do Lago b83f23ae27 fix(tui): enable agent cycling and mode toggle commands
- Remove disabled: true from agent_cycle and agent_cycle_reverse
- Remove disabled: true from mode_toggle
- Tab now switches between agents as expected

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:58 +01:00
Artur Do Lago b942644003 fix(tui): add placeholder agent for loading state
Return a placeholder agent object when no agents have loaded yet,
preventing crashes when accessing .name or other properties on
undefined.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:28 +01:00
Artur Do Lago ac29b335db fix(tui): handle undefined agent in current() gracefully
When agents haven't loaded yet or the stored agent name doesn't match
any loaded agent, fallback to the first available agent instead of
returning undefined which caused crashes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:28 +01:00
Artur Do Lago 525fb52f12 fix(tui): trust agent's configured model without validation
Agent-configured models (like cerebras/zai-glm-4.7) may not be in the
provider list returned by the API. Instead of validating and falling
back, trust the agent's configured model directly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:28 +01:00
Artur Do Lago 6e660cc506 fix(tui): prioritize agent's configured model over cached selection
Agent's model config now takes priority:
1. Agent's configured model (from .agent-core/agent/*.md)
2. User's cached selection (for agents without config)
3. Global fallback

This ensures personas always use their intended models on startup.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:28 +01:00
Artur Do Lago 9055690525 refactor: clean up dead code and fix working directory detection
- Delete unused prompt files (anthropic-20250930.txt, copilot-gpt-5.txt, explore.txt)
- Fix thread.ts to use AGENT_CORE_ORIGINAL_PWD for correct cwd detection
- Remove misleading tips about non-existent vim features (:w, :wq, :help)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:28 +01:00
Artur Do Lago 79e87bad37 fix(llm): filter out non-provider options from agent config
The 'includes' field (for skill loading) was being passed to providers
like Cerebras, causing "body.includes is unsupported" errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:28 +01:00
Artur Do Lago 938c0f62c2 fix(provider): improve Anthropic model version filtering
- Parse all Claude naming formats (old/new with/without minor version)
- Prioritize highest version number over -latest suffix
- Group by model family (opus, sonnet, haiku) and keep only best version

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:25:42 +01:00
Artur Do Lago f5fb04b208 refactor(tui): hide dated model versions and remove variant cycle
- Auto-hide dated model versions (e.g. claude-opus-4-5-20250202) when
  latest or base version exists for Anthropic and Z.AI providers
- Remove variant cycle command from agent options

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:25:42 +01:00
Artur Do Lago 72c71a3a17 feat: rename .opencode to .agent-core and add vim commands
- Rename config directory from .opencode/ to .agent-core/
- Add vim-style commands: :w (commit), :q (quit), :wq, :e, :help, :mode
- Update version format to V0.YYYYMMDD
- Remove unused plan/build prompt files
- Update SDK generated files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:25:16 +01:00
Artur Do Lago d22fd66a24 feat(tui): vim-style commands and branding updates
- Change command prefix from / to : (vim-style, e.g. :connect, :models)
- Update tips with vim commands (:w, :q, :wq, :help)
- Update branding from OpenCode to agent-core in sidebar
- Update footer hints to use : prefix

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:16:53 +01:00
Artur Do Lago 91363ca549 refactor(tui): remove favorite and suggested commands features
Simplify the UI by removing:
- Model favorites (toggleFavorite, favorite list, Ctrl+F keybind)
- Suggested commands category in command palette

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:12:28 +01:00
Artur Do Lago 4126df9d2b fix(tui): show persona banners and remove OpenRouter warning
- Replace AGENT-CORE logo with dynamic persona ASCII art
- Logo now shows Zee, Stanley, or Johny based on active persona
- Remove OpenRouter warning dialog (was promoting OpenCode Zen)
- Update CLI logo to show Zee banner (default persona)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:06:37 +01:00
Artur Do Lago 47d3e7ef9a feat(branding): rename package to agent-core and configure personas
- Rename packages/opencode to packages/agent-core
- Update bin entry from opencode to agent-core
- Set default_agent to "zee" for persona-first UX
- Update terminal title to show current persona name
- Fix persona colors:
  - Zee: #2563EB (blue)
  - Stanley: #059669 (emerald green)
  - Johny: #DC2626 (red)
- Update all documentation and build script references
- Update root package.json name and dev script

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:05:26 +01:00
Artur Do Lago 240e989e8f feat(daemon): add lifecycle hooks and WezTerm orchestration (Phase 4-5)
Phase 4: Tiara Hook Integration
- Add lifecycle hooks module (src/hooks/lifecycle.ts)
- Daemon lifecycle hooks: start, ready, shutdown
- Session lifecycle hooks: start, restore, end, transfer
- Todo lifecycle hooks: continuation, completed, blocked
- Integrate hooks with daemon startup/shutdown
- Integrate hooks with Telegram gateway for session events

Phase 5: WezTerm Visual Orchestration
- Add WezTerm orchestration module (src/orchestration/wezterm.ts)
- Display detection (X11 via DISPLAY, Wayland via WAYLAND_DISPLAY)
- Status pane showing daemon health, services, sessions
- Session pane management API (create/close/focus)
- Graceful degradation when no display available
- CLI options: --wezterm, --wezterm-layout
- Integration with lifecycle hooks for auto-updates

Also includes:
- Session persistence module (src/session/persistence.ts)
- Telegram gateway (src/gateway/telegram.ts)
- Daemon CLI command (src/cli/cmd/daemon.ts)
- Systemd service files (scripts/systemd/)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:54:24 +01:00
Artur Do Lago bb5857fb3b feat(todo-continuation): integrate todo continuation into TUI
Phase 0.2 of Always-On Personas architecture:

- Add toast notification on session switch when incomplete todos exist
  (routes/session/index.tsx)
- Inject system reminder into LLM context for incomplete tasks
  (session/prompt.ts)
- Add visual hint in prompt area showing current todo progress
  (component/prompt/index.tsx)
- Create architecture roadmap for Always-On Personas system
  (docs/architecture/ALWAYS-ON-PERSONAS.md)

This enables automatic continuation of incomplete tasks when:
1. Switching to a session with pending todos (toast + hint)
2. Sending any prompt in a session with incomplete tasks (system reminder)

Part of the headless agent infrastructure for remote access via Zee.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:54:09 +01:00
Artur Do Lago d144d36e8c fix: use agent-core config path and guard against empty agents array
- Change app name from "opencode" to "agent-core" so config loads from
  ~/.config/agent-core/ where personas (zee, johny, stanley) are defined
- Add defensive optional chaining to prevent crash if agents array is
  empty during initialization

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:53:31 +01:00
Artur Do Lago b839e53c5c fix(fallback): handle mid-stream errors with automatic fallback
When providers like OpenAI return a stream successfully but error during
iteration (e.g., insufficient_quota mid-stream), the fallback system now
catches these errors and switches to a fallback provider.

Key changes:
- Add wrapFullStream() using Proxy to intercept async iteration
- Add tryMidStreamFallback() for mid-stream recovery
- Wrap all returned streams with the mid-stream error handler
- Emit FallbackUsed event with "mid-stream:" reason prefix

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:53:31 +01:00
Artur Do Lago eaa3df3fe7 fix(fallback): add insufficient_quota error classification
- Classify OpenAI insufficient_quota errors as rate_limit to trigger fallback
- Add quota pattern matching in JSON error body parsing
- Add quota string pattern matching for error messages
- Remove premature success recording - stream might still error during iteration

Note: Stream-time errors (errors during iteration) are not yet caught by
fallback retry logic. This is a known limitation when errors occur mid-stream
rather than at call time.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:53:31 +01:00
Artur Do Lago 3ca5a72a73 feat: Add EXA_API_KEY support to WebSearch tool
Reads EXA_API_KEY from environment for higher rate limits.
Falls back to public MCP endpoint if not set.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:53:31 +01:00
Artur Do Lago 171e2db8b3 feat(personas): add model config, TUI banner, and fallback system
- Configure per-persona models with temperature/top_p:
  - Zee: cerebras/zai-glm-4.7 (0.8/0.9)
  - Stanley: openrouter/xai/grok-4.1-fast (0.7/0.85)
  - Johny: antigravity/claude-opus-4-5 (0.8/0.9)
- Configure internal agents:
  - title: cerebras/gpt-oss-120b (0.5)
  - compaction: antigravity/gemini-3-flash (0.3)
- Add ASCII art banner on startup with Tab switching
- Sort agents reverse alphabetically (Zee, Stanley, Johny)
- Add provider fallback system with circuit breaker

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:53:04 +01:00
Artur Do Lago 6d4c0aaf6e feat: replace built-in agents with Personas triad
- Remove hardcoded build/plan/general/explore agents from source
- Add Zee, Stanley, Johny agent definitions in .opencode/agent/
- Remove upstream docs/duplicate-pr/triage agents
- Update CLAUDE.md with agent-core → tiara → personas architecture
- Configure Cerebras as default model for all agents (fast instruct)
- Set small_model for internal agents (title, compaction)

The Personas system now provides all agent functionality through
the triad, with shared orchestration via tiara.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:53:04 +01:00
GitHub Action 616329ae97 chore: generate 2026-01-20 06:33:16 +00:00
Aiden Cline 9706aaf552 rm filetime assertions from patch tool 2026-01-20 00:32:29 -06:00
Brendan Allan 8b379329a6 fix(desktop): completely disable pinch to zoom 2026-01-20 14:07:39 +08:00
Craig Jellick 68d1755a9e fix: add space toggle hint to tool selection prompt (#9535) 2026-01-19 23:38:26 -06:00
Aiden Cline 419004992d chore: remove duplicate prompt file 2026-01-19 23:22:57 -06:00
Aiden Cline 0d49df46ef fix: ensure truncation handling applies to mcp servers too 2026-01-19 23:19:24 -06:00
James Meng 36f5ba52e9 fix(batch): update batch tool definition to outline correct value for max tool calls (#9517) 2026-01-19 22:15:02 -06:00
GitHub Action 088b537657 chore: generate 2026-01-20 01:42:14 +00:00
Filip 4ddfa86e7f fix(app): message list overflow & scrolling (#9530) 2026-01-19 19:41:42 -06:00
David Hill b91b76e9eb add 8px padding to recent sessions popover 2026-01-20 01:41:36 +00:00
David Hill 6ed656a615 remove top padding from edit project dialog form 2026-01-20 01:36:34 +00:00