@agent-native/core 0.112.0 → 0.113.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/corpus/README.md +4 -2
- package/corpus/core/CHANGELOG.md +22 -0
- package/corpus/core/docs/AGENTS.md +7 -0
- package/corpus/core/docs/content/integrations.mdx +63 -2
- package/corpus/core/docs/design/provider-integration-authority.md +117 -0
- package/corpus/core/package.json +6 -1
- package/corpus/core/scripts/materialize-source-corpus.mjs +9 -2
- package/corpus/core/src/cli/atomic-json-file.ts +324 -0
- package/corpus/core/src/cli/claude-code-participant.ts +515 -0
- package/corpus/core/src/cli/code-agent-executor.ts +18 -10
- package/corpus/core/src/cli/code-agent-runs.concurrent-worker.ts +33 -0
- package/corpus/core/src/cli/code-agent-runs.ts +55 -62
- package/corpus/core/src/cli/codex-cli-participant.ts +496 -0
- package/corpus/core/src/cli/multi-frontier-runs.ts +1246 -135
- package/corpus/core/src/client/chat/ChatHistoryList.tsx +7 -404
- package/corpus/core/src/integrations/index.ts +10 -0
- package/corpus/core/src/integrations/slack-oauth.ts +1 -0
- package/corpus/core/src/integrations/webhook-delivery.ts +55 -0
- package/corpus/core/src/notifications/channels.ts +4 -10
- package/corpus/core/src/provider-api/actions/custom-provider-registration.ts +197 -0
- package/corpus/core/src/provider-api/actions/delete-staged-dataset.ts +3 -42
- package/corpus/core/src/provider-api/actions/list-staged-datasets.ts +3 -45
- package/corpus/core/src/provider-api/actions/provider-api-audit.ts +88 -0
- package/corpus/core/src/provider-api/actions/provider-api.ts +460 -0
- package/corpus/core/src/provider-api/actions/query-staged-dataset.ts +3 -140
- package/corpus/core/src/provider-api/actions/staged-datasets.ts +359 -0
- package/corpus/core/src/provider-api/gong.ts +108 -0
- package/corpus/core/src/scripts/docs/source-search.ts +2 -1
- package/corpus/core/src/server/google-oauth-credentials.ts +80 -3
- package/corpus/core/src/server/index.ts +6 -0
- package/corpus/core/src/styles/chat-history-list.css +1 -313
- package/corpus/core/src/templates/default/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/core/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/core/src/templates/default/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/core/src/templates/default/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/corpus/core/src/templates/default/.agents/skills/onboarding/SKILL.md +56 -0
- package/corpus/core/src/templates/default/.agents/skills/secrets/SKILL.md +273 -0
- package/corpus/core/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/core/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/core/src/templates/default/AGENTS.md +25 -18
- package/corpus/core/src/templates/headless/.agents/skills/actions/SKILL.md +512 -0
- package/corpus/core/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/core/src/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/core/src/templates/headless/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/corpus/core/src/templates/headless/.agents/skills/secrets/SKILL.md +273 -0
- package/corpus/core/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/core/src/templates/headless/AGENTS.md +7 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/core/src/templates/workspace-core/AGENTS.md +4 -0
- package/corpus/core/src/templates/workspace-root/AGENTS.md +4 -0
- package/corpus/templates/analytics/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/analytics/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/analytics/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/analytics/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/analytics/actions/delete-staged-dataset.ts +3 -23
- package/corpus/templates/analytics/actions/list-staged-datasets.ts +3 -27
- package/corpus/templates/analytics/actions/provider-api-catalog.ts +16 -19
- package/corpus/templates/analytics/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/analytics/actions/provider-api-request.ts +162 -185
- package/corpus/templates/analytics/actions/query-staged-dataset.ts +3 -47
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +52 -161
- package/corpus/templates/assets/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/assets/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/assets/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/assets/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/assets/app/components/layout/Sidebar.tsx +63 -160
- package/corpus/templates/brain/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/brain/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/brain/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/brain/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/brain/actions/_schemas.ts +13 -7
- package/corpus/templates/brain/actions/delete-staged-dataset.ts +3 -24
- package/corpus/templates/brain/actions/list-staged-datasets.ts +3 -28
- package/corpus/templates/brain/actions/provider-api-catalog.ts +5 -11
- package/corpus/templates/brain/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/brain/actions/provider-api-request.ts +3 -37
- package/corpus/templates/brain/actions/query-staged-dataset.ts +3 -48
- package/corpus/templates/brain/actions/update-source.ts +5 -1
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +48 -154
- package/corpus/templates/brain/app/lib/brain.ts +55 -0
- package/corpus/templates/brain/app/lib/ingest-handoff.ts +35 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-backfills-can-now-join-configured-public-channels-befo.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-backfills-now-continue-across-the-configured-number-of.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-backfills-now-start-with-a-safe-four-week-window-and-r.md +6 -0
- package/corpus/templates/brain/server/lib/connectors.ts +53 -2
- package/corpus/templates/brain/server/lib/slack-channel-membership.ts +44 -0
- package/corpus/templates/brain/shared/slack-source-config.ts +60 -0
- package/corpus/templates/calendar/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/calendar/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/calendar/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/calendar/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/calendar/actions/delete-staged-dataset.ts +3 -24
- package/corpus/templates/calendar/actions/list-staged-datasets.ts +3 -28
- package/corpus/templates/calendar/actions/provider-api-catalog.ts +5 -11
- package/corpus/templates/calendar/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/calendar/actions/provider-api-request.ts +3 -37
- package/corpus/templates/calendar/actions/query-staged-dataset.ts +3 -48
- package/corpus/templates/calendar/server/handlers/gong.ts +6 -61
- package/corpus/templates/calendar/server/handlers/google-auth.ts +10 -8
- package/corpus/templates/calendar/server/lib/google-calendar.ts +7 -45
- package/corpus/templates/chat/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/chat/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/chat/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/chat/AGENTS.md +5 -2
- package/corpus/templates/chat/app/components/layout/Sidebar.tsx +51 -157
- package/corpus/templates/clips/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/clips/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/clips/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/clips/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/clips/AGENTS.md +11 -0
- package/corpus/templates/clips/actions/export-to-brain.ts +505 -171
- package/corpus/templates/clips/changelog/2026-07-19-ready-clips-transcripts-can-be-backfilled-to-brain-for-a-bou.md +6 -0
- package/corpus/templates/clips/server/lib/calendar-event-meetings.ts +1 -1
- package/corpus/templates/clips/server/lib/google-calendar-client.ts +12 -22
- package/corpus/templates/clips/server/lib/google-calendar-oauth.ts +9 -6
- package/corpus/templates/clips/server/lib/slack-oauth.ts +12 -47
- package/corpus/templates/clips/server/routes/_agent-native/google/auth-url.get.ts +2 -6
- package/corpus/templates/clips/server/routes/api/auth/google-calendar.get.ts +4 -4
- package/corpus/templates/content/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/content/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/content/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/content/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/content/actions/delete-staged-dataset.ts +3 -24
- package/corpus/templates/content/actions/list-staged-datasets.ts +3 -28
- package/corpus/templates/content/actions/provider-api-catalog.ts +5 -11
- package/corpus/templates/content/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/content/actions/provider-api-request.ts +3 -37
- package/corpus/templates/content/actions/query-staged-dataset.ts +3 -48
- package/corpus/templates/design/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/design/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/design/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/design/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/design/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/design/actions/list-staged-datasets.ts +4 -27
- package/corpus/templates/design/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/design/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/design/actions/provider-api-request.ts +140 -164
- package/corpus/templates/design/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/dispatch/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/dispatch/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/dispatch/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/dispatch/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/dispatch/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/dispatch/actions/list-staged-datasets.ts +4 -30
- package/corpus/templates/dispatch/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/dispatch/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/dispatch/actions/provider-api-request.ts +138 -163
- package/corpus/templates/dispatch/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/forms/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/forms/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/forms/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/forms/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/forms/server/lib/integrations.ts +23 -22
- package/corpus/templates/macros/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/macros/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/mail/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/mail/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/mail/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/mail/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/mail/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/mail/actions/list-staged-datasets.ts +4 -27
- package/corpus/templates/mail/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/mail/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/mail/actions/provider-api-request.ts +146 -173
- package/corpus/templates/mail/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/mail/server/handlers/gong.ts +6 -61
- package/corpus/templates/mail/server/lib/google-auth.ts +10 -13
- package/corpus/templates/plan/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/plan/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/plan/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/plan/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +47 -156
- package/corpus/templates/slides/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/slides/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/slides/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/slides/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/slides/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/slides/actions/list-staged-datasets.ts +4 -27
- package/corpus/templates/slides/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/slides/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/slides/actions/provider-api-request.ts +145 -172
- package/corpus/templates/slides/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/slides/server/lib/google-docs-oauth.ts +11 -36
- package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/tasks/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/templates/tasks/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/tasks/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/tasks/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/toolkit/CHANGELOG.md +125 -0
- package/corpus/toolkit/README.md +60 -0
- package/corpus/toolkit/export-snapshot.json +35 -0
- package/corpus/toolkit/migration-manifest.json +4 -0
- package/corpus/toolkit/package.json +281 -0
- package/corpus/toolkit/scripts/finalize-build.mjs +55 -0
- package/corpus/toolkit/src/app-shell/header-actions.tsx +84 -0
- package/corpus/toolkit/src/app-shell/index.ts +1 -0
- package/corpus/toolkit/src/chat-history/ChatHistoryList.tsx +469 -0
- package/corpus/toolkit/src/chat-history/index.ts +7 -0
- package/corpus/toolkit/src/chat-history.css +314 -0
- package/corpus/toolkit/src/collab-ui/AgentPresenceChip.tsx +69 -0
- package/corpus/toolkit/src/collab-ui/LiveCursorOverlay.tsx +241 -0
- package/corpus/toolkit/src/collab-ui/PresenceBar.tsx +346 -0
- package/corpus/toolkit/src/collab-ui/RecentEditHighlights.tsx +225 -0
- package/corpus/toolkit/src/collab-ui/RemoteSelectionRings.tsx +227 -0
- package/corpus/toolkit/src/collab-ui/agent-identity.ts +16 -0
- package/corpus/toolkit/src/collab-ui/index.ts +39 -0
- package/corpus/toolkit/src/collab-ui/lead-client.ts +32 -0
- package/corpus/toolkit/src/collab-ui/types.ts +96 -0
- package/corpus/toolkit/src/composer/AgentComposerFrame.tsx +59 -0
- package/corpus/toolkit/src/composer/ComposerPlusMenu.tsx +983 -0
- package/corpus/toolkit/src/composer/MentionPopover.tsx +412 -0
- package/corpus/toolkit/src/composer/PastedTextChip.tsx +150 -0
- package/corpus/toolkit/src/composer/PromptComposer.tsx +718 -0
- package/corpus/toolkit/src/composer/RealtimeVoiceMode.tsx +856 -0
- package/corpus/toolkit/src/composer/TiptapComposer.tsx +2936 -0
- package/corpus/toolkit/src/composer/VoiceButton.tsx +255 -0
- package/corpus/toolkit/src/composer/asset-picker-url.ts +80 -0
- package/corpus/toolkit/src/composer/attachment-accept.ts +71 -0
- package/corpus/toolkit/src/composer/draft-key.ts +7 -0
- package/corpus/toolkit/src/composer/extensions/FileReference.tsx +55 -0
- package/corpus/toolkit/src/composer/extensions/MentionReference.tsx +93 -0
- package/corpus/toolkit/src/composer/extensions/SkillReference.tsx +56 -0
- package/corpus/toolkit/src/composer/index.ts +79 -0
- package/corpus/toolkit/src/composer/pasted-text.ts +160 -0
- package/corpus/toolkit/src/composer/prompt-attachments.ts +93 -0
- package/corpus/toolkit/src/composer/realtime-voice-audio-level.ts +64 -0
- package/corpus/toolkit/src/composer/realtime-voice-transcript.ts +134 -0
- package/corpus/toolkit/src/composer/runtime-adapters.tsx +343 -0
- package/corpus/toolkit/src/composer/types.ts +66 -0
- package/corpus/toolkit/src/composer/use-file-search.ts +64 -0
- package/corpus/toolkit/src/composer/use-mention-search.ts +90 -0
- package/corpus/toolkit/src/composer/use-skills.ts +45 -0
- package/corpus/toolkit/src/composer/useRealtimeVoiceMode.tsx +2117 -0
- package/corpus/toolkit/src/composer/useVoiceDictation.ts +1191 -0
- package/corpus/toolkit/src/context-ui/ContextMeter.tsx +101 -0
- package/corpus/toolkit/src/context-ui/ContextSegmentRow.tsx +184 -0
- package/corpus/toolkit/src/context-ui/ContextTreemap.tsx +125 -0
- package/corpus/toolkit/src/context-ui/ContextXRayPanel.tsx +377 -0
- package/corpus/toolkit/src/context-ui/format.ts +42 -0
- package/corpus/toolkit/src/context-ui/index.ts +15 -0
- package/corpus/toolkit/src/context-ui/types.ts +43 -0
- package/corpus/toolkit/src/design-tweaks/index.ts +1 -0
- package/corpus/toolkit/src/design-tweaks/visual-style-controls.tsx +1084 -0
- package/corpus/toolkit/src/editor/BubbleToolbar.tsx +253 -0
- package/corpus/toolkit/src/editor/CodeBlockNode.tsx +254 -0
- package/corpus/toolkit/src/editor/DragHandle.ts +1437 -0
- package/corpus/toolkit/src/editor/ImageExtension.ts +306 -0
- package/corpus/toolkit/src/editor/RegistryBlockContext.tsx +107 -0
- package/corpus/toolkit/src/editor/RegistryBlockNode.tsx +652 -0
- package/corpus/toolkit/src/editor/RichMarkdownEditor.tsx +81 -0
- package/corpus/toolkit/src/editor/RunId.ts +61 -0
- package/corpus/toolkit/src/editor/SharedRichEditor.tsx +321 -0
- package/corpus/toolkit/src/editor/SlashCommandMenu.tsx +310 -0
- package/corpus/toolkit/src/editor/extensions.ts +402 -0
- package/corpus/toolkit/src/editor/gfmDoc.ts +92 -0
- package/corpus/toolkit/src/editor/index.ts +93 -0
- package/corpus/toolkit/src/editor/registrySlashCommands.ts +131 -0
- package/corpus/toolkit/src/editor/surgical-apply.ts +192 -0
- package/corpus/toolkit/src/editor/useCollabReconcile.ts +589 -0
- package/corpus/toolkit/src/editor.css +510 -0
- package/corpus/toolkit/src/hooks/index.ts +2 -0
- package/corpus/toolkit/src/hooks/use-mobile.tsx +21 -0
- package/corpus/toolkit/src/hooks/use-toast.ts +188 -0
- package/corpus/toolkit/src/index.ts +8 -0
- package/corpus/toolkit/src/onboarding/index.ts +1 -0
- package/corpus/toolkit/src/provider.tsx +47 -0
- package/corpus/toolkit/src/sharing/VisibilityBadge.tsx +37 -0
- package/corpus/toolkit/src/sharing/index.ts +4 -0
- package/corpus/toolkit/src/styles.css +21 -0
- package/corpus/toolkit/src/ui/accordion.tsx +56 -0
- package/corpus/toolkit/src/ui/alert-dialog.tsx +141 -0
- package/corpus/toolkit/src/ui/alert.tsx +59 -0
- package/corpus/toolkit/src/ui/aspect-ratio.tsx +5 -0
- package/corpus/toolkit/src/ui/avatar.tsx +48 -0
- package/corpus/toolkit/src/ui/badge.tsx +37 -0
- package/corpus/toolkit/src/ui/breadcrumb.tsx +115 -0
- package/corpus/toolkit/src/ui/button.tsx +78 -0
- package/corpus/toolkit/src/ui/calendar.tsx +214 -0
- package/corpus/toolkit/src/ui/card.tsx +86 -0
- package/corpus/toolkit/src/ui/carousel.tsx +260 -0
- package/corpus/toolkit/src/ui/chart.tsx +375 -0
- package/corpus/toolkit/src/ui/checkbox.tsx +28 -0
- package/corpus/toolkit/src/ui/collapsible.tsx +9 -0
- package/corpus/toolkit/src/ui/command.tsx +174 -0
- package/corpus/toolkit/src/ui/context-menu.tsx +202 -0
- package/corpus/toolkit/src/ui/date-picker.tsx +64 -0
- package/corpus/toolkit/src/ui/dialog.tsx +146 -0
- package/corpus/toolkit/src/ui/drawer.tsx +126 -0
- package/corpus/toolkit/src/ui/dropdown-menu.tsx +218 -0
- package/corpus/toolkit/src/ui/form.tsx +177 -0
- package/corpus/toolkit/src/ui/hover-card.tsx +27 -0
- package/corpus/toolkit/src/ui/index.ts +52 -0
- package/corpus/toolkit/src/ui/input-otp.tsx +69 -0
- package/corpus/toolkit/src/ui/input.tsx +22 -0
- package/corpus/toolkit/src/ui/label.tsx +24 -0
- package/corpus/toolkit/src/ui/logo.tsx +36 -0
- package/corpus/toolkit/src/ui/menubar.tsx +235 -0
- package/corpus/toolkit/src/ui/navigation-menu.tsx +128 -0
- package/corpus/toolkit/src/ui/pagination.tsx +121 -0
- package/corpus/toolkit/src/ui/popover.tsx +44 -0
- package/corpus/toolkit/src/ui/progress.tsx +26 -0
- package/corpus/toolkit/src/ui/radio-group.tsx +42 -0
- package/corpus/toolkit/src/ui/resizable.tsx +43 -0
- package/corpus/toolkit/src/ui/scroll-area.tsx +46 -0
- package/corpus/toolkit/src/ui/select.tsx +158 -0
- package/corpus/toolkit/src/ui/separator.tsx +29 -0
- package/corpus/toolkit/src/ui/sheet.tsx +160 -0
- package/corpus/toolkit/src/ui/sidebar.tsx +777 -0
- package/corpus/toolkit/src/ui/skeleton.tsx +18 -0
- package/corpus/toolkit/src/ui/slider.tsx +26 -0
- package/corpus/toolkit/src/ui/sonner.tsx +58 -0
- package/corpus/toolkit/src/ui/spinner.tsx +17 -0
- package/corpus/toolkit/src/ui/switch.tsx +27 -0
- package/corpus/toolkit/src/ui/table.tsx +117 -0
- package/corpus/toolkit/src/ui/tabs.tsx +53 -0
- package/corpus/toolkit/src/ui/textarea.tsx +23 -0
- package/corpus/toolkit/src/ui/toast.tsx +127 -0
- package/corpus/toolkit/src/ui/toaster.tsx +33 -0
- package/corpus/toolkit/src/ui/toggle-group.tsx +59 -0
- package/corpus/toolkit/src/ui/toggle.tsx +43 -0
- package/corpus/toolkit/src/ui/tooltip.tsx +53 -0
- package/corpus/toolkit/src/ui/use-toast.ts +3 -0
- package/corpus/toolkit/src/utils.ts +8 -0
- package/corpus/toolkit/tsconfig.json +23 -0
- package/dist/cli/atomic-json-file.d.ts +30 -0
- package/dist/cli/atomic-json-file.d.ts.map +1 -0
- package/dist/cli/atomic-json-file.js +240 -0
- package/dist/cli/atomic-json-file.js.map +1 -0
- package/dist/cli/claude-code-participant.d.ts +77 -0
- package/dist/cli/claude-code-participant.d.ts.map +1 -0
- package/dist/cli/claude-code-participant.js +355 -0
- package/dist/cli/claude-code-participant.js.map +1 -0
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +18 -10
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/code-agent-runs.concurrent-worker.d.ts +2 -0
- package/dist/cli/code-agent-runs.concurrent-worker.d.ts.map +1 -0
- package/dist/cli/code-agent-runs.concurrent-worker.js +32 -0
- package/dist/cli/code-agent-runs.concurrent-worker.js.map +1 -0
- package/dist/cli/code-agent-runs.d.ts.map +1 -1
- package/dist/cli/code-agent-runs.js +43 -56
- package/dist/cli/code-agent-runs.js.map +1 -1
- package/dist/cli/codex-cli-participant.d.ts +77 -0
- package/dist/cli/codex-cli-participant.d.ts.map +1 -0
- package/dist/cli/codex-cli-participant.js +354 -0
- package/dist/cli/codex-cli-participant.js.map +1 -0
- package/dist/cli/multi-frontier-runs.d.ts +115 -0
- package/dist/cli/multi-frontier-runs.d.ts.map +1 -1
- package/dist/cli/multi-frontier-runs.js +831 -113
- package/dist/cli/multi-frontier-runs.js.map +1 -1
- package/dist/client/chat/ChatHistoryList.d.ts +1 -87
- package/dist/client/chat/ChatHistoryList.d.ts.map +1 -1
- package/dist/client/chat/ChatHistoryList.js +1 -82
- package/dist/client/chat/ChatHistoryList.js.map +1 -1
- package/dist/integrations/index.d.ts +2 -1
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +2 -1
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/slack-manifest.d.ts +1 -1
- package/dist/integrations/slack-oauth.d.ts +1 -1
- package/dist/integrations/slack-oauth.d.ts.map +1 -1
- package/dist/integrations/slack-oauth.js +1 -0
- package/dist/integrations/slack-oauth.js.map +1 -1
- package/dist/integrations/webhook-delivery.d.ts +23 -0
- package/dist/integrations/webhook-delivery.d.ts.map +1 -0
- package/dist/integrations/webhook-delivery.js +32 -0
- package/dist/integrations/webhook-delivery.js.map +1 -0
- package/dist/notifications/channels.d.ts.map +1 -1
- package/dist/notifications/channels.js +4 -9
- package/dist/notifications/channels.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/provider-api/actions/custom-provider-registration.d.ts +136 -0
- package/dist/provider-api/actions/custom-provider-registration.d.ts.map +1 -0
- package/dist/provider-api/actions/custom-provider-registration.js +154 -0
- package/dist/provider-api/actions/custom-provider-registration.js.map +1 -0
- package/dist/provider-api/actions/delete-staged-dataset.d.ts +1 -1
- package/dist/provider-api/actions/delete-staged-dataset.d.ts.map +1 -1
- package/dist/provider-api/actions/delete-staged-dataset.js +3 -34
- package/dist/provider-api/actions/delete-staged-dataset.js.map +1 -1
- package/dist/provider-api/actions/list-staged-datasets.d.ts +2 -3
- package/dist/provider-api/actions/list-staged-datasets.d.ts.map +1 -1
- package/dist/provider-api/actions/list-staged-datasets.js +3 -40
- package/dist/provider-api/actions/list-staged-datasets.js.map +1 -1
- package/dist/provider-api/actions/provider-api-audit.d.ts +7 -0
- package/dist/provider-api/actions/provider-api-audit.d.ts.map +1 -0
- package/dist/provider-api/actions/provider-api-audit.js +74 -0
- package/dist/provider-api/actions/provider-api-audit.js.map +1 -0
- package/dist/provider-api/actions/provider-api.d.ts +370 -0
- package/dist/provider-api/actions/provider-api.d.ts.map +1 -0
- package/dist/provider-api/actions/provider-api.js +280 -0
- package/dist/provider-api/actions/provider-api.js.map +1 -0
- package/dist/provider-api/actions/query-staged-dataset.d.ts +1 -1
- package/dist/provider-api/actions/query-staged-dataset.d.ts.map +1 -1
- package/dist/provider-api/actions/query-staged-dataset.js +3 -116
- package/dist/provider-api/actions/query-staged-dataset.js.map +1 -1
- package/dist/provider-api/actions/staged-datasets.d.ts +190 -0
- package/dist/provider-api/actions/staged-datasets.d.ts.map +1 -0
- package/dist/provider-api/actions/staged-datasets.js +210 -0
- package/dist/provider-api/actions/staged-datasets.js.map +1 -0
- package/dist/provider-api/gong.d.ts +44 -0
- package/dist/provider-api/gong.d.ts.map +1 -0
- package/dist/provider-api/gong.js +56 -0
- package/dist/provider-api/gong.js.map +1 -0
- package/dist/scripts/docs/source-search.d.ts +2 -1
- package/dist/scripts/docs/source-search.d.ts.map +1 -1
- package/dist/scripts/docs/source-search.js +2 -1
- package/dist/scripts/docs/source-search.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/google-oauth-credentials.d.ts +35 -0
- package/dist/server/google-oauth-credentials.d.ts.map +1 -1
- package/dist/server/google-oauth-credentials.js +48 -2
- package/dist/server/google-oauth-credentials.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/styles/chat-history-list.css +1 -313
- package/dist/templates/chat/.agents/skills/actions/SKILL.md +32 -12
- package/dist/templates/chat/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/dist/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/dist/templates/chat/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/dist/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/chat/AGENTS.md +5 -2
- package/dist/templates/chat/app/components/layout/Sidebar.tsx +51 -157
- package/dist/templates/default/.agents/skills/actions/SKILL.md +32 -12
- package/dist/templates/default/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/dist/templates/default/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/dist/templates/default/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/dist/templates/default/.agents/skills/onboarding/SKILL.md +56 -0
- package/dist/templates/default/.agents/skills/secrets/SKILL.md +273 -0
- package/dist/templates/default/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/dist/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/default/AGENTS.md +25 -18
- package/dist/templates/headless/.agents/skills/actions/SKILL.md +512 -0
- package/dist/templates/headless/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/dist/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/dist/templates/headless/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/dist/templates/headless/.agents/skills/secrets/SKILL.md +273 -0
- package/dist/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/headless/AGENTS.md +7 -0
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -12
- package/dist/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
- package/dist/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/dist/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/workspace-core/AGENTS.md +4 -0
- package/dist/templates/workspace-root/AGENTS.md +4 -0
- package/docs/AGENTS.md +7 -0
- package/docs/content/integrations.mdx +63 -2
- package/docs/design/provider-integration-authority.md +117 -0
- package/package.json +7 -2
- package/src/templates/chat/.agents/skills/actions/SKILL.md +32 -12
- package/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/src/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/src/templates/chat/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/chat/AGENTS.md +5 -2
- package/src/templates/chat/app/components/layout/Sidebar.tsx +51 -157
- package/src/templates/default/.agents/skills/actions/SKILL.md +32 -12
- package/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/src/templates/default/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/src/templates/default/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/src/templates/default/.agents/skills/onboarding/SKILL.md +56 -0
- package/src/templates/default/.agents/skills/secrets/SKILL.md +273 -0
- package/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/default/AGENTS.md +25 -18
- package/src/templates/headless/.agents/skills/actions/SKILL.md +512 -0
- package/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/src/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/src/templates/headless/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/src/templates/headless/.agents/skills/secrets/SKILL.md +273 -0
- package/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/headless/AGENTS.md +7 -0
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -12
- package/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
- package/src/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/workspace-core/AGENTS.md +4 -0
- package/src/templates/workspace-root/AGENTS.md +4 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// Page-sized pastes turn into a `Pasted text` attachment chip instead of being
|
|
2
|
+
// dumped into the editor. Short paragraphs and everyday lists should stay
|
|
3
|
+
// inline so the composer still feels like a normal text field.
|
|
4
|
+
const PASTED_TEXT_MIN_CHARS = 3200;
|
|
5
|
+
const PASTED_TEXT_MIN_LINES = 24;
|
|
6
|
+
|
|
7
|
+
const PASTED_TEXT_FILENAME_PREFIX = "pasted-text-";
|
|
8
|
+
|
|
9
|
+
// A copied HTML document/source is recognizable from its markup: a closing tag
|
|
10
|
+
// (`</div>`), a doctype, or a common structural/element tag. We key off the
|
|
11
|
+
// *content* the user actually pasted, not the clipboard's `text/html` flavor —
|
|
12
|
+
// editors (VS Code) and rich-text apps (Google Docs) populate `text/html` with
|
|
13
|
+
// syntax-highlight spans or formatting wrappers even when the real content is
|
|
14
|
+
// plain code/prose, so trusting `text/html` blindly would mangle those pastes.
|
|
15
|
+
const HTML_SOURCE_SIGNAL =
|
|
16
|
+
/<!doctype\s+html|<html[\s>]|<\/[a-z][a-z0-9-]*\s*>|<(?:body|head|div|span|section|main|header|footer|nav|article|aside|ul|ol|li|table|thead|tbody|tr|td|th|h[1-6]|p|a|img|button|input|textarea|select|form|label|script|style|link|meta|svg|canvas|template)\b/i;
|
|
17
|
+
|
|
18
|
+
// A real HTML *document* announces itself with a doctype / html / head / body.
|
|
19
|
+
// When one of these is present we keep the HTML classification even if an inline
|
|
20
|
+
// <script> contains JS keywords — it's a genuine page.
|
|
21
|
+
const HTML_DOCUMENT_SIGNAL =
|
|
22
|
+
/<!doctype\s+html|<html[\s>]|<head[\s>]|<body[\s>]/i;
|
|
23
|
+
|
|
24
|
+
// JSX/TSX source contains the same `</div>`/`<span>` tags as an HTML document,
|
|
25
|
+
// so the HTML tag signal alone misfiles a pasted React/TS component (even a bare
|
|
26
|
+
// function component) as an `.html` artifact — the agent then mishandles it as a
|
|
27
|
+
// hostable document instead of source. These markers appear in JS/TS/JSX source
|
|
28
|
+
// but not in a plain HTML *fragment*: `className=` (JSX uses it; HTML uses
|
|
29
|
+
// `class=`), ES module import/export, arrow functions, TS type/React annotations,
|
|
30
|
+
// React hooks, and the basic JS declaration/return keywords that make up a
|
|
31
|
+
// component body.
|
|
32
|
+
const CODE_SOURCE_SIGNAL =
|
|
33
|
+
/\bclassName=|\bimport\b|\bexport\b|=>|:\s*React\.|\buse[A-Z]\w*\(|\b(?:function|const|let|var|return|class|interface|type|enum)\b/;
|
|
34
|
+
|
|
35
|
+
function looksLikeHtml(value: string): boolean {
|
|
36
|
+
if (!value || !HTML_SOURCE_SIGNAL.test(value)) return false;
|
|
37
|
+
// A self-announcing HTML document stays HTML even if it embeds a <script>.
|
|
38
|
+
if (HTML_DOCUMENT_SIGNAL.test(value)) return true;
|
|
39
|
+
// Otherwise it's a bare fragment — if it carries JS/TS/JSX code signals,
|
|
40
|
+
// treat it as source code, not an HTML attachment.
|
|
41
|
+
if (CODE_SOURCE_SIGNAL.test(value)) return false;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The clipboard flavors we care about for a paste. */
|
|
46
|
+
export interface ClipboardPaste {
|
|
47
|
+
/** `text/plain` flavor — used for size heuristics and as the default body. */
|
|
48
|
+
text: string;
|
|
49
|
+
/** `text/html` flavor when the source provided one. */
|
|
50
|
+
html?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Read the relevant clipboard flavors from a paste/drop DataTransfer. */
|
|
54
|
+
export function readClipboardPaste(
|
|
55
|
+
data: { getData(type: string): string } | null | undefined,
|
|
56
|
+
): ClipboardPaste {
|
|
57
|
+
const text = data?.getData("text/plain") ?? "";
|
|
58
|
+
const html = data?.getData("text/html") ?? "";
|
|
59
|
+
return { text, html: html.trim() ? html : undefined };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface SelectedPasteBody {
|
|
63
|
+
body: string;
|
|
64
|
+
ext: "html" | "txt";
|
|
65
|
+
type: "text/html" | "text/plain";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Decide what to actually store for a paste. Preserving HTML markup means a
|
|
69
|
+
// pasted HTML document behaves exactly like uploading that .html file: the agent
|
|
70
|
+
// recognizes it as a hostable artifact and reads it verbatim via
|
|
71
|
+
// `contentFromAttachment` instead of retyping it inline (which cuts off
|
|
72
|
+
// mid-stream on large files and triggers a continuation loop / "spin").
|
|
73
|
+
function selectPasteBody(paste: ClipboardPaste): SelectedPasteBody {
|
|
74
|
+
const plain = paste.text ?? "";
|
|
75
|
+
const html = paste.html ?? "";
|
|
76
|
+
|
|
77
|
+
// 1) The pasted text is itself HTML source (copied from an editor, a file, or
|
|
78
|
+
// view-source). The plain text *is* the markup, so keep it as .html.
|
|
79
|
+
if (plain.trim() && looksLikeHtml(plain)) {
|
|
80
|
+
return { body: plain, ext: "html", type: "text/html" };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 2) No usable plain text, but a real HTML flavor exists (some apps only
|
|
84
|
+
// expose text/html). Fall back to the markup so nothing is dropped.
|
|
85
|
+
if (!plain.trim() && looksLikeHtml(html)) {
|
|
86
|
+
return { body: html, ext: "html", type: "text/html" };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 3) Default: keep the clean plain text. Avoids the syntax-highlight /
|
|
90
|
+
// rich-text noise that lives in text/html when the plain text is already
|
|
91
|
+
// the real content (code from an editor, prose from a doc).
|
|
92
|
+
return { body: plain, ext: "txt", type: "text/plain" };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function shouldConvertPasteToAttachment(text: string): boolean {
|
|
96
|
+
if (!text) return false;
|
|
97
|
+
if (text.length >= PASTED_TEXT_MIN_CHARS) return true;
|
|
98
|
+
let lines = 1;
|
|
99
|
+
for (let i = 0; i < text.length; i++) {
|
|
100
|
+
if (text.charCodeAt(i) === 10) {
|
|
101
|
+
lines++;
|
|
102
|
+
if (lines >= PASTED_TEXT_MIN_LINES) return true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Whether a clipboard paste is large enough to become a `Pasted text`
|
|
110
|
+
* attachment chip. Mirrors `shouldConvertPasteToAttachment` but evaluates the
|
|
111
|
+
* representation we'd actually store, so an HTML-only paste (empty text/plain)
|
|
112
|
+
* still converts on the strength of its markup.
|
|
113
|
+
*/
|
|
114
|
+
export function shouldConvertClipboardToAttachment(
|
|
115
|
+
paste: ClipboardPaste,
|
|
116
|
+
): boolean {
|
|
117
|
+
return shouldConvertPasteToAttachment(selectPasteBody(paste).body);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function pastedAttachmentName(ext: "html" | "txt"): string {
|
|
121
|
+
return `${PASTED_TEXT_FILENAME_PREFIX}${Date.now()}-${Math.random()
|
|
122
|
+
.toString(36)
|
|
123
|
+
.slice(2, 8)}.${ext}`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Build the attachment File for a page-sized paste, preserving HTML markup when
|
|
128
|
+
* the pasted content is an HTML document so it travels the same rail as an
|
|
129
|
+
* uploaded .html file.
|
|
130
|
+
*/
|
|
131
|
+
export function createPastedAttachmentFile(paste: ClipboardPaste): File {
|
|
132
|
+
const { body, ext, type } = selectPasteBody(paste);
|
|
133
|
+
return new File([body], pastedAttachmentName(ext), { type });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Back-compat helper for callers that only have plain text. */
|
|
137
|
+
export function createPastedTextFile(text: string): File {
|
|
138
|
+
return createPastedAttachmentFile({ text });
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function isPastedTextAttachmentName(name: string | undefined): boolean {
|
|
142
|
+
return !!name && name.startsWith(PASTED_TEXT_FILENAME_PREFIX);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Strips the `<attachment name=...>\n` / `\n</attachment>` envelope that
|
|
146
|
+
// SimpleTextAttachmentAdapter wraps the file body in when sending. Returns the
|
|
147
|
+
// raw body for previewing.
|
|
148
|
+
export function unwrapAttachmentEnvelope(text: string): string {
|
|
149
|
+
const match = text.match(/^<attachment\b[^>]*>\n([\s\S]*)\n<\/attachment>$/);
|
|
150
|
+
return match ? match[1] : text;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function countLines(text: string): number {
|
|
154
|
+
if (!text) return 0;
|
|
155
|
+
let lines = 1;
|
|
156
|
+
for (let i = 0; i < text.length; i++) {
|
|
157
|
+
if (text.charCodeAt(i) === 10) lines++;
|
|
158
|
+
}
|
|
159
|
+
return lines;
|
|
160
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export interface AgentPromptAttachment {
|
|
2
|
+
name: string;
|
|
3
|
+
type?: string;
|
|
4
|
+
size?: number;
|
|
5
|
+
text?: string;
|
|
6
|
+
dataUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function escapePromptAttachmentAttribute(value: string): string {
|
|
10
|
+
return value.replace(/&/g, "&").replace(/"/g, """);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function formatPromptWithAttachments(
|
|
14
|
+
prompt: string,
|
|
15
|
+
attachments: readonly AgentPromptAttachment[],
|
|
16
|
+
): string {
|
|
17
|
+
if (attachments.length === 0) return prompt;
|
|
18
|
+
const attachmentText = attachments
|
|
19
|
+
.map((attachment) => {
|
|
20
|
+
const size = attachment.size ? ` size="${attachment.size}"` : "";
|
|
21
|
+
const type = attachment.type
|
|
22
|
+
? ` type="${escapePromptAttachmentAttribute(attachment.type)}"`
|
|
23
|
+
: "";
|
|
24
|
+
if (attachment.dataUrl) {
|
|
25
|
+
return `<attached-image name="${escapePromptAttachmentAttribute(attachment.name)}"${type}${size}>\n${attachment.dataUrl}\n</attached-image>`;
|
|
26
|
+
}
|
|
27
|
+
const body =
|
|
28
|
+
attachment.text?.trim() ||
|
|
29
|
+
"Selected in the UI. If this file is needed, inspect it from the workspace or ask for a readable copy.";
|
|
30
|
+
return `<attached-file name="${escapePromptAttachmentAttribute(attachment.name)}"${type}${size}>\n${body}\n</attached-file>`;
|
|
31
|
+
})
|
|
32
|
+
.join("\n\n");
|
|
33
|
+
return `${prompt.trimEnd()}\n\nAttached context:\n${attachmentText}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const AGENT_PROMPT_MAX_INLINE_TEXT_CHARS = 60_000;
|
|
37
|
+
export const AGENT_PROMPT_MAX_INLINE_IMAGE_BYTES = 2 * 1024 * 1024;
|
|
38
|
+
|
|
39
|
+
export interface ReadAgentPromptAttachmentOptions {
|
|
40
|
+
maxInlineTextChars?: number;
|
|
41
|
+
maxInlineImageBytes?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function readAgentPromptAttachment(
|
|
45
|
+
file: File,
|
|
46
|
+
options: ReadAgentPromptAttachmentOptions = {},
|
|
47
|
+
): Promise<AgentPromptAttachment> {
|
|
48
|
+
const maxInlineTextChars =
|
|
49
|
+
options.maxInlineTextChars ?? AGENT_PROMPT_MAX_INLINE_TEXT_CHARS;
|
|
50
|
+
const maxInlineImageBytes =
|
|
51
|
+
options.maxInlineImageBytes ?? AGENT_PROMPT_MAX_INLINE_IMAGE_BYTES;
|
|
52
|
+
const attachment: AgentPromptAttachment = {
|
|
53
|
+
name: file.name,
|
|
54
|
+
type: file.type || undefined,
|
|
55
|
+
size: file.size,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
if (isInlineableAgentPromptFile(file) && file.size <= maxInlineTextChars) {
|
|
59
|
+
try {
|
|
60
|
+
attachment.text = await file.text();
|
|
61
|
+
} catch {
|
|
62
|
+
// Keep the filename-only attachment if the browser cannot read it.
|
|
63
|
+
}
|
|
64
|
+
} else if (
|
|
65
|
+
file.type.startsWith("image/") &&
|
|
66
|
+
file.size <= maxInlineImageBytes
|
|
67
|
+
) {
|
|
68
|
+
try {
|
|
69
|
+
attachment.dataUrl = await readFileAsDataUrl(file);
|
|
70
|
+
} catch {
|
|
71
|
+
// Keep the filename-only attachment if the browser cannot read it.
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return attachment;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function isInlineableAgentPromptFile(file: File): boolean {
|
|
79
|
+
if (file.type.startsWith("text/")) return true;
|
|
80
|
+
return /\.(cjs|css|csv|html|js|json|jsx|md|mdx|mjs|sql|tsx?|txt|xml|yaml|yml)$/i.test(
|
|
81
|
+
file.name,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function readFileAsDataUrl(file: File): Promise<string> {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
const reader = new FileReader();
|
|
88
|
+
reader.onload = () => resolve(String(reader.result ?? ""));
|
|
89
|
+
reader.onerror = () =>
|
|
90
|
+
reject(reader.error ?? new Error("Could not read file"));
|
|
91
|
+
reader.readAsDataURL(file);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface RealtimeVoiceAudioLevels {
|
|
2
|
+
input: number;
|
|
3
|
+
output: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface RealtimeVoiceAudioLevelStore {
|
|
7
|
+
getSnapshot: () => RealtimeVoiceAudioLevels;
|
|
8
|
+
subscribe: (listener: () => void) => () => void;
|
|
9
|
+
set: (levels: RealtimeVoiceAudioLevels) => void;
|
|
10
|
+
reset: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const SILENT_LEVELS: RealtimeVoiceAudioLevels = { input: 0, output: 0 };
|
|
14
|
+
|
|
15
|
+
function clampLevel(value: number): number {
|
|
16
|
+
if (!Number.isFinite(value)) return 0;
|
|
17
|
+
return Math.max(0, Math.min(1, value));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function normalizeRealtimeVoiceRms(samples: Uint8Array): number {
|
|
21
|
+
if (samples.length === 0) return 0;
|
|
22
|
+
let sumSquares = 0;
|
|
23
|
+
for (const sample of samples) {
|
|
24
|
+
const normalized = (sample - 128) / 128;
|
|
25
|
+
sumSquares += normalized * normalized;
|
|
26
|
+
}
|
|
27
|
+
const rms = Math.sqrt(sumSquares / samples.length);
|
|
28
|
+
return clampLevel(Math.max(0, rms - 0.012) * 3.2);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function smoothRealtimeVoiceLevel(
|
|
32
|
+
previous: number,
|
|
33
|
+
next: number,
|
|
34
|
+
): number {
|
|
35
|
+
const target = clampLevel(next);
|
|
36
|
+
const factor = target > previous ? 0.55 : 0.2;
|
|
37
|
+
return clampLevel(previous + (target - previous) * factor);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function createRealtimeVoiceAudioLevelStore(): RealtimeVoiceAudioLevelStore {
|
|
41
|
+
let snapshot = SILENT_LEVELS;
|
|
42
|
+
const listeners = new Set<() => void>();
|
|
43
|
+
|
|
44
|
+
const set = (levels: RealtimeVoiceAudioLevels) => {
|
|
45
|
+
const next = {
|
|
46
|
+
input: clampLevel(levels.input),
|
|
47
|
+
output: clampLevel(levels.output),
|
|
48
|
+
};
|
|
49
|
+
if (next.input === snapshot.input && next.output === snapshot.output)
|
|
50
|
+
return;
|
|
51
|
+
snapshot = next;
|
|
52
|
+
for (const listener of listeners) listener();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
getSnapshot: () => snapshot,
|
|
57
|
+
subscribe(listener) {
|
|
58
|
+
listeners.add(listener);
|
|
59
|
+
return () => listeners.delete(listener);
|
|
60
|
+
},
|
|
61
|
+
set,
|
|
62
|
+
reset: () => set(SILENT_LEVELS),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export type RealtimeVoiceTranscriptRole = "user" | "assistant";
|
|
2
|
+
|
|
3
|
+
export interface RealtimeVoiceTranscriptMessage {
|
|
4
|
+
id: string;
|
|
5
|
+
threadId: string;
|
|
6
|
+
role: RealtimeVoiceTranscriptRole;
|
|
7
|
+
text: string;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RealtimeVoiceTranscriptSink {
|
|
12
|
+
threadId: string;
|
|
13
|
+
active: boolean;
|
|
14
|
+
append: (message: RealtimeVoiceTranscriptMessage) => boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface RealtimeVoiceTranscriptRegistry {
|
|
18
|
+
activeThreadId: () => string | undefined;
|
|
19
|
+
publish: (message: RealtimeVoiceTranscriptMessage) => void;
|
|
20
|
+
register: (sink: RealtimeVoiceTranscriptSink) => () => void;
|
|
21
|
+
pendingCount: () => number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function appendRealtimeVoiceTranscriptToRepository(
|
|
25
|
+
value: unknown,
|
|
26
|
+
transcript: RealtimeVoiceTranscriptMessage,
|
|
27
|
+
): { appended: boolean; repository: Record<string, unknown> } {
|
|
28
|
+
const repository =
|
|
29
|
+
value && typeof value === "object" && !Array.isArray(value)
|
|
30
|
+
? (value as Record<string, unknown>)
|
|
31
|
+
: {};
|
|
32
|
+
const messages = Array.isArray(repository.messages)
|
|
33
|
+
? [...repository.messages]
|
|
34
|
+
: [];
|
|
35
|
+
const duplicate = messages.some((entry) => {
|
|
36
|
+
if (!entry || typeof entry !== "object") return false;
|
|
37
|
+
const record = entry as Record<string, unknown>;
|
|
38
|
+
const message =
|
|
39
|
+
record.message && typeof record.message === "object"
|
|
40
|
+
? (record.message as Record<string, unknown>)
|
|
41
|
+
: record;
|
|
42
|
+
return message.id === transcript.id;
|
|
43
|
+
});
|
|
44
|
+
if (duplicate) return { appended: false, repository };
|
|
45
|
+
|
|
46
|
+
const parentId =
|
|
47
|
+
typeof repository.headId === "string" ? repository.headId : null;
|
|
48
|
+
const createdAt = new Date(transcript.createdAt);
|
|
49
|
+
const message = {
|
|
50
|
+
id: transcript.id,
|
|
51
|
+
role: transcript.role,
|
|
52
|
+
content: [{ type: "text", text: transcript.text }],
|
|
53
|
+
createdAt: Number.isNaN(createdAt.getTime()) ? new Date() : createdAt,
|
|
54
|
+
metadata: {
|
|
55
|
+
custom: {
|
|
56
|
+
source: "realtime-voice",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
...(transcript.role === "assistant"
|
|
60
|
+
? { status: { type: "complete", reason: "stop" } }
|
|
61
|
+
: {}),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
appended: true,
|
|
66
|
+
repository: {
|
|
67
|
+
...repository,
|
|
68
|
+
messages: [...messages, { message, parentId }],
|
|
69
|
+
headId: transcript.id,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function createRealtimeVoiceTranscriptRegistry(): RealtimeVoiceTranscriptRegistry {
|
|
75
|
+
const sinks = new Map<
|
|
76
|
+
symbol,
|
|
77
|
+
RealtimeVoiceTranscriptSink & { order: number }
|
|
78
|
+
>();
|
|
79
|
+
const pending = new Map<string, RealtimeVoiceTranscriptMessage>();
|
|
80
|
+
const delivered = new Set<string>();
|
|
81
|
+
let order = 0;
|
|
82
|
+
|
|
83
|
+
const flush = () => {
|
|
84
|
+
for (const [id, message] of pending) {
|
|
85
|
+
let consumed = false;
|
|
86
|
+
for (const sink of sinks.values()) {
|
|
87
|
+
if (sink.threadId !== message.threadId) continue;
|
|
88
|
+
try {
|
|
89
|
+
consumed = sink.append(message) || consumed;
|
|
90
|
+
} catch {
|
|
91
|
+
// Keep the completed transcript queued until the chat can import it.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (!consumed) continue;
|
|
95
|
+
pending.delete(id);
|
|
96
|
+
delivered.add(id);
|
|
97
|
+
if (delivered.size > 1_000) {
|
|
98
|
+
const oldest = delivered.values().next().value;
|
|
99
|
+
if (typeof oldest === "string") delivered.delete(oldest);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
activeThreadId() {
|
|
106
|
+
let active: (RealtimeVoiceTranscriptSink & { order: number }) | undefined;
|
|
107
|
+
for (const sink of sinks.values()) {
|
|
108
|
+
if (!sink.active || (active && sink.order <= active.order)) continue;
|
|
109
|
+
active = sink;
|
|
110
|
+
}
|
|
111
|
+
return active?.threadId;
|
|
112
|
+
},
|
|
113
|
+
publish(message) {
|
|
114
|
+
const id = message.id.trim();
|
|
115
|
+
const threadId = message.threadId.trim();
|
|
116
|
+
const text = message.text.trim();
|
|
117
|
+
if (!id || !threadId || !text || delivered.has(id) || pending.has(id)) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
pending.set(id, { ...message, id, threadId, text });
|
|
121
|
+
flush();
|
|
122
|
+
},
|
|
123
|
+
register(sink) {
|
|
124
|
+
const token = Symbol("realtime-voice-transcript-sink");
|
|
125
|
+
sinks.set(token, { ...sink, order: ++order });
|
|
126
|
+
flush();
|
|
127
|
+
return () => sinks.delete(token);
|
|
128
|
+
},
|
|
129
|
+
pendingCount: () => pending.size,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export const realtimeVoiceTranscriptRegistry =
|
|
134
|
+
createRealtimeVoiceTranscriptRegistry();
|