30 Commits

Author SHA1 Message Date
southseact-3d
a0eb6408f1 fix: mergeDeep only accepts 2 arguments - chain calls to fix CLI crash
Fixes remeda mergeDeep error that was causing all OpenCode CLI commands
to fail with 'Wrong number of arguments' before processing any messages.

The bug was introduced in commit 2536784 where providerPreference support
was added, passing 3 arguments to mergeDeep which only accepts 2.

Changed from:
  mergeDeep(A, B, C)
To:
  mergeDeep(mergeDeep(A, B), C)

This preserves the provider preference functionality while fixing the crash.
2026-02-19 15:50:39 +00:00
southseact-3d
25367847ed feat: add OpenRouter provider preference support
Implement provider preference feature for OpenRouter models:

1. Database Schema:
   - Add ModelProviderPreferenceTable to store provider preferences per model

2. Console Core API:
   - Add ProviderPreferenceSchema for validation
   - Add setProviderPreference(), getProviderPreference(), deleteProviderPreference(), and listProviderPreferences() functions

3. Request Handler:
   - Modify handler.ts to fetch provider preferences from database
   - Pass provider preferences to OpenRouter in request body

4. Admin UI:
   - Add provider preference dropdown for OpenRouter models in model-section.tsx
   - Add 'Allow fallbacks' checkbox for fallback control
   - Add corresponding CSS styles

5. CLI Config:
   - Add providerPreference field to Provider model config schema
   - Support configuring provider preferences via opencode.json

6. Provider SDK:
   - Inject provider preferences into OpenRouter request body in fetch wrapper

This allows workspace admins to specify preferred providers for OpenRouter
models, ensuring models like Claude route through specific providers
(e.g., Anthropic direct) rather than third-party providers.
2026-02-19 14:18:58 +00:00
southseact-3d
25ee088d6c test: Add comprehensive test coverage for critical modules
- Add tests for chat/encryption.js: encryption/decryption, hashing, token generation
- Add tests for chat/tokenManager.js: JWT tokens, device fingerprints, cookie handling
- Add tests for chat/prompt-sanitizer.js: security patterns, attack detection, obfuscation
- Add tests for admin panel: session management, rate limiting, user/token management
- Add tests for OpenCode write tool: file creation, overwrites, nested directories
- Add tests for OpenCode todo tools: todo CRUD operations
- Add tests for Console billing/account/provider: schemas, validation, price utilities

These tests cover previously untested critical paths including:
- Authentication and security
- Payment processing validation
- Admin functionality
- Model routing and management
- Account management
2026-02-18 16:43:10 +00:00
southseact-3d
81ff352966 feat: Add Kilo Gateway as AI provider
Add full support for Kilo Gateway AI provider across the codebase:

- Add custom loader for 'kilo' provider in provider.ts with API key detection
- Add auth CLI hint for Kilo Gateway in auth.ts
- Add Kilo to DEFAULT_PROVIDER_SEEDS in chat server.js
- Add Kilo to PLANNING_PROVIDERS for planning chain support
- Add Kilo provider configuration with baseURL and API key support
- Update admin env config to show Kilo API key status

Kilo Gateway provides access to 500+ AI models through a single
OpenAI-compatible endpoint at https://api.kilo.ai/api/gateway
2026-02-18 16:22:34 +00:00
southseact-3d
17568c405d Fix ReferenceError: Use process.env instead of env before initialization
The debug logging added in commit dacde39 tried to access 'env' variable
before it was initialized at line 946. Changed to use process.env which
is always available.
2026-02-16 18:37:47 +00:00
southseact-3d
4af4dc114f fix 1 2026-02-16 15:56:52 +00:00
southseact-3d
63698e1d19 Fix missing closing brace in OPENCODE_EXTRA_MCP_SERVERS if block 2026-02-16 12:03:49 +00:00
southseact-3d
3e96a41e39 fix: prevent multiple HTTP requests for Chutes AI provider
Chutes AI counts each HTTP API request separately. The existing fix using
stepCountIs(1) only limited the Vercel AI SDK's internal loop, but the
outer while(true) loops in processor.ts and prompt.ts continued to make
additional HTTP requests after tool execution.

This fix:
- Returns singleStepTools flag from LLM.stream() to signal single-step mode
- Breaks out of processor.ts inner loop after one iteration for Chutes
- Breaks out of prompt.ts outer loop after one iteration for Chutes

