Skip to content

feat(provider): add ClinePass subscription provider - #880

Open
n3wr1ch wants to merge 4 commits into
lidge-jun:devfrom
n3wr1ch:feat/cline-pass-provider
Open

feat(provider): add ClinePass subscription provider#880
n3wr1ch wants to merge 4 commits into
lidge-jun:devfrom
n3wr1ch:feat/cline-pass-provider

Conversation

@n3wr1ch

@n3wr1ch n3wr1ch commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add ClinePass as a canonical API-key provider preset with the 11 model slugs published by Cline
  • preserve full cline-pass/<model> upstream ids and seed context-window and input-modality metadata
  • support the gateway's reasoning object, non-stream response envelope, reasoning deltas, choice-scoped stream errors, and safe numeric error classification
  • expose reasoningWireFormat through the safe management DTO and keep GUI diagnostics, provider docs, and all five documentation locales synchronized

Why

Cline officially supports using ClinePass outside the Cline clients through its OpenAI-compatible Chat Completions API. OpenCodex previously had no canonical preset for that subscription route, so users had to configure the endpoint manually and would lose gateway-specific reasoning, error, and non-stream response behavior.

The adapter fixes are intentionally shared where they describe valid OpenAI-compatible response behavior. Regression coverage protects ordinary non-Cline providers from changes to standard response parsing and pending tool-call termination.

Primary-source evidence

Verified 2026-08-02:

The public API reference does not currently document the reasoning: { enabled, effort } request object or the { success, error, data } non-stream envelope. Those two shapes are explicitly marked in code as live-observed on 2026-08-02. Only the live-accepted low reasoning tier is advertised until Cline documents or validates a broader ladder.

Security and privacy

  • the new credential destination is fixed to https://api.cline.bot/api/v1
  • same-named custom providers retain their custom destination and credential boundary
  • API keys and response bodies are not logged
  • arbitrary upstream metadata is discarded; only a bounded request id with an allowlisted character set is retained, and secret-shaped values are rejected by the existing redactor
  • reasoningWireFormat is added only to the existing non-secret management DTO allowlist

This provider preset changes a credential destination and therefore requires explicit security review before merge.

Validation

  • bun run typecheck
  • bun run test — 6,973 passed, 8 skipped, 0 failed
  • focused ClinePass/OpenAI Chat/management/request-log tests — 156 passed, 0 failed
  • bun run privacy:scan
  • cd gui && bun test tests — 493 passed, 0 failed
  • cd gui && bun run lint
  • cd gui && bun run build
  • cd docs-site && bun install --frozen-lockfile
  • cd docs-site && bun run build — 206 pages built

Summary by CodeRabbit

  • New Features

    • Added ClinePass as a built-in provider with model routing, supported modalities, subscription details, and usage limits.
    • Added support for gateways using object-based reasoning settings, including automatic provider configuration.
    • Improved reasoning metadata and response handling for streaming, wrapped responses, usage details, and errors.
  • Documentation

    • Updated setup guides and provider catalogs across supported languages to reflect 67 built-in presets and document ClinePass.
  • Bug Fixes

    • Improved request logging, validation, and upstream error handling, including boolean reasoning values and request identifiers.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds the ClinePass provider preset, gateway-object reasoning configuration, hardened OpenAI-compatible response handling, boolean reasoning diagnostics, tests, and localized documentation.

Changes

ClinePass gateway integration

