@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,406 @@
|
|
|
1
|
+
import {
|
|
2
|
+
nativeCreativeArtifactFromMetadata,
|
|
3
|
+
type NativeCreativeArtifact,
|
|
4
|
+
} from "./native-artifact.js";
|
|
5
|
+
import type { ContextDetail } from "./types.js";
|
|
6
|
+
|
|
7
|
+
const MAX_REASSEMBLY_DEPTH = 16;
|
|
8
|
+
const MAX_REASSEMBLED_BYTES = 64 * 1024 * 1024;
|
|
9
|
+
const SAFE_MEDIA_ROUTE = "/_agent-native/creative-context/media?";
|
|
10
|
+
const ALLOWED_TAGS = new Set([
|
|
11
|
+
"html",
|
|
12
|
+
"head",
|
|
13
|
+
"meta",
|
|
14
|
+
"style",
|
|
15
|
+
"body",
|
|
16
|
+
"div",
|
|
17
|
+
"p",
|
|
18
|
+
"span",
|
|
19
|
+
"img",
|
|
20
|
+
"table",
|
|
21
|
+
"thead",
|
|
22
|
+
"tbody",
|
|
23
|
+
"tfoot",
|
|
24
|
+
"tr",
|
|
25
|
+
"td",
|
|
26
|
+
"th",
|
|
27
|
+
"br",
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
export interface NativeArtifactEvidence {
|
|
31
|
+
itemId: string;
|
|
32
|
+
itemVersionId: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ReassembledNativeArtifact {
|
|
36
|
+
html: string;
|
|
37
|
+
artifact: NativeCreativeArtifact;
|
|
38
|
+
evidence: NativeArtifactEvidence[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function reassembleNativeCreativeArtifact(input: {
|
|
42
|
+
root: ContextDetail;
|
|
43
|
+
app: NativeCreativeArtifact["app"];
|
|
44
|
+
format: NativeCreativeArtifact["format"];
|
|
45
|
+
resolveChild: (input: {
|
|
46
|
+
sourceId: string;
|
|
47
|
+
externalId: string;
|
|
48
|
+
itemId?: string;
|
|
49
|
+
itemVersionId?: string;
|
|
50
|
+
sourceVersion?: string;
|
|
51
|
+
}) => Promise<ContextDetail | null>;
|
|
52
|
+
}): Promise<ReassembledNativeArtifact> {
|
|
53
|
+
const evidence = new Map<string, NativeArtifactEvidence>();
|
|
54
|
+
const active = new Set<string>();
|
|
55
|
+
const headResources = new Set<string>();
|
|
56
|
+
|
|
57
|
+
const visit = async (
|
|
58
|
+
detail: ContextDetail,
|
|
59
|
+
depth: number,
|
|
60
|
+
): Promise<{ html: string; artifact: NativeCreativeArtifact }> => {
|
|
61
|
+
if (depth > MAX_REASSEMBLY_DEPTH) {
|
|
62
|
+
throw new Error("Native creative artifact hierarchy is too deep.");
|
|
63
|
+
}
|
|
64
|
+
const artifact = nativeCreativeArtifactFromMetadata(
|
|
65
|
+
detail.version.metadata,
|
|
66
|
+
);
|
|
67
|
+
if (
|
|
68
|
+
!artifact ||
|
|
69
|
+
artifact.app !== input.app ||
|
|
70
|
+
artifact.format !== input.format
|
|
71
|
+
) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
`Creative context item ${detail.item.id} is not a ${input.format} native artifact.`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (
|
|
77
|
+
detail.item.mimeType !== "text/html" ||
|
|
78
|
+
!isTrustedCompilerItem(detail)
|
|
79
|
+
) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
`Creative context item ${detail.item.id} was not produced by a trusted native artifact compiler.`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
validateCompiledNativeHtml(detail.version.content, artifact);
|
|
85
|
+
const evidenceKey = `${detail.item.id}:${detail.version.id}`;
|
|
86
|
+
evidence.set(evidenceKey, {
|
|
87
|
+
itemId: detail.item.id,
|
|
88
|
+
itemVersionId: detail.version.id,
|
|
89
|
+
});
|
|
90
|
+
if (active.has(evidenceKey)) {
|
|
91
|
+
throw new Error("Native creative artifact hierarchy contains a cycle.");
|
|
92
|
+
}
|
|
93
|
+
if (!artifact.manifest) {
|
|
94
|
+
collectHeadResources(detail.version.content, headResources);
|
|
95
|
+
return { html: detail.version.content, artifact };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
active.add(evidenceKey);
|
|
99
|
+
let html = detail.version.content;
|
|
100
|
+
for (const child of [...artifact.manifest.children].sort(
|
|
101
|
+
(left, right) => left.zOrder - right.zOrder,
|
|
102
|
+
)) {
|
|
103
|
+
const pinnedEdge = detail.edges.find(
|
|
104
|
+
(edge) =>
|
|
105
|
+
edge.relation === "contains-native-child" &&
|
|
106
|
+
edge.toExternalId === child.externalId,
|
|
107
|
+
);
|
|
108
|
+
if (
|
|
109
|
+
(pinnedEdge?.toItemId && !pinnedEdge.toItemVersionId) ||
|
|
110
|
+
(!pinnedEdge?.toItemId && pinnedEdge?.toItemVersionId)
|
|
111
|
+
) {
|
|
112
|
+
throw new Error(
|
|
113
|
+
`Native creative artifact child ${child.externalId} has an incomplete pinned version reference.`,
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
if (
|
|
117
|
+
!pinnedEdge?.toItemId &&
|
|
118
|
+
!pinnedEdge?.toItemVersionId &&
|
|
119
|
+
!detail.version.sourceVersion
|
|
120
|
+
) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
`Native creative artifact child ${child.externalId} has no immutable version reference.`,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
const childDetail = await input.resolveChild({
|
|
126
|
+
sourceId: detail.item.sourceId,
|
|
127
|
+
externalId: child.externalId,
|
|
128
|
+
...(pinnedEdge?.toItemId && pinnedEdge.toItemVersionId
|
|
129
|
+
? {
|
|
130
|
+
itemId: pinnedEdge.toItemId,
|
|
131
|
+
itemVersionId: pinnedEdge.toItemVersionId,
|
|
132
|
+
}
|
|
133
|
+
: { sourceVersion: detail.version.sourceVersion! }),
|
|
134
|
+
});
|
|
135
|
+
if (!childDetail) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
`Native creative artifact child ${child.externalId} is unavailable at the pinned source version.`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
const compiledChild = await visit(childDetail, depth + 1);
|
|
141
|
+
collectHeadResources(compiledChild.html, headResources);
|
|
142
|
+
html = fillGeneratedChildPlaceholder(
|
|
143
|
+
html,
|
|
144
|
+
child,
|
|
145
|
+
extractBody(compiledChild.html, compiledChild.artifact.format),
|
|
146
|
+
compiledChild.artifact.format,
|
|
147
|
+
);
|
|
148
|
+
assertReassembledSize(html);
|
|
149
|
+
}
|
|
150
|
+
active.delete(evidenceKey);
|
|
151
|
+
return { html, artifact };
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const result = await visit(input.root, 0);
|
|
155
|
+
collectHeadResources(result.html, headResources);
|
|
156
|
+
const html = insertHeadResources(result.html, headResources);
|
|
157
|
+
assertReassembledSize(html);
|
|
158
|
+
validateCompiledNativeHtml(html, {
|
|
159
|
+
...result.artifact,
|
|
160
|
+
childExternalIds: undefined,
|
|
161
|
+
manifest: undefined,
|
|
162
|
+
assetRefs: collectNativeAssetUrls(html),
|
|
163
|
+
});
|
|
164
|
+
return { html, artifact: result.artifact, evidence: [...evidence.values()] };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function validateCompiledNativeHtml(
|
|
168
|
+
html: string,
|
|
169
|
+
artifact: NativeCreativeArtifact,
|
|
170
|
+
): void {
|
|
171
|
+
if (
|
|
172
|
+
artifact.format === "design-html" &&
|
|
173
|
+
(!/^\s*<!doctype html>/i.test(html) || !/<html(?:\s|>)/i.test(html))
|
|
174
|
+
) {
|
|
175
|
+
throw new Error(
|
|
176
|
+
"Native creative artifact must be a complete HTML document.",
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
if (
|
|
180
|
+
/<\s*(?:script|iframe|object|embed|base|form|input|button|textarea|select|video|audio|source)\b/i.test(
|
|
181
|
+
html,
|
|
182
|
+
) ||
|
|
183
|
+
/\s(?:on[a-z]+|srcdoc|http-equiv)\s*=/i.test(html) ||
|
|
184
|
+
/(?:expression\s*\(|-moz-binding\s*:|behavior\s*:|@import\b)/i.test(html)
|
|
185
|
+
) {
|
|
186
|
+
throw new Error("Native creative artifact contains executable HTML/CSS.");
|
|
187
|
+
}
|
|
188
|
+
if (
|
|
189
|
+
/\s(?:x-|hx-|ng-|v-)[a-z0-9_:.@-]*\s*=/i.test(html) ||
|
|
190
|
+
/\s[@:][^\s=/>]+\s*=/.test(html)
|
|
191
|
+
) {
|
|
192
|
+
throw new Error(
|
|
193
|
+
"Native creative artifact contains executable framework attributes.",
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
if (
|
|
197
|
+
/\s(?:srcset|lowsrc|background|poster|cite|ping|longdesc|usemap|formaction|action|manifest|xlink:href)\s*=/i.test(
|
|
198
|
+
html,
|
|
199
|
+
) ||
|
|
200
|
+
/(?:-webkit-)?image-set\s*\(/i.test(html)
|
|
201
|
+
) {
|
|
202
|
+
throw new Error(
|
|
203
|
+
"Native creative artifact contains an unsupported URL-bearing construct.",
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
for (const match of html.matchAll(/<\/?\s*([a-z][a-z0-9-]*)\b/gi)) {
|
|
207
|
+
const tag = match[1]?.toLowerCase();
|
|
208
|
+
if (tag && !ALLOWED_TAGS.has(tag)) {
|
|
209
|
+
throw new Error(
|
|
210
|
+
`Native creative artifact contains unsupported <${tag}> markup.`,
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const urlAttributes = [
|
|
215
|
+
...html.matchAll(/\s(?:src|href)\s*=\s*(["'])(.*?)\1/gi),
|
|
216
|
+
];
|
|
217
|
+
const attributeCount = (html.match(/\s(?:src|href)\s*=/gi) ?? []).length;
|
|
218
|
+
if (urlAttributes.length !== attributeCount) {
|
|
219
|
+
throw new Error(
|
|
220
|
+
"Native creative artifact contains an invalid URL attribute.",
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
for (const match of urlAttributes) assertSafeMediaUrl(match[2] ?? "");
|
|
224
|
+
for (const match of html.matchAll(/url\(\s*(["']?)(.*?)\1\s*\)/gi)) {
|
|
225
|
+
assertSafeMediaUrl(match[2] ?? "");
|
|
226
|
+
}
|
|
227
|
+
for (const match of html.matchAll(
|
|
228
|
+
/<style(?:\s[^>]*)?>([\s\S]*?)<\/style>|\sstyle\s*=\s*(["'])(.*?)\2/gi,
|
|
229
|
+
)) {
|
|
230
|
+
const css = match[1] ?? match[3] ?? "";
|
|
231
|
+
if (/(?:https?:|data:|javascript:|(?:^|[\s("'])\/\/)/i.test(css)) {
|
|
232
|
+
throw new Error(
|
|
233
|
+
"Native creative artifact CSS contains an external or executable URL.",
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const usedAssetRefs = collectNativeAssetUrls(html);
|
|
239
|
+
const declaredAssetRefs = [...new Set(artifact.assetRefs ?? [])].map(
|
|
240
|
+
canonicalMediaUrl,
|
|
241
|
+
);
|
|
242
|
+
for (const assetRef of declaredAssetRefs) assertSafeMediaUrl(assetRef);
|
|
243
|
+
if (
|
|
244
|
+
usedAssetRefs.length !== declaredAssetRefs.length ||
|
|
245
|
+
usedAssetRefs.some((value) => !declaredAssetRefs.includes(value))
|
|
246
|
+
) {
|
|
247
|
+
throw new Error(
|
|
248
|
+
"Native creative artifact code does not match its declared asset references.",
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const placeholders = [
|
|
253
|
+
...html.matchAll(/data-creative-context-child\s*=\s*"([^"]+)"/g),
|
|
254
|
+
].map((match) => match[1]!);
|
|
255
|
+
const expected = (artifact.manifest?.children ?? []).map((child) =>
|
|
256
|
+
escapeAttribute(child.externalId),
|
|
257
|
+
);
|
|
258
|
+
const declaredChildren = artifact.childExternalIds ?? [];
|
|
259
|
+
const manifestChildren = (artifact.manifest?.children ?? []).map(
|
|
260
|
+
(child) => child.externalId,
|
|
261
|
+
);
|
|
262
|
+
if (
|
|
263
|
+
placeholders.length !== expected.length ||
|
|
264
|
+
placeholders.some((value, index) => value !== expected[index]) ||
|
|
265
|
+
new Set(placeholders).size !== placeholders.length
|
|
266
|
+
) {
|
|
267
|
+
throw new Error(
|
|
268
|
+
"Native creative artifact code does not match its child manifest.",
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
if (
|
|
272
|
+
declaredChildren.length !== manifestChildren.length ||
|
|
273
|
+
declaredChildren.some((value, index) => value !== manifestChildren[index])
|
|
274
|
+
) {
|
|
275
|
+
throw new Error(
|
|
276
|
+
"Native creative artifact child ids do not match its child manifest.",
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function assertSafeMediaUrl(value: string): void {
|
|
282
|
+
const canonical = canonicalMediaUrl(value);
|
|
283
|
+
if (!canonical.startsWith(SAFE_MEDIA_ROUTE)) {
|
|
284
|
+
throw new Error(
|
|
285
|
+
"Native creative artifact assets must use the private relative media route.",
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
const url = new URL(canonical, "https://creative-context.invalid");
|
|
289
|
+
if (
|
|
290
|
+
url.origin !== "https://creative-context.invalid" ||
|
|
291
|
+
url.pathname !== "/_agent-native/creative-context/media" ||
|
|
292
|
+
[...url.searchParams.keys()].length !== 1 ||
|
|
293
|
+
!/^ccm_[a-f0-9]{28}$/.test(url.searchParams.get("mediaId") ?? "")
|
|
294
|
+
) {
|
|
295
|
+
throw new Error("Native creative artifact contains an invalid media URL.");
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function isTrustedCompilerItem(detail: ContextDetail): boolean {
|
|
300
|
+
const compiler = detail.item.provenance.compiler;
|
|
301
|
+
return (
|
|
302
|
+
typeof compiler === "string" &&
|
|
303
|
+
(compiler === "@agent-native/core/ingestion:figma-node-to-html" ||
|
|
304
|
+
compiler === "@agent-native/creative-context:google-slides-native")
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function fillGeneratedChildPlaceholder(
|
|
309
|
+
html: string,
|
|
310
|
+
child: NonNullable<NativeCreativeArtifact["manifest"]>["children"][number],
|
|
311
|
+
childBody: string,
|
|
312
|
+
format: NativeCreativeArtifact["format"],
|
|
313
|
+
): string {
|
|
314
|
+
const externalId = child.externalId;
|
|
315
|
+
const marker = `data-creative-context-child="${escapeAttribute(externalId)}"`;
|
|
316
|
+
const markerIndex = html.indexOf(marker);
|
|
317
|
+
if (markerIndex < 0) {
|
|
318
|
+
throw new Error(
|
|
319
|
+
`Native creative artifact is missing child placeholder ${externalId}.`,
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
const openStart = html.lastIndexOf("<div", markerIndex);
|
|
323
|
+
const openEnd = html.indexOf(">", markerIndex);
|
|
324
|
+
const closeStart = html.indexOf("</div>", openEnd + 1);
|
|
325
|
+
if (
|
|
326
|
+
openStart < 0 ||
|
|
327
|
+
openEnd < 0 ||
|
|
328
|
+
closeStart < 0 ||
|
|
329
|
+
html.slice(openEnd + 1, closeStart).trim()
|
|
330
|
+
) {
|
|
331
|
+
throw new Error(
|
|
332
|
+
`Native creative artifact child placeholder ${externalId} is malformed.`,
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
const opening =
|
|
336
|
+
format === "slides-html"
|
|
337
|
+
? "<div>"
|
|
338
|
+
: `<div style="position:absolute;left:${child.bounds.x}px;top:${child.bounds.y}px;width:${child.bounds.width}px;height:${child.bounds.height}px;z-index:${child.zOrder}">`;
|
|
339
|
+
return `${html.slice(0, openStart)}${opening}\n${childBody}\n${html.slice(closeStart)}`;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function collectNativeAssetUrls(html: string): string[] {
|
|
343
|
+
const values = [
|
|
344
|
+
...[...html.matchAll(/\s(?:src|href)\s*=\s*(["'])(.*?)\1/gi)].map(
|
|
345
|
+
(match) => match[2] ?? "",
|
|
346
|
+
),
|
|
347
|
+
...[...html.matchAll(/url\(\s*(["']?)(.*?)\1\s*\)/gi)].map(
|
|
348
|
+
(match) => match[2] ?? "",
|
|
349
|
+
),
|
|
350
|
+
]
|
|
351
|
+
.filter(Boolean)
|
|
352
|
+
.map(canonicalMediaUrl);
|
|
353
|
+
return [...new Set(values)].sort();
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function canonicalMediaUrl(value: string): string {
|
|
357
|
+
return value.replace(/&/g, "&");
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function extractBody(
|
|
361
|
+
html: string,
|
|
362
|
+
format: NativeCreativeArtifact["format"],
|
|
363
|
+
): string {
|
|
364
|
+
const match = html.match(/<body(?:\s[^>]*)?>([\s\S]*?)<\/body>/i);
|
|
365
|
+
if (!match) {
|
|
366
|
+
if (format === "slides-html") return html;
|
|
367
|
+
throw new Error("Native creative artifact has no HTML body.");
|
|
368
|
+
}
|
|
369
|
+
return match[1] ?? "";
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function collectHeadResources(html: string, resources: Set<string>): void {
|
|
373
|
+
const match = html.match(/<head(?:\s[^>]*)?>([\s\S]*?)<\/head>/i);
|
|
374
|
+
if (!match?.[1]) return;
|
|
375
|
+
for (const entry of match[1].matchAll(
|
|
376
|
+
/<style(?:\s[^>]*)?>[\s\S]*?<\/style>|<link\s[^>]*rel=["']stylesheet["'][^>]*\/?>/gi,
|
|
377
|
+
)) {
|
|
378
|
+
if (entry[0]) resources.add(entry[0]);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function insertHeadResources(html: string, resources: Set<string>): string {
|
|
383
|
+
const closingHead = html.search(/<\/head>/i);
|
|
384
|
+
if (closingHead < 0) {
|
|
385
|
+
if (!resources.size) return html;
|
|
386
|
+
throw new Error("Native creative artifact has no HTML head.");
|
|
387
|
+
}
|
|
388
|
+
const missing = [...resources].filter((resource) => !html.includes(resource));
|
|
389
|
+
return missing.length
|
|
390
|
+
? `${html.slice(0, closingHead)}${missing.join("\n")}\n${html.slice(closingHead)}`
|
|
391
|
+
: html;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function assertReassembledSize(html: string): void {
|
|
395
|
+
if (Buffer.byteLength(html, "utf8") > MAX_REASSEMBLED_BYTES) {
|
|
396
|
+
throw new Error("Reassembled native creative artifact exceeds 64 MiB.");
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function escapeAttribute(value: string): string {
|
|
401
|
+
return value
|
|
402
|
+
.replace(/&/g, "&")
|
|
403
|
+
.replace(/"/g, """)
|
|
404
|
+
.replace(/</g, "<")
|
|
405
|
+
.replace(/>/g, ">");
|
|
406
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
const finiteNumber = z.number().finite();
|
|
4
|
+
const boundsSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
x: finiteNumber,
|
|
7
|
+
y: finiteNumber,
|
|
8
|
+
width: finiteNumber.nonnegative(),
|
|
9
|
+
height: finiteNumber.nonnegative(),
|
|
10
|
+
})
|
|
11
|
+
.strict();
|
|
12
|
+
const fidelityReasonSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
nodeId: z.string().min(1).max(256),
|
|
15
|
+
nodeName: z.string().max(500),
|
|
16
|
+
nodeType: z.string().max(100),
|
|
17
|
+
reasons: z.array(z.string().max(2_000)).max(50),
|
|
18
|
+
})
|
|
19
|
+
.strict();
|
|
20
|
+
const fidelityReportSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
exact: z.object({ count: z.number().int().nonnegative() }).strict(),
|
|
23
|
+
approximated: z
|
|
24
|
+
.object({
|
|
25
|
+
count: z.number().int().nonnegative(),
|
|
26
|
+
reasons: z.array(fidelityReasonSchema).max(1_000),
|
|
27
|
+
})
|
|
28
|
+
.strict(),
|
|
29
|
+
imageFallback: z
|
|
30
|
+
.object({
|
|
31
|
+
count: z.number().int().nonnegative(),
|
|
32
|
+
reasons: z.array(fidelityReasonSchema).max(1_000),
|
|
33
|
+
})
|
|
34
|
+
.strict(),
|
|
35
|
+
})
|
|
36
|
+
.strict();
|
|
37
|
+
const manifestChildSchema = z
|
|
38
|
+
.object({
|
|
39
|
+
externalId: z.string().min(1).max(1_000),
|
|
40
|
+
sourceNodeId: z.string().min(1).max(256),
|
|
41
|
+
bounds: boundsSchema,
|
|
42
|
+
transform: z
|
|
43
|
+
.tuple([
|
|
44
|
+
finiteNumber,
|
|
45
|
+
finiteNumber,
|
|
46
|
+
finiteNumber,
|
|
47
|
+
finiteNumber,
|
|
48
|
+
finiteNumber,
|
|
49
|
+
finiteNumber,
|
|
50
|
+
])
|
|
51
|
+
.optional(),
|
|
52
|
+
zOrder: z.number().int().nonnegative(),
|
|
53
|
+
})
|
|
54
|
+
.strict();
|
|
55
|
+
|
|
56
|
+
export const nativeCreativeArtifactSchema = z
|
|
57
|
+
.object({
|
|
58
|
+
schemaVersion: z.literal(1),
|
|
59
|
+
app: z.enum(["design", "slides"]),
|
|
60
|
+
format: z.enum(["design-html", "slides-html"]),
|
|
61
|
+
rootExternalId: z.string().min(1).max(1_000),
|
|
62
|
+
sourceBounds: boundsSchema.optional(),
|
|
63
|
+
childExternalIds: z
|
|
64
|
+
.array(z.string().min(1).max(1_000))
|
|
65
|
+
.max(2_000)
|
|
66
|
+
.optional(),
|
|
67
|
+
manifest: z
|
|
68
|
+
.object({
|
|
69
|
+
kind: z.literal("hierarchical-artboard"),
|
|
70
|
+
children: z.array(manifestChildSchema).min(1).max(2_000),
|
|
71
|
+
})
|
|
72
|
+
.strict()
|
|
73
|
+
.optional(),
|
|
74
|
+
fidelityReport: fidelityReportSchema,
|
|
75
|
+
assetRefs: z.array(z.string().min(1).max(2_000)).max(1_000).optional(),
|
|
76
|
+
})
|
|
77
|
+
.strict();
|
|
78
|
+
|
|
79
|
+
export type NativeCreativeArtifact = z.infer<
|
|
80
|
+
typeof nativeCreativeArtifactSchema
|
|
81
|
+
>;
|
|
82
|
+
export type NativeCreativeArtifactFidelityReport = z.infer<
|
|
83
|
+
typeof fidelityReportSchema
|
|
84
|
+
>;
|
|
85
|
+
|
|
86
|
+
export function parseNativeCreativeArtifact(
|
|
87
|
+
value: unknown,
|
|
88
|
+
): NativeCreativeArtifact {
|
|
89
|
+
return nativeCreativeArtifactSchema.parse(value);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function nativeCreativeArtifactFromMetadata(
|
|
93
|
+
metadata: unknown,
|
|
94
|
+
): NativeCreativeArtifact | null {
|
|
95
|
+
if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const result = nativeCreativeArtifactSchema.safeParse(
|
|
99
|
+
(metadata as Record<string, unknown>).nativeArtifact,
|
|
100
|
+
);
|
|
101
|
+
return result.success ? result.data : null;
|
|
102
|
+
}
|