@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.
Files changed (39) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/actions/execute-action-suggestion.js +6 -3
  3. package/dist/actions/execute-action-suggestion.js.map +1 -1
  4. package/dist/components/workspace-app-host.d.ts.map +1 -1
  5. package/dist/components/workspace-app-host.js +17 -16
  6. package/dist/components/workspace-app-host.js.map +1 -1
  7. package/dist/lib/workspace-apps.d.ts +1 -1
  8. package/dist/lib/workspace-apps.d.ts.map +1 -1
  9. package/dist/lib/workspace-apps.js +16 -114
  10. package/dist/lib/workspace-apps.js.map +1 -1
  11. package/dist/lib/workspace-apps.test.js +7 -9
  12. package/dist/lib/workspace-apps.test.js.map +1 -1
  13. package/dist/server/lib/app-creation-store.d.ts.map +1 -1
  14. package/dist/server/lib/app-creation-store.js +38 -69
  15. package/dist/server/lib/app-creation-store.js.map +1 -1
  16. package/dist/server/lib/mcp-gateway.d.ts +1 -1
  17. package/dist/server/lib/mcp-gateway.d.ts.map +1 -1
  18. package/dist/server/lib/mcp-gateway.js +36 -93
  19. package/dist/server/lib/mcp-gateway.js.map +1 -1
  20. package/dist/shared/workspace-app-route.d.ts +0 -1
  21. package/dist/shared/workspace-app-route.d.ts.map +1 -1
  22. package/dist/shared/workspace-app-route.js +0 -3
  23. package/dist/shared/workspace-app-route.js.map +1 -1
  24. package/package.json +5 -5
  25. package/src/actions/action-suggestions.spec.ts +2 -1
  26. package/src/actions/execute-action-suggestion.ts +7 -5
  27. package/src/components/layout/workspace-apps-rail.spec.tsx +1 -1
  28. package/src/components/workspace-app-card.spec.tsx +4 -4
  29. package/src/components/workspace-app-host.spec.tsx +20 -16
  30. package/src/components/workspace-app-host.tsx +19 -16
  31. package/src/lib/workspace-apps.spec.ts +22 -30
  32. package/src/lib/workspace-apps.test.ts +8 -15
  33. package/src/lib/workspace-apps.ts +19 -128
  34. package/src/server/lib/app-creation-store.spec.ts +55 -7
  35. package/src/server/lib/app-creation-store.ts +42 -82
  36. package/src/server/lib/mcp-gateway.spec.ts +57 -113
  37. package/src/server/lib/mcp-gateway.ts +63 -94
  38. package/src/shared/workspace-app-route.spec.ts +5 -17
  39. package/src/shared/workspace-app-route.ts +0 -4
@@ -8,6 +8,7 @@ import {
8
8
  resolveEnvironmentTargets,
9
9
  withBuilderUtmTrackingParams,
10
10
  } from "@agent-native/core/shared";
11
+ import { resolveWorkspaceLink } from "@agent-native/core/shared/workspace-links";
11
12
 
12
13
  import { workspaceAppRoute } from "../shared/workspace-app-route";
13
14
  import {
@@ -69,16 +70,6 @@ interface WorkspaceAppHrefSource {
69
70
  workspaceSso?: boolean;
70
71
  }
71
72
 
72
- function stripHostPageUrl<T extends WorkspaceAppHrefSource>(app: T): T {
73
- if (!app.id || !app.url?.trim() || !app.path?.trim()) return app;
74
- const origin =
75
- typeof window === "undefined" ? undefined : window.location.origin;
76
- if (!isWorkspaceAppHostPageUrl({ id: app.id, url: app.url }, origin)) {
77
- return app;
78
- }
79
- return { ...app, url: null };
80
- }
81
-
82
73
  export function isDispatchWorkspaceAppId(appId: string): boolean {
83
74
  return appId.trim().toLowerCase() === "dispatch";
84
75
  }
@@ -350,25 +341,18 @@ export function workspaceAppIdFromRoute(pathname: string): string | null {
350
341
  }
351
342
  }
352
343
 