Layer / File(s) Summary
Gateway reasoning configuration and diagnostics
src/types.ts, src/adapters/base.ts, src/providers/derive.ts, src/router.ts, src/server/*, src/usage/log.ts, gui/src/*, docs-site/src/content/docs/*/reference/configuration/providers.md
Adds reasoningWireFormat?: "gateway-object" and propagates it through provider configuration. Reasoning logs and persisted usage now support validated boolean wire values.
ClinePass registry and documentation
src/providers/registry.ts, tests/provider-registry-parity.test.ts, tests/cline-pass-provider.test.ts, docs-site/src/content/docs/*/guides/providers.md, docs-site/src/content/docs/*/getting-started/quickstart.md
Adds ClinePass models, routing, modalities, limits, endpoint metadata, and low-only gateway reasoning. Updates provider counts and localized catalogs.
OpenAI-compatible request and response handling
src/adapters/openai-chat.ts, tests/openai-chat-eof.test.ts, tests/openai-chat-hardening.test.ts
Serializes gateway-object reasoning, unwraps responses, normalizes errors, handles alternate reasoning fields and finish reasons, preserves usage, and avoids fabricated tool-call completions.
Reasoning diagnostics validation
tests/request-log.test.ts, tests/usage-log.test.ts, tests/server-auth.test.ts
Validates boolean reasoning logging, usage normalization, and sanitized configuration output.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant openaiChatAdapter
  participant ClinePassGateway
  participant RequestLog
  Client->>openaiChatAdapter: Send provider request
  openaiChatAdapter->>ClinePassGateway: Send gateway-object reasoning payload
  ClinePassGateway-->>openaiChatAdapter: Return wrapped response or normalized error data
  openaiChatAdapter->>RequestLog: Record reasoning wire fields and usage
  openaiChatAdapter-->>Client: Emit reasoning, completion, usage, or error events
Loading

Possibly related PRs

Suggested reviewers: ingwannu, wibias, lidge-jun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding the ClinePass subscription provider.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the enhancement New feature or request label Aug 2, 2026
@n3wr1ch
n3wr1ch marked this pull request as ready for review August 2, 2026 09:54

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/guides/providers.md`:
- Around line 193-210: Update the openai-chat adapter reference in the primary
and ja, ko, ru, and zh-cn localized documents to document ClinePass, including
its reasoning object format, the live-verified low reasoning clamp, reasoning
deltas, and usage handling. Use the existing provider guide’s ClinePass facts
and keep the documentation consistent across all adapter references.

In `@src/adapters/base.ts`:
- Around line 51-56: Update the reasoningLog type in the adapter base definition
to a discriminated union keyed by wireField, pairing each field with its valid
wireValue type: boolean only for "reasoning.enabled", numeric values for
"thinking_budget", and string values for the remaining reasoning fields.
Preserve effectiveEffort on every union member so producers and
recordAdapterReasoning retain the existing diagnostics contract.

In `@src/router.ts`:
- Around line 279-281: Add a route test for a matching ClinePass provider whose
config explicitly sets reasoningWireFormat to "gateway-object". Assert that
routeModel() preserves this explicit value rather than replacing it with the
registry entry, alongside the existing registry-backfill and
non-matching-provider cases in cline-pass-provider.test.ts.

In `@src/usage/log.ts`:
- Around line 271-277: Update normalizeUsageAttempt and normalizeUsageEntry so
boolean reasoningWireValue is preserved only when the corresponding
reasoningWireField equals "reasoning.enabled", matching recordAdapterReasoning;
continue accepting string values and non-negative finite numeric values through
their existing paths, and omit mismatched boolean pairs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 97bd7df2-f305-4852-beef-9753dc6a982b

📥 Commits

Reviewing files that changed from the base of the PR and between f9b9440 and fef239b.

📒 Files selected for processing (33)
  • docs-site/src/content/docs/getting-started/quickstart.md
  • docs-site/src/content/docs/guides/providers.md
  • docs-site/src/content/docs/ja/getting-started/quickstart.md
  • docs-site/src/content/docs/ja/guides/providers.md
  • docs-site/src/content/docs/ja/reference/configuration/providers.md
  • docs-site/src/content/docs/ko/getting-started/quickstart.md
  • docs-site/src/content/docs/ko/guides/providers.md
  • docs-site/src/content/docs/ko/reference/configuration/providers.md
  • docs-site/src/content/docs/reference/configuration/providers.md
  • docs-site/src/content/docs/ru/getting-started/quickstart.md
  • docs-site/src/content/docs/ru/guides/providers.md
  • docs-site/src/content/docs/ru/reference/configuration/providers.md
  • docs-site/src/content/docs/zh-cn/getting-started/quickstart.md
  • docs-site/src/content/docs/zh-cn/guides/providers.md
  • docs-site/src/content/docs/zh-cn/reference/configuration/providers.md
  • gui/src/hooks/useJsonConfigEditor.ts
  • gui/src/pages/Logs.tsx
  • gui/src/pages/providers-shared.ts
  • src/adapters/base.ts
  • src/adapters/openai-chat.ts
  • src/providers/derive.ts
  • src/providers/registry.ts
  • src/router.ts
  • src/server/auth-cors.ts
  • src/server/request-log.ts
  • src/types.ts
  • src/usage/log.ts
  • tests/cline-pass-provider.test.ts
  • tests/openai-chat-eof.test.ts
  • tests/openai-chat-hardening.test.ts
  • tests/provider-registry-parity.test.ts
  • tests/request-log.test.ts
  • tests/server-auth.test.ts

Comment thread docs-site/src/content/docs/guides/providers.md
Comment thread src/adapters/base.ts Outdated
Comment thread src/router.ts
Comment thread src/usage/log.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/adapters/openai-chat.ts`:
- Around line 105-115: In src/adapters/openai-chat.ts lines 105-115, update
upstreamErrorEvent to sanitize rawMessage for credential-shaped API keys, bearer
tokens, and OAuth values before constructing message, while preserving benign
text and replacing secrets with a fixed redaction marker. In
tests/cline-pass-provider.test.ts lines 241-245, add a secret-shaped upstream
error fixture and assert the emitted message does not contain the original
secret.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fcb349ea-76da-45c0-9858-4b7ef18e1afe

