From f2d24cb7d437ad099291262d7c1b021809cd66ae Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Sun, 13 Sep 2026 13:35:03 +0900 Subject: feat(multimedia): MCP画像・音声artifactの安全な表示経路を追加 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MCP Tool結果をテキストと型付きartifactへ分離し、画像・音声のbase64をMIME、サイズ、件数のallowlistで検証する。annotations.audienceを反映し、ユーザー向けartifactだけをセッションへ保存してSSEにはメタデータのみを公開する。 画像はvision capabilityが明示されたモデルだけへ渡し、非対応時は既存の多言語プロンプト機構による固定通知へ置き換える。MCP生成音声とユーザー添付音声はOllamaへ送らず、誤デコードしたテキストやbase64がモデル入力へ混入しないポリシーに統一する。 保存メディア用の認証済み同一オリジン配信ルートを追加し、セッションスコープ、MIME allowlist、nosniff、private/no-store、Rangeリクエストを適用する。UIはMCP由来HTMLを使わずDOM APIでimgとaudio controlsを生成し、CSPへmedia-src selfを追加する。 web_searchは文字列メタデータだけを返す既存仕様を維持する。scrape_urlとsearch_and_fetchは画像・音声・動画レスポンスを拒否し、search_and_fetchの対象拡張子を明示的allowlistへ変更して標準Webツールをテキスト専用の契約に揃える。 責務境界と導入しない過剰対策をdocs/multimedia.mdへ記録し、README、ツール仕様、CHANGELOGを更新する。MCP artifact変換・永続化、vision分岐、音声非送信、認証、Range配信、MIME偽装拒否をテストで追加確認した。 Validation: 148 tests passed; ruff check passed; mypy src passed; node --check src/ollama_web/static/app.js passed. --- src/ollama_web/i18n/__init__.py | 2 +- src/ollama_web/i18n/messages/en.json | 3 ++- src/ollama_web/i18n/messages/ja.json | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/ollama_web/i18n') diff --git a/src/ollama_web/i18n/__init__.py b/src/ollama_web/i18n/__init__.py index 6ab540c..9cd55e5 100644 --- a/src/ollama_web/i18n/__init__.py +++ b/src/ollama_web/i18n/__init__.py @@ -81,4 +81,4 @@ def t(key: str, lang: str | None = None, fallback: str | None = None) -> str: value = _resolve(key, get_messages(resolve_language(lang))) if isinstance(value, str): return value - return fallback if fallback is not None else key \ No newline at end of file + return fallback if fallback is not None else key diff --git a/src/ollama_web/i18n/messages/en.json b/src/ollama_web/i18n/messages/en.json index 74e0c00..878e53c 100644 --- a/src/ollama_web/i18n/messages/en.json +++ b/src/ollama_web/i18n/messages/en.json @@ -32,7 +32,8 @@ "processing": "Processing…", "no_response": "(No response)", "clear_failed": "Failed to clear", - "clear_messages_failed": "Failed to clear messages" + "clear_messages_failed": "Failed to clear messages", + "image_attachment": "Attached image" }, "mcp": { "server_settings": "MCP Server Settings", diff --git a/src/ollama_web/i18n/messages/ja.json b/src/ollama_web/i18n/messages/ja.json index f775ba6..b39e85e 100644 --- a/src/ollama_web/i18n/messages/ja.json +++ b/src/ollama_web/i18n/messages/ja.json @@ -32,7 +32,8 @@ "processing": "処理中…", "no_response": "(応答なし)", "clear_failed": "クリアに失敗しました", - "clear_messages_failed": "メッセージのクリアに失敗しました" + "clear_messages_failed": "メッセージのクリアに失敗しました", + "image_attachment": "添付画像" }, "mcp": { "server_settings": "MCPサーバー設定", -- cgit v1.2.3