-
Notifications
You must be signed in to change notification settings - Fork 678
feat: manage provider custom headers via PATCH and ocx provider edit --headers #961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ both `--adapter` and `--base-url`. | |
| | --- | --- | --- | | ||
| | `list` | `--json` | List configured providers and the remaining registry entries. | | ||
| | `add <name>` | `--adapter <adapter>`, `--base-url <url>`, `--api-key <key>`, `--default-model <model>`, `--set-default`, `--force`, `--json`, `--sync` | Add a registry/custom provider. `--force` overwrites; `--sync` refreshes a running proxy in human-output mode. | | ||
| | `edit <name>` | provider field flags, `--json` | Edit validated live provider fields without replacing key pools. | | ||
| | `edit <name>` | provider field flags, `--headers <json>`, `--json` | Edit validated live provider fields without replacing key pools. `--headers` merges custom request headers; pass `{}` or `-` to clear them. | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win Document the header scope and authentication restriction. The descriptions say that
As per path instructions, custom-header documentation must distinguish custom upstream headers from forwarded credentials and must not imply that sensitive authentication headers are overridable. 📍 Affects 4 files
🤖 Prompt for AI AgentsSource: Path instructions |
||
| | `test <name>` | `--json` | Probe the real upstream model endpoint. | | ||
| | `show <name>` | `--json` | Show config with API keys masked. | | ||
| | `remove <name>` | `--json` | Remove a non-default provider; the last provider cannot be removed. | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,7 +183,7 @@ keys are not returned to dashboard clients. | |
| | --- | --- | --- | | ||
| | `GET /api/providers` | List redacted provider configuration and discovery state | — | | ||
| | `POST /api/providers` | Add or replace one validated provider and optionally make it default | 400 invalid/dangerous destination or config; 409 namespace collision | | ||
| | `PATCH /api/providers?name=...` | Update allowed provider fields, enabled/default state, or OpenAI account mode | 400 invalid field or transition; 404 unknown provider | | ||
| | `PATCH /api/providers?name=...` | Update allowed provider fields (including a merged `headers` block), enabled/default state, or OpenAI account mode | 400 invalid field or transition; 404 unknown provider | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Keep the provider The endpoint does more than merge headers. A non-empty object is shallow-merged;
Suggested English row wording-| `PATCH /api/providers?name=...` | Update allowed provider fields (including a merged `headers` block), enabled/default state, or OpenAI account mode | 400 invalid field or transition; 404 unknown provider |
+| `PATCH /api/providers?name=...` | Update allowed provider fields. A non-empty `headers` object is shallow-merged; `null` or `{}` clears it. These are custom adapter headers, not forwarded caller credentials. | 400 invalid field, header name/value, or transition; 404 unknown provider |As per path instructions, 📍 Affects 5 files
🤖 Prompt for AI AgentsSource: Path instructions |
||
| | `DELETE /api/providers?name=...` | Delete a provider, reassigning the default when possible | 404 unknown provider; 409 `last_provider`; 409 `provider_has_dependent_combos` | | ||
| | `POST /api/providers/test?name=...` | Perform a bounded live provider connectivity/model-discovery probe | 404 unknown provider; failures are normally returned as `ok: false` evidence | | ||
| | `GET /api/provider-quotas` | Read provider quota reports; `refresh=1` forces refresh | — | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,8 @@ const USAGE = `Usage: | |
| ocx provider edit <name> [--adapter <id>] [--base-url <url>] [--default-model <id|->] | ||
| [--auth-mode <key|forward|oauth|local|->] [--note <text|->] | ||
| [--api-key-transport <x-api-key|bearer|->] | ||
| [--enabled <on|off>] [--live-models <on|off>] [--allow-private-network <on|off>] [--json] | ||
| [--headers <json>] [--enabled <on|off>] [--live-models <on|off>] | ||
| [--allow-private-network <on|off>] [--json] | ||
| ocx provider test <name> [--json] | ||
| ocx provider quota [--refresh] [--json] | ||
| ocx provider presets [--json] | ||
|
|
@@ -39,6 +40,7 @@ async function edit(argv: string[], deps: RuntimeApiDeps): Promise<void> { | |
| const authMode = cleared(takeOption(args, "--auth-mode")); | ||
| const note = cleared(takeOption(args, "--note")); | ||
| const apiKeyTransport = cleared(takeOption(args, "--api-key-transport")); | ||
| const headers = takeOption(args, "--headers"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a user uses the common AGENTS.md reference: AGENTS.md:L189-L195 Useful? React with 👍 / 👎. |
||
| const enabled = takeBooleanOption(args, "--enabled"); | ||
| const liveModels = takeBooleanOption(args, "--live-models"); | ||
| const allowPrivateNetwork = takeBooleanOption(args, "--allow-private-network"); | ||
|
|
@@ -49,6 +51,21 @@ async function edit(argv: string[], deps: RuntimeApiDeps): Promise<void> { | |
| if (authMode !== undefined) patch.authMode = authMode; | ||
| if (note !== undefined) patch.note = note; | ||
| if (apiKeyTransport !== undefined) patch.apiKeyTransport = apiKeyTransport; | ||
| if (headers !== undefined) { | ||
| if (headers === "-") { | ||
| patch.headers = null; | ||
| } else { | ||
| let parsed: unknown; | ||
| try { parsed = JSON.parse(headers); } catch { throw new CliUsageError("--headers must be valid JSON"); } | ||
| if (parsed === null) { | ||
| patch.headers = null; | ||
| } else if (typeof parsed !== "object" || Array.isArray(parsed)) { | ||
| throw new CliUsageError("--headers must be a JSON object like {\"X-Custom\":\"value\"}"); | ||
| } else { | ||
| patch.headers = parsed; | ||
| } | ||
| } | ||
| } | ||
| if (enabled !== undefined) patch.disabled = !enabled; | ||
| if (liveModels !== undefined) patch.liveModels = liveModels; | ||
| if (allowPrivateNetwork !== undefined) patch.allowPrivateNetwork = allowPrivateNetwork; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Restore the missing Markdown table delimiter.
Line 169 lacks the
|separator before400. The error text joins the purpose cell, so the row has two cells instead of the required three.As per path instructions,
docs-site/**changes must preserve readable user-facing documentation.📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.23.1)
[warning] 169-169: Table column count
Expected: 3; Actual: 2; Too few cells, row will be missing data
(MD056, table-column-count)
🤖 Prompt for AI Agents
Sources: Path instructions, Linters/SAST tools