@agent-native/core 0.106.3 → 0.107.1
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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +23 -0
- package/corpus/core/docs/content/integrations.mdx +597 -0
- package/corpus/core/docs/content/locales/ar-SA/mcp-clients.mdx +19 -1
- package/corpus/core/docs/content/locales/de-DE/mcp-clients.mdx +22 -1
- package/corpus/core/docs/content/locales/es-ES/mcp-clients.mdx +23 -1
- package/corpus/core/docs/content/locales/fr-FR/mcp-clients.mdx +23 -1
- package/corpus/core/docs/content/locales/hi-IN/mcp-clients.mdx +22 -1
- package/corpus/core/docs/content/locales/ja-JP/mcp-clients.mdx +21 -1
- package/corpus/core/docs/content/locales/ko-KR/mcp-clients.mdx +20 -1
- package/corpus/core/docs/content/locales/pt-BR/mcp-clients.mdx +22 -1
- package/corpus/core/docs/content/locales/zh-CN/mcp-clients.mdx +17 -1
- package/corpus/core/docs/content/locales/zh-TW/mcp-clients.mdx +17 -1
- package/corpus/core/docs/content/mcp-clients.mdx +51 -1
- package/corpus/core/docs/content/organizations-teams-permissions.mdx +413 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/production-agent.ts +19 -0
- package/corpus/core/src/agent/run-store.ts +98 -2
- package/corpus/core/src/client/AssistantChat.tsx +26 -1
- package/corpus/core/src/client/CommandMenu.tsx +5 -0
- package/corpus/core/src/client/active-run-state.ts +34 -0
- package/corpus/core/src/client/agent-chat-adapter.ts +4 -0
- package/corpus/core/src/client/chat/message-components.tsx +41 -0
- package/corpus/core/src/client/composer/TiptapComposer.tsx +45 -8
- package/corpus/core/src/client/integrations/IntegrationsPanel.tsx +30 -11
- package/corpus/core/src/client/resources/McpConnectionSuggestion.tsx +270 -0
- package/corpus/core/src/client/resources/McpIntegrationDialog.tsx +177 -40
- package/corpus/core/src/client/resources/mcp-integration-catalog.ts +478 -4
- package/corpus/core/src/client/resources/mcp-integration-logos.ts +108 -0
- package/corpus/core/src/client/sharing/ShareButton.tsx +30 -9
- package/corpus/core/src/client/use-agent-chat-home-handoff.ts +2 -2
- package/corpus/core/src/deploy/build.ts +32 -0
- package/corpus/core/src/extensions/html-shell.ts +33 -1
- package/corpus/core/src/ingestion/office.ts +1 -2
- package/corpus/core/src/ingestion/pptx.ts +2 -4
- package/corpus/core/src/localization/default-messages.ts +129 -1
- package/corpus/core/src/mcp/actions/call-mcp-tool.ts +1 -0
- package/corpus/core/src/secrets/register-framework-secrets.ts +28 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +29 -1
- package/corpus/core/src/server/index.ts +4 -0
- package/corpus/core/src/server/org-admin.ts +28 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +9 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/extensions/references/api.md +31 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +9 -0
- package/corpus/core/src/vite/client.ts +24 -0
- package/corpus/templates/analytics/.agents/skills/creative-context/SKILL.md +64 -0
- package/corpus/templates/analytics/.agents/skills/dashboard-management/SKILL.md +29 -21
- package/corpus/templates/analytics/AGENTS.md +13 -0
- package/corpus/templates/analytics/actions/clone-creative-context-dashboard.ts +86 -0
- package/corpus/templates/analytics/actions/dashboard-mutation-api.ts +1 -1
- package/corpus/templates/analytics/actions/update-dashboard.ts +6 -2
- package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +35 -7
- package/corpus/templates/analytics/app/components/layout/Layout.tsx +3 -3
- package/corpus/templates/analytics/app/i18n/zh-TW.ts +1 -0
- package/corpus/templates/analytics/app/i18n-data.ts +1 -0
- package/corpus/templates/analytics/app/pages/Ask.tsx +8 -4
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/SqlChartCard.tsx +11 -1
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/extension-slot.ts +11 -0
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +86 -0
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/types.ts +6 -0
- package/corpus/templates/analytics/app/routes/agent.tsx +7 -1
- package/corpus/templates/analytics/changelog/2026-07-17-dashboard-extension-boxes.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-17-library-now-flags-published-dashboards-with-newer-versions-a.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-17-resources-can-be-added-to-creative-context-from-their-action.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-17-you-can-add-exact-approved-artifact-versions-to-governed-cre.md +6 -0
- package/corpus/templates/analytics/package.json +1 -0
- package/corpus/templates/analytics/server/lib/agent-readable-resource-context.ts +8 -0
- package/corpus/templates/analytics/server/lib/native-creative-context.ts +158 -0
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +1 -0
- package/corpus/templates/analytics/server/plugins/creative-context.ts +10 -0
- package/corpus/templates/assets/.agents/skills/creative-context/SKILL.md +12 -3
- package/corpus/templates/assets/AGENTS.md +5 -0
- package/corpus/templates/assets/actions/clone-creative-context-asset.ts +74 -0
- package/corpus/templates/assets/app/hooks/use-navigation-state.ts +2 -1
- package/corpus/templates/assets/app/routes/brand-kits.$id.tsx +308 -178
- package/corpus/templates/assets/app/routes/library.tsx +5 -11
- package/corpus/templates/assets/changelog/2026-07-17-library-now-flags-published-assets-with-newer-versions-and-l.md +6 -0
- package/corpus/templates/assets/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/corpus/templates/assets/changelog/2026-07-17-you-can-add-exact-approved-artifact-versions-to-governed-cre.md +6 -0
- package/corpus/templates/assets/server/lib/native-creative-context.ts +198 -0
- package/corpus/templates/assets/server/plugins/creative-context.ts +4 -0
- package/corpus/templates/brain/actions/provider-api-request.ts +1 -0
- package/corpus/templates/brain/app/hooks/use-navigation-state.ts +6 -1
- package/corpus/templates/brain/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/corpus/templates/calendar/actions/provider-api-request.ts +1 -0
- package/corpus/templates/calendar/app/components/layout/AppLayout.tsx +1 -1
- package/corpus/templates/calendar/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/corpus/templates/chat/app/hooks/use-navigation-state.ts +4 -1
- package/corpus/templates/chat/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/corpus/templates/clips/actions/get-recording-insights.ts +7 -4
- package/corpus/templates/clips/actions/list-recordings.ts +48 -0
- package/corpus/templates/clips/actions/list-viewers.ts +2 -1
- package/corpus/templates/clips/app/components/editor/stitch-manager.tsx +3 -1
- package/corpus/templates/clips/app/components/library/library-layout.tsx +1 -1
- package/corpus/templates/clips/app/components/player/share-dialog.tsx +1 -3
- package/corpus/templates/clips/app/hooks/use-desktop-promo.ts +11 -6
- package/corpus/templates/clips/app/hooks/use-view-tracking.ts +6 -1
- package/corpus/templates/clips/app/lib/ffmpeg-export.ts +4 -2
- package/corpus/templates/clips/app/routes/share.$shareId.tsx +21 -3
- package/corpus/templates/clips/changelog/2026-07-17-dictation-keeps-sentence-spacing-and-no-longer-crashes-when-.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-17-shared-clips-now-preserve-editor-access-and-show-editor-insi.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-17-stitching-clips-no-longer-fails-when-editor-media-metadata-i.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/corpus/templates/clips/server/routes/api/public-recording.get.ts +14 -8
- package/corpus/templates/clips/shared/view-analytics.ts +4 -0
- package/corpus/templates/content/.agents/skills/creative-context/SKILL.md +12 -3
- package/corpus/templates/content/AGENTS.md +5 -0
- package/corpus/templates/content/actions/_content-space-access.ts +45 -2
- package/corpus/templates/content/actions/clone-creative-context-document.ts +61 -0
- package/corpus/templates/content/actions/create-content-database.ts +41 -7
- package/corpus/templates/content/actions/provider-api-request.ts +1 -0
- package/corpus/templates/content/app/components/editor/DocumentToolbar.tsx +21 -0
- package/corpus/templates/content/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/content/app/components/sidebar/DocumentTreeItem.tsx +29 -0
- package/corpus/templates/content/app/root.tsx +1 -10
- package/corpus/templates/content/changelog/2026-07-17-creating-a-database-now-completes-reliably-in-hosted-workspa.md +6 -0
- package/corpus/templates/content/changelog/2026-07-17-library-now-flags-published-documents-with-newer-versions-an.md +6 -0
- package/corpus/templates/content/changelog/2026-07-17-resources-can-be-added-to-creative-context-from-their-action.md +6 -0
- package/corpus/templates/content/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/corpus/templates/content/changelog/2026-07-17-you-can-add-exact-approved-artifact-versions-to-governed-cre.md +6 -0
- package/corpus/templates/content/parity/matrix.md +1 -1
- package/corpus/templates/content/parity/matrix.ts +1 -0
- package/corpus/templates/content/server/lib/native-creative-context.ts +191 -0
- package/corpus/templates/content/server/plugins/creative-context.ts +8 -1
- package/corpus/templates/design/.agents/skills/creative-context/SKILL.md +11 -3
- package/corpus/templates/design/AGENTS.md +5 -0
- package/corpus/templates/design/actions/clone-creative-context-design-native.ts +111 -0
- package/corpus/templates/design/actions/provider-api-request.ts +1 -0
- package/corpus/templates/design/app/pages/Index.tsx +44 -0
- package/corpus/templates/design/app/pages/design-editor/types.ts +1 -0
- package/corpus/templates/design/changelog/2026-07-17-library-now-flags-published-designs-with-newer-versions-and-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-17-resources-can-be-added-to-creative-context-from-their-action.md +6 -0
- package/corpus/templates/design/changelog/2026-07-17-you-can-add-exact-approved-artifact-versions-to-governed-cre.md +6 -0
- package/corpus/templates/design/server/lib/native-creative-context.ts +265 -0
- package/corpus/templates/design/server/plugins/creative-context.ts +8 -1
- package/corpus/templates/dispatch/actions/provider-api-request.ts +1 -0
- package/corpus/templates/dispatch/app/hooks/use-navigation-state.ts +4 -1
- package/corpus/templates/dispatch/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/corpus/templates/forms/app/components/layout/Layout.tsx +2 -4
- package/corpus/templates/forms/app/components/ui/popover.tsx +25 -1
- package/corpus/templates/forms/app/hooks/use-navigation-state.ts +6 -1
- package/corpus/templates/forms/app/pages/FormBuilderPage.tsx +13 -10
- package/corpus/templates/forms/app/root.tsx +6 -1
- package/corpus/templates/forms/changelog/2026-07-17-form-builder-popovers-stay-within-the-viewport.md +6 -0
- package/corpus/templates/forms/changelog/2026-07-17-form-editor-loading-matches-current-sidebar-free-layout.md +6 -0
- package/corpus/templates/forms/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/corpus/templates/mail/actions/provider-api-request.ts +1 -0
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +1 -1
- package/corpus/templates/mail/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +14 -3
- package/corpus/templates/plan/app/hooks/use-navigation-state.ts +8 -1
- package/corpus/templates/plan/app/root.tsx +0 -2
- package/corpus/templates/plan/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/corpus/templates/slides/.agents/skills/creative-context/SKILL.md +11 -3
- package/corpus/templates/slides/AGENTS.md +5 -0
- package/corpus/templates/slides/actions/clone-creative-context-deck.ts +96 -0
- package/corpus/templates/slides/actions/extract-pdf.ts +3 -2
- package/corpus/templates/slides/actions/import-file.ts +3 -2
- package/corpus/templates/slides/actions/provider-api-request.ts +1 -0
- package/corpus/templates/slides/app/components/deck/DeckCard.tsx +27 -0
- package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +21 -0
- package/corpus/templates/slides/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/slides/app/context/DeckContext.tsx +23 -23
- package/corpus/templates/slides/changelog/2026-07-17-duplicated-slides-now-stay-in-the-deck.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-17-library-now-flags-published-decks-with-newer-versions-and-le.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-17-pdf-and-powerpoint-imports-now-work-reliably-in-hosted-decks.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-17-resources-can-be-added-to-creative-context-from-their-action.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-17-you-can-add-exact-approved-artifact-versions-to-governed-cre.md +6 -0
- package/corpus/templates/slides/server/lib/native-creative-context.ts +288 -0
- package/corpus/templates/slides/server/plugins/creative-context.ts +4 -0
- package/corpus/templates/tasks/app/components/layout/Layout.tsx +2 -13
- package/corpus/templates/tasks/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it.md +6 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +13 -1
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-store.d.ts +17 -0
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +84 -2
- package/dist/agent/run-store.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +18 -3
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/CommandMenu.d.ts.map +1 -1
- package/dist/client/CommandMenu.js +4 -0
- package/dist/client/CommandMenu.js.map +1 -1
- package/dist/client/active-run-state.d.ts +7 -0
- package/dist/client/active-run-state.d.ts.map +1 -1
- package/dist/client/active-run-state.js +28 -0
- package/dist/client/active-run-state.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +4 -1
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +35 -1
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +7 -0
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +37 -8
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/integrations/IntegrationsPanel.d.ts.map +1 -1
- package/dist/client/integrations/IntegrationsPanel.js +3 -2
- package/dist/client/integrations/IntegrationsPanel.js.map +1 -1
- package/dist/client/resources/McpConnectionSuggestion.d.ts +9 -0
- package/dist/client/resources/McpConnectionSuggestion.d.ts.map +1 -0
- package/dist/client/resources/McpConnectionSuggestion.js +134 -0
- package/dist/client/resources/McpConnectionSuggestion.js.map +1 -0
- package/dist/client/resources/McpIntegrationDialog.d.ts +2 -1
- package/dist/client/resources/McpIntegrationDialog.d.ts.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.js +51 -21
- package/dist/client/resources/McpIntegrationDialog.js.map +1 -1
- package/dist/client/resources/mcp-integration-catalog.d.ts +15 -0
- package/dist/client/resources/mcp-integration-catalog.d.ts.map +1 -1
- package/dist/client/resources/mcp-integration-catalog.js +420 -4
- package/dist/client/resources/mcp-integration-catalog.js.map +1 -1
- package/dist/client/resources/mcp-integration-logos.d.ts +2 -0
- package/dist/client/resources/mcp-integration-logos.d.ts.map +1 -0
- package/dist/client/resources/mcp-integration-logos.js +109 -0
- package/dist/client/resources/mcp-integration-logos.js.map +1 -0
- package/dist/client/sharing/ShareButton.d.ts.map +1 -1
- package/dist/client/sharing/ShareButton.js +15 -12
- package/dist/client/sharing/ShareButton.js.map +1 -1
- package/dist/client/use-agent-chat-home-handoff.d.ts +1 -1
- package/dist/client/use-agent-chat-home-handoff.d.ts.map +1 -1
- package/dist/client/use-agent-chat-home-handoff.js +1 -1
- package/dist/client/use-agent-chat-home-handoff.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +23 -0
- package/dist/deploy/build.js.map +1 -1
- package/dist/extensions/html-shell.d.ts.map +1 -1
- package/dist/extensions/html-shell.js +33 -1
- package/dist/extensions/html-shell.js.map +1 -1
- package/dist/ingestion/office.d.ts.map +1 -1
- package/dist/ingestion/office.js +1 -2
- package/dist/ingestion/office.js.map +1 -1
- package/dist/ingestion/pptx.js +2 -4
- package/dist/ingestion/pptx.js.map +1 -1
- package/dist/localization/default-messages.d.ts +100 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +101 -1
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/mcp/actions/call-mcp-tool.js +1 -0
- package/dist/mcp/actions/call-mcp-tool.js.map +1 -1
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/observability/routes.d.ts +5 -5
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/secrets/register-framework-secrets.d.ts.map +1 -1
- package/dist/secrets/register-framework-secrets.js +25 -0
- package/dist/secrets/register-framework-secrets.js.map +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +23 -1
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/org-admin.d.ts +3 -0
- package/dist/server/org-admin.d.ts.map +1 -0
- package/dist/server/org-admin.js +24 -0
- package/dist/server/org-admin.js.map +1 -0
- package/dist/templates/chat/app/hooks/use-navigation-state.ts +4 -1
- package/dist/templates/chat/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/dist/templates/workspace-core/.agents/skills/extensions/SKILL.md +9 -0
- package/dist/templates/workspace-core/.agents/skills/extensions/references/api.md +31 -0
- package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +9 -0
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +20 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/integrations.mdx +597 -0
- package/docs/content/locales/ar-SA/mcp-clients.mdx +19 -1
- package/docs/content/locales/de-DE/mcp-clients.mdx +22 -1
- package/docs/content/locales/es-ES/mcp-clients.mdx +23 -1
- package/docs/content/locales/fr-FR/mcp-clients.mdx +23 -1
- package/docs/content/locales/hi-IN/mcp-clients.mdx +22 -1
- package/docs/content/locales/ja-JP/mcp-clients.mdx +21 -1
- package/docs/content/locales/ko-KR/mcp-clients.mdx +20 -1
- package/docs/content/locales/pt-BR/mcp-clients.mdx +22 -1
- package/docs/content/locales/zh-CN/mcp-clients.mdx +17 -1
- package/docs/content/locales/zh-TW/mcp-clients.mdx +17 -1
- package/docs/content/mcp-clients.mdx +51 -1
- package/docs/content/organizations-teams-permissions.mdx +413 -0
- package/package.json +1 -1
- package/src/templates/chat/app/hooks/use-navigation-state.ts +4 -1
- package/src/templates/chat/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +9 -0
- package/src/templates/workspace-core/.agents/skills/extensions/references/api.md +31 -0
- package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +9 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
import { defineAction } from "@agent-native/core";
|
|
4
|
+
import {
|
|
5
|
+
readPrivateBlob,
|
|
6
|
+
type PrivateBlobHandle,
|
|
7
|
+
} from "@agent-native/core/private-blob";
|
|
8
|
+
import {
|
|
9
|
+
getRequestOrgId,
|
|
10
|
+
getRequestUserEmail,
|
|
11
|
+
} from "@agent-native/core/server/request-context";
|
|
12
|
+
import { resolveNativeContextCloneReference } from "@agent-native/creative-context/server";
|
|
13
|
+
import { eq } from "drizzle-orm";
|
|
14
|
+
import { nanoid } from "nanoid";
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
|
|
17
|
+
import { getDb, schema } from "../server/db/index.js";
|
|
18
|
+
import { getDeckUrl } from "./_app-url.js";
|
|
19
|
+
|
|
20
|
+
export default defineAction({
|
|
21
|
+
description:
|
|
22
|
+
"Clone one exact governed Slides deck version without exposing its native payload.",
|
|
23
|
+
schema: z.object({
|
|
24
|
+
contextId: z.string(),
|
|
25
|
+
artifactKey: z.string(),
|
|
26
|
+
resourceId: z.string(),
|
|
27
|
+
expectedUpdatedAt: z.string().optional(),
|
|
28
|
+
title: z.string().optional(),
|
|
29
|
+
}),
|
|
30
|
+
publicAgent: { expose: true, readOnly: false, requiresAuth: true },
|
|
31
|
+
run: async (args) => {
|
|
32
|
+
const reference = await resolveNativeContextCloneReference({
|
|
33
|
+
appId: "slides",
|
|
34
|
+
resourceType: "deck",
|
|
35
|
+
resourceId: args.resourceId,
|
|
36
|
+
expectedUpdatedAt: args.expectedUpdatedAt,
|
|
37
|
+
contextId: args.contextId,
|
|
38
|
+
artifactKey: args.artifactKey,
|
|
39
|
+
});
|
|
40
|
+
const raw = await readPrivateBlob(
|
|
41
|
+
reference.cloneHandle as PrivateBlobHandle,
|
|
42
|
+
);
|
|
43
|
+
const data = Buffer.from(raw.data).toString("utf8");
|
|
44
|
+
const contentHash = createHash("sha256").update(data).digest("hex");
|
|
45
|
+
if (
|
|
46
|
+
raw.metadata?.appId !== "slides" ||
|
|
47
|
+
raw.metadata?.resourceType !== "deck" ||
|
|
48
|
+
raw.metadata?.resourceId !== args.resourceId ||
|
|
49
|
+
raw.metadata?.contentHash !== contentHash
|
|
50
|
+
)
|
|
51
|
+
throw new Error(
|
|
52
|
+
"Governed deck clone payload failed integrity verification.",
|
|
53
|
+
);
|
|
54
|
+
const deck = JSON.parse(data) as Record<string, unknown> & {
|
|
55
|
+
slides?: Array<Record<string, unknown>>;
|
|
56
|
+
title?: string;
|
|
57
|
+
designSystemId?: string;
|
|
58
|
+
};
|
|
59
|
+
const email = getRequestUserEmail();
|
|
60
|
+
if (!email) throw new Error("no authenticated user");
|
|
61
|
+
const id = `deck-${nanoid()}`;
|
|
62
|
+
const now = new Date().toISOString();
|
|
63
|
+
const title = args.title?.trim() || `Copy of ${deck.title ?? "deck"}`;
|
|
64
|
+
deck.title = title;
|
|
65
|
+
deck.createdAt = now;
|
|
66
|
+
deck.updatedAt = now;
|
|
67
|
+
deck.slides = (deck.slides ?? []).map((slide) => ({
|
|
68
|
+
...slide,
|
|
69
|
+
id: `slide-${nanoid(8)}`,
|
|
70
|
+
}));
|
|
71
|
+
await getDb()
|
|
72
|
+
.insert(schema.decks)
|
|
73
|
+
.values({
|
|
74
|
+
id,
|
|
75
|
+
title,
|
|
76
|
+
data: JSON.stringify(deck),
|
|
77
|
+
designSystemId: deck.designSystemId ?? null,
|
|
78
|
+
ownerEmail: email,
|
|
79
|
+
orgId: getRequestOrgId() ?? null,
|
|
80
|
+
createdAt: now,
|
|
81
|
+
updatedAt: now,
|
|
82
|
+
});
|
|
83
|
+
const [saved] = await getDb()
|
|
84
|
+
.select({ id: schema.decks.id, title: schema.decks.title })
|
|
85
|
+
.from(schema.decks)
|
|
86
|
+
.where(eq(schema.decks.id, id));
|
|
87
|
+
if (!saved) throw new Error("Deck clone did not persist.");
|
|
88
|
+
return {
|
|
89
|
+
id: saved.id,
|
|
90
|
+
title: saved.title,
|
|
91
|
+
slideCount: deck.slides.length,
|
|
92
|
+
url: getDeckUrl(id),
|
|
93
|
+
clonedExactVersion: reference.publishedItemVersionId,
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
});
|
|
@@ -10,13 +10,14 @@ export default async function (args: string[]) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const buf = fs.readFileSync(pdfPath);
|
|
13
|
-
const { CanvasFactory } = await import("pdf-parse/worker");
|
|
13
|
+
const { CanvasFactory, getData } = await import("pdf-parse/worker");
|
|
14
14
|
const { PDFParse } = await import("pdf-parse");
|
|
15
|
+
PDFParse.setWorker(getData());
|
|
15
16
|
const pdf = new PDFParse({
|
|
16
17
|
data: new Uint8Array(buf),
|
|
17
18
|
CanvasFactory,
|
|
18
19
|
});
|
|
19
|
-
const result = await pdf.getText();
|
|
20
|
+
const result = await pdf.getText().finally(() => pdf.destroy());
|
|
20
21
|
const pages = result.pages || [];
|
|
21
22
|
console.log("Total pages:", pages.length);
|
|
22
23
|
pages.forEach((page: { num: number; text: string }) => {
|
|
@@ -211,15 +211,16 @@ export default defineAction({
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
if (detectedFormat === "pdf") {
|
|
214
|
-
const { CanvasFactory } = await import("pdf-parse/worker");
|
|
214
|
+
const { CanvasFactory, getData } = await import("pdf-parse/worker");
|
|
215
215
|
const { PDFParse } = await import("pdf-parse");
|
|
216
|
+
PDFParse.setWorker(getData());
|
|
216
217
|
const { convertSectionsToSlides } =
|
|
217
218
|
await import("../server/handlers/import/html-converter.js");
|
|
218
219
|
const pdf = new PDFParse({
|
|
219
220
|
data: new Uint8Array(fileBuffer),
|
|
220
221
|
CanvasFactory,
|
|
221
222
|
});
|
|
222
|
-
const result = await pdf.getText();
|
|
223
|
+
const result = await pdf.getText().finally(() => pdf.destroy());
|
|
223
224
|
const pages = normalizePdfPages(result);
|
|
224
225
|
const textPages = pages.filter((p) => p.text.trim());
|
|
225
226
|
const title = titleFromPath(filename);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { VisibilityBadge, useT } from "@agent-native/core/client";
|
|
2
|
+
import { CreativeContextShareSheet } from "@agent-native/creative-context/client";
|
|
2
3
|
import {
|
|
3
4
|
IconDots,
|
|
4
5
|
IconTrash,
|
|
5
6
|
IconCopy,
|
|
6
7
|
IconPencil,
|
|
7
8
|
IconPalette,
|
|
9
|
+
IconPlus,
|
|
8
10
|
} from "@tabler/icons-react";
|
|
9
11
|
import { useState, useRef, useEffect } from "react";
|
|
10
12
|
import { Link } from "react-router";
|
|
@@ -42,6 +44,7 @@ export default function DeckCard({
|
|
|
42
44
|
const [isRenaming, setIsRenaming] = useState(false);
|
|
43
45
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
44
46
|
const [renameValue, setRenameValue] = useState(deck.title);
|
|
47
|
+
const [contextOpen, setContextOpen] = useState(false);
|
|
45
48
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
46
49
|
const pendingRenameRef = useRef(false);
|
|
47
50
|
|
|
@@ -188,6 +191,16 @@ export default function DeckCard({
|
|
|
188
191
|
<IconCopy className="w-3.5 h-3.5 me-2" />
|
|
189
192
|
{isDuplicating ? "Duplicating..." : "Duplicate"}
|
|
190
193
|
</DropdownMenuItem>
|
|
194
|
+
<DropdownMenuItem
|
|
195
|
+
onSelect={(event) => {
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
setMenuOpen(false);
|
|
198
|
+
setContextOpen(true);
|
|
199
|
+
}}
|
|
200
|
+
>
|
|
201
|
+
<IconPlus className="w-3.5 h-3.5 me-2" />
|
|
202
|
+
{t("creativeContext.addToContext" /* i18n-key-ignore */)}
|
|
203
|
+
</DropdownMenuItem>
|
|
191
204
|
<DropdownMenuSeparator />
|
|
192
205
|
<DropdownMenuItem
|
|
193
206
|
onClick={(e) => {
|
|
@@ -203,6 +216,20 @@ export default function DeckCard({
|
|
|
203
216
|
</DropdownMenuContent>
|
|
204
217
|
</DropdownMenu>
|
|
205
218
|
</div>
|
|
219
|
+
<CreativeContextShareSheet
|
|
220
|
+
open={contextOpen}
|
|
221
|
+
onOpenChange={setContextOpen}
|
|
222
|
+
resource={{
|
|
223
|
+
appId: "slides",
|
|
224
|
+
resourceType: "deck",
|
|
225
|
+
resourceId: deck.id,
|
|
226
|
+
title: deck.title,
|
|
227
|
+
updatedAt: deck.updatedAt,
|
|
228
|
+
visibility: deck.visibility,
|
|
229
|
+
preview: { kind: "document", label: "Deck" },
|
|
230
|
+
}}
|
|
231
|
+
canManage={deck.createdByMe}
|
|
232
|
+
/>
|
|
206
233
|
</div>
|
|
207
234
|
);
|
|
208
235
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
type CollabUser,
|
|
12
12
|
} from "@agent-native/core/client";
|
|
13
13
|
import { RunsTray } from "@agent-native/core/client/progress";
|
|
14
|
+
import { CreativeContextShareTab } from "@agent-native/creative-context/client";
|
|
14
15
|
import {
|
|
15
16
|
IconArrowLeft,
|
|
16
17
|
IconPlayerPlay,
|
|
@@ -955,6 +956,26 @@ graph TD
|
|
|
955
956
|
secondaryShareUrlDescription={t(
|
|
956
957
|
"editorToolbar.presentationLinkDescription",
|
|
957
958
|
)}
|
|
959
|
+
shareTabs={{
|
|
960
|
+
tabs: [
|
|
961
|
+
{
|
|
962
|
+
value: "context",
|
|
963
|
+
label: "Context",
|
|
964
|
+
content: (
|
|
965
|
+
<CreativeContextShareTab
|
|
966
|
+
resource={{
|
|
967
|
+
appId: "slides",
|
|
968
|
+
resourceType: "deck",
|
|
969
|
+
resourceId: deckId,
|
|
970
|
+
title: deckTitle,
|
|
971
|
+
updatedAt: deck.updatedAt,
|
|
972
|
+
preview: { kind: "document", label: "Deck" },
|
|
973
|
+
}}
|
|
974
|
+
/>
|
|
975
|
+
),
|
|
976
|
+
},
|
|
977
|
+
],
|
|
978
|
+
}}
|
|
958
979
|
/>
|
|
959
980
|
</div>
|
|
960
981
|
{/* Present button — matches Share trigger height (h-9) */}
|
|
@@ -1920,39 +1920,39 @@ export function DeckProvider({ children }: { children: ReactNode }) {
|
|
|
1920
1920
|
|
|
1921
1921
|
const duplicateSlide = useCallback(
|
|
1922
1922
|
(deckId: string, slideId: string) => {
|
|
1923
|
-
markDeckDirty(deckId);
|
|
1924
1923
|
const before = decksRef.current.find((d) => d.id === deckId);
|
|
1925
|
-
|
|
1924
|
+
const original = before?.slides.find((slide) => slide.id === slideId);
|
|
1925
|
+
if (!before || !original) return;
|
|
1926
|
+
|
|
1927
|
+
markDeckDirty(deckId);
|
|
1928
|
+
const copiedSlide: Slide = { ...original, id: nanoid(8) };
|
|
1926
1929
|
setDecksLocal((prev) =>
|
|
1927
1930
|
prev.map((d) => {
|
|
1928
1931
|
if (d.id !== deckId) return d;
|
|
1929
1932
|
const idx = d.slides.findIndex((s) => s.id === slideId);
|
|
1930
1933
|
if (idx === -1) return d;
|
|
1931
|
-
const original = d.slides[idx];
|
|
1932
|
-
const copy: Slide = { ...original, id: nanoid(8) };
|
|
1933
|
-
copiedSlide = copy;
|
|
1934
1934
|
const slides = [...d.slides];
|
|
1935
|
-
slides.splice(idx + 1, 0,
|
|
1935
|
+
slides.splice(idx + 1, 0, copiedSlide);
|
|
1936
1936
|
return { ...d, slides, updatedAt: new Date().toISOString() };
|
|
1937
1937
|
}),
|
|
1938
1938
|
);
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
}
|
|
1939
|
+
// Granular add-slide op — inserts the copy after the original. Build it
|
|
1940
|
+
// from the current deck before scheduling the React state update; the
|
|
1941
|
+
// functional updater runs later and cannot be used to produce the op.
|
|
1942
|
+
const { id: newSlideId, ...rest } = copiedSlide;
|
|
1943
|
+
const op: PatchDeckOp = {
|
|
1944
|
+
op: "add-slide",
|
|
1945
|
+
slideId: newSlideId,
|
|
1946
|
+
afterSlideId: slideId,
|
|
1947
|
+
fields: {
|
|
1948
|
+
content: rest.content,
|
|
1949
|
+
notes: rest.notes,
|
|
1950
|
+
layout: rest.layout,
|
|
1951
|
+
background: rest.background,
|
|
1952
|
+
},
|
|
1953
|
+
};
|
|
1954
|
+
enqueueDeckOp(deckId, op);
|
|
1955
|
+
recordUndo(before, op, { label: "Duplicate slide" });
|
|
1956
1956
|
},
|
|
1957
1957
|
[markDeckDirty, recordUndo, setDecksLocal],
|
|
1958
1958
|
);
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
import { putPrivateBlob } from "@agent-native/core/private-blob";
|
|
4
|
+
import { accessFilter, resolveAccess } from "@agent-native/core/sharing";
|
|
5
|
+
import {
|
|
6
|
+
renderSafeNativeHtmlPreviews,
|
|
7
|
+
serializePrivateBlobHandle,
|
|
8
|
+
type NativeResourceCaptureAdapter,
|
|
9
|
+
} from "@agent-native/creative-context/server";
|
|
10
|
+
import { and, inArray } from "drizzle-orm";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
getAspectRatioDims,
|
|
14
|
+
type AspectRatio,
|
|
15
|
+
} from "../../shared/aspect-ratios.js";
|
|
16
|
+
import { getDb, schema } from "../db/index.js";
|
|
17
|
+
import { createDeckVersionSnapshot } from "./deck-versions.js";
|
|
18
|
+
|
|
19
|
+
function hash(value: string | Uint8Array) {
|
|
20
|
+
return createHash("sha256").update(value).digest("hex");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function text(value: string) {
|
|
24
|
+
return value
|
|
25
|
+
.replace(/<[^>]+>/g, " ")
|
|
26
|
+
.replace(/\s+/g, " ")
|
|
27
|
+
.trim();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function previewText(value: string | undefined, limit = 280) {
|
|
31
|
+
return text(value ?? "").slice(0, limit);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function slidePreviewDocument(content: string, width: number, height: number) {
|
|
35
|
+
return `<!doctype html><html><head><style>
|
|
36
|
+
*,*::before,*::after{box-sizing:border-box}html,body{width:${width}px;height:${height}px;margin:0;overflow:hidden;background:#fff}.context-slide{position:relative;width:${width}px;height:${height}px;overflow:hidden}.context-slide>*{width:100%;height:100%}.fmd-slide{width:100%;height:100%}
|
|
37
|
+
</style></head><body><div class="context-slide">${content}</div></body></html>`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function captureSlidePreviewMedia(input: {
|
|
41
|
+
deckId: string;
|
|
42
|
+
ownerEmail: string;
|
|
43
|
+
slides: Array<{ id: string; content: string; title: string }>;
|
|
44
|
+
aspectRatio?: AspectRatio;
|
|
45
|
+
}) {
|
|
46
|
+
const dimensions = getAspectRatioDims(input.aspectRatio);
|
|
47
|
+
const rendered = await renderSafeNativeHtmlPreviews(
|
|
48
|
+
input.slides.map((slide) => ({
|
|
49
|
+
id: slide.id,
|
|
50
|
+
html: slidePreviewDocument(
|
|
51
|
+
slide.content,
|
|
52
|
+
dimensions.width,
|
|
53
|
+
dimensions.height,
|
|
54
|
+
),
|
|
55
|
+
width: dimensions.width,
|
|
56
|
+
height: dimensions.height,
|
|
57
|
+
})),
|
|
58
|
+
);
|
|
59
|
+
const media = new Map<
|
|
60
|
+
string,
|
|
61
|
+
{
|
|
62
|
+
kind: "image";
|
|
63
|
+
mimeType: "image/png";
|
|
64
|
+
accessMode: "private";
|
|
65
|
+
storageKey: string;
|
|
66
|
+
altText: string;
|
|
67
|
+
contentHash: string;
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
70
|
+
metadata: { role: "slide-preview"; slideId: string };
|
|
71
|
+
}
|
|
72
|
+
>();
|
|
73
|
+
await Promise.all(
|
|
74
|
+
rendered.map(async (preview) => {
|
|
75
|
+
const contentHash = hash(preview.data);
|
|
76
|
+
const handle = await putPrivateBlob({
|
|
77
|
+
data: preview.data,
|
|
78
|
+
filename: `${input.deckId}-${preview.id}.preview.png`,
|
|
79
|
+
mimeType: "image/png",
|
|
80
|
+
ownerEmail: input.ownerEmail,
|
|
81
|
+
key: `creative-context/slides/${input.deckId}/previews/${contentHash}.png`,
|
|
82
|
+
metadata: {
|
|
83
|
+
appId: "slides",
|
|
84
|
+
resourceType: "slide-preview",
|
|
85
|
+
resourceId: input.deckId,
|
|
86
|
+
contentHash,
|
|
87
|
+
},
|
|
88
|
+
}).catch(() => null);
|
|
89
|
+
if (!handle) return;
|
|
90
|
+
const slide = input.slides.find(
|
|
91
|
+
(candidate) => candidate.id === preview.id,
|
|
92
|
+
);
|
|
93
|
+
media.set(preview.id, {
|
|
94
|
+
kind: "image",
|
|
95
|
+
mimeType: "image/png",
|
|
96
|
+
accessMode: "private",
|
|
97
|
+
storageKey: serializePrivateBlobHandle(handle),
|
|
98
|
+
altText: slide?.title ?? "Slide preview",
|
|
99
|
+
contentHash,
|
|
100
|
+
width: preview.width,
|
|
101
|
+
height: preview.height,
|
|
102
|
+
metadata: { role: "slide-preview", slideId: preview.id },
|
|
103
|
+
});
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
106
|
+
return media;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const nativeDeckCreativeContextAdapter: NativeResourceCaptureAdapter = {
|
|
110
|
+
appId: "slides",
|
|
111
|
+
resourceType: "deck",
|
|
112
|
+
async listResourceVersions(resourceIds) {
|
|
113
|
+
if (!resourceIds.length) return [];
|
|
114
|
+
return getDb()
|
|
115
|
+
.select({
|
|
116
|
+
resourceId: schema.decks.id,
|
|
117
|
+
sourceModifiedAt: schema.decks.updatedAt,
|
|
118
|
+
})
|
|
119
|
+
.from(schema.decks)
|
|
120
|
+
.where(
|
|
121
|
+
and(
|
|
122
|
+
inArray(schema.decks.id, [...resourceIds]),
|
|
123
|
+
accessFilter(schema.decks, schema.deckShares),
|
|
124
|
+
),
|
|
125
|
+
);
|
|
126
|
+
},
|
|
127
|
+
async capture(reference) {
|
|
128
|
+
const access = await resolveAccess("deck", reference.resourceId);
|
|
129
|
+
if (!access) throw new Error("Deck not found");
|
|
130
|
+
const deck = access.resource as {
|
|
131
|
+
id: string;
|
|
132
|
+
title: string;
|
|
133
|
+
data: string;
|
|
134
|
+
ownerEmail: string;
|
|
135
|
+
updatedAt: string;
|
|
136
|
+
visibility?: "private" | "org" | "public";
|
|
137
|
+
};
|
|
138
|
+
if (
|
|
139
|
+
reference.expectedUpdatedAt &&
|
|
140
|
+
reference.expectedUpdatedAt !== deck.updatedAt
|
|
141
|
+
) {
|
|
142
|
+
throw new Error("Deck changed before it could be submitted to Context.");
|
|
143
|
+
}
|
|
144
|
+
const version = await createDeckVersionSnapshot(deck, {
|
|
145
|
+
force: true,
|
|
146
|
+
label: "Creative Context submission",
|
|
147
|
+
});
|
|
148
|
+
const contentHash = hash(deck.data);
|
|
149
|
+
const handle = await putPrivateBlob({
|
|
150
|
+
data: Buffer.from(deck.data),
|
|
151
|
+
filename: `${deck.id}.deck.json`,
|
|
152
|
+
mimeType: "application/json",
|
|
153
|
+
ownerEmail: deck.ownerEmail,
|
|
154
|
+
key: `creative-context/slides/${deck.id}/${contentHash}.json`,
|
|
155
|
+
metadata: {
|
|
156
|
+
appId: "slides",
|
|
157
|
+
resourceType: "deck",
|
|
158
|
+
resourceId: deck.id,
|
|
159
|
+
contentHash,
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
if (!handle)
|
|
163
|
+
throw new Error(
|
|
164
|
+
"Private blob storage is required to submit a deck to Context.",
|
|
165
|
+
);
|
|
166
|
+
const parsed = JSON.parse(deck.data) as {
|
|
167
|
+
aspectRatio?: string;
|
|
168
|
+
slides?: Array<{
|
|
169
|
+
id?: string;
|
|
170
|
+
content?: string;
|
|
171
|
+
notes?: string;
|
|
172
|
+
title?: string;
|
|
173
|
+
}>;
|
|
174
|
+
};
|
|
175
|
+
const slides = Array.isArray(parsed.slides) ? parsed.slides : [];
|
|
176
|
+
const slidePreviewMedia = await captureSlidePreviewMedia({
|
|
177
|
+
deckId: deck.id,
|
|
178
|
+
ownerEmail: deck.ownerEmail,
|
|
179
|
+
aspectRatio:
|
|
180
|
+
parsed.aspectRatio === "16:9" ||
|
|
181
|
+
parsed.aspectRatio === "1:1" ||
|
|
182
|
+
parsed.aspectRatio === "9:16" ||
|
|
183
|
+
parsed.aspectRatio === "4:5"
|
|
184
|
+
? parsed.aspectRatio
|
|
185
|
+
: undefined,
|
|
186
|
+
slides: slides.slice(0, 12).map((slide, index) => ({
|
|
187
|
+
id: slide.id ?? String(index),
|
|
188
|
+
content: slide.content ?? "",
|
|
189
|
+
title: slide.title ?? `Slide ${index + 1}`,
|
|
190
|
+
})),
|
|
191
|
+
});
|
|
192
|
+
return {
|
|
193
|
+
artifactKey: `slides:deck:${deck.id}`,
|
|
194
|
+
source: {
|
|
195
|
+
name: "Slides",
|
|
196
|
+
kind: "native-app",
|
|
197
|
+
externalRef: deck.id,
|
|
198
|
+
access: {
|
|
199
|
+
visibility: deck.visibility ?? "private",
|
|
200
|
+
canManage: access.role === "owner" || access.role === "admin",
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
items: [
|
|
204
|
+
{
|
|
205
|
+
externalId: `native:slides:deck:${deck.id}`,
|
|
206
|
+
kind: "slides-deck",
|
|
207
|
+
title: deck.title || "Untitled deck",
|
|
208
|
+
canonicalUrl: `/deck/${deck.id}`,
|
|
209
|
+
mimeType: "application/json",
|
|
210
|
+
content: slides
|
|
211
|
+
.map(
|
|
212
|
+
(slide, index) =>
|
|
213
|
+
`Slide ${index + 1}: ${text(slide.content ?? "")} ${slide.notes ?? ""}`,
|
|
214
|
+
)
|
|
215
|
+
.join("\n")
|
|
216
|
+
.slice(0, 40_000),
|
|
217
|
+
summary: `${slides.length} slides captured as an immutable deck version.`,
|
|
218
|
+
contentHash,
|
|
219
|
+
sourceModifiedAt: deck.updatedAt,
|
|
220
|
+
sourceVersion: version.id ?? contentHash,
|
|
221
|
+
metadata: {
|
|
222
|
+
preview: {
|
|
223
|
+
type: "slides",
|
|
224
|
+
slideCount: slides.length,
|
|
225
|
+
slides: slides.slice(0, 24).map((slide, index) => ({
|
|
226
|
+
index: index + 1,
|
|
227
|
+
title: previewText(slide.title, 120) || `Slide ${index + 1}`,
|
|
228
|
+
excerpt: previewText(slide.content),
|
|
229
|
+
})),
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
media: [...slidePreviewMedia.values()],
|
|
233
|
+
edges: slides.map((slide, index) => ({
|
|
234
|
+
relation: "contains",
|
|
235
|
+
toExternalId: `native:slides:deck:${deck.id}:slide:${slide.id ?? index}`,
|
|
236
|
+
})),
|
|
237
|
+
},
|
|
238
|
+
...slides.map((slide, index) => {
|
|
239
|
+
const content =
|
|
240
|
+
`${text(slide.content ?? "")} ${slide.notes ?? ""}`.trim();
|
|
241
|
+
const id = slide.id ?? String(index);
|
|
242
|
+
return {
|
|
243
|
+
externalId: `native:slides:deck:${deck.id}:slide:${id}`,
|
|
244
|
+
kind: "slide",
|
|
245
|
+
title: slide.title ?? `Slide ${index + 1}`,
|
|
246
|
+
canonicalUrl: `/deck/${deck.id}?slide=${encodeURIComponent(id)}`,
|
|
247
|
+
mimeType: "text/html",
|
|
248
|
+
content,
|
|
249
|
+
summary: content.slice(0, 500),
|
|
250
|
+
contentHash: hash(
|
|
251
|
+
`${deck.id}:${id}:${slide.content ?? ""}:${slide.notes ?? ""}`,
|
|
252
|
+
),
|
|
253
|
+
sourceModifiedAt: deck.updatedAt,
|
|
254
|
+
sourceVersion: version.id ?? contentHash,
|
|
255
|
+
metadata: {
|
|
256
|
+
preview: {
|
|
257
|
+
type: "slide",
|
|
258
|
+
index: index + 1,
|
|
259
|
+
title: previewText(slide.title, 120) || `Slide ${index + 1}`,
|
|
260
|
+
excerpt: previewText(slide.content),
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
media: slidePreviewMedia.has(id)
|
|
264
|
+
? [slidePreviewMedia.get(id)!]
|
|
265
|
+
: undefined,
|
|
266
|
+
};
|
|
267
|
+
}),
|
|
268
|
+
],
|
|
269
|
+
privateMetadata: {
|
|
270
|
+
nativeResource: {
|
|
271
|
+
appId: "slides",
|
|
272
|
+
resourceType: "deck",
|
|
273
|
+
resourceId: deck.id,
|
|
274
|
+
expectedUpdatedAt: reference.expectedUpdatedAt,
|
|
275
|
+
},
|
|
276
|
+
clone: {
|
|
277
|
+
handle,
|
|
278
|
+
appId: "slides",
|
|
279
|
+
resourceType: "deck",
|
|
280
|
+
resourceId: deck.id,
|
|
281
|
+
contentHash,
|
|
282
|
+
sourceVersion: version.id ?? contentHash,
|
|
283
|
+
updatedAt: deck.updatedAt,
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
},
|
|
288
|
+
};
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
getRequestUserEmail,
|
|
5
5
|
} from "@agent-native/core/server/request-context";
|
|
6
6
|
import {
|
|
7
|
+
registerNativeResourceCaptureAdapter,
|
|
7
8
|
setupCreativeContext,
|
|
8
9
|
type CreativeContextProjectionAdapters,
|
|
9
10
|
} from "@agent-native/creative-context/server";
|
|
@@ -12,6 +13,7 @@ import { desc, eq } from "drizzle-orm";
|
|
|
12
13
|
import { nanoid } from "nanoid";
|
|
13
14
|
|
|
14
15
|
import { getDb, schema } from "../db/index.js";
|
|
16
|
+
import { nativeDeckCreativeContextAdapter } from "../lib/native-creative-context.js";
|
|
15
17
|
|
|
16
18
|
type ProjectedLayoutTemplate = {
|
|
17
19
|
id: string;
|
|
@@ -163,4 +165,6 @@ registerOnboardingStep({
|
|
|
163
165
|
},
|
|
164
166
|
});
|
|
165
167
|
|
|
168
|
+
registerNativeResourceCaptureAdapter(nativeDeckCreativeContextAdapter);
|
|
169
|
+
|
|
166
170
|
export default setupCreativeContext({ appId: "slides", projections });
|