@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,529 @@
|
|
|
1
|
+
import { notionBlocksToMarkdown } from "@agent-native/core/ingestion";
|
|
2
|
+
|
|
3
|
+
import type { ContextMediaInput, NormalizedContextChunk } from "../types.js";
|
|
4
|
+
import { collectProviderText, normalizeContextItem } from "./normalize.js";
|
|
5
|
+
import {
|
|
6
|
+
rehostRemoteMedia,
|
|
7
|
+
sanitizeProvenanceUrl,
|
|
8
|
+
} from "./private-artifacts.js";
|
|
9
|
+
import {
|
|
10
|
+
asRecord,
|
|
11
|
+
connectorConnectionId,
|
|
12
|
+
cursorOffset,
|
|
13
|
+
executeConnectorProviderRequest,
|
|
14
|
+
positiveLimit,
|
|
15
|
+
stringArray,
|
|
16
|
+
stringValue,
|
|
17
|
+
} from "./provider-response.js";
|
|
18
|
+
import type {
|
|
19
|
+
ContextConnectorExecutionContext,
|
|
20
|
+
ContextConnectorFetchRequest,
|
|
21
|
+
ContextConnectorFetchResult,
|
|
22
|
+
ContextConnectorInventoryPage,
|
|
23
|
+
ContextConnectorInventoryRequest,
|
|
24
|
+
ContextImportConnector,
|
|
25
|
+
} from "./types.js";
|
|
26
|
+
|
|
27
|
+
export class NotionContextConnector implements ContextImportConnector {
|
|
28
|
+
readonly kind = "notion" as const;
|
|
29
|
+
readonly label = "Notion";
|
|
30
|
+
readonly supportsIncremental = true;
|
|
31
|
+
|
|
32
|
+
async inventory(
|
|
33
|
+
request: ContextConnectorInventoryRequest,
|
|
34
|
+
context: ContextConnectorExecutionContext,
|
|
35
|
+
): Promise<ContextConnectorInventoryPage> {
|
|
36
|
+
const connectionId = await connectorConnectionId(
|
|
37
|
+
"notion",
|
|
38
|
+
request.config,
|
|
39
|
+
context.resolveConnection,
|
|
40
|
+
);
|
|
41
|
+
const roots = notionBoundaryRoots(request.config);
|
|
42
|
+
const limit = positiveLimit(request.limit, 100, 100);
|
|
43
|
+
const maxPages = positiveLimit(request.config.maxPages, 500, 2_000);
|
|
44
|
+
const maxDepth = positiveLimit(request.config.maxDepth, 20, 50);
|
|
45
|
+
const state = parseNotionInventoryCursor(request.cursor);
|
|
46
|
+
const items: ContextConnectorInventoryPage["items"] = [];
|
|
47
|
+
while (items.length < limit && state.seen.length < maxPages) {
|
|
48
|
+
if (state.queue.length === 0) {
|
|
49
|
+
const root = roots[state.rootIndex];
|
|
50
|
+
if (!root) break;
|
|
51
|
+
state.rootIndex++;
|
|
52
|
+
state.queue.push({
|
|
53
|
+
...root,
|
|
54
|
+
selectedRootId: root.id,
|
|
55
|
+
depth: 0,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const candidate = state.queue.shift()!;
|
|
59
|
+
if (state.seen.includes(candidate.id)) continue;
|
|
60
|
+
const page = asRecord(
|
|
61
|
+
await executeConnectorProviderRequest(context.providerApi, {
|
|
62
|
+
provider: "notion",
|
|
63
|
+
method: "GET",
|
|
64
|
+
path: `/pages/${encodeURIComponent(candidate.id)}`,
|
|
65
|
+
connectionId,
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
68
|
+
if (!page) continue;
|
|
69
|
+
const discovery = await fetchNotionBlocks(
|
|
70
|
+
candidate.id,
|
|
71
|
+
connectionId,
|
|
72
|
+
context,
|
|
73
|
+
positiveLimit(request.config.maxDiscoveryBlocksPerPage, 500, 2_000),
|
|
74
|
+
);
|
|
75
|
+
state.seen.push(candidate.id);
|
|
76
|
+
if (candidate.depth < maxDepth) {
|
|
77
|
+
for (const child of discovery.childPages) {
|
|
78
|
+
if (
|
|
79
|
+
state.seen.includes(child.id) ||
|
|
80
|
+
state.queue.some((queued) => queued.id === child.id) ||
|
|
81
|
+
state.seen.length + state.queue.length >= maxPages
|
|
82
|
+
) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
state.queue.push({
|
|
86
|
+
id: child.id,
|
|
87
|
+
title: child.title,
|
|
88
|
+
boundary: candidate.boundary,
|
|
89
|
+
selectedRootId: candidate.selectedRootId,
|
|
90
|
+
parentId: candidate.id,
|
|
91
|
+
depth: candidate.depth + 1,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
items.push({
|
|
96
|
+
externalId: candidate.id,
|
|
97
|
+
kind: "notion-page",
|
|
98
|
+
title:
|
|
99
|
+
notionPageTitle(page) ??
|
|
100
|
+
candidate.title ??
|
|
101
|
+
(candidate.depth === 0 ? "Notion root page" : "Notion child page"),
|
|
102
|
+
canonicalUrl: stringValue(page.url) ?? candidate.url ?? undefined,
|
|
103
|
+
mimeType: "application/vnd.notion.page",
|
|
104
|
+
sourceModifiedAt: stringValue(page.last_edited_time),
|
|
105
|
+
upstreamAccess: notionPageAccess(page),
|
|
106
|
+
metadata: {
|
|
107
|
+
boundary: candidate.boundary,
|
|
108
|
+
selectedRootPageId: candidate.selectedRootId,
|
|
109
|
+
parentPageId: candidate.parentId ?? null,
|
|
110
|
+
depth: candidate.depth,
|
|
111
|
+
childPageIds: discovery.childPages.map((child) => child.id),
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const hasMore =
|
|
116
|
+
state.seen.length < maxPages &&
|
|
117
|
+
(state.queue.length > 0 || state.rootIndex < roots.length);
|
|
118
|
+
const nextCursor = hasMore ? encodeNotionInventoryCursor(state) : null;
|
|
119
|
+
return {
|
|
120
|
+
items,
|
|
121
|
+
nextCursor,
|
|
122
|
+
complete: !nextCursor,
|
|
123
|
+
coverage: {
|
|
124
|
+
inspected: items.length,
|
|
125
|
+
returned: items.length,
|
|
126
|
+
truncated: Boolean(nextCursor) || state.seen.length >= maxPages,
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async fetch(
|
|
132
|
+
request: ContextConnectorFetchRequest,
|
|
133
|
+
context: ContextConnectorExecutionContext,
|
|
134
|
+
): Promise<ContextConnectorFetchResult> {
|
|
135
|
+
const connectionId = await connectorConnectionId(
|
|
136
|
+
"notion",
|
|
137
|
+
request.config,
|
|
138
|
+
context.resolveConnection,
|
|
139
|
+
);
|
|
140
|
+
const page = asRecord(
|
|
141
|
+
await executeConnectorProviderRequest(context.providerApi, {
|
|
142
|
+
provider: "notion",
|
|
143
|
+
method: "GET",
|
|
144
|
+
path: `/pages/${encodeURIComponent(request.item.externalId)}`,
|
|
145
|
+
connectionId,
|
|
146
|
+
}),
|
|
147
|
+
);
|
|
148
|
+
if (!page) {
|
|
149
|
+
throw new Error(
|
|
150
|
+
`Notion page ${request.item.externalId} returned no data.`,
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
const discovery = await fetchNotionBlocks(
|
|
154
|
+
request.item.externalId,
|
|
155
|
+
connectionId,
|
|
156
|
+
context,
|
|
157
|
+
positiveLimit(request.config.maxBlocks, 500, 2_000),
|
|
158
|
+
);
|
|
159
|
+
const blocks = discovery.blocks;
|
|
160
|
+
const indexableBlocks = blocks.map(sanitizeNotionBlockMediaUrl);
|
|
161
|
+
const markdown = notionBlocksToMarkdown(indexableBlocks);
|
|
162
|
+
const content =
|
|
163
|
+
markdown.markdown ||
|
|
164
|
+
collectProviderText(
|
|
165
|
+
{ properties: page.properties, blocks: indexableBlocks },
|
|
166
|
+
{
|
|
167
|
+
skipKeys: ["id", "created_by", "last_edited_by", "request_id"],
|
|
168
|
+
},
|
|
169
|
+
);
|
|
170
|
+
const chunks = notionHeadingChunks(markdown.sections);
|
|
171
|
+
const media = await rehostNotionMedia(blocks, context);
|
|
172
|
+
return {
|
|
173
|
+
items: [
|
|
174
|
+
normalizeContextItem({
|
|
175
|
+
externalId: request.item.externalId,
|
|
176
|
+
kind: request.item.kind,
|
|
177
|
+
title: notionPageTitle(page) ?? request.item.title,
|
|
178
|
+
canonicalUrl: stringValue(page.url) ?? request.item.canonicalUrl,
|
|
179
|
+
mimeType: request.item.mimeType,
|
|
180
|
+
content,
|
|
181
|
+
chunks,
|
|
182
|
+
sourceModifiedAt:
|
|
183
|
+
stringValue(page.last_edited_time) ?? request.item.sourceModifiedAt,
|
|
184
|
+
sourceVersion: stringValue(page.last_edited_time),
|
|
185
|
+
parseStatus: "parsed",
|
|
186
|
+
upstreamAccess: notionPageAccess(page),
|
|
187
|
+
curationStatus:
|
|
188
|
+
notionPageAccess(page) === "restricted" ? "review" : "included",
|
|
189
|
+
provenance: {
|
|
190
|
+
provider: "notion",
|
|
191
|
+
pageId: request.item.externalId,
|
|
192
|
+
},
|
|
193
|
+
metadata: {
|
|
194
|
+
provider: "notion",
|
|
195
|
+
blockCount: blocks.length,
|
|
196
|
+
archived: page.archived === true,
|
|
197
|
+
inTrash: page.in_trash === true,
|
|
198
|
+
selectedRootPageId:
|
|
199
|
+
stringValue(request.item.metadata?.selectedRootPageId) ??
|
|
200
|
+
request.item.externalId,
|
|
201
|
+
parentPageId:
|
|
202
|
+
stringValue(request.item.metadata?.parentPageId) ?? null,
|
|
203
|
+
depth: finiteNonNegative(request.item.metadata?.depth),
|
|
204
|
+
childPageIds: discovery.childPages.map((child) => child.id),
|
|
205
|
+
},
|
|
206
|
+
media,
|
|
207
|
+
edges: [
|
|
208
|
+
...discovery.childPages.map((child) => ({
|
|
209
|
+
relation: "contains-page",
|
|
210
|
+
toExternalId: child.id,
|
|
211
|
+
})),
|
|
212
|
+
...(stringValue(request.item.metadata?.parentPageId)
|
|
213
|
+
? [
|
|
214
|
+
{
|
|
215
|
+
relation: "parent-page",
|
|
216
|
+
toExternalId: stringValue(
|
|
217
|
+
request.item.metadata?.parentPageId,
|
|
218
|
+
)!,
|
|
219
|
+
},
|
|
220
|
+
]
|
|
221
|
+
: []),
|
|
222
|
+
],
|
|
223
|
+
}),
|
|
224
|
+
],
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function sanitizeNotionBlockMediaUrl(value: unknown): unknown {
|
|
230
|
+
const block = asRecord(value);
|
|
231
|
+
const type = stringValue(block?.type);
|
|
232
|
+
if (
|
|
233
|
+
!block ||
|
|
234
|
+
!type ||
|
|
235
|
+
!(["image", "video", "audio", "file", "pdf"] as string[]).includes(type)
|
|
236
|
+
) {
|
|
237
|
+
return value;
|
|
238
|
+
}
|
|
239
|
+
const payload = asRecord(block[type]);
|
|
240
|
+
if (!payload) return value;
|
|
241
|
+
const location = payload.file ? "file" : payload.external ? "external" : null;
|
|
242
|
+
const providerFile = location ? asRecord(payload[location]) : null;
|
|
243
|
+
const url = stringValue(providerFile?.url);
|
|
244
|
+
if (!location || !providerFile || !url) return value;
|
|
245
|
+
return {
|
|
246
|
+
...block,
|
|
247
|
+
[type]: {
|
|
248
|
+
...payload,
|
|
249
|
+
[location]: {
|
|
250
|
+
...providerFile,
|
|
251
|
+
url: sanitizeProvenanceUrl(url),
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
interface NotionInventoryCandidate {
|
|
258
|
+
id: string;
|
|
259
|
+
title?: string;
|
|
260
|
+
url?: string;
|
|
261
|
+
boundary: "root-page" | "teamspace-root";
|
|
262
|
+
selectedRootId: string;
|
|
263
|
+
parentId?: string;
|
|
264
|
+
depth: number;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
interface NotionInventoryCursor {
|
|
268
|
+
rootIndex: number;
|
|
269
|
+
queue: NotionInventoryCandidate[];
|
|
270
|
+
seen: string[];
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function parseNotionInventoryCursor(
|
|
274
|
+
value?: string | null,
|
|
275
|
+
): NotionInventoryCursor {
|
|
276
|
+
if (!value) return { rootIndex: 0, queue: [], seen: [] };
|
|
277
|
+
if (/^\d+$/.test(value)) {
|
|
278
|
+
return { rootIndex: cursorOffset(value), queue: [], seen: [] };
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
const parsed = JSON.parse(
|
|
282
|
+
Buffer.from(value, "base64url").toString("utf8"),
|
|
283
|
+
) as Partial<NotionInventoryCursor>;
|
|
284
|
+
return {
|
|
285
|
+
rootIndex: finiteNonNegative(parsed.rootIndex),
|
|
286
|
+
queue: Array.isArray(parsed.queue)
|
|
287
|
+
? parsed.queue.filter(isNotionInventoryCandidate).slice(0, 2_000)
|
|
288
|
+
: [],
|
|
289
|
+
seen: stringArray(parsed.seen).slice(0, 2_000),
|
|
290
|
+
};
|
|
291
|
+
} catch {
|
|
292
|
+
throw new Error("Notion inventory cursor is invalid.");
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function encodeNotionInventoryCursor(state: NotionInventoryCursor): string {
|
|
297
|
+
return Buffer.from(JSON.stringify(state)).toString("base64url");
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function isNotionInventoryCandidate(
|
|
301
|
+
value: unknown,
|
|
302
|
+
): value is NotionInventoryCandidate {
|
|
303
|
+
const candidate = asRecord(value);
|
|
304
|
+
return Boolean(
|
|
305
|
+
stringValue(candidate?.id) &&
|
|
306
|
+
stringValue(candidate?.selectedRootId) &&
|
|
307
|
+
(candidate?.boundary === "root-page" ||
|
|
308
|
+
candidate?.boundary === "teamspace-root") &&
|
|
309
|
+
Number.isInteger(candidate?.depth) &&
|
|
310
|
+
Number(candidate?.depth) >= 0,
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export function notionRecommendedRootPageIds(
|
|
315
|
+
config: Record<string, unknown>,
|
|
316
|
+
): string[] {
|
|
317
|
+
return stringArray(config.recommendedRootPageIds);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function notionBoundaryRoots(config: Record<string, unknown>): Array<{
|
|
321
|
+
id: string;
|
|
322
|
+
title?: string;
|
|
323
|
+
url?: string;
|
|
324
|
+
boundary: "root-page" | "teamspace-root";
|
|
325
|
+
}> {
|
|
326
|
+
const roots = new Map<
|
|
327
|
+
string,
|
|
328
|
+
{
|
|
329
|
+
id: string;
|
|
330
|
+
title?: string;
|
|
331
|
+
url?: string;
|
|
332
|
+
boundary: "root-page" | "teamspace-root";
|
|
333
|
+
}
|
|
334
|
+
>();
|
|
335
|
+
for (const id of stringArray(config.rootPageIds)) {
|
|
336
|
+
roots.set(id, { id, boundary: "root-page" });
|
|
337
|
+
}
|
|
338
|
+
for (const url of stringArray(config.rootPageUrls)) {
|
|
339
|
+
const id = notionPageIdFromUrl(url);
|
|
340
|
+
roots.set(id, { id, url, boundary: "root-page" });
|
|
341
|
+
}
|
|
342
|
+
for (const id of stringArray(config.teamspaceRootPageIds)) {
|
|
343
|
+
roots.set(id, { id, boundary: "teamspace-root" });
|
|
344
|
+
}
|
|
345
|
+
for (const url of stringArray(config.teamspaceRootPageUrls)) {
|
|
346
|
+
const id = notionPageIdFromUrl(url);
|
|
347
|
+
roots.set(id, { id, url, boundary: "teamspace-root" });
|
|
348
|
+
}
|
|
349
|
+
for (const value of Array.isArray(config.roots) ? config.roots : []) {
|
|
350
|
+
const root = asRecord(value);
|
|
351
|
+
const id = stringValue(root?.id);
|
|
352
|
+
if (!id) continue;
|
|
353
|
+
const boundary =
|
|
354
|
+
root?.boundary === "teamspace-root" ? "teamspace-root" : "root-page";
|
|
355
|
+
roots.set(id, {
|
|
356
|
+
id,
|
|
357
|
+
boundary,
|
|
358
|
+
title: stringValue(root?.title),
|
|
359
|
+
url: stringValue(root?.url),
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
if (roots.size === 0) {
|
|
363
|
+
throw new Error(
|
|
364
|
+
"Notion connector config requires rootPageIds or teamspaceRootPageIds. Search recommendations are not an import boundary.",
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
return [...roots.values()];
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function notionPageIdFromUrl(value: string): string {
|
|
371
|
+
const url = new URL(value);
|
|
372
|
+
if (url.hostname !== "notion.so" && !url.hostname.endsWith(".notion.so")) {
|
|
373
|
+
throw new Error("Notion root page URLs must use notion.so.");
|
|
374
|
+
}
|
|
375
|
+
const compact = url.pathname.match(/([a-f0-9]{32})(?:$|[/?#])/i)?.[1];
|
|
376
|
+
if (!compact) throw new Error(`Could not find a Notion page ID in ${value}.`);
|
|
377
|
+
return [
|
|
378
|
+
compact.slice(0, 8),
|
|
379
|
+
compact.slice(8, 12),
|
|
380
|
+
compact.slice(12, 16),
|
|
381
|
+
compact.slice(16, 20),
|
|
382
|
+
compact.slice(20),
|
|
383
|
+
].join("-");
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function notionHeadingChunks(
|
|
387
|
+
sections: ReturnType<typeof notionBlocksToMarkdown>["sections"],
|
|
388
|
+
): NormalizedContextChunk[] {
|
|
389
|
+
return sections.map((section, ordinal) => ({
|
|
390
|
+
ordinal,
|
|
391
|
+
kind: "notion-section",
|
|
392
|
+
text: section.markdown,
|
|
393
|
+
metadata: {
|
|
394
|
+
...(section.heading ? { heading: section.heading } : {}),
|
|
395
|
+
...(section.headingLevel ? { headingLevel: section.headingLevel } : {}),
|
|
396
|
+
},
|
|
397
|
+
}));
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
async function rehostNotionMedia(
|
|
401
|
+
blocks: unknown[],
|
|
402
|
+
context: ContextConnectorExecutionContext,
|
|
403
|
+
): Promise<ContextMediaInput[]> {
|
|
404
|
+
const candidates: Array<{
|
|
405
|
+
url: string;
|
|
406
|
+
kind: ContextMediaInput["kind"];
|
|
407
|
+
mimeType?: string;
|
|
408
|
+
filename: string;
|
|
409
|
+
blockId?: string;
|
|
410
|
+
}> = [];
|
|
411
|
+
for (const value of blocks) {
|
|
412
|
+
const block = asRecord(value);
|
|
413
|
+
const type = stringValue(block?.type);
|
|
414
|
+
if (
|
|
415
|
+
!block ||
|
|
416
|
+
!type ||
|
|
417
|
+
!(["image", "video", "audio", "file", "pdf"] as string[]).includes(type)
|
|
418
|
+
) {
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
const payload = asRecord(block[type]);
|
|
422
|
+
const providerFile = asRecord(payload?.file) ?? asRecord(payload?.external);
|
|
423
|
+
const url = stringValue(providerFile?.url);
|
|
424
|
+
if (!url) continue;
|
|
425
|
+
const blockId = stringValue(block.id);
|
|
426
|
+
candidates.push({
|
|
427
|
+
url,
|
|
428
|
+
kind:
|
|
429
|
+
type === "file" || type === "pdf"
|
|
430
|
+
? "document"
|
|
431
|
+
: (type as "image" | "video" | "audio"),
|
|
432
|
+
mimeType: type === "pdf" ? "application/pdf" : undefined,
|
|
433
|
+
filename: `${blockId ?? `notion-media-${candidates.length + 1}`}${type === "pdf" ? ".pdf" : ""}`,
|
|
434
|
+
blockId,
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
return Promise.all(
|
|
438
|
+
candidates.slice(0, 50).map((candidate) =>
|
|
439
|
+
rehostRemoteMedia({
|
|
440
|
+
...candidate,
|
|
441
|
+
context,
|
|
442
|
+
metadata: { provider: "notion", blockId: candidate.blockId },
|
|
443
|
+
}),
|
|
444
|
+
),
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
async function fetchNotionBlocks(
|
|
449
|
+
rootId: string,
|
|
450
|
+
connectionId: string | undefined,
|
|
451
|
+
context: ContextConnectorExecutionContext,
|
|
452
|
+
maxBlocks: number,
|
|
453
|
+
): Promise<{
|
|
454
|
+
blocks: unknown[];
|
|
455
|
+
childPages: Array<{ id: string; title?: string }>;
|
|
456
|
+
}> {
|
|
457
|
+
const blocks: unknown[] = [];
|
|
458
|
+
const childPages = new Map<string, { id: string; title?: string }>();
|
|
459
|
+
const queue = [rootId];
|
|
460
|
+
while (queue.length > 0 && blocks.length < maxBlocks) {
|
|
461
|
+
if (context.signal?.aborted) throw context.signal.reason;
|
|
462
|
+
const blockId = queue.shift()!;
|
|
463
|
+
let cursor: string | undefined;
|
|
464
|
+
do {
|
|
465
|
+
const payload = asRecord(
|
|
466
|
+
await executeConnectorProviderRequest(context.providerApi, {
|
|
467
|
+
provider: "notion",
|
|
468
|
+
method: "GET",
|
|
469
|
+
path: `/blocks/${encodeURIComponent(blockId)}/children`,
|
|
470
|
+
query: {
|
|
471
|
+
page_size: Math.min(100, maxBlocks - blocks.length),
|
|
472
|
+
...(cursor ? { start_cursor: cursor } : {}),
|
|
473
|
+
},
|
|
474
|
+
connectionId,
|
|
475
|
+
}),
|
|
476
|
+
);
|
|
477
|
+
const results = Array.isArray(payload?.results) ? payload.results : [];
|
|
478
|
+
for (const value of results) {
|
|
479
|
+
if (blocks.length >= maxBlocks) break;
|
|
480
|
+
blocks.push(value);
|
|
481
|
+
const block = asRecord(value);
|
|
482
|
+
const id = stringValue(block?.id);
|
|
483
|
+
if (id && block?.type === "child_page") {
|
|
484
|
+
const child = asRecord(block.child_page);
|
|
485
|
+
childPages.set(id, { id, title: stringValue(child?.title) });
|
|
486
|
+
} else if (id && block?.has_children === true) {
|
|
487
|
+
queue.push(id);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
cursor =
|
|
491
|
+
payload?.has_more === true
|
|
492
|
+
? stringValue(payload.next_cursor)
|
|
493
|
+
: undefined;
|
|
494
|
+
} while (cursor && blocks.length < maxBlocks);
|
|
495
|
+
}
|
|
496
|
+
return { blocks, childPages: [...childPages.values()] };
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function finiteNonNegative(value: unknown): number {
|
|
500
|
+
const number = Number(value);
|
|
501
|
+
return Number.isInteger(number) && number >= 0 ? number : 0;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function notionPageTitle(page: Record<string, unknown>): string | undefined {
|
|
505
|
+
const properties = asRecord(page.properties);
|
|
506
|
+
if (!properties) return undefined;
|
|
507
|
+
for (const value of Object.values(properties)) {
|
|
508
|
+
const property = asRecord(value);
|
|
509
|
+
if (property?.type !== "title" || !Array.isArray(property.title)) continue;
|
|
510
|
+
const title = property.title
|
|
511
|
+
.map((part) => {
|
|
512
|
+
const rich = asRecord(part);
|
|
513
|
+
return stringValue(rich?.plain_text);
|
|
514
|
+
})
|
|
515
|
+
.filter(Boolean)
|
|
516
|
+
.join("")
|
|
517
|
+
.trim();
|
|
518
|
+
if (title) return title;
|
|
519
|
+
}
|
|
520
|
+
return undefined;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function notionPageAccess(
|
|
524
|
+
page: Record<string, unknown>,
|
|
525
|
+
): "available" | "restricted" | "unknown" {
|
|
526
|
+
if (page.archived === true || page.in_trash === true) return "restricted";
|
|
527
|
+
if (stringValue(page.public_url)) return "available";
|
|
528
|
+
return "unknown";
|
|
529
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
const ssrfSafeFetch = vi.hoisted(() => vi.fn());
|
|
4
|
+
|
|
5
|
+
vi.mock("@agent-native/core/extensions/url-safety", () => ({
|
|
6
|
+
ssrfSafeFetch,
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
const { rehostRemoteMedia } = await import("./private-artifacts.js");
|
|
10
|
+
|
|
11
|
+
function context(putPrivateBlob = vi.fn(async () => blobHandle())) {
|
|
12
|
+
return {
|
|
13
|
+
appId: "design",
|
|
14
|
+
ownerEmail: "owner@example.com",
|
|
15
|
+
putPrivateBlob,
|
|
16
|
+
} as never;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function blobHandle() {
|
|
20
|
+
return {
|
|
21
|
+
id: "private-svg",
|
|
22
|
+
provider: "fixture",
|
|
23
|
+
opaque: true as const,
|
|
24
|
+
encrypted: true,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe("private connector artifacts", () => {
|
|
29
|
+
beforeEach(() => ssrfSafeFetch.mockReset());
|
|
30
|
+
|
|
31
|
+
it("sanitizes SVGs and strips signed query credentials from provenance", async () => {
|
|
32
|
+
ssrfSafeFetch.mockResolvedValue(
|
|
33
|
+
new Response(
|
|
34
|
+
'<svg xmlns="http://www.w3.org/2000/svg"><!-- provider --><use href="#mark"/><path id="mark" d="M0 0h1v1z"/></svg>',
|
|
35
|
+
{ status: 200, headers: { "content-type": "image/svg+xml" } },
|
|
36
|
+
),
|
|
37
|
+
);
|
|
38
|
+
const putPrivateBlob = vi.fn(async () => blobHandle());
|
|
39
|
+
const media = await rehostRemoteMedia({
|
|
40
|
+
url: "https://signed.example.com/logo.svg?X-Amz-Credential=top-secret#fragment",
|
|
41
|
+
filename: "logo.svg",
|
|
42
|
+
kind: "image",
|
|
43
|
+
context: context(putPrivateBlob),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
expect(media.provenanceUrl).toBe("https://signed.example.com/logo.svg");
|
|
47
|
+
expect(JSON.stringify(media)).not.toContain("top-secret");
|
|
48
|
+
expect(
|
|
49
|
+
new TextDecoder().decode(putPrivateBlob.mock.calls[0]?.[0].data),
|
|
50
|
+
).not.toContain("provider");
|
|
51
|
+
expect(putPrivateBlob.mock.calls[0]?.[0].key).toMatch(
|
|
52
|
+
/^creative-context\/[a-f0-9]{24}\/[a-f0-9]{64}$/,
|
|
53
|
+
);
|
|
54
|
+
expect(putPrivateBlob.mock.calls[0]?.[0].key).not.toContain(
|
|
55
|
+
"owner@example.com",
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it.each([
|
|
60
|
+
'<svg xmlns="http://www.w3.org/2000/svg"><script>alert(1)</script></svg>',
|
|
61
|
+
'<svg xmlns="http://www.w3.org/2000/svg"><image href="https://tracker.example/pixel.png"/></svg>',
|
|
62
|
+
'<svg xmlns="http://www.w3.org/2000/svg"><style>.x{fill:url(https://tracker.example/a)}</style></svg>',
|
|
63
|
+
])("rejects active or external SVG content", async (svg) => {
|
|
64
|
+
ssrfSafeFetch.mockResolvedValue(
|
|
65
|
+
new Response(svg, {
|
|
66
|
+
status: 200,
|
|
67
|
+
headers: { "content-type": "image/svg+xml" },
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
|
+
const putPrivateBlob = vi.fn(async () => blobHandle());
|
|
71
|
+
|
|
72
|
+
await expect(
|
|
73
|
+
rehostRemoteMedia({
|
|
74
|
+
url: "https://signed.example.com/logo.svg?token=do-not-store",
|
|
75
|
+
filename: "logo.svg",
|
|
76
|
+
kind: "image",
|
|
77
|
+
context: context(putPrivateBlob),
|
|
78
|
+
}),
|
|
79
|
+
).rejects.toThrow(/SVG contains (?:active content|an external reference)/i);
|
|
80
|
+
expect(putPrivateBlob).not.toHaveBeenCalled();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("never includes a signed media URL in fetch failures", async () => {
|
|
84
|
+
ssrfSafeFetch.mockResolvedValue(new Response("denied", { status: 403 }));
|
|
85
|
+
const request = rehostRemoteMedia({
|
|
86
|
+
url: "https://signed.example.com/logo.svg?token=do-not-log",
|
|
87
|
+
filename: "logo.svg",
|
|
88
|
+
kind: "image",
|
|
89
|
+
context: context(),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
await expect(request).rejects.toThrow("Media fetch failed (403).");
|
|
93
|
+
await expect(request).rejects.not.toThrow("do-not-log");
|
|
94
|
+
});
|
|
95
|
+
});
|