@lowdefy/build 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.
Files changed (38) hide show
  1. package/dist/build/buildAgents.js +249 -0
  2. package/dist/build/buildApi/buildRoutine/countStepTypes.js +1 -1
  3. package/dist/build/buildApi/buildRoutine/setStepId.js +6 -2
  4. package/dist/build/buildApi/buildRoutine/validateStep.js +18 -0
  5. package/dist/build/buildApp.js +18 -5
  6. package/dist/build/buildImports/buildImportsDev.js +5 -0
  7. package/dist/build/buildImports/buildImportsProd.js +1 -0
  8. package/dist/build/buildJs/writeJs.js +2 -2
  9. package/dist/build/buildMenu.js +5 -0
  10. package/dist/build/buildModuleDefs.js +52 -1
  11. package/dist/build/buildModules.js +1 -1
  12. package/dist/build/buildPages/validateCallApiRefs.js +9 -0
  13. package/dist/build/buildRefs/getUserJavascriptFunction.js +6 -9
  14. package/dist/build/buildRefs/runTransformer.js +3 -2
  15. package/dist/build/buildRefs/walker.js +22 -39
  16. package/dist/build/buildTypes.js +7 -0
  17. package/dist/build/codegenI18nLocales.js +53 -0
  18. package/dist/build/copyAgentFileSystems.js +45 -0
  19. package/dist/build/full/updateServerPackageJson.js +1 -0
  20. package/dist/build/jit/shallowBuild.js +31 -0
  21. package/dist/build/registerModules.js +11 -33
  22. package/dist/build/writeAgents.js +26 -0
  23. package/dist/build/writeAppMeta.js +19 -0
  24. package/dist/build/writeI18n.js +117 -0
  25. package/dist/build/writePluginImports/writeAgentImports.js +22 -0
  26. package/dist/build/writePluginImports/writePluginImports.js +10 -0
  27. package/dist/build/writePluginImports/writeServerExternalPackages.js +121 -0
  28. package/dist/createContext.js +8 -1
  29. package/dist/defaultMessagesMap.js +3 -0
  30. package/dist/defaultPackages.js +7 -0
  31. package/dist/defaultTypesMap.js +590 -377
  32. package/dist/index.js +30 -0
  33. package/dist/lowdefySchema.js +414 -0
  34. package/dist/scripts/generateDefaultMessages.js +37 -0
  35. package/dist/scripts/generateDefaultTypes.js +1 -0
  36. package/dist/test-utils/testContext.js +2 -0
  37. package/dist/utils/createPluginTypesMap.js +7 -0
  38. package/package.json +51 -44
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ import makeId from './utils/makeId.js';
20
20
  import tryBuildStep from './utils/tryBuildStep.js';
21
21
  import addDefaultPages from './build/addDefaultPages/addDefaultPages.js';
22
22
  import addKeys from './build/addKeys.js';
23
+ import buildAgents from './build/buildAgents.js';
23
24
  import buildApp from './build/buildApp.js';
24
25
  import buildAuth from './build/buildAuth/buildAuth.js';
25
26
  import buildConnections from './build/buildConnections.js';
@@ -35,16 +36,21 @@ import buildRefs from './build/buildRefs/buildRefs.js';
35
36
  import collectPageContent from './build/collectPageContent.js';
36
37
  import buildTypes from './build/buildTypes.js';
37
38
  import cleanBuildDirectory from './build/cleanBuildDirectory.js';
39
+ import copyAgentFileSystems from './build/copyAgentFileSystems.js';
38
40
  import copyPublicFolder from './build/copyPublicFolder.js';
39
41
  import testSchema from './build/testSchema.js';
40
42
  import updateServerPackageJson from './build/full/updateServerPackageJson.js';
41
43
  import validateConfig from './build/validateConfig.js';
44
+ import writeAgents from './build/writeAgents.js';
42
45
  import writeApp from './build/writeApp.js';
46
+ import writeAppMeta from './build/writeAppMeta.js';
43
47
  import writeAuth from './build/writeAuth.js';
44
48
  import writeConfig from './build/writeConfig.js';
45
49
  import writeConnections from './build/writeConnections.js';
46
50
  import writeApi from './build/writeApi.js';
47
51
  import writeGlobal from './build/writeGlobal.js';
52
+ import codegenI18nLocales from './build/codegenI18nLocales.js';
53
+ import writeI18n from './build/writeI18n.js';
48
54
  import writeTheme from './build/writeTheme.js';
49
55
  import writeJs from './build/buildJs/writeJs.js';
