@agent-native/dispatch 0.13.13 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/actions/delete-destination.d.ts +12 -12
  2. package/dist/actions/navigate.js +1 -1
  3. package/dist/actions/navigate.js.map +1 -1
  4. package/dist/actions/provider-api-audit.d.ts +7 -0
  5. package/dist/actions/provider-api-audit.d.ts.map +1 -0
  6. package/dist/actions/provider-api-audit.js +74 -0
  7. package/dist/actions/provider-api-audit.js.map +1 -0
  8. package/dist/actions/provider-api-catalog.d.ts +1 -1
  9. package/dist/actions/provider-api-request.js +10 -0
  10. package/dist/actions/provider-api-request.js.map +1 -1
  11. package/dist/actions/send-platform-message.d.ts +1 -0
  12. package/dist/actions/send-platform-message.js +43 -22
  13. package/dist/actions/send-platform-message.js.map +1 -1
  14. package/dist/actions/view-screen.js +9 -0
  15. package/dist/actions/view-screen.js.map +1 -1
  16. package/dist/components/layout/Layout.d.ts.map +1 -1
  17. package/dist/components/layout/Layout.js +75 -70
  18. package/dist/components/layout/Layout.js.map +1 -1
  19. package/dist/components/messaging-setup-panel.d.ts.map +1 -1
  20. package/dist/components/messaging-setup-panel.js +203 -127
  21. package/dist/components/messaging-setup-panel.js.map +1 -1
  22. package/dist/routes/index.d.ts.map +1 -1
  23. package/dist/routes/index.js +1 -0
  24. package/dist/routes/index.js.map +1 -1
  25. package/dist/routes/pages/messaging.js +1 -1
  26. package/dist/routes/pages/messaging.js.map +1 -1
  27. package/dist/routes/pages/operations.d.ts +5 -0
  28. package/dist/routes/pages/operations.d.ts.map +1 -0
  29. package/dist/routes/pages/operations.js +51 -0
  30. package/dist/routes/pages/operations.js.map +1 -0
  31. package/dist/routes/pages/overview.d.ts +2 -2
  32. package/dist/server/lib/dispatch-integrations.d.ts +7 -1
  33. package/dist/server/lib/dispatch-integrations.d.ts.map +1 -1
  34. package/dist/server/lib/dispatch-integrations.js +178 -8
  35. package/dist/server/lib/dispatch-integrations.js.map +1 -1
  36. package/dist/server/lib/dispatch-routing.d.ts +6 -0
  37. package/dist/server/lib/dispatch-routing.d.ts.map +1 -0
  38. package/dist/server/lib/dispatch-routing.js +30 -0
  39. package/dist/server/lib/dispatch-routing.js.map +1 -0
  40. package/dist/server/lib/env-config.d.ts.map +1 -1
  41. package/dist/server/lib/env-config.js +50 -0
  42. package/dist/server/lib/env-config.js.map +1 -1
  43. package/dist/server/lib/onboarding-steps.d.ts.map +1 -1
  44. package/dist/server/lib/onboarding-steps.js +25 -0
  45. package/dist/server/lib/onboarding-steps.js.map +1 -1
  46. package/dist/server/lib/provider-api.d.ts +2 -2
  47. package/dist/server/lib/provider-api.d.ts.map +1 -1
  48. package/dist/server/plugins/integrations.d.ts.map +1 -1
  49. package/dist/server/plugins/integrations.js +5 -2
  50. package/dist/server/plugins/integrations.js.map +1 -1
  51. package/package.json +2 -2
  52. package/src/actions/navigate.ts +1 -1
  53. package/src/actions/provider-api-audit.spec.ts +52 -0
  54. package/src/actions/provider-api-audit.ts +88 -0
  55. package/src/actions/provider-api-request.ts +10 -0
  56. package/src/actions/send-platform-message.spec.ts +108 -0
  57. package/src/actions/send-platform-message.ts +73 -25
  58. package/src/actions/view-screen.ts +11 -0
  59. package/src/components/layout/Layout.spec.tsx +154 -0
  60. package/src/components/layout/Layout.tsx +196 -189
  61. package/src/components/messaging-setup-panel.spec.tsx +191 -0
  62. package/src/components/messaging-setup-panel.tsx +472 -193
  63. package/src/routes/index.spec.ts +23 -0
  64. package/src/routes/index.ts +1 -0
  65. package/src/routes/pages/messaging.tsx +1 -1
  66. package/src/routes/pages/operations.tsx +134 -0
  67. package/src/server/lib/dispatch-integrations.spec.ts +113 -0
  68. package/src/server/lib/dispatch-integrations.ts +239 -6
  69. package/src/server/lib/dispatch-routing.spec.ts +44 -0
  70. package/src/server/lib/dispatch-routing.ts +42 -0
  71. package/src/server/lib/env-config.ts +50 -0
  72. package/src/server/lib/onboarding-steps.ts +32 -0
  73. package/src/server/plugins/integrations.ts +5 -2
  74. package/src/styles/dispatch-css.spec.ts +11 -0