📥 Commits

Reviewing files that changed from the base of the PR and between 0bedc56 and ac9a858.

📒 Files selected for processing (2)
  • src/adapters/openai-chat.ts
  • tests/cline-pass-provider.test.ts

Comment on lines +105 to +115
error: OpenAIChatError | string | undefined,
usage?: OcxUsage,
): Extract<AdapterEvent, { type: "error" }> {
const details = typeof error === "string" ? undefined : error;
const rawMessage = typeof error === "string"
? error.trim() || "upstream error"
: typeof details?.message === "string" ? details.message : "upstream error";
const requestId = safeUpstreamRequestId(details?.metadata);
const message = requestId !== undefined && !rawMessage.includes(requestId)
? `${rawMessage} (request ID: ${requestId})`
: rawMessage;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Redact credential material before returning upstream error text.

upstreamErrorEvent forwards a string-valued upstream error directly into an AdapterEvent message. A gateway can include an echoed API key, bearer token, or OAuth value in that text. This path can expose configured provider credentials to downstream clients.

Sanitize both raw string errors and details.message at this adapter boundary. Preserve benign messages. Replace credential-shaped values with a fixed redaction marker. Update the test to verify that a secret-shaped upstream error is not returned verbatim.

  • src/adapters/openai-chat.ts#L105-L115: Redact sensitive values in rawMessage before constructing message.
  • tests/cline-pass-provider.test.ts#L241-L245: Add a secret-shaped error fixture and assert that the emitted message does not contain the secret.
📍 Affects 2 files
  • src/adapters/openai-chat.ts#L105-L115 (this comment)
  • tests/cline-pass-provider.test.ts#L241-L245
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/adapters/openai-chat.ts` around lines 105 - 115, In
src/adapters/openai-chat.ts lines 105-115, update upstreamErrorEvent to sanitize
rawMessage for credential-shaped API keys, bearer tokens, and OAuth values
before constructing message, while preserving benign text and replacing secrets
with a fixed redaction marker. In tests/cline-pass-provider.test.ts lines
241-245, add a secret-shaped upstream error fixture and assert the emitted
message does not contain the original secret.

Source: Path instructions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant