@lowdefy/server-dev 5.1.0 → 5.3.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.
@@ -18,13 +18,14 @@ function setPageId(router, rootConfig) {
18
18
  if (router.pathname === `/404`) {
19
19
  return { redirect: false, pageId: '404' };
20
20
  }
21
- if (!router.query.pageId) {
21
+ const segments = router.query.pageId;
22
+ if (!segments || segments.length === 0) {
22
23
  if (rootConfig.home.configured === false) {
23
24
  return { redirect: true, pageId: rootConfig.home.pageId };
24
25
  }
25
26
  return { redirect: false, pageId: rootConfig.home.pageId };
26
27
  }
27
- return { redirect: false, pageId: router.query.pageId };
28
+ return { redirect: false, pageId: segments.join('/') };
28
29
  }
29
30
 
30
31
  export default setPageId;
@@ -20,6 +20,7 @@ import { getSecretsFromEnv } from '@lowdefy/node-utils';
20
20
  import { serializer } from '@lowdefy/helpers';
21
21
  import { v4 as uuid } from 'uuid';
22
22
 
23
+ import agents from '../../build/plugins/agents.js';
23
24
  import config from '../build/config.js';
24
25
  import connections from '../../build/plugins/connections.js';
25
26
  import createLogger from './log/createLogger.js';
@@ -65,6 +66,7 @@ function apiWrapper(handler) {
65
66
  const context = {
66
67
  // Important to give absolute path so Next can trace build files
67
68
  rid: uuid(),
69
+ agents,
68
70
  buildDirectory,
69
71
  configDirectory: process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd(),
70
72
  config,
@@ -119,6 +119,12 @@ function getBuildContext(buildDirectory, configDirectory) {
119
119
  readJsonFile(path.join(buildDirectory, 'installedPluginPackages.json')) ?? [];
120
120
  cachedBuildContext.installedPluginPackages = new Set(installedPluginPackages);
121
121
 
122
+ // Restore module entries from skeleton build for JIT module page builds
123
+ const modules = readJsonFile(path.join(buildDirectory, 'modules.json'));
124
+ if (modules) {
125
+ Object.assign(cachedBuildContext.modules, modules);
126
+ }
127
+
122
128
  // Use the frozen icon imports from the initial build for JIT detection.
123
129
  // This represents what's actually in the Next.js bundle — not what shallowBuild
124
130
  // discovers on subsequent rebuilds (those icons aren't bundled yet).
@@ -16,6 +16,7 @@
16
16
 
17
17
  import envWatcher from '../watchers/envWatcher.mjs';
18
18
  import lowdefyBuildWatcher from '../watchers/lowdefyBuildWatcher.mjs';
19
+ import moduleBuildWatcher from '../watchers/moduleBuildWatcher.mjs';
19
20
  import nextBuildWatcher from '../watchers/nextBuildWatcher.mjs';
20
21
 
21
22
  function startWatchers(context) {
@@ -23,6 +24,7 @@ function startWatchers(context) {
23
24
  await Promise.all([
24
25
  envWatcher(context),
25
26
  lowdefyBuildWatcher(context),
27
+ moduleBuildWatcher(context),
26
28
  nextBuildWatcher(context),
27
29
  ]);
28
30
  };
@@ -39,6 +39,7 @@ async function getPluginDefinitions({ directories }) {
39
39
  async function createCustomPluginTypesMap({ directories, logger }) {
40
40
  const customTypesMap = {
41
41
  actions: {},
42
+ agents: {},
42
43
  auth: {
43
44
  adapters: {},
44
45
  callbacks: {},
@@ -0,0 +1,80 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import fs from 'fs';
18
+ import path from 'path';
19
+ import loadSkeletonSourceFiles from '../utils/loadSkeletonSourceFiles.mjs';
20
+ import setupWatcher from '../utils/setupWatcher.mjs';
21
+
22
+ function moduleBuildWatcher(context) {
23
+ // Collect local module directories from the build context
24
+ const buildContext = context.buildContext;
25
+ if (!buildContext || !buildContext.modules) {
26
+ return Promise.resolve();
27
+ }
28
+
29
+ const localModuleRoots = [];
30
+ for (const moduleEntry of Object.values(buildContext.modules)) {
31
+ if (moduleEntry.isLocal) {
32
+ localModuleRoots.push(moduleEntry.moduleRoot);
33
+ }
34
+ }
35
+
36
+ if (localModuleRoots.length === 0) {
37
+ return Promise.resolve();
38
+ }
39
+
40
+ const callback = async (filePaths) => {
41
+ const changedFiles = filePaths.flat();
42
+
43
+ // If module.lowdefy.yaml itself changed, do a full shallow rebuild (module exports may have changed)
44
+ const moduleYamlChanged = changedFiles.some(
45
+ (filePath) => path.basename(filePath) === 'module.lowdefy.yaml'
46
+ );
47
+
48
+ try {
49
+ const skeletonSourceFiles = loadSkeletonSourceFiles(context.directories.build);
50
+ const hasSkeletonChanges = changedFiles.some((f) => skeletonSourceFiles.has(f));
51
+
52
+ if (moduleYamlChanged || hasSkeletonChanges) {
53
+ context.logger.info(
54
+ moduleYamlChanged
55
+ ? 'module.lowdefy.yaml changed, running full shallow rebuild.'
56
+ : 'Module skeleton files changed, running shallow rebuild.'
57
+ );
58
+ await context.lowdefyBuild();
59
+ await context.compileCss();
60
+ } else {
61
+ const invalidatePath = path.join(context.directories.build, 'invalidatePages');
62
+ fs.writeFileSync(invalidatePath, String(Date.now()));
63
+ context.logger.info('Module files changed, invalidated all pages.');
64
+ }
65
+ } catch (error) {
66
+ context.logger.error(error);
67
+ } finally {
68
+ await context.reloadClients();
69
+ }
70
+ };
71
+
72
+ return setupWatcher({
73
+ callback,
74
+ context,
75
+ ignorePaths: ['**/node_modules/**'],
76
+ watchPaths: localModuleRoots,
77
+ });
78
+ }
79
+
80
+ export default moduleBuildWatcher;
package/next.config.js CHANGED
@@ -4,7 +4,12 @@ const blockPackages = require('./build/blockPackages.json');
4
4
  // Transpile @lowdefy/client plus all block plugin packages that may
5
5
  // contain CSS imports (e.g., AG Grid themes, loaders, markdown).
6
6
  // Built dynamically so custom user plugins are included automatically.
7
- const transpilePackages = ['@lowdefy/client', ...blockPackages];
7
+ const transpilePackages = [
8
+ '@lowdefy/client',
9
+ '@ant-design/x',
10
+ '@ant-design/x-markdown',
11
+ ...blockPackages,
12
+ ];
8
13
 
9
14
  const nextConfig = {
10
15
  basePath: lowdefyConfig.basePath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -36,33 +36,35 @@
36
36
  ".npmrc"
37
37
  ],
38
38
  "dependencies": {
39
- "@lowdefy/actions-core": "5.1.0",
40
- "@lowdefy/api": "5.1.0",
41
- "@lowdefy/block-utils": "5.1.0",
42
- "@lowdefy/blocks-aggrid": "5.1.0",
43
- "@lowdefy/blocks-antd": "5.1.0",
44
- "@lowdefy/blocks-basic": "5.1.0",
45
- "@lowdefy/blocks-echarts": "5.1.0",
46
- "@lowdefy/blocks-loaders": "5.1.0",
47
- "@lowdefy/blocks-markdown": "5.1.0",
48
- "@lowdefy/build": "5.1.0",
49
- "@lowdefy/client": "5.1.0",
50
- "@lowdefy/connection-axios-http": "5.1.0",
51
- "@lowdefy/engine": "5.1.0",
52
- "@lowdefy/errors": "5.1.0",
53
- "@lowdefy/helpers": "5.1.0",
54
- "@lowdefy/layout": "5.1.0",
55
- "@lowdefy/logger": "5.1.0",
56
- "@lowdefy/node-utils": "5.1.0",
57
- "@lowdefy/operators-change-case": "5.1.0",
58
- "@lowdefy/operators-dayjs": "5.1.0",
59
- "@lowdefy/operators-diff": "5.1.0",
60
- "@lowdefy/operators-js": "5.1.0",
61
- "@lowdefy/operators-mql": "5.1.0",
62
- "@lowdefy/operators-nunjucks": "5.1.0",
63
- "@lowdefy/operators-uuid": "5.1.0",
64
- "@lowdefy/operators-yaml": "5.1.0",
65
- "@lowdefy/plugin-next-auth": "5.1.0",
39
+ "@lowdefy/actions-core": "5.3.0",
40
+ "@lowdefy/api": "5.3.0",
41
+ "@lowdefy/block-utils": "5.3.0",
42
+ "@lowdefy/blocks-aggrid": "5.3.0",
43
+ "@lowdefy/blocks-antd": "5.3.0",
44
+ "@lowdefy/blocks-antd-x": "5.3.0",
45
+ "@lowdefy/blocks-basic": "5.3.0",
46
+ "@lowdefy/blocks-echarts": "5.3.0",
47
+ "@lowdefy/blocks-loaders": "5.3.0",
48
+ "@lowdefy/blocks-markdown": "5.3.0",
49
+ "@lowdefy/blocks-tiptap": "5.3.0",
50
+ "@lowdefy/build": "5.3.0",
51
+ "@lowdefy/client": "5.3.0",
52
+ "@lowdefy/connection-axios-http": "5.3.0",
53
+ "@lowdefy/engine": "5.3.0",
54
+ "@lowdefy/errors": "5.3.0",
55
+ "@lowdefy/helpers": "5.3.0",
56
+ "@lowdefy/layout": "5.3.0",
57
+ "@lowdefy/logger": "5.3.0",
58
+ "@lowdefy/node-utils": "5.3.0",
59
+ "@lowdefy/operators-change-case": "5.3.0",
60
+ "@lowdefy/operators-dayjs": "5.3.0",
61
+ "@lowdefy/operators-diff": "5.3.0",
62
+ "@lowdefy/operators-js": "5.3.0",
63
+ "@lowdefy/operators-mql": "5.3.0",
64
+ "@lowdefy/operators-nunjucks": "5.3.0",
65
+ "@lowdefy/operators-uuid": "5.3.0",
66
+ "@lowdefy/operators-yaml": "5.3.0",
67
+ "@lowdefy/plugin-next-auth": "5.3.0",
66
68
  "@ant-design/cssinjs": "2.1.2",
67
69
  "antd": "6.3.1",
68
70
  "dayjs": "1.11.19",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -44,33 +44,35 @@
44
44
  "prepublishOnly": "pnpm build"
45
45
  },
46
46
  "dependencies": {
47
- "@lowdefy/actions-core": "5.1.0",
48
- "@lowdefy/api": "5.1.0",
49
- "@lowdefy/block-utils": "5.1.0",
50
- "@lowdefy/blocks-aggrid": "5.1.0",
51
- "@lowdefy/blocks-antd": "5.1.0",
52
- "@lowdefy/blocks-basic": "5.1.0",
53
- "@lowdefy/blocks-echarts": "5.1.0",
54
- "@lowdefy/blocks-loaders": "5.1.0",
55
- "@lowdefy/blocks-markdown": "5.1.0",
56
- "@lowdefy/build": "5.1.0",
57
- "@lowdefy/client": "5.1.0",
58
- "@lowdefy/connection-axios-http": "5.1.0",
59
- "@lowdefy/engine": "5.1.0",
60
- "@lowdefy/errors": "5.1.0",
61
- "@lowdefy/helpers": "5.1.0",
62
- "@lowdefy/layout": "5.1.0",
63
- "@lowdefy/logger": "5.1.0",
64
- "@lowdefy/node-utils": "5.1.0",
65
- "@lowdefy/operators-change-case": "5.1.0",
66
- "@lowdefy/operators-dayjs": "5.1.0",
67
- "@lowdefy/operators-diff": "5.1.0",
68
- "@lowdefy/operators-js": "5.1.0",
69
- "@lowdefy/operators-mql": "5.1.0",
70
- "@lowdefy/operators-nunjucks": "5.1.0",
71
- "@lowdefy/operators-uuid": "5.1.0",
72
- "@lowdefy/operators-yaml": "5.1.0",
73
- "@lowdefy/plugin-next-auth": "5.1.0",
47
+ "@lowdefy/actions-core": "5.3.0",
48
+ "@lowdefy/api": "5.3.0",
49
+ "@lowdefy/block-utils": "5.3.0",
50
+ "@lowdefy/blocks-aggrid": "5.3.0",
51
+ "@lowdefy/blocks-antd": "5.3.0",
52
+ "@lowdefy/blocks-antd-x": "5.3.0",
53
+ "@lowdefy/blocks-basic": "5.3.0",
54
+ "@lowdefy/blocks-echarts": "5.3.0",
55
+ "@lowdefy/blocks-loaders": "5.3.0",
56
+ "@lowdefy/blocks-markdown": "5.3.0",
57
+ "@lowdefy/blocks-tiptap": "5.3.0",
58
+ "@lowdefy/build": "5.3.0",
59
+ "@lowdefy/client": "5.3.0",
60
+ "@lowdefy/connection-axios-http": "5.3.0",
61
+ "@lowdefy/engine": "5.3.0",
62
+ "@lowdefy/errors": "5.3.0",
63
+ "@lowdefy/helpers": "5.3.0",
64
+ "@lowdefy/layout": "5.3.0",
65
+ "@lowdefy/logger": "5.3.0",
66
+ "@lowdefy/node-utils": "5.3.0",
67
+ "@lowdefy/operators-change-case": "5.3.0",
68
+ "@lowdefy/operators-dayjs": "5.3.0",
69
+ "@lowdefy/operators-diff": "5.3.0",
70
+ "@lowdefy/operators-js": "5.3.0",
71
+ "@lowdefy/operators-mql": "5.3.0",
72
+ "@lowdefy/operators-nunjucks": "5.3.0",
73
+ "@lowdefy/operators-uuid": "5.3.0",
74
+ "@lowdefy/operators-yaml": "5.3.0",
75
+ "@lowdefy/plugin-next-auth": "5.3.0",
74
76
  "@ant-design/cssinjs": "2.1.2",
75
77
  "antd": "6.3.1",
76
78
  "dayjs": "1.11.19",
@@ -100,6 +102,11 @@
100
102
  "engines": {
101
103
  "node": ">=18"
102
104
  },
105
+ "pnpm": {
106
+ "onlyBuiltDependencies": [
107
+ "better-sqlite3"
108
+ ]
109
+ },
103
110
  "publishConfig": {
104
111
  "access": "public"
105
112
  }
@@ -0,0 +1,85 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { callAgent } from '@lowdefy/api';
18
+ import { type } from '@lowdefy/helpers';
19
+
20
+ import apiWrapper from '../../../lib/server/apiWrapper.js';
21
+
22
+ async function handler({ context, req, res }) {
23
+ if (req.method !== 'POST') {
24
+ throw new Error('Only POST requests are supported.');
25
+ }
26
+ const segments = req.query.path;
27
+ if (!Array.isArray(segments) || segments.length < 2) {
28
+ res.status(400).json({ error: 'Invalid agent path' });
29
+ return;
30
+ }
31
+ const agentId = segments[segments.length - 1];
32
+ const pageId = segments.slice(0, -1).join('/');
33
+ context.logger.info({ color: 'gray' }, `Agent: ${pageId} → ${agentId}`);
34
+ const { conversationId } = req.query;
35
+ const { messages, urlQuery, sharedState } = req.body;
36
+ if (!Array.isArray(messages)) {
37
+ res.status(400).json({ error: 'messages must be an array' });
38
+ return;
39
+ }
40
+ if (urlQuery != null && (typeof urlQuery !== 'object' || Array.isArray(urlQuery))) {
41
+ res.status(400).json({ error: 'urlQuery must be an object' });
42
+ return;
43
+ }
44
+ if (sharedState != null && !type.isObject(sharedState)) {
45
+ res.status(400).json({ error: 'sharedState must be an object' });
46
+ return;
47
+ }
48
+ const { response: webResponse } = await callAgent(context, {
49
+ agentId,
50
+ pageId,
51
+ messages,
52
+ conversationId: conversationId ?? undefined,
53
+ sharedState: sharedState ?? undefined,
54
+ urlQuery: urlQuery ?? undefined,
55
+ });
56
+
57
+ // Stream the Web Response body to the Next.js response
58
+ res.setHeader('Content-Type', 'text/event-stream');
59
+ res.setHeader('Cache-Control', 'no-cache');
60
+ res.setHeader('Connection', 'keep-alive');
61
+ res.setHeader('Content-Encoding', 'none');
62
+ res.setHeader('Transfer-Encoding', 'chunked');
63
+
64
+ const reader = webResponse.body.getReader();
65
+ const decoder = new TextDecoder();
66
+ let done = false;
67
+ while (!done) {
68
+ const { value, done: readerDone } = await reader.read();
69
+ done = readerDone;
70
+ if (value) {
71
+ res.write(decoder.decode(value, { stream: true }));
72
+ }
73
+ }
74
+ res.end();
75
+ }
76
+
77
+ export const config = {
78
+ api: {
79
+ bodyParser: {
80
+ sizeLimit: '10mb',
81
+ },
82
+ },
83
+ };
84
+
85
+ export default apiWrapper(handler);
@@ -22,7 +22,7 @@ async function handler({ context, req, res }) {
22
22
  if (req.method !== 'POST') {
23
23
  throw new Error('Only POST requests are supported.');
24
24
  }
25
- const { endpointId } = req.query;
25
+ const endpointId = req.query.endpointId.join('/');
26
26
  const { blockId, payload, pageId } = req.body;
27
27
  context.logger.info({ event: 'call_api_endpoint', blockId, endpointId, pageId });
28
28
  const response = await callEndpoint(context, { blockId, endpointId, pageId, payload });
@@ -20,7 +20,7 @@ import apiWrapper from '../../../lib/server/apiWrapper.js';
20
20
  import buildPageIfNeeded from '../../../lib/server/jitPageBuilder.js';
21
21
 
22
22
  async function handler({ context, req, res }) {
23
- const { pageId } = req.query;
23
+ const pageId = req.query.pageId.join('/');
24
24
 
25
25
  // Attempt JIT build if page not yet compiled
26
26
  let buildResult;
@@ -16,13 +16,19 @@
16
16
 
17
17
  import { callRequest } from '@lowdefy/api';
18
18
 
19
- import apiWrapper from '../../../../lib/server/apiWrapper.js';
19
+ import apiWrapper from '../../../lib/server/apiWrapper.js';
20
20
 
21
21
  async function handler({ context, req, res }) {
22
22
  if (req.method !== 'POST') {
23
23
  throw new Error('Only POST requests are supported.');
24
24
  }
25
- const { pageId, requestId } = req.query;
25
+ const segments = req.query.path;
26
+ if (!Array.isArray(segments) || segments.length < 2) {
27
+ res.status(400).json({ error: 'Invalid request path' });
28
+ return;
29
+ }
30
+ const requestId = segments[segments.length - 1];
31
+ const pageId = segments.slice(0, -1).join('/');
26
32
  const { actionId, blockId, payload } = req.body;
27
33
  context.logger.info(
28
34
  { color: 'gray' },
package/pages/index.js DELETED
@@ -1,19 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import App from '../lib/client/App.js';
18
-
19
- export default App;
File without changes