@agent-native/dispatch 0.40.41-nightly-20261025033716 → 0.40.41-nightly-20261025123739
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 +6 -3
- package/dist/server/lib/app-creation-store.d.ts.map +1 -1
- package/dist/server/lib/app-creation-store.js +148 -39
- package/dist/server/lib/app-creation-store.js.map +1 -1
- package/dist/server/lib/mcp-gateway.d.ts +1 -0
- package/dist/server/lib/mcp-gateway.d.ts.map +1 -1
- package/dist/server/lib/mcp-gateway.js +59 -5
- package/dist/server/lib/mcp-gateway.js.map +1 -1
- package/package.json +4 -4
- package/src/server/lib/app-creation-store.spec.ts +499 -8
- package/src/server/lib/app-creation-store.ts +166 -40
- package/src/server/lib/mcp-gateway.spec.ts +222 -0
- package/src/server/lib/mcp-gateway.ts +69 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
# @agent-native/dispatch
|
|
2
2
|
|
|
3
|
-
## 0.40.41-nightly-
|
|
3
|
+
## 0.40.41-nightly-20261025123739
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- 62b1459: Fix embedded workspace app chats on path-mounted deployments.
|
|
7
8
|
- Updated dependencies [5c03c72]
|
|
8
9
|
- Updated dependencies [5135ed2]
|
|
9
10
|
- Updated dependencies [4e91166]
|
|
10
11
|
- Updated dependencies [5aee004]
|
|
11
12
|
- Updated dependencies [5135ed2]
|
|
12
13
|
- Updated dependencies [5aee004]
|
|
14
|
+
- Updated dependencies [461542e]
|
|
13
15
|
- Updated dependencies [5aee004]
|
|
14
16
|
- Updated dependencies [5135ed2]
|
|
15
17
|
- Updated dependencies [5135ed2]
|
|
18
|
+
- Updated dependencies [1368ef4]
|
|
16
19
|
- Updated dependencies [c8190ab]
|
|
17
20
|
- Updated dependencies [5aee004]
|
|
18
21
|
- Updated dependencies [4e91166]
|
|
19
22
|
- Updated dependencies [5aee004]
|
|
20
|
-
- @agent-native/core@0.220.1-nightly-
|
|
21
|
-
- @agent-native/toolkit@0.220.1-nightly-
|
|
23
|
+
- @agent-native/core@0.220.1-nightly-20261025123739
|
|
24
|
+
- @agent-native/toolkit@0.220.1-nightly-20261025123739
|
|
22
25
|
|
|
23
26
|
## 0.40.40
|
|
24
27
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-creation-store.d.ts","sourceRoot":"","sources":["../../../src/server/lib/app-creation-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app-creation-store.d.ts","sourceRoot":"","sources":["../../../src/server/lib/app-creation-store.ts"],"names":[],"mappings":"AAwBA,OAAO,EAeL,KAAK,sBAAsB,EAC5B,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EAOL,KAAK,mBAAmB,EACzB,MAAM,2BAA2B,CAAC;AA2InC,KAAK,oBAAoB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAClD,KAAK,sBAAsB,GAAG,SAAS,GAAG,KAAK,CAAC;AAEhD,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,U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AE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,+BAA+B,GACvC,oCAAoC,GACpC,mCAAmC,GACnC,2BAA2B,GAC3B,2BAA2B,GAC3B,2BAA2B,GAC3B,wBAAwB,CAAC;AAE7B,wBAAsB,yBAAyB,CAAC,KAAK,EAAE;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAqQ3C"}
|
|
@@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
import { canonicalA2AAudience, getGlobalA2ASecret, signA2AToken, } from "@agent-native/core/a2a";
|
|
6
6
|
import { ActionContractError, isActionContractError, } from "@agent-native/core/action";
|
|
7
7
|
import { describeErrorWithCauses } from "@agent-native/core/agent/engine/error-detail";
|
|
8
|
+
import { getAppConfig } from "@agent-native/core/app-config";
|
|
8
9
|
import { getDbExec } from "@agent-native/core/db";
|
|
9
10
|
import { and, eq, inArray } from "@agent-native/core/db/schema";
|
|
10
11
|
import { getOrgA2ASecret, getOrgDomain, isWorkspaceAppAccessAllowed, workspaceApps, } from "@agent-native/core/org";
|
|
@@ -83,6 +84,14 @@ class WorkspaceAppOrgRequiredError extends Error {
|
|
|
83
84
|
this.name = "WorkspaceAppOrgRequiredError";
|
|
84
85
|
}
|
|
85
86
|
}
|
|
87
|
+
class WorkspaceGatewayConfigurationError extends Error {
|
|
88
|
+
constructor(cause) {
|
|
89
|
+
super("WORKSPACE_GATEWAY_URL must be a valid absolute HTTP(S) URL.", {
|
|
90
|
+
cause,
|
|
91
|
+
});
|
|
92
|
+
this.name = "WorkspaceGatewayConfigurationError";
|
|
93
|
+
}
|
|
94
|
+
}
|
|
86
95
|
function requireWorkspaceAppOrgId() {
|
|
87
96
|
const orgId = currentOrgId();
|
|
88
97
|
if (!orgId)
|
|
@@ -101,17 +110,20 @@ function warnWorkspaceAppsGatewayDenial(denial, source) {
|
|
|
101
110
|
console.warn(`[dispatch] workspace apps gateway denied the registry read with HTTP ${denial.statusCode}; served the ${source} instead`);
|
|
102
111
|
}
|
|
103
112
|
function readJson(file) {
|
|
104
|
-
|
|
105
|
-
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
106
|
-
}
|
|
107
|
-
catch {
|
|
113
|
+
if (!fs.existsSync(file))
|
|
108
114
|
return null;
|
|
109
|
-
|
|
115
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
110
116
|
}
|
|
111
117
|
function findWorkspaceRoot(startDir = process.cwd()) {
|
|
112
118
|
let dir = path.resolve(startDir);
|
|
113
119
|
for (let i = 0; i < 20; i++) {
|
|
114
|
-
|
|
120
|
+
let pkg;
|
|
121
|
+
try {
|
|
122
|
+
pkg = readJson(path.join(dir, "package.json"));
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
console.warn(`[dispatch] Could not read workspace package metadata in ${dir}; continuing parent search`, error);
|
|
126
|
+
}
|
|
115
127
|
if (typeof pkg?.["agent-native"]?.workspaceCore === "string") {
|
|
116
128
|
return dir;
|
|
117
129
|
}
|
|
@@ -393,16 +405,83 @@ function applyWorkspaceAppMetadataOverride(app, settings) {
|
|
|
393
405
|
// code belongs here; changes to authorship, content trust, or sharing require
|
|
394
406
|
// an explicit auth, origin, or sandbox boundary before this invariant changes.
|
|
395
407
|
function workspaceAppUrl(appPath) {
|
|
408
|
+
const gateway = workspaceGatewayBaseUrl();
|
|
409
|
+
if (gateway)
|
|
410
|
+
return appendWorkspaceAppPath(gateway, appPath);
|
|
396
411
|
const base = resolveAppRuntimeUrl();
|
|
397
412
|
if (!base)
|
|
398
413
|
return null;
|
|
399
414
|
try {
|
|
400
|
-
|
|
415
|
+
const baseUrl = new URL(addBasePath(projectEnvironmentUrl(base), getConfiguredAppBasePath()));
|
|
416
|
+
return appendWorkspaceAppPath(baseUrl, appPath);
|
|
401
417
|
}
|
|
402
418
|
catch {
|
|
403
419
|
return null;
|
|
404
420
|
}
|
|
405
421
|
}
|
|
422
|
+
function appendWorkspaceAppPath(baseUrl, appPath) {
|
|
423
|
+
const parsedPath = new URL(appPath, "http://agent-native.invalid");
|
|
424
|
+
const basePath = baseUrl.pathname.replace(/\/+$/, "");
|
|
425
|
+
let appPathname = parsedPath.pathname;
|
|
426
|
+
if (basePath &&
|
|
427
|
+
(appPathname === basePath || appPathname.startsWith(`${basePath}/`))) {
|
|
428
|
+
appPathname = appPathname.slice(basePath.length) || "/";
|
|
429
|
+
}
|
|
430
|
+
baseUrl.pathname =
|
|
431
|
+
`${basePath}${appPathname.startsWith("/") ? appPathname : `/${appPathname}`}` ||
|
|
432
|
+
"/";
|
|
433
|
+
baseUrl.search = parsedPath.search;
|
|
434
|
+
baseUrl.hash = parsedPath.hash;
|
|
435
|
+
return baseUrl.toString().replace(/\/$/, "");
|
|
436
|
+
}
|
|
437
|
+
function workspaceGatewayBaseUrl() {
|
|
438
|
+
const configured = getAppConfig().workspace.gatewayUrl?.trim();
|
|
439
|
+
if (!configured)
|
|
440
|
+
return null;
|
|
441
|
+
let configuredUrl;
|
|
442
|
+
try {
|
|
443
|
+
configuredUrl = new URL(configured);
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
throw new WorkspaceGatewayConfigurationError(error);
|
|
447
|
+
}
|
|
448
|
+
if (configuredUrl.protocol !== "http:" &&
|
|
449
|
+
configuredUrl.protocol !== "https:") {
|
|
450
|
+
throw new WorkspaceGatewayConfigurationError();
|
|
451
|
+
}
|
|
452
|
+
let url;
|
|
453
|
+
try {
|
|
454
|
+
url = new URL(projectEnvironmentUrl(configuredUrl.toString()));
|
|
455
|
+
}
|
|
456
|
+
catch (error) {
|
|
457
|
+
throw new WorkspaceGatewayConfigurationError(error);
|
|
458
|
+
}
|
|
459
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
460
|
+
throw new WorkspaceGatewayConfigurationError();
|
|
461
|
+
}
|
|
462
|
+
return new URL(addBasePath(url.toString(), getConfiguredAppBasePath()));
|
|
463
|
+
}
|
|
464
|
+
function workspaceGatewayAppUrl(appPath) {
|
|
465
|
+
const baseUrl = workspaceGatewayBaseUrl();
|
|
466
|
+
if (!baseUrl)
|
|
467
|
+
return null;
|
|
468
|
+
const requestOrigin = getRequestContext()?.requestOrigin;
|
|
469
|
+
if (requestOrigin && new URL(requestOrigin).origin === baseUrl.origin) {
|
|
470
|
+
return null;
|
|
471
|
+
}
|
|
472
|
+
return appendWorkspaceAppPath(baseUrl, appPath);
|
|
473
|
+
}
|
|
474
|
+
function addBasePath(urlValue, basePath) {
|
|
475
|
+
if (!basePath)
|
|
476
|
+
return urlValue;
|
|
477
|
+
const url = new URL(urlValue);
|
|
478
|
+
const pathname = url.pathname.replace(/\/+$/, "") || "/";
|
|
479
|
+
if (pathname === basePath || pathname.startsWith(`${basePath}/`)) {
|
|
480
|
+
return url.toString();
|
|
481
|
+
}
|
|
482
|
+
url.pathname = `${basePath}${pathname === "/" ? "" : pathname}` || "/";
|
|
483
|
+
return url.toString();
|
|
484
|
+
}
|
|
406
485
|
function isLocalWorkspaceGateway(url) {
|
|
407
486
|
const hostname = url.hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
408
487
|
return (hostname === "localhost" ||
|
|
@@ -412,16 +491,22 @@ function isLocalWorkspaceGateway(url) {
|
|
|
412
491
|
}
|
|
413
492
|
function workspaceAppLink(appPath, explicitUrl) {
|
|
414
493
|
const urlValue = typeof explicitUrl === "string" ? explicitUrl.trim() : "";
|
|
415
|
-
if (!urlValue)
|
|
416
|
-
return workspaceAppUrl(appPath);
|
|
417
|
-
if (urlValue.startsWith("/"))
|
|
418
|
-
return workspaceAppUrl(urlValue) ?? urlValue;
|
|
419
|
-
try {
|
|
420
|
-
return projectEnvironmentUrl(new URL(urlValue).toString());
|
|
494
|
+
if (!urlValue) {
|
|
495
|
+
return workspaceGatewayAppUrl(appPath) ?? workspaceAppUrl(appPath);
|
|
421
496
|
}
|
|
422
|
-
|
|
423
|
-
return urlValue;
|
|
497
|
+
if (urlValue.startsWith("/")) {
|
|
498
|
+
return (workspaceGatewayAppUrl(urlValue) ?? workspaceAppUrl(urlValue) ?? urlValue);
|
|
499
|
+
}
|
|
500
|
+
const resolved = projectEnvironmentUrl(new URL(urlValue).toString());
|
|
501
|
+
const gateway = workspaceGatewayBaseUrl();
|
|
502
|
+
if (gateway && new URL(resolved).origin === gateway.origin) {
|
|
503
|
+
return addBasePath(resolved, gateway.pathname.replace(/\/+$/, ""));
|
|
504
|
+
}
|
|
505
|
+
const runtimeBase = resolveAppRuntimeUrl();
|
|
506
|
+
if (runtimeBase && new URL(resolved).origin === new URL(runtimeBase).origin) {
|
|
507
|
+
return addBasePath(resolved, getConfiguredAppBasePath());
|
|
424
508
|
}
|
|
509
|
+
return resolved;
|
|
425
510
|
}
|
|
426
511
|
function normalizeWorkspaceAppAudience(value) {
|
|
427
512
|
return value === "public" ? "public" : DEFAULT_WORKSPACE_APP_AUDIENCE;
|
|
@@ -528,7 +613,7 @@ function workspaceAppRouteAccessFromPackageJson(pkg) {
|
|
|
528
613
|
record.workspaceAppProtectedPaths),
|
|
529
614
|
};
|
|
530
615
|
}
|
|
531
|
-
function parseWorkspaceAppsManifest(parsed) {
|
|
616
|
+
function parseWorkspaceAppsManifest(parsed, onInvalidAppUrl) {
|
|
532
617
|
const rawApps = Array.isArray(parsed?.apps)
|
|
533
618
|
? parsed.apps
|
|
534
619
|
: Array.isArray(parsed)
|
|
@@ -550,6 +635,17 @@ function parseWorkspaceAppsManifest(parsed) {
|
|
|
550
635
|
if (!profile)
|
|
551
636
|
return null;
|
|
552
637
|
const metadata = workspaceAppMetadataFromRecord(entry);
|
|
638
|
+
let url;
|
|
639
|
+
try {
|
|
640
|
+
url = workspaceAppLink(pathValue, entry.url);
|
|
641
|
+
}
|
|
642
|
+
catch (error) {
|
|
643
|
+
if (error instanceof WorkspaceGatewayConfigurationError)
|
|
644
|
+
throw error;
|
|
645
|
+
onInvalidAppUrl?.();
|
|
646
|
+
console.warn(`[dispatch] Could not resolve Workspace app ${id}; skipping app`, error);
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
553
649
|
return {
|
|
554
650
|
id,
|
|
555
651
|
name: typeof entry.name === "string" && entry.name.trim()
|
|
@@ -559,7 +655,7 @@ function parseWorkspaceAppsManifest(parsed) {
|
|
|
559
655
|
...(profile.whenToUse ? { whenToUse: profile.whenToUse } : {}),
|
|
560
656
|
path: pathValue,
|
|
561
657
|
homePath: normalizeWorkspaceAppHomePath(entry.homePath),
|
|
562
|
-
url
|
|
658
|
+
url,
|
|
563
659
|
isDispatch: typeof entry.isDispatch === "boolean"
|
|
564
660
|
? entry.isDispatch
|
|
565
661
|
: id === "dispatch",
|
|
@@ -587,8 +683,11 @@ function parseWorkspaceAppsGatewayResponse(parsed) {
|
|
|
587
683
|
return null;
|
|
588
684
|
if (rawApps.length === 0)
|
|
589
685
|
return [];
|
|
590
|
-
|
|
591
|
-
|
|
686
|
+
let invalidUrlCount = 0;
|
|
687
|
+
const apps = parseWorkspaceAppsManifest(parsed, () => {
|
|
688
|
+
invalidUrlCount += 1;
|
|
689
|
+
});
|
|
690
|
+
if (!apps || apps.length + invalidUrlCount !== rawApps.length)
|
|
592
691
|
return null;
|
|
593
692
|
const ids = new Set(apps.map((app) => app.id.toLowerCase()));
|
|
594
693
|
return ids.size === apps.length ? apps : null;
|
|
@@ -1359,29 +1458,25 @@ function readWorkspaceAppsFromEnv() {
|
|
|
1359
1458
|
if (!raw)
|
|
1360
1459
|
return null;
|
|
1361
1460
|
try {
|
|
1362
|
-
|
|
1461
|
+
const apps = parseWorkspaceAppsManifest(JSON.parse(raw));
|
|
1462
|
+
if (apps)
|
|
1463
|
+
return apps;
|
|
1464
|
+
console.warn(`[dispatch] Could not parse Workspace app manifest from ${WORKSPACE_APPS_ENV_KEY}; skipping source`);
|
|
1363
1465
|
}
|
|
1364
|
-
catch {
|
|
1365
|
-
|
|
1466
|
+
catch (error) {
|
|
1467
|
+
if (error instanceof WorkspaceGatewayConfigurationError)
|
|
1468
|
+
throw error;
|
|
1469
|
+
console.warn(`[dispatch] Could not read Workspace app manifest from ${WORKSPACE_APPS_ENV_KEY}; skipping source`);
|
|
1366
1470
|
}
|
|
1471
|
+
return null;
|
|
1367
1472
|
}
|
|
1368
1473
|
async function readWorkspaceAppsFromGateway() {
|
|
1369
|
-
const configuredBase =
|
|
1474
|
+
const configuredBase = getAppConfig().workspace.gatewayUrl?.trim();
|
|
1370
1475
|
if (!configuredBase)
|
|
1371
1476
|
return null;
|
|
1372
|
-
const
|
|
1373
|
-
|
|
1374
|
-
try {
|
|
1375
|
-
baseUrl = new URL(base);
|
|
1376
|
-
}
|
|
1377
|
-
catch {
|
|
1378
|
-
// coercion-ok: malformed gateway configuration is an unavailable registry
|
|
1379
|
-
// and falls back to local sources.
|
|
1380
|
-
return null;
|
|
1381
|
-
}
|
|
1382
|
-
if (baseUrl.protocol !== "http:" && baseUrl.protocol !== "https:") {
|
|
1477
|
+
const baseUrl = workspaceGatewayBaseUrl();
|
|
1478
|
+
if (!baseUrl)
|
|
1383
1479
|
return null;
|
|
1384
|
-
}
|
|
1385
1480
|
const requestContext = getRequestContext();
|
|
1386
1481
|
const isLocalGateway = isLocalWorkspaceGateway(baseUrl);
|
|
1387
1482
|
const requestOrigin = requestContext?.requestOrigin;
|
|
@@ -1563,9 +1658,16 @@ function readWorkspaceAppsFromManifestFile() {
|
|
|
1563
1658
|
for (const file of workspaceAppsManifestCandidates()) {
|
|
1564
1659
|
if (!fs.existsSync(file))
|
|
1565
1660
|
continue;
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1661
|
+
try {
|
|
1662
|
+
const apps = parseWorkspaceAppsManifest(readJson(file));
|
|
1663
|
+
if (apps)
|
|
1664
|
+
return apps;
|
|
1665
|
+
}
|
|
1666
|
+
catch (error) {
|
|
1667
|
+
if (error instanceof WorkspaceGatewayConfigurationError)
|
|
1668
|
+
throw error;
|
|
1669
|
+
console.warn(`[dispatch] Could not read Workspace app manifest ${file}; skipping source`);
|
|
1670
|
+
}
|
|
1569
1671
|
}
|
|
1570
1672
|
return null;
|
|
1571
1673
|
}
|
|
@@ -1578,7 +1680,14 @@ async function readWorkspaceAppsFromFilesystem(workspaceRoot) {
|
|
|
1578
1680
|
.readdirSync(appsDir, { withFileTypes: true })
|
|
1579
1681
|
.filter((entry) => entry.isDirectory() && !entry.name.startsWith("."))) {
|
|
1580
1682
|
const appDir = path.join(appsDir, entry.name);
|
|
1581
|
-
|
|
1683
|
+
let pkg;
|
|
1684
|
+
try {
|
|
1685
|
+
pkg = readJson(path.join(appDir, "package.json"));
|
|
1686
|
+
}
|
|
1687
|
+
catch (error) {
|
|
1688
|
+
console.warn(`[dispatch] Could not read workspace app ${entry.name}; skipping app`, error);
|
|
1689
|
+
continue;
|
|
1690
|
+
}
|
|
1582
1691
|
if (!pkg)
|
|
1583
1692
|
continue;
|
|
1584
1693
|
const routeAccess = workspaceAppRouteAccessFromPackageJson(pkg);
|