theprogrammablemind_4wp 9.5.1-beta.11 → 9.5.1-beta.13
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/client.js +1 -1
- package/lines.js +1 -1
- package/package.json +1 -1
- package/src/config.js +16 -6
- package/src/configHelpers.js +21 -9
- package/src/fragments.js +3 -1
- package/src/generators.js +5 -6
- package/src/semantics.js +2 -0
package/client.js
CHANGED
|
@@ -916,7 +916,7 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
|
|
|
916
916
|
console.log('')
|
|
917
917
|
const screen_width = process.stdout.columns
|
|
918
918
|
// || 0 for when running without a console
|
|
919
|
-
const widths = [70, 10
|
|
919
|
+
const widths = Lines.addRemainder([70, 10])
|
|
920
920
|
const lines = new Lines(widths)
|
|
921
921
|
lines.setElement(0, 0, '--- The paraphrases are ----------')
|
|
922
922
|
lines.setElement(0, 2, '--- The response strings are ----------')
|
package/lines.js
CHANGED
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -402,11 +402,15 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
|
402
402
|
if (bridge.generatorp) {
|
|
403
403
|
const match = bridge.generatorp.match || (() => true)
|
|
404
404
|
const apply = typeof bridge.generatorp === 'function' ? bridge.generatorp : bridge.generatorp.apply || bridge.generatorp
|
|
405
|
-
|
|
405
|
+
let level = bridge.generatorp.level >= 0 ? bridge.generatorp.level : bridge.level + 1
|
|
406
|
+
if (!bridge.bridge) {
|
|
407
|
+
level = 0
|
|
408
|
+
}
|
|
406
409
|
|
|
407
410
|
const generator = {
|
|
408
411
|
where: bridge.generatorp.where || bridge.where || helpers.where(4),
|
|
409
|
-
match: async (args) => bridge.id === args.context.marker && args.context.level === level && args.context.paraphrase && await match(args),
|
|
412
|
+
// match: async (args) => bridge.id === args.context.marker && args.context.level === level && args.context.paraphrase && await match(args),
|
|
413
|
+
match: async (args) => args.isA(args.context.marker, bridge.id) && args.context.level === level && args.context.paraphrase && await match(args),
|
|
410
414
|
apply: (args) => apply(args),
|
|
411
415
|
applyWrapped: apply,
|
|
412
416
|
property: 'generatorp'
|
|
@@ -423,7 +427,8 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
|
423
427
|
const level = bridge.generatorr.level >= 0 ? bridge.generatorr.level : bridge.level + 1
|
|
424
428
|
const generator = {
|
|
425
429
|
where: bridge.generatorr.where || bridge.where || helpers.where(4),
|
|
426
|
-
match: async (args) => bridge.id === args.context.marker && args.context.level === level && !args.context.paraphrase && (args.context.response || args.context.isResponse) && await match(args),
|
|
430
|
+
// match: async (args) => bridge.id === args.context.marker && args.context.level === level && !args.context.paraphrase && (args.context.response || args.context.isResponse) && await match(args),
|
|
431
|
+
match: async (args) => args.isA(args.context.marker, bridge.id) && args.context.level === level && !args.context.paraphrase && (args.context.response || args.context.isResponse) && await match(args),
|
|
427
432
|
apply: (args) => apply(args),
|
|
428
433
|
applyWrapped: apply,
|
|
429
434
|
property: 'generatorr'
|
|
@@ -1506,6 +1511,11 @@ class Config {
|
|
|
1506
1511
|
}
|
|
1507
1512
|
}
|
|
1508
1513
|
|
|
1514
|
+
updateBridge(id, updater) {
|
|
1515
|
+
const bridge = this.config.bridges.find((b) => b.id === id)
|
|
1516
|
+
updater({ config: this, bridge })
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1509
1519
|
addBridge (bridge, uuid) {
|
|
1510
1520
|
if (!this.config.bridges) {
|
|
1511
1521
|
this.config.bridges = []
|
|
@@ -1807,7 +1817,7 @@ class Config {
|
|
|
1807
1817
|
|
|
1808
1818
|
// set the args in the api's
|
|
1809
1819
|
setArgs (args) {
|
|
1810
|
-
const
|
|
1820
|
+
const setConfigArgs = (config) => {
|
|
1811
1821
|
if (!config._api) {
|
|
1812
1822
|
return
|
|
1813
1823
|
}
|
|
@@ -1820,10 +1830,10 @@ class Config {
|
|
|
1820
1830
|
}
|
|
1821
1831
|
}
|
|
1822
1832
|
|
|
1823
|
-
|
|
1833
|
+
setConfigArgs(this)
|
|
1824
1834
|
for (const config of this.configs) {
|
|
1825
1835
|
if (config.config instanceof Config) {
|
|
1826
|
-
|
|
1836
|
+
setConfigArgs(config.config)
|
|
1827
1837
|
}
|
|
1828
1838
|
}
|
|
1829
1839
|
}
|
package/src/configHelpers.js
CHANGED
|
@@ -144,15 +144,27 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
144
144
|
return { ...args, assumed: Object.assign({}, assumed, (args.assumed || {}), ...moreAssumed) }
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
args.s = (c) => config.getSemantics(logs).apply(args, c)
|
|
148
|
-
args.g = (c,
|
|
149
|
-
|
|
147
|
+
args.s = (c, options = {}) => config.getSemantics(logs).apply(args, c, options)
|
|
148
|
+
args.g = (c, rest = {}) => {
|
|
149
|
+
// if (JSON.stringify(rest) !== '{}' && !(rest.assumed || rest.options)) {
|
|
150
|
+
// debugger
|
|
151
|
+
// }
|
|
152
|
+
const { assumed = {}, options = {} } = rest
|
|
153
|
+
return config.getGenerators(logs).apply(addAssumed(args, assumed), c, assumed, options)
|
|
150
154
|
}
|
|
151
|
-
args.gp = (c,
|
|
152
|
-
|
|
155
|
+
args.gp = (c, rest = {}) => {
|
|
156
|
+
// if (JSON.stringify(rest) !== '{}' && !(rest.assumed || rest.options)) {
|
|
157
|
+
// debugger
|
|
158
|
+
// }
|
|
159
|
+
const { assumed = {}, options = {} } = rest
|
|
160
|
+
return config.getGenerators(logs).apply(addAssumed(args, assumed, { paraphrase: true, isResponse: false, response: false }), c, { paraphrase: true, isResponse: false, response: false }, options)
|
|
153
161
|
}
|
|
154
|
-
args.gr = (c,
|
|
155
|
-
|
|
162
|
+
args.gr = (c, rest = {}) => {
|
|
163
|
+
// if (JSON.stringify(rest) !== '{}' && !(rest.assumed || rest.options)) {
|
|
164
|
+
// debugger
|
|
165
|
+
// }
|
|
166
|
+
const { assumed = {}, options = {} } = rest
|
|
167
|
+
return config.getGenerators(logs).apply(addAssumed(args, assumed, { paraphrase: false, isResponse: true }), { ...c, paraphrase: false, isResponse: true }, options)
|
|
156
168
|
}
|
|
157
169
|
args.e = (c) => {
|
|
158
170
|
if (!c) {
|
|
@@ -180,13 +192,14 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
180
192
|
args.getUUIDScoped = (uuid) => {
|
|
181
193
|
return {
|
|
182
194
|
api: getAPI(uuid),
|
|
183
|
-
apis: getAPIs(uuid)
|
|
195
|
+
// apis: getAPIs(uuid)
|
|
184
196
|
}
|
|
185
197
|
}
|
|
186
198
|
config.getAddedArgs(args)
|
|
187
199
|
|
|
188
200
|
Object.assign(args, args.getUUIDScoped(uuidForScoping || config.uuid))
|
|
189
201
|
args.apis = args.apis || ((name) => config.getConfig(name).api)
|
|
202
|
+
// args.apis = (name) => config.getAPIs(name)
|
|
190
203
|
/*
|
|
191
204
|
if (uuidForScoping) {
|
|
192
205
|
Object.assign(args, args.getUUIDScoped(uuidForScoping))
|
|
@@ -214,7 +227,6 @@ const run = async (config, handler) => {
|
|
|
214
227
|
|
|
215
228
|
const hierarchy = new DigraphInternal((config.config || {}).hierarchy || [])
|
|
216
229
|
|
|
217
|
-
debugger
|
|
218
230
|
const objects = config.config.objects.namespaced[config.uuid]
|
|
219
231
|
const logs = []
|
|
220
232
|
const args = {}
|
package/src/fragments.js
CHANGED
|
@@ -3,7 +3,9 @@ const helpers = require('./helpers')
|
|
|
3
3
|
|
|
4
4
|
function fragmentInstantiator (args, contexts) {
|
|
5
5
|
return new Object({
|
|
6
|
-
contexts: () =>
|
|
6
|
+
contexts: () => {
|
|
7
|
+
return _.cloneDeep(contexts)
|
|
8
|
+
},
|
|
7
9
|
instantiate: async (mappings) => {
|
|
8
10
|
const instantiated = _.cloneDeep(contexts)
|
|
9
11
|
const todo = [{ context: instantiated, path: [] }]
|
package/src/generators.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { stringify } = require('flatted');
|
|
2
1
|
const { args: contextArgs, normalizeGenerator } = require('./helpers')
|
|
3
2
|
const Lines = require('../lines')
|
|
4
3
|
const helpers = require('./helpers')
|
|
@@ -186,7 +185,7 @@ class Generators {
|
|
|
186
185
|
// this.logs.push(`Generators: applied ${generator.toString()}\n to\n ${stringify(context)}`)
|
|
187
186
|
let errorMessage = 'The apply function did not return a value'
|
|
188
187
|
try {
|
|
189
|
-
generated = await generator.apply(args, objects, context, hierarchy, config, response, log)
|
|
188
|
+
generated = await generator.apply(args, objects, context, hierarchy, config, response, log, options)
|
|
190
189
|
} catch (e) {
|
|
191
190
|
// the next if handle this
|
|
192
191
|
generated = null
|
|
@@ -213,7 +212,7 @@ class Generators {
|
|
|
213
212
|
lines.newRow()
|
|
214
213
|
lines.setElement(0, 1, 'TO')
|
|
215
214
|
lines.setElement(0, 2, `context_id: ${context.context_id}`)
|
|
216
|
-
lines.setElement(1, 2, stringify(helpers.sortJson(context, { depth: 10 }), null, 2))
|
|
215
|
+
lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 10 }), null, 2))
|
|
217
216
|
lines.newRow()
|
|
218
217
|
lines.setElement(0, 1, 'STACK')
|
|
219
218
|
lines.setElement(0, 2, stack)
|
|
@@ -224,7 +223,7 @@ class Generators {
|
|
|
224
223
|
lines.setElement(0, 1, 'ERROR')
|
|
225
224
|
lines.setElement(0, 2, errorMessage)
|
|
226
225
|
this.logs.push(lines.toString())
|
|
227
|
-
const message = `ERROR while applying (${source}) ${generator.toLabel()}\n to\n ${stringify(context, null, 2)}.\n${errorMessage}'`
|
|
226
|
+
const message = `ERROR while applying (${source}) ${generator.toLabel()}\n to\n ${JSON.stringify(context, null, 2)}.\n${errorMessage}'`
|
|
228
227
|
// this.logs.push(message)
|
|
229
228
|
// return [message]
|
|
230
229
|
args.calls.pop()
|
|
@@ -255,7 +254,7 @@ class Generators {
|
|
|
255
254
|
lines.newRow()
|
|
256
255
|
lines.setElement(0, 1, 'TO')
|
|
257
256
|
lines.setElement(0, 2, `context_id: ${context.context_id}`)
|
|
258
|
-
lines.setElement(1, 2, stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
|
|
257
|
+
lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
|
|
259
258
|
this.logs.push(lines.toString())
|
|
260
259
|
}
|
|
261
260
|
applied = true
|
|
@@ -273,7 +272,7 @@ class Generators {
|
|
|
273
272
|
lines.setElement(0, 2, stack)
|
|
274
273
|
lines.newRow()
|
|
275
274
|
lines.setElement(0, 1, 'TO')
|
|
276
|
-
lines.setElement(0, 2, stringify(context, null, 2))
|
|
275
|
+
lines.setElement(0, 2, JSON.stringify(context, null, 2))
|
|
277
276
|
this.logs.push(lines.toString())
|
|
278
277
|
}
|
|
279
278
|
return ((config || {}).parenthesized ? '(' + generated + ')' : generated)
|
package/src/semantics.js
CHANGED
|
@@ -70,6 +70,7 @@ class Semantic {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
async matches (args, context, options = {}) {
|
|
73
|
+
args = {...args}
|
|
73
74
|
this.fixUpArgs(args, context)
|
|
74
75
|
const matches = await this.matcher(args)
|
|
75
76
|
if (matches && (options.debug || {}).match || args.callId === this.callId) {
|
|
@@ -81,6 +82,7 @@ class Semantic {
|
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
async apply (args, context, s, options = {}) {
|
|
85
|
+
args = {...args}
|
|
84
86
|
const { config } = args
|
|
85
87
|
if (config && config.debugLoops) {
|
|
86
88
|
console.log('apply', this.toLabel())
|