- Notifications
You must be signed in to change notification settings - Fork 212
Fix anime-watch-hub #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -57,40 +57,33 @@ export function useAnimeSearch() { | |
| try { | ||
| const data = JSON.parse(line.slice(6)) | ||
| | ||
| if (data.streamingUrl) { | ||
| if (data.type === 'STREAMING_URL' && data.streaming_url) { | ||
| updateAgent(platform.id, { | ||
| status: 'browsing', | ||
| streamingUrl: data.streamingUrl, | ||
| streamingUrl: data.streaming_url, | ||
| statusMessage: 'Browsing platform...', | ||
| }) | ||
| } | ||
| | ||
| if (data.type === 'STATUS' && data.message) { | ||
| updateAgent(platform.id, { statusMessage: data.message }) | ||
| if (data.type === 'PROGRESS' && data.purpose) { | ||
| updateAgent(platform.id, { statusMessage: data.purpose }) | ||
| } | ||
| | ||
| if (data.type === 'COMPLETE') { | ||
| let result = { | ||
| available: false, | ||
| message: 'Check completed', | ||
| if (data.status === 'failed') { | ||
| updateAgent(platform.id, { | ||
| status: 'error', | ||
| statusMessage: data.error?.message ?? 'Automation failed', | ||
| streamingUrl: undefined, | ||
| }) | ||
| } else { | ||
| updateAgent(platform.id, { | ||
| status: 'complete', | ||
| result: data.result, | ||
| statusMessage: undefined, | ||
| Comment on lines +60 to +83 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash set -euo pipefail echo "== Documented Mino SSE fields ==" rg -n -C2 'streamingUrl|type":"STATUS"|resultJson' anime-watch-hub/docs/mino-api-integration.md echo echo "== Current client parser ==" sed -n '56,85p' anime-watch-hub/hooks/use-anime-search.ts echo echo "== Server proxy behavior ==" sed -n '88,97p' anime-watch-hub/app/api/check-platform/route.ts echo echo "== Downstream UI dependence on agent.result.available ==" rg -n -C2 'result\?\.available' anime-watch-hub/components/platform-card.tsxRepository: tinyfish-io/tinyfish-cookbook Length of output: 4228 Fix schema mismatch between Mino SSE and client parser. The documented Mino SSE schema (lines 256–265 in
The hook parser (lines 60–83 in
Since 🔧 Proposed compatibility fix- if (data.type === 'STREAMING_URL' && data.streaming_url) { + const streamingUrl = data.streamingUrl ?? data.streaming_url + if (streamingUrl) { updateAgent(platform.id, { status: 'browsing', - streamingUrl: data.streaming_url, + streamingUrl, statusMessage: 'Browsing platform...', }) } - if (data.type === 'PROGRESS' && data.purpose) { - updateAgent(platform.id, { statusMessage: data.purpose }) + const progressMessage = + data.type === 'STATUS' + ? data.message + : data.type === 'PROGRESS' + ? data.purpose + : undefined + if (progressMessage) { + updateAgent(platform.id, { statusMessage: progressMessage }) } if (data.type === 'COMPLETE') { if (data.status === 'failed') { updateAgent(platform.id, { @@ } else { + const result = + data.result ?? + (typeof data.resultJson === 'string' + ? JSON.parse(data.resultJson) + : data.resultJson) + updateAgent(platform.id, { status: 'complete', - result: data.result, + result, statusMessage: undefined, streamingUrl: undefined, }) } }🤖 Prompt for AI Agents | ||
| streamingUrl: undefined, | ||
| }) | ||
| } | ||
| | ||
| if (data.resultJson) { | ||
| try { | ||
| result = typeof data.resultJson === 'string' | ||
| ? JSON.parse(data.resultJson) | ||
| : data.resultJson | ||
| } catch { | ||
| // Use default result if parsing fails | ||
| } | ||
| } | ||
| | ||
| updateAgent(platform.id, { | ||
| status: 'complete', | ||
| result, | ||
| statusMessage: undefined, | ||
| streamingUrl: undefined, | ||
| }) | ||
| } | ||
| | ||
| if (data.type === 'ERROR') { | ||
| | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: tinyfish-io/tinyfish-cookbook
Length of output: 100
🏁 Script executed:
Repository: tinyfish-io/tinyfish-cookbook
Length of output: 1292
🏁 Script executed:
Repository: tinyfish-io/tinyfish-cookbook
Length of output: 117
🏁 Script executed:
Repository: tinyfish-io/tinyfish-cookbook
Length of output: 89
🏁 Script executed:
# Read the platform-card.tsx file to verify the actual code cat -n anime-watch-hub/components/platform-card.tsxRepository: tinyfish-io/tinyfish-cookbook
Length of output: 5057
🏁 Script executed:
Repository: tinyfish-io/tinyfish-cookbook
Length of output: 164
🏁 Script executed:
Repository: tinyfish-io/tinyfish-cookbook
Length of output: 2016
🏁 Script executed:
# Read types.ts to check MinoAgentState definition and streamingUrl type cat -n anime-watch-hub/lib/types.tsRepository: tinyfish-io/tinyfish-cookbook
Length of output: 1761
🏁 Script executed:
# Check the start of use-anime-search.ts to see where the SSE endpoint comes from head -50 anime-watch-hub/hooks/use-anime-search.tsRepository: tinyfish-io/tinyfish-cookbook
Length of output: 1619
Harden iframe sandbox + validate streaming URL before render
Line 72 enables scripts and forms while line 69 renders
agent.streamingUrldirectly. ThestreamingUrloriginates from external SSE payloads via/api/check-platform(anime-watch-hub/hooks/use-anime-search.ts, line 64) with no origin validation or format checking before assignment to state. This creates a high-risk trust boundary: an attacker controlling the backend or intercepting the SSE stream could inject arbitrary URLs that execute scripts inside your app frame. Gate the URL with a strict HTTPS origin allowlist and removeallow-same-originunless absolutely required.🔒 Suggested fix (least-privilege + allowlist)
🤖 Prompt for AI Agents