Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHAGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Keep proposed and unmerged changes out of released sections.

## [Unreleased]

- Proposed onboarding-wizard follow-up ([#1219](https://github.com/BitterSecurity/Decepticon/pull/1219)): offer OpenCode Zen and OpenCode Go as separate wizard entries so the billing plan is explicit at install time. Both plans share one key, and a Go credential that reaches the Zen base is billed to the credit balance instead of the monthly plan. Depends on [#1218](https://github.com/BitterSecurity/Decepticon/pull/1218) for the `opencode_go` route.

- Proposed per-run proxy credential correction ([#1211](https://github.com/BitterSecurity/Decepticon/pull/1211)): preserve selected-model streaming, usage, token limits, retry/timeout settings, vendor protocol subclasses and HTTP transports when binding an engagement key. Refuse dispatch if an explicit key cannot be bound instead of silently using the environment account; requests without a per-run key are unchanged. No package version, publication or deployment. [Verification and compatibility](docs/verification/proxy-key-transport-20261120.md).

- Proposed CI verification correction ([#1210](https://github.com/BitterSecurity/Decepticon/pull/1210)): require every declared dependency to succeed or intentionally skip before CI OK passes. Reject abandoned, unknown and missing outcomes while preserving existing scope skips and protections. This corrects a false-positive aggregate after a hosted macOS runner could not be assigned; runner availability and actual hosted CI remain separate. [Verification](docs/verification/ci-required-terminal-results-20261120.md).
Expand Down
53 changes: 53 additions & 0 deletions clients/launcher/cmd/onboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ const (
methodCohereAPI = "cohere_api"
methodMoonshotAPI = "moonshot_api"
methodKimiAPI = "kimi_api"
methodOpencodeAPI = "opencode_api"
methodOpencodeGoAPI = "opencode_go_api"
methodZaiAPI = "zai_api"
methodDashscopeAPI = "dashscope_api"
methodGitHubModelsAPI = "github_models_api"
Expand Down Expand Up @@ -149,6 +151,11 @@ var methodOrder = []string{
methodCohereAPI,
methodMoonshotAPI,
methodKimiAPI,
// Two plans on one key format. Keep them adjacent and separate: a Go
// subscriber who picks the pay-as-you-go entry is billed to the credit
// balance instead of the monthly plan, with no error from either side.
methodOpencodeAPI,
methodOpencodeGoAPI,
methodZaiAPI,
methodDashscopeAPI,
// Local last so cloud-preferred default still picks remote
Expand All @@ -159,6 +166,20 @@ var methodOrder = []string{
methodCustomOpenAIAPI,
}

// opencodeEnvValues maps the two OpenCode wizard answers to their key variables.
// Zen and Go share one key format but not one billing plan, so the entry the
// user picked decides the variable; a blank answer writes nothing.
func opencodeEnvValues(zenKey, goKey string) map[string]string {
env := make(map[string]string, 2)
if key := strings.TrimSpace(zenKey); key != "" {
env["OPENCODE_API_KEY"] = key
}
if key := strings.TrimSpace(goKey); key != "" {
env["OPENCODE_GO_API_KEY"] = key
}
return env
}

// systemCheckGroup renders the host-environment snapshot as the first
// step of onboarding. It detects OS/architecture (so the user sees the
// machine is recognized — be it Windows, macOS, a Linux pentest distro,
Expand Down Expand Up @@ -259,6 +280,8 @@ func runOnboard(cmd *cobra.Command, args []string) error {
cohereKey string
moonshotKey string
kimiKey string
opencodeKey string
opencodeGoKey string
zaiKey string
dashscopeKey string
githubToken string
Expand Down Expand Up @@ -342,6 +365,8 @@ func runOnboard(cmd *cobra.Command, args []string) error {
huh.NewOption("Cohere Command — Command-A / Command-R (cohere/*)", methodCohereAPI),
huh.NewOption("Moonshot Kimi K2 — Kimi K2 (moonshot/*)", methodMoonshotAPI),
huh.NewOption("Kimi for Coding — Kimi K3 / K2.7 Coding (kimi/*)", methodKimiAPI),
huh.NewOption("OpenCode Zen — pay-as-you-go credits (opencode/*)", methodOpencodeAPI),
huh.NewOption("OpenCode Go — monthly subscription, billed to the plan", methodOpencodeGoAPI),
huh.NewOption("Z.ai GLM-4.5 — GLM-4.5 / GLM-4.5-Air (zai/*)", methodZaiAPI),
huh.NewOption("Alibaba DashScope — Qwen Max/Plus/Turbo (dashscope/*)", methodDashscopeAPI),
huh.NewOption("LM Studio (local) — local OpenAI-compatible server (lm_studio/*)", methodLMStudioLocal),
Expand Down Expand Up @@ -714,6 +739,30 @@ func runOnboard(cmd *cobra.Command, args []string) error {
).Title("2 / 5 · Kimi for Coding").
WithHideFunc(func() bool { return !contains(methods, methodKimiAPI) }),

// Step 2-cloud-ix-c: OpenCode Zen (pay-as-you-go)
huh.NewGroup(
huh.NewInput().
Title("OPENCODE_API_KEY").
Description("opencode.ai/zen — pay-as-you-go credits. Keys start with 'oc_sk_'.\nFor the monthly Go plan choose the OpenCode Go entry instead.").
Placeholder("oc_sk_...").
EchoMode(huh.EchoModePassword).
Value(&opencodeKey).
Validate(nonEmpty),
).Title("2 / 5 · OpenCode Zen").
WithHideFunc(func() bool { return !contains(methods, methodOpencodeAPI) }),

// Step 2-cloud-ix-d: OpenCode Go (subscription)
huh.NewGroup(
huh.NewInput().
Title("OPENCODE_GO_API_KEY").
Description("opencode.ai/inference/go — billed to the Go monthly plan, not credits.\nThe same key also works on the Zen base, which would bill the balance instead.").
Placeholder("oc_sk_...").
EchoMode(huh.EchoModePassword).
Value(&opencodeGoKey).
Validate(nonEmpty),
).Title("2 / 5 · OpenCode Go").
WithHideFunc(func() bool { return !contains(methods, methodOpencodeGoAPI) }),

// Step 2-cloud-x: Z.ai GLM-4.5
huh.NewGroup(
huh.NewInput().
Expand Down Expand Up @@ -1053,6 +1102,10 @@ func runOnboard(cmd *cobra.Command, args []string) error {
if kimiKey != "" {
values["KIMI_API_KEY"] = strings.TrimSpace(kimiKey)
}

for name, value := range opencodeEnvValues(opencodeKey, opencodeGoKey) {
values[name] = value
}
if zaiKey != "" {
values["ZAI_API_KEY"] = strings.TrimSpace(zaiKey)
}
Expand Down
81 changes: 81 additions & 0 deletions clients/launcher/cmd/onboard_opencode_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package cmd

import (
"slices"
"testing"
)

func TestMethodOrderListsBothOpencodePlansOnceWithZenFirst(t *testing.T) {
zen := slices.Index(methodOrder, methodOpencodeAPI)
plan := slices.Index(methodOrder, methodOpencodeGoAPI)

if zen < 0 || plan < 0 {
t.Fatalf("methodOrder must list both OpenCode plans: zen=%d go=%d", zen, plan)
}
if zen > plan {
t.Errorf("OpenCode Zen must precede Go in methodOrder so the picker reads pay-as-you-go first: zen=%d go=%d", zen, plan)
}
for _, method := range []string{methodOpencodeAPI, methodOpencodeGoAPI} {
count := 0
for _, listed := range methodOrder {
if listed == method {
count++
}
}
if count != 1 {
t.Errorf("methodOrder contains %q %d times, want 1", method, count)
}
}
}

func TestOpencodeEnvValuesSeparatesTheTwoBillingPlans(t *testing.T) {
cases := []struct {
name string
zen string
goKey string
want map[string]string
}{
{
name: "zen key only writes the pay-as-you-go variable",
zen: "oc_sk_zen_aaaaaaaaaaaaaaaaaaaa",
want: map[string]string{"OPENCODE_API_KEY": "oc_sk_zen_aaaaaaaaaaaaaaaaaaaa"},
},
{
name: "go key only writes the subscription variable",
goKey: "oc_sk_go_aaaaaaaaaaaaaaaaaaaaa",
want: map[string]string{"OPENCODE_GO_API_KEY": "oc_sk_go_aaaaaaaaaaaaaaaaaaaaa"},
},
{
name: "both keys stay in their own variables",
zen: "oc_sk_zen_aaaaaaaaaaaaaaaaaaaa",
goKey: "oc_sk_go_aaaaaaaaaaaaaaaaaaaaa",
want: map[string]string{
"OPENCODE_API_KEY": "oc_sk_zen_aaaaaaaaaaaaaaaaaaaa",
"OPENCODE_GO_API_KEY": "oc_sk_go_aaaaaaaaaaaaaaaaaaaaa",
},
},
{
name: "blank answers write nothing",
want: map[string]string{},
},
{
name: "surrounding whitespace is trimmed",
goKey: " oc_sk_go_aaaaaaaaaaaaaaaaaaaaa\n",
want: map[string]string{"OPENCODE_GO_API_KEY": "oc_sk_go_aaaaaaaaaaaaaaaaaaaaa"},
},
}

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got := opencodeEnvValues(tc.zen, tc.goKey)
if len(got) != len(tc.want) {
t.Fatalf("opencodeEnvValues(%q, %q) = %v, want %v", tc.zen, tc.goKey, got, tc.want)
}
for name, value := range tc.want {
if got[name] != value {
t.Errorf("opencodeEnvValues(%q, %q)[%q] = %q, want %q", tc.zen, tc.goKey, name, got[name], value)
}
}
})
}
}
Loading