@agent-native/dispatch 0.43.0-nightly-20261120212328 → 0.43.7

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 (296) hide show
  1. package/CHANGELOG.md +194 -174
  2. package/dist/actions/ask_app.d.ts +3 -0
  3. package/dist/actions/ask_app.js +7 -2
  4. package/dist/actions/ask_app.js.map +1 -1
  5. package/dist/actions/ask_app_status.d.ts +3 -0
  6. package/dist/actions/ask_app_status.js +5 -1
  7. package/dist/actions/ask_app_status.js.map +1 -1
  8. package/dist/actions/call_app_action.d.ts +1 -0
  9. package/dist/actions/call_app_action.js +21 -5
  10. package/dist/actions/call_app_action.js.map +1 -1
  11. package/dist/actions/create_embed_session.d.ts +3 -2
  12. package/dist/actions/create_embed_session.js +4 -2
  13. package/dist/actions/create_embed_session.js.map +1 -1
  14. package/dist/actions/create_workspace_app_embed_session.d.ts +3 -2
  15. package/dist/actions/create_workspace_app_embed_session.js +3 -1
  16. package/dist/actions/create_workspace_app_embed_session.js.map +1 -1
  17. package/dist/actions/delete-destination.d.ts +12 -12
  18. package/dist/actions/execute-action-suggestion.d.ts +44 -0
  19. package/dist/actions/execute-action-suggestion.d.ts.map +1 -0
  20. package/dist/actions/execute-action-suggestion.js +148 -0
  21. package/dist/actions/execute-action-suggestion.js.map +1 -0
  22. package/dist/actions/import-agent.d.ts +13 -13
  23. package/dist/actions/index.d.ts.map +1 -1
  24. package/dist/actions/index.js +5 -1
  25. package/dist/actions/index.js.map +1 -1
  26. package/dist/actions/list-connected-agents.js +3 -2
  27. package/dist/actions/list-connected-agents.js.map +1 -1
  28. package/dist/actions/list-workspace-connections.d.ts +1 -0
  29. package/dist/actions/list-workspace-connections.d.ts.map +1 -1
  30. package/dist/actions/list_app_actions.js +1 -1
  31. package/dist/actions/list_app_actions.js.map +1 -1
  32. package/dist/actions/list_apps.d.ts +2 -0
  33. package/dist/actions/list_apps.js +11 -3
  34. package/dist/actions/list_apps.js.map +1 -1
  35. package/dist/actions/navigate.js +1 -0
  36. package/dist/actions/navigate.js.map +1 -1
  37. package/dist/actions/open_app.d.ts +4 -0
  38. package/dist/actions/open_app.js +14 -6
  39. package/dist/actions/open_app.js.map +1 -1
  40. package/dist/actions/propose-action-suggestions.d.ts +45 -0
  41. package/dist/actions/propose-action-suggestions.d.ts.map +1 -0
  42. package/dist/actions/propose-action-suggestions.js +32 -0
  43. package/dist/actions/propose-action-suggestions.js.map +1 -0
  44. package/dist/actions/provider-api-register.d.ts +12 -12
  45. package/dist/actions/read_view.js +1 -1
  46. package/dist/actions/read_view.js.map +1 -1
  47. package/dist/actions/remember-pointer.js +1 -1
  48. package/dist/actions/remember-pointer.js.map +1 -1
  49. package/dist/actions/resolve-pointer.js +1 -1
  50. package/dist/actions/resolve-pointer.js.map +1 -1
  51. package/dist/actions/route-app-intent.d.ts +6 -0
  52. package/dist/actions/route-app-intent.js +79 -5
  53. package/dist/actions/route-app-intent.js.map +1 -1
  54. package/dist/actions/send-code-agent-remote-command.js +4 -0
  55. package/dist/actions/send-code-agent-remote-command.js.map +1 -1
  56. package/dist/actions/start-workspace-app-creation.js +1 -1
  57. package/dist/actions/start-workspace-app-creation.js.map +1 -1
  58. package/dist/actions/upsert-destination.d.ts +12 -12
  59. package/dist/actions/view-screen.d.ts +12 -1
  60. package/dist/actions/view-screen.js +53 -5
  61. package/dist/actions/view-screen.js.map +1 -1
  62. package/dist/components/chat-action-suggestions.d.ts +8 -0
  63. package/dist/components/chat-action-suggestions.d.ts.map +1 -0
  64. package/dist/components/chat-action-suggestions.js +191 -0
  65. package/dist/components/chat-action-suggestions.js.map +1 -0
  66. package/dist/components/chat-home-apps.d.ts.map +1 -1
  67. package/dist/components/chat-home-apps.js +1 -1
  68. package/dist/components/chat-home-apps.js.map +1 -1
  69. package/dist/components/google-broker-settings-group.d.ts +2 -0
  70. package/dist/components/google-broker-settings-group.d.ts.map +1 -0
  71. package/dist/components/google-broker-settings-group.js +53 -0
  72. package/dist/components/google-broker-settings-group.js.map +1 -0
  73. package/dist/components/layout/Layout.d.ts +4 -1
  74. package/dist/components/layout/Layout.d.ts.map +1 -1
  75. package/dist/components/layout/Layout.js +246 -69
  76. package/dist/components/layout/Layout.js.map +1 -1
  77. package/dist/components/messaging-setup-panel.d.ts.map +1 -1
  78. package/dist/components/messaging-setup-panel.js +47 -15
  79. package/dist/components/messaging-setup-panel.js.map +1 -1
  80. package/dist/components/workspace-app-host.d.ts +27 -4
  81. package/dist/components/workspace-app-host.d.ts.map +1 -1
  82. package/dist/components/workspace-app-host.js +355 -74
  83. package/dist/components/workspace-app-host.js.map +1 -1
  84. package/dist/config.d.ts +5 -0
  85. package/dist/config.d.ts.map +1 -1
  86. package/dist/config.js.map +1 -1
  87. package/dist/db/google-broker-admission.d.ts +36 -0
  88. package/dist/db/google-broker-admission.d.ts.map +1 -0
  89. package/dist/db/google-broker-admission.js +129 -0
  90. package/dist/db/google-broker-admission.js.map +1 -0
  91. package/dist/db/migrations.d.ts +1 -1
  92. package/dist/db/migrations.d.ts.map +1 -1
  93. package/dist/db/migrations.js +42 -0
  94. package/dist/db/migrations.js.map +1 -1
  95. package/dist/lib/action-suggestions.d.ts +20 -0
  96. package/dist/lib/action-suggestions.d.ts.map +1 -0
  97. package/dist/lib/action-suggestions.js +219 -0
  98. package/dist/lib/action-suggestions.js.map +1 -0
  99. package/dist/lib/chat-first-app-route.d.ts +11 -5
  100. package/dist/lib/chat-first-app-route.d.ts.map +1 -1
  101. package/dist/lib/chat-first-app-route.js +9 -5
  102. package/dist/lib/chat-first-app-route.js.map +1 -1
  103. package/dist/lib/chat-first-pane.d.ts +25 -1
  104. package/dist/lib/chat-first-pane.d.ts.map +1 -1
  105. package/dist/lib/chat-first-pane.js +67 -1
  106. package/dist/lib/chat-first-pane.js.map +1 -1
  107. package/dist/lib/data-intent.d.ts +3 -0
  108. package/dist/lib/data-intent.d.ts.map +1 -0
  109. package/dist/lib/data-intent.js +14 -0
  110. package/dist/lib/data-intent.js.map +1 -0
  111. package/dist/lib/dispatch-app-identity.d.ts +10 -0
  112. package/dist/lib/dispatch-app-identity.d.ts.map +1 -0
  113. package/dist/lib/dispatch-app-identity.js +18 -0
  114. package/dist/lib/dispatch-app-identity.js.map +1 -0
  115. package/dist/lib/other-apps.d.ts +15 -0
  116. package/dist/lib/other-apps.d.ts.map +1 -1
  117. package/dist/lib/other-apps.js +31 -0
  118. package/dist/lib/other-apps.js.map +1 -1
  119. package/dist/lib/workspace-app-frame-view.d.ts +15 -0
  120. package/dist/lib/workspace-app-frame-view.d.ts.map +1 -0
  121. package/dist/lib/workspace-app-frame-view.js +72 -0
  122. package/dist/lib/workspace-app-frame-view.js.map +1 -0
  123. package/dist/lib/workspace-apps.d.ts +5 -0
  124. package/dist/lib/workspace-apps.d.ts.map +1 -1
  125. package/dist/lib/workspace-apps.js +85 -23
  126. package/dist/lib/workspace-apps.js.map +1 -1
  127. package/dist/lib/workspace-apps.test.js +6 -0
  128. package/dist/lib/workspace-apps.test.js.map +1 -1
  129. package/dist/routes/pages/_index.d.ts +2 -2
  130. package/dist/routes/pages/chat.d.ts.map +1 -1
  131. package/dist/routes/pages/chat.js +33 -2
  132. package/dist/routes/pages/chat.js.map +1 -1
  133. package/dist/routes/pages/settings-page.d.ts +1 -1
  134. package/dist/routes/pages/settings-page.d.ts.map +1 -1
  135. package/dist/routes/pages/settings-page.js +3 -2
  136. package/dist/routes/pages/settings-page.js.map +1 -1
  137. package/dist/server/index.d.ts +4 -1
  138. package/dist/server/index.d.ts.map +1 -1
  139. package/dist/server/index.js +5 -5
  140. package/dist/server/index.js.map +1 -1
  141. package/dist/server/lib/action-suggestions.d.ts +41 -0
  142. package/dist/server/lib/action-suggestions.d.ts.map +1 -0
  143. package/dist/server/lib/action-suggestions.js +94 -0
  144. package/dist/server/lib/action-suggestions.js.map +1 -0
  145. package/dist/server/lib/app-action-result.d.ts +5 -0
  146. package/dist/server/lib/app-action-result.d.ts.map +1 -1
  147. package/dist/server/lib/app-action-result.js +7 -0
  148. package/dist/server/lib/app-action-result.js.map +1 -1
  149. package/dist/server/lib/app-creation-store.d.ts.map +1 -1
  150. package/dist/server/lib/app-creation-store.js +63 -13
  151. package/dist/server/lib/app-creation-store.js.map +1 -1
  152. package/dist/server/lib/curated-workspace-templates.d.ts.map +1 -1
  153. package/dist/server/lib/curated-workspace-templates.js +3 -0
  154. package/dist/server/lib/curated-workspace-templates.js.map +1 -1
  155. package/dist/server/lib/dispatch-config.d.ts +5 -0
  156. package/dist/server/lib/dispatch-config.d.ts.map +1 -0
  157. package/dist/server/lib/dispatch-config.js +11 -0
  158. package/dist/server/lib/dispatch-config.js.map +1 -0
  159. package/dist/server/lib/dispatch-pane-context.d.ts +11 -0
  160. package/dist/server/lib/dispatch-pane-context.d.ts.map +1 -0
  161. package/dist/server/lib/dispatch-pane-context.js +35 -0
  162. package/dist/server/lib/dispatch-pane-context.js.map +1 -0
  163. package/dist/server/lib/google-broker-provider.d.ts +41 -0
  164. package/dist/server/lib/google-broker-provider.d.ts.map +1 -0
  165. package/dist/server/lib/google-broker-provider.js +96 -0
  166. package/dist/server/lib/google-broker-provider.js.map +1 -0
  167. package/dist/server/lib/google-broker-rpc.d.ts +26 -0
  168. package/dist/server/lib/google-broker-rpc.d.ts.map +1 -0
  169. package/dist/server/lib/google-broker-rpc.js +52 -0
  170. package/dist/server/lib/google-broker-rpc.js.map +1 -0
  171. package/dist/server/lib/hosted-apps-settings.d.ts.map +1 -1
  172. package/dist/server/lib/hosted-apps-settings.js +4 -0
  173. package/dist/server/lib/hosted-apps-settings.js.map +1 -1
  174. package/dist/server/lib/mcp-app-discovery.d.ts +17 -0
  175. package/dist/server/lib/mcp-app-discovery.d.ts.map +1 -0
  176. package/dist/server/lib/mcp-app-discovery.js +231 -0
  177. package/dist/server/lib/mcp-app-discovery.js.map +1 -0
  178. package/dist/server/lib/mcp-gateway.d.ts +64 -21
  179. package/dist/server/lib/mcp-gateway.d.ts.map +1 -1
  180. package/dist/server/lib/mcp-gateway.js +730 -88
  181. package/dist/server/lib/mcp-gateway.js.map +1 -1
  182. package/dist/server/plugins/agent-chat.js +9 -7
  183. package/dist/server/plugins/agent-chat.js.map +1 -1
  184. package/dist/server/plugins/auth.d.ts.map +1 -1
  185. package/dist/server/plugins/auth.js +1 -0
  186. package/dist/server/plugins/auth.js.map +1 -1
  187. package/dist/server/plugins/db.d.ts.map +1 -1
  188. package/dist/server/plugins/db.js +0 -46
  189. package/dist/server/plugins/db.js.map +1 -1
  190. package/dist/server/plugins/integrations.d.ts.map +1 -1
  191. package/dist/server/plugins/integrations.js +4 -1
  192. package/dist/server/plugins/integrations.js.map +1 -1
  193. package/dist/shared/chat-first-pane.d.ts +24 -0
  194. package/dist/shared/chat-first-pane.d.ts.map +1 -1
  195. package/dist/shared/chat-first-pane.js +34 -0
  196. package/dist/shared/chat-first-pane.js.map +1 -1
  197. package/dist/shared/labs.d.ts +1 -0
  198. package/dist/shared/labs.d.ts.map +1 -1
  199. package/dist/shared/labs.js +7 -0
  200. package/dist/shared/labs.js.map +1 -1
  201. package/package.json +7 -6
  202. package/src/actions/action-suggestions.spec.ts +342 -0
  203. package/src/actions/app_actions.spec.ts +103 -0
  204. package/src/actions/ask_app.ts +9 -2
  205. package/src/actions/ask_app_status.ts +12 -1
  206. package/src/actions/call_app_action.ts +28 -8
  207. package/src/actions/create_embed_session.ts +8 -2
  208. package/src/actions/create_workspace_app_embed_session.ts +6 -1
  209. package/src/actions/execute-action-suggestion.ts +177 -0
  210. package/src/actions/index.spec.ts +6 -3
  211. package/src/actions/index.ts +5 -1
  212. package/src/actions/list-connected-agents.spec.ts +26 -1
  213. package/src/actions/list-connected-agents.ts +7 -4
  214. package/src/actions/list_app_actions.ts +1 -1
  215. package/src/actions/list_apps.spec.ts +58 -22
  216. package/src/actions/list_apps.ts +12 -5
  217. package/src/actions/navigate.ts +1 -0
  218. package/src/actions/open_app.spec.ts +17 -1
  219. package/src/actions/open_app.ts +21 -8
  220. package/src/actions/propose-action-suggestions.ts +42 -0
  221. package/src/actions/read_view.ts +1 -1
  222. package/src/actions/remember-pointer.ts +1 -1
  223. package/src/actions/resolve-pointer.ts +1 -1
  224. package/src/actions/route-app-intent.spec.ts +234 -5
  225. package/src/actions/route-app-intent.ts +89 -4
  226. package/src/actions/send-code-agent-remote-command.spec.ts +40 -0
  227. package/src/actions/send-code-agent-remote-command.ts +5 -0
  228. package/src/actions/start-workspace-app-creation.ts +1 -1
  229. package/src/actions/view-screen.bundle.spec.ts +15 -2
  230. package/src/actions/view-screen.spec.ts +81 -3
  231. package/src/actions/view-screen.ts +60 -4
  232. package/src/components/chat-action-suggestions.spec.tsx +362 -0
  233. package/src/components/chat-action-suggestions.tsx +432 -0
  234. package/src/components/chat-home-apps.spec.tsx +19 -0
  235. package/src/components/chat-home-apps.tsx +0 -1
  236. package/src/components/google-broker-settings-group.tsx +186 -0
  237. package/src/components/layout/Layout.spec.tsx +419 -28
  238. package/src/components/layout/Layout.tsx +304 -66
  239. package/src/components/messaging-setup-panel.spec.tsx +278 -4
  240. package/src/components/messaging-setup-panel.tsx +82 -19
  241. package/src/components/workspace-app-card.spec.tsx +79 -10
  242. package/src/components/workspace-app-chat-rail.spec.tsx +81 -3
  243. package/src/components/workspace-app-host.spec.tsx +269 -16
  244. package/src/components/workspace-app-host.tsx +464 -87
  245. package/src/config.ts +5 -0
  246. package/src/db/google-broker-admission.ts +160 -0
  247. package/src/db/migrations.spec.ts +165 -2
  248. package/src/db/migrations.ts +43 -1
  249. package/src/lib/action-suggestions.ts +267 -0
  250. package/src/lib/chat-first-app-route.spec.ts +15 -2
  251. package/src/lib/chat-first-app-route.ts +19 -7
  252. package/src/lib/chat-first-pane.spec.ts +71 -0
  253. package/src/lib/chat-first-pane.ts +101 -4
  254. package/src/lib/data-intent.spec.ts +21 -0
  255. package/src/lib/data-intent.ts +13 -0
  256. package/src/lib/dispatch-app-identity.ts +40 -0
  257. package/src/lib/other-apps.spec.ts +110 -1
  258. package/src/lib/other-apps.ts +41 -0
  259. package/src/lib/workspace-app-frame-view.spec.ts +13 -0
  260. package/src/lib/workspace-app-frame-view.ts +98 -0
  261. package/src/lib/workspace-apps.spec.ts +101 -0
  262. package/src/lib/workspace-apps.test.ts +18 -0
  263. package/src/lib/workspace-apps.ts +102 -24
  264. package/src/routes/pages/chat.spec.tsx +92 -1
  265. package/src/routes/pages/chat.tsx +41 -2
  266. package/src/routes/pages/settings-page.tsx +22 -17
  267. package/src/routes/pages/settings.spec.tsx +4 -0
  268. package/src/server/index.ts +6 -6
  269. package/src/server/lib/action-suggestions.ts +122 -0
  270. package/src/server/lib/app-action-result.ts +8 -0
  271. package/src/server/lib/app-creation-store.spec.ts +251 -0
  272. package/src/server/lib/app-creation-store.ts +72 -12
  273. package/src/server/lib/community-apps.spec.ts +19 -1
  274. package/src/server/lib/curated-workspace-templates.spec.ts +12 -0
  275. package/src/server/lib/curated-workspace-templates.ts +2 -0
  276. package/src/server/lib/dispatch-config.ts +15 -0
  277. package/src/server/lib/dispatch-pane-context.spec.ts +54 -0
  278. package/src/server/lib/dispatch-pane-context.ts +54 -0
  279. package/src/server/lib/google-broker-provider.ts +121 -0
  280. package/src/server/lib/google-broker-rpc.spec.ts +95 -0
  281. package/src/server/lib/google-broker-rpc.ts +107 -0
  282. package/src/server/lib/hosted-apps-settings.ts +4 -0
  283. package/src/server/lib/mcp-app-discovery.ts +318 -0
  284. package/src/server/lib/mcp-gateway.spec.ts +2252 -524
  285. package/src/server/lib/mcp-gateway.ts +1044 -181
  286. package/src/server/plugins/agent-chat.direct-mcp.spec.ts +84 -5
  287. package/src/server/plugins/agent-chat.ts +9 -7
  288. package/src/server/plugins/auth.spec.ts +5 -1
  289. package/src/server/plugins/auth.ts +1 -0
  290. package/src/server/plugins/db.ts +0 -51
  291. package/src/server/plugins/integrations.ts +4 -1
  292. package/src/shared/chat-first-pane.spec.ts +36 -0
  293. package/src/shared/chat-first-pane.ts +55 -0
  294. package/src/shared/labs.ts +8 -0
  295. package/src/server/plugins/agent-chat.spec.ts +0 -206
  296. package/src/server/plugins/integrations.spec.ts +0 -60
