Implementation:2aronS Duel Agents buildOpenClawPatch
| Knowledge Sources | |
|---|---|
| Domains | Configuration, Developer_Tools |
| Last Updated | 2026-10-27 14:00 GMT |
Overview
Concrete tool for constructing the JSON patch object that adds the Duel provider to an OpenClaw config, with the API key as an environment-variable reference rather than plaintext, provided by @duel-agents/core.
Description
The buildOpenClawPatch function is a pure factory that returns the patch object to be deep-merged into an existing OpenClaw config. The key design property is that the API key is referenced as "${DUEL_API_KEY}" — an interpolation placeholder — and never written as plaintext. The actual key is written separately to ~/.openclaw/.env by the caller.
The patch object contains three top-level keys:
models— sets merge mode and adds theduelprovider with theduel-automodelagents— sets the default model toduel/duel-autowith aliasDuelenv— setsDUEL_PROXY_URL(the proxy URL is not secret)
The output of this function matches the reference file integrations/openclaw/duel-provider.json exactly.
Usage
Import this function when you need to:
- Construct the OpenClaw patch object programmatically
- Inspect the expected patch shape for testing or documentation
- Build a custom patch that extends the Duel provider entry
Code Reference
Source Location
- Repository: Duel-Agents
- File:
packages/core/src/config.ts(lines 99-139) - Reference:
integrations/openclaw/duel-provider.json(matches output)
Signature
export function buildOpenClawPatch(
apiKey: string,
proxyUrl?: string, // default: getProxyUrl()
): Record<string, unknown>;
Import
import { buildOpenClawPatch } from "@duel-agents/core";
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| apiKey | string |
Yes | Validated key (re-validated; not stored in output) |
| proxyUrl | string |
No | Proxy URL (default getProxyUrl())
|
Outputs
| Name | Type | Description |
|---|---|---|
| returns | Record<string, unknown> |
Patch object with ${DUEL_API_KEY} placeholder
|
Usage Examples
Build and Inspect the Patch
import { buildOpenClawPatch } from "@duel-agents/core";
const patch = buildOpenClawPatch("duel_abcd1234_...");
console.log(JSON.stringify(patch, null, 2));
// {
// "models": { "mode": "merge", "providers": { "duel": {
// "baseUrl": "https://duelagents.com/v1",
// "apiKey": "${DUEL_API_KEY}", ← placeholder, NOT plaintext
// "api": "openai-completions",
// "models": [{ "id": "duel-auto", ... }]
// }}},
// "agents": { "defaults": { "model": { "primary": "duel/duel-auto" }, ... }},
// "env": { "DUEL_PROXY_URL": "https://duelagents.com/v1" }
// }