@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,248 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
import { ssrfSafeFetch } from "@agent-native/core/extensions/url-safety";
|
|
4
|
+
import {
|
|
5
|
+
extractDominantColors,
|
|
6
|
+
fingerprintMedia,
|
|
7
|
+
readBoundedResponseBytes,
|
|
8
|
+
} from "@agent-native/core/ingestion";
|
|
9
|
+
import {
|
|
10
|
+
putPrivateBlob as corePutPrivateBlob,
|
|
11
|
+
readPrivateBlob as coreReadPrivateBlob,
|
|
12
|
+
type PrivateBlobHandle,
|
|
13
|
+
} from "@agent-native/core/private-blob";
|
|
14
|
+
|
|
15
|
+
import type { ContextMediaInput } from "../types.js";
|
|
16
|
+
import type { ContextConnectorExecutionContext } from "./types.js";
|
|
17
|
+
|
|
18
|
+
const PRIVATE_BLOB_REF_PREFIX = "creative-context-blob:v1:";
|
|
19
|
+
const MAX_REMOTE_ARTIFACT_BYTES = 20 * 1024 * 1024;
|
|
20
|
+
|
|
21
|
+
export async function storePrivateArtifact(input: {
|
|
22
|
+
data: Uint8Array;
|
|
23
|
+
filename: string;
|
|
24
|
+
mimeType?: string;
|
|
25
|
+
context: ContextConnectorExecutionContext;
|
|
26
|
+
metadata?: Record<string, string | number | boolean | null | undefined>;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
handle: PrivateBlobHandle;
|
|
29
|
+
reference: string;
|
|
30
|
+
contentHash: string;
|
|
31
|
+
palette: string[];
|
|
32
|
+
}> {
|
|
33
|
+
const put = input.context.putPrivateBlob ?? corePutPrivateBlob;
|
|
34
|
+
const fingerprint = fingerprintMedia(input.data, input.mimeType);
|
|
35
|
+
const ownerScope = createHash("sha256")
|
|
36
|
+
.update(
|
|
37
|
+
JSON.stringify({
|
|
38
|
+
appId: input.context.appId,
|
|
39
|
+
ownerEmail: input.context.ownerEmail ?? null,
|
|
40
|
+
}),
|
|
41
|
+
)
|
|
42
|
+
.digest("hex")
|
|
43
|
+
.slice(0, 24);
|
|
44
|
+
const handle = await put({
|
|
45
|
+
data: input.data,
|
|
46
|
+
key: `creative-context/${ownerScope}/${fingerprint.sha256}`,
|
|
47
|
+
filename: input.filename,
|
|
48
|
+
mimeType: input.mimeType,
|
|
49
|
+
ownerEmail: input.context.ownerEmail,
|
|
50
|
+
metadata: {
|
|
51
|
+
...input.metadata,
|
|
52
|
+
sha256: fingerprint.sha256,
|
|
53
|
+
byteLength: fingerprint.byteLength,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
if (!handle) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
"Private blob storage is required for creative context artifacts.",
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
const palette = input.mimeType?.startsWith("image/")
|
|
62
|
+
? await extractDominantColors(input.data).catch(() => [])
|
|
63
|
+
: [];
|
|
64
|
+
return {
|
|
65
|
+
handle,
|
|
66
|
+
reference: serializePrivateBlobHandle(handle),
|
|
67
|
+
contentHash: fingerprint.sha256,
|
|
68
|
+
palette,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function rehostRemoteMedia(input: {
|
|
73
|
+
url: string;
|
|
74
|
+
provenanceUrl?: string;
|
|
75
|
+
filename: string;
|
|
76
|
+
kind: ContextMediaInput["kind"];
|
|
77
|
+
mimeType?: string;
|
|
78
|
+
context: ContextConnectorExecutionContext;
|
|
79
|
+
metadata?: Record<string, unknown>;
|
|
80
|
+
}): Promise<ContextMediaInput> {
|
|
81
|
+
const remote = await fetchRemoteArtifact(input.url, input.context);
|
|
82
|
+
const mimeType = input.mimeType ?? remote.mimeType;
|
|
83
|
+
const data = sanitizeRemoteArtifact({
|
|
84
|
+
data: remote.data,
|
|
85
|
+
mimeType,
|
|
86
|
+
filename: input.filename,
|
|
87
|
+
});
|
|
88
|
+
const stored = await storePrivateArtifact({
|
|
89
|
+
data,
|
|
90
|
+
filename: input.filename,
|
|
91
|
+
mimeType,
|
|
92
|
+
context: input.context,
|
|
93
|
+
metadata: { kind: input.kind, source: "creative-context-import" },
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
kind: input.kind,
|
|
97
|
+
...(mimeType ? { mimeType } : {}),
|
|
98
|
+
accessMode: "private",
|
|
99
|
+
storageKey: stored.reference,
|
|
100
|
+
provenanceUrl: sanitizeProvenanceUrl(
|
|
101
|
+
input.provenanceUrl ?? remote.finalUrl,
|
|
102
|
+
),
|
|
103
|
+
contentHash: stored.contentHash,
|
|
104
|
+
...(stored.palette.length > 0 ? { palette: stored.palette } : {}),
|
|
105
|
+
captionStatus: input.kind === "image" ? "pending" : "not-needed",
|
|
106
|
+
metadata: input.metadata,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export async function fetchRemoteArtifact(
|
|
111
|
+
url: string,
|
|
112
|
+
context: ContextConnectorExecutionContext,
|
|
113
|
+
): Promise<{ data: Uint8Array; mimeType?: string; finalUrl: string }> {
|
|
114
|
+
const response = await ssrfSafeFetch(
|
|
115
|
+
url,
|
|
116
|
+
{ signal: context.signal },
|
|
117
|
+
{ maxRedirects: 5 },
|
|
118
|
+
);
|
|
119
|
+
if (!response.ok) {
|
|
120
|
+
throw new Error(`Media fetch failed (${response.status}).`);
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
data: await readBoundedResponseBytes(response, MAX_REMOTE_ARTIFACT_BYTES),
|
|
124
|
+
mimeType: response.headers.get("content-type") ?? undefined,
|
|
125
|
+
finalUrl: sanitizeProvenanceUrl(response.url || url),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function sanitizeProvenanceUrl(value: string): string {
|
|
130
|
+
try {
|
|
131
|
+
const url = new URL(value);
|
|
132
|
+
return `${url.origin}${url.pathname}`;
|
|
133
|
+
} catch {
|
|
134
|
+
return "redacted-source";
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function sanitizeRemoteArtifact(input: {
|
|
139
|
+
data: Uint8Array;
|
|
140
|
+
mimeType?: string;
|
|
141
|
+
filename?: string;
|
|
142
|
+
}): Uint8Array {
|
|
143
|
+
const mimeType = input.mimeType?.split(";")[0]?.trim().toLowerCase();
|
|
144
|
+
const prefix = new TextDecoder().decode(input.data.slice(0, 512));
|
|
145
|
+
const isSvg =
|
|
146
|
+
mimeType === "image/svg+xml" ||
|
|
147
|
+
((!mimeType ||
|
|
148
|
+
mimeType === "application/octet-stream" ||
|
|
149
|
+
mimeType === "text/xml" ||
|
|
150
|
+
mimeType === "application/xml") &&
|
|
151
|
+
input.filename?.toLowerCase().endsWith(".svg") === true) ||
|
|
152
|
+
/^\s*(?:<\?xml[^>]*>\s*)?<svg\b/i.test(prefix);
|
|
153
|
+
if (!isSvg) return input.data;
|
|
154
|
+
|
|
155
|
+
let source: string;
|
|
156
|
+
try {
|
|
157
|
+
source = new TextDecoder("utf-8", { fatal: true }).decode(input.data);
|
|
158
|
+
} catch {
|
|
159
|
+
throw new Error("Remote SVG is not valid UTF-8.");
|
|
160
|
+
}
|
|
161
|
+
source = source
|
|
162
|
+
.replace(/^\uFEFF/, "")
|
|
163
|
+
.replace(/<!--[\s\S]*?-->/g, "")
|
|
164
|
+
.trim();
|
|
165
|
+
if (!/<svg\b/i.test(source)) {
|
|
166
|
+
throw new Error("Remote SVG is missing an SVG root element.");
|
|
167
|
+
}
|
|
168
|
+
const forbidden = [
|
|
169
|
+
/<\s*(?:script|foreignObject|iframe|object|embed|link|audio|video|animate|set|discard)\b/i,
|
|
170
|
+
/<!\s*(?:DOCTYPE|ENTITY)\b/i,
|
|
171
|
+
/<\?xml-stylesheet\b/i,
|
|
172
|
+
/\son[a-z][a-z0-9:_-]*\s*=/i,
|
|
173
|
+
/\b(?:javascript|vbscript)\s*:/i,
|
|
174
|
+
/\b(?:expression|behavior|-moz-binding)\s*\(/i,
|
|
175
|
+
/@import\b/i,
|
|
176
|
+
];
|
|
177
|
+
if (forbidden.some((pattern) => pattern.test(source))) {
|
|
178
|
+
throw new Error("Remote SVG contains active content.");
|
|
179
|
+
}
|
|
180
|
+
for (const match of source.matchAll(
|
|
181
|
+
/(?:href|xlink:href)\s*=\s*(["'])(.*?)\1/gi,
|
|
182
|
+
)) {
|
|
183
|
+
const target = match[2]?.trim() ?? "";
|
|
184
|
+
if (
|
|
185
|
+
target &&
|
|
186
|
+
!target.startsWith("#") &&
|
|
187
|
+
!/^data:image\/(?:png|jpeg|gif|webp);base64,/i.test(target)
|
|
188
|
+
) {
|
|
189
|
+
throw new Error("Remote SVG contains an external reference.");
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
for (const match of source.matchAll(/url\(\s*(["']?)(.*?)\1\s*\)/gi)) {
|
|
193
|
+
const target = match[2]?.trim() ?? "";
|
|
194
|
+
if (
|
|
195
|
+
target &&
|
|
196
|
+
!target.startsWith("#") &&
|
|
197
|
+
!/^data:image\/(?:png|jpeg|gif|webp);base64,/i.test(target)
|
|
198
|
+
) {
|
|
199
|
+
throw new Error("Remote SVG contains an external reference.");
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return new TextEncoder().encode(source);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export async function readPrivateArtifact(
|
|
206
|
+
handle: PrivateBlobHandle,
|
|
207
|
+
context: ContextConnectorExecutionContext,
|
|
208
|
+
): Promise<Uint8Array> {
|
|
209
|
+
const read = context.readPrivateBlob ?? coreReadPrivateBlob;
|
|
210
|
+
return (await read(handle)).data;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export function serializePrivateBlobHandle(handle: PrivateBlobHandle): string {
|
|
214
|
+
return `${PRIVATE_BLOB_REF_PREFIX}${Buffer.from(JSON.stringify(handle), "utf8").toString("base64url")}`;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function parsePrivateBlobHandle(
|
|
218
|
+
value: unknown,
|
|
219
|
+
): PrivateBlobHandle | null {
|
|
220
|
+
if (value && typeof value === "object") {
|
|
221
|
+
return validateHandle(value as Record<string, unknown>);
|
|
222
|
+
}
|
|
223
|
+
if (typeof value !== "string" || !value.startsWith(PRIVATE_BLOB_REF_PREFIX)) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
try {
|
|
227
|
+
const parsed = JSON.parse(
|
|
228
|
+
Buffer.from(
|
|
229
|
+
value.slice(PRIVATE_BLOB_REF_PREFIX.length),
|
|
230
|
+
"base64url",
|
|
231
|
+
).toString("utf8"),
|
|
232
|
+
) as Record<string, unknown>;
|
|
233
|
+
return validateHandle(parsed);
|
|
234
|
+
} catch {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function validateHandle(
|
|
240
|
+
value: Record<string, unknown>,
|
|
241
|
+
): PrivateBlobHandle | null {
|
|
242
|
+
return typeof value.id === "string" &&
|
|
243
|
+
typeof value.provider === "string" &&
|
|
244
|
+
value.opaque === true &&
|
|
245
|
+
typeof value.encrypted === "boolean"
|
|
246
|
+
? (value as unknown as PrivateBlobHandle)
|
|
247
|
+
: null;
|
|
248
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ProviderApiRequestArgs,
|
|
3
|
+
ProviderApiRuntime,
|
|
4
|
+
} from "@agent-native/core/provider-api";
|
|
5
|
+
|
|
6
|
+
export class ContextConnectorQuotaError extends Error {
|
|
7
|
+
readonly provider: string;
|
|
8
|
+
readonly retryAt: string;
|
|
9
|
+
readonly retryAfterMs: number;
|
|
10
|
+
|
|
11
|
+
constructor(input: {
|
|
12
|
+
provider: string;
|
|
13
|
+
retryAt: string;
|
|
14
|
+
retryAfterMs?: number;
|
|
15
|
+
}) {
|
|
16
|
+
super(`Provider quota exhausted; retry after ${input.retryAt}.`);
|
|
17
|
+
this.name = "ContextConnectorQuotaError";
|
|
18
|
+
this.provider = input.provider;
|
|
19
|
+
this.retryAt = input.retryAt;
|
|
20
|
+
this.retryAfterMs = Math.max(0, input.retryAfterMs ?? 0);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function isContextConnectorQuotaError(
|
|
25
|
+
value: unknown,
|
|
26
|
+
): value is ContextConnectorQuotaError {
|
|
27
|
+
return value instanceof ContextConnectorQuotaError;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function executeConnectorProviderRequest(
|
|
31
|
+
runtime: Pick<ProviderApiRuntime, "executeRequest"> | undefined,
|
|
32
|
+
args: ProviderApiRequestArgs,
|
|
33
|
+
): Promise<unknown> {
|
|
34
|
+
if (!runtime) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`The ${args.provider} connector requires a provider API runtime.`,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
const raw = (await runtime.executeRequest(args)) as Record<string, unknown>;
|
|
40
|
+
const response = asRecord(raw.response);
|
|
41
|
+
if (!response) return raw;
|
|
42
|
+
const quota = asRecord(response.quota);
|
|
43
|
+
if (quota?.exhausted === true) {
|
|
44
|
+
throw new ContextConnectorQuotaError({
|
|
45
|
+
provider: stringValue(quota.providerId) ?? String(args.provider),
|
|
46
|
+
retryAt:
|
|
47
|
+
stringValue(quota.retryAt) ??
|
|
48
|
+
new Date(
|
|
49
|
+
Date.now() + Number(quota.retryAfterMs ?? 60_000),
|
|
50
|
+
).toISOString(),
|
|
51
|
+
retryAfterMs: Number(quota.retryAfterMs ?? 0),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (response.ok !== true) {
|
|
55
|
+
const status = response.status ?? "unknown";
|
|
56
|
+
const detail = response.text ?? response.json ?? response.statusText ?? "";
|
|
57
|
+
throw new Error(
|
|
58
|
+
`Provider request failed (${String(status)}): ${brief(detail)}`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
if (response.json !== undefined) return response.json;
|
|
62
|
+
if (typeof response.text === "string") {
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(response.text);
|
|
65
|
+
} catch {
|
|
66
|
+
return response.text;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function connectorConnectionId(
|
|
73
|
+
provider: string,
|
|
74
|
+
config: Record<string, unknown>,
|
|
75
|
+
resolve?: (
|
|
76
|
+
provider: string,
|
|
77
|
+
requestedConnectionId?: string,
|
|
78
|
+
) => Promise<string | undefined>,
|
|
79
|
+
): Promise<string | undefined> {
|
|
80
|
+
const requested = stringValue(config.connectionId);
|
|
81
|
+
const credentialMode = stringValue(config.credentialMode);
|
|
82
|
+
if (credentialMode === "admin-token" || config.useAdminToken === true) {
|
|
83
|
+
if (provider !== "figma") {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`${provider} creative-context imports require a per-user granted workspace connection; admin-token mode is not allowed.`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (requested) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
`${provider} connector config cannot combine connectionId with admin-token credentialMode.`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
if (!resolve) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
`${provider} creative-context imports require a workspace connection resolver.`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
const resolved = await resolve(provider, requested);
|
|
101
|
+
if (!resolved) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
`${provider} creative-context imports require a granted workspace connection.`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
return resolved;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function asRecord(value: unknown): Record<string, unknown> | null {
|
|
110
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
111
|
+
? (value as Record<string, unknown>)
|
|
112
|
+
: null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function stringValue(value: unknown): string | undefined {
|
|
116
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function stringArray(value: unknown): string[] {
|
|
120
|
+
return Array.isArray(value)
|
|
121
|
+
? value.map(stringValue).filter((item): item is string => Boolean(item))
|
|
122
|
+
: [];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function positiveLimit(
|
|
126
|
+
value: unknown,
|
|
127
|
+
fallback = 100,
|
|
128
|
+
max = 1_000,
|
|
129
|
+
): number {
|
|
130
|
+
const parsed = Number(value);
|
|
131
|
+
return Number.isInteger(parsed) && parsed > 0
|
|
132
|
+
? Math.min(parsed, max)
|
|
133
|
+
: fallback;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function cursorOffset(cursor: string | null | undefined): number {
|
|
137
|
+
const parsed = Number(cursor ?? 0);
|
|
138
|
+
return Number.isInteger(parsed) && parsed >= 0 ? parsed : 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function brief(value: unknown): string {
|
|
142
|
+
const text = typeof value === "string" ? value : JSON.stringify(value);
|
|
143
|
+
return (text ?? "").slice(0, 500);
|
|
144
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asRecord,
|
|
3
|
+
connectorConnectionId,
|
|
4
|
+
executeConnectorProviderRequest,
|
|
5
|
+
positiveLimit,
|
|
6
|
+
stringValue,
|
|
7
|
+
} from "./provider-response.js";
|
|
8
|
+
import type { ContextConnectorExecutionContext } from "./types.js";
|
|
9
|
+
|
|
10
|
+
export type ContextRootRecommendationProvider =
|
|
11
|
+
| "notion"
|
|
12
|
+
| "google-slides"
|
|
13
|
+
| "figma";
|
|
14
|
+
|
|
15
|
+
export interface ContextRootRecommendation {
|
|
16
|
+
externalId: string;
|
|
17
|
+
provider: ContextRootRecommendationProvider;
|
|
18
|
+
kind: "page" | "presentation" | "file";
|
|
19
|
+
title: string;
|
|
20
|
+
canonicalUrl?: string;
|
|
21
|
+
sourceModifiedAt?: string;
|
|
22
|
+
containerRef?: string;
|
|
23
|
+
metadata?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function recommendContextRoots(
|
|
27
|
+
input: {
|
|
28
|
+
provider: ContextRootRecommendationProvider;
|
|
29
|
+
connectionId?: string;
|
|
30
|
+
limit?: number;
|
|
31
|
+
figmaProjectId?: string;
|
|
32
|
+
figmaTeamId?: string;
|
|
33
|
+
},
|
|
34
|
+
context: ContextConnectorExecutionContext,
|
|
35
|
+
): Promise<{
|
|
36
|
+
recommendations: ContextRootRecommendation[];
|
|
37
|
+
persisted: false;
|
|
38
|
+
requiresExplicitBoundary: true;
|
|
39
|
+
unavailableReason?: string;
|
|
40
|
+
}> {
|
|
41
|
+
const limit = positiveLimit(input.limit, 15, 50);
|
|
42
|
+
const config = input.connectionId ? { connectionId: input.connectionId } : {};
|
|
43
|
+
if (input.provider === "notion") {
|
|
44
|
+
const connectionId = await connectorConnectionId(
|
|
45
|
+
"notion",
|
|
46
|
+
config,
|
|
47
|
+
context.resolveConnection,
|
|
48
|
+
);
|
|
49
|
+
const payload = asRecord(
|
|
50
|
+
await executeConnectorProviderRequest(context.providerApi, {
|
|
51
|
+
provider: "notion",
|
|
52
|
+
method: "POST",
|
|
53
|
+
path: "/search",
|
|
54
|
+
body: {
|
|
55
|
+
filter: { property: "object", value: "page" },
|
|
56
|
+
sort: { direction: "descending", timestamp: "last_edited_time" },
|
|
57
|
+
page_size: limit,
|
|
58
|
+
},
|
|
59
|
+
connectionId,
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
const recommendations = (
|
|
63
|
+
Array.isArray(payload?.results) ? payload.results : []
|
|
64
|
+
).flatMap((value) => {
|
|
65
|
+
const page = asRecord(value);
|
|
66
|
+
const id = stringValue(page?.id);
|
|
67
|
+
if (!id) return [];
|
|
68
|
+
return [
|
|
69
|
+
{
|
|
70
|
+
externalId: id,
|
|
71
|
+
provider: "notion" as const,
|
|
72
|
+
kind: "page" as const,
|
|
73
|
+
title: page
|
|
74
|
+
? (notionRecommendationTitle(page) ?? "Notion page")
|
|
75
|
+
: "Notion page",
|
|
76
|
+
...(stringValue(page?.url)
|
|
77
|
+
? { canonicalUrl: stringValue(page?.url) }
|
|
78
|
+
: {}),
|
|
79
|
+
...(stringValue(page?.last_edited_time)
|
|
80
|
+
? { sourceModifiedAt: stringValue(page?.last_edited_time) }
|
|
81
|
+
: {}),
|
|
82
|
+
metadata: { recommendationOnly: true },
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
});
|
|
86
|
+
return recommendationResult(recommendations.slice(0, limit));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (input.provider === "google-slides") {
|
|
90
|
+
const connectionId = await connectorConnectionId(
|
|
91
|
+
"google_drive",
|
|
92
|
+
config,
|
|
93
|
+
context.resolveConnection,
|
|
94
|
+
);
|
|
95
|
+
const payload = asRecord(
|
|
96
|
+
await executeConnectorProviderRequest(context.providerApi, {
|
|
97
|
+
provider: "google_drive",
|
|
98
|
+
method: "GET",
|
|
99
|
+
path: "/files",
|
|
100
|
+
query: {
|
|
101
|
+
q: "mimeType = 'application/vnd.google-apps.presentation' and trashed = false",
|
|
102
|
+
pageSize: limit,
|
|
103
|
+
orderBy: "modifiedTime desc",
|
|
104
|
+
fields:
|
|
105
|
+
"files(id,name,modifiedTime,webViewLink,parents,driveId,shared,ownedByMe)",
|
|
106
|
+
},
|
|
107
|
+
connectionId,
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
110
|
+
const recommendations = (
|
|
111
|
+
Array.isArray(payload?.files) ? payload.files : []
|
|
112
|
+
).flatMap((value) => {
|
|
113
|
+
const file = asRecord(value);
|
|
114
|
+
const id = stringValue(file?.id);
|
|
115
|
+
if (!id) return [];
|
|
116
|
+
return [
|
|
117
|
+
{
|
|
118
|
+
externalId: id,
|
|
119
|
+
provider: "google-slides" as const,
|
|
120
|
+
kind: "presentation" as const,
|
|
121
|
+
title: stringValue(file?.name) ?? id,
|
|
122
|
+
canonicalUrl:
|
|
123
|
+
stringValue(file?.webViewLink) ??
|
|
124
|
+
`https://docs.google.com/presentation/d/${encodeURIComponent(id)}/edit`,
|
|
125
|
+
...(stringValue(file?.modifiedTime)
|
|
126
|
+
? { sourceModifiedAt: stringValue(file?.modifiedTime) }
|
|
127
|
+
: {}),
|
|
128
|
+
...(stringValue(file?.driveId)
|
|
129
|
+
? { containerRef: `shared-drive:${stringValue(file?.driveId)}` }
|
|
130
|
+
: {}),
|
|
131
|
+
metadata: {
|
|
132
|
+
recommendationOnly: true,
|
|
133
|
+
shared: file?.shared === true,
|
|
134
|
+
ownedByMe: file?.ownedByMe === true,
|
|
135
|
+
...(Array.isArray(file?.parents) ? { parents: file.parents } : {}),
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
});
|
|
140
|
+
return recommendationResult(recommendations.slice(0, limit));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const connectionId = await connectorConnectionId(
|
|
144
|
+
"figma",
|
|
145
|
+
config,
|
|
146
|
+
context.resolveConnection,
|
|
147
|
+
);
|
|
148
|
+
const projectIds = new Set<string>();
|
|
149
|
+
if (input.figmaProjectId?.trim()) projectIds.add(input.figmaProjectId.trim());
|
|
150
|
+
if (input.figmaTeamId?.trim()) {
|
|
151
|
+
const projects = asRecord(
|
|
152
|
+
await executeConnectorProviderRequest(context.providerApi, {
|
|
153
|
+
provider: "figma",
|
|
154
|
+
method: "GET",
|
|
155
|
+
path: `/teams/${encodeURIComponent(input.figmaTeamId.trim())}/projects`,
|
|
156
|
+
connectionId,
|
|
157
|
+
}),
|
|
158
|
+
);
|
|
159
|
+
for (const value of Array.isArray(projects?.projects)
|
|
160
|
+
? projects.projects
|
|
161
|
+
: []) {
|
|
162
|
+
const id = stringValue(asRecord(value)?.id);
|
|
163
|
+
if (id) projectIds.add(id);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (projectIds.size === 0) {
|
|
167
|
+
return {
|
|
168
|
+
...recommendationResult([]),
|
|
169
|
+
unavailableReason:
|
|
170
|
+
"Figma has no global recent-files API. Choose a team or project before requesting file recommendations.",
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
const recommendations: ContextRootRecommendation[] = [];
|
|
174
|
+
for (const projectId of projectIds) {
|
|
175
|
+
if (recommendations.length >= limit) break;
|
|
176
|
+
const payload = asRecord(
|
|
177
|
+
await executeConnectorProviderRequest(context.providerApi, {
|
|
178
|
+
provider: "figma",
|
|
179
|
+
method: "GET",
|
|
180
|
+
path: `/projects/${encodeURIComponent(projectId)}/files`,
|
|
181
|
+
connectionId,
|
|
182
|
+
}),
|
|
183
|
+
);
|
|
184
|
+
for (const value of Array.isArray(payload?.files) ? payload.files : []) {
|
|
185
|
+
const file = asRecord(value);
|
|
186
|
+
const key = stringValue(file?.key);
|
|
187
|
+
if (!key) continue;
|
|
188
|
+
recommendations.push({
|
|
189
|
+
externalId: key,
|
|
190
|
+
provider: "figma",
|
|
191
|
+
kind: "file",
|
|
192
|
+
title: stringValue(file?.name) ?? key,
|
|
193
|
+
canonicalUrl: `https://www.figma.com/design/${encodeURIComponent(key)}`,
|
|
194
|
+
...(stringValue(file?.last_modified)
|
|
195
|
+
? { sourceModifiedAt: stringValue(file?.last_modified) }
|
|
196
|
+
: {}),
|
|
197
|
+
containerRef: `project:${projectId}`,
|
|
198
|
+
metadata: { recommendationOnly: true, projectId },
|
|
199
|
+
});
|
|
200
|
+
if (recommendations.length >= limit) break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
recommendations.sort(
|
|
204
|
+
(left, right) =>
|
|
205
|
+
timestamp(right.sourceModifiedAt) - timestamp(left.sourceModifiedAt),
|
|
206
|
+
);
|
|
207
|
+
return recommendationResult(recommendations.slice(0, limit));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function recommendationResult(recommendations: ContextRootRecommendation[]) {
|
|
211
|
+
return {
|
|
212
|
+
recommendations,
|
|
213
|
+
persisted: false as const,
|
|
214
|
+
requiresExplicitBoundary: true as const,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function notionRecommendationTitle(
|
|
219
|
+
page: Record<string, unknown>,
|
|
220
|
+
): string | undefined {
|
|
221
|
+
const properties = asRecord(page.properties);
|
|
222
|
+
for (const value of Object.values(properties ?? {})) {
|
|
223
|
+
const property = asRecord(value);
|
|
224
|
+
if (!Array.isArray(property?.title)) continue;
|
|
225
|
+
const title = property.title
|
|
226
|
+
.map((entry) => stringValue(asRecord(entry)?.plain_text) ?? "")
|
|
227
|
+
.join("")
|
|
228
|
+
.trim();
|
|
229
|
+
if (title) return title;
|
|
230
|
+
}
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function timestamp(value: string | undefined): number {
|
|
235
|
+
const parsed = value ? Date.parse(value) : Number.NaN;
|
|
236
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
237
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ContextImportConnector,
|
|
3
|
+
ContextImportConnectorSummary,
|
|
4
|
+
ContextConnectorKind,
|
|
5
|
+
} from "./types.js";
|
|
6
|
+
|
|
7
|
+
export class ContextImportConnectorRegistry {
|
|
8
|
+
readonly #connectors = new Map<
|
|
9
|
+
ContextConnectorKind,
|
|
10
|
+
ContextImportConnector
|
|
11
|
+
>();
|
|
12
|
+
|
|
13
|
+
constructor(connectors: readonly ContextImportConnector[] = []) {
|
|
14
|
+
for (const connector of connectors) this.register(connector);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
register(connector: ContextImportConnector): this {
|
|
18
|
+
if (this.#connectors.has(connector.kind)) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
`Context connector ${connector.kind} is already registered.`,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
this.#connectors.set(connector.kind, connector);
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get(kind: string): ContextImportConnector {
|
|
28
|
+
const connector = this.#connectors.get(kind as ContextConnectorKind);
|
|
29
|
+
if (!connector) {
|
|
30
|
+
throw new Error(`Unknown context connector ${kind}.`);
|
|
31
|
+
}
|
|
32
|
+
return connector;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
has(kind: string): boolean {
|
|
36
|
+
return this.#connectors.has(kind as ContextConnectorKind);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
list(): ContextImportConnectorSummary[] {
|
|
40
|
+
return [...this.#connectors.values()]
|
|
41
|
+
.map((connector) => ({
|
|
42
|
+
kind: connector.kind,
|
|
43
|
+
label: connector.label,
|
|
44
|
+
supportsIncremental: connector.supportsIncremental,
|
|
45
|
+
}))
|
|
46
|
+
.sort((a, b) => a.label.localeCompare(b.label));
|
|
47
|
+
}
|
|
48
|
+
}
|