@@ -0,0 +1,191 @@
1
+ // @vitest-environment happy-dom
2
+ import React, { act } from "react";
3
+ import { createRoot, type Root } from "react-dom/client";
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
+
6
+ import { MessagingSetupPanel } from "./messaging-setup-panel";
7
+ import { TooltipProvider } from "./ui/tooltip";
8
+
9
+ const clientState = vi.hoisted(() => ({
10
+ statuses: [] as any[],
11
+ envStatuses: [] as any[],
12
+ }));
13
+
14
+ vi.mock("@agent-native/core/client", () => ({
15
+ disconnectManagedIntegrationInstallation: vi.fn(() => Promise.resolve()),
16
+ listManagedIntegrationBudgets: vi.fn(() => Promise.resolve([])),
17
+ listManagedIntegrationInstallations: vi.fn(() => Promise.resolve([])),
18
+ listManagedIntegrationScopes: vi.fn(() => Promise.resolve([])),
19
+ listIntegrationStatuses: vi.fn(() => Promise.resolve(clientState.statuses)),
20
+ listIntegrationEnvStatuses: vi.fn(() =>
21
+ Promise.resolve(clientState.envStatuses),
22
+ ),
23
+ managedIntegrationOAuthUrl: vi.fn(
24
+ (platform: string) => `/_agent-native/integrations/${platform}/oauth/start`,
25
+ ),
26
+ managedSlackAgentManifestUrl: vi.fn(
27
+ () => "/_agent-native/integrations/slack/manifest",
28
+ ),
29
+ saveIntegrationEnvVars: vi.fn(),
30
+ saveManagedIntegrationBudget: vi.fn(() => Promise.resolve()),
31
+ saveManagedIntegrationScope: vi.fn(() => Promise.resolve()),
32
+ setIntegrationEnabled: vi.fn(),
33
+ setupIntegration: vi.fn(),
34
+ testManagedIntegrationInstallation: vi.fn(() => Promise.resolve()),
35
+ useFormatters: () => ({
36
+ formatDate: (value: Date | number | string) =>
37
+ new Date(value).toLocaleDateString("en-US"),
38
+ }),
39
+ useT: () => (key: string) =>
40
+ (
41
+ ({
42
+ "messaging.managed.agentManifest": "Agent manifest",
43
+ "messaging.managed.agentManifestDescription":
44
+ "The Agent manifest enables Slack's Agent view and direct messages.",
45
+ "messaging.managed.addToSlack": "Add to Slack",
46
+ "messaging.managed.requiredCredentials":
47
+ "Save the required Slack app credentials below to enable Add to Slack.",
48
+ }) as Record<string, string>
49
+ )[key] ?? key,
50
+ }));
51
+
52
+ vi.mock("@agent-native/core/integrations", () => ({
53
+ listBuiltInChannelIntegrations: () => [
54
+ {
55
+ id: "slack",
56
+ name: "Slack",
57
+ iconKey: "slack",
58
+ description: "Slack description",
59
+ documentation: { href: "/docs/messaging#slack" },
60
+ setup: { steps: ["Create a Slack app."] },
61
+ credentialRequirements: [
62
+ { key: "SLACK_BOT_TOKEN", label: "Slack Bot Token", required: true },
63
+ ],
64
+ },
65
+ {
66
+ id: "email",
67
+ name: "Email",
68
+ iconKey: "email",
69
+ description: "Email description",
70
+ documentation: { href: "/docs/messaging#email" },
71
+ setup: { steps: ["Choose a provider."] },
72
+ credentialRequirements: [
73
+ {
74
+ key: "RESEND_API_KEY",
75
+ label: "Resend API Key",
76
+ required: true,
77
+ alternativeGroup: "email-provider",
78
+ },
79
+ {
80
+ key: "SENDGRID_API_KEY",
81
+ label: "SendGrid API Key",
82
+ required: true,
83
+ alternativeGroup: "email-provider",
84
+ },
85
+ ],
86
+ },
87
+ ],
88
+ }));
89
+
90
+ describe("MessagingSetupPanel", () => {
91
+ let container: HTMLDivElement;
92
+ let root: Root;
93
+
94
+ beforeEach(() => {
95
+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
96
+ clientState.statuses = [];
97
+ clientState.envStatuses = [];
98
+ container = document.createElement("div");
99
+ document.body.appendChild(container);
100
+ root = createRoot(container);
101
+ });
102
+
103
+ afterEach(() => {
104
+ act(() => root.unmount());
105
+ container.remove();
106
+ vi.unstubAllGlobals();
107
+ });
108
+
109
+ it("renders catalog-backed channel cards", async () => {
110
+ await act(async () => {
111
+ root.render(
112
+ <TooltipProvider>
113
+ <MessagingSetupPanel />
114
+ </TooltipProvider>,
115
+ );
116
+ await Promise.resolve();
117
+ });
118
+
119
+ expect(container.textContent).toContain("Slack");
120
+ expect(container.textContent).toContain("Slack description");
121
+ expect(container.textContent).toContain("Email");
122
+ expect(container.textContent).toContain("Email description");
123
+ expect(container.textContent).not.toContain("Discord");
124
+ expect(
125
+ container.querySelector(
126
+ 'a[href="/_agent-native/integrations/slack/manifest"]',
127
+ )?.textContent,
128
+ ).toContain("Agent manifest");
129
+ expect(container.textContent).toContain(
130
+ "enables Slack's Agent view and direct messages",
131
+ );
132
+ expect(
133
+ container.querySelector(
134
+ 'a[href="/_agent-native/integrations/slack/oauth/start"]',
135
+ ),
136
+ ).toBeNull();
137
+ expect(
138
+ [...container.querySelectorAll("button")].find((button) =>
139
+ button.textContent?.includes("Add to Slack"),
140
+ )?.disabled,
141
+ ).toBe(true);
142
+ expect(container.textContent).toContain(
143
+ "Save the required Slack app credentials below",
144
+ );
145
+ });
146
+
147
+ it("shows connected and alternative credential states", async () => {
148
+ clientState.statuses = [
149
+ { platform: "slack", label: "Slack", configured: true, enabled: true },
150
+ ];
151
+ clientState.envStatuses = [
152
+ {
153
+ key: "SLACK_BOT_TOKEN",
154
+ label: "Slack Bot Token",
155
+ required: true,
156
+ configured: true,
157
+ },
158
+ {
159
+ key: "RESEND_API_KEY",
160
+ label: "Resend API Key",
161
+ required: true,
162
+ configured: true,
163
+ },
164
+ {
165
+ key: "SENDGRID_API_KEY",
166
+ label: "SendGrid API Key",
167
+ required: true,
168
+ configured: false,
169
+ },
170
+ ];
171
+
172
+ await act(async () => {
173
+ root.render(
174
+ <TooltipProvider>
175
+ <MessagingSetupPanel />
176
+ </TooltipProvider>,
177
+ );
178
+ await Promise.resolve();
179
+ });
180
+
181
+ expect(container.textContent).toContain("Connected");
182
+ expect(container.textContent).toContain("Saved");
183
+ expect(
184
+ container.querySelector(
185
+ 'a[href="/_agent-native/integrations/slack/oauth/start"]',
186
+ ),
187
+ ).not.toBeNull();
188
+ expect(container.querySelectorAll("button").length).toBeGreaterThan(0);
189
+ expect(container.textContent).not.toContain("Save credentials");
190
+ });
191
+ });