@agent-native/dispatch 0.42.9-nightly-20261118063257 → 0.42.10

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 (63) hide show
  1. package/CHANGELOG.md +25 -61
  2. package/dist/actions/call_app_action.d.ts +15 -0
  3. package/dist/actions/call_app_action.d.ts.map +1 -0
  4. package/dist/actions/call_app_action.js +48 -0
  5. package/dist/actions/call_app_action.js.map +1 -0
  6. package/dist/actions/create-workspace-resource.d.ts +13 -13
  7. package/dist/actions/delete-workspace-resource.d.ts +13 -13
  8. package/dist/actions/import-agent.d.ts +13 -13
  9. package/dist/actions/index.d.ts +8 -0
  10. package/dist/actions/index.d.ts.map +1 -1
  11. package/dist/actions/index.js +31 -0
  12. package/dist/actions/index.js.map +1 -1
  13. package/dist/actions/list_app_actions.d.ts +14 -0
  14. package/dist/actions/list_app_actions.d.ts.map +1 -0
  15. package/dist/actions/list_app_actions.js +29 -0
  16. package/dist/actions/list_app_actions.js.map +1 -0
  17. package/dist/actions/read_view.d.ts +8 -0
  18. package/dist/actions/read_view.d.ts.map +1 -0
  19. package/dist/actions/read_view.js +38 -0
  20. package/dist/actions/read_view.js.map +1 -0
  21. package/dist/components/usage-alerts-panel.d.ts +6 -0
  22. package/dist/components/usage-alerts-panel.d.ts.map +1 -1
  23. package/dist/components/usage-alerts-panel.js +12 -1
  24. package/dist/components/usage-alerts-panel.js.map +1 -1
  25. package/dist/server/index.d.ts +1 -0
  26. package/dist/server/index.d.ts.map +1 -1
  27. package/dist/server/index.js +1 -0
  28. package/dist/server/index.js.map +1 -1
  29. package/dist/server/lib/app-action-result.d.ts +4 -0
  30. package/dist/server/lib/app-action-result.d.ts.map +1 -0
  31. package/dist/server/lib/app-action-result.js +15 -0
  32. package/dist/server/lib/app-action-result.js.map +1 -0
  33. package/dist/server/lib/app-creation-store.d.ts +9 -1
  34. package/dist/server/lib/app-creation-store.d.ts.map +1 -1
  35. package/dist/server/lib/app-creation-store.js +70 -7
  36. package/dist/server/lib/app-creation-store.js.map +1 -1
  37. package/dist/server/lib/mcp-gateway.d.ts +33 -0
  38. package/dist/server/lib/mcp-gateway.d.ts.map +1 -1
  39. package/dist/server/lib/mcp-gateway.js +204 -3
  40. package/dist/server/lib/mcp-gateway.js.map +1 -1
  41. package/dist/server/lib/usage-metrics-store.d.ts.map +1 -1
  42. package/dist/server/lib/usage-metrics-store.js +2 -2
  43. package/dist/server/lib/usage-metrics-store.js.map +1 -1
  44. package/dist/server/plugins/agent-chat.js +2 -2
  45. package/dist/server/plugins/agent-chat.js.map +1 -1
  46. package/package.json +4 -4
  47. package/src/actions/app_actions.spec.ts +198 -0
  48. package/src/actions/call_app_action.ts +59 -0
  49. package/src/actions/index.spec.ts +50 -2
  50. package/src/actions/index.ts +34 -0
  51. package/src/actions/list_app_actions.ts +33 -0
  52. package/src/actions/read_view.ts +46 -0
  53. package/src/components/usage-alerts-panel.tsx +17 -3
  54. package/src/server/index.ts +5 -0
  55. package/src/server/lib/app-action-result.ts +19 -0
  56. package/src/server/lib/app-creation-store.spec.ts +181 -0
  57. package/src/server/lib/app-creation-store.ts +100 -7
  58. package/src/server/lib/mcp-gateway.spec.ts +254 -0
  59. package/src/server/lib/mcp-gateway.ts +279 -2
  60. package/src/server/lib/usage-metrics-store.spec.ts +1 -0
  61. package/src/server/lib/usage-metrics-store.ts +2 -1
  62. package/src/server/plugins/agent-chat.spec.ts +4 -0
  63. package/src/server/plugins/agent-chat.ts +2 -2
