@jami-studio/core 0.92.33 → 0.92.34

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.
@@ -1,5 +1,11 @@
1
1
  # @agent-native/core
2
2
 
3
+ ## 0.92.34
4
+
5
+ ### Patch Changes
6
+
7
+ - 28a9f38: `getConfiguredAppBasePath()` (and the Vite-env variant) now falls back to the per-module-graph baked `APP_BASE_PATH` on unified workerd deployments. Without it the auth guard could not strip the mount prefix, so app-declared public paths outside `/api` and `/_agent-native` (e.g. analytics `/track` ingest) never matched on the unified worker — cookieless callers got the guard's 401 while the same handler at an `/api/...` alias worked. Matches the Netlify preset, which delivers the same value via per-function env.
8
+
3
9
  ## 0.92.33
4
10
 
5
11
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.92.33",
3
+ "version": "0.92.34",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/studio-jami/jami-studio#readme",
6
6
  "bugs": {
@@ -1,3 +1,5 @@
1
+ import { getModuleGraphEnvDefault } from "../shared/global-scope.js";
2
+
1
3
  export function normalizeAppBasePath(value: string | undefined): string {
2
4
  if (!value || value === "/") return "";
3
5
  const trimmed = value.trim();
@@ -8,7 +10,16 @@ export function normalizeAppBasePath(value: string | undefined): string {
8
10
 
9
11
  export function getConfiguredAppBasePath(): string {
10
12
  return normalizeAppBasePath(
11
- process.env.VITE_APP_BASE_PATH || process.env.APP_BASE_PATH,
13
+ process.env.VITE_APP_BASE_PATH ||
14
+ process.env.APP_BASE_PATH ||
15
+ // Unified workerd deployments deliver per-app config via the module
16
+ // graph (shared process.env would cross-poison sibling apps). Without
17
+ // this, the auth guard cannot strip the mount prefix, so app-declared
18
+ // public paths outside /api and /_agent-native (e.g. analytics
19
+ // /track) never match on the unified worker. Matches the Netlify
20
+ // preset, which delivers the same value via per-function env.
21
+ getModuleGraphEnvDefault("VITE_APP_BASE_PATH") ||
22
+ getModuleGraphEnvDefault("APP_BASE_PATH"),
12
23
  );
13
24
  }
14
25
 
@@ -34,7 +45,9 @@ export function getAppBasePathFromViteEnv(): string {
34
45
  process.env.APP_BASE_PATH ||
35
46
  metaEnv?.VITE_APP_BASE_PATH ||
36
47
  metaEnv?.APP_BASE_PATH ||
37
- metaEnv?.BASE_URL,
48
+ metaEnv?.BASE_URL ||
49
+ getModuleGraphEnvDefault("VITE_APP_BASE_PATH") ||
50
+ getModuleGraphEnvDefault("APP_BASE_PATH"),
38
51
  );
39
52
  }
40
53
 
@@ -1 +1 @@
1
- {"version":3,"file":"app-base-path.d.ts","sourceRoot":"","sources":["../../src/server/app-base-path.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAMtE;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CAIjD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAalD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,QAAQ,SAA6B,GACpC,MAAM,CAOR;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAmBjE"}
1
+ {"version":3,"file":"app-base-path.d.ts","sourceRoot":"","sources":["../../src/server/app-base-path.ts"],"names":[],"mappings":"AAEA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAMtE;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CAajD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAelD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,QAAQ,SAA6B,GACpC,MAAM,CAOR;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAmBjE"}
@@ -1,3 +1,4 @@
1
+ import { getModuleGraphEnvDefault } from "../shared/global-scope.js";
1
2
  export function normalizeAppBasePath(value) {
2
3
  if (!value || value === "/")
3
4
  return "";
@@ -8,7 +9,16 @@ export function normalizeAppBasePath(value) {
8
9
  return normalized ? `/${normalized}` : "";
9
10
  }
10
11
  export function getConfiguredAppBasePath() {
11
- return normalizeAppBasePath(process.env.VITE_APP_BASE_PATH || process.env.APP_BASE_PATH);
12
+ return normalizeAppBasePath(process.env.VITE_APP_BASE_PATH ||
13
+ process.env.APP_BASE_PATH ||
14
+ // Unified workerd deployments deliver per-app config via the module
15
+ // graph (shared process.env would cross-poison sibling apps). Without
16
+ // this, the auth guard cannot strip the mount prefix, so app-declared
17
+ // public paths outside /api and /_agent-native (e.g. analytics
18
+ // /track) never match on the unified worker. Matches the Netlify
19
+ // preset, which delivers the same value via per-function env.
20
+ getModuleGraphEnvDefault("VITE_APP_BASE_PATH") ||
21
+ getModuleGraphEnvDefault("APP_BASE_PATH"));
12
22
  }
13
23
  /**
14
24
  * SSR-aware variant of getConfiguredAppBasePath.
@@ -27,7 +37,9 @@ export function getAppBasePathFromViteEnv() {
27
37
  process.env.APP_BASE_PATH ||
28
38
  metaEnv?.VITE_APP_BASE_PATH ||
29
39
  metaEnv?.APP_BASE_PATH ||
30
- metaEnv?.BASE_URL);
40
+ metaEnv?.BASE_URL ||
41
+ getModuleGraphEnvDefault("VITE_APP_BASE_PATH") ||
42
+ getModuleGraphEnvDefault("APP_BASE_PATH"));
31
43
  }
32
44
  /**
33
45
  * Strip the configured app base path prefix from a pathname.
@@ -1 +1 @@
1
- {"version":3,"file":"app-base-path.js","sourceRoot":"","sources":["../../src/server/app-base-path.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB,CAAC,KAAyB;IAC5D,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,GAAG;QAAE,OAAO,EAAE,CAAC;IACvC,MAAM,OAAO,GAAG,KAAK,CAAC,IAA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;IAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC3C,IAAI,CAAC,QAAQ;QAAE,OAAO,OAAO,CAAC;IAE9B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7B,MAAM,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACpD,IAAI,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,CAAC,EAAE,CAAC;YACjE,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,0DAA0D;IAC5D,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,CAAC,EAAE,CAAC;QACnE,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,OAAO,GAAG,QAAQ,EAAE,CAAC;AACjC,CAAC","sourcesContent":["export function normalizeAppBasePath(value: string | undefined): string {\r\n if (!value || value === \"/\") return \"\";\r\n const trimmed = value.trim();\r\n if (!trimmed || trimmed === \"/\") return \"\";\r\n const normalized = trimmed.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\r\n return normalized ? `/${normalized}` : \"\";\r\n}\r\n\r\nexport function getConfiguredAppBasePath(): string {\r\n return normalizeAppBasePath(\r\n process.env.VITE_APP_BASE_PATH || process.env.APP_BASE_PATH,\r\n );\r\n}\r\n\r\n/**\r\n * SSR-aware variant of getConfiguredAppBasePath.\r\n *\r\n * In SSR builds (Vite's server-side bundle), `process.env` may not carry\r\n * VITE_* variables that were only statically replaced at build time. As a\r\n * fallback this variant also checks `import.meta.env` (available inside a\r\n * Vite SSR build) including `BASE_URL`, which Vite sets from the `base`\r\n * config option. Used by ssr-handler.ts where the Nitro server bundle is\r\n * built with Vite and the env may be delivered via import.meta rather than\r\n * process.env.\r\n */\r\nexport function getAppBasePathFromViteEnv(): string {\r\n const metaEnv = (\r\n import.meta as unknown as {\r\n env?: Record<string, string | undefined>;\r\n }\r\n ).env;\r\n return normalizeAppBasePath(\r\n process.env.VITE_APP_BASE_PATH ||\r\n process.env.APP_BASE_PATH ||\r\n metaEnv?.VITE_APP_BASE_PATH ||\r\n metaEnv?.APP_BASE_PATH ||\r\n metaEnv?.BASE_URL,\r\n );\r\n}\r\n\r\n/**\r\n * Strip the configured app base path prefix from a pathname.\r\n *\r\n * Returns \"/\" when the pathname equals the base path exactly, the suffix\r\n * when it starts with `${basePath}/`, or the original pathname unchanged\r\n * when no prefix match is found.\r\n */\r\nexport function stripAppBasePath(\r\n pathname: string,\r\n basePath = getConfiguredAppBasePath(),\r\n): string {\r\n if (!basePath) return pathname;\r\n if (pathname === basePath) return \"/\";\r\n if (pathname.startsWith(`${basePath}/`)) {\r\n return pathname.slice(basePath.length) || \"/\";\r\n }\r\n return pathname;\r\n}\r\n\r\nexport function withConfiguredAppBasePath(baseUrl: string): string {\r\n const basePath = getConfiguredAppBasePath();\r\n const trimmed = baseUrl.replace(/\\/$/, \"\");\r\n if (!basePath) return trimmed;\r\n\r\n try {\r\n const url = new URL(trimmed);\r\n const pathname = normalizeAppBasePath(url.pathname);\r\n if (pathname === basePath || pathname.startsWith(`${basePath}/`)) {\r\n return trimmed;\r\n }\r\n } catch {\r\n // Fall through for relative or otherwise non-URL strings.\r\n }\r\n\r\n if (trimmed.endsWith(basePath) || trimmed.includes(`${basePath}/`)) {\r\n return trimmed;\r\n }\r\n return `${trimmed}${basePath}`;\r\n}\r\n"]}
1
+ {"version":3,"file":"app-base-path.js","sourceRoot":"","sources":["../../src/server/app-base-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,UAAU,oBAAoB,CAAC,KAAyB;IAC5D,IAAI,CAAC,KA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AK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACtC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,CAAC,EAAE,CAAC;QACxC,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC;IAChD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,OAAe;IACvD,MAAM,QAAQ,GAAG,wBAAwB,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC3C,IAAI,CAAC,QAAQ;QAAE,OAAO,OAAO,CAAC;IAE9B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7B,MAAM,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACpD,IAAI,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,CAAC,EAAE,CAAC;YACjE,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,0DAA0D;IAC5D,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,CAAC,EAAE,CAAC;QACnE,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,OAAO,GAAG,QAAQ,EAAE,CAAC;AACjC,CAAC","sourcesContent":["import { getModuleGraphEnvDefault } from \"../shared/global-scope.js\";\r\n\r\nexport function normalizeAppBasePath(value: string | undefined): string {\r\n if (!value || value === \"/\") return \"\";\r\n const trimmed = value.trim();\r\n if (!trimmed || trimmed === \"/\") return \"\";\r\n const normalized = trimmed.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\r\n return normalized ? `/${normalized}` : \"\";\r\n}\r\n\r\nexport function getConfiguredAppBasePath(): string {\r\n return normalizeAppBasePath(\r\n process.env.VITE_APP_BASE_PATH ||\r\n process.env.APP_BASE_PATH ||\r\n // Unified workerd deployments deliver per-app config via the module\r\n // graph (shared process.env would cross-poison sibling apps). Without\r\n // this, the auth guard cannot strip the mount prefix, so app-declared\r\n // public paths outside /api and /_agent-native (e.g. analytics\r\n // /track) never match on the unified worker. Matches the Netlify\r\n // preset, which delivers the same value via per-function env.\r\n getModuleGraphEnvDefault(\"VITE_APP_BASE_PATH\") ||\r\n getModuleGraphEnvDefault(\"APP_BASE_PATH\"),\r\n );\r\n}\r\n\r\n/**\r\n * SSR-aware variant of getConfiguredAppBasePath.\r\n *\r\n * In SSR builds (Vite's server-side bundle), `process.env` may not carry\r\n * VITE_* variables that were only statically replaced at build time. As a\r\n * fallback this variant also checks `import.meta.env` (available inside a\r\n * Vite SSR build) including `BASE_URL`, which Vite sets from the `base`\r\n * config option. Used by ssr-handler.ts where the Nitro server bundle is\r\n * built with Vite and the env may be delivered via import.meta rather than\r\n * process.env.\r\n */\r\nexport function getAppBasePathFromViteEnv(): string {\r\n const metaEnv = (\r\n import.meta as unknown as {\r\n env?: Record<string, string | undefined>;\r\n }\r\n ).env;\r\n return normalizeAppBasePath(\r\n process.env.VITE_APP_BASE_PATH ||\r\n process.env.APP_BASE_PATH ||\r\n metaEnv?.VITE_APP_BASE_PATH ||\r\n metaEnv?.APP_BASE_PATH ||\r\n metaEnv?.BASE_URL ||\r\n getModuleGraphEnvDefault(\"VITE_APP_BASE_PATH\") ||\r\n getModuleGraphEnvDefault(\"APP_BASE_PATH\"),\r\n );\r\n}\r\n\r\n/**\r\n * Strip the configured app base path prefix from a pathname.\r\n *\r\n * Returns \"/\" when the pathname equals the base path exactly, the suffix\r\n * when it starts with `${basePath}/`, or the original pathname unchanged\r\n * when no prefix match is found.\r\n */\r\nexport function stripAppBasePath(\r\n pathname: string,\r\n basePath = getConfiguredAppBasePath(),\r\n): string {\r\n if (!basePath) return pathname;\r\n if (pathname === basePath) return \"/\";\r\n if (pathname.startsWith(`${basePath}/`)) {\r\n return pathname.slice(basePath.length) || \"/\";\r\n }\r\n return pathname;\r\n}\r\n\r\nexport function withConfiguredAppBasePath(baseUrl: string): string {\r\n const basePath = getConfiguredAppBasePath();\r\n const trimmed = baseUrl.replace(/\\/$/, \"\");\r\n if (!basePath) return trimmed;\r\n\r\n try {\r\n const url = new URL(trimmed);\r\n const pathname = normalizeAppBasePath(url.pathname);\r\n if (pathname === basePath || pathname.startsWith(`${basePath}/`)) {\r\n return trimmed;\r\n }\r\n } catch {\r\n // Fall through for relative or otherwise non-URL strings.\r\n }\r\n\r\n if (trimmed.endsWith(basePath) || trimmed.includes(`${basePath}/`)) {\r\n return trimmed;\r\n }\r\n return `${trimmed}${basePath}`;\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jami-studio/core",
3
- "version": "0.92.33",
3
+ "version": "0.92.34",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/studio-jami/jami-studio#readme",
6
6
  "bugs": {