@agent-native/creative-context 0.1.0
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 +108 -0
- package/agent-native.package.json +104 -0
- package/dist/actions/confirm-canonical-logo.d.ts +6 -0
- package/dist/actions/confirm-canonical-logo.d.ts.map +1 -0
- package/dist/actions/confirm-canonical-logo.js +19 -0
- package/dist/actions/confirm-canonical-logo.js.map +1 -0
- package/dist/actions/continue-context-import.d.ts +7 -0
- package/dist/actions/continue-context-import.d.ts.map +1 -0
- package/dist/actions/continue-context-import.js +10 -0
- package/dist/actions/continue-context-import.js.map +1 -0
- package/dist/actions/creative-context-a2a.d.ts +10 -0
- package/dist/actions/creative-context-a2a.d.ts.map +1 -0
- package/dist/actions/creative-context-a2a.js +66 -0
- package/dist/actions/creative-context-a2a.js.map +1 -0
- package/dist/actions/get-brand-profile.d.ts +33 -0
- package/dist/actions/get-brand-profile.d.ts.map +1 -0
- package/dist/actions/get-brand-profile.js +13 -0
- package/dist/actions/get-brand-profile.js.map +1 -0
- package/dist/actions/get-context-import-status.d.ts +22 -0
- package/dist/actions/get-context-import-status.d.ts.map +1 -0
- package/dist/actions/get-context-import-status.js +12 -0
- package/dist/actions/get-context-import-status.js.map +1 -0
- package/dist/actions/get-context-item.d.ts +2 -0
- package/dist/actions/get-context-item.d.ts.map +1 -0
- package/dist/actions/get-context-item.js +2 -0
- package/dist/actions/get-context-item.js.map +1 -0
- package/dist/actions/get-context-pack.d.ts +7 -0
- package/dist/actions/get-context-pack.d.ts.map +1 -0
- package/dist/actions/get-context-pack.js +12 -0
- package/dist/actions/get-context-pack.js.map +1 -0
- package/dist/actions/get-creative-context.d.ts +119 -0
- package/dist/actions/get-creative-context.d.ts.map +1 -0
- package/dist/actions/get-creative-context.js +112 -0
- package/dist/actions/get-creative-context.js.map +1 -0
- package/dist/actions/index.d.ts +3 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +63 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/infer-brand-dna.d.ts +52 -0
- package/dist/actions/infer-brand-dna.d.ts.map +1 -0
- package/dist/actions/infer-brand-dna.js +13 -0
- package/dist/actions/infer-brand-dna.js.map +1 -0
- package/dist/actions/list-canonical-logo-candidates.d.ts +9 -0
- package/dist/actions/list-canonical-logo-candidates.d.ts.map +1 -0
- package/dist/actions/list-canonical-logo-candidates.js +82 -0
- package/dist/actions/list-canonical-logo-candidates.js.map +1 -0
- package/dist/actions/list-context-connections.d.ts +22 -0
- package/dist/actions/list-context-connections.d.ts.map +1 -0
- package/dist/actions/list-context-connections.js +43 -0
- package/dist/actions/list-context-connections.js.map +1 -0
- package/dist/actions/list-context-packs.d.ts +10 -0
- package/dist/actions/list-context-packs.d.ts.map +1 -0
- package/dist/actions/list-context-packs.js +16 -0
- package/dist/actions/list-context-packs.js.map +1 -0
- package/dist/actions/list-context-sources.d.ts +12 -0
- package/dist/actions/list-context-sources.d.ts.map +1 -0
- package/dist/actions/list-context-sources.js +20 -0
- package/dist/actions/list-context-sources.js.map +1 -0
- package/dist/actions/list-context-suggestions.d.ts +13 -0
- package/dist/actions/list-context-suggestions.d.ts.map +1 -0
- package/dist/actions/list-context-suggestions.js +28 -0
- package/dist/actions/list-context-suggestions.js.map +1 -0
- package/dist/actions/manage-brand-profile.d.ts +28 -0
- package/dist/actions/manage-brand-profile.d.ts.map +1 -0
- package/dist/actions/manage-brand-profile.js +47 -0
- package/dist/actions/manage-brand-profile.js.map +1 -0
- package/dist/actions/manage-context-pack.d.ts +33 -0
- package/dist/actions/manage-context-pack.d.ts.map +1 -0
- package/dist/actions/manage-context-pack.js +65 -0
- package/dist/actions/manage-context-pack.js.map +1 -0
- package/dist/actions/manage-context-source.d.ts +51 -0
- package/dist/actions/manage-context-source.d.ts.map +1 -0
- package/dist/actions/manage-context-source.js +137 -0
- package/dist/actions/manage-context-source.js.map +1 -0
- package/dist/actions/manage-layout-template.d.ts +13 -0
- package/dist/actions/manage-layout-template.d.ts.map +1 -0
- package/dist/actions/manage-layout-template.js +43 -0
- package/dist/actions/manage-layout-template.js.map +1 -0
- package/dist/actions/preview-context-import.d.ts +23 -0
- package/dist/actions/preview-context-import.d.ts.map +1 -0
- package/dist/actions/preview-context-import.js +57 -0
- package/dist/actions/preview-context-import.js.map +1 -0
- package/dist/actions/process-context-purge.d.ts +22 -0
- package/dist/actions/process-context-purge.d.ts.map +1 -0
- package/dist/actions/process-context-purge.js +19 -0
- package/dist/actions/process-context-purge.js.map +1 -0
- package/dist/actions/propose-brand-dna.d.ts +15 -0
- package/dist/actions/propose-brand-dna.d.ts.map +1 -0
- package/dist/actions/propose-brand-dna.js +19 -0
- package/dist/actions/propose-brand-dna.js.map +1 -0
- package/dist/actions/propose-canonical-logo.d.ts +9 -0
- package/dist/actions/propose-canonical-logo.d.ts.map +1 -0
- package/dist/actions/propose-canonical-logo.js +16 -0
- package/dist/actions/propose-canonical-logo.js.map +1 -0
- package/dist/actions/publish-brand-dna.d.ts +13 -0
- package/dist/actions/publish-brand-dna.d.ts.map +1 -0
- package/dist/actions/publish-brand-dna.js +23 -0
- package/dist/actions/publish-brand-dna.js.map +1 -0
- package/dist/actions/recommend-context-roots.d.ts +14 -0
- package/dist/actions/recommend-context-roots.d.ts.map +1 -0
- package/dist/actions/recommend-context-roots.js +22 -0
- package/dist/actions/recommend-context-roots.js.map +1 -0
- package/dist/actions/record-context-feedback.d.ts +10 -0
- package/dist/actions/record-context-feedback.d.ts.map +1 -0
- package/dist/actions/record-context-feedback.js +14 -0
- package/dist/actions/record-context-feedback.js.map +1 -0
- package/dist/actions/review-context-items.d.ts +35 -0
- package/dist/actions/review-context-items.d.ts.map +1 -0
- package/dist/actions/review-context-items.js +65 -0
- package/dist/actions/review-context-items.js.map +1 -0
- package/dist/actions/run-embedding-bakeoff.d.ts +15 -0
- package/dist/actions/run-embedding-bakeoff.d.ts.map +1 -0
- package/dist/actions/run-embedding-bakeoff.js +72 -0
- package/dist/actions/run-embedding-bakeoff.js.map +1 -0
- package/dist/actions/search-creative-context.d.ts +75 -0
- package/dist/actions/search-creative-context.d.ts.map +1 -0
- package/dist/actions/search-creative-context.js +41 -0
- package/dist/actions/search-creative-context.js.map +1 -0
- package/dist/actions/set-brand-dna.d.ts +15 -0
- package/dist/actions/set-brand-dna.d.ts.map +1 -0
- package/dist/actions/set-brand-dna.js +19 -0
- package/dist/actions/set-brand-dna.js.map +1 -0
- package/dist/actions/start-context-enrichment.d.ts +10 -0
- package/dist/actions/start-context-enrichment.d.ts.map +1 -0
- package/dist/actions/start-context-enrichment.js +46 -0
- package/dist/actions/start-context-enrichment.js.map +1 -0
- package/dist/actions/start-context-import.d.ts +9 -0
- package/dist/actions/start-context-import.d.ts.map +1 -0
- package/dist/actions/start-context-import.js +36 -0
- package/dist/actions/start-context-import.js.map +1 -0
- package/dist/client/CreativeContextChip.d.ts +13 -0
- package/dist/client/CreativeContextChip.d.ts.map +1 -0
- package/dist/client/CreativeContextChip.js +45 -0
- package/dist/client/CreativeContextChip.js.map +1 -0
- package/dist/client/CreativeContextPanel.d.ts +131 -0
- package/dist/client/CreativeContextPanel.d.ts.map +1 -0
- package/dist/client/CreativeContextPanel.js +778 -0
- package/dist/client/CreativeContextPanel.js.map +1 -0
- package/dist/client/CreativeContextSettingsLink.d.ts +4 -0
- package/dist/client/CreativeContextSettingsLink.d.ts.map +1 -0
- package/dist/client/CreativeContextSettingsLink.js +8 -0
- package/dist/client/CreativeContextSettingsLink.js.map +1 -0
- package/dist/client/actions.d.ts +256 -0
- package/dist/client/actions.d.ts.map +1 -0
- package/dist/client/actions.js +89 -0
- package/dist/client/actions.js.map +1 -0
- package/dist/client/agent-tab.d.ts +9 -0
- package/dist/client/agent-tab.d.ts.map +1 -0
- package/dist/client/agent-tab.js +32 -0
- package/dist/client/agent-tab.js.map +1 -0
- package/dist/client/application-state.d.ts +22 -0
- package/dist/client/application-state.d.ts.map +1 -0
- package/dist/client/application-state.js +88 -0
- package/dist/client/application-state.js.map +1 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +8 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/messages.d.ts +5 -0
- package/dist/client/messages.d.ts.map +1 -0
- package/dist/client/messages.js +1059 -0
- package/dist/client/messages.js.map +1 -0
- package/dist/connectors/context.d.ts +9 -0
- package/dist/connectors/context.d.ts.map +1 -0
- package/dist/connectors/context.js +59 -0
- package/dist/connectors/context.js.map +1 -0
- package/dist/connectors/document-parser.d.ts +2 -0
- package/dist/connectors/document-parser.d.ts.map +1 -0
- package/dist/connectors/document-parser.js +2 -0
- package/dist/connectors/document-parser.js.map +1 -0
- package/dist/connectors/figma-native.d.ts +18 -0
- package/dist/connectors/figma-native.d.ts.map +1 -0
- package/dist/connectors/figma-native.js +883 -0
- package/dist/connectors/figma-native.js.map +1 -0
- package/dist/connectors/figma.d.ts +10 -0
- package/dist/connectors/figma.d.ts.map +1 -0
- package/dist/connectors/figma.js +166 -0
- package/dist/connectors/figma.js.map +1 -0
- package/dist/connectors/google-slides-native.d.ts +58 -0
- package/dist/connectors/google-slides-native.d.ts.map +1 -0
- package/dist/connectors/google-slides-native.js +1118 -0
- package/dist/connectors/google-slides-native.js.map +1 -0
- package/dist/connectors/google-slides.d.ts +15 -0
- package/dist/connectors/google-slides.d.ts.map +1 -0
- package/dist/connectors/google-slides.js +896 -0
- package/dist/connectors/google-slides.js.map +1 -0
- package/dist/connectors/index.d.ts +20 -0
- package/dist/connectors/index.d.ts.map +1 -0
- package/dist/connectors/index.js +44 -0
- package/dist/connectors/index.js.map +1 -0
- package/dist/connectors/manual.d.ts +9 -0
- package/dist/connectors/manual.d.ts.map +1 -0
- package/dist/connectors/manual.js +91 -0
- package/dist/connectors/manual.js.map +1 -0
- package/dist/connectors/normalize.d.ts +35 -0
- package/dist/connectors/normalize.d.ts.map +1 -0
- package/dist/connectors/normalize.js +216 -0
- package/dist/connectors/normalize.js.map +1 -0
- package/dist/connectors/notion.d.ts +10 -0
- package/dist/connectors/notion.d.ts.map +1 -0
- package/dist/connectors/notion.js +393 -0
- package/dist/connectors/notion.js.map +1 -0
- package/dist/connectors/private-artifacts.d.ts +39 -0
- package/dist/connectors/private-artifacts.d.ts.map +1 -0
- package/dist/connectors/private-artifacts.js +175 -0
- package/dist/connectors/private-artifacts.js.map +1 -0
- package/dist/connectors/provider-response.d.ts +20 -0
- package/dist/connectors/provider-response.d.ts.map +1 -0
- package/dist/connectors/provider-response.js +98 -0
- package/dist/connectors/provider-response.js.map +1 -0
- package/dist/connectors/recommendations.d.ts +25 -0
- package/dist/connectors/recommendations.d.ts.map +1 -0
- package/dist/connectors/recommendations.js +172 -0
- package/dist/connectors/recommendations.js.map +1 -0
- package/dist/connectors/registry.d.ts +10 -0
- package/dist/connectors/registry.d.ts.map +1 -0
- package/dist/connectors/registry.js +34 -0
- package/dist/connectors/registry.js.map +1 -0
- package/dist/connectors/rendered-page.d.ts +101 -0
- package/dist/connectors/rendered-page.d.ts.map +1 -0
- package/dist/connectors/rendered-page.js +504 -0
- package/dist/connectors/rendered-page.js.map +1 -0
- package/dist/connectors/smart-defaults.d.ts +9 -0
- package/dist/connectors/smart-defaults.d.ts.map +1 -0
- package/dist/connectors/smart-defaults.js +72 -0
- package/dist/connectors/smart-defaults.js.map +1 -0
- package/dist/connectors/types.d.ts +79 -0
- package/dist/connectors/types.d.ts.map +1 -0
- package/dist/connectors/types.js +2 -0
- package/dist/connectors/types.js.map +1 -0
- package/dist/connectors/upload.d.ts +9 -0
- package/dist/connectors/upload.d.ts.map +1 -0
- package/dist/connectors/upload.js +440 -0
- package/dist/connectors/upload.js.map +1 -0
- package/dist/connectors/website.d.ts +20 -0
- package/dist/connectors/website.d.ts.map +1 -0
- package/dist/connectors/website.js +616 -0
- package/dist/connectors/website.js.map +1 -0
- package/dist/embeddings/index.d.ts +3 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +3 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/embeddings/providers.d.ts +7 -0
- package/dist/embeddings/providers.d.ts.map +1 -0
- package/dist/embeddings/providers.js +176 -0
- package/dist/embeddings/providers.js.map +1 -0
- package/dist/embeddings/types.d.ts +19 -0
- package/dist/embeddings/types.d.ts.map +1 -0
- package/dist/embeddings/types.js +2 -0
- package/dist/embeddings/types.js.map +1 -0
- package/dist/eval/acceptance-fixtures.d.ts +3 -0
- package/dist/eval/acceptance-fixtures.d.ts.map +1 -0
- package/dist/eval/acceptance-fixtures.js +84 -0
- package/dist/eval/acceptance-fixtures.js.map +1 -0
- package/dist/eval/acceptance.d.ts +114 -0
- package/dist/eval/acceptance.d.ts.map +1 -0
- package/dist/eval/acceptance.js +260 -0
- package/dist/eval/acceptance.js.map +1 -0
- package/dist/eval/fixtures.d.ts +16 -0
- package/dist/eval/fixtures.d.ts.map +1 -0
- package/dist/eval/fixtures.js +119 -0
- package/dist/eval/fixtures.js.map +1 -0
- package/dist/eval/index.d.ts +63 -0
- package/dist/eval/index.d.ts.map +1 -0
- package/dist/eval/index.js +174 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/jobs/background-worker.d.ts +31 -0
- package/dist/jobs/background-worker.d.ts.map +1 -0
- package/dist/jobs/background-worker.js +315 -0
- package/dist/jobs/background-worker.js.map +1 -0
- package/dist/jobs/import-runner.d.ts +3 -0
- package/dist/jobs/import-runner.d.ts.map +1 -0
- package/dist/jobs/import-runner.js +613 -0
- package/dist/jobs/import-runner.js.map +1 -0
- package/dist/jobs/index.d.ts +9 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js +8 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/progress.d.ts +3 -0
- package/dist/jobs/progress.d.ts.map +1 -0
- package/dist/jobs/progress.js +30 -0
- package/dist/jobs/progress.js.map +1 -0
- package/dist/jobs/rebuild.d.ts +13 -0
- package/dist/jobs/rebuild.d.ts.map +1 -0
- package/dist/jobs/rebuild.js +178 -0
- package/dist/jobs/rebuild.js.map +1 -0
- package/dist/jobs/server-worker.d.ts +16 -0
- package/dist/jobs/server-worker.d.ts.map +1 -0
- package/dist/jobs/server-worker.js +252 -0
- package/dist/jobs/server-worker.js.map +1 -0
- package/dist/jobs/store-adapter.d.ts +3 -0
- package/dist/jobs/store-adapter.d.ts.map +1 -0
- package/dist/jobs/store-adapter.js +37 -0
- package/dist/jobs/store-adapter.js.map +1 -0
- package/dist/jobs/types.d.ts +138 -0
- package/dist/jobs/types.d.ts.map +1 -0
- package/dist/jobs/types.js +2 -0
- package/dist/jobs/types.js.map +1 -0
- package/dist/jobs/worker.d.ts +27 -0
- package/dist/jobs/worker.d.ts.map +1 -0
- package/dist/jobs/worker.js +90 -0
- package/dist/jobs/worker.js.map +1 -0
- package/dist/media-url.d.ts +7 -0
- package/dist/media-url.d.ts.map +1 -0
- package/dist/media-url.js +15 -0
- package/dist/media-url.js.map +1 -0
- package/dist/native-artifact-reassembly.d.ts +25 -0
- package/dist/native-artifact-reassembly.d.ts.map +1 -0
- package/dist/native-artifact-reassembly.js +262 -0
- package/dist/native-artifact-reassembly.js.map +1 -0
- package/dist/native-artifact.d.ts +88 -0
- package/dist/native-artifact.d.ts.map +1 -0
- package/dist/native-artifact.js +86 -0
- package/dist/native-artifact.js.map +1 -0
- package/dist/schema/index.d.ts +5519 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +374 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/migrations.d.ts +10 -0
- package/dist/schema/migrations.d.ts.map +1 -0
- package/dist/schema/migrations.js +253 -0
- package/dist/schema/migrations.js.map +1 -0
- package/dist/search/fusion.d.ts +15 -0
- package/dist/search/fusion.d.ts.map +1 -0
- package/dist/search/fusion.js +25 -0
- package/dist/search/fusion.js.map +1 -0
- package/dist/search/mode.d.ts +4 -0
- package/dist/search/mode.d.ts.map +1 -0
- package/dist/search/mode.js +13 -0
- package/dist/search/mode.js.map +1 -0
- package/dist/search/postgres-fts.d.ts +22 -0
- package/dist/search/postgres-fts.d.ts.map +1 -0
- package/dist/search/postgres-fts.js +83 -0
- package/dist/search/postgres-fts.js.map +1 -0
- package/dist/server/brand-context.d.ts +15 -0
- package/dist/server/brand-context.d.ts.map +1 -0
- package/dist/server/brand-context.js +149 -0
- package/dist/server/brand-context.js.map +1 -0
- package/dist/server/context.d.ts +77 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/context.js +63 -0
- package/dist/server/context.js.map +1 -0
- package/dist/server/enrichment.d.ts +23 -0
- package/dist/server/enrichment.d.ts.map +1 -0
- package/dist/server/enrichment.js +136 -0
- package/dist/server/enrichment.js.map +1 -0
- package/dist/server/generation-artifact-access.d.ts +21 -0
- package/dist/server/generation-artifact-access.d.ts.map +1 -0
- package/dist/server/generation-artifact-access.js +111 -0
- package/dist/server/generation-artifact-access.js.map +1 -0
- package/dist/server/generation-context.d.ts +204 -0
- package/dist/server/generation-context.d.ts.map +1 -0
- package/dist/server/generation-context.js +310 -0
- package/dist/server/generation-context.js.map +1 -0
- package/dist/server/index.d.ts +22 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +96 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/isolated-a2a.d.ts +172 -0
- package/dist/server/isolated-a2a.d.ts.map +1 -0
- package/dist/server/isolated-a2a.js +310 -0
- package/dist/server/isolated-a2a.js.map +1 -0
- package/dist/server/media.d.ts +15 -0
- package/dist/server/media.d.ts.map +1 -0
- package/dist/server/media.js +93 -0
- package/dist/server/media.js.map +1 -0
- package/dist/server/prompt-provider.d.ts +5 -0
- package/dist/server/prompt-provider.d.ts.map +1 -0
- package/dist/server/prompt-provider.js +59 -0
- package/dist/server/prompt-provider.js.map +1 -0
- package/dist/server/public-serialization.d.ts +160 -0
- package/dist/server/public-serialization.d.ts.map +1 -0
- package/dist/server/public-serialization.js +108 -0
- package/dist/server/public-serialization.js.map +1 -0
- package/dist/server/resource-paths.d.ts +3 -0
- package/dist/server/resource-paths.d.ts.map +1 -0
- package/dist/server/resource-paths.js +5 -0
- package/dist/server/resource-paths.js.map +1 -0
- package/dist/server/retrieval.d.ts +78 -0
- package/dist/server/retrieval.d.ts.map +1 -0
- package/dist/server/retrieval.js +443 -0
- package/dist/server/retrieval.js.map +1 -0
- package/dist/server/untrusted-reference.d.ts +8 -0
- package/dist/server/untrusted-reference.d.ts.map +1 -0
- package/dist/server/untrusted-reference.js +19 -0
- package/dist/server/untrusted-reference.js.map +1 -0
- package/dist/store/brand.d.ts +47 -0
- package/dist/store/brand.d.ts.map +1 -0
- package/dist/store/brand.js +360 -0
- package/dist/store/brand.js.map +1 -0
- package/dist/store/content.d.ts +120 -0
- package/dist/store/content.d.ts.map +1 -0
- package/dist/store/content.js +1437 -0
- package/dist/store/content.js.map +1 -0
- package/dist/store/generation.d.ts +28 -0
- package/dist/store/generation.d.ts.map +1 -0
- package/dist/store/generation.js +140 -0
- package/dist/store/generation.js.map +1 -0
- package/dist/store/helpers.d.ts +12 -0
- package/dist/store/helpers.d.ts.map +1 -0
- package/dist/store/helpers.js +41 -0
- package/dist/store/helpers.js.map +1 -0
- package/dist/store/index.d.ts +10 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +10 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/inference.d.ts +57 -0
- package/dist/store/inference.d.ts.map +1 -0
- package/dist/store/inference.js +279 -0
- package/dist/store/inference.js.map +1 -0
- package/dist/store/jobs.d.ts +80 -0
- package/dist/store/jobs.d.ts.map +1 -0
- package/dist/store/jobs.js +428 -0
- package/dist/store/jobs.js.map +1 -0
- package/dist/store/packs.d.ts +33 -0
- package/dist/store/packs.d.ts.map +1 -0
- package/dist/store/packs.js +321 -0
- package/dist/store/packs.js.map +1 -0
- package/dist/store/purge.d.ts +16 -0
- package/dist/store/purge.d.ts.map +1 -0
- package/dist/store/purge.js +256 -0
- package/dist/store/purge.js.map +1 -0
- package/dist/store/sources.d.ts +76 -0
- package/dist/store/sources.d.ts.map +1 -0
- package/dist/store/sources.js +538 -0
- package/dist/store/sources.js.map +1 -0
- package/dist/store/suggestions.d.ts +28 -0
- package/dist/store/suggestions.d.ts.map +1 -0
- package/dist/store/suggestions.js +250 -0
- package/dist/store/suggestions.js.map +1 -0
- package/dist/types.d.ts +493 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/vector/index.d.ts +2 -0
- package/dist/vector/index.d.ts.map +1 -0
- package/dist/vector/index.js +2 -0
- package/dist/vector/index.js.map +1 -0
- package/dist/vector/pgvector.d.ts +28 -0
- package/dist/vector/pgvector.d.ts.map +1 -0
- package/dist/vector/pgvector.js +117 -0
- package/dist/vector/pgvector.js.map +1 -0
- package/docs/evaluation.md +92 -0
- package/docs/llms-full.txt +168 -0
- package/docs/llms.txt +76 -0
- package/docs/skills/creative-context/SKILL.md +74 -0
- package/package.json +91 -0
- package/src/actions/agent-input-schemas.spec.ts +46 -0
- package/src/actions/confirm-canonical-logo.ts +20 -0
- package/src/actions/continue-context-import.ts +12 -0
- package/src/actions/creative-context-a2a.spec.ts +64 -0
- package/src/actions/creative-context-a2a.ts +88 -0
- package/src/actions/get-brand-profile.ts +16 -0
- package/src/actions/get-context-import-status.ts +13 -0
- package/src/actions/get-context-item.ts +1 -0
- package/src/actions/get-context-pack.ts +14 -0
- package/src/actions/get-creative-context.spec.ts +315 -0
- package/src/actions/get-creative-context.ts +148 -0
- package/src/actions/index.ts +65 -0
- package/src/actions/infer-brand-dna.ts +15 -0
- package/src/actions/list-canonical-logo-candidates.ts +121 -0
- package/src/actions/list-context-connections.spec.ts +23 -0
- package/src/actions/list-context-connections.ts +51 -0
- package/src/actions/list-context-packs.ts +17 -0
- package/src/actions/list-context-sources.ts +21 -0
- package/src/actions/list-context-suggestions.ts +30 -0
- package/src/actions/manage-brand-profile.ts +58 -0
- package/src/actions/manage-context-pack.ts +75 -0
- package/src/actions/manage-context-source.ts +154 -0
- package/src/actions/manage-layout-template.ts +51 -0
- package/src/actions/preview-context-import.spec.ts +64 -0
- package/src/actions/preview-context-import.ts +61 -0
- package/src/actions/process-context-purge.ts +25 -0
- package/src/actions/propose-brand-dna.ts +22 -0
- package/src/actions/propose-canonical-logo.ts +19 -0
- package/src/actions/publish-brand-dna.ts +25 -0
- package/src/actions/recommend-context-roots.ts +24 -0
- package/src/actions/record-context-feedback.ts +16 -0
- package/src/actions/review-context-items.ts +69 -0
- package/src/actions/run-embedding-bakeoff.ts +90 -0
- package/src/actions/search-creative-context.ts +47 -0
- package/src/actions/set-brand-dna.ts +22 -0
- package/src/actions/start-context-enrichment.ts +50 -0
- package/src/actions/start-context-import.ts +37 -0
- package/src/client/CreativeContextChip.tsx +162 -0
- package/src/client/CreativeContextPanel.tsx +2442 -0
- package/src/client/CreativeContextSettingsLink.tsx +30 -0
- package/src/client/actions.ts +438 -0
- package/src/client/agent-tab.tsx +58 -0
- package/src/client/application-state.spec.ts +41 -0
- package/src/client/application-state.ts +130 -0
- package/src/client/index.ts +62 -0
- package/src/client/messages.ts +1240 -0
- package/src/client/source-config.spec.ts +152 -0
- package/src/connectors/connectors.spec.ts +778 -0
- package/src/connectors/context.ts +83 -0
- package/src/connectors/document-parser.ts +5 -0
- package/src/connectors/figma-native.ts +1192 -0
- package/src/connectors/figma-native.visual.spec.ts +221 -0
- package/src/connectors/figma.spec.ts +812 -0
- package/src/connectors/figma.ts +257 -0
- package/src/connectors/fixtures/google-slides-native.json +353 -0
- package/src/connectors/google-slides-native.spec.ts +804 -0
- package/src/connectors/google-slides-native.ts +1656 -0
- package/src/connectors/google-slides-native.visual.spec.ts +119 -0
- package/src/connectors/google-slides.ts +1172 -0
- package/src/connectors/index.ts +103 -0
- package/src/connectors/manual.ts +132 -0
- package/src/connectors/normalize.ts +277 -0
- package/src/connectors/notion.ts +529 -0
- package/src/connectors/private-artifacts.spec.ts +95 -0
- package/src/connectors/private-artifacts.ts +248 -0
- package/src/connectors/provider-response.ts +144 -0
- package/src/connectors/recommendations.ts +237 -0
- package/src/connectors/registry.ts +48 -0
- package/src/connectors/rendered-page.ts +705 -0
- package/src/connectors/smart-defaults.spec.ts +135 -0
- package/src/connectors/smart-defaults.ts +87 -0
- package/src/connectors/types.ts +115 -0
- package/src/connectors/upload.spec.ts +175 -0
- package/src/connectors/upload.ts +548 -0
- package/src/connectors/website.spec.ts +509 -0
- package/src/connectors/website.ts +777 -0
- package/src/embeddings/index.ts +2 -0
- package/src/embeddings/providers.spec.ts +73 -0
- package/src/embeddings/providers.ts +228 -0
- package/src/embeddings/types.ts +24 -0
- package/src/eval/acceptance-fixtures.ts +97 -0
- package/src/eval/acceptance.spec.ts +92 -0
- package/src/eval/acceptance.ts +371 -0
- package/src/eval/connectors-golden.spec.ts +421 -0
- package/src/eval/eval.spec.ts +166 -0
- package/src/eval/fixtures/README.md +17 -0
- package/src/eval/fixtures/figma-brand-system-v1.json +140 -0
- package/src/eval/fixtures/figma-brand-system-v2.json +127 -0
- package/src/eval/fixtures/launch-hero.png +0 -0
- package/src/eval/fixtures/launch-system-v1.pptx +0 -0
- package/src/eval/fixtures/launch-system-v2.pptx +0 -0
- package/src/eval/fixtures/notion-brand-root.json +218 -0
- package/src/eval/fixtures/pricing-hero.png +0 -0
- package/src/eval/fixtures/rendered-brand-page.html +76 -0
- package/src/eval/fixtures.spec.ts +43 -0
- package/src/eval/fixtures.ts +136 -0
- package/src/eval/index.ts +291 -0
- package/src/eval/library-flow.acceptance.spec.tsx +141 -0
- package/src/index.ts +4 -0
- package/src/jobs/background-worker.ts +423 -0
- package/src/jobs/import-runner.spec.ts +582 -0
- package/src/jobs/import-runner.ts +792 -0
- package/src/jobs/index.ts +40 -0
- package/src/jobs/progress.ts +37 -0
- package/src/jobs/rebuild.ts +245 -0
- package/src/jobs/server-worker.spec.ts +159 -0
- package/src/jobs/server-worker.ts +344 -0
- package/src/jobs/store-adapter.ts +52 -0
- package/src/jobs/types.ts +147 -0
- package/src/jobs/worker.ts +152 -0
- package/src/manifest.spec.ts +26 -0
- package/src/media-url.ts +17 -0
- package/src/native-artifact-reassembly.spec.ts +386 -0
- package/src/native-artifact-reassembly.ts +406 -0
- package/src/native-artifact.ts +102 -0
- package/src/schema/index.ts +411 -0
- package/src/schema/migrations.spec.ts +41 -0
- package/src/schema/migrations.ts +258 -0
- package/src/search/fusion.spec.ts +21 -0
- package/src/search/fusion.ts +39 -0
- package/src/search/mode.spec.ts +28 -0
- package/src/search/mode.ts +21 -0
- package/src/search/postgres-fts.spec.ts +71 -0
- package/src/search/postgres-fts.ts +112 -0
- package/src/server/brand-context.spec.ts +43 -0
- package/src/server/brand-context.ts +160 -0
- package/src/server/context.ts +162 -0
- package/src/server/enrichment.ts +163 -0
- package/src/server/generation-artifact-access.ts +216 -0
- package/src/server/generation-context-a2a.spec.ts +131 -0
- package/src/server/generation-context-off.spec.ts +213 -0
- package/src/server/generation-context.spec.ts +124 -0
- package/src/server/generation-context.ts +493 -0
- package/src/server/index.ts +135 -0
- package/src/server/isolated-a2a.spec.ts +164 -0
- package/src/server/isolated-a2a.ts +413 -0
- package/src/server/media.spec.ts +92 -0
- package/src/server/media.ts +117 -0
- package/src/server/prompt-provider.spec.ts +78 -0
- package/src/server/prompt-provider.ts +73 -0
- package/src/server/public-serialization.spec.ts +149 -0
- package/src/server/public-serialization.ts +130 -0
- package/src/server/resource-paths.spec.ts +9 -0
- package/src/server/resource-paths.ts +5 -0
- package/src/server/retrieval-vector.spec.ts +180 -0
- package/src/server/retrieval.ts +587 -0
- package/src/server/untrusted-reference.spec.ts +22 -0
- package/src/server/untrusted-reference.ts +24 -0
- package/src/store/access.integration.spec.ts +1922 -0
- package/src/store/brand.ts +477 -0
- package/src/store/content.ts +1900 -0
- package/src/store/generation.ts +226 -0
- package/src/store/helpers.ts +53 -0
- package/src/store/index.ts +9 -0
- package/src/store/inference.spec.ts +84 -0
- package/src/store/inference.ts +339 -0
- package/src/store/invariants.spec.ts +119 -0
- package/src/store/jobs.ts +672 -0
- package/src/store/packs.ts +466 -0
- package/src/store/purge.ts +321 -0
- package/src/store/sources.spec.ts +102 -0
- package/src/store/sources.ts +708 -0
- package/src/store/suggestions.ts +333 -0
- package/src/types.ts +571 -0
- package/src/vector/index.ts +1 -0
- package/src/vector/pgvector.spec.ts +98 -0
- package/src/vector/pgvector.ts +164 -0
|
@@ -0,0 +1,705 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
isBlockedExtensionUrlWithDns,
|
|
5
|
+
ssrfSafeFetch,
|
|
6
|
+
} from "@agent-native/core/extensions/url-safety";
|
|
7
|
+
import {
|
|
8
|
+
extractStaticWebsiteContext,
|
|
9
|
+
rankColorSamples,
|
|
10
|
+
readBoundedResponseBytes,
|
|
11
|
+
type WebsiteExtraction,
|
|
12
|
+
} from "@agent-native/core/ingestion";
|
|
13
|
+
|
|
14
|
+
import { normalizeWhitespace } from "./normalize.js";
|
|
15
|
+
|
|
16
|
+
export type RenderedPageMethod =
|
|
17
|
+
| "builder-browser"
|
|
18
|
+
| "local-playwright"
|
|
19
|
+
| "attached-chrome"
|
|
20
|
+
| "static-html";
|
|
21
|
+
|
|
22
|
+
const MAX_RENDERED_TEXT_CHARS = 2_000_000;
|
|
23
|
+
const MAX_SCREENSHOT_BYTES = 10 * 1024 * 1024;
|
|
24
|
+
const MAX_STATIC_HTML_BYTES = 5 * 1024 * 1024;
|
|
25
|
+
const MAX_EXTRACTED_ASSETS = 500;
|
|
26
|
+
const MAX_INTERNAL_LINKS = 500;
|
|
27
|
+
const MAX_COLORS = 256;
|
|
28
|
+
const MAX_TYPOGRAPHY = 100;
|
|
29
|
+
const MAX_SPACING = 100;
|
|
30
|
+
const MAX_RADII = 64;
|
|
31
|
+
const MAX_CSS_VARIABLES = 128;
|
|
32
|
+
|
|
33
|
+
export interface RenderedPageRequest {
|
|
34
|
+
url: string;
|
|
35
|
+
timeoutMs?: number;
|
|
36
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
37
|
+
preferHosted?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface RenderedPageResult {
|
|
41
|
+
url: string;
|
|
42
|
+
finalUrl: string;
|
|
43
|
+
title: string;
|
|
44
|
+
text: string;
|
|
45
|
+
method: RenderedPageMethod;
|
|
46
|
+
rendered: boolean;
|
|
47
|
+
warnings: string[];
|
|
48
|
+
extraction: WebsiteExtraction;
|
|
49
|
+
screenshots: Array<{
|
|
50
|
+
viewport: "desktop" | "mobile";
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
data: Uint8Array;
|
|
54
|
+
}>;
|
|
55
|
+
confidence: number;
|
|
56
|
+
classification:
|
|
57
|
+
| "homepage"
|
|
58
|
+
| "marketing"
|
|
59
|
+
| "documentation"
|
|
60
|
+
| "content"
|
|
61
|
+
| "unknown";
|
|
62
|
+
diagnostics: string[];
|
|
63
|
+
metadata: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface RenderedPageProvider {
|
|
67
|
+
render(request: RenderedPageRequest): Promise<RenderedPageResult>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface PlaywrightRequestLike {
|
|
71
|
+
url(): string;
|
|
72
|
+
isNavigationRequest(): boolean;
|
|
73
|
+
resourceType(): string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface PlaywrightRouteLike {
|
|
77
|
+
request(): PlaywrightRequestLike;
|
|
78
|
+
continue(): Promise<void>;
|
|
79
|
+
abort(errorCode?: string): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface PlaywrightPageLike {
|
|
83
|
+
route(
|
|
84
|
+
pattern: string,
|
|
85
|
+
handler: (route: PlaywrightRouteLike) => Promise<void>,
|
|
86
|
+
): Promise<void>;
|
|
87
|
+
goto(
|
|
88
|
+
url: string,
|
|
89
|
+
options: { timeout: number; waitUntil: string },
|
|
90
|
+
): Promise<unknown>;
|
|
91
|
+
title(): Promise<string>;
|
|
92
|
+
url(): string;
|
|
93
|
+
locator(selector: string): { innerText(): Promise<string> };
|
|
94
|
+
setViewportSize(size: { width: number; height: number }): Promise<void>;
|
|
95
|
+
screenshot(options: { type: "png"; fullPage: boolean }): Promise<Uint8Array>;
|
|
96
|
+
evaluate<T>(callback: () => T): Promise<T>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interface PlaywrightContextLike {
|
|
100
|
+
pages(): PlaywrightPageLike[];
|
|
101
|
+
newPage(): Promise<PlaywrightPageLike>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface PlaywrightBrowserLike {
|
|
105
|
+
contexts(): PlaywrightContextLike[];
|
|
106
|
+
newContext(): Promise<PlaywrightContextLike>;
|
|
107
|
+
close(): Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface PlaywrightLike {
|
|
111
|
+
chromium: {
|
|
112
|
+
connectOverCDP(endpoint: string): Promise<PlaywrightBrowserLike>;
|
|
113
|
+
launch(options: { headless: boolean }): Promise<PlaywrightBrowserLike>;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface LayeredRenderedPageProviderOptions {
|
|
118
|
+
requestBuilderBrowserConnection?: (input: {
|
|
119
|
+
sessionId: string;
|
|
120
|
+
}) => Promise<Record<string, unknown>>;
|
|
121
|
+
loadPlaywright?: () => Promise<PlaywrightLike | null>;
|
|
122
|
+
requestAttachedBrowserConnection?: (input: {
|
|
123
|
+
sessionId: string;
|
|
124
|
+
url: string;
|
|
125
|
+
}) => Promise<{ wsUrl: string }>;
|
|
126
|
+
staticFetch?: typeof ssrfSafeFetch;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export class LayeredRenderedPageProvider implements RenderedPageProvider {
|
|
130
|
+
readonly #requestBuilderBrowserConnection: (input: {
|
|
131
|
+
sessionId: string;
|
|
132
|
+
}) => Promise<Record<string, unknown>>;
|
|
133
|
+
readonly #loadPlaywright: () => Promise<PlaywrightLike | null>;
|
|
134
|
+
readonly #requestAttachedBrowserConnection?: NonNullable<
|
|
135
|
+
LayeredRenderedPageProviderOptions["requestAttachedBrowserConnection"]
|
|
136
|
+
>;
|
|
137
|
+
readonly #staticFetch: typeof ssrfSafeFetch;
|
|
138
|
+
|
|
139
|
+
constructor(options: LayeredRenderedPageProviderOptions = {}) {
|
|
140
|
+
this.#requestBuilderBrowserConnection =
|
|
141
|
+
options.requestBuilderBrowserConnection ?? defaultBuilderBrowserRequest;
|
|
142
|
+
this.#loadPlaywright = options.loadPlaywright ?? loadOptionalPlaywright;
|
|
143
|
+
this.#requestAttachedBrowserConnection =
|
|
144
|
+
options.requestAttachedBrowserConnection;
|
|
145
|
+
this.#staticFetch = options.staticFetch ?? ssrfSafeFetch;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async render(request: RenderedPageRequest): Promise<RenderedPageResult> {
|
|
149
|
+
await assertPublicBrowserUrl(request.url);
|
|
150
|
+
const warnings: string[] = [];
|
|
151
|
+
const playwright = await this.#loadPlaywright().catch((error) => {
|
|
152
|
+
warnings.push(`Playwright unavailable: ${errorMessage(error)}`);
|
|
153
|
+
return null;
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
if (request.preferHosted !== false && playwright) {
|
|
157
|
+
try {
|
|
158
|
+
const connection = await this.#requestBuilderBrowserConnection({
|
|
159
|
+
sessionId: `creative-context-${randomUUID()}`,
|
|
160
|
+
});
|
|
161
|
+
const wsUrl = stringValue(connection.wsUrl);
|
|
162
|
+
if (!wsUrl) throw new Error("Builder Browser did not return wsUrl.");
|
|
163
|
+
return await renderWithPlaywright(
|
|
164
|
+
playwright,
|
|
165
|
+
request,
|
|
166
|
+
warnings,
|
|
167
|
+
"builder-browser",
|
|
168
|
+
wsUrl,
|
|
169
|
+
);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
warnings.push(`Builder Browser unavailable: ${errorMessage(error)}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (playwright) {
|
|
176
|
+
try {
|
|
177
|
+
return await renderWithPlaywright(
|
|
178
|
+
playwright,
|
|
179
|
+
request,
|
|
180
|
+
warnings,
|
|
181
|
+
"local-playwright",
|
|
182
|
+
);
|
|
183
|
+
} catch (error) {
|
|
184
|
+
warnings.push(`Local Playwright unavailable: ${errorMessage(error)}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (playwright && this.#requestAttachedBrowserConnection) {
|
|
189
|
+
try {
|
|
190
|
+
const connection = await this.#requestAttachedBrowserConnection({
|
|
191
|
+
sessionId: `creative-context-attached-${randomUUID()}`,
|
|
192
|
+
url: request.url,
|
|
193
|
+
});
|
|
194
|
+
if (!connection.wsUrl?.trim()) {
|
|
195
|
+
throw new Error("Approved attached browser did not return wsUrl.");
|
|
196
|
+
}
|
|
197
|
+
return await renderWithPlaywright(
|
|
198
|
+
playwright,
|
|
199
|
+
request,
|
|
200
|
+
warnings,
|
|
201
|
+
"attached-chrome",
|
|
202
|
+
connection.wsUrl,
|
|
203
|
+
);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
warnings.push(`Attached Chrome unavailable: ${errorMessage(error)}`);
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
warnings.push(
|
|
209
|
+
"Attached Chrome unavailable: no approved browser connection adapter is configured.",
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return renderStatic(request, warnings, this.#staticFetch);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async function renderWithPlaywright(
|
|
218
|
+
playwright: PlaywrightLike,
|
|
219
|
+
request: RenderedPageRequest,
|
|
220
|
+
warnings: string[],
|
|
221
|
+
method: "builder-browser" | "local-playwright" | "attached-chrome",
|
|
222
|
+
wsUrl?: string,
|
|
223
|
+
): Promise<RenderedPageResult> {
|
|
224
|
+
const browser = wsUrl
|
|
225
|
+
? await playwright.chromium.connectOverCDP(wsUrl)
|
|
226
|
+
: await playwright.chromium.launch({ headless: true });
|
|
227
|
+
try {
|
|
228
|
+
const context = browser.contexts()[0] ?? (await browser.newContext());
|
|
229
|
+
const page = context.pages()[0] ?? (await context.newPage());
|
|
230
|
+
await installNavigationGuard(page);
|
|
231
|
+
await page.setViewportSize({ width: 1440, height: 900 });
|
|
232
|
+
await page.goto(request.url, {
|
|
233
|
+
timeout: boundedTimeout(request.timeoutMs),
|
|
234
|
+
waitUntil: request.waitUntil ?? "domcontentloaded",
|
|
235
|
+
});
|
|
236
|
+
const finalUrl = page.url();
|
|
237
|
+
await assertPublicBrowserUrl(finalUrl);
|
|
238
|
+
const [title, text, desktopScreenshot, extraction] = await Promise.all([
|
|
239
|
+
page.title().catch(() => ""),
|
|
240
|
+
page
|
|
241
|
+
.locator("body")
|
|
242
|
+
.innerText()
|
|
243
|
+
.catch(() => ""),
|
|
244
|
+
page
|
|
245
|
+
.screenshot({ type: "png", fullPage: false })
|
|
246
|
+
.then(boundedScreenshot)
|
|
247
|
+
.catch(() => undefined),
|
|
248
|
+
page
|
|
249
|
+
.evaluate(captureRenderedWebsiteContext)
|
|
250
|
+
.catch(() => emptyExtraction()),
|
|
251
|
+
]);
|
|
252
|
+
await page.setViewportSize({ width: 390, height: 844 });
|
|
253
|
+
const mobileScreenshot = await page
|
|
254
|
+
.screenshot({ type: "png", fullPage: false })
|
|
255
|
+
.then(boundedScreenshot)
|
|
256
|
+
.catch(() => undefined);
|
|
257
|
+
const unboundedText = normalizeWhitespace(text);
|
|
258
|
+
const textTruncated = unboundedText.length > MAX_RENDERED_TEXT_CHARS;
|
|
259
|
+
const normalizedText = unboundedText.slice(0, MAX_RENDERED_TEXT_CHARS);
|
|
260
|
+
const resolvedExtraction = boundWebsiteExtraction({
|
|
261
|
+
...extraction,
|
|
262
|
+
title: normalizeWhitespace(title) || extraction.title,
|
|
263
|
+
text: normalizedText || extraction.text,
|
|
264
|
+
designTokens: {
|
|
265
|
+
...extraction.designTokens,
|
|
266
|
+
colors: rankColorSamples(extraction.designTokens.colors),
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
const diagnostics = [
|
|
270
|
+
...warnings,
|
|
271
|
+
`Captured ${resolvedExtraction.assets.length} assets and ${resolvedExtraction.internalLinks.length} same-origin links.`,
|
|
272
|
+
...(desktopScreenshot && mobileScreenshot
|
|
273
|
+
? []
|
|
274
|
+
: ["One or more viewport screenshots could not be captured."]),
|
|
275
|
+
...(textTruncated
|
|
276
|
+
? [`Body text was truncated at ${MAX_RENDERED_TEXT_CHARS} characters.`]
|
|
277
|
+
: []),
|
|
278
|
+
];
|
|
279
|
+
return {
|
|
280
|
+
url: request.url,
|
|
281
|
+
finalUrl,
|
|
282
|
+
title: normalizeWhitespace(title) || new URL(finalUrl).hostname,
|
|
283
|
+
text: resolvedExtraction.text,
|
|
284
|
+
method,
|
|
285
|
+
rendered: true,
|
|
286
|
+
warnings,
|
|
287
|
+
extraction: resolvedExtraction,
|
|
288
|
+
screenshots: [
|
|
289
|
+
...(desktopScreenshot
|
|
290
|
+
? [
|
|
291
|
+
{
|
|
292
|
+
viewport: "desktop" as const,
|
|
293
|
+
width: 1440,
|
|
294
|
+
height: 900,
|
|
295
|
+
data: desktopScreenshot,
|
|
296
|
+
},
|
|
297
|
+
]
|
|
298
|
+
: []),
|
|
299
|
+
...(mobileScreenshot
|
|
300
|
+
? [
|
|
301
|
+
{
|
|
302
|
+
viewport: "mobile" as const,
|
|
303
|
+
width: 390,
|
|
304
|
+
height: 844,
|
|
305
|
+
data: mobileScreenshot,
|
|
306
|
+
},
|
|
307
|
+
]
|
|
308
|
+
: []),
|
|
309
|
+
],
|
|
310
|
+
confidence: 0.92,
|
|
311
|
+
classification: classifyWebsite(resolvedExtraction, finalUrl),
|
|
312
|
+
diagnostics,
|
|
313
|
+
metadata: {
|
|
314
|
+
browser: method,
|
|
315
|
+
assetCount: resolvedExtraction.assets.length,
|
|
316
|
+
internalLinkCount: resolvedExtraction.internalLinks.length,
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
} finally {
|
|
320
|
+
await browser.close().catch(() => undefined);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
async function installNavigationGuard(page: PlaywrightPageLike): Promise<void> {
|
|
325
|
+
await page.route("**/*", async (route) => {
|
|
326
|
+
const request = route.request();
|
|
327
|
+
let parsed: URL;
|
|
328
|
+
try {
|
|
329
|
+
parsed = new URL(request.url());
|
|
330
|
+
} catch {
|
|
331
|
+
await route.abort("blockedbyclient");
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (parsed.protocol === "data:" || parsed.protocol === "blob:") {
|
|
335
|
+
await route.continue();
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
339
|
+
await route.abort("blockedbyclient");
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
try {
|
|
343
|
+
await assertPublicBrowserUrl(parsed.href);
|
|
344
|
+
} catch {
|
|
345
|
+
await route.abort("blockedbyclient");
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
await route.continue();
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
async function renderStatic(
|
|
353
|
+
request: RenderedPageRequest,
|
|
354
|
+
warnings: string[],
|
|
355
|
+
fetcher: typeof ssrfSafeFetch,
|
|
356
|
+
): Promise<RenderedPageResult> {
|
|
357
|
+
const response = await fetcher(
|
|
358
|
+
request.url,
|
|
359
|
+
{
|
|
360
|
+
headers: {
|
|
361
|
+
Accept: "text/html,application/xhtml+xml,text/plain;q=0.9,*/*;q=0.1",
|
|
362
|
+
},
|
|
363
|
+
signal: AbortSignal.timeout(boundedTimeout(request.timeoutMs)),
|
|
364
|
+
},
|
|
365
|
+
{ maxRedirects: 5 },
|
|
366
|
+
);
|
|
367
|
+
if (!response.ok) {
|
|
368
|
+
throw new Error(`Static page fetch failed (${response.status}).`);
|
|
369
|
+
}
|
|
370
|
+
const html = new TextDecoder().decode(
|
|
371
|
+
await readBoundedResponseBytes(response, MAX_STATIC_HTML_BYTES),
|
|
372
|
+
);
|
|
373
|
+
const finalUrl = response.url || request.url;
|
|
374
|
+
const extraction = extractStaticWebsiteContext(html, finalUrl);
|
|
375
|
+
const title = extraction.title || new URL(finalUrl).hostname;
|
|
376
|
+
warnings.push(
|
|
377
|
+
"Used the SSRF-safe static HTML fallback; client-rendered content may be missing.",
|
|
378
|
+
);
|
|
379
|
+
return {
|
|
380
|
+
url: request.url,
|
|
381
|
+
finalUrl,
|
|
382
|
+
title,
|
|
383
|
+
text: extraction.text,
|
|
384
|
+
method: "static-html",
|
|
385
|
+
rendered: false,
|
|
386
|
+
warnings,
|
|
387
|
+
extraction: { ...extraction, title },
|
|
388
|
+
screenshots: [],
|
|
389
|
+
confidence: 0.45,
|
|
390
|
+
classification: classifyWebsite(extraction, finalUrl),
|
|
391
|
+
diagnostics: [
|
|
392
|
+
...warnings,
|
|
393
|
+
"Static extraction cannot verify client-rendered layout or viewport behavior.",
|
|
394
|
+
],
|
|
395
|
+
metadata: {
|
|
396
|
+
contentType: response.headers.get("content-type"),
|
|
397
|
+
etag: response.headers.get("etag"),
|
|
398
|
+
lastModified: response.headers.get("last-modified"),
|
|
399
|
+
staticFallback: true,
|
|
400
|
+
assetCount: extraction.assets.length,
|
|
401
|
+
internalLinkCount: extraction.internalLinks.length,
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
async function assertPublicBrowserUrl(value: string): Promise<void> {
|
|
407
|
+
let parsed: URL;
|
|
408
|
+
try {
|
|
409
|
+
parsed = new URL(value);
|
|
410
|
+
} catch {
|
|
411
|
+
throw new Error("Website URL must be an absolute http(s) URL.");
|
|
412
|
+
}
|
|
413
|
+
if (!(["http:", "https:"] as string[]).includes(parsed.protocol)) {
|
|
414
|
+
throw new Error("Website URL must use http or https.");
|
|
415
|
+
}
|
|
416
|
+
if (parsed.username || parsed.password) {
|
|
417
|
+
throw new Error("Website URLs cannot contain credentials.");
|
|
418
|
+
}
|
|
419
|
+
if (await isBlockedExtensionUrlWithDns(parsed.href)) {
|
|
420
|
+
throw new Error(
|
|
421
|
+
"SSRF blocked: website resolved to a private/internal host.",
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
async function defaultBuilderBrowserRequest(input: {
|
|
427
|
+
sessionId: string;
|
|
428
|
+
}): Promise<Record<string, unknown>> {
|
|
429
|
+
const server = (await import("@agent-native/core/server")) as unknown as {
|
|
430
|
+
requestBuilderBrowserConnection?: (value: {
|
|
431
|
+
sessionId: string;
|
|
432
|
+
}) => Promise<Record<string, unknown>>;
|
|
433
|
+
};
|
|
434
|
+
if (!server.requestBuilderBrowserConnection) {
|
|
435
|
+
throw new Error(
|
|
436
|
+
"@agent-native/core/server does not export requestBuilderBrowserConnection.",
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
return server.requestBuilderBrowserConnection(input);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
async function loadOptionalPlaywright(): Promise<PlaywrightLike | null> {
|
|
443
|
+
const specifier = "playwright";
|
|
444
|
+
try {
|
|
445
|
+
return (await import(specifier)) as PlaywrightLike;
|
|
446
|
+
} catch {
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function captureRenderedWebsiteContext(): WebsiteExtraction {
|
|
452
|
+
const MAX_ASSETS = 500;
|
|
453
|
+
const MAX_LINKS = 500;
|
|
454
|
+
const MAX_COLOR_VALUES = 256;
|
|
455
|
+
const MAX_TYPE_STYLES = 100;
|
|
456
|
+
const MAX_SPACING_VALUES = 100;
|
|
457
|
+
const MAX_RADIUS_VALUES = 64;
|
|
458
|
+
const MAX_VARIABLES = 128;
|
|
459
|
+
const MAX_TEXT = 2_000_000;
|
|
460
|
+
const assets = new Map<string, WebsiteExtraction["assets"][number]>();
|
|
461
|
+
const links = new Set<string>();
|
|
462
|
+
const colors: string[] = [];
|
|
463
|
+
const typography = new Map<
|
|
464
|
+
string,
|
|
465
|
+
WebsiteExtraction["designTokens"]["typography"][number]
|
|
466
|
+
>();
|
|
467
|
+
const spacing = new Set<string>();
|
|
468
|
+
const radii = new Set<string>();
|
|
469
|
+
const cssVariables: Record<string, string> = {};
|
|
470
|
+
const addAsset = (
|
|
471
|
+
raw: string | null | undefined,
|
|
472
|
+
kind: WebsiteExtraction["assets"][number]["kind"],
|
|
473
|
+
role?: "logo" | "open-graph",
|
|
474
|
+
) => {
|
|
475
|
+
if (!raw || assets.size >= MAX_ASSETS) return;
|
|
476
|
+
try {
|
|
477
|
+
const url = new URL(raw, document.baseURI);
|
|
478
|
+
if (url.protocol === "http:" || url.protocol === "https:") {
|
|
479
|
+
url.hash = "";
|
|
480
|
+
assets.set(url.href, {
|
|
481
|
+
url: url.href,
|
|
482
|
+
kind,
|
|
483
|
+
...(role ? { role } : {}),
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
} catch {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
for (const image of document.querySelectorAll("img")) {
|
|
491
|
+
if (assets.size >= MAX_ASSETS) break;
|
|
492
|
+
const identity = `${image.getAttribute("alt") ?? ""} ${image.getAttribute("class") ?? ""} ${image.id}`;
|
|
493
|
+
addAsset(
|
|
494
|
+
image.currentSrc || image.src,
|
|
495
|
+
"image",
|
|
496
|
+
/logo|wordmark|brandmark/i.test(identity) ? "logo" : undefined,
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
for (const video of document.querySelectorAll("video")) {
|
|
500
|
+
if (assets.size >= MAX_ASSETS) break;
|
|
501
|
+
addAsset(video.currentSrc || video.src, "video");
|
|
502
|
+
}
|
|
503
|
+
for (const audio of document.querySelectorAll("audio")) {
|
|
504
|
+
if (assets.size >= MAX_ASSETS) break;
|
|
505
|
+
addAsset(audio.currentSrc || audio.src, "audio");
|
|
506
|
+
}
|
|
507
|
+
for (const script of document.querySelectorAll("script[src]")) {
|
|
508
|
+
if (assets.size >= MAX_ASSETS) break;
|
|
509
|
+
addAsset(script.getAttribute("src"), "script");
|
|
510
|
+
}
|
|
511
|
+
for (const link of document.querySelectorAll("link[href]")) {
|
|
512
|
+
if (assets.size >= MAX_ASSETS) break;
|
|
513
|
+
const rel = link.getAttribute("rel") ?? "";
|
|
514
|
+
const icon = /icon/i.test(rel);
|
|
515
|
+
addAsset(
|
|
516
|
+
link.getAttribute("href"),
|
|
517
|
+
icon ? "image" : /font|preload/i.test(rel) ? "font" : "stylesheet",
|
|
518
|
+
icon ? "logo" : undefined,
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
for (const meta of document.querySelectorAll(
|
|
522
|
+
'meta[property="og:image"],meta[property="og:image:url"],meta[name="twitter:image"]',
|
|
523
|
+
)) {
|
|
524
|
+
if (assets.size >= MAX_ASSETS) break;
|
|
525
|
+
addAsset(meta.getAttribute("content"), "image", "open-graph");
|
|
526
|
+
}
|
|
527
|
+
for (const anchor of document.querySelectorAll("a[href]")) {
|
|
528
|
+
if (links.size >= MAX_LINKS) break;
|
|
529
|
+
try {
|
|
530
|
+
const url = new URL(anchor.getAttribute("href") ?? "", document.baseURI);
|
|
531
|
+
if (url.origin === location.origin) {
|
|
532
|
+
url.hash = "";
|
|
533
|
+
links.add(url.href);
|
|
534
|
+
}
|
|
535
|
+
} catch {
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
const rootStyle = getComputedStyle(document.documentElement);
|
|
540
|
+
let variableCount = 0;
|
|
541
|
+
for (const name of rootStyle) {
|
|
542
|
+
if (name.startsWith("--")) {
|
|
543
|
+
const value = rootStyle.getPropertyValue(name).trim();
|
|
544
|
+
if (value) {
|
|
545
|
+
cssVariables[name] = value;
|
|
546
|
+
variableCount++;
|
|
547
|
+
if (variableCount >= MAX_VARIABLES) break;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
const elements = Array.from(document.querySelectorAll("body *")).slice(
|
|
552
|
+
0,
|
|
553
|
+
500,
|
|
554
|
+
);
|
|
555
|
+
for (const element of elements) {
|
|
556
|
+
const style = getComputedStyle(element);
|
|
557
|
+
if (colors.length < MAX_COLOR_VALUES) {
|
|
558
|
+
colors.push(
|
|
559
|
+
style.color,
|
|
560
|
+
style.backgroundColor,
|
|
561
|
+
style.borderTopColor,
|
|
562
|
+
style.borderRightColor,
|
|
563
|
+
style.borderBottomColor,
|
|
564
|
+
style.borderLeftColor,
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
const type = {
|
|
568
|
+
family: style.fontFamily,
|
|
569
|
+
size: style.fontSize,
|
|
570
|
+
weight: style.fontWeight,
|
|
571
|
+
lineHeight: style.lineHeight,
|
|
572
|
+
letterSpacing: style.letterSpacing,
|
|
573
|
+
};
|
|
574
|
+
if (typography.size < MAX_TYPE_STYLES) {
|
|
575
|
+
typography.set(JSON.stringify(type), type);
|
|
576
|
+
}
|
|
577
|
+
for (const value of [
|
|
578
|
+
style.marginTop,
|
|
579
|
+
style.marginRight,
|
|
580
|
+
style.marginBottom,
|
|
581
|
+
style.marginLeft,
|
|
582
|
+
style.paddingTop,
|
|
583
|
+
style.paddingRight,
|
|
584
|
+
style.paddingBottom,
|
|
585
|
+
style.paddingLeft,
|
|
586
|
+
style.gap,
|
|
587
|
+
style.rowGap,
|
|
588
|
+
style.columnGap,
|
|
589
|
+
]) {
|
|
590
|
+
if (
|
|
591
|
+
spacing.size < MAX_SPACING_VALUES &&
|
|
592
|
+
value &&
|
|
593
|
+
value !== "0px" &&
|
|
594
|
+
value !== "normal"
|
|
595
|
+
) {
|
|
596
|
+
spacing.add(value);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
for (const value of [
|
|
600
|
+
style.borderTopLeftRadius,
|
|
601
|
+
style.borderTopRightRadius,
|
|
602
|
+
style.borderBottomRightRadius,
|
|
603
|
+
style.borderBottomLeftRadius,
|
|
604
|
+
]) {
|
|
605
|
+
if (radii.size < MAX_RADIUS_VALUES && value && value !== "0px") {
|
|
606
|
+
radii.add(value);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return {
|
|
611
|
+
title: document.title,
|
|
612
|
+
text: (document.body?.innerText ?? "").slice(0, MAX_TEXT),
|
|
613
|
+
assets: [...assets.values()],
|
|
614
|
+
internalLinks: [...links],
|
|
615
|
+
designTokens: {
|
|
616
|
+
colors,
|
|
617
|
+
typography: [...typography.values()],
|
|
618
|
+
spacing: [...spacing],
|
|
619
|
+
radii: [...radii],
|
|
620
|
+
cssVariables,
|
|
621
|
+
},
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
export function boundWebsiteExtraction(
|
|
626
|
+
extraction: WebsiteExtraction,
|
|
627
|
+
): WebsiteExtraction {
|
|
628
|
+
return {
|
|
629
|
+
title: normalizeWhitespace(extraction.title).slice(0, 500),
|
|
630
|
+
text: normalizeWhitespace(extraction.text).slice(
|
|
631
|
+
0,
|
|
632
|
+
MAX_RENDERED_TEXT_CHARS,
|
|
633
|
+
),
|
|
634
|
+
assets: extraction.assets.slice(0, MAX_EXTRACTED_ASSETS).map((asset) => ({
|
|
635
|
+
...asset,
|
|
636
|
+
url: asset.url.slice(0, 4_096),
|
|
637
|
+
})),
|
|
638
|
+
internalLinks: extraction.internalLinks
|
|
639
|
+
.slice(0, MAX_INTERNAL_LINKS)
|
|
640
|
+
.map((url) => url.slice(0, 4_096)),
|
|
641
|
+
designTokens: {
|
|
642
|
+
colors: extraction.designTokens.colors.slice(0, MAX_COLORS),
|
|
643
|
+
typography: extraction.designTokens.typography.slice(0, MAX_TYPOGRAPHY),
|
|
644
|
+
spacing: extraction.designTokens.spacing.slice(0, MAX_SPACING),
|
|
645
|
+
radii: extraction.designTokens.radii.slice(0, MAX_RADII),
|
|
646
|
+
cssVariables: Object.fromEntries(
|
|
647
|
+
Object.entries(extraction.designTokens.cssVariables)
|
|
648
|
+
.slice(0, MAX_CSS_VARIABLES)
|
|
649
|
+
.map(([name, value]) => [name.slice(0, 500), value.slice(0, 4_096)]),
|
|
650
|
+
),
|
|
651
|
+
},
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
function emptyExtraction(): WebsiteExtraction {
|
|
656
|
+
return {
|
|
657
|
+
title: "",
|
|
658
|
+
text: "",
|
|
659
|
+
assets: [],
|
|
660
|
+
internalLinks: [],
|
|
661
|
+
designTokens: {
|
|
662
|
+
colors: [],
|
|
663
|
+
typography: [],
|
|
664
|
+
spacing: [],
|
|
665
|
+
radii: [],
|
|
666
|
+
cssVariables: {},
|
|
667
|
+
},
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
function classifyWebsite(
|
|
672
|
+
extraction: WebsiteExtraction,
|
|
673
|
+
finalUrl: string,
|
|
674
|
+
): RenderedPageResult["classification"] {
|
|
675
|
+
const path = new URL(finalUrl).pathname.replace(/\/+$/, "") || "/";
|
|
676
|
+
const sample =
|
|
677
|
+
`${extraction.title} ${extraction.text.slice(0, 2_000)}`.toLowerCase();
|
|
678
|
+
if (path === "/") return "homepage";
|
|
679
|
+
if (/\b(api|docs?|guide|reference|tutorial)\b/.test(sample)) {
|
|
680
|
+
return "documentation";
|
|
681
|
+
}
|
|
682
|
+
if (/\b(blog|article|news|author|published)\b/.test(sample)) return "content";
|
|
683
|
+
if (/\b(pricing|features|customers|solutions|product)\b/.test(sample)) {
|
|
684
|
+
return "marketing";
|
|
685
|
+
}
|
|
686
|
+
return "unknown";
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
function boundedTimeout(value: number | undefined): number {
|
|
690
|
+
return Number.isFinite(value)
|
|
691
|
+
? Math.max(1_000, Math.min(120_000, Math.floor(value!)))
|
|
692
|
+
: 30_000;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function boundedScreenshot(value: Uint8Array): Uint8Array | undefined {
|
|
696
|
+
return value.byteLength <= MAX_SCREENSHOT_BYTES ? value : undefined;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
function stringValue(value: unknown): string | undefined {
|
|
700
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
function errorMessage(error: unknown): string {
|
|
704
|
+
return error instanceof Error ? error.message : String(error);
|
|
705
|
+
}
|