@agent-native/core 0.225.2-nightly-20261106152255 → 0.226.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.
Files changed (115) hide show
  1. package/dist/agent/actions/get-agentkit-capabilities.d.ts +12 -1
  2. package/dist/agent/actions/get-agentkit-capabilities.js +13 -5
  3. package/dist/agent/production-agent.js +14 -4
  4. package/dist/agentkit/capabilities.d.ts +4 -2
  5. package/dist/agentkit/capabilities.js +71 -18
  6. package/dist/app-config/experience-profiles.d.ts +4 -0
  7. package/dist/app-config/experience-profiles.js +7 -0
  8. package/dist/app-config/onboarding.d.ts +2 -0
  9. package/dist/app-config/onboarding.js +5 -0
  10. package/dist/app-config/schema.d.ts +5 -0
  11. package/dist/app-config/schema.js +2 -0
  12. package/dist/application-state/handlers.d.ts +2 -2
  13. package/dist/client/agent-chat.d.ts +3 -1
  14. package/dist/client/agent-chat.js +8 -0
  15. package/dist/client/agentkit-chat/transport.d.ts +2 -1
  16. package/dist/client/agentkit-chat/transport.js +2 -1
  17. package/dist/client/auth/builder-signup.d.ts +14 -0
  18. package/dist/client/auth/builder-signup.js +75 -0
  19. package/dist/client/chat/agentkit-agent-native.d.ts +4 -0
  20. package/dist/client/chat/agentkit-agent-native.js +25 -0
  21. package/dist/client/chat/composer-draft.d.ts +1 -7
  22. package/dist/client/chat/composer-draft.js +5 -1
  23. package/dist/client/chat/native-uploads.d.ts +11 -0
  24. package/dist/client/chat/native-uploads.js +97 -0
  25. package/dist/client/experience-profiles.d.ts +182 -0
  26. package/dist/client/experience-profiles.js +19 -0
  27. package/dist/client/uploads/index.d.ts +1 -1
  28. package/dist/client/uploads/index.js +1 -1
  29. package/dist/client/use-action.js +3 -0
  30. package/dist/collab/routes.d.ts +1 -1
  31. package/dist/experience-profiles/index.d.ts +13 -0
  32. package/dist/experience-profiles/index.js +10 -0
  33. package/dist/experience-profiles/server.d.ts +38 -0
  34. package/dist/experience-profiles/server.js +76 -0
  35. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  36. package/dist/framework-package-versions.json +11 -11
  37. package/dist/localization/workspace-integration-messages.d.ts +11 -0
  38. package/dist/localization/workspace-integration-messages.js +132 -0
  39. package/dist/mcp/screen-memory-stdio.d.ts +3 -3
  40. package/dist/notifications/routes.d.ts +3 -3
  41. package/dist/org/index.d.ts +1 -1
  42. package/dist/provider-api/actions/custom-provider-registration.d.ts +5 -5
  43. package/dist/provider-api/actions/provider-api.d.ts +3 -3
  44. package/dist/provider-api/actions/provider-api.js +2 -0
  45. package/dist/provider-api/index.d.ts +7 -1
  46. package/dist/provider-api/index.js +42 -2
  47. package/dist/scripts/resources/read.d.ts +6 -1
  48. package/dist/scripts/resources/read.js +85 -8
  49. package/dist/secrets/routes.d.ts +2 -2
  50. package/dist/server/agent-chat/script-entries.js +27 -6
  51. package/dist/server/agent-chat-plugin.js +102 -33
  52. package/dist/server/agent-engine-api-key-route.d.ts +4 -4
  53. package/dist/server/agent-engine-ollama-models-route.d.ts +1 -1
  54. package/dist/server/auth.js +25 -1
  55. package/dist/server/better-auth-instance.d.ts +1 -0
  56. package/dist/server/builder-browser.d.ts +2 -0
  57. package/dist/server/builder-browser.js +8 -4
  58. package/dist/server/builder-signup-experiment.d.ts +67 -0
  59. package/dist/server/builder-signup-experiment.js +345 -0
  60. package/dist/server/core-routes-plugin.d.ts +2 -0
  61. package/dist/server/core-routes-plugin.js +77 -25
  62. package/dist/server/first-touch-route.d.ts +1 -1
  63. package/dist/server/google-oauth.d.ts +2 -0
  64. package/dist/server/google-oauth.js +5 -0
  65. package/dist/server/index.d.ts +1 -1
  66. package/dist/server/index.js +1 -1
  67. package/dist/server/transcribe-voice.d.ts +1 -1
  68. package/dist/shared/agent-chat-references.d.ts +2 -0
  69. package/dist/shared/agent-chat-references.js +8 -0
  70. package/dist/shared/auth-copy.d.ts +1 -0
  71. package/dist/shared/auth-copy.js +11 -0
  72. package/dist/shared/index.d.ts +1 -0
  73. package/dist/shared/index.js +1 -0
  74. package/dist/templates/builder-code-starter/server/lib/composer-reference-messages.ts.patch +44 -0
  75. package/dist/templates/builder-code-starter/server/plugins/agent-chat.ts.patch +10 -1
  76. package/dist/templates/chat/app/components/ChatComposerContext.tsx +31 -0
  77. package/dist/templates/chat/app/components/chat/ChatRouteContent.tsx +3 -0
  78. package/dist/templates/chat/app/components/home/HomePage.tsx +4 -2
  79. package/dist/templates/chat/app/components/layout/AgentInspector.tsx +2 -0
  80. package/dist/templates/chat/app/i18n/ar-SA.ts +7 -0
  81. package/dist/templates/chat/app/i18n/de-DE.ts +8 -0
  82. package/dist/templates/chat/app/i18n/en-US.ts +8 -0
  83. package/dist/templates/chat/app/i18n/es-ES.ts +8 -0
  84. package/dist/templates/chat/app/i18n/fr-FR.ts +8 -0
  85. package/dist/templates/chat/app/i18n/hi-IN.ts +7 -0
  86. package/dist/templates/chat/app/i18n/ja-JP.ts +8 -0
  87. package/dist/templates/chat/app/i18n/ko-KR.ts +8 -0
  88. package/dist/templates/chat/app/i18n/pt-BR.ts +8 -0
  89. package/dist/templates/chat/app/i18n/zh-CN.ts +7 -0
  90. package/dist/templates/chat/app/i18n/zh-TW.ts +7 -0
  91. package/dist/templates/chat/server/lib/composer-reference-messages.ts +34 -0
  92. package/dist/templates/chat/server/lib/composer-references.ts +60 -0
  93. package/dist/templates/chat/server/plugins/agent-chat.ts +13 -0
  94. package/docs/content/components.mdx +7 -2
  95. package/package.json +9 -4
  96. package/src/templates/builder-code-starter/server/lib/composer-reference-messages.ts.patch +44 -0
  97. package/src/templates/builder-code-starter/server/plugins/agent-chat.ts.patch +10 -1
  98. package/src/templates/chat/app/components/ChatComposerContext.tsx +31 -0
  99. package/src/templates/chat/app/components/chat/ChatRouteContent.tsx +3 -0
  100. package/src/templates/chat/app/components/home/HomePage.tsx +4 -2
  101. package/src/templates/chat/app/components/layout/AgentInspector.tsx +2 -0
  102. package/src/templates/chat/app/i18n/ar-SA.ts +7 -0
  103. package/src/templates/chat/app/i18n/de-DE.ts +8 -0
  104. package/src/templates/chat/app/i18n/en-US.ts +8 -0
  105. package/src/templates/chat/app/i18n/es-ES.ts +8 -0
  106. package/src/templates/chat/app/i18n/fr-FR.ts +8 -0
  107. package/src/templates/chat/app/i18n/hi-IN.ts +7 -0
  108. package/src/templates/chat/app/i18n/ja-JP.ts +8 -0
  109. package/src/templates/chat/app/i18n/ko-KR.ts +8 -0
  110. package/src/templates/chat/app/i18n/pt-BR.ts +8 -0
  111. package/src/templates/chat/app/i18n/zh-CN.ts +7 -0
  112. package/src/templates/chat/app/i18n/zh-TW.ts +7 -0
  113. package/src/templates/chat/server/lib/composer-reference-messages.ts +34 -0
  114. package/src/templates/chat/server/lib/composer-references.ts +60 -0
  115. package/src/templates/chat/server/plugins/agent-chat.ts +13 -0
