@agent-native/dispatch 0.43.7 → 0.43.8-nightly-20261202183703
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 +10 -0
- package/dist/actions/execute-action-suggestion.js +6 -3
- package/dist/actions/execute-action-suggestion.js.map +1 -1
- package/dist/components/workspace-app-host.d.ts.map +1 -1
- package/dist/components/workspace-app-host.js +17 -16
- package/dist/components/workspace-app-host.js.map +1 -1
- package/dist/lib/workspace-apps.d.ts +1 -1
- package/dist/lib/workspace-apps.d.ts.map +1 -1
- package/dist/lib/workspace-apps.js +16 -114
- package/dist/lib/workspace-apps.js.map +1 -1
- package/dist/lib/workspace-apps.test.js +7 -9
- package/dist/lib/workspace-apps.test.js.map +1 -1
- package/dist/server/lib/app-creation-store.d.ts.map +1 -1
- package/dist/server/lib/app-creation-store.js +38 -69
- package/dist/server/lib/app-creation-store.js.map +1 -1
- package/dist/server/lib/mcp-gateway.d.ts +1 -1
- package/dist/server/lib/mcp-gateway.d.ts.map +1 -1
- package/dist/server/lib/mcp-gateway.js +36 -93
- package/dist/server/lib/mcp-gateway.js.map +1 -1
- package/dist/shared/workspace-app-route.d.ts +0 -1
- package/dist/shared/workspace-app-route.d.ts.map +1 -1
- package/dist/shared/workspace-app-route.js +0 -3
- package/dist/shared/workspace-app-route.js.map +1 -1
- package/package.json +5 -5
- package/src/actions/action-suggestions.spec.ts +2 -1
- package/src/actions/execute-action-suggestion.ts +7 -5
- package/src/components/layout/workspace-apps-rail.spec.tsx +1 -1
- package/src/components/workspace-app-card.spec.tsx +4 -4
- package/src/components/workspace-app-host.spec.tsx +20 -16
- package/src/components/workspace-app-host.tsx +19 -16
- package/src/lib/workspace-apps.spec.ts +22 -30
- package/src/lib/workspace-apps.test.ts +8 -15
- package/src/lib/workspace-apps.ts +19 -128
- package/src/server/lib/app-creation-store.spec.ts +55 -7
- package/src/server/lib/app-creation-store.ts +42 -82
- package/src/server/lib/mcp-gateway.spec.ts +57 -113
- package/src/server/lib/mcp-gateway.ts +63 -94
- package/src/shared/workspace-app-route.spec.ts +5 -17
- package/src/shared/workspace-app-route.ts +0 -4
|
@@ -16,7 +16,6 @@ import { BUILDER_CONNECT_PROVIDER, BUILDER_CONNECT_PROVIDER_LABEL, assertValidWo
|
|
|
16
16
|
import { resolveAccessMany } from "@agent-native/core/sharing";
|
|
17
17
|
import { resolveScaffoldWorkspaceAppPaths, resolveWorkspaceAppPaths, } from "@agent-native/core/workspace-app-paths";
|
|
18
18
|
import { getDb } from "../../db/index.js";
|
|
19
|
-
import { workspaceAppRoute } from "../../shared/workspace-app-route.js";
|
|
20
19
|
import { isWorkspaceSsoAppUrl } from "../../shared/workspace-sso.js";
|
|
21
20
|
import { getDispatchDefaultOwnerEmail } from "./admin-config.js";
|
|
22
21
|
import { identityKeyForIncoming } from "./dispatch-integrations.js";
|
|
@@ -461,37 +460,37 @@ function applyWorkspaceAppMetadataOverride(app, settings) {
|
|
|
461
460
|
// user's session cookie (`path: "/"`). Only trusted, workspace-owner-authored
|
|
462
461
|
// code belongs here; changes to authorship, content trust, or sharing require
|
|
463
462
|
// an explicit auth, origin, or sandbox boundary before this invariant changes.
|
|
464
|
-
function workspaceAppUrl(
|
|
465
|
-
|
|
463
|
+
function workspaceAppUrl(mountPath) {
|
|
464
|
+
return workspaceAppAddress(workspaceOrigin(), mountPath);
|
|
465
|
+
}
|
|
466
|
+
function workspaceAppAddress(origin, mountPath) {
|
|
467
|
+
if (!origin)
|
|
468
|
+
return null;
|
|
469
|
+
const mount = mountPath.replace(/\/+$/, "");
|
|
470
|
+
return `${origin}${mount.startsWith("/") ? mount : `/${mount}`}`;
|
|
471
|
+
}
|
|
472
|
+
function workspaceOrigin() {
|
|
473
|
+
const gateway = workspaceGatewayOriginUrl();
|
|
466
474
|
if (gateway)
|
|
467
|
-
return
|
|
475
|
+
return gateway.origin;
|
|
468
476
|
const base = resolveAppRuntimeUrl();
|
|
469
477
|
if (!base)
|
|
470
478
|
return null;
|
|
471
479
|
try {
|
|
472
|
-
|
|
473
|
-
return appendWorkspaceAppPath(baseUrl, appPath);
|
|
480
|
+
return new URL(projectEnvironmentUrl(base)).origin;
|
|
474
481
|
}
|
|
475
482
|
catch {
|
|
483
|
+
// coercion-ok: an unparseable runtime URL leaves the address absent.
|
|
476
484
|
return null;
|
|
477
485
|
}
|
|
478
486
|
}
|
|
479
|
-
function appendWorkspaceAppPath(baseUrl, appPath) {
|
|
480
|
-
const parsedPath = new URL(appPath, "http://agent-native.invalid");
|
|
481
|
-
const basePath = baseUrl.pathname.replace(/\/+$/, "");
|
|
482
|
-
let appPathname = parsedPath.pathname;
|
|
483
|
-
if (basePath &&
|
|
484
|
-
(appPathname === basePath || appPathname.startsWith(`${basePath}/`))) {
|
|
485
|
-
appPathname = appPathname.slice(basePath.length) || "/";
|
|
486
|
-
}
|
|
487
|
-
baseUrl.pathname =
|
|
488
|
-
`${basePath}${appPathname.startsWith("/") ? appPathname : `/${appPathname}`}` ||
|
|
489
|
-
"/";
|
|
490
|
-
baseUrl.search = parsedPath.search;
|
|
491
|
-
baseUrl.hash = parsedPath.hash;
|
|
492
|
-
return baseUrl.toString().replace(/\/$/, "");
|
|
493
|
-
}
|
|
494
487
|
function workspaceGatewayBaseUrl() {
|
|
488
|
+
const url = workspaceGatewayOriginUrl();
|
|
489
|
+
if (!url)
|
|
490
|
+
return null;
|
|
491
|
+
return new URL(addBasePath(url.toString(), getConfiguredAppBasePath()));
|
|
492
|
+
}
|
|
493
|
+
function workspaceGatewayOriginUrl() {
|
|
495
494
|
const configured = getAppConfig().workspace.gatewayUrl?.trim();
|
|
496
495
|
if (!configured)
|
|
497
496
|
return null;
|
|
@@ -516,17 +515,7 @@ function workspaceGatewayBaseUrl() {
|
|
|
516
515
|
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
517
516
|
throw new WorkspaceGatewayConfigurationError();
|
|
518
517
|
}
|
|
519
|
-
return
|
|
520
|
-
}
|
|
521
|
-
function workspaceGatewayAppUrl(appPath) {
|
|
522
|
-
const baseUrl = workspaceGatewayBaseUrl();
|
|
523
|
-
if (!baseUrl)
|
|
524
|
-
return null;
|
|
525
|
-
const requestOrigin = getRequestContext()?.requestOrigin;
|
|
526
|
-
if (requestOrigin && new URL(requestOrigin).origin === baseUrl.origin) {
|
|
527
|
-
return null;
|
|
528
|
-
}
|
|
529
|
-
return appendWorkspaceAppPath(baseUrl, appPath);
|
|
518
|
+
return url;
|
|
530
519
|
}
|
|
531
520
|
function addBasePath(urlValue, basePath) {
|
|
532
521
|
if (!basePath)
|
|
@@ -546,39 +535,19 @@ function isLocalWorkspaceGateway(url) {
|
|
|
546
535
|
hostname === "0.0.0.0" ||
|
|
547
536
|
hostname === "::1");
|
|
548
537
|
}
|
|
549
|
-
function
|
|
550
|
-
const
|
|
551
|
-
if (!urlValue)
|
|
552
|
-
return route;
|
|
553
|
-
const parsed = new URL(urlValue, "https://agent-native.invalid");
|
|
554
|
-
return `${route}${parsed.search}${parsed.hash}`;
|
|
555
|
-
}
|
|
556
|
-
function workspaceAppLink(appId, explicitUrl) {
|
|
538
|
+
function workspaceAppLink(mountPath, explicitUrl) {
|
|
539
|
+
const origin = workspaceOrigin();
|
|
557
540
|
const urlValue = typeof explicitUrl === "string" ? explicitUrl.trim() : "";
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
}
|
|
569
|
-
const resolved = projectEnvironmentUrl(new URL(urlValue).toString());
|
|
570
|
-
const gateway = workspaceGatewayBaseUrl();
|
|
571
|
-
if (gateway && new URL(resolved).origin === gateway.origin) {
|
|
572
|
-
return (workspaceGatewayAppUrl(routePath) ??
|
|
573
|
-
workspaceAppUrl(routePath) ??
|
|
574
|
-
routePath);
|
|
575
|
-
}
|
|
576
|
-
const runtimeBase = resolveAppRuntimeUrl();
|
|
577
|
-
if (runtimeBase && new URL(resolved).origin === new URL(runtimeBase).origin) {
|
|
578
|
-
const runtimeUrl = new URL(addBasePath(projectEnvironmentUrl(runtimeBase), getConfiguredAppBasePath()));
|
|
579
|
-
return appendWorkspaceAppPath(runtimeUrl, routePath);
|
|
580
|
-
}
|
|
581
|
-
return resolved;
|
|
541
|
+
if (!urlValue || urlValue.startsWith("/")) {
|
|
542
|
+
return workspaceAppAddress(origin, urlValue || mountPath);
|
|
543
|
+
}
|
|
544
|
+
const resolved = new URL(projectEnvironmentUrl(new URL(urlValue).toString()));
|
|
545
|
+
if (resolved.protocol !== "http:" && resolved.protocol !== "https:") {
|
|
546
|
+
throw new Error(`Workspace app url must be http(s): ${urlValue}`);
|
|
547
|
+
}
|
|
548
|
+
resolved.search = "";
|
|
549
|
+
resolved.hash = "";
|
|
550
|
+
return resolved.toString().replace(/\/+$/, "");
|
|
582
551
|
}
|
|
583
552
|
function normalizeWorkspaceAppAudience(value) {
|
|
584
553
|
return value === "public" ? "public" : DEFAULT_WORKSPACE_APP_AUDIENCE;
|
|
@@ -709,7 +678,7 @@ function parseWorkspaceAppsManifest(parsed, onInvalidAppUrl) {
|
|
|
709
678
|
const metadata = workspaceAppMetadataFromRecord(entry);
|
|
710
679
|
let url;
|
|
711
680
|
try {
|
|
712
|
-
url = workspaceAppLink(
|
|
681
|
+
url = workspaceAppLink(pathValue, entry.url);
|
|
713
682
|
}
|
|
714
683
|
catch (error) {
|
|
715
684
|
if (error instanceof WorkspaceGatewayConfigurationError)
|
|
@@ -1092,7 +1061,7 @@ function pendingAppToSummary(app) {
|
|
|
1092
1061
|
description: app.description,
|
|
1093
1062
|
path: app.path,
|
|
1094
1063
|
homePath: "/home",
|
|
1095
|
-
url:
|
|
1064
|
+
url: null,
|
|
1096
1065
|
isDispatch: false,
|
|
1097
1066
|
audience: app.audience ?? DEFAULT_WORKSPACE_APP_AUDIENCE,
|
|
1098
1067
|
publicPaths: [],
|
|
@@ -1824,7 +1793,7 @@ async function readWorkspaceAppsFromFilesystem(workspaceRoot) {
|
|
|
1824
1793
|
description: pkg.description || "",
|
|
1825
1794
|
path: `/${entry.name}`,
|
|
1826
1795
|
homePath: normalizeWorkspaceAppHomePath(configuredHomePath ?? inferredHomePath),
|
|
1827
|
-
url: workspaceAppUrl(
|
|
1796
|
+
url: workspaceAppUrl(`/${entry.name}`),
|
|
1828
1797
|
isDispatch: entry.name === "dispatch",
|
|
1829
1798
|
audience: workspaceAppAudienceFromPackageJson(pkg) ??
|
|
1830
1799
|
DEFAULT_WORKSPACE_APP_AUDIENCE,
|
|
@@ -2246,7 +2215,7 @@ export async function scaffoldWorkspaceAppFromTemplate(input) {
|
|
|
2246
2215
|
description: "",
|
|
2247
2216
|
path: `/${appId}`,
|
|
2248
2217
|
homePath: "/home",
|
|
2249
|
-
url: workspaceAppUrl(
|
|
2218
|
+
url: workspaceAppUrl(`/${appId}`),
|
|
2250
2219
|
isDispatch: false,
|
|
2251
2220
|
audience: DEFAULT_WORKSPACE_APP_AUDIENCE,
|
|
2252
2221
|
publicPaths: [],
|
|
@@ -2959,7 +2928,7 @@ export async function startWorkspaceAppCreation(input) {
|
|
|
2959
2928
|
projectId: builderProjectId,
|
|
2960
2929
|
branchName: result.branchName,
|
|
2961
2930
|
url: result.url,
|
|
2962
|
-
workspaceUrl: workspaceAppUrl(
|
|
2931
|
+
workspaceUrl: workspaceAppUrl(`/${built.appId}`),
|
|
2963
2932
|
status: result.status,
|
|
2964
2933
|
message: `Builder started a branch for /${built.appId}. Use the Builder branch URL to track creation now. ` +
|
|
2965
2934
|
`The workspace path will be live after that branch is merged and the workspace deploy finishes, so it may 404 until then.`,
|