@gradial/aci 0.1.52-rc.24 → 0.1.52-rc.25

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.52-rc.25 - 2026-09-30
4
+
5
+ ### Added
6
+
7
+ - Allow Astro builds to opt into framework-neutral `assets/` output with
8
+ `ACI_ASSET_PATH_LAYOUT=flat-assets`. Next.js rejects that layout until it
9
+ can produce the same public and stored paths safely.
10
+
11
+ ## 0.1.52-rc.24 - 2026-09-18
12
+
13
+ ### Added
14
+
15
+ - `withAci()` (Astro and Next.js) reads `ACI_ASSET_BASE_TPL` and, when it is
16
+ an absolute CDN URL, sets Vite's `base` / Next.js's `assetPrefix` to it so
17
+ the SSG build writes asset URLs pointing at the CDN directly — no HTML
18
+ post-processing needed. `__RELEASE_ID__` is stripped because build assets
19
+ are content-addressed and release-independent. Managed tenants (the
20
+ `/__r/__RELEASE_ID__/` default) are left untouched; the edge handler
21
+ rewrites relative paths to the global S3 key.
22
+
3
23
  ## 0.1.52-rc.7 - 2026-08-19
4
24
 
5
25
  ### Fixed
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Agentic Content Infrastructure SDK
2
2
 
3
- `@gradial/aci` `0.1.52-rc.24` is a pre-1.0 public-surface reset for the ACI
3
+ `@gradial/aci` `0.1.52-rc.25` is a pre-1.0 public-surface reset for the ACI
4
4
  client SDK. Breaking changes from the old `0.1.x` accidental surface are
5
5
  intentional: the root import is framework-neutral, framework runtime behavior is
6
6
  behind explicit subpaths, and the first required customer path is React/Next.
@@ -8,7 +8,7 @@ behind explicit subpaths, and the first required customer path is React/Next.
8
8
  ## Install
9
9
 
10
10
  ```bash
11
- npm install @gradial/aci@0.1.52-rc.24 zod@^4
11
+ npm install @gradial/aci@0.1.52-rc.25 zod@^4
12
12
  ```
13
13
 
14
14
  ## Root Import
@@ -130,13 +130,13 @@ host bundles select and serve immutable release artifacts.
130
130
  The first RC scaffold path is Next:
131
131
 
132
132
  ```bash
133
- npx @gradial/aci@0.1.52-rc.24 init my-site --template next-starter
133
+ npx @gradial/aci@0.1.52-rc.25 init my-site --template next-starter
134
134
  ```
135
135
 
136
136
  List available templates:
137
137
 
138
138
  ```bash
139
- npx @gradial/aci@0.1.52-rc.24 init --list
139
+ npx @gradial/aci@0.1.52-rc.25 init --list
140
140
  ```
141
141
 
142
142
  ## Personalization: The One-Tag Install
@@ -4,8 +4,12 @@ import type { BlockRef } from '../types/block-ref.js';
4
4
  interface AstroConfigSetupParams {
5
5
  injectScript(stage: 'head-inline' | 'page' | 'page-ssr', content: string): void;
6
6
  updateConfig(config: {
7
+ build?: {
8
+ assets?: string;
9
+ };
7
10
  vite?: {
8
11
  plugins?: unknown[];
12
+ base?: string;
9
13
  };
10
14
  }): void;
11
15
  }
