@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.
- package/CHANGELOG.md +194 -174
- package/dist/actions/ask_app.d.ts +3 -0
- package/dist/actions/ask_app.js +7 -2
- package/dist/actions/ask_app.js.map +1 -1
- package/dist/actions/ask_app_status.d.ts +3 -0
- package/dist/actions/ask_app_status.js +5 -1
- package/dist/actions/ask_app_status.js.map +1 -1
- package/dist/actions/call_app_action.d.ts +1 -0
- package/dist/actions/call_app_action.js +21 -5
- package/dist/actions/call_app_action.js.map +1 -1
- package/dist/actions/create_embed_session.d.ts +3 -2
- package/dist/actions/create_embed_session.js +4 -2
- package/dist/actions/create_embed_session.js.map +1 -1
- package/dist/actions/create_workspace_app_embed_session.d.ts +3 -2
- package/dist/actions/create_workspace_app_embed_session.js +3 -1
- package/dist/actions/create_workspace_app_embed_session.js.map +1 -1
- package/dist/actions/delete-destination.d.ts +12 -12
- package/dist/actions/execute-action-suggestion.d.ts +44 -0
- package/dist/actions/execute-action-suggestion.d.ts.map +1 -0
- package/dist/actions/execute-action-suggestion.js +148 -0
- package/dist/actions/execute-action-suggestion.js.map +1 -0
- package/dist/actions/import-agent.d.ts +13 -13
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +5 -1
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/list-connected-agents.js +3 -2
- package/dist/actions/list-connected-agents.js.map +1 -1
- package/dist/actions/list-workspace-connections.d.ts +1 -0
- package/dist/actions/list-workspace-connections.d.ts.map +1 -1
- package/dist/actions/list_app_actions.js +1 -1
- package/dist/actions/list_app_actions.js.map +1 -1
- package/dist/actions/list_apps.d.ts +2 -0
- package/dist/actions/list_apps.js +11 -3
- package/dist/actions/list_apps.js.map +1 -1
- package/dist/actions/navigate.js +1 -0
- package/dist/actions/navigate.js.map +1 -1
- package/dist/actions/open_app.d.ts +4 -0
- package/dist/actions/open_app.js +14 -6
- package/dist/actions/open_app.js.map +1 -1
- package/dist/actions/propose-action-suggestions.d.ts +45 -0
- package/dist/actions/propose-action-suggestions.d.ts.map +1 -0
- package/dist/actions/propose-action-suggestions.js +32 -0
- package/dist/actions/propose-action-suggestions.js.map +1 -0
- package/dist/actions/provider-api-register.d.ts +12 -12
- package/dist/actions/read_view.js +1 -1
- package/dist/actions/read_view.js.map +1 -1
- package/dist/actions/remember-pointer.js +1 -1
- package/dist/actions/remember-pointer.js.map +1 -1
- package/dist/actions/resolve-pointer.js +1 -1
- package/dist/actions/resolve-pointer.js.map +1 -1
- package/dist/actions/route-app-intent.d.ts +6 -0
- package/dist/actions/route-app-intent.js +79 -5
- package/dist/actions/route-app-intent.js.map +1 -1
- package/dist/actions/send-code-agent-remote-command.js +4 -0
- package/dist/actions/send-code-agent-remote-command.js.map +1 -1
- package/dist/actions/start-workspace-app-creation.js +1 -1
- package/dist/actions/start-workspace-app-creation.js.map +1 -1
- package/dist/actions/upsert-destination.d.ts +12 -12
- package/dist/actions/view-screen.d.ts +12 -1
- package/dist/actions/view-screen.js +53 -5
- package/dist/actions/view-screen.js.map +1 -1
- package/dist/components/chat-action-suggestions.d.ts +8 -0
- package/dist/components/chat-action-suggestions.d.ts.map +1 -0
- package/dist/components/chat-action-suggestions.js +191 -0
- package/dist/components/chat-action-suggestions.js.map +1 -0
- package/dist/components/chat-home-apps.d.ts.map +1 -1
- package/dist/components/chat-home-apps.js +1 -1
- package/dist/components/chat-home-apps.js.map +1 -1
- package/dist/components/google-broker-settings-group.d.ts +2 -0
- package/dist/components/google-broker-settings-group.d.ts.map +1 -0
- package/dist/components/google-broker-settings-group.js +53 -0
- package/dist/components/google-broker-settings-group.js.map +1 -0
- package/dist/components/layout/Layout.d.ts +4 -1
- package/dist/components/layout/Layout.d.ts.map +1 -1
- package/dist/components/layout/Layout.js +246 -69
- package/dist/components/layout/Layout.js.map +1 -1
- package/dist/components/messaging-setup-panel.d.ts.map +1 -1
- package/dist/components/messaging-setup-panel.js +47 -15
- package/dist/components/messaging-setup-panel.js.map +1 -1
- package/dist/components/workspace-app-host.d.ts +27 -4
- package/dist/components/workspace-app-host.d.ts.map +1 -1
- package/dist/components/workspace-app-host.js +355 -74
- package/dist/components/workspace-app-host.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/db/google-broker-admission.d.ts +36 -0
- package/dist/db/google-broker-admission.d.ts.map +1 -0
- package/dist/db/google-broker-admission.js +129 -0
- package/dist/db/google-broker-admission.js.map +1 -0
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +42 -0
- package/dist/db/migrations.js.map +1 -1
- package/dist/lib/action-suggestions.d.ts +20 -0
- package/dist/lib/action-suggestions.d.ts.map +1 -0
- package/dist/lib/action-suggestions.js +219 -0
- package/dist/lib/action-suggestions.js.map +1 -0
- package/dist/lib/chat-first-app-route.d.ts +11 -5
- package/dist/lib/chat-first-app-route.d.ts.map +1 -1
- package/dist/lib/chat-first-app-route.js +9 -5
- package/dist/lib/chat-first-app-route.js.map +1 -1
- package/dist/lib/chat-first-pane.d.ts +25 -1
- package/dist/lib/chat-first-pane.d.ts.map +1 -1
- package/dist/lib/chat-first-pane.js +67 -1
- package/dist/lib/chat-first-pane.js.map +1 -1
- package/dist/lib/data-intent.d.ts +3 -0
- package/dist/lib/data-intent.d.ts.map +1 -0
- package/dist/lib/data-intent.js +14 -0
- package/dist/lib/data-intent.js.map +1 -0
- package/dist/lib/dispatch-app-identity.d.ts +10 -0
- package/dist/lib/dispatch-app-identity.d.ts.map +1 -0
- package/dist/lib/dispatch-app-identity.js +18 -0
- package/dist/lib/dispatch-app-identity.js.map +1 -0
- package/dist/lib/other-apps.d.ts +15 -0
- package/dist/lib/other-apps.d.ts.map +1 -1
- package/dist/lib/other-apps.js +31 -0
- package/dist/lib/other-apps.js.map +1 -1
- package/dist/lib/workspace-app-frame-view.d.ts +15 -0
- package/dist/lib/workspace-app-frame-view.d.ts.map +1 -0
- package/dist/lib/workspace-app-frame-view.js +72 -0
- package/dist/lib/workspace-app-frame-view.js.map +1 -0
- package/dist/lib/workspace-apps.d.ts +5 -0
- package/dist/lib/workspace-apps.d.ts.map +1 -1
- package/dist/lib/workspace-apps.js +85 -23
- package/dist/lib/workspace-apps.js.map +1 -1
- package/dist/lib/workspace-apps.test.js +6 -0
- package/dist/lib/workspace-apps.test.js.map +1 -1
- package/dist/routes/pages/_index.d.ts +2 -2
- package/dist/routes/pages/chat.d.ts.map +1 -1
- package/dist/routes/pages/chat.js +33 -2
- package/dist/routes/pages/chat.js.map +1 -1
- package/dist/routes/pages/settings-page.d.ts +1 -1
- package/dist/routes/pages/settings-page.d.ts.map +1 -1
- package/dist/routes/pages/settings-page.js +3 -2
- package/dist/routes/pages/settings-page.js.map +1 -1
- package/dist/server/index.d.ts +4 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +5 -5
- package/dist/server/index.js.map +1 -1
- package/dist/server/lib/action-suggestions.d.ts +41 -0
- package/dist/server/lib/action-suggestions.d.ts.map +1 -0
- package/dist/server/lib/action-suggestions.js +94 -0
- package/dist/server/lib/action-suggestions.js.map +1 -0
- package/dist/server/lib/app-action-result.d.ts +5 -0
- package/dist/server/lib/app-action-result.d.ts.map +1 -1
- package/dist/server/lib/app-action-result.js +7 -0
- package/dist/server/lib/app-action-result.js.map +1 -1
- package/dist/server/lib/app-creation-store.d.ts.map +1 -1
- package/dist/server/lib/app-creation-store.js +63 -13
- package/dist/server/lib/app-creation-store.js.map +1 -1
- package/dist/server/lib/curated-workspace-templates.d.ts.map +1 -1
- package/dist/server/lib/curated-workspace-templates.js +3 -0
- package/dist/server/lib/curated-workspace-templates.js.map +1 -1
- package/dist/server/lib/dispatch-config.d.ts +5 -0
- package/dist/server/lib/dispatch-config.d.ts.map +1 -0
- package/dist/server/lib/dispatch-config.js +11 -0
- package/dist/server/lib/dispatch-config.js.map +1 -0
- package/dist/server/lib/dispatch-pane-context.d.ts +11 -0
- package/dist/server/lib/dispatch-pane-context.d.ts.map +1 -0
- package/dist/server/lib/dispatch-pane-context.js +35 -0
- package/dist/server/lib/dispatch-pane-context.js.map +1 -0
- package/dist/server/lib/google-broker-provider.d.ts +41 -0
- package/dist/server/lib/google-broker-provider.d.ts.map +1 -0
- package/dist/server/lib/google-broker-provider.js +96 -0
- package/dist/server/lib/google-broker-provider.js.map +1 -0
- package/dist/server/lib/google-broker-rpc.d.ts +26 -0
- package/dist/server/lib/google-broker-rpc.d.ts.map +1 -0
- package/dist/server/lib/google-broker-rpc.js +52 -0
- package/dist/server/lib/google-broker-rpc.js.map +1 -0
- package/dist/server/lib/hosted-apps-settings.d.ts.map +1 -1
- package/dist/server/lib/hosted-apps-settings.js +4 -0
- package/dist/server/lib/hosted-apps-settings.js.map +1 -1
- package/dist/server/lib/mcp-app-discovery.d.ts +17 -0
- package/dist/server/lib/mcp-app-discovery.d.ts.map +1 -0
- package/dist/server/lib/mcp-app-discovery.js +231 -0
- package/dist/server/lib/mcp-app-discovery.js.map +1 -0
- package/dist/server/lib/mcp-gateway.d.ts +64 -21
- package/dist/server/lib/mcp-gateway.d.ts.map +1 -1
- package/dist/server/lib/mcp-gateway.js +730 -88
- package/dist/server/lib/mcp-gateway.js.map +1 -1
- package/dist/server/plugins/agent-chat.js +9 -7
- package/dist/server/plugins/agent-chat.js.map +1 -1
- package/dist/server/plugins/auth.d.ts.map +1 -1
- package/dist/server/plugins/auth.js +1 -0
- package/dist/server/plugins/auth.js.map +1 -1
- package/dist/server/plugins/db.d.ts.map +1 -1
- package/dist/server/plugins/db.js +0 -46
- package/dist/server/plugins/db.js.map +1 -1
- package/dist/server/plugins/integrations.d.ts.map +1 -1
- package/dist/server/plugins/integrations.js +4 -1
- package/dist/server/plugins/integrations.js.map +1 -1
- package/dist/shared/chat-first-pane.d.ts +24 -0
- package/dist/shared/chat-first-pane.d.ts.map +1 -1
- package/dist/shared/chat-first-pane.js +34 -0
- package/dist/shared/chat-first-pane.js.map +1 -1
- package/dist/shared/labs.d.ts +1 -0
- package/dist/shared/labs.d.ts.map +1 -1
- package/dist/shared/labs.js +7 -0
- package/dist/shared/labs.js.map +1 -1
- package/package.json +7 -6
- package/src/actions/action-suggestions.spec.ts +342 -0
- package/src/actions/app_actions.spec.ts +103 -0
- package/src/actions/ask_app.ts +9 -2
- package/src/actions/ask_app_status.ts +12 -1
- package/src/actions/call_app_action.ts +28 -8
- package/src/actions/create_embed_session.ts +8 -2
- package/src/actions/create_workspace_app_embed_session.ts +6 -1
- package/src/actions/execute-action-suggestion.ts +177 -0
- package/src/actions/index.spec.ts +6 -3
- package/src/actions/index.ts +5 -1
- package/src/actions/list-connected-agents.spec.ts +26 -1
- package/src/actions/list-connected-agents.ts +7 -4
- package/src/actions/list_app_actions.ts +1 -1
- package/src/actions/list_apps.spec.ts +58 -22
- package/src/actions/list_apps.ts +12 -5
- package/src/actions/navigate.ts +1 -0
- package/src/actions/open_app.spec.ts +17 -1
- package/src/actions/open_app.ts +21 -8
- package/src/actions/propose-action-suggestions.ts +42 -0
- package/src/actions/read_view.ts +1 -1
- package/src/actions/remember-pointer.ts +1 -1
- package/src/actions/resolve-pointer.ts +1 -1
- package/src/actions/route-app-intent.spec.ts +234 -5
- package/src/actions/route-app-intent.ts +89 -4
- package/src/actions/send-code-agent-remote-command.spec.ts +40 -0
- package/src/actions/send-code-agent-remote-command.ts +5 -0
- package/src/actions/start-workspace-app-creation.ts +1 -1
- package/src/actions/view-screen.bundle.spec.ts +15 -2
- package/src/actions/view-screen.spec.ts +81 -3
- package/src/actions/view-screen.ts +60 -4
- package/src/components/chat-action-suggestions.spec.tsx +362 -0
- package/src/components/chat-action-suggestions.tsx +432 -0
- package/src/components/chat-home-apps.spec.tsx +19 -0
- package/src/components/chat-home-apps.tsx +0 -1
- package/src/components/google-broker-settings-group.tsx +186 -0
- package/src/components/layout/Layout.spec.tsx +419 -28
- package/src/components/layout/Layout.tsx +304 -66
- package/src/components/messaging-setup-panel.spec.tsx +278 -4
- package/src/components/messaging-setup-panel.tsx +82 -19
- package/src/components/workspace-app-card.spec.tsx +79 -10
- package/src/components/workspace-app-chat-rail.spec.tsx +81 -3
- package/src/components/workspace-app-host.spec.tsx +269 -16
- package/src/components/workspace-app-host.tsx +464 -87
- package/src/config.ts +5 -0
- package/src/db/google-broker-admission.ts +160 -0
- package/src/db/migrations.spec.ts +165 -2
- package/src/db/migrations.ts +43 -1
- package/src/lib/action-suggestions.ts +267 -0
- package/src/lib/chat-first-app-route.spec.ts +15 -2
- package/src/lib/chat-first-app-route.ts +19 -7
- package/src/lib/chat-first-pane.spec.ts +71 -0
- package/src/lib/chat-first-pane.ts +101 -4
- package/src/lib/data-intent.spec.ts +21 -0
- package/src/lib/data-intent.ts +13 -0
- package/src/lib/dispatch-app-identity.ts +40 -0
- package/src/lib/other-apps.spec.ts +110 -1
- package/src/lib/other-apps.ts +41 -0
- package/src/lib/workspace-app-frame-view.spec.ts +13 -0
- package/src/lib/workspace-app-frame-view.ts +98 -0
- package/src/lib/workspace-apps.spec.ts +101 -0
- package/src/lib/workspace-apps.test.ts +18 -0
- package/src/lib/workspace-apps.ts +102 -24
- package/src/routes/pages/chat.spec.tsx +92 -1
- package/src/routes/pages/chat.tsx +41 -2
- package/src/routes/pages/settings-page.tsx +22 -17
- package/src/routes/pages/settings.spec.tsx +4 -0
- package/src/server/index.ts +6 -6
- package/src/server/lib/action-suggestions.ts +122 -0
- package/src/server/lib/app-action-result.ts +8 -0
- package/src/server/lib/app-creation-store.spec.ts +251 -0
- package/src/server/lib/app-creation-store.ts +72 -12
- package/src/server/lib/community-apps.spec.ts +19 -1
- package/src/server/lib/curated-workspace-templates.spec.ts +12 -0
- package/src/server/lib/curated-workspace-templates.ts +2 -0
- package/src/server/lib/dispatch-config.ts +15 -0
- package/src/server/lib/dispatch-pane-context.spec.ts +54 -0
- package/src/server/lib/dispatch-pane-context.ts +54 -0
- package/src/server/lib/google-broker-provider.ts +121 -0
- package/src/server/lib/google-broker-rpc.spec.ts +95 -0
- package/src/server/lib/google-broker-rpc.ts +107 -0
- package/src/server/lib/hosted-apps-settings.ts +4 -0
- package/src/server/lib/mcp-app-discovery.ts +318 -0
- package/src/server/lib/mcp-gateway.spec.ts +2252 -524
- package/src/server/lib/mcp-gateway.ts +1044 -181
- package/src/server/plugins/agent-chat.direct-mcp.spec.ts +84 -5
- package/src/server/plugins/agent-chat.ts +9 -7
- package/src/server/plugins/auth.spec.ts +5 -1
- package/src/server/plugins/auth.ts +1 -0
- package/src/server/plugins/db.ts +0 -51
- package/src/server/plugins/integrations.ts +4 -1
- package/src/shared/chat-first-pane.spec.ts +36 -0
- package/src/shared/chat-first-pane.ts +55 -0
- package/src/shared/labs.ts +8 -0
- package/src/server/plugins/agent-chat.spec.ts +0 -206
- 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: {
|
|
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({
|
|
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(/\.
|
|
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
|
|
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
|
|
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.
|
|
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)
|
|
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.
|
|
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
|
-
|
|
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 (
|
|
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
|
|
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: () => ({}) };";
|