@@ -0,0 +1,44 @@
1
+ --- a/server/lib/composer-reference-messages.ts
2
+ +++ b/server/lib/composer-reference-messages.ts
3
+ @@ -1,5 +1 @@
4
+ -import {
5
+ - DEFAULT_LOCALE,
6
+ - LOCALIZATION_SETTING_KEY,
7
+ - normalizeLocalizationPreference,
8
+ -} from "@agent-native/core/localization";
9
+ +import { workspaceIntegrationMessagesForUser } from "@agent-native/core/localization/workspace-integration-messages";
10
+ @@ -7 +2,0 @@
11
+ -import { getUserSetting } from "@agent-native/core/settings";
12
+ @@ -9,14 +3,0 @@
13
+ -const catalogs = {
14
+ - "en-US": () => import("../../app/i18n/en-US.js"),
15
+ - "ar-SA": () => import("../../app/i18n/ar-SA.js"),
16
+ - "de-DE": () => import("../../app/i18n/de-DE.js"),
17
+ - "es-ES": () => import("../../app/i18n/es-ES.js"),
18
+ - "fr-FR": () => import("../../app/i18n/fr-FR.js"),
19
+ - "hi-IN": () => import("../../app/i18n/hi-IN.js"),
20
+ - "ja-JP": () => import("../../app/i18n/ja-JP.js"),
21
+ - "ko-KR": () => import("../../app/i18n/ko-KR.js"),
22
+ - "pt-BR": () => import("../../app/i18n/pt-BR.js"),
23
+ - "zh-CN": () => import("../../app/i18n/zh-CN.js"),
24
+ - "zh-TW": () => import("../../app/i18n/zh-TW.js"),
25
+ -};
26
+ -
27
+ @@ -24,3 +5,2 @@
28
+ - const email = getRequestUserEmail();
29
+ - const preference = normalizeLocalizationPreference(
30
+ - email ? await getUserSetting(email, LOCALIZATION_SETTING_KEY) : undefined,
31
+ + const messages = await workspaceIntegrationMessagesForUser(
32
+ + getRequestUserEmail() ?? "",
33
+ @@ -28,6 +8,5 @@
34
+ - const locale = preference.locale;
35
+ - const load =
36
+ - locale && locale in catalogs
37
+ - ? catalogs[locale as keyof typeof catalogs]
38
+ - : catalogs[DEFAULT_LOCALE];
39
+ - return (await load()).default.composerSources;
40
+ + return {
41
+ + authentication: messages.composerReferenceAuthentication,
42
+ + invalid: messages.composerReferenceInvalid,
43
+ + unavailable: messages.composerReferenceUnavailable,
44
+ + };
@@ -1,12 +1,16 @@
1
1
  ===================================================================
2
2
  --- a/server/plugins/agent-chat.ts
3
3
  +++ b/server/plugins/agent-chat.ts
4
- @@ -4,25 +4,21 @@
4
+ @@ -4,21 +4,14 @@
5
5
  loadActionsFromStaticRegistry,
6
6
  } from "@agent-native/core/server";
7
7
 
8
8
  import actionsRegistry from "../../.generated/actions-registry.js";
9
9
  +import { appOperationFinalResponseGuard } from "../agent/app-operation-guard.js";
10
+ import {
11
+ searchConversationReferences,
12
+ validateConversationReferences,
13
+ } from "../lib/composer-references.js";
10
14
 
11
15
  -const INITIAL_TOOL_NAMES = [
12
16
  - "view-screen",
@@ -18,6 +22,11 @@
18
22
  -
19
23
  export default createAgentChatPlugin({
20
24
  appId: "chat",
25
+ mentionProviders: {
26
+ chats: {
27
+ @@ -30,12 +23,15 @@
28
+ await validateConversationReferences(references);
29
+ },
21
30
  actions: loadActionsFromStaticRegistry(actionsRegistry),
22
31
  mcp: { connectorCatalog: [], appApprovalPage: true },
23
32
  - initialToolNames: INITIAL_TOOL_NAMES,
@@ -0,0 +1,31 @@
1
+ import { useT } from "@agent-native/core/client/i18n";
2
+ import type { AssistantChatComposerContextProviderProps } from "@agent-native/toolkit/app/chat/chat";
3
+ import type { ComposerContextMenuItem } from "@agent-native/toolkit/composer";
4
+ import { IconMessages } from "@tabler/icons-react";
5
+
6
+ export function useChatComposerMenuItems(): ComposerContextMenuItem[] {
7
+ const t = useT();
8
+ return [
9
+ {
10
+ id: "reference-chat",
11
+ label: t("composerSources.reference"),
12
+ icon: <IconMessages />,
13
+ section: "context",
14
+ order: 20,
15
+ referenceType: "chat",
16
+ referencePicker: { source: "chats", referenceType: "chat" },
17
+ },
18
+ ];
19
+ }
20
+
21
+ export function ChatComposerContextProvider({
22
+ children,
23
+ }: AssistantChatComposerContextProviderProps) {
24
+ return children({
25
+ menuItems: useChatComposerMenuItems(),
26
+ contextItems: [],
27
+ onRemoveContextItem: () => {},
28
+ prepareSubmission: async (snapshot) => snapshot,
29
+ submissionAccepted: () => {},
30
+ });
31
+ }
@@ -81,6 +81,7 @@ import {
81
81
  import { useLocation, useNavigate, useParams } from "react-router";
82
82
  import { toast } from "sonner";
83
83
 
84
+ import { useChatComposerMenuItems } from "@/components/ChatComposerContext";
84
85
  import { Button } from "@/components/ui/button";
85
86
  import {
86
87
  Tooltip,
@@ -1390,6 +1391,7 @@ function ChatCanvas({
1390
1391
  ),
1391
1392
  [setWorkspaceOpen, t, workspaceOpen],
1392
1393
  );
1394
+ const contextMenuItems = useChatComposerMenuItems();
1393
1395
  const chatTitle = thread.thread?.title?.trim() || APP_TITLE;
1394
1396
 
1395
1397
  return (
@@ -1406,6 +1408,7 @@ function ChatCanvas({
1406
1408
  expectExistingThread={!isDraftThread}
1407
1409
  onStartNewChat={() => void navigate(NEW_CHAT_PATH)}
1408
1410
  composerProps={{
1411
+ contextMenuItems,
1409
1412
  requireAgentEngine: true,
1410
1413
  contextUsageSlot: <ChatContextRing threadId={threadId} />,
1411
1414
  ...(initialText === undefined ? {} : { initialText }),
@@ -20,6 +20,7 @@ import {
20
20
  import { useState, type ReactNode } from "react";
21
21
  import { useNavigate } from "react-router";
22
22
 
23
+ import { useChatComposerMenuItems } from "@/components/ChatComposerContext";
23
24
  import { Button } from "@/components/ui/button";
24
25
  import {
25
26
  Item,
@@ -120,14 +121,15 @@ function HomeAgentComposerInput({
120
121
  }) {
121
122
  const t = useT();
122
123
  const control = useAgentKitControl(threadId);
124
+ const contextMenuItems = useChatComposerMenuItems();
123
125
 
124
126
  return (
125
127
  <AgentKitComposer
126
128
  threadId={threadId}
127
129
  requireAgentEngine
128
130
  placeholder={t("chat.composerPlaceholder")}
129
- plusMenuMode="hidden"
130
- attachmentsEnabled={false}
131
+ plusMenuMode="full"
132
+ contextMenuItems={contextMenuItems}
131
133
  voiceEnabled
132
134
  onVoiceChatStart={onVoiceChatStart}
133
135
  onSubmit={async (text, files, references, options) => {
@@ -5,6 +5,7 @@ import { AgentSidebar } from "@agent-native/toolkit/app/chat";
5
5
  import { type ReactNode } from "react";
6
6
  import { useNavigate } from "react-router";
7
7
 
8
+ import { ChatComposerContextProvider } from "@/components/ChatComposerContext";
8
9
  import { chatThreadPath } from "@/lib/chat-paths";
9
10
  import { TAB_ID } from "@/lib/tab-id";
10
11
 
@@ -30,6 +31,7 @@ export function AgentInspector({
30
31
 
31
32
  return (
32
33
  <AgentSidebar
34
+ composerContextProvider={ChatComposerContextProvider}
33
35
  position="right"
34
36
  chatViewTransition
35
37
  chatViewTransitionHandoff={chatHomeHandoffPending}
@@ -1,4 +1,11 @@
1
1
  const messages = {
2
+ composerSources: {
3
+ reference: "الإشارة إلى محادثة…",
4
+ group: "المحادثات",
5
+ authentication: "سجّل الدخول لإضافة مرجع.",
6
+ invalid: "اختر مرجعًا صالحًا قبل الإرسال.",
7
+ unavailable: "لم يعد المرجع المحدد متاحًا. أزله أو اختره مرة أخرى.",
8
+ },
2
9
  composer: {
3
10
  removeAttachment: "إزالة {{name}}",
4
11
  removeReference: "إزالة مرجع {{name}}",
@@ -1,4 +1,12 @@
1
1
  const messages = {
2
+ composerSources: {
3
+ reference: "Unterhaltung referenzieren…",
4
+ group: "Unterhaltungen",
5
+ authentication: "Melde dich an, um eine Referenz hinzuzufügen.",
6
+ invalid: "Wähle vor dem Senden eine gültige Referenz.",
7
+ unavailable:
8
+ "Eine ausgewählte Referenz ist nicht mehr verfügbar. Entferne sie oder wähle sie erneut.",
9
+ },
2
10
  composer: {
3
11
  removeAttachment: "{{name}} entfernen",
4
12
  removeReference: "Referenz {{name}} entfernen",
@@ -1,4 +1,12 @@
1
1
  const messages = {
2
+ composerSources: {
3
+ reference: "Reference a conversation…",
4
+ group: "Conversations",
5
+ authentication: "Sign in to add a reference.",
6
+ invalid: "Choose a valid reference before sending.",
7
+ unavailable:
8
+ "A selected reference is no longer available. Remove it or choose it again.",
9
+ },
2
10
  composer: {
3
11
  removeAttachment: "Remove {{name}}",
4
12
  removeReference: "Remove {{name}} reference",
@@ -1,4 +1,12 @@
1
1
  const messages = {
2
+ composerSources: {
3
+ reference: "Referenciar una conversación…",
4
+ group: "Conversaciones",
5
+ authentication: "Inicia sesión para añadir una referencia.",
6
+ invalid: "Elige una referencia válida antes de enviar.",
7
+ unavailable:
8
+ "Una referencia seleccionada ya no está disponible. Elimínala o selecciónala de nuevo.",
9
+ },
2
10
  composer: {
3
11
  removeAttachment: "Quitar {{name}}",
4
12
  removeReference: "Eliminar la referencia {{name}}",
@@ -1,4 +1,12 @@
1
1
  const messages = {
2
+ composerSources: {
3
+ reference: "Référencer une conversation…",
4
+ group: "Conversations",
5
+ authentication: "Connectez-vous pour ajouter une référence.",
6
+ invalid: "Choisissez une référence valide avant l’envoi.",
7
+ unavailable:
8
+ "Une référence sélectionnée n’est plus disponible. Supprimez-la ou sélectionnez-la à nouveau.",
9
+ },
2
10
  composer: {
3
11
  removeAttachment: "Supprimer {{name}}",
4
12
  removeReference: "Supprimer la référence {{name}}",
@@ -1,4 +1,11 @@
1
1
  const messages = {
2
+ composerSources: {
3
+ reference: "बातचीत का संदर्भ दें…",
4
+ group: "बातचीत",
5
+ authentication: "संदर्भ जोड़ने के लिए साइन इन करें।",
6
+ invalid: "भेजने से पहले एक मान्य संदर्भ चुनें।",
7
+ unavailable: "चुना गया संदर्भ अब उपलब्ध नहीं है। उसे हटाएँ या फिर से चुनें।",
8
+ },
2
9
  composer: {
3
10
  removeAttachment: "{{name}} हटाएँ",
4
11
  removeReference: "{{name}} संदर्भ हटाएँ",
@@ -1,4 +1,12 @@
1
1
  const messages = {
2
+ composerSources: {
3
+ reference: "会話を参照…",
4
+ group: "会話",
5
+ authentication: "参照を追加するにはログインしてください。",
6
+ invalid: "送信する前に有効な参照を選択してください。",
7
+ unavailable:
8
+ "選択した参照は利用できなくなりました。削除するか、もう一度選択してください。",
9
+ },
2
10
  composer: {
3
11
  removeAttachment: "{{name}} を削除",
4
12
  removeReference: "{{name}} の参照を削除",
@@ -1,4 +1,12 @@
1
1
  const messages = {
2
+ composerSources: {
3
+ reference: "대화 참조…",
4
+ group: "대화",
5
+ authentication: "참조를 추가하려면 로그인하세요.",
6
+ invalid: "전송하기 전에 유효한 참조를 선택하세요.",
7
+ unavailable:
8
+ "선택한 참조를 더 이상 사용할 수 없습니다. 제거하거나 다시 선택하세요.",
9
+ },
2
10
  composer: {
3
11
  removeAttachment: "{{name}} 제거",
4
12
  removeReference: "{{name}} 참조 제거",
@@ -1,4 +1,12 @@
1
1
  const messages = {
2
+ composerSources: {
3
+ reference: "Referenciar uma conversa…",
4
+ group: "Conversas",
5
+ authentication: "Entre para adicionar uma referência.",
6
+ invalid: "Escolha uma referência válida antes de enviar.",
7
+ unavailable:
8
+ "Uma referência selecionada não está mais disponível. Remova-a ou selecione-a novamente.",
9
+ },
2
10
  composer: {
3
11
  removeAttachment: "Remover {{name}}",
4
12
  removeReference: "Remover referência {{name}}",
@@ -1,4 +1,11 @@
1
1
  const messages = {
2
+ composerSources: {
3
+ reference: "引用对话…",
4
+ group: "对话",
5
+ authentication: "登录以添加引用。",
6
+ invalid: "发送前请选择有效的引用。",
7
+ unavailable: "所选引用已不可用。请移除或重新选择。",
8
+ },
2
9
  composer: {
3
10
  removeAttachment: "移除 {{name}}",
4
11
  removeReference: "移除 {{name}} 引用",
@@ -1,4 +1,11 @@
1
1
  const messages = {
2
+ composerSources: {
3
+ reference: "引用對話…",
4
+ group: "對話",
5
+ authentication: "登入以新增引用。",
6
+ invalid: "傳送前請選擇有效的引用。",
7
+ unavailable: "所選引用已無法使用。請移除或重新選擇。",
8
+ },
2
9
  composer: {
3
10
  removeAttachment: "移除 {{name}}",
4
11
  removeReference: "移除 {{name}} 參照",
@@ -0,0 +1,34 @@
1
+ import {
2
+ DEFAULT_LOCALE,
3
+ LOCALIZATION_SETTING_KEY,
4
+ normalizeLocalizationPreference,
5
+ } from "@agent-native/core/localization";
6
+ import { getRequestUserEmail } from "@agent-native/core/server/request-context";
7
+ import { getUserSetting } from "@agent-native/core/settings";
8
+
9
+ const catalogs = {
10
+ "en-US": () => import("../../app/i18n/en-US.js"),
11
+ "ar-SA": () => import("../../app/i18n/ar-SA.js"),
12
+ "de-DE": () => import("../../app/i18n/de-DE.js"),
13
+ "es-ES": () => import("../../app/i18n/es-ES.js"),
14
+ "fr-FR": () => import("../../app/i18n/fr-FR.js"),
15
+ "hi-IN": () => import("../../app/i18n/hi-IN.js"),
16
+ "ja-JP": () => import("../../app/i18n/ja-JP.js"),
17
+ "ko-KR": () => import("../../app/i18n/ko-KR.js"),
18
+ "pt-BR": () => import("../../app/i18n/pt-BR.js"),
19
+ "zh-CN": () => import("../../app/i18n/zh-CN.js"),
20
+ "zh-TW": () => import("../../app/i18n/zh-TW.js"),
21
+ };
22
+
23
+ export async function composerReferenceMessages() {
24
+ const email = getRequestUserEmail();
25
+ const preference = normalizeLocalizationPreference(
26
+ email ? await getUserSetting(email, LOCALIZATION_SETTING_KEY) : undefined,
27
+ );
28
+ const locale = preference.locale;
29
+ const load =
30
+ locale && locale in catalogs
31
+ ? catalogs[locale as keyof typeof catalogs]
32
+ : catalogs[DEFAULT_LOCALE];
33
+ return (await load()).default.composerSources;
34
+ }
@@ -0,0 +1,60 @@
1
+ import { getOrgContext } from "@agent-native/core/org";
2
+ import {
3
+ listThreads,
4
+ searchThreads,
5
+ type AgentChatReference,
6
+ } from "@agent-native/core/server";
7
+ import { assertAccess, ForbiddenError } from "@agent-native/core/sharing";
8
+ import { createError, type H3Event } from "h3";
9
+
10
+ import { composerReferenceMessages } from "./composer-reference-messages.js";
11
+
12
+ export async function searchConversationReferences(
13
+ query: string,
14
+ event?: H3Event,
15
+ ) {
16
+ if (!event)
17
+ throw createError({
18
+ statusCode: 401,
19
+ statusMessage: (await composerReferenceMessages()).authentication,
20
+ });
21
+ const { email, orgId } = await getOrgContext(event);
22
+ const options = { orgId, includeExternal: false, sourceAppId: "chat" };
23
+ const search = query.trim().slice(0, 200);
24
+ const rows = search
25
+ ? await searchThreads(email, search, 20, options)
26
+ : await listThreads(email, { ...options, limit: 20 });
27
+ return rows.map((row) => ({
28
+ id: `chat:${row.id}`,
29
+ label: row.title || row.id,
30
+ description: row.preview.slice(0, 500),
31
+ refType: "chat",
32
+ refId: row.id,
33
+ refPath: `/chat/${encodeURIComponent(row.id)}`,
34
+ icon: "message",
35
+ }));
36
+ }
37
+
38
+ export async function validateConversationReferences(
39
+ references: readonly AgentChatReference[],
40
+ ) {
41
+ for (const reference of references) {
42
+ if (reference.type !== "mention" || reference.refType !== "chat") continue;
43
+ if (!reference.refId)
44
+ throw createError({
45
+ statusCode: 400,
46
+ statusMessage: (await composerReferenceMessages()).invalid,
47
+ });
48
+ try {
49
+ await assertAccess("chat_thread", reference.refId, "viewer", undefined, {
50
+ skipResourceBody: true,
51
+ });
52
+ } catch (error) {
53
+ if (error instanceof ForbiddenError)
54
+ throw new ForbiddenError(
55
+ (await composerReferenceMessages()).unavailable,
56
+ );
57
+ throw error;
58
+ }
59
+ }
60
+ }
@@ -5,6 +5,10 @@ import {
5
5
  } from "@agent-native/core/server";
6
6
 
7
7
  import actionsRegistry from "../../.generated/actions-registry.js";
8
+ import {
9
+ searchConversationReferences,
10
+ validateConversationReferences,
11
+ } from "../lib/composer-references.js";
8
12
 
9
13
  const INITIAL_TOOL_NAMES = [
10
14
  "view-screen",
@@ -16,6 +20,15 @@ const INITIAL_TOOL_NAMES = [
16
20
 
17
21
  export default createAgentChatPlugin({
18
22
  appId: "chat",
23
+ mentionProviders: {
24
+ chats: {
25
+ label: "composerSources.group",
26
+ search: searchConversationReferences,
27
+ },
28
+ },
29
+ prepareRequest: async ({ references }) => {
30
+ await validateConversationReferences(references);
31
+ },
19
32
  actions: loadActionsFromStaticRegistry(actionsRegistry),
20
33
  mcp: { connectorCatalog: [], appApprovalPage: true },
21
34
  initialToolNames: INITIAL_TOOL_NAMES,