@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
@@ -0,0 +1,177 @@
1
+ import {
2
+ defineAction,
3
+ noteExternalWrite,
4
+ NoWriteError,
5
+ } from "@agent-native/core/action";
6
+ import { runBuilderAgent } from "@agent-native/core/server";
7
+ import { z } from "zod";
8
+
9
+ import {
10
+ actionSuggestionSchema,
11
+ canOfferActionSuggestion,
12
+ resolveCustomizationTarget,
13
+ } from "../server/lib/action-suggestions.js";
14
+ import {
15
+ listWorkspaceApps,
16
+ startWorkspaceAppCreation,
17
+ } from "../server/lib/app-creation-store.js";
18
+ import callAppAction from "./call_app_action.js";
19
+
20
+ const receiptSchema = z.discriminatedUnion("outcome", [
21
+ z.object({
22
+ suggestionId: z.string(),
23
+ status: z.literal("accepted"),
24
+ outcome: z.literal("action-completed"),
25
+ url: z.string().url().optional(),
26
+ }),
27
+ z.object({
28
+ suggestionId: z.string(),
29
+ status: z.literal("accepted"),
30
+ outcome: z.enum(["app-creation-started", "customization-started"]),
31
+ url: z.string().url(),
32
+ }),
33
+ z.object({
34
+ suggestionId: z.string(),
35
+ status: z.literal("handoff"),
36
+ outcome: z.literal("open-creation-workspace"),
37
+ url: z.string().url(),
38
+ }),
39
+ z.object({
40
+ suggestionId: z.string(),
41
+ status: z.literal("handoff"),
42
+ outcome: z.literal("local-app-creation"),
43
+ prompt: z.string(),
44
+ }),
45
+ ]);
46
+
47
+ function targetAlreadyExists(error: unknown): boolean {
48
+ return (
49
+ error instanceof Error &&
50
+ (error as { errorCode?: unknown }).errorCode === "already_exists"
51
+ );
52
+ }
53
+
54
+ function safeAppUrl(value: string | null | undefined): string | undefined {
55
+ if (!value || !URL.canParse(value)) return undefined;
56
+ const url = new URL(value);
57
+ if (url.username || url.password) return undefined;
58
+ const local =
59
+ url.protocol === "http:" &&
60
+ ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
61
+ return url.protocol === "https:" || local ? url.href : undefined;
62
+ }
63
+
64
+ function unavailable(): never {
65
+ throw new NoWriteError(
66
+ "This suggestion is no longer available in this workspace.",
67
+ {
68
+ errorCode: "action_suggestion_unavailable",
69
+ statusCode: 409,
70
+ },
71
+ );
72
+ }
73
+
74
+ export default defineAction({
75
+ description:
76
+ "Execute the typed action the signed-in user selected in the chat.",
77
+ schema: z.object({ suggestion: actionSuggestionSchema }),
78
+ outputSchema: receiptSchema,
79
+ maxBodyBytes: 65_536,
80
+ uiOnly: true,
81
+ requiresAuth: true,
82
+ requiresSignedInBrowser: true,
83
+ agentTool: false,
84
+ mcpTool: false,
85
+ run: async (
86
+ { suggestion },
87
+ context,
88
+ ): Promise<z.output<typeof receiptSchema>> => {
89
+ const { id: suggestionId, appId, execution } = suggestion;
90
+ if (execution.type === "customize") {
91
+ const target = await resolveCustomizationTarget(execution.targetAppId);
92
+ if (!target) unavailable();
93
+ noteExternalWrite("app-customization");
94
+ const result = await runBuilderAgent({
95
+ projectId: target.builderProjectId,
96
+ userEmail: target.userEmail,
97
+ prompt: `Update only the existing workspace app apps/${target.appId}.\n\n${execution.editSpec}`,
98
+ });
99
+ return {
100
+ suggestionId,
101
+ status: "accepted",
102
+ outcome: "customization-started",
103
+ url: result.url,
104
+ };
105
+ }
106
+
107
+ if (!(await canOfferActionSuggestion(suggestion))) unavailable();
108
+ if (execution.type === "action") {
109
+ try {
110
+ await callAppAction.run(
111
+ { app: appId, action: execution.action, args: execution.params },
112
+ context,
113
+ );
114
+ } catch (error) {
115
+ if (!targetAlreadyExists(error)) throw error;
116
+ }
117
+ return { suggestionId, status: "accepted", outcome: "action-completed" };
118
+ }
119
+
120
+ const result = await startWorkspaceAppCreation({
121
+ prompt: execution.domainSpec,
122
+ });
123
+ switch (result.mode) {
124
+ case "builder":
125
+ return {
126
+ suggestionId,
127
+ status: "accepted",
128
+ outcome: "app-creation-started",
129
+ url: result.url,
130
+ };
131
+ case "builder-managed":
132
+ return {
133
+ suggestionId,
134
+ status: "handoff",
135
+ outcome: "open-creation-workspace",
136
+ url: result.url,
137
+ };
138
+ case "local-agent":
139
+ return {
140
+ suggestionId,
141
+ status: "handoff",
142
+ outcome: "local-app-creation",
143
+ prompt: result.prompt,
144
+ };
145
+ case "app-id-taken": {
146
+ const app = (
147
+ await listWorkspaceApps({ includeAgentCards: false })
148
+ ).find(
149
+ (item) =>
150
+ item.id === result.appId && !item.archived && !item.isDispatch,
151
+ );
152
+ const url = safeAppUrl(app?.url);
153
+ if (!app || !url) return unavailable();
154
+ if (result.conflict === "registered" && app.status === "ready") {
155
+ return {
156
+ suggestionId,
157
+ status: "accepted",
158
+ outcome: "action-completed",
159
+ url,
160
+ };
161
+ }
162
+ if (result.conflict === "pending" && app.status === "pending") {
163
+ return {
164
+ suggestionId,
165
+ status: "accepted",
166
+ outcome: "app-creation-started",
167
+ url,
168
+ };
169
+ }
170
+ return unavailable();
171
+ }
172
+ case "builder-unavailable":
173
+ case "coming-soon":
174
+ return unavailable();
175
+ }
176
+ },
177
+ });
@@ -42,7 +42,7 @@ describe("dispatch direct app actions", () => {
42
42
  }
43
43
  expect(actions.ask_app.run).toBe(dispatchActions.ask_app.run);
44
44
  expect(actions.ask_app.tool.description).toContain(
45
- "prefer list_app_actions and call_app_action",
45
+ "list_app_actions and call_app_action",
46
46
  );
47
47
  expect(dispatchActions.ask_app.tool.description).not.toContain(
48
48
  "call_app_action",
@@ -130,9 +130,12 @@ describe("dispatch action registry", () => {
130
130
  expect(dispatchActions["inspect-connect-agent-card"].mcpTool).toBe(false);
131
131
  });
132
132
 
133
- it("teaches MCP hosts to route through their existing Dispatch connection", () => {
133
+ it("describes ask_app factually without prescriptive tool-selection instructions", () => {
134
134
  expect(dispatchActions.ask_app.tool.description).toContain(
135
- "do not require a separate app MCP connection",
135
+ "this Dispatch connection",
136
+ );
137
+ expect(dispatchActions.ask_app.tool.description).not.toMatch(
138
+ /do not require|call list_apps first|prefer /i,
136
139
  );
137
140
  });
138
141
 
@@ -26,6 +26,7 @@ import deleteVaultSecret from "./delete-vault-secret.js";
26
26
  import deleteWorkspaceResource from "./delete-workspace-resource.js";
27
27
  import denyVaultRequest from "./deny-vault-request.js";
28
28
  import ensureDreamJob from "./ensure-dream-job.js";
29
+ import executeActionSuggestion from "./execute-action-suggestion.js";
29
30
  import getAgentThreadDebug from "./get-agent-thread-debug.js";
30
31
  import getAppCreationSettings from "./get-app-creation-settings.js";
31
32
  import getDispatchSettings from "./get-dispatch-settings.js";
@@ -78,6 +79,7 @@ import navigate from "./navigate.js";
78
79
  import openApp from "./open_app.js";
79
80
  import previewDreamProposal from "./preview-dream-proposal.js";
80
81
  import previewWorkspaceResourceChange from "./preview-workspace-resource-change.js";
82
+ import proposeActionSuggestions from "./propose-action-suggestions.js";
81
83
  import providerApiCatalog from "./provider-api-catalog.js";
82
84
  import providerApiDocs from "./provider-api-docs.js";
83
85
  import providerApiRegister from "./provider-api-register.js";
@@ -191,6 +193,8 @@ export const dispatchActions: Record<string, ActionEntry> = {
191
193
  navigate: navigate,
192
194
  open_app: openApp,
193
195
  "apply-dream-proposal": applyDreamProposal,
196
+ "execute-action-suggestion": executeActionSuggestion,
197
+ "propose-action-suggestions": proposeActionSuggestions,
194
198
  "preview-dream-proposal": previewDreamProposal,
195
199
  "preview-workspace-resource-change": previewWorkspaceResourceChange,
196
200
  "provider-api-catalog": providerApiCatalog,
@@ -239,7 +243,7 @@ export const dispatchDirectAppActions: Record<string, ActionEntry> = {
239
243
  };
240
244
 
241
245
  const ASK_APP_DIRECT_ACTIONS_HINT =
242
- " For a known step prefer list_app_actions and call_app_action, which skip the app's agent and return in about a second.";
246
+ " Runs the target app's agent (slower than invoking a single action directly via list_app_actions and call_app_action).";
243
247
 
244
248
  /**
245
249
  * The actions Dispatch serves to its own agent and MCP callers. Direct app
@@ -1,6 +1,9 @@
1
1
  import { describe, expect, it, vi } from "vitest";
2
2
 
3
3
  const mocks = vi.hoisted(() => ({
4
+ getDispatchConfig: vi.fn<() => Record<string, unknown>>(() => ({
5
+ hiddenAgentIds: [],
6
+ })),
4
7
  discoverAgents: vi.fn(),
5
8
  getBuiltinAgents: vi.fn(),
6
9
  getRequestUserEmail: vi.fn<() => string | undefined>(
@@ -59,7 +62,7 @@ vi.mock("@agent-native/core/server/agent-discovery", () => ({
59
62
  }));
60
63
 
61
64
  vi.mock("../server/index.js", () => ({
62
- getDispatchConfig: vi.fn(async () => ({ hiddenAgentIds: [] })),
65
+ getDispatchConfig: mocks.getDispatchConfig,
63
66
  }));
64
67
 
65
68
  describe("list-connected-agents", () => {
@@ -94,6 +97,28 @@ describe("list-connected-agents", () => {
94
97
  });
95
98
  });
96
99
 
100
+ it("drops hosted apps entirely when the deployment turns the hosted catalog off", async () => {
101
+ const clips = {
102
+ id: "clips",
103
+ name: "Clips",
104
+ description: "",
105
+ url: "https://clips.agent-native.com",
106
+ color: "#000000",
107
+ };
108
+ const partner = { ...clips, id: "partner", url: "https://p.example.test" };
109
+ mocks.getBuiltinAgents.mockReturnValue([clips]);
110
+ mocks.discoverAgents.mockResolvedValue([clips, partner]);
111
+ mocks.resourceListAccessible.mockImplementation(async () => []);
112
+ mocks.getDispatchConfig.mockReturnValueOnce({ hostedCatalog: false });
113
+
114
+ const { default: action } = await import("./list-connected-agents.js");
115
+ const agents = await action.run({});
116
+
117
+ expect(agents.map((agent: { id: string }) => agent.id)).toEqual([
118
+ "partner",
119
+ ]);
120
+ });
121
+
97
122
  it("marks hosted apps hidden from launchers when the organization hides them", async () => {
98
123
  const clips = {
99
124
  id: "clips",
@@ -28,9 +28,8 @@ export default defineAction({
28
28
  schema: z.object({}),
29
29
  http: { method: "GET" },
30
30
  run: async () => {
31
- const { hiddenAgentIds = [] } = await import("../server/index.js").then(
32
- (m) => m.getDispatchConfig(),
33
- );
31
+ const { hiddenAgentIds = [], hostedCatalog = true } =
32
+ await import("../server/index.js").then((m) => m.getDispatchConfig());
34
33
  const [discovered, hosted, hostedAppsSettings] = await Promise.all([
35
34
  discoverAgents("dispatch"),
36
35
  listHostedApps(),
@@ -119,6 +118,10 @@ export default defineAction({
119
118
  });
120
119
  }
121
120
 
122
- return connected.filter((a) => !hiddenAgentIds.includes(a.id));
121
+ return connected.filter(
122
+ (a) =>
123
+ !hiddenAgentIds.includes(a.id) &&
124
+ (hostedCatalog || a.source !== "builtin"),
125
+ );
123
126
  },
124
127
  });
@@ -5,7 +5,7 @@ import { listGrantedDispatchMcpAppActions } from "../server/lib/mcp-gateway.js";
5
5
 
6
6
  export default defineAction({
7
7
  description:
8
- "List the actions a granted app exposes (read inbox, create draft, move event, and so on) as names and one-line descriptions. Pass names to get full input schemas for just those actions. Call before call_app_action; results are fast, unlike ask_app.",
8
+ "List the actions exposed by a granted app (such as reading inbox messages, creating drafts, or managing events) as names and brief descriptions. Optional `names` filters the response to full input schemas for specific actions.",
9
9
  schema: z.object({
10
10
  app: z.string().describe("Granted app id, e.g. mail or calendar."),
11
11
  names: z
@@ -10,7 +10,7 @@ vi.mock("../server/lib/hosted-apps-settings.js", () => ({
10
10
  }));
11
11
 
12
12
  vi.mock("../server/lib/mcp-gateway.js", () => ({
13
- listGrantedDispatchMcpApps: mocks.listGrantedApps,
13
+ listGrantedDispatchMcpAppsWithStatus: mocks.listGrantedApps,
14
14
  }));
15
15
 
16
16
  import listApps from "./list_apps.js";
@@ -18,20 +18,23 @@ import listApps from "./list_apps.js";
18
18
  beforeEach(() => {
19
19
  vi.clearAllMocks();
20
20
  mocks.hideHostedAppsWhenOff.mockImplementation(async (apps) => apps);
21
- mocks.listGrantedApps.mockResolvedValue([
22
- {
23
- id: "slides",
24
- name: "Slides",
25
- description: "Create presentations",
26
- url: "https://slides.example.test",
27
- },
28
- {
29
- id: "analytics",
30
- name: "Analytics",
31
- description: "Answer data questions",
32
- url: "https://analytics.example.test",
33
- },
34
- ]);
21
+ mocks.listGrantedApps.mockResolvedValue({
22
+ degradedSources: [],
23
+ apps: [
24
+ {
25
+ id: "slides",
26
+ name: "Slides",
27
+ description: "Create presentations",
28
+ url: "https://slides.example.test",
29
+ },
30
+ {
31
+ id: "analytics",
32
+ name: "Analytics",
33
+ description: "Answer data questions",
34
+ url: "https://analytics.example.test",
35
+ },
36
+ ],
37
+ });
35
38
  });
36
39
 
37
40
  describe("list_apps", () => {
@@ -66,15 +69,48 @@ describe("list_apps", () => {
66
69
  ]);
67
70
  });
68
71
 
69
- it("lists only what the gateway discovered, so disabled built-ins never appear", async () => {
70
- mocks.listGrantedApps.mockResolvedValue([
72
+ it("exposes degraded sources to structured and compact MCP clients", async () => {
73
+ const degradedSources = [
71
74
  {
72
- id: "crm",
73
- name: "CRM",
74
- description: "Workspace app",
75
- url: "https://workspace.example.test/crm",
75
+ source: "workspace-directory",
76
+ status: "unavailable",
77
+ usingCache: true,
76
78
  },
77
- ]);
79
+ ];
80
+ mocks.listGrantedApps.mockResolvedValue({
81
+ degradedSources,
82
+ apps: [
83
+ {
84
+ id: "workspace/fleet",
85
+ name: "Fleet",
86
+ aliases: ["Delivery desk"],
87
+ url: "https://workspace.example.test/fleet",
88
+ },
89
+ ],
90
+ });
91
+
92
+ const result = await listApps.run({});
93
+ expect(result.degradedSources).toEqual(degradedSources);
94
+ expect(JSON.parse(result.message)).toEqual({
95
+ apps: [
96
+ { id: "workspace/fleet", name: "Fleet", aliases: ["Delivery desk"] },
97
+ ],
98
+ degradedSources,
99
+ });
100
+ });
101
+
102
+ it("lists only what the gateway discovered, so disabled built-ins never appear", async () => {
103
+ mocks.listGrantedApps.mockResolvedValue({
104
+ degradedSources: [],
105
+ apps: [
106
+ {
107
+ id: "crm",
108
+ name: "CRM",
109
+ description: "Workspace app",
110
+ url: "https://workspace.example.test/crm",
111
+ },
112
+ ],
113
+ });
78
114
 
79
115
  const result = await listApps.run({});
80
116
 
@@ -2,7 +2,7 @@ import { defineAction } from "@agent-native/core/action";
2
2
  import { z } from "zod";
3
3
 
4
4
  import { hideHostedAppsWhenOff } from "../server/lib/hosted-apps-settings.js";
5
- import { listGrantedDispatchMcpApps } from "../server/lib/mcp-gateway.js";
5
+ import { listGrantedDispatchMcpAppsWithStatus } from "../server/lib/mcp-gateway.js";
6
6
 
7
7
  export default defineAction({
8
8
  description:
@@ -12,14 +12,15 @@ export default defineAction({
12
12
  readOnly: true,
13
13
  parallelSafe: true,
14
14
  run: async () => {
15
- const apps = await hideHostedAppsWhenOff(
16
- await listGrantedDispatchMcpApps(),
17
- );
15
+ const { apps: granted, degradedSources } =
16
+ await listGrantedDispatchMcpAppsWithStatus();
17
+ const apps = await hideHostedAppsWhenOff(granted);
18
18
  const appSummaries = apps.map((app) => ({
19
19
  id: app.id,
20
20
  name: app.name,
21
21
  description: app.description,
22
22
  url: app.url,
23
+ ...(app.aliases?.length ? { aliases: app.aliases } : {}),
23
24
  running: true,
24
25
  source: "dispatch-mcp-grant",
25
26
  }));
@@ -27,8 +28,14 @@ export default defineAction({
27
28
  workspace: true,
28
29
  gateway: "dispatch",
29
30
  apps: appSummaries,
31
+ degradedSources,
30
32
  message: JSON.stringify({
31
- apps: appSummaries.map(({ id, name }) => ({ id, name })),
33
+ apps: appSummaries.map(({ id, name, aliases }) => ({
34
+ id,
35
+ name,
36
+ ...(aliases?.length ? { aliases } : {}),
37
+ })),
38
+ ...(degradedSources.length ? { degradedSources } : {}),
32
39
  }),
33
40
  };
34
41
  },
@@ -23,6 +23,7 @@ export default defineAction({
23
23
  intent: navigationIntentSchema,
24
24
  }),
25
25
  http: false,
26
+ mcpTool: "search",
26
27
  run: async (args) => {
27
28
  const threadId = args.threadId?.trim();
28
29
  if (!args.view && !args.path && !threadId) {
@@ -22,6 +22,19 @@ describe("open_app MCP App metadata", () => {
22
22
  vi.clearAllMocks();
23
23
  });
24
24
 
25
+ it("tells the model to open the pane for show, draft, chart, and calendar asks", () => {
26
+ for (const ask of [
27
+ "show",
28
+ "open",
29
+ "draft",
30
+ "chart",
31
+ "calendar",
32
+ "dashboard",
33
+ ]) {
34
+ expect(openAppAction.tool.description).toContain(ask);
35
+ }
36
+ });
37
+
25
38
  it("uses exact granted app origins instead of broad HTTPS CSP", async () => {
26
39
  mocks.listGrantedDispatchMcpAppOrigins.mockResolvedValue([
27
40
  "https://dispatch.agent-native.com",
@@ -132,8 +145,11 @@ describe("open_app MCP App metadata", () => {
132
145
  { caller } as any,
133
146
  );
134
147
 
135
- const input = mocks.openGrantedDispatchMcpApp.mock.calls[0]?.[0];
148
+ const [input, options] = mocks.openGrantedDispatchMcpApp.mock.calls[0];
136
149
  expect(input.embed).toBe(expected);
150
+ expect(options).toEqual(
151
+ caller === "tool" ? { prefetchEmbed: true } : undefined,
152
+ );
137
153
  },
138
154
  );
139
155
 
@@ -33,6 +33,12 @@ const openAppSchema = z.object({
33
33
  .describe(
34
34
  "What the user wants to see, in their words (for example: my unread email from Dana). Used to pick the app when app is not given; app wins when both are set.",
35
35
  ),
36
+ screen: z
37
+ .string()
38
+ .optional()
39
+ .describe(
40
+ "Declared manifest screen id to resolve with params, e.g. deck or thread.",
41
+ ),
36
42
  view: z.string().optional().describe("Target view in the app, e.g. inbox."),
37
43
  path: z
38
44
  .string()
@@ -44,6 +50,12 @@ const openAppSchema = z.object({
44
50
  .record(z.string(), deepLinkParam)
45
51
  .optional()
46
52
  .describe("Optional record-focus or filter params."),
53
+ focus: z
54
+ .boolean()
55
+ .optional()
56
+ .describe(
57
+ "Explicitly transfer foreground pane focus when another app was already committed during this turn.",
58
+ ),
47
59
  embed: z
48
60
  .boolean()
49
61
  .optional()
@@ -155,7 +167,7 @@ async function pickAppForIntent(
155
167
 
156
168
  export default defineAction({
157
169
  description:
158
- "Show a found or created mail, event, document, or record when viewing it is the useful result. Pass app (or just intent, in the user's words, to let Dispatch pick the app). Returns a registered app route for the chat client to open beside the conversation.",
170
+ "Return a registered app route for the host to open beside the conversation to show a view or item such as mail, a draft, a calendar view, a chart, a dashboard, a document, or a record. Accepts an `app` id or a natural-language `intent` to select a matching granted app.",
159
171
  schema: openAppSchema,
160
172
  http: { method: "GET" },
161
173
  readOnly: true,
@@ -174,13 +186,14 @@ export default defineAction({
174
186
  app = await pickAppForIntent(intent, ctx);
175
187
  }
176
188
  const normalized = { ...normalizedArgs, app };
177
- // An MCP host shows the app from the session the target app mints, so
178
- // ask for one unless the caller opted out.
179
- const result = await openGrantedDispatchMcpApp(
180
- normalized.embed == null && ctx?.caller === "mcp"
181
- ? { ...normalized, embed: true }
182
- : normalized,
183
- );
189
+ const result =
190
+ ctx?.caller === "tool"
191
+ ? await openGrantedDispatchMcpApp(normalized, { prefetchEmbed: true })
192
+ : await openGrantedDispatchMcpApp(
193
+ normalized.embed == null && ctx?.caller === "mcp"
194
+ ? { ...normalized, embed: true }
195
+ : normalized,
196
+ );
184
197
  const targetApp = normalizeTrackingDimension(result.app) ?? result.app;
185
198
  if (targetApp !== "dispatch") {
186
199
  track(
@@ -0,0 +1,42 @@
1
+ import {
2
+ MAX_ACTION_SUGGESTIONS_PER_TURN,
3
+ type ActionSuggestionResult,
4
+ } from "@agent-native/agentkit/protocol";
5
+ import { defineAction } from "@agent-native/core/action";
6
+ import { z } from "zod";
7
+
8
+ import { uniqueActionSuggestions } from "../lib/action-suggestions.js";
9
+ import {
10
+ actionSuggestionSchema,
11
+ canOfferActionSuggestion,
12
+ } from "../server/lib/action-suggestions.js";
13
+
14
+ export default defineAction({
15
+ description:
16
+ "Offer up to two concrete, optional next actions in the current chat turn. Use only work that would benefit the user and that the user has not already asked you to perform. For an app action, use the exact app ID and action name from the granted app catalog and supply its actual inputs. For a persistent workflow that no installed app fits, use kind create-app, trigger new-domain, and appId dispatch. Suggestions take effect only after the user selects one.",
17
+ schema: z.object({
18
+ suggestions: z
19
+ .array(actionSuggestionSchema)
20
+ .max(MAX_ACTION_SUGGESTIONS_PER_TURN),
21
+ }),
22
+ outputSchema: z.object({
23
+ suggestions: z
24
+ .array(actionSuggestionSchema)
25
+ .max(MAX_ACTION_SUGGESTIONS_PER_TURN),
26
+ }),
27
+ readOnly: true,
28
+ http: false,
29
+ mcpTool: false,
30
+ run: async ({ suggestions }): Promise<ActionSuggestionResult> => {
31
+ const candidates = uniqueActionSuggestions(suggestions);
32
+ const available = await Promise.allSettled(
33
+ candidates.map(canOfferActionSuggestion),
34
+ );
35
+ return {
36
+ suggestions: candidates.filter((_, index) => {
37
+ const result = available.at(index);
38
+ return result?.status === "fulfilled" && result.value;
39
+ }),
40
+ };
41
+ },
42
+ });
@@ -9,7 +9,7 @@ import { callGrantedDispatchMcpAppAction } from "../server/lib/mcp-gateway.js";
9
9
 
10
10
  export default defineAction({
11
11
  description:
12
- "Read what the user is looking at in a granted app right now: the open screen, selection, and any open composer or draft, including edits not yet saved. Call it before answering questions like 'what does my draft say now?'. Fast; use after the user edits in the app view.",
12
+ "Read the current view state in the active tab of a granted app, including the open screen, selection, and any open composer or unsaved draft edits.",
13
13
  schema: z.object({
14
14
  app: z.string().describe("Granted app id, e.g. mail or calendar."),
15
15
  }),
@@ -10,7 +10,7 @@ import { rememberPointer } from "../server/lib/pointers-store.js";
10
10
 
11
11
  export default defineAction({
12
12
  description:
13
- 'Remember that a name the user uses (an alias such as "todo list") points to a specific object in a workspace app, such as a doc, deck, or board. Call it when the user says "X is my Y" or "my Y is this <app item or link>". Later requests that mention the alias open that object instead of the app the request would otherwise route to.',
13
+ 'Save a user-defined alias (such as "todo list") pointing to a specific workspace app object (such as a doc, deck, or board) by app id and object id or URL.',
14
14
  schema: z
15
15
  .object({
16
16
  alias: z
@@ -9,7 +9,7 @@ import { listPointers, matchPointer } from "../server/lib/pointers-store.js";
9
9
 
10
10
  export default defineAction({
11
11
  description:
12
- 'Look up whether the user\'s request names something they saved as a pointer (for example "my todo list" saved as a specific doc). Call it BEFORE opening or choosing an app for any request that refers to something by a personal name. When it returns a match, open that app and object instead of guessing from the request.',
12
+ 'Look up whether a text query matches a user-saved pointer alias (for example, "my todo list" mapped to a specific document). Returns the matched alias, app id, and object id or URL when found.',
13
13
  schema: z.object({
14
14
  text: z.string().trim().min(1).max(4000).describe("The user's request."),
15
15
  }),