Commit graph

10 commits

Author SHA1 Message Date
Diego Rodrigues de Sa e Souza
91b6983564
Release v3.8.1 (#2441)
Release v3.8.1 — feature flags settings page, bracketed combo names, security hardening, multi-driver SQLite
2026-05-21 01:29:12 -03:00
diegosouzapw
d291834481 fix(ci): use explicit test path in opencode-provider to fix glob on Linux runners 2026-05-18 17:57:35 -03:00
diegosouzapw
04d44f6262 fix(security): sanitize error messages, fix ReDoS patterns, harden OAuth callback
Error message sanitization (Hard Rule #12):
- claude-auth/export, codex-auth/export, gemini-cli-auth/export routes: replace
  raw err.message with sanitizeErrorMessage() from open-sse/utils/error.ts
- imageGeneration, musicGeneration, videoGeneration handlers: import
  sanitizeErrorMessage and replace all err.message in return values
- veoaifree-web executor: replace raw upstream response data in errResp() calls
  with static strings

OAuth callback page (callback/page.tsx):
- Remove useSearchParams/Suspense dependency that caused hydration failures in
  popup windows navigating back from Google OAuth (COOP header severs opener)
- Use window.location.search directly in useEffect with three send methods:
  postMessage, BroadcastChannel, localStorage
- Fix postMessage target from "*" to window.location.origin (semgrep finding)
- Move setCurrentUrl call to manual-only branch to avoid unnecessary renders

copilot-web executor:
- Move accessToken from WebSocket URL query string to Authorization header
  (avoids credential exposure in server logs)
- Add MAX_POOL_SIZE=100 cap to sessionPool with LRU eviction of oldest entry

CodeQL ReDoS fixes (js/polynomial-redos #233-240):
- Replace while(s.endsWith("/")) s=s.slice(0,-1) pattern (O(n²) allocations)
  with index-based loop (O(n) time, single final slice) in:
  bin/cli/api.mjs, all 6 cli-helper config generators, opencode-provider

Gemini OAuth:
- mapTokens: add idToken field to fix "missing id_token" export error
2026-05-18 17:42:09 -03:00
Diego Rodrigues de Sa e Souza
85a4bacf31
Merge pull request #2375 from mrmm/mm/opencode-provider-v3
feat(@omniroute/opencode-provider): expand config helpers, MCP entry, live model fetch, combo builder
2026-05-18 14:33:29 -03:00
Mourad Maatoug
57354ac6d7 feat(@omniroute/opencode-provider): model capabilities, agent block, mode block (UI helpers)
Adds three UI-surface helpers on top of T1–T8 in PR #2375:

A) Model capability flags
   - ModelCapabilities interface (label, attachment, reasoning, temperature, tool_call)
   - OMNIROUTE_DEFAULT_MODEL_CAPABILITIES seeds capabilities for all 7 default
     model ids
   - OmniRouteProviderOptions.modelCapabilities merges over defaults per id
   - createOmniRouteProvider emits capability flags inline in models[id], per
     OpenCode's ProviderConfig.models schema (snake_case JSON keys, optional)
   - Label precedence: modelCapabilities[id].label > modelLabels[id] > id

B) createOmniRouteAgentBlock
   - OmniRouteAgentRole + OmniRouteAgentBlockOptions + OpenCodeAgentEntry
   - Emits Record<role, { model: 'omniroute/<id>', temperature?, top_p?,
     tools?: Record<string, boolean>, prompt? }>
   - Only fields present in OpenCode's AgentConfig schema are emitted
   - Tools normalized to Record<string, boolean> per schema (not string[])
   - Roles with empty modelId are skipped

C) createOmniRouteModesBlock (deprecated alias)
   - Same shape as createOmniRouteAgentBlock since OpenCode treats top-level
     'mode' block identically to 'agent' (both reference AgentConfig)
   - Helper kept for back-compat; @deprecated tags steer callers to agent

Shared helper buildAgentEntry eliminates duplication between A/B helpers.

Schema validation
- All emitted keys verified against https://opencode.ai/config.json
- Removed initially-considered reasoningEffort + max_tokens fields (not in
  AgentConfig schema)
- tools shape changed from string[] to Record<string, boolean> per schema

Build hygiene
- tsconfig.json narrowed to lib: ['ES2022'] + types: ['node'] (no DOM lib
  leakage); @types/node added as devDep
- Tests: 32 → 45 green (+13 net)
- Build: ESM 10.39 KB / CJS 11.01 KB / DTS 18.87 KB
2026-05-18 17:06:13 +02:00
Mourad Maatoug
0c44185d0d fix(@omniroute/opencode-provider): address gemini-code-assist review
- fetchJSON: consolidate all ops inside try, handle non-Error throws,
  catch JSON parse errors
