theprogrammablemind_4wp 7.4.0-beta.0 → 7.4.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/client.js +7 -2
- package/package.json +1 -1
- package/src/config.js +6 -1
- package/src/generators.js +2 -2
- package/src/semantics.js +7 -3
package/client.js
CHANGED
@@ -12,14 +12,16 @@ const { appendNoDups, InitCalls } = require('./src/helpers')
|
|
12
12
|
const runtime = require('./runtime')
|
13
13
|
const sortJson = runtime.sortJson
|
14
14
|
|
15
|
-
const
|
15
|
+
const getAsk = (config) => (uuid) => (asks) => {
|
16
16
|
for (let ask of asks) {
|
17
17
|
config.addMotivation({
|
18
|
+
uuid,
|
18
19
|
match: (args) => ask.matchr(args),
|
19
20
|
apply: (args) => ask.applyr(args)
|
20
21
|
})
|
21
22
|
}
|
22
23
|
config.addMotivation({
|
24
|
+
uuid,
|
23
25
|
match: ({context}) => context.marker == 'controlEnd' || context.marker == 'controlBetween',
|
24
26
|
apply: (args) => {
|
25
27
|
for (let ask of asks) {
|
@@ -100,7 +102,10 @@ const setupArgs = (args, config, logs, hierarchy) => {
|
|
100
102
|
args.listable = listable(hierarchy)
|
101
103
|
args.asList = asList
|
102
104
|
args.retry = () => { throw new RetryError() }
|
103
|
-
|
105
|
+
const scopedAsk = getAsk(config)
|
106
|
+
args.getUUIDScoped = (uuid) => {
|
107
|
+
return { ask: scopedAsk(uuid) }
|
108
|
+
}
|
104
109
|
args.motivation = (m) => config.addMotivation(m)
|
105
110
|
args.s = (c) => config.getSemantics(logs).apply(args, c)
|
106
111
|
args.g = (c) => config.getGenerators(logs).apply(args, c)
|
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -1198,6 +1198,9 @@ class Config {
|
|
1198
1198
|
|
1199
1199
|
// motivation === { match, apply, uuid }
|
1200
1200
|
addMotivation (motivation) {
|
1201
|
+
if (!motivation.uuid) {
|
1202
|
+
motivation.uuid = this.uuid
|
1203
|
+
}
|
1201
1204
|
this.motivations.push(motivation)
|
1202
1205
|
}
|
1203
1206
|
|
@@ -1207,11 +1210,13 @@ class Config {
|
|
1207
1210
|
|
1208
1211
|
doMotivations (args, context) {
|
1209
1212
|
args = Object.assign({}, args, { context })
|
1210
|
-
|
1213
|
+
// console.log('src/config doMotivations this.uuid', this.uuid)
|
1214
|
+
// args.objects = args.getObjects(this.uuid)
|
1211
1215
|
const motivations = this.motivations
|
1212
1216
|
this.motivations = []
|
1213
1217
|
let done = false
|
1214
1218
|
for (const motivation of motivations) {
|
1219
|
+
args.objects = args.getObjects(motivation.uuid)
|
1215
1220
|
if (!done && motivation.match(args)) {
|
1216
1221
|
motivation.apply(args)
|
1217
1222
|
if (args.context.controlKeepMotivation || motivation.repeat) {
|
package/src/generators.js
CHANGED
@@ -59,7 +59,7 @@ class Generator {
|
|
59
59
|
api: this.getAPI(config),
|
60
60
|
apis: this.getAPIs(config)
|
61
61
|
}
|
62
|
-
const args = Object.assign({}, baseArgs, moreArgs)
|
62
|
+
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))
|
63
63
|
// return this.match(args)
|
64
64
|
const matches = this.match(args)
|
65
65
|
if ((matches && (options.debug || {}).match)
|
@@ -106,7 +106,7 @@ class Generator {
|
|
106
106
|
api: this.getAPI(config),
|
107
107
|
apis: this.getAPIs(config)
|
108
108
|
}
|
109
|
-
const args = Object.assign({}, baseArgs, moreArgs)
|
109
|
+
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))
|
110
110
|
// if (this.callId) {
|
111
111
|
// greg
|
112
112
|
/*
|
package/src/semantics.js
CHANGED
@@ -45,13 +45,16 @@ class Semantic {
|
|
45
45
|
matches (baseArgs, context, options = {}) {
|
46
46
|
const hierarchy = baseArgs.hierarchy
|
47
47
|
const config = baseArgs.config
|
48
|
+
|
48
49
|
const objects = baseArgs.getObjects(this.uuid)
|
50
|
+
// const ask = baseArgs.getAsk(this.uuid)
|
51
|
+
|
49
52
|
// return this.matcher(Object.assign({}, argsBase, {args: contextArgs(context, hierarchy), objects: objects, global: objects, context: context, hierarchy: hierarchy, api: this.getAPI(config)})
|
50
53
|
const callId = baseArgs.calls.current()
|
51
54
|
const moreArgs = {
|
52
55
|
uuid: this.uuid,
|
53
56
|
args: contextArgs(context, hierarchy),
|
54
|
-
objects
|
57
|
+
objects,
|
55
58
|
global: objects,
|
56
59
|
context: context,
|
57
60
|
// hierarchy: hierarchy,
|
@@ -59,7 +62,7 @@ class Semantic {
|
|
59
62
|
api: this.getAPI(config),
|
60
63
|
apis: this.getAPIs(config)
|
61
64
|
}
|
62
|
-
const args = Object.assign({}, baseArgs, moreArgs)
|
65
|
+
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))
|
63
66
|
|
64
67
|
const matches = this.matcher(args)
|
65
68
|
if (matches && (options.debug || {}).match
|
@@ -74,6 +77,7 @@ class Semantic {
|
|
74
77
|
apply (baseArgs, context, s, log, options = {}) {
|
75
78
|
const { hierarchy, config, response } = baseArgs
|
76
79
|
const objects = baseArgs.getObjects(this.uuid)
|
80
|
+
// const ask = baseArgs.getAsk(this.uuid)
|
77
81
|
if (!log) {
|
78
82
|
console.trace()
|
79
83
|
throw 'log is a required argument'
|
@@ -99,7 +103,7 @@ class Semantic {
|
|
99
103
|
api: this.getAPI(config),
|
100
104
|
apis: this.getAPIs(config)
|
101
105
|
}
|
102
|
-
const args = Object.assign({}, baseArgs, moreArgs)
|
106
|
+
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))
|
103
107
|
if ((options.debug || {}).apply
|
104
108
|
||
|
105
109
|
callId == this.callId) {
|