This ensures only one HTTP request is made per user message for providers
like Chutes that bill per request.
2026-02-15 16:38:07 +00:00
Liam Hetherington
cd76767dc2 Delete opencode/packages/opencode/src/session/prompt/wordpress-plugin-subsequent.txt 2026-02-13 13:20:53 +00:00
Liam Hetherington
ca6fcba172 Update description in base.txt to include 'plugin compass' 2026-02-13 13:19:02 +00:00
Liam Hetherington
4a386bce98 Delete anthropic-20250930.txt instructions
Removed detailed instructions and guidelines for PluginCompass.
2026-02-13 13:16:39 +00:00
southseact-3d
16f620cccb added internal mcp for the wp verify scripts 2026-02-12 17:01:18 +00:00
Liam Hetherington
6a133b3038 Fix Chutes single-step tool loop detection for OpenAI-compatible routes 2026-02-12 09:41:03 +00:00
Liam Hetherington
b6386d1777 Fix chutes tool calls to stay single-step 2026-02-11 15:03:23 +00:00
dependabot[bot]
58a1d40744 Bump the cargo group across 1 directory with 2 updates
Bumps the cargo group with 2 updates in the /opencode/packages/desktop/src-tauri directory: [bytes](https://github.com/tokio-rs/bytes) and [time](https://github.com/time-rs/time).


Updates `bytes` from 1.11.0 to 1.11.1
- [Release notes](https://github.com/tokio-rs/bytes/releases)
- [Changelog](https://github.com/tokio-rs/bytes/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/bytes/compare/v1.11.0...v1.11.1)

Updates `time` from 0.3.44 to 0.3.47
- [Release notes](https://github.com/time-rs/time/releases)
- [Changelog](https://github.com/time-rs/time/blob/main/CHANGELOG.md)
- [Commits](https://github.com/time-rs/time/compare/v0.3.44...v0.3.47)

---
updated-dependencies:
- dependency-name: bytes
  dependency-version: 1.11.1
  dependency-type: indirect
  dependency-group: cargo
- dependency-name: time
  dependency-version: 0.3.47
  dependency-type: indirect
  dependency-group: cargo
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-10 21:25:04 +00:00
Liam Hetherington
e58ebdcc4d Merge pull request #6 from southseact-3d/dependabot/npm_and_yarn/opencode/packages/console/app/npm_and_yarn-118d70433f
Bump the npm_and_yarn group across 3 directories with 4 updates
2026-02-10 21:22:40 +00:00
southseact-3d
dc071a04e8 Fix TypeScript errors: add missing type assignment and remove missing opencode theme 2026-02-10 12:24:24 +00:00
southseact-3d
a89e6940c0 Fix: Resolve @opentui/core from various node_modules locations 2026-02-10 12:21:38 +00:00
southseact-3d
bd6817f697 completed tools and setup 2026-02-08 20:02:30 +00:00
southseact-3d
541b6bc946 fix: pony-alpha model status and SSE stream heartbeat issue
- Change openrouter/pony-alpha model status from 'alpha' to 'beta' to prevent deletion
- Fix ReferenceError where heartbeat was used before initialization in cleanupStream
- Declare heartbeat and streamTimeout with let before cleanupStream function
- Change const assignments to let assignments for timer variables
2026-02-08 19:20:23 +00:00
southseact-3d
dacde39400 debug: Add logging to help diagnose provider loading issues
Add detailed logging to provider initialization to help debug why Chutes
and other providers aren't loading:
- Log all providers found in database
- Log API key env vars detected
- Log custom loader results with autoload status
- Log final loaded providers count

This will help identify if the issue is:
1. Database not loading correctly
2. Missing env vars
3. Custom loaders not being called
4. Providers being filtered out
2026-02-08 16:23:51 +00:00
southseact-3d
26c6f5f6c7 fix: Add pony-alpha model and fix model lookup for prefixed model IDs
- Add openrouter/pony-alpha model to models-api.json fixture
- Fix getModel() to lookup models with provider prefix (e.g., openrouter/pony-alpha)
  When user specifies openrouter/pony-alpha, the code now correctly looks for
  the full model ID including prefix in the provider's models object

This fixes the 'ModelNotFoundError' when using OpenRouter models that have
prefixed IDs in the database.
2026-02-08 16:21:21 +00:00
southseact-3d
1fbf5abce6 feat: Add support for multiple AI providers (bytez, llm7.io, aimlapi.com, routeway.ai, g4f.dev) and fix Chutes loader
- Add custom loaders for bytez, llm7, aimlapi, routeway, and g4f providers
- Add provider definitions to models-api.json with sample models
- Add provider icon names to types.ts
- Chutes loader already exists and should work with CHUTES_API_KEY env var

Providers added:
- bytez: Uses BYTEZ_API_KEY, OpenAI-compatible
- llm7: Uses LLM7_API_KEY (optional), OpenAI-compatible
- aimlapi: Uses AIMLAPI_API_KEY, OpenAI-compatible
- routeway: Uses ROUTEWAY_API_KEY, OpenAI-compatible
- g4f: Uses G4F_API_KEY (optional), free tier available
2026-02-08 16:07:02 +00:00
southseact-3d
fccfd80b10 feat: Add custom loader for Chutes provider 2026-02-08 15:55:33 +00:00
southseact-3d
ab7799ca58 feat: Add rate limiting and automatic provider switching
- Add rate limit detection and parsing from HTTP 429 responses
- Implement automatic retry with exponential backoff for short-term rate limits
- Implement automatic provider switching for long-term rate limits
- Add circuit breaker pattern for failing providers
- Integrate with existing admin panel rate limit configuration
- Add allProviders parameter to LLM.stream calls to enable provider fallback

Rate limit behavior:
- Short-term (< 5 min): Retry with configured backoff strategy
- Long-term (≥ 5 min): Switch to next available provider
- Max retries: 3 (configurable via admin panel)
- Max wait time: 5 minutes (configurable via admin panel)
- Provider switching: Enabled by default (configurable via admin panel)

Provider priority:
1. Anthropic
2. OpenAI
3. Google
4. OpenRouter
5. Groq
6. xAI
7. Together AI
8. Perplexity
9. DeepInfra
10. Cerebras
11. Mistral
12. Cohere
13. Amazon Bedrock
14. Azure
15. GitHub Copilot
16. GitHub Copilot Enterprise
17. OpenCode
18. ZenMux
19. Google Vertex
20. GitLab
2026-02-08 14:37:02 +00:00
southseact-3d
0f631dc99a feat: implement prompt injection protection and OpenRouter paid API key support
- Add comprehensive prompt injection security module with 160+ attack pattern detection
- Implement security checks in message handling with proper blocking and user feedback
- Add OpenRouter paid API key support (OPENROUTER_PAID_API_KEY) for premium models
- Update model discovery and chat functions to use paid API key for premium models
- Add comprehensive test suite with 434 test cases (98.39% accuracy)
- Tests cover legitimate WordPress development queries, injection attacks, obfuscated attempts
- Improve builder loading indicators with text-based progress (building/planning)
- Replace spinning animations with 'Starting build/planning process' messages
2026-02-08 13:23:59 +00:00
dependabot[bot]
bbc7daff39 Bump the npm_and_yarn group across 3 directories with 4 updates
Bumps the npm_and_yarn group with 1 update in the /opencode/packages/console/app directory: [wrangler](https://github.com/cloudflare/workers-sdk/tree/HEAD/packages/wrangler).
Bumps the npm_and_yarn group with 1 update in the /opencode/packages/opencode directory: [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk).
Bumps the npm_and_yarn group with 2 updates in the /opencode/packages/web directory: [@astrojs/cloudflare](https://github.com/withastro/astro/tree/HEAD/packages/integrations/cloudflare) and [astro](https://github.com/withastro/astro/tree/HEAD/packages/astro).


Updates `wrangler` from 4.50.0 to 4.59.1
- [Release notes](https://github.com/cloudflare/workers-sdk/releases)
- [Commits](https://github.com/cloudflare/workers-sdk/commits/wrangler@4.59.1/packages/wrangler)

Updates `@modelcontextprotocol/sdk` from 1.25.2 to 1.26.0
- [Release notes](https://github.com/modelcontextprotocol/typescript-sdk/releases)
- [Commits](https://github.com/modelcontextprotocol/typescript-sdk/compare/v1.25.2...v1.26.0)

Updates `@astrojs/cloudflare` from 12.6.3 to 12.6.6
- [Release notes](https://github.com/withastro/astro/releases)
- [Changelog](https://github.com/withastro/astro/blob/main/packages/integrations/cloudflare/CHANGELOG.md)
- [Commits](https://github.com/withastro/astro/commits/@astrojs/cloudflare@12.6.6/packages/integrations/cloudflare)

Updates `astro` from 5.7.13 to 5.15.9
- [Release notes](https://github.com/withastro/astro/releases)
- [Changelog](https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md)
- [Commits](https://github.com/withastro/astro/commits/astro@5.15.9/packages/astro)

---
updated-dependencies:
- dependency-name: wrangler
  dependency-version: 4.59.1
  dependency-type: direct:development
  dependency-group: npm_and_yarn
- dependency-name: "@modelcontextprotocol/sdk"
  dependency-version: 1.26.0
  dependency-type: direct:production
  dependency-group: npm_and_yarn
- dependency-name: "@astrojs/cloudflare"
  dependency-version: 12.6.6
  dependency-type: direct:production
  dependency-group: npm_and_yarn
- dependency-name: astro
  dependency-version: 5.15.9
  dependency-type: direct:production
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-08 09:46:02 +00:00
cto-new[bot]
23d4c8d0e6 Refactor WordPress prompt system and add completion signal 2026-02-07 22:12:43 +00:00
cto-new[bot]
9ff3f5c489 Delete the github folder from opencode and remove related functionality 2026-02-07 21:53:18 +00:00
southseact-3d
efda260214 Vendor opencode source for docker build 2026-02-07 20:54:46 +00:00