@agent-native/dispatch 0.13.12 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/delete-destination.d.ts +12 -12
- package/dist/actions/provider-api-audit.d.ts +7 -0
- package/dist/actions/provider-api-audit.d.ts.map +1 -0
- package/dist/actions/provider-api-audit.js +74 -0
- package/dist/actions/provider-api-audit.js.map +1 -0
- package/dist/actions/provider-api-catalog.d.ts +1 -1
- package/dist/actions/provider-api-request.js +10 -0
- package/dist/actions/provider-api-request.js.map +1 -1
- package/dist/actions/send-platform-message.d.ts +1 -0
- package/dist/actions/send-platform-message.js +43 -22
- package/dist/actions/send-platform-message.js.map +1 -1
- package/dist/components/dispatch-control-plane.d.ts.map +1 -1
- package/dist/components/dispatch-control-plane.js +1 -1
- package/dist/components/dispatch-control-plane.js.map +1 -1
- package/dist/components/messaging-setup-panel.d.ts.map +1 -1
- package/dist/components/messaging-setup-panel.js +203 -127
- package/dist/components/messaging-setup-panel.js.map +1 -1
- package/dist/hooks/use-navigation-state.d.ts.map +1 -1
- package/dist/hooks/use-navigation-state.js +1 -2
- package/dist/hooks/use-navigation-state.js.map +1 -1
- package/dist/routes/pages/$appId.d.ts.map +1 -1
- package/dist/routes/pages/$appId.js +3 -1
- package/dist/routes/pages/$appId.js.map +1 -1
- package/dist/routes/pages/apps.$appId.d.ts.map +1 -1
- package/dist/routes/pages/apps.$appId.js +2 -2
- package/dist/routes/pages/apps.$appId.js.map +1 -1
- package/dist/routes/pages/apps.d.ts.map +1 -1
- package/dist/routes/pages/apps.js +1 -3
- package/dist/routes/pages/apps.js.map +1 -1
- package/dist/routes/pages/messaging.js +1 -1
- package/dist/routes/pages/messaging.js.map +1 -1
- package/dist/routes/pages/team.js +1 -1
- package/dist/routes/pages/team.js.map +1 -1
- package/dist/server/lib/dispatch-integrations.d.ts +7 -1
- package/dist/server/lib/dispatch-integrations.d.ts.map +1 -1
- package/dist/server/lib/dispatch-integrations.js +178 -8
- package/dist/server/lib/dispatch-integrations.js.map +1 -1
- package/dist/server/lib/dispatch-routing.d.ts +6 -0
- package/dist/server/lib/dispatch-routing.d.ts.map +1 -0
- package/dist/server/lib/dispatch-routing.js +30 -0
- package/dist/server/lib/dispatch-routing.js.map +1 -0
- package/dist/server/lib/env-config.d.ts.map +1 -1
- package/dist/server/lib/env-config.js +50 -0
- package/dist/server/lib/env-config.js.map +1 -1
- package/dist/server/lib/onboarding-steps.d.ts.map +1 -1
- package/dist/server/lib/onboarding-steps.js +25 -0
- package/dist/server/lib/onboarding-steps.js.map +1 -1
- package/dist/server/lib/provider-api.d.ts +2 -2
- package/dist/server/lib/provider-api.d.ts.map +1 -1
- package/dist/server/plugins/integrations.d.ts.map +1 -1
- package/dist/server/plugins/integrations.js +5 -2
- package/dist/server/plugins/integrations.js.map +1 -1
- package/package.json +2 -2
- package/src/actions/provider-api-audit.spec.ts +52 -0
- package/src/actions/provider-api-audit.ts +88 -0
- package/src/actions/provider-api-request.ts +10 -0
- package/src/actions/send-platform-message.spec.ts +108 -0
- package/src/actions/send-platform-message.ts +73 -25
- package/src/components/dispatch-control-plane.tsx +1 -5
- package/src/components/messaging-setup-panel.spec.tsx +191 -0
- package/src/components/messaging-setup-panel.tsx +472 -193
- package/src/hooks/use-navigation-state.ts +1 -2
- package/src/routes/pages/$appId.tsx +3 -5
- package/src/routes/pages/apps.$appId.tsx +3 -7
- package/src/routes/pages/apps.tsx +0 -3
- package/src/routes/pages/messaging.tsx +1 -1
- package/src/routes/pages/team.tsx +1 -1
- package/src/server/lib/dispatch-integrations.spec.ts +113 -0
- package/src/server/lib/dispatch-integrations.ts +239 -6
- package/src/server/lib/dispatch-routing.spec.ts +42 -0
- package/src/server/lib/dispatch-routing.ts +42 -0
- package/src/server/lib/env-config.ts +50 -0
- package/src/server/lib/onboarding-steps.ts +32 -0
- package/src/server/plugins/integrations.ts +5 -2
|
@@ -2,6 +2,16 @@ export const envKeys = [
|
|
|
2
2
|
{
|
|
3
3
|
key: "SLACK_BOT_TOKEN",
|
|
4
4
|
label: "Slack bot token",
|
|
5
|
+
required: false,
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
key: "SLACK_CLIENT_ID",
|
|
9
|
+
label: "Slack OAuth client ID",
|
|
10
|
+
required: true,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
key: "SLACK_CLIENT_SECRET",
|
|
14
|
+
label: "Slack OAuth client secret",
|
|
5
15
|
required: true,
|
|
6
16
|
},
|
|
7
17
|
{
|
|
@@ -14,6 +24,41 @@ export const envKeys = [
|
|
|
14
24
|
label: "Telegram bot token",
|
|
15
25
|
required: true,
|
|
16
26
|
},
|
|
27
|
+
{
|
|
28
|
+
key: "TELEGRAM_WEBHOOK_SECRET",
|
|
29
|
+
label: "Telegram webhook secret",
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
key: "MICROSOFT_TEAMS_APP_ID",
|
|
34
|
+
label: "Microsoft Bot app ID",
|
|
35
|
+
required: false,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: "MICROSOFT_TEAMS_APP_PASSWORD",
|
|
39
|
+
label: "Microsoft Bot client secret",
|
|
40
|
+
required: false,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
key: "MICROSOFT_TEAMS_APP_TENANT_ID",
|
|
44
|
+
label: "Microsoft Bot tenant ID",
|
|
45
|
+
required: false,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
key: "MICROSOFT_TEAMS_ALLOWED_TENANT_IDS",
|
|
49
|
+
label: "Allowed Microsoft Teams tenant IDs",
|
|
50
|
+
required: false,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
key: "DISCORD_APPLICATION_ID",
|
|
54
|
+
label: "Discord application ID",
|
|
55
|
+
required: false,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: "DISCORD_PUBLIC_KEY",
|
|
59
|
+
label: "Discord public key",
|
|
60
|
+
required: false,
|
|
61
|
+
},
|
|
17
62
|
{
|
|
18
63
|
key: "EMAIL_AGENT_ADDRESS",
|
|
19
64
|
label: "Agent email address",
|
|
@@ -39,6 +84,11 @@ export const envKeys = [
|
|
|
39
84
|
label: "WhatsApp phone number ID",
|
|
40
85
|
required: false,
|
|
41
86
|
},
|
|
87
|
+
{
|
|
88
|
+
key: "WHATSAPP_APP_SECRET",
|
|
89
|
+
label: "WhatsApp app secret",
|
|
90
|
+
required: false,
|
|
91
|
+
},
|
|
42
92
|
{
|
|
43
93
|
key: "PYLON_API_KEY",
|
|
44
94
|
label: "Pylon API key",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-config.js","sourceRoot":"","sources":["../../../src/server/lib/env-config.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAmB;IACrC;QACE,GAAG,EAAE,iBAAiB;QACtB,KAAK,EAAE,iBAAiB;QACxB,QAAQ,EAAE,IAAI;KACf;IACD;QACE,GAAG,EAAE,sBAAsB;QAC3B,KAAK,EAAE,sBAAsB;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD;QACE,GAAG,EAAE,oBAAoB;QACzB,KAAK,EAAE,oBAAoB;QAC3B,QAAQ,EAAE,IAAI;KACf;IACD;QACE,GAAG,EAAE,qBAAqB;QAC1B,KAAK,EAAE,qBAAqB;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,8BAA8B;QACnC,KAAK,EAAE,2BAA2B;QAClC,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,uBAAuB;QAC5B,KAAK,EAAE,uBAAuB;QAC9B,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,uBAAuB;QAC5B,KAAK,EAAE,uBAAuB;QAC9B,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,0BAA0B;QAC/B,KAAK,EAAE,0BAA0B;QACjC,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,eAAe;QACpB,KAAK,EAAE,eAAe;QACtB,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC","sourcesContent":["import type { EnvKeyConfig } from \"@agent-native/core/server\";\n\nexport const envKeys: EnvKeyConfig[] = [\n {\n key: \"SLACK_BOT_TOKEN\",\n label: \"Slack bot token\",\n required: true,\n },\n {\n key: \"SLACK_SIGNING_SECRET\",\n label: \"Slack signing secret\",\n required: true,\n },\n {\n key: \"TELEGRAM_BOT_TOKEN\",\n label: \"Telegram bot token\",\n required: true,\n },\n {\n key: \"EMAIL_AGENT_ADDRESS\",\n label: \"Agent email address\",\n required: false,\n },\n {\n key: \"DISPATCH_DEFAULT_OWNER_EMAIL\",\n label: \"Default Slack owner email\",\n required: false,\n },\n {\n key: \"WHATSAPP_ACCESS_TOKEN\",\n label: \"WhatsApp access token\",\n required: false,\n },\n {\n key: \"WHATSAPP_VERIFY_TOKEN\",\n label: \"WhatsApp verify token\",\n required: false,\n },\n {\n key: \"WHATSAPP_PHONE_NUMBER_ID\",\n label: \"WhatsApp phone number ID\",\n required: false,\n },\n {\n key: \"PYLON_API_KEY\",\n label: \"Pylon API key\",\n required: false,\n },\n];\n"]}
|
|
1
|
+
{"version":3,"file":"env-config.js","sourceRoot":"","sources":["../../../src/server/lib/env-config.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAmB;IACrC;QACE,GAAG,EAAE,iBAAiB;QACtB,KAAK,EAAE,iBAAiB;QACxB,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,iBAAiB;QACtB,KAAK,EAAE,uBAAuB;QAC9B,QAAQ,EAAE,IAAI;KACf;IACD;QACE,GAAG,EAAE,qBAAqB;QAC1B,KAAK,EAAE,2BAA2B;QAClC,QAAQ,EAAE,IAAI;KACf;IACD;QACE,GAAG,EAAE,sBAAsB;QAC3B,KAAK,EAAE,sBAAsB;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD;QACE,GAAG,EAAE,oBAAoB;QACzB,KAAK,EAAE,oBAAoB;QAC3B,QAAQ,EAAE,IAAI;KACf;IACD;QACE,GAAG,EAAE,yBAAyB;QAC9B,KAAK,EAAE,yBAAyB;QAChC,QAAQ,EAAE,IAAI;KACf;IACD;QACE,GAAG,EAAE,wBAAwB;QAC7B,KAAK,EAAE,sBAAsB;QAC7B,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,8BAA8B;QACnC,KAAK,EAAE,6BAA6B;QACpC,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,+BAA+B;QACpC,KAAK,EAAE,yBAAyB;QAChC,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,oCAAoC;QACzC,KAAK,EAAE,oCAAoC;QAC3C,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,wBAAwB;QAC7B,KAAK,EAAE,wBAAwB;QAC/B,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,oBAAoB;QACzB,KAAK,EAAE,oBAAoB;QAC3B,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,qBAAqB;QAC1B,KAAK,EAAE,qBAAqB;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,8BAA8B;QACnC,KAAK,EAAE,2BAA2B;QAClC,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,uBAAuB;QAC5B,KAAK,EAAE,uBAAuB;QAC9B,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,uBAAuB;QAC5B,KAAK,EAAE,uBAAuB;QAC9B,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,0BAA0B;QAC/B,KAAK,EAAE,0BAA0B;QACjC,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,qBAAqB;QAC1B,KAAK,EAAE,qBAAqB;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,eAAe;QACpB,KAAK,EAAE,eAAe;QACtB,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC","sourcesContent":["import type { EnvKeyConfig } from \"@agent-native/core/server\";\n\nexport const envKeys: EnvKeyConfig[] = [\n {\n key: \"SLACK_BOT_TOKEN\",\n label: \"Slack bot token\",\n required: false,\n },\n {\n key: \"SLACK_CLIENT_ID\",\n label: \"Slack OAuth client ID\",\n required: true,\n },\n {\n key: \"SLACK_CLIENT_SECRET\",\n label: \"Slack OAuth client secret\",\n required: true,\n },\n {\n key: \"SLACK_SIGNING_SECRET\",\n label: \"Slack signing secret\",\n required: true,\n },\n {\n key: \"TELEGRAM_BOT_TOKEN\",\n label: \"Telegram bot token\",\n required: true,\n },\n {\n key: \"TELEGRAM_WEBHOOK_SECRET\",\n label: \"Telegram webhook secret\",\n required: true,\n },\n {\n key: \"MICROSOFT_TEAMS_APP_ID\",\n label: \"Microsoft Bot app ID\",\n required: false,\n },\n {\n key: \"MICROSOFT_TEAMS_APP_PASSWORD\",\n label: \"Microsoft Bot client secret\",\n required: false,\n },\n {\n key: \"MICROSOFT_TEAMS_APP_TENANT_ID\",\n label: \"Microsoft Bot tenant ID\",\n required: false,\n },\n {\n key: \"MICROSOFT_TEAMS_ALLOWED_TENANT_IDS\",\n label: \"Allowed Microsoft Teams tenant IDs\",\n required: false,\n },\n {\n key: \"DISCORD_APPLICATION_ID\",\n label: \"Discord application ID\",\n required: false,\n },\n {\n key: \"DISCORD_PUBLIC_KEY\",\n label: \"Discord public key\",\n required: false,\n },\n {\n key: \"EMAIL_AGENT_ADDRESS\",\n label: \"Agent email address\",\n required: false,\n },\n {\n key: \"DISPATCH_DEFAULT_OWNER_EMAIL\",\n label: \"Default Slack owner email\",\n required: false,\n },\n {\n key: \"WHATSAPP_ACCESS_TOKEN\",\n label: \"WhatsApp access token\",\n required: false,\n },\n {\n key: \"WHATSAPP_VERIFY_TOKEN\",\n label: \"WhatsApp verify token\",\n required: false,\n },\n {\n key: \"WHATSAPP_PHONE_NUMBER_ID\",\n label: \"WhatsApp phone number ID\",\n required: false,\n },\n {\n key: \"WHATSAPP_APP_SECRET\",\n label: \"WhatsApp app secret\",\n required: false,\n },\n {\n key: \"PYLON_API_KEY\",\n label: \"Pylon API key\",\n required: false,\n },\n];\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onboarding-steps.d.ts","sourceRoot":"","sources":["../../../src/server/lib/onboarding-steps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"onboarding-steps.d.ts","sourceRoot":"","sources":["../../../src/server/lib/onboarding-steps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH,wBAAgB,+BAA+B,IAAI,IAAI,CA2DtD"}
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
* the user has even created a real app. This step nudges them at adding
|
|
9
9
|
* their first workspace app first.
|
|
10
10
|
*/
|
|
11
|
+
import { listIntegrationInstallations } from "@agent-native/core/integrations";
|
|
11
12
|
import { registerOnboardingStep } from "@agent-native/core/onboarding";
|
|
13
|
+
import { getRequestOrgId, getRequestUserEmail, } from "@agent-native/core/server/request-context";
|
|
12
14
|
import { listWorkspaceApps } from "./app-creation-store.js";
|
|
13
15
|
let registered = false;
|
|
14
16
|
export function registerDispatchOnboardingSteps() {
|
|
@@ -43,5 +45,28 @@ export function registerDispatchOnboardingSteps() {
|
|
|
43
45
|
}
|
|
44
46
|
},
|
|
45
47
|
});
|
|
48
|
+
registerOnboardingStep({
|
|
49
|
+
id: "dispatch:connect-slack-workspace",
|
|
50
|
+
title: "Connect a Slack workspace",
|
|
51
|
+
description: "Install Agent Native with OAuth, then configure channel identities and access policies.",
|
|
52
|
+
order: 60,
|
|
53
|
+
required: false,
|
|
54
|
+
methods: [
|
|
55
|
+
{
|
|
56
|
+
id: "open-messaging",
|
|
57
|
+
kind: "link",
|
|
58
|
+
primary: true,
|
|
59
|
+
label: "Open Messaging",
|
|
60
|
+
payload: { url: "/messaging", external: false },
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
isComplete: async () => {
|
|
64
|
+
const userEmail = getRequestUserEmail();
|
|
65
|
+
if (!userEmail)
|
|
66
|
+
return false;
|
|
67
|
+
const rows = await listIntegrationInstallations({ userEmail, orgId: getRequestOrgId() ?? null }, "slack").catch(() => []);
|
|
68
|
+
return rows.some((row) => row.status === "connected");
|
|
69
|
+
},
|
|
70
|
+
});
|
|
46
71
|
}
|
|
47
72
|
//# sourceMappingURL=onboarding-steps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onboarding-steps.js","sourceRoot":"","sources":["../../../src/server/lib/onboarding-steps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"onboarding-steps.js","sourceRoot":"","sources":["../../../src/server/lib/onboarding-steps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EACL,eAAe,EACf,mBAAmB,GACpB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,MAAM,UAAU,+BAA+B;IAC7C,IAAI,UAAU;QAAE,OAAO;IACvB,UAAU,GAAG,IAAI,CAAC;IAElB,sBAAsB,CAAC;QACrB,EAAE,EAAE,2BAA2B;QAC/B,KAAK,EAAE,uBAAuB;QAC9B,WAAW,EACT,mGAAmG;QACrG,KAAK,EAAE,CAAC;QACR,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE;YACP;gBACE,EAAE,EAAE,WAAW;gBACf,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,IAAI;gBACb,KAAK,EAAE,aAAa;gBACpB,OAAO,EAAE,EAAE,GAAG,EAAE,gBAAgB,EAAE,QAAQ,EAAE,KAAK,EAAE;aACpD;SACF;QACD,UAAU,EAAE,KAAK,IAAI,EAAE;YACrB,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC;oBACnC,iBAAiB,EAAE,KAAK;oBACxB,eAAe,EAAE,IAAI;iBACtB,CAAC,CAAC;gBACH,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC7C,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,sBAAsB,CAAC;QACrB,EAAE,EAAE,kCAAkC;QACtC,KAAK,EAAE,2BAA2B;QAClC,WAAW,EACT,yFAAyF;QAC3F,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE;YACP;gBACE,EAAE,EAAE,gBAAgB;gBACpB,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,IAAI;gBACb,KAAK,EAAE,gBAAgB;gBACvB,OAAO,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE;aAChD;SACF;QACD,UAAU,EAAE,KAAK,IAAI,EAAE;YACrB,MAAM,SAAS,GAAG,mBAAmB,EAAE,CAAC;YACxC,IAAI,CAAC,SAAS;gBAAE,OAAO,KAAK,CAAC;YAC7B,MAAM,IAAI,GAAG,MAAM,4BAA4B,CAC7C,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,IAAI,EAAE,EAC/C,OAAO,CACR,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;YAClB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC;QACxD,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Dispatch-specific onboarding steps.\n *\n * Slack/Telegram/etc. are auto-registered at order 60 by the framework when\n * their env keys are declared `required: true` in `env-config.ts`. Without\n * any earlier dispatch-specific step, a brand-new workspace lands on\n * \"Connect Slack\" as the first visible to-do — which is intimidating before\n * the user has even created a real app. This step nudges them at adding\n * their first workspace app first.\n */\n\nimport { listIntegrationInstallations } from \"@agent-native/core/integrations\";\nimport { registerOnboardingStep } from \"@agent-native/core/onboarding\";\nimport {\n getRequestOrgId,\n getRequestUserEmail,\n} from \"@agent-native/core/server/request-context\";\n\nimport { listWorkspaceApps } from \"./app-creation-store.js\";\n\nlet registered = false;\n\nexport function registerDispatchOnboardingSteps(): void {\n if (registered) return;\n registered = true;\n\n registerOnboardingStep({\n id: \"dispatch:create-first-app\",\n title: \"Create your first app\",\n description:\n \"Add a workspace app like Mail, Calendar, or Slides — or describe a custom app from the Apps page.\",\n order: 5,\n required: false,\n methods: [\n {\n id: \"open-apps\",\n kind: \"link\",\n primary: true,\n label: \"Browse apps\",\n payload: { url: \"/dispatch/apps\", external: false },\n },\n ],\n isComplete: async () => {\n try {\n const apps = await listWorkspaceApps({\n includeAgentCards: false,\n includeArchived: true,\n });\n return apps.some((app) => !app.isDispatch);\n } catch {\n return false;\n }\n },\n });\n\n registerOnboardingStep({\n id: \"dispatch:connect-slack-workspace\",\n title: \"Connect a Slack workspace\",\n description:\n \"Install Agent Native with OAuth, then configure channel identities and access policies.\",\n order: 60,\n required: false,\n methods: [\n {\n id: \"open-messaging\",\n kind: \"link\",\n primary: true,\n label: \"Open Messaging\",\n payload: { url: \"/messaging\", external: false },\n },\n ],\n isComplete: async () => {\n const userEmail = getRequestUserEmail();\n if (!userEmail) return false;\n const rows = await listIntegrationInstallations(\n { userEmail, orgId: getRequestOrgId() ?? null },\n \"slack\",\n ).catch(() => []);\n return rows.some((row) => row.status === \"connected\");\n },\n });\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type ProviderApiDocsOptions, type ProviderApiId, type ProviderApiMethod, type ProviderApiRequestArgs } from "@agent-native/core/provider-api";
|
|
2
2
|
export declare const DISPATCH_APP_ID = "dispatch";
|
|
3
|
-
export declare const DISPATCH_PROVIDER_API_IDS: readonly ["amplitude", "apollo", "bigquery", "commonroom", "dataforseo", "ga4", "gcloud", "github", "figma", "gmail", "gong", "google_calendar", "google_drive", "granola", "grafana", "hubspot", "jira", "mixpanel", "notion", "posthog", "prometheus", "pylon", "sentry", "slack", "stripe", "twitter"];
|
|
3
|
+
export declare const DISPATCH_PROVIDER_API_IDS: readonly ["amplitude", "apollo", "bigquery", "clay", "commonroom", "dataforseo", "ga4", "gcloud", "github", "figma", "gmail", "gong", "google_calendar", "google_drive", "granola", "grafana", "hubspot", "jira", "mixpanel", "notion", "posthog", "prometheus", "pylon", "sentry", "slack", "stripe", "twitter"];
|
|
4
4
|
export type DispatchProviderApiId = ProviderApiId;
|
|
5
5
|
export type { ProviderApiMethod, ProviderApiRequestArgs };
|
|
6
6
|
export declare function listProviderApiCatalog(provider?: string): {
|
|
7
|
-
id: "amplitude" | "apollo" | "bigquery" | "commonroom" | "dataforseo" | "figma" | "ga4" | "gcloud" | "github" | "gmail" | "gong" | "google_calendar" | "google_drive" | "grafana" | "granola" | "hubspot" | "jira" | "mixpanel" | "notion" | "posthog" | "prometheus" | "pylon" | "sentry" | "slack" | "stripe" | "twitter";
|
|
7
|
+
id: "amplitude" | "apollo" | "bigquery" | "clay" | "commonroom" | "dataforseo" | "figma" | "ga4" | "gcloud" | "github" | "gmail" | "gong" | "google_calendar" | "google_drive" | "grafana" | "granola" | "hubspot" | "jira" | "mixpanel" | "notion" | "posthog" | "prometheus" | "pylon" | "sentry" | "slack" | "stripe" | "twitter";
|
|
8
8
|
label: string;
|
|
9
9
|
defaultBaseUrl: string;
|
|
10
10
|
baseUrlCredentialKey: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-api.d.ts","sourceRoot":"","sources":["../../../src/server/lib/provider-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAC;AAGzC,eAAO,MAAM,eAAe,aAAa,CAAC;AAC1C,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"provider-api.d.ts","sourceRoot":"","sources":["../../../src/server/lib/provider-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAC;AAGzC,eAAO,MAAM,eAAe,aAAa,CAAC;AAC1C,eAAO,MAAM,yBAAyB,mTAAmB,CAAC;AAC1D,MAAM,MAAM,qBAAqB,GAAG,aAAa,CAAC;AAClD,YAAY,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,CAAC;AA0C1D,wBAAgB,sBAAsB,CAAC,QAAQ,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;yBAEvD;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,sBAAsB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,oBAGvD;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,sBAAsB,oBAErE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../../src/server/plugins/integrations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../../src/server/plugins/integrations.ts"],"names":[],"mappings":"AAiDA;;;;GAIG;AACH,QAAA,MAAM,0BAA0B,aAAoB,GAAG,kBAuBtD,CAAC;eAEa,0BAA0B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createIntegrationsPlugin } from "@agent-native/core/server";
|
|
2
2
|
import { dispatchActions } from "../../actions/index.js";
|
|
3
3
|
import { getDispatchConfig } from "../index.js";
|
|
4
|
-
import { beforeDispatchProcess,
|
|
4
|
+
import { beforeDispatchProcess, resolveDispatchExecutionContext, } from "../lib/dispatch-integrations.js";
|
|
5
5
|
const dispatchIntegrationActions = {
|
|
6
6
|
...dispatchActions,
|
|
7
7
|
// Messaging integrations should use the core call-agent tool for cross-app
|
|
@@ -26,6 +26,9 @@ Default posture:
|
|
|
26
26
|
|
|
27
27
|
When a user asks for something:
|
|
28
28
|
- If it belongs to analytics, content, slides, clips, assets, etc., delegate via call-agent — do not re-implement the domain logic in dispatch.
|
|
29
|
+
- Synthetic uptime, health-check, and URL-availability monitors belong to Analytics, even when the monitored target is another app such as Clips. Delegate creation to Analytics and relay its exact monitor URL. Dispatch-native recurring jobs are for reminders, digests, and agent workflows, not HTTP uptime probes.
|
|
30
|
+
- Route by the requested artifact type, not by organization-specific names stored in code. For structured records, databases, tables, queues, boards, and intake forms, resolve the owning app and canonical destination from loaded workspace instructions/resources plus discovered app capabilities; do not assume Content, a database ID, schema, owner, or required fields. Visual designs, mockups, wireframes, screens, and interfaces belong to Design. A trusted Required target agent hint in integration context is authoritative.
|
|
31
|
+
- When delegating structured intake to the resolved owning app, preserve the exact Source thread URL and the workspace instruction context, inspect the destination's current required fields, ask only for missing values, submit once, verify the saved record, and return the exact link.
|
|
29
32
|
- In messaging integrations, use call-agent for cross-app delegation; do not use ask_app.
|
|
30
33
|
- After call-agent returns an answer, RELAY IT DIRECTLY to the user with at most a one-line preface — do not rephrase, summarize, or add commentary. The downstream agent already crafted the answer; your job is delivery, not editing. This minimizes round-trips and keeps the user-visible reply fast.
|
|
31
34
|
- Exception: if the downstream agent reports a missing model/provider credential, do not name exact env vars, Vault keys, tokens, or secrets. Say the target app needs an LLM connection and recommend connecting Builder/managed LLM for that app; keep bring-your-own provider keys as a secondary option only if the user asks.
|
|
@@ -53,7 +56,7 @@ const dispatchIntegrationsPlugin = async (nitroApp) => {
|
|
|
53
56
|
const plugin = createIntegrationsPlugin({
|
|
54
57
|
appId: "dispatch",
|
|
55
58
|
actions: dispatchIntegrationActions,
|
|
56
|
-
|
|
59
|
+
resolveExecutionContext: resolveDispatchExecutionContext,
|
|
57
60
|
beforeProcess: beforeDispatchProcess,
|
|
58
61
|
systemPrompt,
|
|
59
62
|
// Inherit the framework default (claude-sonnet-4-6 from
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../../src/server/plugins/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,0BAA0B,GAAG;IACjC,GAAG,eAAe;IAClB,2EAA2E;IAC3E,6EAA6E;IAC7E,6EAA6E;IAC7E,OAAO,EAAE;QACP,GAAG,eAAe,CAAC,OAAO;QAC1B,SAAS,EAAE,KAAK;KACjB;CACF,CAAC;AAEF,MAAM,kCAAkC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;4FAwBiD,CAAC;AAE7F;;;;GAIG;AACH,MAAM,0BAA0B,GAAG,KAAK,EAAE,QAAa,EAAE,EAAE;IACzD,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAClD,MAAM,cAAc,GAAG,YAAY,CAAC,YAAY,CAAC;IACjD,MAAM,YAAY,GAChB,OAAO,cAAc,KAAK,QAAQ;QAChC,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,OAAO,cAAc,KAAK,UAAU;YACpC,CAAC,CAAC,cAAc,CAAC,kCAAkC,CAAC;YACpD,CAAC,CAAC,kCAAkC,CAAC;IAE3C,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,KAAK,EAAE,UAAU;QACjB,OAAO,EAAE,0BAA0B;QACnC,YAAY,EAAE,oBAAoB;QAClC,aAAa,EAAE,qBAAqB;QACpC,YAAY;QACZ,wDAAwD;QACxD,yEAAyE;QACzE,+DAA+D;QAC/D,6EAA6E;KAC9E,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,eAAe,0BAA0B,CAAC","sourcesContent":["import { createIntegrationsPlugin } from \"@agent-native/core/server\";\n\nimport { dispatchActions } from \"../../actions/index.js\";\nimport { getDispatchConfig } from \"../index.js\";\nimport {\n beforeDispatchProcess,\n resolveDispatchOwner,\n} from \"../lib/dispatch-integrations.js\";\n\nconst dispatchIntegrationActions = {\n ...dispatchActions,\n // Messaging integrations should use the core call-agent tool for cross-app\n // delegation because it queues A2A continuations when serverless budgets are\n // tight. The MCP-facing ask_app action is still available outside this path.\n ask_app: {\n ...dispatchActions.ask_app,\n agentTool: false,\n },\n};\n\nconst DISPATCH_INTEGRATION_SYSTEM_PROMPT = `You are the central dispatch for this workspace, responding via a messaging platform integration (Slack, Telegram, email, etc.).\n\nDefault posture:\n- Treat Slack, Telegram, and email as shared entrypoints into the workspace.\n- Heavily delegate domain work to specialized agents through A2A (call-agent) when another app owns the job. Apps you can delegate to include slides (decks/presentations), analytics (data/dashboards), content (docs/articles), forms (form builder), clips (screen recordings), design (visual designs), and assets (brand libraries plus generated images/videos).\n- Use the available-apps prompt context first, then list-connected-agents when you need fresh details, to see what agents are available before assuming a request must be handled locally.\n- When asked whether workspace apps expose agent cards or A2A endpoints, call list-workspace-apps with includeAgentCards=true. Without that probe, missing agent-card fields mean unchecked, not unavailable.\n- Treat first-party apps such as Mail, Calendar, Analytics, Brain, Assets, and Dispatch as existing hosted/connected neighbors available through links and A2A/default connected agents. Do not create wrapper apps, child apps, nested routes, or cloned template copies just to give a new app access to them; build only the genuinely new workflow and delegate cross-app work to those existing apps.\n- Integration grants are not provider capability limits. For ad hoc provider inspection, querying, reporting, or troubleshooting, call provider-api-catalog/provider-api-docs, then provider-api-request against the provider's real HTTP API. Use connectionId for a specific shared grant and accountId for a specific OAuth account. Never expose secret values or silently widen app access while doing this.\n- Keep durable memory and operating instructions in resources rather than ephemeral chat.\n- Reply in the originating thread unless the user explicitly asks you to send to a saved destination.\n\nWhen a user asks for something:\n- If it belongs to analytics, content, slides, clips, assets, etc., delegate via call-agent — do not re-implement the domain logic in dispatch.\n- In messaging integrations, use call-agent for cross-app delegation; do not use ask_app.\n- After call-agent returns an answer, RELAY IT DIRECTLY to the user with at most a one-line preface — do not rephrase, summarize, or add commentary. The downstream agent already crafted the answer; your job is delivery, not editing. This minimizes round-trips and keeps the user-visible reply fast.\n- Exception: if the downstream agent reports a missing model/provider credential, do not name exact env vars, Vault keys, tokens, or secrets. Say the target app needs an LLM connection and recommend connecting Builder/managed LLM for that app; keep bring-your-own provider keys as a secondary option only if the user asks.\n- If the user asks to create, build, make, scaffold, or generate an \"agent\" from Dispatch chat or by tagging @agent-native in Slack, email, or Telegram, first classify the ask. If it is a simple Dispatch-native behavior like a reminder, digest, monitor, routing rule, saved instruction, or recurring workflow, create or update the recurring job/resource/destination in Dispatch. If it is a robust unique product or teammate that needs its own UI, data model, actions, integrations, or domain workflow, treat it as a new workspace app and call start-workspace-app-creation.\n- If a new-app prompt asks for access to Mail, Calendar, Analytics, Brain, Assets, or similar first-party app data/agents, keep using the existing hosted/connected app and A2A path. Do not ask Builder to scaffold those apps as children of the new app unless the user explicitly asks for a customized fork/copy.\n- If the chat template is used, treat it as scaffolding only: the finished app must be branded as the requested app with its own home screen/navigation/package metadata/manifest, and must not leave visible \"Chat\", \"Starter\", \"Blank app\", or \"New app\" UI behind.\n- If the user explicitly asks for a new app or workspace app, call start-workspace-app-creation with their prompt and include a concise generated description by default. Do not satisfy a new-app request by adding a route, page, component, or file inside apps/chat or another existing app unless the user explicitly asks to modify that existing app. If the request is too vague to classify, ask one concise follow-up. If the action returns mode \"builder\", reply with the Builder branch URL; Builder is responsible for creating the separate workspace app under apps/<app-id>, mounting it at /<app-id>, ensuring apps/<app-id>/package.json exists with name/displayName and description so Dispatch discovers it, using relative /<app-id> links instead of hardcoded localhost/dev ports, and preserving APP_BASE_PATH/VITE_APP_BASE_PATH via appBasePath() in the React Router client entry. The new app lives at the workspace root /<app-id>, NOT under /dispatch/<app-id>, /apps/<app-id>, or any other Dispatch tab — when telling the user where to find it, link to /<app-id> only. There is no separate workspace app registry to edit. If it returns mode \"local-agent\", tell the user it is ready for the local code agent and include the returned app path/prompt summary. If it returns mode \"coming-soon\", say this requires a code change and they can edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way they like; do not send them to Builder org/beta settings. If it returns mode \"builder-unavailable\", report the action's message exactly enough to preserve the missing identity/credential detail.\n- For digests, reminders, or saved behavior, prefer recurring jobs, resources, or destinations over chat replies.\n- Keep responses concise and operational — messaging platforms have character limits.\n- Use markdown sparingly (bold and lists are fine, avoid complex formatting).\n- If a task requires many steps, summarize what you did rather than streaming every detail.`;\n\n/**\n * Defer plugin construction until the Nitro plugin actually fires so the\n * config-aware system prompt resolves AFTER `setupDispatch(config)` has\n * stamped the active config (plugin module load order is not guaranteed).\n */\nconst dispatchIntegrationsPlugin = async (nitroApp: any) => {\n const { integrations = {} } = getDispatchConfig();\n const promptOverride = integrations.systemPrompt;\n const systemPrompt =\n typeof promptOverride === \"string\"\n ? promptOverride\n : typeof promptOverride === \"function\"\n ? promptOverride(DISPATCH_INTEGRATION_SYSTEM_PROMPT)\n : DISPATCH_INTEGRATION_SYSTEM_PROMPT;\n\n const plugin = createIntegrationsPlugin({\n appId: \"dispatch\",\n actions: dispatchIntegrationActions,\n resolveOwner: resolveDispatchOwner,\n beforeProcess: beforeDispatchProcess,\n systemPrompt,\n // Inherit the framework default (claude-sonnet-4-6 from\n // packages/core/src/integrations/plugin.ts). Haiku was tried for latency\n // but hallucinated URLs/IDs after delegated call-agent results\n // (e.g. inventing `https://slides.workspace.com/deck/builder-io-deck-2024`).\n });\n\n return plugin(nitroApp);\n};\n\nexport default dispatchIntegrationsPlugin;\n"]}
|
|
1
|
+
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../../src/server/plugins/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,qBAAqB,EACrB,+BAA+B,GAChC,MAAM,iCAAiC,CAAC;AAEzC,MAAM,0BAA0B,GAAG;IACjC,GAAG,eAAe;IAClB,2EAA2E;IAC3E,6EAA6E;IAC7E,6EAA6E;IAC7E,OAAO,EAAE;QACP,GAAG,eAAe,CAAC,OAAO;QAC1B,SAAS,EAAE,KAAK;KACjB;CACF,CAAC;AAEF,MAAM,kCAAkC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;4FA2BiD,CAAC;AAE7F;;;;GAIG;AACH,MAAM,0BAA0B,GAAG,KAAK,EAAE,QAAa,EAAE,EAAE;IACzD,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAClD,MAAM,cAAc,GAAG,YAAY,CAAC,YAAY,CAAC;IACjD,MAAM,YAAY,GAChB,OAAO,cAAc,KAAK,QAAQ;QAChC,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,OAAO,cAAc,KAAK,UAAU;YACpC,CAAC,CAAC,cAAc,CAAC,kCAAkC,CAAC;YACpD,CAAC,CAAC,kCAAkC,CAAC;IAE3C,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,KAAK,EAAE,UAAU;QACjB,OAAO,EAAE,0BAA0B;QACnC,uBAAuB,EAAE,+BAA+B;QACxD,aAAa,EAAE,qBAAqB;QACpC,YAAY;QACZ,wDAAwD;QACxD,yEAAyE;QACzE,+DAA+D;QAC/D,6EAA6E;KAC9E,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,eAAe,0BAA0B,CAAC","sourcesContent":["import { createIntegrationsPlugin } from \"@agent-native/core/server\";\n\nimport { dispatchActions } from \"../../actions/index.js\";\nimport { getDispatchConfig } from \"../index.js\";\nimport {\n beforeDispatchProcess,\n resolveDispatchExecutionContext,\n} from \"../lib/dispatch-integrations.js\";\n\nconst dispatchIntegrationActions = {\n ...dispatchActions,\n // Messaging integrations should use the core call-agent tool for cross-app\n // delegation because it queues A2A continuations when serverless budgets are\n // tight. The MCP-facing ask_app action is still available outside this path.\n ask_app: {\n ...dispatchActions.ask_app,\n agentTool: false,\n },\n};\n\nconst DISPATCH_INTEGRATION_SYSTEM_PROMPT = `You are the central dispatch for this workspace, responding via a messaging platform integration (Slack, Telegram, email, etc.).\n\nDefault posture:\n- Treat Slack, Telegram, and email as shared entrypoints into the workspace.\n- Heavily delegate domain work to specialized agents through A2A (call-agent) when another app owns the job. Apps you can delegate to include slides (decks/presentations), analytics (data/dashboards), content (docs/articles), forms (form builder), clips (screen recordings), design (visual designs), and assets (brand libraries plus generated images/videos).\n- Use the available-apps prompt context first, then list-connected-agents when you need fresh details, to see what agents are available before assuming a request must be handled locally.\n- When asked whether workspace apps expose agent cards or A2A endpoints, call list-workspace-apps with includeAgentCards=true. Without that probe, missing agent-card fields mean unchecked, not unavailable.\n- Treat first-party apps such as Mail, Calendar, Analytics, Brain, Assets, and Dispatch as existing hosted/connected neighbors available through links and A2A/default connected agents. Do not create wrapper apps, child apps, nested routes, or cloned template copies just to give a new app access to them; build only the genuinely new workflow and delegate cross-app work to those existing apps.\n- Integration grants are not provider capability limits. For ad hoc provider inspection, querying, reporting, or troubleshooting, call provider-api-catalog/provider-api-docs, then provider-api-request against the provider's real HTTP API. Use connectionId for a specific shared grant and accountId for a specific OAuth account. Never expose secret values or silently widen app access while doing this.\n- Keep durable memory and operating instructions in resources rather than ephemeral chat.\n- Reply in the originating thread unless the user explicitly asks you to send to a saved destination.\n\nWhen a user asks for something:\n- If it belongs to analytics, content, slides, clips, assets, etc., delegate via call-agent — do not re-implement the domain logic in dispatch.\n- Synthetic uptime, health-check, and URL-availability monitors belong to Analytics, even when the monitored target is another app such as Clips. Delegate creation to Analytics and relay its exact monitor URL. Dispatch-native recurring jobs are for reminders, digests, and agent workflows, not HTTP uptime probes.\n- Route by the requested artifact type, not by organization-specific names stored in code. For structured records, databases, tables, queues, boards, and intake forms, resolve the owning app and canonical destination from loaded workspace instructions/resources plus discovered app capabilities; do not assume Content, a database ID, schema, owner, or required fields. Visual designs, mockups, wireframes, screens, and interfaces belong to Design. A trusted Required target agent hint in integration context is authoritative.\n- When delegating structured intake to the resolved owning app, preserve the exact Source thread URL and the workspace instruction context, inspect the destination's current required fields, ask only for missing values, submit once, verify the saved record, and return the exact link.\n- In messaging integrations, use call-agent for cross-app delegation; do not use ask_app.\n- After call-agent returns an answer, RELAY IT DIRECTLY to the user with at most a one-line preface — do not rephrase, summarize, or add commentary. The downstream agent already crafted the answer; your job is delivery, not editing. This minimizes round-trips and keeps the user-visible reply fast.\n- Exception: if the downstream agent reports a missing model/provider credential, do not name exact env vars, Vault keys, tokens, or secrets. Say the target app needs an LLM connection and recommend connecting Builder/managed LLM for that app; keep bring-your-own provider keys as a secondary option only if the user asks.\n- If the user asks to create, build, make, scaffold, or generate an \"agent\" from Dispatch chat or by tagging @agent-native in Slack, email, or Telegram, first classify the ask. If it is a simple Dispatch-native behavior like a reminder, digest, monitor, routing rule, saved instruction, or recurring workflow, create or update the recurring job/resource/destination in Dispatch. If it is a robust unique product or teammate that needs its own UI, data model, actions, integrations, or domain workflow, treat it as a new workspace app and call start-workspace-app-creation.\n- If a new-app prompt asks for access to Mail, Calendar, Analytics, Brain, Assets, or similar first-party app data/agents, keep using the existing hosted/connected app and A2A path. Do not ask Builder to scaffold those apps as children of the new app unless the user explicitly asks for a customized fork/copy.\n- If the chat template is used, treat it as scaffolding only: the finished app must be branded as the requested app with its own home screen/navigation/package metadata/manifest, and must not leave visible \"Chat\", \"Starter\", \"Blank app\", or \"New app\" UI behind.\n- If the user explicitly asks for a new app or workspace app, call start-workspace-app-creation with their prompt and include a concise generated description by default. Do not satisfy a new-app request by adding a route, page, component, or file inside apps/chat or another existing app unless the user explicitly asks to modify that existing app. If the request is too vague to classify, ask one concise follow-up. If the action returns mode \"builder\", reply with the Builder branch URL; Builder is responsible for creating the separate workspace app under apps/<app-id>, mounting it at /<app-id>, ensuring apps/<app-id>/package.json exists with name/displayName and description so Dispatch discovers it, using relative /<app-id> links instead of hardcoded localhost/dev ports, and preserving APP_BASE_PATH/VITE_APP_BASE_PATH via appBasePath() in the React Router client entry. The new app lives at the workspace root /<app-id>, NOT under /dispatch/<app-id>, /apps/<app-id>, or any other Dispatch tab — when telling the user where to find it, link to /<app-id> only. There is no separate workspace app registry to edit. If it returns mode \"local-agent\", tell the user it is ready for the local code agent and include the returned app path/prompt summary. If it returns mode \"coming-soon\", say this requires a code change and they can edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way they like; do not send them to Builder org/beta settings. If it returns mode \"builder-unavailable\", report the action's message exactly enough to preserve the missing identity/credential detail.\n- For digests, reminders, or saved behavior, prefer recurring jobs, resources, or destinations over chat replies.\n- Keep responses concise and operational — messaging platforms have character limits.\n- Use markdown sparingly (bold and lists are fine, avoid complex formatting).\n- If a task requires many steps, summarize what you did rather than streaming every detail.`;\n\n/**\n * Defer plugin construction until the Nitro plugin actually fires so the\n * config-aware system prompt resolves AFTER `setupDispatch(config)` has\n * stamped the active config (plugin module load order is not guaranteed).\n */\nconst dispatchIntegrationsPlugin = async (nitroApp: any) => {\n const { integrations = {} } = getDispatchConfig();\n const promptOverride = integrations.systemPrompt;\n const systemPrompt =\n typeof promptOverride === \"string\"\n ? promptOverride\n : typeof promptOverride === \"function\"\n ? promptOverride(DISPATCH_INTEGRATION_SYSTEM_PROMPT)\n : DISPATCH_INTEGRATION_SYSTEM_PROMPT;\n\n const plugin = createIntegrationsPlugin({\n appId: \"dispatch\",\n actions: dispatchIntegrationActions,\n resolveExecutionContext: resolveDispatchExecutionContext,\n beforeProcess: beforeDispatchProcess,\n systemPrompt,\n // Inherit the framework default (claude-sonnet-4-6 from\n // packages/core/src/integrations/plugin.ts). Haiku was tried for latency\n // but hallucinated URLs/IDs after delegated call-agent results\n // (e.g. inventing `https://slides.workspace.com/deck/builder-io-deck-2024`).\n });\n\n return plugin(nitroApp);\n};\n\nexport default dispatchIntegrationsPlugin;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/dispatch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Dispatch — workspace control plane for agent-native apps. Vault, integrations, destinations, scheduled jobs, and cross-app delegation, shipped as a single drop-in package.",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"typescript-7": "npm:typescript@^7.0.2",
|
|
95
95
|
"vite": "8.1.0",
|
|
96
96
|
"vitest": "^4.1.5",
|
|
97
|
-
"@agent-native/core": "0.
|
|
97
|
+
"@agent-native/core": "0.93.0"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
100
100
|
"@agent-native/core": ">=0.8.0",
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
buildProviderApiAuditSummary,
|
|
5
|
+
sanitizeProviderApiAuditPath,
|
|
6
|
+
} from "./provider-api-audit.js";
|
|
7
|
+
|
|
8
|
+
describe("provider API audit summaries", () => {
|
|
9
|
+
it("redacts every query value from relative and absolute request paths", () => {
|
|
10
|
+
expect(
|
|
11
|
+
sanitizeProviderApiAuditPath(
|
|
12
|
+
"/v1/resources?api_key=secret-example&cursor=page-example",
|
|
13
|
+
),
|
|
14
|
+
).toBe("/v1/resources?api_key=[redacted]&cursor=[redacted]");
|
|
15
|
+
expect(
|
|
16
|
+
sanitizeProviderApiAuditPath(
|
|
17
|
+
"https://api.example.test/download?X-Amz-Signature=signed-example&part=1",
|
|
18
|
+
),
|
|
19
|
+
).toBe(
|
|
20
|
+
"https://api.example.test/download?X-Amz-Signature=[redacted]&part=[redacted]",
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("redacts credential-named and opaque path segments", () => {
|
|
25
|
+
expect(
|
|
26
|
+
sanitizeProviderApiAuditPath(
|
|
27
|
+
"/hooks/token/secret-example-value/callback/api_key=another-example",
|
|
28
|
+
),
|
|
29
|
+
).toBe("/hooks/token/[redacted]/callback/api_key=[redacted]");
|
|
30
|
+
expect(
|
|
31
|
+
sanitizeProviderApiAuditPath(
|
|
32
|
+
"/download/0123456789abcdef0123456789abcdef/file",
|
|
33
|
+
),
|
|
34
|
+
).toBe("/download/[redacted]/file");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("drops fragments and keeps explicit query arguments out of summaries", () => {
|
|
38
|
+
const summary = buildProviderApiAuditSummary({
|
|
39
|
+
method: "get",
|
|
40
|
+
provider: "example",
|
|
41
|
+
path: "/records?filter=customer-example#secret-example-fragment",
|
|
42
|
+
query: { api_key: "query-secret-example" },
|
|
43
|
+
} as Parameters<typeof buildProviderApiAuditSummary>[0] & {
|
|
44
|
+
query: unknown;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
expect(summary).toBe("GET example /records?filter=[redacted]");
|
|
48
|
+
expect(summary).not.toContain("customer-example");
|
|
49
|
+
expect(summary).not.toContain("secret-example");
|
|
50
|
+
expect(summary).not.toContain("query-secret-example");
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const REDACTED = "[redacted]";
|
|
2
|
+
|
|
3
|
+
const CREDENTIAL_NAME =
|
|
4
|
+
/^(?:api[-_]?key|access[-_]?token|auth(?:orization)?|bearer|credential|password|secret|signature|sig|token|x-amz-credential|x-amz-signature)$/i;
|
|
5
|
+
|
|
6
|
+
function decodePathSegment(segment: string): string {
|
|
7
|
+
try {
|
|
8
|
+
return decodeURIComponent(segment);
|
|
9
|
+
} catch {
|
|
10
|
+
return segment;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function looksLikeCredentialValue(segment: string): boolean {
|
|
15
|
+
const value = decodePathSegment(segment);
|
|
16
|
+
if (/^eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(value)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
if (
|
|
20
|
+
/^(?:sk|pk|rk|ghp|github_pat|xox[baprs]|ya29|AIza)[-_][A-Za-z0-9_-]+$/i.test(
|
|
21
|
+
value,
|
|
22
|
+
)
|
|
23
|
+
) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return value.length >= 32 && /^[A-Za-z0-9._~-]+$/.test(value);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function sanitizePathname(pathname: string): string {
|
|
30
|
+
let redactNext = false;
|
|
31
|
+
return pathname
|
|
32
|
+
.split("/")
|
|
33
|
+
.map((segment) => {
|
|
34
|
+
if (!segment) return segment;
|
|
35
|
+
const decoded = decodePathSegment(segment);
|
|
36
|
+
if (redactNext) {
|
|
37
|
+
redactNext = false;
|
|
38
|
+
return REDACTED;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const assignment = decoded.match(/^([^=:]+)([=:])(.+)$/);
|
|
42
|
+
if (assignment && CREDENTIAL_NAME.test(assignment[1]!)) {
|
|
43
|
+
return `${assignment[1]}${assignment[2]}${REDACTED}`;
|
|
44
|
+
}
|
|
45
|
+
if (CREDENTIAL_NAME.test(decoded)) {
|
|
46
|
+
redactNext = true;
|
|
47
|
+
return segment;
|
|
48
|
+
}
|
|
49
|
+
return looksLikeCredentialValue(segment) ? REDACTED : segment;
|
|
50
|
+
})
|
|
51
|
+
.join("/");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function sanitizeQuery(search: string): string {
|
|
55
|
+
if (!search) return "";
|
|
56
|
+
const redacted = Array.from(new URLSearchParams(search).keys(), (key) => {
|
|
57
|
+
const safeKey = encodeURIComponent(key.slice(0, 100));
|
|
58
|
+
return `${safeKey}=${REDACTED}`;
|
|
59
|
+
});
|
|
60
|
+
return redacted.length > 0 ? `?${redacted.join("&")}` : "";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function sanitizeProviderApiAuditPath(path: unknown): string {
|
|
64
|
+
const raw = String(path ?? "");
|
|
65
|
+
const withoutFragment = raw.split("#", 1)[0] ?? "";
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const url = new URL(withoutFragment);
|
|
69
|
+
return `${url.protocol}//${url.host}${sanitizePathname(url.pathname)}${sanitizeQuery(url.search)}`;
|
|
70
|
+
} catch {
|
|
71
|
+
const queryIndex = withoutFragment.indexOf("?");
|
|
72
|
+
const pathname =
|
|
73
|
+
queryIndex >= 0 ? withoutFragment.slice(0, queryIndex) : withoutFragment;
|
|
74
|
+
const search = queryIndex >= 0 ? withoutFragment.slice(queryIndex + 1) : "";
|
|
75
|
+
return `${sanitizePathname(pathname)}${sanitizeQuery(search)}`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function buildProviderApiAuditSummary(args: {
|
|
80
|
+
method?: unknown;
|
|
81
|
+
provider?: unknown;
|
|
82
|
+
path?: unknown;
|
|
83
|
+
}): string {
|
|
84
|
+
const method = String(args.method || "GET").toUpperCase();
|
|
85
|
+
const provider = String(args.provider ?? "");
|
|
86
|
+
const path = sanitizeProviderApiAuditPath(args.path);
|
|
87
|
+
return `${method} ${provider} ${path}`.slice(0, 200);
|
|
88
|
+
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
DISPATCH_APP_ID,
|
|
8
8
|
executeProviderApiRequest,
|
|
9
9
|
} from "../server/lib/provider-api.js";
|
|
10
|
+
import { buildProviderApiAuditSummary } from "./provider-api-audit.js";
|
|
10
11
|
|
|
11
12
|
const MethodSchema = z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]);
|
|
12
13
|
|
|
@@ -197,6 +198,15 @@ export default defineAction({
|
|
|
197
198
|
),
|
|
198
199
|
}),
|
|
199
200
|
http: false,
|
|
201
|
+
audit: {
|
|
202
|
+
recordInputs: false,
|
|
203
|
+
target: (args) => ({
|
|
204
|
+
type: "provider-api",
|
|
205
|
+
id: String(args.provider),
|
|
206
|
+
visibility: "private",
|
|
207
|
+
}),
|
|
208
|
+
summary: (args) => buildProviderApiAuditSummary(args),
|
|
209
|
+
},
|
|
200
210
|
run: async (args) => {
|
|
201
211
|
if (args.stageAs) {
|
|
202
212
|
const ctx = getCredentialContext();
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
const mocks = vi.hoisted(() => ({
|
|
4
|
+
getInstallation: vi.fn(),
|
|
5
|
+
resolveTokenBundle: vi.fn(),
|
|
6
|
+
resolveSecret: vi.fn(),
|
|
7
|
+
sendMessageToTarget: vi.fn(),
|
|
8
|
+
getDestinationById: vi.fn(),
|
|
9
|
+
slackAdapter: vi.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
vi.mock("@agent-native/core/integrations", () => ({
|
|
13
|
+
listIntegrationInstallations: mocks.getInstallation,
|
|
14
|
+
resolveIntegrationTokenBundle: mocks.resolveTokenBundle,
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
vi.mock("@agent-native/core/server", () => ({
|
|
18
|
+
getRequestUserEmail: () => "member@example.com",
|
|
19
|
+
getRequestOrgId: () => "org-a",
|
|
20
|
+
resolveSecret: mocks.resolveSecret,
|
|
21
|
+
isEmailConfigured: vi.fn(),
|
|
22
|
+
slackAdapter: mocks.slackAdapter,
|
|
23
|
+
telegramAdapter: vi.fn(),
|
|
24
|
+
emailAdapter: vi.fn(),
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
vi.mock("../server/lib/dispatch-store.js", () => ({
|
|
28
|
+
getDestinationById: mocks.getDestinationById,
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
const action = (await import("./send-platform-message.js")).default;
|
|
32
|
+
|
|
33
|
+
describe("send-platform-message tenant scoping", () => {
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
vi.clearAllMocks();
|
|
36
|
+
mocks.getDestinationById.mockResolvedValue(null);
|
|
37
|
+
mocks.resolveSecret.mockResolvedValue(null);
|
|
38
|
+
mocks.slackAdapter.mockImplementation(
|
|
39
|
+
(options: { resolveBotToken: () => Promise<string | undefined> }) => ({
|
|
40
|
+
formatAgentResponse: (text: string) => ({
|
|
41
|
+
text,
|
|
42
|
+
platformContext: {},
|
|
43
|
+
}),
|
|
44
|
+
sendMessageToTarget: async (...args: unknown[]) => {
|
|
45
|
+
expect(await options.resolveBotToken()).toBe("own-managed-token");
|
|
46
|
+
return mocks.sendMessageToTarget(...args);
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("resolves and uses only the caller org's Slack installation", async () => {
|
|
53
|
+
mocks.getInstallation.mockResolvedValue([
|
|
54
|
+
{
|
|
55
|
+
id: "installation-a",
|
|
56
|
+
installationKey: "team:T1:app:A1",
|
|
57
|
+
teamId: "T1",
|
|
58
|
+
enterpriseId: null,
|
|
59
|
+
},
|
|
60
|
+
]);
|
|
61
|
+
mocks.resolveTokenBundle.mockResolvedValue({
|
|
62
|
+
accessToken: "own-managed-token",
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
await action.run(
|
|
66
|
+
{
|
|
67
|
+
platform: "slack",
|
|
68
|
+
destination: "C1",
|
|
69
|
+
tenantId: "T1",
|
|
70
|
+
text: "hello",
|
|
71
|
+
},
|
|
72
|
+
{} as never,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
expect(mocks.getInstallation).toHaveBeenCalledWith(
|
|
76
|
+
{
|
|
77
|
+
userEmail: "member@example.com",
|
|
78
|
+
orgId: "org-a",
|
|
79
|
+
},
|
|
80
|
+
"slack",
|
|
81
|
+
);
|
|
82
|
+
expect(mocks.resolveTokenBundle).toHaveBeenCalledWith(
|
|
83
|
+
"slack",
|
|
84
|
+
"team:T1:app:A1",
|
|
85
|
+
);
|
|
86
|
+
expect(mocks.sendMessageToTarget).toHaveBeenCalledOnce();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("does not use another org's managed installation", async () => {
|
|
90
|
+
mocks.getInstallation.mockResolvedValue([]);
|
|
91
|
+
|
|
92
|
+
await expect(
|
|
93
|
+
action.run(
|
|
94
|
+
{
|
|
95
|
+
platform: "slack",
|
|
96
|
+
destination: "C1",
|
|
97
|
+
tenantId: "T-other",
|
|
98
|
+
text: "hello",
|
|
99
|
+
},
|
|
100
|
+
{} as never,
|
|
101
|
+
),
|
|
102
|
+
).rejects.toThrow("That Slack workspace is not connected");
|
|
103
|
+
|
|
104
|
+
expect(mocks.resolveTokenBundle).not.toHaveBeenCalled();
|
|
105
|
+
expect(mocks.slackAdapter).not.toHaveBeenCalled();
|
|
106
|
+
expect(mocks.sendMessageToTarget).not.toHaveBeenCalled();
|
|
107
|
+
});
|
|
108
|
+
});
|