{"id":"33a16691-9661-492e-9b2b-c47d0da7a3ce","entityType":"agent","slug":"clawhub-smyx-sunjinhui-smyx-fish-isolation-detection-analysis","name":"Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别","canonicalUrl":"https://www.xpersona.co/agent/clawhub-smyx-sunjinhui-smyx-fish-isolation-detection-analysis","canonicalPath":"/agent/clawhub-smyx-sunjinhui-smyx-fish-isolation-detection-analysis","generatedAt":"2026-10-10T11:52:52.166Z","source":"CLAWHUB","claimStatus":"UNCLAIMED","verificationTier":"NONE","summary":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-10T08:54:24.070Z","emptyReason":null},"description":"Through fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。","descriptionLabel":"Source description","evidenceSummary":"Capability contract not published. No trust telemetry is available yet. 1.5K downloads reported by the source. Last updated 10/10/2026.","installCommand":"clawhub skill install s17cfv2h26b7hq5w47tgfy23xx83z9x6:smyx-fish-isolation-detection-analysis","sourceUrl":"https://clawhub.ai/smyx-sunjinhui/smyx-fish-isolation-detection-analysis","homepage":"https://clawhub.ai/smyx-sunjinhui/skills/smyx-fish-isolation-detection-analysis","primaryLinks":[{"label":"View on ClawHub","url":"https://clawhub.ai/smyx-sunjinhui/smyx-fish-isolation-detection-analysis","kind":"source"},{"label":"Homepage","url":"https://clawhub.ai/smyx-sunjinhui/skills/smyx-fish-isolation-detection-analysis","kind":"homepage"}],"safetyScore":84,"overallRank":62,"popularityScore":64,"trustScore":null,"claimedByName":null,"isOwner":false,"seoDescription":"Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别 technical dossier on Xpersona with agent coverage, OPENCLEW support, and live trust metadata."},"coverage":{"evidence":{"source":"public-profile","verified":false,"confidence":"medium","updatedAt":"2026-10-10T08:54:24.070Z","emptyReason":null},"protocols":[{"protocol":"OPENCLEW","label":"OpenClaw","status":"self-declared","notes":"Declared in the public agent profile."}],"capabilities":[],"verifiedCount":0,"selfDeclaredCount":1,"capabilityMatrix":{"rows":[{"key":"OPENCLEW","type":"protocol","support":"unknown","confidenceSource":"profile","notes":"Listed on profile"}],"flattenedTokens":"protocol:OPENCLEW|unknown|profile"}},"adoption":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-10T08:54:24.070Z","emptyReason":null},"stars":null,"forks":null,"downloads":1544,"packageName":null,"latestVersion":"1.0.10","tractionLabel":"1.5K downloads"},"release":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-10T08:54:24.070Z","emptyReason":null},"lastUpdatedAt":"2026-10-10T08:54:24.070Z","lastCrawledAt":"2026-10-10T08:54:24.070Z","lastIndexedAt":null,"nextCrawlAt":"2026-10-11T08:54:24.070Z","lastVerifiedAt":null,"highlights":[{"version":"1.0.10","createdAt":"2026-10-03T08:52:40.368Z","changelog":"**smyx-fish-isolation-detection-analysis 1.0.10 Changelog** - Updated SKILL.md: version number increased from 1.0.13 to 1.0.16 with no other content differences observed. - Updated configuration in skills/smyx_common/scripts/config.yaml (details not specified). - General maintenance updates and documentation version synchronization.","fileCount":31,"zipByteSize":44498},{"version":"1.0.9","createdAt":"2026-09-16T08:54:38.962Z","changelog":"- Updated version to 1.0.13 in SKILL.md. - Removed the file skill-card.md from the repository. - No functional or code changes; documentation/metadata cleanup only.","fileCount":30,"zipByteSize":43318},{"version":"1.0.8","createdAt":"2026-08-26T11:43:30.176Z","changelog":"- Updated version to 1.0.12 in SKILL.md. - Removed the file skill-card.md. - No changes to core workflow or technical capabilities were introduced. - Minor documentation/content update only; no change to APIs or logic.","fileCount":31,"zipByteSize":44783},{"version":"1.0.7","createdAt":"2026-08-23T12:32:54.080Z","changelog":"- Updated documentation (SKILL.md) to reflect version 1.0.11 and recent adjustments. - Removed the file skill-card.md from the project. - Refined configuration in skills/smyx_common/scripts/config.yaml. - Improved and clarified feature descriptions and operational instructions in the main documentation.","fileCount":31,"zipByteSize":44716},{"version":"1.0.6","createdAt":"2026-08-10T18:04:34.957Z","changelog":"- Updated version number in SKILL.md from 1.0.8 to 1.0.9. - Removed redundant file: skill-card.md. - No logic or functionality changes; maintenance update only.","fileCount":31,"zipByteSize":44745},{"version":"1.0.5","createdAt":"2026-08-04T20:39:32.592Z","changelog":"Changelog for smyx-fish-isolation-detection-analysis v1.0.5 - Removed the file `skill-card.md` from the project. - No other changes in code or documentation are indicated for this version.","fileCount":31,"zipByteSize":44844},{"version":"1.0.4","createdAt":"2026-08-01T07:53:30.592Z","changelog":"- Updated skill version to 1.0.8 in SKILL.md. - Updated documentation content in SKILL.md with clarification and detail enhancements. - Removed the skill-card.md file.","fileCount":31,"zipByteSize":44965},{"version":"1.0.3","createdAt":"2026-07-12T22:18:25.559Z","changelog":"- Updated version number to 1.0.5 in SKILL.md. - Documentation maintained and clarified; no user-facing feature changes described. - Removed obsolete file: skill-card.md. - Internal scripts and utilities adjusted (see skills/smyx_common/scripts/util.py for details). - No changes to core algorithm or user workflow reported.","fileCount":31,"zipByteSize":44840}]},"execution":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No published capability contract is available yet."},"installCommand":"clawhub skill install s17cfv2h26b7hq5w47tgfy23xx83z9x6:smyx-fish-isolation-detection-analysis","setupComplexity":"low","setupSteps":["Install using `clawhub skill install s17cfv2h26b7hq5w47tgfy23xx83z9x6:smyx-fish-isolation-detection-analysis` in an isolated environment before connecting it to live workloads.","No published capability contract is available yet, so validate auth and request/response behavior manually.","Review the upstream CLAWHUB listing at https://clawhub.ai/smyx-sunjinhui/smyx-fish-isolation-detection-analysis before using production credentials."],"contract":{"contractStatus":"missing","authModes":[],"requires":[],"forbidden":[],"supportsMcp":false,"supportsA2a":false,"supportsStreaming":false,"inputSchemaRef":null,"outputSchemaRef":null,"dataRegion":null,"contractUpdatedAt":null,"sourceUpdatedAt":null,"freshnessSeconds":null},"invocationGuide":{"preferredApi":{"snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-smyx-sunjinhui-smyx-fish-isolation-detection-analysis/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-smyx-sunjinhui-smyx-fish-isolation-detection-analysis/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-smyx-sunjinhui-smyx-fish-isolation-detection-analysis/trust"},"curlExamples":["curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-smyx-sunjinhui-smyx-fish-isolation-detection-analysis/snapshot\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-smyx-sunjinhui-smyx-fish-isolation-detection-analysis/contract\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-smyx-sunjinhui-smyx-fish-isolation-detection-analysis/trust\""],"jsonRequestTemplate":{"query":"summarize this repo","constraints":{"maxLatencyMs":2000,"protocolPreference":["OPENCLEW"]}},"jsonResponseTemplate":{"ok":true,"result":{"summary":"...","confidence":0.9},"meta":{"source":"CLAWHUB","generatedAt":"2026-10-10T11:52:52.162Z"}},"retryPolicy":{"maxAttempts":3,"backoffMs":[500,1500,3500],"retryableConditions":["HTTP_429","HTTP_503","NETWORK_TIMEOUT"]}},"endpoints":{"dossierUrl":"https://www.xpersona.co/api/v1/agents/clawhub-smyx-sunjinhui-smyx-fish-isolation-detection-analysis/dossier","snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-smyx-sunjinhui-smyx-fish-isolation-detection-analysis/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-smyx-sunjinhui-smyx-fish-isolation-detection-analysis/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-smyx-sunjinhui-smyx-fish-isolation-detection-analysis/trust"}},"reliability":{"evidence":{"source":"runtime-metrics","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No trust, reliability, or runtime telemetry is available."},"trust":{"status":"unavailable","handshakeStatus":"UNKNOWN","verificationFreshnessHours":null,"reputationScore":null,"p95LatencyMs":null,"successRate30d":null,"fallbackRate":null,"attempts30d":null,"trustUpdatedAt":null,"trustConfidence":"unknown","sourceUpdatedAt":null,"freshnessSeconds":null},"decisionGuardrails":{"doNotUseIf":["Contract metadata is missing or unavailable for deterministic execution."],"safeUseWhen":[],"riskFlags":["missing_or_unavailable_contract","trust_data_unavailable","schema_references_missing"],"operationalConfidence":"low"},"executionMetrics":{"observedLatencyMsP50":null,"observedLatencyMsP95":null,"estimatedCostUsd":null,"uptime30d":null,"rateLimitRpm":null,"rateLimitBurst":null,"lastVerifiedAt":null,"verificationSource":null},"runtimeMetrics":{"successRate":null,"avgLatencyMs":null,"avgCostUsd":null,"hallucinationRate":null,"retryRate":null,"disputeRate":null,"p50Latency":null,"p95Latency":null,"lastUpdated":null}},"benchmarks":{"evidence":{"source":"no-benchmark-data","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No benchmark suites or observed failure patterns are available."},"suites":[],"failurePatterns":[]},"artifacts":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-10T08:54:24.070Z","emptyReason":null},"readme":"Skill: Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别\n\nOwner: smyx-sunjinhui\n\nSummary: Through fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。\n\nTags: latest:1.0.10\n\nVersion history:\n\nv1.0.10 | 2026-10-03T08:52:40.368Z | auto\n\n**smyx-fish-isolation-detection-analysis 1.0.10 Changelog**\n\n- Updated SKILL.md: version number increased from 1.0.13 to 1.0.16 with no other content differences observed.\n- Updated configuration in skills/smyx_common/scripts/config.yaml (details not specified).\n- General maintenance updates and documentation version synchronization.\n\nv1.0.9 | 2026-09-16T08:54:38.962Z | auto\n\n- Updated version to 1.0.13 in SKILL.md.\n- Removed the file skill-card.md from the repository.\n- No functional or code changes; documentation/metadata cleanup only.\n\nv1.0.8 | 2026-08-26T11:43:30.176Z | auto\n\n- Updated version to 1.0.12 in SKILL.md.\n- Removed the file skill-card.md.\n- No changes to core workflow or technical capabilities were introduced.\n- Minor documentation/content update only; no change to APIs or logic.\n\nv1.0.7 | 2026-08-23T12:32:54.080Z | auto\n\n- Updated documentation (SKILL.md) to reflect version 1.0.11 and recent adjustments.\n- Removed the file skill-card.md from the project.\n- Refined configuration in skills/smyx_common/scripts/config.yaml.\n- Improved and clarified feature descriptions and operational instructions in the main documentation.\n\nv1.0.6 | 2026-08-10T18:04:34.957Z | auto\n\n- Updated version number in SKILL.md from 1.0.8 to 1.0.9.\n- Removed redundant file: skill-card.md.\n- No logic or functionality changes; maintenance update only.\n\nv1.0.5 | 2026-08-04T20:39:32.592Z | auto\n\nChangelog for smyx-fish-isolation-detection-analysis v1.0.5\n\n- Removed the file `skill-card.md` from the project.\n- No other changes in code or documentation are indicated for this version.\n\nv1.0.4 | 2026-08-01T07:53:30.592Z | auto\n\n- Updated skill version to 1.0.8 in SKILL.md.\n- Updated documentation content in SKILL.md with clarification and detail enhancements.\n- Removed the skill-card.md file.\n\nv1.0.3 | 2026-07-12T22:18:25.559Z | auto\n\n- Updated version number to 1.0.5 in SKILL.md.\n- Documentation maintained and clarified; no user-facing feature changes described.\n- Removed obsolete file: skill-card.md. \n- Internal scripts and utilities adjusted (see skills/smyx_common/scripts/util.py for details).\n- No changes to core algorithm or user workflow reported.\n\nv1.0.2 | 2026-07-06T22:08:26.919Z | auto\n\nNo file changes detected for version 1.0.2.\n\n- No updates or modifications were introduced in this version.\n- Functionality, features, and documentation remain unchanged from the previous release.\n\nv1.0.1 | 2026-07-04T23:44:23.823Z | auto\n\n- Major overhaul of documentation and user workflow: SKILL.md rewritten for clarity and easier use.\n- User identification handling is now completely automatic and internal; users are no longer asked for or shown any identity parameter.\n- Historical report queries are strictly handled via cloud API; local/previous session data is no longer used or accessible.\n- Instance and script requirements, workflow steps, and warning notes are clearly structured and summarized.\n- Non-essential and duplicate files removed for better maintainability.\n\nv1.0.0 | 2026-05-28T04:34:35.440Z | auto\n\nsmyx-fish-isolation-detection-analysis 1.0.0\n\n- Initial release supporting continuous 2D tracking of individual fish in aquarium video feeds using fixed cameras.\n- Automatically detects and alerts on prolonged isolation behavior (over 10 body lengths from centroid for more than 1 hour, configurable).\n- Differentiates between isolation types and supports multi-level alerting strategies for early disease or stress detection.\n- Considers species-specific behavior, physiological isolation contexts, and tracking reliability to reduce false alarms.\n- Integrates with smart aquarium cameras; outputs detailed daily reports and real-time reminders to prompt user intervention.\n- Enforces secure open-id acquisition before processing or historical queries; all historical data is fetched from cloud API only.\n\nArchive index:\n\nArchive v1.0.10: 31 files, 44498 bytes\n\nFiles: references/api_doc.md (6925b), scripts/__init__.py (64b), scripts/config.py (684b), scripts/config.yaml (3b), scripts/skill.py (580b), scripts/smyx_fish_isolation_detection_analysis.py (3725b), skill-card.md (2059b), SKILL.md (17402b), skills/smyx_analysis/__init__.py (0b), skills/smyx_analysis/references/api_doc.md (427b), skills/smyx_analysis/requirements.txt (45b), skills/smyx_analysis/scripts/__init__.py (0b), skills/smyx_analysis/scripts/api_service.py (1509b), skills/smyx_analysis/scripts/config.py (1003b), skills/smyx_analysis/scripts/config.yaml (3b), skills/smyx_analysis/scripts/skill.py (6529b), skills/smyx_analysis/scripts/smyx_analysis.py (3833b), skills/smyx_common/__init__.py (0b), skills/smyx_common/requirements.txt (47b), skills/smyx_common/scripts/__init__.py (177b), skills/smyx_common/scripts/api_service.py (2645b), skills/smyx_common/scripts/base.py (469b), skills/smyx_common/scripts/config-dev.yaml (214b), skills/smyx_common/scripts/config-prod.yaml (0b), skills/smyx_common/scripts/config-test.yaml (256b), skills/smyx_common/scripts/config.py (24363b), skills/smyx_common/scripts/config.yaml (473b), skills/smyx_common/scripts/dao.py (18266b), skills/smyx_common/scripts/skill.py (2473b), skills/smyx_common/scripts/util.py (28776b), _meta.json (158b)\n\nFile v1.0.10:SKILL.md\n\n---\nname: \"smyx-fish-isolation-detection-analysis\"\ndescription: \"Through fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。\"\nversion: \"1.0.16\"\nlicense: \"MIT-0\"\n---\n\n# 🐟 Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别\n> **智能分析中枢** · 图片/视频智能分析 · 结构化报告 · 历史报告云端查询\n\n---\n\n## 🧭 技能概览 | Overview\n\n| 模块 | 内容 |\n|---|---|\n| 🏷️ 技能名称 | **鱼类聚集/离群行为识别** |\n| 🎯 核心目标 | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。 |\n| 🖼️ 输入类型 | 图片、视频、本地文件、网络 URL |\n| 📝 输出能力 | 结构化分析报告、识别/监测结果、建议与报告链接 |\n| 🧩 场景码 | `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` |\n\nThrough fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). When a fish drifts more than 10 body lengths away from the school center and the state lasts longer than 1 hour (or a user-defined threshold), the system outputs an 'isolation behavior' alert. This skill helps early detection of bullied, sick (e.g. parasites, bacterial infections), spawning-period solitary or environment-distressed (e.g. strong water flow, temperature gradient) individuals, prompting aquarists to inspect and intervene. Application scenarios: home aquariums, public aquariums, aquaculture ponds, quarantine tanks. The system monitors continuously and pushes reminders when prolonged isolated fish is found. Skill features: prolonged isolation is often an early signal of disease (e.g. external parasites, digestive issues) or stress from bullying. AI-based automatic identification of isolation behavior helps aquarists detect sick fish early and isolate for treatment, reducing whole-tank infection risk. This skill can be integrated into smart aquarium cameras to enhance product behavior-analysis capability.\n\n通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。该技能有助于早期发现被欺凌、生病（如寄生虫、细菌感染）、产卵期孤立或环境不适（如水流过强、温度不均）的个体，提醒养鱼者及时检查干预。应用场景：家庭鱼缸、水族馆、水产养殖池、检疫缸。系统连续监测，当发现长期离群鱼只时推送提醒。技能特点：鱼只长期离群往往是疾病的早期信号（如体表寄生虫、消化问题），或受欺凌导致应激。通过 AI 自动识别离群行为，可帮助养鱼者及早发现病鱼并隔离治疗，降低全缸感染风险。该技能可集成到智能鱼缸摄像头中，提升产品行为分析能力。\n\n## 🤖 AI 角色 | AI Role\n| 角色要点 | 说明 |\n|---|---|\n| 说明 1 | **假设你是一个专业的水族行为监测 AI。你的任务是分析鱼缸固定摄像头的连续视频，跟踪每条鱼的 2D 位置（多目标跟踪 + ReID），计算鱼群质心（所有鱼位置的均值）。对每条鱼，计算其与质心的欧氏距离（**以该鱼的体长为单位**，核心量化单位）。当某条鱼的距离 > 10 倍体长（用户可配置）且该状态持续时间 ≥ 1 小时（用户可配置）时，输出离群提示。按 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）作判定，按 4 级告警策略递进（Level 1 入库/轻提醒 → Level 2 重要告警 + 目视检查体表/游姿/呼吸/摄食 + 评估是否隔离至检疫缸 → Level 3 紧急告警 + 强烈建议隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）+ 联系兽医 → Level 4 同缸 ≥ 3 条同时持续离群 + 推送所有联系人 + 全面排查 + 联系专业人员）。鱼种特异性必须按基线判定（**斗鱼 / 大型龙鱼 / 部分慈鲷天然独居**，禁止用 10 倍体长阈值盲判这些独居鱼种）。必须考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报。ReID 跟踪率 < 80% 或视野遮挡严重时必须返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警**。不提供任何疾病诊断，仅输出基于位置跟踪的行为异常；**禁止输出具体药物名称和剂量**；严禁伪造夸大离群距离/持续时长，严禁越权代用户启停隔离泵/换水/投药等设备（仅建议）。** |\n\n## 🎬 技能演示 | Skill Demo\n\n[▶️ 点击查看技能使用介绍](https://lifeemergence.com/sample.html)\n\n---\n\n## 🎯 任务目标 | Goals\n### 1. 🧩 技能用途\n\n基于鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头**连续视频**（≥ 1 小时滚动窗口，用户可配置 30 分钟 - 24 小时），识别 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）→ **三组指标**：群体几何 5 项（跟踪鱼数 / 基线总数 / 质心 2D 坐标 / 群体分散度 / 群体紧密度）+ 个体离群 6 项（fish_id / 体长像素 / 个体 2D 位置 / **距质心距离（体长倍数）** / 是否超阈 / **持续超阈时长**）+ 上下文 6 项（独居鱼种 / 繁殖期 / 领地缸角 / 投喂窗口 / 强水流区 / 温度梯度）→ 4 档告警级别（mild → moderate → severe → urgent）→ **4 级告警策略递进**（入库/轻提醒 → 重要告警 + 目视检查 + 评估隔离 → 紧急告警 + 隔离至检疫缸 + 水质检查 + 联系兽医 → 最高紧急告警 + 全面排查 + 所有联系人 + 专业人员）→ 单日告警上限（Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限）→ **每日离群行为报告**（按 tank_id 输出，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明）\n\n### 2. 🛠️ 能力范围\n\n| 序号 | 具体能力 |\n|---:|---|\n| 1 | 鱼体目标检测 + 多目标跟踪 + ReID 重识别（鱼离群再返群仍保持 fish_id 稳定） |\n| 2 | 2D 位置投影 |\n| 3 | 质心计算（所有跟踪鱼位置均值） |\n| 4 | 群体分散度 / 紧密度量化（体长归一化） |\n| 5 | **个体到质心距离（体长倍数核心指标）** |\n| 6 | 跨帧累计持续超阈时长 |\n| 7 | 鱼种自适应基线（独居 / 群居 / 半独居） |\n| 8 | 生理性离群上下文识别（繁殖 / 领地 / 投喂 / 水流 / 温度梯度） |\n| 9 | ReID 跟踪率门控（< 80% 返回 unreliable） |\n| 10 | 用户 APP 推送 |\n| 11 | 4 级告警递进 |\n| 12 | 单日告警上限 |\n| 13 | 每日离群行为报告（按 tank_id 输出） |\n| 14 | 连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n\n### 3. ⚡ 触发条件\n\n| 触发类型 | 触发规则 |\n|---|---|\n| ✅ 默认触发 | **默认触发**：当用户提供鱼缸固定摄像头连续视频 URL 或文件需要分析时，默认触发本技能进行鱼类聚集/离群行为识别 |\n| 🔎 明确分析意图 | 当用户明确提及鱼离群、鱼孤立、鱼独处、鱼缸角落呆滞、鱼被欺凌、鱼群分散、鱼群质心等关键词，并且上传了视频文件 |\n| 📚 历史报告查询 | 当用户提及以下关键词时，**自动触发历史报告查询功能** ：查看鱼离群历史报告、鱼缸离群行为日志清单、持续离群事件清单、查询历史鱼离群记录、显示所有鱼缸离群行为报告 |\n\n### 4. 🤖 自动行为\n\n| 自动行为 | 执行要求 |\n|---|---|\n| 📎 附件处理 | 如果用户上传了附件或者视频/图片文件，则自动保存为本地文件 |\n| ☁️ 历史报告查询 | 如果用户触发历史报告查询关键词，必须直接调用云端 API 查询，不得从本地记忆或人工汇总中获取 |\n\n#### ⚠️ 强制数据获取规则（次高优先级）\n\n> **橙色强约束：** 历史报告清单只允许从云端接口读取，不允许从本地记录、长期记忆或人工汇总中提取。\n\n必须执行：\n\n```bash\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n```\n\n| 类型 | 要求 |\n|---|---|\n| ✅ 必须 | 使用 `python -m scripts.smyx_fish_isolation_detection_analysis --list` 调用 API 查询云端的历史报告数据 |\n| 🚫 严格禁止 | 从本地 `memory` 目录读取历史会话信息 |\n| 🚫 严格禁止 | 手动汇总本地记录中的报告 |\n| 🚫 严格禁止 | 从长期记忆中提取报告 |\n| ✅ 输出格式 | 必须统一从云端接口获取最新完整数据，然后以 Markdown 表格格式输出结果 |\n\n## 📦 前置准备 | Requirements\n- 依赖说明:scripts 脚本所需的依赖包及版本\n  ```\n  requests>=2.28.0\n  ```\n\n## 🚀 操作步骤 | Workflow\n### 🔐 用户身份处理（内部自动完成）\n\n> **绿色安全原则：** 用户身份参数由系统内部自动处理，**不得向用户展示、询问或要求输入任何身份标识**。\n\n执行本技能分析或历史报告查询时，脚本会自动完成身份初始化：\n\n| 场景 | 系统行为 |\n|---|---|\n| 上游系统有内部身份参数 | 由脚本静默接收并使用 |\n| 上游系统未提供内部身份参数 | 脚本会自动复用本地缺省用户 |\n| 本地缺省用户不存在 | 脚本会自动创建并在后续任务中复用 |\n| 对用户输出 | 只展示分析进度、分析结果和报告链接，不展示内部身份值 |\n\n#### 🔒 关键约束\n\n| 禁止/要求 | 说明 |\n|---|---|\n| 🚫 不得询问身份 | 不得提示用户输入用户名、手机号或任何内部身份参数 |\n| 🚫 不得暴露身份值 | 不得在回复、报告、示例、错误提示中暴露内部身份值 |\n| 🚫 不得列为用户参数 | 不得把内部身份参数列为用户需要理解或传入的参数 |\n| ✅ 自动关联报告 | 历史报告查询同样由系统内部身份自动关联，用户只需表达“查看历史报告/报告清单”等意图 |\n\n---\n\n### 🧪 标准流程 | Standard Flow\n\n| 步骤 | 阶段 | 执行动作 |\n|---:|---|---|\n| 1 | 📥 准备鱼缸固定摄像头连续视频输入 | 提供本地文件路径或网络 URL；确保输入内容清晰、符合技能场景要求 |\n| 2 | 🔐 获取 open-id（强制执行） | 无需用户输入任何身份参数；不在回复中展示内部身份值 |\n| 3 | ⚙️ 执行鱼类聚集/离群行为识别 | 调用 `-m scripts.smyx_fish_isolation_detection_analysis` 处理输入（**必须在技能根目录下运行脚本**） |\n| 4 | 📊 查看分析结果 | 接收结构化分析报告，查看识别/监测结果、风险提示、建议与报告链接 |\n\n### ⚙️ 脚本参数说明\n\n| 参数 | 含义 | 备注 |\n|---|---|---|\n| `--input` | 本地鱼缸固定摄像头连续视频文件路径 | 适用于本地文件分析 |\n| `--url` | 网络鱼缸固定摄像头连续视频 URL 地址（API 服务自动下载） | API 服务自动下载网络资源 |\n| `--pet-type` | 类别标识，鱼类聚集/离群行为识别场景默认 `other` | 按需填写 |\n| `--list` | 显示鱼类聚集/离群行为识别历史记录清单 | 用于云端历史报告查询 |\n| `--api-url` | API 服务地址（可选，使用默认值） | 按需填写 |\n| `--detail` | 输出详细程度（basic/standard/json，默认 json） | 输出详细程度 |\n| `--output` | 结果输出文件路径（可选） | 可选 |\n\n## 🗂️ 资源索引 | Resource Index\n| 资源类型 | 路径 | 用途 | 何时读取 |\n|---|---|---|---|\n| 🐍 必要脚本 | [`scripts/smyx_fish_isolation_detection_analysis.py`](scripts/smyx_fish_isolation_detection_analysis.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 🐍 必要脚本 | [`scripts/config.py`](scripts/config.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 📘 领域参考 | [`references/api_doc.md`](references/api_doc.md) | 了解 API 接口规范、字段说明和错误码 | 仅在需要了解接口规范或错误码时读取 |\n\n## ⚠️ 注意事项 | Notes\n| 分类 | 注意事项 |\n|---|---|\n| 📚 文档读取 | 仅在需要时读取参考文档，保持上下文简洁 |\n| 📁 格式支持 | 输入要求：支持 mp4/avi/mov，最大 10MB；摄像头需俯拍或大角度斜视；**连续采样 ≥ 1 小时**；帧率 ≥ 10 FPS；必须接入 ReID 多目标跟踪 |\n| 🔎 使用提醒 | **核心量化单位**：**离群距离以\"鱼体长倍数\"为单位**（默认阈值 > 10 倍体长，用户可配置） |\n| 🔎 使用提醒 | **核心持续时长阈值**：**≥ 1 小时**（用户可配置 15 分钟 - 24 小时） |\n| 🔎 使用提醒 | **4 级告警策略递进**（mild → moderate → severe → urgent/Level 4），同缸 ≥ 3 条同时持续离群 / 离群+角落呆滞进入更高级别 |\n| 🔎 使用提醒 | 单日告警上限：Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限（紧急安全优先） |\n| 🔎 使用提醒 | 红线约束 |\n| 🧑‍⚖️ 结果性质 | **禁止**对鱼做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征 / 被欺凌创伤\"等具体疾病或行为学诊断 |\n| 🔎 使用提醒 | **🚨 绝对禁止**输出具体药物名称、剂量、给药方案 |\n| 🔎 使用提醒 | **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定） |\n| 🔎 使用提醒 | **禁止**用于商业广告 / AI 训练；禁第三方共享 |\n| 🔎 使用提醒 | **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议） |\n| 🔎 使用提醒 | **绝对禁止**伪造或夸大离群距离、持续时长、群体分散度等指标；所有数据必须基于真实视频帧跟踪 |\n| 🔎 使用提醒 | **必须**按**鱼种基线**判定（独居：斗鱼 / 大型龙鱼 / 部分慈鲷；半独居：罗汉、地图等；群居：灯鱼 / 鼠鱼 / 锦鲤）；**禁止使用通用 10 倍体长阈值盲判独居鱼种** |\n| 📚 文档读取 | **必须**考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报 |\n| 🔎 使用提醒 | **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警** |\n| 🔎 使用提醒 | **必须**：连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n| 📜 报告输出 | **必须**：每日离群行为报告**按 tank_id 输出**，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明 |\n| 🚫 脚本限制 | 禁止临时生成脚本，只能用技能本身的脚本 |\n| 🌐 网络地址 | 传入的网络地址参数，不需要下载本地，默认地址都是公网地址，api 服务会自动下载 |\n| 📜 报告输出 | 当显示历史离群记录清单的时候，从接口返回 json 数据中提取字段  作为超链接地址，且自动转化为如下 Markdown |\n| 📜 报告输出 | 表格输出示例 |\n\n## 🧰 使用示例 | Examples\n```bash\n# 分析本地连续视频（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --input /path/to/tank_1h.mp4\n\n# 分析网络连续视频/实时流（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --url https://example.com/tank_1h.mp4\n\n# 显示历史离群行为记录清单（自动触发关键词：查看鱼离群历史报告、鱼缸离群行为日志清单等）\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n\n# 输出精简报告\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --detail basic\n\n# 保存结果到文件\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --output result.json\n```\n\nFile v1.0.10:_meta.json\n\n{\n  \"ownerId\": \"kn7cyxkr2ymf7zwsrybpedg8xx83ywrj\",\n  \"slug\": \"smyx-fish-isolation-detection-analysis\",\n  \"version\": \"1.0.10\",\n  \"publishedAt\": 1791017560368\n}\n\nFile v1.0.10:references/api_doc.md\n\n# API 接口文档\n\n此处用于存放鱼类聚集/离群行为识别 API 的接口文档，待后续补充。\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 响应格式：JSON\n\n## 主要接口\n\n1. `/web/health-analysis/v2/start-health-analysis` - 启动鱼类聚集/离群行为识别任务\n2. `/web/health-analysis/v2/get-health-analysis-result` - 获取离群检测结果（离群个体清单 + 离群距离 + 持续时长）\n3. `/web/health-analysis/page-health-analysis-result` - 分页查询历史离群行为报告\n4. `/health/order/api/getReportDetailExport?id={id}` - 导出离群行为报告\n5. （可选）`/web/companion/v2/trigger-soothing-action` - 触发联动提醒（用户 APP 推送 / 智能鱼缸告警灯 / 提示隔离至检疫缸建议）\n\n## 场景代码\n\n- `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` - 鱼类聚集/离群行为识别\n\n## 输入约束\n\n- 摄像头：鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头，建议**俯拍或大角度斜视**（保证 2D 位置投影稳定）\n- 分辨率 ≥ 720p；**帧率 ≥ 10 FPS**（位置跟踪需稳定）\n- 光照：建议鱼缸照明开启 + 无强反光；水质清澈（浑浊度低）\n- **核心采样窗口**：连续观察 ≥ 1 小时（用户可配置 30 分钟 - 24 小时滚动窗口）\n- 视野约束：必须覆盖整个鱼缸/养殖池**完整水平投影**（任何 dead zone 都可能误判为\"离群\"）\n- 多鱼缸/池场景按摄像头 ID 绑定到注册容器 ID\n- **多鱼场景必须接入 ReID**（多目标跟踪 + 重识别），每条鱼建立稳定 fish_id\n- **部署时必须录入**：鱼种清单、群体大小 N（用户输入或首次自动统计取众数）、每条鱼体长校准（像素 ↔ cm，可单次手动校准或自动学习）\n- 用户必须授权部署；公共水族馆 / 养殖场需公示告知\n\n## 关键观测信号\n\n### 群体几何信号\n- `tracked_fish_count` - 当前帧成功跟踪到的鱼数\n- `total_fish_count_baseline` - 容器注册总鱼数（基线）\n- `school_centroid_xy` - 鱼群质心（所有鱼 2D 位置均值）\n- `school_dispersion_score` - 群体分散度（所有鱼到质心距离的标准差，体长归一化）\n- `school_compactness_score` - 群体紧密度（0-100，越高越紧密；夜行鱼休息时自然偏低）\n\n### 个体离群信号（每条 fish_id 独立）\n- `fish_id` - 个体唯一标识（ReID 输出）\n- `fish_body_length_px` - 该鱼当前体长（像素，自动估计）\n- `fish_position_xy` - 该鱼当前 2D 位置\n- `distance_to_centroid_body_lengths` - 与质心欧氏距离（**以体长为单位**，核心指标）\n- `over_threshold_flag` - 是否超过阈值（默认 > 10 倍体长）\n- `over_threshold_duration_min` - 持续超阈时长（分钟，跨帧累计）\n\n### 上下文信号（避免误报）\n- `is_natural_solitary_species` - 是否独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷天然独居）\n- `is_breeding_period` - 是否繁殖期（公鱼护卵 / 母鱼离群产卵）\n- `is_territory_corner_fish` - 是否为领地型缸角守卫鱼（\"离群\"实为正常占地）\n- `is_during_feeding` - 是否在投喂窗口内（短时聚拢/分散为生理性）\n- `tank_has_strong_water_flow` - 是否有强水流区（被冲到角落可能误判）\n- `tank_temperature_gradient_detected` - 是否检测到温度不均（鱼可能聚于舒适温区，余者\"离群\"）\n\n## 综合判定\n\n- `schooling_normal` - 群体正常聚集\n- `schooling_loose` - 群体偏松散（但无明显离群个体）\n- `isolation_short` - 短时离群（> 10 倍体长但 < 1 小时）\n- `isolation_persistent` - **持续离群**（> 10 倍体长且 ≥ 1 小时，核心告警场景）\n- `isolation_corner_stuck` - 角落呆滞（离群 + 长时间几乎不动，疑似严重不适）\n- `multiple_isolated_individuals` - 多鱼同时离群（疑似全缸应激 / 水质恶化）\n- `isolation_signal_unreliable` - 信号不可靠（ReID 断裂 / 视野遮挡 / 浑浊度过高 / 跟踪 < 80% 鱼数）\n\n## 4 级告警策略递进\n\n- Level 1（isolation_short / schooling_loose）：仅入库或用户 APP 轻提醒\"观察某条鱼是否长期离群\"\n- Level 2（isolation_persistent，单条）：用户 APP 重要告警，建议**目视检查该鱼体表 / 游姿 / 呼吸 / 摄食活跃度**，并**评估是否隔离至检疫缸**\n- Level 3（isolation_corner_stuck / 连续 ≥ 2 日 isolation_persistent）：紧急告警，**强烈建议立即隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）**，并提示联系**当地观赏鱼兽医**\n- Level 4（multiple_isolated_individuals / 同缸 ≥ 3 条同时持续离群）：最高紧急告警 + 推送家庭/管理人员所有联系人 + 强烈建议**立即全面排查（水质 + 体表 + 游姿 + 呼吸 + 摄食）+ 联系专业人员**\n\n## 单日告警上限\n\n- Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限\n\n## 红线约束\n\n- **禁止**做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征\"等具体疾病诊断\n- **禁止**输出具体药物名称、剂量、给药方案\n- **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定）\n- **禁止**用于商业广告 / AI 训练；禁第三方共享\n- **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议）\n- 离群距离、持续时长、群体分散度等指标必须基于真实视频帧跟踪；**禁止伪造或夸大指标**\n- 鱼种特异性：**独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷）天然不集群** → 必须按鱼种基线判定；**禁止使用通用 10 倍体长阈值盲判独居鱼种**\n- 必须考虑生理性离群上下文：**繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集** → 不可直接告警\n- **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable`，并建议重拍 / 调整摄像头角度；**禁止给出不可靠告警**\n- 必须告知用户：AI 行为识别仅供参考，**最终诊断与治疗方案需专业水族兽医确认**\n\n## 输出报告字段\n\n- `report_date` - 报告日期\n- `tank_id` - 鱼缸/养殖池/检疫缸 ID\n- `species` - 鱼种\n- `total_fish_count_baseline` - 注册总鱼数\n- `school_compactness_score` - 群体紧密度\n- `isolated_fish_list` - 离群个体清单（每条含 fish_id / distance_to_centroid_body_lengths / over_threshold_duration_min / 缩略图轨迹）\n- `composite_scene` - 综合判定\n- `alert_level` - 告警等级\n- `recommended_actions` - 建议动作（观察 / 隔离检疫缸 / 检查水质 / 联系兽医，**不含药物**）\n- `disclaimer` - 免责声明\n\nFile v1.0.10:skills/smyx_analysis/references/api_doc.md\n\n# API接口文档\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 请求格式：支持文件上传\n- 响应格式：JSON\n\n## 错误码说明\n\n| 错误码 | 说明       |\n|-----|----------|\n| 400 | 请求参数错误   |\n| 401 | API密钥无效  |\n| 403 | 权限不足     |\n| 413 | 文件过大     |\n| 415 | 不支持的文件格式 |\n| 500 | 服务器内部错误  |\n\nFile v1.0.10:scripts/config.yaml\n\n{}\n\nFile v1.0.10:skills/smyx_analysis/scripts/config.yaml\n\n{}\n\nFile v1.0.10:skills/smyx_common/scripts/config-dev.yaml\n\nApiEnum:\n  base-url-open-api: \"http://192.168.1.234:9601/smyx-open-api\"\n  base-url-open-h5: \"http://192.168.1.234:4100\"\n  base-url-health: \"http://192.168.1.234:7070/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.10:skills/smyx_common/scripts/config-test.yaml\n\nApiEnum:\n  base-url-open-api: \"https://livemonitortest.lifeemergence.com/smyx-open-api\"\n  base-url-open-h5: \"http://livemonitortest.lifeemergence.com\"\n  base-url-health: \"https://healthtest.lifeemergence.com/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.10:skills/smyx_common/scripts/config.yaml\n\nApiEnum:\n  api-key: null\n  api-secret-key: null\n  base-url-health: https://lifeemergence.com/jeecg-boot-xzgz\n  base-url-open-api: https://open.lifeemergence.com/smyx-open-api\n  base-url-open-h5: http://livemonitor.lifeemergence.com\n  database-url: null\nConstantEnum:\n  app--id: x1a3s4nwy1s2r4se\n  current--tentant-code: XIAN_ZHAO_GAN_ZHI\n  default--skill-platform-name: ARK_CLAW\n  feishu-app--id: cli_a93d769369badcb1\n  feishu-app--secret: null\n  is-debug: false\nenv: prod\n\nFile v1.0.10:skill-card.md\n\n## Description:\n\nAnalyzes aquarium video to identify fish that remain separated from their school and provide behavior alerts and reports.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[smyx-sunjinhui](https://clawhub.ai/user/smyx-sunjinhui)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nAquarists and aquaculture operators use this skill to review video for persistent fish isolation, receive behavior alerts, and consult past analysis reports. Its observations are not a disease diagnosis.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Aquarium videos or video URLs are sent to the publisher's cloud service.\n\nMitigation: Obtain explicit user confirmation before uploading or submitting a video URL.\n\nRisk: The skill can create or reuse an identity and store access tokens locally.\n\nMitigation: Review identity and token storage before installation; restrict workspace access to trusted users.\n\nRisk: History queries can access cloud-stored, account-scoped reports.\n\nMitigation: Confirm user intent before querying report history.\n\n## Reference(s):\n\n- [ClawHub skill listing](https://clawhub.ai/smyx-sunjinhui/skills/smyx-fish-isolation-detection-analysis)\n- [Fish isolation API documentation](artifact/references/api_doc.md)\n- [Skill demonstration](https://lifeemergence.com/sample.html)\n\n## Skill Output:\n\n**Output Type(s):** [Text, Markdown, Analysis]\n\n**Output Format:** [Text and Markdown summaries of structured analysis results and report links]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [Results may include fish isolation alerts, suggested checks, and links to cloud-stored reports.]\n\n## Skill Version(s):\n\n1.0.10 (source: server-resolved ClawHub release; bundled SKILL.md lists 1.0.16)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.\n\nFile v1.0.10:skills/smyx_analysis/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nyaml==6.0.3\n\nFile v1.0.10:skills/smyx_common/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nPyYAML==6.0.3\n\nArchive v1.0.9: 30 files, 43318 bytes\n\nFiles: references/api_doc.md (6925b), scripts/__init__.py (64b), scripts/config.py (684b), scripts/config.yaml (3b), scripts/skill.py (580b), scripts/smyx_fish_isolation_detection_analysis.py (3725b), SKILL.md (17402b), skills/smyx_analysis/__init__.py (0b), skills/smyx_analysis/references/api_doc.md (427b), skills/smyx_analysis/requirements.txt (45b), skills/smyx_analysis/scripts/__init__.py (0b), skills/smyx_analysis/scripts/api_service.py (1509b), skills/smyx_analysis/scripts/config.py (1003b), skills/smyx_analysis/scripts/config.yaml (3b), skills/smyx_analysis/scripts/skill.py (6529b), skills/smyx_analysis/scripts/smyx_analysis.py (3833b), skills/smyx_common/__init__.py (0b), skills/smyx_common/requirements.txt (47b), skills/smyx_common/scripts/__init__.py (177b), skills/smyx_common/scripts/api_service.py (2645b), skills/smyx_common/scripts/base.py (469b), skills/smyx_common/scripts/config-dev.yaml (214b), skills/smyx_common/scripts/config-prod.yaml (0b), skills/smyx_common/scripts/config-test.yaml (256b), skills/smyx_common/scripts/config.py (24363b), skills/smyx_common/scripts/config.yaml (472b), skills/smyx_common/scripts/dao.py (18266b), skills/smyx_common/scripts/skill.py (2473b), skills/smyx_common/scripts/util.py (28776b), _meta.json (157b)\n\nFile v1.0.9:SKILL.md\n\n---\nname: \"smyx-fish-isolation-detection-analysis\"\ndescription: \"Through fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。\"\nversion: \"1.0.13\"\nlicense: \"MIT-0\"\n---\n\n# 🐟 Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别\n> **智能分析中枢** · 图片/视频智能分析 · 结构化报告 · 历史报告云端查询\n\n---\n\n## 🧭 技能概览 | Overview\n\n| 模块 | 内容 |\n|---|---|\n| 🏷️ 技能名称 | **鱼类聚集/离群行为识别** |\n| 🎯 核心目标 | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。 |\n| 🖼️ 输入类型 | 图片、视频、本地文件、网络 URL |\n| 📝 输出能力 | 结构化分析报告、识别/监测结果、建议与报告链接 |\n| 🧩 场景码 | `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` |\n\nThrough fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). When a fish drifts more than 10 body lengths away from the school center and the state lasts longer than 1 hour (or a user-defined threshold), the system outputs an 'isolation behavior' alert. This skill helps early detection of bullied, sick (e.g. parasites, bacterial infections), spawning-period solitary or environment-distressed (e.g. strong water flow, temperature gradient) individuals, prompting aquarists to inspect and intervene. Application scenarios: home aquariums, public aquariums, aquaculture ponds, quarantine tanks. The system monitors continuously and pushes reminders when prolonged isolated fish is found. Skill features: prolonged isolation is often an early signal of disease (e.g. external parasites, digestive issues) or stress from bullying. AI-based automatic identification of isolation behavior helps aquarists detect sick fish early and isolate for treatment, reducing whole-tank infection risk. This skill can be integrated into smart aquarium cameras to enhance product behavior-analysis capability.\n\n通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。该技能有助于早期发现被欺凌、生病（如寄生虫、细菌感染）、产卵期孤立或环境不适（如水流过强、温度不均）的个体，提醒养鱼者及时检查干预。应用场景：家庭鱼缸、水族馆、水产养殖池、检疫缸。系统连续监测，当发现长期离群鱼只时推送提醒。技能特点：鱼只长期离群往往是疾病的早期信号（如体表寄生虫、消化问题），或受欺凌导致应激。通过 AI 自动识别离群行为，可帮助养鱼者及早发现病鱼并隔离治疗，降低全缸感染风险。该技能可集成到智能鱼缸摄像头中，提升产品行为分析能力。\n\n## 🤖 AI 角色 | AI Role\n| 角色要点 | 说明 |\n|---|---|\n| 说明 1 | **假设你是一个专业的水族行为监测 AI。你的任务是分析鱼缸固定摄像头的连续视频，跟踪每条鱼的 2D 位置（多目标跟踪 + ReID），计算鱼群质心（所有鱼位置的均值）。对每条鱼，计算其与质心的欧氏距离（**以该鱼的体长为单位**，核心量化单位）。当某条鱼的距离 > 10 倍体长（用户可配置）且该状态持续时间 ≥ 1 小时（用户可配置）时，输出离群提示。按 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）作判定，按 4 级告警策略递进（Level 1 入库/轻提醒 → Level 2 重要告警 + 目视检查体表/游姿/呼吸/摄食 + 评估是否隔离至检疫缸 → Level 3 紧急告警 + 强烈建议隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）+ 联系兽医 → Level 4 同缸 ≥ 3 条同时持续离群 + 推送所有联系人 + 全面排查 + 联系专业人员）。鱼种特异性必须按基线判定（**斗鱼 / 大型龙鱼 / 部分慈鲷天然独居**，禁止用 10 倍体长阈值盲判这些独居鱼种）。必须考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报。ReID 跟踪率 < 80% 或视野遮挡严重时必须返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警**。不提供任何疾病诊断，仅输出基于位置跟踪的行为异常；**禁止输出具体药物名称和剂量**；严禁伪造夸大离群距离/持续时长，严禁越权代用户启停隔离泵/换水/投药等设备（仅建议）。** |\n\n## 🎬 技能演示 | Skill Demo\n\n[▶️ 点击查看技能使用介绍](https://lifeemergence.com/sample.html)\n\n---\n\n## 🎯 任务目标 | Goals\n### 1. 🧩 技能用途\n\n基于鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头**连续视频**（≥ 1 小时滚动窗口，用户可配置 30 分钟 - 24 小时），识别 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）→ **三组指标**：群体几何 5 项（跟踪鱼数 / 基线总数 / 质心 2D 坐标 / 群体分散度 / 群体紧密度）+ 个体离群 6 项（fish_id / 体长像素 / 个体 2D 位置 / **距质心距离（体长倍数）** / 是否超阈 / **持续超阈时长**）+ 上下文 6 项（独居鱼种 / 繁殖期 / 领地缸角 / 投喂窗口 / 强水流区 / 温度梯度）→ 4 档告警级别（mild → moderate → severe → urgent）→ **4 级告警策略递进**（入库/轻提醒 → 重要告警 + 目视检查 + 评估隔离 → 紧急告警 + 隔离至检疫缸 + 水质检查 + 联系兽医 → 最高紧急告警 + 全面排查 + 所有联系人 + 专业人员）→ 单日告警上限（Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限）→ **每日离群行为报告**（按 tank_id 输出，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明）\n\n### 2. 🛠️ 能力范围\n\n| 序号 | 具体能力 |\n|---:|---|\n| 1 | 鱼体目标检测 + 多目标跟踪 + ReID 重识别（鱼离群再返群仍保持 fish_id 稳定） |\n| 2 | 2D 位置投影 |\n| 3 | 质心计算（所有跟踪鱼位置均值） |\n| 4 | 群体分散度 / 紧密度量化（体长归一化） |\n| 5 | **个体到质心距离（体长倍数核心指标）** |\n| 6 | 跨帧累计持续超阈时长 |\n| 7 | 鱼种自适应基线（独居 / 群居 / 半独居） |\n| 8 | 生理性离群上下文识别（繁殖 / 领地 / 投喂 / 水流 / 温度梯度） |\n| 9 | ReID 跟踪率门控（< 80% 返回 unreliable） |\n| 10 | 用户 APP 推送 |\n| 11 | 4 级告警递进 |\n| 12 | 单日告警上限 |\n| 13 | 每日离群行为报告（按 tank_id 输出） |\n| 14 | 连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n\n### 3. ⚡ 触发条件\n\n| 触发类型 | 触发规则 |\n|---|---|\n| ✅ 默认触发 | **默认触发**：当用户提供鱼缸固定摄像头连续视频 URL 或文件需要分析时，默认触发本技能进行鱼类聚集/离群行为识别 |\n| 🔎 明确分析意图 | 当用户明确提及鱼离群、鱼孤立、鱼独处、鱼缸角落呆滞、鱼被欺凌、鱼群分散、鱼群质心等关键词，并且上传了视频文件 |\n| 📚 历史报告查询 | 当用户提及以下关键词时，**自动触发历史报告查询功能** ：查看鱼离群历史报告、鱼缸离群行为日志清单、持续离群事件清单、查询历史鱼离群记录、显示所有鱼缸离群行为报告 |\n\n### 4. 🤖 自动行为\n\n| 自动行为 | 执行要求 |\n|---|---|\n| 📎 附件处理 | 如果用户上传了附件或者视频/图片文件，则自动保存为本地文件 |\n| ☁️ 历史报告查询 | 如果用户触发历史报告查询关键词，必须直接调用云端 API 查询，不得从本地记忆或人工汇总中获取 |\n\n#### ⚠️ 强制数据获取规则（次高优先级）\n\n> **橙色强约束：** 历史报告清单只允许从云端接口读取，不允许从本地记录、长期记忆或人工汇总中提取。\n\n必须执行：\n\n```bash\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n```\n\n| 类型 | 要求 |\n|---|---|\n| ✅ 必须 | 使用 `python -m scripts.smyx_fish_isolation_detection_analysis --list` 调用 API 查询云端的历史报告数据 |\n| 🚫 严格禁止 | 从本地 `memory` 目录读取历史会话信息 |\n| 🚫 严格禁止 | 手动汇总本地记录中的报告 |\n| 🚫 严格禁止 | 从长期记忆中提取报告 |\n| ✅ 输出格式 | 必须统一从云端接口获取最新完整数据，然后以 Markdown 表格格式输出结果 |\n\n## 📦 前置准备 | Requirements\n- 依赖说明:scripts 脚本所需的依赖包及版本\n  ```\n  requests>=2.28.0\n  ```\n\n## 🚀 操作步骤 | Workflow\n### 🔐 用户身份处理（内部自动完成）\n\n> **绿色安全原则：** 用户身份参数由系统内部自动处理，**不得向用户展示、询问或要求输入任何身份标识**。\n\n执行本技能分析或历史报告查询时，脚本会自动完成身份初始化：\n\n| 场景 | 系统行为 |\n|---|---|\n| 上游系统有内部身份参数 | 由脚本静默接收并使用 |\n| 上游系统未提供内部身份参数 | 脚本会自动复用本地缺省用户 |\n| 本地缺省用户不存在 | 脚本会自动创建并在后续任务中复用 |\n| 对用户输出 | 只展示分析进度、分析结果和报告链接，不展示内部身份值 |\n\n#### 🔒 关键约束\n\n| 禁止/要求 | 说明 |\n|---|---|\n| 🚫 不得询问身份 | 不得提示用户输入用户名、手机号或任何内部身份参数 |\n| 🚫 不得暴露身份值 | 不得在回复、报告、示例、错误提示中暴露内部身份值 |\n| 🚫 不得列为用户参数 | 不得把内部身份参数列为用户需要理解或传入的参数 |\n| ✅ 自动关联报告 | 历史报告查询同样由系统内部身份自动关联，用户只需表达“查看历史报告/报告清单”等意图 |\n\n---\n\n### 🧪 标准流程 | Standard Flow\n\n| 步骤 | 阶段 | 执行动作 |\n|---:|---|---|\n| 1 | 📥 准备鱼缸固定摄像头连续视频输入 | 提供本地文件路径或网络 URL；确保输入内容清晰、符合技能场景要求 |\n| 2 | 🔐 获取 open-id（强制执行） | 无需用户输入任何身份参数；不在回复中展示内部身份值 |\n| 3 | ⚙️ 执行鱼类聚集/离群行为识别 | 调用 `-m scripts.smyx_fish_isolation_detection_analysis` 处理输入（**必须在技能根目录下运行脚本**） |\n| 4 | 📊 查看分析结果 | 接收结构化分析报告，查看识别/监测结果、风险提示、建议与报告链接 |\n\n### ⚙️ 脚本参数说明\n\n| 参数 | 含义 | 备注 |\n|---|---|---|\n| `--input` | 本地鱼缸固定摄像头连续视频文件路径 | 适用于本地文件分析 |\n| `--url` | 网络鱼缸固定摄像头连续视频 URL 地址（API 服务自动下载） | API 服务自动下载网络资源 |\n| `--pet-type` | 类别标识，鱼类聚集/离群行为识别场景默认 `other` | 按需填写 |\n| `--list` | 显示鱼类聚集/离群行为识别历史记录清单 | 用于云端历史报告查询 |\n| `--api-url` | API 服务地址（可选，使用默认值） | 按需填写 |\n| `--detail` | 输出详细程度（basic/standard/json，默认 json） | 输出详细程度 |\n| `--output` | 结果输出文件路径（可选） | 可选 |\n\n## 🗂️ 资源索引 | Resource Index\n| 资源类型 | 路径 | 用途 | 何时读取 |\n|---|---|---|---|\n| 🐍 必要脚本 | [`scripts/smyx_fish_isolation_detection_analysis.py`](scripts/smyx_fish_isolation_detection_analysis.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 🐍 必要脚本 | [`scripts/config.py`](scripts/config.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 📘 领域参考 | [`references/api_doc.md`](references/api_doc.md) | 了解 API 接口规范、字段说明和错误码 | 仅在需要了解接口规范或错误码时读取 |\n\n## ⚠️ 注意事项 | Notes\n| 分类 | 注意事项 |\n|---|---|\n| 📚 文档读取 | 仅在需要时读取参考文档，保持上下文简洁 |\n| 📁 格式支持 | 输入要求：支持 mp4/avi/mov，最大 10MB；摄像头需俯拍或大角度斜视；**连续采样 ≥ 1 小时**；帧率 ≥ 10 FPS；必须接入 ReID 多目标跟踪 |\n| 🔎 使用提醒 | **核心量化单位**：**离群距离以\"鱼体长倍数\"为单位**（默认阈值 > 10 倍体长，用户可配置） |\n| 🔎 使用提醒 | **核心持续时长阈值**：**≥ 1 小时**（用户可配置 15 分钟 - 24 小时） |\n| 🔎 使用提醒 | **4 级告警策略递进**（mild → moderate → severe → urgent/Level 4），同缸 ≥ 3 条同时持续离群 / 离群+角落呆滞进入更高级别 |\n| 🔎 使用提醒 | 单日告警上限：Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限（紧急安全优先） |\n| 🔎 使用提醒 | 红线约束 |\n| 🧑‍⚖️ 结果性质 | **禁止**对鱼做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征 / 被欺凌创伤\"等具体疾病或行为学诊断 |\n| 🔎 使用提醒 | **🚨 绝对禁止**输出具体药物名称、剂量、给药方案 |\n| 🔎 使用提醒 | **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定） |\n| 🔎 使用提醒 | **禁止**用于商业广告 / AI 训练；禁第三方共享 |\n| 🔎 使用提醒 | **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议） |\n| 🔎 使用提醒 | **绝对禁止**伪造或夸大离群距离、持续时长、群体分散度等指标；所有数据必须基于真实视频帧跟踪 |\n| 🔎 使用提醒 | **必须**按**鱼种基线**判定（独居：斗鱼 / 大型龙鱼 / 部分慈鲷；半独居：罗汉、地图等；群居：灯鱼 / 鼠鱼 / 锦鲤）；**禁止使用通用 10 倍体长阈值盲判独居鱼种** |\n| 📚 文档读取 | **必须**考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报 |\n| 🔎 使用提醒 | **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警** |\n| 🔎 使用提醒 | **必须**：连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n| 📜 报告输出 | **必须**：每日离群行为报告**按 tank_id 输出**，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明 |\n| 🚫 脚本限制 | 禁止临时生成脚本，只能用技能本身的脚本 |\n| 🌐 网络地址 | 传入的网络地址参数，不需要下载本地，默认地址都是公网地址，api 服务会自动下载 |\n| 📜 报告输出 | 当显示历史离群记录清单的时候，从接口返回 json 数据中提取字段  作为超链接地址，且自动转化为如下 Markdown |\n| 📜 报告输出 | 表格输出示例 |\n\n## 🧰 使用示例 | Examples\n```bash\n# 分析本地连续视频（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --input /path/to/tank_1h.mp4\n\n# 分析网络连续视频/实时流（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --url https://example.com/tank_1h.mp4\n\n# 显示历史离群行为记录清单（自动触发关键词：查看鱼离群历史报告、鱼缸离群行为日志清单等）\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n\n# 输出精简报告\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --detail basic\n\n# 保存结果到文件\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --output result.json\n```\n\nFile v1.0.9:_meta.json\n\n{\n  \"ownerId\": \"kn7cyxkr2ymf7zwsrybpedg8xx83ywrj\",\n  \"slug\": \"smyx-fish-isolation-detection-analysis\",\n  \"version\": \"1.0.9\",\n  \"publishedAt\": 1789548878962\n}\n\nFile v1.0.9:references/api_doc.md\n\n# API 接口文档\n\n此处用于存放鱼类聚集/离群行为识别 API 的接口文档，待后续补充。\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 响应格式：JSON\n\n## 主要接口\n\n1. `/web/health-analysis/v2/start-health-analysis` - 启动鱼类聚集/离群行为识别任务\n2. `/web/health-analysis/v2/get-health-analysis-result` - 获取离群检测结果（离群个体清单 + 离群距离 + 持续时长）\n3. `/web/health-analysis/page-health-analysis-result` - 分页查询历史离群行为报告\n4. `/health/order/api/getReportDetailExport?id={id}` - 导出离群行为报告\n5. （可选）`/web/companion/v2/trigger-soothing-action` - 触发联动提醒（用户 APP 推送 / 智能鱼缸告警灯 / 提示隔离至检疫缸建议）\n\n## 场景代码\n\n- `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` - 鱼类聚集/离群行为识别\n\n## 输入约束\n\n- 摄像头：鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头，建议**俯拍或大角度斜视**（保证 2D 位置投影稳定）\n- 分辨率 ≥ 720p；**帧率 ≥ 10 FPS**（位置跟踪需稳定）\n- 光照：建议鱼缸照明开启 + 无强反光；水质清澈（浑浊度低）\n- **核心采样窗口**：连续观察 ≥ 1 小时（用户可配置 30 分钟 - 24 小时滚动窗口）\n- 视野约束：必须覆盖整个鱼缸/养殖池**完整水平投影**（任何 dead zone 都可能误判为\"离群\"）\n- 多鱼缸/池场景按摄像头 ID 绑定到注册容器 ID\n- **多鱼场景必须接入 ReID**（多目标跟踪 + 重识别），每条鱼建立稳定 fish_id\n- **部署时必须录入**：鱼种清单、群体大小 N（用户输入或首次自动统计取众数）、每条鱼体长校准（像素 ↔ cm，可单次手动校准或自动学习）\n- 用户必须授权部署；公共水族馆 / 养殖场需公示告知\n\n## 关键观测信号\n\n### 群体几何信号\n- `tracked_fish_count` - 当前帧成功跟踪到的鱼数\n- `total_fish_count_baseline` - 容器注册总鱼数（基线）\n- `school_centroid_xy` - 鱼群质心（所有鱼 2D 位置均值）\n- `school_dispersion_score` - 群体分散度（所有鱼到质心距离的标准差，体长归一化）\n- `school_compactness_score` - 群体紧密度（0-100，越高越紧密；夜行鱼休息时自然偏低）\n\n### 个体离群信号（每条 fish_id 独立）\n- `fish_id` - 个体唯一标识（ReID 输出）\n- `fish_body_length_px` - 该鱼当前体长（像素，自动估计）\n- `fish_position_xy` - 该鱼当前 2D 位置\n- `distance_to_centroid_body_lengths` - 与质心欧氏距离（**以体长为单位**，核心指标）\n- `over_threshold_flag` - 是否超过阈值（默认 > 10 倍体长）\n- `over_threshold_duration_min` - 持续超阈时长（分钟，跨帧累计）\n\n### 上下文信号（避免误报）\n- `is_natural_solitary_species` - 是否独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷天然独居）\n- `is_breeding_period` - 是否繁殖期（公鱼护卵 / 母鱼离群产卵）\n- `is_territory_corner_fish` - 是否为领地型缸角守卫鱼（\"离群\"实为正常占地）\n- `is_during_feeding` - 是否在投喂窗口内（短时聚拢/分散为生理性）\n- `tank_has_strong_water_flow` - 是否有强水流区（被冲到角落可能误判）\n- `tank_temperature_gradient_detected` - 是否检测到温度不均（鱼可能聚于舒适温区，余者\"离群\"）\n\n## 综合判定\n\n- `schooling_normal` - 群体正常聚集\n- `schooling_loose` - 群体偏松散（但无明显离群个体）\n- `isolation_short` - 短时离群（> 10 倍体长但 < 1 小时）\n- `isolation_persistent` - **持续离群**（> 10 倍体长且 ≥ 1 小时，核心告警场景）\n- `isolation_corner_stuck` - 角落呆滞（离群 + 长时间几乎不动，疑似严重不适）\n- `multiple_isolated_individuals` - 多鱼同时离群（疑似全缸应激 / 水质恶化）\n- `isolation_signal_unreliable` - 信号不可靠（ReID 断裂 / 视野遮挡 / 浑浊度过高 / 跟踪 < 80% 鱼数）\n\n## 4 级告警策略递进\n\n- Level 1（isolation_short / schooling_loose）：仅入库或用户 APP 轻提醒\"观察某条鱼是否长期离群\"\n- Level 2（isolation_persistent，单条）：用户 APP 重要告警，建议**目视检查该鱼体表 / 游姿 / 呼吸 / 摄食活跃度**，并**评估是否隔离至检疫缸**\n- Level 3（isolation_corner_stuck / 连续 ≥ 2 日 isolation_persistent）：紧急告警，**强烈建议立即隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）**，并提示联系**当地观赏鱼兽医**\n- Level 4（multiple_isolated_individuals / 同缸 ≥ 3 条同时持续离群）：最高紧急告警 + 推送家庭/管理人员所有联系人 + 强烈建议**立即全面排查（水质 + 体表 + 游姿 + 呼吸 + 摄食）+ 联系专业人员**\n\n## 单日告警上限\n\n- Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限\n\n## 红线约束\n\n- **禁止**做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征\"等具体疾病诊断\n- **禁止**输出具体药物名称、剂量、给药方案\n- **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定）\n- **禁止**用于商业广告 / AI 训练；禁第三方共享\n- **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议）\n- 离群距离、持续时长、群体分散度等指标必须基于真实视频帧跟踪；**禁止伪造或夸大指标**\n- 鱼种特异性：**独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷）天然不集群** → 必须按鱼种基线判定；**禁止使用通用 10 倍体长阈值盲判独居鱼种**\n- 必须考虑生理性离群上下文：**繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集** → 不可直接告警\n- **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable`，并建议重拍 / 调整摄像头角度；**禁止给出不可靠告警**\n- 必须告知用户：AI 行为识别仅供参考，**最终诊断与治疗方案需专业水族兽医确认**\n\n## 输出报告字段\n\n- `report_date` - 报告日期\n- `tank_id` - 鱼缸/养殖池/检疫缸 ID\n- `species` - 鱼种\n- `total_fish_count_baseline` - 注册总鱼数\n- `school_compactness_score` - 群体紧密度\n- `isolated_fish_list` - 离群个体清单（每条含 fish_id / distance_to_centroid_body_lengths / over_threshold_duration_min / 缩略图轨迹）\n- `composite_scene` - 综合判定\n- `alert_level` - 告警等级\n- `recommended_actions` - 建议动作（观察 / 隔离检疫缸 / 检查水质 / 联系兽医，**不含药物**）\n- `disclaimer` - 免责声明\n\nFile v1.0.9:skills/smyx_analysis/references/api_doc.md\n\n# API接口文档\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 请求格式：支持文件上传\n- 响应格式：JSON\n\n## 错误码说明\n\n| 错误码 | 说明       |\n|-----|----------|\n| 400 | 请求参数错误   |\n| 401 | API密钥无效  |\n| 403 | 权限不足     |\n| 413 | 文件过大     |\n| 415 | 不支持的文件格式 |\n| 500 | 服务器内部错误  |\n\nFile v1.0.9:scripts/config.yaml\n\n{}\n\nFile v1.0.9:skills/smyx_analysis/scripts/config.yaml\n\n{}\n\nFile v1.0.9:skills/smyx_common/scripts/config-dev.yaml\n\nApiEnum:\n  base-url-open-api: \"http://192.168.1.234:9601/smyx-open-api\"\n  base-url-open-h5: \"http://192.168.1.234:4100\"\n  base-url-health: \"http://192.168.1.234:7070/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.9:skills/smyx_common/scripts/config-test.yaml\n\nApiEnum:\n  base-url-open-api: \"https://livemonitortest.lifeemergence.com/smyx-open-api\"\n  base-url-open-h5: \"http://livemonitortest.lifeemergence.com\"\n  base-url-health: \"https://healthtest.lifeemergence.com/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.9:skills/smyx_common/scripts/config.yaml\n\nApiEnum:\n  api-key: null\n  api-secret-key: null\n  base-url-health: https://lifeemergence.com/jeecg-boot-xzgz\n  base-url-open-api: https://open.lifeemergence.com/smyx-open-api\n  base-url-open-h5: http://livemonitor.lifeemergence.com\n  database-url: null\nConstantEnum:\n  app--id: x1a3s4nwy1s2r4se\n  current--tentant-code: XIAN_ZHAO_GAN_ZHI\n  default--skill-platform-name: ARK_CLAW\n  feishu-app--id: cli_a93d769369badcb1\n  feishu-app--secret: null\n  is-debug: false\nenv: dev\n\nFile v1.0.9:skills/smyx_analysis/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nyaml==6.0.3\n\nFile v1.0.9:skills/smyx_common/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nPyYAML==6.0.3\n\nArchive v1.0.8: 31 files, 44783 bytes\n\nFiles: references/api_doc.md (6925b), scripts/__init__.py (64b), scripts/config.py (684b), scripts/config.yaml (3b), scripts/skill.py (580b), scripts/smyx_fish_isolation_detection_analysis.py (3725b), skill-card.md (2714b), SKILL.md (17402b), skills/smyx_analysis/__init__.py (0b), skills/smyx_analysis/references/api_doc.md (427b), skills/smyx_analysis/requirements.txt (45b), skills/smyx_analysis/scripts/__init__.py (0b), skills/smyx_analysis/scripts/api_service.py (1509b), skills/smyx_analysis/scripts/config.py (1003b), skills/smyx_analysis/scripts/config.yaml (3b), skills/smyx_analysis/scripts/skill.py (6529b), skills/smyx_analysis/scripts/smyx_analysis.py (3833b), skills/smyx_common/__init__.py (0b), skills/smyx_common/requirements.txt (47b), skills/smyx_common/scripts/__init__.py (177b), skills/smyx_common/scripts/api_service.py (2645b), skills/smyx_common/scripts/base.py (469b), skills/smyx_common/scripts/config-dev.yaml (214b), skills/smyx_common/scripts/config-prod.yaml (0b), skills/smyx_common/scripts/config-test.yaml (256b), skills/smyx_common/scripts/config.py (24363b), skills/smyx_common/scripts/config.yaml (472b), skills/smyx_common/scripts/dao.py (18266b), skills/smyx_common/scripts/skill.py (2473b), skills/smyx_common/scripts/util.py (28776b), _meta.json (157b)\n\nFile v1.0.8:SKILL.md\n\n---\nname: \"smyx-fish-isolation-detection-analysis\"\ndescription: \"Through fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。\"\nversion: \"1.0.12\"\nlicense: \"MIT-0\"\n---\n\n# 🐟 Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别\n> **智能分析中枢** · 图片/视频智能分析 · 结构化报告 · 历史报告云端查询\n\n---\n\n## 🧭 技能概览 | Overview\n\n| 模块 | 内容 |\n|---|---|\n| 🏷️ 技能名称 | **鱼类聚集/离群行为识别** |\n| 🎯 核心目标 | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。 |\n| 🖼️ 输入类型 | 图片、视频、本地文件、网络 URL |\n| 📝 输出能力 | 结构化分析报告、识别/监测结果、建议与报告链接 |\n| 🧩 场景码 | `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` |\n\nThrough fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). When a fish drifts more than 10 body lengths away from the school center and the state lasts longer than 1 hour (or a user-defined threshold), the system outputs an 'isolation behavior' alert. This skill helps early detection of bullied, sick (e.g. parasites, bacterial infections), spawning-period solitary or environment-distressed (e.g. strong water flow, temperature gradient) individuals, prompting aquarists to inspect and intervene. Application scenarios: home aquariums, public aquariums, aquaculture ponds, quarantine tanks. The system monitors continuously and pushes reminders when prolonged isolated fish is found. Skill features: prolonged isolation is often an early signal of disease (e.g. external parasites, digestive issues) or stress from bullying. AI-based automatic identification of isolation behavior helps aquarists detect sick fish early and isolate for treatment, reducing whole-tank infection risk. This skill can be integrated into smart aquarium cameras to enhance product behavior-analysis capability.\n\n通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。该技能有助于早期发现被欺凌、生病（如寄生虫、细菌感染）、产卵期孤立或环境不适（如水流过强、温度不均）的个体，提醒养鱼者及时检查干预。应用场景：家庭鱼缸、水族馆、水产养殖池、检疫缸。系统连续监测，当发现长期离群鱼只时推送提醒。技能特点：鱼只长期离群往往是疾病的早期信号（如体表寄生虫、消化问题），或受欺凌导致应激。通过 AI 自动识别离群行为，可帮助养鱼者及早发现病鱼并隔离治疗，降低全缸感染风险。该技能可集成到智能鱼缸摄像头中，提升产品行为分析能力。\n\n## 🤖 AI 角色 | AI Role\n| 角色要点 | 说明 |\n|---|---|\n| 说明 1 | **假设你是一个专业的水族行为监测 AI。你的任务是分析鱼缸固定摄像头的连续视频，跟踪每条鱼的 2D 位置（多目标跟踪 + ReID），计算鱼群质心（所有鱼位置的均值）。对每条鱼，计算其与质心的欧氏距离（**以该鱼的体长为单位**，核心量化单位）。当某条鱼的距离 > 10 倍体长（用户可配置）且该状态持续时间 ≥ 1 小时（用户可配置）时，输出离群提示。按 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）作判定，按 4 级告警策略递进（Level 1 入库/轻提醒 → Level 2 重要告警 + 目视检查体表/游姿/呼吸/摄食 + 评估是否隔离至检疫缸 → Level 3 紧急告警 + 强烈建议隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）+ 联系兽医 → Level 4 同缸 ≥ 3 条同时持续离群 + 推送所有联系人 + 全面排查 + 联系专业人员）。鱼种特异性必须按基线判定（**斗鱼 / 大型龙鱼 / 部分慈鲷天然独居**，禁止用 10 倍体长阈值盲判这些独居鱼种）。必须考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报。ReID 跟踪率 < 80% 或视野遮挡严重时必须返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警**。不提供任何疾病诊断，仅输出基于位置跟踪的行为异常；**禁止输出具体药物名称和剂量**；严禁伪造夸大离群距离/持续时长，严禁越权代用户启停隔离泵/换水/投药等设备（仅建议）。** |\n\n## 🎬 技能演示 | Skill Demo\n\n[▶️ 点击查看技能使用介绍](https://lifeemergence.com/sample.html)\n\n---\n\n## 🎯 任务目标 | Goals\n### 1. 🧩 技能用途\n\n基于鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头**连续视频**（≥ 1 小时滚动窗口，用户可配置 30 分钟 - 24 小时），识别 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）→ **三组指标**：群体几何 5 项（跟踪鱼数 / 基线总数 / 质心 2D 坐标 / 群体分散度 / 群体紧密度）+ 个体离群 6 项（fish_id / 体长像素 / 个体 2D 位置 / **距质心距离（体长倍数）** / 是否超阈 / **持续超阈时长**）+ 上下文 6 项（独居鱼种 / 繁殖期 / 领地缸角 / 投喂窗口 / 强水流区 / 温度梯度）→ 4 档告警级别（mild → moderate → severe → urgent）→ **4 级告警策略递进**（入库/轻提醒 → 重要告警 + 目视检查 + 评估隔离 → 紧急告警 + 隔离至检疫缸 + 水质检查 + 联系兽医 → 最高紧急告警 + 全面排查 + 所有联系人 + 专业人员）→ 单日告警上限（Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限）→ **每日离群行为报告**（按 tank_id 输出，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明）\n\n### 2. 🛠️ 能力范围\n\n| 序号 | 具体能力 |\n|---:|---|\n| 1 | 鱼体目标检测 + 多目标跟踪 + ReID 重识别（鱼离群再返群仍保持 fish_id 稳定） |\n| 2 | 2D 位置投影 |\n| 3 | 质心计算（所有跟踪鱼位置均值） |\n| 4 | 群体分散度 / 紧密度量化（体长归一化） |\n| 5 | **个体到质心距离（体长倍数核心指标）** |\n| 6 | 跨帧累计持续超阈时长 |\n| 7 | 鱼种自适应基线（独居 / 群居 / 半独居） |\n| 8 | 生理性离群上下文识别（繁殖 / 领地 / 投喂 / 水流 / 温度梯度） |\n| 9 | ReID 跟踪率门控（< 80% 返回 unreliable） |\n| 10 | 用户 APP 推送 |\n| 11 | 4 级告警递进 |\n| 12 | 单日告警上限 |\n| 13 | 每日离群行为报告（按 tank_id 输出） |\n| 14 | 连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n\n### 3. ⚡ 触发条件\n\n| 触发类型 | 触发规则 |\n|---|---|\n| ✅ 默认触发 | **默认触发**：当用户提供鱼缸固定摄像头连续视频 URL 或文件需要分析时，默认触发本技能进行鱼类聚集/离群行为识别 |\n| 🔎 明确分析意图 | 当用户明确提及鱼离群、鱼孤立、鱼独处、鱼缸角落呆滞、鱼被欺凌、鱼群分散、鱼群质心等关键词，并且上传了视频文件 |\n| 📚 历史报告查询 | 当用户提及以下关键词时，**自动触发历史报告查询功能** ：查看鱼离群历史报告、鱼缸离群行为日志清单、持续离群事件清单、查询历史鱼离群记录、显示所有鱼缸离群行为报告 |\n\n### 4. 🤖 自动行为\n\n| 自动行为 | 执行要求 |\n|---|---|\n| 📎 附件处理 | 如果用户上传了附件或者视频/图片文件，则自动保存为本地文件 |\n| ☁️ 历史报告查询 | 如果用户触发历史报告查询关键词，必须直接调用云端 API 查询，不得从本地记忆或人工汇总中获取 |\n\n#### ⚠️ 强制数据获取规则（次高优先级）\n\n> **橙色强约束：** 历史报告清单只允许从云端接口读取，不允许从本地记录、长期记忆或人工汇总中提取。\n\n必须执行：\n\n```bash\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n```\n\n| 类型 | 要求 |\n|---|---|\n| ✅ 必须 | 使用 `python -m scripts.smyx_fish_isolation_detection_analysis --list` 调用 API 查询云端的历史报告数据 |\n| 🚫 严格禁止 | 从本地 `memory` 目录读取历史会话信息 |\n| 🚫 严格禁止 | 手动汇总本地记录中的报告 |\n| 🚫 严格禁止 | 从长期记忆中提取报告 |\n| ✅ 输出格式 | 必须统一从云端接口获取最新完整数据，然后以 Markdown 表格格式输出结果 |\n\n## 📦 前置准备 | Requirements\n- 依赖说明:scripts 脚本所需的依赖包及版本\n  ```\n  requests>=2.28.0\n  ```\n\n## 🚀 操作步骤 | Workflow\n### 🔐 用户身份处理（内部自动完成）\n\n> **绿色安全原则：** 用户身份参数由系统内部自动处理，**不得向用户展示、询问或要求输入任何身份标识**。\n\n执行本技能分析或历史报告查询时，脚本会自动完成身份初始化：\n\n| 场景 | 系统行为 |\n|---|---|\n| 上游系统有内部身份参数 | 由脚本静默接收并使用 |\n| 上游系统未提供内部身份参数 | 脚本会自动复用本地缺省用户 |\n| 本地缺省用户不存在 | 脚本会自动创建并在后续任务中复用 |\n| 对用户输出 | 只展示分析进度、分析结果和报告链接，不展示内部身份值 |\n\n#### 🔒 关键约束\n\n| 禁止/要求 | 说明 |\n|---|---|\n| 🚫 不得询问身份 | 不得提示用户输入用户名、手机号或任何内部身份参数 |\n| 🚫 不得暴露身份值 | 不得在回复、报告、示例、错误提示中暴露内部身份值 |\n| 🚫 不得列为用户参数 | 不得把内部身份参数列为用户需要理解或传入的参数 |\n| ✅ 自动关联报告 | 历史报告查询同样由系统内部身份自动关联，用户只需表达“查看历史报告/报告清单”等意图 |\n\n---\n\n### 🧪 标准流程 | Standard Flow\n\n| 步骤 | 阶段 | 执行动作 |\n|---:|---|---|\n| 1 | 📥 准备鱼缸固定摄像头连续视频输入 | 提供本地文件路径或网络 URL；确保输入内容清晰、符合技能场景要求 |\n| 2 | 🔐 获取 open-id（强制执行） | 无需用户输入任何身份参数；不在回复中展示内部身份值 |\n| 3 | ⚙️ 执行鱼类聚集/离群行为识别 | 调用 `-m scripts.smyx_fish_isolation_detection_analysis` 处理输入（**必须在技能根目录下运行脚本**） |\n| 4 | 📊 查看分析结果 | 接收结构化分析报告，查看识别/监测结果、风险提示、建议与报告链接 |\n\n### ⚙️ 脚本参数说明\n\n| 参数 | 含义 | 备注 |\n|---|---|---|\n| `--input` | 本地鱼缸固定摄像头连续视频文件路径 | 适用于本地文件分析 |\n| `--url` | 网络鱼缸固定摄像头连续视频 URL 地址（API 服务自动下载） | API 服务自动下载网络资源 |\n| `--pet-type` | 类别标识，鱼类聚集/离群行为识别场景默认 `other` | 按需填写 |\n| `--list` | 显示鱼类聚集/离群行为识别历史记录清单 | 用于云端历史报告查询 |\n| `--api-url` | API 服务地址（可选，使用默认值） | 按需填写 |\n| `--detail` | 输出详细程度（basic/standard/json，默认 json） | 输出详细程度 |\n| `--output` | 结果输出文件路径（可选） | 可选 |\n\n## 🗂️ 资源索引 | Resource Index\n| 资源类型 | 路径 | 用途 | 何时读取 |\n|---|---|---|---|\n| 🐍 必要脚本 | [`scripts/smyx_fish_isolation_detection_analysis.py`](scripts/smyx_fish_isolation_detection_analysis.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 🐍 必要脚本 | [`scripts/config.py`](scripts/config.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 📘 领域参考 | [`references/api_doc.md`](references/api_doc.md) | 了解 API 接口规范、字段说明和错误码 | 仅在需要了解接口规范或错误码时读取 |\n\n## ⚠️ 注意事项 | Notes\n| 分类 | 注意事项 |\n|---|---|\n| 📚 文档读取 | 仅在需要时读取参考文档，保持上下文简洁 |\n| 📁 格式支持 | 输入要求：支持 mp4/avi/mov，最大 10MB；摄像头需俯拍或大角度斜视；**连续采样 ≥ 1 小时**；帧率 ≥ 10 FPS；必须接入 ReID 多目标跟踪 |\n| 🔎 使用提醒 | **核心量化单位**：**离群距离以\"鱼体长倍数\"为单位**（默认阈值 > 10 倍体长，用户可配置） |\n| 🔎 使用提醒 | **核心持续时长阈值**：**≥ 1 小时**（用户可配置 15 分钟 - 24 小时） |\n| 🔎 使用提醒 | **4 级告警策略递进**（mild → moderate → severe → urgent/Level 4），同缸 ≥ 3 条同时持续离群 / 离群+角落呆滞进入更高级别 |\n| 🔎 使用提醒 | 单日告警上限：Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限（紧急安全优先） |\n| 🔎 使用提醒 | 红线约束 |\n| 🧑‍⚖️ 结果性质 | **禁止**对鱼做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征 / 被欺凌创伤\"等具体疾病或行为学诊断 |\n| 🔎 使用提醒 | **🚨 绝对禁止**输出具体药物名称、剂量、给药方案 |\n| 🔎 使用提醒 | **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定） |\n| 🔎 使用提醒 | **禁止**用于商业广告 / AI 训练；禁第三方共享 |\n| 🔎 使用提醒 | **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议） |\n| 🔎 使用提醒 | **绝对禁止**伪造或夸大离群距离、持续时长、群体分散度等指标；所有数据必须基于真实视频帧跟踪 |\n| 🔎 使用提醒 | **必须**按**鱼种基线**判定（独居：斗鱼 / 大型龙鱼 / 部分慈鲷；半独居：罗汉、地图等；群居：灯鱼 / 鼠鱼 / 锦鲤）；**禁止使用通用 10 倍体长阈值盲判独居鱼种** |\n| 📚 文档读取 | **必须**考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报 |\n| 🔎 使用提醒 | **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警** |\n| 🔎 使用提醒 | **必须**：连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n| 📜 报告输出 | **必须**：每日离群行为报告**按 tank_id 输出**，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明 |\n| 🚫 脚本限制 | 禁止临时生成脚本，只能用技能本身的脚本 |\n| 🌐 网络地址 | 传入的网络地址参数，不需要下载本地，默认地址都是公网地址，api 服务会自动下载 |\n| 📜 报告输出 | 当显示历史离群记录清单的时候，从接口返回 json 数据中提取字段  作为超链接地址，且自动转化为如下 Markdown |\n| 📜 报告输出 | 表格输出示例 |\n\n## 🧰 使用示例 | Examples\n```bash\n# 分析本地连续视频（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --input /path/to/tank_1h.mp4\n\n# 分析网络连续视频/实时流（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --url https://example.com/tank_1h.mp4\n\n# 显示历史离群行为记录清单（自动触发关键词：查看鱼离群历史报告、鱼缸离群行为日志清单等）\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n\n# 输出精简报告\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --detail basic\n\n# 保存结果到文件\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --output result.json\n```\n\nFile v1.0.8:_meta.json\n\n{\n  \"ownerId\": \"kn7cyxkr2ymf7zwsrybpedg8xx83ywrj\",\n  \"slug\": \"smyx-fish-isolation-detection-analysis\",\n  \"version\": \"1.0.8\",\n  \"publishedAt\": 1787744610176\n}\n\nFile v1.0.8:references/api_doc.md\n\n# API 接口文档\n\n此处用于存放鱼类聚集/离群行为识别 API 的接口文档，待后续补充。\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 响应格式：JSON\n\n## 主要接口\n\n1. `/web/health-analysis/v2/start-health-analysis` - 启动鱼类聚集/离群行为识别任务\n2. `/web/health-analysis/v2/get-health-analysis-result` - 获取离群检测结果（离群个体清单 + 离群距离 + 持续时长）\n3. `/web/health-analysis/page-health-analysis-result` - 分页查询历史离群行为报告\n4. `/health/order/api/getReportDetailExport?id={id}` - 导出离群行为报告\n5. （可选）`/web/companion/v2/trigger-soothing-action` - 触发联动提醒（用户 APP 推送 / 智能鱼缸告警灯 / 提示隔离至检疫缸建议）\n\n## 场景代码\n\n- `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` - 鱼类聚集/离群行为识别\n\n## 输入约束\n\n- 摄像头：鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头，建议**俯拍或大角度斜视**（保证 2D 位置投影稳定）\n- 分辨率 ≥ 720p；**帧率 ≥ 10 FPS**（位置跟踪需稳定）\n- 光照：建议鱼缸照明开启 + 无强反光；水质清澈（浑浊度低）\n- **核心采样窗口**：连续观察 ≥ 1 小时（用户可配置 30 分钟 - 24 小时滚动窗口）\n- 视野约束：必须覆盖整个鱼缸/养殖池**完整水平投影**（任何 dead zone 都可能误判为\"离群\"）\n- 多鱼缸/池场景按摄像头 ID 绑定到注册容器 ID\n- **多鱼场景必须接入 ReID**（多目标跟踪 + 重识别），每条鱼建立稳定 fish_id\n- **部署时必须录入**：鱼种清单、群体大小 N（用户输入或首次自动统计取众数）、每条鱼体长校准（像素 ↔ cm，可单次手动校准或自动学习）\n- 用户必须授权部署；公共水族馆 / 养殖场需公示告知\n\n## 关键观测信号\n\n### 群体几何信号\n- `tracked_fish_count` - 当前帧成功跟踪到的鱼数\n- `total_fish_count_baseline` - 容器注册总鱼数（基线）\n- `school_centroid_xy` - 鱼群质心（所有鱼 2D 位置均值）\n- `school_dispersion_score` - 群体分散度（所有鱼到质心距离的标准差，体长归一化）\n- `school_compactness_score` - 群体紧密度（0-100，越高越紧密；夜行鱼休息时自然偏低）\n\n### 个体离群信号（每条 fish_id 独立）\n- `fish_id` - 个体唯一标识（ReID 输出）\n- `fish_body_length_px` - 该鱼当前体长（像素，自动估计）\n- `fish_position_xy` - 该鱼当前 2D 位置\n- `distance_to_centroid_body_lengths` - 与质心欧氏距离（**以体长为单位**，核心指标）\n- `over_threshold_flag` - 是否超过阈值（默认 > 10 倍体长）\n- `over_threshold_duration_min` - 持续超阈时长（分钟，跨帧累计）\n\n### 上下文信号（避免误报）\n- `is_natural_solitary_species` - 是否独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷天然独居）\n- `is_breeding_period` - 是否繁殖期（公鱼护卵 / 母鱼离群产卵）\n- `is_territory_corner_fish` - 是否为领地型缸角守卫鱼（\"离群\"实为正常占地）\n- `is_during_feeding` - 是否在投喂窗口内（短时聚拢/分散为生理性）\n- `tank_has_strong_water_flow` - 是否有强水流区（被冲到角落可能误判）\n- `tank_temperature_gradient_detected` - 是否检测到温度不均（鱼可能聚于舒适温区，余者\"离群\"）\n\n## 综合判定\n\n- `schooling_normal` - 群体正常聚集\n- `schooling_loose` - 群体偏松散（但无明显离群个体）\n- `isolation_short` - 短时离群（> 10 倍体长但 < 1 小时）\n- `isolation_persistent` - **持续离群**（> 10 倍体长且 ≥ 1 小时，核心告警场景）\n- `isolation_corner_stuck` - 角落呆滞（离群 + 长时间几乎不动，疑似严重不适）\n- `multiple_isolated_individuals` - 多鱼同时离群（疑似全缸应激 / 水质恶化）\n- `isolation_signal_unreliable` - 信号不可靠（ReID 断裂 / 视野遮挡 / 浑浊度过高 / 跟踪 < 80% 鱼数）\n\n## 4 级告警策略递进\n\n- Level 1（isolation_short / schooling_loose）：仅入库或用户 APP 轻提醒\"观察某条鱼是否长期离群\"\n- Level 2（isolation_persistent，单条）：用户 APP 重要告警，建议**目视检查该鱼体表 / 游姿 / 呼吸 / 摄食活跃度**，并**评估是否隔离至检疫缸**\n- Level 3（isolation_corner_stuck / 连续 ≥ 2 日 isolation_persistent）：紧急告警，**强烈建议立即隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）**，并提示联系**当地观赏鱼兽医**\n- Level 4（multiple_isolated_individuals / 同缸 ≥ 3 条同时持续离群）：最高紧急告警 + 推送家庭/管理人员所有联系人 + 强烈建议**立即全面排查（水质 + 体表 + 游姿 + 呼吸 + 摄食）+ 联系专业人员**\n\n## 单日告警上限\n\n- Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限\n\n## 红线约束\n\n- **禁止**做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征\"等具体疾病诊断\n- **禁止**输出具体药物名称、剂量、给药方案\n- **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定）\n- **禁止**用于商业广告 / AI 训练；禁第三方共享\n- **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议）\n- 离群距离、持续时长、群体分散度等指标必须基于真实视频帧跟踪；**禁止伪造或夸大指标**\n- 鱼种特异性：**独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷）天然不集群** → 必须按鱼种基线判定；**禁止使用通用 10 倍体长阈值盲判独居鱼种**\n- 必须考虑生理性离群上下文：**繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集** → 不可直接告警\n- **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable`，并建议重拍 / 调整摄像头角度；**禁止给出不可靠告警**\n- 必须告知用户：AI 行为识别仅供参考，**最终诊断与治疗方案需专业水族兽医确认**\n\n## 输出报告字段\n\n- `report_date` - 报告日期\n- `tank_id` - 鱼缸/养殖池/检疫缸 ID\n- `species` - 鱼种\n- `total_fish_count_baseline` - 注册总鱼数\n- `school_compactness_score` - 群体紧密度\n- `isolated_fish_list` - 离群个体清单（每条含 fish_id / distance_to_centroid_body_lengths / over_threshold_duration_min / 缩略图轨迹）\n- `composite_scene` - 综合判定\n- `alert_level` - 告警等级\n- `recommended_actions` - 建议动作（观察 / 隔离检疫缸 / 检查水质 / 联系兽医，**不含药物**）\n- `disclaimer` - 免责声明\n\nFile v1.0.8:skills/smyx_analysis/references/api_doc.md\n\n# API接口文档\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 请求格式：支持文件上传\n- 响应格式：JSON\n\n## 错误码说明\n\n| 错误码 | 说明       |\n|-----|----------|\n| 400 | 请求参数错误   |\n| 401 | API密钥无效  |\n| 403 | 权限不足     |\n| 413 | 文件过大     |\n| 415 | 不支持的文件格式 |\n| 500 | 服务器内部错误  |\n\nFile v1.0.8:scripts/config.yaml\n\n{}\n\nFile v1.0.8:skills/smyx_analysis/scripts/config.yaml\n\n{}\n\nFile v1.0.8:skills/smyx_common/scripts/config-dev.yaml\n\nApiEnum:\n  base-url-open-api: \"http://192.168.1.234:9601/smyx-open-api\"\n  base-url-open-h5: \"http://192.168.1.234:4100\"\n  base-url-health: \"http://192.168.1.234:7070/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.8:skills/smyx_common/scripts/config-test.yaml\n\nApiEnum:\n  base-url-open-api: \"https://livemonitortest.lifeemergence.com/smyx-open-api\"\n  base-url-open-h5: \"http://livemonitortest.lifeemergence.com\"\n  base-url-health: \"https://healthtest.lifeemergence.com/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.8:skills/smyx_common/scripts/config.yaml\n\nApiEnum:\n  api-key: null\n  api-secret-key: null\n  base-url-health: https://lifeemergence.com/jeecg-boot-xzgz\n  base-url-open-api: https://open.lifeemergence.com/smyx-open-api\n  base-url-open-h5: http://livemonitor.lifeemergence.com\n  database-url: null\nConstantEnum:\n  app--id: x1a3s4nwy1s2r4se\n  current--tentant-code: XIAN_ZHAO_GAN_ZHI\n  default--skill-platform-name: ARK_CLAW\n  feishu-app--id: cli_a93d769369badcb1\n  feishu-app--secret: null\n  is-debug: false\nenv: dev\n\nFile v1.0.8:skill-card.md\n\n## Description:\n\nThrough fixed cameras on aquariums, the system continuously tracks fish positions, computes the school centroid, measures each fish's distance from that centroid in body-length units, and reports prolonged isolation behavior.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[smyx-sunjinhui](https://clawhub.ai/user/smyx-sunjinhui)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nExternal users and developers use this skill to analyze aquarium or aquaculture camera media for schooling, loose-schooling, persistent isolation, corner-stuck behavior, and related alert levels. The skill returns behavior-focused reports and guidance without providing disease diagnoses or medication instructions.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Security evidence reports that the skill can upload aquarium media or submitted URLs to remote services.\n\nMitigation: Use only with media the user is authorized to share, and require clear privacy, retention, and data-use disclosure from the publisher before deployment.\n\nRisk: Security evidence reports local identity state and service tokens may be created, reused, read from the workspace, and stored in SQLite.\n\nMitigation: Run the skill in an isolated workspace, avoid shared machines for sensitive use, and review or clear local identity and token storage after testing.\n\nRisk: Security evidence reports the published package is configured for private development HTTP endpoints rather than the documented cloud service.\n\nMitigation: Do not install or operate the release until the publisher provides corrected production configuration and documents the intended service endpoints.\n\n## Reference(s):\n\n- [API Documentation](artifact/references/api_doc.md)\n- [Skill Demo](https://lifeemergence.com/sample.html)\n- [ClawHub Skill Page](https://clawhub.ai/smyx-sunjinhui/skills/smyx-fish-isolation-detection-analysis)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, JSON, guidance]\n\n**Output Format:** [Markdown or JSON analysis report with alert level, isolated-fish details, recommended actions, disclaimers, and optional report links]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [Can write the analysis output to a user-specified file and can list historical reports as Markdown.]\n\n## Skill Version(s):\n\n1.0.8 (source: server release metadata; artifact SKILL.md frontmatter states 1.0.12)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.\n\nFile v1.0.8:skills/smyx_analysis/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nyaml==6.0.3\n\nFile v1.0.8:skills/smyx_common/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nPyYAML==6.0.3\n\nArchive v1.0.7: 31 files, 44716 bytes\n\nFiles: references/api_doc.md (6925b), scripts/__init__.py (64b), scripts/config.py (684b), scripts/config.yaml (3b), scripts/skill.py (580b), scripts/smyx_fish_isolation_detection_analysis.py (3725b), skill-card.md (2595b), SKILL.md (17402b), skills/smyx_analysis/__init__.py (0b), skills/smyx_analysis/references/api_doc.md (427b), skills/smyx_analysis/requirements.txt (45b), skills/smyx_analysis/scripts/__init__.py (0b), skills/smyx_analysis/scripts/api_service.py (1509b), skills/smyx_analysis/scripts/config.py (1003b), skills/smyx_analysis/scripts/config.yaml (3b), skills/smyx_analysis/scripts/skill.py (6529b), skills/smyx_analysis/scripts/smyx_analysis.py (3833b), skills/smyx_common/__init__.py (0b), skills/smyx_common/requirements.txt (47b), skills/smyx_common/scripts/__init__.py (177b), skills/smyx_common/scripts/api_service.py (2645b), skills/smyx_common/scripts/base.py (469b), skills/smyx_common/scripts/config-dev.yaml (214b), skills/smyx_common/scripts/config-prod.yaml (0b), skills/smyx_common/scripts/config-test.yaml (256b), skills/smyx_common/scripts/config.py (24363b), skills/smyx_common/scripts/config.yaml (472b), skills/smyx_common/scripts/dao.py (18266b), skills/smyx_common/scripts/skill.py (2473b), skills/smyx_common/scripts/util.py (28776b), _meta.json (157b)\n\nFile v1.0.7:SKILL.md\n\n---\nname: \"smyx-fish-isolation-detection-analysis\"\ndescription: \"Through fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。\"\nversion: \"1.0.11\"\nlicense: \"MIT-0\"\n---\n\n# 🐟 Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别\n> **智能分析中枢** · 图片/视频智能分析 · 结构化报告 · 历史报告云端查询\n\n---\n\n## 🧭 技能概览 | Overview\n\n| 模块 | 内容 |\n|---|---|\n| 🏷️ 技能名称 | **鱼类聚集/离群行为识别** |\n| 🎯 核心目标 | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。 |\n| 🖼️ 输入类型 | 图片、视频、本地文件、网络 URL |\n| 📝 输出能力 | 结构化分析报告、识别/监测结果、建议与报告链接 |\n| 🧩 场景码 | `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` |\n\nThrough fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). When a fish drifts more than 10 body lengths away from the school center and the state lasts longer than 1 hour (or a user-defined threshold), the system outputs an 'isolation behavior' alert. This skill helps early detection of bullied, sick (e.g. parasites, bacterial infections), spawning-period solitary or environment-distressed (e.g. strong water flow, temperature gradient) individuals, prompting aquarists to inspect and intervene. Application scenarios: home aquariums, public aquariums, aquaculture ponds, quarantine tanks. The system monitors continuously and pushes reminders when prolonged isolated fish is found. Skill features: prolonged isolation is often an early signal of disease (e.g. external parasites, digestive issues) or stress from bullying. AI-based automatic identification of isolation behavior helps aquarists detect sick fish early and isolate for treatment, reducing whole-tank infection risk. This skill can be integrated into smart aquarium cameras to enhance product behavior-analysis capability.\n\n通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。该技能有助于早期发现被欺凌、生病（如寄生虫、细菌感染）、产卵期孤立或环境不适（如水流过强、温度不均）的个体，提醒养鱼者及时检查干预。应用场景：家庭鱼缸、水族馆、水产养殖池、检疫缸。系统连续监测，当发现长期离群鱼只时推送提醒。技能特点：鱼只长期离群往往是疾病的早期信号（如体表寄生虫、消化问题），或受欺凌导致应激。通过 AI 自动识别离群行为，可帮助养鱼者及早发现病鱼并隔离治疗，降低全缸感染风险。该技能可集成到智能鱼缸摄像头中，提升产品行为分析能力。\n\n## 🤖 AI 角色 | AI Role\n| 角色要点 | 说明 |\n|---|---|\n| 说明 1 | **假设你是一个专业的水族行为监测 AI。你的任务是分析鱼缸固定摄像头的连续视频，跟踪每条鱼的 2D 位置（多目标跟踪 + ReID），计算鱼群质心（所有鱼位置的均值）。对每条鱼，计算其与质心的欧氏距离（**以该鱼的体长为单位**，核心量化单位）。当某条鱼的距离 > 10 倍体长（用户可配置）且该状态持续时间 ≥ 1 小时（用户可配置）时，输出离群提示。按 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）作判定，按 4 级告警策略递进（Level 1 入库/轻提醒 → Level 2 重要告警 + 目视检查体表/游姿/呼吸/摄食 + 评估是否隔离至检疫缸 → Level 3 紧急告警 + 强烈建议隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）+ 联系兽医 → Level 4 同缸 ≥ 3 条同时持续离群 + 推送所有联系人 + 全面排查 + 联系专业人员）。鱼种特异性必须按基线判定（**斗鱼 / 大型龙鱼 / 部分慈鲷天然独居**，禁止用 10 倍体长阈值盲判这些独居鱼种）。必须考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报。ReID 跟踪率 < 80% 或视野遮挡严重时必须返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警**。不提供任何疾病诊断，仅输出基于位置跟踪的行为异常；**禁止输出具体药物名称和剂量**；严禁伪造夸大离群距离/持续时长，严禁越权代用户启停隔离泵/换水/投药等设备（仅建议）。** |\n\n## 🎬 技能演示 | Skill Demo\n\n[▶️ 点击查看技能使用介绍](https://lifeemergence.com/sample.html)\n\n---\n\n## 🎯 任务目标 | Goals\n### 1. 🧩 技能用途\n\n基于鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头**连续视频**（≥ 1 小时滚动窗口，用户可配置 30 分钟 - 24 小时），识别 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）→ **三组指标**：群体几何 5 项（跟踪鱼数 / 基线总数 / 质心 2D 坐标 / 群体分散度 / 群体紧密度）+ 个体离群 6 项（fish_id / 体长像素 / 个体 2D 位置 / **距质心距离（体长倍数）** / 是否超阈 / **持续超阈时长**）+ 上下文 6 项（独居鱼种 / 繁殖期 / 领地缸角 / 投喂窗口 / 强水流区 / 温度梯度）→ 4 档告警级别（mild → moderate → severe → urgent）→ **4 级告警策略递进**（入库/轻提醒 → 重要告警 + 目视检查 + 评估隔离 → 紧急告警 + 隔离至检疫缸 + 水质检查 + 联系兽医 → 最高紧急告警 + 全面排查 + 所有联系人 + 专业人员）→ 单日告警上限（Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限）→ **每日离群行为报告**（按 tank_id 输出，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明）\n\n### 2. 🛠️ 能力范围\n\n| 序号 | 具体能力 |\n|---:|---|\n| 1 | 鱼体目标检测 + 多目标跟踪 + ReID 重识别（鱼离群再返群仍保持 fish_id 稳定） |\n| 2 | 2D 位置投影 |\n| 3 | 质心计算（所有跟踪鱼位置均值） |\n| 4 | 群体分散度 / 紧密度量化（体长归一化） |\n| 5 | **个体到质心距离（体长倍数核心指标）** |\n| 6 | 跨帧累计持续超阈时长 |\n| 7 | 鱼种自适应基线（独居 / 群居 / 半独居） |\n| 8 | 生理性离群上下文识别（繁殖 / 领地 / 投喂 / 水流 / 温度梯度） |\n| 9 | ReID 跟踪率门控（< 80% 返回 unreliable） |\n| 10 | 用户 APP 推送 |\n| 11 | 4 级告警递进 |\n| 12 | 单日告警上限 |\n| 13 | 每日离群行为报告（按 tank_id 输出） |\n| 14 | 连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n\n### 3. ⚡ 触发条件\n\n| 触发类型 | 触发规则 |\n|---|---|\n| ✅ 默认触发 | **默认触发**：当用户提供鱼缸固定摄像头连续视频 URL 或文件需要分析时，默认触发本技能进行鱼类聚集/离群行为识别 |\n| 🔎 明确分析意图 | 当用户明确提及鱼离群、鱼孤立、鱼独处、鱼缸角落呆滞、鱼被欺凌、鱼群分散、鱼群质心等关键词，并且上传了视频文件 |\n| 📚 历史报告查询 | 当用户提及以下关键词时，**自动触发历史报告查询功能** ：查看鱼离群历史报告、鱼缸离群行为日志清单、持续离群事件清单、查询历史鱼离群记录、显示所有鱼缸离群行为报告 |\n\n### 4. 🤖 自动行为\n\n| 自动行为 | 执行要求 |\n|---|---|\n| 📎 附件处理 | 如果用户上传了附件或者视频/图片文件，则自动保存为本地文件 |\n| ☁️ 历史报告查询 | 如果用户触发历史报告查询关键词，必须直接调用云端 API 查询，不得从本地记忆或人工汇总中获取 |\n\n#### ⚠️ 强制数据获取规则（次高优先级）\n\n> **橙色强约束：** 历史报告清单只允许从云端接口读取，不允许从本地记录、长期记忆或人工汇总中提取。\n\n必须执行：\n\n```bash\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n```\n\n| 类型 | 要求 |\n|---|---|\n| ✅ 必须 | 使用 `python -m scripts.smyx_fish_isolation_detection_analysis --list` 调用 API 查询云端的历史报告数据 |\n| 🚫 严格禁止 | 从本地 `memory` 目录读取历史会话信息 |\n| 🚫 严格禁止 | 手动汇总本地记录中的报告 |\n| 🚫 严格禁止 | 从长期记忆中提取报告 |\n| ✅ 输出格式 | 必须统一从云端接口获取最新完整数据，然后以 Markdown 表格格式输出结果 |\n\n## 📦 前置准备 | Requirements\n- 依赖说明:scripts 脚本所需的依赖包及版本\n  ```\n  requests>=2.28.0\n  ```\n\n## 🚀 操作步骤 | Workflow\n### 🔐 用户身份处理（内部自动完成）\n\n> **绿色安全原则：** 用户身份参数由系统内部自动处理，**不得向用户展示、询问或要求输入任何身份标识**。\n\n执行本技能分析或历史报告查询时，脚本会自动完成身份初始化：\n\n| 场景 | 系统行为 |\n|---|---|\n| 上游系统有内部身份参数 | 由脚本静默接收并使用 |\n| 上游系统未提供内部身份参数 | 脚本会自动复用本地缺省用户 |\n| 本地缺省用户不存在 | 脚本会自动创建并在后续任务中复用 |\n| 对用户输出 | 只展示分析进度、分析结果和报告链接，不展示内部身份值 |\n\n#### 🔒 关键约束\n\n| 禁止/要求 | 说明 |\n|---|---|\n| 🚫 不得询问身份 | 不得提示用户输入用户名、手机号或任何内部身份参数 |\n| 🚫 不得暴露身份值 | 不得在回复、报告、示例、错误提示中暴露内部身份值 |\n| 🚫 不得列为用户参数 | 不得把内部身份参数列为用户需要理解或传入的参数 |\n| ✅ 自动关联报告 | 历史报告查询同样由系统内部身份自动关联，用户只需表达“查看历史报告/报告清单”等意图 |\n\n---\n\n### 🧪 标准流程 | Standard Flow\n\n| 步骤 | 阶段 | 执行动作 |\n|---:|---|---|\n| 1 | 📥 准备鱼缸固定摄像头连续视频输入 | 提供本地文件路径或网络 URL；确保输入内容清晰、符合技能场景要求 |\n| 2 | 🔐 获取 open-id（强制执行） | 无需用户输入任何身份参数；不在回复中展示内部身份值 |\n| 3 | ⚙️ 执行鱼类聚集/离群行为识别 | 调用 `-m scripts.smyx_fish_isolation_detection_analysis` 处理输入（**必须在技能根目录下运行脚本**） |\n| 4 | 📊 查看分析结果 | 接收结构化分析报告，查看识别/监测结果、风险提示、建议与报告链接 |\n\n### ⚙️ 脚本参数说明\n\n| 参数 | 含义 | 备注 |\n|---|---|---|\n| `--input` | 本地鱼缸固定摄像头连续视频文件路径 | 适用于本地文件分析 |\n| `--url` | 网络鱼缸固定摄像头连续视频 URL 地址（API 服务自动下载） | API 服务自动下载网络资源 |\n| `--pet-type` | 类别标识，鱼类聚集/离群行为识别场景默认 `other` | 按需填写 |\n| `--list` | 显示鱼类聚集/离群行为识别历史记录清单 | 用于云端历史报告查询 |\n| `--api-url` | API 服务地址（可选，使用默认值） | 按需填写 |\n| `--detail` | 输出详细程度（basic/standard/json，默认 json） | 输出详细程度 |\n| `--output` | 结果输出文件路径（可选） | 可选 |\n\n## 🗂️ 资源索引 | Resource Index\n| 资源类型 | 路径 | 用途 | 何时读取 |\n|---|---|---|---|\n| 🐍 必要脚本 | [`scripts/smyx_fish_isolation_detection_analysis.py`](scripts/smyx_fish_isolation_detection_analysis.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 🐍 必要脚本 | [`scripts/config.py`](scripts/config.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 📘 领域参考 | [`references/api_doc.md`](references/api_doc.md) | 了解 API 接口规范、字段说明和错误码 | 仅在需要了解接口规范或错误码时读取 |\n\n## ⚠️ 注意事项 | Notes\n| 分类 | 注意事项 |\n|---|---|\n| 📚 文档读取 | 仅在需要时读取参考文档，保持上下文简洁 |\n| 📁 格式支持 | 输入要求：支持 mp4/avi/mov，最大 10MB；摄像头需俯拍或大角度斜视；**连续采样 ≥ 1 小时**；帧率 ≥ 10 FPS；必须接入 ReID 多目标跟踪 |\n| 🔎 使用提醒 | **核心量化单位**：**离群距离以\"鱼体长倍数\"为单位**（默认阈值 > 10 倍体长，用户可配置） |\n| 🔎 使用提醒 | **核心持续时长阈值**：**≥ 1 小时**（用户可配置 15 分钟 - 24 小时） |\n| 🔎 使用提醒 | **4 级告警策略递进**（mild → moderate → severe → urgent/Level 4），同缸 ≥ 3 条同时持续离群 / 离群+角落呆滞进入更高级别 |\n| 🔎 使用提醒 | 单日告警上限：Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限（紧急安全优先） |\n| 🔎 使用提醒 | 红线约束 |\n| 🧑‍⚖️ 结果性质 | **禁止**对鱼做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征 / 被欺凌创伤\"等具体疾病或行为学诊断 |\n| 🔎 使用提醒 | **🚨 绝对禁止**输出具体药物名称、剂量、给药方案 |\n| 🔎 使用提醒 | **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定） |\n| 🔎 使用提醒 | **禁止**用于商业广告 / AI 训练；禁第三方共享 |\n| 🔎 使用提醒 | **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议） |\n| 🔎 使用提醒 | **绝对禁止**伪造或夸大离群距离、持续时长、群体分散度等指标；所有数据必须基于真实视频帧跟踪 |\n| 🔎 使用提醒 | **必须**按**鱼种基线**判定（独居：斗鱼 / 大型龙鱼 / 部分慈鲷；半独居：罗汉、地图等；群居：灯鱼 / 鼠鱼 / 锦鲤）；**禁止使用通用 10 倍体长阈值盲判独居鱼种** |\n| 📚 文档读取 | **必须**考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报 |\n| 🔎 使用提醒 | **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警** |\n| 🔎 使用提醒 | **必须**：连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n| 📜 报告输出 | **必须**：每日离群行为报告**按 tank_id 输出**，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明 |\n| 🚫 脚本限制 | 禁止临时生成脚本，只能用技能本身的脚本 |\n| 🌐 网络地址 | 传入的网络地址参数，不需要下载本地，默认地址都是公网地址，api 服务会自动下载 |\n| 📜 报告输出 | 当显示历史离群记录清单的时候，从接口返回 json 数据中提取字段  作为超链接地址，且自动转化为如下 Markdown |\n| 📜 报告输出 | 表格输出示例 |\n\n## 🧰 使用示例 | Examples\n```bash\n# 分析本地连续视频（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --input /path/to/tank_1h.mp4\n\n# 分析网络连续视频/实时流（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --url https://example.com/tank_1h.mp4\n\n# 显示历史离群行为记录清单（自动触发关键词：查看鱼离群历史报告、鱼缸离群行为日志清单等）\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n\n# 输出精简报告\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --detail basic\n\n# 保存结果到文件\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --output result.json\n```\n\nFile v1.0.7:_meta.json\n\n{\n  \"ownerId\": \"kn7cyxkr2ymf7zwsrybpedg8xx83ywrj\",\n  \"slug\": \"smyx-fish-isolation-detection-analysis\",\n  \"version\": \"1.0.7\",\n  \"publishedAt\": 1787488374080\n}\n\nFile v1.0.7:references/api_doc.md\n\n# API 接口文档\n\n此处用于存放鱼类聚集/离群行为识别 API 的接口文档，待后续补充。\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 响应格式：JSON\n\n## 主要接口\n\n1. `/web/health-analysis/v2/start-health-analysis` - 启动鱼类聚集/离群行为识别任务\n2. `/web/health-analysis/v2/get-health-analysis-result` - 获取离群检测结果（离群个体清单 + 离群距离 + 持续时长）\n3. `/web/health-analysis/page-health-analysis-result` - 分页查询历史离群行为报告\n4. `/health/order/api/getReportDetailExport?id={id}` - 导出离群行为报告\n5. （可选）`/web/companion/v2/trigger-soothing-action` - 触发联动提醒（用户 APP 推送 / 智能鱼缸告警灯 / 提示隔离至检疫缸建议）\n\n## 场景代码\n\n- `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` - 鱼类聚集/离群行为识别\n\n## 输入约束\n\n- 摄像头：鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头，建议**俯拍或大角度斜视**（保证 2D 位置投影稳定）\n- 分辨率 ≥ 720p；**帧率 ≥ 10 FPS**（位置跟踪需稳定）\n- 光照：建议鱼缸照明开启 + 无强反光；水质清澈（浑浊度低）\n- **核心采样窗口**：连续观察 ≥ 1 小时（用户可配置 30 分钟 - 24 小时滚动窗口）\n- 视野约束：必须覆盖整个鱼缸/养殖池**完整水平投影**（任何 dead zone 都可能误判为\"离群\"）\n- 多鱼缸/池场景按摄像头 ID 绑定到注册容器 ID\n- **多鱼场景必须接入 ReID**（多目标跟踪 + 重识别），每条鱼建立稳定 fish_id\n- **部署时必须录入**：鱼种清单、群体大小 N（用户输入或首次自动统计取众数）、每条鱼体长校准（像素 ↔ cm，可单次手动校准或自动学习）\n- 用户必须授权部署；公共水族馆 / 养殖场需公示告知\n\n## 关键观测信号\n\n### 群体几何信号\n- `tracked_fish_count` - 当前帧成功跟踪到的鱼数\n- `total_fish_count_baseline` - 容器注册总鱼数（基线）\n- `school_centroid_xy` - 鱼群质心（所有鱼 2D 位置均值）\n- `school_dispersion_score` - 群体分散度（所有鱼到质心距离的标准差，体长归一化）\n- `school_compactness_score` - 群体紧密度（0-100，越高越紧密；夜行鱼休息时自然偏低）\n\n### 个体离群信号（每条 fish_id 独立）\n- `fish_id` - 个体唯一标识（ReID 输出）\n- `fish_body_length_px` - 该鱼当前体长（像素，自动估计）\n- `fish_position_xy` - 该鱼当前 2D 位置\n- `distance_to_centroid_body_lengths` - 与质心欧氏距离（**以体长为单位**，核心指标）\n- `over_threshold_flag` - 是否超过阈值（默认 > 10 倍体长）\n- `over_threshold_duration_min` - 持续超阈时长（分钟，跨帧累计）\n\n### 上下文信号（避免误报）\n- `is_natural_solitary_species` - 是否独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷天然独居）\n- `is_breeding_period` - 是否繁殖期（公鱼护卵 / 母鱼离群产卵）\n- `is_territory_corner_fish` - 是否为领地型缸角守卫鱼（\"离群\"实为正常占地）\n- `is_during_feeding` - 是否在投喂窗口内（短时聚拢/分散为生理性）\n- `tank_has_strong_water_flow` - 是否有强水流区（被冲到角落可能误判）\n- `tank_temperature_gradient_detected` - 是否检测到温度不均（鱼可能聚于舒适温区，余者\"离群\"）\n\n## 综合判定\n\n- `schooling_normal` - 群体正常聚集\n- `schooling_loose` - 群体偏松散（但无明显离群个体）\n- `isolation_short` - 短时离群（> 10 倍体长但 < 1 小时）\n- `isolation_persistent` - **持续离群**（> 10 倍体长且 ≥ 1 小时，核心告警场景）\n- `isolation_corner_stuck` - 角落呆滞（离群 + 长时间几乎不动，疑似严重不适）\n- `multiple_isolated_individuals` - 多鱼同时离群（疑似全缸应激 / 水质恶化）\n- `isolation_signal_unreliable` - 信号不可靠（ReID 断裂 / 视野遮挡 / 浑浊度过高 / 跟踪 < 80% 鱼数）\n\n## 4 级告警策略递进\n\n- Level 1（isolation_short / schooling_loose）：仅入库或用户 APP 轻提醒\"观察某条鱼是否长期离群\"\n- Level 2（isolation_persistent，单条）：用户 APP 重要告警，建议**目视检查该鱼体表 / 游姿 / 呼吸 / 摄食活跃度**，并**评估是否隔离至检疫缸**\n- Level 3（isolation_corner_stuck / 连续 ≥ 2 日 isolation_persistent）：紧急告警，**强烈建议立即隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）**，并提示联系**当地观赏鱼兽医**\n- Level 4（multiple_isolated_individuals / 同缸 ≥ 3 条同时持续离群）：最高紧急告警 + 推送家庭/管理人员所有联系人 + 强烈建议**立即全面排查（水质 + 体表 + 游姿 + 呼吸 + 摄食）+ 联系专业人员**\n\n## 单日告警上限\n\n- Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限\n\n## 红线约束\n\n- **禁止**做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征\"等具体疾病诊断\n- **禁止**输出具体药物名称、剂量、给药方案\n- **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定）\n- **禁止**用于商业广告 / AI 训练；禁第三方共享\n- **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议）\n- 离群距离、持续时长、群体分散度等指标必须基于真实视频帧跟踪；**禁止伪造或夸大指标**\n- 鱼种特异性：**独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷）天然不集群** → 必须按鱼种基线判定；**禁止使用通用 10 倍体长阈值盲判独居鱼种**\n- 必须考虑生理性离群上下文：**繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集** → 不可直接告警\n- **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable`，并建议重拍 / 调整摄像头角度；**禁止给出不可靠告警**\n- 必须告知用户：AI 行为识别仅供参考，**最终诊断与治疗方案需专业水族兽医确认**\n\n## 输出报告字段\n\n- `report_date` - 报告日期\n- `tank_id` - 鱼缸/养殖池/检疫缸 ID\n- `species` - 鱼种\n- `total_fish_count_baseline` - 注册总鱼数\n- `school_compactness_score` - 群体紧密度\n- `isolated_fish_list` - 离群个体清单（每条含 fish_id / distance_to_centroid_body_lengths / over_threshold_duration_min / 缩略图轨迹）\n- `composite_scene` - 综合判定\n- `alert_level` - 告警等级\n- `recommended_actions` - 建议动作（观察 / 隔离检疫缸 / 检查水质 / 联系兽医，**不含药物**）\n- `disclaimer` - 免责声明\n\nFile v1.0.7:skills/smyx_analysis/references/api_doc.md\n\n# API接口文档\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 请求格式：支持文件上传\n- 响应格式：JSON\n\n## 错误码说明\n\n| 错误码 | 说明       |\n|-----|----------|\n| 400 | 请求参数错误   |\n| 401 | API密钥无效  |\n| 403 | 权限不足     |\n| 413 | 文件过大     |\n| 415 | 不支持的文件格式 |\n| 500 | 服务器内部错误  |\n\nFile v1.0.7:scripts/config.yaml\n\n{}\n\nFile v1.0.7:skills/smyx_analysis/scripts/config.yaml\n\n{}\n\nFile v1.0.7:skills/smyx_common/scripts/config-dev.yaml\n\nApiEnum:\n  base-url-open-api: \"http://192.168.1.234:9601/smyx-open-api\"\n  base-url-open-h5: \"http://192.168.1.234:4100\"\n  base-url-health: \"http://192.168.1.234:7070/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.7:skills/smyx_common/scripts/config-test.yaml\n\nApiEnum:\n  base-url-open-api: \"https://livemonitortest.lifeemergence.com/smyx-open-api\"\n  base-url-open-h5: \"http://livemonitortest.lifeemergence.com\"\n  base-url-health: \"https://healthtest.lifeemergence.com/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.7:skills/smyx_common/scripts/config.yaml\n\nApiEnum:\n  api-key: null\n  api-secret-key: null\n  base-url-health: https://lifeemergence.com/jeecg-boot-xzgz\n  base-url-open-api: https://open.lifeemergence.com/smyx-open-api\n  base-url-open-h5: http://livemonitor.lifeemergence.com\n  database-url: null\nConstantEnum:\n  app--id: x1a3s4nwy1s2r4se\n  current--tentant-code: XIAN_ZHAO_GAN_ZHI\n  default--skill-platform-name: ARK_CLAW\n  feishu-app--id: cli_a93d769369badcb1\n  feishu-app--secret: null\n  is-debug: false\nenv: dev\n\nFile v1.0.7:skill-card.md\n\n## Description:\n\nAnalyzes fixed aquarium camera video to track fish positions, compare each fish with the school centroid, and report prolonged isolation behavior with contextual cautions.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[smyx-sunjinhui](https://clawhub.ai/user/smyx-sunjinhui)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nAquarium owners, public aquarium teams, aquaculture operators, and developers use this skill to analyze uploaded or URL-based fish tank media for schooling, isolation, and alert-level reporting. It supports behavior monitoring and historical report lookup, while keeping diagnosis and treatment decisions with qualified aquatic professionals.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Aquarium media, video URLs, and history queries may be sent to the configured cloud service.\n\nMitigation: Use the skill only with media you are authorized to process, review the configured service endpoints before running it, and avoid sensitive or shared aquarium footage unless cloud processing is acceptable.\n\nRisk: The skill can silently initialize an identity and persist identity or token data in the local workspace.\n\nMitigation: Review local workspace storage before and after use, avoid shared workspaces when token persistence is unacceptable, and clear stored identity data according to your environment's policy.\n\nRisk: Fish isolation output may be mistaken for a veterinary diagnosis or treatment plan.\n\nMitigation: Treat results as behavior-monitoring guidance only; confirm health concerns, isolation decisions, medication, and treatment with a qualified aquatic professional.\n\n## Reference(s):\n\n- [ClawHub skill page](https://clawhub.ai/smyx-sunjinhui/skills/smyx-fish-isolation-detection-analysis)\n- [API documentation](references/api_doc.md)\n- [Skill demo](https://lifeemergence.com/sample.html)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, JSON, shell commands, guidance]\n\n**Output Format:** [Markdown or JSON analysis reports with alerts, recommended actions, and report links]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [May save output to a file when requested; history lookup is formatted as a Markdown table.]\n\n## Skill Version(s):\n\n1.0.7 (source: server release metadata)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.\n\nFile v1.0.7:skills/smyx_analysis/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nyaml==6.0.3\n\nFile v1.0.7:skills/smyx_common/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nPyYAML==6.0.3\n\nArchive v1.0.6: 31 files, 44745 bytes\n\nFiles: references/api_doc.md (6925b), scripts/__init__.py (64b), scripts/config.py (684b), scripts/config.yaml (3b), scripts/skill.py (580b), scripts/smyx_fish_isolation_detection_analysis.py (3725b), skill-card.md (2563b), SKILL.md (17401b), skills/smyx_analysis/__init__.py (0b), skills/smyx_analysis/references/api_doc.md (427b), skills/smyx_analysis/requirements.txt (45b), skills/smyx_analysis/scripts/__init__.py (0b), skills/smyx_analysis/scripts/api_service.py (1509b), skills/smyx_analysis/scripts/config.py (1003b), skills/smyx_analysis/scripts/config.yaml (3b), skills/smyx_analysis/scripts/skill.py (6529b), skills/smyx_analysis/scripts/smyx_analysis.py (3833b), skills/smyx_common/__init__.py (0b), skills/smyx_common/requirements.txt (47b), skills/smyx_common/scripts/__init__.py (177b), skills/smyx_common/scripts/api_service.py (2645b), skills/smyx_common/scripts/base.py (469b), skills/smyx_common/scripts/config-dev.yaml (214b), skills/smyx_common/scripts/config-prod.yaml (0b), skills/smyx_common/scripts/config-test.yaml (256b), skills/smyx_common/scripts/config.py (24363b), skills/smyx_common/scripts/config.yaml (473b), skills/smyx_common/scripts/dao.py (18266b), skills/smyx_common/scripts/skill.py (2473b), skills/smyx_common/scripts/util.py (28776b), _meta.json (157b)\n\nFile v1.0.6:SKILL.md\n\n---\nname: \"smyx-fish-isolation-detection-analysis\"\ndescription: \"Through fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。\"\nversion: \"1.0.9\"\nlicense: \"MIT-0\"\n---\n\n# 🐟 Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别\n> **智能分析中枢** · 图片/视频智能分析 · 结构化报告 · 历史报告云端查询\n\n---\n\n## 🧭 技能概览 | Overview\n\n| 模块 | 内容 |\n|---|---|\n| 🏷️ 技能名称 | **鱼类聚集/离群行为识别** |\n| 🎯 核心目标 | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。 |\n| 🖼️ 输入类型 | 图片、视频、本地文件、网络 URL |\n| 📝 输出能力 | 结构化分析报告、识别/监测结果、建议与报告链接 |\n| 🧩 场景码 | `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` |\n\nThrough fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). When a fish drifts more than 10 body lengths away from the school center and the state lasts longer than 1 hour (or a user-defined threshold), the system outputs an 'isolation behavior' alert. This skill helps early detection of bullied, sick (e.g. parasites, bacterial infections), spawning-period solitary or environment-distressed (e.g. strong water flow, temperature gradient) individuals, prompting aquarists to inspect and intervene. Application scenarios: home aquariums, public aquariums, aquaculture ponds, quarantine tanks. The system monitors continuously and pushes reminders when prolonged isolated fish is found. Skill features: prolonged isolation is often an early signal of disease (e.g. external parasites, digestive issues) or stress from bullying. AI-based automatic identification of isolation behavior helps aquarists detect sick fish early and isolate for treatment, reducing whole-tank infection risk. This skill can be integrated into smart aquarium cameras to enhance product behavior-analysis capability.\n\n通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。该技能有助于早期发现被欺凌、生病（如寄生虫、细菌感染）、产卵期孤立或环境不适（如水流过强、温度不均）的个体，提醒养鱼者及时检查干预。应用场景：家庭鱼缸、水族馆、水产养殖池、检疫缸。系统连续监测，当发现长期离群鱼只时推送提醒。技能特点：鱼只长期离群往往是疾病的早期信号（如体表寄生虫、消化问题），或受欺凌导致应激。通过 AI 自动识别离群行为，可帮助养鱼者及早发现病鱼并隔离治疗，降低全缸感染风险。该技能可集成到智能鱼缸摄像头中，提升产品行为分析能力。\n\n## 🤖 AI 角色 | AI Role\n| 角色要点 | 说明 |\n|---|---|\n| 说明 1 | **假设你是一个专业的水族行为监测 AI。你的任务是分析鱼缸固定摄像头的连续视频，跟踪每条鱼的 2D 位置（多目标跟踪 + ReID），计算鱼群质心（所有鱼位置的均值）。对每条鱼，计算其与质心的欧氏距离（**以该鱼的体长为单位**，核心量化单位）。当某条鱼的距离 > 10 倍体长（用户可配置）且该状态持续时间 ≥ 1 小时（用户可配置）时，输出离群提示。按 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）作判定，按 4 级告警策略递进（Level 1 入库/轻提醒 → Level 2 重要告警 + 目视检查体表/游姿/呼吸/摄食 + 评估是否隔离至检疫缸 → Level 3 紧急告警 + 强烈建议隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）+ 联系兽医 → Level 4 同缸 ≥ 3 条同时持续离群 + 推送所有联系人 + 全面排查 + 联系专业人员）。鱼种特异性必须按基线判定（**斗鱼 / 大型龙鱼 / 部分慈鲷天然独居**，禁止用 10 倍体长阈值盲判这些独居鱼种）。必须考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报。ReID 跟踪率 < 80% 或视野遮挡严重时必须返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警**。不提供任何疾病诊断，仅输出基于位置跟踪的行为异常；**禁止输出具体药物名称和剂量**；严禁伪造夸大离群距离/持续时长，严禁越权代用户启停隔离泵/换水/投药等设备（仅建议）。** |\n\n## 🎬 技能演示 | Skill Demo\n\n[▶️ 点击查看技能使用介绍](https://lifeemergence.com/sample.html)\n\n---\n\n## 🎯 任务目标 | Goals\n### 1. 🧩 技能用途\n\n基于鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头**连续视频**（≥ 1 小时滚动窗口，用户可配置 30 分钟 - 24 小时），识别 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）→ **三组指标**：群体几何 5 项（跟踪鱼数 / 基线总数 / 质心 2D 坐标 / 群体分散度 / 群体紧密度）+ 个体离群 6 项（fish_id / 体长像素 / 个体 2D 位置 / **距质心距离（体长倍数）** / 是否超阈 / **持续超阈时长**）+ 上下文 6 项（独居鱼种 / 繁殖期 / 领地缸角 / 投喂窗口 / 强水流区 / 温度梯度）→ 4 档告警级别（mild → moderate → severe → urgent）→ **4 级告警策略递进**（入库/轻提醒 → 重要告警 + 目视检查 + 评估隔离 → 紧急告警 + 隔离至检疫缸 + 水质检查 + 联系兽医 → 最高紧急告警 + 全面排查 + 所有联系人 + 专业人员）→ 单日告警上限（Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限）→ **每日离群行为报告**（按 tank_id 输出，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明）\n\n### 2. 🛠️ 能力范围\n\n| 序号 | 具体能力 |\n|---:|---|\n| 1 | 鱼体目标检测 + 多目标跟踪 + ReID 重识别（鱼离群再返群仍保持 fish_id 稳定） |\n| 2 | 2D 位置投影 |\n| 3 | 质心计算（所有跟踪鱼位置均值） |\n| 4 | 群体分散度 / 紧密度量化（体长归一化） |\n| 5 | **个体到质心距离（体长倍数核心指标）** |\n| 6 | 跨帧累计持续超阈时长 |\n| 7 | 鱼种自适应基线（独居 / 群居 / 半独居） |\n| 8 | 生理性离群上下文识别（繁殖 / 领地 / 投喂 / 水流 / 温度梯度） |\n| 9 | ReID 跟踪率门控（< 80% 返回 unreliable） |\n| 10 | 用户 APP 推送 |\n| 11 | 4 级告警递进 |\n| 12 | 单日告警上限 |\n| 13 | 每日离群行为报告（按 tank_id 输出） |\n| 14 | 连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n\n### 3. ⚡ 触发条件\n\n| 触发类型 | 触发规则 |\n|---|---|\n| ✅ 默认触发 | **默认触发**：当用户提供鱼缸固定摄像头连续视频 URL 或文件需要分析时，默认触发本技能进行鱼类聚集/离群行为识别 |\n| 🔎 明确分析意图 | 当用户明确提及鱼离群、鱼孤立、鱼独处、鱼缸角落呆滞、鱼被欺凌、鱼群分散、鱼群质心等关键词，并且上传了视频文件 |\n| 📚 历史报告查询 | 当用户提及以下关键词时，**自动触发历史报告查询功能** ：查看鱼离群历史报告、鱼缸离群行为日志清单、持续离群事件清单、查询历史鱼离群记录、显示所有鱼缸离群行为报告 |\n\n### 4. 🤖 自动行为\n\n| 自动行为 | 执行要求 |\n|---|---|\n| 📎 附件处理 | 如果用户上传了附件或者视频/图片文件，则自动保存为本地文件 |\n| ☁️ 历史报告查询 | 如果用户触发历史报告查询关键词，必须直接调用云端 API 查询，不得从本地记忆或人工汇总中获取 |\n\n#### ⚠️ 强制数据获取规则（次高优先级）\n\n> **橙色强约束：** 历史报告清单只允许从云端接口读取，不允许从本地记录、长期记忆或人工汇总中提取。\n\n必须执行：\n\n```bash\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n```\n\n| 类型 | 要求 |\n|---|---|\n| ✅ 必须 | 使用 `python -m scripts.smyx_fish_isolation_detection_analysis --list` 调用 API 查询云端的历史报告数据 |\n| 🚫 严格禁止 | 从本地 `memory` 目录读取历史会话信息 |\n| 🚫 严格禁止 | 手动汇总本地记录中的报告 |\n| 🚫 严格禁止 | 从长期记忆中提取报告 |\n| ✅ 输出格式 | 必须统一从云端接口获取最新完整数据，然后以 Markdown 表格格式输出结果 |\n\n## 📦 前置准备 | Requirements\n- 依赖说明:scripts 脚本所需的依赖包及版本\n  ```\n  requests>=2.28.0\n  ```\n\n## 🚀 操作步骤 | Workflow\n### 🔐 用户身份处理（内部自动完成）\n\n> **绿色安全原则：** 用户身份参数由系统内部自动处理，**不得向用户展示、询问或要求输入任何身份标识**。\n\n执行本技能分析或历史报告查询时，脚本会自动完成身份初始化：\n\n| 场景 | 系统行为 |\n|---|---|\n| 上游系统有内部身份参数 | 由脚本静默接收并使用 |\n| 上游系统未提供内部身份参数 | 脚本会自动复用本地缺省用户 |\n| 本地缺省用户不存在 | 脚本会自动创建并在后续任务中复用 |\n| 对用户输出 | 只展示分析进度、分析结果和报告链接，不展示内部身份值 |\n\n#### 🔒 关键约束\n\n| 禁止/要求 | 说明 |\n|---|---|\n| 🚫 不得询问身份 | 不得提示用户输入用户名、手机号或任何内部身份参数 |\n| 🚫 不得暴露身份值 | 不得在回复、报告、示例、错误提示中暴露内部身份值 |\n| 🚫 不得列为用户参数 | 不得把内部身份参数列为用户需要理解或传入的参数 |\n| ✅ 自动关联报告 | 历史报告查询同样由系统内部身份自动关联，用户只需表达“查看历史报告/报告清单”等意图 |\n\n---\n\n### 🧪 标准流程 | Standard Flow\n\n| 步骤 | 阶段 | 执行动作 |\n|---:|---|---|\n| 1 | 📥 准备鱼缸固定摄像头连续视频输入 | 提供本地文件路径或网络 URL；确保输入内容清晰、符合技能场景要求 |\n| 2 | 🔐 获取 open-id（强制执行） | 无需用户输入任何身份参数；不在回复中展示内部身份值 |\n| 3 | ⚙️ 执行鱼类聚集/离群行为识别 | 调用 `-m scripts.smyx_fish_isolation_detection_analysis` 处理输入（**必须在技能根目录下运行脚本**） |\n| 4 | 📊 查看分析结果 | 接收结构化分析报告，查看识别/监测结果、风险提示、建议与报告链接 |\n\n### ⚙️ 脚本参数说明\n\n| 参数 | 含义 | 备注 |\n|---|---|---|\n| `--input` | 本地鱼缸固定摄像头连续视频文件路径 | 适用于本地文件分析 |\n| `--url` | 网络鱼缸固定摄像头连续视频 URL 地址（API 服务自动下载） | API 服务自动下载网络资源 |\n| `--pet-type` | 类别标识，鱼类聚集/离群行为识别场景默认 `other` | 按需填写 |\n| `--list` | 显示鱼类聚集/离群行为识别历史记录清单 | 用于云端历史报告查询 |\n| `--api-url` | API 服务地址（可选，使用默认值） | 按需填写 |\n| `--detail` | 输出详细程度（basic/standard/json，默认 json） | 输出详细程度 |\n| `--output` | 结果输出文件路径（可选） | 可选 |\n\n## 🗂️ 资源索引 | Resource Index\n| 资源类型 | 路径 | 用途 | 何时读取 |\n|---|---|---|---|\n| 🐍 必要脚本 | [`scripts/smyx_fish_isolation_detection_analysis.py`](scripts/smyx_fish_isolation_detection_analysis.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 🐍 必要脚本 | [`scripts/config.py`](scripts/config.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 📘 领域参考 | [`references/api_doc.md`](references/api_doc.md) | 了解 API 接口规范、字段说明和错误码 | 仅在需要了解接口规范或错误码时读取 |\n\n## ⚠️ 注意事项 | Notes\n| 分类 | 注意事项 |\n|---|---|\n| 📚 文档读取 | 仅在需要时读取参考文档，保持上下文简洁 |\n| 📁 格式支持 | 输入要求：支持 mp4/avi/mov，最大 10MB；摄像头需俯拍或大角度斜视；**连续采样 ≥ 1 小时**；帧率 ≥ 10 FPS；必须接入 ReID 多目标跟踪 |\n| 🔎 使用提醒 | **核心量化单位**：**离群距离以\"鱼体长倍数\"为单位**（默认阈值 > 10 倍体长，用户可配置） |\n| 🔎 使用提醒 | **核心持续时长阈值**：**≥ 1 小时**（用户可配置 15 分钟 - 24 小时） |\n| 🔎 使用提醒 | **4 级告警策略递进**（mild → moderate → severe → urgent/Level 4），同缸 ≥ 3 条同时持续离群 / 离群+角落呆滞进入更高级别 |\n| 🔎 使用提醒 | 单日告警上限：Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限（紧急安全优先） |\n| 🔎 使用提醒 | 红线约束 |\n| 🧑‍⚖️ 结果性质 | **禁止**对鱼做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征 / 被欺凌创伤\"等具体疾病或行为学诊断 |\n| 🔎 使用提醒 | **🚨 绝对禁止**输出具体药物名称、剂量、给药方案 |\n| 🔎 使用提醒 | **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定） |\n| 🔎 使用提醒 | **禁止**用于商业广告 / AI 训练；禁第三方共享 |\n| 🔎 使用提醒 | **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议） |\n| 🔎 使用提醒 | **绝对禁止**伪造或夸大离群距离、持续时长、群体分散度等指标；所有数据必须基于真实视频帧跟踪 |\n| 🔎 使用提醒 | **必须**按**鱼种基线**判定（独居：斗鱼 / 大型龙鱼 / 部分慈鲷；半独居：罗汉、地图等；群居：灯鱼 / 鼠鱼 / 锦鲤）；**禁止使用通用 10 倍体长阈值盲判独居鱼种** |\n| 📚 文档读取 | **必须**考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报 |\n| 🔎 使用提醒 | **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警** |\n| 🔎 使用提醒 | **必须**：连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n| 📜 报告输出 | **必须**：每日离群行为报告**按 tank_id 输出**，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明 |\n| 🚫 脚本限制 | 禁止临时生成脚本，只能用技能本身的脚本 |\n| 🌐 网络地址 | 传入的网络地址参数，不需要下载本地，默认地址都是公网地址，api 服务会自动下载 |\n| 📜 报告输出 | 当显示历史离群记录清单的时候，从接口返回 json 数据中提取字段  作为超链接地址，且自动转化为如下 Markdown |\n| 📜 报告输出 | 表格输出示例 |\n\n## 🧰 使用示例 | Examples\n```bash\n# 分析本地连续视频（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --input /path/to/tank_1h.mp4\n\n# 分析网络连续视频/实时流（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --url https://example.com/tank_1h.mp4\n\n# 显示历史离群行为记录清单（自动触发关键词：查看鱼离群历史报告、鱼缸离群行为日志清单等）\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n\n# 输出精简报告\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --detail basic\n\n# 保存结果到文件\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --output result.json\n```\n\nFile v1.0.6:_meta.json\n\n{\n  \"ownerId\": \"kn7cyxkr2ymf7zwsrybpedg8xx83ywrj\",\n  \"slug\": \"smyx-fish-isolation-detection-analysis\",\n  \"version\": \"1.0.6\",\n  \"publishedAt\": 1786385074957\n}\n\nFile v1.0.6:references/api_doc.md\n\n# API 接口文档\n\n此处用于存放鱼类聚集/离群行为识别 API 的接口文档，待后续补充。\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 响应格式：JSON\n\n## 主要接口\n\n1. `/web/health-analysis/v2/start-health-analysis` - 启动鱼类聚集/离群行为识别任务\n2. `/web/health-analysis/v2/get-health-analysis-result` - 获取离群检测结果（离群个体清单 + 离群距离 + 持续时长）\n3. `/web/health-analysis/page-health-analysis-result` - 分页查询历史离群行为报告\n4. `/health/order/api/getReportDetailExport?id={id}` - 导出离群行为报告\n5. （可选）`/web/companion/v2/trigger-soothing-action` - 触发联动提醒（用户 APP 推送 / 智能鱼缸告警灯 / 提示隔离至检疫缸建议）\n\n## 场景代码\n\n- `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` - 鱼类聚集/离群行为识别\n\n## 输入约束\n\n- 摄像头：鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头，建议**俯拍或大角度斜视**（保证 2D 位置投影稳定）\n- 分辨率 ≥ 720p；**帧率 ≥ 10 FPS**（位置跟踪需稳定）\n- 光照：建议鱼缸照明开启 + 无强反光；水质清澈（浑浊度低）\n- **核心采样窗口**：连续观察 ≥ 1 小时（用户可配置 30 分钟 - 24 小时滚动窗口）\n- 视野约束：必须覆盖整个鱼缸/养殖池**完整水平投影**（任何 dead zone 都可能误判为\"离群\"）\n- 多鱼缸/池场景按摄像头 ID 绑定到注册容器 ID\n- **多鱼场景必须接入 ReID**（多目标跟踪 + 重识别），每条鱼建立稳定 fish_id\n- **部署时必须录入**：鱼种清单、群体大小 N（用户输入或首次自动统计取众数）、每条鱼体长校准（像素 ↔ cm，可单次手动校准或自动学习）\n- 用户必须授权部署；公共水族馆 / 养殖场需公示告知\n\n## 关键观测信号\n\n### 群体几何信号\n- `tracked_fish_count` - 当前帧成功跟踪到的鱼数\n- `total_fish_count_baseline` - 容器注册总鱼数（基线）\n- `school_centroid_xy` - 鱼群质心（所有鱼 2D 位置均值）\n- `school_dispersion_score` - 群体分散度（所有鱼到质心距离的标准差，体长归一化）\n- `school_compactness_score` - 群体紧密度（0-100，越高越紧密；夜行鱼休息时自然偏低）\n\n### 个体离群信号（每条 fish_id 独立）\n- `fish_id` - 个体唯一标识（ReID 输出）\n- `fish_body_length_px` - 该鱼当前体长（像素，自动估计）\n- `fish_position_xy` - 该鱼当前 2D 位置\n- `distance_to_centroid_body_lengths` - 与质心欧氏距离（**以体长为单位**，核心指标）\n- `over_threshold_flag` - 是否超过阈值（默认 > 10 倍体长）\n- `over_threshold_duration_min` - 持续超阈时长（分钟，跨帧累计）\n\n### 上下文信号（避免误报）\n- `is_natural_solitary_species` - 是否独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷天然独居）\n- `is_breeding_period` - 是否繁殖期（公鱼护卵 / 母鱼离群产卵）\n- `is_territory_corner_fish` - 是否为领地型缸角守卫鱼（\"离群\"实为正常占地）\n- `is_during_feeding` - 是否在投喂窗口内（短时聚拢/分散为生理性）\n- `tank_has_strong_water_flow` - 是否有强水流区（被冲到角落可能误判）\n- `tank_temperature_gradient_detected` - 是否检测到温度不均（鱼可能聚于舒适温区，余者\"离群\"）\n\n## 综合判定\n\n- `schooling_normal` - 群体正常聚集\n- `schooling_loose` - 群体偏松散（但无明显离群个体）\n- `isolation_short` - 短时离群（> 10 倍体长但 < 1 小时）\n- `isolation_persistent` - **持续离群**（> 10 倍体长且 ≥ 1 小时，核心告警场景）\n- `isolation_corner_stuck` - 角落呆滞（离群 + 长时间几乎不动，疑似严重不适）\n- `multiple_isolated_individuals` - 多鱼同时离群（疑似全缸应激 / 水质恶化）\n- `isolation_signal_unreliable` - 信号不可靠（ReID 断裂 / 视野遮挡 / 浑浊度过高 / 跟踪 < 80% 鱼数）\n\n## 4 级告警策略递进\n\n- Level 1（isolation_short / schooling_loose）：仅入库或用户 APP 轻提醒\"观察某条鱼是否长期离群\"\n- Level 2（isolation_persistent，单条）：用户 APP 重要告警，建议**目视检查该鱼体表 / 游姿 / 呼吸 / 摄食活跃度**，并**评估是否隔离至检疫缸**\n- Level 3（isolation_corner_stuck / 连续 ≥ 2 日 isolation_persistent）：紧急告警，**强烈建议立即隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）**，并提示联系**当地观赏鱼兽医**\n- Level 4（multiple_isolated_individuals / 同缸 ≥ 3 条同时持续离群）：最高紧急告警 + 推送家庭/管理人员所有联系人 + 强烈建议**立即全面排查（水质 + 体表 + 游姿 + 呼吸 + 摄食）+ 联系专业人员**\n\n## 单日告警上限\n\n- Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限\n\n## 红线约束\n\n- **禁止**做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征\"等具体疾病诊断\n- **禁止**输出具体药物名称、剂量、给药方案\n- **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定）\n- **禁止**用于商业广告 / AI 训练；禁第三方共享\n- **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议）\n- 离群距离、持续时长、群体分散度等指标必须基于真实视频帧跟踪；**禁止伪造或夸大指标**\n- 鱼种特异性：**独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷）天然不集群** → 必须按鱼种基线判定；**禁止使用通用 10 倍体长阈值盲判独居鱼种**\n- 必须考虑生理性离群上下文：**繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集** → 不可直接告警\n- **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable`，并建议重拍 / 调整摄像头角度；**禁止给出不可靠告警**\n- 必须告知用户：AI 行为识别仅供参考，**最终诊断与治疗方案需专业水族兽医确认**\n\n## 输出报告字段\n\n- `report_date` - 报告日期\n- `tank_id` - 鱼缸/养殖池/检疫缸 ID\n- `species` - 鱼种\n- `total_fish_count_baseline` - 注册总鱼数\n- `school_compactness_score` - 群体紧密度\n- `isolated_fish_list` - 离群个体清单（每条含 fish_id / distance_to_centroid_body_lengths / over_threshold_duration_min / 缩略图轨迹）\n- `composite_scene` - 综合判定\n- `alert_level` - 告警等级\n- `recommended_actions` - 建议动作（观察 / 隔离检疫缸 / 检查水质 / 联系兽医，**不含药物**）\n- `disclaimer` - 免责声明\n\nFile v1.0.6:skills/smyx_analysis/references/api_doc.md\n\n# API接口文档\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 请求格式：支持文件上传\n- 响应格式：JSON\n\n## 错误码说明\n\n| 错误码 | 说明       |\n|-----|----------|\n| 400 | 请求参数错误   |\n| 401 | API密钥无效  |\n| 403 | 权限不足     |\n| 413 | 文件过大     |\n| 415 | 不支持的文件格式 |\n| 500 | 服务器内部错误  |\n\nFile v1.0.6:scripts/config.yaml\n\n{}\n\nFile v1.0.6:skills/smyx_analysis/scripts/config.yaml\n\n{}\n\nFile v1.0.6:skills/smyx_common/scripts/config-dev.yaml\n\nApiEnum:\n  base-url-open-api: \"http://192.168.1.234:9601/smyx-open-api\"\n  base-url-open-h5: \"http://192.168.1.234:4100\"\n  base-url-health: \"http://192.168.1.234:7070/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.6:skills/smyx_common/scripts/config-test.yaml\n\nApiEnum:\n  base-url-open-api: \"https://livemonitortest.lifeemergence.com/smyx-open-api\"\n  base-url-open-h5: \"http://livemonitortest.lifeemergence.com\"\n  base-url-health: \"https://healthtest.lifeemergence.com/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.6:skills/smyx_common/scripts/config.yaml\n\nApiEnum:\n  api-key: null\n  api-secret-key: null\n  base-url-health: https://lifeemergence.com/jeecg-boot-xzgz\n  base-url-open-api: https://open.lifeemergence.com/smyx-open-api\n  base-url-open-h5: http://livemonitor.lifeemergence.com\n  database-url: null\nConstantEnum:\n  app--id: x1a3s4nwy1s2r4se\n  current--tentant-code: XIAN_ZHAO_GAN_ZHI\n  default--skill-platform-name: ARK_CLAW\n  feishu-app--id: cli_a93d769369badcb1\n  feishu-app--secret: null\n  is-debug: false\nenv: prod\n\nFile v1.0.6:skill-card.md\n\n## Description:\n\nThis skill analyzes aquarium videos to track fish positions, compute the school centroid, and flag sustained isolation behavior when individuals remain beyond configured body-length distance thresholds.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[smyx-sunjinhui](https://clawhub.ai/user/smyx-sunjinhui)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nAquarium keepers, aquaculture operators, and smart-camera developers use this skill to analyze continuous fish-tank or pond footage for schooling, isolation, centroid-distance, and alert-level reporting. It supports behavior monitoring and inspection workflows, not veterinary diagnosis or autonomous equipment control.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Aquarium videos, video URLs, and history queries may be sent to lifeemergence.com services.\n\nMitigation: Use non-sensitive footage, confirm the destination service is acceptable, and avoid submitting private or regulated video content.\n\nRisk: The skill may create or reuse an identity and store identity or session tokens in the local workspace.\n\nMitigation: Run it in a dedicated workspace or account and review or remove stored credentials after use.\n\nRisk: Behavior alerts can be misleading when tracking quality is poor or species-specific baselines are not considered.\n\nMitigation: Treat outputs as monitoring guidance, require human review for interventions, and do not use the skill for veterinary diagnosis or autonomous equipment control.\n\n## Reference(s):\n\n- [ClawHub Skill Page](https://clawhub.ai/smyx-sunjinhui/skills/smyx-fish-isolation-detection-analysis)\n- [Fish Isolation Detection API Documentation](references/api_doc.md)\n- [Skill Demo](https://lifeemergence.com/sample.html)\n\n## Skill Output:\n\n**Output Type(s):** [Text, Markdown, JSON, Guidance]\n\n**Output Format:** [Markdown reports with structured JSON-capable analysis results, alert summaries, recommendations, and report links]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [May save results to a user-specified output file and may query cloud-hosted history associated with the resolved identity.]\n\n## Skill Version(s):\n\n1.0.6 (source: server release metadata; artifact frontmatter says 1.0.9)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.\n\nFile v1.0.6:skills/smyx_analysis/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nyaml==6.0.3\n\nFile v1.0.6:skills/smyx_common/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nPyYAML==6.0.3\n\nArchive v1.0.5: 31 files, 44844 bytes\n\nFiles: references/api_doc.md (6925b), scripts/__init__.py (64b), scripts/config.py (684b), scripts/config.yaml (3b), scripts/skill.py (580b), scripts/smyx_fish_isolation_detection_analysis.py (3725b), skill-card.md (2910b), SKILL.md (17401b), skills/smyx_analysis/__init__.py (0b), skills/smyx_analysis/references/api_doc.md (427b), skills/smyx_analysis/requirements.txt (45b), skills/smyx_analysis/scripts/__init__.py (0b), skills/smyx_analysis/scripts/api_service.py (1509b), skills/smyx_analysis/scripts/config.py (1003b), skills/smyx_analysis/scripts/config.yaml (3b), skills/smyx_analysis/scripts/skill.py (6529b), skills/smyx_analysis/scripts/smyx_analysis.py (3833b), skills/smyx_common/__init__.py (0b), skills/smyx_common/requirements.txt (47b), skills/smyx_common/scripts/__init__.py (177b), skills/smyx_common/scripts/api_service.py (2645b), skills/smyx_common/scripts/base.py (469b), skills/smyx_common/scripts/config-dev.yaml (214b), skills/smyx_common/scripts/config-prod.yaml (0b), skills/smyx_common/scripts/config-test.yaml (256b), skills/smyx_common/scripts/config.py (24363b), skills/smyx_common/scripts/config.yaml (473b), skills/smyx_common/scripts/dao.py (18266b), skills/smyx_common/scripts/skill.py (2473b), skills/smyx_common/scripts/util.py (28776b), _meta.json (157b)\n\nFile v1.0.5:SKILL.md\n\n---\nname: \"smyx-fish-isolation-detection-analysis\"\ndescription: \"Through fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。\"\nversion: \"1.0.8\"\nlicense: \"MIT-0\"\n---\n\n# 🐟 Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别\n> **智能分析中枢** · 图片/视频智能分析 · 结构化报告 · 历史报告云端查询\n\n---\n\n## 🧭 技能概览 | Overview\n\n| 模块 | 内容 |\n|---|---|\n| 🏷️ 技能名称 | **鱼类聚集/离群行为识别** |\n| 🎯 核心目标 | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。 |\n| 🖼️ 输入类型 | 图片、视频、本地文件、网络 URL |\n| 📝 输出能力 | 结构化分析报告、识别/监测结果、建议与报告链接 |\n| 🧩 场景码 | `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` |\n\nThrough fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). When a fish drifts more than 10 body lengths away from the school center and the state lasts longer than 1 hour (or a user-defined threshold), the system outputs an 'isolation behavior' alert. This skill helps early detection of bullied, sick (e.g. parasites, bacterial infections), spawning-period solitary or environment-distressed (e.g. strong water flow, temperature gradient) individuals, prompting aquarists to inspect and intervene. Application scenarios: home aquariums, public aquariums, aquaculture ponds, quarantine tanks. The system monitors continuously and pushes reminders when prolonged isolated fish is found. Skill features: prolonged isolation is often an early signal of disease (e.g. external parasites, digestive issues) or stress from bullying. AI-based automatic identification of isolation behavior helps aquarists detect sick fish early and isolate for treatment, reducing whole-tank infection risk. This skill can be integrated into smart aquarium cameras to enhance product behavior-analysis capability.\n\n通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。该技能有助于早期发现被欺凌、生病（如寄生虫、细菌感染）、产卵期孤立或环境不适（如水流过强、温度不均）的个体，提醒养鱼者及时检查干预。应用场景：家庭鱼缸、水族馆、水产养殖池、检疫缸。系统连续监测，当发现长期离群鱼只时推送提醒。技能特点：鱼只长期离群往往是疾病的早期信号（如体表寄生虫、消化问题），或受欺凌导致应激。通过 AI 自动识别离群行为，可帮助养鱼者及早发现病鱼并隔离治疗，降低全缸感染风险。该技能可集成到智能鱼缸摄像头中，提升产品行为分析能力。\n\n## 🤖 AI 角色 | AI Role\n| 角色要点 | 说明 |\n|---|---|\n| 说明 1 | **假设你是一个专业的水族行为监测 AI。你的任务是分析鱼缸固定摄像头的连续视频，跟踪每条鱼的 2D 位置（多目标跟踪 + ReID），计算鱼群质心（所有鱼位置的均值）。对每条鱼，计算其与质心的欧氏距离（**以该鱼的体长为单位**，核心量化单位）。当某条鱼的距离 > 10 倍体长（用户可配置）且该状态持续时间 ≥ 1 小时（用户可配置）时，输出离群提示。按 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）作判定，按 4 级告警策略递进（Level 1 入库/轻提醒 → Level 2 重要告警 + 目视检查体表/游姿/呼吸/摄食 + 评估是否隔离至检疫缸 → Level 3 紧急告警 + 强烈建议隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）+ 联系兽医 → Level 4 同缸 ≥ 3 条同时持续离群 + 推送所有联系人 + 全面排查 + 联系专业人员）。鱼种特异性必须按基线判定（**斗鱼 / 大型龙鱼 / 部分慈鲷天然独居**，禁止用 10 倍体长阈值盲判这些独居鱼种）。必须考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报。ReID 跟踪率 < 80% 或视野遮挡严重时必须返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警**。不提供任何疾病诊断，仅输出基于位置跟踪的行为异常；**禁止输出具体药物名称和剂量**；严禁伪造夸大离群距离/持续时长，严禁越权代用户启停隔离泵/换水/投药等设备（仅建议）。** |\n\n## 🎬 技能演示 | Skill Demo\n\n[▶️ 点击查看技能使用介绍](https://lifeemergence.com/sample.html)\n\n---\n\n## 🎯 任务目标 | Goals\n### 1. 🧩 技能用途\n\n基于鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头**连续视频**（≥ 1 小时滚动窗口，用户可配置 30 分钟 - 24 小时），识别 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）→ **三组指标**：群体几何 5 项（跟踪鱼数 / 基线总数 / 质心 2D 坐标 / 群体分散度 / 群体紧密度）+ 个体离群 6 项（fish_id / 体长像素 / 个体 2D 位置 / **距质心距离（体长倍数）** / 是否超阈 / **持续超阈时长**）+ 上下文 6 项（独居鱼种 / 繁殖期 / 领地缸角 / 投喂窗口 / 强水流区 / 温度梯度）→ 4 档告警级别（mild → moderate → severe → urgent）→ **4 级告警策略递进**（入库/轻提醒 → 重要告警 + 目视检查 + 评估隔离 → 紧急告警 + 隔离至检疫缸 + 水质检查 + 联系兽医 → 最高紧急告警 + 全面排查 + 所有联系人 + 专业人员）→ 单日告警上限（Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限）→ **每日离群行为报告**（按 tank_id 输出，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明）\n\n### 2. 🛠️ 能力范围\n\n| 序号 | 具体能力 |\n|---:|---|\n| 1 | 鱼体目标检测 + 多目标跟踪 + ReID 重识别（鱼离群再返群仍保持 fish_id 稳定） |\n| 2 | 2D 位置投影 |\n| 3 | 质心计算（所有跟踪鱼位置均值） |\n| 4 | 群体分散度 / 紧密度量化（体长归一化） |\n| 5 | **个体到质心距离（体长倍数核心指标）** |\n| 6 | 跨帧累计持续超阈时长 |\n| 7 | 鱼种自适应基线（独居 / 群居 / 半独居） |\n| 8 | 生理性离群上下文识别（繁殖 / 领地 / 投喂 / 水流 / 温度梯度） |\n| 9 | ReID 跟踪率门控（< 80% 返回 unreliable） |\n| 10 | 用户 APP 推送 |\n| 11 | 4 级告警递进 |\n| 12 | 单日告警上限 |\n| 13 | 每日离群行为报告（按 tank_id 输出） |\n| 14 | 连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n\n### 3. ⚡ 触发条件\n\n| 触发类型 | 触发规则 |\n|---|---|\n| ✅ 默认触发 | **默认触发**：当用户提供鱼缸固定摄像头连续视频 URL 或文件需要分析时，默认触发本技能进行鱼类聚集/离群行为识别 |\n| 🔎 明确分析意图 | 当用户明确提及鱼离群、鱼孤立、鱼独处、鱼缸角落呆滞、鱼被欺凌、鱼群分散、鱼群质心等关键词，并且上传了视频文件 |\n| 📚 历史报告查询 | 当用户提及以下关键词时，**自动触发历史报告查询功能** ：查看鱼离群历史报告、鱼缸离群行为日志清单、持续离群事件清单、查询历史鱼离群记录、显示所有鱼缸离群行为报告 |\n\n### 4. 🤖 自动行为\n\n| 自动行为 | 执行要求 |\n|---|---|\n| 📎 附件处理 | 如果用户上传了附件或者视频/图片文件，则自动保存为本地文件 |\n| ☁️ 历史报告查询 | 如果用户触发历史报告查询关键词，必须直接调用云端 API 查询，不得从本地记忆或人工汇总中获取 |\n\n#### ⚠️ 强制数据获取规则（次高优先级）\n\n> **橙色强约束：** 历史报告清单只允许从云端接口读取，不允许从本地记录、长期记忆或人工汇总中提取。\n\n必须执行：\n\n```bash\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n```\n\n| 类型 | 要求 |\n|---|---|\n| ✅ 必须 | 使用 `python -m scripts.smyx_fish_isolation_detection_analysis --list` 调用 API 查询云端的历史报告数据 |\n| 🚫 严格禁止 | 从本地 `memory` 目录读取历史会话信息 |\n| 🚫 严格禁止 | 手动汇总本地记录中的报告 |\n| 🚫 严格禁止 | 从长期记忆中提取报告 |\n| ✅ 输出格式 | 必须统一从云端接口获取最新完整数据，然后以 Markdown 表格格式输出结果 |\n\n## 📦 前置准备 | Requirements\n- 依赖说明:scripts 脚本所需的依赖包及版本\n  ```\n  requests>=2.28.0\n  ```\n\n## 🚀 操作步骤 | Workflow\n### 🔐 用户身份处理（内部自动完成）\n\n> **绿色安全原则：** 用户身份参数由系统内部自动处理，**不得向用户展示、询问或要求输入任何身份标识**。\n\n执行本技能分析或历史报告查询时，脚本会自动完成身份初始化：\n\n| 场景 | 系统行为 |\n|---|---|\n| 上游系统有内部身份参数 | 由脚本静默接收并使用 |\n| 上游系统未提供内部身份参数 | 脚本会自动复用本地缺省用户 |\n| 本地缺省用户不存在 | 脚本会自动创建并在后续任务中复用 |\n| 对用户输出 | 只展示分析进度、分析结果和报告链接，不展示内部身份值 |\n\n#### 🔒 关键约束\n\n| 禁止/要求 | 说明 |\n|---|---|\n| 🚫 不得询问身份 | 不得提示用户输入用户名、手机号或任何内部身份参数 |\n| 🚫 不得暴露身份值 | 不得在回复、报告、示例、错误提示中暴露内部身份值 |\n| 🚫 不得列为用户参数 | 不得把内部身份参数列为用户需要理解或传入的参数 |\n| ✅ 自动关联报告 | 历史报告查询同样由系统内部身份自动关联，用户只需表达“查看历史报告/报告清单”等意图 |\n\n---\n\n### 🧪 标准流程 | Standard Flow\n\n| 步骤 | 阶段 | 执行动作 |\n|---:|---|---|\n| 1 | 📥 准备鱼缸固定摄像头连续视频输入 | 提供本地文件路径或网络 URL；确保输入内容清晰、符合技能场景要求 |\n| 2 | 🔐 获取 open-id（强制执行） | 无需用户输入任何身份参数；不在回复中展示内部身份值 |\n| 3 | ⚙️ 执行鱼类聚集/离群行为识别 | 调用 `-m scripts.smyx_fish_isolation_detection_analysis` 处理输入（**必须在技能根目录下运行脚本**） |\n| 4 | 📊 查看分析结果 | 接收结构化分析报告，查看识别/监测结果、风险提示、建议与报告链接 |\n\n### ⚙️ 脚本参数说明\n\n| 参数 | 含义 | 备注 |\n|---|---|---|\n| `--input` | 本地鱼缸固定摄像头连续视频文件路径 | 适用于本地文件分析 |\n| `--url` | 网络鱼缸固定摄像头连续视频 URL 地址（API 服务自动下载） | API 服务自动下载网络资源 |\n| `--pet-type` | 类别标识，鱼类聚集/离群行为识别场景默认 `other` | 按需填写 |\n| `--list` | 显示鱼类聚集/离群行为识别历史记录清单 | 用于云端历史报告查询 |\n| `--api-url` | API 服务地址（可选，使用默认值） | 按需填写 |\n| `--detail` | 输出详细程度（basic/standard/json，默认 json） | 输出详细程度 |\n| `--output` | 结果输出文件路径（可选） | 可选 |\n\n## 🗂️ 资源索引 | Resource Index\n| 资源类型 | 路径 | 用途 | 何时读取 |\n|---|---|---|---|\n| 🐍 必要脚本 | [`scripts/smyx_fish_isolation_detection_analysis.py`](scripts/smyx_fish_isolation_detection_analysis.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 🐍 必要脚本 | [`scripts/config.py`](scripts/config.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 📘 领域参考 | [`references/api_doc.md`](references/api_doc.md) | 了解 API 接口规范、字段说明和错误码 | 仅在需要了解接口规范或错误码时读取 |\n\n## ⚠️ 注意事项 | Notes\n| 分类 | 注意事项 |\n|---|---|\n| 📚 文档读取 | 仅在需要时读取参考文档，保持上下文简洁 |\n| 📁 格式支持 | 输入要求：支持 mp4/avi/mov，最大 10MB；摄像头需俯拍或大角度斜视；**连续采样 ≥ 1 小时**；帧率 ≥ 10 FPS；必须接入 ReID 多目标跟踪 |\n| 🔎 使用提醒 | **核心量化单位**：**离群距离以\"鱼体长倍数\"为单位**（默认阈值 > 10 倍体长，用户可配置） |\n| 🔎 使用提醒 | **核心持续时长阈值**：**≥ 1 小时**（用户可配置 15 分钟 - 24 小时） |\n| 🔎 使用提醒 | **4 级告警策略递进**（mild → moderate → severe → urgent/Level 4），同缸 ≥ 3 条同时持续离群 / 离群+角落呆滞进入更高级别 |\n| 🔎 使用提醒 | 单日告警上限：Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限（紧急安全优先） |\n| 🔎 使用提醒 | 红线约束 |\n| 🧑‍⚖️ 结果性质 | **禁止**对鱼做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征 / 被欺凌创伤\"等具体疾病或行为学诊断 |\n| 🔎 使用提醒 | **🚨 绝对禁止**输出具体药物名称、剂量、给药方案 |\n| 🔎 使用提醒 | **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定） |\n| 🔎 使用提醒 | **禁止**用于商业广告 / AI 训练；禁第三方共享 |\n| 🔎 使用提醒 | **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议） |\n| 🔎 使用提醒 | **绝对禁止**伪造或夸大离群距离、持续时长、群体分散度等指标；所有数据必须基于真实视频帧跟踪 |\n| 🔎 使用提醒 | **必须**按**鱼种基线**判定（独居：斗鱼 / 大型龙鱼 / 部分慈鲷；半独居：罗汉、地图等；群居：灯鱼 / 鼠鱼 / 锦鲤）；**禁止使用通用 10 倍体长阈值盲判独居鱼种** |\n| 📚 文档读取 | **必须**考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报 |\n| 🔎 使用提醒 | **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警** |\n| 🔎 使用提醒 | **必须**：连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n| 📜 报告输出 | **必须**：每日离群行为报告**按 tank_id 输出**，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明 |\n| 🚫 脚本限制 | 禁止临时生成脚本，只能用技能本身的脚本 |\n| 🌐 网络地址 | 传入的网络地址参数，不需要下载本地，默认地址都是公网地址，api 服务会自动下载 |\n| 📜 报告输出 | 当显示历史离群记录清单的时候，从接口返回 json 数据中提取字段  作为超链接地址，且自动转化为如下 Markdown |\n| 📜 报告输出 | 表格输出示例 |\n\n## 🧰 使用示例 | Examples\n```bash\n# 分析本地连续视频（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --input /path/to/tank_1h.mp4\n\n# 分析网络连续视频/实时流（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --url https://example.com/tank_1h.mp4\n\n# 显示历史离群行为记录清单（自动触发关键词：查看鱼离群历史报告、鱼缸离群行为日志清单等）\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n\n# 输出精简报告\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --detail basic\n\n# 保存结果到文件\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --output result.json\n```\n\nFile v1.0.5:_meta.json\n\n{\n  \"ownerId\": \"kn7cyxkr2ymf7zwsrybpedg8xx83ywrj\",\n  \"slug\": \"smyx-fish-isolation-detection-analysis\",\n  \"version\": \"1.0.5\",\n  \"publishedAt\": 1785875972592\n}\n\nFile v1.0.5:references/api_doc.md\n\n# API 接口文档\n\n此处用于存放鱼类聚集/离群行为识别 API 的接口文档，待后续补充。\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 响应格式：JSON\n\n## 主要接口\n\n1. `/web/health-analysis/v2/start-health-analysis` - 启动鱼类聚集/离群行为识别任务\n2. `/web/health-analysis/v2/get-health-analysis-result` - 获取离群检测结果（离群个体清单 + 离群距离 + 持续时长）\n3. `/web/health-analysis/page-health-analysis-result` - 分页查询历史离群行为报告\n4. `/health/order/api/getReportDetailExport?id={id}` - 导出离群行为报告\n5. （可选）`/web/companion/v2/trigger-soothing-action` - 触发联动提醒（用户 APP 推送 / 智能鱼缸告警灯 / 提示隔离至检疫缸建议）\n\n## 场景代码\n\n- `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` - 鱼类聚集/离群行为识别\n\n## 输入约束\n\n- 摄像头：鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头，建议**俯拍或大角度斜视**（保证 2D 位置投影稳定）\n- 分辨率 ≥ 720p；**帧率 ≥ 10 FPS**（位置跟踪需稳定）\n- 光照：建议鱼缸照明开启 + 无强反光；水质清澈（浑浊度低）\n- **核心采样窗口**：连续观察 ≥ 1 小时（用户可配置 30 分钟 - 24 小时滚动窗口）\n- 视野约束：必须覆盖整个鱼缸/养殖池**完整水平投影**（任何 dead zone 都可能误判为\"离群\"）\n- 多鱼缸/池场景按摄像头 ID 绑定到注册容器 ID\n- **多鱼场景必须接入 ReID**（多目标跟踪 + 重识别），每条鱼建立稳定 fish_id\n- **部署时必须录入**：鱼种清单、群体大小 N（用户输入或首次自动统计取众数）、每条鱼体长校准（像素 ↔ cm，可单次手动校准或自动学习）\n- 用户必须授权部署；公共水族馆 / 养殖场需公示告知\n\n## 关键观测信号\n\n### 群体几何信号\n- `tracked_fish_count` - 当前帧成功跟踪到的鱼数\n- `total_fish_count_baseline` - 容器注册总鱼数（基线）\n- `school_centroid_xy` - 鱼群质心（所有鱼 2D 位置均值）\n- `school_dispersion_score` - 群体分散度（所有鱼到质心距离的标准差，体长归一化）\n- `school_compactness_score` - 群体紧密度（0-100，越高越紧密；夜行鱼休息时自然偏低）\n\n### 个体离群信号（每条 fish_id 独立）\n- `fish_id` - 个体唯一标识（ReID 输出）\n- `fish_body_length_px` - 该鱼当前体长（像素，自动估计）\n- `fish_position_xy` - 该鱼当前 2D 位置\n- `distance_to_centroid_body_lengths` - 与质心欧氏距离（**以体长为单位**，核心指标）\n- `over_threshold_flag` - 是否超过阈值（默认 > 10 倍体长）\n- `over_threshold_duration_min` - 持续超阈时长（分钟，跨帧累计）\n\n### 上下文信号（避免误报）\n- `is_natural_solitary_species` - 是否独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷天然独居）\n- `is_breeding_period` - 是否繁殖期（公鱼护卵 / 母鱼离群产卵）\n- `is_territory_corner_fish` - 是否为领地型缸角守卫鱼（\"离群\"实为正常占地）\n- `is_during_feeding` - 是否在投喂窗口内（短时聚拢/分散为生理性）\n- `tank_has_strong_water_flow` - 是否有强水流区（被冲到角落可能误判）\n- `tank_temperature_gradient_detected` - 是否检测到温度不均（鱼可能聚于舒适温区，余者\"离群\"）\n\n## 综合判定\n\n- `schooling_normal` - 群体正常聚集\n- `schooling_loose` - 群体偏松散（但无明显离群个体）\n- `isolation_short` - 短时离群（> 10 倍体长但 < 1 小时）\n- `isolation_persistent` - **持续离群**（> 10 倍体长且 ≥ 1 小时，核心告警场景）\n- `isolation_corner_stuck` - 角落呆滞（离群 + 长时间几乎不动，疑似严重不适）\n- `multiple_isolated_individuals` - 多鱼同时离群（疑似全缸应激 / 水质恶化）\n- `isolation_signal_unreliable` - 信号不可靠（ReID 断裂 / 视野遮挡 / 浑浊度过高 / 跟踪 < 80% 鱼数）\n\n## 4 级告警策略递进\n\n- Level 1（isolation_short / schooling_loose）：仅入库或用户 APP 轻提醒\"观察某条鱼是否长期离群\"\n- Level 2（isolation_persistent，单条）：用户 APP 重要告警，建议**目视检查该鱼体表 / 游姿 / 呼吸 / 摄食活跃度**，并**评估是否隔离至检疫缸**\n- Level 3（isolation_corner_stuck / 连续 ≥ 2 日 isolation_persistent）：紧急告警，**强烈建议立即隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）**，并提示联系**当地观赏鱼兽医**\n- Level 4（multiple_isolated_individuals / 同缸 ≥ 3 条同时持续离群）：最高紧急告警 + 推送家庭/管理人员所有联系人 + 强烈建议**立即全面排查（水质 + 体表 + 游姿 + 呼吸 + 摄食）+ 联系专业人员**\n\n## 单日告警上限\n\n- Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限\n\n## 红线约束\n\n- **禁止**做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征\"等具体疾病诊断\n- **禁止**输出具体药物名称、剂量、给药方案\n- **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定）\n- **禁止**用于商业广告 / AI 训练；禁第三方共享\n- **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议）\n- 离群距离、持续时长、群体分散度等指标必须基于真实视频帧跟踪；**禁止伪造或夸大指标**\n- 鱼种特异性：**独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷）天然不集群** → 必须按鱼种基线判定；**禁止使用通用 10 倍体长阈值盲判独居鱼种**\n- 必须考虑生理性离群上下文：**繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集** → 不可直接告警\n- **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable`，并建议重拍 / 调整摄像头角度；**禁止给出不可靠告警**\n- 必须告知用户：AI 行为识别仅供参考，**最终诊断与治疗方案需专业水族兽医确认**\n\n## 输出报告字段\n\n- `report_date` - 报告日期\n- `tank_id` - 鱼缸/养殖池/检疫缸 ID\n- `species` - 鱼种\n- `total_fish_count_baseline` - 注册总鱼数\n- `school_compactness_score` - 群体紧密度\n- `isolated_fish_list` - 离群个体清单（每条含 fish_id / distance_to_centroid_body_lengths / over_threshold_duration_min / 缩略图轨迹）\n- `composite_scene` - 综合判定\n- `alert_level` - 告警等级\n- `recommended_actions` - 建议动作（观察 / 隔离检疫缸 / 检查水质 / 联系兽医，**不含药物**）\n- `disclaimer` - 免责声明\n\nFile v1.0.5:skills/smyx_analysis/references/api_doc.md\n\n# API接口文档\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 请求格式：支持文件上传\n- 响应格式：JSON\n\n## 错误码说明\n\n| 错误码 | 说明       |\n|-----|----------|\n| 400 | 请求参数错误   |\n| 401 | API密钥无效  |\n| 403 | 权限不足     |\n| 413 | 文件过大     |\n| 415 | 不支持的文件格式 |\n| 500 | 服务器内部错误  |\n\nFile v1.0.5:scripts/config.yaml\n\n{}\n\nFile v1.0.5:skills/smyx_analysis/scripts/config.yaml\n\n{}\n\nFile v1.0.5:skills/smyx_common/scripts/config-dev.yaml\n\nApiEnum:\n  base-url-open-api: \"http://192.168.1.234:9601/smyx-open-api\"\n  base-url-open-h5: \"http://192.168.1.234:4100\"\n  base-url-health: \"http://192.168.1.234:7070/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.5:skills/smyx_common/scripts/config-test.yaml\n\nApiEnum:\n  base-url-open-api: \"https://livemonitortest.lifeemergence.com/smyx-open-api\"\n  base-url-open-h5: \"http://livemonitortest.lifeemergence.com\"\n  base-url-health: \"https://healthtest.lifeemergence.com/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.5:skills/smyx_common/scripts/config.yaml\n\nApiEnum:\n  api-key: null\n  api-secret-key: null\n  base-url-health: https://lifeemergence.com/jeecg-boot-xzgz\n  base-url-open-api: https://open.lifeemergence.com/smyx-open-api\n  base-url-open-h5: http://livemonitor.lifeemergence.com\n  database-url: null\nConstantEnum:\n  app--id: x1a3s4nwy1s2r4se\n  current--tentant-code: XIAN_ZHAO_GAN_ZHI\n  default--skill-platform-name: ARK_CLAW\n  feishu-app--id: cli_a93d769369badcb1\n  feishu-app--secret: null\n  is-debug: false\nenv: prod\n\nFile v1.0.5:skill-card.md\n\n## Description:\n\nAnalyzes aquarium or aquaculture video to identify fish schooling state, persistent isolation behavior, alert level, and recommended non-medication follow-up actions.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[smyx-sunjinhui](https://clawhub.ai/user/smyx-sunjinhui)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nExternal aquarium keepers, aquaculture operators, and developers use this skill to analyze fixed-camera fish videos or video URLs for schooling, isolation, and historical report review. It supports monitoring workflows for home aquariums, public aquariums, aquaculture ponds, and quarantine tanks.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Aquarium videos, video URLs, and report history are sent to or queried from the LifeEmergence cloud service.\n\nMitigation: Use the skill only with videos and report data that are approved for cloud processing, and review the service endpoint and data retention expectations before deployment.\n\nRisk: The skill can create or reuse a local identity and store service tokens in the workspace data directory.\n\nMitigation: Review and protect the workspace data directory, rotate or remove stored tokens when access should end, and avoid shared workspaces for sensitive deployments.\n\nRisk: Fish isolation alerts may be unreliable when tracking quality is poor, the view is obstructed, or the species naturally lives alone.\n\nMitigation: Require clear fixed-camera footage, validate species-specific baselines, and treat unreliable tracking states as a request to reshoot or adjust the camera rather than as a definitive alert.\n\nRisk: Behavior analysis could be mistaken for veterinary diagnosis or treatment advice.\n\nMitigation: Use the output as monitoring guidance only; confirm health decisions with a qualified aquarium veterinarian or aquaculture professional and avoid medication or device-control actions without user confirmation.\n\n## Reference(s):\n\n- [ClawHub Skill Page](https://clawhub.ai/smyx-sunjinhui/skills/smyx-fish-isolation-detection-analysis)\n- [API Documentation](references/api_doc.md)\n- [Skill Demo](https://lifeemergence.com/sample.html)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, JSON, API calls, files, guidance]\n\n**Output Format:** [Markdown text with structured JSON analysis content and optional saved output files]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [May include cloud report export links, historical report lists, alert levels, recommended actions, and disclaimers.]\n\n## Skill Version(s):\n\n1.0.5 (source: server release evidence)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.\n\nFile v1.0.5:skills/smyx_analysis/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nyaml==6.0.3\n\nFile v1.0.5:skills/smyx_common/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nPyYAML==6.0.3\n\nArchive v1.0.4: 31 files, 44965 bytes\n\nFiles: references/api_doc.md (6925b), scripts/__init__.py (64b), scripts/config.py (684b), scripts/config.yaml (3b), scripts/skill.py (580b), scripts/smyx_fish_isolation_detection_analysis.py (3725b), skill-card.md (3231b), SKILL.md (17401b), skills/smyx_analysis/__init__.py (0b), skills/smyx_analysis/references/api_doc.md (427b), skills/smyx_analysis/requirements.txt (45b), skills/smyx_analysis/scripts/__init__.py (0b), skills/smyx_analysis/scripts/api_service.py (1509b), skills/smyx_analysis/scripts/config.py (1003b), skills/smyx_analysis/scripts/config.yaml (3b), skills/smyx_analysis/scripts/skill.py (6529b), skills/smyx_analysis/scripts/smyx_analysis.py (3833b), skills/smyx_common/__init__.py (0b), skills/smyx_common/requirements.txt (47b), skills/smyx_common/scripts/__init__.py (177b), skills/smyx_common/scripts/api_service.py (2645b), skills/smyx_common/scripts/base.py (469b), skills/smyx_common/scripts/config-dev.yaml (214b), skills/smyx_common/scripts/config-prod.yaml (0b), skills/smyx_common/scripts/config-test.yaml (256b), skills/smyx_common/scripts/config.py (24363b), skills/smyx_common/scripts/config.yaml (473b), skills/smyx_common/scripts/dao.py (18266b), skills/smyx_common/scripts/skill.py (2473b), skills/smyx_common/scripts/util.py (28776b), _meta.json (157b)\n\nFile v1.0.4:SKILL.md\n\n---\nname: \"smyx-fish-isolation-detection-analysis\"\ndescription: \"Through fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。\"\nversion: \"1.0.8\"\nlicense: \"MIT-0\"\n---\n\n# 🐟 Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别\n> **智能分析中枢** · 图片/视频智能分析 · 结构化报告 · 历史报告云端查询\n\n---\n\n## 🧭 技能概览 | Overview\n\n| 模块 | 内容 |\n|---|---|\n| 🏷️ 技能名称 | **鱼类聚集/离群行为识别** |\n| 🎯 核心目标 | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。 |\n| 🖼️ 输入类型 | 图片、视频、本地文件、网络 URL |\n| 📝 输出能力 | 结构化分析报告、识别/监测结果、建议与报告链接 |\n| 🧩 场景码 | `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` |\n\nThrough fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). When a fish drifts more than 10 body lengths away from the school center and the state lasts longer than 1 hour (or a user-defined threshold), the system outputs an 'isolation behavior' alert. This skill helps early detection of bullied, sick (e.g. parasites, bacterial infections), spawning-period solitary or environment-distressed (e.g. strong water flow, temperature gradient) individuals, prompting aquarists to inspect and intervene. Application scenarios: home aquariums, public aquariums, aquaculture ponds, quarantine tanks. The system monitors continuously and pushes reminders when prolonged isolated fish is found. Skill features: prolonged isolation is often an early signal of disease (e.g. external parasites, digestive issues) or stress from bullying. AI-based automatic identification of isolation behavior helps aquarists detect sick fish early and isolate for treatment, reducing whole-tank infection risk. This skill can be integrated into smart aquarium cameras to enhance product behavior-analysis capability.\n\n通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。该技能有助于早期发现被欺凌、生病（如寄生虫、细菌感染）、产卵期孤立或环境不适（如水流过强、温度不均）的个体，提醒养鱼者及时检查干预。应用场景：家庭鱼缸、水族馆、水产养殖池、检疫缸。系统连续监测，当发现长期离群鱼只时推送提醒。技能特点：鱼只长期离群往往是疾病的早期信号（如体表寄生虫、消化问题），或受欺凌导致应激。通过 AI 自动识别离群行为，可帮助养鱼者及早发现病鱼并隔离治疗，降低全缸感染风险。该技能可集成到智能鱼缸摄像头中，提升产品行为分析能力。\n\n## 🤖 AI 角色 | AI Role\n| 角色要点 | 说明 |\n|---|---|\n| 说明 1 | **假设你是一个专业的水族行为监测 AI。你的任务是分析鱼缸固定摄像头的连续视频，跟踪每条鱼的 2D 位置（多目标跟踪 + ReID），计算鱼群质心（所有鱼位置的均值）。对每条鱼，计算其与质心的欧氏距离（**以该鱼的体长为单位**，核心量化单位）。当某条鱼的距离 > 10 倍体长（用户可配置）且该状态持续时间 ≥ 1 小时（用户可配置）时，输出离群提示。按 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）作判定，按 4 级告警策略递进（Level 1 入库/轻提醒 → Level 2 重要告警 + 目视检查体表/游姿/呼吸/摄食 + 评估是否隔离至检疫缸 → Level 3 紧急告警 + 强烈建议隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）+ 联系兽医 → Level 4 同缸 ≥ 3 条同时持续离群 + 推送所有联系人 + 全面排查 + 联系专业人员）。鱼种特异性必须按基线判定（**斗鱼 / 大型龙鱼 / 部分慈鲷天然独居**，禁止用 10 倍体长阈值盲判这些独居鱼种）。必须考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报。ReID 跟踪率 < 80% 或视野遮挡严重时必须返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警**。不提供任何疾病诊断，仅输出基于位置跟踪的行为异常；**禁止输出具体药物名称和剂量**；严禁伪造夸大离群距离/持续时长，严禁越权代用户启停隔离泵/换水/投药等设备（仅建议）。** |\n\n## 🎬 技能演示 | Skill Demo\n\n[▶️ 点击查看技能使用介绍](https://lifeemergence.com/sample.html)\n\n---\n\n## 🎯 任务目标 | Goals\n### 1. 🧩 技能用途\n\n基于鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头**连续视频**（≥ 1 小时滚动窗口，用户可配置 30 分钟 - 24 小时），识别 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）→ **三组指标**：群体几何 5 项（跟踪鱼数 / 基线总数 / 质心 2D 坐标 / 群体分散度 / 群体紧密度）+ 个体离群 6 项（fish_id / 体长像素 / 个体 2D 位置 / **距质心距离（体长倍数）** / 是否超阈 / **持续超阈时长**）+ 上下文 6 项（独居鱼种 / 繁殖期 / 领地缸角 / 投喂窗口 / 强水流区 / 温度梯度）→ 4 档告警级别（mild → moderate → severe → urgent）→ **4 级告警策略递进**（入库/轻提醒 → 重要告警 + 目视检查 + 评估隔离 → 紧急告警 + 隔离至检疫缸 + 水质检查 + 联系兽医 → 最高紧急告警 + 全面排查 + 所有联系人 + 专业人员）→ 单日告警上限（Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限）→ **每日离群行为报告**（按 tank_id 输出，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明）\n\n### 2. 🛠️ 能力范围\n\n| 序号 | 具体能力 |\n|---:|---|\n| 1 | 鱼体目标检测 + 多目标跟踪 + ReID 重识别（鱼离群再返群仍保持 fish_id 稳定） |\n| 2 | 2D 位置投影 |\n| 3 | 质心计算（所有跟踪鱼位置均值） |\n| 4 | 群体分散度 / 紧密度量化（体长归一化） |\n| 5 | **个体到质心距离（体长倍数核心指标）** |\n| 6 | 跨帧累计持续超阈时长 |\n| 7 | 鱼种自适应基线（独居 / 群居 / 半独居） |\n| 8 | 生理性离群上下文识别（繁殖 / 领地 / 投喂 / 水流 / 温度梯度） |\n| 9 | ReID 跟踪率门控（< 80% 返回 unreliable） |\n| 10 | 用户 APP 推送 |\n| 11 | 4 级告警递进 |\n| 12 | 单日告警上限 |\n| 13 | 每日离群行为报告（按 tank_id 输出） |\n| 14 | 连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n\n### 3. ⚡ 触发条件\n\n| 触发类型 | 触发规则 |\n|---|---|\n| ✅ 默认触发 | **默认触发**：当用户提供鱼缸固定摄像头连续视频 URL 或文件需要分析时，默认触发本技能进行鱼类聚集/离群行为识别 |\n| 🔎 明确分析意图 | 当用户明确提及鱼离群、鱼孤立、鱼独处、鱼缸角落呆滞、鱼被欺凌、鱼群分散、鱼群质心等关键词，并且上传了视频文件 |\n| 📚 历史报告查询 | 当用户提及以下关键词时，**自动触发历史报告查询功能** ：查看鱼离群历史报告、鱼缸离群行为日志清单、持续离群事件清单、查询历史鱼离群记录、显示所有鱼缸离群行为报告 |\n\n### 4. 🤖 自动行为\n\n| 自动行为 | 执行要求 |\n|---|---|\n| 📎 附件处理 | 如果用户上传了附件或者视频/图片文件，则自动保存为本地文件 |\n| ☁️ 历史报告查询 | 如果用户触发历史报告查询关键词，必须直接调用云端 API 查询，不得从本地记忆或人工汇总中获取 |\n\n#### ⚠️ 强制数据获取规则（次高优先级）\n\n> **橙色强约束：** 历史报告清单只允许从云端接口读取，不允许从本地记录、长期记忆或人工汇总中提取。\n\n必须执行：\n\n```bash\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n```\n\n| 类型 | 要求 |\n|---|---|\n| ✅ 必须 | 使用 `python -m scripts.smyx_fish_isolation_detection_analysis --list` 调用 API 查询云端的历史报告数据 |\n| 🚫 严格禁止 | 从本地 `memory` 目录读取历史会话信息 |\n| 🚫 严格禁止 | 手动汇总本地记录中的报告 |\n| 🚫 严格禁止 | 从长期记忆中提取报告 |\n| ✅ 输出格式 | 必须统一从云端接口获取最新完整数据，然后以 Markdown 表格格式输出结果 |\n\n## 📦 前置准备 | Requirements\n- 依赖说明:scripts 脚本所需的依赖包及版本\n  ```\n  requests>=2.28.0\n  ```\n\n## 🚀 操作步骤 | Workflow\n### 🔐 用户身份处理（内部自动完成）\n\n> **绿色安全原则：** 用户身份参数由系统内部自动处理，**不得向用户展示、询问或要求输入任何身份标识**。\n\n执行本技能分析或历史报告查询时，脚本会自动完成身份初始化：\n\n| 场景 | 系统行为 |\n|---|---|\n| 上游系统有内部身份参数 | 由脚本静默接收并使用 |\n| 上游系统未提供内部身份参数 | 脚本会自动复用本地缺省用户 |\n| 本地缺省用户不存在 | 脚本会自动创建并在后续任务中复用 |\n| 对用户输出 | 只展示分析进度、分析结果和报告链接，不展示内部身份值 |\n\n#### 🔒 关键约束\n\n| 禁止/要求 | 说明 |\n|---|---|\n| 🚫 不得询问身份 | 不得提示用户输入用户名、手机号或任何内部身份参数 |\n| 🚫 不得暴露身份值 | 不得在回复、报告、示例、错误提示中暴露内部身份值 |\n| 🚫 不得列为用户参数 | 不得把内部身份参数列为用户需要理解或传入的参数 |\n| ✅ 自动关联报告 | 历史报告查询同样由系统内部身份自动关联，用户只需表达“查看历史报告/报告清单”等意图 |\n\n---\n\n### 🧪 标准流程 | Standard Flow\n\n| 步骤 | 阶段 | 执行动作 |\n|---:|---|---|\n| 1 | 📥 准备鱼缸固定摄像头连续视频输入 | 提供本地文件路径或网络 URL；确保输入内容清晰、符合技能场景要求 |\n| 2 | 🔐 获取 open-id（强制执行） | 无需用户输入任何身份参数；不在回复中展示内部身份值 |\n| 3 | ⚙️ 执行鱼类聚集/离群行为识别 | 调用 `-m scripts.smyx_fish_isolation_detection_analysis` 处理输入（**必须在技能根目录下运行脚本**） |\n| 4 | 📊 查看分析结果 | 接收结构化分析报告，查看识别/监测结果、风险提示、建议与报告链接 |\n\n### ⚙️ 脚本参数说明\n\n| 参数 | 含义 | 备注 |\n|---|---|---|\n| `--input` | 本地鱼缸固定摄像头连续视频文件路径 | 适用于本地文件分析 |\n| `--url` | 网络鱼缸固定摄像头连续视频 URL 地址（API 服务自动下载） | API 服务自动下载网络资源 |\n| `--pet-type` | 类别标识，鱼类聚集/离群行为识别场景默认 `other` | 按需填写 |\n| `--list` | 显示鱼类聚集/离群行为识别历史记录清单 | 用于云端历史报告查询 |\n| `--api-url` | API 服务地址（可选，使用默认值） | 按需填写 |\n| `--detail` | 输出详细程度（basic/standard/json，默认 json） | 输出详细程度 |\n| `--output` | 结果输出文件路径（可选） | 可选 |\n\n## 🗂️ 资源索引 | Resource Index\n| 资源类型 | 路径 | 用途 | 何时读取 |\n|---|---|---|---|\n| 🐍 必要脚本 | [`scripts/smyx_fish_isolation_detection_analysis.py`](scripts/smyx_fish_isolation_detection_analysis.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 🐍 必要脚本 | [`scripts/config.py`](scripts/config.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 📘 领域参考 | [`references/api_doc.md`](references/api_doc.md) | 了解 API 接口规范、字段说明和错误码 | 仅在需要了解接口规范或错误码时读取 |\n\n## ⚠️ 注意事项 | Notes\n| 分类 | 注意事项 |\n|---|---|\n| 📚 文档读取 | 仅在需要时读取参考文档，保持上下文简洁 |\n| 📁 格式支持 | 输入要求：支持 mp4/avi/mov，最大 10MB；摄像头需俯拍或大角度斜视；**连续采样 ≥ 1 小时**；帧率 ≥ 10 FPS；必须接入 ReID 多目标跟踪 |\n| 🔎 使用提醒 | **核心量化单位**：**离群距离以\"鱼体长倍数\"为单位**（默认阈值 > 10 倍体长，用户可配置） |\n| 🔎 使用提醒 | **核心持续时长阈值**：**≥ 1 小时**（用户可配置 15 分钟 - 24 小时） |\n| 🔎 使用提醒 | **4 级告警策略递进**（mild → moderate → severe → urgent/Level 4），同缸 ≥ 3 条同时持续离群 / 离群+角落呆滞进入更高级别 |\n| 🔎 使用提醒 | 单日告警上限：Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限（紧急安全优先） |\n| 🔎 使用提醒 | 红线约束 |\n| 🧑‍⚖️ 结果性质 | **禁止**对鱼做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征 / 被欺凌创伤\"等具体疾病或行为学诊断 |\n| 🔎 使用提醒 | **🚨 绝对禁止**输出具体药物名称、剂量、给药方案 |\n| 🔎 使用提醒 | **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定） |\n| 🔎 使用提醒 | **禁止**用于商业广告 / AI 训练；禁第三方共享 |\n| 🔎 使用提醒 | **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议） |\n| 🔎 使用提醒 | **绝对禁止**伪造或夸大离群距离、持续时长、群体分散度等指标；所有数据必须基于真实视频帧跟踪 |\n| 🔎 使用提醒 | **必须**按**鱼种基线**判定（独居：斗鱼 / 大型龙鱼 / 部分慈鲷；半独居：罗汉、地图等；群居：灯鱼 / 鼠鱼 / 锦鲤）；**禁止使用通用 10 倍体长阈值盲判独居鱼种** |\n| 📚 文档读取 | **必须**考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报 |\n| 🔎 使用提醒 | **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警** |\n| 🔎 使用提醒 | **必须**：连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n| 📜 报告输出 | **必须**：每日离群行为报告**按 tank_id 输出**，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明 |\n| 🚫 脚本限制 | 禁止临时生成脚本，只能用技能本身的脚本 |\n| 🌐 网络地址 | 传入的网络地址参数，不需要下载本地，默认地址都是公网地址，api 服务会自动下载 |\n| 📜 报告输出 | 当显示历史离群记录清单的时候，从接口返回 json 数据中提取字段  作为超链接地址，且自动转化为如下 Markdown |\n| 📜 报告输出 | 表格输出示例 |\n\n## 🧰 使用示例 | Examples\n```bash\n# 分析本地连续视频（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --input /path/to/tank_1h.mp4\n\n# 分析网络连续视频/实时流（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --url https://example.com/tank_1h.mp4\n\n# 显示历史离群行为记录清单（自动触发关键词：查看鱼离群历史报告、鱼缸离群行为日志清单等）\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n\n# 输出精简报告\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --detail basic\n\n# 保存结果到文件\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --output result.json\n```\n\nFile v1.0.4:_meta.json\n\n{\n  \"ownerId\": \"kn7cyxkr2ymf7zwsrybpedg8xx83ywrj\",\n  \"slug\": \"smyx-fish-isolation-detection-analysis\",\n  \"version\": \"1.0.4\",\n  \"publishedAt\": 1785570810592\n}\n\nFile v1.0.4:references/api_doc.md\n\n# API 接口文档\n\n此处用于存放鱼类聚集/离群行为识别 API 的接口文档，待后续补充。\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 响应格式：JSON\n\n## 主要接口\n\n1. `/web/health-analysis/v2/start-health-analysis` - 启动鱼类聚集/离群行为识别任务\n2. `/web/health-analysis/v2/get-health-analysis-result` - 获取离群检测结果（离群个体清单 + 离群距离 + 持续时长）\n3. `/web/health-analysis/page-health-analysis-result` - 分页查询历史离群行为报告\n4. `/health/order/api/getReportDetailExport?id={id}` - 导出离群行为报告\n5. （可选）`/web/companion/v2/trigger-soothing-action` - 触发联动提醒（用户 APP 推送 / 智能鱼缸告警灯 / 提示隔离至检疫缸建议）\n\n## 场景代码\n\n- `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` - 鱼类聚集/离群行为识别\n\n## 输入约束\n\n- 摄像头：鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头，建议**俯拍或大角度斜视**（保证 2D 位置投影稳定）\n- 分辨率 ≥ 720p；**帧率 ≥ 10 FPS**（位置跟踪需稳定）\n- 光照：建议鱼缸照明开启 + 无强反光；水质清澈（浑浊度低）\n- **核心采样窗口**：连续观察 ≥ 1 小时（用户可配置 30 分钟 - 24 小时滚动窗口）\n- 视野约束：必须覆盖整个鱼缸/养殖池**完整水平投影**（任何 dead zone 都可能误判为\"离群\"）\n- 多鱼缸/池场景按摄像头 ID 绑定到注册容器 ID\n- **多鱼场景必须接入 ReID**（多目标跟踪 + 重识别），每条鱼建立稳定 fish_id\n- **部署时必须录入**：鱼种清单、群体大小 N（用户输入或首次自动统计取众数）、每条鱼体长校准（像素 ↔ cm，可单次手动校准或自动学习）\n- 用户必须授权部署；公共水族馆 / 养殖场需公示告知\n\n## 关键观测信号\n\n### 群体几何信号\n- `tracked_fish_count` - 当前帧成功跟踪到的鱼数\n- `total_fish_count_baseline` - 容器注册总鱼数（基线）\n- `school_centroid_xy` - 鱼群质心（所有鱼 2D 位置均值）\n- `school_dispersion_score` - 群体分散度（所有鱼到质心距离的标准差，体长归一化）\n- `school_compactness_score` - 群体紧密度（0-100，越高越紧密；夜行鱼休息时自然偏低）\n\n### 个体离群信号（每条 fish_id 独立）\n- `fish_id` - 个体唯一标识（ReID 输出）\n- `fish_body_length_px` - 该鱼当前体长（像素，自动估计）\n- `fish_position_xy` - 该鱼当前 2D 位置\n- `distance_to_centroid_body_lengths` - 与质心欧氏距离（**以体长为单位**，核心指标）\n- `over_threshold_flag` - 是否超过阈值（默认 > 10 倍体长）\n- `over_threshold_duration_min` - 持续超阈时长（分钟，跨帧累计）\n\n### 上下文信号（避免误报）\n- `is_natural_solitary_species` - 是否独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷天然独居）\n- `is_breeding_period` - 是否繁殖期（公鱼护卵 / 母鱼离群产卵）\n- `is_territory_corner_fish` - 是否为领地型缸角守卫鱼（\"离群\"实为正常占地）\n- `is_during_feeding` - 是否在投喂窗口内（短时聚拢/分散为生理性）\n- `tank_has_strong_water_flow` - 是否有强水流区（被冲到角落可能误判）\n- `tank_temperature_gradient_detected` - 是否检测到温度不均（鱼可能聚于舒适温区，余者\"离群\"）\n\n## 综合判定\n\n- `schooling_normal` - 群体正常聚集\n- `schooling_loose` - 群体偏松散（但无明显离群个体）\n- `isolation_short` - 短时离群（> 10 倍体长但 < 1 小时）\n- `isolation_persistent` - **持续离群**（> 10 倍体长且 ≥ 1 小时，核心告警场景）\n- `isolation_corner_stuck` - 角落呆滞（离群 + 长时间几乎不动，疑似严重不适）\n- `multiple_isolated_individuals` - 多鱼同时离群（疑似全缸应激 / 水质恶化）\n- `isolation_signal_unreliable` - 信号不可靠（ReID 断裂 / 视野遮挡 / 浑浊度过高 / 跟踪 < 80% 鱼数）\n\n## 4 级告警策略递进\n\n- Level 1（isolation_short / schooling_loose）：仅入库或用户 APP 轻提醒\"观察某条鱼是否长期离群\"\n- Level 2（isolation_persistent，单条）：用户 APP 重要告警，建议**目视检查该鱼体表 / 游姿 / 呼吸 / 摄食活跃度**，并**评估是否隔离至检疫缸**\n- Level 3（isolation_corner_stuck / 连续 ≥ 2 日 isolation_persistent）：紧急告警，**强烈建议立即隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）**，并提示联系**当地观赏鱼兽医**\n- Level 4（multiple_isolated_individuals / 同缸 ≥ 3 条同时持续离群）：最高紧急告警 + 推送家庭/管理人员所有联系人 + 强烈建议**立即全面排查（水质 + 体表 + 游姿 + 呼吸 + 摄食）+ 联系专业人员**\n\n## 单日告警上限\n\n- Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限\n\n## 红线约束\n\n- **禁止**做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征\"等具体疾病诊断\n- **禁止**输出具体药物名称、剂量、给药方案\n- **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定）\n- **禁止**用于商业广告 / AI 训练；禁第三方共享\n- **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议）\n- 离群距离、持续时长、群体分散度等指标必须基于真实视频帧跟踪；**禁止伪造或夸大指标**\n- 鱼种特异性：**独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷）天然不集群** → 必须按鱼种基线判定；**禁止使用通用 10 倍体长阈值盲判独居鱼种**\n- 必须考虑生理性离群上下文：**繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集** → 不可直接告警\n- **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable`，并建议重拍 / 调整摄像头角度；**禁止给出不可靠告警**\n- 必须告知用户：AI 行为识别仅供参考，**最终诊断与治疗方案需专业水族兽医确认**\n\n## 输出报告字段\n\n- `report_date` - 报告日期\n- `tank_id` - 鱼缸/养殖池/检疫缸 ID\n- `species` - 鱼种\n- `total_fish_count_baseline` - 注册总鱼数\n- `school_compactness_score` - 群体紧密度\n- `isolated_fish_list` - 离群个体清单（每条含 fish_id / distance_to_centroid_body_lengths / over_threshold_duration_min / 缩略图轨迹）\n- `composite_scene` - 综合判定\n- `alert_level` - 告警等级\n- `recommended_actions` - 建议动作（观察 / 隔离检疫缸 / 检查水质 / 联系兽医，**不含药物**）\n- `disclaimer` - 免责声明\n\nFile v1.0.4:skills/smyx_analysis/references/api_doc.md\n\n# API接口文档\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 请求格式：支持文件上传\n- 响应格式：JSON\n\n## 错误码说明\n\n| 错误码 | 说明       |\n|-----|----------|\n| 400 | 请求参数错误   |\n| 401 | API密钥无效  |\n| 403 | 权限不足     |\n| 413 | 文件过大     |\n| 415 | 不支持的文件格式 |\n| 500 | 服务器内部错误  |\n\nFile v1.0.4:scripts/config.yaml\n\n{}\n\nFile v1.0.4:skills/smyx_analysis/scripts/config.yaml\n\n{}\n\nFile v1.0.4:skills/smyx_common/scripts/config-dev.yaml\n\nApiEnum:\n  base-url-open-api: \"http://192.168.1.234:9601/smyx-open-api\"\n  base-url-open-h5: \"http://192.168.1.234:4100\"\n  base-url-health: \"http://192.168.1.234:7070/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.4:skills/smyx_common/scripts/config-test.yaml\n\nApiEnum:\n  base-url-open-api: \"https://livemonitortest.lifeemergence.com/smyx-open-api\"\n  base-url-open-h5: \"http://livemonitortest.lifeemergence.com\"\n  base-url-health: \"https://healthtest.lifeemergence.com/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.4:skills/smyx_common/scripts/config.yaml\n\nApiEnum:\n  api-key: null\n  api-secret-key: null\n  base-url-health: https://lifeemergence.com/jeecg-boot-xzgz\n  base-url-open-api: https://open.lifeemergence.com/smyx-open-api\n  base-url-open-h5: http://livemonitor.lifeemergence.com\n  database-url: null\nConstantEnum:\n  app--id: x1a3s4nwy1s2r4se\n  current--tentant-code: XIAN_ZHAO_GAN_ZHI\n  default--skill-platform-name: ARK_CLAW\n  feishu-app--id: cli_a93d769369badcb1\n  feishu-app--secret: null\n  is-debug: false\nenv: prod\n\nFile v1.0.4:skill-card.md\n\n## Description: <br>\nAnalyzes aquarium or aquaculture video to track fish positions, estimate schooling behavior, and flag persistent isolation from the school centroid. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[smyx-sunjinhui](https://clawhub.ai/user/smyx-sunjinhui) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nExternal users, aquarists, aquarium operators, and aquaculture teams use this skill to analyze fixed-camera footage for schooling patterns, prolonged isolation, and alert-oriented behavior reports. It supports review of isolation events, historical report lookup, and non-diagnostic guidance such as visual inspection, water-quality checks, and escalation to aquatic professionals. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: Analysis inputs, tank URLs, account-linked history, and report data may be sent to LifeEmergence services. <br>\nMitigation: Use the skill only when that provider relationship is acceptable and avoid submitting sensitive footage or URLs without appropriate consent. <br>\nRisk: The skill can create or reuse a persistent local user identity and store reusable user or token data in the workspace. <br>\nMitigation: Review local persistence before shared or regulated deployments, and remove stored identity or token data when the workspace is retired. <br>\nRisk: Behavior alerts can be misleading when tracking quality is low, visibility is obstructed, or naturally solitary species are judged with generic schooling thresholds. <br>\nMitigation: Require adequate camera coverage and ReID quality, apply species-specific baselines, and treat unreliable signals as requests to reshoot or adjust the camera rather than as alerts. <br>\nRisk: Fish isolation signals may be mistaken for medical diagnosis or automated treatment instructions. <br>\nMitigation: Keep outputs non-diagnostic, avoid drug names or dosages, and require user or professional confirmation before isolation, water changes, medication, or device actions. <br>\n\n\n## Reference(s): <br>\n- [Fish isolation API documentation](artifact/references/api_doc.md) <br>\n- [Skill demo](https://lifeemergence.com/sample.html) <br>\n- [ClawHub skill page](https://clawhub.ai/smyx-sunjinhui/skills/smyx-fish-isolation-detection-analysis) <br>\n- [Publisher profile](https://clawhub.ai/user/smyx-sunjinhui) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [Text, Markdown, JSON, Shell commands, Guidance] <br>\n**Output Format:** [Markdown or JSON analysis reports with command-line status text and report links] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [May include isolated-fish lists, distance and duration metrics, alert levels, recommended actions, disclaimers, and historical report tables.] <br>\n\n## Skill Version(s): <br>\n1.0.4 (source: server release metadata; artifact frontmatter reports 1.0.8) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nFile v1.0.4:skills/smyx_analysis/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nyaml==6.0.3\n\nFile v1.0.4:skills/smyx_common/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nPyYAML==6.0.3\n\nArchive v1.0.3: 31 files, 44840 bytes\n\nFiles: references/api_doc.md (6925b), scripts/__init__.py (64b), scripts/config.py (684b), scripts/config.yaml (3b), scripts/skill.py (580b), scripts/smyx_fish_isolation_detection_analysis.py (3725b), skill-card.md (2943b), SKILL.md (17401b), skills/smyx_analysis/__init__.py (0b), skills/smyx_analysis/references/api_doc.md (427b), skills/smyx_analysis/requirements.txt (45b), skills/smyx_analysis/scripts/__init__.py (0b), skills/smyx_analysis/scripts/api_service.py (1509b), skills/smyx_analysis/scripts/config.py (1003b), skills/smyx_analysis/scripts/config.yaml (3b), skills/smyx_analysis/scripts/skill.py (6529b), skills/smyx_analysis/scripts/smyx_analysis.py (3833b), skills/smyx_common/__init__.py (0b), skills/smyx_common/requirements.txt (47b), skills/smyx_common/scripts/__init__.py (177b), skills/smyx_common/scripts/api_service.py (2645b), skills/smyx_common/scripts/base.py (469b), skills/smyx_common/scripts/config-dev.yaml (214b), skills/smyx_common/scripts/config-prod.yaml (0b), skills/smyx_common/scripts/config-test.yaml (256b), skills/smyx_common/scripts/config.py (24363b), skills/smyx_common/scripts/config.yaml (473b), skills/smyx_common/scripts/dao.py (18266b), skills/smyx_common/scripts/skill.py (2473b), skills/smyx_common/scripts/util.py (28776b), _meta.json (157b)\n\nFile v1.0.3:SKILL.md\n\n---\nname: \"smyx-fish-isolation-detection-analysis\"\ndescription: \"Through fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。\"\nversion: \"1.0.5\"\nlicense: \"MIT-0\"\n---\n\n# 🐟 Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别\n> **智能分析中枢** · 图片/视频智能分析 · 结构化报告 · 历史报告云端查询\n\n---\n\n## 🧭 技能概览 | Overview\n\n| 模块 | 内容 |\n|---|---|\n| 🏷️ 技能名称 | **鱼类聚集/离群行为识别** |\n| 🎯 核心目标 | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。 |\n| 🖼️ 输入类型 | 图片、视频、本地文件、网络 URL |\n| 📝 输出能力 | 结构化分析报告、识别/监测结果、建议与报告链接 |\n| 🧩 场景码 | `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` |\n\nThrough fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). When a fish drifts more than 10 body lengths away from the school center and the state lasts longer than 1 hour (or a user-defined threshold), the system outputs an 'isolation behavior' alert. This skill helps early detection of bullied, sick (e.g. parasites, bacterial infections), spawning-period solitary or environment-distressed (e.g. strong water flow, temperature gradient) individuals, prompting aquarists to inspect and intervene. Application scenarios: home aquariums, public aquariums, aquaculture ponds, quarantine tanks. The system monitors continuously and pushes reminders when prolonged isolated fish is found. Skill features: prolonged isolation is often an early signal of disease (e.g. external parasites, digestive issues) or stress from bullying. AI-based automatic identification of isolation behavior helps aquarists detect sick fish early and isolate for treatment, reducing whole-tank infection risk. This skill can be integrated into smart aquarium cameras to enhance product behavior-analysis capability.\n\n通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。该技能有助于早期发现被欺凌、生病（如寄生虫、细菌感染）、产卵期孤立或环境不适（如水流过强、温度不均）的个体，提醒养鱼者及时检查干预。应用场景：家庭鱼缸、水族馆、水产养殖池、检疫缸。系统连续监测，当发现长期离群鱼只时推送提醒。技能特点：鱼只长期离群往往是疾病的早期信号（如体表寄生虫、消化问题），或受欺凌导致应激。通过 AI 自动识别离群行为，可帮助养鱼者及早发现病鱼并隔离治疗，降低全缸感染风险。该技能可集成到智能鱼缸摄像头中，提升产品行为分析能力。\n\n## 🤖 AI 角色 | AI Role\n| 角色要点 | 说明 |\n|---|---|\n| 说明 1 | **假设你是一个专业的水族行为监测 AI。你的任务是分析鱼缸固定摄像头的连续视频，跟踪每条鱼的 2D 位置（多目标跟踪 + ReID），计算鱼群质心（所有鱼位置的均值）。对每条鱼，计算其与质心的欧氏距离（**以该鱼的体长为单位**，核心量化单位）。当某条鱼的距离 > 10 倍体长（用户可配置）且该状态持续时间 ≥ 1 小时（用户可配置）时，输出离群提示。按 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）作判定，按 4 级告警策略递进（Level 1 入库/轻提醒 → Level 2 重要告警 + 目视检查体表/游姿/呼吸/摄食 + 评估是否隔离至检疫缸 → Level 3 紧急告警 + 强烈建议隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）+ 联系兽医 → Level 4 同缸 ≥ 3 条同时持续离群 + 推送所有联系人 + 全面排查 + 联系专业人员）。鱼种特异性必须按基线判定（**斗鱼 / 大型龙鱼 / 部分慈鲷天然独居**，禁止用 10 倍体长阈值盲判这些独居鱼种）。必须考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报。ReID 跟踪率 < 80% 或视野遮挡严重时必须返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警**。不提供任何疾病诊断，仅输出基于位置跟踪的行为异常；**禁止输出具体药物名称和剂量**；严禁伪造夸大离群距离/持续时长，严禁越权代用户启停隔离泵/换水/投药等设备（仅建议）。** |\n\n## 🎬 技能演示 | Skill Demo\n\n[▶️ 点击查看技能使用介绍](https://lifeemergence.com/sample.html)\n\n---\n\n## 🎯 任务目标 | Goals\n### 1. 🧩 技能用途\n\n基于鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头**连续视频**（≥ 1 小时滚动窗口，用户可配置 30 分钟 - 24 小时），识别 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）→ **三组指标**：群体几何 5 项（跟踪鱼数 / 基线总数 / 质心 2D 坐标 / 群体分散度 / 群体紧密度）+ 个体离群 6 项（fish_id / 体长像素 / 个体 2D 位置 / **距质心距离（体长倍数）** / 是否超阈 / **持续超阈时长**）+ 上下文 6 项（独居鱼种 / 繁殖期 / 领地缸角 / 投喂窗口 / 强水流区 / 温度梯度）→ 4 档告警级别（mild → moderate → severe → urgent）→ **4 级告警策略递进**（入库/轻提醒 → 重要告警 + 目视检查 + 评估隔离 → 紧急告警 + 隔离至检疫缸 + 水质检查 + 联系兽医 → 最高紧急告警 + 全面排查 + 所有联系人 + 专业人员）→ 单日告警上限（Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限）→ **每日离群行为报告**（按 tank_id 输出，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明）\n\n### 2. 🛠️ 能力范围\n\n| 序号 | 具体能力 |\n|---:|---|\n| 1 | 鱼体目标检测 + 多目标跟踪 + ReID 重识别（鱼离群再返群仍保持 fish_id 稳定） |\n| 2 | 2D 位置投影 |\n| 3 | 质心计算（所有跟踪鱼位置均值） |\n| 4 | 群体分散度 / 紧密度量化（体长归一化） |\n| 5 | **个体到质心距离（体长倍数核心指标）** |\n| 6 | 跨帧累计持续超阈时长 |\n| 7 | 鱼种自适应基线（独居 / 群居 / 半独居） |\n| 8 | 生理性离群上下文识别（繁殖 / 领地 / 投喂 / 水流 / 温度梯度） |\n| 9 | ReID 跟踪率门控（< 80% 返回 unreliable） |\n| 10 | 用户 APP 推送 |\n| 11 | 4 级告警递进 |\n| 12 | 单日告警上限 |\n| 13 | 每日离群行为报告（按 tank_id 输出） |\n| 14 | 连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n\n### 3. ⚡ 触发条件\n\n| 触发类型 | 触发规则 |\n|---|---|\n| ✅ 默认触发 | **默认触发**：当用户提供鱼缸固定摄像头连续视频 URL 或文件需要分析时，默认触发本技能进行鱼类聚集/离群行为识别 |\n| 🔎 明确分析意图 | 当用户明确提及鱼离群、鱼孤立、鱼独处、鱼缸角落呆滞、鱼被欺凌、鱼群分散、鱼群质心等关键词，并且上传了视频文件 |\n| 📚 历史报告查询 | 当用户提及以下关键词时，**自动触发历史报告查询功能** ：查看鱼离群历史报告、鱼缸离群行为日志清单、持续离群事件清单、查询历史鱼离群记录、显示所有鱼缸离群行为报告 |\n\n### 4. 🤖 自动行为\n\n| 自动行为 | 执行要求 |\n|---|---|\n| 📎 附件处理 | 如果用户上传了附件或者视频/图片文件，则自动保存为本地文件 |\n| ☁️ 历史报告查询 | 如果用户触发历史报告查询关键词，必须直接调用云端 API 查询，不得从本地记忆或人工汇总中获取 |\n\n#### ⚠️ 强制数据获取规则（次高优先级）\n\n> **橙色强约束：** 历史报告清单只允许从云端接口读取，不允许从本地记录、长期记忆或人工汇总中提取。\n\n必须执行：\n\n```bash\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n```\n\n| 类型 | 要求 |\n|---|---|\n| ✅ 必须 | 使用 `python -m scripts.smyx_fish_isolation_detection_analysis --list` 调用 API 查询云端的历史报告数据 |\n| 🚫 严格禁止 | 从本地 `memory` 目录读取历史会话信息 |\n| 🚫 严格禁止 | 手动汇总本地记录中的报告 |\n| 🚫 严格禁止 | 从长期记忆中提取报告 |\n| ✅ 输出格式 | 必须统一从云端接口获取最新完整数据，然后以 Markdown 表格格式输出结果 |\n\n## 📦 前置准备 | Requirements\n- 依赖说明:scripts 脚本所需的依赖包及版本\n  ```\n  requests>=2.28.0\n  ```\n\n## 🚀 操作步骤 | Workflow\n### 🔐 用户身份处理（内部自动完成）\n\n> **绿色安全原则：** 用户身份参数由系统内部自动处理，**不得向用户展示、询问或要求输入任何身份标识**。\n\n执行本技能分析或历史报告查询时，脚本会自动完成身份初始化：\n\n| 场景 | 系统行为 |\n|---|---|\n| 上游系统有内部身份参数 | 由脚本静默接收并使用 |\n| 上游系统未提供内部身份参数 | 脚本会自动复用本地缺省用户 |\n| 本地缺省用户不存在 | 脚本会自动创建并在后续任务中复用 |\n| 对用户输出 | 只展示分析进度、分析结果和报告链接，不展示内部身份值 |\n\n#### 🔒 关键约束\n\n| 禁止/要求 | 说明 |\n|---|---|\n| 🚫 不得询问身份 | 不得提示用户输入用户名、手机号或任何内部身份参数 |\n| 🚫 不得暴露身份值 | 不得在回复、报告、示例、错误提示中暴露内部身份值 |\n| 🚫 不得列为用户参数 | 不得把内部身份参数列为用户需要理解或传入的参数 |\n| ✅ 自动关联报告 | 历史报告查询同样由系统内部身份自动关联，用户只需表达“查看历史报告/报告清单”等意图 |\n\n---\n\n### 🧪 标准流程 | Standard Flow\n\n| 步骤 | 阶段 | 执行动作 |\n|---:|---|---|\n| 1 | 📥 准备鱼缸固定摄像头连续视频输入 | 提供本地文件路径或网络 URL；确保输入内容清晰、符合技能场景要求 |\n| 2 | 🔐 获取 open-id（强制执行） | 无需用户输入任何身份参数；不在回复中展示内部身份值 |\n| 3 | ⚙️ 执行鱼类聚集/离群行为识别 | 调用 `-m scripts.smyx_fish_isolation_detection_analysis` 处理输入（**必须在技能根目录下运行脚本**） |\n| 4 | 📊 查看分析结果 | 接收结构化分析报告，查看识别/监测结果、风险提示、建议与报告链接 |\n\n### ⚙️ 脚本参数说明\n\n| 参数 | 含义 | 备注 |\n|---|---|---|\n| `--input` | 本地鱼缸固定摄像头连续视频文件路径 | 适用于本地文件分析 |\n| `--url` | 网络鱼缸固定摄像头连续视频 URL 地址（API 服务自动下载） | API 服务自动下载网络资源 |\n| `--pet-type` | 类别标识，鱼类聚集/离群行为识别场景默认 `other` | 按需填写 |\n| `--list` | 显示鱼类聚集/离群行为识别历史记录清单 | 用于云端历史报告查询 |\n| `--api-url` | API 服务地址（可选，使用默认值） | 按需填写 |\n| `--detail` | 输出详细程度（basic/standard/json，默认 json） | 输出详细程度 |\n| `--output` | 结果输出文件路径（可选） | 可选 |\n\n## 🗂️ 资源索引 | Resource Index\n| 资源类型 | 路径 | 用途 | 何时读取 |\n|---|---|---|---|\n| 🐍 必要脚本 | [`scripts/smyx_fish_isolation_detection_analysis.py`](scripts/smyx_fish_isolation_detection_analysis.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 🐍 必要脚本 | [`scripts/config.py`](scripts/config.py) | 调用 API、执行分析或查询历史报告 | 执行分析或查询时使用 |\n| 📘 领域参考 | [`references/api_doc.md`](references/api_doc.md) | 了解 API 接口规范、字段说明和错误码 | 仅在需要了解接口规范或错误码时读取 |\n\n## ⚠️ 注意事项 | Notes\n| 分类 | 注意事项 |\n|---|---|\n| 📚 文档读取 | 仅在需要时读取参考文档，保持上下文简洁 |\n| 📁 格式支持 | 输入要求：支持 mp4/avi/mov，最大 10MB；摄像头需俯拍或大角度斜视；**连续采样 ≥ 1 小时**；帧率 ≥ 10 FPS；必须接入 ReID 多目标跟踪 |\n| 🔎 使用提醒 | **核心量化单位**：**离群距离以\"鱼体长倍数\"为单位**（默认阈值 > 10 倍体长，用户可配置） |\n| 🔎 使用提醒 | **核心持续时长阈值**：**≥ 1 小时**（用户可配置 15 分钟 - 24 小时） |\n| 🔎 使用提醒 | **4 级告警策略递进**（mild → moderate → severe → urgent/Level 4），同缸 ≥ 3 条同时持续离群 / 离群+角落呆滞进入更高级别 |\n| 🔎 使用提醒 | 单日告警上限：Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限（紧急安全优先） |\n| 🔎 使用提醒 | 红线约束 |\n| 🧑‍⚖️ 结果性质 | **禁止**对鱼做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征 / 被欺凌创伤\"等具体疾病或行为学诊断 |\n| 🔎 使用提醒 | **🚨 绝对禁止**输出具体药物名称、剂量、给药方案 |\n| 🔎 使用提醒 | **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定） |\n| 🔎 使用提醒 | **禁止**用于商业广告 / AI 训练；禁第三方共享 |\n| 🔎 使用提醒 | **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议） |\n| 🔎 使用提醒 | **绝对禁止**伪造或夸大离群距离、持续时长、群体分散度等指标；所有数据必须基于真实视频帧跟踪 |\n| 🔎 使用提醒 | **必须**按**鱼种基线**判定（独居：斗鱼 / 大型龙鱼 / 部分慈鲷；半独居：罗汉、地图等；群居：灯鱼 / 鼠鱼 / 锦鲤）；**禁止使用通用 10 倍体长阈值盲判独居鱼种** |\n| 📚 文档读取 | **必须**考虑生理性离群的上下文（繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集），避免误报 |\n| 🔎 使用提醒 | **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable` 并建议重拍/调整摄像头角度，**禁止给出不可靠的告警** |\n| 🔎 使用提醒 | **必须**：连续 ≥ 2 日 Level 2+ → 强烈建议联系**当地观赏鱼兽医或养殖场技术员** |\n| 📜 报告输出 | **必须**：每日离群行为报告**按 tank_id 输出**，含离群个体清单 + 轨迹缩略图 + 建议动作 + 免责声明 |\n| 🚫 脚本限制 | 禁止临时生成脚本，只能用技能本身的脚本 |\n| 🌐 网络地址 | 传入的网络地址参数，不需要下载本地，默认地址都是公网地址，api 服务会自动下载 |\n| 📜 报告输出 | 当显示历史离群记录清单的时候，从接口返回 json 数据中提取字段  作为超链接地址，且自动转化为如下 Markdown |\n| 📜 报告输出 | 表格输出示例 |\n\n## 🧰 使用示例 | Examples\n```bash\n# 分析本地连续视频（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --input /path/to/tank_1h.mp4\n\n# 分析网络连续视频/实时流（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --url https://example.com/tank_1h.mp4\n\n# 显示历史离群行为记录清单（自动触发关键词：查看鱼离群历史报告、鱼缸离群行为日志清单等）\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n\n# 输出精简报告\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --detail basic\n\n# 保存结果到文件\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --output result.json\n```\n\nFile v1.0.3:_meta.json\n\n{\n  \"ownerId\": \"kn7cyxkr2ymf7zwsrybpedg8xx83ywrj\",\n  \"slug\": \"smyx-fish-isolation-detection-analysis\",\n  \"version\": \"1.0.3\",\n  \"publishedAt\": 1783894705559\n}\n\nFile v1.0.3:references/api_doc.md\n\n# API 接口文档\n\n此处用于存放鱼类聚集/离群行为识别 API 的接口文档，待后续补充。\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 响应格式：JSON\n\n## 主要接口\n\n1. `/web/health-analysis/v2/start-health-analysis` - 启动鱼类聚集/离群行为识别任务\n2. `/web/health-analysis/v2/get-health-analysis-result` - 获取离群检测结果（离群个体清单 + 离群距离 + 持续时长）\n3. `/web/health-analysis/page-health-analysis-result` - 分页查询历史离群行为报告\n4. `/health/order/api/getReportDetailExport?id={id}` - 导出离群行为报告\n5. （可选）`/web/companion/v2/trigger-soothing-action` - 触发联动提醒（用户 APP 推送 / 智能鱼缸告警灯 / 提示隔离至检疫缸建议）\n\n## 场景代码\n\n- `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` - 鱼类聚集/离群行为识别\n\n## 输入约束\n\n- 摄像头：鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头，建议**俯拍或大角度斜视**（保证 2D 位置投影稳定）\n- 分辨率 ≥ 720p；**帧率 ≥ 10 FPS**（位置跟踪需稳定）\n- 光照：建议鱼缸照明开启 + 无强反光；水质清澈（浑浊度低）\n- **核心采样窗口**：连续观察 ≥ 1 小时（用户可配置 30 分钟 - 24 小时滚动窗口）\n- 视野约束：必须覆盖整个鱼缸/养殖池**完整水平投影**（任何 dead zone 都可能误判为\"离群\"）\n- 多鱼缸/池场景按摄像头 ID 绑定到注册容器 ID\n- **多鱼场景必须接入 ReID**（多目标跟踪 + 重识别），每条鱼建立稳定 fish_id\n- **部署时必须录入**：鱼种清单、群体大小 N（用户输入或首次自动统计取众数）、每条鱼体长校准（像素 ↔ cm，可单次手动校准或自动学习）\n- 用户必须授权部署；公共水族馆 / 养殖场需公示告知\n\n## 关键观测信号\n\n### 群体几何信号\n- `tracked_fish_count` - 当前帧成功跟踪到的鱼数\n- `total_fish_count_baseline` - 容器注册总鱼数（基线）\n- `school_centroid_xy` - 鱼群质心（所有鱼 2D 位置均值）\n- `school_dispersion_score` - 群体分散度（所有鱼到质心距离的标准差，体长归一化）\n- `school_compactness_score` - 群体紧密度（0-100，越高越紧密；夜行鱼休息时自然偏低）\n\n### 个体离群信号（每条 fish_id 独立）\n- `fish_id` - 个体唯一标识（ReID 输出）\n- `fish_body_length_px` - 该鱼当前体长（像素，自动估计）\n- `fish_position_xy` - 该鱼当前 2D 位置\n- `distance_to_centroid_body_lengths` - 与质心欧氏距离（**以体长为单位**，核心指标）\n- `over_threshold_flag` - 是否超过阈值（默认 > 10 倍体长）\n- `over_threshold_duration_min` - 持续超阈时长（分钟，跨帧累计）\n\n### 上下文信号（避免误报）\n- `is_natural_solitary_species` - 是否独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷天然独居）\n- `is_breeding_period` - 是否繁殖期（公鱼护卵 / 母鱼离群产卵）\n- `is_territory_corner_fish` - 是否为领地型缸角守卫鱼（\"离群\"实为正常占地）\n- `is_during_feeding` - 是否在投喂窗口内（短时聚拢/分散为生理性）\n- `tank_has_strong_water_flow` - 是否有强水流区（被冲到角落可能误判）\n- `tank_temperature_gradient_detected` - 是否检测到温度不均（鱼可能聚于舒适温区，余者\"离群\"）\n\n## 综合判定\n\n- `schooling_normal` - 群体正常聚集\n- `schooling_loose` - 群体偏松散（但无明显离群个体）\n- `isolation_short` - 短时离群（> 10 倍体长但 < 1 小时）\n- `isolation_persistent` - **持续离群**（> 10 倍体长且 ≥ 1 小时，核心告警场景）\n- `isolation_corner_stuck` - 角落呆滞（离群 + 长时间几乎不动，疑似严重不适）\n- `multiple_isolated_individuals` - 多鱼同时离群（疑似全缸应激 / 水质恶化）\n- `isolation_signal_unreliable` - 信号不可靠（ReID 断裂 / 视野遮挡 / 浑浊度过高 / 跟踪 < 80% 鱼数）\n\n## 4 级告警策略递进\n\n- Level 1（isolation_short / schooling_loose）：仅入库或用户 APP 轻提醒\"观察某条鱼是否长期离群\"\n- Level 2（isolation_persistent，单条）：用户 APP 重要告警，建议**目视检查该鱼体表 / 游姿 / 呼吸 / 摄食活跃度**，并**评估是否隔离至检疫缸**\n- Level 3（isolation_corner_stuck / 连续 ≥ 2 日 isolation_persistent）：紧急告警，**强烈建议立即隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）**，并提示联系**当地观赏鱼兽医**\n- Level 4（multiple_isolated_individuals / 同缸 ≥ 3 条同时持续离群）：最高紧急告警 + 推送家庭/管理人员所有联系人 + 强烈建议**立即全面排查（水质 + 体表 + 游姿 + 呼吸 + 摄食）+ 联系专业人员**\n\n## 单日告警上限\n\n- Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限\n\n## 红线约束\n\n- **禁止**做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征\"等具体疾病诊断\n- **禁止**输出具体药物名称、剂量、给药方案\n- **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定）\n- **禁止**用于商业广告 / AI 训练；禁第三方共享\n- **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投药 / 灯光参数；任何水族设备控制变更必须由用户确认（仅可建议）\n- 离群距离、持续时长、群体分散度等指标必须基于真实视频帧跟踪；**禁止伪造或夸大指标**\n- 鱼种特异性：**独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷）天然不集群** → 必须按鱼种基线判定；**禁止使用通用 10 倍体长阈值盲判独居鱼种**\n- 必须考虑生理性离群上下文：**繁殖期护卵 / 母鱼产卵 / 领地型缸角守卫 / 投喂前后短时聚拢分散 / 强水流区被冲 / 温度梯度造成的舒适区聚集** → 不可直接告警\n- **必须**在 ReID 跟踪率 < 80% 或视野遮挡严重时返回 `isolation_signal_unreliable`，并建议重拍 / 调整摄像头角度；**禁止给出不可靠告警**\n- 必须告知用户：AI 行为识别仅供参考，**最终诊断与治疗方案需专业水族兽医确认**\n\n## 输出报告字段\n\n- `report_date` - 报告日期\n- `tank_id` - 鱼缸/养殖池/检疫缸 ID\n- `species` - 鱼种\n- `total_fish_count_baseline` - 注册总鱼数\n- `school_compactness_score` - 群体紧密度\n- `isolated_fish_list` - 离群个体清单（每条含 fish_id / distance_to_centroid_body_lengths / over_threshold_duration_min / 缩略图轨迹）\n- `composite_scene` - 综合判定\n- `alert_level` - 告警等级\n- `recommended_actions` - 建议动作（观察 / 隔离检疫缸 / 检查水质 / 联系兽医，**不含药物**）\n- `disclaimer` - 免责声明\n\nFile v1.0.3:skills/smyx_analysis/references/api_doc.md\n\n# API接口文档\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 请求格式：支持文件上传\n- 响应格式：JSON\n\n## 错误码说明\n\n| 错误码 | 说明       |\n|-----|----------|\n| 400 | 请求参数错误   |\n| 401 | API密钥无效  |\n| 403 | 权限不足     |\n| 413 | 文件过大     |\n| 415 | 不支持的文件格式 |\n| 500 | 服务器内部错误  |\n\nFile v1.0.3:scripts/config.yaml\n\n{}\n\nFile v1.0.3:skills/smyx_analysis/scripts/config.yaml\n\n{}\n\nFile v1.0.3:skills/smyx_common/scripts/config-dev.yaml\n\nApiEnum:\n  base-url-open-api: \"http://192.168.1.234:9601/smyx-open-api\"\n  base-url-open-h5: \"http://192.168.1.234:4100\"\n  base-url-health: \"http://192.168.1.234:7070/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.3:skills/smyx_common/scripts/config-test.yaml\n\nApiEnum:\n  base-url-open-api: \"https://livemonitortest.lifeemergence.com/smyx-open-api\"\n  base-url-open-h5: \"http://livemonitortest.lifeemergence.com\"\n  base-url-health: \"https://healthtest.lifeemergence.com/jeecg-boot-xzgz\"\n\nConstantEnum:\n  is-debug: true\n\nFile v1.0.3:skills/smyx_common/scripts/config.yaml\n\nApiEnum:\n  api-key: null\n  api-secret-key: null\n  base-url-health: https://lifeemergence.com/jeecg-boot-xzgz\n  base-url-open-api: https://open.lifeemergence.com/smyx-open-api\n  base-url-open-h5: http://livemonitor.lifeemergence.com\n  database-url: null\nConstantEnum:\n  app--id: x1a3s4nwy1s2r4se\n  current--tentant-code: XIAN_ZHAO_GAN_ZHI\n  default--skill-platform-name: ARK_CLAW\n  feishu-app--id: cli_a93d769369badcb1\n  feishu-app--secret: null\n  is-debug: false\nenv: prod\n\nFile v1.0.3:skill-card.md\n\n## Description: <br>\nAnalyzes aquarium media to detect fish schooling patterns, persistent isolation from the school centroid, unreliable tracking conditions, and suggested observation or escalation actions. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[smyx-sunjinhui](https://clawhub.ai/user/smyx-sunjinhui) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nAquarium keepers, aquaculture teams, and developers can use this skill to analyze fixed-camera fish footage or URLs for prolonged isolation behavior, schooling quality, alert severity, and non-diagnostic recommended follow-up actions. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: Aquarium media or video URLs may be processed by the Life Emergence cloud service. <br>\nMitigation: Use only media the user is comfortable sending to that service, and restrict network access or avoid private camera footage where policy requires local processing. <br>\nRisk: The skill may create or reuse a persistent account-linked identity and store tokens for history queries. <br>\nMitigation: Review token storage and account-linking behavior before deployment, and clear or isolate workspace data for shared or sensitive environments. <br>\nRisk: Behavior alerts could be mistaken for veterinary diagnosis or treatment guidance. <br>\nMitigation: Present results as behavioral signals only, avoid medication names or dosing, and direct users to a qualified aquarium veterinarian or aquaculture specialist for diagnosis and treatment. <br>\nRisk: Poor ReID tracking, occlusion, unclear water, or incomplete tank coverage can make isolation signals unreliable. <br>\nMitigation: Require clear fixed-camera footage, whole-tank coverage, and a stable tracking rate; return an unreliable-signal result instead of an alert when tracking quality is insufficient. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/smyx-sunjinhui/skills/smyx-fish-isolation-detection-analysis) <br>\n- [API documentation](artifact/references/api_doc.md) <br>\n- [Skill demo](https://lifeemergence.com/sample.html) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, markdown, JSON, guidance] <br>\n**Output Format:** [Markdown or JSON analysis report with report links and optional history-list output] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [May include isolation classifications, alert levels, tracked-fish metrics, recommended actions, and report export links.] <br>\n\n## Skill Version(s): <br>\n1.0.3 (source: ClawHub release metadata; artifact frontmatter says 1.0.5) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nFile v1.0.3:skills/smyx_analysis/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nyaml==6.0.3\n\nFile v1.0.3:skills/smyx_common/requirements.txt\n\npydash==8.0.6\nSQLAlchemy==2.0.46\nPyYAML==6.0.3\n\nArchive v1.0.2: 31 files, 44662 bytes\n\nFiles: references/api_doc.md (6925b), scripts/__init__.py (64b), scripts/config.py (684b), scripts/config.yaml (3b), scripts/skill.py (580b), scripts/smyx_fish_isolation_detection_analysis.py (3725b), skill-card.md (2727b), SKILL.md (17401b), skills/smyx_analysis/__init__.py (0b), skills/smyx_analysis/references/api_doc.md (427b), skills/smyx_analysis/requirements.txt (45b), skills/smyx_analysis/scripts/__init__.py (0b), skills/smyx_analysis/scripts/api_service.py (1509b), skills/smyx_analysis/scripts/config.py (1003b), skills/smyx_analysis/scripts/config.yaml (3b), skills/smyx_analysis/scripts/skill.py (6529b), skills/smyx_analysis/scripts/smyx_analysis.py (3833b), skills/smyx_common/__init__.py (0b), skills/smyx_common/requirements.txt (47b), skills/smyx_common/scripts/__init__.py (177b), skills/smyx_common/scripts/api_service.py (2645b), skills/smyx_common/scripts/base.py (469b), skills/smyx_common/scripts/config-dev.yaml (214b), skills/smyx_common/scripts/config-prod.yaml (0b), skills/smyx_common/scripts/config-test.yaml (256b), skills/smyx_common/scripts/config.py (24363b), skills/smyx_common/scripts/config.yaml (473b), skills/smyx_common/scripts/dao.py (18266b), skills/smyx_common/scripts/skill.py (2473b), skills/smyx_common/scripts/util.py (28605b), _meta.json (157b)\n\nFile v1.0.2:SKILL.md\n\n---\nname: \"smyx-fish-isolation-detection-analysis\"\ndescription: \"Through fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。\"\nversion: \"1.0.4\"\nlicense: \"MIT-0\"\n---\n\n# 🐟 Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别\n> **智能分析中枢** · 图片/视频智能分析 · 结构化报告 · 历史报告云端查询\n\n---\n\n## 🧭 技能概览 | Overview\n\n| 模块 | 内容 |\n|---|---|\n| 🏷️ 技能名称 | **鱼类聚集/离群行为识别** |\n| 🎯 核心目标 | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。 |\n| 🖼️ 输入类型 | 图片、视频、本地文件、网络 URL |\n| 📝 输出能力 | 结构化分析报告、识别/监测结果、建议与报告链接 |\n| 🧩 场景码 | `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` |\n\nThrough fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). When a fish drifts more than 10 body lengths away from the school center and the state lasts longer than 1 hour (or a user-defined threshold), the system outputs an 'isolation behavior' alert. This skill helps early detection of bullied, sick (e.g. parasites, bacterial infections), spawning-period solitary or environment-distressed (e.g. strong water flow, temperature gradient) individuals, prompting aquarists to inspect and intervene. Application scenarios: home aquariums, public aquariums, aquaculture ponds, quarantine tanks. The system monitors continuously and pushes reminders when prolonged isolated fish is found. Skill features: prolonged isolation is often an early signal of disease (e.g. external parasites, digestive issues) or stress from bullying. AI-based automatic identification of isolation behavior helps aquarists detect sick fish early and isolate for treatment, reducing whole-tank infection risk. This skill can be integrated into smart aquarium cameras to enhance product behavior-analysis capability.\n\n通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。该技能有助于早期发现被欺凌、生病（如寄生虫、细菌感染）、产卵期孤立或环...","readmeExcerpt":"Skill: Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别 Owner: smyx-sunjinhui Summary: Through fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 1","codeSnippets":[],"executableExamples":[{"language":"bash","snippet":"python -m scripts.smyx_fish_isolation_detection_analysis --list"},{"language":"text","snippet":"requests>=2.28.0"},{"language":"bash","snippet":"# 分析本地连续视频（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --input /path/to/tank_1h.mp4\n\n# 分析网络连续视频/实时流（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --url https://example.com/tank_1h.mp4\n\n# 显示历史离群行为记录清单（自动触发关键词：查看鱼离群历史报告、鱼缸离群行为日志清单等）\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n\n# 输出精简报告\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --detail basic\n\n# 保存结果到文件\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --output result.json"},{"language":"bash","snippet":"python -m scripts.smyx_fish_isolation_detection_analysis --list"},{"language":"text","snippet":"requests>=2.28.0"},{"language":"bash","snippet":"# 分析本地连续视频（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --input /path/to/tank_1h.mp4\n\n# 分析网络连续视频/实时流（以下只是示例，禁止直接使用 作为 open-id）\npython -m scripts.smyx_fish_isolation_detection_analysis --url https://example.com/tank_1h.mp4\n\n# 显示历史离群行为记录清单（自动触发关键词：查看鱼离群历史报告、鱼缸离群行为日志清单等）\npython -m scripts.smyx_fish_isolation_detection_analysis --list\n\n# 输出精简报告\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --detail basic\n\n# 保存结果到文件\npython -m scripts.smyx_fish_isolation_detection_analysis --input tank.mp4 --output result.json"}],"parameters":null,"dependencies":[],"permissions":[],"extractedFiles":[{"path":"SKILL.md","content":"---\nname: \"smyx-fish-isolation-detection-analysis\"\ndescription: \"Through fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。\"\nversion: \"1.0.16\"\nlicense: \"MIT-0\"\n---\n\n# 🐟 Fish Isolation / Schooling Behavior Detection | 鱼类聚集/离群行为识别\n> **智能分析中枢** · 图片/视频智能分析 · 结构化报告 · 历史报告云端查询\n\n---\n\n## 🧭 技能概览 | Overview\n\n| 模块 | 内容 |\n|---|---|\n| 🏷️ 技能名称 | **鱼类聚集/离群行为识别** |\n| 🎯 核心目标 | 通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。 |\n| 🖼️ 输入类型 | 图片、视频、本地文件、网络 URL |\n| 📝 输出能力 | 结构化分析报告、识别/监测结果、建议与报告链接 |\n| 🧩 场景码 | `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` |\n\nThrough fixed cameras on aquariums, the system continuously tracks the 2D position of each fish in the school, computes the school centroid (center of mass), and measures the distance from each fish to the centroid (in units of fish body length). When a fish drifts more than 10 body lengths away from the school center and the state lasts longer than 1 hour (or a user-defined threshold), the system outputs an 'isolation behavior' alert. This skill helps early detection of bullied, sick (e.g. parasites, bacterial infections), spawning-period solitary or environment-distressed (e.g. strong water flow, temperature gradient) individuals, prompting aquarists to inspect and intervene. Application scenarios: home aquariums, public aquariums, aquaculture ponds, quarantine tanks. The system monitors continuously and pushes reminders when prolonged isolated fish is found. Skill features: prolonged isolation is often an early signal of disease (e.g. external parasites, digestive issues) or stress from bullying. AI-based automatic identification of isolation behavior helps aquarists detect sick fish early and isolate for treatment, reducing whole-tank infection risk. This skill can be integrated into smart aquarium cameras to enhance product behavior-analysis capability.\n\n通过鱼缸固定摄像头，持续跟踪鱼群中每条鱼的二维位置，计算鱼群中心（质心），并检测每条鱼与中心的距离（以鱼体长为单位）。当某条鱼偏离鱼群中心超过 10 倍体长，且持续时间超过 1 小时（或用户设定阈值）时，输出'离群行为'提示。该技能有助于早期发现被欺凌、生病（如寄生虫、细菌感染）、产卵期孤立或环境不适（如水流过强、温度不均）的个体，提醒养鱼者及时检查干预。应用场景：家庭鱼缸、水族馆、水产养殖池、检疫缸。系统连续监测，当发现长期离群鱼只时推送提醒。技能特点：鱼只长期离群往往是疾病的早期信号（如体表寄生虫、消化问题），或受欺凌导致应激。通过 AI 自动识别离群行为，可帮助养鱼者及早发现病鱼并隔离治疗，降低全缸感染风险。该技能可集成到智能鱼缸摄像头中，提升产品行为分析能力。\n\n## 🤖 AI 角色 | AI Role\n| 角色要点 | 说明 |\n|---|---|\n| 说明 1 | **假设你是一个专业的水族行为监测 AI。你的任务是分析鱼缸固定摄像头的连续视频，跟踪每条鱼的 2D 位置（多目标跟踪 + ReID），计算鱼群质心（所有鱼位置的均值）。对每条鱼，计算其与质心的欧氏距离（**以该鱼的体长为单位**，核心量化单位）。当某条鱼的距离 > 10 倍体长（用户可配置）且该状态持续时间 ≥ 1 小时（用户可配置）时，输出离群提示。按 7 类综合场景（schooling_normal / schooling_loose / isolation_short / isolation_persistent / isolation_corner_stuck / multiple_isolated_individuals / isolation_signal_unreliable）作判定，按 4 级告警策略递进（Level 1 入库/轻提醒 → Level 2 重要告警 + 目视检查体表/游姿/呼吸"},{"path":"_meta.json","content":"{\n  \"ownerId\": \"kn7cyxkr2ymf7zwsrybpedg8xx83ywrj\",\n  \"slug\": \"smyx-fish-isolation-detection-analysis\",\n  \"version\": \"1.0.10\",\n  \"publishedAt\": 1791017560368\n}"},{"path":"references/api_doc.md","content":"# API 接口文档\n\n此处用于存放鱼类聚集/离群行为识别 API 的接口文档，待后续补充。\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 响应格式：JSON\n\n## 主要接口\n\n1. `/web/health-analysis/v2/start-health-analysis` - 启动鱼类聚集/离群行为识别任务\n2. `/web/health-analysis/v2/get-health-analysis-result` - 获取离群检测结果（离群个体清单 + 离群距离 + 持续时长）\n3. `/web/health-analysis/page-health-analysis-result` - 分页查询历史离群行为报告\n4. `/health/order/api/getReportDetailExport?id={id}` - 导出离群行为报告\n5. （可选）`/web/companion/v2/trigger-soothing-action` - 触发联动提醒（用户 APP 推送 / 智能鱼缸告警灯 / 提示隔离至检疫缸建议）\n\n## 场景代码\n\n- `SMYX_FISH_ISOLATION_DETECTION_ANALYSIS` - 鱼类聚集/离群行为识别\n\n## 输入约束\n\n- 摄像头：鱼缸固定摄像头 / 养殖池上方摄像头 / 检疫缸全景摄像头，建议**俯拍或大角度斜视**（保证 2D 位置投影稳定）\n- 分辨率 ≥ 720p；**帧率 ≥ 10 FPS**（位置跟踪需稳定）\n- 光照：建议鱼缸照明开启 + 无强反光；水质清澈（浑浊度低）\n- **核心采样窗口**：连续观察 ≥ 1 小时（用户可配置 30 分钟 - 24 小时滚动窗口）\n- 视野约束：必须覆盖整个鱼缸/养殖池**完整水平投影**（任何 dead zone 都可能误判为\"离群\"）\n- 多鱼缸/池场景按摄像头 ID 绑定到注册容器 ID\n- **多鱼场景必须接入 ReID**（多目标跟踪 + 重识别），每条鱼建立稳定 fish_id\n- **部署时必须录入**：鱼种清单、群体大小 N（用户输入或首次自动统计取众数）、每条鱼体长校准（像素 ↔ cm，可单次手动校准或自动学习）\n- 用户必须授权部署；公共水族馆 / 养殖场需公示告知\n\n## 关键观测信号\n\n### 群体几何信号\n- `tracked_fish_count` - 当前帧成功跟踪到的鱼数\n- `total_fish_count_baseline` - 容器注册总鱼数（基线）\n- `school_centroid_xy` - 鱼群质心（所有鱼 2D 位置均值）\n- `school_dispersion_score` - 群体分散度（所有鱼到质心距离的标准差，体长归一化）\n- `school_compactness_score` - 群体紧密度（0-100，越高越紧密；夜行鱼休息时自然偏低）\n\n### 个体离群信号（每条 fish_id 独立）\n- `fish_id` - 个体唯一标识（ReID 输出）\n- `fish_body_length_px` - 该鱼当前体长（像素，自动估计）\n- `fish_position_xy` - 该鱼当前 2D 位置\n- `distance_to_centroid_body_lengths` - 与质心欧氏距离（**以体长为单位**，核心指标）\n- `over_threshold_flag` - 是否超过阈值（默认 > 10 倍体长）\n- `over_threshold_duration_min` - 持续超阈时长（分钟，跨帧累计）\n\n### 上下文信号（避免误报）\n- `is_natural_solitary_species` - 是否独居鱼种（斗鱼 / 大型龙鱼 / 部分慈鲷天然独居）\n- `is_breeding_period` - 是否繁殖期（公鱼护卵 / 母鱼离群产卵）\n- `is_territory_corner_fish` - 是否为领地型缸角守卫鱼（\"离群\"实为正常占地）\n- `is_during_feeding` - 是否在投喂窗口内（短时聚拢/分散为生理性）\n- `tank_has_strong_water_flow` - 是否有强水流区（被冲到角落可能误判）\n- `tank_temperature_gradient_detected` - 是否检测到温度不均（鱼可能聚于舒适温区，余者\"离群\"）\n\n## 综合判定\n\n- `schooling_normal` - 群体正常聚集\n- `schooling_loose` - 群体偏松散（但无明显离群个体）\n- `isolation_short` - 短时离群（> 10 倍体长但 < 1 小时）\n- `isolation_persistent` - **持续离群**（> 10 倍体长且 ≥ 1 小时，核心告警场景）\n- `isolation_corner_stuck` - 角落呆滞（离群 + 长时间几乎不动，疑似严重不适）\n- `multiple_isolated_individuals` - 多鱼同时离群（疑似全缸应激 / 水质恶化）\n- `isolation_signal_unreliable` - 信号不可靠（ReID 断裂 / 视野遮挡 / 浑浊度过高 / 跟踪 < 80% 鱼数）\n\n## 4 级告警策略递进\n\n- Level 1（isolation_short / schooling_loose）：仅入库或用户 APP 轻提醒\"观察某条鱼是否长期离群\"\n- Level 2（isolation_persistent，单条）：用户 APP 重要告警，建议**目视检查该鱼体表 / 游姿 / 呼吸 / 摄食活跃度**，并**评估是否隔离至检疫缸**\n- Level 3（isolation_corner_stuck / 连续 ≥ 2 日 isolation_persistent）：紧急告警，**强烈建议立即隔离至检疫缸 + 检查水质（溶氧/pH/氨氮/温度梯度）**，并提示联系**当地观赏鱼兽医**\n- Level 4（multiple_isolated_individuals / 同缸 ≥ 3 条同时持续离群）：最高紧急告警 + 推送家庭/管理人员所有联系人 + 强烈建议**立即全面排查（水质 + 体表 + 游姿 + 呼吸 + 摄食）+ 联系专业人员**\n\n## 单日告警上限\n\n- Level 1 不限 / Level 2 × 6 / Level 3 × 3 / Level 4 不设上限\n\n## 红线约束\n\n- **禁止**做\"寄生虫 / 细菌感染 / 鳃病 / 肠炎 / 应激综合征\"等具体疾病诊断\n- **禁止**输出具体药物名称、剂量、给药方案\n- **禁止**长期存储完整鱼缸/养殖池视频（≤ 7 天，仅入库离群事件片段与轨迹摘要；公共水族馆/养殖场按管理规定）\n- **禁止**用于商业广告 / AI 训练；禁第三方共享\n- **禁止**越权代用户启停隔离泵 / 加热棒 / 换水 / 投"},{"path":"skills/smyx_analysis/references/api_doc.md","content":"# API接口文档\n\n## 接口规范\n\n- 基础地址：由 smyx_common 配置统一管理\n- 认证方式：API Key 鉴权\n- 请求格式：支持文件上传\n- 响应格式：JSON\n\n## 错误码说明\n\n| 错误码 | 说明       |\n|-----|----------|\n| 400 | 请求参数错误   |\n| 401 | API密钥无效  |\n| 403 | 权限不足     |\n| 413 | 文件过大     |\n| 415 | 不支持的文件格式 |\n| 500 | 服务器内部错误  |"},{"path":"scripts/config.yaml","content":"{}"}],"languages":[],"docsSourceLabel":"CLAWHUB","editorialOverview":null,"editorialQuality":{"score":100,"threshold":65,"status":"thin","wordCount":1176,"uniquenessScore":44,"reasons":["uniqueness-below-45"]}},"media":{"evidence":{"source":"no-media","verified":false,"confidence":"low","updatedAt":"2026-10-10T08:54:24.070Z","emptyReason":"No screenshots, media assets, or demo links are available."},"primaryImageUrl":null,"mediaAssetCount":0,"assets":[],"demoUrl":null},"ownerResources":{"evidence":{"source":"unclaimed","verified":false,"confidence":"low","updatedAt":"2026-10-10T08:54:24.070Z","emptyReason":"This page has not been claimed by the agent owner."},"hasCustomPage":false,"customPageUpdatedAt":null,"customLinks":[],"structuredLinks":{"docsUrl":null,"demoUrl":null,"supportUrl":null,"pricingUrl":null,"statusUrl":null},"customPage":null},"relatedAgents":{"evidence":{"source":"protocol-neighbors","verified":false,"confidence":"medium","updatedAt":"2026-10-10T11:52:52.166Z","emptyReason":null},"items":[{"id":"8ebccd8e-3863-4187-8355-c3f14e1f9edf","entityType":"agent","canonicalPath":"/agent/iofficeai-aionui","slug":"iofficeai-aionui","name":"AionUi","description":"Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!","url":"https://github.com/iOfficeAI/AionUi","homepage":"https://www.aionui.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-10-09T19:11:12.944Z","createdAt":"2026-02-25T03:38:16.584Z","downloads":null},{"id":"b917f68a-ebff-438e-84f8-3f4b2494c0bc","entityType":"agent","canonicalPath":"/agent/activepieces-activepieces","slug":"activepieces-activepieces","name":"activepieces","description":"AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents","url":"https://github.com/activepieces/activepieces","homepage":"https://www.activepieces.com","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-15T02:22:12.426Z","createdAt":"2026-02-25T03:38:12.412Z","downloads":null},{"id":"5cb26759-3a39-483f-94cf-276a98c13bb8","entityType":"agent","canonicalPath":"/agent/cherryhq-cherry-studio","slug":"cherryhq-cherry-studio","name":"cherry-studio","description":"AI productivity studio with smart chat, autonomous agents, and 300+ assistants. Unified access to frontier LLMs","url":"https://github.com/CherryHQ/cherry-studio","homepage":"https://cherry-ai.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-11T14:38:40.986Z","createdAt":"2026-02-25T03:38:19.379Z","downloads":null},{"id":"6f6582d0-5d76-4f0f-b81d-86520247950b","entityType":"agent","canonicalPath":"/agent/copilotkit-copilotkit","slug":"copilotkit-copilotkit","name":"CopilotKit","description":"The Frontend for Agents & Generative UI. React + Angular","url":"https://github.com/CopilotKit/CopilotKit","homepage":"https://docs.copilotkit.ai","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-03-25T09:50:57.846Z","createdAt":"2026-02-25T03:39:14.617Z","downloads":null}],"links":{"hub":"/agent","source":"/agent/source/clawhub","protocols":[{"label":"OpenClaw","href":"/agent/protocol/openclew"}]}}}