-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(provider): add official CodeBuddy Global and CN providers (carry #3340) #4026
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
87b685d
feat(provider): add official CodeBuddy Global and CN providers
Flowershangfromthebranches e80f5a3
fix(provider): harden CodeBuddy CLI lifecycle
Flowershangfromthebranches 1e3cd67
fix(provider): address CodeBuddy runtime review
Flowershangfromthebranches aa5404a
docs(codebuddy): document adapter factory and turn input contracts
Flowershangfromthebranches 769e420
test(providers): place CodeBuddy tests in their layout domain
invalid-email-address File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| import type { AdapterEvent, OcxParsedRequest, OcxProviderConfig } from "../../types"; | ||
| import type { AdapterRequest, ProviderAdapter } from "../base"; | ||
| import { mapReasoningEffort } from "../../reasoning-effort"; | ||
| import { buildSystemPrompt } from "../coding-agent/protocol"; | ||
| import { baseScopedEnv, runCodingAgentTurn, type CodingAgentDeps, type SpawnFn } from "../coding-agent/turn"; | ||
| import { CODEBUDDY_PROFILES, type CodeBuddyProfile } from "./profiles"; | ||
|
|
||
| export type { SpawnFn } from "../coding-agent/turn"; | ||
| export type CodeBuddyAdapterDeps = CodingAgentDeps; | ||
|
|
||
| /** | ||
| * Build the scoped child-process environment for a CodeBuddy turn (§六/§十四). | ||
| * | ||
| * The region switch and credential are layered on top of the shared base env, which never inherits a | ||
| * parent `CODEBUDDY_*`. `CODEBUDDY_CODE_DISABLE_BACKGROUND_TASKS=1` matches the vendor SDK's own | ||
| * single-shot behavior (a `-p` turn stops at the first result and cannot receive cross-turn | ||
| * background push-back). | ||
| */ | ||
| export function buildChildEnv(profile: CodeBuddyProfile, apiKey: string): Record<string, string> { | ||
| return { | ||
| ...baseScopedEnv(), | ||
| CODEBUDDY_API_KEY: apiKey, | ||
| CODEBUDDY_INTERNET_ENVIRONMENT: profile.internetEnvironment, | ||
| CODEBUDDY_CODE_DISABLE_BACKGROUND_TASKS: "1", | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Build the headless CLI arguments (§七/§十一). | ||
| * | ||
| * Tool ownership stays with Codex: `--tools ""` disables every built-in tool and `--strict-mcp-config` | ||
| * (with no `--mcp-config`) blocks MCP tools, so the CLI can neither read, write, exec, nor browse the | ||
| * workspace. `-y/--dangerously-skip-permissions` is deliberately NOT passed, so any operation that | ||
| * would require authorization is blocked. The turn is a single text/reasoning pass over stream-json; | ||
| * Codex's tool catalog is not advertised in v1 (the control-protocol tool bridge is a fast-follow). | ||
| */ | ||
| export function buildArgs(profile: CodeBuddyProfile, parsed: OcxParsedRequest, provider: OcxProviderConfig): string[] { | ||
| const args: string[] = [ | ||
| "-p", | ||
| "--output-format", "stream-json", | ||
| "--input-format", "stream-json", | ||
| "--include-partial-messages", | ||
| "--verbose", | ||
| "--no-session-persistence", | ||
| "--tools", "", | ||
| "--strict-mcp-config", | ||
| "--max-turns", "1", | ||
| "--model", parsed.modelId, | ||
| ]; | ||
| const effort = mapReasoningEffort(provider, parsed.modelId, parsed.options.reasoning); | ||
| if (effort) args.push("--effort", effort); | ||
| const system = buildSystemPrompt(parsed); | ||
| if (system) args.push("--append-system-prompt", system); | ||
| // profile is retained for symmetry with the region-isolated design and future per-region flags. | ||
| void profile; | ||
| return args; | ||
| } | ||
|
|
||
| /** Create the shared CodeBuddy adapter: region profile selects Global vs CN, one turn runs tools-disabled. */ | ||
| export function createCodeBuddyAdapter(provider: OcxProviderConfig, deps: CodeBuddyAdapterDeps = {}): ProviderAdapter { | ||
| return { | ||
| name: "codebuddy", | ||
|
|
||
| // runTurn owns the turn; buildRequest/parseStream are the disabled HTTP path (mirrors cursor). | ||
| buildRequest(): AdapterRequest { | ||
| return { url: provider.baseUrl, method: "POST", headers: {}, body: "" }; | ||
| }, | ||
| async *parseStream(): AsyncGenerator<AdapterEvent> { | ||
| yield { type: "error", message: "CodeBuddy adapter uses runTurn; the fetch/parseStream path is disabled." }; | ||
| }, | ||
|
|
||
| async runTurn(parsed, incoming, emit): Promise<void> { | ||
| await runCodingAgentTurn({ | ||
| profiles: CODEBUDDY_PROFILES, | ||
| provider, | ||
| parsed, | ||
| incoming, | ||
| emit, | ||
| buildArgs: (resolved, req, prov) => buildArgs(resolved as CodeBuddyProfile, req, prov), | ||
| buildEnv: (resolved, apiKey) => buildChildEnv(resolved as CodeBuddyProfile, apiKey), | ||
| deps, | ||
| }); | ||
| }, | ||
| }; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When the globally installed CLI resolves to its normal npm
.cmdshim on Windows,commandInvocationserializes every argument intocmd.exe /c; placing the full Codex system/developer prompt here therefore exceeds cmd.exe's 8,191-character limit for ordinary long agent instructions, causing the spawn to fail before CodeBuddy receives the stdin conversation. It also exposes potentially sensitive prompt content through process command-line metadata. Pass the prompt through a supported file/stdin mechanism instead of argv.AGENTS.md reference: AGENTS.md:L357-L363
Useful? React with 👍 / 👎.