@lowdefy/server 5.2.0 → 5.4.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/lib/build/appMeta.js +19 -0
- package/lib/build/i18n.js +19 -0
- package/lib/server/apiWrapper.js +6 -0
- package/lib/server/auth/getAuthOptions.js +2 -1
- package/lib/server/serverSidePropsWrapper.js +2 -0
- package/lowdefy/build.mjs +3 -0
- package/lowdefy/createCustomPluginMessagesMap.mjs +57 -0
- package/lowdefy/createCustomPluginTypesMap.mjs +1 -0
- package/next.config.js +12 -1
- package/package.json +19 -17
- package/package.original.json +19 -22
- package/pages/404.js +2 -0
- package/pages/_app.js +33 -4
- package/pages/api/agent/[...path].js +86 -0
- package/pages/api/usage.js +2 -3
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
import { serializer } from '@lowdefy/helpers';
|
|
17
|
+
import raw from '../../build/appMeta.json';
|
|
18
|
+
|
|
19
|
+
export default serializer.deserialize(raw);
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
import { serializer } from '@lowdefy/helpers';
|
|
17
|
+
import raw from '../../build/i18n.json';
|
|
18
|
+
|
|
19
|
+
export default serializer.deserialize(raw);
|
package/lib/server/apiWrapper.js
CHANGED
|
@@ -20,7 +20,10 @@ 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';
|
|
24
|
+
import appMeta from '../build/appMeta.js';
|
|
23
25
|
import config from '../build/config.js';
|
|
26
|
+
import i18nConfig from '../build/i18n.js';
|
|
24
27
|
import connections from '../../build/plugins/connections.js';
|
|
25
28
|
import createLogger from './log/createLogger.js';
|
|
26
29
|
import fileCache from './fileCache.js';
|
|
@@ -40,11 +43,14 @@ function apiWrapper(handler) {
|
|
|
40
43
|
const context = {
|
|
41
44
|
// Important to give absolute path so Next can trace build files
|
|
42
45
|
rid: uuid(),
|
|
46
|
+
agents,
|
|
47
|
+
appMeta,
|
|
43
48
|
buildDirectory: path.join(process.cwd(), 'build'),
|
|
44
49
|
config,
|
|
45
50
|
connections,
|
|
46
51
|
fileCache,
|
|
47
52
|
headers: req?.headers,
|
|
53
|
+
i18n: i18nConfig,
|
|
48
54
|
jsMap,
|
|
49
55
|
handleError: async (err) => {
|
|
50
56
|
console.error(err);
|
|
@@ -23,8 +23,9 @@ import callbacks from '../../../build/plugins/auth/callbacks.js';
|
|
|
23
23
|
import events from '../../../build/plugins/auth/events.js';
|
|
24
24
|
import providers from '../../../build/plugins/auth/providers.js';
|
|
25
25
|
|
|
26
|
-
function getAuthOptions({ logger }) {
|
|
26
|
+
function getAuthOptions({ appMeta, logger }) {
|
|
27
27
|
return getNextAuthConfig({
|
|
28
|
+
appMeta,
|
|
28
29
|
authJson,
|
|
29
30
|
logger,
|
|
30
31
|
plugins: { adapters, callbacks, events, providers },
|
|
@@ -18,6 +18,7 @@ import path from 'path';
|
|
|
18
18
|
import { createApiContext } from '@lowdefy/api';
|
|
19
19
|
import { v4 as uuid } from 'uuid';
|
|
20
20
|
|
|
21
|
+
import appMeta from '../build/appMeta.js';
|
|
21
22
|
import config from '../build/config.js';
|
|
22
23
|
import createLogger from './log/createLogger.js';
|
|
23
24
|
import fileCache from './fileCache.js';
|
|
@@ -32,6 +33,7 @@ function serverSidePropsWrapper(handler) {
|
|
|
32
33
|
const context = {
|
|
33
34
|
// Important to give absolute path so Next can trace build files
|
|
34
35
|
rid: uuid(),
|
|
36
|
+
appMeta,
|
|
35
37
|
buildDirectory: path.join(process.cwd(), 'build'),
|
|
36
38
|
config,
|
|
37
39
|
fileCache,
|
package/lowdefy/build.mjs
CHANGED
|
@@ -22,6 +22,7 @@ import { hideBin } from 'yargs/helpers';
|
|
|
22
22
|
import build from '@lowdefy/build';
|
|
23
23
|
import { BuildError } from '@lowdefy/errors';
|
|
24
24
|
import { createNodeLogger } from '@lowdefy/logger/node';
|
|
25
|
+
import createCustomPluginMessagesMap from './createCustomPluginMessagesMap.mjs';
|
|
25
26
|
import createCustomPluginTypesMap from './createCustomPluginTypesMap.mjs';
|
|
26
27
|
|
|
27
28
|
const argv = yargs(hideBin(process.argv)).argv;
|
|
@@ -39,6 +40,7 @@ async function run() {
|
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
const customTypesMap = await createCustomPluginTypesMap({ directories });
|
|
43
|
+
const customMessagesMap = await createCustomPluginMessagesMap({ directories });
|
|
42
44
|
|
|
43
45
|
let logger;
|
|
44
46
|
logger = createNodeLogger({
|
|
@@ -48,6 +50,7 @@ async function run() {
|
|
|
48
50
|
});
|
|
49
51
|
|
|
50
52
|
await build({
|
|
53
|
+
customMessagesMap,
|
|
51
54
|
customTypesMap,
|
|
52
55
|
directories,
|
|
53
56
|
logger,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { createRequire } from 'node:module';
|
|
19
|
+
import path from 'path';
|
|
20
|
+
import { get } from '@lowdefy/helpers';
|
|
21
|
+
import { readFile } from '@lowdefy/node-utils';
|
|
22
|
+
import YAML from 'yaml';
|
|
23
|
+
|
|
24
|
+
const require = createRequire(import.meta.url);
|
|
25
|
+
|
|
26
|
+
async function getPluginDefinitions({ directories }) {
|
|
27
|
+
let lowdefyYaml = await readFile(path.join(directories.config, 'lowdefy.yaml'));
|
|
28
|
+
if (!lowdefyYaml) {
|
|
29
|
+
lowdefyYaml = await readFile(path.join(directories.config, 'lowdefy.yml'));
|
|
30
|
+
}
|
|
31
|
+
if (!lowdefyYaml) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
const lowdefy = YAML.parse(lowdefyYaml);
|
|
35
|
+
return get(lowdefy, 'plugins', { default: [] });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function createCustomPluginMessagesMap({ directories }) {
|
|
39
|
+
const customMessagesMap = {};
|
|
40
|
+
const pluginDefinitions = await getPluginDefinitions({ directories });
|
|
41
|
+
|
|
42
|
+
for (const plugin of pluginDefinitions) {
|
|
43
|
+
let messagesModule;
|
|
44
|
+
try {
|
|
45
|
+
messagesModule = require(`${plugin.name}/messages`);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const messages = messagesModule.default ?? messagesModule;
|
|
50
|
+
if (!messages || typeof messages !== 'object') continue;
|
|
51
|
+
customMessagesMap[plugin.name] = messages;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return customMessagesMap;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default createCustomPluginMessagesMap;
|
package/next.config.js
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
const { withSentryConfig } = require('@sentry/nextjs');
|
|
2
2
|
const lowdefyConfig = require('./build/config.json');
|
|
3
3
|
const blockPackages = require('./build/blockPackages.json');
|
|
4
|
+
const agentFileSystems = require('./build/agentFileSystems.json');
|
|
5
|
+
const serverExternalPackages = require('./build/serverExternalPackages.json');
|
|
4
6
|
|
|
5
7
|
const nextConfig = {
|
|
6
8
|
basePath: lowdefyConfig.basePath,
|
|
7
9
|
reactStrictMode: true,
|
|
8
|
-
transpilePackages: [
|
|
10
|
+
transpilePackages: [
|
|
11
|
+
'@lowdefy/client',
|
|
12
|
+
'@ant-design/x',
|
|
13
|
+
'@ant-design/x-markdown',
|
|
14
|
+
...blockPackages,
|
|
15
|
+
],
|
|
16
|
+
serverExternalPackages,
|
|
9
17
|
turbopack: {},
|
|
10
18
|
poweredByHeader: false,
|
|
11
19
|
// productionBrowserSourceMaps: true
|
|
12
20
|
output: process.env.LOWDEFY_BUILD_OUTPUT_STANDALONE === '1' ? 'standalone' : undefined,
|
|
21
|
+
outputFileTracingIncludes: agentFileSystems.length
|
|
22
|
+
? { '/api/agent/*': agentFileSystems.map((p) => `${p}/**/*`) }
|
|
23
|
+
: undefined,
|
|
13
24
|
};
|
|
14
25
|
|
|
15
26
|
// Only wrap with Sentry if SENTRY_DSN is configured
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -38,21 +38,23 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@ant-design/cssinjs": "2.1.2",
|
|
41
|
-
"@
|
|
42
|
-
"@lowdefy/
|
|
43
|
-
"@lowdefy/
|
|
44
|
-
"@lowdefy/
|
|
45
|
-
"@lowdefy/blocks-
|
|
46
|
-
"@lowdefy/blocks-
|
|
47
|
-
"@lowdefy/blocks-
|
|
48
|
-
"@lowdefy/
|
|
49
|
-
"@lowdefy/
|
|
50
|
-
"@lowdefy/
|
|
51
|
-
"@lowdefy/
|
|
52
|
-
"@lowdefy/
|
|
53
|
-
"@lowdefy/
|
|
54
|
-
"@lowdefy/
|
|
55
|
-
"@lowdefy/
|
|
41
|
+
"@ant-design/x": "2.7.0",
|
|
42
|
+
"@lowdefy/actions-core": "5.4.0",
|
|
43
|
+
"@lowdefy/api": "5.4.0",
|
|
44
|
+
"@lowdefy/block-utils": "5.4.0",
|
|
45
|
+
"@lowdefy/blocks-antd": "5.4.0",
|
|
46
|
+
"@lowdefy/blocks-antd-x": "5.4.0",
|
|
47
|
+
"@lowdefy/blocks-basic": "5.4.0",
|
|
48
|
+
"@lowdefy/blocks-loaders": "5.4.0",
|
|
49
|
+
"@lowdefy/blocks-tiptap": "5.4.0",
|
|
50
|
+
"@lowdefy/client": "5.4.0",
|
|
51
|
+
"@lowdefy/errors": "5.4.0",
|
|
52
|
+
"@lowdefy/helpers": "5.4.0",
|
|
53
|
+
"@lowdefy/layout": "5.4.0",
|
|
54
|
+
"@lowdefy/logger": "5.4.0",
|
|
55
|
+
"@lowdefy/node-utils": "5.4.0",
|
|
56
|
+
"@lowdefy/operators-js": "5.4.0",
|
|
57
|
+
"@lowdefy/plugin-next-auth": "5.4.0",
|
|
56
58
|
"@sentry/nextjs": "8.53.0",
|
|
57
59
|
"@tailwindcss/postcss": "4.2.1",
|
|
58
60
|
"antd": "6.3.1",
|
|
@@ -67,7 +69,7 @@
|
|
|
67
69
|
"uuid": "13.0.0"
|
|
68
70
|
},
|
|
69
71
|
"devDependencies": {
|
|
70
|
-
"@lowdefy/build": "5.
|
|
72
|
+
"@lowdefy/build": "5.4.0",
|
|
71
73
|
"@next/eslint-plugin-next": "16.1.6",
|
|
72
74
|
"@tailwindcss/postcss": "4.2.1",
|
|
73
75
|
"tailwindcss": "4.2.1",
|
package/package.original.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -48,21 +48,23 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@ant-design/cssinjs": "2.1.2",
|
|
51
|
-
"@
|
|
52
|
-
"@lowdefy/
|
|
53
|
-
"@lowdefy/
|
|
54
|
-
"@lowdefy/
|
|
55
|
-
"@lowdefy/blocks-
|
|
56
|
-
"@lowdefy/blocks-
|
|
57
|
-
"@lowdefy/blocks-
|
|
58
|
-
"@lowdefy/
|
|
59
|
-
"@lowdefy/
|
|
60
|
-
"@lowdefy/
|
|
61
|
-
"@lowdefy/
|
|
62
|
-
"@lowdefy/
|
|
63
|
-
"@lowdefy/
|
|
64
|
-
"@lowdefy/
|
|
65
|
-
"@lowdefy/
|
|
51
|
+
"@ant-design/x": "2.7.0",
|
|
52
|
+
"@lowdefy/actions-core": "5.4.0",
|
|
53
|
+
"@lowdefy/api": "5.4.0",
|
|
54
|
+
"@lowdefy/block-utils": "5.4.0",
|
|
55
|
+
"@lowdefy/blocks-antd": "5.4.0",
|
|
56
|
+
"@lowdefy/blocks-antd-x": "5.4.0",
|
|
57
|
+
"@lowdefy/blocks-basic": "5.4.0",
|
|
58
|
+
"@lowdefy/blocks-loaders": "5.4.0",
|
|
59
|
+
"@lowdefy/blocks-tiptap": "5.4.0",
|
|
60
|
+
"@lowdefy/client": "5.4.0",
|
|
61
|
+
"@lowdefy/errors": "5.4.0",
|
|
62
|
+
"@lowdefy/helpers": "5.4.0",
|
|
63
|
+
"@lowdefy/layout": "5.4.0",
|
|
64
|
+
"@lowdefy/logger": "5.4.0",
|
|
65
|
+
"@lowdefy/node-utils": "5.4.0",
|
|
66
|
+
"@lowdefy/operators-js": "5.4.0",
|
|
67
|
+
"@lowdefy/plugin-next-auth": "5.4.0",
|
|
66
68
|
"@sentry/nextjs": "8.53.0",
|
|
67
69
|
"@tailwindcss/postcss": "4.2.1",
|
|
68
70
|
"antd": "6.3.1",
|
|
@@ -77,7 +79,7 @@
|
|
|
77
79
|
"uuid": "13.0.0"
|
|
78
80
|
},
|
|
79
81
|
"devDependencies": {
|
|
80
|
-
"@lowdefy/build": "5.
|
|
82
|
+
"@lowdefy/build": "5.4.0",
|
|
81
83
|
"@next/eslint-plugin-next": "16.1.6",
|
|
82
84
|
"@tailwindcss/postcss": "4.2.1",
|
|
83
85
|
"tailwindcss": "4.2.1",
|
|
@@ -88,11 +90,6 @@
|
|
|
88
90
|
"engines": {
|
|
89
91
|
"node": ">=18"
|
|
90
92
|
},
|
|
91
|
-
"pnpm": {
|
|
92
|
-
"onlyBuiltDependencies": [
|
|
93
|
-
"better-sqlite3"
|
|
94
|
-
]
|
|
95
|
-
},
|
|
96
93
|
"publishConfig": {
|
|
97
94
|
"access": "public"
|
|
98
95
|
}
|
package/pages/404.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import path from 'path';
|
|
18
18
|
import { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
|
|
19
19
|
|
|
20
|
+
import appMeta from '../lib/build/appMeta.js';
|
|
20
21
|
import config from '../lib/build/config.js';
|
|
21
22
|
import fileCache from '../lib/server/fileCache.js';
|
|
22
23
|
import Page from '../lib/client/Page.js';
|
|
@@ -24,6 +25,7 @@ import Page from '../lib/client/Page.js';
|
|
|
24
25
|
export async function getStaticProps() {
|
|
25
26
|
// Important to give absolute path so Next can trace build files
|
|
26
27
|
const context = {
|
|
28
|
+
appMeta,
|
|
27
29
|
buildDirectory: path.join(process.cwd(), 'build'),
|
|
28
30
|
config,
|
|
29
31
|
fileCache,
|
package/pages/_app.js
CHANGED
|
@@ -23,10 +23,14 @@ import React, { useCallback, useRef } from 'react';
|
|
|
23
23
|
import dynamic from 'next/dynamic';
|
|
24
24
|
|
|
25
25
|
import { ErrorBoundary } from '@lowdefy/block-utils';
|
|
26
|
-
import { useDarkMode } from '@lowdefy/client';
|
|
26
|
+
import { useDarkMode, useLocale } from '@lowdefy/client';
|
|
27
27
|
import { StyleProvider } from '@ant-design/cssinjs';
|
|
28
|
-
import { App as AntdApp,
|
|
28
|
+
import { App as AntdApp, theme as antdTheme } from 'antd';
|
|
29
|
+
import { XProvider } from '@ant-design/x';
|
|
29
30
|
|
|
31
|
+
import antdLocaleLoaders from '../build/i18n/antdLocales.js';
|
|
32
|
+
import antdXLocaleLoaders from '../build/i18n/antdXLocales.js';
|
|
33
|
+
import dayjsLocaleMap from '../build/i18n/dayjsLocales.js';
|
|
30
34
|
import Auth from '../lib/client/auth/Auth.js';
|
|
31
35
|
import createLogUsage from '../lib/client/createLogUsage.js';
|
|
32
36
|
import initSentryClient from '../lib/client/sentry/initSentryClient.js';
|
|
@@ -63,6 +67,17 @@ function App({ Component, pageProps: { session, rootConfig, pageConfig } }) {
|
|
|
63
67
|
configDarkMode: lowdefyRef.current.theme?.darkMode,
|
|
64
68
|
});
|
|
65
69
|
|
|
70
|
+
const { active: activeLocale, antdLocale, antdXLocale } = useLocale({
|
|
71
|
+
i18n: rootConfig?.i18n,
|
|
72
|
+
antdLocaleLoaders,
|
|
73
|
+
antdXLocaleLoaders,
|
|
74
|
+
dayjsLocaleMap,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (rootConfig?.i18n?.defaultLocale) {
|
|
78
|
+
lowdefyRef.current.i18n = { ...rootConfig.i18n, active: activeLocale };
|
|
79
|
+
}
|
|
80
|
+
|
|
66
81
|
const {
|
|
67
82
|
lightToken: _lightToken,
|
|
68
83
|
darkToken: _darkToken,
|
|
@@ -79,9 +94,23 @@ function App({ Component, pageProps: { session, rootConfig, pageConfig } }) {
|
|
|
79
94
|
}
|
|
80
95
|
}, []);
|
|
81
96
|
|
|
97
|
+
// XProvider extends antd's ConfigProvider; merging antd + antd-X locale packs
|
|
98
|
+
// gives X components (Bubble, Sender, Conversations, ...) their built-in strings
|
|
99
|
+
// alongside antd's. antd X ships only en_US + zh_CN; other locales fall back
|
|
100
|
+
// to en_US for X-native strings.
|
|
101
|
+
const mergedLocale = antdLocale || antdXLocale
|
|
102
|
+
? { ...(antdLocale ?? {}), ...(antdXLocale ?? {}) }
|
|
103
|
+
: undefined;
|
|
104
|
+
|
|
82
105
|
return (
|
|
83
106
|
<StyleProvider layer>
|
|
84
|
-
<
|
|
107
|
+
<XProvider
|
|
108
|
+
locale={mergedLocale}
|
|
109
|
+
form={
|
|
110
|
+
antdLocale?.Form?.defaultValidateMessages
|
|
111
|
+
? { validateMessages: antdLocale.Form.defaultValidateMessages }
|
|
112
|
+
: undefined
|
|
113
|
+
}
|
|
85
114
|
theme={{
|
|
86
115
|
...antdConfig,
|
|
87
116
|
token,
|
|
@@ -115,7 +144,7 @@ function App({ Component, pageProps: { session, rootConfig, pageConfig } }) {
|
|
|
115
144
|
</ErrorBoundary>
|
|
116
145
|
</ThemeTokenResolver>
|
|
117
146
|
</AntdApp>
|
|
118
|
-
</
|
|
147
|
+
</XProvider>
|
|
119
148
|
</StyleProvider>
|
|
120
149
|
);
|
|
121
150
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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 { translate, type } from '@lowdefy/helpers';
|
|
19
|
+
|
|
20
|
+
import apiWrapper from '../../../lib/server/apiWrapper.js';
|
|
21
|
+
|
|
22
|
+
async function handler({ context, req, res }) {
|
|
23
|
+
const t = (key, values) => translate({ key, values, i18n: context.i18n });
|
|
24
|
+
if (req.method !== 'POST') {
|
|
25
|
+
throw new Error(t('agent.runtime.methodNotAllowed'));
|
|
26
|
+
}
|
|
27
|
+
const segments = req.query.path;
|
|
28
|
+
if (!Array.isArray(segments) || segments.length < 2) {
|
|
29
|
+
res.status(400).json({ error: t('agent.runtime.invalidPath') });
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const agentId = segments[segments.length - 1];
|
|
33
|
+
const pageId = segments.slice(0, -1).join('/');
|
|
34
|
+
context.logger.info({ event: 'call_agent', agentId, pageId });
|
|
35
|
+
const { conversationId } = req.query;
|
|
36
|
+
const { messages, urlQuery, sharedState } = req.body;
|
|
37
|
+
if (!Array.isArray(messages)) {
|
|
38
|
+
res.status(400).json({ error: t('agent.runtime.messagesMustBeArray') });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (urlQuery != null && (typeof urlQuery !== 'object' || Array.isArray(urlQuery))) {
|
|
42
|
+
res.status(400).json({ error: t('agent.runtime.urlQueryMustBeObject') });
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (sharedState != null && !type.isObject(sharedState)) {
|
|
46
|
+
res.status(400).json({ error: t('agent.runtime.sharedStateMustBeObject') });
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const { response: webResponse } = await callAgent(context, {
|
|
50
|
+
agentId,
|
|
51
|
+
pageId,
|
|
52
|
+
messages,
|
|
53
|
+
conversationId: conversationId ?? undefined,
|
|
54
|
+
sharedState: sharedState ?? undefined,
|
|
55
|
+
urlQuery: urlQuery ?? undefined,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Stream the Web Response body to the Next.js response
|
|
59
|
+
res.setHeader('Content-Type', 'text/event-stream');
|
|
60
|
+
res.setHeader('Cache-Control', 'no-cache');
|
|
61
|
+
res.setHeader('Connection', 'keep-alive');
|
|
62
|
+
res.setHeader('Content-Encoding', 'none');
|
|
63
|
+
res.setHeader('Transfer-Encoding', 'chunked');
|
|
64
|
+
|
|
65
|
+
const reader = webResponse.body.getReader();
|
|
66
|
+
const decoder = new TextDecoder();
|
|
67
|
+
let done = false;
|
|
68
|
+
while (!done) {
|
|
69
|
+
const { value, done: readerDone } = await reader.read();
|
|
70
|
+
done = readerDone;
|
|
71
|
+
if (value) {
|
|
72
|
+
res.write(decoder.decode(value, { stream: true }));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
res.end();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const config = {
|
|
79
|
+
api: {
|
|
80
|
+
bodyParser: {
|
|
81
|
+
sizeLimit: '10mb',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default apiWrapper(handler);
|
package/pages/api/usage.js
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
// TODO
|
|
18
18
|
// import crypto from 'crypto';
|
|
19
19
|
|
|
20
|
-
import appJson from '../../lib/build/app.js';
|
|
21
20
|
import packageJson from '../../package.json';
|
|
22
21
|
import apiWrapper from '../../lib/server/apiWrapper.js';
|
|
23
22
|
// import validateLicense from '../../lib/server/validateLicense.js';
|
|
@@ -37,7 +36,7 @@ async function handler({ context, req, res }) {
|
|
|
37
36
|
const timestamp = Date.now();
|
|
38
37
|
|
|
39
38
|
// const data = [
|
|
40
|
-
// `
|
|
39
|
+
// `gitSha: ${context.appMeta.gitSha}`,
|
|
41
40
|
// `host: ${host}`,
|
|
42
41
|
// `license_key: ${license.id}`,
|
|
43
42
|
// `machine: ${machine}`,
|
|
@@ -53,7 +52,7 @@ async function handler({ context, req, res }) {
|
|
|
53
52
|
return res.status(200).json({
|
|
54
53
|
offline: false,
|
|
55
54
|
data: {
|
|
56
|
-
|
|
55
|
+
gitSha: context.appMeta.gitSha,
|
|
57
56
|
host,
|
|
58
57
|
// license_key: license.id,
|
|
59
58
|
machine,
|