@wenathlan/saddle 1.8.7 → 1.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -18
- package/dist/adapters/forge.d.ts +17 -0
- package/dist/adapters/forge.d.ts.map +1 -0
- package/dist/adapters/forge.js +19 -0
- package/dist/adapters/forge.js.map +1 -0
- package/dist/adapters/forgejo.d.ts +49 -0
- package/dist/adapters/forgejo.d.ts.map +1 -0
- package/{adapters → dist/adapters}/forgejo.js +1 -1
- package/dist/adapters/forgejo.js.map +1 -0
- package/dist/adapters/github.d.ts +12 -0
- package/dist/adapters/github.d.ts.map +1 -0
- package/dist/adapters/github.js +20 -0
- package/dist/adapters/github.js.map +1 -0
- package/dist/adapters/gitlab.d.ts +17 -0
- package/dist/adapters/gitlab.d.ts.map +1 -0
- package/dist/adapters/gitlab.js +10 -0
- package/dist/adapters/gitlab.js.map +1 -0
- package/dist/adapters/huggingface.d.ts +17 -0
- package/dist/adapters/huggingface.d.ts.map +1 -0
- package/{adapters → dist/adapters}/huggingface.js +1 -1
- package/dist/adapters/huggingface.js.map +1 -0
- package/dist/adapters/socket.d.ts +11 -0
- package/dist/adapters/socket.d.ts.map +1 -0
- package/dist/adapters/socket.js +17 -0
- package/dist/adapters/socket.js.map +1 -0
- package/dist/adapters/transport.d.ts +7 -0
- package/dist/adapters/transport.d.ts.map +1 -0
- package/dist/adapters/transport.js +36 -0
- package/dist/adapters/transport.js.map +1 -0
- package/dist/ai/chunk.d.ts +2 -0
- package/dist/ai/chunk.d.ts.map +1 -0
- package/dist/ai/chunk.js +36 -0
- package/dist/ai/chunk.js.map +1 -0
- package/dist/ai/llmstxt.d.ts +6 -0
- package/dist/ai/llmstxt.d.ts.map +1 -0
- package/dist/ai/llmstxt.js +12 -0
- package/dist/ai/llmstxt.js.map +1 -0
- package/dist/ai/provenance.d.ts +22 -0
- package/dist/ai/provenance.d.ts.map +1 -0
- package/dist/ai/provenance.js +25 -0
- package/dist/ai/provenance.js.map +1 -0
- package/dist/ai/rag.d.ts +26 -0
- package/dist/ai/rag.d.ts.map +1 -0
- package/dist/ai/rag.js +22 -0
- package/dist/ai/rag.js.map +1 -0
- package/dist/ai/tokens.d.ts +15 -0
- package/dist/ai/tokens.d.ts.map +1 -0
- package/{ai → dist/ai}/tokens.js +1 -1
- package/dist/ai/tokens.js.map +1 -0
- package/dist/api/auth.d.ts +16 -0
- package/dist/api/auth.d.ts.map +1 -0
- package/dist/api/auth.js +19 -0
- package/dist/api/auth.js.map +1 -0
- package/dist/api/contracts.d.ts +28 -0
- package/dist/api/contracts.d.ts.map +1 -0
- package/{api → dist/api}/contracts.js +3 -6
- package/dist/api/contracts.js.map +1 -0
- package/dist/api/control.d.ts +10 -0
- package/dist/api/control.d.ts.map +1 -0
- package/dist/api/control.js +35 -0
- package/dist/api/control.js.map +1 -0
- package/dist/api/http.d.ts +7 -0
- package/dist/api/http.d.ts.map +1 -0
- package/{api → dist/api}/http.js +5 -5
- package/dist/api/http.js.map +1 -0
- package/dist/api/rate.d.ts +28 -0
- package/dist/api/rate.d.ts.map +1 -0
- package/dist/api/rate.js +36 -0
- package/dist/api/rate.js.map +1 -0
- package/dist/api/security.d.ts +12 -0
- package/dist/api/security.d.ts.map +1 -0
- package/dist/api/security.js +56 -0
- package/dist/api/security.js.map +1 -0
- package/dist/api/service.d.ts +5 -0
- package/dist/api/service.d.ts.map +1 -0
- package/dist/api/service.js +70 -0
- package/dist/api/service.js.map +1 -0
- package/dist/apps/registry.d.ts +33 -0
- package/dist/apps/registry.d.ts.map +1 -0
- package/dist/apps/registry.js +24 -0
- package/dist/apps/registry.js.map +1 -0
- package/dist/binary/build.d.ts +29 -0
- package/dist/binary/build.d.ts.map +1 -0
- package/dist/binary/build.js +17 -0
- package/dist/binary/build.js.map +1 -0
- package/dist/bot/adapter.d.ts +5 -0
- package/dist/bot/adapter.d.ts.map +1 -0
- package/dist/bot/adapter.js +11 -0
- package/dist/bot/adapter.js.map +1 -0
- package/dist/bot/bot.d.ts +28 -0
- package/dist/bot/bot.d.ts.map +1 -0
- package/dist/bot/bot.js +52 -0
- package/dist/bot/bot.js.map +1 -0
- package/dist/bot/commands.d.ts +8 -0
- package/dist/bot/commands.d.ts.map +1 -0
- package/dist/bot/commands.js +19 -0
- package/dist/bot/commands.js.map +1 -0
- package/dist/bot/permissions.d.ts +13 -0
- package/dist/bot/permissions.d.ts.map +1 -0
- package/dist/bot/permissions.js +16 -0
- package/dist/bot/permissions.js.map +1 -0
- package/dist/browser/actions.d.ts +33 -0
- package/dist/browser/actions.d.ts.map +1 -0
- package/dist/browser/actions.js +44 -0
- package/dist/browser/actions.js.map +1 -0
- package/dist/browser/agent.d.ts +21 -0
- package/dist/browser/agent.d.ts.map +1 -0
- package/dist/browser/agent.js +13 -0
- package/dist/browser/agent.js.map +1 -0
- package/dist/browser/context.d.ts +43 -0
- package/dist/browser/context.d.ts.map +1 -0
- package/dist/browser/context.js +54 -0
- package/dist/browser/context.js.map +1 -0
- package/dist/browser/fingerprint.d.ts +4 -0
- package/dist/browser/fingerprint.d.ts.map +1 -0
- package/{browser → dist/browser}/fingerprint.js +4 -4
- package/dist/browser/fingerprint.js.map +1 -0
- package/dist/browser/index.d.ts +11 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/{browser → dist/browser}/index.js +1 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/playwright.d.ts +11 -0
- package/dist/browser/playwright.d.ts.map +1 -0
- package/dist/browser/playwright.js +24 -0
- package/dist/browser/playwright.js.map +1 -0
- package/dist/browser/recorder.d.ts +27 -0
- package/dist/browser/recorder.d.ts.map +1 -0
- package/dist/browser/recorder.js +22 -0
- package/dist/browser/recorder.js.map +1 -0
- package/dist/browser/session.d.ts +14 -0
- package/dist/browser/session.d.ts.map +1 -0
- package/dist/browser/session.js +21 -0
- package/dist/browser/session.js.map +1 -0
- package/dist/browser/snapshot.d.ts +57 -0
- package/dist/browser/snapshot.d.ts.map +1 -0
- package/dist/browser/snapshot.js +57 -0
- package/dist/browser/snapshot.js.map +1 -0
- package/dist/captcha/contract.d.ts +35 -0
- package/dist/captcha/contract.d.ts.map +1 -0
- package/dist/captcha/contract.js +17 -0
- package/dist/captcha/contract.js.map +1 -0
- package/dist/captcha/evidence.d.ts +10 -0
- package/dist/captcha/evidence.d.ts.map +1 -0
- package/dist/captcha/evidence.js +9 -0
- package/dist/captcha/evidence.js.map +1 -0
- package/dist/captcha/guard.d.ts +23 -0
- package/dist/captcha/guard.d.ts.map +1 -0
- package/dist/captcha/guard.js +12 -0
- package/dist/captcha/guard.js.map +1 -0
- package/dist/cli/main.d.ts +4 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +46 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/core/errors.d.ts +84 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +54 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/events.d.ts +9 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/events.js +21 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/hash.d.ts +10 -0
- package/dist/core/hash.d.ts.map +1 -0
- package/dist/core/hash.js +82 -0
- package/dist/core/hash.js.map +1 -0
- package/dist/core/ids.d.ts +10 -0
- package/dist/core/ids.d.ts.map +1 -0
- package/dist/core/ids.js +15 -0
- package/dist/core/ids.js.map +1 -0
- package/dist/deploy/index.d.ts +6 -0
- package/dist/deploy/index.d.ts.map +1 -0
- package/dist/deploy/index.js +6 -0
- package/dist/deploy/index.js.map +1 -0
- package/dist/dispatch/resumable.d.ts +85 -0
- package/dist/dispatch/resumable.d.ts.map +1 -0
- package/dist/dispatch/resumable.js +39 -0
- package/dist/dispatch/resumable.js.map +1 -0
- package/dist/dispatch/workflow.d.ts +6 -0
- package/dist/dispatch/workflow.d.ts.map +1 -0
- package/dist/dispatch/workflow.js +37 -0
- package/dist/dispatch/workflow.js.map +1 -0
- package/dist/domain/artifacts.d.ts +12 -0
- package/dist/domain/artifacts.d.ts.map +1 -0
- package/dist/domain/artifacts.js +14 -0
- package/dist/domain/artifacts.js.map +1 -0
- package/dist/domain/jobs.d.ts +12 -0
- package/dist/domain/jobs.d.ts.map +1 -0
- package/dist/domain/jobs.js +20 -0
- package/dist/domain/jobs.js.map +1 -0
- package/dist/domain/providers.d.ts +10 -0
- package/dist/domain/providers.d.ts.map +1 -0
- package/{domain → dist/domain}/providers.js +2 -2
- package/dist/domain/providers.js.map +1 -0
- package/dist/domain/runtime.d.ts +14 -0
- package/dist/domain/runtime.d.ts.map +1 -0
- package/{domain → dist/domain}/runtime.js +3 -3
- package/dist/domain/runtime.js.map +1 -0
- package/dist/domain/sessions.d.ts +12 -0
- package/dist/domain/sessions.d.ts.map +1 -0
- package/dist/domain/sessions.js +57 -0
- package/dist/domain/sessions.js.map +1 -0
- package/dist/examples/localjob.d.ts +2 -0
- package/dist/examples/localjob.d.ts.map +1 -0
- package/{examples → dist/examples}/localjob.js +1 -1
- package/dist/examples/localjob.js.map +1 -0
- package/dist/examples/publicapi.d.ts +2 -0
- package/dist/examples/publicapi.d.ts.map +1 -0
- package/{examples → dist/examples}/publicapi.js +1 -1
- package/dist/examples/publicapi.js.map +1 -0
- package/dist/extension/build.d.ts +9 -0
- package/dist/extension/build.d.ts.map +1 -0
- package/dist/extension/build.js +61 -0
- package/dist/extension/build.js.map +1 -0
- package/dist/extension/content.d.ts +6 -0
- package/dist/extension/content.d.ts.map +1 -0
- package/dist/extension/content.js +135 -0
- package/dist/extension/content.js.map +1 -0
- package/dist/extension/index.d.ts +7 -0
- package/dist/extension/index.d.ts.map +1 -0
- package/{extension → dist/extension}/index.js +1 -0
- package/dist/extension/index.js.map +1 -0
- package/dist/extension/pagebridge.d.ts +6 -0
- package/dist/extension/pagebridge.d.ts.map +1 -0
- package/dist/extension/pagebridge.js +42 -0
- package/dist/extension/pagebridge.js.map +1 -0
- package/dist/extension/permissions.d.ts +26 -0
- package/dist/extension/permissions.d.ts.map +1 -0
- package/dist/extension/permissions.js +28 -0
- package/dist/extension/permissions.js.map +1 -0
- package/dist/extension/popup.d.ts +5 -0
- package/dist/extension/popup.d.ts.map +1 -0
- package/dist/extension/popup.js +26 -0
- package/dist/extension/popup.js.map +1 -0
- package/dist/extension/protocol.d.ts +58 -0
- package/dist/extension/protocol.d.ts.map +1 -0
- package/dist/extension/protocol.js +101 -0
- package/dist/extension/protocol.js.map +1 -0
- package/dist/extension/serviceworker.d.ts +25 -0
- package/dist/extension/serviceworker.d.ts.map +1 -0
- package/dist/extension/serviceworker.js +102 -0
- package/dist/extension/serviceworker.js.map +1 -0
- package/dist/extension/worker.d.ts +28 -0
- package/dist/extension/worker.d.ts.map +1 -0
- package/dist/extension/worker.js +22 -0
- package/dist/extension/worker.js.map +1 -0
- package/dist/format/check.d.ts +8 -0
- package/dist/format/check.d.ts.map +1 -0
- package/dist/format/check.js +38 -0
- package/dist/format/check.js.map +1 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.d.ts.map +1 -0
- package/{index.js → dist/index.js} +3 -7
- package/dist/index.js.map +1 -0
- package/dist/library/public.d.ts +53 -0
- package/dist/library/public.d.ts.map +1 -0
- package/dist/library/public.js +83 -0
- package/dist/library/public.js.map +1 -0
- package/dist/mcp/browser.d.ts +9 -0
- package/dist/mcp/browser.d.ts.map +1 -0
- package/dist/mcp/browser.js +13 -0
- package/dist/mcp/browser.js.map +1 -0
- package/dist/mcp/server.d.ts +35 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +40 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/transport.d.ts +7 -0
- package/dist/mcp/transport.d.ts.map +1 -0
- package/dist/mcp/transport.js +17 -0
- package/dist/mcp/transport.js.map +1 -0
- package/dist/memory/bridge.d.ts +14 -0
- package/dist/memory/bridge.d.ts.map +1 -0
- package/dist/memory/bridge.js +16 -0
- package/dist/memory/bridge.js.map +1 -0
- package/dist/memory/engine.d.ts +28 -0
- package/dist/memory/engine.d.ts.map +1 -0
- package/dist/memory/engine.js +59 -0
- package/dist/memory/engine.js.map +1 -0
- package/dist/memory/modes.d.ts +43 -0
- package/dist/memory/modes.d.ts.map +1 -0
- package/dist/memory/modes.js +66 -0
- package/dist/memory/modes.js.map +1 -0
- package/dist/memory/objects.d.ts +21 -0
- package/dist/memory/objects.d.ts.map +1 -0
- package/dist/memory/objects.js +20 -0
- package/dist/memory/objects.js.map +1 -0
- package/dist/memory/targets.d.ts +78 -0
- package/dist/memory/targets.d.ts.map +1 -0
- package/dist/memory/targets.js +29 -0
- package/dist/memory/targets.js.map +1 -0
- package/dist/memory/transforms.d.ts +19 -0
- package/dist/memory/transforms.d.ts.map +1 -0
- package/dist/memory/transforms.js +14 -0
- package/dist/memory/transforms.js.map +1 -0
- package/dist/modes/matrix.d.ts +23 -0
- package/dist/modes/matrix.d.ts.map +1 -0
- package/{modes → dist/modes}/matrix.js +8 -10
- package/dist/modes/matrix.js.map +1 -0
- package/dist/modes/modes.d.ts +33 -0
- package/dist/modes/modes.d.ts.map +1 -0
- package/{modes → dist/modes}/modes.js +3 -4
- package/dist/modes/modes.js.map +1 -0
- package/dist/modes/resolve.d.ts +41 -0
- package/dist/modes/resolve.d.ts.map +1 -0
- package/dist/modes/resolve.js +39 -0
- package/dist/modes/resolve.js.map +1 -0
- package/dist/observability/metrics.d.ts +14 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +18 -0
- package/dist/observability/metrics.js.map +1 -0
- package/dist/packager/manifest.d.ts +49 -0
- package/dist/packager/manifest.d.ts.map +1 -0
- package/dist/packager/manifest.js +49 -0
- package/dist/packager/manifest.js.map +1 -0
- package/dist/packager/publish.d.ts +51 -0
- package/dist/packager/publish.d.ts.map +1 -0
- package/dist/packager/publish.js +18 -0
- package/dist/packager/publish.js.map +1 -0
- package/dist/packager/targetcli.d.ts +7 -0
- package/dist/packager/targetcli.d.ts.map +1 -0
- package/dist/packager/targetcli.js +22 -0
- package/dist/packager/targetcli.js.map +1 -0
- package/dist/persistence/adapter.d.ts +5 -0
- package/dist/persistence/adapter.d.ts.map +1 -0
- package/dist/persistence/adapter.js +11 -0
- package/dist/persistence/adapter.js.map +1 -0
- package/dist/persistence/drizzle.d.ts +2 -0
- package/dist/persistence/drizzle.d.ts.map +1 -0
- package/dist/persistence/drizzle.js +12 -0
- package/dist/persistence/drizzle.js.map +1 -0
- package/dist/persistence/memory.d.ts +2 -0
- package/dist/persistence/memory.d.ts.map +1 -0
- package/dist/persistence/memory.js +27 -0
- package/dist/persistence/memory.js.map +1 -0
- package/dist/persistence/migrations.d.ts +19 -0
- package/dist/persistence/migrations.d.ts.map +1 -0
- package/{persistence → dist/persistence}/migrations.js +4 -5
- package/dist/persistence/migrations.js.map +1 -0
- package/dist/persistence/prisma.d.ts +2 -0
- package/dist/persistence/prisma.d.ts.map +1 -0
- package/dist/persistence/prisma.js +25 -0
- package/dist/persistence/prisma.js.map +1 -0
- package/dist/persistence/schema.d.ts +63 -0
- package/dist/persistence/schema.d.ts.map +1 -0
- package/dist/persistence/schema.js +28 -0
- package/dist/persistence/schema.js.map +1 -0
- package/dist/persistence/sql.d.ts +3 -0
- package/dist/persistence/sql.d.ts.map +1 -0
- package/dist/persistence/sql.js +37 -0
- package/dist/persistence/sql.js.map +1 -0
- package/dist/protocol/blocks.d.ts +10 -0
- package/dist/protocol/blocks.d.ts.map +1 -0
- package/dist/protocol/blocks.js +26 -0
- package/dist/protocol/blocks.js.map +1 -0
- package/dist/protocol/json.d.ts +6 -0
- package/dist/protocol/json.d.ts.map +1 -0
- package/{protocol → dist/protocol}/json.js +1 -0
- package/dist/protocol/json.js.map +1 -0
- package/dist/protocol/ndjson.d.ts +3 -0
- package/dist/protocol/ndjson.d.ts.map +1 -0
- package/dist/protocol/ndjson.js +20 -0
- package/dist/protocol/ndjson.js.map +1 -0
- package/dist/protocol/sse.d.ts +7 -0
- package/dist/protocol/sse.d.ts.map +1 -0
- package/dist/protocol/sse.js +25 -0
- package/dist/protocol/sse.js.map +1 -0
- package/dist/proxy/pool.d.ts +9 -0
- package/dist/proxy/pool.d.ts.map +1 -0
- package/dist/proxy/pool.js +27 -0
- package/dist/proxy/pool.js.map +1 -0
- package/dist/queue/idempotency.d.ts +10 -0
- package/dist/queue/idempotency.d.ts.map +1 -0
- package/dist/queue/idempotency.js +13 -0
- package/dist/queue/idempotency.js.map +1 -0
- package/dist/queue/persistent.d.ts +13 -0
- package/dist/queue/persistent.d.ts.map +1 -0
- package/dist/queue/persistent.js +49 -0
- package/dist/queue/persistent.js.map +1 -0
- package/dist/queue/queue.d.ts +7 -0
- package/dist/queue/queue.d.ts.map +1 -0
- package/dist/queue/queue.js +55 -0
- package/dist/queue/queue.js.map +1 -0
- package/dist/queue/saga.d.ts +5 -0
- package/dist/queue/saga.d.ts.map +1 -0
- package/dist/queue/saga.js +20 -0
- package/dist/queue/saga.js.map +1 -0
- package/dist/release/assets.d.ts +118 -0
- package/dist/release/assets.d.ts.map +1 -0
- package/dist/release/assets.js +69 -0
- package/dist/release/assets.js.map +1 -0
- package/dist/runners/health.d.ts +36 -0
- package/dist/runners/health.d.ts.map +1 -0
- package/dist/runners/health.js +26 -0
- package/dist/runners/health.js.map +1 -0
- package/dist/runners/heartbeat.d.ts +23 -0
- package/dist/runners/heartbeat.d.ts.map +1 -0
- package/dist/runners/heartbeat.js +29 -0
- package/dist/runners/heartbeat.js.map +1 -0
- package/dist/runners/inprocess.d.ts +17 -0
- package/dist/runners/inprocess.d.ts.map +1 -0
- package/dist/runners/inprocess.js +20 -0
- package/dist/runners/inprocess.js.map +1 -0
- package/dist/runners/scheduler.d.ts +5 -0
- package/dist/runners/scheduler.d.ts.map +1 -0
- package/dist/runners/scheduler.js +19 -0
- package/dist/runners/scheduler.js.map +1 -0
- package/dist/runtime/abort.d.ts +8 -0
- package/dist/runtime/abort.d.ts.map +1 -0
- package/dist/runtime/abort.js +13 -0
- package/dist/runtime/abort.js.map +1 -0
- package/dist/runtime/compatibility.d.ts +37 -0
- package/dist/runtime/compatibility.d.ts.map +1 -0
- package/{runtime → dist/runtime}/compatibility.js +1 -4
- package/dist/runtime/compatibility.js.map +1 -0
- package/dist/runtime/detect.d.ts +13 -0
- package/dist/runtime/detect.d.ts.map +1 -0
- package/dist/runtime/detect.js +18 -0
- package/dist/runtime/detect.js.map +1 -0
- package/dist/runtime/engine.d.ts +20 -0
- package/dist/runtime/engine.d.ts.map +1 -0
- package/dist/runtime/engine.js +61 -0
- package/dist/runtime/engine.js.map +1 -0
- package/dist/runtime/retry.d.ts +19 -0
- package/dist/runtime/retry.d.ts.map +1 -0
- package/dist/runtime/retry.js +54 -0
- package/dist/runtime/retry.js.map +1 -0
- package/dist/runtime/worker.d.ts +10 -0
- package/dist/runtime/worker.d.ts.map +1 -0
- package/dist/runtime/worker.js +25 -0
- package/dist/runtime/worker.js.map +1 -0
- package/dist/scrape/cache.d.ts +45 -0
- package/dist/scrape/cache.d.ts.map +1 -0
- package/dist/scrape/cache.js +45 -0
- package/dist/scrape/cache.js.map +1 -0
- package/dist/scrape/crawl.d.ts +47 -0
- package/dist/scrape/crawl.d.ts.map +1 -0
- package/dist/scrape/crawl.js +114 -0
- package/dist/scrape/crawl.js.map +1 -0
- package/dist/scrape/extract.d.ts +63 -0
- package/dist/scrape/extract.d.ts.map +1 -0
- package/dist/scrape/extract.js +47 -0
- package/dist/scrape/extract.js.map +1 -0
- package/dist/scrape/normalize.d.ts +52 -0
- package/dist/scrape/normalize.d.ts.map +1 -0
- package/dist/scrape/normalize.js +102 -0
- package/dist/scrape/normalize.js.map +1 -0
- package/dist/scrape/robots.d.ts +37 -0
- package/dist/scrape/robots.d.ts.map +1 -0
- package/dist/scrape/robots.js +71 -0
- package/dist/scrape/robots.js.map +1 -0
- package/dist/scrape/schema.d.ts +5 -0
- package/dist/scrape/schema.d.ts.map +1 -0
- package/dist/scrape/schema.js +25 -0
- package/dist/scrape/schema.js.map +1 -0
- package/dist/scrape/scraper.d.ts +6 -0
- package/dist/scrape/scraper.d.ts.map +1 -0
- package/dist/scrape/scraper.js +46 -0
- package/dist/scrape/scraper.js.map +1 -0
- package/dist/scrape/semantic.d.ts +25 -0
- package/dist/scrape/semantic.d.ts.map +1 -0
- package/dist/scrape/semantic.js +27 -0
- package/dist/scrape/semantic.js.map +1 -0
- package/dist/server/node.d.ts +7 -0
- package/dist/server/node.d.ts.map +1 -0
- package/dist/server/node.js +38 -0
- package/dist/server/node.js.map +1 -0
- package/dist/sessions/file.d.ts +25 -0
- package/dist/sessions/file.d.ts.map +1 -0
- package/dist/sessions/file.js +13 -0
- package/dist/sessions/file.js.map +1 -0
- package/dist/sessions/replay.d.ts +9 -0
- package/dist/sessions/replay.d.ts.map +1 -0
- package/dist/sessions/replay.js +70 -0
- package/dist/sessions/replay.js.map +1 -0
- package/dist/sessions/store.d.ts +25 -0
- package/dist/sessions/store.d.ts.map +1 -0
- package/dist/sessions/store.js +13 -0
- package/dist/sessions/store.js.map +1 -0
- package/dist/storage/adapter.d.ts +5 -0
- package/dist/storage/adapter.d.ts.map +1 -0
- package/dist/storage/adapter.js +11 -0
- package/dist/storage/adapter.js.map +1 -0
- package/dist/storage/cache.d.ts +23 -0
- package/dist/storage/cache.d.ts.map +1 -0
- package/dist/storage/cache.js +79 -0
- package/dist/storage/cache.js.map +1 -0
- package/dist/storage/checksum.d.ts +3 -0
- package/dist/storage/checksum.d.ts.map +1 -0
- package/dist/storage/checksum.js +19 -0
- package/dist/storage/checksum.js.map +1 -0
- package/dist/storage/chunked.d.ts +21 -0
- package/dist/storage/chunked.d.ts.map +1 -0
- package/dist/storage/chunked.js +67 -0
- package/dist/storage/chunked.js.map +1 -0
- package/dist/storage/content.d.ts +24 -0
- package/dist/storage/content.d.ts.map +1 -0
- package/dist/storage/content.js +44 -0
- package/dist/storage/content.js.map +1 -0
- package/dist/storage/filehosting.d.ts +2 -0
- package/dist/storage/filehosting.d.ts.map +1 -0
- package/dist/storage/filehosting.js +24 -0
- package/dist/storage/filehosting.js.map +1 -0
- package/dist/storage/githubcontents.d.ts +2 -0
- package/dist/storage/githubcontents.d.ts.map +1 -0
- package/dist/storage/githubcontents.js +29 -0
- package/dist/storage/githubcontents.js.map +1 -0
- package/dist/storage/index.d.ts +11 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/{storage → dist/storage}/index.js +1 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/local.d.ts +2 -0
- package/dist/storage/local.d.ts.map +1 -0
- package/dist/storage/local.js +72 -0
- package/dist/storage/local.js.map +1 -0
- package/dist/storage/memory.d.ts +6 -0
- package/dist/storage/memory.d.ts.map +1 -0
- package/dist/storage/memory.js +36 -0
- package/dist/storage/memory.js.map +1 -0
- package/dist/storage/s3compatible.d.ts +2 -0
- package/dist/storage/s3compatible.d.ts.map +1 -0
- package/dist/storage/s3compatible.js +31 -0
- package/dist/storage/s3compatible.js.map +1 -0
- package/dist/storage/sync.d.ts +47 -0
- package/dist/storage/sync.d.ts.map +1 -0
- package/dist/storage/sync.js +75 -0
- package/dist/storage/sync.js.map +1 -0
- package/dist/surfaces/adapters.d.ts +97 -0
- package/dist/surfaces/adapters.d.ts.map +1 -0
- package/dist/surfaces/adapters.js +50 -0
- package/dist/surfaces/adapters.js.map +1 -0
- package/dist/surfaces/controls.d.ts +18 -0
- package/dist/surfaces/controls.d.ts.map +1 -0
- package/dist/surfaces/controls.js +45 -0
- package/dist/surfaces/controls.js.map +1 -0
- package/dist/surfaces/manifest.d.ts +68 -0
- package/dist/surfaces/manifest.d.ts.map +1 -0
- package/dist/surfaces/manifest.js +42 -0
- package/dist/surfaces/manifest.js.map +1 -0
- package/dist/surfaces/n8n.d.ts +25 -0
- package/dist/surfaces/n8n.d.ts.map +1 -0
- package/dist/surfaces/n8n.js +31 -0
- package/dist/surfaces/n8n.js.map +1 -0
- package/dist/surfaces/operations.d.ts +32 -0
- package/dist/surfaces/operations.d.ts.map +1 -0
- package/dist/surfaces/operations.js +53 -0
- package/dist/surfaces/operations.js.map +1 -0
- package/dist/surfaces/targets.d.ts +196 -0
- package/dist/surfaces/targets.d.ts.map +1 -0
- package/dist/surfaces/targets.js +27 -0
- package/dist/surfaces/targets.js.map +1 -0
- package/dist/webhook/delivery.d.ts +18 -0
- package/dist/webhook/delivery.d.ts.map +1 -0
- package/dist/webhook/delivery.js +36 -0
- package/dist/webhook/delivery.js.map +1 -0
- package/dist/webhook/receiver.d.ts +26 -0
- package/dist/webhook/receiver.d.ts.map +1 -0
- package/dist/webhook/receiver.js +24 -0
- package/dist/webhook/receiver.js.map +1 -0
- package/dist/webhook/signature.d.ts +3 -0
- package/dist/webhook/signature.d.ts.map +1 -0
- package/{webhook → dist/webhook}/signature.js +1 -1
- package/dist/webhook/signature.js.map +1 -0
- package/dist/workflow/manifest.d.ts +21 -0
- package/dist/workflow/manifest.d.ts.map +1 -0
- package/dist/workflow/manifest.js +20 -0
- package/dist/workflow/manifest.js.map +1 -0
- package/dist/workflow/registry.d.ts +7 -0
- package/dist/workflow/registry.d.ts.map +1 -0
- package/dist/workflow/registry.js +18 -0
- package/dist/workflow/registry.js.map +1 -0
- package/dist/workflow/templates.d.ts +6 -0
- package/dist/workflow/templates.d.ts.map +1 -0
- package/dist/workflow/templates.js +18 -0
- package/dist/workflow/templates.js.map +1 -0
- package/dist/workflow/triggers.d.ts +36 -0
- package/dist/workflow/triggers.d.ts.map +1 -0
- package/dist/workflow/triggers.js +33 -0
- package/dist/workflow/triggers.js.map +1 -0
- package/docs/enginearchitecture.md +5 -4
- package/docs/gapmatrix.md +2 -2
- package/docs/libraryapi.md +4 -4
- package/docs/release.md +5 -5
- package/docs/releaseassets.md +1 -1
- package/docs/reorganization-1.8.8.md +31 -0
- package/docs/reorganization-1.8.9.md +28 -0
- package/docs/toolchainresearch-1.8.9.md +18 -0
- package/extension/manifest.json +1 -1
- package/package.json +61 -91
- package/adapters/forge.js +0 -16
- package/adapters/github.js +0 -19
- package/adapters/gitlab.js +0 -10
- package/adapters/socket.js +0 -14
- package/adapters/transport.js +0 -30
- package/ai/chunk.js +0 -22
- package/ai/llmstxt.js +0 -12
- package/ai/provenance.js +0 -18
- package/ai/rag.js +0 -14
- package/api/auth.js +0 -13
- package/api/control.js +0 -33
- package/api/rate.js +0 -31
- package/api/security.js +0 -42
- package/api/service.js +0 -36
- package/binary/build.js +0 -17
- package/bot/adapter.js +0 -8
- package/bot/bot.js +0 -39
- package/bot/commands.js +0 -18
- package/bot/permissions.js +0 -16
- package/browser/actions.js +0 -33
- package/browser/agent.js +0 -9
- package/browser/context.js +0 -52
- package/browser/playwright.js +0 -22
- package/browser/recorder.js +0 -21
- package/browser/session.js +0 -19
- package/browser/snapshot.js +0 -57
- package/captcha/contract.js +0 -15
- package/captcha/evidence.js +0 -9
- package/captcha/guard.js +0 -10
- package/cli/main.js +0 -36
- package/core/errors.js +0 -37
- package/core/events.js +0 -21
- package/core/hash.js +0 -73
- package/core/ids.js +0 -15
- package/crawl/crawler.js +0 -29
- package/crawl/frontier.js +0 -34
- package/crawl/normalize.js +0 -14
- package/crawl/persistent.js +0 -13
- package/dispatch/resumable.js +0 -31
- package/dispatch/workflow.js +0 -33
- package/domain/artifacts.js +0 -13
- package/domain/jobs.js +0 -20
- package/domain/sessions.js +0 -46
- package/errors/taxonomy.js +0 -18
- package/extension/build.js +0 -46
- package/extension/content.js +0 -127
- package/extension/pagebridge.js +0 -41
- package/extension/permissions.js +0 -22
- package/extension/popup.css +0 -13
- package/extension/popup.html +0 -24
- package/extension/popup.js +0 -25
- package/extension/protocol.js +0 -95
- package/extension/serviceworker.js +0 -109
- package/extension/worker.js +0 -22
- package/format/check.js +0 -21
- package/library/public.js +0 -85
- package/mcp/browser.js +0 -12
- package/mcp/server.js +0 -28
- package/mcp/transport.js +0 -14
- package/memory/bridge.js +0 -16
- package/memory/engine.js +0 -45
- package/memory/modes.js +0 -55
- package/memory/objects.js +0 -18
- package/memory/targets.js +0 -21
- package/memory/transforms.js +0 -15
- package/modes/resolve.js +0 -39
- package/packager/manifest.js +0 -28
- package/packager/publish.js +0 -15
- package/persistence/adapter.js +0 -8
- package/persistence/drizzle.js +0 -10
- package/persistence/memory.js +0 -26
- package/persistence/prisma.js +0 -23
- package/persistence/schema.js +0 -29
- package/persistence/sql.js +0 -30
- package/protocol/blocks.js +0 -18
- package/protocol/ndjson.js +0 -17
- package/protocol/sse.js +0 -22
- package/proxy/pool.js +0 -12
- package/queue/idempotency.js +0 -12
- package/queue/persistent.js +0 -44
- package/queue/queue.js +0 -50
- package/queue/saga.js +0 -13
- package/release/assets.js +0 -70
- package/retry/circuit.js +0 -15
- package/retry/policy.js +0 -12
- package/runners/health.js +0 -23
- package/runners/heartbeat.js +0 -26
- package/runners/inprocess.js +0 -19
- package/runners/scheduler.js +0 -16
- package/runtime/abort.js +0 -10
- package/runtime/detect.js +0 -14
- package/runtime/engine.js +0 -56
- package/runtime/worker.js +0 -18
- package/scrape/agent.ts +0 -122
- package/scrape/batch.ts +0 -79
- package/scrape/biome.json +0 -76
- package/scrape/browser.ts +0 -222
- package/scrape/cache.js +0 -14
- package/scrape/cache.ts +0 -84
- package/scrape/chunking.ts +0 -193
- package/scrape/cli.ts +0 -105
- package/scrape/crawler.ts +0 -115
- package/scrape/dev-server.ts +0 -94
- package/scrape/errors.ts +0 -132
- package/scrape/events.ts +0 -26
- package/scrape/extract.js +0 -14
- package/scrape/extract.ts +0 -165
- package/scrape/fetch.ts +0 -105
- package/scrape/formats.ts +0 -85
- package/scrape/headers.ts +0 -71
- package/scrape/index.ts +0 -92
- package/scrape/jsdom.d.ts +0 -6
- package/scrape/llms-txt.ts +0 -84
- package/scrape/middleware.ts +0 -90
- package/scrape/normalize.js +0 -86
- package/scrape/pool.ts +0 -95
- package/scrape/port.ts +0 -18
- package/scrape/proxy.ts +0 -103
- package/scrape/rate-limiter.ts +0 -95
- package/scrape/renderer.ts +0 -194
- package/scrape/retry.ts +0 -64
- package/scrape/robots.js +0 -32
- package/scrape/robots.ts +0 -137
- package/scrape/schema.js +0 -21
- package/scrape/scrape.ts +0 -123
- package/scrape/scraper.js +0 -40
- package/scrape/semantic.js +0 -22
- package/scrape/serialize.ts +0 -310
- package/scrape/server.ts +0 -137
- package/scrape/session.ts +0 -109
- package/scrape/sitemap.ts +0 -131
- package/scrape/tokens.ts +0 -45
- package/scrape/tsconfig.json +0 -28
- package/scrape/types.ts +0 -214
- package/scrape/utils.ts +0 -77
- package/scrape/vite.config.ts +0 -55
- package/scrape/vitest.config.ts +0 -17
- package/server/node.js +0 -34
- package/sessions/file.js +0 -13
- package/sessions/replay.js +0 -61
- package/sessions/store.js +0 -13
- package/storage/adapter.js +0 -8
- package/storage/cache.js +0 -54
- package/storage/checksum.js +0 -17
- package/storage/chunked.js +0 -58
- package/storage/content.js +0 -42
- package/storage/filehosting.js +0 -17
- package/storage/githubcontents.js +0 -18
- package/storage/local.js +0 -35
- package/storage/memory.js +0 -28
- package/storage/s3compatible.js +0 -23
- package/storage/sync.js +0 -55
- package/surfaces/adapters.js +0 -48
- package/surfaces/controls.js +0 -37
- package/surfaces/manifest.js +0 -25
- package/surfaces/n8n.js +0 -24
- package/surfaces/operations.js +0 -43
- package/surfaces/targets.js +0 -16
- package/webhook/delivery.js +0 -26
- package/webhook/receiver.js +0 -20
- package/workflow/manifest.js +0 -20
- package/workflow/registry.js +0 -16
- package/workflow/templates.js +0 -18
- package/workflow/triggers.js +0 -31
package/scrape/chunking.ts
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { estimateTokens } from './tokens.js';
|
|
2
|
-
|
|
3
|
-
export interface ChunkOptions {
|
|
4
|
-
maxTokens?: number;
|
|
5
|
-
overlapTokens?: number;
|
|
6
|
-
preserveCodeBlocks?: boolean;
|
|
7
|
-
includeHeadingPath?: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface Chunk {
|
|
11
|
-
content: string;
|
|
12
|
-
headingPath: string[];
|
|
13
|
-
tokenCount: number;
|
|
14
|
-
index: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const DEFAULT_CHUNK_OPTIONS: Required<ChunkOptions> = {
|
|
18
|
-
maxTokens: 512,
|
|
19
|
-
overlapTokens: 50,
|
|
20
|
-
preserveCodeBlocks: true,
|
|
21
|
-
includeHeadingPath: true,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function splitByHeaders(markdown: string): { heading: string; level: number; content: string }[] {
|
|
25
|
-
const sections: { heading: string; level: number; content: string }[] = [];
|
|
26
|
-
const lines = markdown.split('\n');
|
|
27
|
-
let currentHeading = '';
|
|
28
|
-
let currentLevel = 0;
|
|
29
|
-
let currentContent: string[] = [];
|
|
30
|
-
|
|
31
|
-
for (const line of lines) {
|
|
32
|
-
const headerMatch = line.match(/^(#{1,6})\s+(.+)/);
|
|
33
|
-
if (headerMatch) {
|
|
34
|
-
if (currentContent.length > 0 || currentHeading) {
|
|
35
|
-
sections.push({
|
|
36
|
-
heading: currentHeading,
|
|
37
|
-
level: currentLevel,
|
|
38
|
-
content: currentContent.join('\n').trim(),
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
currentLevel = headerMatch[1].length;
|
|
42
|
-
currentHeading = headerMatch[2];
|
|
43
|
-
currentContent = [];
|
|
44
|
-
} else {
|
|
45
|
-
currentContent.push(line);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (currentContent.length > 0 || currentHeading) {
|
|
50
|
-
sections.push({
|
|
51
|
-
heading: currentHeading,
|
|
52
|
-
level: currentLevel,
|
|
53
|
-
content: currentContent.join('\n').trim(),
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return sections;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function splitByParagraphs(text: string): string[] {
|
|
61
|
-
return text.split(/\n\n+/).filter(p => p.trim().length > 0);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function splitBySentences(text: string): string[] {
|
|
65
|
-
return text.match(/[^.!?]+[.!?]+/g) || [text];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function chunkMarkdown(markdown: string, options: ChunkOptions = {}): Chunk[] {
|
|
69
|
-
const opts = { ...DEFAULT_CHUNK_OPTIONS, ...options };
|
|
70
|
-
const chunks: Chunk[] = [];
|
|
71
|
-
const sections = splitByHeaders(markdown);
|
|
72
|
-
const headingPath: string[] = [];
|
|
73
|
-
let headingDepth = 0;
|
|
74
|
-
|
|
75
|
-
for (const section of sections) {
|
|
76
|
-
while (headingDepth > 0 && headingDepth >= section.level) {
|
|
77
|
-
headingDepth--;
|
|
78
|
-
headingPath.pop();
|
|
79
|
-
}
|
|
80
|
-
if (section.heading) {
|
|
81
|
-
headingDepth = section.level;
|
|
82
|
-
headingPath.push(section.heading);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const sectionText = section.heading ? `#${'#'.repeat(section.level - 1)} ${section.heading}\n\n${section.content}` : section.content;
|
|
86
|
-
|
|
87
|
-
if (estimateTokens(sectionText) <= opts.maxTokens) {
|
|
88
|
-
chunks.push({
|
|
89
|
-
content: sectionText,
|
|
90
|
-
headingPath: opts.includeHeadingPath ? [...headingPath] : [],
|
|
91
|
-
tokenCount: estimateTokens(sectionText),
|
|
92
|
-
index: chunks.length,
|
|
93
|
-
});
|
|
94
|
-
} else {
|
|
95
|
-
const paragraphs = splitByParagraphs(sectionText);
|
|
96
|
-
let currentChunk = '';
|
|
97
|
-
|
|
98
|
-
for (const paragraph of paragraphs) {
|
|
99
|
-
const testChunk = currentChunk ? `${currentChunk}\n\n${paragraph}` : paragraph;
|
|
100
|
-
|
|
101
|
-
if (estimateTokens(testChunk) <= opts.maxTokens) {
|
|
102
|
-
currentChunk = testChunk;
|
|
103
|
-
} else {
|
|
104
|
-
if (currentChunk) {
|
|
105
|
-
chunks.push({
|
|
106
|
-
content: currentChunk,
|
|
107
|
-
headingPath: opts.includeHeadingPath ? [...headingPath] : [],
|
|
108
|
-
tokenCount: estimateTokens(currentChunk),
|
|
109
|
-
index: chunks.length,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (estimateTokens(paragraph) > opts.maxTokens) {
|
|
114
|
-
const sentences = splitBySentences(paragraph);
|
|
115
|
-
let sentenceChunk = '';
|
|
116
|
-
for (const sentence of sentences) {
|
|
117
|
-
const testSentence = sentenceChunk ? `${sentenceChunk} ${sentence}` : sentence;
|
|
118
|
-
if (estimateTokens(testSentence) <= opts.maxTokens) {
|
|
119
|
-
sentenceChunk = testSentence;
|
|
120
|
-
} else {
|
|
121
|
-
if (sentenceChunk) {
|
|
122
|
-
chunks.push({
|
|
123
|
-
content: sentenceChunk,
|
|
124
|
-
headingPath: opts.includeHeadingPath ? [...headingPath] : [],
|
|
125
|
-
tokenCount: estimateTokens(sentenceChunk),
|
|
126
|
-
index: chunks.length,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
sentenceChunk = sentence;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
currentChunk = sentenceChunk;
|
|
133
|
-
} else {
|
|
134
|
-
currentChunk = paragraph;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (currentChunk) {
|
|
140
|
-
chunks.push({
|
|
141
|
-
content: currentChunk,
|
|
142
|
-
headingPath: opts.includeHeadingPath ? [...headingPath] : [],
|
|
143
|
-
tokenCount: estimateTokens(currentChunk),
|
|
144
|
-
index: chunks.length,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return chunks;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export function chunkText(text: string, options: ChunkOptions = {}): Chunk[] {
|
|
154
|
-
const opts = { ...DEFAULT_CHUNK_OPTIONS, ...options };
|
|
155
|
-
const chunks: Chunk[] = [];
|
|
156
|
-
const paragraphs = splitByParagraphs(text);
|
|
157
|
-
let currentChunk = '';
|
|
158
|
-
|
|
159
|
-
for (const paragraph of paragraphs) {
|
|
160
|
-
const testChunk = currentChunk ? `${currentChunk}\n\n${paragraph}` : paragraph;
|
|
161
|
-
if (estimateTokens(testChunk) <= opts.maxTokens) {
|
|
162
|
-
currentChunk = testChunk;
|
|
163
|
-
} else {
|
|
164
|
-
if (currentChunk) {
|
|
165
|
-
chunks.push({
|
|
166
|
-
content: currentChunk,
|
|
167
|
-
headingPath: [],
|
|
168
|
-
tokenCount: estimateTokens(currentChunk),
|
|
169
|
-
index: chunks.length,
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
currentChunk = paragraph;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (currentChunk) {
|
|
177
|
-
chunks.push({
|
|
178
|
-
content: currentChunk,
|
|
179
|
-
headingPath: [],
|
|
180
|
-
tokenCount: estimateTokens(currentChunk),
|
|
181
|
-
index: chunks.length,
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return chunks;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export function formatChunksForRAG(chunks: Chunk[]): string {
|
|
189
|
-
return chunks.map(chunk => {
|
|
190
|
-
const heading = chunk.headingPath.length > 0 ? `## ${chunk.headingPath.join(' > ')}\n\n` : '';
|
|
191
|
-
return `${heading}${chunk.content}`;
|
|
192
|
-
}).join('\n\n---\n\n');
|
|
193
|
-
}
|
package/scrape/cli.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
import { readFileSync, existsSync } from 'node:fs';
|
|
4
|
-
import { resolve } from 'node:path';
|
|
5
|
-
import { scrapeUrl, scrapeHtml } from './scrape.js';
|
|
6
|
-
import { serializeResult } from './serialize.js';
|
|
7
|
-
import { resolveFormat, extensionForFormat, buildSerializeOptions } from './formats.js';
|
|
8
|
-
import { formatForAgent } from './agent.js';
|
|
9
|
-
import { writeOutput } from './utils.js';
|
|
10
|
-
import type { ScrapeOptions, ScrapeResult } from './types.js';
|
|
11
|
-
|
|
12
|
-
const program = new Command();
|
|
13
|
-
|
|
14
|
-
program
|
|
15
|
-
.name('webscrape')
|
|
16
|
-
.description('DevThink WebScrape — Universal AI-powered web scraping toolkit')
|
|
17
|
-
.version('2.0.0');
|
|
18
|
-
|
|
19
|
-
program
|
|
20
|
-
.argument('[url]', 'URL to scrape')
|
|
21
|
-
.option('-f, --format <type>', 'Output format: markdown, html, text, json, xml, redis', 'markdown')
|
|
22
|
-
.option('-o, --output <file>', 'Write output to file')
|
|
23
|
-
.option('--file <path>', 'Scrape HTML from local file')
|
|
24
|
-
.option('--mode <mode>', 'Scraping mode: auto, fetch, browser', 'auto')
|
|
25
|
-
.option('--no-headless', 'Show browser window')
|
|
26
|
-
.option('--timeout <ms>', 'Navigation timeout', '30000')
|
|
27
|
-
.option('--scroll', 'Scroll page to load dynamic content')
|
|
28
|
-
.option('--readable', 'Extract readable content only')
|
|
29
|
-
.option('--agent', 'Format output for AI agent consumption')
|
|
30
|
-
.option('--pretty', 'Pretty-print JSON output')
|
|
31
|
-
.option('--proxy <url>', 'Proxy server URL')
|
|
32
|
-
.option('--retries <n>', 'Number of retries', '3')
|
|
33
|
-
.option('--user-agent <ua>', 'Custom User-Agent string')
|
|
34
|
-
.action(async (url, options) => {
|
|
35
|
-
if (!url && !options.file) {
|
|
36
|
-
program.help();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const format = resolveFormat(options.format);
|
|
40
|
-
const scrapeOpts: ScrapeOptions = {
|
|
41
|
-
format,
|
|
42
|
-
timeout: parseInt(options.timeout),
|
|
43
|
-
scroll: options.scroll,
|
|
44
|
-
readable: options.readable,
|
|
45
|
-
mode: options.mode,
|
|
46
|
-
proxy: options.proxy,
|
|
47
|
-
retries: parseInt(options.retries),
|
|
48
|
-
userAgent: options.userAgent,
|
|
49
|
-
extractLinks: true,
|
|
50
|
-
extractImages: true,
|
|
51
|
-
extractTables: true,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
if (options.readable) {
|
|
55
|
-
scrapeOpts.removeSelectors = [
|
|
56
|
-
'script', 'style', 'nav', 'footer', 'header',
|
|
57
|
-
'.sidebar', '.advertisement', '.ads', '.menu',
|
|
58
|
-
'.comments', '.comment', '#comments',
|
|
59
|
-
];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
console.error(`Scraping: ${url || options.file}`);
|
|
63
|
-
|
|
64
|
-
let result: ScrapeResult;
|
|
65
|
-
|
|
66
|
-
if (options.file) {
|
|
67
|
-
const filePath = resolve(options.file);
|
|
68
|
-
if (!existsSync(filePath)) {
|
|
69
|
-
console.error(`File not found: ${filePath}`);
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
const html = readFileSync(filePath, 'utf-8');
|
|
73
|
-
result = await scrapeHtml(html, scrapeOpts);
|
|
74
|
-
} else {
|
|
75
|
-
result = await scrapeUrl(url, scrapeOpts);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
console.error(`Done in ${result.duration}ms (${(result.size / 1024).toFixed(1)} KB)`);
|
|
79
|
-
|
|
80
|
-
if (options.agent) {
|
|
81
|
-
const agentOutput = formatForAgent(result);
|
|
82
|
-
const output = JSON.stringify(agentOutput, null, 2);
|
|
83
|
-
|
|
84
|
-
if (options.output) {
|
|
85
|
-
writeOutput(options.output, output);
|
|
86
|
-
console.error(`Saved to ${options.output}`);
|
|
87
|
-
} else {
|
|
88
|
-
console.log(output);
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
const serializeOpts = buildSerializeOptions(format, options.pretty);
|
|
92
|
-
const serialized = serializeResult(result, serializeOpts);
|
|
93
|
-
|
|
94
|
-
if (options.output) {
|
|
95
|
-
const ext = extensionForFormat(format);
|
|
96
|
-
const finalPath = options.output.endsWith(ext) ? options.output : options.output + ext;
|
|
97
|
-
writeOutput(finalPath, serialized.content);
|
|
98
|
-
console.error(`Saved to ${finalPath}`);
|
|
99
|
-
} else {
|
|
100
|
-
console.log(serialized.content);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
program.parse();
|
package/scrape/crawler.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import type { ScrapeOptions, ScrapeResult, CrawlStats } from './types.js';
|
|
2
|
-
import { scrapeUrl } from './scrape.js';
|
|
3
|
-
|
|
4
|
-
export interface CrawlOptions extends ScrapeOptions {
|
|
5
|
-
maxDepth?: number;
|
|
6
|
-
maxPages?: number;
|
|
7
|
-
maxConcurrent?: number;
|
|
8
|
-
sameDomain?: boolean;
|
|
9
|
-
delayMs?: number;
|
|
10
|
-
onDiscover?: (url: string, depth: number) => void;
|
|
11
|
-
onResult?: (result: ScrapeResult) => void;
|
|
12
|
-
onError?: (url: string, error: Error) => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface CrawlEntry {
|
|
16
|
-
url: string;
|
|
17
|
-
depth: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function isSameDomain(url1: string, url2: string): boolean {
|
|
21
|
-
try {
|
|
22
|
-
return new URL(url1).hostname === new URL(url2).hostname;
|
|
23
|
-
} catch {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function normalizeForDedup(url: string): string {
|
|
29
|
-
try {
|
|
30
|
-
const u = new URL(url);
|
|
31
|
-
u.hash = '';
|
|
32
|
-
u.search = '';
|
|
33
|
-
return u.href.replace(/\/+$/, '') || u.href;
|
|
34
|
-
} catch {
|
|
35
|
-
return url;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export async function crawl(
|
|
40
|
-
startUrl: string,
|
|
41
|
-
options: CrawlOptions = {}
|
|
42
|
-
): Promise<{ results: ScrapeResult[]; stats: CrawlStats }> {
|
|
43
|
-
const {
|
|
44
|
-
maxDepth = 2,
|
|
45
|
-
maxPages = 50,
|
|
46
|
-
maxConcurrent = 3,
|
|
47
|
-
sameDomain = true,
|
|
48
|
-
delayMs = 1000,
|
|
49
|
-
onDiscover,
|
|
50
|
-
onResult,
|
|
51
|
-
onError,
|
|
52
|
-
...scrapeOpts
|
|
53
|
-
} = options;
|
|
54
|
-
|
|
55
|
-
const startTime = Date.now();
|
|
56
|
-
const visited = new Set<string>();
|
|
57
|
-
const queue: CrawlEntry[] = [{ url: startUrl, depth: 0 }];
|
|
58
|
-
const results: ScrapeResult[] = [];
|
|
59
|
-
let failed = 0;
|
|
60
|
-
|
|
61
|
-
visited.add(normalizeForDedup(startUrl));
|
|
62
|
-
|
|
63
|
-
while (queue.length > 0 && results.length < maxPages) {
|
|
64
|
-
const batch = queue.splice(0, maxConcurrent);
|
|
65
|
-
const promises = batch.map(async (entry) => {
|
|
66
|
-
if (entry.depth > maxDepth) return;
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
const result = await scrapeUrl(entry.url, scrapeOpts);
|
|
70
|
-
results.push(result);
|
|
71
|
-
onResult?.(result);
|
|
72
|
-
|
|
73
|
-
// Extract links for further crawling
|
|
74
|
-
if (entry.depth < maxDepth) {
|
|
75
|
-
for (const link of result.links) {
|
|
76
|
-
const normalized = normalizeForDedup(link.href);
|
|
77
|
-
if (visited.has(normalized)) continue;
|
|
78
|
-
if (sameDomain && !isSameDomain(startUrl, link.href)) continue;
|
|
79
|
-
try {
|
|
80
|
-
new URL(link.href);
|
|
81
|
-
} catch {
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
visited.add(normalized);
|
|
85
|
-
queue.push({ url: link.href, depth: entry.depth + 1 });
|
|
86
|
-
onDiscover?.(link.href, entry.depth + 1);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
} catch (error) {
|
|
90
|
-
failed++;
|
|
91
|
-
onError?.(entry.url, error as Error);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
await Promise.all(promises);
|
|
96
|
-
|
|
97
|
-
if (delayMs > 0 && queue.length > 0) {
|
|
98
|
-
await new Promise(r => setTimeout(r, delayMs));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const duration = Date.now() - startTime;
|
|
103
|
-
|
|
104
|
-
return {
|
|
105
|
-
results,
|
|
106
|
-
stats: {
|
|
107
|
-
totalUrls: visited.size,
|
|
108
|
-
successful: results.length,
|
|
109
|
-
failed,
|
|
110
|
-
skipped: visited.size - results.length - failed,
|
|
111
|
-
duration,
|
|
112
|
-
avgResponseTime: results.length > 0 ? results.reduce((sum, r) => sum + r.duration, 0) / results.length : 0,
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
}
|
package/scrape/dev-server.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createServer } from 'node:http';
|
|
3
|
-
|
|
4
|
-
import { scrapeUrl } from './scrape.js';
|
|
5
|
-
import { serializeResult } from './serialize.js';
|
|
6
|
-
import { resolveFormat, buildSerializeOptions } from './formats.js';
|
|
7
|
-
import { formatForAgent } from './agent.js';
|
|
8
|
-
import { randomPort } from './utils/port.js';
|
|
9
|
-
import type { ScrapeOptions } from './types.js';
|
|
10
|
-
|
|
11
|
-
const PORT = randomPort();
|
|
12
|
-
|
|
13
|
-
const server = createServer(async (req, res) => {
|
|
14
|
-
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
15
|
-
res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
|
|
16
|
-
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
|
17
|
-
|
|
18
|
-
if (req.method === 'OPTIONS') {
|
|
19
|
-
res.writeHead(200);
|
|
20
|
-
res.end();
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (req.method !== 'POST' || req.url !== '/api/scrape') {
|
|
25
|
-
res.writeHead(404);
|
|
26
|
-
res.end(JSON.stringify({ error: 'Not found' }));
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let body = '';
|
|
31
|
-
req.on('data', (chunk: Buffer) => { body += chunk.toString(); });
|
|
32
|
-
req.on('end', async () => {
|
|
33
|
-
try {
|
|
34
|
-
const { url, format: fmt, options = {} }: {
|
|
35
|
-
url: string;
|
|
36
|
-
format?: string;
|
|
37
|
-
options?: Record<string, unknown>;
|
|
38
|
-
} = JSON.parse(body);
|
|
39
|
-
if (!url) throw new Error('URL is required');
|
|
40
|
-
|
|
41
|
-
const format = resolveFormat(fmt || 'markdown');
|
|
42
|
-
const result = await scrapeUrl(url, {
|
|
43
|
-
timeout: 30000,
|
|
44
|
-
scroll: options.scroll as boolean,
|
|
45
|
-
extractLinks: (options.extractLinks as boolean) ?? true,
|
|
46
|
-
extractImages: (options.extractImages as boolean) ?? true,
|
|
47
|
-
extractTables: (options.extractTables as boolean) ?? true,
|
|
48
|
-
} as ScrapeOptions);
|
|
49
|
-
|
|
50
|
-
let response: Record<string, unknown>;
|
|
51
|
-
|
|
52
|
-
if (options.agent) {
|
|
53
|
-
const agentOutput = formatForAgent(result);
|
|
54
|
-
response = {
|
|
55
|
-
success: true,
|
|
56
|
-
title: result.title,
|
|
57
|
-
url: result.url,
|
|
58
|
-
duration: result.duration,
|
|
59
|
-
size: result.size,
|
|
60
|
-
agentOutput,
|
|
61
|
-
};
|
|
62
|
-
} else {
|
|
63
|
-
const serializeOpts = buildSerializeOptions(format);
|
|
64
|
-
const serialized = serializeResult(result, serializeOpts);
|
|
65
|
-
response = {
|
|
66
|
-
success: true,
|
|
67
|
-
title: result.title,
|
|
68
|
-
url: result.url,
|
|
69
|
-
format,
|
|
70
|
-
content: serialized.content,
|
|
71
|
-
duration: result.duration,
|
|
72
|
-
size: serialized.size,
|
|
73
|
-
metadata: result.metadata,
|
|
74
|
-
links: result.links,
|
|
75
|
-
images: result.images,
|
|
76
|
-
tables: result.tables,
|
|
77
|
-
result,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
82
|
-
res.end(JSON.stringify(response));
|
|
83
|
-
} catch (err) {
|
|
84
|
-
const error = err as Error;
|
|
85
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
86
|
-
res.end(JSON.stringify({ error: error.message }));
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
server.listen(PORT, () => {
|
|
92
|
-
console.log(`API server running at http://localhost:${PORT}`);
|
|
93
|
-
console.log(`POST /api/scrape with { url, format?, options? }`);
|
|
94
|
-
});
|
package/scrape/errors.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
export const ErrorCode = {
|
|
2
|
-
VALIDATION_FAILED: 'VALIDATION_FAILED',
|
|
3
|
-
INVALID_URL: 'INVALID_URL',
|
|
4
|
-
TIMEOUT: 'TIMEOUT',
|
|
5
|
-
BLOCKED: 'BLOCKED',
|
|
6
|
-
RATE_LIMITED: 'RATE_LIMITED',
|
|
7
|
-
PROXY_ERROR: 'PROXY_ERROR',
|
|
8
|
-
PARSE_ERROR: 'PARSE_ERROR',
|
|
9
|
-
AUTH_REQUIRED: 'AUTH_REQUIRED',
|
|
10
|
-
NETWORK_ERROR: 'NETWORK_ERROR',
|
|
11
|
-
BROWSER_NOT_AVAILABLE: 'BROWSER_NOT_AVAILABLE',
|
|
12
|
-
CRAWL_DEPTH_EXCEEDED: 'CRAWL_DEPTH_EXCEEDED',
|
|
13
|
-
MAX_RETRIES_EXCEEDED: 'MAX_RETRIES_EXCEEDED',
|
|
14
|
-
} as const;
|
|
15
|
-
|
|
16
|
-
export type ErrorCode = typeof ErrorCode[keyof typeof ErrorCode];
|
|
17
|
-
|
|
18
|
-
export class WebScrapeError extends Error {
|
|
19
|
-
public readonly code: ErrorCode;
|
|
20
|
-
public readonly statusCode: number;
|
|
21
|
-
public readonly isRetryable: boolean;
|
|
22
|
-
public readonly timestamp: string;
|
|
23
|
-
public readonly details?: Record<string, unknown>;
|
|
24
|
-
public readonly cause?: Error;
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
message: string,
|
|
28
|
-
code: ErrorCode,
|
|
29
|
-
statusCode: number,
|
|
30
|
-
isRetryable: boolean,
|
|
31
|
-
details?: Record<string, unknown>,
|
|
32
|
-
cause?: Error
|
|
33
|
-
) {
|
|
34
|
-
super(message);
|
|
35
|
-
this.name = 'WebScrapeError';
|
|
36
|
-
this.code = code;
|
|
37
|
-
this.statusCode = statusCode;
|
|
38
|
-
this.isRetryable = isRetryable;
|
|
39
|
-
this.timestamp = new Date().toISOString();
|
|
40
|
-
this.details = details;
|
|
41
|
-
this.cause = cause;
|
|
42
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
43
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
toJSON() {
|
|
47
|
-
return {
|
|
48
|
-
error: {
|
|
49
|
-
name: this.name,
|
|
50
|
-
code: this.code,
|
|
51
|
-
message: this.message,
|
|
52
|
-
statusCode: this.statusCode,
|
|
53
|
-
isRetryable: this.isRetryable,
|
|
54
|
-
timestamp: this.timestamp,
|
|
55
|
-
details: this.details,
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export class ValidationError extends WebScrapeError {
|
|
62
|
-
constructor(message: string, details?: Record<string, unknown>, cause?: Error) {
|
|
63
|
-
super(message, ErrorCode.VALIDATION_FAILED, 400, false, details, cause);
|
|
64
|
-
this.name = 'ValidationError';
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export class TimeoutError extends WebScrapeError {
|
|
69
|
-
constructor(message: string, details?: Record<string, unknown>, cause?: Error) {
|
|
70
|
-
super(message, ErrorCode.TIMEOUT, 504, true, details, cause);
|
|
71
|
-
this.name = 'TimeoutError';
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export class BlockedError extends WebScrapeError {
|
|
76
|
-
constructor(message: string, details?: Record<string, unknown>, cause?: Error) {
|
|
77
|
-
super(message, ErrorCode.BLOCKED, 403, false, details, cause);
|
|
78
|
-
this.name = 'BlockedError';
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export class RateLimitError extends WebScrapeError {
|
|
83
|
-
public readonly retryAfterMs?: number;
|
|
84
|
-
constructor(
|
|
85
|
-
message: string,
|
|
86
|
-
retryAfterMs?: number,
|
|
87
|
-
details?: Record<string, unknown>,
|
|
88
|
-
cause?: Error
|
|
89
|
-
) {
|
|
90
|
-
super(message, ErrorCode.RATE_LIMITED, 429, true, { ...details, retryAfterMs }, cause);
|
|
91
|
-
this.name = 'RateLimitError';
|
|
92
|
-
this.retryAfterMs = retryAfterMs;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export class ProxyError extends WebScrapeError {
|
|
97
|
-
constructor(message: string, details?: Record<string, unknown>, cause?: Error) {
|
|
98
|
-
super(message, ErrorCode.PROXY_ERROR, 502, true, details, cause);
|
|
99
|
-
this.name = 'ProxyError';
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export class ParseError extends WebScrapeError {
|
|
104
|
-
constructor(message: string, details?: Record<string, unknown>, cause?: Error) {
|
|
105
|
-
super(message, ErrorCode.PARSE_ERROR, 422, false, details, cause);
|
|
106
|
-
this.name = 'ParseError';
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export class AuthError extends WebScrapeError {
|
|
111
|
-
constructor(message: string, details?: Record<string, unknown>, cause?: Error) {
|
|
112
|
-
super(message, ErrorCode.AUTH_REQUIRED, 401, false, details, cause);
|
|
113
|
-
this.name = 'AuthError';
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export class NetworkError extends WebScrapeError {
|
|
118
|
-
constructor(message: string, details?: Record<string, unknown>, cause?: Error) {
|
|
119
|
-
super(message, ErrorCode.NETWORK_ERROR, 503, true, details, cause);
|
|
120
|
-
this.name = 'NetworkError';
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export class BrowserNotAvailableError extends WebScrapeError {
|
|
125
|
-
constructor(
|
|
126
|
-
message: string = 'Playwright is not installed. Install it with: npm install playwright',
|
|
127
|
-
details?: Record<string, unknown>
|
|
128
|
-
) {
|
|
129
|
-
super(message, ErrorCode.BROWSER_NOT_AVAILABLE, 500, false, details);
|
|
130
|
-
this.name = 'BrowserNotAvailableError';
|
|
131
|
-
}
|
|
132
|
-
}
|
package/scrape/events.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import Emittery from 'emittery';
|
|
2
|
-
import type { ScrapeOptions } from './types.js';
|
|
3
|
-
|
|
4
|
-
export interface WebScrapeEvents {
|
|
5
|
-
'request:start': { url: string; options: ScrapeOptions; timestamp: number };
|
|
6
|
-
'request:response': { url: string; status: number; attempt: number; duration: number };
|
|
7
|
-
'request:error': { url: string; error: Error; attempt: number };
|
|
8
|
-
'request:retry': { url: string; attempt: number; maxRetries: number; delayMs: number };
|
|
9
|
-
'request:complete': { url: string; duration: number; success: boolean };
|
|
10
|
-
'cache:hit': { key: string };
|
|
11
|
-
'cache:miss': { key: string };
|
|
12
|
-
'cache:set': { key: string; ttlMs?: number };
|
|
13
|
-
'proxy:rotate': { proxy: string; reason: string };
|
|
14
|
-
'proxy:error': { proxy: string; error: Error };
|
|
15
|
-
'proxy:disabled': { proxy: string; reason: string };
|
|
16
|
-
'crawl:discover': { url: string; depth: number; parentUrl?: string };
|
|
17
|
-
'crawl:complete': { totalUrls: number; successful: number; failed: number; duration: number };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type EventEmitter = Emittery<WebScrapeEvents>;
|
|
21
|
-
|
|
22
|
-
export function createEventEmitter(): EventEmitter {
|
|
23
|
-
return new Emittery<WebScrapeEvents>();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const globalEmitter = createEventEmitter();
|
package/scrape/extract.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* structured first extraction uses small built in heuristics and returns serializable data.
|
|
3
|
-
*/
|
|
4
|
-
export function extracthtml(html, url) {
|
|
5
|
-
const title = match(html, /<title[^>]*>([\s\S]*?)<\/title>/i);
|
|
6
|
-
const description = match(html, /<meta[^>]+name=["']description["'][^>]+content=["']([^"']*)["']/i) ?? match(html, /<meta[^>]+content=["']([^"']*)["'][^>]+name=["']description["']/i);
|
|
7
|
-
const links = [...html.matchAll(/<a[^>]+href=["']([^"']+)["'][^>]*>/gi)].map((item) => resolveurl(item[1], url)).filter(Boolean);
|
|
8
|
-
const text = html.replace(/<script[\s\S]*?<\/script>/gi, " ").replace(/<style[\s\S]*?<\/style>/gi, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
9
|
-
return { url, title: decode(title ?? ""), description: decode(description ?? ""), text, links: [...new Set(links)] };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function match(value, expression) { return value.match(expression)?.[1]?.trim(); }
|
|
13
|
-
function decode(value) { return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll(""", '"'); }
|
|
14
|
-
function resolveurl(value, base) { try { return base ? new URL(value, base).href : new URL(value).href; } catch { return null; } }
|