@agent-native/creative-context 0.0.0-beta-20260820202238
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 +154 -0
- package/agent-native.eject.json +41 -0
- package/agent-native.package.json +119 -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 +22 -0
- package/dist/actions/continue-context-import.d.ts.map +1 -0
- package/dist/actions/continue-context-import.js +13 -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 +157 -0
- package/dist/actions/get-creative-context.d.ts.map +1 -0
- package/dist/actions/get-creative-context.js +148 -0
- package/dist/actions/get-creative-context.js.map +1 -0
- package/dist/actions/get-google-picker-session.d.ts +10 -0
- package/dist/actions/get-google-picker-session.d.ts.map +1 -0
- package/dist/actions/get-google-picker-session.js +38 -0
- package/dist/actions/get-google-picker-session.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 +73 -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-memberships.d.ts +11 -0
- package/dist/actions/list-context-memberships.d.ts.map +1 -0
- package/dist/actions/list-context-memberships.js +47 -0
- package/dist/actions/list-context-memberships.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/list-creative-contexts.d.ts +12 -0
- package/dist/actions/list-creative-contexts.d.ts.map +1 -0
- package/dist/actions/list-creative-contexts.js +28 -0
- package/dist/actions/list-creative-contexts.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-membership.d.ts +64 -0
- package/dist/actions/manage-context-membership.d.ts.map +1 -0
- package/dist/actions/manage-context-membership.js +70 -0
- package/dist/actions/manage-context-membership.js.map +1 -0
- package/dist/actions/manage-context-pack.d.ts +36 -0
- package/dist/actions/manage-context-pack.d.ts.map +1 -0
- package/dist/actions/manage-context-pack.js +71 -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 +130 -0
- package/dist/actions/manage-context-source.js.map +1 -0
- package/dist/actions/manage-creative-context.d.ts +28 -0
- package/dist/actions/manage-creative-context.d.ts.map +1 -0
- package/dist/actions/manage-creative-context.js +65 -0
- package/dist/actions/manage-creative-context.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 +37 -0
- package/dist/actions/process-context-purge.d.ts.map +1 -0
- package/dist/actions/process-context-purge.js +20 -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 +80 -0
- package/dist/actions/search-creative-context.d.ts.map +1 -0
- package/dist/actions/search-creative-context.js +42 -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 +25 -0
- package/dist/actions/start-context-enrichment.d.ts.map +1 -0
- package/dist/actions/start-context-enrichment.js +48 -0
- package/dist/actions/start-context-enrichment.js.map +1 -0
- package/dist/actions/start-context-import.d.ts +24 -0
- package/dist/actions/start-context-import.d.ts.map +1 -0
- package/dist/actions/start-context-import.js +37 -0
- package/dist/actions/start-context-import.js.map +1 -0
- package/dist/client/CreativeContextChip.d.ts +18 -0
- package/dist/client/CreativeContextChip.d.ts.map +1 -0
- package/dist/client/CreativeContextChip.js +80 -0
- package/dist/client/CreativeContextChip.js.map +1 -0
- package/dist/client/CreativeContextPanel.d.ts +73 -0
- package/dist/client/CreativeContextPanel.d.ts.map +1 -0
- package/dist/client/CreativeContextPanel.js +1171 -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/CreativeContextShareTab.d.ts +56 -0
- package/dist/client/CreativeContextShareTab.d.ts.map +1 -0
- package/dist/client/CreativeContextShareTab.js +213 -0
- package/dist/client/CreativeContextShareTab.js.map +1 -0
- package/dist/client/actions.d.ts +474 -0
- package/dist/client/actions.d.ts.map +1 -0
- package/dist/client/actions.js +411 -0
- package/dist/client/actions.js.map +1 -0
- package/dist/client/agent-tab.d.ts +10 -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 +24 -0
- package/dist/client/application-state.d.ts.map +1 -0
- package/dist/client/application-state.js +111 -0
- package/dist/client/application-state.js.map +1 -0
- package/dist/client/google-slides-picker.d.ts +19 -0
- package/dist/client/google-slides-picker.d.ts.map +1 -0
- package/dist/client/google-slides-picker.js +106 -0
- package/dist/client/google-slides-picker.js.map +1 -0
- package/dist/client/index.d.ts +10 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +10 -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 +1158 -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 +895 -0
- package/dist/connectors/google-slides.js.map +1 -0
- package/dist/connectors/index.d.ts +21 -0
- package/dist/connectors/index.d.ts.map +1 -0
- package/dist/connectors/index.js +45 -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 +42 -0
- package/dist/connectors/normalize.d.ts.map +1 -0
- package/dist/connectors/normalize.js +335 -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-design.d.ts +68 -0
- package/dist/connectors/rendered-design.d.ts.map +1 -0
- package/dist/connectors/rendered-design.js +362 -0
- package/dist/connectors/rendered-design.js.map +1 -0
- package/dist/connectors/rendered-page.d.ts +115 -0
- package/dist/connectors/rendered-page.d.ts.map +1 -0
- package/dist/connectors/rendered-page.js +1036 -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 +2 -0
- package/dist/embeddings/providers.d.ts.map +1 -0
- package/dist/embeddings/providers.js +2 -0
- package/dist/embeddings/providers.js.map +1 -0
- package/dist/embeddings/types.d.ts +2 -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 +262 -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 +7111 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +469 -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 +333 -0
- package/dist/schema/migrations.js.map +1 -0
- package/dist/search/fusion.d.ts +2 -0
- package/dist/search/fusion.d.ts.map +1 -0
- package/dist/search/fusion.js +2 -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 +2 -0
- package/dist/search/postgres-fts.d.ts.map +1 -0
- package/dist/search/postgres-fts.js +2 -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 +24 -0
- package/dist/server/enrichment.d.ts.map +1 -0
- package/dist/server/enrichment.js +138 -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 +113 -0
- package/dist/server/generation-artifact-access.js.map +1 -0
- package/dist/server/generation-context.d.ts +220 -0
- package/dist/server/generation-context.d.ts.map +1 -0
- package/dist/server/generation-context.js +432 -0
- package/dist/server/generation-context.js.map +1 -0
- package/dist/server/index.d.ts +27 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +115 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/isolated-a2a.d.ts +175 -0
- package/dist/server/isolated-a2a.d.ts.map +1 -0
- package/dist/server/isolated-a2a.js +312 -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 +108 -0
- package/dist/server/media.js.map +1 -0
- package/dist/server/native-resource-capture.d.ts +78 -0
- package/dist/server/native-resource-capture.d.ts.map +1 -0
- package/dist/server/native-resource-capture.js +94 -0
- package/dist/server/native-resource-capture.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 +83 -0
- package/dist/server/retrieval.d.ts.map +1 -0
- package/dist/server/retrieval.js +445 -0
- package/dist/server/retrieval.js.map +1 -0
- package/dist/server/safe-native-preview.d.ts +15 -0
- package/dist/server/safe-native-preview.d.ts.map +1 -0
- package/dist/server/safe-native-preview.js +148 -0
- package/dist/server/safe-native-preview.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 +346 -0
- package/dist/store/brand.js.map +1 -0
- package/dist/store/content.d.ts +134 -0
- package/dist/store/content.d.ts.map +1 -0
- package/dist/store/content.js +1677 -0
- package/dist/store/content.js.map +1 -0
- package/dist/store/contexts.d.ts +216 -0
- package/dist/store/contexts.d.ts.map +1 -0
- package/dist/store/contexts.js +1346 -0
- package/dist/store/contexts.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 +11 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +11 -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/native-artifact-summary.d.ts +7 -0
- package/dist/store/native-artifact-summary.d.ts.map +1 -0
- package/dist/store/native-artifact-summary.js +10 -0
- package/dist/store/native-artifact-summary.js.map +1 -0
- package/dist/store/packs.d.ts +36 -0
- package/dist/store/packs.d.ts.map +1 -0
- package/dist/store/packs.js +438 -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 +354 -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 +525 -0
- package/dist/store/sources.js.map +1 -0
- package/dist/store/suggestions.d.ts +29 -0
- package/dist/store/suggestions.d.ts.map +1 -0
- package/dist/store/suggestions.js +270 -0
- package/dist/store/suggestions.js.map +1 -0
- package/dist/types.d.ts +578 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/untrusted-reference.d.ts +8 -0
- package/dist/untrusted-reference.d.ts.map +1 -0
- package/dist/untrusted-reference.js +19 -0
- package/dist/untrusted-reference.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 +2 -0
- package/dist/vector/pgvector.d.ts.map +1 -0
- package/dist/vector/pgvector.js +2 -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 +90 -0
- package/package.json +100 -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 +15 -0
- package/src/actions/creative-context-a2a.spec.ts +162 -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 +435 -0
- package/src/actions/get-creative-context.ts +197 -0
- package/src/actions/get-google-picker-session.spec.ts +62 -0
- package/src/actions/get-google-picker-session.ts +45 -0
- package/src/actions/index.ts +75 -0
- package/src/actions/infer-brand-dna.ts +15 -0
- package/src/actions/job-public-serialization.spec.ts +143 -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-memberships.ts +56 -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/list-creative-contexts.spec.ts +38 -0
- package/src/actions/list-creative-contexts.ts +32 -0
- package/src/actions/manage-brand-profile.ts +58 -0
- package/src/actions/manage-context-membership.ts +80 -0
- package/src/actions/manage-context-pack.ts +81 -0
- package/src/actions/manage-context-source.ts +151 -0
- package/src/actions/manage-creative-context.ts +73 -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 +28 -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 +48 -0
- package/src/actions/set-brand-dna.ts +22 -0
- package/src/actions/start-context-enrichment.ts +52 -0
- package/src/actions/start-context-import.ts +38 -0
- package/src/client/CreativeContextChip.spec.ts +59 -0
- package/src/client/CreativeContextChip.tsx +243 -0
- package/src/client/CreativeContextPanel.tsx +3600 -0
- package/src/client/CreativeContextSettingsLink.tsx +30 -0
- package/src/client/CreativeContextShareTab.spec.ts +70 -0
- package/src/client/CreativeContextShareTab.tsx +666 -0
- package/src/client/actions.spec.ts +177 -0
- package/src/client/actions.ts +1024 -0
- package/src/client/agent-tab.tsx +56 -0
- package/src/client/application-state.spec.ts +46 -0
- package/src/client/application-state.ts +158 -0
- package/src/client/google-slides-picker.spec.ts +36 -0
- package/src/client/google-slides-picker.ts +146 -0
- package/src/client/index.ts +102 -0
- package/src/client/messages.ts +1370 -0
- package/src/client/source-config.spec.ts +166 -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 +1171 -0
- package/src/connectors/index.ts +112 -0
- package/src/connectors/manual.ts +132 -0
- package/src/connectors/normalize.spec.ts +144 -0
- package/src/connectors/normalize.ts +475 -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-design.spec.ts +171 -0
- package/src/connectors/rendered-design.ts +495 -0
- package/src/connectors/rendered-page.spec.ts +388 -0
- package/src/connectors/rendered-page.ts +1387 -0
- package/src/connectors/smart-defaults.spec.ts +135 -0
- package/src/connectors/smart-defaults.ts +87 -0
- package/src/connectors/types.ts +113 -0
- package/src/connectors/upload.spec.ts +175 -0
- package/src/connectors/upload.ts +548 -0
- package/src/connectors/website.spec.ts +465 -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 +1 -0
- package/src/embeddings/types.ts +6 -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 +145 -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 +791 -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 +181 -0
- package/src/jobs/server-worker.ts +354 -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 +527 -0
- package/src/schema/migrations.spec.ts +41 -0
- package/src/schema/migrations.ts +338 -0
- package/src/search/fusion.spec.ts +21 -0
- package/src/search/fusion.ts +1 -0
- package/src/search/mode.spec.ts +28 -0
- package/src/search/mode.ts +21 -0
- package/src/search/postgres-fts.spec.ts +63 -0
- package/src/search/postgres-fts.ts +1 -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.spec.ts +94 -0
- package/src/server/enrichment.ts +166 -0
- package/src/server/generation-artifact-access.spec.ts +104 -0
- package/src/server/generation-artifact-access.ts +217 -0
- package/src/server/generation-context-a2a.spec.ts +282 -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 +639 -0
- package/src/server/index.spec.ts +30 -0
- package/src/server/index.ts +163 -0
- package/src/server/isolated-a2a.spec.ts +184 -0
- package/src/server/isolated-a2a.ts +416 -0
- package/src/server/media.spec.ts +120 -0
- package/src/server/media.ts +136 -0
- package/src/server/native-resource-capture.spec.ts +121 -0
- package/src/server/native-resource-capture.ts +198 -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 +150 -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 +590 -0
- package/src/server/safe-native-preview.spec.ts +29 -0
- package/src/server/safe-native-preview.ts +199 -0
- package/src/store/access.integration.spec.ts +3523 -0
- package/src/store/brand.ts +458 -0
- package/src/store/content.ts +2317 -0
- package/src/store/contexts.ts +1840 -0
- package/src/store/generation.ts +226 -0
- package/src/store/helpers.ts +53 -0
- package/src/store/index.ts +10 -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 +674 -0
- package/src/store/native-artifact-summary.ts +13 -0
- package/src/store/packs.ts +721 -0
- package/src/store/purge.ts +463 -0
- package/src/store/sources.spec.ts +102 -0
- package/src/store/sources.ts +692 -0
- package/src/store/suggestions.ts +361 -0
- package/src/types.ts +671 -0
- package/src/untrusted-reference.spec.ts +22 -0
- package/src/untrusted-reference.ts +24 -0
- package/src/vector/index.ts +1 -0
- package/src/vector/pgvector.spec.ts +115 -0
- package/src/vector/pgvector.ts +1 -0
- package/tsconfig.json +31 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ContextCurationRank,
|
|
5
|
+
ContextCurationStatus,
|
|
6
|
+
ContextEdgeInput,
|
|
7
|
+
ContextMediaInput,
|
|
8
|
+
NormalizedContextChunk,
|
|
9
|
+
NormalizedContextItem,
|
|
10
|
+
UpstreamAccess,
|
|
11
|
+
} from "../types.js";
|
|
12
|
+
|
|
13
|
+
const DEFAULT_CHUNK_CHARS = 4_000;
|
|
14
|
+
export const MAX_SEARCHABLE_CONTENT_BYTES = 64 * 1024;
|
|
15
|
+
export const MAX_SUMMARY_BYTES = 8 * 1024;
|
|
16
|
+
export const MAX_NATIVE_CONTENT_BYTES = 128 * 1024;
|
|
17
|
+
export const MAX_METADATA_BYTES = 32 * 1024;
|
|
18
|
+
export const MAX_MEDIA_TEXT_BYTES = 64 * 1024;
|
|
19
|
+
export const MAX_MEDIA_LOCATOR_BYTES = 16 * 1024;
|
|
20
|
+
|
|
21
|
+
export interface NormalizeContextItemInput {
|
|
22
|
+
externalId: string;
|
|
23
|
+
kind: string;
|
|
24
|
+
title: string;
|
|
25
|
+
content: string;
|
|
26
|
+
preserveContent?: boolean;
|
|
27
|
+
canonicalUrl?: string;
|
|
28
|
+
mimeType?: string;
|
|
29
|
+
summary?: string;
|
|
30
|
+
sourceModifiedAt?: string;
|
|
31
|
+
sourceVersion?: string;
|
|
32
|
+
rawSnapshotBlobRef?: string;
|
|
33
|
+
parseStatus?: "pending" | "parsed" | "failed";
|
|
34
|
+
parseError?: string;
|
|
35
|
+
upstreamAccess?: UpstreamAccess;
|
|
36
|
+
curationStatus?: ContextCurationStatus;
|
|
37
|
+
curationRank?: ContextCurationRank;
|
|
38
|
+
thumbnailBlobRef?: string;
|
|
39
|
+
provenance?: Record<string, unknown>;
|
|
40
|
+
metadata?: Record<string, unknown>;
|
|
41
|
+
chunks?: NormalizedContextChunk[];
|
|
42
|
+
media?: ContextMediaInput[];
|
|
43
|
+
edges?: ContextEdgeInput[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function normalizeContextItem(
|
|
47
|
+
input: NormalizeContextItemInput,
|
|
48
|
+
): NormalizedContextItem {
|
|
49
|
+
const externalId = required(input.externalId, "externalId");
|
|
50
|
+
const title = required(input.title, "title");
|
|
51
|
+
const nativeArtifact =
|
|
52
|
+
input.metadata &&
|
|
53
|
+
typeof input.metadata === "object" &&
|
|
54
|
+
!Array.isArray(input.metadata) &&
|
|
55
|
+
input.metadata.nativeArtifact &&
|
|
56
|
+
typeof input.metadata.nativeArtifact === "object" &&
|
|
57
|
+
!Array.isArray(input.metadata.nativeArtifact)
|
|
58
|
+
? (input.metadata.nativeArtifact as Record<string, unknown>)
|
|
59
|
+
: null;
|
|
60
|
+
const preserveContent =
|
|
61
|
+
input.preserveContent === true ||
|
|
62
|
+
(input.mimeType === "text/html" &&
|
|
63
|
+
(nativeArtifact?.format === "slides-html" ||
|
|
64
|
+
nativeArtifact?.format === "design-html"));
|
|
65
|
+
const candidateContent = preserveContent
|
|
66
|
+
? input.content.replace(/\r\n?/g, "\n").trim()
|
|
67
|
+
: normalizeWhitespace(input.content);
|
|
68
|
+
const content = preserveContent
|
|
69
|
+
? requireBoundedNativeContent(candidateContent)
|
|
70
|
+
: boundText(candidateContent, MAX_SEARCHABLE_CONTENT_BYTES);
|
|
71
|
+
const summary = input.summary
|
|
72
|
+
? boundText(normalizeWhitespace(input.summary), MAX_SUMMARY_BYTES)
|
|
73
|
+
: undefined;
|
|
74
|
+
const chunks = boundChunks(input.chunks ?? chunkContextText(content));
|
|
75
|
+
const normalized = {
|
|
76
|
+
externalId,
|
|
77
|
+
kind: required(input.kind, "kind"),
|
|
78
|
+
title,
|
|
79
|
+
...(input.canonicalUrl ? { canonicalUrl: input.canonicalUrl } : {}),
|
|
80
|
+
...(input.mimeType ? { mimeType: input.mimeType } : {}),
|
|
81
|
+
content,
|
|
82
|
+
...(summary ? { summary } : {}),
|
|
83
|
+
...(input.sourceModifiedAt
|
|
84
|
+
? { sourceModifiedAt: input.sourceModifiedAt }
|
|
85
|
+
: {}),
|
|
86
|
+
...(input.sourceVersion ? { sourceVersion: input.sourceVersion } : {}),
|
|
87
|
+
...(input.rawSnapshotBlobRef
|
|
88
|
+
? { rawSnapshotBlobRef: input.rawSnapshotBlobRef }
|
|
89
|
+
: {}),
|
|
90
|
+
...(input.parseStatus ? { parseStatus: input.parseStatus } : {}),
|
|
91
|
+
...(input.parseError ? { parseError: input.parseError } : {}),
|
|
92
|
+
...(input.upstreamAccess ? { upstreamAccess: input.upstreamAccess } : {}),
|
|
93
|
+
...(input.curationStatus ? { curationStatus: input.curationStatus } : {}),
|
|
94
|
+
...(input.curationRank ? { curationRank: input.curationRank } : {}),
|
|
95
|
+
...(input.thumbnailBlobRef
|
|
96
|
+
? { thumbnailBlobRef: input.thumbnailBlobRef }
|
|
97
|
+
: {}),
|
|
98
|
+
...(input.provenance ? { provenance: input.provenance } : {}),
|
|
99
|
+
...(input.metadata ? { metadata: input.metadata } : {}),
|
|
100
|
+
...(chunks.length > 0 ? { chunks } : {}),
|
|
101
|
+
...(input.media?.length ? { media: input.media } : {}),
|
|
102
|
+
...(input.edges?.length ? { edges: input.edges } : {}),
|
|
103
|
+
};
|
|
104
|
+
return {
|
|
105
|
+
...normalized,
|
|
106
|
+
contentHash: hashContextVersion(normalized),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function boundText(value: string, maxBytes: number): string {
|
|
111
|
+
if (Buffer.byteLength(value, "utf8") <= maxBytes) return value;
|
|
112
|
+
let bytes = 0;
|
|
113
|
+
let endOffset = 0;
|
|
114
|
+
for (const codePoint of value) {
|
|
115
|
+
const codePointBytes = Buffer.byteLength(codePoint, "utf8");
|
|
116
|
+
if (bytes + codePointBytes > maxBytes) break;
|
|
117
|
+
bytes += codePointBytes;
|
|
118
|
+
endOffset += codePoint.length;
|
|
119
|
+
}
|
|
120
|
+
return value.slice(0, endOffset);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function requireBoundedNativeContent(value: string): string {
|
|
124
|
+
const bytes = Buffer.byteLength(value, "utf8");
|
|
125
|
+
if (bytes > MAX_NATIVE_CONTENT_BYTES) {
|
|
126
|
+
throw new Error(
|
|
127
|
+
`Creative context native content is ${bytes} bytes and exceeds the ${MAX_NATIVE_CONTENT_BYTES}-byte SQL inline limit; split the artifact or store it in private blob storage instead of truncating it`,
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function assertContextItemSqlTextLimits(
|
|
134
|
+
item: Pick<
|
|
135
|
+
NormalizedContextItem,
|
|
136
|
+
| "content"
|
|
137
|
+
| "summary"
|
|
138
|
+
| "mimeType"
|
|
139
|
+
| "provenance"
|
|
140
|
+
| "metadata"
|
|
141
|
+
| "chunks"
|
|
142
|
+
| "media"
|
|
143
|
+
| "edges"
|
|
144
|
+
>,
|
|
145
|
+
): void {
|
|
146
|
+
const nativeArtifact = item.metadata?.nativeArtifact;
|
|
147
|
+
const isNativeContent =
|
|
148
|
+
item.mimeType === "text/html" &&
|
|
149
|
+
typeof nativeArtifact === "object" &&
|
|
150
|
+
nativeArtifact !== null &&
|
|
151
|
+
!Array.isArray(nativeArtifact) &&
|
|
152
|
+
((nativeArtifact as Record<string, unknown>).format === "slides-html" ||
|
|
153
|
+
(nativeArtifact as Record<string, unknown>).format === "design-html");
|
|
154
|
+
const contentLimit = isNativeContent
|
|
155
|
+
? MAX_NATIVE_CONTENT_BYTES
|
|
156
|
+
: MAX_SEARCHABLE_CONTENT_BYTES;
|
|
157
|
+
assertSqlTextLimit(
|
|
158
|
+
isNativeContent ? "native content" : "searchable content",
|
|
159
|
+
item.content,
|
|
160
|
+
contentLimit,
|
|
161
|
+
isNativeContent
|
|
162
|
+
? "split the artifact or store it in private blob storage"
|
|
163
|
+
: "normalize or chunk the source before ingest",
|
|
164
|
+
);
|
|
165
|
+
if (item.summary) {
|
|
166
|
+
assertSqlTextLimit(
|
|
167
|
+
"summary",
|
|
168
|
+
item.summary,
|
|
169
|
+
MAX_SUMMARY_BYTES,
|
|
170
|
+
"normalize the summary before ingest",
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
assertJsonSqlTextLimit(
|
|
174
|
+
"item metadata",
|
|
175
|
+
item.metadata,
|
|
176
|
+
MAX_METADATA_BYTES,
|
|
177
|
+
"move raw payloads to private blob storage before ingest",
|
|
178
|
+
);
|
|
179
|
+
assertJsonSqlTextLimit(
|
|
180
|
+
"item provenance",
|
|
181
|
+
item.provenance,
|
|
182
|
+
MAX_METADATA_BYTES,
|
|
183
|
+
"move raw payloads to private blob storage before ingest",
|
|
184
|
+
);
|
|
185
|
+
let chunkBytes = 0;
|
|
186
|
+
for (const chunk of item.chunks ?? []) {
|
|
187
|
+
chunkBytes += Buffer.byteLength(chunk.text, "utf8");
|
|
188
|
+
if (chunkBytes > MAX_SEARCHABLE_CONTENT_BYTES) {
|
|
189
|
+
throw new Error(
|
|
190
|
+
`Creative context chunks exceed the ${MAX_SEARCHABLE_CONTENT_BYTES}-byte SQL text limit; normalize or split the chunks before ingest`,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
assertJsonSqlTextLimit(
|
|
194
|
+
"chunk metadata",
|
|
195
|
+
chunk.metadata,
|
|
196
|
+
MAX_METADATA_BYTES,
|
|
197
|
+
"move raw payloads to private blob storage before ingest",
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
for (const media of item.media ?? []) {
|
|
201
|
+
for (const [label, value] of [
|
|
202
|
+
["media alt text", media.altText],
|
|
203
|
+
["media caption", media.caption],
|
|
204
|
+
["media OCR text", media.ocrText],
|
|
205
|
+
] as const) {
|
|
206
|
+
if (value) {
|
|
207
|
+
assertSqlTextLimit(
|
|
208
|
+
label,
|
|
209
|
+
value,
|
|
210
|
+
MAX_MEDIA_TEXT_BYTES,
|
|
211
|
+
"move raw payloads to private blob storage before ingest",
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
for (const [label, value] of [
|
|
216
|
+
["media URL", media.url],
|
|
217
|
+
["media storage key", media.storageKey],
|
|
218
|
+
["media provenance URL", media.provenanceUrl],
|
|
219
|
+
] as const) {
|
|
220
|
+
if (!value) continue;
|
|
221
|
+
if (value.trim().toLowerCase().startsWith("data:")) {
|
|
222
|
+
throw new Error(
|
|
223
|
+
`Creative context ${label} cannot be an inline data URL; store the payload in private blob storage instead`,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
assertSqlTextLimit(
|
|
227
|
+
label,
|
|
228
|
+
value,
|
|
229
|
+
MAX_MEDIA_LOCATOR_BYTES,
|
|
230
|
+
"move raw payloads to private blob storage before ingest",
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
assertJsonSqlTextLimit(
|
|
234
|
+
"media metadata",
|
|
235
|
+
media.metadata,
|
|
236
|
+
MAX_METADATA_BYTES,
|
|
237
|
+
"move raw payloads to private blob storage before ingest",
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
for (const edge of item.edges ?? []) {
|
|
241
|
+
assertJsonSqlTextLimit(
|
|
242
|
+
"edge metadata",
|
|
243
|
+
edge.metadata,
|
|
244
|
+
MAX_METADATA_BYTES,
|
|
245
|
+
"move raw payloads to private blob storage before ingest",
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function assertJsonSqlTextLimit(
|
|
251
|
+
label: string,
|
|
252
|
+
value: unknown,
|
|
253
|
+
maxBytes: number,
|
|
254
|
+
guidance: string,
|
|
255
|
+
): void {
|
|
256
|
+
if (value === undefined) return;
|
|
257
|
+
const serialized = JSON.stringify(value);
|
|
258
|
+
if (serialized === undefined) return;
|
|
259
|
+
assertSqlTextLimit(label, serialized, maxBytes, guidance);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function assertSqlTextLimit(
|
|
263
|
+
label: string,
|
|
264
|
+
value: string,
|
|
265
|
+
maxBytes: number,
|
|
266
|
+
guidance: string,
|
|
267
|
+
): void {
|
|
268
|
+
const bytes = Buffer.byteLength(value, "utf8");
|
|
269
|
+
if (bytes > maxBytes) {
|
|
270
|
+
throw new Error(
|
|
271
|
+
`Creative context ${label} is ${bytes} bytes and exceeds the ${maxBytes}-byte SQL text limit; ${guidance}`,
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function boundChunks(
|
|
277
|
+
chunks: NormalizedContextChunk[],
|
|
278
|
+
): NormalizedContextChunk[] {
|
|
279
|
+
let remaining = MAX_SEARCHABLE_CONTENT_BYTES;
|
|
280
|
+
return chunks.flatMap((chunk) => {
|
|
281
|
+
if (remaining <= 0) return [];
|
|
282
|
+
const text = boundText(chunk.text, remaining);
|
|
283
|
+
remaining -= Buffer.byteLength(text, "utf8");
|
|
284
|
+
return text
|
|
285
|
+
? [
|
|
286
|
+
{
|
|
287
|
+
...chunk,
|
|
288
|
+
text,
|
|
289
|
+
endOffset:
|
|
290
|
+
chunk.startOffset == null
|
|
291
|
+
? chunk.endOffset
|
|
292
|
+
: chunk.startOffset + text.length,
|
|
293
|
+
},
|
|
294
|
+
]
|
|
295
|
+
: [];
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export function hashContextContent(value: unknown): string {
|
|
300
|
+
return createHash("sha256").update(stableJson(value)).digest("hex");
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export function hashContextVersion(
|
|
304
|
+
item: Omit<NormalizedContextItem, "contentHash">,
|
|
305
|
+
): string {
|
|
306
|
+
return hashContextContent({
|
|
307
|
+
externalId: item.externalId,
|
|
308
|
+
kind: item.kind,
|
|
309
|
+
title: item.title,
|
|
310
|
+
content: item.content,
|
|
311
|
+
summary: item.summary ?? null,
|
|
312
|
+
mimeType: item.mimeType ?? null,
|
|
313
|
+
sourceVersion: item.sourceVersion ?? null,
|
|
314
|
+
rawSnapshotBlobRef: item.rawSnapshotBlobRef ?? null,
|
|
315
|
+
parseStatus: item.parseStatus ?? "parsed",
|
|
316
|
+
parseError: item.parseError ?? null,
|
|
317
|
+
metadata: withoutVolatileCaptureMetadata(item.metadata ?? {}),
|
|
318
|
+
chunks: canonicalUnordered(item.chunks ?? [], (chunk) => ({
|
|
319
|
+
ordinal: chunk.ordinal,
|
|
320
|
+
kind: chunk.kind ?? "text",
|
|
321
|
+
text: chunk.text,
|
|
322
|
+
startOffset: chunk.startOffset ?? null,
|
|
323
|
+
endOffset: chunk.endOffset ?? null,
|
|
324
|
+
tokenCount: chunk.tokenCount ?? null,
|
|
325
|
+
metadata: chunk.metadata ?? {},
|
|
326
|
+
})),
|
|
327
|
+
media: canonicalUnordered(item.media ?? [], (entry) => ({
|
|
328
|
+
id: entry.id ?? null,
|
|
329
|
+
kind: entry.kind,
|
|
330
|
+
mimeType: entry.mimeType ?? null,
|
|
331
|
+
accessMode: entry.accessMode ?? "public",
|
|
332
|
+
url: entry.url ?? null,
|
|
333
|
+
storageKey: entry.storageKey ?? null,
|
|
334
|
+
provenanceUrl: entry.provenanceUrl ?? null,
|
|
335
|
+
altText: entry.altText ?? null,
|
|
336
|
+
caption: entry.caption ?? null,
|
|
337
|
+
captionStatus: entry.captionStatus ?? "pending",
|
|
338
|
+
ocrText: entry.ocrText ?? null,
|
|
339
|
+
palette: entry.palette ?? [],
|
|
340
|
+
contentHash: entry.contentHash ?? null,
|
|
341
|
+
width: entry.width ?? null,
|
|
342
|
+
height: entry.height ?? null,
|
|
343
|
+
durationMs: entry.durationMs ?? null,
|
|
344
|
+
metadata: entry.metadata ?? {},
|
|
345
|
+
})),
|
|
346
|
+
edges: canonicalUnordered(item.edges ?? [], (edge) => ({
|
|
347
|
+
id: edge.id ?? null,
|
|
348
|
+
relation: edge.relation,
|
|
349
|
+
toItemId: edge.toItemId ?? null,
|
|
350
|
+
toItemVersionId: edge.toItemVersionId ?? null,
|
|
351
|
+
toExternalId: edge.toExternalId ?? null,
|
|
352
|
+
metadata: edge.metadata ?? {},
|
|
353
|
+
})),
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export function chunkContextText(
|
|
358
|
+
input: string,
|
|
359
|
+
maxChars = DEFAULT_CHUNK_CHARS,
|
|
360
|
+
): NormalizedContextChunk[] {
|
|
361
|
+
const text = normalizeWhitespace(input);
|
|
362
|
+
if (!text) return [];
|
|
363
|
+
const chunks: NormalizedContextChunk[] = [];
|
|
364
|
+
let start = 0;
|
|
365
|
+
while (start < text.length) {
|
|
366
|
+
let end = Math.min(text.length, start + maxChars);
|
|
367
|
+
if (end < text.length) {
|
|
368
|
+
const boundary = Math.max(
|
|
369
|
+
text.lastIndexOf("\n\n", end),
|
|
370
|
+
text.lastIndexOf(". ", end),
|
|
371
|
+
);
|
|
372
|
+
if (boundary > start + Math.floor(maxChars / 2)) {
|
|
373
|
+
end = boundary + (text.startsWith("\n\n", boundary) ? 2 : 1);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
const chunk = text.slice(start, end).trim();
|
|
377
|
+
if (chunk) {
|
|
378
|
+
chunks.push({
|
|
379
|
+
ordinal: chunks.length,
|
|
380
|
+
kind: "text",
|
|
381
|
+
text: chunk,
|
|
382
|
+
startOffset: start,
|
|
383
|
+
endOffset: end,
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
start = end;
|
|
387
|
+
}
|
|
388
|
+
return chunks;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export function collectProviderText(
|
|
392
|
+
value: unknown,
|
|
393
|
+
options: { skipKeys?: readonly string[]; maxChars?: number } = {},
|
|
394
|
+
): string {
|
|
395
|
+
const skip = new Set([
|
|
396
|
+
"id",
|
|
397
|
+
"url",
|
|
398
|
+
"href",
|
|
399
|
+
"etag",
|
|
400
|
+
"thumbnailUrl",
|
|
401
|
+
...(options.skipKeys ?? []),
|
|
402
|
+
]);
|
|
403
|
+
const values: string[] = [];
|
|
404
|
+
const maxChars = options.maxChars ?? 2_000_000;
|
|
405
|
+
const visit = (current: unknown, key?: string): void => {
|
|
406
|
+
if (values.join("\n").length >= maxChars || skip.has(key ?? "")) return;
|
|
407
|
+
if (typeof current === "string") {
|
|
408
|
+
const normalized = normalizeWhitespace(current);
|
|
409
|
+
if (normalized && !looksLikeOpaqueId(normalized)) values.push(normalized);
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (Array.isArray(current)) {
|
|
413
|
+
for (const item of current) visit(item);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
if (!current || typeof current !== "object") return;
|
|
417
|
+
for (const [childKey, child] of Object.entries(current)) {
|
|
418
|
+
visit(child, childKey);
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
visit(value);
|
|
422
|
+
return normalizeWhitespace(values.join("\n")).slice(0, maxChars);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export function normalizeWhitespace(value: string): string {
|
|
426
|
+
return value
|
|
427
|
+
.replace(/\r\n?/g, "\n")
|
|
428
|
+
.replace(/[\t\f\v ]+/g, " ")
|
|
429
|
+
.replace(/ *\n */g, "\n")
|
|
430
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
431
|
+
.trim();
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function stableJson(value: unknown): string {
|
|
435
|
+
if (Array.isArray(value)) return `[${value.map(stableJson).join(",")}]`;
|
|
436
|
+
if (value && typeof value === "object") {
|
|
437
|
+
return `{${Object.entries(value as Record<string, unknown>)
|
|
438
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
439
|
+
.map(([key, child]) => `${JSON.stringify(key)}:${stableJson(child)}`)
|
|
440
|
+
.join(",")}}`;
|
|
441
|
+
}
|
|
442
|
+
return JSON.stringify(value) ?? "null";
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function canonicalUnordered<T, U>(
|
|
446
|
+
values: readonly T[],
|
|
447
|
+
canonicalize: (value: T) => U,
|
|
448
|
+
): U[] {
|
|
449
|
+
return values
|
|
450
|
+
.map(canonicalize)
|
|
451
|
+
.sort((left, right) =>
|
|
452
|
+
stableJson(left) < stableJson(right)
|
|
453
|
+
? -1
|
|
454
|
+
: stableJson(left) > stableJson(right)
|
|
455
|
+
? 1
|
|
456
|
+
: 0,
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function withoutVolatileCaptureMetadata(
|
|
461
|
+
metadata: Record<string, unknown>,
|
|
462
|
+
): Record<string, unknown> {
|
|
463
|
+
const { capturedAt: _capturedAt, ...stableMetadata } = metadata;
|
|
464
|
+
return stableMetadata;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function required(value: string, label: string): string {
|
|
468
|
+
const normalized = value.trim();
|
|
469
|
+
if (!normalized) throw new Error(`${label} is required.`);
|
|
470
|
+
return normalized;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function looksLikeOpaqueId(value: string): boolean {
|
|
474
|
+
return value.length > 30 && /^[A-Za-z0-9_-]+$/.test(value);
|
|
475
|
+
}
|