@agent-native/core 0.111.4 → 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 +34 -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 +8 -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 +35 -15
- package/corpus/core/src/cli/code-agent-runs.concurrent-worker.ts +33 -0
- package/corpus/core/src/cli/code-agent-runs.ts +70 -36
- package/corpus/core/src/cli/codex-cli-participant.ts +496 -0
- package/corpus/core/src/cli/multi-frontier-runs.ts +1952 -0
- package/corpus/core/src/client/chat/ChatHistoryList.tsx +7 -404
- package/corpus/core/src/coding-tools/index.ts +27 -8
- package/corpus/core/src/embeddings/index.ts +233 -0
- package/corpus/core/src/index.ts +2 -0
- 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/search/index.ts +413 -0
- 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/brain/RUNBOOK.md +48 -5
- package/corpus/templates/brain/.agents/skills/brain/SKILL.md +46 -14
- 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/README.md +34 -3
- package/corpus/templates/brain/actions/_schemas.ts +13 -7
- package/corpus/templates/brain/actions/approve-proposal.ts +2 -0
- package/corpus/templates/brain/actions/claim-distillation.ts +24 -27
- package/corpus/templates/brain/actions/create-source.ts +1 -1
- package/corpus/templates/brain/actions/delete-staged-dataset.ts +3 -24
- package/corpus/templates/brain/actions/get-knowledge.ts +6 -2
- package/corpus/templates/brain/actions/get-pilot-report.ts +44 -8
- package/corpus/templates/brain/actions/import-capture.ts +21 -9
- package/corpus/templates/brain/actions/import-transcript.ts +42 -14
- package/corpus/templates/brain/actions/list-captures.ts +10 -1
- package/corpus/templates/brain/actions/list-distillation-queue.ts +39 -14
- package/corpus/templates/brain/actions/list-projects.ts +51 -0
- package/corpus/templates/brain/actions/list-proposals.ts +80 -4
- package/corpus/templates/brain/actions/list-sources.ts +17 -3
- package/corpus/templates/brain/actions/list-staged-datasets.ts +3 -28
- package/corpus/templates/brain/actions/manage-project.ts +118 -0
- package/corpus/templates/brain/actions/mark-capture-distilled.ts +68 -20
- package/corpus/templates/brain/actions/navigate.ts +1 -0
- 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/reject-proposal.ts +6 -1
- package/corpus/templates/brain/actions/resanitize-captures.ts +159 -33
- package/corpus/templates/brain/actions/review-proposal.ts +2 -0
- package/corpus/templates/brain/actions/search-everything.ts +10 -1
- package/corpus/templates/brain/actions/search-knowledge.ts +1 -1
- package/corpus/templates/brain/actions/set-settings.ts +36 -1
- package/corpus/templates/brain/actions/update-proposal.ts +2 -0
- 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/hooks/use-distillation-bridge.ts +18 -9
- package/corpus/templates/brain/app/hooks/use-navigation-state.ts +3 -0
- package/corpus/templates/brain/app/i18n-data.ts +731 -2
- package/corpus/templates/brain/app/lib/brain.ts +88 -1
- package/corpus/templates/brain/app/lib/ingest-handoff.ts +35 -0
- package/corpus/templates/brain/app/routes/ops.tsx +47 -0
- package/corpus/templates/brain/app/routes/review.tsx +41 -2
- package/corpus/templates/brain/app/routes/search.tsx +33 -2
- package/corpus/templates/brain/app/routes/settings.tsx +158 -0
- package/corpus/templates/brain/app/routes/sources.tsx +31 -0
- package/corpus/templates/brain/changelog/2026-07-19-added-private-source-safe-semantic-search.md +6 -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/jobs/process-ingest-queue.ts +270 -36
- package/corpus/templates/brain/package.json +1 -0
- package/corpus/templates/brain/server/db/index.ts +18 -0
- package/corpus/templates/brain/server/db/schema.ts +197 -1
- package/corpus/templates/brain/server/jobs/distillation-queue.ts +12 -5
- package/corpus/templates/brain/server/lib/audiences.ts +708 -0
- package/corpus/templates/brain/server/lib/brain-health.ts +251 -38
- package/corpus/templates/brain/server/lib/brain.ts +877 -50
- package/corpus/templates/brain/server/lib/capture-sanitization.ts +217 -53
- package/corpus/templates/brain/server/lib/connectors.ts +609 -72
- package/corpus/templates/brain/server/lib/demo.ts +17 -4
- package/corpus/templates/brain/server/lib/hybrid-search.ts +363 -0
- package/corpus/templates/brain/server/lib/ingest-queue.ts +104 -0
- package/corpus/templates/brain/server/lib/privacy-readiness.ts +24 -0
- package/corpus/templates/brain/server/lib/search-index-contracts.ts +72 -0
- package/corpus/templates/brain/server/lib/search-index.ts +714 -0
- package/corpus/templates/brain/server/lib/search.ts +120 -4
- package/corpus/templates/brain/server/lib/sensitivity-policy.ts +174 -0
- package/corpus/templates/brain/server/lib/slack-channel-membership.ts +44 -0
- package/corpus/templates/brain/server/lib/slack-events.ts +281 -0
- package/corpus/templates/brain/server/onboarding.ts +29 -0
- package/corpus/templates/brain/server/plugins/db.ts +204 -0
- package/corpus/templates/brain/server/register-secrets.ts +46 -0
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/ingest.post.ts +36 -16
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/slack-events.post.ts +28 -0
- package/corpus/templates/brain/shared/slack-source-config.ts +60 -0
- package/corpus/templates/brain/shared/types.ts +10 -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 +8 -9
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +27 -13
- 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 +5 -0
- package/dist/cli/code-agent-runs.d.ts.map +1 -1
- package/dist/cli/code-agent-runs.js +51 -33
- 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 +246 -0
- package/dist/cli/multi-frontier-runs.d.ts.map +1 -0
- package/dist/cli/multi-frontier-runs.js +1247 -0
- package/dist/cli/multi-frontier-runs.js.map +1 -0
- 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/coding-tools/index.d.ts +1 -0
- package/dist/coding-tools/index.d.ts.map +1 -1
- package/dist/coding-tools/index.js +25 -7
- package/dist/coding-tools/index.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/embeddings/index.d.ts +24 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +172 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.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/progress/routes.d.ts +1 -1
- 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/resources/handlers.d.ts +1 -1
- 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/search/index.d.ts +88 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +267 -0
- package/dist/search/index.js.map +1 -0
- 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 +9 -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,51 @@
|
|
|
1
|
+
import { defineAction } from "@agent-native/core";
|
|
2
|
+
import { getRequestUserEmail } from "@agent-native/core/server/request-context";
|
|
3
|
+
import { getUserSetting } from "@agent-native/core/settings";
|
|
4
|
+
import { accessFilter } from "@agent-native/core/sharing";
|
|
5
|
+
import { inArray } from "drizzle-orm";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
|
|
8
|
+
import { getDb, schema } from "../server/db/index.js";
|
|
9
|
+
|
|
10
|
+
const DEFAULT_PROJECT_SETTING = "brain-default-project";
|
|
11
|
+
|
|
12
|
+
export default defineAction({
|
|
13
|
+
description: "List accessible Brain projects and their source membership.",
|
|
14
|
+
schema: z.object({}),
|
|
15
|
+
http: { method: "GET" },
|
|
16
|
+
readOnly: true,
|
|
17
|
+
publicAgent: { expose: true, readOnly: true, requiresAuth: true },
|
|
18
|
+
run: async () => {
|
|
19
|
+
const db = getDb();
|
|
20
|
+
const projects = await db
|
|
21
|
+
.select()
|
|
22
|
+
.from(schema.brainProjects)
|
|
23
|
+
.where(accessFilter(schema.brainProjects, schema.brainProjectShares));
|
|
24
|
+
const projectIds = projects.map((project) => project.id);
|
|
25
|
+
const links = projectIds.length
|
|
26
|
+
? await db
|
|
27
|
+
.select()
|
|
28
|
+
.from(schema.brainProjectSources)
|
|
29
|
+
.where(inArray(schema.brainProjectSources.projectId, projectIds))
|
|
30
|
+
: [];
|
|
31
|
+
const userEmail = getRequestUserEmail();
|
|
32
|
+
const setting = userEmail
|
|
33
|
+
? ((await getUserSetting(userEmail, DEFAULT_PROJECT_SETTING)) as {
|
|
34
|
+
projectId?: string;
|
|
35
|
+
} | null)
|
|
36
|
+
: null;
|
|
37
|
+
return {
|
|
38
|
+
projects: projects.map((project) => ({
|
|
39
|
+
id: project.id,
|
|
40
|
+
title: project.title,
|
|
41
|
+
description: project.description,
|
|
42
|
+
visibility: project.visibility,
|
|
43
|
+
sourceIds: links
|
|
44
|
+
.filter((link) => link.projectId === project.id)
|
|
45
|
+
.map((link) => link.sourceId),
|
|
46
|
+
isDefault: setting?.projectId === project.id,
|
|
47
|
+
updatedAt: project.updatedAt,
|
|
48
|
+
})),
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
});
|
|
@@ -1,26 +1,102 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core";
|
|
2
|
-
import { accessFilter } from "@agent-native/core/sharing";
|
|
3
|
-
import { and, desc, eq } from "drizzle-orm";
|
|
2
|
+
import { accessFilter, assertAccess } from "@agent-native/core/sharing";
|
|
3
|
+
import { and, desc, eq, inArray, isNull, or, sql } from "drizzle-orm";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
import { getDb, schema } from "../server/db/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { listAccessibleAudienceIds } from "../server/lib/audiences.js";
|
|
8
|
+
import { parseJson, serializeProposal } from "../server/lib/brain.js";
|
|
8
9
|
|
|
9
10
|
export default defineAction({
|
|
10
11
|
description: "List Brain knowledge proposals requiring review.",
|
|
11
12
|
schema: z.object({
|
|
12
|
-
status: z
|
|
13
|
+
status: z
|
|
14
|
+
.enum(["pending", "approved", "rejected", "quarantine"])
|
|
15
|
+
.default("pending"),
|
|
13
16
|
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
14
17
|
}),
|
|
15
18
|
http: { method: "GET" },
|
|
16
19
|
readOnly: true,
|
|
17
20
|
run: async ({ status, limit }) => {
|
|
21
|
+
if (status === "quarantine") {
|
|
22
|
+
const accessibleSources = await getDb()
|
|
23
|
+
.select({ id: schema.brainSources.id })
|
|
24
|
+
.from(schema.brainSources)
|
|
25
|
+
.where(accessFilter(schema.brainSources, schema.brainSourceShares));
|
|
26
|
+
const adminSourceIds = (
|
|
27
|
+
await Promise.all(
|
|
28
|
+
accessibleSources.map(async ({ id }) => {
|
|
29
|
+
try {
|
|
30
|
+
await assertAccess("brain-source", id, "admin");
|
|
31
|
+
return id;
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
)
|
|
37
|
+
).filter((sourceId): sourceId is string => Boolean(sourceId));
|
|
38
|
+
if (!adminSourceIds.length) return { count: 0, proposals: [] };
|
|
39
|
+
const rows = await getDb()
|
|
40
|
+
.select({
|
|
41
|
+
id: schema.brainSensitivityEvents.id,
|
|
42
|
+
sourceId: schema.brainSensitivityEvents.sourceId,
|
|
43
|
+
sourceName: schema.brainSources.title,
|
|
44
|
+
disposition: schema.brainSensitivityEvents.disposition,
|
|
45
|
+
categoriesJson: schema.brainSensitivityEvents.categoriesJson,
|
|
46
|
+
confidenceBand: schema.brainSensitivityEvents.confidenceBand,
|
|
47
|
+
expiresAt: schema.brainSensitivityEvents.expiresAt,
|
|
48
|
+
createdAt: schema.brainSensitivityEvents.createdAt,
|
|
49
|
+
updatedAt: schema.brainSensitivityEvents.updatedAt,
|
|
50
|
+
})
|
|
51
|
+
.from(schema.brainSensitivityEvents)
|
|
52
|
+
.innerJoin(
|
|
53
|
+
schema.brainSources,
|
|
54
|
+
eq(schema.brainSources.id, schema.brainSensitivityEvents.sourceId),
|
|
55
|
+
)
|
|
56
|
+
.where(
|
|
57
|
+
and(
|
|
58
|
+
eq(schema.brainSensitivityEvents.disposition, "quarantined"),
|
|
59
|
+
inArray(schema.brainSensitivityEvents.sourceId, adminSourceIds),
|
|
60
|
+
),
|
|
61
|
+
)
|
|
62
|
+
.orderBy(desc(schema.brainSensitivityEvents.createdAt))
|
|
63
|
+
.limit(limit);
|
|
64
|
+
const proposals = rows.map((row) => ({
|
|
65
|
+
id: row.id,
|
|
66
|
+
title: "Privacy quarantine",
|
|
67
|
+
sourceId: row.sourceId,
|
|
68
|
+
sourceName: row.sourceName,
|
|
69
|
+
reason: [
|
|
70
|
+
row.confidenceBand,
|
|
71
|
+
...parseJson<string[]>(row.categoriesJson, []),
|
|
72
|
+
row.expiresAt ? `expires ${row.expiresAt}` : "metadata-only",
|
|
73
|
+
].join(" · "),
|
|
74
|
+
status: "quarantine" as const,
|
|
75
|
+
createdAt: row.createdAt,
|
|
76
|
+
updatedAt: row.updatedAt,
|
|
77
|
+
}));
|
|
78
|
+
return { count: proposals.length, proposals };
|
|
79
|
+
}
|
|
80
|
+
const audienceIds = await listAccessibleAudienceIds();
|
|
18
81
|
const rows = await getDb()
|
|
19
82
|
.select()
|
|
20
83
|
.from(schema.brainProposals)
|
|
21
84
|
.where(
|
|
22
85
|
and(
|
|
23
86
|
accessFilter(schema.brainProposals, schema.brainProposalShares),
|
|
87
|
+
or(
|
|
88
|
+
isNull(schema.brainProposals.captureId),
|
|
89
|
+
audienceIds.length
|
|
90
|
+
? and(
|
|
91
|
+
sql`exists (
|
|
92
|
+
select 1 from ${schema.brainSources}
|
|
93
|
+
where ${schema.brainSources.id} = ${schema.brainProposals.sourceId}
|
|
94
|
+
and ${accessFilter(schema.brainSources, schema.brainSourceShares)}
|
|
95
|
+
)`,
|
|
96
|
+
inArray(schema.brainProposals.audienceId, audienceIds),
|
|
97
|
+
)
|
|
98
|
+
: undefined,
|
|
99
|
+
),
|
|
24
100
|
eq(schema.brainProposals.status, status),
|
|
25
101
|
),
|
|
26
102
|
)
|
|
@@ -1,20 +1,34 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core";
|
|
2
2
|
import { accessFilter } from "@agent-native/core/sharing";
|
|
3
|
-
import { and,
|
|
3
|
+
import { and, countDistinct, desc, eq, inArray, ne } from "drizzle-orm";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
import { getDb, schema } from "../server/db/index.js";
|
|
7
7
|
import { nextBrainSourceSyncAt } from "../server/jobs/sync-sources.js";
|
|
8
|
+
import { listAccessibleAudienceIds } from "../server/lib/audiences.js";
|
|
8
9
|
import { parseJson, serializeSource } from "../server/lib/brain.js";
|
|
9
10
|
import { sourceProviderSchema } from "./_schemas.js";
|
|
10
11
|
|
|
11
12
|
async function sourceRecordCount(sourceId: string): Promise<number> {
|
|
13
|
+
const audienceIds = await listAccessibleAudienceIds([sourceId]);
|
|
14
|
+
if (!audienceIds.length) return 0;
|
|
15
|
+
|
|
12
16
|
// Count only — never load the heavy `content` blob of every capture row
|
|
13
17
|
// just to take `.length`.
|
|
14
18
|
const [row] = await getDb()
|
|
15
|
-
.select({ value:
|
|
19
|
+
.select({ value: countDistinct(schema.brainRawCaptures.id) })
|
|
16
20
|
.from(schema.brainRawCaptures)
|
|
17
|
-
.
|
|
21
|
+
.innerJoin(
|
|
22
|
+
schema.brainCaptureAudiences,
|
|
23
|
+
eq(schema.brainCaptureAudiences.captureId, schema.brainRawCaptures.id),
|
|
24
|
+
)
|
|
25
|
+
.where(
|
|
26
|
+
and(
|
|
27
|
+
eq(schema.brainRawCaptures.sourceId, sourceId),
|
|
28
|
+
eq(schema.brainRawCaptures.sensitivityDisposition, "allowed"),
|
|
29
|
+
inArray(schema.brainCaptureAudiences.audienceId, audienceIds),
|
|
30
|
+
),
|
|
31
|
+
);
|
|
18
32
|
return row?.value ?? 0;
|
|
19
33
|
}
|
|
20
34
|
|
|
@@ -1,40 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Thin Brain re-export of staged dataset listing, pre-bound to appId="brain".
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { listStagedDatasets } from "@agent-native/core/provider-api/staged-datasets-store";
|
|
6
|
-
import { getCredentialContext } from "@agent-native/core/server/request-context";
|
|
4
|
+
import { createListStagedDatasetsAction } from "@agent-native/core/provider-api/actions/staged-datasets";
|
|
7
5
|
import { z } from "zod";
|
|
8
6
|
|
|
9
7
|
import { BRAIN_APP_ID } from "../server/lib/provider-api.js";
|
|
10
8
|
|
|
11
|
-
export default
|
|
9
|
+
export default createListStagedDatasetsAction({
|
|
12
10
|
description:
|
|
13
11
|
"List staged datasets stored by provider-api-request (stageAs) for the current user. Returns dataset ids, names, row counts, columns, and sizes. Use dataset ids with query-staged-dataset to aggregate, or with delete-staged-dataset to free scratch storage.",
|
|
14
12
|
schema: z.object({}),
|
|
15
13
|
http: { method: "GET" },
|
|
16
|
-
|
|
17
|
-
run: async () => {
|
|
18
|
-
const ctx = getCredentialContext();
|
|
19
|
-
if (!ctx) {
|
|
20
|
-
throw new Error("No authenticated context for list-staged-datasets.");
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const datasets = await listStagedDatasets({
|
|
24
|
-
appId: BRAIN_APP_ID,
|
|
25
|
-
ownerEmail: ctx.userEmail,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
datasets: datasets.map((d) => ({
|
|
30
|
-
id: d.id,
|
|
31
|
-
name: d.name,
|
|
32
|
-
rowCount: d.rowCount,
|
|
33
|
-
columns: d.columns,
|
|
34
|
-
byteSize: d.byteSize,
|
|
35
|
-
updatedAt: new Date(d.updatedAt).toISOString(),
|
|
36
|
-
})),
|
|
37
|
-
total: datasets.length,
|
|
38
|
-
};
|
|
39
|
-
},
|
|
14
|
+
appId: BRAIN_APP_ID,
|
|
40
15
|
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { defineAction } from "@agent-native/core";
|
|
2
|
+
import {
|
|
3
|
+
getRequestOrgId,
|
|
4
|
+
getRequestUserEmail,
|
|
5
|
+
} from "@agent-native/core/server/request-context";
|
|
6
|
+
import { putUserSetting } from "@agent-native/core/settings";
|
|
7
|
+
import { accessFilter, assertAccess } from "@agent-native/core/sharing";
|
|
8
|
+
import { and, eq, inArray } from "drizzle-orm";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
|
|
11
|
+
import { getDb, schema } from "../server/db/index.js";
|
|
12
|
+
import { nanoid, nowIso } from "../server/lib/brain.js";
|
|
13
|
+
|
|
14
|
+
const DEFAULT_PROJECT_SETTING = "brain-default-project";
|
|
15
|
+
|
|
16
|
+
export default defineAction({
|
|
17
|
+
description:
|
|
18
|
+
"Create, update, remove, or select a Brain project that scopes related knowledge sources.",
|
|
19
|
+
schema: z.object({
|
|
20
|
+
operation: z.enum(["create", "update", "delete", "set-default"]),
|
|
21
|
+
projectId: z.string().optional(),
|
|
22
|
+
title: z.string().min(1).optional(),
|
|
23
|
+
description: z.string().optional(),
|
|
24
|
+
sourceIds: z.array(z.string().min(1)).optional(),
|
|
25
|
+
}),
|
|
26
|
+
run: async (args) => {
|
|
27
|
+
const userEmail = getRequestUserEmail();
|
|
28
|
+
if (!userEmail) throw new Error("Not authenticated");
|
|
29
|
+
const db = getDb();
|
|
30
|
+
const now = nowIso();
|
|
31
|
+
|
|
32
|
+
if (args.operation === "create") {
|
|
33
|
+
if (!args.title) throw new Error("title is required");
|
|
34
|
+
const id = args.projectId ?? nanoid();
|
|
35
|
+
await db.insert(schema.brainProjects).values({
|
|
36
|
+
id,
|
|
37
|
+
title: args.title,
|
|
38
|
+
description: args.description ?? "",
|
|
39
|
+
ownerEmail: userEmail,
|
|
40
|
+
orgId: getRequestOrgId() ?? null,
|
|
41
|
+
visibility: "private",
|
|
42
|
+
createdAt: now,
|
|
43
|
+
updatedAt: now,
|
|
44
|
+
});
|
|
45
|
+
await replaceProjectSources(id, args.sourceIds ?? []);
|
|
46
|
+
return { projectId: id, operation: args.operation };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!args.projectId) throw new Error("projectId is required");
|
|
50
|
+
if (args.operation === "set-default") {
|
|
51
|
+
await assertAccess("brain-project", args.projectId, "viewer");
|
|
52
|
+
await putUserSetting(userEmail, DEFAULT_PROJECT_SETTING, {
|
|
53
|
+
projectId: args.projectId,
|
|
54
|
+
});
|
|
55
|
+
return { projectId: args.projectId, default: true };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
await assertAccess("brain-project", args.projectId, "editor");
|
|
59
|
+
if (args.operation === "delete") {
|
|
60
|
+
await db
|
|
61
|
+
.delete(schema.brainProjectSources)
|
|
62
|
+
.where(eq(schema.brainProjectSources.projectId, args.projectId));
|
|
63
|
+
await db
|
|
64
|
+
.delete(schema.brainProjectShares)
|
|
65
|
+
.where(eq(schema.brainProjectShares.resourceId, args.projectId));
|
|
66
|
+
await db
|
|
67
|
+
.delete(schema.brainProjects)
|
|
68
|
+
.where(eq(schema.brainProjects.id, args.projectId));
|
|
69
|
+
return { projectId: args.projectId, deleted: true };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
await db
|
|
73
|
+
.update(schema.brainProjects)
|
|
74
|
+
.set({
|
|
75
|
+
...(args.title ? { title: args.title } : {}),
|
|
76
|
+
...(args.description !== undefined
|
|
77
|
+
? { description: args.description }
|
|
78
|
+
: {}),
|
|
79
|
+
updatedAt: now,
|
|
80
|
+
})
|
|
81
|
+
.where(eq(schema.brainProjects.id, args.projectId));
|
|
82
|
+
if (args.sourceIds) {
|
|
83
|
+
await replaceProjectSources(args.projectId, args.sourceIds);
|
|
84
|
+
}
|
|
85
|
+
return { projectId: args.projectId, operation: args.operation };
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
async function replaceProjectSources(projectId: string, sourceIds: string[]) {
|
|
90
|
+
const db = getDb();
|
|
91
|
+
const unique = Array.from(new Set(sourceIds));
|
|
92
|
+
if (unique.length) {
|
|
93
|
+
const accessible = await db
|
|
94
|
+
.select({ id: schema.brainSources.id })
|
|
95
|
+
.from(schema.brainSources)
|
|
96
|
+
.where(
|
|
97
|
+
and(
|
|
98
|
+
accessFilter(schema.brainSources, schema.brainSourceShares),
|
|
99
|
+
inArray(schema.brainSources.id, unique),
|
|
100
|
+
),
|
|
101
|
+
);
|
|
102
|
+
if (accessible.length !== unique.length) {
|
|
103
|
+
throw new Error("One or more Brain sources were not found");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
await db
|
|
107
|
+
.delete(schema.brainProjectSources)
|
|
108
|
+
.where(eq(schema.brainProjectSources.projectId, projectId));
|
|
109
|
+
if (!unique.length) return;
|
|
110
|
+
await db.insert(schema.brainProjectSources).values(
|
|
111
|
+
unique.map((sourceId) => ({
|
|
112
|
+
id: nanoid(),
|
|
113
|
+
projectId,
|
|
114
|
+
sourceId,
|
|
115
|
+
createdAt: nowIso(),
|
|
116
|
+
})),
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core";
|
|
2
|
-
import {
|
|
2
|
+
import { getDbExec } from "@agent-native/core/db";
|
|
3
|
+
import { and, desc, eq } from "drizzle-orm";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
|
|
5
6
|
import { getDb, schema } from "../server/db/index.js";
|
|
@@ -15,15 +16,76 @@ import {
|
|
|
15
16
|
|
|
16
17
|
export default defineAction({
|
|
17
18
|
description: "Mark a raw Brain capture as distilled or ignored.",
|
|
18
|
-
schema: z
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
schema: z
|
|
20
|
+
.object({
|
|
21
|
+
captureId: z.string().min(1),
|
|
22
|
+
status: z.enum(["distilled", "ignored"]).default("distilled"),
|
|
23
|
+
queueId: z.string().min(1).optional(),
|
|
24
|
+
claimToken: z.string().min(1).optional(),
|
|
25
|
+
})
|
|
26
|
+
.superRefine((value, ctx) => {
|
|
27
|
+
if (Boolean(value.queueId) !== Boolean(value.claimToken)) {
|
|
28
|
+
ctx.addIssue({
|
|
29
|
+
code: z.ZodIssueCode.custom,
|
|
30
|
+
message: "queueId and claimToken must be supplied together.",
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
run: async ({ captureId, status, queueId, claimToken }) => {
|
|
23
35
|
const access = await getAccessibleCapture(captureId);
|
|
24
36
|
if (!access) throw new Error(`No access to capture ${captureId}`);
|
|
25
37
|
const db = getDb();
|
|
26
38
|
const now = nowIso();
|
|
39
|
+
|
|
40
|
+
if (queueId && claimToken) {
|
|
41
|
+
const result = await getDbExec().execute({
|
|
42
|
+
sql: `UPDATE brain_ingest_queue
|
|
43
|
+
SET status = ?, error = NULL, lease_token = NULL,
|
|
44
|
+
lease_expires_at = NULL, updated_at = ?
|
|
45
|
+
WHERE id = ? AND capture_id = ? AND operation = 'distill'
|
|
46
|
+
AND status = 'processing' AND lease_token = ?`,
|
|
47
|
+
args: ["done", now, queueId, captureId, claimToken],
|
|
48
|
+
});
|
|
49
|
+
if (result.rowsAffected === 0) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
"The distillation claim is no longer active; do not complete a newer worker's queue item.",
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
const [processing] = await db
|
|
56
|
+
.select()
|
|
57
|
+
.from(schema.brainIngestQueue)
|
|
58
|
+
.where(
|
|
59
|
+
and(
|
|
60
|
+
eq(schema.brainIngestQueue.captureId, captureId),
|
|
61
|
+
eq(schema.brainIngestQueue.operation, "distill"),
|
|
62
|
+
eq(schema.brainIngestQueue.status, "processing"),
|
|
63
|
+
),
|
|
64
|
+
)
|
|
65
|
+
.orderBy(desc(schema.brainIngestQueue.updatedAt))
|
|
66
|
+
.limit(1);
|
|
67
|
+
if (processing) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
"This capture has an active distillation claim. Supply its queueId and claimToken to complete it.",
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
await db
|
|
73
|
+
.update(schema.brainIngestQueue)
|
|
74
|
+
.set({
|
|
75
|
+
status: "done",
|
|
76
|
+
error: null,
|
|
77
|
+
leaseToken: null,
|
|
78
|
+
leaseExpiresAt: null,
|
|
79
|
+
updatedAt: now,
|
|
80
|
+
})
|
|
81
|
+
.where(
|
|
82
|
+
and(
|
|
83
|
+
eq(schema.brainIngestQueue.captureId, captureId),
|
|
84
|
+
eq(schema.brainIngestQueue.operation, "distill"),
|
|
85
|
+
eq(schema.brainIngestQueue.status, "queued"),
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
}
|
|
27
89
|
await db
|
|
28
90
|
.update(schema.brainRawCaptures)
|
|
29
91
|
.set({
|
|
@@ -32,20 +94,6 @@ export default defineAction({
|
|
|
32
94
|
updatedAt: now,
|
|
33
95
|
})
|
|
34
96
|
.where(eq(schema.brainRawCaptures.id, captureId));
|
|
35
|
-
await db
|
|
36
|
-
.update(schema.brainIngestQueue)
|
|
37
|
-
.set({
|
|
38
|
-
status: "done",
|
|
39
|
-
error: null,
|
|
40
|
-
updatedAt: now,
|
|
41
|
-
})
|
|
42
|
-
.where(
|
|
43
|
-
and(
|
|
44
|
-
eq(schema.brainIngestQueue.captureId, captureId),
|
|
45
|
-
eq(schema.brainIngestQueue.operation, "distill"),
|
|
46
|
-
inArray(schema.brainIngestQueue.status, ["queued", "processing"]),
|
|
47
|
-
),
|
|
48
|
-
);
|
|
49
97
|
const updated = await getAccessibleCapture(captureId);
|
|
50
98
|
if (!updated) return { capture: null };
|
|
51
99
|
const capture = serializeCapture(updated.capture);
|
|
@@ -28,6 +28,7 @@ export default defineAction({
|
|
|
28
28
|
proposalId: z.string().optional(),
|
|
29
29
|
extensionId: z.string().optional(),
|
|
30
30
|
query: z.string().optional(),
|
|
31
|
+
projectId: z.string().optional(),
|
|
31
32
|
type: z.enum(["knowledge", "capture", "source", "all"]).optional(),
|
|
32
33
|
provider: z.string().optional(),
|
|
33
34
|
status: z.string().optional(),
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createProviderApiCatalogAction } from "@agent-native/core/provider-api/actions/provider-api";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
BRAIN_PROVIDER_API_IDS,
|
|
6
|
-
|
|
6
|
+
getBrainProviderApiRuntime,
|
|
7
7
|
} from "../server/lib/provider-api.js";
|
|
8
8
|
|
|
9
9
|
const ProviderSchema = z.enum(BRAIN_PROVIDER_API_IDS);
|
|
10
10
|
|
|
11
|
-
export default
|
|
11
|
+
export default createProviderApiCatalogAction(getBrainProviderApiRuntime(), {
|
|
12
12
|
description:
|
|
13
13
|
"List raw HTTP API capabilities for configured/shared providers that Brain can use for ad hoc analysis. Use before provider-api-request when source readers or canned actions are too narrow. Returns base URLs, auth style, credential key names, docs/spec URLs, placeholders, and examples; never returns secret values.",
|
|
14
14
|
schema: z.object({
|
|
@@ -17,12 +17,6 @@ export default defineAction({
|
|
|
17
17
|
),
|
|
18
18
|
}),
|
|
19
19
|
http: { method: "GET" },
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
providers: await listProviderApiCatalog(provider),
|
|
24
|
-
guidance:
|
|
25
|
-
"Brain source sync and retrieval actions are convenience readers, not capability limits. When a question needs an endpoint, object type, filter, pagination mode, or API version that a source action does not model, inspect docs/spec URLs here and call provider-api-request with the exact provider API method/path/query/body. For broad searches, joins, classification, or absence claims, stage or save the full bounded corpus and reduce it with query-staged-dataset or run-code.",
|
|
26
|
-
};
|
|
27
|
-
},
|
|
20
|
+
guidance:
|
|
21
|
+
"Brain source sync and retrieval actions are convenience readers, not capability limits. When a question needs an endpoint, object type, filter, pagination mode, or API version that a source action does not model, inspect docs/spec URLs here and call provider-api-request with the exact provider API method/path/query/body. For broad searches, joins, classification, or absence claims, stage or save the full bounded corpus and reduce it with query-staged-dataset or run-code.",
|
|
28
22
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createProviderApiDocsAction } from "@agent-native/core/provider-api/actions/provider-api";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
BRAIN_PROVIDER_API_IDS,
|
|
6
|
-
|
|
6
|
+
getBrainProviderApiRuntime,
|
|
7
7
|
} from "../server/lib/provider-api.js";
|
|
8
8
|
|
|
9
9
|
const ProviderSchema = z.enum(BRAIN_PROVIDER_API_IDS);
|
|
@@ -23,7 +23,7 @@ const WebContentSearchSchema = z.object({
|
|
|
23
23
|
caseSensitive: BooleanFromQuerySchema.optional(),
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
export default
|
|
26
|
+
export default createProviderApiDocsAction(getBrainProviderApiRuntime(), {
|
|
27
27
|
description:
|
|
28
28
|
"Inspect provider API docs/spec metadata, or fetch a public provider docs/spec/changelog URL. Use this before arbitrary provider-api-request calls when the exact endpoint, filter operator, payload shape, pagination, or API version is uncertain.",
|
|
29
29
|
schema: z.object({
|
|
@@ -69,6 +69,4 @@ export default defineAction({
|
|
|
69
69
|
),
|
|
70
70
|
}),
|
|
71
71
|
http: { method: "GET" },
|
|
72
|
-
readOnly: true,
|
|
73
|
-
run: async (args) => fetchProviderApiDocs(args),
|
|
74
72
|
});
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { stagingExecuteRequest } from "@agent-native/core/provider-api/staging";
|
|
3
|
-
import { getCredentialContext } from "@agent-native/core/server/request-context";
|
|
1
|
+
import { createProviderApiRequestAction } from "@agent-native/core/provider-api/actions/provider-api";
|
|
4
2
|
import { z } from "zod";
|
|
5
3
|
|
|
6
4
|
import {
|
|
7
5
|
BRAIN_APP_ID,
|
|
8
6
|
BRAIN_PROVIDER_API_IDS,
|
|
9
|
-
executeProviderApiRequest,
|
|
10
7
|
getBrainProviderApiRuntime,
|
|
11
8
|
} from "../server/lib/provider-api.js";
|
|
12
9
|
|
|
@@ -68,7 +65,7 @@ const PaginationSchema = z
|
|
|
68
65
|
})
|
|
69
66
|
.optional();
|
|
70
67
|
|
|
71
|
-
export default
|
|
68
|
+
export default createProviderApiRequestAction(getBrainProviderApiRuntime(), {
|
|
72
69
|
description:
|
|
73
70
|
"Make an arbitrary authenticated HTTP request to a configured or shared provider API for Brain analysis. Use this as the flexible escape hatch when Brain source readers cannot express the needed endpoint, filters, pagination, payload, or API version. The request is constrained to the provider host, uses configured credentials automatically, blocks private/internal URLs, and redacts secrets from responses.",
|
|
74
71
|
schema: z.object({
|
|
@@ -198,36 +195,5 @@ export default defineAction({
|
|
|
198
195
|
}),
|
|
199
196
|
http: false,
|
|
200
197
|
toolCallable: false,
|
|
201
|
-
|
|
202
|
-
if (args.stageAs) {
|
|
203
|
-
const ctx = getCredentialContext();
|
|
204
|
-
if (!ctx) {
|
|
205
|
-
throw new Error("No authenticated context for provider API staging.");
|
|
206
|
-
}
|
|
207
|
-
const providerRuntime = getBrainProviderApiRuntime();
|
|
208
|
-
return stagingExecuteRequest(
|
|
209
|
-
{
|
|
210
|
-
provider: args.provider,
|
|
211
|
-
method: args.method,
|
|
212
|
-
path: args.path,
|
|
213
|
-
query: args.query,
|
|
214
|
-
headers: args.headers,
|
|
215
|
-
body: args.body,
|
|
216
|
-
auth: args.auth,
|
|
217
|
-
connectionId: args.connectionId,
|
|
218
|
-
accountId: args.accountId,
|
|
219
|
-
timeoutMs: args.timeoutMs,
|
|
220
|
-
maxBytes: args.maxBytes,
|
|
221
|
-
stageAs: args.stageAs,
|
|
222
|
-
itemsPath: args.itemsPath,
|
|
223
|
-
pagination: args.pagination,
|
|
224
|
-
},
|
|
225
|
-
(reqArgs) => providerRuntime.executeRequest(reqArgs),
|
|
226
|
-
{ appId: BRAIN_APP_ID, ownerEmail: ctx.userEmail },
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
return executeProviderApiRequest(
|
|
230
|
-
args as unknown as Parameters<typeof executeProviderApiRequest>[0],
|
|
231
|
-
);
|
|
232
|
-
},
|
|
198
|
+
appId: BRAIN_APP_ID,
|
|
233
199
|
});
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Thin Brain re-export of the staged dataset query helper, pre-bound to appId="brain".
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { runAggregateQuery } from "@agent-native/core/provider-api/staged-datasets-aggregate";
|
|
6
|
-
import {
|
|
7
|
-
getStagedDatasetMeta,
|
|
8
|
-
getStagedDatasetRows,
|
|
9
|
-
} from "@agent-native/core/provider-api/staged-datasets-store";
|
|
10
|
-
import { getCredentialContext } from "@agent-native/core/server/request-context";
|
|
4
|
+
import { createQueryStagedDatasetAction } from "@agent-native/core/provider-api/actions/staged-datasets";
|
|
11
5
|
import { z } from "zod";
|
|
12
6
|
|
|
13
7
|
import { BRAIN_APP_ID } from "../server/lib/provider-api.js";
|
|
@@ -40,7 +34,7 @@ const AggregateFieldSchema = z.object({
|
|
|
40
34
|
.describe("Output column name. Default: {op}_{column}."),
|
|
41
35
|
});
|
|
42
36
|
|
|
43
|
-
export default
|
|
37
|
+
export default createQueryStagedDatasetAction({
|
|
44
38
|
description:
|
|
45
39
|
"Run a filter/aggregate/project query over a staged dataset previously written by provider-api-request (stageAs). Use after staging provider source records, messages, transcripts, documents, issues, events, or search results to count, group, filter, or project rows without re-fetching provider APIs.",
|
|
46
40
|
schema: z.object({
|
|
@@ -86,44 +80,5 @@ export default defineAction({
|
|
|
86
80
|
.describe("Maximum rows to return (default all, max 10000)."),
|
|
87
81
|
}),
|
|
88
82
|
http: false,
|
|
89
|
-
|
|
90
|
-
run: async (args) => {
|
|
91
|
-
const ctx = getCredentialContext();
|
|
92
|
-
if (!ctx) {
|
|
93
|
-
throw new Error("No authenticated context for query-staged-dataset.");
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const meta = await getStagedDatasetMeta({
|
|
97
|
-
id: args.datasetId,
|
|
98
|
-
appId: BRAIN_APP_ID,
|
|
99
|
-
ownerEmail: ctx.userEmail,
|
|
100
|
-
});
|
|
101
|
-
if (!meta) {
|
|
102
|
-
throw new Error(
|
|
103
|
-
`Dataset ${args.datasetId} not found (or belongs to a different owner/app).`,
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const rows = await getStagedDatasetRows({
|
|
108
|
-
id: args.datasetId,
|
|
109
|
-
appId: BRAIN_APP_ID,
|
|
110
|
-
ownerEmail: ctx.userEmail,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const result = runAggregateQuery(rows, {
|
|
114
|
-
where: args.where,
|
|
115
|
-
groupBy: args.groupBy,
|
|
116
|
-
aggregate: args.aggregate,
|
|
117
|
-
select: args.select,
|
|
118
|
-
orderBy: args.orderBy,
|
|
119
|
-
orderDir: args.orderDir,
|
|
120
|
-
limit: args.limit,
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
dataset: { id: meta.id, name: meta.name, totalRows: meta.rowCount },
|
|
125
|
-
rowCount: result.length,
|
|
126
|
-
rows: result,
|
|
127
|
-
};
|
|
128
|
-
},
|
|
83
|
+
appId: BRAIN_APP_ID,
|
|
129
84
|
});
|