diff --git a/bin/momentry b/bin/momentry new file mode 100755 index 0000000..1d34a8e Binary files /dev/null and b/bin/momentry differ diff --git a/bin/momentry-proxy b/bin/momentry-proxy new file mode 100755 index 0000000..ed948f8 Binary files /dev/null and b/bin/momentry-proxy differ diff --git a/config/admin_config.json b/config/admin_config.json new file mode 100644 index 0000000..b7f084f --- /dev/null +++ b/config/admin_config.json @@ -0,0 +1,661 @@ +{ + "version": "1.0.0", + "updated_at": "2026-11-08T08:03:46.203934+00:00", + "updated_by": "admin", + "vlm_prompts": { + "rust_vlm_summary": { + "system_prompt": "You are a helpful assistant that describes people in images.", + "user_prompt": "Describe the person in this image. Focus on clothing, accessories, and distinctive features.", + "max_tokens": 300, + "description": "Face trace VLM prompt for person description" + }, + "scene_vlm": { + "system_prompt": "You are a helpful assistant that analyzes video scenes.", + "user_prompt": "Describe this scene. What is happening? What objects and people are visible?", + "max_tokens": 200, + "description": "Scene analysis VLM prompt" + } + }, + "llm_config": { + "chat": { + "url": "http://localhost:8080/v1/chat/completions", + "model": "gemma-4-12b-it", + "timeout": 30 + }, + "summary": { + "url": "http://localhost:8080/v1/chat/completions", + "model": "gemma-4-12b-it", + "timeout": 60 + } + }, + "processor_config": { + "FACE": { + "timeout": 3600, + "enabled": true, + "tools": [ + { + "name": "swift", + "priority": 0, + "enabled": true, + "parameters": {} + }, + { + "name": "python", + "priority": 2, + "enabled": true, + "parameters": {} + } + ], + "default_tool": "swift" + }, + "FACE_TRACE": { + "timeout": 3600, + "enabled": true, + "tools": [ + { + "name": "rust", + "priority": 0, + "enabled": true, + "parameters": {} + }, + { + "name": "python", + "priority": 1, + "enabled": true, + "parameters": {} + } + ], + "default_tool": "rust" + }, + "POSE": { + "timeout": 3600, + "enabled": true, + "tools": [ + { + "name": "swift", + "priority": 0, + "enabled": true, + "parameters": {} + }, + { + "name": "rust", + "priority": 1, + "enabled": true, + "parameters": {} + }, + { + "name": "mediapipe", + "priority": 2, + "enabled": true, + "parameters": { + "min_confidence": 0.5, + "model_complexity": 2 + } + } + ], + "default_tool": "swift" + }, + "CUT": { + "timeout": 3600, + "enabled": true, + "tools": [ + { + "name": "rust", + "priority": 0, + "enabled": true, + "parameters": {} + }, + { + "name": "python", + "priority": 2, + "enabled": true, + "parameters": {} + } + ], + "default_tool": "rust" + }, + "ASRX": { + "timeout": 3600, + "enabled": true, + "tools": [ + { + "name": "swift", + "priority": 0, + "enabled": true, + "parameters": {} + } + ], + "default_tool": "swift" + }, + "OCR": { + "timeout": 3600, + "enabled": true, + "tools": [ + { + "name": "swift", + "priority": 0, + "enabled": true, + "parameters": {} + } + ], + "default_tool": "swift" + } + }, + "filter_config": { + "face": { + "min_confidence": 0.5, + "min_size": 30 + } + }, + "face_filter_defaults": { + "min_confidence": 50.0, + "min_size": 1, + "min_capture_quality": 0.25 + }, + "paths": { + "root": "/Users/accusys/momentry", + "bin": "/Users/accusys/momentry/bin", + "config": "/Users/accusys/momentry/config", + "scripts": "/Users/accusys/momentry/scripts", + "output": "/Users/accusys/momentry/output", + "logs": "/Users/accusys/momentry/logs", + "processors": "/Users/accusys/momentry/processors", + "tools": "/Users/accusys/momentry/tools", + "tools_cli_rust": "/Users/accusys/momentry/tools/cli/rust/target/release", + "tools_cli_swift_symlinks": "/Users/accusys/momentry/bin/tools/cli/swift/.build/release", + "var": "/Users/accusys/momentry/var", + "var_sftpgo": "/Users/accusys/momentry/var/sftpgo", + "var_data": "/Users/accusys/momentry/var/data", + "etc": "/Users/accusys/momentry/etc", + "dist": "/Users/accusys/momentry/dist", + "models": "/Users/accusys/momentry/models", + "release": "/Users/accusys/momentry/release", + "frontend": "/Users/accusys/momentry/frontend", + "thumbnails": "/Users/accusys/momentry/thumbnails", + "external": { + "ffmpeg": "/opt/homebrew/bin/ffmpeg", + "ffprobe": "/opt/homebrew/bin/ffprobe", + "python3": "/opt/homebrew/bin/python3.11" + }, + "markbase": { + "root": "/Users/accusys/markbase", + "data": "/Users/accusys/markbase/data", + "auth_db": "/Users/accusys/markbase/data/auth.sqlite", + "filetree_users": "/Users/accusys/markbase/filetree/data/users", + "logs": "/Users/accusys/markbase/logs" + }, + "studio": { + "root": "/Users/accusys/momentry_studio", + "data": "/Users/accusys/momentry_studio/data", + "data_users": "/Users/accusys/momentry_studio/data/users" + }, + "sqlite": { + "workspace_pattern": "{output}/{uuid}.workspace.sqlite", + "face_operations": "{output}/face_operations.sqlite", + "sftpgo_webdav": "{var_sftpgo}/data/demo/webdav_virtual.sqlite", + "markbase_auth": "/Users/accusys/markbase/data/auth.sqlite", + "markbase_filetree": "/Users/accusys/markbase/filetree/data/users/{user}.sqlite", + "studio_user": "/Users/accusys/momentry_studio/data/users/{user}.sqlite", + "var_demo": "/Users/accusys/momentry/var/data/demo.sqlite" + }, + "output_dir": "/Users/accusys/momentry/output", + "backup_dir": "/Users/accusys/momentry/var/backup", + "scripts_dir": "/Users/accusys/momentry/scripts", + "cli_dir": "/Users/accusys/momentry/tools/cli", + "python_path": "/opt/homebrew/bin/python3.11", + "ffmpeg_path": "/opt/homebrew/bin/ffmpeg" + }, + "concurrency": { + "max_concurrent_jobs": 0, + "poll_interval": 0, + "batch_size": 0, + "processor_timeout_secs": 0 + }, + "feature_flags": { + "cache_enabled": true, + "auto_pipeline_enabled": true, + "watcher_auto_register": true, + "summary_enabled": true + }, + "server": { + "port": 3002, + "host": "0.0.0.0", + "media_base_url": "/Users/accusys/momentry/var/sftpgo/data", + "serve_base_url": "/api/v1/media", + "storage_root": "/Users/accusys/momentry/var/sftpgo/data", + "timezone": "Asia/Taipei", + "proxy_port": 8888, + "proxy_url": "http://localhost:8888" + }, + "admin_settings": { + "session_timeout": 0, + "max_login_attempts": 0, + "api_key_expiry_days": 0, + "system_stats_refresh_sec": 0, + "preferred_language": "" + }, + "search": { + "vlm_min_score": 0.0, + "vlm_output_language": "ja" + }, + "pipeline": { + "enabled": true, + "max_concurrent_stages": 5, + "default_timeout_secs": 7200, + "flows": {} + }, + "database": { + "url": "postgres://accusys@localhost:5432/momentry", + "schema": "public", + "pg_host": "/tmp" + }, + "redis": { + "url": "redis://:accusys@localhost:6379", + "prefix": "momentry:" + }, + "qdrant": { + "url": "http://127.0.0.1:6333", + "api_key": "Test3200Test3200Test3200", + "collection": "momentry_rule1" + }, + "llm": { + "chat": { + "url": "http://localhost:8080/v1/chat/completions", + "model": "gemma-4-12b-it", + "timeout": 30 + }, + "vision": { + "url": "http://127.0.0.1:8080/v1/chat/completions", + "model": "gemma-4-12b-it", + "timeout": 60 + }, + "embedding": { + "url": "http://localhost:11436/embed", + "model": "embeddinggemma-300m", + "timeout": 30 + } + }, + "worker": { + "max_concurrent": 6, + "poll_interval_secs": 5, + "batch_size": 5, + "processor_timeout_secs": 7200 + }, + "sqlite": { + "markbase": { + "auth": "/Users/accusys/markbase/data/auth.sqlite", + "description": "Markbase 認證 + SFTPGo users/groups 映射" + }, + "markbase_filetree": { + "dir": "/Users/accusys/markbase/filetree/data/users", + "pattern": "test_*.sqlite", + "description": "每用戶 file registry/nodes/locations" + }, + "studio": { + "dir": "/Users/accusys/momentry_studio/data/users", + "pattern": "*.sqlite", + "description": "前端用戶 bookmarks/search_history/video_marks" + }, + "workspace": { + "dir": "/Users/accusys/momentry/output", + "pattern": "{uuid}.workspace.sqlite", + "description": "每影片的 processor_results/chunks/face_detections/pre_chunks/speaker_detections" + }, + "face_operations": { + "path": "/Users/accusys/momentry/output/face_operations.sqlite", + "description": "人臉操作共享資料庫" + }, + "sftpgo_webdav": { + "path": "/Users/accusys/momentry/var/sftpgo/data/demo/webdav_virtual.sqlite", + "description": "WebDAV virtual folders / file_tags / config" + }, + "var_data": { + "path": "/Users/accusys/momentry/var/data/demo.sqlite", + "description": "共享 demo 資料 (app_users/bookmarks/search_history)" + } + }, + "services": { + "proxy": { + "name": "momentry-proxy", + "binary": "/Users/accusys/momentry/bin/momentry-proxy", + "port": 8888, + "description": "Tauri desktop app API proxy — Rust backend + Vue3 frontend", + "architecture": "Rust (Tauri) + Vue3", + "role": "API proxy for Admin UI, forwards requests to core API (3002)", + "launchd": "com.momentry.proxy" + }, + "server": { + "name": "momentry", + "binary": "/Users/accusys/momentry/bin/momentry", + "port": 3002, + "subcommand": "server", + "description": "Core API server", + "launchd": "com.momentry.server" + }, + "worker": { + "name": "momentry", + "binary": "/Users/accusys/momentry/bin/momentry", + "subcommand": "worker", + "description": "Background job processor", + "launchd": "com.momentry.worker" + } + }, + "architecture": { + "layers": [ + { + "id": "layer1_infra", + "name": "基礎設施層", + "name_en": "Infrastructure", + "services": [ + { + "name": "PostgreSQL", + "port": 5432, + "role": "主要關聯式資料庫", + "launchd": "com.momentry.postgresql" + }, + { + "name": "Redis", + "port": 6379, + "role": "快取 / 任務佇列 / Session", + "launchd": "com.momentry.redis" + }, + { + "name": "Qdrant", + "port": 6333, + "role": "向量資料庫(人臉、文字 embedding)", + "launchd": "com.momentry.qdrant" + } + ] + }, + { + "id": "layer2_file", + "name": "檔案管理層", + "name_en": "File Management", + "services": [ + { + "name": "SFTPGo", + "ports": [ + 2022, + 8081 + ], + "role": "SFTP/WebDAV 檔案上傳與管理", + "launchd": "com.momentry.sftpgo" + }, + { + "name": "markbase", + "binary": "/Users/accusys/momentry/bin/markbase-core", + "command": "web-start", + "port": 3010, + "workdir": "/Users/accusys/markbase", + "role": "檔案樹管理、WebDAV、SSH、使用者認證", + "description": "Rust workspace: filetree, markbase-core, markbase-webdav, markbase-fskit 等", + "sqlite": { + "auth": "/Users/accusys/markbase/data/auth.sqlite", + "filetree": "/Users/accusys/markbase/filetree/data/users/" + }, + "launchd": "com.momentry.markbase" + } + ] + }, + { + "id": "layer3_llm", + "name": "LLM/VLM 層", + "name_en": "AI Inference", + "services": [ + { + "name": "Chat LLM", + "binary": "/Users/accusys/momentry/bin/llama-server", + "port": 8080, + "model": "/Users/accusys/models/gemma-4-12b-it-Q4_K_M.gguf", + "role": "文字生成、場景摘要、Agent 查詢", + "launchd": "com.momentry.llm" + }, + { + "name": "Embedding", + "port": 11436, + "model": "/Users/accusys/models/embeddinggemma-300M-Q8_0.gguf", + "role": "文字向量嵌入", + "launchd": "com.momentry.embedding" + }, + { + "name": "markbaseengine", + "binary": "/Users/accusys/momentry/bin/markbaseengine", + "config": "/Users/accusys/momentry/config/markbaseengine.json", + "port": 8082, + "role": "LLM 封裝服務 — 包裝 llama-server 提供健康檢查、自動重啟、token 限制", + "description": "使用 gemma-4-12b-it + mmproj-F16.gguf (VLM)", + "launchd": "com.momentry.markbaseengine" + } + ] + }, + { + "id": "layer4_core", + "name": "核心服務層", + "name_en": "Core Services", + "services": [ + { + "name": "Momentry API", + "binary": "/Users/accusys/momentry/bin/momentry", + "command": "server", + "port": 3002, + "role": "REST API — 影片管理、查詢、處理器調度", + "launchd": "com.momentry.server" + }, + { + "name": "Momentry Worker", + "binary": "/Users/accusys/momentry/bin/momentry", + "command": "worker", + "role": "背景處理器 — ASR/OCR/Face/Cut/VLM/TKG 管線執行", + "launchd": "com.momentry.worker" + } + ] + }, + { + "id": "layer5_ui", + "name": "使用者介面層", + "name_en": "User Interface", + "services": [ + { + "name": "momentry-proxy", + "binary": "/Users/accusys/momentry/bin/momentry-proxy", + "port": 8888, + "role": "Admin UI API 代理 — Rust (Tauri) + Vue3", + "architecture": "Rust (Tauri backend) + Vue3 (frontend)", + "launchd": "com.momentry.proxy" + } + ] + } + ], + "startup_order": [ + "layer1_infra", + "layer2_file", + "layer3_llm", + "layer4_core", + "layer5_ui" + ] + }, + "api": { + "markbase_core": { + "port": 3010, + "base_url": "http://localhost:3010", + "binary": "/Users/accusys/momentry/bin/markbase-core", + "command": "web-start", + "framework": "axum 0.7 (Rust)", + "endpoints": { + "auth": { + "POST /api/v2/auth/login": "使用者登入", + "POST /api/v2/auth/logout": "使用者登出", + "GET /api/v2/auth/verify": "驗證 token" + }, + "admin": { + "POST /api/v2/admin/login": "管理員登入", + "GET /api/v2/admin/verify": "管理員驗證", + "GET /api/v2/admin/users": "列出使用者", + "POST /api/v2/admin/users": "建立使用者", + "DELETE /api/v2/admin/users/:username": "刪除使用者", + "PUT /api/v2/admin/users/:username": "更新使用者", + "POST /api/v2/admin/users/:username/password": "修改密碼", + "POST /api/v2/admin/sync": "手動同步", + "GET /api/v2/admin/sync/status": "同步狀態", + "GET /api/v2/admin/system-stats": "系統統計", + "GET /api/v2/admin/shares": "共享列表" + }, + "config": { + "GET /api/v2/config": "取得配置", + "POST /api/v2/config/edit": "編輯配置", + "GET /api/v2/config/validate": "驗證配置", + "GET /api/v2/config/s3": "S3 配置", + "POST /api/v2/config/s3/edit": "編輯 S3 配置", + "GET /api/v2/config/s3/validate": "驗證 S3 配置" + }, + "settings": { + "GET /api/v2/settings": "取得設定", + "POST /api/v2/settings": "更新設定", + "POST /api/v2/settings/validate": "驗證設定" + }, + "tree": { + "GET /api/v2/tree/:user_id": "取得檔案樹", + "GET /api/v2/tree/:user_id/search": "搜尋檔案樹", + "POST /api/v2/tree/:user_id/node": "建立節點", + "PUT /api/v2/tree/:user_id/node/:node_id": "更新節點", + "DELETE /api/v2/tree/:user_id/node/:node_id": "刪除節點", + "DELETE /api/v2/tree/:user_id": "刪除全部節點", + "POST /api/v2/tree/:user_id/restore": "還原檔案樹", + "PUT /api/v2/tree/:user_id/node/:node_id/move": "移動節點" + }, + "files": { + "GET /api/v2/files/:user_id": "列出上傳檔案", + "GET /api/v2/files/:user_id/:file_uuid/info": "檔案資訊", + "GET /api/v2/files/:user_id/:file_uuid/probe": "檔案 probe", + "GET /api/v2/files/:user_id/:file_uuid/stream": "串流檔案", + "GET /api/v2/files/:user_id/:filename": "檔案資訊 (by name)", + "GET /api/v2/files/search": "搜尋檔案", + "POST /api/v2/upload/:user_id": "上傳檔案", + "POST /api/v2/upload-unlimited/:user_id": "無限上傳", + "POST /api/v2/unregister/:file_uuid": "取消註冊檔案" + }, + "myfiles": { + "GET /api/v2/myfiles/:username/folders": "列出資料夾", + "GET /api/v2/myfiles/:username/folders/tree": "資料夾樹", + "POST /api/v2/myfiles/:username/folders": "建立資料夾", + "DELETE /api/v2/myfiles/:username/folders/*path": "刪除資料夾", + "GET /api/v2/myfiles/:username/files": "列出檔案", + "DELETE /api/v2/myfiles/:username/files/:filename": "刪除檔案", + "POST /api/v2/myfiles/:username/tags": "新增標籤", + "DELETE /api/v2/myfiles/:username/tags": "移除標籤", + "GET /api/v2/myfiles/:username/files/:filename/tags": "檔案標籤", + "GET /api/v2/myfiles/:username/preview/:filename": "預覽檔案", + "POST /api/v2/myfiles/:username/move": "移動檔案", + "POST /api/v2/myfiles/:username/move-folder": "移動資料夾", + "POST /api/v2/myfiles/:username/rename-file": "重新命名檔案", + "POST /api/v2/myfiles/:username/rename-folder": "重新命名資料夾" + }, + "search": { + "GET /api/v2/search-sessions": "列出搜尋session", + "POST /api/v2/search-sessions": "建立搜尋session", + "PUT /api/v2/search-sessions/:id": "更新session", + "DELETE /api/v2/search-sessions/:id": "刪除session", + "GET /api/v2/search-sessions/:id/messages": "列出訊息", + "POST /api/v2/search-sessions/:id/messages": "建立訊息", + "PATCH /api/v2/search-sessions/:id/messages/:msgId": "更新訊息" + }, + "s3": { + "GET /api/v2/s3/status": "S3 狀態", + "POST /api/v2/s3/generate-key": "產生 S3 key", + "GET /s3": "列出 buckets", + "GET /s3/:bucket": "列出 objects", + "GET /s3/:bucket/*key": "下載 object", + "GET /s3/policy/:bucket": "取得 policy", + "PUT /s3/policy/:bucket": "設定 policy", + "DELETE /s3/policy/:bucket": "刪除 policy" + }, + "products_downloads": { + "GET /api/v2/products": "產品列表", + "GET /api/v2/products/stats": "產品統計", + "POST /api/v2/products/create": "建立產品", + "GET /api/v2/products/:product_id/files": "產品檔案", + "GET /api/v2/download/:file_id": "下載檔案", + "GET /api/v2/download/:user_id/*path": "路徑下載", + "GET /api/v2/download/stats": "下載統計" + }, + "categories_series": { + "GET /api/v2/categories": "分類列表", + "GET /api/v2/categories/:name": "分類詳情", + "GET /api/v2/series": "系列列表", + "GET /api/v2/series/:name": "系列詳情" + }, + "backup": { + "GET /api/v2/backup/stats": "備份統計", + "GET /api/v2/backup/config": "備份配置", + "POST /api/v2/backup/config": "設定備份", + "POST /api/v2/backup/run": "執行備份", + "GET /api/v2/snapshots": "快照列表", + "POST /api/v2/snapshots/:name": "建立快照", + "DELETE /api/v2/snapshots/:name": "刪除快照", + "POST /api/v2/snapshots/:name/restore": "還原快照" + }, + "mbe": { + "GET /api/v2/mbe/models": "取得 MBE 模型列表" + }, + "service": { + "POST /api/v2/service/stop": "停止服務", + "POST /api/v2/service/start": "啟動服務", + "GET /api/v2/worker/status": "Worker 狀態" + }, + "misc": { + "GET /api/v2/health": "健康檢查", + "GET /api/v2/status": "狀態", + "GET /api/v2/version": "版本", + "GET /api/v2/metrics": "指標", + "GET /api/v2/audit": "稽核", + "GET /api/v2/storage/stats": "儲存統計", + "GET /api/v2/labels": "標籤列表", + "POST /api/v2/labels": "新增標籤", + "GET /api/v2/dupes/:user_id": "重複檔案", + "GET /api/v2/render/:file_uuid": "渲染檔案", + "GET /api/v2/modes": "模式列表" + }, + "webdav": { + "ANY /webdav": "WebDAV 端點", + "ANY /webdav/*path": "WebDAV 路徑", + "ANY /admin-webdav": "管理員 WebDAV", + "ANY /admin-webdav/*path": "管理員 WebDAV 路徑" + } + } + }, + "markbaseengine": { + "port": 8082, + "base_url": "http://localhost:8082", + "binary": "/Users/accusys/momentry/bin/markbaseengine", + "config": "/Users/accusys/momentry/config/markbaseengine.json", + "description": "llama-server wrapper — 提供 OpenAI 相容 API + 健康檢查 + 自動重啟", + "framework": "llama.cpp (llama-server)", + "endpoints": { + "models": { + "GET /v1/models": "列出可用模型 (OpenAI 相容)" + }, + "chat": { + "POST /v1/chat/completions": "對話生成 (OpenAI 相容, 支援 VLM)" + }, + "completion": { + "POST /v1/completions": "文字生成 (OpenAI 相容)" + }, + "embedding": { + "POST /v1/embeddings": "向量嵌入 (如果模型支援)" + }, + "health": { + "GET /health": "健康檢查 {\"status\":\"ok\"}" + } + }, + "model": { + "path": "/Users/accusys/models/gemma-4-12b-it-Q4_K_M.gguf", + "size": "7.1 GB", + "mmproj": "/Users/accusys/models/mmproj-F16.gguf", + "capabilities": [ + "completion", + "multimodal" + ] + } + } + } +} \ No newline at end of file