ekms 9.6.1-beta.4 → 9.6.1-beta.5
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/dimension.instance.json +1 -1
- package/common/dimension.js +3 -3
- package/common/drone.instance.json +8 -3
- package/common/drone.js +13 -14
- package/common/drone_v1.instance.json +3 -3
- package/common/drone_v1.js +14 -14
- package/common/helpers/conjunction.js +9 -5
- package/common/nameable.js +0 -11
- package/common/ordinals.js +13 -0
- package/common/stm.js +22 -15
- package/package.json +2 -2
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"verb"
|
|
93
93
|
],
|
|
94
94
|
"bridge": "{ ...next(operator), quantity: after[0], operator: operator, interpolate: [{ property: 'operator' }, { property: 'quantity' }] }",
|
|
95
|
-
"semantic": "async ({context, e, api, toArray, resolveResponse}) => {\n const preferredUnits = 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 resolveResponse(context, value.evalue)\n }"
|
|
95
|
+
"semantic": "async ({context, e, api, toArray, resolveResponse}) => {\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 resolveResponse(context, value.evalue)\n }"
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
"where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:214",
|
package/common/dimension.js
CHANGED
|
@@ -37,8 +37,8 @@ class API {
|
|
|
37
37
|
this._objects = objects
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
getPreferredUnits(quantity) {
|
|
41
|
-
const preferredUnits = this.args.mentions({
|
|
40
|
+
async getPreferredUnits(quantity) {
|
|
41
|
+
const preferredUnits = await this.args.mentions({
|
|
42
42
|
context: { marker: 'unit' },
|
|
43
43
|
condition: (unit) => {
|
|
44
44
|
if (quantity.unit.marker == 'unitPerUnit') {
|
|
@@ -201,7 +201,7 @@ const config = {
|
|
|
201
201
|
isA: ['verb'],
|
|
202
202
|
bridge: "{ ...next(operator), quantity: after[0], operator: operator, interpolate: [{ property: 'operator' }, { property: 'quantity' }] }",
|
|
203
203
|
semantic: async ({context, e, api, toArray, resolveResponse}) => {
|
|
204
|
-
const preferredUnits = api.getPreferredUnits(context.quantity)
|
|
204
|
+
const preferredUnits = await api.getPreferredUnits(context.quantity)
|
|
205
205
|
if (!preferredUnits) {
|
|
206
206
|
return
|
|
207
207
|
}
|
|
@@ -333,7 +333,7 @@
|
|
|
333
333
|
"1": "{ marker: 'drone' }"
|
|
334
334
|
},
|
|
335
335
|
"bridge": "{ ...next(operator), object: after[0], interpolate: [{ context: operator }, { property: 'object' }] }",
|
|
336
|
-
"semantic": "async ({mentioned, context, objects, api, say}) => {\n await api.stop()\n api.markCurrentPoint()\n }"
|
|
336
|
+
"semantic": "async ({mentioned, context, objects, api, say}) => {\n await api.stop()\n await api.markCurrentPoint()\n }"
|
|
337
337
|
}
|
|
338
338
|
],
|
|
339
339
|
"generators": [
|
|
@@ -353,7 +353,11 @@
|
|
|
353
353
|
},
|
|
354
354
|
{
|
|
355
355
|
"match": "({context, contextHierarchy}) => {\n if (!context.pullFromContext || !context.evaluate || contextHierarchy.under('doAction')) {\n return false\n }\n \n if (context.marker == 'path' || context.marker == 'this' || context.marker == 'that') {\n return true\n }\n }",
|
|
356
|
-
"apply": "async ({context, fragments, stm, objects, mentioned, mentions, resolveEvaluate, _continue, contextHierarchy}) => {\n
|
|
356
|
+
"apply": "async ({context, toArray, fragments, stm, objects, mentioned, mentions, resolveEvaluate, _continue, contextHierarchy}) => {\n const pathComponents = toArray(await mentions({ context: { marker: 'pathComponent' }, all: true }))\n const path = (await fragments('path')).contexts()[0]\n delete path.value\n path.points = pathComponents.reverse()\n await mentioned(path)\n\n _continue() // let the call pick the object out from the stm\n }"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"match": "({context, contextHierarchy}) => {\n if (!context.pullFromContext || !context.evaluate || !contextHierarchy.under('call') || context.notUnderCall) {\n return false\n }\n \n if (context.marker == 'point' || context.marker == 'ordinal') {\n return true\n }\n }",
|
|
360
|
+
"apply": "async ({context, e, fragments, stm, toEValue, toArray, objects, mentioned, mentions, 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.points = pathComponents.reverse()\n await mentioned(path)\n resolveEvaluate(context, path)\n }"
|
|
357
361
|
},
|
|
358
362
|
{
|
|
359
363
|
"match": "({context}) => context.marker == 'thenTime'",
|
|
@@ -361,7 +365,7 @@
|
|
|
361
365
|
},
|
|
362
366
|
{
|
|
363
367
|
"match": "({context}) => context.evaluate && ['start', 'end'].includes(context.marker) && context.objects && context.objects[1].marker == 'path'",
|
|
364
|
-
"apply": "async ({gp, s, context, objects, fragments, resolveEvaluate, api, mentions}) => {\n const path = mentions({ 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 }"
|
|
368
|
+
"apply": "async ({gp, s, context, objects, fragments, resolveEvaluate, api, mentions}) => {\n const path = await mentions({ 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 }"
|
|
365
369
|
},
|
|
366
370
|
{
|
|
367
371
|
"match": "({context}) => context.marker == 'speed' && context.evaluate",
|
|
@@ -50265,6 +50269,7 @@
|
|
|
50265
50269
|
{},
|
|
50266
50270
|
{},
|
|
50267
50271
|
{},
|
|
50272
|
+
{},
|
|
50268
50273
|
{}
|
|
50269
50274
|
]
|
|
50270
50275
|
}
|
package/common/drone.js
CHANGED
|
@@ -310,7 +310,7 @@ class API {
|
|
|
310
310
|
return this._objects.current.ordinal += 1
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
currentPoint() {
|
|
313
|
+
async currentPoint() {
|
|
314
314
|
const current = this._objects.current
|
|
315
315
|
if (current.durationInSeconds) {
|
|
316
316
|
// okay
|
|
@@ -318,7 +318,7 @@ class API {
|
|
|
318
318
|
return null // in motion
|
|
319
319
|
}
|
|
320
320
|
const ordinal = this.currentOrdinal()
|
|
321
|
-
const lastPoint = this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
321
|
+
const lastPoint = await this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
322
322
|
if (!current.startTime && !current.endTime && !current.durationInSeconds) {
|
|
323
323
|
return lastPoint // did not move
|
|
324
324
|
}
|
|
@@ -338,8 +338,8 @@ class API {
|
|
|
338
338
|
return { x: xPrime, y: yPrime }
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
markCurrentPoint() {
|
|
342
|
-
const point = this.currentPoint()
|
|
341
|
+
async markCurrentPoint() {
|
|
342
|
+
const point = await this.currentPoint()
|
|
343
343
|
if (!point) {
|
|
344
344
|
return
|
|
345
345
|
}
|
|
@@ -405,14 +405,14 @@ class API {
|
|
|
405
405
|
objects.current.durationInSeconds = distanceMeters / speed_meters_per_second
|
|
406
406
|
await this.pause(objects.current.durationInSeconds, { batched: true })
|
|
407
407
|
await this.stop({ batched: true })
|
|
408
|
-
this.markCurrentPoint()
|
|
408
|
+
await this.markCurrentPoint()
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
if (objects.current.path.length > 0) {
|
|
412
412
|
if (objects.current.timeRepeats) {
|
|
413
413
|
this.startRepeats(objects.current.timeRepeats)
|
|
414
414
|
}
|
|
415
|
-
let currentPoint = this.args.mentions({ context: { marker: 'point' } }).point
|
|
415
|
+
let currentPoint = (await this.args.mentions({ context: { marker: 'point' } })).point
|
|
416
416
|
this._objects.history.push({ marker: 'history', debug: 'doing path' })
|
|
417
417
|
for (const pathComponent of objects.current.path) {
|
|
418
418
|
if (pathComponent.marker == 'pause') {
|
|
@@ -544,7 +544,7 @@ class API {
|
|
|
544
544
|
} else {
|
|
545
545
|
ordinal = this.currentOrdinal() - 1
|
|
546
546
|
}
|
|
547
|
-
const lastPoint = this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
547
|
+
const lastPoint = await this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
548
548
|
if (!lastPoint) {
|
|
549
549
|
this.args.say(`There is no previous point to go back to`)
|
|
550
550
|
return
|
|
@@ -558,8 +558,8 @@ class API {
|
|
|
558
558
|
const current = objects.current
|
|
559
559
|
current.backAndForth = true
|
|
560
560
|
const ordinal = this.currentOrdinal()
|
|
561
|
-
const currentPoint = this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
562
|
-
const lastPoint = this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal-1 })
|
|
561
|
+
const currentPoint = await this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
562
|
+
const lastPoint = await this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal-1 })
|
|
563
563
|
current.path.push(lastPoint)
|
|
564
564
|
current.path.push(currentPoint)
|
|
565
565
|
objects.runCommand = true
|
|
@@ -1072,7 +1072,7 @@ const template = {
|
|
|
1072
1072
|
bridge: "{ ...next(operator), object: after[0], interpolate: [{ context: operator }, { property: 'object' }] }",
|
|
1073
1073
|
semantic: async ({mentioned, context, objects, api, say}) => {
|
|
1074
1074
|
await api.stop()
|
|
1075
|
-
api.markCurrentPoint()
|
|
1075
|
+
await api.markCurrentPoint()
|
|
1076
1076
|
}
|
|
1077
1077
|
},
|
|
1078
1078
|
],
|
|
@@ -1108,9 +1108,8 @@ const template = {
|
|
|
1108
1108
|
return true
|
|
1109
1109
|
}
|
|
1110
1110
|
},
|
|
1111
|
-
apply: async ({context, fragments, stm, objects, mentioned, mentions, resolveEvaluate, _continue, contextHierarchy}) => {
|
|
1112
|
-
|
|
1113
|
-
const pathComponents = mentions({ context: { marker: 'pathComponent' }, all: true })
|
|
1111
|
+
apply: async ({context, toArray, fragments, stm, objects, mentioned, mentions, resolveEvaluate, _continue, contextHierarchy}) => {
|
|
1112
|
+
const pathComponents = toArray(await mentions({ context: { marker: 'pathComponent' }, all: true }))
|
|
1114
1113
|
const path = (await fragments('path')).contexts()[0]
|
|
1115
1114
|
delete path.value
|
|
1116
1115
|
path.points = pathComponents.reverse()
|
|
@@ -1152,7 +1151,7 @@ const template = {
|
|
|
1152
1151
|
{
|
|
1153
1152
|
match: ({context}) => context.evaluate && ['start', 'end'].includes(context.marker) && context.objects && context.objects[1].marker == 'path',
|
|
1154
1153
|
apply: async ({gp, s, context, objects, fragments, resolveEvaluate, api, mentions}) => {
|
|
1155
|
-
const path = mentions({ context: context.objects[1] })
|
|
1154
|
+
const path = await mentions({ context: context.objects[1] })
|
|
1156
1155
|
if (!path?.points) {
|
|
1157
1156
|
return
|
|
1158
1157
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"point is a concept",
|
|
7
7
|
"points are nameable orderable and memorable",
|
|
8
8
|
{
|
|
9
|
-
"apply": "(args) => {\n askForCalibrationDistance(args)\n askForEndTime(args)\n askForStartTime(args)\n\n expectDirection(args)\n expectDistanceForCalibration(args)\n expectCalibrationCompletion(args)\n\n args.config.addSemantic({\n match: ({context, isA}) => isA(context.marker, 'quantity') && isA(context.unit.marker, 'unitPerUnit'),\n apply: async ({context, objects, api, fragments, e}) => {\n // send a command to the drone\n const instantiation = await fragments(\"quantity in meters per second\", { quantity: context })\n const result = await e(instantiation)\n const desired_speed = result.evalue.amount.evalue.evalue\n const desired_power = objects.current.power * (desired_speed / objects.calibration.speed)\n objects.runCommand = true\n objects.current.power = desired_power \n }\n })\n\n args.config.addSemantic({\n match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && context.marker == 'controlStart',\n apply: ({context, objects, api}) => {\n objects.runCommand = false \n }\n })\n\n args.config.addSemantic({\n // match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && (context.marker == 'controlEnd' || context.marker == 'controlBetween'),\n match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && context.marker == 'controlEnd',\n apply: ({context, objects, api}) => {\n // send a command to the drone\n if (objects.runCommand) {\n // debugger\n api.sendCommand()\n }\n }\n })\n }"
|
|
9
|
+
"apply": "(args) => {\n askForCalibrationDistance(args)\n askForEndTime(args)\n askForStartTime(args)\n\n expectDirection(args)\n expectDistanceForCalibration(args)\n expectCalibrationCompletion(args)\n\n args.config.addSemantic({\n match: ({context, isA}) => isA(context.marker, 'quantity') && isA(context.unit.marker, 'unitPerUnit'),\n apply: async ({context, objects, api, fragments, e}) => {\n // send a command to the drone\n const instantiation = await fragments(\"quantity in meters per second\", { quantity: context })\n const result = await e(instantiation)\n const desired_speed = result.evalue.amount.evalue.evalue\n const desired_power = objects.current.power * (desired_speed / objects.calibration.speed)\n objects.runCommand = true\n objects.current.power = desired_power \n }\n })\n\n args.config.addSemantic({\n match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && context.marker == 'controlStart',\n apply: ({context, objects, api}) => {\n objects.runCommand = false \n }\n })\n\n args.config.addSemantic({\n // match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && (context.marker == 'controlEnd' || context.marker == 'controlBetween'),\n match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && context.marker == 'controlEnd',\n apply: async ({context, objects, api}) => {\n // send a command to the drone\n if (objects.runCommand) {\n // debugger\n await api.sendCommand()\n }\n }\n })\n }"
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
"operators": [
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"1": "{ marker: 'drone' }"
|
|
63
63
|
},
|
|
64
64
|
"bridge": "{ ...next(operator), object: after[0], interpolate: [{ context: operator }, { property: 'object' }] }",
|
|
65
|
-
"semantic": "({mentioned, context, objects, api, say}) => {\n if (!objects.calibration.startTime) {\n return // ignore\n }\n if (objects.calibration.speed) {\n /*\n const stopTime = api.stop()\n const ordinal = api.nextOrdinal()\n const point = api.currentPoint()\n mentioned({ marker: 'point', ordinal, point })\n objects.current.ordinal = ordinal\n */\n api.stop()\n api.markCurrentPoint()\n } else {\n const stopTime = api.stop()\n objects.calibration.endTime = stopTime\n objects.calibration.duration = (objects.calibration.endTime - objects.calibration.startTime)/1000\n }\n }"
|
|
65
|
+
"semantic": "async ({mentioned, context, objects, api, say}) => {\n if (!objects.calibration.startTime) {\n return // ignore\n }\n if (objects.calibration.speed) {\n /*\n const stopTime = api.stop()\n const ordinal = api.nextOrdinal()\n const point = api.currentPoint()\n mentioned({ marker: 'point', ordinal, point })\n objects.current.ordinal = ordinal\n */\n api.stop()\n await api.markCurrentPoint()\n } else {\n const stopTime = api.stop()\n objects.calibration.endTime = stopTime\n objects.calibration.duration = (objects.calibration.endTime - objects.calibration.startTime)/1000\n }\n }"
|
|
66
66
|
}
|
|
67
67
|
],
|
|
68
68
|
"generators": [
|
|
@@ -17782,7 +17782,7 @@
|
|
|
17782
17782
|
}
|
|
17783
17783
|
},
|
|
17784
17784
|
{
|
|
17785
|
-
"apply": "(args) => {\n askForCalibrationDistance(args)\n askForEndTime(args)\n askForStartTime(args)\n\n expectDirection(args)\n expectDistanceForCalibration(args)\n expectCalibrationCompletion(args)\n\n args.config.addSemantic({\n match: ({context, isA}) => isA(context.marker, 'quantity') && isA(context.unit.marker, 'unitPerUnit'),\n apply: async ({context, objects, api, fragments, e}) => {\n // send a command to the drone\n const instantiation = await fragments(\"quantity in meters per second\", { quantity: context })\n const result = await e(instantiation)\n const desired_speed = result.evalue.amount.evalue.evalue\n const desired_power = objects.current.power * (desired_speed / objects.calibration.speed)\n objects.runCommand = true\n objects.current.power = desired_power \n }\n })\n\n args.config.addSemantic({\n match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && context.marker == 'controlStart',\n apply: ({context, objects, api}) => {\n objects.runCommand = false \n }\n })\n\n args.config.addSemantic({\n // match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && (context.marker == 'controlEnd' || context.marker == 'controlBetween'),\n match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && context.marker == 'controlEnd',\n apply: ({context, objects, api}) => {\n // send a command to the drone\n if (objects.runCommand) {\n // debugger\n api.sendCommand()\n }\n }\n })\n }"
|
|
17785
|
+
"apply": "(args) => {\n askForCalibrationDistance(args)\n askForEndTime(args)\n askForStartTime(args)\n\n expectDirection(args)\n expectDistanceForCalibration(args)\n expectCalibrationCompletion(args)\n\n args.config.addSemantic({\n match: ({context, isA}) => isA(context.marker, 'quantity') && isA(context.unit.marker, 'unitPerUnit'),\n apply: async ({context, objects, api, fragments, e}) => {\n // send a command to the drone\n const instantiation = await fragments(\"quantity in meters per second\", { quantity: context })\n const result = await e(instantiation)\n const desired_speed = result.evalue.amount.evalue.evalue\n const desired_power = objects.current.power * (desired_speed / objects.calibration.speed)\n objects.runCommand = true\n objects.current.power = desired_power \n }\n })\n\n args.config.addSemantic({\n match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && context.marker == 'controlStart',\n apply: ({context, objects, api}) => {\n objects.runCommand = false \n }\n })\n\n args.config.addSemantic({\n // match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && (context.marker == 'controlEnd' || context.marker == 'controlBetween'),\n match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && context.marker == 'controlEnd',\n apply: async ({context, objects, api}) => {\n // send a command to the drone\n if (objects.runCommand) {\n // debugger\n await api.sendCommand()\n }\n }\n })\n }"
|
|
17786
17786
|
},
|
|
17787
17787
|
{
|
|
17788
17788
|
"extraConfig": true,
|
package/common/drone_v1.js
CHANGED
|
@@ -141,12 +141,12 @@ class API {
|
|
|
141
141
|
return this._objects.ordinal += 1
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
currentPoint() {
|
|
144
|
+
async currentPoint() {
|
|
145
145
|
if (!this._objects.current.endTime) {
|
|
146
146
|
return null // in motion
|
|
147
147
|
}
|
|
148
148
|
const ordinal = this._objects.current.ordinal
|
|
149
|
-
const lastPoint = this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
149
|
+
const lastPoint = await this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
150
150
|
|
|
151
151
|
const durationInSeconds = (this._objects.current.endTime - this._objects.current.startTime) / 1000
|
|
152
152
|
const speedInMetersPerSecond = (this._objects.current.power / this._objects.calibration.power) * this._objects.calibration.speed
|
|
@@ -159,9 +159,9 @@ class API {
|
|
|
159
159
|
return { x: xPrime, y: yPrime }
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
markCurrentPoint() {
|
|
162
|
+
async markCurrentPoint() {
|
|
163
163
|
const ordinal = this.nextOrdinal()
|
|
164
|
-
const point = this.currentPoint()
|
|
164
|
+
const point = await this.currentPoint()
|
|
165
165
|
this.args.mentioned({ marker: 'point', ordinal, point })
|
|
166
166
|
this._objects.current.ordinal = ordinal
|
|
167
167
|
this._objects.current.endTime = null
|
|
@@ -186,17 +186,17 @@ class API {
|
|
|
186
186
|
this.testDate = new Date(this.testDate.getTime() + (duration_in_seconds-1)*1000)
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
sendCommand() {
|
|
190
|
-
const stopAtDistance = (distanceMeters) => {
|
|
189
|
+
async sendCommand() {
|
|
190
|
+
const stopAtDistance = async (distanceMeters) => {
|
|
191
191
|
const speed_meters_per_second = this._objects.calibration.speed
|
|
192
192
|
const duration_seconds = distanceMeters / speed_meters_per_second
|
|
193
193
|
this.pause(duration_seconds)
|
|
194
194
|
this.stop()
|
|
195
|
-
this.markCurrentPoint()
|
|
195
|
+
await this.markCurrentPoint()
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
if (this._objects.current.destination) {
|
|
199
|
-
const currentPoint = this.args.mentions({ context: { marker: 'point' } })
|
|
199
|
+
const currentPoint = await this.args.mentions({ context: { marker: 'point' } })
|
|
200
200
|
const polar = cartesianToPolar(currentPoint.point, this._objects.current.destination.point)
|
|
201
201
|
const destinationAngleInDegrees = radiansToDegrees(polar.angle)
|
|
202
202
|
let angleDelta = destinationAngleInDegrees - this._objects.current.angleInDegrees
|
|
@@ -207,7 +207,7 @@ class API {
|
|
|
207
207
|
}
|
|
208
208
|
this.rotate(angleDelta)
|
|
209
209
|
this.forward(this._objects.current.power)
|
|
210
|
-
stopAtDistance(polar.radius)
|
|
210
|
+
await stopAtDistance(polar.radius)
|
|
211
211
|
return
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -232,7 +232,7 @@ class API {
|
|
|
232
232
|
|
|
233
233
|
if (command.distance) {
|
|
234
234
|
const distanceMeters = command.distance
|
|
235
|
-
stopAtDistance(distanceMeters)
|
|
235
|
+
await stopAtDistance(distanceMeters)
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
|
|
@@ -456,11 +456,11 @@ const template = {
|
|
|
456
456
|
args.config.addSemantic({
|
|
457
457
|
// match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && (context.marker == 'controlEnd' || context.marker == 'controlBetween'),
|
|
458
458
|
match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && context.marker == 'controlEnd',
|
|
459
|
-
apply: ({context, objects, api}) => {
|
|
459
|
+
apply: async ({context, objects, api}) => {
|
|
460
460
|
// send a command to the drone
|
|
461
461
|
if (objects.runCommand) {
|
|
462
462
|
// debugger
|
|
463
|
-
api.sendCommand()
|
|
463
|
+
await api.sendCommand()
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
})
|
|
@@ -529,7 +529,7 @@ const template = {
|
|
|
529
529
|
1: "{ marker: 'drone' }",
|
|
530
530
|
},
|
|
531
531
|
bridge: "{ ...next(operator), object: after[0], interpolate: [{ context: operator }, { property: 'object' }] }",
|
|
532
|
-
semantic: ({mentioned, context, objects, api, say}) => {
|
|
532
|
+
semantic: async ({mentioned, context, objects, api, say}) => {
|
|
533
533
|
if (!objects.calibration.startTime) {
|
|
534
534
|
return // ignore
|
|
535
535
|
}
|
|
@@ -542,7 +542,7 @@ const template = {
|
|
|
542
542
|
objects.current.ordinal = ordinal
|
|
543
543
|
*/
|
|
544
544
|
api.stop()
|
|
545
|
-
api.markCurrentPoint()
|
|
545
|
+
await api.markCurrentPoint()
|
|
546
546
|
} else {
|
|
547
547
|
const stopTime = api.stop()
|
|
548
548
|
objects.calibration.endTime = stopTime
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { propertyToArray } = require('../helpers.js')
|
|
2
2
|
|
|
3
|
-
function asList(context) {
|
|
3
|
+
function asList(context, maybe=false) {
|
|
4
4
|
if (Array.isArray(context)) {
|
|
5
5
|
return {
|
|
6
6
|
marker: 'list',
|
|
@@ -10,10 +10,14 @@ function asList(context) {
|
|
|
10
10
|
} else if (context.marker === 'list') {
|
|
11
11
|
return context
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
if (maybe) {
|
|
14
|
+
return context
|
|
15
|
+
} else {
|
|
16
|
+
return {
|
|
17
|
+
marker: 'list',
|
|
18
|
+
types: [context.marker],
|
|
19
|
+
value: [context]
|
|
20
|
+
}
|
|
17
21
|
}
|
|
18
22
|
}
|
|
19
23
|
|
package/common/nameable.js
CHANGED
|
@@ -21,17 +21,6 @@ class API {
|
|
|
21
21
|
this.args.config.addWord(name, { id: context.marker, initial: `{ value: "${name}", pullFromContext: true, nameable_named: true }` })
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
get(type, name) {
|
|
25
|
-
return this.args.kms.stm.api.mentions({
|
|
26
|
-
context: type,
|
|
27
|
-
condition: (context) => {
|
|
28
|
-
if (context.stm && context.stm.names) {
|
|
29
|
-
return context.stm.names.includes(name)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
24
|
getNamesByType(type) {
|
|
36
25
|
const contexts = this.args.kms.stm.api.getByType(type)
|
|
37
26
|
const names = new Set()
|
package/common/ordinals.js
CHANGED
|
@@ -31,6 +31,19 @@ const config = {
|
|
|
31
31
|
bridge: "{ ...after[0], ordinal: before[0], modifiers: append(['ordinal'], after[0].modifiers) }"
|
|
32
32
|
},
|
|
33
33
|
],
|
|
34
|
+
semantics: [
|
|
35
|
+
{
|
|
36
|
+
where: where(),
|
|
37
|
+
match: ({context}) => context.marker == 'mentions' && context.evaluate,
|
|
38
|
+
apply: async ({callId, _continue, toList, context, kms, e, log, retry}) => {
|
|
39
|
+
if (context.args?.context?.ordinal?.marker == 'ordinal' && context.args?.context?.ordinal?.value == -1) {
|
|
40
|
+
const lastN = context.args.context.quantity.value || 1
|
|
41
|
+
context.args.lastN = lastN
|
|
42
|
+
}
|
|
43
|
+
_continue()
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
],
|
|
34
47
|
words: {
|
|
35
48
|
"literals": {
|
|
36
49
|
"first": [{"id": "ordinal", "initial": "{ value: 1, ordinal: true, instance: true }" }],
|
package/common/stm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { knowledgeModule, where, debug } = require('./runtime').theprogrammablemind
|
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
|
3
3
|
const helpers = require('./helpers')
|
|
4
|
+
const helpers_conjunction = require('./helpers/conjunction')
|
|
4
5
|
const articles = require('./articles')
|
|
5
6
|
const evaluate = require('./evaluate')
|
|
6
7
|
const stm_tests = require('./stm.test.json')
|
|
@@ -68,12 +69,8 @@ class API {
|
|
|
68
69
|
concept.value = value
|
|
69
70
|
}
|
|
70
71
|
concept.fromSTM = true
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
if (!concept.stm.id) {
|
|
75
|
-
concept.stm.id = this.getId()
|
|
76
|
-
}
|
|
72
|
+
concept.stm ??= {}
|
|
73
|
+
concept.stm.id ??= this.getId()
|
|
77
74
|
frameOfReference.mentioned = (frameOfReference.mentioned || []).filter( (context) => context.stm && context.stm.id != concept.stm.id )
|
|
78
75
|
helpers.unshiftL(frameOfReference.mentioned, concept, this.maximumMentioned)
|
|
79
76
|
}
|
|
@@ -275,17 +272,22 @@ const config = {
|
|
|
275
272
|
},
|
|
276
273
|
],
|
|
277
274
|
semantics: [
|
|
275
|
+
{
|
|
276
|
+
where: where(),
|
|
277
|
+
match: ({context}) => context.marker == 'mentions' && context.evaluate,
|
|
278
|
+
apply: ({context, kms, toList, resolveEvaluate}) => {
|
|
279
|
+
resolveEvaluate(context, kms.stm.api.mentions(context.args))
|
|
280
|
+
}
|
|
281
|
+
},
|
|
278
282
|
{
|
|
279
283
|
where: where(),
|
|
280
284
|
notes: 'pull from context',
|
|
281
285
|
// match: ({context}) => context.marker == 'it' && context.pullFromContext, // && context.value,
|
|
282
286
|
match: ({context, callId}) => context.pullFromContext && !context.same, // && context.value,
|
|
283
|
-
apply: async ({callId, toList, context, kms, e, log, retry}) => {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
context.value = toList(
|
|
287
|
-
} else {
|
|
288
|
-
context.value = kms.stm.api.mentions({ context })
|
|
287
|
+
apply: async ({callId, mentions, toList, context, kms, e, log, retry}) => {
|
|
288
|
+
context.value = (await mentions({ context }))
|
|
289
|
+
if (Array.isArray(context.value)) {
|
|
290
|
+
context.value = toList(context.value)
|
|
289
291
|
}
|
|
290
292
|
|
|
291
293
|
if (!context.value) {
|
|
@@ -307,12 +309,17 @@ const config = {
|
|
|
307
309
|
}
|
|
308
310
|
|
|
309
311
|
function initializer({config}) {
|
|
310
|
-
config.addArgs(({kms}) => ({
|
|
312
|
+
config.addArgs(({kms, e}) => ({
|
|
311
313
|
mentioned: (args) => {
|
|
312
314
|
kms.stm.api.mentioned(args)
|
|
313
315
|
},
|
|
314
|
-
mentions: (args) => {
|
|
315
|
-
|
|
316
|
+
mentions: async (args) => {
|
|
317
|
+
const result = await e({ marker: 'mentions', args })
|
|
318
|
+
// evalue will return the argument if there is no evalue. dont want that for this case
|
|
319
|
+
if (!result.evalue) {
|
|
320
|
+
return
|
|
321
|
+
}
|
|
322
|
+
return helpers_conjunction.asList(helpers.toEValue(result), true)
|
|
316
323
|
},
|
|
317
324
|
}))
|
|
318
325
|
}
|
package/package.json
CHANGED
|
@@ -386,8 +386,8 @@
|
|
|
386
386
|
"scriptjs": "^2.5.9",
|
|
387
387
|
"table": "^6.7.1",
|
|
388
388
|
"uuid": "^9.0.0",
|
|
389
|
-
"theprogrammablemind": "9.6.1-beta.
|
|
389
|
+
"theprogrammablemind": "9.6.1-beta.5"
|
|
390
390
|
},
|
|
391
|
-
"version": "9.6.1-beta.
|
|
391
|
+
"version": "9.6.1-beta.5",
|
|
392
392
|
"license": "UNLICENSED"
|
|
393
393
|
}
|