@wenathlan/saddle 1.8.8 → 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 +15 -15
- 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} +1 -0
- 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 +2 -2
- package/docs/gapmatrix.md +2 -2
- package/docs/libraryapi.md +1 -1
- package/docs/release.md +5 -5
- package/docs/releaseassets.md +1 -1
- 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 -88
- 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 -57
- package/core/events.js +0 -21
- package/core/hash.js +0 -73
- package/core/ids.js +0 -15
- 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/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/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/retry.js +0 -27
- 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/crawl.js +0 -104
- 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/serialize.ts
DELETED
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import { JSDOM } from 'jsdom';
|
|
2
|
-
import type { SerializeOptions, SerializedOutput, ScrapeResult } from './types.js';
|
|
3
|
-
import { chunkText } from './utils.js';
|
|
4
|
-
|
|
5
|
-
function htmlToMarkdown(html: string): string {
|
|
6
|
-
const dom = new JSDOM(html);
|
|
7
|
-
const doc = dom.window.document;
|
|
8
|
-
let md = '';
|
|
9
|
-
|
|
10
|
-
function processNode(node: globalThis.Node, depth = 0): void {
|
|
11
|
-
if (node.nodeType === 3) {
|
|
12
|
-
const text = (node as globalThis.Text).textContent?.trim();
|
|
13
|
-
if (text) md += text + ' ';
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (node.nodeType !== 1) return;
|
|
17
|
-
const el = node as globalThis.Element;
|
|
18
|
-
const tag = el.tagName.toLowerCase();
|
|
19
|
-
|
|
20
|
-
switch (tag) {
|
|
21
|
-
case 'h1': case 'h2': case 'h3': case 'h4': case 'h5': case 'h6': {
|
|
22
|
-
const level = parseInt(tag[1]);
|
|
23
|
-
md += '\n' + '#'.repeat(level) + ' ' + el.textContent?.trim() + '\n\n';
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
case 'p':
|
|
27
|
-
md += '\n' + el.textContent?.trim() + '\n\n';
|
|
28
|
-
break;
|
|
29
|
-
case 'br':
|
|
30
|
-
md += '\n';
|
|
31
|
-
break;
|
|
32
|
-
case 'hr':
|
|
33
|
-
md += '\n---\n\n';
|
|
34
|
-
break;
|
|
35
|
-
case 'ul': case 'ol': {
|
|
36
|
-
el.childNodes.forEach(li => {
|
|
37
|
-
if (li.nodeType === 1) {
|
|
38
|
-
const liEl = li as globalThis.Element;
|
|
39
|
-
if (liEl.tagName.toLowerCase() === 'li') {
|
|
40
|
-
md += ' '.repeat(depth) + '- ' + liEl.textContent?.trim() + '\n';
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
md += '\n';
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
case 'a': {
|
|
48
|
-
const href = el.getAttribute('href') || '';
|
|
49
|
-
const text = el.textContent?.trim() || href;
|
|
50
|
-
if (href && href !== '#') md += `[${text}](${href}) `;
|
|
51
|
-
else md += text + ' ';
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
case 'img': {
|
|
55
|
-
const src = el.getAttribute('src') || '';
|
|
56
|
-
const alt = el.getAttribute('alt') || '';
|
|
57
|
-
if (src) md += ` `;
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
case 'strong': case 'b':
|
|
61
|
-
md += '**' + el.textContent?.trim() + '** ';
|
|
62
|
-
break;
|
|
63
|
-
case 'em': case 'i':
|
|
64
|
-
md += '*' + el.textContent?.trim() + '* ';
|
|
65
|
-
break;
|
|
66
|
-
case 'code':
|
|
67
|
-
md += '`' + el.textContent?.trim() + '` ';
|
|
68
|
-
break;
|
|
69
|
-
case 'pre': {
|
|
70
|
-
const code = el.querySelector('code');
|
|
71
|
-
const lang = code?.getAttribute('class')?.replace(/^language-/, '') || '';
|
|
72
|
-
md += '\n```' + lang + '\n' + (code || el).textContent + '\n```\n\n';
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
case 'blockquote':
|
|
76
|
-
md += '\n> ' + el.textContent?.trim().replace(/\n/g, '\n> ') + '\n\n';
|
|
77
|
-
break;
|
|
78
|
-
case 'table': {
|
|
79
|
-
const rows = el.querySelectorAll('tr');
|
|
80
|
-
rows.forEach((row, i) => {
|
|
81
|
-
const cells = row.querySelectorAll('td, th');
|
|
82
|
-
md += '| ' + Array.from(cells).map(c => c.textContent?.trim()).join(' | ') + ' |\n';
|
|
83
|
-
if (i === 0 && row.parentElement?.tagName === 'THEAD') {
|
|
84
|
-
md += '|' + Array.from(cells).map(() => ' --- ').join('|') + '|\n';
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
md += '\n';
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
default:
|
|
91
|
-
el.childNodes.forEach(child => processNode(child, depth));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
doc.body?.childNodes.forEach((child: globalThis.Node) => processNode(child));
|
|
96
|
-
return md.replace(/\n{3,}/g, '\n\n').trim();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function htmlToXml(html: string, root = 'document'): string {
|
|
100
|
-
const dom = new JSDOM(html);
|
|
101
|
-
const doc = dom.window.document;
|
|
102
|
-
|
|
103
|
-
function serialize(el: globalThis.Element, depth = 0): string {
|
|
104
|
-
const indent = ' '.repeat(depth);
|
|
105
|
-
const tag = el.tagName.toLowerCase();
|
|
106
|
-
if (el.childNodes.length === 0) {
|
|
107
|
-
return `${indent}<${tag} />\n`;
|
|
108
|
-
}
|
|
109
|
-
const text = el.textContent?.trim();
|
|
110
|
-
if (el.childNodes.length === 1 && el.firstChild?.nodeType === 3 && text) {
|
|
111
|
-
return `${indent}<${tag}>${escapeXml(text)}</${tag}>\n`;
|
|
112
|
-
}
|
|
113
|
-
let xml = `${indent}<${tag}>\n`;
|
|
114
|
-
el.childNodes.forEach(child => {
|
|
115
|
-
if (child.nodeType === 1) xml += serialize(child as globalThis.Element, depth + 1);
|
|
116
|
-
else if (child.nodeType === 3 && (child as globalThis.Text).textContent?.trim()) {
|
|
117
|
-
xml += `${indent} ${escapeXml((child as globalThis.Text).textContent!.trim())}\n`;
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
xml += `${indent}</${tag}>\n`;
|
|
121
|
-
return xml;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function escapeXml(s: string): string {
|
|
125
|
-
return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
let xml = `<?xml version="1.0" encoding="UTF-8"?>\n<${root}>\n`;
|
|
129
|
-
doc.body?.childNodes.forEach((child: globalThis.Node) => {
|
|
130
|
-
if (child.nodeType === 1) xml += serialize(child as globalThis.Element, 1);
|
|
131
|
-
});
|
|
132
|
-
xml += `</${root}>\n`;
|
|
133
|
-
return xml;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function htmlToRedisJson(html: string, key = 'page'): string {
|
|
137
|
-
const dom = new JSDOM(html);
|
|
138
|
-
const doc = dom.window.document;
|
|
139
|
-
|
|
140
|
-
function extract(el: globalThis.Element): Record<string, unknown> {
|
|
141
|
-
const tag = el.tagName.toLowerCase();
|
|
142
|
-
const children = Array.from(el.children);
|
|
143
|
-
if (children.length === 0) return { _tag: tag, _text: el.textContent?.trim() || '' };
|
|
144
|
-
const result: Record<string, unknown> = { _tag: tag };
|
|
145
|
-
if (el.getAttribute('href')) result.href = el.getAttribute('href')!;
|
|
146
|
-
if (el.getAttribute('src')) result.src = el.getAttribute('src')!;
|
|
147
|
-
if (el.getAttribute('alt')) result.alt = el.getAttribute('alt')!;
|
|
148
|
-
if (el.getAttribute('class')) result.class = el.getAttribute('class')!;
|
|
149
|
-
children.forEach(child => {
|
|
150
|
-
const childTag = child.tagName.toLowerCase();
|
|
151
|
-
if (result[childTag]) {
|
|
152
|
-
if (!Array.isArray(result[childTag])) result[childTag] = [result[childTag]];
|
|
153
|
-
(result[childTag] as unknown[]).push(extract(child));
|
|
154
|
-
} else {
|
|
155
|
-
result[childTag] = extract(child);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
return result;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const title = doc.title;
|
|
162
|
-
const bodyArr: Record<string, unknown>[] = [];
|
|
163
|
-
doc.body?.childNodes.forEach((child: globalThis.Node) => {
|
|
164
|
-
if (child.nodeType === 1) bodyArr.push(extract(child as globalThis.Element));
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
const json: Record<string, unknown> = {
|
|
168
|
-
title,
|
|
169
|
-
body: bodyArr,
|
|
170
|
-
links: Array.from(doc.querySelectorAll('a[href]')).map((a) => ({
|
|
171
|
-
href: (a as globalThis.Element).getAttribute('href'),
|
|
172
|
-
text: (a as globalThis.Element).textContent?.trim(),
|
|
173
|
-
})),
|
|
174
|
-
images: Array.from(doc.querySelectorAll('img[src]')).map((img) => ({
|
|
175
|
-
src: (img as globalThis.Element).getAttribute('src'),
|
|
176
|
-
alt: (img as globalThis.Element).getAttribute('alt'),
|
|
177
|
-
})),
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
return `JSON.SET ${key} $ ${JSON.stringify(json, null, 2)}`;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function plainText(html: string): string {
|
|
184
|
-
return html
|
|
185
|
-
.replace(/<style[^>]*>.*?<\/style>/gs, '')
|
|
186
|
-
.replace(/<script[^>]*>.*?<\/script>/gs, '')
|
|
187
|
-
.replace(/<br\s*\/?>/gi, '\n')
|
|
188
|
-
.replace(/<\/p>/gi, '\n\n')
|
|
189
|
-
.replace(/<\/h[1-6]>/gi, '\n')
|
|
190
|
-
.replace(/<\/li>/gi, '\n')
|
|
191
|
-
.replace(/<\/tr>/gi, '\n')
|
|
192
|
-
.replace(/<\/td>/gi, ' | ')
|
|
193
|
-
.replace(/<\/th>/gi, ' | ')
|
|
194
|
-
.replace(/<[^>]+>/g, '')
|
|
195
|
-
.replace(/ /g, ' ')
|
|
196
|
-
.replace(/&/g, '&')
|
|
197
|
-
.replace(/</g, '<')
|
|
198
|
-
.replace(/>/g, '>')
|
|
199
|
-
.replace(/"/g, '"')
|
|
200
|
-
.replace(/'/g, "'")
|
|
201
|
-
.replace(/\n{3,}/g, '\n\n')
|
|
202
|
-
.trim();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function tableToMarkdown(headers: string[], rows: string[][], caption?: string): string {
|
|
206
|
-
let md = caption ? `### ${caption}\n\n` : '';
|
|
207
|
-
md += '| ' + headers.join(' | ') + ' |\n';
|
|
208
|
-
md += '|' + headers.map(() => ' --- ').join('|') + '|\n';
|
|
209
|
-
for (const row of rows) {
|
|
210
|
-
md += '| ' + row.join(' | ') + ' |\n';
|
|
211
|
-
}
|
|
212
|
-
return md + '\n';
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export function serializeResult(result: ScrapeResult, options: SerializeOptions): SerializedOutput {
|
|
216
|
-
let content = '';
|
|
217
|
-
|
|
218
|
-
if (options.includeMetadata !== false) {
|
|
219
|
-
content += `# ${result.title}\n\n`;
|
|
220
|
-
content += `- **URL:** ${result.url}\n`;
|
|
221
|
-
content += `- **Extracted:** ${result.extractedAt}\n`;
|
|
222
|
-
if (result.metadata.author) content += `- **Author:** ${result.metadata.author}\n`;
|
|
223
|
-
if (result.metadata.publishedDate) content += `- **Published:** ${result.metadata.publishedDate}\n`;
|
|
224
|
-
content += `- **Size:** ${result.size} bytes\n\n---\n\n`;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
switch (options.format) {
|
|
228
|
-
case 'markdown':
|
|
229
|
-
content += result.content;
|
|
230
|
-
if (result.tables.length) {
|
|
231
|
-
content += '\n\n## Tables\n\n';
|
|
232
|
-
for (const t of result.tables) {
|
|
233
|
-
content += tableToMarkdown(t.headers, t.rows, t.caption);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
break;
|
|
237
|
-
|
|
238
|
-
case 'text':
|
|
239
|
-
content += result.text;
|
|
240
|
-
break;
|
|
241
|
-
|
|
242
|
-
case 'xml':
|
|
243
|
-
content = htmlToXml(`<html><head><title>${result.title}</title></head><body>${result.content}</body></html>`, options.xmlRoot || 'document');
|
|
244
|
-
break;
|
|
245
|
-
|
|
246
|
-
case 'json':
|
|
247
|
-
content = JSON.stringify({
|
|
248
|
-
title: result.title,
|
|
249
|
-
url: result.url,
|
|
250
|
-
metadata: result.metadata,
|
|
251
|
-
content: result.content,
|
|
252
|
-
links: result.links,
|
|
253
|
-
images: result.images,
|
|
254
|
-
tables: result.tables,
|
|
255
|
-
extractedAt: result.extractedAt,
|
|
256
|
-
duration: result.duration,
|
|
257
|
-
}, null, options.pretty ? 2 : undefined);
|
|
258
|
-
break;
|
|
259
|
-
|
|
260
|
-
case 'redis':
|
|
261
|
-
content = htmlToRedisJson(`<html><head><title>${result.title}</title></head><body>${result.content}</body></html>`, options.redisKey || `page:${encodeURIComponent(result.url)}`);
|
|
262
|
-
break;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const chunks = options.maxChunkSize ? chunkText(content, options.maxChunkSize) : [];
|
|
266
|
-
|
|
267
|
-
const output: SerializedOutput = {
|
|
268
|
-
format: options.format,
|
|
269
|
-
content,
|
|
270
|
-
chunks: chunks.length ? chunks : undefined,
|
|
271
|
-
size: content.length,
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
if (options.includeMetadata) {
|
|
275
|
-
output.metadata = {
|
|
276
|
-
title: result.title,
|
|
277
|
-
url: result.url,
|
|
278
|
-
format: result.format,
|
|
279
|
-
extractedAt: result.extractedAt,
|
|
280
|
-
duration: result.duration,
|
|
281
|
-
linkCount: result.links.length,
|
|
282
|
-
imageCount: result.images.length,
|
|
283
|
-
tableCount: result.tables.length,
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return output;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
export function serializeHtml(html: string, options: SerializeOptions): SerializedOutput {
|
|
291
|
-
const content = (() => {
|
|
292
|
-
switch (options.format) {
|
|
293
|
-
case 'markdown': return htmlToMarkdown(html);
|
|
294
|
-
case 'xml': return htmlToXml(html, options.xmlRoot || 'document');
|
|
295
|
-
case 'json': return JSON.stringify({ html }, null, options.pretty ? 2 : undefined);
|
|
296
|
-
case 'redis': return htmlToRedisJson(html, options.redisKey || 'page:1');
|
|
297
|
-
case 'text': return plainText(html);
|
|
298
|
-
default: return plainText(html);
|
|
299
|
-
}
|
|
300
|
-
})();
|
|
301
|
-
|
|
302
|
-
const chunks = options.maxChunkSize ? chunkText(content, options.maxChunkSize) : [];
|
|
303
|
-
|
|
304
|
-
return {
|
|
305
|
-
format: options.format,
|
|
306
|
-
content,
|
|
307
|
-
chunks: chunks.length ? chunks : undefined,
|
|
308
|
-
size: content.length,
|
|
309
|
-
};
|
|
310
|
-
}
|
package/scrape/server.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { Hono } from 'hono';
|
|
2
|
-
import { cors } from 'hono/cors';
|
|
3
|
-
import { scrapeUrl } from './scrape.js';
|
|
4
|
-
import { batchScrape } from './batch.js';
|
|
5
|
-
import { crawl } from './crawler.js';
|
|
6
|
-
import { formatForAgent } from './agent.js';
|
|
7
|
-
import { randomPort } from './utils/port.js';
|
|
8
|
-
import type { ScrapeOptions } from './types.js';
|
|
9
|
-
|
|
10
|
-
export interface ServerConfig {
|
|
11
|
-
port?: number;
|
|
12
|
-
host?: string;
|
|
13
|
-
apiKey?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const app = new Hono();
|
|
17
|
-
|
|
18
|
-
app.use('*', cors());
|
|
19
|
-
|
|
20
|
-
const api = new Hono();
|
|
21
|
-
|
|
22
|
-
api.post('/scrape', async (c) => {
|
|
23
|
-
const body = await c.req.json();
|
|
24
|
-
const { url, options = {} } = body;
|
|
25
|
-
|
|
26
|
-
if (!url) {
|
|
27
|
-
return c.json({ error: { code: 'MISSING_URL', message: 'URL is required' } }, 400);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
const result = await scrapeUrl(url, options as ScrapeOptions);
|
|
32
|
-
return c.json({ status: 'ok', data: result });
|
|
33
|
-
} catch (error) {
|
|
34
|
-
return c.json({
|
|
35
|
-
error: {
|
|
36
|
-
code: (error as any).code || 'SCRAPE_ERROR',
|
|
37
|
-
message: (error as Error).message,
|
|
38
|
-
}
|
|
39
|
-
}, (error as any).statusCode || 500);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
api.post('/scrape/agent', async (c) => {
|
|
44
|
-
const body = await c.req.json();
|
|
45
|
-
const { url, options = {} } = body;
|
|
46
|
-
|
|
47
|
-
if (!url) {
|
|
48
|
-
return c.json({ error: { code: 'MISSING_URL', message: 'URL is required' } }, 400);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
const result = await scrapeUrl(url, options as ScrapeOptions);
|
|
53
|
-
const agentOutput = formatForAgent(result);
|
|
54
|
-
return c.json({ status: 'ok', data: agentOutput });
|
|
55
|
-
} catch (error) {
|
|
56
|
-
return c.json({
|
|
57
|
-
error: {
|
|
58
|
-
code: (error as any).code || 'SCRAPE_ERROR',
|
|
59
|
-
message: (error as Error).message,
|
|
60
|
-
}
|
|
61
|
-
}, (error as any).statusCode || 500);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
api.post('/batch', async (c) => {
|
|
66
|
-
const body = await c.req.json();
|
|
67
|
-
const { urls, options = {}, scrapeOptions = {} } = body;
|
|
68
|
-
|
|
69
|
-
if (!urls || !Array.isArray(urls) || urls.length === 0) {
|
|
70
|
-
return c.json({ error: { code: 'MISSING_URLS', message: 'urls array is required' } }, 400);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
const result = await batchScrape({ urls, ...options }, scrapeOptions as ScrapeOptions);
|
|
75
|
-
return c.json({
|
|
76
|
-
status: 'ok',
|
|
77
|
-
data: {
|
|
78
|
-
successful: result.successful,
|
|
79
|
-
failed: result.failed,
|
|
80
|
-
duration: result.duration,
|
|
81
|
-
results: result.results,
|
|
82
|
-
errors: result.errors.map(e => ({ url: e.url, error: e.error.message })),
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
} catch (error) {
|
|
86
|
-
return c.json({
|
|
87
|
-
error: {
|
|
88
|
-
code: 'BATCH_ERROR',
|
|
89
|
-
message: (error as Error).message,
|
|
90
|
-
}
|
|
91
|
-
}, 500);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
api.post('/crawl', async (c) => {
|
|
96
|
-
const body = await c.req.json();
|
|
97
|
-
const { url, options = {} } = body;
|
|
98
|
-
|
|
99
|
-
if (!url) {
|
|
100
|
-
return c.json({ error: { code: 'MISSING_URL', message: 'URL is required' } }, 400);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
try {
|
|
104
|
-
const result = await crawl(url, options);
|
|
105
|
-
return c.json({
|
|
106
|
-
status: 'ok',
|
|
107
|
-
data: {
|
|
108
|
-
stats: result.stats,
|
|
109
|
-
results: result.results.slice(0, 100),
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
} catch (error) {
|
|
113
|
-
return c.json({
|
|
114
|
-
error: {
|
|
115
|
-
code: 'CRAWL_ERROR',
|
|
116
|
-
message: (error as Error).message,
|
|
117
|
-
}
|
|
118
|
-
}, 500);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
api.get('/health', (c) => {
|
|
123
|
-
return c.json({ status: 'ok', version: '2.0.0', uptime: process.uptime() });
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
app.route('/v1', api);
|
|
127
|
-
|
|
128
|
-
export function createServer(config: ServerConfig = {}) {
|
|
129
|
-
return {
|
|
130
|
-
fetch: app.fetch,
|
|
131
|
-
port: config.port || randomPort(),
|
|
132
|
-
host: config.host || '0.0.0.0',
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export { app };
|
|
137
|
-
export default app;
|
package/scrape/session.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
export interface Cookie {
|
|
2
|
-
name: string;
|
|
3
|
-
value: string;
|
|
4
|
-
domain?: string;
|
|
5
|
-
path?: string;
|
|
6
|
-
expires?: number;
|
|
7
|
-
httpOnly?: boolean;
|
|
8
|
-
secure?: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class CookieJar {
|
|
12
|
-
private cookies = new Map<string, Cookie>();
|
|
13
|
-
|
|
14
|
-
set(cookie: Cookie): void {
|
|
15
|
-
const key = `${cookie.domain || ''}:${cookie.path || '/'}:${cookie.name}`;
|
|
16
|
-
this.cookies.set(key, cookie);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get(name: string, domain?: string, _path?: string): Cookie | undefined {
|
|
20
|
-
for (const [key, cookie] of this.cookies) {
|
|
21
|
-
if (cookie.name !== name) continue;
|
|
22
|
-
if (domain && cookie.domain && !domain.includes(cookie.domain)) continue;
|
|
23
|
-
if (cookie.expires && cookie.expires < Date.now()) {
|
|
24
|
-
this.cookies.delete(key);
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
return cookie;
|
|
28
|
-
}
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getAll(domain?: string): Cookie[] {
|
|
33
|
-
const result: Cookie[] = [];
|
|
34
|
-
const now = Date.now();
|
|
35
|
-
for (const [key, cookie] of this.cookies) {
|
|
36
|
-
if (cookie.expires && cookie.expires < now) {
|
|
37
|
-
this.cookies.delete(key);
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (domain && cookie.domain && !domain.includes(cookie.domain)) continue;
|
|
41
|
-
result.push(cookie);
|
|
42
|
-
}
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
toString(domain?: string): string {
|
|
47
|
-
return this.getAll(domain)
|
|
48
|
-
.map(c => `${c.name}=${c.value}`)
|
|
49
|
-
.join('; ');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
parseSetCookie(header: string, defaultDomain?: string): void {
|
|
53
|
-
const parts = header.split(';').map(s => s.trim());
|
|
54
|
-
const [nameValue, ...attrs] = parts;
|
|
55
|
-
const [name, ...valueParts] = nameValue.split('=');
|
|
56
|
-
const value = valueParts.join('=');
|
|
57
|
-
|
|
58
|
-
const cookie: Cookie = {
|
|
59
|
-
name: name.trim(),
|
|
60
|
-
value: value.trim(),
|
|
61
|
-
domain: defaultDomain,
|
|
62
|
-
path: '/',
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
for (const attr of attrs) {
|
|
66
|
-
const [key, val] = attr.split('=').map(s => s.trim());
|
|
67
|
-
const lower = key.toLowerCase();
|
|
68
|
-
if (lower === 'domain') cookie.domain = val;
|
|
69
|
-
else if (lower === 'path') cookie.path = val;
|
|
70
|
-
else if (lower === 'expires') cookie.expires = new Date(val).getTime();
|
|
71
|
-
else if (lower === 'httponly') cookie.httpOnly = true;
|
|
72
|
-
else if (lower === 'secure') cookie.secure = true;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
this.set(cookie);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
clear(): void {
|
|
79
|
-
this.cookies.clear();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export class ScrapingSession {
|
|
84
|
-
public readonly cookieJar: CookieJar;
|
|
85
|
-
public readonly id: string;
|
|
86
|
-
private data = new Map<string, unknown>();
|
|
87
|
-
|
|
88
|
-
constructor(id?: string) {
|
|
89
|
-
this.id = id || crypto.randomUUID();
|
|
90
|
-
this.cookieJar = new CookieJar();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
get<T = unknown>(key: string): T | undefined {
|
|
94
|
-
return this.data.get(key) as T;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
set(key: string, value: unknown): void {
|
|
98
|
-
this.data.set(key, value);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
clear(): void {
|
|
102
|
-
this.cookieJar.clear();
|
|
103
|
-
this.data.clear();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function createSession(id?: string): ScrapingSession {
|
|
108
|
-
return new ScrapingSession(id);
|
|
109
|
-
}
|
package/scrape/sitemap.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { WebScrapeError, ErrorCode } from './errors.js';
|
|
2
|
-
|
|
3
|
-
export interface SitemapUrl {
|
|
4
|
-
loc: string;
|
|
5
|
-
lastmod?: string;
|
|
6
|
-
changefreq?: string;
|
|
7
|
-
priority?: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface SitemapResult {
|
|
11
|
-
urls: SitemapUrl[];
|
|
12
|
-
sitemaps: string[];
|
|
13
|
-
duration: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function parseSitemapXml(xml: string): SitemapUrl[] {
|
|
17
|
-
const urls: SitemapUrl[] = [];
|
|
18
|
-
const urlMatches = xml.match(/<url[^>]*>([\s\S]*?)<\/url>/gi) || [];
|
|
19
|
-
|
|
20
|
-
for (const urlBlock of urlMatches) {
|
|
21
|
-
const loc = urlBlock.match(/<loc>([\s\S]*?)<\/loc>/i)?.[1]?.trim();
|
|
22
|
-
if (!loc) continue;
|
|
23
|
-
|
|
24
|
-
const lastmod = urlBlock.match(/<lastmod>([\s\S]*?)<\/lastmod>/i)?.[1]?.trim();
|
|
25
|
-
const changefreq = urlBlock.match(/<changefreq>([\s\S]*?)<\/changefreq>/i)?.[1]?.trim();
|
|
26
|
-
const priorityStr = urlBlock.match(/<priority>([\s\S]*?)<\/priority>/i)?.[1]?.trim();
|
|
27
|
-
const priority = priorityStr ? parseFloat(priorityStr) : undefined;
|
|
28
|
-
|
|
29
|
-
urls.push({ loc, lastmod, changefreq, priority });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return urls;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function extractSitemapUrls(xml: string): string[] {
|
|
36
|
-
const urls: string[] = [];
|
|
37
|
-
const sitemapMatches = xml.match(/<sitemap[^>]*>[\s\S]*?<loc>([\s\S]*?)<\/loc>[\s\S]*?<\/sitemap>/gi) || [];
|
|
38
|
-
for (const match of sitemapMatches) {
|
|
39
|
-
const loc = match.match(/<loc>([\s\S]*?)<\/loc>/i)?.[1]?.trim();
|
|
40
|
-
if (loc) urls.push(loc);
|
|
41
|
-
}
|
|
42
|
-
return urls;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export async function fetchSitemap(url: string, options: { timeout?: number; headers?: Record<string, string> } = {}): Promise<SitemapResult> {
|
|
46
|
-
const startTime = Date.now();
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
const response = await fetch(url, {
|
|
50
|
-
headers: {
|
|
51
|
-
'User-Agent': 'DevThink-WebScrape/2.0 (sitemap parser)',
|
|
52
|
-
...options.headers,
|
|
53
|
-
},
|
|
54
|
-
signal: AbortSignal.timeout(options.timeout || 10000),
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (!response.ok) {
|
|
58
|
-
throw new WebScrapeError(`Failed to fetch sitemap: ${response.status}`, ErrorCode.NETWORK_ERROR, response.status, false, { url });
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const text = await response.text();
|
|
62
|
-
const isIndex = text.includes('<sitemapindex');
|
|
63
|
-
const urls = isIndex ? [] : parseSitemapXml(text);
|
|
64
|
-
const sitemaps = isIndex ? extractSitemapUrls(text) : [];
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
urls,
|
|
68
|
-
sitemaps,
|
|
69
|
-
duration: Date.now() - startTime,
|
|
70
|
-
};
|
|
71
|
-
} catch (error) {
|
|
72
|
-
if (error instanceof WebScrapeError) throw error;
|
|
73
|
-
throw new WebScrapeError(`Failed to parse sitemap: ${(error as Error).message}`, ErrorCode.PARSE_ERROR, 422, false, { url }, error as Error);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export async function discoverSitemaps(siteUrl: string): Promise<string[]> {
|
|
78
|
-
const candidates = [
|
|
79
|
-
'/sitemap.xml',
|
|
80
|
-
'/sitemap_index.xml',
|
|
81
|
-
'/sitemap-index.xml',
|
|
82
|
-
'/sitemaps.xml',
|
|
83
|
-
'/robots.txt',
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
const found: string[] = [];
|
|
87
|
-
const base = siteUrl.replace(/\/$/, '');
|
|
88
|
-
|
|
89
|
-
for (const path of candidates) {
|
|
90
|
-
try {
|
|
91
|
-
const url = path === '/robots.txt' ? `${base}/robots.txt` : `${base}${path}`;
|
|
92
|
-
const response = await fetch(url, {
|
|
93
|
-
headers: { 'User-Agent': 'DevThink-WebScrape/2.0' },
|
|
94
|
-
signal: AbortSignal.timeout(5000),
|
|
95
|
-
});
|
|
96
|
-
if (response.ok) {
|
|
97
|
-
const text = await response.text();
|
|
98
|
-
if (path === '/robots.txt') {
|
|
99
|
-
const sitemapUrls = text.match(/Sitemap:\s*(https?:\/\/[^\s]+)/gi);
|
|
100
|
-
if (sitemapUrls) {
|
|
101
|
-
for (const s of sitemapUrls) {
|
|
102
|
-
found.push(s.replace(/Sitemap:\s*/i, '').trim());
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
} else {
|
|
106
|
-
found.push(url);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
} catch {}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return [...new Set(found)];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export async function parseSitemap(url: string, options: { timeout?: number; followIndexes?: boolean; maxUrls?: number } = {}): Promise<SitemapUrl[]> {
|
|
116
|
-
const { followIndexes = true, maxUrls = 10000 } = options;
|
|
117
|
-
const result = await fetchSitemap(url, options);
|
|
118
|
-
let allUrls = [...result.urls];
|
|
119
|
-
|
|
120
|
-
if (followIndexes && result.sitemaps.length > 0) {
|
|
121
|
-
for (const sitemapUrl of result.sitemaps) {
|
|
122
|
-
if (allUrls.length >= maxUrls) break;
|
|
123
|
-
try {
|
|
124
|
-
const subResult = await fetchSitemap(sitemapUrl, options);
|
|
125
|
-
allUrls.push(...subResult.urls);
|
|
126
|
-
} catch {}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return allUrls.slice(0, maxUrls);
|
|
131
|
-
}
|