@agent-native/dispatch 0.40.41-same-host-mcp-20261027-20261027081850 → 0.40.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -10
- package/dist/actions/provider-api-register.d.ts +11 -11
- package/dist/actions/upsert-destination.d.ts +12 -12
- package/dist/components/action-query-error.d.ts.map +1 -1
- package/dist/components/action-query-error.js +8 -0
- package/dist/components/action-query-error.js.map +1 -1
- package/dist/server/lib/app-creation-store.d.ts.map +1 -1
- package/dist/server/lib/app-creation-store.js +48 -3
- package/dist/server/lib/app-creation-store.js.map +1 -1
- package/dist/server/lib/mcp-gateway.d.ts +8 -0
- package/dist/server/lib/mcp-gateway.d.ts.map +1 -1
- package/dist/server/lib/mcp-gateway.js +71 -11
- package/dist/server/lib/mcp-gateway.js.map +1 -1
- package/dist/server/lib/workspace-app-chat-proxy.d.ts +6 -5
- package/dist/server/lib/workspace-app-chat-proxy.d.ts.map +1 -1
- package/dist/server/lib/workspace-app-chat-proxy.js +78 -11
- package/dist/server/lib/workspace-app-chat-proxy.js.map +1 -1
- package/dist/server/plugins/agent-chat.js +1 -0
- package/dist/server/plugins/agent-chat.js.map +1 -1
- package/package.json +3 -3
- package/src/components/action-query-error.spec.tsx +37 -0
- package/src/components/action-query-error.tsx +11 -0
- package/src/server/lib/app-creation-store.spec.ts +101 -1
- package/src/server/lib/app-creation-store.ts +65 -4
- package/src/server/lib/mcp-gateway.spec.ts +135 -1
- package/src/server/lib/mcp-gateway.ts +122 -22
- package/src/server/lib/workspace-app-chat-proxy.spec.ts +309 -5
- package/src/server/lib/workspace-app-chat-proxy.ts +123 -25
- package/src/server/plugins/agent-chat.spec.ts +1 -0
- package/src/server/plugins/agent-chat.ts +1 -0
|
@@ -81,6 +81,10 @@ export declare function createGrantedDispatchMcpEmbedSession(input: {
|
|
|
81
81
|
expiresAt?: number;
|
|
82
82
|
app: string;
|
|
83
83
|
}>;
|
|
84
|
+
export declare function createGrantedDispatchMcpEmbedSessionForWorkspaceAppChat(appId: string): Promise<{
|
|
85
|
+
startUrl: string;
|
|
86
|
+
appBaseUrl: string;
|
|
87
|
+
}>;
|
|
84
88
|
export declare function createWorkspaceSsoEmbedSession(input: {
|
|
85
89
|
app?: string;
|
|
86
90
|
url?: string;
|
|
@@ -92,5 +96,9 @@ export declare function createWorkspaceSsoEmbedSession(input: {
|
|
|
92
96
|
expiresAt?: number;
|
|
93
97
|
app: string;
|
|
94
98
|
}>;
|
|
99
|
+
export declare function createWorkspaceSsoEmbedSessionForWorkspaceAppChat(appId: string): Promise<{
|
|
100
|
+
startUrl: string;
|
|
101
|
+
appBaseUrl: string;
|
|
102
|
+
}>;
|
|
95
103
|
export {};
|
|
96
104
|
//# sourceMappingURL=mcp-gateway.d.ts.map
|
|
@@ -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;
|
|
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;AAoChC,OAAO,EAGL,KAAK,4BAA4B,EAClC,MAAM,uBAAuB,CAAC;AA8B/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;CAClB;AA2DD,KAAK,uBAAuB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AAM,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,CAID;AAED,wBAAsB,uDAAuD,CAC3E,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAOnD;AA4KD,wBAAsB,8BAA8B,CAAC,KAAK,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,CAED;AAED,wBAAsB,iDAAiD,CACrE,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAOnD"}
|
|
@@ -3,7 +3,7 @@ import { getAppConfig } from "@agent-native/core/app-config";
|
|
|
3
3
|
import { isFeatureFlagEnabled } from "@agent-native/core/feature-flags";
|
|
4
4
|
import { buildMcpToolName, McpClientManager, } from "@agent-native/core/mcp-client";
|
|
5
5
|
import { getOrgA2ASecret, getOrgDomain } from "@agent-native/core/org";
|
|
6
|
-
import { buildDeepLink, buildEmbedStartPath, createEmbedSessionTicket, getConfiguredAppBasePath, getRequestContext, getRequestOrgId, getRequestUserEmail, } from "@agent-native/core/server";
|
|
6
|
+
import { buildDeepLink, buildEmbedStartPath, createEmbedSessionTicket, getAppProductionUrl, getConfiguredAppBasePath, getRequestContext, getRequestOrgId, getRequestUserEmail, resolveAppRuntimeUrl, } from "@agent-native/core/server";
|
|
7
7
|
import { discoverAgents, getBuiltinAgents, } from "@agent-native/core/server/agent-discovery";
|
|
8
8
|
import { EMBED_START_PATH } from "@agent-native/core/shared";
|
|
9
9
|
import { DESKTOP_WORKSPACE_SSO_FLAG } from "../../shared/feature-flags.js";
|
|
@@ -326,8 +326,9 @@ function withConfiguredBasePath(baseUrl) {
|
|
|
326
326
|
}
|
|
327
327
|
function dispatchSelfBaseUrl() {
|
|
328
328
|
const requestOrigin = normalizeBaseUrl(getRequestContext()?.requestOrigin);
|
|
329
|
-
if (requestOrigin)
|
|
329
|
+
if (requestOrigin && isTrustedRequestOrigin(requestOrigin)) {
|
|
330
330
|
return withConfiguredBasePath(requestOrigin);
|
|
331
|
+
}
|
|
331
332
|
const configured = normalizeBaseUrl(process.env.WORKSPACE_GATEWAY_URL) ??
|
|
332
333
|
normalizeBaseUrl(process.env.APP_URL) ??
|
|
333
334
|
normalizeBaseUrl(process.env.URL) ??
|
|
@@ -339,6 +340,24 @@ function dispatchSelfBaseUrl() {
|
|
|
339
340
|
? "https://dispatch.agent-native.com"
|
|
340
341
|
: "http://localhost:8092";
|
|
341
342
|
}
|
|
343
|
+
function isTrustedRequestOrigin(value) {
|
|
344
|
+
// An embed ticket is fetched from this origin and becomes a bearer token.
|
|
345
|
+
const origin = new URL(value).origin;
|
|
346
|
+
const candidates = [
|
|
347
|
+
{ source: "production", value: getAppProductionUrl() },
|
|
348
|
+
{ source: "runtime", value: resolveAppRuntimeUrl() },
|
|
349
|
+
];
|
|
350
|
+
return candidates.some(({ source, value }) => {
|
|
351
|
+
if (!value)
|
|
352
|
+
return false;
|
|
353
|
+
const url = normalizeBaseUrl(value);
|
|
354
|
+
if (!url) {
|
|
355
|
+
console.warn("[dispatch] invalid configured request origin", { source });
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
return new URL(url).origin === origin;
|
|
359
|
+
});
|
|
360
|
+
}
|
|
342
361
|
function dispatchSelfApp(settings) {
|
|
343
362
|
return {
|
|
344
363
|
id: DISPATCH_APP_ID,
|
|
@@ -478,6 +497,13 @@ function appMcpBaseUrl(app) {
|
|
|
478
497
|
url.hash = "";
|
|
479
498
|
return url.toString().replace(/\/$/, "");
|
|
480
499
|
}
|
|
500
|
+
function appChatBaseUrl(app) {
|
|
501
|
+
const homeUrl = new URL(appHomeBaseUrl(app));
|
|
502
|
+
if (homeUrl.pathname !== "/") {
|
|
503
|
+
return homeUrl.toString().replace(/\/+$/, "");
|
|
504
|
+
}
|
|
505
|
+
return appMcpBaseUrl(app);
|
|
506
|
+
}
|
|
481
507
|
function resolveGrantedAppEmbedStartUrl(app, startUrl) {
|
|
482
508
|
try {
|
|
483
509
|
const baseUrl = appMcpBaseUrl(app);
|
|
@@ -1103,7 +1129,15 @@ async function createDispatchSelfEmbedSession(input) {
|
|
|
1103
1129
|
app: DISPATCH_APP_ID,
|
|
1104
1130
|
};
|
|
1105
1131
|
}
|
|
1106
|
-
|
|
1132
|
+
function publicEmbedSession({ startUrl, targetPath, expiresAt, app, }) {
|
|
1133
|
+
return {
|
|
1134
|
+
startUrl,
|
|
1135
|
+
...(targetPath ? { targetPath } : {}),
|
|
1136
|
+
...(typeof expiresAt === "number" ? { expiresAt } : {}),
|
|
1137
|
+
app,
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
async function createGrantedDispatchMcpEmbedSessionResult(input) {
|
|
1107
1141
|
const userEmail = getRequestUserEmail();
|
|
1108
1142
|
if (!userEmail)
|
|
1109
1143
|
throw new Error("no authenticated user");
|
|
@@ -1115,16 +1149,30 @@ export async function createGrantedDispatchMcpEmbedSession(input) {
|
|
|
1115
1149
|
chrome: input.chrome,
|
|
1116
1150
|
});
|
|
1117
1151
|
}
|
|
1152
|
+
export async function createGrantedDispatchMcpEmbedSession(input) {
|
|
1153
|
+
return publicEmbedSession(await createGrantedDispatchMcpEmbedSessionResult(input));
|
|
1154
|
+
}
|
|
1155
|
+
export async function createGrantedDispatchMcpEmbedSessionForWorkspaceAppChat(appId) {
|
|
1156
|
+
const session = await createGrantedDispatchMcpEmbedSessionResult({
|
|
1157
|
+
app: appId,
|
|
1158
|
+
path: "/",
|
|
1159
|
+
chrome: "minimal",
|
|
1160
|
+
});
|
|
1161
|
+
return { startUrl: session.startUrl, appBaseUrl: session.appBaseUrl };
|
|
1162
|
+
}
|
|
1118
1163
|
async function createEmbedSessionForResolvedApp(input) {
|
|
1119
1164
|
const { ownerEmail, orgId, target, chrome } = input;
|
|
1120
1165
|
if (target.app.id === DISPATCH_APP_ID) {
|
|
1121
|
-
return
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1166
|
+
return {
|
|
1167
|
+
...(await createDispatchSelfEmbedSession({
|
|
1168
|
+
ownerEmail,
|
|
1169
|
+
...(orgId !== undefined ? { orgId } : {}),
|
|
1170
|
+
path: target.path,
|
|
1171
|
+
baseUrl: appBaseUrl(target.app),
|
|
1172
|
+
...(chrome !== undefined ? { chrome } : {}),
|
|
1173
|
+
})),
|
|
1174
|
+
appBaseUrl: appBaseUrl(target.app),
|
|
1175
|
+
};
|
|
1128
1176
|
}
|
|
1129
1177
|
const targetMcpUrl = appMcpUrl(target.app);
|
|
1130
1178
|
const targetCredentials = await createTargetMcpUserCredentials({
|
|
@@ -1197,6 +1245,7 @@ async function createEmbedSessionForResolvedApp(input) {
|
|
|
1197
1245
|
const output = {
|
|
1198
1246
|
startUrl,
|
|
1199
1247
|
app: target.app.id,
|
|
1248
|
+
appBaseUrl: appChatBaseUrl(target.app),
|
|
1200
1249
|
};
|
|
1201
1250
|
if (parsed.targetPath)
|
|
1202
1251
|
output.targetPath = parsed.targetPath;
|
|
@@ -1204,7 +1253,7 @@ async function createEmbedSessionForResolvedApp(input) {
|
|
|
1204
1253
|
output.expiresAt = parsed.expiresAt;
|
|
1205
1254
|
return output;
|
|
1206
1255
|
}
|
|
1207
|
-
|
|
1256
|
+
async function createWorkspaceSsoEmbedSessionResult(input) {
|
|
1208
1257
|
const ownerEmail = getRequestUserEmail();
|
|
1209
1258
|
if (!ownerEmail) {
|
|
1210
1259
|
console.warn("[dispatch] workspace embed mint rejected", {
|
|
@@ -1243,4 +1292,15 @@ export async function createWorkspaceSsoEmbedSession(input) {
|
|
|
1243
1292
|
chrome: input.chrome,
|
|
1244
1293
|
});
|
|
1245
1294
|
}
|
|
1295
|
+
export async function createWorkspaceSsoEmbedSession(input) {
|
|
1296
|
+
return publicEmbedSession(await createWorkspaceSsoEmbedSessionResult(input));
|
|
1297
|
+
}
|
|
1298
|
+
export async function createWorkspaceSsoEmbedSessionForWorkspaceAppChat(appId) {
|
|
1299
|
+
const session = await createWorkspaceSsoEmbedSessionResult({
|
|
1300
|
+
app: appId,
|
|
1301
|
+
path: "/",
|
|
1302
|
+
chrome: "minimal",
|
|
1303
|
+
});
|
|
1304
|
+
return { startUrl: session.startUrl, appBaseUrl: session.appBaseUrl };
|
|
1305
|
+
}
|
|
1246
1306
|
//# sourceMappingURL=mcp-gateway.js.map
|