- fetchLiveModels: null-safe data-envelope check
- listCombos: null-safe combos-envelope check
- createOmniRouteComboConfig: omit providers key when filtered list empty
2026-05-18 16:43:09 +02:00
Mourad Maatoug
e50126e639 feat(@omniroute/opencode-provider): expand config helpers, MCP entry, live model fetch, combo builder
- T1: model/small_model top-level keys in buildOmniRouteOpenCodeConfig
- T2: mergeIntoExistingConfig() non-destructive provider merge
- T3: createOmniRouteMCPEntry() + OMNIROUTE_MCP_DEFAULT_SCOPES (7 read scopes)
- T4: fetchLiveModels() async helper, plain fetch, camelCase+snake_case normalisation
      (field-variant logic adapted from Alph4d0g/opencode-omniroute-auth, MIT)
- T5: listCombos() hits GET /api/combos, normalises compressionOverride
- T6: createOmniRouteComboConfig() typed POST/PATCH payload builder
- T7: OMNIROUTE_DEFAULT_OPENCODE_MODELS expanded to 7 (added cc/ prefix models)
- T8: CI workflow path-filtered on @omniroute/opencode-provider/**, Node 20/22/24
- 32 tests (was 12), 0 failures
2026-05-18 16:25:31 +02:00
diegosouzapw
a45d9190db fix(security): resolve CodeQL ReDoS + URL sanitization alerts
- Replace replace(/\/+$/, "") with explicit while-endsWith loop to avoid
  polynomial backtracking on inputs with repeated trailing slashes
  (CodeQL js/polynomial-redos #233-240, 8 alerts):
  - @omniroute/opencode-provider/src/index.ts (normalizeBaseURL)
  - bin/cli/api.mjs (stripTrailingSlash)
  - src/lib/cli-helper/config-generator/{claude,cline,codex,continue,
    kilocode,opencode}.ts (6 generators with identical pattern)

- tests/live/deepseek-web-live.test.ts: assert hostname via URL parsing
  instead of String.includes() so the check is exact-match rather than
  substring (CodeQL js/incomplete-url-substring-sanitization #241).

Alert #242 (Array.prototype.includes against fixed needle constant
OPENWEBUI_PARAGRAPH_ANCHORS) dismissed as CodeQL false-positive — not a
URL sanitization callsite.
2026-05-17 07:43:32 -03:00
diegosouzapw
4b1e57443a refactor(@omniroute/opencode-provider): rewrite for schema correctness + publishability
The 1.0.0 release of the package was broken end-to-end:

  1. index.js re-exported from "./index.ts" — Node can't import .ts at runtime,
     so any consumer who `npm install`ed the package got ERR_UNKNOWN_FILE_EXTENSION.
  2. The emitted provider shape did not match the OpenCode schema
     (https://opencode.ai/config.json). It used a custom `{id, name, npm, options, auth}`
     instead of the schema's `{npm: "@ai-sdk/openai-compatible", name, options, models}`.
  3. README told users to pass `baseURL: "http://localhost:20128/v1"` but the code
     appended `/v1` again — every request would 404 at `/v1/v1/...`.
  4. No build step, no LICENSE file, no repository/author/engines fields, no tests.

This rewrite:

- Moves source under `src/`, adds a tsup build emitting CJS + ESM + .d.ts.
- `createOmniRouteProvider` now returns a schema-valid entry with
  `npm: "@ai-sdk/openai-compatible"` + `models: Record<string, { name }>`.
- Adds `buildOmniRouteOpenCodeConfig` for full-document scaffolding.
- `normalizeBaseURL` deduplicates trailing `/` and `/v1`, accepts both forms,
  and rejects malformed URLs and empty inputs.
- 13 unit tests covering URL normalisation, input validation, default model
  catalog, custom models + labels, dedup/trim behaviour, and JSON round-trip.
- Adds LICENSE, full package.json (repository, engines, scripts, exports),
  .gitignore, .npmignore, tsconfig.json, and a comprehensive README.
- Resets version to 0.1.0 to signal the pre-1.0 reset (1.0.0 was never on npm).

Documentation:

- New `docs/frameworks/OPENCODE.md` covering both integration paths (CLI vs npm),
  URL normalisation, auth modes, troubleshooting, and runtime flow.
- README.md links the package and points to the new doc.
- CHANGELOG entry under Unreleased > Changed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 16:58:33 -03:00
oyi77
2d601ea459 feat: CLI Integration Suite for issue #2016
- Add tool-detector.ts (6 CLI tools: claude, codex, opencode, cline, kilocode, continue)
- Add config-generator/ factory + 6 generators (JSON + YAML)
- Add doctor/checks.ts for CLI tool health checks
- Add log-streamer.ts for usage log streaming
- Add @omniroute/opencode-provider npm package
- Add 5 CLI commands: config, status, logs, update, provider
- Add 3 API routes: config, detect, apply
- Update bin/omniroute.mjs, bin/cli/index.mjs, package.json
- Update docs: SETUP_GUIDE.md, CLI-TOOLS.md
- All tests pass (4302/4326, 24 pre-existing failures unchanged)
2026-05-14 17:26:30 +07:00