theprogrammablemind 9.5.1-beta.33 → 9.5.1-beta.35
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/package.json +1 -1
- package/src/config.js +39 -1
- package/src/configHelpers.js +6 -18
- package/src/generators.js +9 -7
- package/src/semantics.js +9 -7
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -1002,9 +1002,17 @@ class Config {
|
|
|
1002
1002
|
|
|
1003
1003
|
semantics: () => this.config.semantics,
|
|
1004
1004
|
getConfigs: () => this.configs,
|
|
1005
|
+
getTestConfig: () => this.getTestConfig(),
|
|
1005
1006
|
getTests: () => this.getTests(),
|
|
1006
1007
|
getName: () => this.getName(),
|
|
1007
1008
|
getDescription: () => this.getDescription(),
|
|
1009
|
+
getDebug: () => this.getDebug(),
|
|
1010
|
+
getDebugLoops: () => this.getDebugLoops(),
|
|
1011
|
+
getMaxDepth: () => this.getMaxDepth(),
|
|
1012
|
+
getAPIs: (...args) => this.getAPIs(...args),
|
|
1013
|
+
getAPI: (...args) => this.getAPI(...args),
|
|
1014
|
+
getUUID: (...args) => this.getUUID(...args),
|
|
1015
|
+
nsToString: (...args) => this.nsToString(...args),
|
|
1008
1016
|
|
|
1009
1017
|
getHierarchy: (...args) => this.config.hierarchy,
|
|
1010
1018
|
getBridges: (...args) => this.config.bridges,
|
|
@@ -1021,6 +1029,26 @@ class Config {
|
|
|
1021
1029
|
}
|
|
1022
1030
|
}
|
|
1023
1031
|
|
|
1032
|
+
getUUID() {
|
|
1033
|
+
return this.uuid
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
getTestConfig() {
|
|
1037
|
+
return this.testConfig
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
getMaxDepth() {
|
|
1041
|
+
return this.config.maxDepth
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
getDebug() {
|
|
1045
|
+
return this.config.debug
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
getDebugLoops() {
|
|
1049
|
+
return this.config.debugLoops
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1024
1052
|
getName() {
|
|
1025
1053
|
return this.name
|
|
1026
1054
|
}
|
|
@@ -1800,7 +1828,9 @@ class Config {
|
|
|
1800
1828
|
|
|
1801
1829
|
getAPIs (uuid) {
|
|
1802
1830
|
let config
|
|
1803
|
-
if (
|
|
1831
|
+
if (!uuid) {
|
|
1832
|
+
config = this
|
|
1833
|
+
} else if (this._uuid === uuid) {
|
|
1804
1834
|
config = this
|
|
1805
1835
|
} else {
|
|
1806
1836
|
for (const km of this.configs) {
|
|
@@ -1815,6 +1845,14 @@ class Config {
|
|
|
1815
1845
|
}
|
|
1816
1846
|
}
|
|
1817
1847
|
|
|
1848
|
+
/*
|
|
1849
|
+
getAPIs (config) {
|
|
1850
|
+
if (config && config._api && config._api.multiApi) {
|
|
1851
|
+
return config._api.apis
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
*/
|
|
1855
|
+
|
|
1818
1856
|
getServer () {
|
|
1819
1857
|
return this._server
|
|
1820
1858
|
}
|
package/src/configHelpers.js
CHANGED
|
@@ -97,11 +97,11 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
97
97
|
if (args.uuid) {
|
|
98
98
|
args.objects = args.getObjects(args.uuid)
|
|
99
99
|
}
|
|
100
|
-
if (!hierarchy) {
|
|
101
|
-
hierarchy = config.
|
|
100
|
+
if (!hierarchy && config.getHierarchy) {
|
|
101
|
+
hierarchy = config.getHierarchy()
|
|
102
102
|
}
|
|
103
103
|
// callId
|
|
104
|
-
args.calls = new InitCalls(args.isInstance ? `${args.isInstance}#${config.
|
|
104
|
+
args.calls = new InitCalls(args.isInstance ? `${args.isInstance}#${config.getName()}` : config.getName())
|
|
105
105
|
if (global.theprogrammablemind && global.theprogrammablemind.loadForTesting) {
|
|
106
106
|
args.calls = new InitCalls(Object.keys(global.theprogrammablemind.loadForTesting)[0])
|
|
107
107
|
}
|
|
@@ -137,8 +137,8 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
137
137
|
args.addPattern = (pattern, def) => config.addPattern(pattern, args.uuid)
|
|
138
138
|
args.addGenerator = (generator) => config.addGenerator(generator, args.uuid, config.name)
|
|
139
139
|
|
|
140
|
-
if (config.
|
|
141
|
-
args.testModuleName = config.
|
|
140
|
+
if (config.getTestConfig()?.testModuleName) {
|
|
141
|
+
args.testModuleName = config.getTestConfig().testModuleName
|
|
142
142
|
}
|
|
143
143
|
args.addAssumedScoped = (args, assumed) => {
|
|
144
144
|
const addAssumed = (args, ...moreAssumed) => {
|
|
@@ -198,15 +198,8 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
198
198
|
}
|
|
199
199
|
config.getAddedArgs(args)
|
|
200
200
|
|
|
201
|
-
Object.assign(args, args.getUUIDScoped(uuidForScoping || config.
|
|
201
|
+
Object.assign(args, args.getUUIDScoped(uuidForScoping || config.getUUID()))
|
|
202
202
|
args.apis = args.apis || ((name) => config.getConfig(name).api)
|
|
203
|
-
// args.apis = (name) => config.getAPIs(name)
|
|
204
|
-
/*
|
|
205
|
-
if (uuidForScoping) {
|
|
206
|
-
Object.assign(args, args.getUUIDScoped(uuidForScoping))
|
|
207
|
-
}
|
|
208
|
-
*/
|
|
209
|
-
// sets args for all the API. that make a copy so the args must be fully setup by here except for scoped
|
|
210
203
|
config.setArgs(args)
|
|
211
204
|
}
|
|
212
205
|
|
|
@@ -467,11 +460,6 @@ const loadInstance = async (config, instance) => {
|
|
|
467
460
|
const transitoryMode = global.transitoryMode
|
|
468
461
|
global.transitoryMode = false
|
|
469
462
|
|
|
470
|
-
/*
|
|
471
|
-
if (config.name == 'people' && instance.name == 'people') {
|
|
472
|
-
debugger
|
|
473
|
-
}
|
|
474
|
-
*/
|
|
475
463
|
const rl = instance.resultss.length
|
|
476
464
|
if (rl > 0) {
|
|
477
465
|
config.addAssociations(instance.resultss[instance.resultss.length - 1].rtf_associations || [])
|
package/src/generators.js
CHANGED
|
@@ -26,11 +26,13 @@ class Generator {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/*
|
|
29
30
|
getAPIs (config) {
|
|
30
31
|
if (config && config._api && config._api.multiApi) {
|
|
31
32
|
return config._api.apis
|
|
32
33
|
}
|
|
33
34
|
}
|
|
35
|
+
*/
|
|
34
36
|
|
|
35
37
|
toLabel () {
|
|
36
38
|
const where = this.where ? `where: "${this.where}"` : ''
|
|
@@ -59,7 +61,7 @@ class Generator {
|
|
|
59
61
|
context,
|
|
60
62
|
callId,
|
|
61
63
|
api: this.getAPI(config),
|
|
62
|
-
apis:
|
|
64
|
+
apis: config.getAPIs(),
|
|
63
65
|
}
|
|
64
66
|
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))
|
|
65
67
|
// return this.match(args)
|
|
@@ -78,11 +80,11 @@ class Generator {
|
|
|
78
80
|
if (!log) {
|
|
79
81
|
throw new Error('generators.apply argument log is required')
|
|
80
82
|
}
|
|
81
|
-
if (baseArgs.call && config && baseArgs.calls.stack.length > config.
|
|
82
|
-
throw new Error(`Max depth of ${config.
|
|
83
|
+
if (baseArgs.call && config && baseArgs.calls.stack.length > config.getMaxDepth()) {
|
|
84
|
+
throw new Error(`Max depth of ${config.getMaxDepth()} for calls has been exceeded. maxDepth can be set on the config object. To see the calls run with the --dl or set the debugLoops property on the config`)
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
if (config && config.
|
|
87
|
+
if (config && config.getDebugLoops()) {
|
|
86
88
|
console.log('apply', this.toLabel())
|
|
87
89
|
}
|
|
88
90
|
// this.getAPI(config)
|
|
@@ -113,7 +115,7 @@ class Generator {
|
|
|
113
115
|
config,
|
|
114
116
|
response,
|
|
115
117
|
api: this.getAPI(config),
|
|
116
|
-
apis:
|
|
118
|
+
apis: config.getAPIs()
|
|
117
119
|
}
|
|
118
120
|
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))
|
|
119
121
|
if (this.property === 'generatorp') {
|
|
@@ -229,7 +231,7 @@ class Generators {
|
|
|
229
231
|
args.calls.pop()
|
|
230
232
|
throw { error: [message], logs: this.logs }
|
|
231
233
|
}
|
|
232
|
-
if (
|
|
234
|
+
if (config.getDebug()) {
|
|
233
235
|
const widths = Lines.addRemainder([10, 10])
|
|
234
236
|
const lines = new Lines(widths)
|
|
235
237
|
lines.setElement(0, 0, 'Generator')
|
|
@@ -262,7 +264,7 @@ class Generators {
|
|
|
262
264
|
}
|
|
263
265
|
}
|
|
264
266
|
args.calls.pop()
|
|
265
|
-
if (!applied &&
|
|
267
|
+
if (!applied && config.getDebug()) {
|
|
266
268
|
const widths = Lines.addRemainder([10, 10])
|
|
267
269
|
const lines = new Lines(widths)
|
|
268
270
|
lines.setElement(0, 0, 'Generator')
|
package/src/semantics.js
CHANGED
|
@@ -44,11 +44,13 @@ class Semantic {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/*
|
|
47
48
|
getAPIs (config) {
|
|
48
49
|
if (config && config._api && config._api.multiApi) {
|
|
49
50
|
return config._api.apis
|
|
50
51
|
}
|
|
51
52
|
}
|
|
53
|
+
*/
|
|
52
54
|
|
|
53
55
|
fixUpArgs (args, context) {
|
|
54
56
|
args.uuid = this.uuid
|
|
@@ -58,7 +60,7 @@ class Semantic {
|
|
|
58
60
|
args.global = objects
|
|
59
61
|
const config = args.config
|
|
60
62
|
args.api = this.getAPI(config)
|
|
61
|
-
args.apis =
|
|
63
|
+
args.apis = config.getAPIs()
|
|
62
64
|
args.args = contextArgs(context, args.hierarchy)
|
|
63
65
|
args.context = context
|
|
64
66
|
let n = (id) => id
|
|
@@ -85,11 +87,11 @@ class Semantic {
|
|
|
85
87
|
async apply (args, context, s, options = {}) {
|
|
86
88
|
args = {...args}
|
|
87
89
|
const { config } = args
|
|
88
|
-
if (config && config.
|
|
90
|
+
if (config && config.getDebugLoops()) {
|
|
89
91
|
console.log('apply', this.toLabel())
|
|
90
92
|
}
|
|
91
|
-
if (args.calls && config && args.calls.stack.length > config.
|
|
92
|
-
throw new Error(`Max depth of ${config.
|
|
93
|
+
if (args.calls && config && args.calls.stack.length > config.getMaxDepth()) {
|
|
94
|
+
throw new Error(`Max depth of ${config.getMaxDepth()} for calls has been exceeded. maxDepth can be set on the config object. To see the calls run with the --dl or set the debugLoops property on the config`)
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
const contextPrime = Object.assign({}, context)
|
|
@@ -160,6 +162,7 @@ class Semantics {
|
|
|
160
162
|
}
|
|
161
163
|
args = { ...args }
|
|
162
164
|
const config = args.config
|
|
165
|
+
const debug = config.getDebug()
|
|
163
166
|
let contextPrime = Object.assign({}, context)
|
|
164
167
|
const s = (context, options) => this.apply(args, context, options)
|
|
165
168
|
let applied = false
|
|
@@ -200,7 +203,6 @@ class Semantics {
|
|
|
200
203
|
continue
|
|
201
204
|
}
|
|
202
205
|
if (!contextPrime.controlKeepMotivation && semantic.oneShot) {
|
|
203
|
-
// semantic.tied_ids.forEach((tied_id) => args.config.removeSemantic(tied_id))
|
|
204
206
|
args.config.removeSemantic(semantic)
|
|
205
207
|
}
|
|
206
208
|
for (const { listener } of deferred) {
|
|
@@ -250,7 +252,7 @@ class Semantics {
|
|
|
250
252
|
}
|
|
251
253
|
args.calls.touch(contextPrime)
|
|
252
254
|
// this.logs.push(`Semantics: applied ${semantic.toString()}\n to\n ${JSON.stringify(context)}\n the result was ${JSON.stringify(contextPrime)}\n`)
|
|
253
|
-
if (
|
|
255
|
+
if (config.getDebug()) {
|
|
254
256
|
const widths = Lines.addRemainder([10, 10])
|
|
255
257
|
const lines = new Lines(widths)
|
|
256
258
|
lines.setElement(0, 0, 'Semantic')
|
|
@@ -297,7 +299,7 @@ class Semantics {
|
|
|
297
299
|
counter += 1
|
|
298
300
|
}
|
|
299
301
|
args.calls.pop()
|
|
300
|
-
if (!applied &&
|
|
302
|
+
if (!applied && debug) {
|
|
301
303
|
const widths = Lines.addRemainder([10, 10])
|
|
302
304
|
const lines = new Lines(widths)
|
|
303
305
|
lines.setElement(0, 0, 'Semantic')
|