Repository navigation
feat(guardrails): cor-local の baseURL/apiKey を環境変数化し MacBook から API key で使えるようにする - #331
Merged
Merged
Conversation
MacBook から鍵 1 本 (COR_LOCAL_BASE_URL/COR_LOCAL_API_KEY) で Mac Studio の
router を使えるよう、managed/profile 両 opencode.json の
provider["cor-local"].options を {env:...} 化した。variable.ts は未設定の
{env:VAR} を "" に解決し (missing:"error" は {file:} にのみ適用) 決してエラー
にしないため、baseURL が空だと既存の Mac Studio 利用が壊れる。
scripts/local-dev-deploy.sh の live wrapper 生成 heredoc に、未設定/空の
COR_LOCAL_BASE_URL を 127.0.0.1:18082/v1 へ既定し、COR_LOCAL_API_KEY が unset
(明示的な空文字は上書きしない) かつ router 用の鍵ファイル (A3a の既定パス
~/cluster-ops 配下) が読める場合はそこから export する処理を追加し、既存利用
の非破壊を担保した。@ai-sdk/openai-compatible は apiKey が空文字なら
Authorization ヘッダを付けないため、A3a 前の無鍵 router とも両立する。
model-whitelist.test.ts に {env:...} 形のピン留めを追加し、新規
cor-local-wrapper-env-defaults.test.ts で live wrapper の heredoc を実際に
実行・source して default/fallback/明示上書きの 3 パターンを検証した (実際の
~/.local/bin の wrapper とホームディレクトリの鍵ファイルには一切触れない)。
README/AGENTS.md に env vars と MacBook 手順を追記。
Agent-Lane: claude-code
Co-Authored-By: Claude Fable 5.1 <[email protected]>
- packages/guardrails/bin/opencode-guardrails が cor-local-env.js を import し、
COR_LOCAL_BASE_URL / COR_LOCAL_API_KEY を project dotfile 読み込み後・
OPENCODE_CONFIG_DIR 確定後に defaulting する(managed deploy・live wrapper・
直接呼び出しの全経路を 1 箇所でカバー)。
- 鍵ファイルは 1 行のみ・owner-only(0600)・[A-Za-z0-9._~+/=-]+ のみ許可。
{env:VAR} は JSON へ生テキスト splice のため、不正な鍵は値を含まない警告で
無視して config 全体の破損を防ぐ。
- scripts/local-dev-deploy.sh の live wrapper heredoc への defaulting 追加は
revert(.sh 差分ゼロ)。デプロイ済み wrapper のドリフト問題も bin 入口への
一本化で解消。
- bash heredoc 再生テストを削除し、cor-local-env.js の直接ユニットテストと
bin/opencode-guardrails をスタブ経由で実行する統合テストに置き換え。
- README/AGENTS.md/providers.mdx を新しいアーキテクチャに追従。
Agent-Lane: claude-code
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
This was referenced Sep 5, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
概要
cor-localprovider(Mac Studio の llama-server router:18082)のoptions.baseURL/options.apiKeyを{env:COR_LOCAL_BASE_URL}/{env:COR_LOCAL_API_KEY}に変更し、MacBook から tailnet 経由で API key 1 本で使えるようにする(ai-cluster 側の router--api-key+tailscale serve --tcp=18082と対)。http://127.0.0.1:18082/v1・~/cluster-ops/cor-local.key)はpackages/guardrails/bin/opencode-guardrailsが import するbin/cor-local-env.jsで一本化(managed deploy / live wrapper / 直接呼び出しの全経路をカバー。project.envの後に適用)。^[A-Za-z0-9._~+/=-]+$のみ採用。不正時は値を含まない警告で無鍵継続({env:}は JSON へ生 splice のため config 全体の破壊を防ぐ)。scripts/*.sh差分ゼロ)。cor-local節(MacBook 手順・鍵ローテーション・opencode debug configに鍵が出る注意)・providers.mdx・AGENTS.md。検証
OPENCODE_DISABLE_MODELS_FETCH=1 bun run local:check-offline→ 61 pass / 0 fail、sync-model-whitelist.pyok(監督が再実行して確認)profile/plugins/cor-local-bin-defaults.test.ts: 未設定→既定 / 設定済み→不変 / project.env優先 / 0644 鍵→無視+警告 / 不正文字・複数行→無視 / 末尾改行→除去smokeのみ。guardrails テストは post-merge のfullで走る。H5-E2E: OPENCODE_DISABLE_MODELS_FETCH=1 bun run local:check-offline
H5-E2E-OUT: 61 pass / 0 fail / 113 expect() calls (5 files); sync-model-whitelist.py ok whitelist covers the catalog snapshot in all three copies
関連: #325 / Cor-Incorporated/ai-cluster#238
🤖 Generated with Claude Code