50
56
  import writeLogger from './build/writeLogger.js';
@@ -133,6 +139,10 @@ async function build(options) {
133
139
  components,
134
140
  context
135
141
  });
142
+ tryBuildStep(buildAgents, 'buildAgents', {
143
+ components,
144
+ context
145
+ });
136
146
  tryBuildStep(buildPages, 'buildPages', {
137
147
  components,
138
148
  context
@@ -178,6 +188,10 @@ async function build(options) {
178
188
  components,
179
189
  context
180
190
  });
191
+ await writeAppMeta({
192
+ components,
193
+ context
194
+ });
181
195
  await writeAuth({
182
196
  components,
183
197
  context
@@ -186,6 +200,10 @@ async function build(options) {
186
200
  components,
187
201
  context
188
202
  });
203
+ await writeAgents({
204
+ components,
205
+ context
206
+ });
189
207
  await writeApi({
190
208
  components,
191
209
  context
@@ -210,6 +228,14 @@ async function build(options) {
210
228
  components,
211
229
  context
212
230
  });
231
+ await writeI18n({
232
+ components,
233
+ context
234
+ });
235
+ await codegenI18nLocales({
236
+ components,
237
+ context
238
+ });
213
239
  await writeLogger({
214
240
  components,
215
241
  context
@@ -242,6 +268,10 @@ async function build(options) {
242
268
  components,
243
269
  context
244
270
  });
271
+ await copyAgentFileSystems({
272
+ components,
273
+ context
274
+ });
245
275
  } catch (err) {
246
276
  if (err instanceof BuildError) {
247
277
  throw err;
@@ -67,6 +67,229 @@ export default {
67
67
  }
68
68
  }
69
69
  },
70
+ agent: {
71
+ type: 'object',
72
+ additionalProperties: false,
73
+ required: [
74
+ 'id',
75
+ 'type',
76
+ 'connectionId'
77
+ ],
78
+ properties: {
79
+ '~ignoreBuildChecks': {
80
+ oneOf: [
81
+ {
82
+ const: true
83
+ },
84
+ {
85
+ type: 'array',
86
+ items: {
87
+ type: 'string',
88
+ enum: [
89
+ 'state-refs',
90
+ 'payload-refs',
91
+ 'step-refs',
92
+ 'link-refs',
93
+ 'request-refs',
94
+ 'connection-refs',
95
+ 'types',
96
+ 'schema'
97
+ ]
98
+ }
99
+ }
100
+ ]
101
+ },
102
+ '~r': {},
103
+ '~l': {},
104
+ id: {
105
+ type: 'string',
106
+ errorMessage: {
107
+ type: 'Agent "id" should be a string.'
108
+ }
109
+ },
110
+ type: {
111
+ type: 'string',
112
+ errorMessage: {
113
+ type: 'Agent "type" should be a string.'
114
+ }
115
+ },
116
+ connectionId: {
117
+ type: 'string',
118
+ errorMessage: {
119
+ type: 'Agent "connectionId" should be a string.'
120
+ }
121
+ },
122
+ properties: {
123
+ type: 'object',
124
+ errorMessage: {
125
+ type: 'Agent "properties" should be an object.'
126
+ }
127
+ },
128
+ tools: {
129
+ type: 'array',
130
+ items: {
131
+ anyOf: [
132
+ {
133
+ type: 'string'
134
+ },
135
+ {
136
+ type: 'object',
137
+ required: [
138
+ 'endpointId'
139
+ ],
140
+ properties: {
141
+ endpointId: {
142
+ type: 'string'
143
+ },
144
+ confirm: {
145
+ const: true
146
+ }
147
+ },
148
+ additionalProperties: false
149
+ }
150
+ ]
151
+ },
152
+ errorMessage: {
153
+ type: 'Agent "tools" should be an array.'
154
+ }
155
+ },
156
+ mcp: {
157
+ type: 'array',
158
+ items: {
159
+ anyOf: [
160
+ {
161
+ type: 'string'
162
+ },
163
+ {
164
+ type: 'object',
165
+ properties: {
166
+ connectionId: {
167
+ type: 'string'
168
+ },
169
+ url: {
170
+ type: 'string'
171
+ },
172
+ transport: {
173
+ type: 'string',
174
+ enum: [
175
+ 'http',
176
+ 'sse',
177
+ 'stdio'
178
+ ],
179
+ default: 'http'
180
+ },
181
+ headers: {
182
+ type: 'object'
183
+ },
184
+ command: {
185
+ type: 'string'
186
+ },
187
+ args: {
188
+ type: 'array',
189
+ items: {
190
+ type: 'string'
191
+ }
192
+ },
193
+ env: {
194
+ type: 'object'
195
+ },
196
+ confirm: {
197
+ const: true
198
+ }
199
+ },
200
+ additionalProperties: false
201
+ }
202
+ ]
203
+ },
204
+ errorMessage: {
205
+ type: 'Agent "mcp" should be an array.'
206
+ }
207
+ },
208
+ hooks: {
209
+ type: 'object',
210
+ properties: {
211
+ onStart: {
212
+ type: 'array',
213
+ items: {
214
+ type: 'string'
215
+ }
216
+ },
217
+ onStepStart: {
218
+ type: 'array',
219
+ items: {
220
+ type: 'string'
221
+ }
222
+ },
223
+ onToolCallStart: {
224
+ type: 'array',
225
+ items: {
226
+ type: 'string'
227
+ }
228
+ },
229
+ onToolCallFinish: {
230
+ type: 'array',
231
+ items: {
232
+ type: 'string'
233
+ }
234
+ },
235
+ onStepFinish: {
236
+ type: 'array',
237
+ items: {
238
+ type: 'string'
239
+ }
240
+ },
241
+ onFinish: {
242
+ type: 'array',
243
+ items: {
244
+ type: 'string'
245
+ }
246
+ }
247
+ },
248
+ errorMessage: {
249
+ type: 'Agent "hooks" should be an object.'
250
+ }
251
+ },
252
+ agents: {
253
+ type: 'array',
254
+ items: {
255
+ anyOf: [
256
+ {
257
+ type: 'string'
258
+ },
259
+ {
260
+ type: 'object',
261
+ required: [
262
+ 'agentId'
263
+ ],
264
+ properties: {
265
+ agentId: {
266
+ type: 'string'
267
+ },
268
+ description: {
269
+ type: 'string'
270
+ },
271
+ inputSchema: {
272
+ type: 'object'
273
+ }
274
+ },
275
+ additionalProperties: false
276
+ }
277
+ ]
278
+ },
279
+ errorMessage: {
280
+ type: 'Agent "agents" should be an array.'
281
+ }
282
+ }
283
+ },
284
+ errorMessage: {
285
+ type: 'Agent should be an object.',
286
+ required: {
287
+ id: 'Agent should have required property "id".',
288
+ type: 'Agent should have required property "type".',
289
+ connectionId: 'Agent should have required property "connectionId".'
290
+ }
291
+ }
292
+ },
70
293
  app: {
71
294
  type: 'object',
72
295
  additionalProperties: false,
@@ -905,6 +1128,18 @@ export default {
905
1128
  type: 'Api endpoint "type" should be a string.'
906
1129
  }
907
1130
  },
1131
+ description: {
1132
+ type: 'string',
1133
+ errorMessage: {
1134
+ type: 'Api endpoint "description" should be a string.'
1135
+ }
1136
+ },
1137
+ payloadSchema: {
1138
+ type: 'object',
1139
+ errorMessage: {
1140
+ type: 'Api endpoint "payloadSchema" should be an object.'
1141
+ }
1142
+ },
908
1143
  routine: {
909
1144
  anyOf: [
910
1145
  {
@@ -1089,6 +1324,16 @@ export default {
1089
1324
  type: 'MenuGroup "type" should be a string.'
1090
1325
  }
1091
1326
  },
1327
+ style: {
1328
+ errorMessage: {
1329
+ type: 'MenuGroup "style" should be an object, string, or array.'
1330
+ }
1331
+ },
1332
+ class: {
1333
+ errorMessage: {
1334
+ type: 'MenuGroup "class" should be a string, array, or object.'
1335
+ }
1336
+ },
1092
1337
  properties: {
1093
1338
  type: 'object',
1094
1339
  errorMessage: {
@@ -1113,8 +1358,81 @@ export default {
1113
1358
  }
1114
1359
  }
1115
1360
  },
1361
+ menuDivider: {
1362
+ type: 'object',
1363
+ additionalProperties: false,
1364
+ required: [
1365
+ 'id',
1366
+ 'type'
1367
+ ],
1368
+ properties: {
1369
+ '~ignoreBuildChecks': {
1370
+ oneOf: [
1371
+ {
1372
+ const: true
1373
+ },
1374
+ {
1375
+ type: 'array',
1376
+ items: {
1377
+ type: 'string',
1378
+ enum: [
1379
+ 'state-refs',
1380
+ 'payload-refs',
1381
+ 'step-refs',
1382
+ 'link-refs',
1383
+ 'request-refs',
1384
+ 'connection-refs',
1385
+ 'types',
1386
+ 'schema'
1387
+ ]
1388
+ }
1389
+ }
1390
+ ]
1391
+ },
1392
+ '~r': {},
1393
+ '~l': {},
1394
+ id: {
1395
+ type: 'string',
1396
+ errorMessage: {
1397
+ type: 'MenuDivider "id" should be a string.'
1398
+ }
1399
+ },
1400
+ type: {
1401
+ type: 'string',
1402
+ errorMessage: {
1403
+ type: 'MenuDivider "type" should be a string.'
1404
+ }
1405
+ },
1406
+ style: {
1407
+ errorMessage: {
1408
+ type: 'MenuDivider "style" should be an object, string, or array.'
1409
+ }
1410
+ },
1411
+ class: {
1412
+ errorMessage: {
1413
+ type: 'MenuDivider "class" should be a string, array, or object.'
1414
+ }
1415
+ },
1416
+ properties: {
1417
+ type: 'object',
1418
+ errorMessage: {
1419
+ type: 'MenuDivider "properties" should be an object.'
1420
+ }
1421
+ }
1422
+ },
1423
+ errorMessage: {
1424
+ type: 'MenuDivider should be an object.',
1425
+ required: {
1426
+ id: 'MenuDivider should have required property "id".',
1427
+ type: 'MenuDivider should have required property "type".'
1428
+ }
1429
+ }
1430
+ },
1116
1431
  menuItem: {
1117
1432
  anyOf: [
1433
+ {
1434
+ $ref: '#/definitions/menuDivider'
1435
+ },
1118
1436
  {
1119
1437
  $ref: '#/definitions/menuGroup'
1120
1438
  },
@@ -1192,6 +1510,16 @@ export default {
1192
1510
  type: 'MenuLink "input" should be an object.'
1193
1511
  }
1194
1512
  },
1513
+ style: {
1514
+ errorMessage: {
1515
+ type: 'MenuLink "style" should be an object, string, or array.'
1516
+ }
1517
+ },
1518
+ class: {
1519
+ errorMessage: {
1520
+ type: 'MenuLink "class" should be a string, array, or object.'
1521
+ }
1522
+ },
1195
1523
  properties: {
1196
1524
  type: 'object',
1197
1525
  errorMessage: {
@@ -1396,6 +1724,20 @@ export default {
1396
1724
  type: 'App "version" should be a string.'
1397
1725
  }
1398
1726
  },
1727
+ slug: {
1728
+ type: 'string',
1729
+ pattern: '^[a-z][a-z0-9]*(-[a-z0-9]+)*$',
1730
+ errorMessage: {
1731
+ type: 'App "slug" should be a string.',
1732
+ pattern: 'App "slug" must be kebab-case: lowercase letters and digits, hyphen-separated, starting with a letter, no leading/trailing/consecutive hyphens, no underscores.'
1733
+ }
1734
+ },
1735
+ description: {
1736
+ type: 'string',
1737
+ errorMessage: {
1738
+ type: 'App "description" should be a string.'
1739
+ }
1740
+ },
1399
1741
  app: {
1400
1742
  $ref: '#/definitions/app'
1401
1743
  },
@@ -1453,6 +1795,69 @@ export default {
1453
1795
  errorMessage: {
1454
1796
  type: 'App "config.homePageId" should be a string.'
1455
1797
  }
1798
+ },
1799
+ i18n: {
1800
+ type: 'object',
1801
+ additionalProperties: false,
1802
+ required: [
1803
+ 'defaultLocale',
1804
+ 'locales'
1805
+ ],
1806
+ properties: {
1807
+ '~k': {},
1808
+ '~r': {},
1809
+ '~l': {},
1810
+ defaultLocale: {
1811
+ type: 'string',
1812
+ description: 'BCP 47 locale code used when no user preference or browser match is available.'
1813
+ },
1814
+ locales: {
1815
+ type: 'array',
1816
+ minItems: 1,
1817
+ items: {
1818
+ type: 'object',
1819
+ additionalProperties: false,
1820
+ required: [
1821
+ 'code'
1822
+ ],
1823
+ properties: {
1824
+ '~k': {},
1825
+ '~r': {},
1826
+ '~l': {},
1827
+ code: {
1828
+ type: 'string',
1829
+ description: 'BCP 47 locale code (e.g. "en-US", "de-DE").'
1830
+ },
1831
+ label: {
1832
+ type: 'string',
1833
+ description: 'Human-readable label for language pickers.'
1834
+ },
1835
+ antd: {
1836
+ type: 'string',
1837
+ description: 'Ant Design locale module name (e.g. "en_US"). Loaded from antd/locale/{name}.'
1838
+ },
1839
+ dayjs: {
1840
+ type: 'string',
1841
+ description: 'Dayjs locale id (e.g. "en", "zh-cn").'
1842
+ }
1843
+ }
1844
+ }
1845
+ },
1846
+ messages: {
1847
+ type: 'object',
1848
+ description: 'Translation messages keyed by locale code. Each locale maps to an object of { key: ICU MessageFormat string }.',
1849
+ additionalProperties: {
1850
+ type: 'object'
1851
+ }
1852
+ }
1853
+ },
1854
+ errorMessage: {
1855
+ type: 'App "config.i18n" should be an object.',
1856
+ required: {
1857
+ defaultLocale: 'App "config.i18n" requires "defaultLocale".',
1858
+ locales: 'App "config.i18n" requires a "locales" array.'
1859
+ }
1860
+ }
1456
1861
  }
1457
1862
  }
1458
1863
  },
@@ -1495,6 +1900,15 @@ export default {
1495
1900
  type: 'App "global" should be an object.'
1496
1901
  }
1497
1902
  },
1903
+ agents: {
1904
+ type: 'array',
1905
+ items: {
1906
+ $ref: '#/definitions/agent'
1907
+ },
1908
+ errorMessage: {
1909
+ type: 'App "agents" should be an array.'
1910
+ }
1911
+ },
1498
1912
  connections: {
1499
1913
  type: 'array',
1500
1914
  items: {
@@ -0,0 +1,37 @@
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
+ */ import path from 'path';
17
+ import { writeFile } from '@lowdefy/node-utils';
18
+ import defaultPackages from '../defaultPackages.js';
19
+ async function generateDefaultMessagesMap() {
20
+ const defaultMessagesMap = {};
21
+ for (const packageName of defaultPackages){
22
+ let messagesModule;
23
+ try {
24
+ messagesModule = await import(`${packageName}/messages`);
25
+ } catch (e) {
26
+ continue;
27
+ }
28
+ const messages = messagesModule.default ?? messagesModule;
29
+ if (!messages || typeof messages !== 'object') continue;
30
+ defaultMessagesMap[packageName] = messages;
31
+ }
32
+ await writeFile(path.resolve(process.cwd(), './dist/defaultMessagesMap.js'), `const defaultMessagesMap = ${JSON.stringify(defaultMessagesMap, null, 2)};
33
+
34
+ export default defaultMessagesMap;
35
+ `);
36
+ }
37
+ generateDefaultMessagesMap();
@@ -21,6 +21,7 @@ async function generateDefaultTypesMap() {
21
21
  const packageFile = JSON.parse(await readFile(path.resolve(process.cwd(), './package.json')));
22
22
  const defaultTypesMap = {
23
23
  actions: {},
24
+ agents: {},
24
25
  auth: {
25
26
  adapters: {},
26
27
  callbacks: {},
@@ -29,6 +29,7 @@ function testContext({ writeBuildArtifact, configDirectory, readConfigFile, logg
29
29
  },
30
30
  typeCounters: {
31
31
  actions: createCounter(),
32
+ agents: createCounter(),
32
33
  auth: {
33
34
  adapters: createCounter(),
34
35
  callbacks: createCounter(),
@@ -49,6 +50,7 @@ function testContext({ writeBuildArtifact, configDirectory, readConfigFile, logg
49
50
  refMap: {},
50
51
  keyMap: {},
51
52
  jsMap: {},
53
+ agentIds: new Set(),
52
54
  connectionIds: new Set()
53
55
  };
54
56
  context.logger = {
@@ -32,6 +32,13 @@ function createPluginTypesMap({ packageName, packageTypes, typePrefix = '', type
32
32
  typePrefix,
33
33
  version
34
34
  });
35
+ createTypeDefinitions({
36
+ typeNames: packageTypes.agents,
37
+ store: typesMap.agents,
38
+ packageName,
39
+ typePrefix,
40
+ version
41
+ });
35
42
  createTypeDefinitions({
36
43
  typeNames: type.isObject(packageTypes.auth) ? packageTypes.auth.adapters : [],
37
44
  store: typesMap.auth.adapters,