@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.
- package/dist/actions/delete-destination.d.ts +12 -12
- package/dist/actions/navigate.js +1 -1
- package/dist/actions/navigate.js.map +1 -1
- 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/actions/view-screen.js +9 -0
- package/dist/actions/view-screen.js.map +1 -1
- package/dist/components/layout/Layout.d.ts.map +1 -1
- package/dist/components/layout/Layout.js +75 -70
- 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 +203 -127
- package/dist/components/messaging-setup-panel.js.map +1 -1
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +1 -0
- package/dist/routes/index.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/operations.d.ts +5 -0
- package/dist/routes/pages/operations.d.ts.map +1 -0
- package/dist/routes/pages/operations.js +51 -0
- package/dist/routes/pages/operations.js.map +1 -0
- package/dist/routes/pages/overview.d.ts +2 -2
- 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/navigate.ts +1 -1
- 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/actions/view-screen.ts +11 -0
- package/src/components/layout/Layout.spec.tsx +154 -0
- package/src/components/layout/Layout.tsx +196 -189
- package/src/components/messaging-setup-panel.spec.tsx +191 -0
- package/src/components/messaging-setup-panel.tsx +472 -193
- package/src/routes/index.spec.ts +23 -0
- package/src/routes/index.ts +1 -0
- package/src/routes/pages/messaging.tsx +1 -1
- package/src/routes/pages/operations.tsx +134 -0
- 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 +44 -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
- package/src/styles/dispatch-css.spec.ts +11 -0
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
2
2
|
id: string;
|
|
3
3
|
}, {
|
|
4
|
+
id: string;
|
|
5
|
+
ownerEmail: string;
|
|
6
|
+
orgId: string | null;
|
|
7
|
+
name: string;
|
|
8
|
+
platform: string;
|
|
9
|
+
destination: string;
|
|
10
|
+
threadRef: string | null;
|
|
11
|
+
notes: string | null;
|
|
12
|
+
createdBy: string;
|
|
13
|
+
createdAt: number;
|
|
14
|
+
updatedAt: number;
|
|
15
|
+
} | {
|
|
4
16
|
id: string;
|
|
5
17
|
ownerEmail: string;
|
|
6
18
|
orgId: string | null;
|
|
@@ -17,18 +29,6 @@ declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
|
17
29
|
reviewedAt: number | null;
|
|
18
30
|
createdAt: number;
|
|
19
31
|
updatedAt: number;
|
|
20
|
-
} | {
|
|
21
|
-
id: string;
|
|
22
|
-
ownerEmail: string;
|
|
23
|
-
orgId: string | null;
|
|
24
|
-
name: string;
|
|
25
|
-
platform: string;
|
|
26
|
-
destination: string;
|
|
27
|
-
threadRef: string | null;
|
|
28
|
-
notes: string | null;
|
|
29
|
-
createdBy: string;
|
|
30
|
-
createdAt: number;
|
|
31
|
-
updatedAt: number;
|
|
32
32
|
}>;
|
|
33
33
|
export default _default;
|
|
34
34
|
//# sourceMappingURL=delete-destination.d.ts.map
|
package/dist/actions/navigate.js
CHANGED
|
@@ -23,7 +23,7 @@ export default defineAction({
|
|
|
23
23
|
view: z
|
|
24
24
|
.string()
|
|
25
25
|
.optional()
|
|
26
|
-
.describe("Named dispatch view to navigate to. Built-in views include chat, overview, apps, metrics, new-app, vault, integrations, messaging, workspace, agents, destinations, identities, approvals, automations, audit, thread-debug, dreams, and team. Generated Dispatch extension tabs can also use their nav item id."),
|
|
26
|
+
.describe("Named dispatch view to navigate to. Built-in views include chat, overview, apps, operations (or monitoring, observability, database), metrics, new-app, vault, integrations, messaging, workspace, agents, destinations, identities, approvals, automations, audit, thread-debug, dreams, and team. Generated Dispatch extension tabs can also use their nav item id."),
|
|
27
27
|
path: z.string().optional().describe("URL path to navigate to"),
|
|
28
28
|
threadId: z
|
|
29
29
|
.string()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigate.js","sourceRoot":"","sources":["../../src/actions/navigate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,gMAAgM;IAClM,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,
|
|
1
|
+
{"version":3,"file":"navigate.js","sourceRoot":"","sources":["../../src/actions/navigate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,gMAAgM;IAClM,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,uWAAuW,CACxW;QACH,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;QAC/D,QAAQ,EAAE,CAAC;aACR,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,0CAA0C,CAAC;KACxD,CAAC;IACF,IAAI,EAAE,KAAK;IACX,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1C,OAAO,4DAA4D,CAAC;QACtE,CAAC;QACD,MAAM,GAAG,GAA2B,EAAE,CAAC;QACvC,iEAAiE;QACjE,IAAI,IAAI,CAAC,IAAI;YAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;aAC/B,IAAI,QAAQ;YAAE,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC;QACrC,IAAI,IAAI,CAAC,IAAI;YAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACpC,IAAI,QAAQ;YAAE,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACtC,MAAM,aAAa,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QACrC,OAAO,iBAAiB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,eAAe,QAAQ,EAAE,EAAE,CAAC;IAChF,CAAC;CACF,CAAC,CAAC","sourcesContent":["/**\n * Navigate the UI to a view.\n *\n * Writes a navigate command to application state which the UI reads and auto-deletes.\n *\n * Usage:\n * pnpm action navigate --view=overview\n * pnpm action navigate --view=dreams\n * pnpm action navigate --view=<custom-dispatch-extension-id>\n * pnpm action navigate --path=/some/route\n *\n * Options:\n * --view View name to navigate to\n * --path URL path to navigate to\n * --threadId Chat thread ID to open on the chat route\n */\n\nimport { defineAction } from \"@agent-native/core\";\nimport { writeAppState } from \"@agent-native/core/application-state\";\nimport { z } from \"zod\";\n\nexport default defineAction({\n description:\n \"Navigate the UI to a specific view or path. Use threadId to open a specific chat thread on the chat route. Writes a navigate command to application state which the UI reads and auto-deletes.\",\n schema: z.object({\n view: z\n .string()\n .optional()\n .describe(\n \"Named dispatch view to navigate to. Built-in views include chat, overview, apps, operations (or monitoring, observability, database), metrics, new-app, vault, integrations, messaging, workspace, agents, destinations, identities, approvals, automations, audit, thread-debug, dreams, and team. Generated Dispatch extension tabs can also use their nav item id.\",\n ),\n path: z.string().optional().describe(\"URL path to navigate to\"),\n threadId: z\n .string()\n .optional()\n .describe(\"Chat thread ID to open on the chat route\"),\n }),\n http: false,\n run: async (args) => {\n const threadId = args.threadId?.trim();\n if (!args.view && !args.path && !threadId) {\n return \"Error: At least --view, --path, or --threadId is required.\";\n }\n const nav: Record<string, string> = {};\n // A thread id without an explicit view implies the chat surface.\n if (args.view) nav.view = args.view;\n else if (threadId) nav.view = \"chat\";\n if (args.path) nav.path = args.path;\n if (threadId) nav.threadId = threadId;\n await writeAppState(\"navigate\", nav);\n return `Navigating to ${args.view || args.path || `chat thread ${threadId}`}`;\n },\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-api-audit.d.ts","sourceRoot":"","sources":["../../src/actions/provider-api-audit.ts"],"names":[],"mappings":"AA8DA,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAclE;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,GAAG,MAAM,CAKT"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const REDACTED = "[redacted]";
|
|
2
|
+
const CREDENTIAL_NAME = /^(?:api[-_]?key|access[-_]?token|auth(?:orization)?|bearer|credential|password|secret|signature|sig|token|x-amz-credential|x-amz-signature)$/i;
|
|
3
|
+
function decodePathSegment(segment) {
|
|
4
|
+
try {
|
|
5
|
+
return decodeURIComponent(segment);
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return segment;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function looksLikeCredentialValue(segment) {
|
|
12
|
+
const value = decodePathSegment(segment);
|
|
13
|
+
if (/^eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(value)) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
if (/^(?:sk|pk|rk|ghp|github_pat|xox[baprs]|ya29|AIza)[-_][A-Za-z0-9_-]+$/i.test(value)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return value.length >= 32 && /^[A-Za-z0-9._~-]+$/.test(value);
|
|
20
|
+
}
|
|
21
|
+
function sanitizePathname(pathname) {
|
|
22
|
+
let redactNext = false;
|
|
23
|
+
return pathname
|
|
24
|
+
.split("/")
|
|
25
|
+
.map((segment) => {
|
|
26
|
+
if (!segment)
|
|
27
|
+
return segment;
|
|
28
|
+
const decoded = decodePathSegment(segment);
|
|
29
|
+
if (redactNext) {
|
|
30
|
+
redactNext = false;
|
|
31
|
+
return REDACTED;
|
|
32
|
+
}
|
|
33
|
+
const assignment = decoded.match(/^([^=:]+)([=:])(.+)$/);
|
|
34
|
+
if (assignment && CREDENTIAL_NAME.test(assignment[1])) {
|
|
35
|
+
return `${assignment[1]}${assignment[2]}${REDACTED}`;
|
|
36
|
+
}
|
|
37
|
+
if (CREDENTIAL_NAME.test(decoded)) {
|
|
38
|
+
redactNext = true;
|
|
39
|
+
return segment;
|
|
40
|
+
}
|
|
41
|
+
return looksLikeCredentialValue(segment) ? REDACTED : segment;
|
|
42
|
+
})
|
|
43
|
+
.join("/");
|
|
44
|
+
}
|
|
45
|
+
function sanitizeQuery(search) {
|
|
46
|
+
if (!search)
|
|
47
|
+
return "";
|
|
48
|
+
const redacted = Array.from(new URLSearchParams(search).keys(), (key) => {
|
|
49
|
+
const safeKey = encodeURIComponent(key.slice(0, 100));
|
|
50
|
+
return `${safeKey}=${REDACTED}`;
|
|
51
|
+
});
|
|
52
|
+
return redacted.length > 0 ? `?${redacted.join("&")}` : "";
|
|
53
|
+
}
|
|
54
|
+
export function sanitizeProviderApiAuditPath(path) {
|
|
55
|
+
const raw = String(path ?? "");
|
|
56
|
+
const withoutFragment = raw.split("#", 1)[0] ?? "";
|
|
57
|
+
try {
|
|
58
|
+
const url = new URL(withoutFragment);
|
|
59
|
+
return `${url.protocol}//${url.host}${sanitizePathname(url.pathname)}${sanitizeQuery(url.search)}`;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
const queryIndex = withoutFragment.indexOf("?");
|
|
63
|
+
const pathname = queryIndex >= 0 ? withoutFragment.slice(0, queryIndex) : withoutFragment;
|
|
64
|
+
const search = queryIndex >= 0 ? withoutFragment.slice(queryIndex + 1) : "";
|
|
65
|
+
return `${sanitizePathname(pathname)}${sanitizeQuery(search)}`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function buildProviderApiAuditSummary(args) {
|
|
69
|
+
const method = String(args.method || "GET").toUpperCase();
|
|
70
|
+
const provider = String(args.provider ?? "");
|
|
71
|
+
const path = sanitizeProviderApiAuditPath(args.path);
|
|
72
|
+
return `${method} ${provider} ${path}`.slice(0, 200);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=provider-api-audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-api-audit.js","sourceRoot":"","sources":["../../src/actions/provider-api-audit.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,YAAY,CAAC;AAE9B,MAAM,eAAe,GACnB,+IAA+I,CAAC;AAElJ,SAAS,iBAAiB,CAAC,OAAe;IACxC,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,OAAe;IAC/C,MAAM,KAAK,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACzC,IAAI,qDAAqD,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACtE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IACE,uEAAuE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gBAAgB,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;IACjE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,IAI5C;IACC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,OAAO,GAAG,MAAM,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACvD,CAAC","sourcesContent":["const REDACTED = \"[redacted]\";\n\nconst CREDENTIAL_NAME =\n /^(?:api[-_]?key|access[-_]?token|auth(?:orization)?|bearer|credential|password|secret|signature|sig|token|x-amz-credential|x-amz-signature)$/i;\n\nfunction decodePathSegment(segment: string): string {\n try {\n return decodeURIComponent(segment);\n } catch {\n return segment;\n }\n}\n\nfunction looksLikeCredentialValue(segment: string): boolean {\n const value = decodePathSegment(segment);\n if (/^eyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$/.test(value)) {\n return true;\n }\n if (\n /^(?:sk|pk|rk|ghp|github_pat|xox[baprs]|ya29|AIza)[-_][A-Za-z0-9_-]+$/i.test(\n value,\n )\n ) {\n return true;\n }\n return value.length >= 32 && /^[A-Za-z0-9._~-]+$/.test(value);\n}\n\nfunction sanitizePathname(pathname: string): string {\n let redactNext = false;\n return pathname\n .split(\"/\")\n .map((segment) => {\n if (!segment) return segment;\n const decoded = decodePathSegment(segment);\n if (redactNext) {\n redactNext = false;\n return REDACTED;\n }\n\n const assignment = decoded.match(/^([^=:]+)([=:])(.+)$/);\n if (assignment && CREDENTIAL_NAME.test(assignment[1]!)) {\n return `${assignment[1]}${assignment[2]}${REDACTED}`;\n }\n if (CREDENTIAL_NAME.test(decoded)) {\n redactNext = true;\n return segment;\n }\n return looksLikeCredentialValue(segment) ? REDACTED : segment;\n })\n .join(\"/\");\n}\n\nfunction sanitizeQuery(search: string): string {\n if (!search) return \"\";\n const redacted = Array.from(new URLSearchParams(search).keys(), (key) => {\n const safeKey = encodeURIComponent(key.slice(0, 100));\n return `${safeKey}=${REDACTED}`;\n });\n return redacted.length > 0 ? `?${redacted.join(\"&\")}` : \"\";\n}\n\nexport function sanitizeProviderApiAuditPath(path: unknown): string {\n const raw = String(path ?? \"\");\n const withoutFragment = raw.split(\"#\", 1)[0] ?? \"\";\n\n try {\n const url = new URL(withoutFragment);\n return `${url.protocol}//${url.host}${sanitizePathname(url.pathname)}${sanitizeQuery(url.search)}`;\n } catch {\n const queryIndex = withoutFragment.indexOf(\"?\");\n const pathname =\n queryIndex >= 0 ? withoutFragment.slice(0, queryIndex) : withoutFragment;\n const search = queryIndex >= 0 ? withoutFragment.slice(queryIndex + 1) : \"\";\n return `${sanitizePathname(pathname)}${sanitizeQuery(search)}`;\n }\n}\n\nexport function buildProviderApiAuditSummary(args: {\n method?: unknown;\n provider?: unknown;\n path?: unknown;\n}): string {\n const method = String(args.method || \"GET\").toUpperCase();\n const provider = String(args.provider ?? \"\");\n const path = sanitizeProviderApiAuditPath(args.path);\n return `${method} ${provider} ${path}`.slice(0, 200);\n}\n"]}
|
|
@@ -2,7 +2,7 @@ declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
|
2
2
|
provider?: string | undefined;
|
|
3
3
|
}, {
|
|
4
4
|
providers: unknown[] | {
|
|
5
|
-
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";
|
|
5
|
+
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";
|
|
6
6
|
label: string;
|
|
7
7
|
defaultBaseUrl: string;
|
|
8
8
|
baseUrlCredentialKey: string;
|
|
@@ -3,6 +3,7 @@ import { stagingExecuteRequest } from "@agent-native/core/provider-api/staging";
|
|
|
3
3
|
import { getCredentialContext } from "@agent-native/core/server/request-context";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { DISPATCH_APP_ID, executeProviderApiRequest, } from "../server/lib/provider-api.js";
|
|
6
|
+
import { buildProviderApiAuditSummary } from "./provider-api-audit.js";
|
|
6
7
|
const MethodSchema = z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]);
|
|
7
8
|
const PaginationSchema = z
|
|
8
9
|
.object({
|
|
@@ -139,6 +140,15 @@ export default defineAction({
|
|
|
139
140
|
.describe("Enable cursor-based pagination. After each response, reads cursorPath from the JSON body and re-issues the request with cursorParam or cursorBodyPath set, accumulating items from itemsPath (or whole bodies) until cursor is empty or maxPages is reached. Combine with saveToFile to write the full dataset to a workspace file."),
|
|
140
141
|
}),
|
|
141
142
|
http: false,
|
|
143
|
+
audit: {
|
|
144
|
+
recordInputs: false,
|
|
145
|
+
target: (args) => ({
|
|
146
|
+
type: "provider-api",
|
|
147
|
+
id: String(args.provider),
|
|
148
|
+
visibility: "private",
|
|
149
|
+
}),
|
|
150
|
+
summary: (args) => buildProviderApiAuditSummary(args),
|
|
151
|
+
},
|
|
142
152
|
run: async (args) => {
|
|
143
153
|
if (args.stageAs) {
|
|
144
154
|
const ctx = getCredentialContext();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-api-request.js","sourceRoot":"","sources":["../../src/actions/provider-api-request.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est } from \"@agent-native/core/provider-api/staging\";\nimport { getCredentialContext } from \"@agent-native/core/server/request-context\";\nimport { z } from \"zod\";\n\nimport {\n DISPATCH_APP_ID,\n executeProviderApiRequest,\n} from \"../server/lib/provider-api.js\";\n\nconst MethodSchema = z.enum([\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\", \"HEAD\"]);\n\nconst PaginationSchema = z\n .object({\n nextCursorPath: z\n .string()\n .optional()\n .describe(\n \"Dot-path in the response JSON where the next cursor/token lives, e.g. 'next_cursor', 'meta.next', or 'nextPageToken'.\",\n ),\n cursorParam: z\n .string()\n .optional()\n .describe(\n \"Query parameter name to inject the cursor into the next request. Use cursorBodyPath for APIs that page through POST bodies.\",\n ),\n cursorBodyPath: z\n .string()\n .optional()\n .describe(\n \"Dot-path in the JSON request body to set to the next cursor. Use this for POST-body pagination.\",\n ),\n pageParam: z\n .string()\n .optional()\n .describe(\n \"Use page-number mode: this query param is incremented on each page.\",\n ),\n startPage: z.coerce\n .number()\n .int()\n .optional()\n .describe(\"Starting page number for pageParam mode (default 1).\"),\n offsetParam: z\n .string()\n .optional()\n .describe(\n \"Use offset mode: this query param is incremented by pageSize on each request.\",\n ),\n pageSize: z.coerce\n .number()\n .int()\n .min(1)\n .optional()\n .describe(\n \"Expected page size for offset increments. Defaults to the actual item count of the first page.\",\n ),\n maxPages: z.coerce\n .number()\n .int()\n .min(1)\n .max(200)\n .optional()\n .describe(\"Maximum pages to fetch server-side (default 50, max 200).\"),\n })\n .optional();\n\nexport default defineAction({\n description:\n \"Make an arbitrary authenticated HTTP request to a shared workspace integration, configured provider API, or custom provider registered via provider-api-register. Use this as the flexible escape hatch when Dispatch needs a provider endpoint, filter, pagination mode, payload, or API version that no canned action models. The request is constrained to the provider host, uses configured credentials automatically, blocks private/internal URLs, and redacts secrets from responses.\",\n schema: z.object({\n provider: z\n .string()\n .min(1)\n .describe(\n \"Provider id to call — built-in (e.g. slack, github, notion, hubspot, gmail, google_drive, google_calendar, granola, stripe, jira) or a custom provider id registered via provider-api-register. Use provider-api-catalog to list available providers.\",\n ),\n method: MethodSchema.default(\"GET\").describe(\"HTTP method to use.\"),\n path: z\n .string()\n .min(1)\n .describe(\n \"Provider API path such as /search.messages, /repos/org/repo/issues, /crm/v3/objects/deals/search, or a full URL on an allowed provider host. Use placeholders from provider-api-catalog when provided.\",\n ),\n query: z\n .unknown()\n .optional()\n .describe(\n \"Optional query params as a JSON object/string. Array values produce repeated query params.\",\n ),\n headers: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Optional extra headers. Unsafe hop-by-hop headers are ignored. Auth headers are injected from stored credentials.\",\n ),\n body: z\n .unknown()\n .optional()\n .describe(\n \"Optional request body. Objects/arrays are JSON encoded; strings are sent as-is.\",\n ),\n auth: z\n .enum([\"default\", \"none\"])\n .default(\"default\")\n .describe(\n \"Use default to inject configured provider auth. Use none only for public provider endpoints that intentionally require no auth.\",\n ),\n connectionId: z\n .string()\n .optional()\n .describe(\n \"Optional shared workspace connection id to use when the provider has multiple granted connections.\",\n ),\n accountId: z\n .string()\n .optional()\n .describe(\n \"Optional OAuth account id to use for OAuth-backed providers such as Gmail, Google Calendar, or Google Drive.\",\n ),\n timeoutMs: z.coerce\n .number()\n .int()\n .min(1_000)\n .max(120_000)\n .optional()\n .describe(\"Request timeout in milliseconds. Default 30000, max 120000.\"),\n maxBytes: z.coerce\n .number()\n .int()\n .min(1_000)\n .max(4 * 1024 * 1024)\n .optional()\n .describe(\n \"Maximum response bytes to read. Default 1MB, max 4MB. Ignored when saveToFile is set (allows up to 20MB).\",\n ),\n saveToFile: z\n .string()\n .optional()\n .describe(\n \"Workspace file path to save the full response body to instead of returning it in context (e.g. 'analysis/provider-response.json'). When set, returns only a compact summary {savedTo, status, bytes, preview} and allows up to 20MB response. Useful for large datasets that would overflow context.\",\n ),\n stageAs: z\n .string()\n .min(1)\n .optional()\n .describe(\n \"When set, parse the response as an array of records and write them into a staged dataset with this name. Returns a compact summary instead of the raw body. Re-staging the same name replaces the previous dataset.\",\n ),\n itemsPath: z\n .string()\n .optional()\n .describe(\n \"Dot-path to the items array in the response JSON, e.g. 'items', 'results', or 'data'. Omit for auto-detection.\",\n ),\n pagination: PaginationSchema.describe(\n \"Pagination config for server-side fetchAll when stageAs is set. Supports cursor (nextCursorPath + cursorParam or cursorBodyPath), page, and offset modes.\",\n ),\n fetchAllPages: z\n .object({\n cursorPath: z\n .string()\n .describe(\n \"Dot-path in the JSON response body where the next-page cursor lives, e.g. 'meta.next_cursor' or 'pagination.next_page_token'.\",\n ),\n cursorParam: z\n .string()\n .optional()\n .describe(\n \"Query parameter name to pass the cursor on subsequent pages, e.g. 'cursor' or 'page_token'. Use cursorBodyPath instead for APIs that put cursors in POST bodies.\",\n ),\n cursorBodyPath: z\n .string()\n .optional()\n .describe(\n \"Dot-path in the JSON request body to set to the next cursor. Use for POST-body pagination.\",\n ),\n itemsPath: z\n .string()\n .optional()\n .describe(\n \"Dot-path to the items array in each response, e.g. 'results' or 'data.items'. When omitted, the whole response body is appended per page.\",\n ),\n maxPages: z.coerce\n .number()\n .int()\n .min(1)\n .max(50)\n .optional()\n .describe(\n \"Maximum pages to fetch. Default 10, max 50. Stops early when the cursor is empty.\",\n ),\n })\n .optional()\n .describe(\n \"Enable cursor-based pagination. After each response, reads cursorPath from the JSON body and re-issues the request with cursorParam or cursorBodyPath set, accumulating items from itemsPath (or whole bodies) until cursor is empty or maxPages is reached. Combine with saveToFile to write the full dataset to a workspace file.\",\n ),\n }),\n http: false,\n run: async (args) => {\n if (args.stageAs) {\n const ctx = getCredentialContext();\n if (!ctx) {\n throw new Error(\"No authenticated context for provider API staging.\");\n }\n return stagingExecuteRequest(\n {\n provider: args.provider,\n method: args.method,\n path: args.path,\n query: args.query,\n headers: args.headers,\n body: args.body,\n auth: args.auth,\n connectionId: args.connectionId,\n accountId: args.accountId,\n timeoutMs: args.timeoutMs,\n maxBytes: args.maxBytes,\n stageAs: args.stageAs,\n itemsPath: args.itemsPath,\n pagination: args.pagination,\n },\n (reqArgs) => executeProviderApiRequest(reqArgs),\n { appId: DISPATCH_APP_ID, ownerEmail: ctx.userEmail },\n );\n }\n return executeProviderApiRequest(\n args as unknown as Parameters<typeof executeProviderApiRequest>[0],\n );\n },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"provider-api-request.js","sourceRoot":"","sources":["../../src/actions/provider-api-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,eAAe,EACf,yBAAyB,GAC1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAEvE,MAAM,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAE/E,MAAM,gBAAgB,GAAG,CAAC;KACvB,MAAM,CAAC;IACN,cAAc,EAAE,CAAC;SACd,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,uHAAuH,CACxH;IACH,WAAW,EAAE,CAAC;SACX,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,6HAA6H,CAC9H;IACH,cAAc,EAAE,CAAC;SACd,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,iGAAiG,CAClG;IACH,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,qEAAqE,CACtE;IACH,SAAS,EAAE,CAAC,CAAC,MAAM;SAChB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,QAAQ,EAAE;SACV,QAAQ,CAAC,sD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EAAE,IAAI,CAAC,IAAI;gBACf,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,UAAU,EAAE,IAAI,CAAC,UAAU;aAC5B,EACD,CAAC,OAAO,EAAE,EAAE,CAAC,yBAAyB,CAAC,OAAO,CAAC,EAC/C,EAAE,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,CAAC,SAAS,EAAE,CACtD,CAAC;QACJ,CAAC;QACD,OAAO,yBAAyB,CAC9B,IAAkE,CACnE,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core\";\nimport { stagingExecuteRequest } from \"@agent-native/core/provider-api/staging\";\nimport { getCredentialContext } from \"@agent-native/core/server/request-context\";\nimport { z } from \"zod\";\n\nimport {\n DISPATCH_APP_ID,\n executeProviderApiRequest,\n} from \"../server/lib/provider-api.js\";\nimport { buildProviderApiAuditSummary } from \"./provider-api-audit.js\";\n\nconst MethodSchema = z.enum([\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\", \"HEAD\"]);\n\nconst PaginationSchema = z\n .object({\n nextCursorPath: z\n .string()\n .optional()\n .describe(\n \"Dot-path in the response JSON where the next cursor/token lives, e.g. 'next_cursor', 'meta.next', or 'nextPageToken'.\",\n ),\n cursorParam: z\n .string()\n .optional()\n .describe(\n \"Query parameter name to inject the cursor into the next request. Use cursorBodyPath for APIs that page through POST bodies.\",\n ),\n cursorBodyPath: z\n .string()\n .optional()\n .describe(\n \"Dot-path in the JSON request body to set to the next cursor. Use this for POST-body pagination.\",\n ),\n pageParam: z\n .string()\n .optional()\n .describe(\n \"Use page-number mode: this query param is incremented on each page.\",\n ),\n startPage: z.coerce\n .number()\n .int()\n .optional()\n .describe(\"Starting page number for pageParam mode (default 1).\"),\n offsetParam: z\n .string()\n .optional()\n .describe(\n \"Use offset mode: this query param is incremented by pageSize on each request.\",\n ),\n pageSize: z.coerce\n .number()\n .int()\n .min(1)\n .optional()\n .describe(\n \"Expected page size for offset increments. Defaults to the actual item count of the first page.\",\n ),\n maxPages: z.coerce\n .number()\n .int()\n .min(1)\n .max(200)\n .optional()\n .describe(\"Maximum pages to fetch server-side (default 50, max 200).\"),\n })\n .optional();\n\nexport default defineAction({\n description:\n \"Make an arbitrary authenticated HTTP request to a shared workspace integration, configured provider API, or custom provider registered via provider-api-register. Use this as the flexible escape hatch when Dispatch needs a provider endpoint, filter, pagination mode, payload, or API version that no canned action models. The request is constrained to the provider host, uses configured credentials automatically, blocks private/internal URLs, and redacts secrets from responses.\",\n schema: z.object({\n provider: z\n .string()\n .min(1)\n .describe(\n \"Provider id to call — built-in (e.g. slack, github, notion, hubspot, gmail, google_drive, google_calendar, granola, stripe, jira) or a custom provider id registered via provider-api-register. Use provider-api-catalog to list available providers.\",\n ),\n method: MethodSchema.default(\"GET\").describe(\"HTTP method to use.\"),\n path: z\n .string()\n .min(1)\n .describe(\n \"Provider API path such as /search.messages, /repos/org/repo/issues, /crm/v3/objects/deals/search, or a full URL on an allowed provider host. Use placeholders from provider-api-catalog when provided.\",\n ),\n query: z\n .unknown()\n .optional()\n .describe(\n \"Optional query params as a JSON object/string. Array values produce repeated query params.\",\n ),\n headers: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Optional extra headers. Unsafe hop-by-hop headers are ignored. Auth headers are injected from stored credentials.\",\n ),\n body: z\n .unknown()\n .optional()\n .describe(\n \"Optional request body. Objects/arrays are JSON encoded; strings are sent as-is.\",\n ),\n auth: z\n .enum([\"default\", \"none\"])\n .default(\"default\")\n .describe(\n \"Use default to inject configured provider auth. Use none only for public provider endpoints that intentionally require no auth.\",\n ),\n connectionId: z\n .string()\n .optional()\n .describe(\n \"Optional shared workspace connection id to use when the provider has multiple granted connections.\",\n ),\n accountId: z\n .string()\n .optional()\n .describe(\n \"Optional OAuth account id to use for OAuth-backed providers such as Gmail, Google Calendar, or Google Drive.\",\n ),\n timeoutMs: z.coerce\n .number()\n .int()\n .min(1_000)\n .max(120_000)\n .optional()\n .describe(\"Request timeout in milliseconds. Default 30000, max 120000.\"),\n maxBytes: z.coerce\n .number()\n .int()\n .min(1_000)\n .max(4 * 1024 * 1024)\n .optional()\n .describe(\n \"Maximum response bytes to read. Default 1MB, max 4MB. Ignored when saveToFile is set (allows up to 20MB).\",\n ),\n saveToFile: z\n .string()\n .optional()\n .describe(\n \"Workspace file path to save the full response body to instead of returning it in context (e.g. 'analysis/provider-response.json'). When set, returns only a compact summary {savedTo, status, bytes, preview} and allows up to 20MB response. Useful for large datasets that would overflow context.\",\n ),\n stageAs: z\n .string()\n .min(1)\n .optional()\n .describe(\n \"When set, parse the response as an array of records and write them into a staged dataset with this name. Returns a compact summary instead of the raw body. Re-staging the same name replaces the previous dataset.\",\n ),\n itemsPath: z\n .string()\n .optional()\n .describe(\n \"Dot-path to the items array in the response JSON, e.g. 'items', 'results', or 'data'. Omit for auto-detection.\",\n ),\n pagination: PaginationSchema.describe(\n \"Pagination config for server-side fetchAll when stageAs is set. Supports cursor (nextCursorPath + cursorParam or cursorBodyPath), page, and offset modes.\",\n ),\n fetchAllPages: z\n .object({\n cursorPath: z\n .string()\n .describe(\n \"Dot-path in the JSON response body where the next-page cursor lives, e.g. 'meta.next_cursor' or 'pagination.next_page_token'.\",\n ),\n cursorParam: z\n .string()\n .optional()\n .describe(\n \"Query parameter name to pass the cursor on subsequent pages, e.g. 'cursor' or 'page_token'. Use cursorBodyPath instead for APIs that put cursors in POST bodies.\",\n ),\n cursorBodyPath: z\n .string()\n .optional()\n .describe(\n \"Dot-path in the JSON request body to set to the next cursor. Use for POST-body pagination.\",\n ),\n itemsPath: z\n .string()\n .optional()\n .describe(\n \"Dot-path to the items array in each response, e.g. 'results' or 'data.items'. When omitted, the whole response body is appended per page.\",\n ),\n maxPages: z.coerce\n .number()\n .int()\n .min(1)\n .max(50)\n .optional()\n .describe(\n \"Maximum pages to fetch. Default 10, max 50. Stops early when the cursor is empty.\",\n ),\n })\n .optional()\n .describe(\n \"Enable cursor-based pagination. After each response, reads cursorPath from the JSON body and re-issues the request with cursorParam or cursorBodyPath set, accumulating items from itemsPath (or whole bodies) until cursor is empty or maxPages is reached. Combine with saveToFile to write the full dataset to a workspace file.\",\n ),\n }),\n http: false,\n audit: {\n recordInputs: false,\n target: (args) => ({\n type: \"provider-api\",\n id: String(args.provider),\n visibility: \"private\",\n }),\n summary: (args) => buildProviderApiAuditSummary(args),\n },\n run: async (args) => {\n if (args.stageAs) {\n const ctx = getCredentialContext();\n if (!ctx) {\n throw new Error(\"No authenticated context for provider API staging.\");\n }\n return stagingExecuteRequest(\n {\n provider: args.provider,\n method: args.method,\n path: args.path,\n query: args.query,\n headers: args.headers,\n body: args.body,\n auth: args.auth,\n connectionId: args.connectionId,\n accountId: args.accountId,\n timeoutMs: args.timeoutMs,\n maxBytes: args.maxBytes,\n stageAs: args.stageAs,\n itemsPath: args.itemsPath,\n pagination: args.pagination,\n },\n (reqArgs) => executeProviderApiRequest(reqArgs),\n { appId: DISPATCH_APP_ID, ownerEmail: ctx.userEmail },\n );\n }\n return executeProviderApiRequest(\n args as unknown as Parameters<typeof executeProviderApiRequest>[0],\n );\n },\n});\n"]}
|
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core";
|
|
2
|
-
import {
|
|
2
|
+
import { listIntegrationInstallations, resolveIntegrationTokenBundle, } from "@agent-native/core/integrations";
|
|
3
|
+
import { getRequestOrgId, getRequestUserEmail, slackAdapter, telegramAdapter, emailAdapter, isEmailConfigured, resolveSecret, } from "@agent-native/core/server";
|
|
3
4
|
import { z } from "zod";
|
|
4
|
-
import { getDestinationById
|
|
5
|
-
function getAdapter(platform) {
|
|
5
|
+
import { getDestinationById } from "../server/lib/dispatch-store.js";
|
|
6
|
+
function getAdapter(platform, slackToken) {
|
|
6
7
|
if (platform === "email")
|
|
7
8
|
return emailAdapter();
|
|
8
|
-
return platform === "slack"
|
|
9
|
+
return platform === "slack"
|
|
10
|
+
? slackAdapter({ resolveBotToken: async () => slackToken })
|
|
11
|
+
: telegramAdapter();
|
|
9
12
|
}
|
|
10
|
-
async function assertOutboundConfigured(platform) {
|
|
11
|
-
if (platform === "slack"
|
|
12
|
-
|
|
13
|
+
async function assertOutboundConfigured(platform, tenantId) {
|
|
14
|
+
if (platform === "slack") {
|
|
15
|
+
const userEmail = getRequestUserEmail();
|
|
16
|
+
if (!userEmail)
|
|
17
|
+
throw new Error("An authenticated user is required");
|
|
18
|
+
const installations = tenantId
|
|
19
|
+
? await listIntegrationInstallations({ userEmail, orgId: getRequestOrgId() ?? null }, "slack")
|
|
20
|
+
: [];
|
|
21
|
+
const installation = installations.find((candidate) => candidate.teamId === tenantId || candidate.enterpriseId === tenantId) ?? null;
|
|
22
|
+
const managed = installation
|
|
23
|
+
? await resolveIntegrationTokenBundle("slack", installation.installationKey)
|
|
24
|
+
: null;
|
|
25
|
+
const token = managed?.accessToken ?? (await resolveSecret("SLACK_BOT_TOKEN"));
|
|
26
|
+
if (!token) {
|
|
27
|
+
throw new Error(tenantId
|
|
28
|
+
? "That Slack workspace is not connected"
|
|
29
|
+
: "Select a Slack workspace for managed outbound messaging");
|
|
30
|
+
}
|
|
31
|
+
return token;
|
|
13
32
|
}
|
|
14
33
|
if (platform === "telegram" && !(await resolveSecret("TELEGRAM_BOT_TOKEN"))) {
|
|
15
34
|
throw new Error("Telegram outbound messaging is not configured");
|
|
@@ -28,9 +47,22 @@ export default defineAction({
|
|
|
28
47
|
destinationId: z.string().optional().describe("Saved destination id"),
|
|
29
48
|
destination: z.string().optional().describe("Raw platform destination id"),
|
|
30
49
|
threadRef: z.string().optional().describe("Optional thread reference"),
|
|
50
|
+
tenantId: z
|
|
51
|
+
.string()
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("Slack workspace/team id for managed installations"),
|
|
31
54
|
text: z.string().describe("Message to send"),
|
|
32
55
|
}),
|
|
33
|
-
|
|
56
|
+
audit: {
|
|
57
|
+
recordInputs: false,
|
|
58
|
+
target: (args) => ({
|
|
59
|
+
type: "destination",
|
|
60
|
+
id: args.destinationId || args.destination || "unknown",
|
|
61
|
+
visibility: "private",
|
|
62
|
+
}),
|
|
63
|
+
summary: (args) => `Sent proactive ${args.platform || "saved"} message`,
|
|
64
|
+
},
|
|
65
|
+
run: async ({ platform, destinationId, destination, threadRef, tenantId, text, }) => {
|
|
34
66
|
const saved = destinationId
|
|
35
67
|
? await getDestinationById(destinationId)
|
|
36
68
|
: null;
|
|
@@ -40,8 +72,8 @@ export default defineAction({
|
|
|
40
72
|
if (!resolvedPlatform || !resolvedDestination) {
|
|
41
73
|
throw new Error("A platform and destination are required");
|
|
42
74
|
}
|
|
43
|
-
await assertOutboundConfigured(resolvedPlatform);
|
|
44
|
-
const adapter = getAdapter(resolvedPlatform);
|
|
75
|
+
const slackToken = await assertOutboundConfigured(resolvedPlatform, tenantId);
|
|
76
|
+
const adapter = getAdapter(resolvedPlatform, slackToken);
|
|
45
77
|
if (!adapter.sendMessageToTarget) {
|
|
46
78
|
throw new Error(`Platform ${resolvedPlatform} does not support proactive outbound messaging`);
|
|
47
79
|
}
|
|
@@ -49,18 +81,7 @@ export default defineAction({
|
|
|
49
81
|
destination: resolvedDestination,
|
|
50
82
|
threadRef: resolvedThreadRef,
|
|
51
83
|
label: saved?.name || undefined,
|
|
52
|
-
|
|
53
|
-
await recordAudit({
|
|
54
|
-
action: "message.sent",
|
|
55
|
-
targetType: "destination",
|
|
56
|
-
targetId: destinationId || resolvedDestination,
|
|
57
|
-
summary: `Sent proactive ${resolvedPlatform} message${saved?.name ? ` to ${saved.name}` : ""}`,
|
|
58
|
-
metadata: {
|
|
59
|
-
platform: resolvedPlatform,
|
|
60
|
-
destination: resolvedDestination,
|
|
61
|
-
threadRef: resolvedThreadRef,
|
|
62
|
-
text,
|
|
63
|
-
},
|
|
84
|
+
tenantId,
|
|
64
85
|
});
|
|
65
86
|
return {
|
|
66
87
|
ok: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-platform-message.js","sourceRoot":"","sources":["../../src/actions/send-platform-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,GACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,
|
|
1
|
+
{"version":3,"file":"send-platform-message.js","sourceRoot":"","sources":["../../src/actions/send-platform-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,GACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,SAAS,UAAU,CACjB,QAAwC,EACxC,UAAmB;IAEnB,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,YAAY,EAAE,CAAC;IAChD,OAAO,QAAQ,KAAK,OAAO;QACzB,CAAC,CAAC,YAAY,CAAC,EAAE,eAAe,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC;QAC3D,CAAC,CAAC,eAAe,EAAE,CAAC;AACxB,CAAC;AAED,KAAK,UAAU,wBAAwB,CACrC,QAAwC,EACxC,QAAiB;IAEjB,IAAI,QAAQ,KAAK,OAAO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,kBAAkB,CAAC,aAAa,CAAC;YACzC,CAAC,CAAC,IAAI,CAAC;QACT,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,IAAI,QAAQ,CAIxC,CAAC;QACd,MAAM,mBAAmB,GAAG,KAAK,EAAE,WAAW,IAAI,WAAW,CAAC;QAC9D,MAAM,iBAAiB,GAAG,KAAK,EAAE,SAAS,IAAI,SAAS,IAAI,IAAI,CAAC;QAEhE,IAAI,CAAC,gBAAgB,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,wBAAwB,CAC/C,gBAAgB,EAChB,QAAQ,CACT,CAAC;QAEF,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CACb,YAAY,gBAAgB,gDAAgD,CAC7E,CAAC;QACJ,CAAC;QAED,MAAM,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE;YACnE,WAAW,EAAE,mBAAmB;YAChC,SAAS,EAAE,iBAAiB;YAC5B,KAAK,EAAE,KAAK,EAAE,IAAI,IAAI,SAAS;YAC/B,QAAQ;SACT,CAAC,CAAC;QAEH,OAAO;YACL,EAAE,EAAE,IAAI;YACR,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,mBAAmB;YAChC,SAAS,EAAE,iBAAiB;SAC7B,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core\";\nimport {\n listIntegrationInstallations,\n resolveIntegrationTokenBundle,\n} from \"@agent-native/core/integrations\";\nimport {\n getRequestOrgId,\n getRequestUserEmail,\n slackAdapter,\n telegramAdapter,\n emailAdapter,\n isEmailConfigured,\n resolveSecret,\n} from \"@agent-native/core/server\";\nimport { z } from \"zod\";\n\nimport { getDestinationById } from \"../server/lib/dispatch-store.js\";\n\nfunction getAdapter(\n platform: \"slack\" | \"telegram\" | \"email\",\n slackToken?: string,\n) {\n if (platform === \"email\") return emailAdapter();\n return platform === \"slack\"\n ? slackAdapter({ resolveBotToken: async () => slackToken })\n : telegramAdapter();\n}\n\nasync function assertOutboundConfigured(\n platform: \"slack\" | \"telegram\" | \"email\",\n tenantId?: string,\n): Promise<string | undefined> {\n if (platform === \"slack\") {\n const userEmail = getRequestUserEmail();\n if (!userEmail) throw new Error(\"An authenticated user is required\");\n const installations = tenantId\n ? await listIntegrationInstallations(\n { userEmail, orgId: getRequestOrgId() ?? null },\n \"slack\",\n )\n : [];\n const installation =\n installations.find(\n (candidate) =>\n candidate.teamId === tenantId || candidate.enterpriseId === tenantId,\n ) ?? null;\n const managed = installation\n ? await resolveIntegrationTokenBundle(\n \"slack\",\n installation.installationKey,\n )\n : null;\n const token =\n managed?.accessToken ?? (await resolveSecret(\"SLACK_BOT_TOKEN\"));\n if (!token) {\n throw new Error(\n tenantId\n ? \"That Slack workspace is not connected\"\n : \"Select a Slack workspace for managed outbound messaging\",\n );\n }\n return token;\n }\n if (platform === \"telegram\" && !(await resolveSecret(\"TELEGRAM_BOT_TOKEN\"))) {\n throw new Error(\"Telegram outbound messaging is not configured\");\n }\n if (platform === \"email\") {\n if (\n !(await resolveSecret(\"EMAIL_AGENT_ADDRESS\")) ||\n !(await isEmailConfigured())\n ) {\n throw new Error(\"Email outbound messaging is not configured\");\n }\n }\n}\n\nexport default defineAction({\n description:\n \"Send a proactive message to a saved Slack, Telegram, or email destination.\",\n schema: z.object({\n platform: z.enum([\"slack\", \"telegram\", \"email\"]).optional(),\n destinationId: z.string().optional().describe(\"Saved destination id\"),\n destination: z.string().optional().describe(\"Raw platform destination id\"),\n threadRef: z.string().optional().describe(\"Optional thread reference\"),\n tenantId: z\n .string()\n .optional()\n .describe(\"Slack workspace/team id for managed installations\"),\n text: z.string().describe(\"Message to send\"),\n }),\n audit: {\n recordInputs: false,\n target: (args) => ({\n type: \"destination\",\n id: args.destinationId || args.destination || \"unknown\",\n visibility: \"private\",\n }),\n summary: (args) => `Sent proactive ${args.platform || \"saved\"} message`,\n },\n run: async ({\n platform,\n destinationId,\n destination,\n threadRef,\n tenantId,\n text,\n }) => {\n const saved = destinationId\n ? await getDestinationById(destinationId)\n : null;\n const resolvedPlatform = (saved?.platform || platform) as\n | \"slack\"\n | \"telegram\"\n | \"email\"\n | undefined;\n const resolvedDestination = saved?.destination || destination;\n const resolvedThreadRef = saved?.threadRef || threadRef || null;\n\n if (!resolvedPlatform || !resolvedDestination) {\n throw new Error(\"A platform and destination are required\");\n }\n\n const slackToken = await assertOutboundConfigured(\n resolvedPlatform,\n tenantId,\n );\n\n const adapter = getAdapter(resolvedPlatform, slackToken);\n if (!adapter.sendMessageToTarget) {\n throw new Error(\n `Platform ${resolvedPlatform} does not support proactive outbound messaging`,\n );\n }\n\n await adapter.sendMessageToTarget(adapter.formatAgentResponse(text), {\n destination: resolvedDestination,\n threadRef: resolvedThreadRef,\n label: saved?.name || undefined,\n tenantId,\n });\n\n return {\n ok: true,\n platform: resolvedPlatform,\n destination: resolvedDestination,\n threadRef: resolvedThreadRef,\n };\n },\n});\n"]}
|
|
@@ -62,6 +62,15 @@ export default defineAction({
|
|
|
62
62
|
screen.connectedAgents = connectedAgents;
|
|
63
63
|
screen.mcpAppAccess = mcpAccess;
|
|
64
64
|
}
|
|
65
|
+
if (navigation?.view === "operations") {
|
|
66
|
+
const nav = navigation;
|
|
67
|
+
screen.operatorConsole = {
|
|
68
|
+
view: nav.operationsView === "database" ? "database" : "monitoring",
|
|
69
|
+
monitoring: "The shared observability dashboard provides traces, conversations, evaluations, experiments, and feedback.",
|
|
70
|
+
database: "The shared database admin is available in Code mode for table browsing and SQL inspection.",
|
|
71
|
+
relatedTools: ["thread-debug", "audit", "destinations", "automations"],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
65
74
|
if (navigation?.view === "overview" ||
|
|
66
75
|
navigation?.view === "metrics" ||
|
|
67
76
|
navigation?.view === "apps" ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-screen.js","sourceRoot":"","sources":["../../src/actions/view-screen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,4CAA4C,CAAC;AAEpD,KAAK,UAAU,sBAAsB,CACnC,IAAY,EACZ,IAA6B;IAE7B,MAAM,UAAU,GAAG,KAAK,IAAI,KAAK,CAAC;IAClC,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAI1D,CAAC;IACF,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,EAAE,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,cAAc,CAAC,IAA6B;IACnD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM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CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrC,OAAO,iDAAiD,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC;CACF,CAAC,CAAC","sourcesContent":["/**\n * See what the user is currently looking at on screen.\n *\n * Reads and returns the current navigation state from application state.\n *\n * Usage:\n * pnpm action view-screen\n */\n\nimport { defineAction } from \"@agent-native/core\";\nimport { readAppState } from \"@agent-native/core/application-state\";\nimport { z } from \"zod\";\n\nimport { listWorkspaceApps } from \"../server/lib/app-creation-store.js\";\nimport { listOverview } from \"../server/lib/dispatch-store.js\";\nimport {\n getAgentThreadDebug,\n listThreadDebugSources,\n searchAgentThreads,\n} from \"../server/lib/thread-debug-store.js\";\nimport { listDispatchUsageMetrics } from \"../server/lib/usage-metrics-store.js\";\nimport {\n listVaultOverview,\n listSecrets,\n listGrants,\n listRequests,\n getVaultAccessSettings,\n} from \"../server/lib/vault-store.js\";\nimport {\n listWorkspaceResourceOptions,\n listWorkspaceResourcesForApp,\n} from \"../server/lib/workspace-resources-store.js\";\n\nasync function runLocalDispatchAction(\n name: string,\n args: Record<string, unknown>,\n) {\n const modulePath = `./${name}.js`;\n const module = (await import(/* @vite-ignore */ modulePath)) as {\n default?: {\n run: (args: Record<string, unknown>) => unknown | Promise<unknown>;\n };\n };\n if (!module.default) throw new Error(`Dispatch action not found: ${name}`);\n return module.default.run(stripUndefined(args));\n}\n\nfunction stripUndefined(args: Record<string, unknown>) {\n return Object.fromEntries(\n Object.entries(args).filter(([, value]) => value !== undefined),\n );\n}\n\nexport default defineAction({\n description:\n \"See what the user is currently looking at in the dispatch UI, including navigation state and a compact operational summary.\",\n schema: z.object({}),\n http: false,\n run: async () => {\n const [navigation, overview, vaultOverview] = await Promise.all([\n readAppState(\"navigation\"),\n listOverview(),\n listVaultOverview(),\n ]);\n\n const screen: Record<string, unknown> = {\n counts: { ...overview.counts, ...vaultOverview },\n approvalPolicy: overview.settings,\n };\n if (navigation) screen.navigation = navigation;\n if (navigation?.view === \"chat\") {\n screen.chatSurface = {\n view: \"full-page Dispatch chat\",\n purpose:\n \"Create apps, manage workspace resources, route work to connected agents, and continue Dispatch conversations.\",\n };\n }\n if (navigation?.view === \"overview\") {\n screen.recentAudit = overview.recentAudit.slice(0, 5);\n screen.recentApprovals = overview.recentApprovals.slice(0, 5);\n }\n if (navigation?.view === \"destinations\") {\n screen.recentDestinations = overview.recentDestinations;\n }\n if (navigation?.view === \"agents\") {\n const [connectedAgents, mcpAccess] = await Promise.all([\n runLocalDispatchAction(\"list-connected-agents\", {}),\n runLocalDispatchAction(\"list-mcp-app-access\", {}),\n ]);\n screen.connectedAgents = connectedAgents;\n screen.mcpAppAccess = mcpAccess;\n }\n if (\n navigation?.view === \"overview\" ||\n navigation?.view === \"metrics\" ||\n navigation?.view === \"apps\" ||\n navigation?.view === \"new-app\"\n ) {\n const workspaceApps = await listWorkspaceApps({\n includeAgentCards: true,\n });\n screen.workspaceApps = workspaceApps;\n if (navigation?.view === \"apps\") {\n screen.workspaceAppResources = await Promise.all(\n workspaceApps\n .filter((app) => !app.isDispatch)\n .slice(0, 12)\n .map(async (app) => {\n const result = await listWorkspaceResourcesForApp(app.id);\n return {\n appId: app.id,\n appName: app.name,\n counts: result.counts,\n resources: result.resources.map((resource) => ({\n name: resource.name,\n path: resource.path,\n kind: resource.kind,\n source: resource.source,\n autoLoaded: resource.autoLoaded,\n })),\n };\n }),\n );\n }\n }\n if (navigation?.view === \"metrics\") {\n try {\n const metrics = await listDispatchUsageMetrics({ sinceDays: 30 });\n screen.usageMetrics = {\n billing: metrics.billing,\n totals: metrics.totals,\n byApp: metrics.byApp.slice(0, 8),\n byUser: metrics.byUser.slice(0, 8),\n appAccess: metrics.appAccess\n .filter((app) => !app.isDispatch)\n .slice(0, 8),\n };\n } catch (error) {\n screen.usageMetricsError =\n error instanceof Error ? error.message : String(error);\n }\n }\n if (navigation?.view === \"vault\" || navigation?.view === \"new-app\") {\n const [secrets, grants, requests, access] = await Promise.all([\n listSecrets(),\n listGrants(),\n listRequests({ status: \"pending\" }),\n getVaultAccessSettings(),\n ]);\n screen.vaultAccessMode = access.mode;\n screen.vaultSecrets = secrets.map((s) => ({\n id: s.id,\n name: s.name,\n credentialKey: s.credentialKey,\n provider: s.provider,\n }));\n screen.vaultActiveGrants = grants\n .filter((g) => g.status === \"active\")\n .map((g) => ({ secretId: g.secretId, appId: g.appId }));\n screen.vaultPendingRequests = requests;\n }\n if (navigation?.view === \"workspace\" || navigation?.view === \"new-app\") {\n screen.workspaceResources = await listWorkspaceResourceOptions();\n screen.workspaceResourceEffectiveContext = {\n action: \"get-workspace-resource-effective-context\",\n description:\n \"Preview workspace -> organization/app -> personal precedence for a resource path and optional app/user. All-app resources are inherited at runtime; selected resources are app-specific exceptions.\",\n };\n screen.workspaceResourceImpactPreview = {\n action: \"preview-workspace-resource-change\",\n description:\n \"Preview All-app reach, overrides, and approval behavior before creating, updating, or deleting a workspace resource.\",\n };\n }\n if (navigation?.view === \"thread-debug\") {\n try {\n const nav = navigation as Record<string, any>;\n screen.threadDebugSources = await listThreadDebugSources();\n if (nav.query) {\n screen.threadDebugResults = await searchAgentThreads({\n sourceId: nav.sourceId,\n query: nav.query,\n ownerEmail: nav.ownerEmail,\n limit: 10,\n });\n }\n if (nav.threadId) {\n const detail = await getAgentThreadDebug({\n sourceId: nav.sourceId,\n threadId: nav.threadId,\n ownerEmail: nav.ownerEmail,\n maxRuns: 5,\n maxEvents: 80,\n maxTraceSpans: 50,\n });\n screen.threadDebugSelection = {\n source: detail.source,\n thread: detail.thread,\n messageCount: detail.messages.length,\n runCount: detail.runs.length,\n debug: detail.debug,\n debugRuns: (detail as any).debugRuns?.slice(-5) ?? [],\n messages: detail.messages.slice(-6),\n };\n }\n } catch (error) {\n screen.threadDebugError =\n error instanceof Error ? error.message : String(error);\n }\n }\n if (navigation?.view === \"dreams\") {\n try {\n const nav = navigation as Record<string, any>;\n const [sources, candidates, dreams, settings] = await Promise.all([\n listThreadDebugSources(),\n runLocalDispatchAction(\"list-dream-candidates\", {\n sourceId: nav.sourceId,\n ownerEmail: nav.ownerEmail,\n limit: 10,\n }),\n runLocalDispatchAction(\"list-dreams\", {\n status: nav.status,\n limit: 10,\n }),\n runLocalDispatchAction(\"get-dream-settings\", {}),\n ]);\n screen.dreamSources = sources;\n screen.dreamCandidates = candidates;\n screen.latestDreams = dreams;\n screen.dreamSettings = settings;\n\n const dreamId = nav.dreamId ?? nav.id;\n if (dreamId) {\n screen.dreamDetail = await runLocalDispatchAction(\"get-dream\", {\n id: dreamId,\n });\n }\n } catch (error) {\n screen.dreamsError =\n error instanceof Error ? error.message : String(error);\n }\n }\n\n if (Object.keys(screen).length === 0) {\n return \"No application state found. Is the app running?\";\n }\n return JSON.stringify(screen, null, 2);\n },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"view-screen.js","sourceRoot":"","sources":["../../src/actions/view-screen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAA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B,sBAAsB,CAAC,uBAAuB,EAAE;wBAC9C,QAAQ,EAAE,GAAG,CAAC,QAAQ;wBACtB,UAAU,EAAE,GAAG,CAAC,UAAU;wBAC1B,KAAK,EAAE,EAAE;qBACV,CAAC;oBACF,sBAAsB,CAAC,aAAa,EAAE;wBACpC,MAAM,EAAE,GAAG,CAAC,MAAM;wBAClB,KAAK,EAAE,EAAE;qBACV,CAAC;oBACF,sBAAsB,CAAC,oBAAoB,EAAE,EAAE,CAAC;iBACjD,CAAC,CAAC;gBACH,MAAM,CAAC,YAAY,GAAG,OAAO,CAAC;gBAC9B,MAAM,CAAC,eAAe,GAAG,UAAU,CAAC;gBACpC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;gBAC7B,MAAM,CAAC,aAAa,GAAG,QAAQ,CAAC;gBAEhC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,EAAE,CAAC;gBACtC,IAAI,OAAO,EAAE,CAAC;oBACZ,MAAM,CAAC,WAAW,GAAG,MAAM,sBAAsB,CAAC,WAAW,EAAE;wBAC7D,EAAE,EAAE,OAAO;qBACZ,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,WAAW;oBAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrC,OAAO,iDAAiD,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC;CACF,CAAC,CAAC","sourcesContent":["/**\n * See what the user is currently looking at on screen.\n *\n * Reads and returns the current navigation state from application state.\n *\n * Usage:\n * pnpm action view-screen\n */\n\nimport { defineAction } from \"@agent-native/core\";\nimport { readAppState } from \"@agent-native/core/application-state\";\nimport { z } from \"zod\";\n\nimport { listWorkspaceApps } from \"../server/lib/app-creation-store.js\";\nimport { listOverview } from \"../server/lib/dispatch-store.js\";\nimport {\n getAgentThreadDebug,\n listThreadDebugSources,\n searchAgentThreads,\n} from \"../server/lib/thread-debug-store.js\";\nimport { listDispatchUsageMetrics } from \"../server/lib/usage-metrics-store.js\";\nimport {\n listVaultOverview,\n listSecrets,\n listGrants,\n listRequests,\n getVaultAccessSettings,\n} from \"../server/lib/vault-store.js\";\nimport {\n listWorkspaceResourceOptions,\n listWorkspaceResourcesForApp,\n} from \"../server/lib/workspace-resources-store.js\";\n\nasync function runLocalDispatchAction(\n name: string,\n args: Record<string, unknown>,\n) {\n const modulePath = `./${name}.js`;\n const module = (await import(/* @vite-ignore */ modulePath)) as {\n default?: {\n run: (args: Record<string, unknown>) => unknown | Promise<unknown>;\n };\n };\n if (!module.default) throw new Error(`Dispatch action not found: ${name}`);\n return module.default.run(stripUndefined(args));\n}\n\nfunction stripUndefined(args: Record<string, unknown>) {\n return Object.fromEntries(\n Object.entries(args).filter(([, value]) => value !== undefined),\n );\n}\n\nexport default defineAction({\n description:\n \"See what the user is currently looking at in the dispatch UI, including navigation state and a compact operational summary.\",\n schema: z.object({}),\n http: false,\n run: async () => {\n const [navigation, overview, vaultOverview] = await Promise.all([\n readAppState(\"navigation\"),\n listOverview(),\n listVaultOverview(),\n ]);\n\n const screen: Record<string, unknown> = {\n counts: { ...overview.counts, ...vaultOverview },\n approvalPolicy: overview.settings,\n };\n if (navigation) screen.navigation = navigation;\n if (navigation?.view === \"chat\") {\n screen.chatSurface = {\n view: \"full-page Dispatch chat\",\n purpose:\n \"Create apps, manage workspace resources, route work to connected agents, and continue Dispatch conversations.\",\n };\n }\n if (navigation?.view === \"overview\") {\n screen.recentAudit = overview.recentAudit.slice(0, 5);\n screen.recentApprovals = overview.recentApprovals.slice(0, 5);\n }\n if (navigation?.view === \"destinations\") {\n screen.recentDestinations = overview.recentDestinations;\n }\n if (navigation?.view === \"agents\") {\n const [connectedAgents, mcpAccess] = await Promise.all([\n runLocalDispatchAction(\"list-connected-agents\", {}),\n runLocalDispatchAction(\"list-mcp-app-access\", {}),\n ]);\n screen.connectedAgents = connectedAgents;\n screen.mcpAppAccess = mcpAccess;\n }\n if (navigation?.view === \"operations\") {\n const nav = navigation as { operationsView?: string };\n screen.operatorConsole = {\n view: nav.operationsView === \"database\" ? \"database\" : \"monitoring\",\n monitoring:\n \"The shared observability dashboard provides traces, conversations, evaluations, experiments, and feedback.\",\n database:\n \"The shared database admin is available in Code mode for table browsing and SQL inspection.\",\n relatedTools: [\"thread-debug\", \"audit\", \"destinations\", \"automations\"],\n };\n }\n if (\n navigation?.view === \"overview\" ||\n navigation?.view === \"metrics\" ||\n navigation?.view === \"apps\" ||\n navigation?.view === \"new-app\"\n ) {\n const workspaceApps = await listWorkspaceApps({\n includeAgentCards: true,\n });\n screen.workspaceApps = workspaceApps;\n if (navigation?.view === \"apps\") {\n screen.workspaceAppResources = await Promise.all(\n workspaceApps\n .filter((app) => !app.isDispatch)\n .slice(0, 12)\n .map(async (app) => {\n const result = await listWorkspaceResourcesForApp(app.id);\n return {\n appId: app.id,\n appName: app.name,\n counts: result.counts,\n resources: result.resources.map((resource) => ({\n name: resource.name,\n path: resource.path,\n kind: resource.kind,\n source: resource.source,\n autoLoaded: resource.autoLoaded,\n })),\n };\n }),\n );\n }\n }\n if (navigation?.view === \"metrics\") {\n try {\n const metrics = await listDispatchUsageMetrics({ sinceDays: 30 });\n screen.usageMetrics = {\n billing: metrics.billing,\n totals: metrics.totals,\n byApp: metrics.byApp.slice(0, 8),\n byUser: metrics.byUser.slice(0, 8),\n appAccess: metrics.appAccess\n .filter((app) => !app.isDispatch)\n .slice(0, 8),\n };\n } catch (error) {\n screen.usageMetricsError =\n error instanceof Error ? error.message : String(error);\n }\n }\n if (navigation?.view === \"vault\" || navigation?.view === \"new-app\") {\n const [secrets, grants, requests, access] = await Promise.all([\n listSecrets(),\n listGrants(),\n listRequests({ status: \"pending\" }),\n getVaultAccessSettings(),\n ]);\n screen.vaultAccessMode = access.mode;\n screen.vaultSecrets = secrets.map((s) => ({\n id: s.id,\n name: s.name,\n credentialKey: s.credentialKey,\n provider: s.provider,\n }));\n screen.vaultActiveGrants = grants\n .filter((g) => g.status === \"active\")\n .map((g) => ({ secretId: g.secretId, appId: g.appId }));\n screen.vaultPendingRequests = requests;\n }\n if (navigation?.view === \"workspace\" || navigation?.view === \"new-app\") {\n screen.workspaceResources = await listWorkspaceResourceOptions();\n screen.workspaceResourceEffectiveContext = {\n action: \"get-workspace-resource-effective-context\",\n description:\n \"Preview workspace -> organization/app -> personal precedence for a resource path and optional app/user. All-app resources are inherited at runtime; selected resources are app-specific exceptions.\",\n };\n screen.workspaceResourceImpactPreview = {\n action: \"preview-workspace-resource-change\",\n description:\n \"Preview All-app reach, overrides, and approval behavior before creating, updating, or deleting a workspace resource.\",\n };\n }\n if (navigation?.view === \"thread-debug\") {\n try {\n const nav = navigation as Record<string, any>;\n screen.threadDebugSources = await listThreadDebugSources();\n if (nav.query) {\n screen.threadDebugResults = await searchAgentThreads({\n sourceId: nav.sourceId,\n query: nav.query,\n ownerEmail: nav.ownerEmail,\n limit: 10,\n });\n }\n if (nav.threadId) {\n const detail = await getAgentThreadDebug({\n sourceId: nav.sourceId,\n threadId: nav.threadId,\n ownerEmail: nav.ownerEmail,\n maxRuns: 5,\n maxEvents: 80,\n maxTraceSpans: 50,\n });\n screen.threadDebugSelection = {\n source: detail.source,\n thread: detail.thread,\n messageCount: detail.messages.length,\n runCount: detail.runs.length,\n debug: detail.debug,\n debugRuns: (detail as any).debugRuns?.slice(-5) ?? [],\n messages: detail.messages.slice(-6),\n };\n }\n } catch (error) {\n screen.threadDebugError =\n error instanceof Error ? error.message : String(error);\n }\n }\n if (navigation?.view === \"dreams\") {\n try {\n const nav = navigation as Record<string, any>;\n const [sources, candidates, dreams, settings] = await Promise.all([\n listThreadDebugSources(),\n runLocalDispatchAction(\"list-dream-candidates\", {\n sourceId: nav.sourceId,\n ownerEmail: nav.ownerEmail,\n limit: 10,\n }),\n runLocalDispatchAction(\"list-dreams\", {\n status: nav.status,\n limit: 10,\n }),\n runLocalDispatchAction(\"get-dream-settings\", {}),\n ]);\n screen.dreamSources = sources;\n screen.dreamCandidates = candidates;\n screen.latestDreams = dreams;\n screen.dreamSettings = settings;\n\n const dreamId = nav.dreamId ?? nav.id;\n if (dreamId) {\n screen.dreamDetail = await runLocalDispatchAction(\"get-dream\", {\n id: dreamId,\n });\n }\n } catch (error) {\n screen.dreamsError =\n error instanceof Error ? error.message : String(error);\n }\n }\n\n if (Object.keys(screen).length === 0) {\n return \"No application state found. Is the app running?\";\n }\n return JSON.stringify(screen, null, 2);\n },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../../src/components/layout/Layout.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../../src/components/layout/Layout.tsx"],"names":[],"mappings":"AA2CA,OAAO,EAKL,KAAK,aAAa,EAElB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAiBf,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,YAAY,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC;IAC1C,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAEH,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,EAAE,EAAE,MAAM,CAAC;IACX,iFAAiF;IACjF,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,mFAAmF;IACnF,OAAO,CAAC,EAAE,kBAA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