@agent-native/dispatch 0.31.14 → 0.31.16

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 (34) hide show
  1. package/dist/actions/provider-api-register.d.ts +7 -7
  2. package/dist/components/dispatch-control-plane.d.ts.map +1 -1
  3. package/dist/components/dispatch-control-plane.js +2 -2
  4. package/dist/components/dispatch-control-plane.js.map +1 -1
  5. package/dist/components/layout/Layout.d.ts +17 -4
  6. package/dist/components/layout/Layout.d.ts.map +1 -1
  7. package/dist/components/layout/Layout.js +45 -20
  8. package/dist/components/layout/Layout.js.map +1 -1
  9. package/dist/components/workspace-app-card.d.ts.map +1 -1
  10. package/dist/components/workspace-app-card.js +18 -1
  11. package/dist/components/workspace-app-card.js.map +1 -1
  12. package/dist/lib/catch-all-target.d.ts.map +1 -1
  13. package/dist/lib/catch-all-target.js +4 -2
  14. package/dist/lib/catch-all-target.js.map +1 -1
  15. package/dist/routes/pages/automations.d.ts.map +1 -1
  16. package/dist/routes/pages/automations.js +19 -16
  17. package/dist/routes/pages/automations.js.map +1 -1
  18. package/dist/server/lib/app-creation-store.d.ts.map +1 -1
  19. package/dist/server/lib/app-creation-store.js +31 -10
  20. package/dist/server/lib/app-creation-store.js.map +1 -1
  21. package/package.json +3 -3
  22. package/src/components/dispatch-control-plane.spec.tsx +3 -1
  23. package/src/components/dispatch-control-plane.tsx +2 -1
  24. package/src/components/layout/Layout.spec.tsx +143 -25
  25. package/src/components/layout/Layout.tsx +79 -47
  26. package/src/components/workspace-app-card.tsx +27 -1
  27. package/src/lib/catch-all-target.spec.ts +8 -0
  28. package/src/lib/catch-all-target.ts +4 -2
  29. package/src/routes/pages/automations.spec.tsx +240 -0
  30. package/src/routes/pages/automations.tsx +22 -16
  31. package/src/server/lib/app-creation-store.spec.ts +42 -15
  32. package/src/server/lib/app-creation-store.ts +36 -10
  33. package/src/styles/dispatch-css.spec.ts +3 -0
  34. package/src/styles/dispatch.css +5 -0
@@ -305,6 +305,13 @@ function workspaceAppUrl(appPath) {
305
305
  return null;
306
306
  }
307
307
  }
308
+ function isLocalWorkspaceGateway(url) {
309
+ const hostname = url.hostname.replace(/^\[|\]$/g, "").toLowerCase();
310
+ return (hostname === "localhost" ||
311
+ hostname === "127.0.0.1" ||
312
+ hostname === "0.0.0.0" ||
313
+ hostname === "::1");
314
+ }
308
315
  function workspaceAppLink(appPath, explicitUrl) {
309
316
  const urlValue = typeof explicitUrl === "string" ? explicitUrl.trim() : "";
310
317
  if (!urlValue)
@@ -1145,17 +1152,31 @@ async function readWorkspaceAppsFromGateway() {
1145
1152
  ...authHeaders,
1146
1153
  };
1147
1154
  try {
1148
- const localResponse = await fetch(gatewayUrl(WORKSPACE_APPS_GATEWAY_PATH), {
1149
- headers,
1150
- signal: controller.signal,
1151
- });
1152
- if (localResponse.ok) {
1153
- return parseWorkspaceAppsManifest(
1154
- // coercion-ok: malformed gateway JSON is an unavailable registry and
1155
- // must fall through to the local manifest sources.
1156
- await localResponse.json().catch(() => null));
1155
+ if (isLocalWorkspaceGateway(baseUrl)) {
1156
+ const localResponse = await fetch(gatewayUrl(WORKSPACE_APPS_GATEWAY_PATH), {
1157
+ headers,
1158
+ signal: controller.signal,
1159
+ });
1160
+ if (localResponse.ok) {
1161
+ return parseWorkspaceAppsManifest(
1162
+ // coercion-ok: malformed gateway JSON is an unavailable registry and
1163
+ // must fall through to the local manifest sources.
1164
+ await localResponse.json().catch(() => null));
1165
+ }
1157
1166
  }
1158
- if (!authHeaders.Authorization)
1167
+ const requestOrigin = requestContext?.requestOrigin;
1168
+ const isSameOriginGateway = requestOrigin
1169
+ ? (() => {
1170
+ try {
1171
+ return new URL(requestOrigin).origin === baseUrl.origin;
1172
+ }
1173
+ catch {
1174
+ // coercion-ok: an invalid request origin cannot prove a self-fetch.
1175
+ return false;
1176
+ }
1177
+ })()
1178
+ : false;
1179
+ if (isSameOriginGateway || !authHeaders.Authorization)
1159
1180
  return null;
1160
1181
  const actionUrl = gatewayUrl(WORKSPACE_APPS_ACTION_PATH);
1161
1182
  actionUrl.searchParams.set("includeAgentCards", "false");