@agent-native/core 0.131.4 → 0.131.6
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 +3 -3
- package/corpus/core/CHANGELOG.md +69 -0
- package/corpus/core/docs/content/agent-native-toolkit.mdx +13 -6
- package/corpus/core/docs/content/cloneable-saas.mdx +5 -5
- package/corpus/core/docs/content/creating-templates.mdx +9 -0
- package/corpus/core/docs/content/deployment.mdx +14 -10
- package/corpus/core/docs/content/docs-components.mdx +491 -0
- package/corpus/core/docs/content/doctor.mdx +8 -1
- package/corpus/core/docs/content/drop-in-agent.mdx +1 -1
- package/corpus/core/docs/content/extensions.mdx +18 -18
- package/corpus/core/docs/content/faq.mdx +4 -4
- package/corpus/core/docs/content/key-concepts.mdx +30 -21
- package/corpus/core/docs/content/template-brain-developers.mdx +4 -1
- package/corpus/core/docs/content/template-mail-developers.mdx +4 -1
- package/corpus/core/docs/content/what-is-agent-native.mdx +6 -6
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/a2a/client.ts +449 -66
- package/corpus/core/src/a2a/correlation.ts +31 -0
- package/corpus/core/src/a2a/types.ts +4 -0
- package/corpus/core/src/action.ts +3 -0
- package/corpus/core/src/agent/engine/registry.ts +45 -5
- package/corpus/core/src/agent/production-agent.ts +151 -18
- package/corpus/core/src/agent/run-loop-with-resume.ts +190 -3
- package/corpus/core/src/agent/run-manager.ts +117 -41
- package/corpus/core/src/agent/thread-debug-history.ts +86 -0
- package/corpus/core/src/agent/types.ts +3 -1
- package/corpus/core/src/cli/create.ts +11 -1
- package/corpus/core/src/cli/templates-meta.ts +2 -2
- package/corpus/core/src/client/agent-chat-adapter.ts +91 -13
- package/corpus/core/src/client/resources/McpIntegrationDialog.tsx +11 -9
- package/corpus/core/src/client/sse-event-processor.ts +17 -3
- package/corpus/core/src/db/client.ts +57 -17
- package/corpus/core/src/integrations/adapters/slack.ts +8 -3
- package/corpus/core/src/localization/default-messages.ts +44 -0
- package/corpus/core/src/observability/traces.ts +78 -5
- package/corpus/core/src/scripts/call-agent.ts +290 -9
- package/corpus/core/src/scripts/describe-workspace-apps.ts +2 -2
- package/corpus/core/src/secrets/crypto.ts +126 -34
- package/corpus/core/src/secrets/storage.ts +61 -25
- package/corpus/core/src/server/agent-capabilities.ts +1 -1
- package/corpus/core/src/server/agent-chat/action-filters-a2a.ts +111 -7
- package/corpus/core/src/server/agent-chat/context-tools.ts +2 -0
- package/corpus/core/src/server/agent-chat/plugin-options.ts +34 -1
- package/corpus/core/src/server/agent-chat/prompt-resources.ts +1 -1
- package/corpus/core/src/server/agent-chat-plugin.ts +91 -59
- package/corpus/core/src/templates/default/.agents/skills/secrets/SKILL.md +14 -7
- package/corpus/core/src/templates/headless/.agents/skills/secrets/SKILL.md +14 -7
- package/corpus/core/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +18 -7
- package/corpus/core/src/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +15 -14
- package/corpus/core/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +14 -7
- package/corpus/core/src/vite/client.ts +1 -0
- package/corpus/templates/analytics/.agents/skills/dashboard-ops/SKILL.md +5 -4
- package/corpus/templates/analytics/.agents/skills/gong/SKILL.md +6 -4
- package/corpus/templates/analytics/AGENTS.md +6 -4
- package/corpus/templates/analytics/actions/query-agent-native-analytics.ts +4 -3
- package/corpus/templates/analytics/changelog/2026-07-30-scheduled-dashboard-emails-complete-every-panel-without-pool.md +6 -0
- package/corpus/templates/analytics/scripts/emit-netlify-dashboard-report-cron.ts +28 -1
- package/corpus/templates/analytics/server/jobs/dashboard-report.ts +18 -11
- package/corpus/templates/analytics/server/lib/analytics-connector-catalog.ts +4 -4
- package/corpus/templates/analytics/server/lib/canonical-first-party-dashboard-repair.ts +9 -5
- package/corpus/templates/analytics/server/lib/dashboard-panel-query.ts +6 -2
- package/corpus/templates/analytics/server/lib/dashboard-panel-source-resolver.ts +11 -4
- package/corpus/templates/analytics/server/lib/dashboard-report-render.ts +49 -31
- package/corpus/templates/analytics/server/lib/first-party-analytics.ts +16 -8
- package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +9 -3
- package/corpus/templates/analytics/server/lib/production-serverless-runtime.ts +11 -0
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +3 -2
- package/corpus/templates/analytics/server/plugins/analytics-alert-jobs.ts +2 -1
- package/corpus/templates/analytics/server/plugins/dashboard-report-jobs.ts +2 -1
- package/corpus/templates/analytics/server/plugins/uptime-monitor-jobs.ts +1 -12
- package/corpus/templates/brain/.agents/skills/brain/RUNBOOK.md +54 -6
- package/corpus/templates/brain/.agents/skills/brain/SKILL.md +20 -9
- package/corpus/templates/brain/.agents/skills/ingestion-and-connectors/SKILL.md +33 -1
- package/corpus/templates/brain/AGENTS.md +3 -1
- package/corpus/templates/brain/README.md +4 -1
- package/corpus/templates/brain/actions/_schemas.ts +30 -8
- package/corpus/templates/brain/actions/ask-brain.ts +124 -14
- package/corpus/templates/brain/actions/create-source.ts +18 -2
- package/corpus/templates/brain/actions/enqueue-captures-distillation.ts +8 -123
- package/corpus/templates/brain/actions/enqueue-distillation.ts +6 -127
- package/corpus/templates/brain/actions/import-capture.ts +17 -5
- package/corpus/templates/brain/actions/import-transcript.ts +17 -5
- package/corpus/templates/brain/actions/update-source.ts +25 -5
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +1 -1
- package/corpus/templates/brain/changelog/2026-07-30-blessed-resources-can-feed-cited-company-answers.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-30-the-left-sidebar-no-longer-shows-a-blank-organization-placeh.md +6 -0
- package/corpus/templates/brain/server/lib/brain.ts +49 -19
- package/corpus/templates/brain/server/lib/distillation-queue.ts +147 -0
- package/corpus/templates/brain/server/lib/source-policy.ts +264 -0
- package/corpus/templates/brain/server/plugins/agent-chat.ts +3 -2
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/ingest.post.ts +116 -19
- package/corpus/templates/clips/app/components/meetings/google-oauth-identity-notice.tsx +51 -0
- package/corpus/templates/clips/app/i18n/en-US.ts +4 -0
- package/corpus/templates/clips/app/routes/_app.meetings._index.tsx +3 -1
- package/corpus/templates/clips/changelog/2026-07-30-google-calendar-warning.md +6 -0
- package/corpus/templates/content/.agents/skills/content-product-development/SKILL.md +47 -0
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +72 -8
- package/corpus/templates/content/changelog/2026-07-30-the-slash-command-hint-now-stays-on-only-the-active-empty-li.md +6 -0
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +506 -11
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +148 -17
- package/corpus/templates/design/app/components/design/canvas-interactions/design-canvas-interactions.ts +357 -0
- package/corpus/templates/design/app/components/design/inspector/ScrubInput.tsx +7 -466
- package/corpus/templates/design/app/components/design/inspector/scrub-input-utils.ts +15 -311
- package/corpus/templates/design/app/components/visual-editor/CanvasCommentPins.tsx +19 -997
- package/corpus/templates/design/app/components/visual-editor/DrawOverlay.tsx +8 -1216
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +31 -38
- package/corpus/templates/design/package.json +0 -1
- package/corpus/templates/dispatch/AGENTS.md +8 -0
- package/corpus/templates/dispatch/DEVELOPING.md +29 -0
- package/corpus/templates/dispatch/actions/view-screen.ts +34 -2
- package/corpus/templates/dispatch/app/i18n-data.ts +457 -0
- package/corpus/templates/dispatch/changelog/2026-07-30-delegated-dispatch-work-continues-reliably-in-the-background.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-30-find-failed-runs-across-apps.md +6 -0
- package/corpus/templates/dispatch/netlify.toml +3 -0
- package/corpus/templates/slides/.agents/skills/analytics-data-for-decks/SKILL.md +8 -12
- package/corpus/templates/slides/AGENTS.md +4 -4
- package/corpus/templates/slides/actions/duplicate-deck.ts +19 -4
- package/corpus/templates/slides/app/components/deck/DeckCard.tsx +2 -10
- package/corpus/templates/slides/app/components/deck/MermaidRenderer.tsx +12 -1
- package/corpus/templates/slides/app/components/deck/SlideRenderer.tsx +30 -13
- package/corpus/templates/slides/app/components/editor/DeckEditorSkeleton.tsx +35 -0
- package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +63 -56
- package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +21 -76
- package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +1110 -292
- package/corpus/templates/slides/app/components/editor/SlideOverflowWarning.tsx +53 -0
- package/corpus/templates/slides/app/components/editor/SlideStyleInspector.tsx +235 -18
- package/corpus/templates/slides/app/components/editor/SpeakerNotesPanel.tsx +4 -1
- package/corpus/templates/slides/app/components/editor/canvas-interactions/index.ts +11 -0
- package/corpus/templates/slides/app/components/editor/canvas-interactions/slides-canvas-adapter.ts +129 -0
- package/corpus/templates/slides/app/components/editor/selection-overlay-measurement.ts +70 -0
- package/corpus/templates/slides/app/components/editor/slide-object-interactions.ts +519 -65
- package/corpus/templates/slides/app/components/visual-editor/CanvasCommentPins.tsx +36 -426
- package/corpus/templates/slides/app/components/visual-editor/DrawOverlay.tsx +19 -458
- package/corpus/templates/slides/app/context/DeckContext.tsx +179 -72
- package/corpus/templates/slides/app/global.css +105 -0
- package/corpus/templates/slides/app/i18n/en-US.ts +8 -0
- package/corpus/templates/slides/app/lib/deck-editor-loading.ts +26 -0
- package/corpus/templates/slides/app/lib/mermaid-blocks.ts +27 -0
- package/corpus/templates/slides/app/pages/DeckEditor.tsx +71 -38
- package/corpus/templates/slides/app/pages/Index.tsx +98 -41
- package/corpus/templates/slides/changelog/2026-07-30-deck-loading-no-longer-flashes-an-unavailable-message.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-duplicating-a-deck-from-the-deck-list-now-opens-the-copy-imm.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-layout-overflow-warning-is-readable-and-dismissible.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-shared-canvas-annotations.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-slide-objects-can-be-moved-as-a-group-copied-and-pasted-with.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-slide-text-editing-and-object-controls-now-match-google-slides.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-style-panel-now-scrolls-with-speaker-notes-open-shows-the-sl.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-top-toolbar-controls-now-use-consistent-sizing-with-undo-and.md +6 -0
- package/corpus/templates/slides/netlify.toml +3 -1
- package/corpus/templates/slides/package.json +0 -1
- package/corpus/templates/slides/server/lib/chat-attachments.ts +18 -0
- package/corpus/templates/slides/server/plugins/agent-chat.ts +5 -0
- package/corpus/templates/slides/vite.config.ts +0 -1
- package/corpus/toolkit/CHANGELOG.md +13 -0
- package/corpus/toolkit/README.md +19 -0
- package/corpus/toolkit/agent-native.eject.json +38 -0
- package/corpus/toolkit/package.json +29 -1
- package/corpus/toolkit/src/canvas-annotations/CanvasCommentPins.tsx +861 -0
- package/corpus/toolkit/src/canvas-annotations/DrawOverlay.tsx +1233 -0
- package/corpus/toolkit/src/canvas-annotations/index.ts +15 -0
- package/corpus/toolkit/src/canvas-annotations/types.ts +14 -0
- package/corpus/toolkit/src/canvas-interactions/canvas-interactions.ts +933 -0
- package/corpus/toolkit/src/canvas-interactions/index.ts +67 -0
- package/corpus/toolkit/src/design-tweaks/scrub-input-utils.ts +311 -0
- package/corpus/toolkit/src/design-tweaks/scrub-input.tsx +491 -0
- package/corpus/toolkit/src/design-tweaks/visual-style-controls.tsx +26 -171
- package/corpus/toolkit/src/index.ts +1 -0
- package/dist/a2a/client.d.ts +23 -0
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +309 -44
- package/dist/a2a/client.js.map +1 -1
- package/dist/a2a/correlation.d.ts +1 -0
- package/dist/a2a/correlation.d.ts.map +1 -1
- package/dist/a2a/correlation.js +27 -0
- package/dist/a2a/correlation.js.map +1 -1
- package/dist/a2a/types.d.ts +4 -0
- package/dist/a2a/types.d.ts.map +1 -1
- package/dist/a2a/types.js.map +1 -1
- package/dist/action.d.ts +3 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js.map +1 -1
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +34 -7
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/production-agent.d.ts +40 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +113 -15
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-loop-with-resume.d.ts +21 -0
- package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
- package/dist/agent/run-loop-with-resume.js +163 -4
- package/dist/agent/run-loop-with-resume.js.map +1 -1
- package/dist/agent/run-manager.d.ts +16 -9
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +93 -42
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/thread-debug-history.d.ts +10 -0
- package/dist/agent/thread-debug-history.d.ts.map +1 -0
- package/dist/agent/thread-debug-history.js +68 -0
- package/dist/agent/thread-debug-history.js.map +1 -0
- package/dist/agent/types.d.ts +3 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +6 -1
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/templates-meta.js +2 -2
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +76 -13
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.d.ts.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.js +1 -1
- package/dist/client/resources/McpIntegrationDialog.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +12 -3
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +48 -17
- package/dist/db/client.js.map +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/integrations/adapters/slack.js +7 -3
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/localization/default-messages.d.ts +43 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +43 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/traces.d.ts +3 -1
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js +73 -4
- package/dist/observability/traces.js.map +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +12 -12
- package/dist/provider-api/actions/provider-api.d.ts +13 -13
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +233 -10
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/scripts/describe-workspace-apps.js +2 -2
- package/dist/scripts/describe-workspace-apps.js.map +1 -1
- package/dist/secrets/crypto.d.ts +31 -21
- package/dist/secrets/crypto.d.ts.map +1 -1
- package/dist/secrets/crypto.js +108 -33
- package/dist/secrets/crypto.js.map +1 -1
- package/dist/secrets/storage.d.ts +3 -5
- package/dist/secrets/storage.d.ts.map +1 -1
- package/dist/secrets/storage.js +40 -25
- package/dist/secrets/storage.js.map +1 -1
- package/dist/server/agent-capabilities.js +1 -1
- package/dist/server/agent-capabilities.js.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.d.ts +17 -3
- package/dist/server/agent-chat/action-filters-a2a.d.ts.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.js +92 -3
- package/dist/server/agent-chat/action-filters-a2a.js.map +1 -1
- package/dist/server/agent-chat/context-tools.d.ts.map +1 -1
- package/dist/server/agent-chat/context-tools.js +2 -0
- package/dist/server/agent-chat/context-tools.js.map +1 -1
- package/dist/server/agent-chat/plugin-options.d.ts +23 -0
- package/dist/server/agent-chat/plugin-options.d.ts.map +1 -1
- package/dist/server/agent-chat/plugin-options.js +4 -1
- package/dist/server/agent-chat/plugin-options.js.map +1 -1
- package/dist/server/agent-chat/prompt-resources.js +1 -1
- package/dist/server/agent-chat/prompt-resources.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +2 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +79 -56
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/templates/default/.agents/skills/secrets/SKILL.md +14 -7
- package/dist/templates/headless/.agents/skills/secrets/SKILL.md +14 -7
- package/dist/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +18 -7
- package/dist/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +15 -14
- package/dist/templates/workspace-core/.agents/skills/secrets/SKILL.md +14 -7
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +1 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/agent-native-toolkit.mdx +13 -6
- package/docs/content/cloneable-saas.mdx +5 -5
- package/docs/content/creating-templates.mdx +9 -0
- package/docs/content/deployment.mdx +14 -10
- package/docs/content/docs-components.mdx +491 -0
- package/docs/content/doctor.mdx +8 -1
- package/docs/content/drop-in-agent.mdx +1 -1
- package/docs/content/extensions.mdx +18 -18
- package/docs/content/faq.mdx +4 -4
- package/docs/content/key-concepts.mdx +30 -21
- package/docs/content/template-brain-developers.mdx +4 -1
- package/docs/content/template-mail-developers.mdx +4 -1
- package/docs/content/what-is-agent-native.mdx +6 -6
- package/package.json +2 -2
- package/src/a2a/client.ts +449 -66
- package/src/a2a/correlation.ts +31 -0
- package/src/a2a/types.ts +4 -0
- package/src/action.ts +3 -0
- package/src/agent/engine/registry.ts +45 -5
- package/src/agent/production-agent.ts +151 -18
- package/src/agent/run-loop-with-resume.ts +190 -3
- package/src/agent/run-manager.ts +117 -41
- package/src/agent/thread-debug-history.ts +86 -0
- package/src/agent/types.ts +3 -1
- package/src/cli/create.ts +11 -1
- package/src/cli/templates-meta.ts +2 -2
- package/src/client/agent-chat-adapter.ts +91 -13
- package/src/client/resources/McpIntegrationDialog.tsx +11 -9
- package/src/client/sse-event-processor.ts +17 -3
- package/src/db/client.ts +57 -17
- package/src/integrations/adapters/slack.ts +8 -3
- package/src/localization/default-messages.ts +44 -0
- package/src/observability/traces.ts +78 -5
- package/src/scripts/call-agent.ts +290 -9
- package/src/scripts/describe-workspace-apps.ts +2 -2
- package/src/secrets/crypto.ts +126 -34
- package/src/secrets/storage.ts +61 -25
- package/src/server/agent-capabilities.ts +1 -1
- package/src/server/agent-chat/action-filters-a2a.ts +111 -7
- package/src/server/agent-chat/context-tools.ts +2 -0
- package/src/server/agent-chat/plugin-options.ts +34 -1
- package/src/server/agent-chat/prompt-resources.ts +1 -1
- package/src/server/agent-chat-plugin.ts +91 -59
- package/src/templates/default/.agents/skills/secrets/SKILL.md +14 -7
- package/src/templates/headless/.agents/skills/secrets/SKILL.md +14 -7
- package/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +18 -7
- package/src/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +15 -14
- package/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +14 -7
- package/src/vite/client.ts +1 -0
|
@@ -1,466 +1,27 @@
|
|
|
1
1
|
import { useT } from "@agent-native/core/client/i18n";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
IconCursorText,
|
|
7
|
-
IconX,
|
|
8
|
-
} from "@tabler/icons-react";
|
|
9
|
-
import { useState, useRef, useCallback, useEffect } from "react";
|
|
3
|
+
DrawOverlay as ToolkitDrawOverlay,
|
|
4
|
+
type DrawOverlayProps as ToolkitDrawOverlayProps,
|
|
5
|
+
} from "@agent-native/toolkit/canvas-annotations";
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
import { Input } from "@/components/ui/input";
|
|
13
|
-
import {
|
|
14
|
-
Tooltip,
|
|
15
|
-
TooltipContent,
|
|
16
|
-
TooltipTrigger,
|
|
17
|
-
} from "@/components/ui/tooltip";
|
|
18
|
-
import { cn } from "@/lib/utils";
|
|
19
|
-
|
|
20
|
-
export interface DrawAnnotation {
|
|
21
|
-
id: string;
|
|
22
|
-
type: "path" | "text";
|
|
23
|
-
/** SVG path data for "path" type */
|
|
24
|
-
pathData?: string;
|
|
25
|
-
/** Text content for "text" type */
|
|
26
|
-
text?: string;
|
|
27
|
-
/** Annotation color (hex) */
|
|
28
|
-
color: string;
|
|
29
|
-
/** Stroke width for paths, font weight reference for text */
|
|
30
|
-
lineWidth: number;
|
|
31
|
-
/** Position relative to the canvas (text annotations only) */
|
|
32
|
-
position: { x: number; y: number };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface DrawOverlayProps {
|
|
36
|
-
/** Whether the overlay is currently visible (toggled from the toolbar) */
|
|
37
|
-
visible: boolean;
|
|
38
|
-
/** Called when the user submits the queued strokes/text to the agent */
|
|
39
|
-
onSend: (
|
|
40
|
-
annotations: DrawAnnotation[],
|
|
41
|
-
instruction: string,
|
|
42
|
-
canvasSize: { width: number; height: number },
|
|
43
|
-
) => void;
|
|
44
|
-
/** Called when the user cancels / closes the draw mode */
|
|
45
|
-
onClose: () => void;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const PRESET_COLORS = [
|
|
49
|
-
{ color: "#ef4444", label: "Red" },
|
|
50
|
-
{ color: "#3b82f6", label: "Blue" },
|
|
51
|
-
{ color: "#22c55e", label: "Green" },
|
|
52
|
-
{ color: "#eab308", label: "Yellow" },
|
|
53
|
-
];
|
|
7
|
+
export type { DrawAnnotation } from "@agent-native/toolkit/canvas-annotations";
|
|
54
8
|
|
|
55
|
-
|
|
56
|
-
{ value: 2, label: "Thin" },
|
|
57
|
-
{ value: 4, label: "Medium" },
|
|
58
|
-
{ value: 8, label: "Thick" },
|
|
59
|
-
];
|
|
9
|
+
export type DrawOverlayProps = Omit<ToolkitDrawOverlayProps, "translate">;
|
|
60
10
|
|
|
61
|
-
|
|
62
|
-
x: number;
|
|
63
|
-
y: number;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface Stroke {
|
|
67
|
-
id: string;
|
|
68
|
-
points: Point[];
|
|
69
|
-
color: string;
|
|
70
|
-
lineWidth: number;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Draw-to-prompt overlay for the slide canvas.
|
|
75
|
-
*
|
|
76
|
-
* Mirrors claude.ai/design's "Draw mode": the user sketches on the canvas,
|
|
77
|
-
* adds a one-line text instruction, hits Send, and the strokes + instruction
|
|
78
|
-
* are forwarded to the agent. The agent receives the path geometry along with
|
|
79
|
-
* the canvas size so it can interpret position semantically (e.g. "move the
|
|
80
|
-
* title here").
|
|
81
|
-
*
|
|
82
|
-
* This component is canvas-agnostic — it overlays absolutely-positioned over
|
|
83
|
-
* its parent, so the parent (a slide editor or design canvas) only needs to
|
|
84
|
-
* be `position: relative`.
|
|
85
|
-
*/
|
|
86
|
-
export function DrawOverlay({ visible, onSend, onClose }: DrawOverlayProps) {
|
|
11
|
+
export function DrawOverlay(props: DrawOverlayProps) {
|
|
87
12
|
const t = useT();
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
y: number;
|
|
99
|
-
value: string;
|
|
100
|
-
} | null>(null);
|
|
101
|
-
const [instruction, setInstruction] = useState("");
|
|
102
|
-
const drawing = useRef(false);
|
|
103
|
-
|
|
104
|
-
// Clear all state on hide so the next open starts fresh.
|
|
105
|
-
useEffect(() => {
|
|
106
|
-
if (!visible) {
|
|
107
|
-
setStrokes([]);
|
|
108
|
-
setTextAnnotations([]);
|
|
109
|
-
setCurrentStroke(null);
|
|
110
|
-
setTextInput(null);
|
|
111
|
-
setInstruction("");
|
|
112
|
-
}
|
|
113
|
-
}, [visible]);
|
|
114
|
-
|
|
115
|
-
// Redraw canvas whenever strokes change.
|
|
116
|
-
useEffect(() => {
|
|
117
|
-
const canvas = canvasRef.current;
|
|
118
|
-
if (!canvas) return;
|
|
119
|
-
const ctx = canvas.getContext("2d");
|
|
120
|
-
if (!ctx) return;
|
|
121
|
-
|
|
122
|
-
const rect = canvas.getBoundingClientRect();
|
|
123
|
-
canvas.width = rect.width * window.devicePixelRatio;
|
|
124
|
-
canvas.height = rect.height * window.devicePixelRatio;
|
|
125
|
-
ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
|
|
126
|
-
|
|
127
|
-
ctx.clearRect(0, 0, rect.width, rect.height);
|
|
128
|
-
|
|
129
|
-
for (const stroke of strokes) {
|
|
130
|
-
drawStroke(ctx, stroke.points, stroke.color, stroke.lineWidth);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (currentStroke && currentStroke.length > 0) {
|
|
134
|
-
drawStroke(ctx, currentStroke, color, lineWidth);
|
|
135
|
-
}
|
|
136
|
-
}, [strokes, currentStroke, color, lineWidth]);
|
|
137
|
-
|
|
138
|
-
const handlePointerDown = useCallback(
|
|
139
|
-
(e: React.PointerEvent) => {
|
|
140
|
-
if (textMode) {
|
|
141
|
-
const rect = canvasRef.current?.getBoundingClientRect();
|
|
142
|
-
if (!rect) return;
|
|
143
|
-
setTextInput({
|
|
144
|
-
x: e.clientX - rect.left,
|
|
145
|
-
y: e.clientY - rect.top,
|
|
146
|
-
value: "",
|
|
147
|
-
});
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
drawing.current = true;
|
|
151
|
-
const rect = canvasRef.current?.getBoundingClientRect();
|
|
152
|
-
if (!rect) return;
|
|
153
|
-
const point = { x: e.clientX - rect.left, y: e.clientY - rect.top };
|
|
154
|
-
setCurrentStroke([point]);
|
|
155
|
-
(e.target as HTMLElement).setPointerCapture(e.pointerId);
|
|
156
|
-
},
|
|
157
|
-
[textMode],
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
const handlePointerMove = useCallback(
|
|
161
|
-
(e: React.PointerEvent) => {
|
|
162
|
-
if (!drawing.current || textMode) return;
|
|
163
|
-
const rect = canvasRef.current?.getBoundingClientRect();
|
|
164
|
-
if (!rect) return;
|
|
165
|
-
const point = { x: e.clientX - rect.left, y: e.clientY - rect.top };
|
|
166
|
-
setCurrentStroke((prev) => (prev ? [...prev, point] : [point]));
|
|
167
|
-
},
|
|
168
|
-
[textMode],
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
const handlePointerUp = useCallback(() => {
|
|
172
|
-
if (!drawing.current) return;
|
|
173
|
-
drawing.current = false;
|
|
174
|
-
if (currentStroke && currentStroke.length > 1) {
|
|
175
|
-
setStrokes((prev) => [
|
|
176
|
-
...prev,
|
|
177
|
-
{
|
|
178
|
-
id: crypto.randomUUID(),
|
|
179
|
-
points: currentStroke,
|
|
180
|
-
color,
|
|
181
|
-
lineWidth,
|
|
182
|
-
},
|
|
183
|
-
]);
|
|
184
|
-
}
|
|
185
|
-
setCurrentStroke(null);
|
|
186
|
-
}, [currentStroke, color, lineWidth]);
|
|
187
|
-
|
|
188
|
-
const undo = () => setStrokes((prev) => prev.slice(0, -1));
|
|
189
|
-
const clear = () => {
|
|
190
|
-
setStrokes([]);
|
|
191
|
-
setTextAnnotations([]);
|
|
13
|
+
const keyMap: Record<string, string> = {
|
|
14
|
+
"visualEditor.typeAnnotationFancy": "raw.typeAnnotation",
|
|
15
|
+
"visualEditor.typeAnywhereOnCanvas": "raw.typeAnywhere",
|
|
16
|
+
"visualEditor.clearAll": "raw.drawClearAll",
|
|
17
|
+
"visualEditor.exitDrawMode": "raw.drawExitMode",
|
|
18
|
+
"visualEditor.undoStroke": "raw.undoStroke",
|
|
19
|
+
"visualEditor.redoStroke": "raw.redoStroke",
|
|
20
|
+
"visualEditor.tellAgentWhatToDo": "raw.tellAgentDo",
|
|
21
|
+
"visualEditor.send": "raw.sendToAgent",
|
|
22
|
+
"visualEditor.sendingDrawing": "raw.sendToAgent",
|
|
192
23
|
};
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
setTextInput(null);
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
setTextAnnotations((prev) => [
|
|
200
|
-
...prev,
|
|
201
|
-
{
|
|
202
|
-
id: crypto.randomUUID(),
|
|
203
|
-
type: "text",
|
|
204
|
-
text: textInput.value.trim(),
|
|
205
|
-
position: { x: textInput.x, y: textInput.y },
|
|
206
|
-
color,
|
|
207
|
-
lineWidth,
|
|
208
|
-
},
|
|
209
|
-
]);
|
|
210
|
-
setTextInput(null);
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
const send = () => {
|
|
214
|
-
const canvas = canvasRef.current;
|
|
215
|
-
if (!canvas) return;
|
|
216
|
-
const rect = canvas.getBoundingClientRect();
|
|
217
|
-
|
|
218
|
-
const pathAnnotations: DrawAnnotation[] = strokes.map((s) => ({
|
|
219
|
-
id: s.id,
|
|
220
|
-
type: "path",
|
|
221
|
-
pathData: s.points
|
|
222
|
-
.map(
|
|
223
|
-
(p, i) => `${i === 0 ? "M" : "L"}${p.x.toFixed(1)},${p.y.toFixed(1)}`,
|
|
224
|
-
)
|
|
225
|
-
.join(" "),
|
|
226
|
-
color: s.color,
|
|
227
|
-
lineWidth: s.lineWidth,
|
|
228
|
-
position: { x: 0, y: 0 },
|
|
229
|
-
}));
|
|
230
|
-
|
|
231
|
-
const all = [...pathAnnotations, ...textAnnotations];
|
|
232
|
-
if (all.length === 0 && !instruction.trim()) return;
|
|
233
|
-
|
|
234
|
-
onSend(all, instruction.trim(), {
|
|
235
|
-
width: rect.width,
|
|
236
|
-
height: rect.height,
|
|
237
|
-
});
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
if (!visible) return null;
|
|
241
|
-
|
|
242
|
-
const hasContent =
|
|
243
|
-
strokes.length > 0 || textAnnotations.length > 0 || instruction.trim();
|
|
244
|
-
|
|
245
|
-
return (
|
|
246
|
-
<div
|
|
247
|
-
ref={containerRef}
|
|
248
|
-
data-draw-overlay
|
|
249
|
-
className="absolute inset-0 z-30 pointer-events-auto"
|
|
250
|
-
>
|
|
251
|
-
{/* Drawing canvas */}
|
|
252
|
-
<canvas
|
|
253
|
-
ref={canvasRef}
|
|
254
|
-
data-draw-canvas
|
|
255
|
-
className={cn(
|
|
256
|
-
"absolute inset-0 h-full w-full",
|
|
257
|
-
textMode ? "cursor-text" : "cursor-crosshair",
|
|
258
|
-
)}
|
|
259
|
-
onPointerDown={handlePointerDown}
|
|
260
|
-
onPointerMove={handlePointerMove}
|
|
261
|
-
onPointerUp={handlePointerUp}
|
|
262
|
-
/>
|
|
263
|
-
|
|
264
|
-
{/* Rendered text annotations */}
|
|
265
|
-
{textAnnotations.map((ann) => (
|
|
266
|
-
<div
|
|
267
|
-
key={ann.id}
|
|
268
|
-
className="absolute pointer-events-none select-none whitespace-nowrap font-semibold"
|
|
269
|
-
style={{
|
|
270
|
-
left: ann.position.x,
|
|
271
|
-
top: ann.position.y,
|
|
272
|
-
color: ann.color,
|
|
273
|
-
fontSize: 14 + ann.lineWidth,
|
|
274
|
-
}}
|
|
275
|
-
>
|
|
276
|
-
{ann.text}
|
|
277
|
-
</div>
|
|
278
|
-
))}
|
|
279
|
-
|
|
280
|
-
{/* Pending text input */}
|
|
281
|
-
{textInput && (
|
|
282
|
-
<div
|
|
283
|
-
className="absolute z-40"
|
|
284
|
-
style={{ left: textInput.x, top: textInput.y }}
|
|
285
|
-
>
|
|
286
|
-
<Input
|
|
287
|
-
value={textInput.value}
|
|
288
|
-
onChange={(e) =>
|
|
289
|
-
setTextInput((prev) =>
|
|
290
|
-
prev ? { ...prev, value: e.target.value } : null,
|
|
291
|
-
)
|
|
292
|
-
}
|
|
293
|
-
onBlur={commitTextAnnotation}
|
|
294
|
-
onKeyDown={(e) => {
|
|
295
|
-
if (e.key === "Enter") {
|
|
296
|
-
e.preventDefault();
|
|
297
|
-
commitTextAnnotation();
|
|
298
|
-
}
|
|
299
|
-
}}
|
|
300
|
-
className="h-7 w-48 border-primary bg-background text-sm"
|
|
301
|
-
autoFocus
|
|
302
|
-
placeholder={t("raw.typeAnnotation")}
|
|
303
|
-
/>
|
|
304
|
-
</div>
|
|
305
|
-
)}
|
|
306
|
-
|
|
307
|
-
{/* Bottom toolbar */}
|
|
308
|
-
<div
|
|
309
|
-
data-draw-toolbar
|
|
310
|
-
className="absolute left-1/2 top-full z-40 mt-3 flex max-w-[min(calc(100vw-2rem),44rem)] -translate-x-1/2 flex-wrap items-center justify-center gap-2 rounded-xl border border-border bg-popover px-3 py-2 shadow-2xl"
|
|
311
|
-
>
|
|
312
|
-
{/* Color picker */}
|
|
313
|
-
<div className="flex gap-1">
|
|
314
|
-
{PRESET_COLORS.map((preset) => (
|
|
315
|
-
<Tooltip key={preset.color}>
|
|
316
|
-
<TooltipTrigger asChild>
|
|
317
|
-
<button
|
|
318
|
-
onClick={() => setColor(preset.color)}
|
|
319
|
-
className={cn(
|
|
320
|
-
"h-5 w-5 cursor-pointer rounded-full",
|
|
321
|
-
color === preset.color
|
|
322
|
-
? "ring-2 ring-foreground ring-offset-1 ring-offset-popover"
|
|
323
|
-
: "ring-1 ring-border",
|
|
324
|
-
)}
|
|
325
|
-
style={{ backgroundColor: preset.color }}
|
|
326
|
-
/>
|
|
327
|
-
</TooltipTrigger>
|
|
328
|
-
<TooltipContent>{preset.label}</TooltipContent>
|
|
329
|
-
</Tooltip>
|
|
330
|
-
))}
|
|
331
|
-
</div>
|
|
332
|
-
|
|
333
|
-
<div className="mx-1 h-4 w-px bg-border" />
|
|
334
|
-
|
|
335
|
-
{/* Line widths */}
|
|
336
|
-
<div className="flex gap-1">
|
|
337
|
-
{LINE_WIDTHS.map((lw) => (
|
|
338
|
-
<Tooltip key={lw.value}>
|
|
339
|
-
<TooltipTrigger asChild>
|
|
340
|
-
<button
|
|
341
|
-
onClick={() => setLineWidth(lw.value)}
|
|
342
|
-
className={cn(
|
|
343
|
-
"flex h-6 w-6 cursor-pointer items-center justify-center rounded",
|
|
344
|
-
lineWidth === lw.value
|
|
345
|
-
? "bg-accent text-foreground"
|
|
346
|
-
: "text-muted-foreground hover:text-foreground",
|
|
347
|
-
)}
|
|
348
|
-
>
|
|
349
|
-
<div
|
|
350
|
-
className="rounded-full bg-current"
|
|
351
|
-
style={{ width: lw.value + 2, height: lw.value + 2 }}
|
|
352
|
-
/>
|
|
353
|
-
</button>
|
|
354
|
-
</TooltipTrigger>
|
|
355
|
-
<TooltipContent>{lw.label}</TooltipContent>
|
|
356
|
-
</Tooltip>
|
|
357
|
-
))}
|
|
358
|
-
</div>
|
|
359
|
-
|
|
360
|
-
<div className="mx-1 h-4 w-px bg-border" />
|
|
361
|
-
|
|
362
|
-
{/* Text mode */}
|
|
363
|
-
<Tooltip>
|
|
364
|
-
<TooltipTrigger asChild>
|
|
365
|
-
<button
|
|
366
|
-
onClick={() => setTextMode(!textMode)}
|
|
367
|
-
className={cn(
|
|
368
|
-
"flex h-6 w-6 cursor-pointer items-center justify-center rounded",
|
|
369
|
-
textMode
|
|
370
|
-
? "bg-accent text-foreground"
|
|
371
|
-
: "text-muted-foreground hover:text-foreground",
|
|
372
|
-
)}
|
|
373
|
-
>
|
|
374
|
-
<IconCursorText className="h-3.5 w-3.5" />
|
|
375
|
-
</button>
|
|
376
|
-
</TooltipTrigger>
|
|
377
|
-
<TooltipContent>{t("raw.typeAnywhere")}</TooltipContent>
|
|
378
|
-
</Tooltip>
|
|
379
|
-
|
|
380
|
-
{/* Undo last stroke */}
|
|
381
|
-
<Tooltip>
|
|
382
|
-
<TooltipTrigger asChild>
|
|
383
|
-
<button
|
|
384
|
-
onClick={undo}
|
|
385
|
-
disabled={strokes.length === 0}
|
|
386
|
-
className="flex h-6 w-6 cursor-pointer items-center justify-center rounded text-muted-foreground hover:text-foreground disabled:cursor-default disabled:opacity-30"
|
|
387
|
-
>
|
|
388
|
-
<IconArrowBackUp className="h-3.5 w-3.5" />
|
|
389
|
-
</button>
|
|
390
|
-
</TooltipTrigger>
|
|
391
|
-
<TooltipContent>{t("raw.undoStroke")}</TooltipContent>
|
|
392
|
-
</Tooltip>
|
|
393
|
-
|
|
394
|
-
{/* Clear all */}
|
|
395
|
-
<Tooltip>
|
|
396
|
-
<TooltipTrigger asChild>
|
|
397
|
-
<button
|
|
398
|
-
onClick={clear}
|
|
399
|
-
disabled={strokes.length === 0 && textAnnotations.length === 0}
|
|
400
|
-
className="flex h-6 w-6 cursor-pointer items-center justify-center rounded text-muted-foreground hover:text-foreground disabled:cursor-default disabled:opacity-30"
|
|
401
|
-
>
|
|
402
|
-
<IconEraser className="h-3.5 w-3.5" />
|
|
403
|
-
</button>
|
|
404
|
-
</TooltipTrigger>
|
|
405
|
-
<TooltipContent>{t("raw.drawClearAll")}</TooltipContent>
|
|
406
|
-
</Tooltip>
|
|
407
|
-
|
|
408
|
-
<div className="mx-1 h-4 w-px bg-border" />
|
|
409
|
-
|
|
410
|
-
{/* Instruction input */}
|
|
411
|
-
<Input
|
|
412
|
-
value={instruction}
|
|
413
|
-
onChange={(e) => setInstruction(e.target.value)}
|
|
414
|
-
onKeyDown={(e) => {
|
|
415
|
-
if (e.key === "Enter" && hasContent) send();
|
|
416
|
-
}}
|
|
417
|
-
placeholder={t("raw.tellAgentDo")}
|
|
418
|
-
className="h-7 w-48 border-border bg-background text-xs sm:w-56"
|
|
419
|
-
/>
|
|
420
|
-
|
|
421
|
-
{/* Send */}
|
|
422
|
-
<Button
|
|
423
|
-
size="sm"
|
|
424
|
-
className="h-7 gap-1 px-3 text-[11px] cursor-pointer"
|
|
425
|
-
onClick={send}
|
|
426
|
-
disabled={!hasContent}
|
|
427
|
-
>
|
|
428
|
-
<IconSend className="h-3 w-3" />
|
|
429
|
-
Send
|
|
430
|
-
</Button>
|
|
431
|
-
|
|
432
|
-
{/* Close */}
|
|
433
|
-
<Tooltip>
|
|
434
|
-
<TooltipTrigger asChild>
|
|
435
|
-
<button
|
|
436
|
-
onClick={onClose}
|
|
437
|
-
className="flex h-6 w-6 cursor-pointer items-center justify-center rounded text-muted-foreground hover:text-foreground"
|
|
438
|
-
>
|
|
439
|
-
<IconX className="h-3.5 w-3.5" />
|
|
440
|
-
</button>
|
|
441
|
-
</TooltipTrigger>
|
|
442
|
-
<TooltipContent>{t("raw.drawExitMode")}</TooltipContent>
|
|
443
|
-
</Tooltip>
|
|
444
|
-
</div>
|
|
445
|
-
</div>
|
|
446
|
-
);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
function drawStroke(
|
|
450
|
-
ctx: CanvasRenderingContext2D,
|
|
451
|
-
points: Point[],
|
|
452
|
-
color: string,
|
|
453
|
-
lineWidth: number,
|
|
454
|
-
) {
|
|
455
|
-
if (points.length < 2) return;
|
|
456
|
-
ctx.beginPath();
|
|
457
|
-
ctx.strokeStyle = color;
|
|
458
|
-
ctx.lineWidth = lineWidth;
|
|
459
|
-
ctx.lineCap = "round";
|
|
460
|
-
ctx.lineJoin = "round";
|
|
461
|
-
ctx.moveTo(points[0].x, points[0].y);
|
|
462
|
-
for (let i = 1; i < points.length; i++) {
|
|
463
|
-
ctx.lineTo(points[i].x, points[i].y);
|
|
464
|
-
}
|
|
465
|
-
ctx.stroke();
|
|
24
|
+
const translate: ToolkitDrawOverlayProps["translate"] = (key, options) =>
|
|
25
|
+
t(keyMap[key] ?? key, options);
|
|
26
|
+
return <ToolkitDrawOverlay {...props} translate={translate} />;
|
|
466
27
|
}
|