kirograph 0.28.0 → 0.28.1
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/dist/bin/installer/config-prompt.js +117 -100
- package/dist/bin/installer/config-prompt.js.map +3 -3
- package/dist/bin/kirograph.js +1 -1
- package/package.json +1 -1
- package/dist/architecture/index.d.ts +0 -11
- package/dist/architecture/index.d.ts.map +0 -1
- package/dist/architecture/layers/csharp.d.ts +0 -6
- package/dist/architecture/layers/csharp.d.ts.map +0 -1
- package/dist/architecture/layers/dart.d.ts +0 -10
- package/dist/architecture/layers/dart.d.ts.map +0 -1
- package/dist/architecture/layers/elixir.d.ts +0 -6
- package/dist/architecture/layers/elixir.d.ts.map +0 -1
- package/dist/architecture/layers/go.d.ts +0 -7
- package/dist/architecture/layers/go.d.ts.map +0 -1
- package/dist/architecture/layers/index.d.ts +0 -30
- package/dist/architecture/layers/index.d.ts.map +0 -1
- package/dist/architecture/layers/java.d.ts +0 -7
- package/dist/architecture/layers/java.d.ts.map +0 -1
- package/dist/architecture/layers/ocaml.d.ts +0 -6
- package/dist/architecture/layers/ocaml.d.ts.map +0 -1
- package/dist/architecture/layers/python.d.ts +0 -7
- package/dist/architecture/layers/python.d.ts.map +0 -1
- package/dist/architecture/layers/ruby.d.ts +0 -6
- package/dist/architecture/layers/ruby.d.ts.map +0 -1
- package/dist/architecture/layers/rust.d.ts +0 -6
- package/dist/architecture/layers/rust.d.ts.map +0 -1
- package/dist/architecture/layers/scala.d.ts +0 -6
- package/dist/architecture/layers/scala.d.ts.map +0 -1
- package/dist/architecture/layers/solidity.d.ts +0 -6
- package/dist/architecture/layers/solidity.d.ts.map +0 -1
- package/dist/architecture/layers/types.d.ts +0 -2
- package/dist/architecture/layers/types.d.ts.map +0 -1
- package/dist/architecture/layers/typescript.d.ts +0 -9
- package/dist/architecture/layers/typescript.d.ts.map +0 -1
- package/dist/architecture/layers/vue.d.ts +0 -6
- package/dist/architecture/layers/vue.d.ts.map +0 -1
- package/dist/architecture/manifest/cargo.d.ts +0 -3
- package/dist/architecture/manifest/cargo.d.ts.map +0 -1
- package/dist/architecture/manifest/csproj.d.ts +0 -3
- package/dist/architecture/manifest/csproj.d.ts.map +0 -1
- package/dist/architecture/manifest/elm.d.ts +0 -3
- package/dist/architecture/manifest/elm.d.ts.map +0 -1
- package/dist/architecture/manifest/go.d.ts +0 -3
- package/dist/architecture/manifest/go.d.ts.map +0 -1
- package/dist/architecture/manifest/gradle.d.ts +0 -3
- package/dist/architecture/manifest/gradle.d.ts.map +0 -1
- package/dist/architecture/manifest/index.d.ts +0 -12
- package/dist/architecture/manifest/index.d.ts.map +0 -1
- package/dist/architecture/manifest/maven.d.ts +0 -3
- package/dist/architecture/manifest/maven.d.ts.map +0 -1
- package/dist/architecture/manifest/npm.d.ts +0 -3
- package/dist/architecture/manifest/npm.d.ts.map +0 -1
- package/dist/architecture/manifest/ocaml.d.ts +0 -3
- package/dist/architecture/manifest/ocaml.d.ts.map +0 -1
- package/dist/architecture/manifest/python.d.ts +0 -3
- package/dist/architecture/manifest/python.d.ts.map +0 -1
- package/dist/architecture/manifest/scala.d.ts +0 -3
- package/dist/architecture/manifest/scala.d.ts.map +0 -1
- package/dist/architecture/manifest/types.d.ts +0 -2
- package/dist/architecture/manifest/types.d.ts.map +0 -1
- package/dist/architecture/types.d.ts +0 -91
- package/dist/architecture/types.d.ts.map +0 -1
- package/dist/banner.d.ts +0 -6
- package/dist/banner.d.ts.map +0 -1
- package/dist/banner.js +0 -67
- package/dist/banner.js.map +0 -1
- package/dist/bin/banner.d.ts +0 -6
- package/dist/bin/banner.d.ts.map +0 -1
- package/dist/bin/commands/affected.d.ts +0 -3
- package/dist/bin/commands/affected.d.ts.map +0 -1
- package/dist/bin/commands/architecture.d.ts +0 -3
- package/dist/bin/commands/architecture.d.ts.map +0 -1
- package/dist/bin/commands/attack-surface.d.ts +0 -3
- package/dist/bin/commands/attack-surface.d.ts.map +0 -1
- package/dist/bin/commands/benchmark.d.ts +0 -9
- package/dist/bin/commands/benchmark.d.ts.map +0 -1
- package/dist/bin/commands/budget.d.ts +0 -6
- package/dist/bin/commands/budget.d.ts.map +0 -1
- package/dist/bin/commands/caveman.d.ts +0 -7
- package/dist/bin/commands/caveman.d.ts.map +0 -1
- package/dist/bin/commands/communities.d.ts +0 -3
- package/dist/bin/commands/communities.d.ts.map +0 -1
- package/dist/bin/commands/compression.d.ts +0 -7
- package/dist/bin/commands/compression.d.ts.map +0 -1
- package/dist/bin/commands/configure-mcp.js +0 -104
- package/dist/bin/commands/configure-mcp.js.map +0 -7
- package/dist/bin/commands/context.d.ts +0 -3
- package/dist/bin/commands/context.d.ts.map +0 -1
- package/dist/bin/commands/coupling.d.ts +0 -3
- package/dist/bin/commands/coupling.d.ts.map +0 -1
- package/dist/bin/commands/dashboard.d.ts +0 -3
- package/dist/bin/commands/dashboard.d.ts.map +0 -1
- package/dist/bin/commands/data.d.ts +0 -3
- package/dist/bin/commands/data.d.ts.map +0 -1
- package/dist/bin/commands/dead-code.d.ts +0 -3
- package/dist/bin/commands/dead-code.d.ts.map +0 -1
- package/dist/bin/commands/dep-confusion.d.ts +0 -3
- package/dist/bin/commands/dep-confusion.d.ts.map +0 -1
- package/dist/bin/commands/docs.d.ts +0 -3
- package/dist/bin/commands/docs.d.ts.map +0 -1
- package/dist/bin/commands/exec.d.ts +0 -11
- package/dist/bin/commands/exec.d.ts.map +0 -1
- package/dist/bin/commands/export.d.ts +0 -3
- package/dist/bin/commands/export.d.ts.map +0 -1
- package/dist/bin/commands/files.d.ts +0 -3
- package/dist/bin/commands/files.d.ts.map +0 -1
- package/dist/bin/commands/flows.d.ts +0 -3
- package/dist/bin/commands/flows.d.ts.map +0 -1
- package/dist/bin/commands/gain.d.ts +0 -6
- package/dist/bin/commands/gain.d.ts.map +0 -1
- package/dist/bin/commands/help.d.ts +0 -11
- package/dist/bin/commands/help.d.ts.map +0 -1
- package/dist/bin/commands/hotspots.d.ts +0 -3
- package/dist/bin/commands/hotspots.d.ts.map +0 -1
- package/dist/bin/commands/index.d.ts +0 -3
- package/dist/bin/commands/index.d.ts.map +0 -1
- package/dist/bin/commands/init.d.ts +0 -3
- package/dist/bin/commands/init.d.ts.map +0 -1
- package/dist/bin/commands/install.d.ts +0 -3
- package/dist/bin/commands/install.d.ts.map +0 -1
- package/dist/bin/commands/licenses.d.ts +0 -3
- package/dist/bin/commands/licenses.d.ts.map +0 -1
- package/dist/bin/commands/mark-dirty.d.ts +0 -3
- package/dist/bin/commands/mark-dirty.d.ts.map +0 -1
- package/dist/bin/commands/memory.d.ts +0 -16
- package/dist/bin/commands/memory.d.ts.map +0 -1
- package/dist/bin/commands/package.d.ts +0 -3
- package/dist/bin/commands/package.d.ts.map +0 -1
- package/dist/bin/commands/path.d.ts +0 -3
- package/dist/bin/commands/path.d.ts.map +0 -1
- package/dist/bin/commands/pattern.d.ts +0 -3
- package/dist/bin/commands/pattern.d.ts.map +0 -1
- package/dist/bin/commands/qdrant.d.ts +0 -3
- package/dist/bin/commands/qdrant.d.ts.map +0 -1
- package/dist/bin/commands/qdrant.js +0 -159
- package/dist/bin/commands/qdrant.js.map +0 -1
- package/dist/bin/commands/query.d.ts +0 -3
- package/dist/bin/commands/query.d.ts.map +0 -1
- package/dist/bin/commands/reachability.d.ts +0 -3
- package/dist/bin/commands/reachability.d.ts.map +0 -1
- package/dist/bin/commands/read.d.ts +0 -6
- package/dist/bin/commands/read.d.ts.map +0 -1
- package/dist/bin/commands/refactor.d.ts +0 -3
- package/dist/bin/commands/refactor.d.ts.map +0 -1
- package/dist/bin/commands/remediation.d.ts +0 -3
- package/dist/bin/commands/remediation.d.ts.map +0 -1
- package/dist/bin/commands/sbom.d.ts +0 -3
- package/dist/bin/commands/sbom.d.ts.map +0 -1
- package/dist/bin/commands/security-ci-report.d.ts +0 -9
- package/dist/bin/commands/security-ci-report.d.ts.map +0 -1
- package/dist/bin/commands/security-export.d.ts +0 -2
- package/dist/bin/commands/security-export.d.ts.map +0 -1
- package/dist/bin/commands/security-flows.d.ts +0 -3
- package/dist/bin/commands/security-flows.d.ts.map +0 -1
- package/dist/bin/commands/security-secrets.d.ts +0 -3
- package/dist/bin/commands/security-secrets.d.ts.map +0 -1
- package/dist/bin/commands/security.d.ts +0 -3
- package/dist/bin/commands/security.d.ts.map +0 -1
- package/dist/bin/commands/serve.d.ts +0 -3
- package/dist/bin/commands/serve.d.ts.map +0 -1
- package/dist/bin/commands/snapshot.d.ts +0 -3
- package/dist/bin/commands/snapshot.d.ts.map +0 -1
- package/dist/bin/commands/staleness.d.ts +0 -3
- package/dist/bin/commands/staleness.d.ts.map +0 -1
- package/dist/bin/commands/status.d.ts +0 -3
- package/dist/bin/commands/status.d.ts.map +0 -1
- package/dist/bin/commands/stop.d.ts +0 -3
- package/dist/bin/commands/stop.d.ts.map +0 -1
- package/dist/bin/commands/stop.js +0 -81
- package/dist/bin/commands/stop.js.map +0 -1
- package/dist/bin/commands/supply-chain.d.ts +0 -3
- package/dist/bin/commands/supply-chain.d.ts.map +0 -1
- package/dist/bin/commands/surprising.d.ts +0 -3
- package/dist/bin/commands/surprising.d.ts.map +0 -1
- package/dist/bin/commands/sync-if-dirty.d.ts +0 -3
- package/dist/bin/commands/sync-if-dirty.d.ts.map +0 -1
- package/dist/bin/commands/sync.d.ts +0 -3
- package/dist/bin/commands/sync.d.ts.map +0 -1
- package/dist/bin/commands/typesense.d.ts +0 -3
- package/dist/bin/commands/typesense.d.ts.map +0 -1
- package/dist/bin/commands/typesense.js +0 -126
- package/dist/bin/commands/typesense.js.map +0 -1
- package/dist/bin/commands/uninit.d.ts +0 -4
- package/dist/bin/commands/uninit.d.ts.map +0 -1
- package/dist/bin/commands/unlock.d.ts +0 -3
- package/dist/bin/commands/unlock.d.ts.map +0 -1
- package/dist/bin/commands/utils.d.ts +0 -17
- package/dist/bin/commands/utils.d.ts.map +0 -1
- package/dist/bin/commands/vex.d.ts +0 -3
- package/dist/bin/commands/vex.d.ts.map +0 -1
- package/dist/bin/commands/vuln-suppress.d.ts +0 -3
- package/dist/bin/commands/vuln-suppress.d.ts.map +0 -1
- package/dist/bin/commands/vulns.d.ts +0 -3
- package/dist/bin/commands/vulns.d.ts.map +0 -1
- package/dist/bin/installer/archive.d.ts +0 -47
- package/dist/bin/installer/archive.d.ts.map +0 -1
- package/dist/bin/installer/auto-detect.d.ts +0 -16
- package/dist/bin/installer/auto-detect.d.ts.map +0 -1
- package/dist/bin/installer/caveman.d.ts +0 -12
- package/dist/bin/installer/caveman.d.ts.map +0 -1
- package/dist/bin/installer/cli-agent.d.ts +0 -20
- package/dist/bin/installer/cli-agent.d.ts.map +0 -1
- package/dist/bin/installer/common.d.ts +0 -36
- package/dist/bin/installer/common.d.ts.map +0 -1
- package/dist/bin/installer/config-prompt.d.ts +0 -13
- package/dist/bin/installer/config-prompt.d.ts.map +0 -1
- package/dist/bin/installer/dashboard.d.ts +0 -3
- package/dist/bin/installer/dashboard.d.ts.map +0 -1
- package/dist/bin/installer/detect.d.ts +0 -30
- package/dist/bin/installer/detect.d.ts.map +0 -1
- package/dist/bin/installer/hooks.d.ts +0 -8
- package/dist/bin/installer/hooks.d.ts.map +0 -1
- package/dist/bin/installer/index.d.ts +0 -12
- package/dist/bin/installer/index.d.ts.map +0 -1
- package/dist/bin/installer/instructions.d.ts +0 -14
- package/dist/bin/installer/instructions.d.ts.map +0 -1
- package/dist/bin/installer/mcp.d.ts +0 -5
- package/dist/bin/installer/mcp.d.ts.map +0 -1
- package/dist/bin/installer/prompts.d.ts +0 -45
- package/dist/bin/installer/prompts.d.ts.map +0 -1
- package/dist/bin/installer/qdrant-dashboard.d.ts +0 -4
- package/dist/bin/installer/qdrant-dashboard.d.ts.map +0 -1
- package/dist/bin/installer/steering.d.ts +0 -17
- package/dist/bin/installer/steering.d.ts.map +0 -1
- package/dist/bin/installer/targets/aider.d.ts +0 -6
- package/dist/bin/installer/targets/aider.d.ts.map +0 -1
- package/dist/bin/installer/targets/amp.d.ts +0 -6
- package/dist/bin/installer/targets/amp.d.ts.map +0 -1
- package/dist/bin/installer/targets/antigravity.d.ts +0 -13
- package/dist/bin/installer/targets/antigravity.d.ts.map +0 -1
- package/dist/bin/installer/targets/augment.d.ts +0 -6
- package/dist/bin/installer/targets/augment.d.ts.map +0 -1
- package/dist/bin/installer/targets/claude.d.ts +0 -6
- package/dist/bin/installer/targets/claude.d.ts.map +0 -1
- package/dist/bin/installer/targets/cline.d.ts +0 -13
- package/dist/bin/installer/targets/cline.d.ts.map +0 -1
- package/dist/bin/installer/targets/codex.d.ts +0 -6
- package/dist/bin/installer/targets/codex.d.ts.map +0 -1
- package/dist/bin/installer/targets/continue.d.ts +0 -12
- package/dist/bin/installer/targets/continue.d.ts.map +0 -1
- package/dist/bin/installer/targets/copilot-cli.d.ts +0 -12
- package/dist/bin/installer/targets/copilot-cli.d.ts.map +0 -1
- package/dist/bin/installer/targets/copilot.d.ts +0 -6
- package/dist/bin/installer/targets/copilot.d.ts.map +0 -1
- package/dist/bin/installer/targets/cursor.d.ts +0 -6
- package/dist/bin/installer/targets/cursor.d.ts.map +0 -1
- package/dist/bin/installer/targets/devin.d.ts +0 -13
- package/dist/bin/installer/targets/devin.d.ts.map +0 -1
- package/dist/bin/installer/targets/gemini-cli.d.ts +0 -16
- package/dist/bin/installer/targets/gemini-cli.d.ts.map +0 -1
- package/dist/bin/installer/targets/generic.d.ts +0 -59
- package/dist/bin/installer/targets/generic.d.ts.map +0 -1
- package/dist/bin/installer/targets/goose.d.ts +0 -6
- package/dist/bin/installer/targets/goose.d.ts.map +0 -1
- package/dist/bin/installer/targets/index.d.ts +0 -11
- package/dist/bin/installer/targets/index.d.ts.map +0 -1
- package/dist/bin/installer/targets/junie.d.ts +0 -13
- package/dist/bin/installer/targets/junie.d.ts.map +0 -1
- package/dist/bin/installer/targets/kilo.d.ts +0 -12
- package/dist/bin/installer/targets/kilo.d.ts.map +0 -1
- package/dist/bin/installer/targets/kiro.d.ts +0 -5
- package/dist/bin/installer/targets/kiro.d.ts.map +0 -1
- package/dist/bin/installer/targets/opencode.d.ts +0 -13
- package/dist/bin/installer/targets/opencode.d.ts.map +0 -1
- package/dist/bin/installer/targets/openhands.d.ts +0 -6
- package/dist/bin/installer/targets/openhands.d.ts.map +0 -1
- package/dist/bin/installer/targets/qoder.d.ts +0 -12
- package/dist/bin/installer/targets/qoder.d.ts.map +0 -1
- package/dist/bin/installer/targets/qwen.d.ts +0 -12
- package/dist/bin/installer/targets/qwen.d.ts.map +0 -1
- package/dist/bin/installer/targets/replit.d.ts +0 -6
- package/dist/bin/installer/targets/replit.d.ts.map +0 -1
- package/dist/bin/installer/targets/roo.d.ts +0 -13
- package/dist/bin/installer/targets/roo.d.ts.map +0 -1
- package/dist/bin/installer/targets/tabnine.d.ts +0 -6
- package/dist/bin/installer/targets/tabnine.d.ts.map +0 -1
- package/dist/bin/installer/targets/trae.d.ts +0 -6
- package/dist/bin/installer/targets/trae.d.ts.map +0 -1
- package/dist/bin/installer/targets/warp.d.ts +0 -12
- package/dist/bin/installer/targets/warp.d.ts.map +0 -1
- package/dist/bin/installer/targets/windsurf.d.ts +0 -13
- package/dist/bin/installer/targets/windsurf.d.ts.map +0 -1
- package/dist/bin/kirograph.d.ts +0 -6
- package/dist/bin/kirograph.d.ts.map +0 -1
- package/dist/bin/progress.d.ts +0 -29
- package/dist/bin/progress.d.ts.map +0 -1
- package/dist/bin/ui.d.ts +0 -11
- package/dist/bin/ui.d.ts.map +0 -1
- package/dist/compression/filters/aws.d.ts +0 -9
- package/dist/compression/filters/aws.d.ts.map +0 -1
- package/dist/compression/filters/docker.d.ts +0 -6
- package/dist/compression/filters/docker.d.ts.map +0 -1
- package/dist/compression/filters/files.d.ts +0 -6
- package/dist/compression/filters/files.d.ts.map +0 -1
- package/dist/compression/filters/generic.d.ts +0 -7
- package/dist/compression/filters/generic.d.ts.map +0 -1
- package/dist/compression/filters/git.d.ts +0 -6
- package/dist/compression/filters/git.d.ts.map +0 -1
- package/dist/compression/filters/github.d.ts +0 -6
- package/dist/compression/filters/github.d.ts.map +0 -1
- package/dist/compression/filters/lint.d.ts +0 -6
- package/dist/compression/filters/lint.d.ts.map +0 -1
- package/dist/compression/filters/misc.d.ts +0 -6
- package/dist/compression/filters/misc.d.ts.map +0 -1
- package/dist/compression/filters/package.d.ts +0 -6
- package/dist/compression/filters/package.d.ts.map +0 -1
- package/dist/compression/filters/test.d.ts +0 -6
- package/dist/compression/filters/test.d.ts.map +0 -1
- package/dist/compression/index.d.ts +0 -29
- package/dist/compression/index.d.ts.map +0 -1
- package/dist/compression/naive-cost.d.ts +0 -26
- package/dist/compression/naive-cost.d.ts.map +0 -1
- package/dist/compression/tracker.d.ts +0 -155
- package/dist/compression/tracker.d.ts.map +0 -1
- package/dist/compression/types.d.ts +0 -49
- package/dist/compression/types.d.ts.map +0 -1
- package/dist/config.d.ts +0 -138
- package/dist/config.d.ts.map +0 -1
- package/dist/context/index.d.ts +0 -61
- package/dist/context/index.d.ts.map +0 -1
- package/dist/core/file-tree.d.ts +0 -15
- package/dist/core/file-tree.d.ts.map +0 -1
- package/dist/core/lock-manager.d.ts +0 -22
- package/dist/core/lock-manager.d.ts.map +0 -1
- package/dist/core/pipeline.d.ts +0 -40
- package/dist/core/pipeline.d.ts.map +0 -1
- package/dist/core/snapshot.d.ts +0 -58
- package/dist/core/snapshot.d.ts.map +0 -1
- package/dist/data/filters.d.ts +0 -23
- package/dist/data/filters.d.ts.map +0 -1
- package/dist/data/indexer.d.ts +0 -25
- package/dist/data/indexer.d.ts.map +0 -1
- package/dist/data/linker.d.ts +0 -37
- package/dist/data/linker.d.ts.map +0 -1
- package/dist/data/linker.test.js +0 -60
- package/dist/data/linker.test.js.map +0 -7
- package/dist/data/lint.d.ts +0 -27
- package/dist/data/lint.d.ts.map +0 -1
- package/dist/data/parsers/__fixtures__/pdf-inspector-stub.js +0 -41
- package/dist/data/parsers/__fixtures__/pdf-inspector-stub.js.map +0 -7
- package/dist/data/parsers/csv.d.ts +0 -11
- package/dist/data/parsers/csv.d.ts.map +0 -1
- package/dist/data/parsers/excel.d.ts +0 -10
- package/dist/data/parsers/excel.d.ts.map +0 -1
- package/dist/data/parsers/index.d.ts +0 -28
- package/dist/data/parsers/index.d.ts.map +0 -1
- package/dist/data/parsers/json-array.d.ts +0 -9
- package/dist/data/parsers/json-array.d.ts.map +0 -1
- package/dist/data/parsers/jsonl.d.ts +0 -9
- package/dist/data/parsers/jsonl.d.ts.map +0 -1
- package/dist/data/parsers/parquet.d.ts +0 -10
- package/dist/data/parsers/parquet.d.ts.map +0 -1
- package/dist/data/parsers/pdf.test.js +0 -125
- package/dist/data/parsers/pdf.test.js.map +0 -7
- package/dist/data/pixelrag-bridge.js +0 -93
- package/dist/data/pixelrag-bridge.js.map +0 -7
- package/dist/data/pixelrag-manager.js +0 -416
- package/dist/data/pixelrag-manager.js.map +0 -7
- package/dist/data/profiler.d.ts +0 -29
- package/dist/data/profiler.d.ts.map +0 -1
- package/dist/data/queries.d.ts +0 -95
- package/dist/data/queries.d.ts.map +0 -1
- package/dist/data/types.d.ts +0 -103
- package/dist/data/types.d.ts.map +0 -1
- package/dist/db/database.d.ts +0 -190
- package/dist/db/database.d.ts.map +0 -1
- package/dist/docs/formats/asciidoc.d.ts +0 -9
- package/dist/docs/formats/asciidoc.d.ts.map +0 -1
- package/dist/docs/formats/html.d.ts +0 -10
- package/dist/docs/formats/html.d.ts.map +0 -1
- package/dist/docs/formats/index.d.ts +0 -31
- package/dist/docs/formats/index.d.ts.map +0 -1
- package/dist/docs/formats/markdown.d.ts +0 -11
- package/dist/docs/formats/markdown.d.ts.map +0 -1
- package/dist/docs/formats/openapi.d.ts +0 -17
- package/dist/docs/formats/openapi.d.ts.map +0 -1
- package/dist/docs/formats/org.d.ts +0 -9
- package/dist/docs/formats/org.d.ts.map +0 -1
- package/dist/docs/formats/plaintext.d.ts +0 -11
- package/dist/docs/formats/plaintext.d.ts.map +0 -1
- package/dist/docs/formats/rdoc.d.ts +0 -10
- package/dist/docs/formats/rdoc.d.ts.map +0 -1
- package/dist/docs/formats/rst.d.ts +0 -11
- package/dist/docs/formats/rst.d.ts.map +0 -1
- package/dist/docs/indexer.d.ts +0 -49
- package/dist/docs/indexer.d.ts.map +0 -1
- package/dist/docs/linker.d.ts +0 -30
- package/dist/docs/linker.d.ts.map +0 -1
- package/dist/docs/lint.d.ts +0 -27
- package/dist/docs/lint.d.ts.map +0 -1
- package/dist/docs/queries.d.ts +0 -78
- package/dist/docs/queries.d.ts.map +0 -1
- package/dist/docs/section-id.d.ts +0 -48
- package/dist/docs/section-id.d.ts.map +0 -1
- package/dist/docs/summarizer.d.ts +0 -13
- package/dist/docs/summarizer.d.ts.map +0 -1
- package/dist/docs/types.d.ts +0 -71
- package/dist/docs/types.d.ts.map +0 -1
- package/dist/docs/vectors.d.ts +0 -54
- package/dist/docs/vectors.d.ts.map +0 -1
- package/dist/errors.d.ts +0 -49
- package/dist/errors.d.ts.map +0 -1
- package/dist/extraction/extractor.d.ts +0 -29
- package/dist/extraction/extractor.d.ts.map +0 -1
- package/dist/extraction/grammars.d.ts +0 -54
- package/dist/extraction/grammars.d.ts.map +0 -1
- package/dist/extraction/languages.d.ts +0 -9
- package/dist/extraction/languages.d.ts.map +0 -1
- package/dist/extraction/notebook.d.ts +0 -14
- package/dist/extraction/notebook.d.ts.map +0 -1
- package/dist/frameworks/amplify.d.ts +0 -9
- package/dist/frameworks/amplify.d.ts.map +0 -1
- package/dist/frameworks/angular.d.ts +0 -9
- package/dist/frameworks/angular.d.ts.map +0 -1
- package/dist/frameworks/ansible.d.ts +0 -8
- package/dist/frameworks/ansible.d.ts.map +0 -1
- package/dist/frameworks/cloudformation.d.ts +0 -9
- package/dist/frameworks/cloudformation.d.ts.map +0 -1
- package/dist/frameworks/csharp.d.ts +0 -8
- package/dist/frameworks/csharp.d.ts.map +0 -1
- package/dist/frameworks/docker.d.ts +0 -9
- package/dist/frameworks/docker.d.ts.map +0 -1
- package/dist/frameworks/elixir.d.ts +0 -6
- package/dist/frameworks/elixir.d.ts.map +0 -1
- package/dist/frameworks/express.d.ts +0 -8
- package/dist/frameworks/express.d.ts.map +0 -1
- package/dist/frameworks/flutter.d.ts +0 -12
- package/dist/frameworks/flutter.d.ts.map +0 -1
- package/dist/frameworks/go.d.ts +0 -8
- package/dist/frameworks/go.d.ts.map +0 -1
- package/dist/frameworks/iac.d.ts +0 -10
- package/dist/frameworks/iac.d.ts.map +0 -1
- package/dist/frameworks/index.d.ts +0 -44
- package/dist/frameworks/index.d.ts.map +0 -1
- package/dist/frameworks/java.d.ts +0 -8
- package/dist/frameworks/java.d.ts.map +0 -1
- package/dist/frameworks/kubernetes.d.ts +0 -9
- package/dist/frameworks/kubernetes.d.ts.map +0 -1
- package/dist/frameworks/laravel.d.ts +0 -9
- package/dist/frameworks/laravel.d.ts.map +0 -1
- package/dist/frameworks/pulumi.d.ts +0 -9
- package/dist/frameworks/pulumi.d.ts.map +0 -1
- package/dist/frameworks/python.d.ts +0 -10
- package/dist/frameworks/python.d.ts.map +0 -1
- package/dist/frameworks/react.d.ts +0 -9
- package/dist/frameworks/react.d.ts.map +0 -1
- package/dist/frameworks/ruby.d.ts +0 -8
- package/dist/frameworks/ruby.d.ts.map +0 -1
- package/dist/frameworks/rust.d.ts +0 -8
- package/dist/frameworks/rust.d.ts.map +0 -1
- package/dist/frameworks/scala.d.ts +0 -6
- package/dist/frameworks/scala.d.ts.map +0 -1
- package/dist/frameworks/solidity.d.ts +0 -6
- package/dist/frameworks/solidity.d.ts.map +0 -1
- package/dist/frameworks/svelte.d.ts +0 -8
- package/dist/frameworks/svelte.d.ts.map +0 -1
- package/dist/frameworks/swift.d.ts +0 -10
- package/dist/frameworks/swift.d.ts.map +0 -1
- package/dist/frameworks/terraform.d.ts +0 -14
- package/dist/frameworks/terraform.d.ts.map +0 -1
- package/dist/frameworks/types.d.ts +0 -37
- package/dist/frameworks/types.d.ts.map +0 -1
- package/dist/frameworks/vue.d.ts +0 -7
- package/dist/frameworks/vue.d.ts.map +0 -1
- package/dist/graph/communities.d.ts +0 -43
- package/dist/graph/communities.d.ts.map +0 -1
- package/dist/graph/flows.d.ts +0 -55
- package/dist/graph/flows.d.ts.map +0 -1
- package/dist/graph/queries.d.ts +0 -53
- package/dist/graph/queries.d.ts.map +0 -1
- package/dist/graph/refactor.d.ts +0 -43
- package/dist/graph/refactor.d.ts.map +0 -1
- package/dist/graph/traversal.d.ts +0 -35
- package/dist/graph/traversal.d.ts.map +0 -1
- package/dist/index.d.ts +0 -134
- package/dist/index.d.ts.map +0 -1
- package/dist/installer/index.d.ts +0 -10
- package/dist/installer/index.d.ts.map +0 -1
- package/dist/installer/index.js +0 -526
- package/dist/installer/index.js.map +0 -1
- package/dist/mcp/cache.d.ts +0 -69
- package/dist/mcp/cache.d.ts.map +0 -1
- package/dist/mcp/read-modes.d.ts +0 -31
- package/dist/mcp/read-modes.d.ts.map +0 -1
- package/dist/mcp/server.d.ts +0 -17
- package/dist/mcp/server.d.ts.map +0 -1
- package/dist/mcp/tool-names.d.ts +0 -2
- package/dist/mcp/tool-names.d.ts.map +0 -1
- package/dist/mcp/tools.d.ts +0 -49
- package/dist/mcp/tools.d.ts.map +0 -1
- package/dist/mcp/transport.d.ts +0 -29
- package/dist/mcp/transport.d.ts.map +0 -1
- package/dist/memory/compress.d.ts +0 -19
- package/dist/memory/compress.d.ts.map +0 -1
- package/dist/memory/database.d.ts +0 -92
- package/dist/memory/database.d.ts.map +0 -1
- package/dist/memory/index.d.ts +0 -71
- package/dist/memory/index.d.ts.map +0 -1
- package/dist/memory/symbols.d.ts +0 -21
- package/dist/memory/symbols.d.ts.map +0 -1
- package/dist/memory/types.d.ts +0 -78
- package/dist/memory/types.d.ts.map +0 -1
- package/dist/memory/vectors.d.ts +0 -43
- package/dist/memory/vectors.d.ts.map +0 -1
- package/dist/patterns/graph.d.ts +0 -16
- package/dist/patterns/graph.d.ts.map +0 -1
- package/dist/patterns/index.d.ts +0 -4
- package/dist/patterns/index.d.ts.map +0 -1
- package/dist/patterns/indexer.d.ts +0 -15
- package/dist/patterns/indexer.d.ts.map +0 -1
- package/dist/patterns/loader.d.ts +0 -18
- package/dist/patterns/loader.d.ts.map +0 -1
- package/dist/patterns/runner.d.ts +0 -42
- package/dist/patterns/runner.d.ts.map +0 -1
- package/dist/patterns/types.d.ts +0 -27
- package/dist/patterns/types.d.ts.map +0 -1
- package/dist/resolution/bridges/android-rn.d.ts +0 -13
- package/dist/resolution/bridges/android-rn.d.ts.map +0 -1
- package/dist/resolution/bridges/expo-modules.d.ts +0 -10
- package/dist/resolution/bridges/expo-modules.d.ts.map +0 -1
- package/dist/resolution/bridges/flutter-channel.d.ts +0 -14
- package/dist/resolution/bridges/flutter-channel.d.ts.map +0 -1
- package/dist/resolution/bridges/index.d.ts +0 -40
- package/dist/resolution/bridges/index.d.ts.map +0 -1
- package/dist/resolution/bridges/native-events.d.ts +0 -10
- package/dist/resolution/bridges/native-events.d.ts.map +0 -1
- package/dist/resolution/bridges/native-views.d.ts +0 -13
- package/dist/resolution/bridges/native-views.d.ts.map +0 -1
- package/dist/resolution/bridges/react-native.d.ts +0 -9
- package/dist/resolution/bridges/react-native.d.ts.map +0 -1
- package/dist/resolution/bridges/swift-objc.d.ts +0 -14
- package/dist/resolution/bridges/swift-objc.d.ts.map +0 -1
- package/dist/resolution/bridges/turbomodules.d.ts +0 -10
- package/dist/resolution/bridges/turbomodules.d.ts.map +0 -1
- package/dist/resolution/index.d.ts +0 -81
- package/dist/resolution/index.d.ts.map +0 -1
- package/dist/resolution/name-matcher.d.ts +0 -25
- package/dist/resolution/name-matcher.d.ts.map +0 -1
- package/dist/scripts/postinstall.js +0 -64
- package/dist/search/query-utils.d.ts +0 -21
- package/dist/search/query-utils.d.ts.map +0 -1
- package/dist/search/searcher.d.ts +0 -15
- package/dist/search/searcher.d.ts.map +0 -1
- package/dist/security/attack-surface.d.ts +0 -46
- package/dist/security/attack-surface.d.ts.map +0 -1
- package/dist/security/context-warnings.d.ts +0 -40
- package/dist/security/context-warnings.d.ts.map +0 -1
- package/dist/security/data-flows.d.ts +0 -33
- package/dist/security/data-flows.d.ts.map +0 -1
- package/dist/security/dep-confusion.d.ts +0 -23
- package/dist/security/dep-confusion.d.ts.map +0 -1
- package/dist/security/errors.d.ts +0 -16
- package/dist/security/errors.d.ts.map +0 -1
- package/dist/security/export/fix-suggestions.d.ts +0 -21
- package/dist/security/export/fix-suggestions.d.ts.map +0 -1
- package/dist/security/export/sbom.d.ts +0 -33
- package/dist/security/export/sbom.d.ts.map +0 -1
- package/dist/security/export/serialization.d.ts +0 -62
- package/dist/security/export/serialization.d.ts.map +0 -1
- package/dist/security/export/vex.d.ts +0 -58
- package/dist/security/export/vex.d.ts.map +0 -1
- package/dist/security/index.d.ts +0 -21
- package/dist/security/index.d.ts.map +0 -1
- package/dist/security/integrator.d.ts +0 -63
- package/dist/security/integrator.d.ts.map +0 -1
- package/dist/security/license.d.ts +0 -33
- package/dist/security/license.d.ts.map +0 -1
- package/dist/security/manifest/adapter.d.ts +0 -92
- package/dist/security/manifest/adapter.d.ts.map +0 -1
- package/dist/security/manifest/parser.d.ts +0 -73
- package/dist/security/manifest/parser.d.ts.map +0 -1
- package/dist/security/manifest/plugins/cargo.d.ts +0 -11
- package/dist/security/manifest/plugins/cargo.d.ts.map +0 -1
- package/dist/security/manifest/plugins/composer.d.ts +0 -11
- package/dist/security/manifest/plugins/composer.d.ts.map +0 -1
- package/dist/security/manifest/plugins/go.d.ts +0 -12
- package/dist/security/manifest/plugins/go.d.ts.map +0 -1
- package/dist/security/manifest/plugins/gradle.d.ts +0 -12
- package/dist/security/manifest/plugins/gradle.d.ts.map +0 -1
- package/dist/security/manifest/plugins/hex.d.ts +0 -11
- package/dist/security/manifest/plugins/hex.d.ts.map +0 -1
- package/dist/security/manifest/plugins/maven.d.ts +0 -11
- package/dist/security/manifest/plugins/maven.d.ts.map +0 -1
- package/dist/security/manifest/plugins/npm.d.ts +0 -11
- package/dist/security/manifest/plugins/npm.d.ts.map +0 -1
- package/dist/security/manifest/plugins/nuget.d.ts +0 -12
- package/dist/security/manifest/plugins/nuget.d.ts.map +0 -1
- package/dist/security/manifest/plugins/pip.d.ts +0 -11
- package/dist/security/manifest/plugins/pip.d.ts.map +0 -1
- package/dist/security/manifest/plugins/pubspec.d.ts +0 -11
- package/dist/security/manifest/plugins/pubspec.d.ts.map +0 -1
- package/dist/security/manifest/plugins/pyproject.d.ts +0 -3
- package/dist/security/manifest/plugins/pyproject.d.ts.map +0 -1
- package/dist/security/manifest/plugins/rubygems.d.ts +0 -11
- package/dist/security/manifest/plugins/rubygems.d.ts.map +0 -1
- package/dist/security/manifest/plugins/swift.d.ts +0 -11
- package/dist/security/manifest/plugins/swift.d.ts.map +0 -1
- package/dist/security/owasp.d.ts +0 -16
- package/dist/security/owasp.d.ts.map +0 -1
- package/dist/security/pipeline.d.ts +0 -37
- package/dist/security/pipeline.d.ts.map +0 -1
- package/dist/security/reachability.d.ts +0 -67
- package/dist/security/reachability.d.ts.map +0 -1
- package/dist/security/remediation.d.ts +0 -51
- package/dist/security/remediation.d.ts.map +0 -1
- package/dist/security/secrets.d.ts +0 -38
- package/dist/security/secrets.d.ts.map +0 -1
- package/dist/security/staleness.d.ts +0 -43
- package/dist/security/staleness.d.ts.map +0 -1
- package/dist/security/supply-chain.d.ts +0 -34
- package/dist/security/supply-chain.d.ts.map +0 -1
- package/dist/security/suppressions.d.ts +0 -18
- package/dist/security/suppressions.d.ts.map +0 -1
- package/dist/security/types.d.ts +0 -144
- package/dist/security/types.d.ts.map +0 -1
- package/dist/security/vuln/client.d.ts +0 -90
- package/dist/security/vuln/client.d.ts.map +0 -1
- package/dist/security/vuln/epss-client.d.ts +0 -26
- package/dist/security/vuln/epss-client.d.ts.map +0 -1
- package/dist/security/vuln/index.d.ts +0 -6
- package/dist/security/vuln/index.d.ts.map +0 -1
- package/dist/security/vuln/osv-adapter.d.ts +0 -58
- package/dist/security/vuln/osv-adapter.d.ts.map +0 -1
- package/dist/security/vuln/types.d.ts +0 -29
- package/dist/security/vuln/types.d.ts.map +0 -1
- package/dist/sync/index.d.ts +0 -35
- package/dist/sync/index.d.ts.map +0 -1
- package/dist/types.d.ts +0 -137
- package/dist/types.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -52
- package/dist/utils.d.ts.map +0 -1
- package/dist/vectors/index.d.ts +0 -79
- package/dist/vectors/index.d.ts.map +0 -1
- package/dist/vectors/lancedb-index.d.ts +0 -50
- package/dist/vectors/lancedb-index.d.ts.map +0 -1
- package/dist/vectors/orama-index.d.ts +0 -54
- package/dist/vectors/orama-index.d.ts.map +0 -1
- package/dist/vectors/pglite-index.d.ts +0 -53
- package/dist/vectors/pglite-index.d.ts.map +0 -1
- package/dist/vectors/qdrant-index.d.ts +0 -77
- package/dist/vectors/qdrant-index.d.ts.map +0 -1
- package/dist/vectors/typesense-index.d.ts +0 -75
- package/dist/vectors/typesense-index.d.ts.map +0 -1
- package/dist/vectors/vec-index.d.ts +0 -52
- package/dist/vectors/vec-index.d.ts.map +0 -1
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var import_vitest = require("vitest");
|
|
3
|
-
var import_pdf = require("./pdf");
|
|
4
|
-
import_vitest.vi.mock("fs", async (importOriginal) => {
|
|
5
|
-
const actual = await importOriginal();
|
|
6
|
-
return { ...actual, readFileSync: import_vitest.vi.fn().mockReturnValue(Buffer.from("fake-pdf")) };
|
|
7
|
-
});
|
|
8
|
-
const mockExtractPages = import_vitest.vi.fn();
|
|
9
|
-
const mockProcessPdf = import_vitest.vi.fn();
|
|
10
|
-
function makeMockResult(pages, opts) {
|
|
11
|
-
return {
|
|
12
|
-
pages,
|
|
13
|
-
pagesWithTables: opts?.pagesWithTables ?? [],
|
|
14
|
-
pagesWithColumns: opts?.pagesWithColumns ?? []
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
(0, import_vitest.describe)("pdfParser", () => {
|
|
18
|
-
(0, import_vitest.beforeEach)(() => {
|
|
19
|
-
import_vitest.vi.clearAllMocks();
|
|
20
|
-
(0, import_pdf._setPdfInspectorForTesting)({ extractPagesMarkdown: mockExtractPages, processPdf: mockProcessPdf });
|
|
21
|
-
});
|
|
22
|
-
(0, import_vitest.afterEach)(() => {
|
|
23
|
-
(0, import_pdf._resetPdfInspectorForTesting)();
|
|
24
|
-
});
|
|
25
|
-
(0, import_vitest.it)("isAvailable returns true when module is injected", () => {
|
|
26
|
-
(0, import_vitest.expect)(import_pdf.pdfParser.isAvailable()).toBe(true);
|
|
27
|
-
});
|
|
28
|
-
(0, import_vitest.it)("isAvailable returns false when module is not available", () => {
|
|
29
|
-
(0, import_pdf._resetPdfInspectorForTesting)();
|
|
30
|
-
(0, import_vitest.expect)(import_pdf.pdfParser.isAvailable()).toBe(false);
|
|
31
|
-
});
|
|
32
|
-
(0, import_vitest.it)("parse returns empty result when library is unavailable", async () => {
|
|
33
|
-
(0, import_pdf._resetPdfInspectorForTesting)();
|
|
34
|
-
const batches = [];
|
|
35
|
-
const result = await import_pdf.pdfParser.parse("/fake/doc.pdf", {
|
|
36
|
-
maxRows: 1e3,
|
|
37
|
-
onBatch: (rows, cols) => batches.push({ rows, cols })
|
|
38
|
-
});
|
|
39
|
-
(0, import_vitest.expect)(result.columns).toEqual([]);
|
|
40
|
-
(0, import_vitest.expect)(result.totalRows).toBe(0);
|
|
41
|
-
(0, import_vitest.expect)(batches).toHaveLength(0);
|
|
42
|
-
});
|
|
43
|
-
(0, import_vitest.it)("happy path: text-based PDF produces correct rows and metadata", async () => {
|
|
44
|
-
mockExtractPages.mockReturnValue(makeMockResult([
|
|
45
|
-
{ page: 0, markdown: "# Title\n\nSome content here.", needsOcr: false },
|
|
46
|
-
{ page: 1, markdown: "Page two content.", needsOcr: false }
|
|
47
|
-
], { pagesWithTables: [1], pagesWithColumns: [] }));
|
|
48
|
-
mockProcessPdf.mockReturnValue({
|
|
49
|
-
pdfType: "TextBased",
|
|
50
|
-
confidence: 0.97,
|
|
51
|
-
title: "Test Doc",
|
|
52
|
-
hasEncodingIssues: false,
|
|
53
|
-
isComplexLayout: false
|
|
54
|
-
});
|
|
55
|
-
const batches = [];
|
|
56
|
-
const result = await import_pdf.pdfParser.parse("/fake/report.pdf", {
|
|
57
|
-
maxRows: 1e3,
|
|
58
|
-
onBatch: (rows, cols) => batches.push({ rows, cols })
|
|
59
|
-
});
|
|
60
|
-
(0, import_vitest.expect)(result.columns).toEqual(["page", "content", "needs_ocr", "has_tables", "has_columns"]);
|
|
61
|
-
(0, import_vitest.expect)(result.totalRows).toBe(2);
|
|
62
|
-
(0, import_vitest.expect)(batches).toHaveLength(1);
|
|
63
|
-
(0, import_vitest.expect)(batches[0].rows[0]).toMatchObject({ page: "0", needs_ocr: "false", has_tables: "false" });
|
|
64
|
-
(0, import_vitest.expect)(batches[0].rows[1]).toMatchObject({ page: "1", needs_ocr: "false", has_tables: "true" });
|
|
65
|
-
(0, import_vitest.expect)(result.metadataJson).toBeTruthy();
|
|
66
|
-
const meta = JSON.parse(result.metadataJson);
|
|
67
|
-
(0, import_vitest.expect)(meta.pdfType).toBe("TextBased");
|
|
68
|
-
(0, import_vitest.expect)(meta.confidence).toBe(0.97);
|
|
69
|
-
(0, import_vitest.expect)(meta.hasEncodingIssues).toBe(false);
|
|
70
|
-
});
|
|
71
|
-
(0, import_vitest.it)("mixed PDF: text pages indexed normally, scanned pages flagged", async () => {
|
|
72
|
-
mockExtractPages.mockReturnValue(makeMockResult([
|
|
73
|
-
{ page: 0, markdown: "Text content", needsOcr: false },
|
|
74
|
-
{ page: 1, markdown: "", needsOcr: true },
|
|
75
|
-
{ page: 2, markdown: "More text", needsOcr: false },
|
|
76
|
-
{ page: 3, markdown: "", needsOcr: true }
|
|
77
|
-
]));
|
|
78
|
-
mockProcessPdf.mockReturnValue({ pdfType: "Mixed", confidence: 0.85, hasEncodingIssues: false, isComplexLayout: false });
|
|
79
|
-
const batches = [];
|
|
80
|
-
await import_pdf.pdfParser.parse("/fake/mixed.pdf", {
|
|
81
|
-
maxRows: 1e3,
|
|
82
|
-
onBatch: (rows2) => batches.push({ rows: rows2 })
|
|
83
|
-
});
|
|
84
|
-
(0, import_vitest.expect)(batches).toHaveLength(1);
|
|
85
|
-
const rows = batches[0].rows;
|
|
86
|
-
(0, import_vitest.expect)(rows).toHaveLength(4);
|
|
87
|
-
(0, import_vitest.expect)(rows.filter((r) => r.needs_ocr === "true")).toHaveLength(2);
|
|
88
|
-
(0, import_vitest.expect)(rows.filter((r) => r.needs_ocr === "false")).toHaveLength(2);
|
|
89
|
-
});
|
|
90
|
-
(0, import_vitest.it)("hasEncodingIssues is captured in metadataJson", async () => {
|
|
91
|
-
mockExtractPages.mockReturnValue(makeMockResult([{ page: 0, markdown: "garbled", needsOcr: false }]));
|
|
92
|
-
mockProcessPdf.mockReturnValue({ pdfType: "TextBased", confidence: 0.4, hasEncodingIssues: true, isComplexLayout: false });
|
|
93
|
-
const result = await import_pdf.pdfParser.parse("/fake/garbled.pdf", { maxRows: 1e3, onBatch: () => {
|
|
94
|
-
} });
|
|
95
|
-
(0, import_vitest.expect)(result.metadataJson).toBeTruthy();
|
|
96
|
-
const meta = JSON.parse(result.metadataJson);
|
|
97
|
-
(0, import_vitest.expect)(meta.hasEncodingIssues).toBe(true);
|
|
98
|
-
});
|
|
99
|
-
(0, import_vitest.it)("empty PDF returns no rows and no batch", async () => {
|
|
100
|
-
mockExtractPages.mockReturnValue({ pages: [], pagesWithTables: [], pagesWithColumns: [] });
|
|
101
|
-
mockProcessPdf.mockReturnValue({ pdfType: "TextBased", confidence: 1, hasEncodingIssues: false, isComplexLayout: false });
|
|
102
|
-
const batches = [];
|
|
103
|
-
const result = await import_pdf.pdfParser.parse("/fake/empty.pdf", {
|
|
104
|
-
maxRows: 1e3,
|
|
105
|
-
onBatch: (rows, cols) => batches.push({ rows, cols })
|
|
106
|
-
});
|
|
107
|
-
(0, import_vitest.expect)(result.totalRows).toBe(0);
|
|
108
|
-
(0, import_vitest.expect)(batches).toHaveLength(0);
|
|
109
|
-
});
|
|
110
|
-
(0, import_vitest.it)("gracefully handles processPdf failure \u2014 still returns rows", async () => {
|
|
111
|
-
mockExtractPages.mockReturnValue(makeMockResult([{ page: 0, markdown: "content", needsOcr: false }]));
|
|
112
|
-
mockProcessPdf.mockImplementation(() => {
|
|
113
|
-
throw new Error("processPdf failed");
|
|
114
|
-
});
|
|
115
|
-
const batches = [];
|
|
116
|
-
const result = await import_pdf.pdfParser.parse("/fake/broken-meta.pdf", {
|
|
117
|
-
maxRows: 1e3,
|
|
118
|
-
onBatch: (rows, cols) => batches.push({ rows, cols })
|
|
119
|
-
});
|
|
120
|
-
(0, import_vitest.expect)(result.totalRows).toBe(1);
|
|
121
|
-
(0, import_vitest.expect)(batches).toHaveLength(1);
|
|
122
|
-
(0, import_vitest.expect)(result.metadataJson).toBeNull();
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
//# sourceMappingURL=pdf.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/data/parsers/pdf.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';\nimport { pdfParser, _setPdfInspectorForTesting, _resetPdfInspectorForTesting } from './pdf';\n\n// \u2500\u2500 Mock fs.readFileSync so tests never touch the filesystem \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nvi.mock('fs', async (importOriginal) => {\n const actual = await importOriginal<typeof import('fs')>();\n return { ...actual, readFileSync: vi.fn().mockReturnValue(Buffer.from('fake-pdf')) };\n});\n\n// \u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst mockExtractPages = vi.fn();\nconst mockProcessPdf = vi.fn();\n\nfunction makeMockResult(\n pages: Array<{ page: number; markdown: string; needsOcr: boolean }>,\n opts?: { pagesWithTables?: number[]; pagesWithColumns?: number[] },\n) {\n return {\n pages,\n pagesWithTables: opts?.pagesWithTables ?? [],\n pagesWithColumns: opts?.pagesWithColumns ?? [],\n };\n}\n\n// \u2500\u2500 Tests \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\ndescribe('pdfParser', () => {\n beforeEach(() => {\n vi.clearAllMocks();\n _setPdfInspectorForTesting({ extractPagesMarkdown: mockExtractPages, processPdf: mockProcessPdf });\n });\n\n afterEach(() => {\n _resetPdfInspectorForTesting();\n });\n\n it('isAvailable returns true when module is injected', () => {\n expect(pdfParser.isAvailable()).toBe(true);\n });\n\n it('isAvailable returns false when module is not available', () => {\n _resetPdfInspectorForTesting(); // clears pdfModule\n // Simulate require() failure by resetting the module\n expect(pdfParser.isAvailable()).toBe(false);\n });\n\n it('parse returns empty result when library is unavailable', async () => {\n _resetPdfInspectorForTesting();\n const batches: any[] = [];\n const result = await pdfParser.parse('/fake/doc.pdf', {\n maxRows: 1000,\n onBatch: (rows, cols) => batches.push({ rows, cols }),\n });\n expect(result.columns).toEqual([]);\n expect(result.totalRows).toBe(0);\n expect(batches).toHaveLength(0);\n });\n\n it('happy path: text-based PDF produces correct rows and metadata', async () => {\n mockExtractPages.mockReturnValue(makeMockResult([\n { page: 0, markdown: '# Title\\n\\nSome content here.', needsOcr: false },\n { page: 1, markdown: 'Page two content.', needsOcr: false },\n ], { pagesWithTables: [1], pagesWithColumns: [] }));\n mockProcessPdf.mockReturnValue({\n pdfType: 'TextBased', confidence: 0.97, title: 'Test Doc',\n hasEncodingIssues: false, isComplexLayout: false,\n });\n\n const batches: Array<{ rows: any[]; cols: string[] }> = [];\n const result = await pdfParser.parse('/fake/report.pdf', {\n maxRows: 1000,\n onBatch: (rows, cols) => batches.push({ rows, cols }),\n });\n\n expect(result.columns).toEqual(['page', 'content', 'needs_ocr', 'has_tables', 'has_columns']);\n expect(result.totalRows).toBe(2);\n expect(batches).toHaveLength(1);\n expect(batches[0]!.rows[0]).toMatchObject({ page: '0', needs_ocr: 'false', has_tables: 'false' });\n expect(batches[0]!.rows[1]).toMatchObject({ page: '1', needs_ocr: 'false', has_tables: 'true' });\n\n expect(result.metadataJson).toBeTruthy();\n const meta = JSON.parse(result.metadataJson!);\n expect(meta.pdfType).toBe('TextBased');\n expect(meta.confidence).toBe(0.97);\n expect(meta.hasEncodingIssues).toBe(false);\n });\n\n it('mixed PDF: text pages indexed normally, scanned pages flagged', async () => {\n mockExtractPages.mockReturnValue(makeMockResult([\n { page: 0, markdown: 'Text content', needsOcr: false },\n { page: 1, markdown: '', needsOcr: true },\n { page: 2, markdown: 'More text', needsOcr: false },\n { page: 3, markdown: '', needsOcr: true },\n ]));\n mockProcessPdf.mockReturnValue({ pdfType: 'Mixed', confidence: 0.85, hasEncodingIssues: false, isComplexLayout: false });\n\n const batches: Array<{ rows: any[] }> = [];\n await pdfParser.parse('/fake/mixed.pdf', {\n maxRows: 1000,\n onBatch: (rows) => batches.push({ rows }),\n });\n\n expect(batches).toHaveLength(1);\n const rows = batches[0]!.rows;\n expect(rows).toHaveLength(4);\n expect(rows.filter((r: any) => r.needs_ocr === 'true')).toHaveLength(2);\n expect(rows.filter((r: any) => r.needs_ocr === 'false')).toHaveLength(2);\n });\n\n it('hasEncodingIssues is captured in metadataJson', async () => {\n mockExtractPages.mockReturnValue(makeMockResult([{ page: 0, markdown: 'garbled', needsOcr: false }]));\n mockProcessPdf.mockReturnValue({ pdfType: 'TextBased', confidence: 0.4, hasEncodingIssues: true, isComplexLayout: false });\n\n const result = await pdfParser.parse('/fake/garbled.pdf', { maxRows: 1000, onBatch: () => {} });\n\n expect(result.metadataJson).toBeTruthy();\n const meta = JSON.parse(result.metadataJson!);\n expect(meta.hasEncodingIssues).toBe(true);\n });\n\n it('empty PDF returns no rows and no batch', async () => {\n mockExtractPages.mockReturnValue({ pages: [], pagesWithTables: [], pagesWithColumns: [] });\n mockProcessPdf.mockReturnValue({ pdfType: 'TextBased', confidence: 1, hasEncodingIssues: false, isComplexLayout: false });\n\n const batches: any[] = [];\n const result = await pdfParser.parse('/fake/empty.pdf', {\n maxRows: 1000,\n onBatch: (rows, cols) => batches.push({ rows, cols }),\n });\n\n expect(result.totalRows).toBe(0);\n expect(batches).toHaveLength(0);\n });\n\n it('gracefully handles processPdf failure \u2014 still returns rows', async () => {\n mockExtractPages.mockReturnValue(makeMockResult([{ page: 0, markdown: 'content', needsOcr: false }]));\n mockProcessPdf.mockImplementation(() => { throw new Error('processPdf failed'); });\n\n const batches: any[] = [];\n const result = await pdfParser.parse('/fake/broken-meta.pdf', {\n maxRows: 1000,\n onBatch: (rows, cols) => batches.push({ rows, cols }),\n });\n\n expect(result.totalRows).toBe(1);\n expect(batches).toHaveLength(1);\n expect(result.metadataJson).toBeNull();\n });\n});\n"],
|
|
5
|
-
"mappings": ";AAAA,oBAAgE;AAChE,iBAAoF;AAIpF,iBAAG,KAAK,MAAM,OAAO,mBAAmB;AACtC,QAAM,SAAS,MAAM,eAAoC;AACzD,SAAO,EAAE,GAAG,QAAQ,cAAc,iBAAG,GAAG,EAAE,gBAAgB,OAAO,KAAK,UAAU,CAAC,EAAE;AACrF,CAAC;AAID,MAAM,mBAAmB,iBAAG,GAAG;AAC/B,MAAM,iBAAiB,iBAAG,GAAG;AAE7B,SAAS,eACP,OACA,MACA;AACA,SAAO;AAAA,IACL;AAAA,IACA,iBAAiB,MAAM,mBAAmB,CAAC;AAAA,IAC3C,kBAAkB,MAAM,oBAAoB,CAAC;AAAA,EAC/C;AACF;AAAA,IAIA,wBAAS,aAAa,MAAM;AAC1B,gCAAW,MAAM;AACf,qBAAG,cAAc;AACjB,+CAA2B,EAAE,sBAAsB,kBAAkB,YAAY,eAAe,CAAC;AAAA,EACnG,CAAC;AAED,+BAAU,MAAM;AACd,iDAA6B;AAAA,EAC/B,CAAC;AAED,wBAAG,oDAAoD,MAAM;AAC3D,8BAAO,qBAAU,YAAY,CAAC,EAAE,KAAK,IAAI;AAAA,EAC3C,CAAC;AAED,wBAAG,0DAA0D,MAAM;AACjE,iDAA6B;AAE7B,8BAAO,qBAAU,YAAY,CAAC,EAAE,KAAK,KAAK;AAAA,EAC5C,CAAC;AAED,wBAAG,0DAA0D,YAAY;AACvE,iDAA6B;AAC7B,UAAM,UAAiB,CAAC;AACxB,UAAM,SAAS,MAAM,qBAAU,MAAM,iBAAiB;AAAA,MACpD,SAAS;AAAA,MACT,SAAS,CAAC,MAAM,SAAS,QAAQ,KAAK,EAAE,MAAM,KAAK,CAAC;AAAA,IACtD,CAAC;AACD,8BAAO,OAAO,OAAO,EAAE,QAAQ,CAAC,CAAC;AACjC,8BAAO,OAAO,SAAS,EAAE,KAAK,CAAC;AAC/B,8BAAO,OAAO,EAAE,aAAa,CAAC;AAAA,EAChC,CAAC;AAED,wBAAG,iEAAiE,YAAY;AAC9E,qBAAiB,gBAAgB,eAAe;AAAA,MAC9C,EAAE,MAAM,GAAG,UAAU,iCAAiC,UAAU,MAAM;AAAA,MACtE,EAAE,MAAM,GAAG,UAAU,qBAAqB,UAAU,MAAM;AAAA,IAC5D,GAAG,EAAE,iBAAiB,CAAC,CAAC,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAAC;AAClD,mBAAe,gBAAgB;AAAA,MAC7B,SAAS;AAAA,MAAa,YAAY;AAAA,MAAM,OAAO;AAAA,MAC/C,mBAAmB;AAAA,MAAO,iBAAiB;AAAA,IAC7C,CAAC;AAED,UAAM,UAAkD,CAAC;AACzD,UAAM,SAAS,MAAM,qBAAU,MAAM,oBAAoB;AAAA,MACvD,SAAS;AAAA,MACT,SAAS,CAAC,MAAM,SAAS,QAAQ,KAAK,EAAE,MAAM,KAAK,CAAC;AAAA,IACtD,CAAC;AAED,8BAAO,OAAO,OAAO,EAAE,QAAQ,CAAC,QAAQ,WAAW,aAAa,cAAc,aAAa,CAAC;AAC5F,8BAAO,OAAO,SAAS,EAAE,KAAK,CAAC;AAC/B,8BAAO,OAAO,EAAE,aAAa,CAAC;AAC9B,8BAAO,QAAQ,CAAC,EAAG,KAAK,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,KAAK,WAAW,SAAS,YAAY,QAAQ,CAAC;AAChG,8BAAO,QAAQ,CAAC,EAAG,KAAK,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,KAAK,WAAW,SAAS,YAAY,OAAO,CAAC;AAE/F,8BAAO,OAAO,YAAY,EAAE,WAAW;AACvC,UAAM,OAAO,KAAK,MAAM,OAAO,YAAa;AAC5C,8BAAO,KAAK,OAAO,EAAE,KAAK,WAAW;AACrC,8BAAO,KAAK,UAAU,EAAE,KAAK,IAAI;AACjC,8BAAO,KAAK,iBAAiB,EAAE,KAAK,KAAK;AAAA,EAC3C,CAAC;AAED,wBAAG,iEAAiE,YAAY;AAC9E,qBAAiB,gBAAgB,eAAe;AAAA,MAC9C,EAAE,MAAM,GAAG,UAAU,gBAAgB,UAAU,MAAM;AAAA,MACrD,EAAE,MAAM,GAAG,UAAU,IAAI,UAAU,KAAK;AAAA,MACxC,EAAE,MAAM,GAAG,UAAU,aAAa,UAAU,MAAM;AAAA,MAClD,EAAE,MAAM,GAAG,UAAU,IAAI,UAAU,KAAK;AAAA,IAC1C,CAAC,CAAC;AACF,mBAAe,gBAAgB,EAAE,SAAS,SAAS,YAAY,MAAM,mBAAmB,OAAO,iBAAiB,MAAM,CAAC;AAEvH,UAAM,UAAkC,CAAC;AACzC,UAAM,qBAAU,MAAM,mBAAmB;AAAA,MACvC,SAAS;AAAA,MACT,SAAS,CAACA,UAAS,QAAQ,KAAK,EAAE,MAAAA,MAAK,CAAC;AAAA,IAC1C,CAAC;AAED,8BAAO,OAAO,EAAE,aAAa,CAAC;AAC9B,UAAM,OAAO,QAAQ,CAAC,EAAG;AACzB,8BAAO,IAAI,EAAE,aAAa,CAAC;AAC3B,8BAAO,KAAK,OAAO,CAAC,MAAW,EAAE,cAAc,MAAM,CAAC,EAAE,aAAa,CAAC;AACtE,8BAAO,KAAK,OAAO,CAAC,MAAW,EAAE,cAAc,OAAO,CAAC,EAAE,aAAa,CAAC;AAAA,EACzE,CAAC;AAED,wBAAG,iDAAiD,YAAY;AAC9D,qBAAiB,gBAAgB,eAAe,CAAC,EAAE,MAAM,GAAG,UAAU,WAAW,UAAU,MAAM,CAAC,CAAC,CAAC;AACpG,mBAAe,gBAAgB,EAAE,SAAS,aAAa,YAAY,KAAK,mBAAmB,MAAM,iBAAiB,MAAM,CAAC;AAEzH,UAAM,SAAS,MAAM,qBAAU,MAAM,qBAAqB,EAAE,SAAS,KAAM,SAAS,MAAM;AAAA,IAAC,EAAE,CAAC;AAE9F,8BAAO,OAAO,YAAY,EAAE,WAAW;AACvC,UAAM,OAAO,KAAK,MAAM,OAAO,YAAa;AAC5C,8BAAO,KAAK,iBAAiB,EAAE,KAAK,IAAI;AAAA,EAC1C,CAAC;AAED,wBAAG,0CAA0C,YAAY;AACvD,qBAAiB,gBAAgB,EAAE,OAAO,CAAC,GAAG,iBAAiB,CAAC,GAAG,kBAAkB,CAAC,EAAE,CAAC;AACzF,mBAAe,gBAAgB,EAAE,SAAS,aAAa,YAAY,GAAG,mBAAmB,OAAO,iBAAiB,MAAM,CAAC;AAExH,UAAM,UAAiB,CAAC;AACxB,UAAM,SAAS,MAAM,qBAAU,MAAM,mBAAmB;AAAA,MACtD,SAAS;AAAA,MACT,SAAS,CAAC,MAAM,SAAS,QAAQ,KAAK,EAAE,MAAM,KAAK,CAAC;AAAA,IACtD,CAAC;AAED,8BAAO,OAAO,SAAS,EAAE,KAAK,CAAC;AAC/B,8BAAO,OAAO,EAAE,aAAa,CAAC;AAAA,EAChC,CAAC;AAED,wBAAG,mEAA8D,YAAY;AAC3E,qBAAiB,gBAAgB,eAAe,CAAC,EAAE,MAAM,GAAG,UAAU,WAAW,UAAU,MAAM,CAAC,CAAC,CAAC;AACpG,mBAAe,mBAAmB,MAAM;AAAE,YAAM,IAAI,MAAM,mBAAmB;AAAA,IAAG,CAAC;AAEjF,UAAM,UAAiB,CAAC;AACxB,UAAM,SAAS,MAAM,qBAAU,MAAM,yBAAyB;AAAA,MAC5D,SAAS;AAAA,MACT,SAAS,CAAC,MAAM,SAAS,QAAQ,KAAK,EAAE,MAAM,KAAK,CAAC;AAAA,IACtD,CAAC;AAED,8BAAO,OAAO,SAAS,EAAE,KAAK,CAAC;AAC/B,8BAAO,OAAO,EAAE,aAAa,CAAC;AAC9B,8BAAO,OAAO,YAAY,EAAE,SAAS;AAAA,EACvC,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": ["rows"]
|
|
7
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var pixelrag_bridge_exports = {};
|
|
20
|
-
__export(pixelrag_bridge_exports, {
|
|
21
|
-
getStatus: () => getStatus,
|
|
22
|
-
isServerRunning: () => isServerRunning,
|
|
23
|
-
searchVisual: () => searchVisual
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(pixelrag_bridge_exports);
|
|
26
|
-
async function isServerRunning(endpoint) {
|
|
27
|
-
try {
|
|
28
|
-
const res = await fetch(`${endpoint}/health`, { signal: AbortSignal.timeout(2e3) });
|
|
29
|
-
return res.ok;
|
|
30
|
-
} catch {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async function searchVisual(endpoint, query, opts = {}) {
|
|
35
|
-
const limit = opts.limit ?? 3;
|
|
36
|
-
const minTileHeight = opts.minTileHeight ?? 50;
|
|
37
|
-
const idMap = opts.idMap ?? {};
|
|
38
|
-
const res = await fetch(`${endpoint}/search`, {
|
|
39
|
-
method: "POST",
|
|
40
|
-
headers: { "Content-Type": "application/json" },
|
|
41
|
-
body: JSON.stringify({ queries: [{ text: query }], n_docs: limit }),
|
|
42
|
-
signal: AbortSignal.timeout(3e4)
|
|
43
|
-
});
|
|
44
|
-
if (!res.ok) {
|
|
45
|
-
const body = await res.text().catch(() => "");
|
|
46
|
-
throw new Error(`PixelRAG /search returned ${res.status}: ${body}`);
|
|
47
|
-
}
|
|
48
|
-
const data = await res.json();
|
|
49
|
-
const hits = data.results?.[0]?.hits ?? [];
|
|
50
|
-
const out = [];
|
|
51
|
-
for (const hit of hits) {
|
|
52
|
-
const h = hit;
|
|
53
|
-
const tileHeight = typeof h.tile_height === "number" ? h.tile_height : 0;
|
|
54
|
-
if (tileHeight < minTileHeight) continue;
|
|
55
|
-
const articleId = String(h.article_id ?? h.url ?? "");
|
|
56
|
-
const filePath = idMap[articleId] ?? articleId;
|
|
57
|
-
out.push({
|
|
58
|
-
score: typeof h.score === "number" ? h.score : 0,
|
|
59
|
-
filePath,
|
|
60
|
-
tileIndex: typeof h.tile_index === "number" ? h.tile_index : 0,
|
|
61
|
-
chunkIndex: typeof h.chunk_index === "number" ? h.chunk_index : 0,
|
|
62
|
-
yOffset: typeof h.y_offset === "number" ? h.y_offset : 0,
|
|
63
|
-
chunkHeight: tileHeight,
|
|
64
|
-
chunkImagePath: typeof h.path === "string" ? h.path : ""
|
|
65
|
-
});
|
|
66
|
-
if (out.length >= limit) break;
|
|
67
|
-
}
|
|
68
|
-
return out;
|
|
69
|
-
}
|
|
70
|
-
async function getStatus(endpoint, indexPath) {
|
|
71
|
-
const running = await isServerRunning(endpoint);
|
|
72
|
-
let tileCount = null;
|
|
73
|
-
let lastBuilt = null;
|
|
74
|
-
if (running) {
|
|
75
|
-
try {
|
|
76
|
-
const res = await fetch(`${endpoint}/status`, { signal: AbortSignal.timeout(3e3) });
|
|
77
|
-
if (res.ok) {
|
|
78
|
-
const data = await res.json();
|
|
79
|
-
if (typeof data.tile_count === "number") tileCount = data.tile_count;
|
|
80
|
-
if (typeof data.built_at === "number") lastBuilt = data.built_at * 1e3;
|
|
81
|
-
}
|
|
82
|
-
} catch {
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return { running, endpoint, indexPath, tileCount, lastBuilt };
|
|
86
|
-
}
|
|
87
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
-
0 && (module.exports = {
|
|
89
|
-
getStatus,
|
|
90
|
-
isServerRunning,
|
|
91
|
-
searchVisual
|
|
92
|
-
});
|
|
93
|
-
//# sourceMappingURL=pixelrag-bridge.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/data/pixelrag-bridge.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * PixelRAG HTTP bridge \u2014 pure client, no lifecycle management.\n * All lifecycle (install, index build, server spawn) lives in pixelrag-manager.ts.\n *\n * EXPERIMENTAL: This module is experimental and may change without notice.\n */\n\nimport type { VisualSearchResult, PixelRAGStatus } from './types';\n\nexport async function isServerRunning(endpoint: string): Promise<boolean> {\n try {\n const res = await fetch(`${endpoint}/health`, { signal: AbortSignal.timeout(2000) });\n return res.ok;\n } catch {\n return false;\n }\n}\n\n/**\n * Actual /search response shape (from live testing with pixelrag 0.3.x):\n * { \"results\": [ { \"hits\": [ { score, article_id, tile_index, chunk_index,\n * y_offset, tile_height, path, url, \u2026 } ] } ] }\n *\n * @param idMap Optional mapping from article_id (string) \u2192 original PDF absolute path.\n * Loaded from <kirographDir>/pixelrag-id-map.json by the caller.\n */\nexport async function searchVisual(\n endpoint: string,\n query: string,\n opts: { limit?: number; minTileHeight?: number; idMap?: Record<string, string> } = {},\n): Promise<VisualSearchResult[]> {\n const limit = opts.limit ?? 3;\n const minTileHeight = opts.minTileHeight ?? 50;\n const idMap = opts.idMap ?? {};\n\n const res = await fetch(`${endpoint}/search`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ queries: [{ text: query }], n_docs: limit }),\n signal: AbortSignal.timeout(30_000),\n });\n\n if (!res.ok) {\n const body = await res.text().catch(() => '');\n throw new Error(`PixelRAG /search returned ${res.status}: ${body}`);\n }\n\n // results[0].hits contains the actual hit list\n const data = await res.json() as { results?: { hits?: unknown[] }[] };\n const hits = data.results?.[0]?.hits ?? [];\n\n const out: VisualSearchResult[] = [];\n for (const hit of hits) {\n const h = hit as Record<string, unknown>;\n\n const tileHeight = typeof h.tile_height === 'number' ? h.tile_height : 0;\n if (tileHeight < minTileHeight) continue;\n\n const articleId = String(h.article_id ?? h.url ?? '');\n const filePath = idMap[articleId] ?? articleId;\n\n out.push({\n score: typeof h.score === 'number' ? h.score : 0,\n filePath,\n tileIndex: typeof h.tile_index === 'number' ? h.tile_index : 0,\n chunkIndex: typeof h.chunk_index === 'number' ? h.chunk_index : 0,\n yOffset: typeof h.y_offset === 'number' ? h.y_offset : 0,\n chunkHeight: tileHeight,\n chunkImagePath: typeof h.path === 'string' ? h.path : '',\n });\n\n if (out.length >= limit) break;\n }\n\n return out;\n}\n\nexport async function getStatus(endpoint: string, indexPath: string | null): Promise<PixelRAGStatus> {\n const running = await isServerRunning(endpoint);\n let tileCount: number | null = null;\n let lastBuilt: number | null = null;\n\n if (running) {\n try {\n const res = await fetch(`${endpoint}/status`, { signal: AbortSignal.timeout(3000) });\n if (res.ok) {\n const data = await res.json() as Record<string, unknown>;\n if (typeof data.tile_count === 'number') tileCount = data.tile_count;\n if (typeof data.built_at === 'number') lastBuilt = data.built_at * 1000;\n }\n } catch { /* best-effort */ }\n }\n\n return { running, endpoint, indexPath, tileCount, lastBuilt };\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,eAAsB,gBAAgB,UAAoC;AACxE,MAAI;AACF,UAAM,MAAM,MAAM,MAAM,GAAG,QAAQ,WAAW,EAAE,QAAQ,YAAY,QAAQ,GAAI,EAAE,CAAC;AACnF,WAAO,IAAI;AAAA,EACb,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAUA,eAAsB,aACpB,UACA,OACA,OAAmF,CAAC,GACrD;AAC/B,QAAM,QAAgB,KAAK,SAAS;AACpC,QAAM,gBAAgB,KAAK,iBAAiB;AAC5C,QAAM,QAAgB,KAAK,SAAS,CAAC;AAErC,QAAM,MAAM,MAAM,MAAM,GAAG,QAAQ,WAAW;AAAA,IAC5C,QAAQ;AAAA,IACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,IAC9C,MAAM,KAAK,UAAU,EAAE,SAAS,CAAC,EAAE,MAAM,MAAM,CAAC,GAAG,QAAQ,MAAM,CAAC;AAAA,IAClE,QAAQ,YAAY,QAAQ,GAAM;AAAA,EACpC,CAAC;AAED,MAAI,CAAC,IAAI,IAAI;AACX,UAAM,OAAO,MAAM,IAAI,KAAK,EAAE,MAAM,MAAM,EAAE;AAC5C,UAAM,IAAI,MAAM,6BAA6B,IAAI,MAAM,KAAK,IAAI,EAAE;AAAA,EACpE;AAGA,QAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,QAAM,OAAO,KAAK,UAAU,CAAC,GAAG,QAAQ,CAAC;AAEzC,QAAM,MAA4B,CAAC;AACnC,aAAW,OAAO,MAAM;AACtB,UAAM,IAAI;AAEV,UAAM,aAAa,OAAO,EAAE,gBAAgB,WAAW,EAAE,cAAc;AACvE,QAAI,aAAa,cAAe;AAEhC,UAAM,YAAY,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE;AACpD,UAAM,WAAY,MAAM,SAAS,KAAK;AAEtC,QAAI,KAAK;AAAA,MACP,OAAgB,OAAO,EAAE,UAAU,WAAW,EAAE,QAAQ;AAAA,MACxD;AAAA,MACA,WAAgB,OAAO,EAAE,eAAiB,WAAW,EAAE,aAAe;AAAA,MACtE,YAAgB,OAAO,EAAE,gBAAiB,WAAW,EAAE,cAAe;AAAA,MACtE,SAAgB,OAAO,EAAE,aAAiB,WAAW,EAAE,WAAe;AAAA,MACtE,aAAgB;AAAA,MAChB,gBAAgB,OAAO,EAAE,SAAS,WAAW,EAAE,OAAO;AAAA,IACxD,CAAC;AAED,QAAI,IAAI,UAAU,MAAO;AAAA,EAC3B;AAEA,SAAO;AACT;AAEA,eAAsB,UAAU,UAAkB,WAAmD;AACnG,QAAM,UAAU,MAAM,gBAAgB,QAAQ;AAC9C,MAAI,YAA2B;AAC/B,MAAI,YAA2B;AAE/B,MAAI,SAAS;AACX,QAAI;AACF,YAAM,MAAM,MAAM,MAAM,GAAG,QAAQ,WAAW,EAAE,QAAQ,YAAY,QAAQ,GAAI,EAAE,CAAC;AACnF,UAAI,IAAI,IAAI;AACV,cAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,YAAI,OAAO,KAAK,eAAe,SAAU,aAAY,KAAK;AAC1D,YAAI,OAAO,KAAK,aAAa,SAAU,aAAY,KAAK,WAAW;AAAA,MACrE;AAAA,IACF,QAAQ;AAAA,IAAoB;AAAA,EAC9B;AAEA,SAAO,EAAE,SAAS,UAAU,WAAW,WAAW,UAAU;AAC9D;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,416 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var pixelrag_manager_exports = {};
|
|
30
|
-
__export(pixelrag_manager_exports, {
|
|
31
|
-
buildIndex: () => buildIndex,
|
|
32
|
-
checkRam: () => checkRam,
|
|
33
|
-
detectPython: () => detectPython,
|
|
34
|
-
detectWSL2: () => detectWSL2,
|
|
35
|
-
downloadPixelRAGModel: () => downloadPixelRAGModel,
|
|
36
|
-
ensurePixelRAGInstalled: () => ensurePixelRAGInstalled,
|
|
37
|
-
ensurePython: () => ensurePython,
|
|
38
|
-
getFlaggedPdfs: () => getFlaggedPdfs,
|
|
39
|
-
installPixelRAG: () => installPixelRAG,
|
|
40
|
-
isPixelRAGInstalled: () => isPixelRAGInstalled,
|
|
41
|
-
startServer: () => startServer
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(pixelrag_manager_exports);
|
|
44
|
-
var fs = __toESM(require("fs"));
|
|
45
|
-
var os = __toESM(require("os"));
|
|
46
|
-
var path = __toESM(require("path"));
|
|
47
|
-
var import_child_process = require("child_process");
|
|
48
|
-
const PIXELRAG_ENV = {
|
|
49
|
-
...process.env,
|
|
50
|
-
OMP_NUM_THREADS: "1",
|
|
51
|
-
KMP_DUPLICATE_LIB_OK: "TRUE"
|
|
52
|
-
};
|
|
53
|
-
function detectPython() {
|
|
54
|
-
for (const bin of ["python3", "python"]) {
|
|
55
|
-
try {
|
|
56
|
-
const result = (0, import_child_process.spawnSync)(bin, ["--version"], { encoding: "utf8", timeout: 5e3 });
|
|
57
|
-
if (result.status !== 0) continue;
|
|
58
|
-
const out = (result.stdout + result.stderr).trim();
|
|
59
|
-
const match = out.match(/Python (\d+)\.(\d+)/);
|
|
60
|
-
if (!match) continue;
|
|
61
|
-
const [, major, minor] = match;
|
|
62
|
-
if (Number(major) >= 3 && Number(minor) >= 12) return bin;
|
|
63
|
-
} catch {
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
function ensurePython() {
|
|
69
|
-
const bin = detectPython();
|
|
70
|
-
if (!bin) {
|
|
71
|
-
throw new Error(
|
|
72
|
-
"PixelRAG (visual PDF search) requires Python 3.12+.\nInstall from https://python.org or via brew: brew install python@3.12"
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
return bin;
|
|
76
|
-
}
|
|
77
|
-
function getPixelRAGBin(python) {
|
|
78
|
-
try {
|
|
79
|
-
const exe = (0, import_child_process.spawnSync)(python, ["-c", "import sys; print(sys.executable)"], {
|
|
80
|
-
encoding: "utf8",
|
|
81
|
-
timeout: 5e3
|
|
82
|
-
}).stdout?.trim() ?? "";
|
|
83
|
-
if (exe) {
|
|
84
|
-
const candidate = path.join(path.dirname(exe), "pixelrag");
|
|
85
|
-
if (fs.existsSync(candidate)) return candidate;
|
|
86
|
-
}
|
|
87
|
-
} catch {
|
|
88
|
-
}
|
|
89
|
-
try {
|
|
90
|
-
const which = (0, import_child_process.spawnSync)("which", ["pixelrag"], { encoding: "utf8", timeout: 3e3 });
|
|
91
|
-
if (which.status === 0) {
|
|
92
|
-
const bin = which.stdout.trim();
|
|
93
|
-
if (bin) return bin;
|
|
94
|
-
}
|
|
95
|
-
} catch {
|
|
96
|
-
}
|
|
97
|
-
for (const loc of ["/opt/homebrew/bin/pixelrag", "/usr/local/bin/pixelrag"]) {
|
|
98
|
-
if (fs.existsSync(loc)) return loc;
|
|
99
|
-
}
|
|
100
|
-
throw new Error(
|
|
101
|
-
"pixelrag binary not found.\nRun: pip install pixelrag[index,serve] pixelrag-render[pdf]\nAlso requires poppler: brew install poppler"
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
function detectWSL2() {
|
|
105
|
-
try {
|
|
106
|
-
const version = fs.readFileSync("/proc/version", "utf8");
|
|
107
|
-
return /microsoft|WSL/i.test(version);
|
|
108
|
-
} catch {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function freeRam() {
|
|
113
|
-
return os.freemem();
|
|
114
|
-
}
|
|
115
|
-
const WARN_RAM_BYTES = 4 * 1024 * 1024 * 1024;
|
|
116
|
-
const BLOCK_RAM_BYTES = 2 * 1024 * 1024 * 1024;
|
|
117
|
-
function checkRam() {
|
|
118
|
-
const free = freeRam();
|
|
119
|
-
if (free < BLOCK_RAM_BYTES) return "block";
|
|
120
|
-
if (free < WARN_RAM_BYTES) return "warn";
|
|
121
|
-
return "ok";
|
|
122
|
-
}
|
|
123
|
-
function isPixelRAGInstalled(python) {
|
|
124
|
-
try {
|
|
125
|
-
const bin = getPixelRAGBin(python);
|
|
126
|
-
const result = (0, import_child_process.spawnSync)(bin, ["--help"], { encoding: "utf8", timeout: 5e3 });
|
|
127
|
-
return result.status === 0;
|
|
128
|
-
} catch {
|
|
129
|
-
}
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
function installPixelRAG(python) {
|
|
133
|
-
console.log(" Installing PixelRAG (pip install pixelrag[index,serve] pixelrag-render[pdf])\u2026");
|
|
134
|
-
let exePath = "";
|
|
135
|
-
try {
|
|
136
|
-
exePath = (0, import_child_process.spawnSync)(python, ["-c", "import sys; print(sys.executable)"], {
|
|
137
|
-
encoding: "utf8",
|
|
138
|
-
timeout: 5e3
|
|
139
|
-
}).stdout?.trim() ?? "";
|
|
140
|
-
} catch {
|
|
141
|
-
}
|
|
142
|
-
const extraArgs = exePath.includes("/opt/homebrew/") || exePath.includes("/usr/local/") ? ["--break-system-packages"] : [];
|
|
143
|
-
const result = (0, import_child_process.spawnSync)(
|
|
144
|
-
python,
|
|
145
|
-
["-m", "pip", "install", "pixelrag[index,serve]", "pixelrag-render[pdf]", ...extraArgs],
|
|
146
|
-
{ stdio: "inherit", timeout: 3e5 }
|
|
147
|
-
);
|
|
148
|
-
if (result.status !== 0) {
|
|
149
|
-
throw new Error(
|
|
150
|
-
"pip install pixelrag failed. Check your Python environment.\nAlso ensure poppler is installed: brew install poppler"
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
function downloadPixelRAGModel(python) {
|
|
155
|
-
const pixelragBin = getPixelRAGBin(python);
|
|
156
|
-
console.log(" Pre-downloading Qwen3-VL-Embedding-2B model (~4 GB)\u2026");
|
|
157
|
-
const result = (0, import_child_process.spawnSync)(
|
|
158
|
-
pixelragBin,
|
|
159
|
-
["embed", "--help"],
|
|
160
|
-
// lightweight call that triggers model cache check
|
|
161
|
-
{ stdio: "inherit", timeout: 18e5, env: PIXELRAG_ENV }
|
|
162
|
-
);
|
|
163
|
-
if (result.status !== 0) {
|
|
164
|
-
console.warn(" \u26A0 Model pre-download may have failed \u2014 it will download on first use.");
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
function ensurePixelRAGInstalled(python) {
|
|
168
|
-
if (!isPixelRAGInstalled(python)) {
|
|
169
|
-
installPixelRAG(python);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
function readManifest(manifestPath) {
|
|
173
|
-
try {
|
|
174
|
-
return JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
175
|
-
} catch {
|
|
176
|
-
return [];
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
function writeManifest(manifestPath, entries) {
|
|
180
|
-
fs.writeFileSync(manifestPath, JSON.stringify(entries, null, 2));
|
|
181
|
-
}
|
|
182
|
-
function buildManifestEntries(absPaths) {
|
|
183
|
-
return absPaths.map((p) => {
|
|
184
|
-
try {
|
|
185
|
-
const st = fs.statSync(p);
|
|
186
|
-
return { path: p, mtime: st.mtimeMs, size: st.size };
|
|
187
|
-
} catch {
|
|
188
|
-
return { path: p, mtime: 0, size: 0 };
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
function manifestIsStale(current, fresh) {
|
|
193
|
-
if (current.length !== fresh.length) return true;
|
|
194
|
-
const map = new Map(current.map((e) => [e.path, e]));
|
|
195
|
-
for (const f of fresh) {
|
|
196
|
-
const c = map.get(f.path);
|
|
197
|
-
if (!c || c.mtime !== f.mtime || c.size !== f.size) return true;
|
|
198
|
-
}
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
function getFlaggedPdfs(rawDb, projectRoot) {
|
|
202
|
-
const datasets = rawDb.all(
|
|
203
|
-
`SELECT id, file_path FROM data_datasets WHERE format = 'pdf'`
|
|
204
|
-
);
|
|
205
|
-
const flagged = [];
|
|
206
|
-
for (const ds of datasets) {
|
|
207
|
-
const tableName = `data_rows_${ds.id.replace(/[^a-zA-Z0-9_]/g, "_")}`;
|
|
208
|
-
try {
|
|
209
|
-
const rows = rawDb.all(
|
|
210
|
-
`SELECT COUNT(*) as cnt FROM "${tableName}" WHERE needs_ocr = 'true' OR has_columns = 'true'`
|
|
211
|
-
);
|
|
212
|
-
if (rows[0]?.cnt > 0) {
|
|
213
|
-
const absPath = path.isAbsolute(ds.file_path) ? ds.file_path : path.join(projectRoot, ds.file_path);
|
|
214
|
-
flagged.push(absPath);
|
|
215
|
-
}
|
|
216
|
-
} catch {
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
return flagged;
|
|
220
|
-
}
|
|
221
|
-
function buildIndex(opts) {
|
|
222
|
-
const { python, flaggedPdfs, kirographDir, force } = opts;
|
|
223
|
-
const indexDir = path.join(kirographDir, "pixelrag-index");
|
|
224
|
-
const stagingDir = path.join(kirographDir, "pixelrag-staging");
|
|
225
|
-
const manifestFile = path.join(kirographDir, "pixelrag-manifest.json");
|
|
226
|
-
const idMapFile = path.join(kirographDir, "pixelrag-id-map.json");
|
|
227
|
-
if (flaggedPdfs.length === 0) {
|
|
228
|
-
console.log(" PixelRAG: no visually complex PDFs found \u2014 skipping index build.");
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
const freshEntries = buildManifestEntries(flaggedPdfs);
|
|
232
|
-
const currentEntries = readManifest(manifestFile);
|
|
233
|
-
const indexExists = fs.existsSync(indexDir);
|
|
234
|
-
if (!force && indexExists && !manifestIsStale(currentEntries, freshEntries)) {
|
|
235
|
-
console.log(` PixelRAG: index up to date (${flaggedPdfs.length} PDF${flaggedPdfs.length > 1 ? "s" : ""}).`);
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
const pixelragBin = getPixelRAGBin(python);
|
|
239
|
-
if (fs.existsSync(stagingDir)) {
|
|
240
|
-
fs.rmSync(stagingDir, { recursive: true, force: true });
|
|
241
|
-
}
|
|
242
|
-
fs.mkdirSync(stagingDir, { recursive: true });
|
|
243
|
-
const idMap = {};
|
|
244
|
-
for (let i = 0; i < flaggedPdfs.length; i++) {
|
|
245
|
-
fs.symlinkSync(flaggedPdfs[i], path.join(stagingDir, `${i}.pdf`));
|
|
246
|
-
idMap[String(i)] = flaggedPdfs[i];
|
|
247
|
-
}
|
|
248
|
-
const tileEstimate = flaggedPdfs.length * 40;
|
|
249
|
-
const cpuMinutes = Math.round(tileEstimate * 10 / 60);
|
|
250
|
-
const mpsMinutes = Math.round(tileEstimate * 2 / 60);
|
|
251
|
-
console.log(
|
|
252
|
-
` Building PixelRAG index: ~${tileEstimate} tiles (~${cpuMinutes} min on CPU, ~${mpsMinutes} min on MPS)\u2026`
|
|
253
|
-
);
|
|
254
|
-
const args = [
|
|
255
|
-
"index",
|
|
256
|
-
"build",
|
|
257
|
-
"--source",
|
|
258
|
-
stagingDir,
|
|
259
|
-
"--source-type",
|
|
260
|
-
"pdf",
|
|
261
|
-
"--output",
|
|
262
|
-
indexDir,
|
|
263
|
-
"--device",
|
|
264
|
-
"cpu"
|
|
265
|
-
];
|
|
266
|
-
if (force) args.push("--force");
|
|
267
|
-
const result = (0, import_child_process.spawnSync)(pixelragBin, args, {
|
|
268
|
-
stdio: "inherit",
|
|
269
|
-
timeout: 72e5,
|
|
270
|
-
// 2h hard limit
|
|
271
|
-
env: PIXELRAG_ENV
|
|
272
|
-
});
|
|
273
|
-
try {
|
|
274
|
-
fs.rmSync(stagingDir, { recursive: true, force: true });
|
|
275
|
-
} catch {
|
|
276
|
-
}
|
|
277
|
-
if (result.status !== 0) {
|
|
278
|
-
throw new Error("PixelRAG index build failed. Check Python output above for details.");
|
|
279
|
-
}
|
|
280
|
-
fs.writeFileSync(idMapFile, JSON.stringify(idMap, null, 2));
|
|
281
|
-
writeManifest(manifestFile, freshEntries);
|
|
282
|
-
console.log(` \u2713 PixelRAG index built (${flaggedPdfs.length} PDF${flaggedPdfs.length > 1 ? "s" : ""}).`);
|
|
283
|
-
}
|
|
284
|
-
let _serverProcess = null;
|
|
285
|
-
let _cleanupRegistered = false;
|
|
286
|
-
function registerCleanup() {
|
|
287
|
-
if (_cleanupRegistered) return;
|
|
288
|
-
_cleanupRegistered = true;
|
|
289
|
-
const cleanup = () => {
|
|
290
|
-
if (_serverProcess) {
|
|
291
|
-
try {
|
|
292
|
-
_serverProcess.kill("SIGTERM");
|
|
293
|
-
} catch {
|
|
294
|
-
}
|
|
295
|
-
setTimeout(() => {
|
|
296
|
-
try {
|
|
297
|
-
_serverProcess?.kill("SIGKILL");
|
|
298
|
-
} catch {
|
|
299
|
-
}
|
|
300
|
-
}, 5e3).unref();
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
process.on("exit", cleanup);
|
|
304
|
-
process.on("SIGINT", () => {
|
|
305
|
-
cleanup();
|
|
306
|
-
process.exit(0);
|
|
307
|
-
});
|
|
308
|
-
process.on("SIGTERM", () => {
|
|
309
|
-
cleanup();
|
|
310
|
-
process.exit(0);
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
async function pollHealth(endpoint, maxAttempts, intervalMs) {
|
|
314
|
-
for (let i = 0; i < maxAttempts; i++) {
|
|
315
|
-
await new Promise((r) => setTimeout(r, intervalMs));
|
|
316
|
-
try {
|
|
317
|
-
const res = await fetch(`${endpoint}/health`, { signal: AbortSignal.timeout(2e3) });
|
|
318
|
-
if (res.ok) return true;
|
|
319
|
-
if (res.status !== 404 && res.status !== 503) {
|
|
320
|
-
console.warn(` \u26A0 Port ${endpoint}: unexpected response (${res.status}). Another process may be on this port.`);
|
|
321
|
-
return false;
|
|
322
|
-
}
|
|
323
|
-
} catch (e) {
|
|
324
|
-
const err = e;
|
|
325
|
-
if (err.code && err.code !== "ECONNREFUSED" && err.code !== "ECONNRESET" && err.code !== "UND_ERR_CONNECT_TIMEOUT") {
|
|
326
|
-
console.warn(` \u26A0 PixelRAG health check: ${String(e)}`);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
if ((i + 1) % 8 === 0) {
|
|
330
|
-
console.log(` PixelRAG loading model\u2026 ${Math.round((i + 1) * intervalMs / 1e3)}s elapsed`);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
async function startServer(python, port, kirographDir) {
|
|
336
|
-
const endpoint = `http://localhost:${port}`;
|
|
337
|
-
const indexDir = path.join(kirographDir, "pixelrag-index");
|
|
338
|
-
const ramState = checkRam();
|
|
339
|
-
if (ramState === "block") {
|
|
340
|
-
throw new Error(
|
|
341
|
-
`PixelRAG server requires at least 4 GB free RAM.
|
|
342
|
-
Current free: ${(freeRam() / 1024 / 1024 / 1024).toFixed(1)} GB.
|
|
343
|
-
Close other applications and retry, or disable enableVisualPDF.`
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
if (ramState === "warn") {
|
|
347
|
-
console.warn(
|
|
348
|
-
` \u26A0 Low RAM: ${(freeRam() / 1024 / 1024 / 1024).toFixed(1)} GB free. PixelRAG may degrade system performance.`
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
if (detectWSL2()) {
|
|
352
|
-
console.warn(
|
|
353
|
-
" \u26A0 WSL2 detected. Visual PDF search has known limitations:\n \u2022 Ensure your project is on the Linux filesystem (/home/...), not /mnt/c/...\n \u2022 Allocate at least 8 GB to WSL2 in %USERPROFILE%\\.wslconfig\n \u2022 CUDA requires updated NVIDIA drivers with WSL2 support"
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
try {
|
|
357
|
-
const res = await fetch(`${endpoint}/health`, { signal: AbortSignal.timeout(2e3) });
|
|
358
|
-
if (res.ok) {
|
|
359
|
-
console.log(` PixelRAG server already running on port ${port}.`);
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
} catch {
|
|
363
|
-
}
|
|
364
|
-
if (!fs.existsSync(indexDir)) {
|
|
365
|
-
console.warn(
|
|
366
|
-
` \u26A0 PixelRAG index not found at ${indexDir}.
|
|
367
|
-
Run: kirograph index \u2014 to build it first.`
|
|
368
|
-
);
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
const pixelragBin = getPixelRAGBin(python);
|
|
372
|
-
console.log(` Starting PixelRAG server on port ${port}\u2026`);
|
|
373
|
-
_serverProcess = (0, import_child_process.spawn)(
|
|
374
|
-
pixelragBin,
|
|
375
|
-
[
|
|
376
|
-
"serve",
|
|
377
|
-
"--index-dir",
|
|
378
|
-
indexDir,
|
|
379
|
-
"--tiles-dir",
|
|
380
|
-
path.join(indexDir, "tiles"),
|
|
381
|
-
"--articles-json",
|
|
382
|
-
path.join(indexDir, "articles.json"),
|
|
383
|
-
"--port",
|
|
384
|
-
String(port)
|
|
385
|
-
],
|
|
386
|
-
{ stdio: ["ignore", "ignore", "ignore"], detached: false, env: PIXELRAG_ENV }
|
|
387
|
-
);
|
|
388
|
-
_serverProcess.on("error", (err) => {
|
|
389
|
-
console.warn(` \u26A0 PixelRAG server error: ${err.message}`);
|
|
390
|
-
});
|
|
391
|
-
registerCleanup();
|
|
392
|
-
const ready = await pollHealth(endpoint, 90, 2e3);
|
|
393
|
-
if (ready) {
|
|
394
|
-
console.log(` \u2713 PixelRAG server ready on port ${port}.`);
|
|
395
|
-
} else {
|
|
396
|
-
console.warn(
|
|
397
|
-
` \u26A0 PixelRAG server did not respond within 3 minutes.
|
|
398
|
-
Visual PDF search calls will fail until it is ready.`
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
403
|
-
0 && (module.exports = {
|
|
404
|
-
buildIndex,
|
|
405
|
-
checkRam,
|
|
406
|
-
detectPython,
|
|
407
|
-
detectWSL2,
|
|
408
|
-
downloadPixelRAGModel,
|
|
409
|
-
ensurePixelRAGInstalled,
|
|
410
|
-
ensurePython,
|
|
411
|
-
getFlaggedPdfs,
|
|
412
|
-
installPixelRAG,
|
|
413
|
-
isPixelRAGInstalled,
|
|
414
|
-
startServer
|
|
415
|
-
});
|
|
416
|
-
//# sourceMappingURL=pixelrag-manager.js.map
|