@@ -72,6 +72,39 @@ export declare function openGrantedDispatchMcpApp(input: {
72
72
  embedExpiresAt?: number;
73
73
  embedUnavailable?: string;
74
74
  }>;
75
+ export type GrantedAppAction = {
76
+ name: string;
77
+ description: string;
78
+ inputSchema?: Record<string, unknown>;
79
+ readOnly?: boolean;
80
+ };
81
+ export type GrantedAppActionResult = {
82
+ isError?: boolean;
83
+ approvalReview?: {
84
+ url?: string;
85
+ expiresAt?: number;
86
+ };
87
+ structuredContent?: unknown;
88
+ content: unknown[];
89
+ };
90
+ export declare function dispatchDirectAppActionsEnabled(): boolean;
91
+ /** One direct app action connection, as a header provider sees it before it opens. */
92
+ export interface DispatchAppActionRequest {
93
+ app: string;
94
+ /** The action about to be called; undefined when only listing actions. */
95
+ action: string | undefined;
96
+ ownerEmail: string;
97
+ orgId?: string;
98
+ }
99
+ export type DispatchAppActionHeaderProvider = (request: DispatchAppActionRequest) => Record<string, string> | undefined | Promise<Record<string, string> | undefined>;
100
+ /**
101
+ * Let the deployment add headers to direct app action connections, such as a
102
+ * per-turn grant the target app's MCP turn grant admitter recognizes. Returns
103
+ * a function that removes it.
104
+ */
105
+ export declare function setDispatchAppActionHeaderProvider(provider: DispatchAppActionHeaderProvider): () => void;
106
+ export declare function listGrantedDispatchMcpAppActions(app: string, names?: string[]): Promise<GrantedAppAction[]>;
107
+ export declare function callGrantedDispatchMcpAppAction(app: string, action: string, args: Record<string, unknown>): Promise<GrantedAppActionResult>;
75
108
  export declare function createGrantedDispatchMcpEmbedSession(input: {
76
109
  app?: string;
77
110
  url?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-gateway.d.ts","sourceRoot":"","sources":["../../../src/server/lib/mcp-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,2BAA2B,EAChC,KAAK,IAAI,EACV,MAAM,wBAAwB,CAAC;AAqChC,OAAO,EAGL,KAAK,4BAA4B,EAClC,MAAM,uBAAuB,CAAC;AAiC/B,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AA2DD,KAAK,u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AAK,EAAE;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,GAAG,OAAO,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC,CAKD;AAED,wBAAsB,iDAAiD,CACrE,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IACT,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC,CAmBD"}
@@ -1,7 +1,8 @@
1
1
  import { A2AClient, canonicalA2AAudience, extractA2APersistedMutationReceipts, getGlobalA2ASecret, signA2AOrgMemberDelegationToken, signA2AOrganizationToken, signA2AToken, stripA2APersistedArtifactMarkers, } from "@agent-native/core/a2a";
2
+ import { fail } from "@agent-native/core/action";
2
3
  import { getAppConfig } from "@agent-native/core/app-config";
3
4
  import { isFeatureFlagEnabled } from "@agent-native/core/feature-flags";
4
- import { buildMcpToolName, McpClientManager, } from "@agent-native/core/mcp-client";
5
+ import { buildMcpToolName, McpClientManager, mcpToolCallWasNotSent, } from "@agent-native/core/mcp-client";
5
6
  import { getOrgA2ASecret, getOrgDomain } from "@agent-native/core/org";
6
7
  import { buildDeepLink, buildEmbedStartPath, createEmbedSessionTicket, FULL_APP_EMBED_SCOPE, getAppProductionUrl, getConfiguredAppBasePath, getRequestContext, getRequestOrgId, getRequestUserEmail, resolveAppRuntimeUrl, } from "@agent-native/core/server";
7
8
  import { discoverAgents, getBuiltinAgents, } from "@agent-native/core/server/agent-discovery";
@@ -610,7 +611,9 @@ function toAccessibleApp(agent, settings) {
610
611
  return {
611
612
  id: agent.id,
612
613
  name: agent.name,
613
- description: agent.description,
614
+ // Deployment manifest and directory entries may omit a description even
615
+ // though the discovered type declares one.
616
+ description: typeof agent.description === "string" ? agent.description : "",
614
617
  url: projectEnvironmentUrl(agent.url),
615
618
  color: agent.color,
616
619
  granted: isAppAllowedByMcpAccess(agent.id, settings),
@@ -1122,6 +1125,203 @@ async function callTargetCreateEmbedSession(input) {
1122
1125
  }
1123
1126
  }
1124
1127
  }
1128
+ const TARGET_APP_ACTION_CONNECT_MS = 15_000;
1129
+ // Embed minting is Dispatch's own handshake with the target, not an app action.
1130
+ const TARGET_APP_HIDDEN_ACTIONS = new Set([
1131
+ "create_embed_session",
1132
+ "open_app",
1133
+ "list_apps",
1134
+ ]);
1135
+ export function dispatchDirectAppActionsEnabled() {
1136
+ return getAppConfig().dispatch.directAppActions;
1137
+ }
1138
+ let appActionHeaderProvider;
1139
+ /**
1140
+ * Let the deployment add headers to direct app action connections, such as a
1141
+ * per-turn grant the target app's MCP turn grant admitter recognizes. Returns
1142
+ * a function that removes it.
1143
+ */
1144
+ export function setDispatchAppActionHeaderProvider(provider) {
1145
+ if (appActionHeaderProvider && appActionHeaderProvider !== provider) {
1146
+ throw new Error("A Dispatch app action header provider is already registered.");
1147
+ }
1148
+ appActionHeaderProvider = provider;
1149
+ return () => {
1150
+ if (appActionHeaderProvider === provider)
1151
+ appActionHeaderProvider = undefined;
1152
+ };
1153
+ }
1154
+ async function appActionHeaders(request) {
1155
+ if (!appActionHeaderProvider)
1156
+ return {};
1157
+ const headers = await appActionHeaderProvider(request);
1158
+ if (headers === undefined)
1159
+ return {};
1160
+ for (const [name, value] of Object.entries(headers)) {
1161
+ if (name.toLowerCase() === "authorization" || typeof value !== "string") {
1162
+ throw new Error(`The app action header provider returned an invalid "${name}" header.`);
1163
+ }
1164
+ }
1165
+ return headers;
1166
+ }
1167
+ // Runs `withClient` against a connected MCP client for the granted app, signed
1168
+ // as the requesting user, the way embed sessions reach the same target. Without a
1169
+ // header provider no per-turn grant is attached, so a target action that
1170
+ // requires a user turn refuses with its own error code.
1171
+ async function withGrantedAppMcp(app, action, withClient) {
1172
+ if (!dispatchDirectAppActionsEnabled()) {
1173
+ fail("Direct app actions are not enabled on this Dispatch deployment.", {
1174
+ errorCode: "direct_app_actions_disabled",
1175
+ statusCode: 403,
1176
+ });
1177
+ }
1178
+ const target = await resolveGrantedDispatchMcpApp(app);
1179
+ if (target.id === DISPATCH_APP_ID) {
1180
+ throw new Error("Dispatch's own actions are tools on this connection; call them directly.");
1181
+ }
1182
+ const ownerEmail = getRequestUserEmail();
1183
+ if (!ownerEmail)
1184
+ throw new Error("no authenticated user");
1185
+ const orgId = getRequestOrgId();
1186
+ const mcpUrl = appMcpUrl(target);
1187
+ if (!targetEndpointKeepsCredentialsPrivate(mcpUrl)) {
1188
+ throw new Error("App actions need an HTTPS target endpoint.");
1189
+ }
1190
+ const firstPartyMcp = isWorkspaceSsoAppUrl({ id: target.id, url: mcpUrl }, { nodeEnv: "production", environmentLane: requestEnvironmentLane() });
1191
+ const prepared = await createTargetMcpUserCredentials({
1192
+ mcpUrl,
1193
+ ownerEmail,
1194
+ fullCatalog: true,
1195
+ ...(firstPartyMcp ? { firstPartyMcp: true } : {}),
1196
+ ...(orgId !== undefined ? { orgId } : {}),
1197
+ });
1198
+ const credentials = [...prepared.credentials];
1199
+ const extraHeaders = await appActionHeaders({
1200
+ app: target.id,
1201
+ action,
1202
+ ownerEmail,
1203
+ ...(orgId !== undefined ? { orgId } : {}),
1204
+ });
1205
+ const serverId = "target";
1206
+ let orgMemberTried = false;
1207
+ for (const [index, credential] of credentials.entries()) {
1208
+ const manager = new McpClientManager({
1209
+ servers: {
1210
+ [serverId]: {
1211
+ type: "http",
1212
+ url: mcpUrl,
1213
+ headers: {
1214
+ ...extraHeaders,
1215
+ Authorization: `Bearer ${credential.token}`,
1216
+ ...(credential.firstPartyMcp
1217
+ ? { "x-agent-native-mcp-inline-apps": "1" }
1218
+ : {}),
1219
+ },
1220
+ },
1221
+ },
1222
+ }, { connectTimeoutMs: TARGET_APP_ACTION_CONNECT_MS });
1223
+ try {
1224
+ await manager.start();
1225
+ const status = manager.getConnectErrorStatus(serverId);
1226
+ if (status === 401 || status === 403) {
1227
+ // The org-member fallback is tried once; its own rejection is final.
1228
+ if (index === credentials.length - 1 && !orgMemberTried) {
1229
+ orgMemberTried = true;
1230
+ const orgMember = await prepared.loadOrgMemberCredential();
1231
+ if (orgMember)
1232
+ credentials.push(orgMember);
1233
+ }
1234
+ if (index < credentials.length - 1)
1235
+ continue;
1236
+ throw new Error(`The ${target.id} app rejected this connection.`);
1237
+ }
1238
+ if (!manager.hasServer(serverId)) {
1239
+ throw new Error(`The ${target.id} app's actions are unavailable.`);
1240
+ }
1241
+ return await withClient(manager, serverId);
1242
+ }
1243
+ finally {
1244
+ await manager.stop().catch((stopError) => {
1245
+ console.warn("[dispatch] Failed to stop target MCP client:", stopError);
1246
+ });
1247
+ }
1248
+ }
1249
+ throw new Error(`The ${target.id} app rejected this connection.`);
1250
+ }
1251
+ export async function listGrantedDispatchMcpAppActions(app, names) {
1252
+ return withGrantedAppMcp(app, undefined, async (manager, serverId) => manager
1253
+ .getToolsForServer(serverId)
1254
+ .filter((tool) => !TARGET_APP_HIDDEN_ACTIONS.has(tool.originalName))
1255
+ .map((tool) => {
1256
+ const detailed = names?.includes(tool.originalName) === true;
1257
+ return {
1258
+ name: tool.originalName,
1259
+ description: detailed
1260
+ ? tool.description
1261
+ : (tool.description.split(/(?<=\.)\s/)[0] ?? "").slice(0, 160),
1262
+ ...(detailed ? { inputSchema: tool.inputSchema } : {}),
1263
+ ...(tool.annotations?.readOnlyHint === true
1264
+ ? { readOnly: true }
1265
+ : {}),
1266
+ };
1267
+ }));
1268
+ }
1269
+ function approvalReviewFrom(result) {
1270
+ const meta = "_meta" in result ? result._meta : undefined;
1271
+ const review = meta !== null && typeof meta === "object"
1272
+ ? meta["agent-native/approvalReview"]
1273
+ : undefined;
1274
+ if (review === null || typeof review !== "object")
1275
+ return undefined;
1276
+ const { url, expiresAt } = review;
1277
+ return {
1278
+ ...(typeof url === "string" ? { url } : {}),
1279
+ ...(typeof expiresAt === "number" ? { expiresAt } : {}),
1280
+ };
1281
+ }
1282
+ export async function callGrantedDispatchMcpAppAction(app, action, args) {
1283
+ if (TARGET_APP_HIDDEN_ACTIONS.has(action)) {
1284
+ throw new Error(`"${action}" is not an app action.`);
1285
+ }
1286
+ return withGrantedAppMcp(app, action, async (manager, serverId) => {
1287
+ const toolName = buildMcpToolName(serverId, action);
1288
+ if (!manager.getTool(toolName)) {
1289
+ throw new Error(`The app has no action named "${action}". Call list_app_actions to see them.`);
1290
+ }
1291
+ let result;
1292
+ try {
1293
+ result = await manager.callTool(toolName, args);
1294
+ }
1295
+ catch (error) {
1296
+ const reason = error instanceof Error ? error.message : String(error);
1297
+ if (mcpToolCallWasNotSent(error)) {
1298
+ fail(`The app action did not run (${reason}).`, {
1299
+ errorCode: "app_action_not_sent",
1300
+ statusCode: error.statusCode === 403 ? 403 : 502,
1301
+ });
1302
+ }
1303
+ fail(`The app action failed before returning a result (${reason}). Its write outcome may be unknown; inspect the app before retrying.`, { errorCode: "app_action_outcome_unknown", statusCode: 502 });
1304
+ }
1305
+ if (result === null ||
1306
+ typeof result !== "object" ||
1307
+ !("content" in result) ||
1308
+ !Array.isArray(result.content)) {
1309
+ fail("The app action returned an unreadable result. Its write outcome may be unknown; inspect the app before retrying.", { errorCode: "app_action_result_unreadable", statusCode: 502 });
1310
+ }
1311
+ const approvalReview = approvalReviewFrom(result);
1312
+ return {
1313
+ ...("isError" in result && result.isError === true
1314
+ ? { isError: true }
1315
+ : {}),
1316
+ ...(approvalReview ? { approvalReview } : {}),
1317
+ ...("structuredContent" in result &&
1318
+ result.structuredContent !== undefined
1319
+ ? { structuredContent: result.structuredContent }
1320
+ : {}),
1321
+ content: result.content,
1322
+ };
1323
+ });
1324
+ }
1125
1325
  async function createTargetMcpUserCredentials(input) {
1126
1326
  const audience = canonicalA2AAudience(input.mcpUrl);
1127
1327
  if (input.runtime) {
@@ -1150,9 +1350,10 @@ async function createTargetMcpUserCredentials(input) {
1150
1350
  expiresIn: "5m",
1151
1351
  audience,
1152
1352
  preferGlobalSecret: true,
1153
- ...(input.firstPartyMcp || input.runtime
1353
+ ...(input.firstPartyMcp || input.runtime || input.fullCatalog
1154
1354
  ? {
1155
1355
  extraClaims: {
1356
+ ...(input.fullCatalog ? { catalog_scope: "full" } : {}),
1156
1357
  ...(input.firstPartyMcp
1157
1358
  ? {
1158
1359
  jti: globalThis.crypto.randomUUID(),