This repository was archived by the owner on Jun 24, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Chrome Sidecar MCP環境の実装 #241
Open
windschord
wants to merge
11
commits into
main
Choose a base branch
from
feat/chrome-sidecar-mcp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8328ece
feat(chrome-sidecar): Chrome Sidecar MCP環境の実装
windschord ab60019
fix(chrome-sidecar): CIのtextlintとtest-migration失敗を修正
windschord 863e2ec
fix(chrome-sidecar): CodeRabbitレビュー指摘の修正
windschord afba23c
docs(chrome-sidecar): 後方互換性の説明を明確化
windschord 2b45e03
fix(chrome-sidecar): 残存レビュー指摘の修正
windschord f37a544
test(chrome-sidecar): mutation-testスコア改善のためテスト強化
windschord 21087e6
test(chrome-sidecar): DockerAdapterのChrome Sidecar統合テストを改善
windschord 04de50f
fix(chrome-sidecar): lint未使用変数エラーを修正
windschord 62b6744
Merge branch 'main' into feat/chrome-sidecar-mcp
windschord b0ce416
feat(chrome-sidecar): デフォルトイメージをclaude-work-sandbox:chrome-devtoolsに変更
windschord e027880
Merge branch 'main' into feat/chrome-sidecar-mcp
windschord 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # API設計: Environment API拡張 | ||
|
|
||
| ## 概要 | ||
|
|
||
| 環境APIの作成・更新エンドポイントにchromeSidecar設定のバリデーションを追加する。 | ||
|
|
||
| ## 対応要件 | ||
|
|
||
| REQ-003-001, REQ-003-002, REQ-003-003 | ||
|
|
||
| ## 変更エンドポイント | ||
|
|
||
| ### PUT /api/environments/:id | ||
|
|
||
| 既存のconfig JSONバリデーションに、chromeSidecar固有のバリデーションルールを追加する。 | ||
|
|
||
| ### POST /api/environments | ||
|
|
||
| 環境作成時も同様のバリデーションを適用する。 | ||
|
|
||
| ## バリデーション仕様 | ||
|
|
||
| ### リクエストボディ (config部分) | ||
|
|
||
| ```json | ||
| { | ||
| "config": { | ||
| "imageName": "ghcr.io/windschord/claude-work-sandbox", | ||
| "imageTag": "latest", | ||
| "chromeSidecar": { | ||
| "enabled": true, | ||
| "image": "ghcr.io/windschord/claude-work-sandbox", | ||
| "tag": "chrome-devtools" | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### バリデーションルール | ||
|
|
||
| | フィールド | ルール | HTTPステータス | エラーメッセージ | | ||
| |-----------|--------|--------------|-----------------| | ||
| | chromeSidecar | オプション(省略時はenabled:falseとして扱う) | - | - | | ||
| | chromeSidecar.enabled | boolean型、必須(chromeSidecarが存在する場合) | 400 | "chromeSidecar.enabled is required and must be a boolean" | | ||
| | chromeSidecar.image | 文字列型、`/^[-a-z0-9._/]+$/` に適合、必須 | 400 | "chromeSidecar.image must be a valid Docker image name" | | ||
| | chromeSidecar.tag | 文字列型、空文字不可、`latest`不可、必須 | 400 | "chromeSidecar.tag must be a specific version (latest is not allowed)" | | ||
| | chromeSidecar + type=HOST | chromeSidecarは無視される(HOST環境には適用不可) | - | - | | ||
|
|
||
| ### バリデーション実装箇所 | ||
|
|
||
| 環境APIのバリデーションロジック内に追加する。 | ||
|
|
||
| ```typescript | ||
| function validateChromeSidecarConfig( | ||
| config: Record<string, unknown> | ||
| ): string | null { | ||
| if (!config.chromeSidecar) return null; // 省略OK | ||
|
|
||
| const sidecar = config.chromeSidecar as Record<string, unknown>; | ||
|
|
||
| if (typeof sidecar.enabled !== 'boolean') { | ||
| return 'chromeSidecar.enabled is required and must be a boolean'; | ||
| } | ||
|
|
||
| if (!sidecar.enabled) return null; // disabled時はimage/tagのバリデーション不要 | ||
|
|
||
| if (typeof sidecar.image !== 'string' || !/^[-a-z0-9._/]+$/.test(sidecar.image)) { | ||
| return 'chromeSidecar.image must be a valid Docker image name (lowercase alphanumeric, dots, slashes, hyphens)'; | ||
| } | ||
|
|
||
| if (typeof sidecar.tag !== 'string' || sidecar.tag.trim() === '') { | ||
| return 'chromeSidecar.tag is required'; | ||
| } | ||
|
|
||
| if (sidecar.tag === 'latest') { | ||
| return 'chromeSidecar.tag must be a specific version (latest is not allowed for reproducibility)'; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| ``` | ||
|
|
||
| ## レスポンス | ||
|
|
||
| 変更なし。既存のEnvironmentレスポンスにconfig JSONが含まれており、chromeSidecarもその中に格納される。 | ||
|
|
||
| ## 後方互換性 | ||
|
|
||
| - chromeSidecarキーが存在しないconfig JSONは引き続き有効 | ||
| - 既存の環境レコードに変更は不要 | ||
| - HOST環境のconfigにchromeSidecarが含まれていても無視される(エラーにはしない) | ||
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,62 @@ | ||
| # API設計: Session API拡張 | ||
|
|
||
| ## 概要 | ||
|
|
||
| セッションAPIのレスポンスにChromeサイドカー情報(コンテナID、デバッグポート)を追加する。 | ||
|
|
||
| ## 対応要件 | ||
|
|
||
| REQ-004-002, REQ-004-003 | ||
|
|
||
| ## 変更エンドポイント | ||
|
|
||
| ### GET /api/sessions/:id | ||
|
|
||
| レスポンスに chrome_container_id と chrome_debug_port を追加する。 | ||
|
|
||
| #### レスポンス例 (サイドカーあり) | ||
|
|
||
| ```json | ||
| { | ||
| "id": "abc-123", | ||
| "name": "my-session", | ||
| "status": "running", | ||
| "container_id": "claude-env-xxx-12345", | ||
| "chrome_container_id": "cw-chrome-abc-123", | ||
| "chrome_debug_port": 32789, | ||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| #### レスポンス例 (サイドカーなし) | ||
|
|
||
| ```json | ||
| { | ||
| "id": "abc-123", | ||
| "name": "my-session", | ||
| "status": "running", | ||
| "container_id": "claude-env-xxx-12345", | ||
| "chrome_container_id": null, | ||
| "chrome_debug_port": null, | ||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| ### GET /api/projects/:id/sessions | ||
|
|
||
| セッション一覧のレスポンスにも同様に chrome_container_id と chrome_debug_port を含める。 | ||
|
|
||
| ### DELETE /api/sessions/:id | ||
|
|
||
| セッション削除時、DockerAdapter.destroySession がサイドカーのクリーンアップを担当するため、APIレイヤーでの追加処理は不要。 | ||
|
|
||
| ## アクセス制御 | ||
|
|
||
| REQ-004-003 では「セッション所有者または管理者権限を持つユーザーのみ」にChrome情報の表示を制限する要件がある。 | ||
|
|
||
| 現状のclaude-workには認証/認可機能が存在しないため、以下の方針とする: | ||
|
|
||
| 1. 現時点: chrome_debug_port は全セッションAPIレスポンスに含める | ||
| 2. 将来の認証機能実装時: APIミドルウェアでユーザー権限を検証し、権限がない場合は chrome_debug_port を null にマスクする | ||
|
|
||
| この方針により、将来の認証機能追加時にAPIレスポンスの構造変更が不要となる。 |
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.
設計書が
/api/environments/:idの PUT/POST を前提にしていますが、このリポジトリでは/api/environments/:idは 410 Gone の deprecated エンドポイントで、後継は/api/projects/[project_id]/environmentです(src/app/api/environments/[id]/route.ts 参照)。ドキュメント内のエンドポイント表記とコード例を後継 API に更新してください。