@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
@@ -38,6 +38,142 @@ describe("route-app-intent", () => {
38
38
  ]);
39
39
  });
40
40
 
41
+ it.each([
42
+ ["show me GitHub messages from actual people", "mail"],
43
+ ["show emails about GitHub issues", "mail"],
44
+ ["open my GitHub inbox", "mail"],
45
+ ["find messages from people", "mail"],
46
+ ["show my GitHub issues", "tasks"],
47
+ ["open GitHub pull requests", "tasks"],
48
+ ["list GitHub PRs assigned to me", "tasks"],
49
+ ])(
50
+ "routes %s to %s despite a competing service pointer",
51
+ async (text, app) => {
52
+ mocks.listGrantedDispatchMcpApps.mockResolvedValue([
53
+ { id: "mail", name: "Mail", description: "Email inbox" },
54
+ { id: "tasks", name: "Tasks", description: "GitHub integration" },
55
+ ]);
56
+ mocks.listPointerRows.mockResolvedValue([
57
+ {
58
+ id: "p1",
59
+ owner: "owner@example.com",
60
+ path: "pointers/github.json",
61
+ content: JSON.stringify({ alias: "GitHub", appId: "tasks" }),
62
+ },
63
+ ]);
64
+ mocks.decide.mockResolvedValue({
65
+ status: "ok",
66
+ provider: "test",
67
+ model: "test",
68
+ answers: {
69
+ app: { type: "choice", choice: app === "mail" ? "tasks" : "mail" },
70
+ },
71
+ });
72
+ expect(await run({ text })).toMatchObject({ status: "ok", app });
73
+ },
74
+ );
75
+
76
+ it("falls back to classification when the mail app is not granted", async () => {
77
+ mocks.listGrantedDispatchMcpApps.mockResolvedValue([
78
+ { id: "tasks", name: "Tasks", description: "GitHub integration" },
79
+ ]);
80
+ mocks.decide.mockResolvedValue({
81
+ status: "ok",
82
+ provider: "test",
83
+ model: "test",
84
+ answers: { app: { type: "choice", choice: "none" } },
85
+ });
86
+ expect(await run({ text: "show my inbox" })).toMatchObject({
87
+ status: "ok",
88
+ app: "none",
89
+ });
90
+ expect(mocks.decide).toHaveBeenCalledOnce();
91
+ });
92
+
93
+ it("recognizes an explicit registered app choice without classifying it", async () => {
94
+ expect(await run({ text: "Open Mail." })).toMatchObject({
95
+ status: "ok",
96
+ app: "mail",
97
+ confidence: 1,
98
+ explicit: true,
99
+ screen: "home",
100
+ });
101
+ expect(mocks.decide).not.toHaveBeenCalled();
102
+ });
103
+
104
+ it("keeps explicit installation IDs ahead of competing workspace aliases", async () => {
105
+ mocks.listGrantedDispatchMcpApps.mockResolvedValue([
106
+ {
107
+ id: "fleet-2",
108
+ name: "Fleet",
109
+ description: "",
110
+ source: "builtin",
111
+ },
112
+ {
113
+ id: "workspace/fleet",
114
+ name: "Fleet",
115
+ description: "",
116
+ aliases: ["fleet-2"],
117
+ source: "workspace",
118
+ },
119
+ ]);
120
+ await expect(run({ text: "Open Fleet-2" })).resolves.toMatchObject({
121
+ app: "fleet-2",
122
+ explicit: true,
123
+ });
124
+ await expect(run({ text: "Open Fleet" })).resolves.toMatchObject({
125
+ app: "workspace/fleet",
126
+ explicit: true,
127
+ });
128
+ expect(mocks.decide).not.toHaveBeenCalled();
129
+ });
130
+
131
+ it("includes the active route, selection, and granted installation manifests", async () => {
132
+ mocks.listGrantedDispatchMcpApps.mockResolvedValue([
133
+ {
134
+ id: "workspace/mail",
135
+ name: "Mail",
136
+ description: "Email",
137
+ aliases: ["Inbox"],
138
+ },
139
+ ]);
140
+ mocks.decide.mockResolvedValue({
141
+ status: "ok",
142
+ provider: "test",
143
+ model: "test",
144
+ answers: {
145
+ app: { type: "choice", choice: "workspace/mail", confidence: 0.88 },
146
+ },
147
+ });
148
+ await run({
149
+ text: "Summarize this",
150
+ openApp: "workspace/mail",
151
+ openPath: "/threads/2?code=fixture#state=fixture",
152
+ selection: "Selected message",
153
+ });
154
+ expect(mocks.decide.mock.lastCall?.[0].input).toEqual(
155
+ expect.arrayContaining([
156
+ {
157
+ type: "json",
158
+ value: {
159
+ connectedWorkspaceApps: [
160
+ {
161
+ id: "workspace/mail",
162
+ name: "Mail",
163
+ description: "Email",
164
+ aliases: ["Inbox"],
165
+ },
166
+ ],
167
+ },
168
+ },
169
+ {
170
+ type: "json",
171
+ value: { openPath: "/threads/2", selection: "Selected message" },
172
+ },
173
+ ]),
174
+ );
175
+ });
176
+
41
177
  it("opens a saved pointer's object instead of the Tasks default", async () => {
42
178
  mocks.listGrantedDispatchMcpApps.mockResolvedValue([
43
179
  { id: "tasks", name: "Tasks", description: "To-dos" },
@@ -103,19 +239,103 @@ describe("route-app-intent", () => {
103
239
  provider: "jev",
104
240
  model: "jev-1",
105
241
  cached: false,
106
- answers: { app: { type: "choice", name: "app", choice: "mail" } },
242
+ answers: {
243
+ app: { type: "choice", name: "app", choice: "mail", confidence: 0.91 },
244
+ },
107
245
  });
108
246
 
109
247
  const result = await run({ text: "whats on my todo list" });
110
248
 
111
- expect(result).toMatchObject({ status: "ok", app: "mail" });
249
+ expect(result).toMatchObject({
250
+ status: "ok",
251
+ app: "mail",
252
+ confidence: 0.91,
253
+ });
112
254
  expect(result).not.toHaveProperty("pointer");
113
255
  const parts = mocks.decide.mock.calls[0][0].input;
114
256
  expect(parts).toContainEqual({
115
257
  type: "json",
116
258
  value: { savedPointers: [{ alias: "standup notes", appId: "mail" }] },
117
259
  });
118
- expect(mocks.decide.mock.calls[0][0].options.cacheKey).toMatch(/\.v2$/);
260
+ expect(mocks.decide.mock.calls[0][0].options.cacheKey).toMatch(/\.v5$/);
261
+ });
262
+
263
+ it.each(["mail", "tasks"])(
264
+ "lets classification resolve a cross-app pointer to %s",
265
+ async (choice) => {
266
+ mocks.listGrantedDispatchMcpApps.mockResolvedValue([
267
+ { id: "mail", name: "Mail", description: "Email inbox" },
268
+ { id: "tasks", name: "Tasks", description: "Pull requests" },
269
+ ]);
270
+ mocks.listPointerRows.mockResolvedValue([
271
+ {
272
+ id: "p1",
273
+ owner: "owner@example.com",
274
+ path: "pointers/github.json",
275
+ content: JSON.stringify({
276
+ alias: "GitHub",
277
+ appId: "tasks",
278
+ url: "https://example.com/reviews",
279
+ }),
280
+ },
281
+ ]);
282
+ mocks.decide.mockResolvedValue({
283
+ status: "ok",
284
+ provider: "test",
285
+ model: "test",
286
+ cached: false,
287
+ answers: { app: { type: "choice", name: "app", choice } },
288
+ });
289
+
290
+ const result = await run({
291
+ text:
292
+ choice === "mail"
293
+ ? "GitHub notifications from people"
294
+ : "open my GitHub reviews",
295
+ openApp: "mail",
296
+ });
297
+ expect(result).toMatchObject({ status: "ok", app: choice });
298
+ expect("pointer" in result && result.pointer === true).toBe(
299
+ choice === "tasks",
300
+ );
301
+ expect("url" in result ? result.url : undefined).toBe(
302
+ choice === "tasks" ? "https://example.com/reviews" : undefined,
303
+ );
304
+ expect(mocks.decide).toHaveBeenCalledOnce();
305
+ },
306
+ );
307
+
308
+ it("lets the request select another app despite a pointer in the current app", async () => {
309
+ mocks.listGrantedDispatchMcpApps.mockResolvedValue([
310
+ { id: "mail", name: "Mail", description: "Email inbox" },
311
+ { id: "tasks", name: "Tasks", description: "Pull requests" },
312
+ ]);
313
+ mocks.listPointerRows.mockResolvedValue([
314
+ {
315
+ id: "p1",
316
+ owner: "owner@example.com",
317
+ path: "pointers/github.json",
318
+ content: JSON.stringify({
319
+ alias: "GitHub",
320
+ appId: "mail",
321
+ url: "https://example.com/mail",
322
+ }),
323
+ },
324
+ ]);
325
+ mocks.decide.mockResolvedValue({
326
+ status: "ok",
327
+ provider: "test",
328
+ model: "test",
329
+ cached: false,
330
+ answers: { app: { type: "choice", name: "app", choice: "tasks" } },
331
+ });
332
+ const result = await run({
333
+ text: "show my GitHub pull requests",
334
+ openApp: "mail",
335
+ });
336
+ expect(result).toMatchObject({ status: "ok", app: "tasks" });
337
+ expect(result).not.toHaveProperty("pointer");
338
+ expect(mocks.decide).not.toHaveBeenCalled();
119
339
  });
120
340
 
121
341
  it("is reachable by desktop MCP clients but hidden from the in-app agent", () => {
@@ -156,6 +376,15 @@ describe("route-app-intent", () => {
156
376
  ]);
157
377
  expect(call.input).toEqual([
158
378
  { type: "text", text: "Request: move it to 4pm" },
379
+ {
380
+ type: "json",
381
+ value: {
382
+ connectedWorkspaceApps: [
383
+ { id: "calendar", name: "Calendar", description: "" },
384
+ { id: "mail", name: "Mail", description: "Email inbox" },
385
+ ],
386
+ },
387
+ },
159
388
  { type: "text", text: "App currently on screen: calendar" },
160
389
  {
161
390
  type: "json",
@@ -185,7 +414,7 @@ describe("route-app-intent", () => {
185
414
  reason: "missing_credentials",
186
415
  providers: [],
187
416
  });
188
- const notConfigured = await run({ text: "my inbox" });
417
+ const notConfigured = await run({ text: "my schedule" });
189
418
  expect(notConfigured).toMatchObject({
190
419
  status: "not_configured",
191
420
  reason: "missing_credentials",
@@ -193,7 +422,7 @@ describe("route-app-intent", () => {
193
422
  expect(notConfigured).not.toHaveProperty("app");
194
423
 
195
424
  mocks.decide.mockResolvedValueOnce({ status: "failed", reason: "timeout" });
196
- const failed = await run({ text: "my inbox" });
425
+ const failed = await run({ text: "my schedule" });
197
426
  expect(failed).toMatchObject({ status: "failed", reason: "timeout" });
198
427
  expect(failed).not.toHaveProperty("app");
199
428
  });
@@ -7,6 +7,8 @@ import {
7
7
  } from "@agent-native/core/server";
8
8
  import { z } from "zod";
9
9
 
10
+ import { classifyDataIntent } from "../lib/data-intent.js";
11
+ import { matchDispatchAppCandidates } from "../lib/dispatch-app-identity.js";
10
12
  import { listGrantedDispatchMcpApps } from "../server/lib/mcp-gateway.js";
11
13
  import { listPointers, matchPointer } from "../server/lib/pointers-store.js";
12
14
 
@@ -14,12 +16,16 @@ const QUESTION = "app";
14
16
  const NONE = "none";
15
17
  // Bump when the question or choice wording changes so cached answers to the
16
18
  // old wording are not replayed.
17
- const CACHE_KEY = "dispatch.route-app-intent.v2";
19
+ const CACHE_KEY = "dispatch.route-app-intent.v5";
18
20
 
19
21
  type RouteAppIntentResult =
20
22
  | {
21
23
  status: "ok";
22
24
  app: string;
25
+ confidence: number;
26
+ explicit?: true;
27
+ screen?: "home";
28
+ params?: Record<string, string>;
23
29
  provider: string;
24
30
  model: string;
25
31
  cached: boolean;
@@ -46,7 +52,7 @@ async function listPointersOrNone(ownerEmail: string) {
46
52
 
47
53
  export default defineAction({
48
54
  description:
49
- 'Pick which granted workspace app should be on screen for a chat request, or "none" for a chat-only answer. Choices come from the apps granted to this Dispatch, so a new app routes without code changes. A saved pointer (remember-pointer) that matches the request wins and returns the object to open.',
55
+ 'Pick which granted workspace app should be on screen for a chat request, or "none" for a chat-only answer. Choices come from the apps granted to this Dispatch, so a new app routes without code changes. A matching saved pointer (remember-pointer) can identify an object to open.',
50
56
  schema: z.object({
51
57
  text: z.string().trim().min(1).max(4000).describe("The user's request."),
52
58
  openApp: z
@@ -55,6 +61,8 @@ export default defineAction({
55
61
  .max(200)
56
62
  .optional()
57
63
  .describe("Id of the app currently on screen, if any."),
64
+ openPath: z.string().max(2000).optional(),
65
+ selection: z.string().max(4000).optional(),
58
66
  previousTurn: z
59
67
  .union([z.string().max(4000), z.record(z.string(), z.unknown())])
60
68
  .optional()
@@ -66,6 +74,10 @@ export default defineAction({
66
74
  z.object({
67
75
  status: z.literal("ok"),
68
76
  app: z.string(),
77
+ confidence: z.number().min(0).max(1),
78
+ explicit: z.literal(true).optional(),
79
+ screen: z.literal("home").optional(),
80
+ params: z.record(z.string(), z.string()).optional(),
69
81
  provider: z.string(),
70
82
  model: z.string(),
71
83
  cached: z.boolean(),
@@ -88,6 +100,8 @@ export default defineAction({
88
100
  run: async ({
89
101
  text,
90
102
  openApp,
103
+ openPath,
104
+ selection,
91
105
  previousTurn,
92
106
  }): Promise<RouteAppIntentResult> => {
93
107
  const ownerEmail = getRequestUserEmail();
@@ -118,16 +132,57 @@ export default defineAction({
118
132
  return { status: "failed", reason: "no_granted_apps" };
119
133
  }
120
134
 
135
+ const explicitName = /^(?:open|show|switch to|go to)\s+(.+?)[.!]?$/i
136
+ .exec(text)?.[1]
137
+ ?.trim()
138
+ .toLowerCase();
139
+ if (explicitName) {
140
+ const candidates = matchDispatchAppCandidates(apps, explicitName);
141
+ const explicitApp = candidates.length === 1 ? candidates[0] : null;
142
+ if (explicitApp) {
143
+ return {
144
+ status: "ok",
145
+ app: explicitApp.id,
146
+ confidence: 1,
147
+ explicit: true,
148
+ screen: "home",
149
+ provider: "registration",
150
+ model: "exact-app-match",
151
+ cached: false,
152
+ latencyMs: 0,
153
+ };
154
+ }
155
+ }
156
+
157
+ const intentApp = classifyDataIntent(text);
158
+ const intentCandidates = intentApp
159
+ ? matchDispatchAppCandidates(apps, intentApp)
160
+ : [];
161
+ const intentCandidate = intentCandidates.at(0);
162
+ if (intentCandidates.length === 1 && intentCandidate) {
163
+ return {
164
+ status: "ok",
165
+ app: intentCandidate.id,
166
+ confidence: 1,
167
+ provider: "routing",
168
+ model: "data-intent",
169
+ cached: false,
170
+ latencyMs: 0,
171
+ };
172
+ }
173
+
121
174
  const hit = matchPointer(text, grantedPointers);
122
- if (hit) {
175
+ if (hit && !openApp) {
123
176
  return {
124
177
  status: "ok",
125
178
  app: hit.appId,
179
+ confidence: 1,
126
180
  provider: "pointer",
127
181
  model: "alias-match",
128
182
  cached: false,
129
183
  latencyMs: 0,
130
184
  pointer: true,
185
+ ...(explicitName === hit.alias.toLowerCase() ? { explicit: true } : {}),
131
186
  ...(hit.objectId ? { objectId: hit.objectId } : {}),
132
187
  ...(hit.url ? { url: hit.url } : {}),
133
188
  };
@@ -136,9 +191,26 @@ export default defineAction({
136
191
  const input: DecisionInputPart[] = [
137
192
  { type: "text", text: `Request: ${text}` },
138
193
  ];
194
+ input.push({
195
+ type: "json",
196
+ value: {
197
+ connectedWorkspaceApps: apps.map(
198
+ ({ id, name, description, aliases }) => ({
199
+ id,
200
+ name,
201
+ description,
202
+ ...(aliases?.length ? { aliases } : {}),
203
+ }),
204
+ ),
205
+ },
206
+ });
139
207
  if (openApp) {
140
208
  input.push({ type: "text", text: `App currently on screen: ${openApp}` });
141
209
  }
210
+ const routePath = openPath?.split(/[?#]/, 1)[0];
211
+ if (routePath !== undefined || selection !== undefined) {
212
+ input.push({ type: "json", value: { openPath: routePath, selection } });
213
+ }
142
214
  if (grantedPointers.length > 0) {
143
215
  input.push({
144
216
  type: "json",
@@ -163,7 +235,7 @@ export default defineAction({
163
235
  type: "choice",
164
236
  name: QUESTION,
165
237
  instructions:
166
- "Which app should be on screen to handle this request? Pick the app whose data or screen the request is about. When the request refers to something by one of the saved pointer aliases, pick that pointer's app. A short follow-up to the previous turn keeps the app on screen unless it clearly asks about another app. Pick none only when no app's data is involved.",
238
+ "Which app should be on screen to handle this request? Pick the app whose data or screen the request is about, not an app associated with a service mentioned in that data. Consider the current app for every request, not only follow-ups: keep it when the request concerns its data, and switch only when the user clearly requests another app's data or screen. Notifications or emails about a service are mail data; requests for that service's actual records are different. A saved pointer alias can refer to an object, but a coincidental mention does not override the requested data or current app. Pick none only when no app's data is involved.",
167
239
  choices,
168
240
  },
169
241
  ],
@@ -206,10 +278,23 @@ export default defineAction({
206
278
  return {
207
279
  status: "ok",
208
280
  app,
281
+ confidence:
282
+ answer?.type === "choice" &&
283
+ typeof answer.confidence === "number" &&
284
+ Number.isFinite(answer.confidence)
285
+ ? Math.max(0, Math.min(1, answer.confidence))
286
+ : 0,
209
287
  provider: result.provider,
210
288
  model: result.model,
211
289
  cached: result.cached === true,
212
290
  latencyMs,
291
+ ...(hit && app === hit.appId
292
+ ? {
293
+ pointer: true,
294
+ ...(hit.objectId ? { objectId: hit.objectId } : {}),
295
+ ...(hit.url ? { url: hit.url } : {}),
296
+ }
297
+ : {}),
213
298
  };
214
299
  },
215
300
  });
@@ -0,0 +1,40 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+
3
+ vi.mock("@agent-native/core/server", () => ({
4
+ getRequestUserEmail: () => "alice@example.com",
5
+ }));
6
+
7
+ vi.mock("../server/lib/dispatch-remote-commands.js", () => ({
8
+ enqueueRemoteCodeCommand: vi.fn(),
9
+ }));
10
+
11
+ import action from "./send-code-agent-remote-command.js";
12
+
13
+ async function gate(command: Record<string, unknown>) {
14
+ const needsApproval = action.needsApproval;
15
+ if (typeof needsApproval !== "function") throw new Error("no gate");
16
+ return needsApproval({ command }, { caller: "tool" });
17
+ }
18
+
19
+ describe("send-code-agent-remote-command approval", () => {
20
+ it.each([
21
+ { type: "create", prompt: "fix it" },
22
+ { type: "continue", runRef: "r1", text: "go on" },
23
+ { type: "approve", approvalId: "a1" },
24
+ ])("asks for $type", async (command) => {
25
+ expect(await gate(command)).toBe(true);
26
+ });
27
+
28
+ it.each([
29
+ { type: "list" },
30
+ { type: "status" },
31
+ { type: "deny", approvalId: "a1" },
32
+ { type: "stop", runRef: "r1" },
33
+ ])("does not ask for $type", async (command) => {
34
+ expect(await gate(command)).toBe(false);
35
+ });
36
+
37
+ it("never offers persistent approval", () => {
38
+ expect(action.allowPersistentApproval).toBe(false);
39
+ });
40
+ });
@@ -37,6 +37,11 @@ export default defineAction({
37
37
  })
38
38
  .optional(),
39
39
  }),
40
+ needsApproval: ({ command }) =>
41
+ command.type === "create" ||
42
+ command.type === "continue" ||
43
+ command.type === "approve",
44
+ allowPersistentApproval: false,
40
45
  run: async ({ command, source }) => {
41
46
  const ownerEmail = getRequestUserEmail();
42
47
  if (!ownerEmail) throw new Error("no authenticated user");
@@ -36,7 +36,7 @@ export type StartWorkspaceAppCreationAttachment = z.infer<
36
36
 
37
37
  export default defineAction({
38
38
  description:
39
- 'Start creating a new workspace app from Dispatch when the request truly needs its own app. For Claude Web, ChatGPT Web, or either host\'s web Project, this action is the Builder handoff: call it after forming a bounded source brief and do not scaffold or edit files in the host sandbox. This handoff is autonomous once the brief exists: do not ask the user for non-blocking product or UX choices; choose recommended defaults and let Builder record assumptions while it implements. Callers should include a concise generated description by default; Dispatch generates one from the prompt when omitted. In local dev this returns a code-agent prompt; in production it reuses the connected Agent-Native workspace project or, for an organization owner/admin, provisions it through the Builder Projects API before starting the Builder Cloud Agent branch. If no project is configured, organization members must ask an owner/admin to configure it first. The result must be a separate workspace app under apps/<app-id>, not a new route or file in apps/chat. If chat is used as the source template, the finished app must be branded as the requested app and must not leave visible "Chat", "Starter", "Blank app", or "New app" UI behind. If the request needs Mail, Calendar, Analytics, Brain, Assets, or another first-party app, use the existing hosted/connected app via links or A2A; do not wrap or nest those apps inside the new app unless the user explicitly asks for a customized app from that template.',
39
+ "Start creating a new workspace app under apps/<app-id> from a natural-language prompt and optional template, description, vault secret IDs, workspace resource IDs, and attachments. In local dev this returns a code-agent prompt; in production it starts a Builder Cloud Agent branch on the organization's connected Agent-Native workspace project (or provisions one for organization owners/admins when configured).",
40
40
  schema: z.object({
41
41
  prompt: z.string().min(1).describe("The user's app creation request"),
42
42
  appId: z
@@ -23,6 +23,7 @@ describe("Dispatch view-screen production bundle", () => {
23
23
  );
24
24
  temporaryDirectories.push(temporaryDirectory);
25
25
  const entry = path.resolve("src/actions/view-screen.ts");
26
+ const paneContext = path.resolve("src/server/lib/dispatch-pane-context.ts");
26
27
  const outputDirectory = path.join(temporaryDirectory, "dist");
27
28
  const calls: Array<[string, Record<string, unknown>]> = [];
28
29
  const stubbedImports = new Set([
@@ -49,7 +50,15 @@ describe("Dispatch view-screen production bundle", () => {
49
50
  enforce: "pre" as const,
50
51
  resolveId(source: string, importer?: string) {
51
52
  if (source.startsWith("\0view-screen-stub:")) return source;
52
- if (importer !== entry || !stubbedImports.has(source)) return null;
53
+ if (
54
+ !(importer === entry && stubbedImports.has(source)) &&
55
+ !(
56
+ importer === paneContext &&
57
+ source === "@agent-native/core/application-state"
58
+ )
59
+ ) {
60
+ return null;
61
+ }
53
62
  return `\0view-screen-stub:${source}`;
54
63
  },
55
64
  load(id: string) {
@@ -65,7 +74,11 @@ describe("Dispatch view-screen production bundle", () => {
65
74
  return "export const defineAction = (action) => action;";
66
75
  }
67
76
  if (source === "@agent-native/core/application-state") {
68
- return "export const readAppState = async () => globalThis.__viewScreenNavigation;";
77
+ return [
78
+ "export const readAppState = async () => globalThis.__viewScreenNavigation;",
79
+ "export const resolveCurrentRequestStateTab = async () => ({ tabId: null, unavailable: true });",
80
+ "export const appStateKeyForBrowserTab = (key, tab) => key + ':' + tab;",
81
+ ].join("\n");
69
82
  }
70
83
  if (source === "zod") {
71
84
  return "export const z = { object: () => ({}) };";