@ekairos/story 1.21.40-beta.0 → 1.21.41-beta.0

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/dist/next.d.ts CHANGED
@@ -11,6 +11,7 @@ type WithEkairosRuntimeOptions = {
11
11
  */
12
12
  bootstrapModule: string;
13
13
  };
14
+ type NextConfigFnLike = (phase: string, ctx: any) => Promise<any> | any;
14
15
  /**
15
16
  * Next.js helper to ensure the story runtime factory is registered in *every* server bundle.
16
17
  *
@@ -19,5 +20,5 @@ type WithEkairosRuntimeOptions = {
19
20
  * - No "magic" root bootstrap file
20
21
  * - Works for step runtimes because the server entry will always evaluate your bootstrap module
21
22
  */
22
- export declare function withEkairosRuntime(nextConfig: NextConfigLike, opts: WithEkairosRuntimeOptions): NextConfigLike;
23
+ export declare function withEkairosRuntime(nextConfigOrFn: NextConfigLike | NextConfigFnLike, opts: WithEkairosRuntimeOptions): any;
23
24
  export {};
package/dist/next.js CHANGED
@@ -72,34 +72,47 @@ function injectBootstrapIntoEntries(entries, bootstrap) {
72
72
  * - No "magic" root bootstrap file
73
73
  * - Works for step runtimes because the server entry will always evaluate your bootstrap module
74
74
  */
75
- export function withEkairosRuntime(nextConfig, opts) {
75
+ export function withEkairosRuntime(nextConfigOrFn, opts) {
76
76
  const bootstrapModule = opts.bootstrapModule;
77
- const userWebpack = nextConfig.webpack ?? undefined;
78
- return {
79
- ...nextConfig,
80
- webpack: (config, options) => {
81
- const out = userWebpack ? userWebpack(config, options) : config;
82
- // Patch the generated workflow step route (esbuild output) so it imports
83
- // the app's `ekairos.ts`, which registers `ekairosConfig` globally.
84
- //
85
- // This is necessary because the steps bundle is produced by @workflow/builders
86
- // (esbuild) and does NOT run through Next's webpack entrypoints.
87
- patchWorkflowStepRouteToImportBootstrap(bootstrapModule);
88
- if (!options?.isServer)
77
+ const apply = (nextConfig) => {
78
+ const userWebpack = nextConfig.webpack ?? undefined;
79
+ return {
80
+ ...nextConfig,
81
+ webpack: (config, options) => {
82
+ const out = userWebpack ? userWebpack(config, options) : config;
83
+ // NOTE:
84
+ // - We still attempt the patch here for webpack builds.
85
+ // - But for Turbopack builds, this hook may never run, so we ALSO patch
86
+ // in the config-function wrapper below (after withWorkflow generates the file).
87
+ patchWorkflowStepRouteToImportBootstrap(bootstrapModule);
88
+ if (!options?.isServer)
89
+ return out;
90
+ const req = createRequire(import.meta.url);
91
+ const contextDir = (out && out.context) || process.cwd();
92
+ // Resolve relative to the app project (webpack context), not to this package.
93
+ const resolvedBootstrap = req.resolve(bootstrapModule, {
94
+ paths: [contextDir],
95
+ });
96
+ const originalEntry = out.entry;
97
+ out.entry = async () => {
98
+ const entries = typeof originalEntry === "function" ? await originalEntry() : originalEntry;
99
+ injectBootstrapIntoEntries(entries, resolvedBootstrap);
100
+ return entries;
101
+ };
89
102
  return out;
90
- const req = createRequire(import.meta.url);
91
- const contextDir = (out && out.context) || process.cwd();
92
- // Resolve relative to the app project (webpack context), not to this package.
93
- const resolvedBootstrap = req.resolve(bootstrapModule, {
94
- paths: [contextDir],
95
- });
96
- const originalEntry = out.entry;
97
- out.entry = async () => {
98
- const entries = typeof originalEntry === "function" ? await originalEntry() : originalEntry;
99
- injectBootstrapIntoEntries(entries, resolvedBootstrap);
100
- return entries;
101
- };
102
- return out;
103
- },
103
+ },
104
+ };
104
105
  };
106
+ // Critical path for Vercel/Turbopack:
107
+ // `@workflow/next` generates `src/app/.well-known/workflow/v1/step/route.js` inside its config function.
108
+ // So we must patch AFTER that function runs (not inside webpack).
109
+ if (typeof nextConfigOrFn === "function") {
110
+ return async (phase, ctx) => {
111
+ const cfg = await nextConfigOrFn(phase, ctx);
112
+ patchWorkflowStepRouteToImportBootstrap(bootstrapModule);
113
+ return apply(cfg);
114
+ };
115
+ }
116
+ // Object config: best-effort patch (file may not exist yet here)
117
+ return apply(nextConfigOrFn);
105
118
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ekairos/story",
3
- "version": "1.21.40-beta.0",
3
+ "version": "1.21.41-beta.0",
4
4
  "description": "Pulzar Story - Workflow-based AI Stories",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@ai-sdk/openai": "^2.0.52",
51
- "@ekairos/domain": "^1.21.40-beta.0",
51
+ "@ekairos/domain": "^1.21.41-beta.0",
52
52
  "@instantdb/admin": "^0.22.13",
53
53
  "@instantdb/core": "^0.22.13",
54
54
  "@vercel/sandbox": "^0.0.23",