353
- // A mounted app's registry `url` is the Dispatch page that hosts it
354
- // (`<dispatch>/apps/<id>`). Read from that same Dispatch, it is the page doing
355
- // the framing, so framing it again nests Dispatch inside itself.
356
- export function isWorkspaceAppHostPageUrl(
357
- app: Pick<WorkspaceAppSummary, "id" | "url">,
344
+ export function isSameOriginWorkspaceApp(
345
+ app: Pick<WorkspaceAppSummary, "url">,
358
346
  dispatchOrigin: string | undefined,
359
347
  ): boolean {
360
348
  const rawUrl = app.url?.trim();
361
349
  if (!rawUrl || !dispatchOrigin) return false;
362
- let url: URL;
363
350
  try {
364
- url = new URL(rawUrl);
351
+ return new URL(rawUrl).origin === dispatchOrigin;
365
352
  } catch {
366
- // coercion-ok: a URL that does not parse is not Dispatch's page for the app.
353
+ // coercion-ok: a URL that does not parse cannot share Dispatch's origin.
367
354
  return false;
368
355
  }
369
- if (url.origin !== dispatchOrigin) return false;
370
- const pathname = url.pathname.replace(/\/+$/, "").toLowerCase();
371
- return pathname.endsWith(workspaceAppRoute(app.id.trim()).toLowerCase());
372
356
  }
373
357
 
374
358
  export function workspaceAppHref(app: WorkspaceAppSummary): string | null {
@@ -380,10 +364,9 @@ export function workspaceAppHref(app: WorkspaceAppSummary): string | null {
380
364
  })
381
365
  : null;
382
366
  }
383
- const normalized = stripHostPageUrl(app);
384
- const base = normalized.path || normalized.url || null;
385
- if (!base || normalized.isDispatch) return base;
386
- return workspaceAppDirectHref(normalized, workspaceAppTargetPath(normalized));
367
+ const base = app.path || app.url || null;
368
+ if (!base || app.isDispatch) return base;
369
+ return workspaceAppDirectHref(app, workspaceAppTargetPath(app));
387
370
  }
388
371
 