@@ -83,6 +83,37 @@ export function withAci(options = {}) {
83
83
  name: 'aci-astro',
84
84
  hooks: {
85
85
  'astro:config:setup'({ injectScript, updateConfig }) {
86
+ const assetPathLayout = (process.env.ACI_ASSET_PATH_LAYOUT || 'preserve').trim();
87
+ if (assetPathLayout !== 'preserve' && assetPathLayout !== 'flat-assets') {
88
+ throw new Error('ACI_ASSET_PATH_LAYOUT must be preserve or flat-assets');
89
+ }
90
+ if (assetPathLayout === 'flat-assets') {
91
+ updateConfig({ build: { assets: 'assets' } });
92
+ }
93
+ // Asset URL prefix for production builds. When
94
+ // ACI_ASSET_BASE_TPL is an absolute CDN URL, use it as Vite's `base`
95
+ // so the SSG build writes asset URLs (CSS, JS, images) pointing at
96
+ // the CDN directly — no post-processing needed.
97
+ //
98
+ // Build assets are content-addressed (hashed filenames) and stored
99
+ // globally, so the URL is release-independent: strip __RELEASE_ID__.
100
+ // - Managed tenants (edge handler): ACI_ASSET_BASE_TPL is
101
+ // "/__r/__RELEASE_ID__/" or unset — do NOT set Vite base; the
102
+ // SSG writes relative paths (/_astro/foo.js) and the edge
103
+ // handler's viewer-request rewrites to the global S3 key.
104
+ // - External CDN tenants: "https://cdn.gradial.com/" → Vite base,
105
+ // Astro writes absolute CDN URLs.
106
+ const rawTpl = process.env.ACI_ASSET_BASE_TPL || '';
107
+ const assetBase = rawTpl
108
+ .replace('__RELEASE_ID__/', '')
109
+ .replace('__RELEASE_ID__', '')
110
+ .replace(/\/+$/, '/');
111
+ const isAbsoluteUrl = assetBase.startsWith('http://') || assetBase.startsWith('https://');
112
+ if (isAbsoluteUrl
113
+ && assetBase !== '/'
114
+ && process.env.NODE_ENV === 'production') {
115
+ updateConfig({ vite: { base: assetBase } });
116
+ }
86
117
  if (process.env.NODE_ENV === 'production') {
87
118
  return;
88
119
  }
@@ -33,9 +33,33 @@ export function withAci(nextConfig = {}, options = {}) {
33
33
  const userRewrites = nextConfig.rewrites;
34
34
  const userHeaders = nextConfig.headers;
35
35
  const userWebpack = nextConfig.webpack;
36
+ // Build assets (_next/static/*) are content-addressed and stored globally.
37
+ // When ACI_ASSET_BASE_TPL is an absolute CDN URL, strip __RELEASE_ID__
38
+ // (release-independent) and use it as Next.js's native assetPrefix so the
39
+ // build writes absolute CDN URLs for _next/static chunks — no post-
40
+ // processing needed.
41
+ // - Managed tenants (edge handler): "/__r/__RELEASE_ID__/" or unset →
42
+ // do not set assetPrefix; the SSG writes relative paths and the edge
43
+ // handler rewrites to the global S3 key.
44
+ // - External CDN tenants: "https://cdn.gradial.com/" → absolute CDN URLs.
45
+ const rawAssetBaseTpl = process.env.ACI_ASSET_BASE_TPL || '';
46
+ const assetPathLayout = (process.env.ACI_ASSET_PATH_LAYOUT || 'preserve').trim();
47
+ if (assetPathLayout !== 'preserve' && assetPathLayout !== 'flat-assets') {
48
+ throw new Error('ACI_ASSET_PATH_LAYOUT must be preserve or flat-assets');
49
+ }
50
+ if (assetPathLayout === 'flat-assets') {
51
+ throw new Error('ACI_ASSET_PATH_LAYOUT=flat-assets currently supports Astro builds only');
52
+ }
53
+ const cdnAssetPrefix = rawAssetBaseTpl
54
+ .replace('__RELEASE_ID__/', '')
55
+ .replace('__RELEASE_ID__', '')
56
+ .replace(/\/+$/, '/');
57
+ const isCdnUrl = cdnAssetPrefix.startsWith('http://') || cdnAssetPrefix.startsWith('https://');
58
+ const nextAssetPrefix = (isCdnUrl && cdnAssetPrefix !== '/') ? cdnAssetPrefix : undefined;
36
59
  return {
37
60
  ...nextConfig,
38
61
  output: 'standalone',
62
+ assetPrefix: nextAssetPrefix ?? nextConfig.assetPrefix,
39
63
  outputFileTracingRoot: nextConfig.outputFileTracingRoot ?? process.cwd(),
40
64
  headers: async () => {
41
65
  const gradialHeaders = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradial/aci",
3
- "version": "0.1.52-rc.24",
3
+ "version": "0.1.52-rc.25",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/gradial/bare-metal-go.git",
@@ -159,11 +159,11 @@
159
159
  "zod": "^4.0.0"
160
160
  },
161
161
  "optionalDependencies": {
162
- "@gradial/aci-cli-darwin-arm64": "0.1.52-rc.24",
163
- "@gradial/aci-cli-darwin-x64": "0.1.52-rc.24",
164
- "@gradial/aci-cli-linux-arm64": "0.1.52-rc.24",
165
- "@gradial/aci-cli-linux-x64": "0.1.52-rc.24",
166
- "@gradial/aci-cli-win32-arm64": "0.1.52-rc.24",
167
- "@gradial/aci-cli-win32-x64": "0.1.52-rc.24"
162
+ "@gradial/aci-cli-darwin-arm64": "0.1.52-rc.25",
163
+ "@gradial/aci-cli-darwin-x64": "0.1.52-rc.25",
164
+ "@gradial/aci-cli-linux-arm64": "0.1.52-rc.25",
165
+ "@gradial/aci-cli-linux-x64": "0.1.52-rc.25",
166
+ "@gradial/aci-cli-win32-arm64": "0.1.52-rc.25",
167
+ "@gradial/aci-cli-win32-x64": "0.1.52-rc.25"
168
168
  }
169
169
  }