@@ -21,13 +21,41 @@ vi.mock("@agent-native/core/server", async (importOriginal) => ({
21
21
  },
22
22
  }));
23
23
 
24
- async function listTools(enabled: boolean) {
24
+ vi.mock("@agent-native/core/settings", async (importOriginal) => ({
25
+ ...(await importOriginal<Record<string, unknown>>()),
26
+ getUserSetting: vi.fn(async () => ({
27
+ mode: "selected-apps",
28
+ selectedAppIds: [],
29
+ })),
30
+ }));
31
+
32
+ vi.mock("../lib/mcp-app-discovery.js", () => ({
33
+ discoverDispatchMcpApps: vi.fn(async () => ({
34
+ agents: [
35
+ {
36
+ id: "slides",
37
+ name: "Slides",
38
+ description: "Presentations",
39
+ url: "https://slides.example.test",
40
+ color: "#000000",
41
+ },
42
+ ],
43
+ mountedApps: [],
44
+ degradedSources: [],
45
+ })),
46
+ }));
47
+
48
+ async function requestMcp(
49
+ enabled: boolean,
50
+ method: string,
51
+ params: Record<string, unknown>,
52
+ ) {
25
53
  resetAppConfigForTests();
26
54
  defineAppConfig({ dispatch: { directAppActions: enabled } });
27
55
  await import("./agent-chat.js");
28
56
  const options = captured.options;
29
57
  if (!options) throw new Error("Dispatch plugin was not registered");
30
- const rpc = { jsonrpc: "2.0", id: 1, method: "tools/list", params: {} };
58
+ const rpc = { jsonrpc: "2.0", id: 1, method, params };
31
59
  const response = await handleMcpFetchRequest(
32
60
  new Request("https://dispatch.example.test/mcp", {
33
61
  method: "POST",
@@ -59,9 +87,12 @@ async function listTools(enabled: boolean) {
59
87
  if (body.startsWith("event:") && !data)
60
88
  throw new Error("Missing MCP response data");
61
89
  const json = data ? data.slice(5) : body;
62
- return JSON.parse(json).result.tools.map(
63
- (tool: { name: string }) => tool.name,
64
- );
90
+ return JSON.parse(json);
91
+ }
92
+
93
+ async function listTools(enabled: boolean) {
94
+ const response = await requestMcp(enabled, "tools/list", {});
95
+ return response.result.tools.map((tool: { name: string }) => tool.name);
65
96
  }
66
97
 
67
98
  describe("Dispatch direct app action MCP catalog", () => {
@@ -72,4 +103,52 @@ describe("Dispatch direct app action MCP catalog", () => {
72
103
  for (const name of names) expect(disabled).not.toContain(name);
73
104
  expect(await listTools(true)).toEqual(expect.arrayContaining(names));
74
105
  });
106
+
107
+ it("advertises neutral capability descriptions without prescriptive cross-tool instructions", async () => {
108
+ const forbidden =
109
+ /\b(?:call\s+\w+\s+(?:first|before)|call\s+it\s+(?:before|after)|prefer\s+this\s+to|prefer\s+list_app_actions|do\s+not\s+require|do\s+not\s+ask\s+the\s+user|do\s+not\s+scaffold|never\s+resubmit|after\s+calling,\s+surface)\b/i;
110
+ for (const enabled of [false, true]) {
111
+ const response = await requestMcp(enabled, "tools/list", {});
112
+ const tools = response.result.tools as Array<{
113
+ name: string;
114
+ description?: string;
115
+ }>;
116
+ expect(tools.length).toBeGreaterThan(0);
117
+ for (const tool of tools) {
118
+ expect(
119
+ tool.description ?? "",
120
+ `${tool.name} (directAppActions=${enabled})`,
121
+ ).not.toMatch(forbidden);
122
+ }
123
+ }
124
+ });
125
+
126
+ it.each([
127
+ { name: "list_app_actions", arguments: { app: "slides" } },
128
+ {
129
+ name: "call_app_action",
130
+ arguments: { app: "slides", action: "list-decks", args: {} },
131
+ },
132
+ { name: "read_view", arguments: { app: "slides" } },
133
+ ])(
134
+ "enforces opt-in and app access on HTTP calls to $name",
135
+ async (params) => {
136
+ const disabled = await requestMcp(false, "tools/call", params);
137
+ expect(disabled.result).toMatchObject({
138
+ isError: true,
139
+ content: [{ type: "text", text: `Unknown tool: ${params.name}` }],
140
+ });
141
+
142
+ const ungranted = await requestMcp(true, "tools/call", params);
143
+ expect(ungranted.result).toMatchObject({
144
+ isError: true,
145
+ content: [
146
+ {
147
+ type: "text",
148
+ text: expect.stringContaining('access to "slides" is not granted'),
149
+ },
150
+ ],
151
+ });
152
+ },
153
+ );
75
154
  });
@@ -19,6 +19,8 @@ const INITIAL_TOOL_NAMES = [
19
19
  "list-workspace-apps",
20
20
  "update-workspace-app-metadata",
21
21
  "list-connected-agents",
22
+ "list_app_actions",
23
+ "call_app_action",
22
24
  "ask_app",
23
25
  "open_app",
24
26
  "list-workspace-resources",
@@ -35,6 +37,7 @@ const INITIAL_TOOL_NAMES = [
35
37
  "upsert-destination",
36
38
  "list-dreams",
37
39
  "start-workspace-app-creation",
40
+ "propose-action-suggestions",
38
41
  "list-dispatch-usage-metrics",
39
42
  "list-available-workspace-templates",
40
43
  "provider-api-catalog",
@@ -54,6 +57,7 @@ export default createAgentChatPlugin({
54
57
  mcp: {
55
58
  appApprovalPage: true,
56
59
  readOnlyResources: true,
60
+ servesAnSkill: true,
57
61
  taskCandidates: async ({ callableActionNames, signal }) => {
58
62
  signal.throwIfAborted();
59
63
  if (!callableActionNames.includes("open_app")) return [];
@@ -105,7 +109,7 @@ export default createAgentChatPlugin({
105
109
 
106
110
  Default posture:
107
111
  - Treat Slack and Telegram as shared entrypoints into the workspace.
108
- - Heavily delegate domain work to specialized agents through A2A when another app owns the job.
112
+ - Prefer direct call_app_action (checking list_app_actions first when action names or inputs are unknown) for single-app reads, lookups, navigation, and simple mutations so standard turns finish in one LLM hop. Reserve ask_app for multi-step specialist sub-workflows that genuinely need the target app's own agent reasoning. Pass viewportMode: "background" on secondary cross-app lookups so they cannot hijack the visible foreground pane.
109
113
  - Keep durable memory and operating instructions in resources rather than ephemeral chat.
110
114
  - Prefer replying in the current external thread unless the user explicitly asks you to send to a saved destination.
111
115
 
@@ -125,7 +129,7 @@ Use the standard workspace primitives:
125
129
  - You receive a compact available-apps block with sibling workspace app names and descriptions. Use it to pick the right A2A target, and call list-connected-agents or tool-search only when you need fresh details.
126
130
  - Saved pointers: when the user says that something is their Y ("my todo list is this doc", "X is my Y", or gives a link and a name for it), call remember-pointer with the alias, the app that owns it and the link or object id. When a request refers to something by a personal name, call resolve-pointer first; if it matches, open that app and object, and do not default to another app (a todo list pointed at a doc opens the doc, not Tasks). Use scope org only when the user asks to share it with the organization.
127
131
  - Show the work in the app: when the user asks to see, open, find, browse, or check something an app owns (mail, events, docs, decks, designs, tasks, clips, analytics, records), the result belongs on screen beside the chat, not only in text. Delegating to that app's agent opens the app beside the chat, and when the answer is a screen (a list, thread, event, doc, deck, record, or something just created or found) also call open_app with the app and, when you know it, the view or path. Then answer in a sentence or two instead of restating what the pane shows.
128
- - Follow-ups about a screen that is already open (narrow it, filter, switch tabs, open the next one, change this item) go to that app's own agent, which navigates the open pane in place. Do not answer from memory, and do not open the same app again.
132
+ - Requests about data in the app already on screen including follow-ups that narrow or filter the view, go to that app's own agent, which navigates the open pane in place. A service mentioned in a message or notification does not make that service's records the subject: use the app holding the messages. Delegate to or open another app when the user asks for that app's own data or screen. Do not answer from memory or open the same app again.
129
133
  - Prefer the workspace app that owns a domain over a connected third-party tool for the same domain (a Notion connector for docs or meeting notes, a calendar connector for events). Use the third-party tool only when the person names that service or no workspace app covers the job.
130
134
  - Requests to create or draft something (a doc, deck, design, post, issue, event, or reply) go to the owning app's agent so the item opens beside the chat as an unsaved draft. Do not answer them as chat text or ask which app to use when one fits.
131
135
  - For Dispatch's own screens (apps, agents, integrations, connections, settings), use navigate to open the page, then summarize what it shows.
@@ -142,20 +146,18 @@ Use the standard workspace primitives:
142
146
  - For broad provider searches, joins, classification, corpus counts, or absence claims, fetch every relevant page or an explicitly bounded cohort, stage/save large responses with stageAs/saveToFile/fetchAllPages, and reduce them with query-staged-dataset or run-code. Report source, filters, row counts, pagination, truncation, failed pages, and uncovered gaps.
143
147
  - Use list-dispatch-usage-metrics only for this workspace's own members' agent/LLM usage and spend, or aggregate adoption of an accessible workspace app. For agent/LLM usage or spend, call it with scope=workspace and the requested sinceDays; it reports workspace-member usage only. For app adoption, call it with scope=app and appId; app creators can see aggregate daily/weekly active users and tracked actions for their own app, while organization owners/admins can inspect any accessible app. App scope omits individual users and prompt previews. External customer, account, or company usage, credits, activity, or product data belongs to the relevant app: use its identity in <relevant-apps> when clear, or call describe-workspace-apps with a query when ownership is unclear. Do not use this action for external customer/account/company data.
144
148
 
149
+ After answering or showing the requested work in Dispatch chat, use propose-action-suggestions only when there is a grounded, useful persistent improvement for the user to consider. Pass the installed app's exact ID and a real action with its required inputs for a filter, saved view, or automation. Use customize-app for a specific missing control. If no installed app fits a durable new workflow, offer create-app with appId="dispatch" and a short specification, even if no app was opened or called this turn. Offer at most two suggestions per turn. Only propose the improvement; wait for the user's selection to execute it.
150
+
145
151
  When a user asks for something like a digest, reminder, routing rule, or saved behavior:
146
152
  - First decide whether it should be a resource, a recurring job, a destination, or a delegated task.
147
153
  - Keep responses concise and operational.
148
154
  - Avoid inventing integrations or destinations that are not configured yet.${builderManagedAppsNote()}`,
149
155
  });
150
156
 
151
- /**
152
- * A Builder-linked workspace builds its apps in Builder; app-creation actions
153
- * return a link there, and the agent should offer it rather than retry.
154
- */
155
157
  function builderManagedAppsNote(): string {
156
158
  const url = getBuilderWorkspaceUrl();
157
159
  if (!url) return "";
158
160
  return `
159
161
 
160
- This workspace is managed in Builder. Never create, scaffold, remix, or install workspace apps from here. When someone asks for a new app, point them to ${url} and tell them to use New app there.`;
162
+ This workspace is managed in Builder. App creation here hands off to the configured workspace. A create-app suggestion allows the user to open that workspace. For an explicit creation request, use the normal creation action and report the handoff it returns.`;
161
163
  }
@@ -42,7 +42,11 @@ describe("dispatchAuthPlugin", () => {
42
42
  expect(mocks.createAuthPlugin).toHaveBeenCalledWith(
43
43
  expect.objectContaining({
44
44
  googleOnly: true,
45
- publicPaths: [...publicPaths, "/_agent-native/private-icons"],
45
+ publicPaths: [
46
+ ...publicPaths,
47
+ "/_agent-native/private-icons",
48
+ "/_agent-native/a2a-google",
49
+ ],
46
50
  workspaceAppPublicPaths: ["/"],
47
51
  }),
48
52
  );
@@ -28,6 +28,7 @@ const dispatchAuthPlugin = async (nitroApp: any) => {
28
28
  publicPaths: [
29
29
  ...(authConfig.publicPaths ?? []),
30
30
  "/_agent-native/private-icons",
31
+ "/_agent-native/a2a-google",
31
32
  ],
32
33
  });
33
34
  return plugin(nitroApp);
@@ -1,58 +1,7 @@
1
1
  import { runMigrations } from "@agent-native/core/db";
2
- import { registerIdentityColumns } from "@agent-native/core/org";
3
2
 
4
3
  import { dispatchMigrations } from "../../db/migrations.js";
5
4
 
6
- registerIdentityColumns([
7
- {
8
- table: "dispatch_identity_links",
9
- column: "owner_email",
10
- emailChange: "rekey",
11
- offboard: "delete",
12
- reason:
13
- "A linked chat identity acts as its owner; transferring it would let the departed member act as the successor.",
14
- },
15
- {
16
- table: "dispatch_link_tokens",
17
- column: "owner_email",
18
- emailChange: "rekey",
19
- offboard: "delete",
20
- reason:
21
- "An unclaimed link token binds a chat identity to its owner; the successor mints their own.",
22
- },
23
- {
24
- table: "identity_sso_authorization_code",
25
- column: "email",
26
- emailChange: "delete",
27
- offboard: "delete",
28
- reason:
29
- "Unconsumed single-use code that asserts this address to an app; the member signs in again.",
30
- },
31
- {
32
- table: "identity_sso_bootstrap",
33
- column: "email",
34
- emailChange: "delete",
35
- offboard: "delete",
36
- reason:
37
- "Unconsumed single-use sign-in bootstrap for this address; the member signs in again.",
38
- },
39
- ...[
40
- "dispatch_destinations",
41
- "dispatch_dreams",
42
- "dispatch_link_tokens",
43
- // No longer read or written. The table stays in existing databases until
44
- // it is dropped, and identity migrations refuse any column without a policy.
45
- "vault_secrets",
46
- "workspace_resources",
47
- ].map((table) => ({
48
- table,
49
- column: "created_by",
50
- emailChange: "retain" as const,
51
- offboard: "retain" as const,
52
- reason: "Creator attribution; ownership is owner_email.",
53
- })),
54
- ]);
55
-
56
5
  export const runDispatchMigrations = runMigrations(dispatchMigrations, {
57
6
  table: "dispatch_migrations",
58
7
  });
@@ -40,7 +40,10 @@ When a user asks for something:
40
40
  - If a user asks to rename an existing workspace app or change its Dispatch title/description, call update-workspace-app-metadata with the existing appId from list-workspace-apps. Do not call start-workspace-app-creation for a metadata-only edit because that starts a new app and Builder branch.
41
41
  - If a new-app prompt asks for access to Mail, Calendar, Analytics, Brain, Assets, or similar first-party app data/agents, keep using the existing app through A2A. Do not ask Builder to scaffold those apps as children of the new app unless the user explicitly asks for a customized app from that template.
42
42
  - If the chat template is used, treat it as scaffolding only: the finished app must be branded as the requested app with its own home screen/navigation/package metadata/manifest, and must not leave visible "Chat", "Starter", "Blank app", or "New app" UI behind.
43
- - If the user explicitly asks for a new app or workspace app, call start-workspace-app-creation with their prompt and include a concise generated description by default. Do not satisfy a new-app request by adding a route, page, component, or file inside apps/chat or another existing app unless the user explicitly asks to modify that existing app. When the prompt contains a source brief or concrete repeatable workflow, choose recommended defaults and do not ask non-blocking product or UX questions; ask only for authorization, credentials, a destructive action, an ambiguous target workspace, or a genuinely missing workflow. If the request is too vague to classify, ask one concise follow-up. If the action returns mode "builder", reply with the Builder branch URL; Builder is responsible for creating the separate workspace app under apps/<app-id>, mounting it at /<app-id>, ensuring apps/<app-id>/package.json exists with name/displayName and description so Dispatch discovers it, using relative /<app-id> links instead of hardcoded localhost/dev ports, and keeping the configureClientRouterBasename() call in app/entry.client.tsx. The new app lives at the workspace root /<app-id>, NOT under /dispatch/<app-id>, /apps/<app-id>, or any other Dispatch tab — when telling the user where to find it, link to /<app-id> only. There is no separate workspace app registry to edit. If it returns mode "local-agent", tell the user it is ready for the local code agent and include the returned app path/prompt summary. Dispatch reuses the connected workspace Builder project or provisions it through the Builder Projects API when an organization owner/admin starts the first app; members need an owner/admin to configure the project first. Do not ask the user to use Builder org/beta settings. If it returns mode "builder-unavailable", the action also returns a \`reason\` code plus a user-facing \`message\` and (for some reasons) an operator-facing \`detail\`. Relay the \`message\` to the user as-is; only surface \`detail\` when the user is clearly an operator debugging the deployment (e.g. troubleshooting a broken Builder connection for the workspace), never as routine detail for an end user. If it returns mode "app-id-taken", the app id is already in use: \`conflict\` is "registered" for a live app or "pending" for a creation in flight, and \`owner\` names who started it. Relay the \`message\` and propose a different app id; never retry the same id.
43
+ - If the user explicitly asks for a new app or workspace app, call start-workspace-app-creation with their prompt and include a concise generated description by default. Do not satisfy a new-app request by adding a route, page, component, or file inside apps/chat or another existing app unless the user explicitly asks to modify that existing app. When the prompt contains a source brief or concrete repeatable workflow, use the shared app quality workflow and do not ask non-blocking product or UX questions; ask only for authorization, credentials, a destructive action, an ambiguous target workspace, or a genuinely missing workflow. If the request is too vague to classify, ask one concise follow-up.
44
+ - If app creation returns mode "builder", give the branch link and say registration is pending. For "builder-managed", give the workspace link and direct the user to New app with the same brief. For "local-agent", give the returned instructions to the local code agent. A workspace owner or admin configures the hosted project before ordinary members can start branches.
45
+ - After creation, use list-workspace-apps to find the registered app. Verify the resolved URL, mount, and home through the workspace registry or preview gateway. Use the returned destination in replies. App-internal links use app-local routes with the framework basename. Keep the status pending until the destination serves the requested app.
46
+ - If it returns mode "builder-unavailable", the action also returns a \`reason\` code plus a user-facing \`message\` and (for some reasons) an operator-facing \`detail\`. Relay the \`message\` to the user as-is; only surface \`detail\` when the user is clearly an operator debugging the deployment (e.g. troubleshooting a broken Builder connection for the workspace), never as routine detail for an end user. If it returns mode "app-id-taken", the app id is already in use: \`conflict\` is "registered" for a live app or "pending" for a creation in flight, and \`owner\` names who started it. Relay the \`message\` and propose a different app id; never retry the same id.
44
47
  - For digests, reminders, or saved behavior, prefer recurring jobs, resources, or destinations over chat replies.
45
48
  - Keep responses concise and operational — messaging platforms have character limits.
46
49
  - Use markdown sparingly (bold and lists are fine, avoid complex formatting).
@@ -0,0 +1,36 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import { parsePersistedChatFirstPane } from "./chat-first-pane";
4
+
5
+ describe("parsePersistedChatFirstPane", () => {
6
+ it("restores a valid saved pane", () => {
7
+ expect(
8
+ parsePersistedChatFirstPane({
9
+ appId: "clips",
10
+ placement: "side",
11
+ path: "/inbox",
12
+ view: "list",
13
+ extra: true,
14
+ }),
15
+ ).toEqual({
16
+ status: "restorable",
17
+ pane: { appId: "clips", placement: "side", path: "/inbox", view: "list" },
18
+ });
19
+ });
20
+
21
+ it("reports absent state when nothing was saved or it was cleared", () => {
22
+ expect(parsePersistedChatFirstPane(null)).toEqual({ status: "absent" });
23
+ expect(parsePersistedChatFirstPane(undefined)).toEqual({
24
+ status: "absent",
25
+ });
26
+ });
27
+
28
+ it.each([["pane"], [42], [[]], [{}], [{ appId: " " }], [{ appId: 7 }]])(
29
+ "reports corrupt state %j as unreadable",
30
+ (value) => {
31
+ expect(parsePersistedChatFirstPane(value)).toEqual({
32
+ status: "unreadable",
33
+ });
34
+ },
35
+ );
36
+ });
@@ -1 +1,56 @@
1
1
  export const CHAT_FIRST_PANE_STATE_KEY = "chat-first-pane";
2
+
3
+ export const CHAT_FIRST_PANE_CONTEXT_STATE_KEY = "dispatch-pane-context";
4
+ export const CHAT_FIRST_PANE_BINDING_MAX_AGE_MS = 30 * 60_000;
5
+
6
+ export function isDispatchChildBrowserTabId(value: unknown): value is string {
7
+ return (
8
+ typeof value === "string" &&
9
+ /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(
10
+ value,
11
+ )
12
+ );
13
+ }
14
+
15
+ /** Core consumes this value when the newly linked child document starts. */
16
+ export const DISPATCH_CHILD_BROWSER_TAB_PARAM = "agentNativeTab";
17
+
18
+ export interface PersistedChatFirstPane {
19
+ appId: string;
20
+ placement?: "main" | "side";
21
+ path?: string;
22
+ view?: string;
23
+ }
24
+
25
+ export type PersistedChatFirstPaneState =
26
+ | { status: "absent" }
27
+ | { status: "restorable"; pane: PersistedChatFirstPane }
28
+ | { status: "unreadable" };
29
+
30
+ /**
31
+ * Absent (never saved, or cleared) and unreadable (saved but malformed) are
32
+ * different outcomes: only the second should surface a failure to the user.
33
+ */
34
+ export function parsePersistedChatFirstPane(
35
+ value: unknown,
36
+ ): PersistedChatFirstPaneState {
37
+ if (value === null || value === undefined) return { status: "absent" };
38
+ if (typeof value !== "object" || Array.isArray(value)) {
39
+ return { status: "unreadable" };
40
+ }
41
+ const record = value as Record<string, unknown>;
42
+ if (typeof record.appId !== "string" || !record.appId.trim()) {
43
+ return { status: "unreadable" };
44
+ }
45
+ return {
46
+ status: "restorable",
47
+ pane: {
48
+ appId: record.appId,
49
+ ...(record.placement === "main" || record.placement === "side"
50
+ ? { placement: record.placement }
51
+ : {}),
52
+ ...(typeof record.path === "string" ? { path: record.path } : {}),
53
+ ...(typeof record.view === "string" ? { view: record.view } : {}),
54
+ },
55
+ };
56
+ }
@@ -7,3 +7,11 @@ export const COMMUNITY_APPS_LAB = defineLab({
7
7
  "Connect trusted remote agents and install reviewed, pinned community app templates.",
8
8
  keywords: "community apps templates connect install",
9
9
  });
10
+
11
+ export const GOOGLE_BROKER_LAB = defineLab({
12
+ key: "dispatch.google-broker",
13
+ defaultEnabled: false,
14
+ displayName: "Cross-app Google access",
15
+ displayNameKey: "agentChat.settingsShell.appGroup.googleBroker",
16
+ descriptionKey: "agentChat.settingsShell.appGroup.googleBrokerDescription",
17
+ });
@@ -1,206 +0,0 @@
1
- import { describe, expect, it, vi } from "vitest";
2
-
3
- const mocks = vi.hoisted(() => ({
4
- createAgentChatPlugin: vi.fn((options: Record<string, unknown>) => options),
5
- registerAgentContextAgentFilter: vi.fn(),
6
- hideHostedAppsWhenOff: vi.fn(),
7
- listGrantedDispatchMcpApps: vi.fn(),
8
- }));
9
-
10
- vi.mock("@agent-native/core/server", () => ({
11
- createAgentChatPlugin: mocks.createAgentChatPlugin,
12
- getBuilderWorkspaceUrl: () => null,
13
- registerAgentContextAgentFilter: mocks.registerAgentContextAgentFilter,
14
- }));
15
-
16
- vi.mock("../lib/hosted-apps-settings.js", () => ({
17
- hideHostedAppsWhenOff: mocks.hideHostedAppsWhenOff,
18
- }));
19
-
20
- vi.mock("@agent-native/core/org", () => ({
21
- getOrgContext: vi.fn(),
22
- }));
23
-
24
- vi.mock("../lib/mcp-gateway.js", () => ({
25
- listGrantedDispatchMcpApps: mocks.listGrantedDispatchMcpApps,
26
- }));
27
-
28
- vi.mock("../lib/workspace-app-action-auth.js", () => ({
29
- workspaceAppActionRouteAuth: { resolveCaller: vi.fn() },
30
- WORKSPACE_APP_CLAIM_ACTION_PATH:
31
- "/_agent-native/actions/claim-workspace-app-organization",
32
- WORKSPACE_APPS_ACTION_PATH: "/_agent-native/actions/list-workspace-apps",
33
- }));
34
-
35
- const resolveDispatchActions = vi.hoisted(() => () => ({}));
36
-
37
- vi.mock("../../actions/index.js", () => ({
38
- dispatchActions: {},
39
- resolveDispatchActions,
40
- }));
41
-
42
- describe("Dispatch agent chat plugin", () => {
43
- it("opts delegated work into the durable background run contract", async () => {
44
- await import("./agent-chat.js");
45
-
46
- expect(mocks.createAgentChatPlugin).toHaveBeenCalledWith(
47
- expect.objectContaining({
48
- appId: "dispatch",
49
- actions: resolveDispatchActions,
50
- durableBackgroundRuns: true,
51
- initialToolNames: expect.arrayContaining([
52
- "list-workspace-apps",
53
- "update-workspace-app-metadata",
54
- "list-dispatch-usage-metrics",
55
- ]),
56
- mcp: {
57
- appApprovalPage: true,
58
- readOnlyResources: true,
59
- taskCandidates: expect.any(Function),
60
- connectorCatalog: expect.arrayContaining([
61
- "start-workspace-app-creation",
62
- "list-dispatch-usage-metrics",
63
- ]),
64
- },
65
- actionRoutePublicPaths: [
66
- "/_agent-native/actions/list-workspace-apps",
67
- "/_agent-native/actions/claim-workspace-app-organization",
68
- ],
69
- actionRouteAuth: expect.objectContaining({
70
- resolveCaller: expect.any(Function),
71
- }),
72
- }),
73
- );
74
- });
75
-
76
- it("hides hosted apps from its own agent context through the setting", async () => {
77
- await import("./agent-chat.js");
78
-
79
- expect(mocks.registerAgentContextAgentFilter).toHaveBeenCalledWith(
80
- "dispatch",
81
- mocks.hideHostedAppsWhenOff,
82
- );
83
- });
84
-
85
- it("supplies only currently granted apps when open_app is callable", async () => {
86
- await import("./agent-chat.js");
87
- const options = mocks.createAgentChatPlugin.mock.calls[0]?.[0] as {
88
- mcp: {
89
- taskCandidates: (input: {
90
- callableActionNames: string[];
91
- signal: AbortSignal;
92
- }) => Promise<any[]>;
93
- };
94
- };
95
- mocks.listGrantedDispatchMcpApps.mockResolvedValue([
96
- { id: "alpha", name: "Alpha", description: "Research" },
97
- ]);
98
- const signal = new AbortController().signal;
99
- expect(
100
- await options.mcp.taskCandidates({ callableActionNames: [], signal }),
101
- ).toEqual([]);
102
- expect(mocks.listGrantedDispatchMcpApps).not.toHaveBeenCalled();
103
- const candidates = await options.mcp.taskCandidates({
104
- callableActionNames: ["open_app"],
105
- signal,
106
- });
107
- expect(candidates).toMatchObject([
108
- {
109
- id: "app:alpha",
110
- kind: "app",
111
- name: "Alpha",
112
- use: { type: "open_app", app: "alpha", path: "/" },
113
- callable: true,
114
- },
115
- ]);
116
- expect(mocks.listGrantedDispatchMcpApps).toHaveBeenCalledOnce();
117
- const aborted = new AbortController();
118
- aborted.abort();
119
- await expect(
120
- options.mcp.taskCandidates({
121
- callableActionNames: ["open_app"],
122
- signal: aborted.signal,
123
- }),
124
- ).rejects.toThrow();
125
- mocks.listGrantedDispatchMcpApps.mockRejectedValueOnce(
126
- new Error("grant unavailable"),
127
- );
128
- await expect(
129
- options.mcp.taskCandidates({ callableActionNames: ["open_app"], signal }),
130
- ).rejects.toThrow("grant unavailable");
131
- });
132
-
133
- it("fails explicitly when the app catalog exceeds task ranking bounds", async () => {
134
- await import("./agent-chat.js");
135
- const options = mocks.createAgentChatPlugin.mock.calls[0]?.[0] as {
136
- mcp: {
137
- taskCandidates: (input: {
138
- callableActionNames: string[];
139
- signal: AbortSignal;
140
- }) => Promise<any[]>;
141
- };
142
- };
143
- mocks.listGrantedDispatchMcpApps.mockResolvedValue(
144
- Array.from({ length: 129 }, (_, i) => ({
145
- id: `app-${i}`,
146
- name: "App",
147
- description: "",
148
- })),
149
- );
150
- await expect(
151
- options.mcp.taskCandidates({
152
- callableActionNames: ["open_app"],
153
- signal: new AbortController().signal,
154
- }),
155
- ).rejects.toThrow(/limit/i);
156
- });
157
-
158
- it("routes customer credit questions to the owning workspace app", async () => {
159
- await import("./agent-chat.js");
160
-
161
- const options = mocks.createAgentChatPlugin.mock.calls[0]?.[0] as {
162
- systemPrompt?: string;
163
- };
164
- expect(options.systemPrompt).toContain(
165
- "External customer, account, or company usage, credits, activity, or product data belongs to the relevant app",
166
- );
167
- expect(options.systemPrompt).toContain(
168
- "Do not use this action for external customer/account/company data.",
169
- );
170
- });
171
-
172
- it("keeps the app on screen beside the chat", async () => {
173
- await import("./agent-chat.js");
174
-
175
- const options = mocks.createAgentChatPlugin.mock.calls[0]?.[0] as {
176
- systemPrompt?: string;
177
- };
178
- expect(options.systemPrompt).toContain("Show the work in the app:");
179
- expect(options.systemPrompt).toContain(
180
- "call open_app with the app and, when you know it, the view or path",
181
- );
182
- expect(options.systemPrompt).toContain(
183
- "go to that app's own agent, which navigates the open pane in place",
184
- );
185
- expect(options.systemPrompt).toContain(
186
- "opens as an unsaved draft in the app",
187
- );
188
- });
189
-
190
- it("routes domain work to workspace apps instead of third-party tools", async () => {
191
- await import("./agent-chat.js");
192
-
193
- const options = mocks.createAgentChatPlugin.mock.calls[0]?.[0] as {
194
- systemPrompt?: string;
195
- };
196
- expect(options.systemPrompt).toContain(
197
- "Prefer the workspace app that owns a domain over a connected third-party tool",
198
- );
199
- expect(options.systemPrompt).toContain(
200
- "go to the owning app's agent so the item opens beside the chat as an unsaved draft",
201
- );
202
- expect(options.systemPrompt).toContain(
203
- "use navigate to open the page, then summarize what it shows",
204
- );
205
- });
206
- });
@@ -1,60 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest";
2
-
3
- const mocks = vi.hoisted(() => ({
4
- createIntegrationsPlugin: vi.fn(),
5
- integrationsPlugin: vi.fn(),
6
- getDispatchConfig: vi.fn(),
7
- }));
8
-
9
- vi.mock("@agent-native/core/server", () => ({
10
- createIntegrationsPlugin: mocks.createIntegrationsPlugin,
11
- }));
12
-
13
- vi.mock("../../actions/index.js", () => ({
14
- dispatchActions: { ask_app: {} },
15
- }));
16
-
17
- vi.mock("../index.js", () => ({
18
- getDispatchConfig: mocks.getDispatchConfig,
19
- }));
20
-
21
- vi.mock("../lib/dispatch-integrations.js", () => ({
22
- beforeDispatchProcess: vi.fn(),
23
- resolveDispatchExecutionContext: vi.fn(),
24
- }));
25
-
26
- describe("Dispatch integrations plugin", () => {
27
- beforeEach(() => {
28
- vi.resetModules();
29
- mocks.createIntegrationsPlugin.mockReset();
30
- mocks.integrationsPlugin.mockReset();
31
- mocks.getDispatchConfig.mockReset();
32
- mocks.createIntegrationsPlugin.mockReturnValue(mocks.integrationsPlugin);
33
- mocks.getDispatchConfig.mockReturnValue({});
34
- });
35
-
36
- it("routes delegation from the prompt resource context without a peer roster", async () => {
37
- const { default: dispatchIntegrationsPlugin } =
38
- await import("./integrations.js");
39
- const nitroApp = {};
40
-
41
- await dispatchIntegrationsPlugin(nitroApp);
42
-
43
- expect(mocks.createIntegrationsPlugin).toHaveBeenCalledWith(
44
- expect.objectContaining({
45
- appId: "dispatch",
46
- systemPrompt: expect.stringContaining(
47
- 'search with describe-workspace-apps query="<capability>"',
48
- ),
49
- }),
50
- );
51
- const options = mocks.createIntegrationsPlugin.mock.calls[0][0];
52
- expect(options.systemPrompt).not.toContain(
53
- "Apps you can delegate to include",
54
- );
55
- expect(options.systemPrompt).toContain("the relevant-apps context");
56
- expect(options.systemPrompt).not.toContain("available-apps context");
57
- expect(options.systemPrompt).not.toContain("slides (decks/presentations)");
58
- expect(mocks.integrationsPlugin).toHaveBeenCalledWith(nitroApp);
59
- });
60
- });