389
372
  export function workspaceAppTargetPath(app: {
@@ -392,12 +375,11 @@ export function workspaceAppTargetPath(app: {
392
375
  homePath?: string | null;
393
376
  url?: string | null;
394
377
  }): string {
395
- const normalized = stripHostPageUrl(app);
396
- if (typeof normalized.homePath === "string") {
397
- return normalizeWorkspaceAppHomePath(normalized.homePath);
378
+ if (typeof app.homePath === "string") {
379
+ return normalizeWorkspaceAppHomePath(app.homePath);
398
380
  }
399
381
 
400
- const rawUrl = normalized.url?.trim();
382
+ const rawUrl = app.url?.trim();
401
383
  if (rawUrl) {
402
384
  try {
403
385
  const url = new URL(rawUrl);
@@ -434,110 +416,19 @@ export function workspaceAppEmbedTarget(
434
416
  return path.startsWith("/") ? { path } : path ? { url: path } : {};
435
417
  }
436
418
 
437
- function collapseRepeatedLeadingMountSegment(
438
- pathname: string,
439
- mountSegment?: string | null,
440
- ): string {
441
- const segments = pathname.split("/").filter(Boolean);
442
- const firstSegment = segments[0];
443
- const secondSegment = segments[1];
444
- if (!firstSegment || !secondSegment) return pathname;
445
- const first = firstSegment.toLowerCase();
446
- const second = secondSegment.toLowerCase();
447
- if (first !== second) return pathname;
448
- if (mountSegment && first !== mountSegment.toLowerCase()) return pathname;
449
- let start = 0;
450
- while (start + 1 < segments.length) {
451
- const current = segments[start];
452
- const next = segments[start + 1];
453
- if (!current || !next || current.toLowerCase() !== next.toLowerCase()) {
454
- break;
455
- }
456
- start += 1;
457
- }
458
- return `/${segments.slice(start).join("/")}`;
459
- }
460
-
461
419
  export function workspaceAppDirectHref(
462
420
  app: WorkspaceAppHrefSource,
463
421
  targetPath: string,
464
422
  ): string | null {
465
- const normalized = stripHostPageUrl(app);
466
- const target = targetPath.trim();
467
- if (!target || !target.startsWith("/") || target.startsWith("//")) {
468
- return null;
469
- }
470
-
471
- let targetUrl: URL;
472
- try {
473
- targetUrl = new URL(target, "https://agent-native.invalid");
474
- } catch {
475
- // coercion-ok: invalid relative target input has no safe href.
476
- return null;
477
- }
478
- const targetPathname = targetUrl.pathname || "/";
479
-
480
- let absoluteBase: URL | null = null;
481
- const rawUrl = normalized.url?.trim();
482
- if (rawUrl) {
483
- try {
484
- const parsedBase = new URL(rawUrl);
485
- if (parsedBase.protocol === "http:" || parsedBase.protocol === "https:") {
486
- absoluteBase = parsedBase;
487
- }
488
- // coercion-ok: invalid app URLs use the mounted path fallback below.
489
- } catch {
490
- absoluteBase = null;
491
- }
492
- }
493
-
494
- const mountedPath = normalized.path?.trim();
495
- const normalizedMountedPath = mountedPath
496
- ? `/${mountedPath.replace(/^[/\\]+/, "").split(/[?#]/, 1)[0]}`.replace(
497
- /\/+$/,
498
- "",
499
- ) || "/"
500
- : null;
501
- const basePath = absoluteBase ? absoluteBase.pathname : normalizedMountedPath;
502
- if (!basePath) return null;
503
-
504
- const mountSegment =
505
- normalizedMountedPath && normalizedMountedPath !== "/"
506
- ? normalizedMountedPath.split("/").filter(Boolean)[0]
507
- : basePath.split("/").filter(Boolean)[0];
508
- const normalizedBasePath =
509
- collapseRepeatedLeadingMountSegment(
510
- basePath.replace(/\/+$/, "") || "/",
511
- mountSegment,
512
- ) || "/";
513
- const cleanedTargetPathname = collapseRepeatedLeadingMountSegment(
514
- targetPathname,
515
- mountSegment,
423
+ const id = app.id?.trim() || "app";
424
+ const resolved = resolveWorkspaceLink(
425
+ {
426
+ apps: [{ id, path: app.path ?? null, url: app.url ?? null }],
427
+ fallbackOrigin: "same-origin",
428
+ },
429
+ { kind: "app-path", appId: id, path: targetPath.trim() },
516
430
  );
517
- const lowerBasePath = normalizedBasePath.toLowerCase();
518
- const lowerTargetPath = cleanedTargetPathname.toLowerCase();
519
- const targetIsMountedPath =
520
- normalizedBasePath !== "/" &&
521
- (lowerTargetPath === lowerBasePath ||
522
- lowerTargetPath.startsWith(`${lowerBasePath}/`));
523
- const resolvedPath = targetIsMountedPath
524
- ? cleanedTargetPathname === "/"
525
- ? normalizedBasePath
526
- : `${normalizedBasePath}${cleanedTargetPathname.slice(normalizedBasePath.length)}`
527
- : normalizedBasePath === "/"
528
- ? cleanedTargetPathname
529
- : cleanedTargetPathname === "/"
530
- ? normalizedBasePath
531
- : `${normalizedBasePath}/${cleanedTargetPathname.replace(/^\/+/, "")}`;
532
-
533
- if (absoluteBase) {
534
- absoluteBase.pathname = resolvedPath;
535
- if (target.includes("?")) absoluteBase.search = targetUrl.search;
536
- if (target.includes("#")) absoluteBase.hash = targetUrl.hash;
537
- return absoluteBase.toString();
538
- }
539
-
540
- return `${resolvedPath}${targetUrl.search}${targetUrl.hash}`;
431
+ return resolved.ok ? resolved.url : null;
541
432
  }
542
433
 
543
434
  export function isPendingBuilderHref(app: WorkspaceAppSummary): boolean {
@@ -8,6 +8,7 @@ import {
8
8
  CredentialStoreUnavailableError,
9
9
  runWithRequestContext,
10
10
  } from "@agent-native/core/server";
11
+ import { workspaceAppAddressProblem } from "@agent-native/core/shared/workspace-links";
11
12
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
12
13
 
13
14
  import {
@@ -631,7 +632,7 @@ describe("listWorkspaceApps", () => {
631
632
  ],
632
633
  ["APP_BASE_PATH", "https://beta.agent-workspace.builder.io", "/dispatch"],
633
634
  ] as const)(
634
- "keeps mounted Workspace prefixes on gateway app URLs with %s",
635
+ "passes manifest app addresses through unchanged with %s",
635
636
  async (_mountConfig, gatewayUrl, appBasePath) => {
636
637
  const fetchMock = vi.fn(async () => {
637
638
  return new Response(
@@ -663,12 +664,58 @@ describe("listWorkspaceApps", () => {
663
664
  );
664
665
 
665
666
  expect(apps.find((app) => app.id === "customer-ticket-triage")?.url).toBe(
666
- "https://beta.agent-workspace.builder.io/dispatch/apps/customer-ticket-triage",
667
+ "https://beta.agent-workspace.builder.io/customer-ticket-triage",
667
668
  );
668
669
  },
669
670
  );
670
671
 
671
- it("applies APP_BASE_PATH to locally resolved workspace app URLs", async () => {
672
+ it("writes only app addresses into the registry for every manifest shape", async () => {
673
+ stubManifest([
674
+ { id: "dispatch", name: "Dispatch", path: "/dispatch" },
675
+ { id: "notes", name: "Notes", path: "/notes", url: "/notes" },
676
+ {
677
+ id: "atlas",
678
+ name: "Atlas",
679
+ path: "/atlas",
680
+ url: "https://beta.agent-workspace.builder.io/atlas/",
681
+ },
682
+ {
683
+ id: "mail",
684
+ name: "Mail",
685
+ path: "/mail",
686
+ url: "https://mail.example.test",
687
+ },
688
+ ]);
689
+ mocks.settings.set(settingsKey, { pendingApps: [pendingApp("drafts")] });
690
+ vi.stubEnv(
691
+ "WORKSPACE_GATEWAY_URL",
692
+ "https://beta.agent-workspace.builder.io/dispatch",
693
+ );
694
+ vi.stubEnv("APP_BASE_PATH", "");
695
+ vi.stubEnv("VITE_APP_BASE_PATH", "");
696
+
697
+ const apps = await runWithRequestContext(
698
+ {
699
+ userEmail: "dev@example.test",
700
+ requestOrigin: "https://beta.agent-workspace.builder.io",
701
+ },
702
+ () => listWorkspaceApps({ includeAgentCards: false }),
703
+ );
704
+
705
+ const urls = Object.fromEntries(apps.map((app) => [app.id, app.url]));
706
+ expect(urls).toEqual({
707
+ dispatch: "https://beta.agent-workspace.builder.io/dispatch",
708
+ notes: "https://beta.agent-workspace.builder.io/notes",
709
+ atlas: "https://beta.agent-workspace.builder.io/atlas",
710
+ mail: "https://mail.example.test",
711
+ drafts: null,
712
+ });
713
+ for (const app of apps) {
714
+ expect(workspaceAppAddressProblem(app)).toBeNull();
715
+ }
716
+ });
717
+
718
+ it("keeps Dispatch's APP_BASE_PATH out of locally resolved workspace app URLs", async () => {
672
719
  stubNoPendingContext();
673
720
  stubManifest([
674
721
  {
@@ -694,7 +741,7 @@ describe("listWorkspaceApps", () => {
694
741
  );
695
742
 
696
743
  expect(apps.find((app) => app.id === "customer-ticket-triage")?.url).toBe(
697
- "https://beta.agent-workspace.builder.io/dispatch/apps/customer-ticket-triage",
744
+ "https://beta.agent-workspace.builder.io/customer-ticket-triage",
698
745
  );
699
746
  });
700
747
 
@@ -807,7 +854,7 @@ describe("listWorkspaceApps", () => {
807
854
  );
808
855
 
809
856
  expect(apps.find((app) => app.id === "todo")?.url).toBe(
810
- "https://workspace-preview.vercel.app/apps/todo",
857
+ "https://workspace-preview.vercel.app/todo",
811
858
  );
812
859
  });
813
860
 
@@ -859,7 +906,7 @@ describe("listWorkspaceApps", () => {
859
906
  }),
860
907
  );
861
908
  expect(apps.map((app) => app.id)).toEqual(["atlas"]);
862
- expect(apps[0]?.url).toBe("https://agent-workspace.builder.io/apps/atlas");
909
+ expect(apps[0]?.url).toBe("https://agent-workspace.builder.io/atlas");
863
910
  });
864
911
 
865
912
  it("signs the hosted registry request as the member with the deployment secret", async () => {
@@ -1478,7 +1525,7 @@ describe("listWorkspaceApps", () => {
1478
1525
  "https://beta.agent-workspace.builder.io/_agent-native/actions/list-workspace-apps?includeAgentCards=false&audience=all",
1479
1526
  );
1480
1527
  expect(apps[0]?.url).toBe(
1481
- "https://beta.agent-workspace.builder.io/apps/private-app",
1528
+ "https://beta.agent-workspace.builder.io/private-app",
1482
1529
  );
1483
1530
  });
1484
1531
 
@@ -2738,6 +2785,7 @@ describe("listWorkspaceApps", () => {
2738
2785
  expect(apps.find((app) => app.id === "mail")?.builderUrl).toContain(
2739
2786
  "feature-a",
2740
2787
  );
2788
+ expect(apps.find((app) => app.id === "mail")?.url).toBeNull();
2741
2789
  });
2742
2790
 
2743
2791
  it("keeps the curated source id on a pending app summary", async () => {
@@ -64,7 +64,6 @@ import {
64
64
  } from "@agent-native/core/workspace-app-paths";
65
65
 
66
66
  import { getDb } from "../../db/index.js";
67
- import { workspaceAppRoute } from "../../shared/workspace-app-route.js";
68
67
  import { isWorkspaceSsoAppUrl } from "../../shared/workspace-sso.js";
69
68
  import { getDispatchDefaultOwnerEmail } from "./admin-config.js";
70
69
  import { identityKeyForIncoming } from "./dispatch-integrations.js";
@@ -732,41 +731,40 @@ function applyWorkspaceAppMetadataOverride(
732
731
  // user's session cookie (`path: "/"`). Only trusted, workspace-owner-authored
733
732
  // code belongs here; changes to authorship, content trust, or sharing require
734
733
  // an explicit auth, origin, or sandbox boundary before this invariant changes.
735
- function workspaceAppUrl(appPath: string): string | null {
736
- const gateway = workspaceGatewayBaseUrl();
737
- if (gateway) return appendWorkspaceAppPath(gateway, appPath);
734
+ function workspaceAppUrl(mountPath: string): string | null {
735
+ return workspaceAppAddress(workspaceOrigin(), mountPath);
736
+ }
737
+
738
+ function workspaceAppAddress(
739
+ origin: string | null,
740
+ mountPath: string,
741
+ ): string | null {
742
+ if (!origin) return null;
743
+ const mount = mountPath.replace(/\/+$/, "");
744
+ return `${origin}${mount.startsWith("/") ? mount : `/${mount}`}`;
745
+ }
746
+
747
+ function workspaceOrigin(): string | null {
748
+ const gateway = workspaceGatewayOriginUrl();
749
+ if (gateway) return gateway.origin;
738
750
 
739
751
  const base = resolveAppRuntimeUrl();
740
752
  if (!base) return null;
741
753
  try {
742
- const baseUrl = new URL(
743
- addBasePath(projectEnvironmentUrl(base), getConfiguredAppBasePath()),
744
- );
745
- return appendWorkspaceAppPath(baseUrl, appPath);
754
+ return new URL(projectEnvironmentUrl(base)).origin;
746
755
  } catch {
756
+ // coercion-ok: an unparseable runtime URL leaves the address absent.
747
757
  return null;
748
758
  }
749
759
  }
750
760
 
751
- function appendWorkspaceAppPath(baseUrl: URL, appPath: string): string {
752
- const parsedPath = new URL(appPath, "http://agent-native.invalid");
753
- const basePath = baseUrl.pathname.replace(/\/+$/, "");
754
- let appPathname = parsedPath.pathname;
755
- if (
756
- basePath &&
757
- (appPathname === basePath || appPathname.startsWith(`${basePath}/`))
758
- ) {
759
- appPathname = appPathname.slice(basePath.length) || "/";
760
- }
761
- baseUrl.pathname =
762
- `${basePath}${appPathname.startsWith("/") ? appPathname : `/${appPathname}`}` ||
763
- "/";
764
- baseUrl.search = parsedPath.search;
765
- baseUrl.hash = parsedPath.hash;
766
- return baseUrl.toString().replace(/\/$/, "");
761
+ function workspaceGatewayBaseUrl(): URL | null {
762
+ const url = workspaceGatewayOriginUrl();
763
+ if (!url) return null;
764
+ return new URL(addBasePath(url.toString(), getConfiguredAppBasePath()));
767
765
  }
768
766
 
769
- function workspaceGatewayBaseUrl(): URL | null {
767
+ function workspaceGatewayOriginUrl(): URL | null {
770
768
  const configured = getAppConfig().workspace.gatewayUrl?.trim();
771
769
  if (!configured) return null;
772
770
  let configuredUrl: URL;
@@ -790,17 +788,7 @@ function workspaceGatewayBaseUrl(): URL | null {
790
788
  if (url.protocol !== "http:" && url.protocol !== "https:") {
791
789
  throw new WorkspaceGatewayConfigurationError();
792
790
  }
793
- return new URL(addBasePath(url.toString(), getConfiguredAppBasePath()));
794
- }
795
-
796
- function workspaceGatewayAppUrl(appPath: string): string | null {
797
- const baseUrl = workspaceGatewayBaseUrl();
798
- if (!baseUrl) return null;
799
- const requestOrigin = getRequestContext()?.requestOrigin;
800
- if (requestOrigin && new URL(requestOrigin).origin === baseUrl.origin) {
801
- return null;
802
- }
803
- return appendWorkspaceAppPath(baseUrl, appPath);
791
+ return url;
804
792
  }
805
793
 
806
794
  function addBasePath(urlValue: string, basePath: string): string {
@@ -824,50 +812,22 @@ function isLocalWorkspaceGateway(url: URL): boolean {
824
812
  );
825
813
  }
826
814
 
827
- function workspaceAppPagePath(appId: string, urlValue?: string): string {
828
- const route = workspaceAppRoute(appId);
829
- if (!urlValue) return route;
830
- const parsed = new URL(urlValue, "https://agent-native.invalid");
831
- return `${route}${parsed.search}${parsed.hash}`;
832
- }
833
-
834
- function workspaceAppLink(appId: string, explicitUrl?: unknown): string {
815
+ function workspaceAppLink(
816
+ mountPath: string,
817
+ explicitUrl?: unknown,
818
+ ): string | null {
819
+ const origin = workspaceOrigin();
835
820
  const urlValue = typeof explicitUrl === "string" ? explicitUrl.trim() : "";
836
- const routePath = workspaceAppPagePath(appId, urlValue || undefined);
837
- if (!urlValue) {
838
- return (
839
- workspaceGatewayAppUrl(routePath) ??
840
- workspaceAppUrl(routePath) ??
841
- routePath
842
- );
843
- }
844
- if (urlValue.startsWith("/")) {
845
- return (
846
- workspaceGatewayAppUrl(routePath) ??
847
- workspaceAppUrl(routePath) ??
848
- routePath
849
- );
821
+ if (!urlValue || urlValue.startsWith("/")) {
822
+ return workspaceAppAddress(origin, urlValue || mountPath);
850
823
  }
851
- const resolved = projectEnvironmentUrl(new URL(urlValue).toString());
852
- const gateway = workspaceGatewayBaseUrl();
853
- if (gateway && new URL(resolved).origin === gateway.origin) {
854
- return (
855
- workspaceGatewayAppUrl(routePath) ??
856
- workspaceAppUrl(routePath) ??
857
- routePath
858
- );
859
- }
860
- const runtimeBase = resolveAppRuntimeUrl();
861
- if (runtimeBase && new URL(resolved).origin === new URL(runtimeBase).origin) {
862
- const runtimeUrl = new URL(
863
- addBasePath(
864
- projectEnvironmentUrl(runtimeBase),
865
- getConfiguredAppBasePath(),
866
- ),
867
- );
868
- return appendWorkspaceAppPath(runtimeUrl, routePath);
824
+ const resolved = new URL(projectEnvironmentUrl(new URL(urlValue).toString()));
825
+ if (resolved.protocol !== "http:" && resolved.protocol !== "https:") {
826
+ throw new Error(`Workspace app url must be http(s): ${urlValue}`);
869
827
  }
870
- return resolved;
828
+ resolved.search = "";
829
+ resolved.hash = "";
830
+ return resolved.toString().replace(/\/+$/, "");
871
831
  }
872
832
 
873
833
  function normalizeWorkspaceAppAudience(value: unknown): WorkspaceAppAudience {
@@ -1052,7 +1012,7 @@ function parseWorkspaceAppsManifest(
1052
1012
  const metadata = workspaceAppMetadataFromRecord(entry);
1053
1013
  let url: string | null;
1054
1014
  try {
1055
- url = workspaceAppLink(id, entry.url);
1015
+ url = workspaceAppLink(pathValue, entry.url);
1056
1016
  } catch (error) {
1057
1017
  if (error instanceof WorkspaceGatewayConfigurationError) throw error;
1058
1018
  onInvalidAppUrl?.();
@@ -1533,7 +1493,7 @@ function pendingAppToSummary(app: PendingWorkspaceApp): WorkspaceAppSummary {
1533
1493
  description: app.description,
1534
1494
  path: app.path,
1535
1495
  homePath: "/home",
1536
- url: app.builderUrl,
1496
+ url: null,
1537
1497
  isDispatch: false,
1538
1498
  audience: app.audience ?? DEFAULT_WORKSPACE_APP_AUDIENCE,
1539
1499
  publicPaths: [],
@@ -2470,7 +2430,7 @@ async function readWorkspaceAppsFromFilesystem(
2470
2430
  homePath: normalizeWorkspaceAppHomePath(
2471
2431
  configuredHomePath ?? inferredHomePath,
2472
2432
  ),
2473
- url: workspaceAppUrl(workspaceAppRoute(entry.name)),
2433
+ url: workspaceAppUrl(`/${entry.name}`),
2474
2434
  isDispatch: entry.name === "dispatch",
2475
2435
  audience:
2476
2436
  workspaceAppAudienceFromPackageJson(pkg) ??
@@ -2976,7 +2936,7 @@ export async function scaffoldWorkspaceAppFromTemplate(input: {
2976
2936
  description: "",
2977
2937
  path: `/${appId}`,
2978
2938
  homePath: "/home",
2979
- url: workspaceAppUrl(workspaceAppRoute(appId)),
2939
+ url: workspaceAppUrl(`/${appId}`),
2980
2940
  isDispatch: false,
2981
2941
  audience: DEFAULT_WORKSPACE_APP_AUDIENCE,
2982
2942
  publicPaths: [],
@@ -3924,7 +3884,7 @@ export async function startWorkspaceAppCreation(input: {
3924
3884
  projectId: builderProjectId,
3925
3885
  branchName: result.branchName,
3926
3886
  url: result.url,
3927
- workspaceUrl: workspaceAppUrl(workspaceAppRoute(built.appId)),
3887
+ workspaceUrl: workspaceAppUrl(`/${built.appId}`),
3928
3888
  status: result.status,
3929
3889
  message:
3930
3890
  `Builder started a branch for /${built.appId}. Use the Builder branch URL to track creation now. ` +