Skip to content

feat(guardrails): cor-local provider (llama-server router・3 local models・offline opt-in) - #326

Merged
cloudia-Cor merged 2 commits into
devfrom
feat/cor-local-provider
Sep 3, 2026
Merged

cloudia-Cor merged 2 commits into
devfrom
feat/cor-local-provider

Conversation

@cloudia-Cor

Copy link
Copy Markdown
Collaborator

概要

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 の仕組みを使う。

  • whitelist: 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」小節を追加。
  • root 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-offline green(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行を出力することを確認。
  • 実チャット(router 未起動)・merge はこの PR の範囲外(監督が実測)。

Test plan

  • bun run local:check-offline green
  • RED→GREEN pin 実測(guardrail-patterns.ts の paid["cor-local"] 有無)
  • models cor-local が3 id を出力
  • .sh ファイル変更なし / core src/ 未変更(git diff --stat で確認)
  • 実 chat 貫通(router起動)は監督が実施

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

…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]>
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants