Repository navigation
feat(guardrails): cor-local provider (llama-server router・3 local models・offline opt-in) - #326
Merged
Merged
Conversation
…ls・offline opt-in) Cor 独自の完全ローカル llama-server ルーター(Mac Studio, http://127.0.0.1:18082/v1)を opt-in provider `cor-local` として guardrails managed/profile 両プロファイルへ追加。 glm53-flash / deepseek-v4-flash-0731 / qwen3.8-27b の3モデルをwhitelistし、 自己ホストのため cost=0 だが free-tier ではないことを guardrail-patterns.ts の paid["cor-local"] で明示。既定モデル(zai-coding-plan/glm-5.3)は変更しない。 Refs #325 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. |
|
The following comment was made by an LLM, it may be inaccurate: |
…ails test:ci を追加(review 対応) PR #326 の code-review 指摘(HIGH 2 / MEDIUM 3)に対応。 HIGH: - paid["cor-local"] を deepseek 等と同じ複数行 new Set([...]) 記法に変更。 一行記法は sync-model-whitelist.py の write_paid 正規表現が複数行前提のため --apply 実行時に不整合を招く(reviewer 再現済み、本コミットで実測確認)。 - whitelist をソート順(deepseek-v4-flash-0731, glm53-flash, qwen3.8-27b)に統一。 managed/profile 両JSON・guardrail-patterns.ts・model-whitelist.test.ts の ids を揃えた。 --apply はソート済みunionを書き戻すため、この順序が固定点になる。 MEDIUM: - packages/guardrails/package.json に test / test:ci スクリプトを追加し、 turbo 経由(bun turbo test:ci --filter=@opencode-ai/guardrails)で拾えるようにした。 - options.chunkTimeout を 120000ms(2分)に設定。timeout:false だけでは生成ストール時に 無限待ちになるため、ヘッダ到達後のチャンク間隔を別途bound。README/providers.mdxに追記。 - README の denyPreview 説明を実装どおりに修正(status!=="active"を先に判定、 regex の \b 境界を明記)。sync-model-whitelist.py docstring の存在しない --check 記述を「引数なし=check」に訂正。 Refs #325, review on PR #326 Agent-Lane: claude-code Co-Authored-By: Claude Fable 5.1 <[email protected]>
3 tasks
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 独自の完全ローカル
llama-serverルーター(Mac Studio,http://127.0.0.1:18082/v1, API key不要)をopt-in の custom provider
cor-localとしてpackages/guardrails/managed/opencode.jsonとpackages/guardrails/profile/opencode.json(両方ともprovider/enabled_providers/modelセクションは編集後も一致することを確認済み)へ追加した。既存の
llama.cpp/lmstudioレシピ(
packages/web/src/content/docs/providers.mdx)と同じ@ai-sdk/openai-compatibleの仕組みを使う。glm53-flash,deepseek-v4-flash-0731,qwen3.8-27b(3モデル、いずれもtool_call: true/reasoning: true/interleaved: "reasoning_content"/limit.context: 32768/limit.output: 16384)options.headerTimeout: 900000,options.timeout: false(コールドロード最大約60秒に対応)profile/plugins/guardrail-patterns.tsのpaid["cor-local"]に3 id を追加。自己ホストで cost=0 だがfree-tier ではないため
denyFreeに誤ってブロックされないようにするための分類。scripts/sync-model-whitelist.pyのPAID_PROVIDERSにcor-localを追加。models.dev カタログのsnapshot には
cor-localが存在しないためcheck()はmissingを空集合として扱い green のまま。zai-coding-plan/glm-5.3)・share: disabled・server.mdns: falseは変更していない。packages/guardrails/README.mdに「cor-local (ローカル lane)」節、packages/guardrails/profile/AGENTS.mdに1段落、providers.mdxに llama.cpp 節直後の「### Cor local router」小節を追加。
package.jsonにlocal:check-offlineスクリプトを追加。ただし委任契約に書かれた"bun test packages/guardrails/profile/plugins && ..."の形はリポジトリ直下のbunfig.toml(
[test] root = "./do-not-run-tests-from-root")によって repo root からのbun testを意図的にブロックするため実際には失敗する(実測)。同義の
"(cd packages/guardrails && bun test profile/plugins) && python3 scripts/sync-model-whitelist.py"に差し替えて offline green を確認した。
検証
bun test packages/guardrails/profile/plugins/model-whitelist.test.tsの pin を RED→GREEN で実測(
paid["cor-local"]を一時的に外すと4件 fail、戻すと 22 pass / 0 fail)。bun run local:check-offlinegreen(27 pass / 0 fail、sync-model-whitelist.pyはok)。bun turbo typecheck(push 時の pre-push hook 経由、30/30 successful)で型崩れなし。packages/guardrails自体にはtsconfig.jsonもtypecheckスクリプトも無いため単体のtypecheck 対象は無し(スキップ)。
cd packages/opencode && bun run script/build.ts --single --skip-embed-web-uiでopencode-darwin-arm64をビルドし、OPENCODE_DISABLE_MODELS_FETCH=1 OPENCODE_CONFIG_DIR=<worktree>/packages/guardrails/profile dist/opencode-darwin-arm64/bin/opencode models cor-localがcor-local/deepseek-v4-flash-0731/cor-local/glm53-flash/cor-local/qwen3.8-27bの3行を出力することを確認。Test plan
bun run local:check-offlinegreenpaid["cor-local"]有無)models cor-localが3 id を出力.shファイル変更なし / coresrc/未変更(git diff --statで確認)H5-E2E: bun run local:check-offline
H5-E2E-OUT: 27 pass / 0 fail across 2 files; sync-model-whitelist.py -> ok whitelist covers snapshot
Refs #325
🤖 Generated with Claude Code