tpmkms_4wp 9.8.0-beta.3 → 9.8.0-beta.4
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/common/actions.instance.json +1 -1
- package/common/actions.js +3 -1
- package/common/askfor.instance.json +1 -1
- package/common/askfor.js +2 -2
- package/common/avatar.js +1 -1
- package/common/dateTimeSelectors.instance.json +3 -3
- package/common/dateTimeSelectors.js +3 -6
- package/common/dialogues.js +7 -6
- package/common/dimension.instance.json +3 -3
- package/common/dimension.js +4 -5
- package/common/drone.instance.json +13 -13
- package/common/drone.js +11 -12
- package/common/evaluate.js +6 -12
- package/common/formulas.instance.json +2 -2
- package/common/formulas.js +3 -3
- package/common/gdefaults.js +3 -3
- package/common/hierarchy.js +2 -2
- package/common/meta.js +2 -1
- package/common/nameable.js +2 -2
- package/common/ordinals.js +1 -1
- package/common/properties.instance.json +25 -25
- package/common/properties.js +16 -21
- package/common/rates.instance.json +1 -1
- package/common/rates.js +1 -1
- package/common/reminders.js +1 -1
- package/common/reports.instance.json +2 -2
- package/common/scorekeeper.js +6 -6
- package/common/stm.js +6 -8
- package/common/time.instance.json +2 -2
- package/common/time.js +2 -2
- package/common/wp.instance.json +2 -2
- package/common/wp.js +2 -2
- package/package.json +2 -2
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
},
|
|
167
167
|
"semantics": [
|
|
168
168
|
{
|
|
169
|
-
"match": "({context, isA, stack, namespaced}) => !context.pullFromContext && !context.evaluate && (isA(context.marker, 'action') || isA(context.marker, 'doAction')) && !namespaced.get('actions', context, 'logged')",
|
|
169
|
+
"match": "({context, isA, contextHierarchy, stack, namespaced}) => {\n if (false) {\n if (!context.pullFromContext && (isA(context.marker, 'action') || isA(context.marker, 'doAction')) && !namespaced.get('actions', context, 'logged')) {\n if (context.evaluate) {\n debugger\n throw new Error(\"this is the error\")\n }\n }\n }\n // return !context.pullFromContext && !context.evaluate && (isA(context.marker, 'action') || isA(context.marker, 'doAction')) && !namespaced.get('actions', context, 'logged')\n return !context.pullFromContext && !contextHierarchy.under('call') && (isA(context.marker, 'action') || isA(context.marker, 'doAction')) && !namespaced.get('actions', context, 'logged')\n }",
|
|
170
170
|
"apply": "async ({context, _continue, testLog, g, remember}) => {\n remember(context)\n await testLog(() => g(context))\n _continue()\n }"
|
|
171
171
|
}
|
|
172
172
|
]
|
package/common/actions.js
CHANGED
|
@@ -147,7 +147,9 @@ const config = {
|
|
|
147
147
|
{
|
|
148
148
|
where: where(),
|
|
149
149
|
priority: -1,
|
|
150
|
-
match: ({context, isA, stack, namespaced}) =>
|
|
150
|
+
match: ({context, isA, contextHierarchy, stack, namespaced}) => {
|
|
151
|
+
return !context.pullFromContext && !contextHierarchy.under('call') && (isA(context.marker, 'action') || isA(context.marker, 'doAction')) && !namespaced.get('actions', context, 'logged')
|
|
152
|
+
},
|
|
151
153
|
apply: async ({context, _continue, testLog, g, remember}) => {
|
|
152
154
|
remember(context)
|
|
153
155
|
await testLog(() => g(context))
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"ask"
|
|
65
65
|
],
|
|
66
66
|
"bridge": "{\n ...next(operator),\n properties: after[0],\n interpolate: [{ self: true }, { property: 'properties' }]\n }",
|
|
67
|
-
"semantic": "async ({e, s, gp, objects, flatten, context, ask, fragments, toEValue}) => {\n const argument = context.properties.argument\n const getValue = (property) => async (args) => {\n const value = toEValue(await e(property))\n if (value.marker
|
|
67
|
+
"semantic": "async ({e, s, gp, objects, flatten, context, ask, fragments, toEValue}) => {\n const argument = context.properties.argument\n const getValue = (property) => async (args) => {\n const value = toEValue(await e(property))\n if (value.marker === 'undefined') {\n return\n }\n return value\n }\n\n const setValue = (property) => async ({ context, namespaced, tag }) => {\n const is = { marker: 'is', one: property, two: context }\n namespaced.set('dialogs', is, 'allowHierarchy', false)\n await s(is)\n }\n\n const properties = flattenInPlace(argument)\n counter = 0\n for (const property of properties.reverse()) {\n counter += 1\n const query = memoizeAsync(async () => await(gp(await fragments(\"what is the concept?\", { concept: property }))))\n const compatible_types = property.compatible_types || [property.marker]\n const matchr = ({context, isA}) => {\n return !context.same && isA(context, compatible_types)\n }\n objects.askFor.push(property);\n askForProperty({\n ask,\n tag: `ask#${counter}`,\n getValue: getValue(property),\n setValue: setValue(property),\n query,\n matchr,\n })\n }\n }"
|
|
68
68
|
}
|
|
69
69
|
]
|
|
70
70
|
},
|
package/common/askfor.js
CHANGED
|
@@ -118,7 +118,7 @@ const template = {
|
|
|
118
118
|
const argument = context.properties.argument
|
|
119
119
|
const getValue = (property) => async (args) => {
|
|
120
120
|
const value = toEValue(await e(property))
|
|
121
|
-
if (value.marker
|
|
121
|
+
if (value.marker === 'undefined') {
|
|
122
122
|
return
|
|
123
123
|
}
|
|
124
124
|
return value
|
|
@@ -137,7 +137,7 @@ const template = {
|
|
|
137
137
|
const query = memoizeAsync(async () => await(gp(await fragments("what is the concept?", { concept: property }))))
|
|
138
138
|
const compatible_types = property.compatible_types || [property.marker]
|
|
139
139
|
const matchr = ({context, isA}) => {
|
|
140
|
-
return !context.same &&
|
|
140
|
+
return !context.same && isA(context, compatible_types)
|
|
141
141
|
}
|
|
142
142
|
objects.askFor.push(property);
|
|
143
143
|
askForProperty({
|
package/common/avatar.js
CHANGED
|
@@ -27,7 +27,7 @@ const config = {
|
|
|
27
27
|
{
|
|
28
28
|
where: where(),
|
|
29
29
|
notes: "unknown answer default response for avatar",
|
|
30
|
-
match: ({context}) => context.marker
|
|
30
|
+
match: ({context}) => context.marker === 'undefined',
|
|
31
31
|
apply: ({context}) => `I don't know`,
|
|
32
32
|
},
|
|
33
33
|
{
|
|
@@ -67,15 +67,15 @@
|
|
|
67
67
|
],
|
|
68
68
|
"semantics": [
|
|
69
69
|
{
|
|
70
|
-
"match": "({context, isA}) =>
|
|
70
|
+
"match": "({context, isA}) => onOrIs('dayAfterDate', context)",
|
|
71
71
|
"apply": "async ({context, isProcess, isTest, kms, isA, e}) => {\n try {\n const now = kms.time.api.now()\n const date = afterOrIs('dayAfterDate', context)\n const afterISO = (await e(date.after)).evalue\n const day_ordinal = date.day.day_ordinal\n const ordinal = date.day.ordinal.value\n context.evalue = dateTimeSelectors_helpers.getNthWeekdayAfterDate(afterISO, day_ordinal, ordinal)\n } catch ( e ) {\n context.evalue = `Implement instatiate for this type of date, ${context.marker}. See the dateTimeSelectors KM ${where()}. ${e}`\n }\n }"
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
|
-
"match": "({context, isA}) =>
|
|
74
|
+
"match": "({context, isA}) => onOrIs('dayOfMonth', context)",
|
|
75
75
|
"apply": "({context, isProcess, isTest, kms, isA}) => {\n try {\n const now = kms.time.api.now()\n const date = onOrIs('dayOfMonth', context)\n context.evalue = dateTimeSelectors_helpers.getNthDayOfMonth(removeDatesSuffix(date.day.value), date.day.ordinal.value || 1, removeDatesSuffix(date.month.value), now)\n } catch ( e ) {\n context.evalue = `Implement instatiate for this type of date, ${context.marker}. See the dateTimeSelectors KM ${where()}. ${e}`\n }\n }"
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
|
-
"match": "({context, isA}) => {\n if (
|
|
78
|
+
"match": "({context, isA}) => {\n if (isA(context.marker, 'onDateValue_dates')) {\n return true\n }\n if (isA(context.marker, 'dateTimeSelector')) {\n return true\n }\n }",
|
|
79
79
|
"apply": "({context, isProcess, isTest, kms, isA}) => {\n context.evalue = instantiate(kms, isA, isProcess || isTest || context.isTest, context)\n }"
|
|
80
80
|
}
|
|
81
81
|
],
|
|
@@ -94,7 +94,7 @@ const template = {
|
|
|
94
94
|
],
|
|
95
95
|
semantics: [
|
|
96
96
|
{
|
|
97
|
-
match: ({context, isA}) =>
|
|
97
|
+
match: ({context, isA}) => onOrIs('dayAfterDate', context),
|
|
98
98
|
apply: async ({context, isProcess, isTest, kms, isA, e}) => {
|
|
99
99
|
try {
|
|
100
100
|
const now = kms.time.api.now()
|
|
@@ -109,7 +109,7 @@ const template = {
|
|
|
109
109
|
},
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
|
-
match: ({context, isA}) =>
|
|
112
|
+
match: ({context, isA}) => onOrIs('dayOfMonth', context),
|
|
113
113
|
apply: ({context, isProcess, isTest, kms, isA}) => {
|
|
114
114
|
try {
|
|
115
115
|
const now = kms.time.api.now()
|
|
@@ -122,9 +122,6 @@ const template = {
|
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
124
|
match: ({context, isA}) => {
|
|
125
|
-
if (!context.evaluate) {
|
|
126
|
-
return false
|
|
127
|
-
}
|
|
128
125
|
if (isA(context.marker, 'onDateValue_dates')) {
|
|
129
126
|
return true
|
|
130
127
|
}
|
|
@@ -156,7 +153,7 @@ knowledgeModule( {
|
|
|
156
153
|
checks: {
|
|
157
154
|
context: [
|
|
158
155
|
// defaultContextCheck({ extra: ['date', 'time', 'response', 'after', 'day', 'month', 'year', 'evalue'] }),
|
|
159
|
-
defaultContextCheck({ extra: ['date', 'time', '
|
|
156
|
+
defaultContextCheck({ extra: ['date', 'time', 'after', 'evalue'] }),
|
|
160
157
|
],
|
|
161
158
|
}
|
|
162
159
|
},
|
package/common/dialogues.js
CHANGED
|
@@ -301,13 +301,13 @@ const config = {
|
|
|
301
301
|
{
|
|
302
302
|
where: where(),
|
|
303
303
|
notes: "unknown answer default response",
|
|
304
|
-
match: ({context, namespaced}) => context.marker
|
|
304
|
+
match: ({context, namespaced}) => context.marker === 'undefined' && context.brief,
|
|
305
305
|
apply: ({context}) => `not known`,
|
|
306
306
|
},
|
|
307
307
|
{
|
|
308
308
|
where: where(),
|
|
309
309
|
notes: "unknown answer default response",
|
|
310
|
-
match: ({context}) => context.marker
|
|
310
|
+
match: ({context}) => context.marker === 'undefined',
|
|
311
311
|
apply: ({context}) => `that is not known`,
|
|
312
312
|
},
|
|
313
313
|
{
|
|
@@ -446,7 +446,7 @@ const config = {
|
|
|
446
446
|
notes: 'x is y',
|
|
447
447
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && !context.evalue,
|
|
448
448
|
apply: async ({isA, context, g, gp, debug, gr, callId}) => {
|
|
449
|
-
if ((context.two.evalue || {}).marker
|
|
449
|
+
if ((context.two.evalue || {}).marker === 'undefined') {
|
|
450
450
|
return await g(context.two.evalue)
|
|
451
451
|
}
|
|
452
452
|
|
|
@@ -454,8 +454,8 @@ const config = {
|
|
|
454
454
|
return `${await gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await g(context.two)}`
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
if (context.
|
|
458
|
-
context = context.
|
|
457
|
+
if (context.evalue) {
|
|
458
|
+
context = context.evalue
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
function hasFocus(property) {
|
|
@@ -575,6 +575,7 @@ const config = {
|
|
|
575
575
|
apply: async ({context, s, log, km, objects, e, toEValue}) => {
|
|
576
576
|
const one = context.one;
|
|
577
577
|
const two = context.two;
|
|
578
|
+
|
|
578
579
|
let query, value;
|
|
579
580
|
if (one.query) {
|
|
580
581
|
query = one;
|
|
@@ -591,7 +592,7 @@ const config = {
|
|
|
591
592
|
return
|
|
592
593
|
}
|
|
593
594
|
|
|
594
|
-
if (toEValue(instance)?.marker
|
|
595
|
+
if (toEValue(instance)?.marker === 'undefined') {
|
|
595
596
|
context.evalue = instance
|
|
596
597
|
context.isResponse = true
|
|
597
598
|
return
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"verb"
|
|
94
94
|
],
|
|
95
95
|
"bridge": "{ ...next(operator), quantity: after[0], operator: operator, interpolate: [{ property: 'operator' }, { property: 'quantity' }] }",
|
|
96
|
-
"semantic": "async ({context, e, api, toArray,
|
|
96
|
+
"semantic": "async ({context, e, api, toArray, resolveEvaluate}) => {\n const preferredUnits = await api.getPreferredUnits(context.quantity)\n if (!preferredUnits) {\n return\n }\n const from = context.quantity;\n const value = await e({ marker: 'convertToUnits', from, to: preferredUnits })\n resolveEvaluate(context, value.evalue)\n }"
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
"where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:215",
|
|
@@ -224,8 +224,8 @@
|
|
|
224
224
|
{
|
|
225
225
|
"semantics": [
|
|
226
226
|
{
|
|
227
|
-
"match": "({context, isA, debug}) => {\n return context.
|
|
228
|
-
"apply": "async ({context, e, unify, toEValue}) => {\n const t1 = context.terms[0]\n const t2 = context.terms[1]\n if (t1.propertyType !== t2.propertyType) {\n return\n }\n if (t1[t1.propertyType].marker !== t2[t2.propertyType].marker) {\n return\n }\n const convert = await e({ marker: 'convertToUnits', from: t2, to: t1.unit })\n const t2InT1Units = await toEValue(await toEValue(convert))\n debug.
|
|
227
|
+
"match": "({context, isA, debug}) => {\n return context.marker == 'unify' && \n context.terms.every((term) => isA(term, 'quantity')) &&\n context.terms.every((term) => term.instance)\n }",
|
|
228
|
+
"apply": "async ({context, e, unify, toEValue}) => {\n const t1 = context.terms[0]\n const t2 = context.terms[1]\n if (t1.propertyType !== t2.propertyType) {\n return\n }\n if (t1[t1.propertyType].marker !== t2[t2.propertyType].marker) {\n return\n }\n const convert = await e({ marker: 'convertToUnits', from: t2, to: t1.unit })\n const t2InT1Units = await toEValue(await toEValue(convert))\n // debug.coxunter('greg29')\n if (!await unify(t1.amount, await t2InT1Units.amount)) {\n // debugger\n }\n // debugger\n }"
|
|
229
229
|
}
|
|
230
230
|
]
|
|
231
231
|
}
|
package/common/dimension.js
CHANGED
|
@@ -201,14 +201,14 @@ const config = {
|
|
|
201
201
|
id: "preferredUnits",
|
|
202
202
|
isA: ['verb'],
|
|
203
203
|
bridge: "{ ...next(operator), quantity: after[0], operator: operator, interpolate: [{ property: 'operator' }, { property: 'quantity' }] }",
|
|
204
|
-
semantic: async ({context, e, api, toArray,
|
|
204
|
+
semantic: async ({context, e, api, toArray, resolveEvaluate}) => {
|
|
205
205
|
const preferredUnits = await api.getPreferredUnits(context.quantity)
|
|
206
206
|
if (!preferredUnits) {
|
|
207
207
|
return
|
|
208
208
|
}
|
|
209
209
|
const from = context.quantity;
|
|
210
210
|
const value = await e({ marker: 'convertToUnits', from, to: preferredUnits })
|
|
211
|
-
|
|
211
|
+
resolveEvaluate(context, value.evalue)
|
|
212
212
|
}
|
|
213
213
|
},
|
|
214
214
|
{
|
|
@@ -334,8 +334,7 @@ const template = {
|
|
|
334
334
|
semantics: [
|
|
335
335
|
{
|
|
336
336
|
match: ({context, isA, debug}) => {
|
|
337
|
-
return context.
|
|
338
|
-
context.marker == 'unify' &&
|
|
337
|
+
return context.marker == 'unify' &&
|
|
339
338
|
context.terms.every((term) => isA(term, 'quantity')) &&
|
|
340
339
|
context.terms.every((term) => term.instance)
|
|
341
340
|
},
|
|
@@ -350,7 +349,7 @@ const template = {
|
|
|
350
349
|
}
|
|
351
350
|
const convert = await e({ marker: 'convertToUnits', from: t2, to: t1.unit })
|
|
352
351
|
const t2InT1Units = await toEValue(await toEValue(convert))
|
|
353
|
-
// debug.
|
|
352
|
+
// debug.coxunter('greg29')
|
|
354
353
|
if (!await unify(t1.amount, await t2InT1Units.amount)) {
|
|
355
354
|
// debugger
|
|
356
355
|
}
|
|
@@ -284,7 +284,7 @@
|
|
|
284
284
|
},
|
|
285
285
|
"path"
|
|
286
286
|
],
|
|
287
|
-
"semantic": "async ({context, g, e, toArray, fragments, toEValue, toFinalValue, recall, objects, verbatim}) => {\n const paths = toArray(context.path)\n for (const context_path of paths) {\n const evaluated = await(e(context_path))\n const path = toEValue(evaluated)\n if (path.marker
|
|
287
|
+
"semantic": "async ({context, g, e, toArray, fragments, toEValue, toFinalValue, recall, objects, verbatim}) => {\n const paths = toArray(context.path)\n for (const context_path of paths) {\n const evaluated = await(e(context_path))\n const path = toEValue(evaluated)\n if (path.marker === 'undefined') {\n verbatim(`${await g(context_path)} is not a known path`)\n continue\n }\n \n objects.current.path.push({ message: await g(context) })\n\n // TODO put this in a common place for use by do+patrol \n\n // ordinal to pause time in seconds \n const pauseTimeInSeconds = {}\n if (context.pause) {\n const timeAtPoints = toArray(context.pause.timeAtPoint)\n for (const timeAtPoint of timeAtPoints) {\n const instantiation = await fragments(\"quantity in seconds\", { quantity: timeAtPoint.time })\n const result = await e(instantiation)\n const seconds = toFinalValue(toFinalValue(result).amount)\n\n const points = await recall({ context: timeAtPoint.point.point, frameOfReference: path })\n for (const point of toArray(points)) {\n pauseTimeInSeconds[point.ordinal] = seconds\n }\n }\n }\n\n let skipPoints = []\n if (context.skip) {\n skipPoints = toArray(await recall({ context: context.skip.points, frameOfReference: path }))\n }\n\n // get to the start of the patrol \n objects.current.path.push(path.points[0])\n objects.current.path.push({ aimOnly: true, ...path.points[1] })\n objects.current.path.push({ repeatStart: true })\n for (const point of path.points) {\n if (skipPoints.find((skipPoint) => skipPoint.ordinal == point.ordinal)) {\n continue\n }\n objects.current.path.push(point)\n if (pauseTimeInSeconds[point.ordinal]) {\n objects.current.path.push({ marker: 'pause', pauseSeconds: pauseTimeInSeconds[point.ordinal] })\n }\n }\n if (context.repeats) {\n objects.current.timeRepeats = toFinalValue(context.repeats.repeats)\n }\n // if the patrol does not start and end at the same spot then \n // go back to the start along the same path\n\n\n // if the start is not the end of the patrol then go backwards along the patrol\n if (JSON.stringify(path.points[0].point) !== JSON.stringify(path.points[path.points.length-1].point)) {\n for (const point of [...path.points].reverse().slice(1)) {\n if (skipPoints.find((skipPoint) => skipPoint.ordinal == point.ordinal)) {\n continue\n }\n objects.current.path.push(point)\n if (pauseTimeInSeconds[point.ordinal]) {\n objects.current.path.push({ marker: 'pause', pauseSeconds: pauseTimeInSeconds[point.ordinal] })\n }\n }\n\n const secondPoint = path.points[1]\n objects.current.path.push({ ...secondPoint, aimOnly: true })\n }\n }\n objects.runCommand = true\n }"
|
|
288
288
|
},
|
|
289
289
|
{
|
|
290
290
|
"id": "lift",
|
|
@@ -826,28 +826,28 @@
|
|
|
826
826
|
"apply": "async ({context, fragments, e, s, toEValue, toFinalValue, namespaced, objects}) => {\n const updated = { ...context, marker: 'patrol', path: context.action }\n namespaced.set('actions', updated, 'logged', true)\n await s(updated)\n // await s({ ...context, marker: 'patrol', path: context.action })\n }"
|
|
827
827
|
},
|
|
828
828
|
{
|
|
829
|
-
"match": "({context, contextHierarchy}) => {\n if (!context.pullFromContext ||
|
|
829
|
+
"match": "({context, contextHierarchy}) => {\n if (!context.pullFromContext || contextHierarchy.under(['doAction', 'evaluate', 'patrol']) || context.isInstance) {\n return false\n }\n \n if (context.marker == 'path' || context.marker == 'this' || context.marker == 'that') {\n return true\n }\n }",
|
|
830
830
|
"apply": "async ({context, frameOfReference, toArray, fragments, objects, remember, recall, resolveEvaluate, _continue, contextHierarchy}) => {\n const pathComponents = toArray(await recall({ \n context: { marker: 'pathComponent' }, \n all: true,\n stopCondition: (context) => context.marker == 'startPath',\n }))\n const path = (await fragments('path')).contexts()[0]\n delete path.value\n path.isInstance = true\n path.points = pathComponents.reverse()\n frameOfReference(path, { mentioned: 'points', reversed: true })\n await remember(path)\n\n _continue() // let the call pick the object out from the stm\n }"
|
|
831
831
|
},
|
|
832
832
|
{
|
|
833
|
-
"match": "({context, contextHierarchy}) => {\n if (!context.pullFromContext || !
|
|
833
|
+
"match": "({context, contextHierarchy}) => {\n if (!context.pullFromContext || !contextHierarchy.under('call') || context.notUnderCall) {\n return false\n }\n \n if (context.marker == 'point' || context.marker == 'ordinal') {\n return true\n }\n }",
|
|
834
834
|
"apply": "async ({frameOfReference, context, e, fragments, stm, toEValue, toArray, objects, remember, recall, resolveEvaluate, _continue, contextHierarchy}) => {\n const evaluated = await e({...context, notUnderCall: true})\n const pointsContext = toEValue(evaluated)\n const pathComponents = toArray(pointsContext)\n\n const path = (await fragments('path')).contexts()[0]\n delete path.value\n path.isInstance = true\n path.points = [...pathComponents]\n frameOfReference(path, { mentioned: 'points', reversed: true })\n await remember(path)\n resolveEvaluate(context, path)\n }"
|
|
835
835
|
},
|
|
836
836
|
{
|
|
837
|
-
"match": "({context}) =>
|
|
837
|
+
"match": "({context}) => ['start', 'end'].includes(context.marker) && context.objects && context.objects[1].marker == 'path'",
|
|
838
838
|
"apply": "async ({gp, s, context, objects, fragments, resolveEvaluate, api, recall}) => {\n const path = await recall({ context: context.objects[1] })\n if (!path?.points) {\n return\n }\n if (context.marker == 'start') {\n resolveEvaluate(context, path?.points[0])\n } else if (context.marker == 'end') {\n resolveEvaluate(context, path?.points[path?.points.length-1])\n }\n }"
|
|
839
839
|
},
|
|
840
840
|
{
|
|
841
|
-
"match": "({context, contextHierarchy}) => \n
|
|
841
|
+
"match": "({context, contextHierarchy}) => \n ['start', 'end', 'point'].includes(context.marker) && \n !context.propertyOf && \n contextHierarchy.under('go') &&\n !contextHierarchy.under('call')",
|
|
842
842
|
"apply": "async ({gp, s, toArray, context, objects, fragments, resolveEvaluate, api, recall}) => {\n const path = await recall({ context: { marker: 'path' } })\n if (!path?.points) {\n return\n }\n \n if (context.marker == 'start') {\n resolveEvaluate(context, path?.points[0])\n } else if (context.marker == 'end') {\n resolveEvaluate(context, path?.points[path?.points.length-1])\n } else {\n const points = await recall({ context, frameOfReference: path })\n resolveEvaluate(context, toArray(points)[0])\n }\n }"
|
|
843
843
|
},
|
|
844
844
|
{
|
|
845
|
-
"match": "({context}) => {\n // from stm lookup\n if (context.marker == 'mentions' && context.
|
|
846
|
-
"apply": "async ({gp, s, context, objects, fragments, resolveEvaluate, api}) => {\n let return_context = context\n if (context.marker == 'speed') {\n // okay\n } else {\n // stm lookup\n return_context = context\n context = context.args.context\n }\n let value = objects.current.speed\n if (context.condition) {\n if (['highest', 'maximum'].includes(context.condition.marker)) {\n value = api.maximumSpeedDrone()\n } else if (['lowest', 'minimum'].includes(context.condition.marker)) {\n value = api.minimumSpeedDrone()\n }\n }\n const speed = await fragments(\"number meters per second\", { number: { marker: 'integer', value, word: undefined} })\n const preferred = await s({ marker: 'preferredUnits', quantity: speed }) \n resolveEvaluate(return_context, preferred.
|
|
845
|
+
"match": "({context}) => {\n // from stm lookup\n if (context.marker == 'mentions' && context.args.context.marker == 'speed') {\n return true\n }\n // from property directly\n if (context.marker == 'speed') {\n return true\n }\n }",
|
|
846
|
+
"apply": "async ({gp, s, context, objects, fragments, resolveEvaluate, api}) => {\n let return_context = context\n if (context.marker == 'speed') {\n // okay\n } else {\n // stm lookup\n return_context = context\n context = context.args.context\n }\n let value = objects.current.speed\n if (context.condition) {\n if (['highest', 'maximum'].includes(context.condition.marker)) {\n value = api.maximumSpeedDrone()\n } else if (['lowest', 'minimum'].includes(context.condition.marker)) {\n value = api.minimumSpeedDrone()\n }\n }\n const speed = await fragments(\"number meters per second\", { number: { marker: 'integer', value, word: undefined} })\n const preferred = await s({ marker: 'preferredUnits', quantity: speed }) \n resolveEvaluate(return_context, preferred.evalue || speed)\n }"
|
|
847
847
|
},
|
|
848
848
|
{
|
|
849
|
-
"match": "({context}) => {\n if (context.marker == 'mentions' &&
|
|
850
|
-
"apply": "async ({gp, s, context, objects, fragments, resolveEvaluate, api}) => {\n const value = objects.current.angleInRadians\n const fi = await fragments(\"number radians\")\n const direction = await fi.instantiate([\n { \n match: ({path, pathEquals}) => pathEquals(path, ['0', 'amount']),\n apply: ({context}) => {\n Object.assign(context, { marker: 'number', value: value, word: undefined })\n }\n }\n ])\n const preferred = await s({ marker: 'preferredUnits', quantity: direction }) \n resolveEvaluate(context, preferred.
|
|
849
|
+
"match": "({context}) => {\n if (context.marker == 'mentions' && ['direction', 'drone_direction'].includes(context.args.context.marker)) {\n return true\n }\n if (['direction', 'drone_direction'].includes(context.marker)) {\n return true\n }\n }",
|
|
850
|
+
"apply": "async ({gp, s, context, objects, fragments, resolveEvaluate, api}) => {\n const value = objects.current.angleInRadians\n const fi = await fragments(\"number radians\")\n const direction = await fi.instantiate([\n { \n match: ({path, pathEquals}) => pathEquals(path, ['0', 'amount']),\n apply: ({context}) => {\n Object.assign(context, { marker: 'number', value: value, word: undefined })\n }\n }\n ])\n const preferred = await s({ marker: 'preferredUnits', quantity: direction }) \n resolveEvaluate(context, preferred.evalue || direction)\n }"
|
|
851
851
|
},
|
|
852
852
|
{
|
|
853
853
|
"match": "({context}) => context.marker == 'timeRepeats'",
|
|
@@ -10782,16 +10782,16 @@
|
|
|
10782
10782
|
},
|
|
10783
10783
|
{},
|
|
10784
10784
|
{
|
|
10785
|
-
"where": "/home/dev/code/theprogrammablemind/kms/common/drone.js:
|
|
10785
|
+
"where": "/home/dev/code/theprogrammablemind/kms/common/drone.js:1437"
|
|
10786
10786
|
},
|
|
10787
10787
|
{
|
|
10788
|
-
"where": "/home/dev/code/theprogrammablemind/kms/common/drone.js:
|
|
10788
|
+
"where": "/home/dev/code/theprogrammablemind/kms/common/drone.js:1471"
|
|
10789
10789
|
},
|
|
10790
10790
|
{
|
|
10791
|
-
"where": "/home/dev/code/theprogrammablemind/kms/common/drone.js:
|
|
10791
|
+
"where": "/home/dev/code/theprogrammablemind/kms/common/drone.js:1497"
|
|
10792
10792
|
},
|
|
10793
10793
|
{
|
|
10794
|
-
"where": "/home/dev/code/theprogrammablemind/kms/common/drone.js:
|
|
10794
|
+
"where": "/home/dev/code/theprogrammablemind/kms/common/drone.js:1504"
|
|
10795
10795
|
}
|
|
10796
10796
|
]
|
|
10797
10797
|
}
|
package/common/drone.js
CHANGED
|
@@ -228,7 +228,7 @@ https://www.amazon.ca/Freenove-Raspberry-Tracking-Avoidance-Ultrasonic/dp/B0BNDQ
|
|
|
228
228
|
|
|
229
229
|
function expectDirection(args) {
|
|
230
230
|
args.config.addSemantic({
|
|
231
|
-
match: ({context, isA}) => isA(context.marker, 'direction')
|
|
231
|
+
match: ({context, isA}) => isA(context.marker, 'direction'),
|
|
232
232
|
apply: ({objects, context}) => {
|
|
233
233
|
objects.runCommand = true
|
|
234
234
|
objects.current.direction = context.marker
|
|
@@ -992,7 +992,7 @@ const template = {
|
|
|
992
992
|
for (const context_path of paths) {
|
|
993
993
|
const evaluated = await(e(context_path))
|
|
994
994
|
const path = toEValue(evaluated)
|
|
995
|
-
if (path.marker
|
|
995
|
+
if (path.marker === 'undefined') {
|
|
996
996
|
verbatim(`${await g(context_path)} is not a known path`)
|
|
997
997
|
continue
|
|
998
998
|
}
|
|
@@ -1337,7 +1337,7 @@ const template = {
|
|
|
1337
1337
|
{
|
|
1338
1338
|
where: where(),
|
|
1339
1339
|
match: ({context, contextHierarchy}) => {
|
|
1340
|
-
if (!context.pullFromContext ||
|
|
1340
|
+
if (!context.pullFromContext || contextHierarchy.under(['doAction', 'evaluate', 'patrol']) || context.isInstance) {
|
|
1341
1341
|
return false
|
|
1342
1342
|
}
|
|
1343
1343
|
|
|
@@ -1364,7 +1364,7 @@ const template = {
|
|
|
1364
1364
|
{
|
|
1365
1365
|
where: where(),
|
|
1366
1366
|
match: ({context, contextHierarchy}) => {
|
|
1367
|
-
if (!context.pullFromContext || !
|
|
1367
|
+
if (!context.pullFromContext || !contextHierarchy.under('call') || context.notUnderCall) {
|
|
1368
1368
|
return false
|
|
1369
1369
|
}
|
|
1370
1370
|
|
|
@@ -1398,7 +1398,7 @@ const template = {
|
|
|
1398
1398
|
*/
|
|
1399
1399
|
{
|
|
1400
1400
|
where: where(),
|
|
1401
|
-
match: ({context}) =>
|
|
1401
|
+
match: ({context}) => ['start', 'end'].includes(context.marker) && context.objects && context.objects[1].marker == 'path',
|
|
1402
1402
|
apply: async ({gp, s, context, objects, fragments, resolveEvaluate, api, recall}) => {
|
|
1403
1403
|
const path = await recall({ context: context.objects[1] })
|
|
1404
1404
|
if (!path?.points) {
|
|
@@ -1413,7 +1413,6 @@ const template = {
|
|
|
1413
1413
|
},
|
|
1414
1414
|
{
|
|
1415
1415
|
match: ({context, contextHierarchy}) =>
|
|
1416
|
-
context.evaluate &&
|
|
1417
1416
|
['start', 'end', 'point'].includes(context.marker) &&
|
|
1418
1417
|
!context.propertyOf &&
|
|
1419
1418
|
contextHierarchy.under('go') &&
|
|
@@ -1438,11 +1437,11 @@ const template = {
|
|
|
1438
1437
|
where: where(),
|
|
1439
1438
|
match: ({context}) => {
|
|
1440
1439
|
// from stm lookup
|
|
1441
|
-
if (context.marker == 'mentions' && context.
|
|
1440
|
+
if (context.marker == 'mentions' && context.args.context.marker == 'speed') {
|
|
1442
1441
|
return true
|
|
1443
1442
|
}
|
|
1444
1443
|
// from property directly
|
|
1445
|
-
if (context.marker == 'speed'
|
|
1444
|
+
if (context.marker == 'speed') {
|
|
1446
1445
|
return true
|
|
1447
1446
|
}
|
|
1448
1447
|
},
|
|
@@ -1465,17 +1464,17 @@ const template = {
|
|
|
1465
1464
|
}
|
|
1466
1465
|
const speed = await fragments("number meters per second", { number: { marker: 'integer', value, word: undefined} })
|
|
1467
1466
|
const preferred = await s({ marker: 'preferredUnits', quantity: speed })
|
|
1468
|
-
resolveEvaluate(return_context, preferred.
|
|
1467
|
+
resolveEvaluate(return_context, preferred.evalue || speed)
|
|
1469
1468
|
}
|
|
1470
1469
|
},
|
|
1471
1470
|
{
|
|
1472
1471
|
where: where(),
|
|
1473
1472
|
// recallOverride(context(), frameOfReference())
|
|
1474
1473
|
match: ({context}) => {
|
|
1475
|
-
if (context.marker == 'mentions' &&
|
|
1474
|
+
if (context.marker == 'mentions' && ['direction', 'drone_direction'].includes(context.args.context.marker)) {
|
|
1476
1475
|
return true
|
|
1477
1476
|
}
|
|
1478
|
-
if (['direction', 'drone_direction'].includes(context.marker)
|
|
1477
|
+
if (['direction', 'drone_direction'].includes(context.marker)) {
|
|
1479
1478
|
return true
|
|
1480
1479
|
}
|
|
1481
1480
|
},
|
|
@@ -1491,7 +1490,7 @@ const template = {
|
|
|
1491
1490
|
}
|
|
1492
1491
|
])
|
|
1493
1492
|
const preferred = await s({ marker: 'preferredUnits', quantity: direction })
|
|
1494
|
-
resolveEvaluate(context, preferred.
|
|
1493
|
+
resolveEvaluate(context, preferred.evalue || direction)
|
|
1495
1494
|
}
|
|
1496
1495
|
},
|
|
1497
1496
|
{
|
package/common/evaluate.js
CHANGED
|
@@ -25,8 +25,8 @@ const config = {
|
|
|
25
25
|
after: ['verb'],
|
|
26
26
|
enhanced_associations: false,
|
|
27
27
|
bridge: "{ ...next(operator), postModifiers: ['value'], value: after[0] }",
|
|
28
|
-
semantic: async ({context, e,
|
|
29
|
-
|
|
28
|
+
semantic: async ({context, e, resolveEvaluate}) => {
|
|
29
|
+
resolveEvaluate(context, (await e(context.value)).evalue)
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
],
|
|
@@ -34,20 +34,14 @@ const config = {
|
|
|
34
34
|
|
|
35
35
|
function initializer({objects, config, isModule}) {
|
|
36
36
|
config.addArgs(({config, api, toList, isA}) => ({
|
|
37
|
-
resolveResponse: (context, value) => {
|
|
38
|
-
context.response = value || { marker: 'answerNotKnown' }
|
|
39
|
-
if (context.response) {
|
|
40
|
-
context.isResponse = true
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
37
|
resolveEvaluate: (context, value) => {
|
|
44
|
-
if (value == undefined) {
|
|
45
|
-
throw new Error("The arguments are context and the value. The value may not be undefined.")
|
|
46
|
-
}
|
|
47
38
|
if (Array.isArray(value)) {
|
|
48
39
|
value = toList(value)
|
|
49
40
|
}
|
|
50
|
-
context.evalue = value
|
|
41
|
+
context.evalue = value || { marker: 'undefined' }
|
|
42
|
+
if (context.evalue) {
|
|
43
|
+
context.isResponse = true
|
|
44
|
+
}
|
|
51
45
|
},
|
|
52
46
|
}))
|
|
53
47
|
}
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"convolution": true,
|
|
46
46
|
"bridge": "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }",
|
|
47
47
|
"generatorp": "async ({context, g}) => `${await g(context.what)} ${await g(context.equality)} ${await g(context.variable)}`",
|
|
48
|
-
"evaluator": "({context, api, objects, verbatim}) => {\n const formulas = api.gets(context.variable).map((f) => { return { ...f.equality, paraphrase: true } })\n if (formulas.length > 0) {\n context.evalue = { marker: 'list', value: formulas }\n } else {\n context.evalue = { marker: '
|
|
48
|
+
"evaluator": "({context, api, objects, verbatim}) => {\n const formulas = api.gets(context.variable).map((f) => { return { ...f.equality, paraphrase: true } })\n if (formulas.length > 0) {\n context.evalue = { marker: 'list', value: formulas }\n } else {\n context.evalue = { marker: 'undefined' }\n }\n }"
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:100",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"enhanced_associations": false,
|
|
54
54
|
"bridge": "{ ...next(operator), equality: after[0], variable: after[2] }",
|
|
55
55
|
"generatorp": "async ({context, gp}) => `${context.word} ${await gp(context.equality)} for ${await gp(context.variable)}`",
|
|
56
|
-
"semantic": "async ({api, context, fragments}) => {\n try {\n context.
|
|
56
|
+
"semantic": "async ({api, context, fragments}) => {\n try {\n context.evalue = await api.solveFor(context.equality, context.variable)\n context.isResponse = true\n context.value = null\n } catch( e ) {\n }\n if (!context.evalue) {\n // TODO some KM for talking to the user wrt brief+avatar\n context.verbatim = `Solving failed`\n }\n }"
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
"id": "forVariable",
|
package/common/formulas.js
CHANGED
|
@@ -92,7 +92,7 @@ const config = {
|
|
|
92
92
|
if (formulas.length > 0) {
|
|
93
93
|
context.evalue = { marker: 'list', value: formulas }
|
|
94
94
|
} else {
|
|
95
|
-
context.evalue = { marker: '
|
|
95
|
+
context.evalue = { marker: 'undefined' }
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
},
|
|
@@ -104,12 +104,12 @@ const config = {
|
|
|
104
104
|
generatorp: async ({context, gp}) => `${context.word} ${await gp(context.equality)} for ${await gp(context.variable)}`,
|
|
105
105
|
semantic: async ({api, context, fragments}) => {
|
|
106
106
|
try {
|
|
107
|
-
context.
|
|
107
|
+
context.evalue = await api.solveFor(context.equality, context.variable)
|
|
108
108
|
context.isResponse = true
|
|
109
109
|
context.value = null
|
|
110
110
|
} catch( e ) {
|
|
111
111
|
}
|
|
112
|
-
if (!context.
|
|
112
|
+
if (!context.evalue) {
|
|
113
113
|
// TODO some KM for talking to the user wrt brief+avatar
|
|
114
114
|
context.verbatim = `Solving failed`
|
|
115
115
|
}
|
package/common/gdefaults.js
CHANGED
|
@@ -29,8 +29,8 @@ const config = {
|
|
|
29
29
|
*/
|
|
30
30
|
{
|
|
31
31
|
where: where(),
|
|
32
|
-
match: ({context}) => context.isResponse && context.
|
|
33
|
-
apply: ({context, gr}) => gr(context.
|
|
32
|
+
match: ({context}) => context.isResponse && context.evalue,
|
|
33
|
+
apply: ({context, gr}) => gr(context.evalue),
|
|
34
34
|
},
|
|
35
35
|
|
|
36
36
|
{
|
|
@@ -269,7 +269,7 @@ const config = {
|
|
|
269
269
|
|
|
270
270
|
{
|
|
271
271
|
where: where(),
|
|
272
|
-
match: ({context}) => context.marker
|
|
272
|
+
match: ({context}) => context.marker === 'undefined',
|
|
273
273
|
apply: ({context}) => 'That is not known',
|
|
274
274
|
},
|
|
275
275
|
|
package/common/hierarchy.js
CHANGED
|
@@ -114,7 +114,7 @@ const config = {
|
|
|
114
114
|
// types of job what are the types of animals -> next one
|
|
115
115
|
notes: 'type of pikachu', // the types of type is the next one
|
|
116
116
|
where: where(),
|
|
117
|
-
match: ({context}) => context.marker == 'type' && context.
|
|
117
|
+
match: ({context}) => context.marker == 'type' && context.objects[context.objects.length-1].number == 'one' && pluralize.isSingular(context.objects[0].word),
|
|
118
118
|
apply: async ({context, hierarchy, objects, e, gs, km, log}) => {
|
|
119
119
|
const concept = context.objects[0];
|
|
120
120
|
const value = context.objects[1];
|
|
@@ -297,7 +297,7 @@ const config = {
|
|
|
297
297
|
// types of job
|
|
298
298
|
notes: 'types of type', // what are the types of animals
|
|
299
299
|
where: where(),
|
|
300
|
-
match: ({context}) => context.marker == 'type' && context.
|
|
300
|
+
match: ({context}) => context.marker == 'type' && context.objects,
|
|
301
301
|
apply: ({context, objects, km, isA}) => {
|
|
302
302
|
const api = km('properties').api
|
|
303
303
|
const conceptApi = km('concept').api
|
package/common/meta.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { knowledgeModule, ensureTestFile, where, unflatten, flattens } = require('./runtime').theprogrammablemind
|
|
1
|
+
const { knowledgeModule, ensureTestFile, where, unflatten, flattens, debug } = require('./runtime').theprogrammablemind
|
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
|
3
3
|
const _ = require('lodash')
|
|
4
4
|
const gdefaults = require('./gdefaults.js')
|
|
@@ -367,6 +367,7 @@ const config = {
|
|
|
367
367
|
TO.query = context.query
|
|
368
368
|
} else {
|
|
369
369
|
TO.evaluate = context.evaluate
|
|
370
|
+
TO.metaDefinition = true
|
|
370
371
|
}
|
|
371
372
|
TO[`disable${uuid}`] = true
|
|
372
373
|
toPrime = await s(TO)
|
package/common/nameable.js
CHANGED
|
@@ -92,7 +92,7 @@ const config = {
|
|
|
92
92
|
isA: ['verb'],
|
|
93
93
|
bridge: "{ ...next(operator), type: after[0] }",
|
|
94
94
|
semantic: async ({context, api}) => {
|
|
95
|
-
context.
|
|
95
|
+
context.evalue = api.getNamesByType(context.type.value).join(" ")
|
|
96
96
|
context.isResponse = true
|
|
97
97
|
}
|
|
98
98
|
},
|
|
@@ -156,7 +156,7 @@ const config = {
|
|
|
156
156
|
semantics: [
|
|
157
157
|
{
|
|
158
158
|
where: where(),
|
|
159
|
-
match: ({context}) => context.marker == 'mentions' && context.
|
|
159
|
+
match: ({context}) => context.marker == 'mentions' && context.args?.context?.nameable_named,
|
|
160
160
|
apply: async ({callId, _continue, toList, context, kms, e, log, retry}) => {
|
|
161
161
|
context.args.condition ??= () => true
|
|
162
162
|
const oldCondition = context.args.condition
|
package/common/ordinals.js
CHANGED
|
@@ -41,7 +41,7 @@ const config = {
|
|
|
41
41
|
semantics: [
|
|
42
42
|
{
|
|
43
43
|
where: where(),
|
|
44
|
-
match: ({context}) => context.marker == 'mentions' && context.
|
|
44
|
+
match: ({context}) => context.marker == 'mentions' && context.args?.context?.ordinal,
|
|
45
45
|
apply: async ({callId, _continue, toList, context, kms, e, log, toArray, retry}) => {
|
|
46
46
|
// const ordinals = toArray(context.args?.context?.ordinal)
|
|
47
47
|
const lastNotFirst = context.args?.context?.ordinal.value < 0
|