theprogrammablemind_4wp 7.5.4-beta.2 → 7.5.4-beta.4
Sign up to get free protection for your applications and to get access to all the features.
- package/client.js +13 -7
- package/package.json +5 -4
- package/src/config.js +150 -4
package/client.js
CHANGED
@@ -478,7 +478,7 @@ const doWithRetries = async (n, url, queryParams, data) => {
|
|
478
478
|
}
|
479
479
|
}
|
480
480
|
|
481
|
-
const setupProcessB = ({ config, allowDelta=false } = {}) => {
|
481
|
+
const setupProcessB = ({ config, initializer, allowDelta=false } = {}) => {
|
482
482
|
const key = config._key
|
483
483
|
|
484
484
|
const data = Object.assign({ key, version: '3' }, { uuid: config._uuid })
|
@@ -526,7 +526,7 @@ const processInstance = (config, instance) => {
|
|
526
526
|
global.transitoryMode = transitoryMode
|
527
527
|
}
|
528
528
|
|
529
|
-
const _process = async (config, query, { commandLineArgs, credentials, writeTests, isTest, saveDeveloper, testConfig, testsFN, errorHandler = defaultErrorHandler } = {}) => {
|
529
|
+
const _process = async (config, query, { initializer, commandLineArgs, credentials, writeTests, isTest, saveDeveloper, testConfig, testsFN, errorHandler = defaultErrorHandler } = {}) => {
|
530
530
|
if (credentials) {
|
531
531
|
config.server(credentials.server, credentials.key)
|
532
532
|
}
|
@@ -546,7 +546,7 @@ const _process = async (config, query, { commandLineArgs, credentials, writeTest
|
|
546
546
|
throw error
|
547
547
|
}
|
548
548
|
|
549
|
-
let { data, /* generators, semantics, */ hierarchy } = setupProcessB({ config, allowDelta: true })
|
549
|
+
let { data, /* generators, semantics, */ hierarchy } = setupProcessB({ config, initializer, allowDelta: true })
|
550
550
|
if (commandLineArgs && commandLineArgs.checkForLoop) {
|
551
551
|
data.checkForLoop = true
|
552
552
|
}
|
@@ -1057,7 +1057,7 @@ const build = async ({ config, target, template, errorHandler = defaultErrorHand
|
|
1057
1057
|
finish()
|
1058
1058
|
return
|
1059
1059
|
}
|
1060
|
-
const { property, hierarchy, query: queryOrExtraConfig, skipSemantics } = queries.shift()
|
1060
|
+
const { property, hierarchy, query: queryOrExtraConfig, initializer, skipSemantics } = queries.shift()
|
1061
1061
|
// queries are strings or { query: "blah", development: true/false }
|
1062
1062
|
if (typeof queryOrExtraConfig === 'string' || queryOrExtraConfig.query) {
|
1063
1063
|
let query = queryOrExtraConfig;
|
@@ -1082,7 +1082,7 @@ const build = async ({ config, target, template, errorHandler = defaultErrorHand
|
|
1082
1082
|
}
|
1083
1083
|
|
1084
1084
|
try {
|
1085
|
-
const results = await _process(config, query.query, {})
|
1085
|
+
const results = await _process(config, query.query, {initializer})
|
1086
1086
|
if (config.config.debug) {
|
1087
1087
|
// TODO pass in the error handler like the other ones
|
1088
1088
|
defaultInnerProcess(config, defaultErrorHandler, results)
|
@@ -1160,7 +1160,9 @@ const build = async ({ config, target, template, errorHandler = defaultErrorHand
|
|
1160
1160
|
return queryStringOrProperties
|
1161
1161
|
}
|
1162
1162
|
}
|
1163
|
-
let todo =
|
1163
|
+
let todo = []
|
1164
|
+
todo = todo.concat((template.initializers || []).map((query) => { return { initializer: true, property: 'resultss', query, skipSemantics: false } }))
|
1165
|
+
todo = todo.concat((template.queries || []).map((query) => { return { property: 'resultss', query, skipSemantics: false } }))
|
1164
1166
|
todo = todo.concat((template.fragments || []).map((query) => { return Object.assign({}, toProperties(query), { property: 'fragments', skipSemantics: false }) }))
|
1165
1167
|
todo = todo.concat((template.semantics || []).map((definition) => { return { property: 'semantics', query: `${definition.from}\n${definition.to}`, skipSemantics: true } }))
|
1166
1168
|
await looper(Object.assign([], todo))
|
@@ -1265,7 +1267,6 @@ const knowledgeModule = async ({
|
|
1265
1267
|
config.load(template.template, template.instance)
|
1266
1268
|
}
|
1267
1269
|
}
|
1268
|
-
|
1269
1270
|
if (isProcess) {
|
1270
1271
|
// setup();
|
1271
1272
|
const parser = new runtime.ArgumentParser({
|
@@ -1299,6 +1300,7 @@ const knowledgeModule = async ({
|
|
1299
1300
|
parser.add_argument('-da', '--debugAssociation', { help: 'When running with the --debugAssociation flag the debugging will break when the specified association is added to the config' })
|
1300
1301
|
parser.add_argument('-dh', '--debugHierarchy', { help: 'When running with the --debugHierarchy flag the debugging will break when the specified child-parent pair is added to the config for the main config. Set DEBUG_HIERARCHY to debug any config loaded. For example DEBUG_HIERARCHY=\'["cat", "mammel"]\'' })
|
1301
1302
|
parser.add_argument('-db', '--debugBridge', { help: 'When running with the --debugBridge flag the debugging will break when the specified bridge is added to the config for the main config. Set DEBUG_BRIDGE to debug any config loaded. For example DEBUG_BRIDGE=\'id/level\'' })
|
1303
|
+
parser.add_argument('-do', '--debugOperator', { help: 'When running with the --debugOperator flag the debugging will break when the specified operator is added to the config for the main config. Set DEBUG_OPERATOR to debug any config loaded. For example DEBUG_OPERATOR=\'([operator] ([arg]))\'' })
|
1302
1304
|
|
1303
1305
|
const args = parser.parse_args()
|
1304
1306
|
args.count = args.count || 1
|
@@ -1316,6 +1318,10 @@ const knowledgeModule = async ({
|
|
1316
1318
|
console.log('Expected DEBUG_BRIDGE to be of the form "id/level"');
|
1317
1319
|
}
|
1318
1320
|
}
|
1321
|
+
if (args.debugOperator) {
|
1322
|
+
// id/level
|
1323
|
+
global.entodictonDebugOperator = args.debugOperator
|
1324
|
+
}
|
1319
1325
|
|
1320
1326
|
if (args.clean) {
|
1321
1327
|
const tests = JSON.parse(runtime.fs.readFileSync(testConfig.name))
|
package/package.json
CHANGED
@@ -10,12 +10,13 @@
|
|
10
10
|
"eslint": "^7.31.0"
|
11
11
|
},
|
12
12
|
"scripts": {
|
13
|
-
"to:debug": "node inspect node_modules/.bin/jest --runInBand -t
|
13
|
+
"to:debug": "node inspect node_modules/.bin/jest --runInBand -t NEO23",
|
14
14
|
"test:debug": "node inspect node_modules/.bin/jest --runInBand --config ./jest.config.json",
|
15
|
-
"tod": "node inspect node_modules/.bin/jest --runInBand -t
|
15
|
+
"tod": "node inspect node_modules/.bin/jest --runInBand -t NEO23",
|
16
16
|
"lint:fix": "eslint \"**/*.js\" --fix",
|
17
17
|
"lint": "eslint \"**/*.js\"",
|
18
|
-
"to": "node node_modules/.bin/jest --runInBand -t
|
18
|
+
"to": "node node_modules/.bin/jest --runInBand -t NEO23",
|
19
|
+
"tos": "node node_modules/.bin/jest --runInBand -t NEOS23",
|
19
20
|
"test": "jest --config ./jest.config.json",
|
20
21
|
"test:watch": "npm run test -- --watch"
|
21
22
|
},
|
@@ -61,6 +62,6 @@
|
|
61
62
|
"json-stable-stringify": "^1.0.1",
|
62
63
|
"node-fetch": "^2.6.1"
|
63
64
|
},
|
64
|
-
"version": "7.5.4-beta.
|
65
|
+
"version": "7.5.4-beta.4",
|
65
66
|
"license": "ISC"
|
66
67
|
}
|
package/src/config.js
CHANGED
@@ -22,6 +22,88 @@ const indent = (string, indent) => {
|
|
22
22
|
return string.replace(/^/gm, ' '.repeat(indent));
|
23
23
|
}
|
24
24
|
|
25
|
+
const handleBridgeProps = (config, bridge) => {
|
26
|
+
if (!bridge.bridge) {
|
27
|
+
bridge.bridge = "{ ...next(operator) }"
|
28
|
+
}
|
29
|
+
if (!bridge.level) {
|
30
|
+
bridge.level = 0
|
31
|
+
}
|
32
|
+
if (bridge.children) {
|
33
|
+
for (let child of bridge.children) {
|
34
|
+
config.addHierarchy(child, bridge.id)
|
35
|
+
}
|
36
|
+
}
|
37
|
+
if (bridge.parents) {
|
38
|
+
for (let parent of bridge.parents) {
|
39
|
+
config.addHierarchy(bridge.id, parent)
|
40
|
+
}
|
41
|
+
}
|
42
|
+
if (bridge.isA) {
|
43
|
+
for (let parent of bridge.isA) {
|
44
|
+
config.addHierarchy(bridge.id, parent)
|
45
|
+
}
|
46
|
+
}
|
47
|
+
if (bridge.before) {
|
48
|
+
for (let after of bridge.before) {
|
49
|
+
if (typeof after == 'string') {
|
50
|
+
after = [after, 0]
|
51
|
+
}
|
52
|
+
config.addPriorities([after, [bridge.id, bridge.level]])
|
53
|
+
}
|
54
|
+
}
|
55
|
+
if (bridge.words) {
|
56
|
+
for (let def of bridge.words) {
|
57
|
+
if (typeof def == 'string') {
|
58
|
+
config.addWordInternal(def, {"id": bridge.id, "initial": `{ value: "${def}"}` })
|
59
|
+
} else {
|
60
|
+
const word = def.word
|
61
|
+
def = { initial: JSON.stringify(def), id: bridge.id, word: undefined }
|
62
|
+
config.addWordInternal(word, def)
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
if (bridge.generator) {
|
67
|
+
config.config.generators.unshift(bridge.generator)
|
68
|
+
}
|
69
|
+
if (bridge.generators) {
|
70
|
+
const generators = [...bridge.generators]
|
71
|
+
generators.reverse()
|
72
|
+
for (let generator of generators) {
|
73
|
+
config.config.generators.unshift(generator)
|
74
|
+
}
|
75
|
+
}
|
76
|
+
if (bridge.generatorp) {
|
77
|
+
config.config.generators.unshift({
|
78
|
+
where: bridge.generatorp.where || client.where(3),
|
79
|
+
match: ({context}) => bridge.id == context.marker && context.paraphrase,
|
80
|
+
apply: (args) => bridge.generatorp(args),
|
81
|
+
})
|
82
|
+
}
|
83
|
+
if (bridge.generatorr) {
|
84
|
+
config.config.generators.unshift({
|
85
|
+
// TODO merge response and isResponse
|
86
|
+
where: bridge.generatorr.where || client.where(3),
|
87
|
+
match: ({context}) => bridge.id == context.marker && !context.paraphrase && (context.response || context.isResponse),
|
88
|
+
apply: (args) => bridge.generatorr(args),
|
89
|
+
})
|
90
|
+
}
|
91
|
+
if (bridge.evaluator) {
|
92
|
+
config.config.semantics.unshift({
|
93
|
+
where: bridge.evaluator.where || client.where(3),
|
94
|
+
match: ({context}) => bridge.id == context.marker && context.evaluate,
|
95
|
+
apply: (args) => bridge.evaluator(args),
|
96
|
+
})
|
97
|
+
}
|
98
|
+
if (bridge.semantic) {
|
99
|
+
config.config.semantics.unshift({
|
100
|
+
where: bridge.semantic.where || client.where(3),
|
101
|
+
match: ({context}) => bridge.id == context.marker,
|
102
|
+
apply: (args) => bridge.semantic(args),
|
103
|
+
})
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
25
107
|
if (runtime.process.env.DEBUG_HIERARCHY) {
|
26
108
|
global.entodictonDebugHierarchy = JSON.parse(runtime.process.env.DEBUG_HIERARCHY)
|
27
109
|
}
|
@@ -35,6 +117,11 @@ if (runtime.process.env.DEBUG_BRIDGE) {
|
|
35
117
|
global.entodictonDebugBridge[1] = int(global.entodictonDebugBridge[1])
|
36
118
|
}
|
37
119
|
|
120
|
+
if (runtime.process.env.DEBUG_OPERATOR) {
|
121
|
+
// id/level
|
122
|
+
global.entodictonDebugOperator = runtime.process.env.DEBUG_OPERATOR
|
123
|
+
}
|
124
|
+
|
38
125
|
const hierarchyCanonical = (element) => {
|
39
126
|
if (element.child && element.parent) {
|
40
127
|
return element
|
@@ -86,6 +173,17 @@ const normalizeConfig = (config) => {
|
|
86
173
|
config[bag][i].km = config.name
|
87
174
|
}
|
88
175
|
}
|
176
|
+
|
177
|
+
}
|
178
|
+
if (config['bridges']) {
|
179
|
+
for (let bridge of config['bridges']) {
|
180
|
+
if (!bridge.level) {
|
181
|
+
bridge.level = 0
|
182
|
+
}
|
183
|
+
if (!bridge.bridge) {
|
184
|
+
bridge.bridge = "{ ...next(operator) }"
|
185
|
+
}
|
186
|
+
}
|
89
187
|
}
|
90
188
|
}
|
91
189
|
}
|
@@ -324,6 +422,29 @@ const multiApiImpl = (initializer) => {
|
|
324
422
|
|
325
423
|
class Config {
|
326
424
|
|
425
|
+
// return the config with just the elements from the included KM's
|
426
|
+
baseConfig() {
|
427
|
+
const operators = this.config.operators.filter((operator) => {
|
428
|
+
return operator.uuid !== this.uuid
|
429
|
+
})
|
430
|
+
const bridges = this.config.bridges.filter((bridge) => {
|
431
|
+
return bridge.uuid !== this.uuid
|
432
|
+
})
|
433
|
+
const words = {}
|
434
|
+
for (let word in this.config.words) {
|
435
|
+
const defs = this.config.words[word].filter( (def) => def.uuid !== this.uuid )
|
436
|
+
if (defs.length > 0) {
|
437
|
+
words[word] = defs
|
438
|
+
}
|
439
|
+
}
|
440
|
+
debugger
|
441
|
+
return {
|
442
|
+
operators,
|
443
|
+
bridges,
|
444
|
+
words
|
445
|
+
}
|
446
|
+
}
|
447
|
+
|
327
448
|
getCounter (maybeName = '') {
|
328
449
|
const counter = this.configCounter
|
329
450
|
this.configCounter += 1
|
@@ -689,6 +810,7 @@ class Config {
|
|
689
810
|
if (global.transitoryMode) {
|
690
811
|
def.transitoryMode = true
|
691
812
|
}
|
813
|
+
handleBridgeProps(this, def)
|
692
814
|
bridges.push(def)
|
693
815
|
this.checkBridges();
|
694
816
|
this._delta.json.bridges.push({ action: 'add', bridge: def })
|
@@ -751,6 +873,7 @@ class Config {
|
|
751
873
|
if (!this.config.operators) {
|
752
874
|
this.config.operators = []
|
753
875
|
}
|
876
|
+
|
754
877
|
const operators = this.config.operators
|
755
878
|
|
756
879
|
let operator;
|
@@ -760,6 +883,12 @@ class Config {
|
|
760
883
|
operator = Object.assign({}, objectOrPattern, { uuid: this._uuid })
|
761
884
|
}
|
762
885
|
|
886
|
+
if (global.entodictonDebugOperator) {
|
887
|
+
if (operator.pattern === global.entodictonDebugOperator) {
|
888
|
+
debugger; // debug operator hit
|
889
|
+
}
|
890
|
+
}
|
891
|
+
|
763
892
|
if (operator.allowDups) {
|
764
893
|
if (operators.find( (o) => o.pattern == operator.pattern )) {
|
765
894
|
return;
|
@@ -1018,6 +1147,7 @@ class Config {
|
|
1018
1147
|
'debug',
|
1019
1148
|
|
1020
1149
|
// TODO Fix these from the test app
|
1150
|
+
'implicits',
|
1021
1151
|
'convolution',
|
1022
1152
|
'expected_generated',
|
1023
1153
|
'expected_results',
|
@@ -1118,6 +1248,18 @@ class Config {
|
|
1118
1248
|
const valid = [ 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generators', 'id', 'convolution', 'inverted', 'isA', 'children', 'parents',
|
1119
1249
|
'level', 'optional', 'selector', 'semantic', 'words', /Bridge$/, 'localHierarchy' ]
|
1120
1250
|
helpers.validProps(valid, bridge, 'bridge')
|
1251
|
+
/* moved
|
1252
|
+
if (!bridge.bridge) {
|
1253
|
+
bridge.bridge = "{ ...next(operator) }"
|
1254
|
+
}
|
1255
|
+
*/
|
1256
|
+
handleBridgeProps(this, bridge)
|
1257
|
+
|
1258
|
+
/* moved
|
1259
|
+
if (!bridge.level) {
|
1260
|
+
bridge.level = 0
|
1261
|
+
}
|
1262
|
+
*/
|
1121
1263
|
/*
|
1122
1264
|
if (bridge.generator) {
|
1123
1265
|
this.config.generators.push({
|
@@ -1126,6 +1268,7 @@ class Config {
|
|
1126
1268
|
})
|
1127
1269
|
}
|
1128
1270
|
*/
|
1271
|
+
/* moved
|
1129
1272
|
if (bridge.children) {
|
1130
1273
|
for (let child of bridge.children) {
|
1131
1274
|
this.addHierarchy(child, bridge.id)
|
@@ -1141,6 +1284,8 @@ class Config {
|
|
1141
1284
|
this.addHierarchy(bridge.id, parent)
|
1142
1285
|
}
|
1143
1286
|
}
|
1287
|
+
*/
|
1288
|
+
/* moved
|
1144
1289
|
if (bridge.before) {
|
1145
1290
|
for (let after of bridge.before) {
|
1146
1291
|
if (typeof after == 'string') {
|
@@ -1163,6 +1308,8 @@ class Config {
|
|
1163
1308
|
if (bridge.generator) {
|
1164
1309
|
this.config.generators.unshift(bridge.generator)
|
1165
1310
|
}
|
1311
|
+
*/
|
1312
|
+
/* moved
|
1166
1313
|
if (bridge.generators) {
|
1167
1314
|
const generators = [...bridge.generators]
|
1168
1315
|
generators.reverse()
|
@@ -1199,6 +1346,7 @@ class Config {
|
|
1199
1346
|
apply: (args) => bridge.semantic(args),
|
1200
1347
|
})
|
1201
1348
|
}
|
1349
|
+
*/
|
1202
1350
|
}
|
1203
1351
|
if (config.operators) {
|
1204
1352
|
config.operators = config.operators.map((operator) => {
|
@@ -1613,7 +1761,8 @@ class Config {
|
|
1613
1761
|
|
1614
1762
|
if (currentConfig.api) {
|
1615
1763
|
currentConfig.api.objects = args.objects
|
1616
|
-
currentConfig.api.config = () => this
|
1764
|
+
// GREG42 currentConfig.api.config = () => this
|
1765
|
+
currentConfig.api.config = () => args.baseConfig
|
1617
1766
|
currentConfig.api.uuid = currentConfig._uuid
|
1618
1767
|
}
|
1619
1768
|
// this.instances.forEach( (instance) => client.processInstance(this, instance) )
|
@@ -2560,9 +2709,6 @@ class Config {
|
|
2560
2709
|
// console.log('key', key, 'XXX')
|
2561
2710
|
// console.log('more', JSON.stringify(more, null, 2))
|
2562
2711
|
// this.config[key] = this.config[key].concat(more[key])
|
2563
|
-
if (key == '2enerators') {
|
2564
|
-
debugger
|
2565
|
-
}
|
2566
2712
|
// this.config[key] = this.config[key].concat(more[key])
|
2567
2713
|
this.config[key] = more[key].concat(this.config[key])
|
2568
2714
|
} else {
|