@ai-ins/nextjs 0.1.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/index.cjs ADDED
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ aiIns: () => aiIns,
24
+ default: () => index_default,
25
+ withAiIns: () => withAiIns
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+ var import_node_http = require("http");
29
+ var import_node_fs = require("fs");
30
+ var import_node_path = require("path");
31
+ var import_core = require("@ai-ins/core");
32
+ var packageDirectory = __dirname;
33
+ var developmentPhase = "phase-development-server";
34
+ var aiInsServers = /* @__PURE__ */ new Map();
35
+ function getBundledAssetPath(fileName) {
36
+ const sourcePath = (0, import_node_path.join)(packageDirectory, "..", "src", fileName);
37
+ return (0, import_node_fs.existsSync)(sourcePath) ? sourcePath : (0, import_node_path.join)(packageDirectory, fileName);
38
+ }
39
+ var clientEntryPath = getBundledAssetPath("client-entry.js");
40
+ var sourceLoaderPath = getBundledAssetPath("source-loader.cjs");
41
+ function hasEntryValue(entry, value) {
42
+ if (entry === value) return true;
43
+ if (Array.isArray(entry)) return entry.some((item) => hasEntryValue(item, value));
44
+ if (entry && typeof entry === "object") return Object.values(entry).some((item) => hasEntryValue(item, value));
45
+ return false;
46
+ }
47
+ function prependEntry(entry, value) {
48
+ if (hasEntryValue(entry, value)) return entry;
49
+ if (!entry) return [value];
50
+ if (typeof entry === "string") return [value, entry];
51
+ if (Array.isArray(entry)) return [value, ...entry];
52
+ if (typeof entry === "function") {
53
+ return async (...args) => prependEntry(await entry(...args), value);
54
+ }
55
+ if (entry && typeof entry === "object") {
56
+ if ("import" in entry) {
57
+ return { ...entry, import: prependEntry(entry.import, value) };
58
+ }
59
+ return Object.fromEntries(Object.entries(entry).map(([key, childEntry]) => [key, prependEntry(childEntry, value)]));
60
+ }
61
+ return entry;
62
+ }
63
+ function normalizeRoot(root) {
64
+ return root || process.cwd();
65
+ }
66
+ function getServerKey(root, options) {
67
+ return `${root}:${options.middlewarePort ?? 0}`;
68
+ }
69
+ function dispatch(routes, req, res) {
70
+ const pathname = req.url ? new URL(req.url, "http://localhost").pathname : "/";
71
+ const route = routes.find((candidate) => pathname === candidate.path || pathname.startsWith(`${candidate.path}/`));
72
+ if (!route) {
73
+ res.statusCode = 404;
74
+ res.end("AI Ins route not found");
75
+ return;
76
+ }
77
+ route.middleware(req, res);
78
+ }
79
+ function startAiInsServer(root, options) {
80
+ const key = getServerKey(root, options);
81
+ const existing = aiInsServers.get(key);
82
+ if (existing) {
83
+ return existing;
84
+ }
85
+ const promise = new Promise((resolve, reject) => {
86
+ const pluginProxy = (0, import_core.normalizeProxy)(options.codex?.proxy ?? options.proxy);
87
+ const routes = [
88
+ {
89
+ path: "/__ai-ins/client.js",
90
+ middleware: (_req, res) => {
91
+ res.setHeader("Content-Type", "application/javascript; charset=utf-8");
92
+ res.end((0, import_core.getAiInsClientCode)({ base: "/", defaultProvider: options.agents?.defaultProvider, options, pluginProxy, root }));
93
+ }
94
+ },
95
+ ...(0, import_core.createAiInsMiddlewares)(root, options)
96
+ ].sort((left, right) => right.path.length - left.path.length);
97
+ const server = (0, import_node_http.createServer)((req, res) => dispatch(routes, req, res));
98
+ server.once("error", reject);
99
+ server.listen(options.middlewarePort ?? 0, "127.0.0.1", () => {
100
+ server.off("error", reject);
101
+ const address = server.address();
102
+ if (!address || typeof address === "string") {
103
+ reject(new Error("failed to start AI Ins middleware server"));
104
+ return;
105
+ }
106
+ resolve({ port: address.port, server });
107
+ });
108
+ });
109
+ aiInsServers.set(key, promise);
110
+ return promise;
111
+ }
112
+ function appendWebpackRule(config) {
113
+ if (!config.module) config.module = {};
114
+ const rules = config.module.rules ?? [];
115
+ config.module.rules = [
116
+ ...rules,
117
+ {
118
+ enforce: "pre",
119
+ exclude: /node_modules/u,
120
+ test: /\.[cm]?[jt]sx$/u,
121
+ use: sourceLoaderPath
122
+ }
123
+ ];
124
+ }
125
+ function withWebpackConfig(config, options) {
126
+ const previousWebpack = config.webpack;
127
+ return {
128
+ ...config,
129
+ webpack(webpackConfig, context) {
130
+ const nextWebpackConfig = previousWebpack ? previousWebpack(webpackConfig, context) : webpackConfig;
131
+ if (context.dev && !context.isServer) {
132
+ nextWebpackConfig.entry = prependEntry(nextWebpackConfig.entry, clientEntryPath);
133
+ }
134
+ if (context.dev && !options.disableSourceAttributes) {
135
+ appendWebpackRule(nextWebpackConfig);
136
+ }
137
+ return nextWebpackConfig;
138
+ }
139
+ };
140
+ }
141
+ function withTurbopackConfig(config, options) {
142
+ if (options.disableSourceAttributes) {
143
+ return config;
144
+ }
145
+ const turbopack = config.turbopack ?? {};
146
+ const rules = turbopack.rules ?? {};
147
+ return {
148
+ ...config,
149
+ turbopack: {
150
+ ...turbopack,
151
+ rules: {
152
+ ...rules,
153
+ "*.{jsx,tsx}": {
154
+ as: "*.js",
155
+ loaders: [sourceLoaderPath]
156
+ }
157
+ }
158
+ }
159
+ };
160
+ }
161
+ async function resolveRewrites(rewrites) {
162
+ const value = typeof rewrites === "function" ? await rewrites() : rewrites;
163
+ if (!value) {
164
+ return [];
165
+ }
166
+ return value;
167
+ }
168
+ async function mergeRewrites(rewrites, middlewarePort) {
169
+ const aiInsRewrites = [
170
+ {
171
+ source: "/__ai-ins/:path*",
172
+ destination: `http://127.0.0.1:${middlewarePort}/__ai-ins/:path*`
173
+ },
174
+ {
175
+ source: "/__ai-ins-agent/:path*",
176
+ destination: `http://127.0.0.1:${middlewarePort}/__ai-ins-agent/:path*`
177
+ },
178
+ {
179
+ source: "/__open-in-editor",
180
+ destination: `http://127.0.0.1:${middlewarePort}/__open-in-editor`
181
+ },
182
+ {
183
+ source: "/__reveal-in-folder",
184
+ destination: `http://127.0.0.1:${middlewarePort}/__reveal-in-folder`
185
+ }
186
+ ];
187
+ const existing = await resolveRewrites(rewrites);
188
+ if (Array.isArray(existing)) {
189
+ return [...aiInsRewrites, ...existing];
190
+ }
191
+ return {
192
+ ...existing,
193
+ beforeFiles: [...aiInsRewrites, ...existing.beforeFiles ?? []]
194
+ };
195
+ }
196
+ function withAiIns(nextConfig = {}, options = {}) {
197
+ return async (phase, context) => {
198
+ const resolvedConfig = typeof nextConfig === "function" ? await nextConfig(phase, context) : nextConfig;
199
+ const root = normalizeRoot(typeof context === "object" && context && "dir" in context ? String(context.dir ?? "") : void 0);
200
+ const config = withTurbopackConfig(withWebpackConfig(resolvedConfig, options), options);
201
+ if (phase !== developmentPhase) {
202
+ return config;
203
+ }
204
+ const { port } = await startAiInsServer(root, options);
205
+ const previousRewrites = config.rewrites;
206
+ return {
207
+ ...config,
208
+ async rewrites() {
209
+ return mergeRewrites(previousRewrites, port);
210
+ }
211
+ };
212
+ };
213
+ }
214
+ var aiIns = withAiIns;
215
+ var index_default = withAiIns;
216
+ // Annotate the CommonJS export names for ESM import in node:
217
+ 0 && (module.exports = {
218
+ aiIns,
219
+ withAiIns
220
+ });
221
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createServer, type IncomingMessage, type Server, type ServerResponse } from 'node:http'\nimport { existsSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { createAiInsMiddlewares, getAiInsClientCode, normalizeProxy } from '@ai-ins/core'\nimport type { AiInsMiddleware, AiInsPluginOptions } from '@ai-ins/core'\n\nexport type { AiInsPluginOptions }\n\nexport type AiInsNextPluginOptions = AiInsPluginOptions & {\n middlewarePort?: number\n}\n\ntype NextConfig = import('next').NextConfig & {\n rewrites?: NextRewrites\n turbopack?: {\n rules?: Record<string, unknown>\n } & import('next').NextConfig['turbopack']\n}\n\ntype NextConfigExport = NextConfig | ((phase: string, context?: unknown) => NextConfig | Promise<NextConfig>)\n\ntype NextRewrites =\n | (() => Promise<Rewrite[] | { afterFiles?: Rewrite[]; beforeFiles?: Rewrite[]; fallback?: Rewrite[] }>)\n | Rewrite[]\n | { afterFiles?: Rewrite[]; beforeFiles?: Rewrite[]; fallback?: Rewrite[] }\n\ntype Rewrite = {\n destination: string\n source: string\n}\n\ntype WebpackConfig = {\n entry?: unknown\n module?: {\n rules?: unknown[]\n }\n}\n\ntype WebpackContext = {\n dev?: boolean\n dir?: string\n isServer?: boolean\n}\n\ntype AiInsServerState = {\n port: number\n server: Server\n}\n\nconst packageDirectory = __dirname\nconst developmentPhase = 'phase-development-server'\nconst aiInsServers = new Map<string, Promise<AiInsServerState>>()\n\nfunction getBundledAssetPath(fileName: string) {\n const sourcePath = join(packageDirectory, '..', 'src', fileName)\n return existsSync(sourcePath) ? sourcePath : join(packageDirectory, fileName)\n}\n\nconst clientEntryPath = getBundledAssetPath('client-entry.js')\nconst sourceLoaderPath = getBundledAssetPath('source-loader.cjs')\n\nfunction hasEntryValue(entry: unknown, value: string): boolean {\n if (entry === value) return true\n if (Array.isArray(entry)) return entry.some((item) => hasEntryValue(item, value))\n if (entry && typeof entry === 'object') return Object.values(entry).some((item) => hasEntryValue(item, value))\n return false\n}\n\nfunction prependEntry(entry: unknown, value: string): unknown {\n if (hasEntryValue(entry, value)) return entry\n if (!entry) return [value]\n if (typeof entry === 'string') return [value, entry]\n if (Array.isArray(entry)) return [value, ...entry]\n if (typeof entry === 'function') {\n return async (...args: unknown[]) => prependEntry(await entry(...args), value)\n }\n if (entry && typeof entry === 'object') {\n if ('import' in entry) {\n return { ...entry, import: prependEntry((entry as { import?: unknown }).import, value) }\n }\n\n return Object.fromEntries(Object.entries(entry).map(([key, childEntry]) => [key, prependEntry(childEntry, value)]))\n }\n\n return entry\n}\n\nfunction normalizeRoot(root: string | undefined) {\n return root || process.cwd()\n}\n\nfunction getServerKey(root: string, options: AiInsNextPluginOptions) {\n return `${root}:${options.middlewarePort ?? 0}`\n}\n\nfunction dispatch(routes: Array<{ middleware: AiInsMiddleware; path: string }>, req: IncomingMessage, res: ServerResponse) {\n const pathname = req.url ? new URL(req.url, 'http://localhost').pathname : '/'\n const route = routes.find((candidate) => pathname === candidate.path || pathname.startsWith(`${candidate.path}/`))\n\n if (!route) {\n res.statusCode = 404\n res.end('AI Ins route not found')\n return\n }\n\n route.middleware(req, res)\n}\n\nfunction startAiInsServer(root: string, options: AiInsNextPluginOptions) {\n const key = getServerKey(root, options)\n const existing = aiInsServers.get(key)\n if (existing) {\n return existing\n }\n\n const promise = new Promise<AiInsServerState>((resolve, reject) => {\n const pluginProxy = normalizeProxy(options.codex?.proxy ?? options.proxy)\n const routes = [\n {\n path: '/__ai-ins/client.js',\n middleware: (_req: IncomingMessage, res: ServerResponse) => {\n res.setHeader('Content-Type', 'application/javascript; charset=utf-8')\n res.end(getAiInsClientCode({ base: '/', defaultProvider: options.agents?.defaultProvider, options, pluginProxy, root }))\n },\n },\n ...createAiInsMiddlewares(root, options),\n ].sort((left, right) => right.path.length - left.path.length)\n\n const server = createServer((req, res) => dispatch(routes, req, res))\n server.once('error', reject)\n server.listen(options.middlewarePort ?? 0, '127.0.0.1', () => {\n server.off('error', reject)\n const address = server.address()\n if (!address || typeof address === 'string') {\n reject(new Error('failed to start AI Ins middleware server'))\n return\n }\n\n resolve({ port: address.port, server })\n })\n })\n\n aiInsServers.set(key, promise)\n return promise\n}\n\nfunction appendWebpackRule(config: WebpackConfig) {\n if (!config.module) config.module = {}\n const rules = config.module.rules ?? []\n config.module.rules = [\n ...rules,\n {\n enforce: 'pre',\n exclude: /node_modules/u,\n test: /\\.[cm]?[jt]sx$/u,\n use: sourceLoaderPath,\n },\n ]\n}\n\nfunction withWebpackConfig(config: NextConfig, options: AiInsNextPluginOptions): NextConfig {\n const previousWebpack = config.webpack as ((config: WebpackConfig, context: WebpackContext) => WebpackConfig) | null | undefined\n\n return {\n ...config,\n webpack(webpackConfig: WebpackConfig, context: WebpackContext) {\n const nextWebpackConfig = previousWebpack ? previousWebpack(webpackConfig, context) : webpackConfig\n if (context.dev && !context.isServer) {\n nextWebpackConfig.entry = prependEntry(nextWebpackConfig.entry, clientEntryPath)\n }\n if (context.dev && !options.disableSourceAttributes) {\n appendWebpackRule(nextWebpackConfig)\n }\n return nextWebpackConfig\n },\n }\n}\n\nfunction withTurbopackConfig(config: NextConfig, options: AiInsNextPluginOptions): NextConfig {\n if (options.disableSourceAttributes) {\n return config\n }\n\n const turbopack = config.turbopack ?? {}\n const rules = turbopack.rules ?? {}\n\n return {\n ...config,\n turbopack: {\n ...turbopack,\n rules: {\n ...rules,\n '*.{jsx,tsx}': {\n as: '*.js',\n loaders: [sourceLoaderPath],\n },\n },\n },\n }\n}\n\nasync function resolveRewrites(rewrites: NextRewrites | undefined) {\n const value = typeof rewrites === 'function' ? await rewrites() : rewrites\n if (!value) {\n return []\n }\n\n return value\n}\n\nasync function mergeRewrites(rewrites: NextRewrites | undefined, middlewarePort: number) {\n const aiInsRewrites: Rewrite[] = [\n {\n source: '/__ai-ins/:path*',\n destination: `http://127.0.0.1:${middlewarePort}/__ai-ins/:path*`,\n },\n {\n source: '/__ai-ins-agent/:path*',\n destination: `http://127.0.0.1:${middlewarePort}/__ai-ins-agent/:path*`,\n },\n {\n source: '/__open-in-editor',\n destination: `http://127.0.0.1:${middlewarePort}/__open-in-editor`,\n },\n {\n source: '/__reveal-in-folder',\n destination: `http://127.0.0.1:${middlewarePort}/__reveal-in-folder`,\n },\n ]\n const existing = await resolveRewrites(rewrites)\n\n if (Array.isArray(existing)) {\n return [...aiInsRewrites, ...existing]\n }\n\n return {\n ...existing,\n beforeFiles: [...aiInsRewrites, ...(existing.beforeFiles ?? [])],\n }\n}\n\nexport function withAiIns(nextConfig: NextConfigExport = {}, options: AiInsNextPluginOptions = {}) {\n return async (phase: string, context?: unknown) => {\n const resolvedConfig = typeof nextConfig === 'function' ? await nextConfig(phase, context) : nextConfig\n const root = normalizeRoot(typeof context === 'object' && context && 'dir' in context ? String((context as { dir?: unknown }).dir ?? '') : undefined)\n const config = withTurbopackConfig(withWebpackConfig(resolvedConfig, options), options)\n\n if (phase !== developmentPhase) {\n return config\n }\n\n const { port } = await startAiInsServer(root, options)\n const previousRewrites = config.rewrites\n\n return {\n ...config,\n async rewrites() {\n return mergeRewrites(previousRewrites, port)\n },\n }\n }\n}\n\nexport const aiIns = withAiIns\nexport default withAiIns\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAqF;AACrF,qBAA2B;AAC3B,uBAAqB;AACrB,kBAA2E;AA8C3E,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AACzB,IAAM,eAAe,oBAAI,IAAuC;AAEhE,SAAS,oBAAoB,UAAkB;AAC7C,QAAM,iBAAa,uBAAK,kBAAkB,MAAM,OAAO,QAAQ;AAC/D,aAAO,2BAAW,UAAU,IAAI,iBAAa,uBAAK,kBAAkB,QAAQ;AAC9E;AAEA,IAAM,kBAAkB,oBAAoB,iBAAiB;AAC7D,IAAM,mBAAmB,oBAAoB,mBAAmB;AAEhE,SAAS,cAAc,OAAgB,OAAwB;AAC7D,MAAI,UAAU,MAAO,QAAO;AAC5B,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,KAAK,CAAC,SAAS,cAAc,MAAM,KAAK,CAAC;AAChF,MAAI,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;AAAA,MACR,aAAa,oBAAoB,cAAc;AAAA,IACjD;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,aAAa,oBAAoB,cAAc;AAAA,IACjD;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,aAAa,oBAAoB,cAAc;AAAA,IACjD;AAAA,EACF;AACA,QAAM,WAAW,MAAM,gBAAgB,QAAQ;AAE/C,MAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,WAAO,CAAC,GAAG,eAAe,GAAG,QAAQ;AAAA,EACvC;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,aAAa,CAAC,GAAG,eAAe,GAAI,SAAS,eAAe,CAAC,CAAE;AAAA,EACjE;AACF;AAEO,SAAS,UAAU,aAA+B,CAAC,GAAG,UAAkC,CAAC,GAAG;AACjG,SAAO,OAAO,OAAe,YAAsB;AACjD,UAAM,iBAAiB,OAAO,eAAe,aAAa,MAAM,WAAW,OAAO,OAAO,IAAI;AAC7F,UAAM,OAAO,cAAc,OAAO,YAAY,YAAY,WAAW,SAAS,UAAU,OAAQ,QAA8B,OAAO,EAAE,IAAI,MAAS;AACpJ,UAAM,SAAS,oBAAoB,kBAAkB,gBAAgB,OAAO,GAAG,OAAO;AAEtF,QAAI,UAAU,kBAAkB;AAC9B,aAAO;AAAA,IACT;AAEA,UAAM,EAAE,KAAK,IAAI,MAAM,iBAAiB,MAAM,OAAO;AACrD,UAAM,mBAAmB,OAAO;AAEhC,WAAO;AAAA,MACL,GAAG;AAAA,MACH,MAAM,WAAW;AACf,eAAO,cAAc,kBAAkB,IAAI;AAAA,MAC7C;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,QAAQ;AACrB,IAAO,gBAAQ;","names":[]}
@@ -0,0 +1,158 @@
1
+ import * as next_dist_shared_lib_image_config from 'next/dist/shared/lib/image-config';
2
+ import * as next_dist_lib_load_custom_routes from 'next/dist/lib/load-custom-routes';
3
+ import * as next_dist_server_config_shared from 'next/dist/server/config-shared';
4
+ import * as next from 'next';
5
+ import { AiInsPluginOptions } from '@ai-ins/core';
6
+ export { AiInsPluginOptions } from '@ai-ins/core';
7
+
8
+ type AiInsNextPluginOptions = AiInsPluginOptions & {
9
+ middlewarePort?: number;
10
+ };
11
+ type NextConfig = next.NextConfig & {
12
+ rewrites?: NextRewrites;
13
+ turbopack?: {
14
+ rules?: Record<string, unknown>;
15
+ } & next.NextConfig['turbopack'];
16
+ };
17
+ type NextConfigExport = NextConfig | ((phase: string, context?: unknown) => NextConfig | Promise<NextConfig>);
18
+ type NextRewrites = (() => Promise<Rewrite[] | {
19
+ afterFiles?: Rewrite[];
20
+ beforeFiles?: Rewrite[];
21
+ fallback?: Rewrite[];
22
+ }>) | Rewrite[] | {
23
+ afterFiles?: Rewrite[];
24
+ beforeFiles?: Rewrite[];
25
+ fallback?: Rewrite[];
26
+ };
27
+ type Rewrite = {
28
+ destination: string;
29
+ source: string;
30
+ };
31
+ declare function withAiIns(nextConfig?: NextConfigExport, options?: AiInsNextPluginOptions): (phase: string, context?: unknown) => Promise<NextConfig | {
32
+ rewrites(): Promise<Rewrite[] | {
33
+ beforeFiles: Rewrite[];
34
+ afterFiles?: Rewrite[];
35
+ fallback?: Rewrite[];
36
+ }>;
37
+ allowedDevOrigins?: string[];
38
+ exportPathMap?: (defaultMap: next_dist_server_config_shared.ExportPathMap, ctx: {
39
+ dev: boolean;
40
+ dir: string;
41
+ outDir: string | null;
42
+ distDir: string;
43
+ buildId: string;
44
+ }) => Promise<next_dist_server_config_shared.ExportPathMap> | next_dist_server_config_shared.ExportPathMap;
45
+ i18n?: next_dist_server_config_shared.I18NConfig | null;
46
+ typescript?: next_dist_server_config_shared.TypeScriptConfig;
47
+ typedRoutes?: boolean;
48
+ headers?: () => Promise<next_dist_lib_load_custom_routes.Header[]> | next_dist_lib_load_custom_routes.Header[];
49
+ redirects?: () => Promise<next_dist_lib_load_custom_routes.Redirect[]> | next_dist_lib_load_custom_routes.Redirect[];
50
+ excludeDefaultMomentLocales?: boolean;
51
+ webpack?: next_dist_server_config_shared.NextJsWebpackConfig | null;
52
+ trailingSlash?: boolean;
53
+ env?: Record<string, string | undefined>;
54
+ distDir?: string;
55
+ cleanDistDir?: boolean;
56
+ assetPrefix?: string;
57
+ cacheHandler?: string | undefined;
58
+ adapterPath?: string;
59
+ cacheHandlers?: {
60
+ default?: string;
61
+ remote?: string;
62
+ static?: string;
63
+ [handlerName: string]: string | undefined;
64
+ };
65
+ cacheMaxMemorySize?: number;
66
+ useFileSystemPublicRoutes?: boolean;
67
+ generateBuildId?: () => string | null | Promise<string | null>;
68
+ generateEtags?: boolean;
69
+ pageExtensions?: string[];
70
+ compress?: boolean;
71
+ poweredByHeader?: boolean;
72
+ images?: next_dist_shared_lib_image_config.ImageConfig;
73
+ devIndicators?: false | {
74
+ position?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
75
+ };
76
+ onDemandEntries?: {
77
+ maxInactiveAge?: number;
78
+ pagesBufferLength?: number;
79
+ };
80
+ deploymentId?: string;
81
+ basePath?: string;
82
+ sassOptions?: {
83
+ implementation?: string;
84
+ [key: string]: any;
85
+ };
86
+ productionBrowserSourceMaps?: boolean;
87
+ reactCompiler?: boolean | next_dist_server_config_shared.ReactCompilerOptions;
88
+ reactProductionProfiling?: boolean;
89
+ reactStrictMode?: boolean | null;
90
+ reactMaxHeadersLength?: number;
91
+ httpAgentOptions?: {
92
+ keepAlive?: boolean;
93
+ };
94
+ staticPageGenerationTimeout?: number;
95
+ crossOrigin?: "anonymous" | "use-credentials";
96
+ compiler?: {
97
+ reactRemoveProperties?: boolean | {
98
+ properties?: string[];
99
+ };
100
+ relay?: {
101
+ src: string;
102
+ artifactDirectory?: string;
103
+ language?: "typescript" | "javascript" | "flow";
104
+ eagerEsModules?: boolean;
105
+ };
106
+ removeConsole?: boolean | {
107
+ exclude?: string[];
108
+ };
109
+ styledComponents?: boolean | next_dist_server_config_shared.StyledComponentsConfig;
110
+ emotion?: boolean | next_dist_server_config_shared.EmotionConfig;
111
+ styledJsx?: boolean | {
112
+ useLightningcss?: boolean;
113
+ };
114
+ define?: Record<string, string | number | boolean>;
115
+ defineServer?: Record<string, string | number | boolean>;
116
+ runAfterProductionCompile?: (metadata: {
117
+ projectDir: string;
118
+ distDir: string;
119
+ }) => Promise<void>;
120
+ };
121
+ output?: "standalone" | "export";
122
+ transpilePackages?: string[];
123
+ turbopack?: (next_dist_server_config_shared.TurbopackOptions & {
124
+ rules?: Record<string, unknown>;
125
+ }) | undefined;
126
+ skipMiddlewareUrlNormalize?: boolean;
127
+ skipProxyUrlNormalize?: boolean;
128
+ skipTrailingSlashRedirect?: boolean;
129
+ modularizeImports?: Record<string, {
130
+ transform: string | Record<string, string>;
131
+ preventFullImport?: boolean;
132
+ skipDefaultConversion?: boolean;
133
+ }>;
134
+ logging?: next_dist_server_config_shared.LoggingConfig | false;
135
+ enablePrerenderSourceMaps?: boolean;
136
+ cacheComponents?: boolean;
137
+ cacheLife?: {
138
+ [profile: string]: {
139
+ stale?: number;
140
+ revalidate?: number;
141
+ expire?: number;
142
+ };
143
+ };
144
+ expireTime?: number;
145
+ experimental?: next_dist_server_config_shared.ExperimentalConfig;
146
+ bundlePagesRouterDependencies?: boolean;
147
+ serverExternalPackages?: string[];
148
+ outputFileTracingRoot?: string;
149
+ outputFileTracingExcludes?: Record<string, string[]>;
150
+ outputFileTracingIncludes?: Record<string, string[]>;
151
+ watchOptions?: {
152
+ pollIntervalMs?: number;
153
+ };
154
+ htmlLimitedBots?: RegExp;
155
+ }>;
156
+ declare const aiIns: typeof withAiIns;
157
+
158
+ export { type AiInsNextPluginOptions, aiIns, withAiIns as default, withAiIns };
@@ -0,0 +1,158 @@
1
+ import * as next_dist_shared_lib_image_config from 'next/dist/shared/lib/image-config';
2
+ import * as next_dist_lib_load_custom_routes from 'next/dist/lib/load-custom-routes';
3
+ import * as next_dist_server_config_shared from 'next/dist/server/config-shared';
4
+ import * as next from 'next';
5
+ import { AiInsPluginOptions } from '@ai-ins/core';
6
+ export { AiInsPluginOptions } from '@ai-ins/core';
7
+
8
+ type AiInsNextPluginOptions = AiInsPluginOptions & {
9
+ middlewarePort?: number;
10
+ };
11
+ type NextConfig = next.NextConfig & {
12
+ rewrites?: NextRewrites;
13
+ turbopack?: {
14
+ rules?: Record<string, unknown>;
15
+ } & next.NextConfig['turbopack'];
16
+ };
17
+ type NextConfigExport = NextConfig | ((phase: string, context?: unknown) => NextConfig | Promise<NextConfig>);
18
+ type NextRewrites = (() => Promise<Rewrite[] | {
19
+ afterFiles?: Rewrite[];
20
+ beforeFiles?: Rewrite[];
21
+ fallback?: Rewrite[];
22
+ }>) | Rewrite[] | {
23
+ afterFiles?: Rewrite[];
24
+ beforeFiles?: Rewrite[];
25
+ fallback?: Rewrite[];
26
+ };
27
+ type Rewrite = {
28
+ destination: string;
29
+ source: string;
30
+ };
31
+ declare function withAiIns(nextConfig?: NextConfigExport, options?: AiInsNextPluginOptions): (phase: string, context?: unknown) => Promise<NextConfig | {
32
+ rewrites(): Promise<Rewrite[] | {
33
+ beforeFiles: Rewrite[];
34
+ afterFiles?: Rewrite[];
35
+ fallback?: Rewrite[];
36
+ }>;
37
+ allowedDevOrigins?: string[];
38
+ exportPathMap?: (defaultMap: next_dist_server_config_shared.ExportPathMap, ctx: {
39
+ dev: boolean;
40
+ dir: string;
41
+ outDir: string | null;
42
+ distDir: string;
43
+ buildId: string;
44
+ }) => Promise<next_dist_server_config_shared.ExportPathMap> | next_dist_server_config_shared.ExportPathMap;
45
+ i18n?: next_dist_server_config_shared.I18NConfig | null;
46
+ typescript?: next_dist_server_config_shared.TypeScriptConfig;
47
+ typedRoutes?: boolean;
48
+ headers?: () => Promise<next_dist_lib_load_custom_routes.Header[]> | next_dist_lib_load_custom_routes.Header[];
49
+ redirects?: () => Promise<next_dist_lib_load_custom_routes.Redirect[]> | next_dist_lib_load_custom_routes.Redirect[];
50
+ excludeDefaultMomentLocales?: boolean;
51
+ webpack?: next_dist_server_config_shared.NextJsWebpackConfig | null;
52
+ trailingSlash?: boolean;
53
+ env?: Record<string, string | undefined>;
54
+ distDir?: string;
55
+ cleanDistDir?: boolean;
56
+ assetPrefix?: string;
57
+ cacheHandler?: string | undefined;
58
+ adapterPath?: string;
59
+ cacheHandlers?: {
60
+ default?: string;
61
+ remote?: string;
62
+ static?: string;
63
+ [handlerName: string]: string | undefined;
64
+ };
65
+ cacheMaxMemorySize?: number;
66
+ useFileSystemPublicRoutes?: boolean;
67
+ generateBuildId?: () => string | null | Promise<string | null>;
68
+ generateEtags?: boolean;
69
+ pageExtensions?: string[];
70
+ compress?: boolean;
71
+ poweredByHeader?: boolean;
72
+ images?: next_dist_shared_lib_image_config.ImageConfig;
73
+ devIndicators?: false | {
74
+ position?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
75
+ };
76
+ onDemandEntries?: {
77
+ maxInactiveAge?: number;
78
+ pagesBufferLength?: number;
79
+ };
80
+ deploymentId?: string;
81
+ basePath?: string;
82
+ sassOptions?: {
83
+ implementation?: string;
84
+ [key: string]: any;
85
+ };
86
+ productionBrowserSourceMaps?: boolean;
87
+ reactCompiler?: boolean | next_dist_server_config_shared.ReactCompilerOptions;
88
+ reactProductionProfiling?: boolean;
89
+ reactStrictMode?: boolean | null;
90
+ reactMaxHeadersLength?: number;
91
+ httpAgentOptions?: {
92
+ keepAlive?: boolean;
93
+ };
94
+ staticPageGenerationTimeout?: number;
95
+ crossOrigin?: "anonymous" | "use-credentials";
96
+ compiler?: {
97
+ reactRemoveProperties?: boolean | {
98
+ properties?: string[];
99
+ };
100
+ relay?: {
101
+ src: string;
102
+ artifactDirectory?: string;
103
+ language?: "typescript" | "javascript" | "flow";
104
+ eagerEsModules?: boolean;
105
+ };
106
+ removeConsole?: boolean | {
107
+ exclude?: string[];
108
+ };
109
+ styledComponents?: boolean | next_dist_server_config_shared.StyledComponentsConfig;
110
+ emotion?: boolean | next_dist_server_config_shared.EmotionConfig;
111
+ styledJsx?: boolean | {
112
+ useLightningcss?: boolean;
113
+ };
114
+ define?: Record<string, string | number | boolean>;
115
+ defineServer?: Record<string, string | number | boolean>;
116
+ runAfterProductionCompile?: (metadata: {
117
+ projectDir: string;
118
+ distDir: string;
119
+ }) => Promise<void>;
120
+ };
121
+ output?: "standalone" | "export";
122
+ transpilePackages?: string[];
123
+ turbopack?: (next_dist_server_config_shared.TurbopackOptions & {
124
+ rules?: Record<string, unknown>;
125
+ }) | undefined;
126
+ skipMiddlewareUrlNormalize?: boolean;
127
+ skipProxyUrlNormalize?: boolean;
128
+ skipTrailingSlashRedirect?: boolean;
129
+ modularizeImports?: Record<string, {
130
+ transform: string | Record<string, string>;
131
+ preventFullImport?: boolean;
132
+ skipDefaultConversion?: boolean;
133
+ }>;
134
+ logging?: next_dist_server_config_shared.LoggingConfig | false;
135
+ enablePrerenderSourceMaps?: boolean;
136
+ cacheComponents?: boolean;
137
+ cacheLife?: {
138
+ [profile: string]: {
139
+ stale?: number;
140
+ revalidate?: number;
141
+ expire?: number;
142
+ };
143
+ };
144
+ expireTime?: number;
145
+ experimental?: next_dist_server_config_shared.ExperimentalConfig;
146
+ bundlePagesRouterDependencies?: boolean;
147
+ serverExternalPackages?: string[];
148
+ outputFileTracingRoot?: string;
149
+ outputFileTracingExcludes?: Record<string, string[]>;
150
+ outputFileTracingIncludes?: Record<string, string[]>;
151
+ watchOptions?: {
152
+ pollIntervalMs?: number;
153
+ };
154
+ htmlLimitedBots?: RegExp;
155
+ }>;
156
+ declare const aiIns: typeof withAiIns;
157
+
158
+ export { type AiInsNextPluginOptions, aiIns, withAiIns as default, withAiIns };