mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
fix(agent): replace jsdom with linkedom to fix Docker EISDIR error (#186)
jsdom relies on Node.js-specific APIs that Bun cannot properly resolve when running a bundled artifact. This caused an EISDIR error in Docker containers (Bun tried to read the jsdom directory as a file). Replace jsdom with linkedom, a lightweight pure-JS DOM implementation that is fully compatible with Bun and @mozilla/readability. Also remove the --external jsdom build flag since linkedom bundles cleanly. Closes #181
This commit is contained in:
@@ -17,10 +17,9 @@
|
||||
"@ai-sdk/mcp": "^1.0.6",
|
||||
"@ai-sdk/openai": "^3.0.7",
|
||||
"@mozilla/readability": "^0.6.0",
|
||||
"@types/jsdom": "^27.0.0",
|
||||
"@types/turndown": "^5.0.6",
|
||||
"ai": "^6.0.25",
|
||||
"jsdom": "^27.4.0",
|
||||
"linkedom": "^0.18.12",
|
||||
"toml": "^3.0.0",
|
||||
"turndown": "^7.2.2",
|
||||
"yaml": "^2.8.2",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { tool } from 'ai'
|
||||
import { z } from 'zod'
|
||||
import { Readability } from '@mozilla/readability'
|
||||
import { JSDOM } from 'jsdom'
|
||||
import { parseHTML } from 'linkedom'
|
||||
import TurndownService from 'turndown'
|
||||
|
||||
const turndownService = new TurndownService()
|
||||
@@ -76,8 +76,8 @@ export const getWebTools = () => {
|
||||
|
||||
case 'markdown': {
|
||||
try {
|
||||
const dom = new JSDOM(content, { url })
|
||||
const reader = new Readability(dom.window.document)
|
||||
const { document } = parseHTML(content)
|
||||
const reader = new Readability(document as unknown as Document)
|
||||
const article = reader.parse()
|
||||
|
||||
if (!article || !article.content) {
|
||||
|
||||
Reference in New Issue
Block a user