@haibun/core 1.73.0 → 1.74.0
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/build/applyEffectFeatures.d.ts.map +1 -1
- package/build/applyEffectFeatures.js +4 -2
- package/build/applyEffectFeatures.js.map +1 -1
- package/build/currentVersion.d.ts +1 -1
- package/build/currentVersion.js +1 -1
- package/build/lib/astepper.d.ts +2 -3
- package/build/lib/astepper.d.ts.map +1 -1
- package/build/lib/astepper.js.map +1 -1
- package/build/lib/defs.d.ts +48 -18
- package/build/lib/defs.d.ts.map +1 -1
- package/build/lib/defs.js +17 -2
- package/build/lib/defs.js.map +1 -1
- package/build/lib/domain-types.d.ts +22 -2
- package/build/lib/domain-types.d.ts.map +1 -1
- package/build/lib/domain-types.js +54 -3
- package/build/lib/domain-types.js.map +1 -1
- package/build/lib/feature-variables.d.ts +8 -9
- package/build/lib/feature-variables.d.ts.map +1 -1
- package/build/lib/feature-variables.js +30 -12
- package/build/lib/feature-variables.js.map +1 -1
- package/build/lib/namedVars.d.ts +10 -15
- package/build/lib/namedVars.d.ts.map +1 -1
- package/build/lib/namedVars.js +130 -114
- package/build/lib/namedVars.js.map +1 -1
- package/build/lib/populateActionArgs.d.ts +4 -0
- package/build/lib/populateActionArgs.d.ts.map +1 -0
- package/build/lib/populateActionArgs.js +58 -0
- package/build/lib/populateActionArgs.js.map +1 -0
- package/build/lib/test/SetTimeStepper.d.ts +2 -2
- package/build/lib/test/SetTimeStepper.d.ts.map +1 -1
- package/build/lib/test/SetTimeStepper.js +6 -1
- package/build/lib/test/SetTimeStepper.js.map +1 -1
- package/build/lib/test/TestSteps.d.ts +3 -3
- package/build/lib/test/TestSteps.d.ts.map +1 -1
- package/build/lib/test/TestSteps.js +3 -1
- package/build/lib/test/TestSteps.js.map +1 -1
- package/build/lib/test/lib.d.ts.map +1 -1
- package/build/lib/test/lib.js +5 -2
- package/build/lib/test/lib.js.map +1 -1
- package/build/lib/util/featureStep-executor.d.ts +6 -0
- package/build/lib/util/featureStep-executor.d.ts.map +1 -0
- package/build/lib/util/featureStep-executor.js +39 -0
- package/build/lib/util/featureStep-executor.js.map +1 -0
- package/build/lib/util/index.d.ts +1 -2
- package/build/lib/util/index.d.ts.map +1 -1
- package/build/lib/util/index.js +2 -3
- package/build/lib/util/index.js.map +1 -1
- package/build/lib/util/resolveAndExecuteStatement.js +1 -1
- package/build/lib/util/resolveAndExecuteStatement.js.map +1 -1
- package/build/phases/Executor.d.ts +3 -3
- package/build/phases/Executor.d.ts.map +1 -1
- package/build/phases/Executor.js +53 -27
- package/build/phases/Executor.js.map +1 -1
- package/build/phases/Resolver.d.ts +2 -5
- package/build/phases/Resolver.d.ts.map +1 -1
- package/build/phases/Resolver.js +28 -20
- package/build/phases/Resolver.js.map +1 -1
- package/build/runner.js +2 -2
- package/build/runner.js.map +1 -1
- package/build/steps/debugger-stepper.d.ts +6 -54
- package/build/steps/debugger-stepper.d.ts.map +1 -1
- package/build/steps/debugger-stepper.js +53 -20
- package/build/steps/debugger-stepper.js.map +1 -1
- package/build/steps/haibun.d.ts +27 -87
- package/build/steps/haibun.d.ts.map +1 -1
- package/build/steps/haibun.js +78 -189
- package/build/steps/haibun.js.map +1 -1
- package/build/steps/narrator.d.ts +81 -0
- package/build/steps/narrator.d.ts.map +1 -0
- package/build/steps/narrator.js +102 -0
- package/build/steps/narrator.js.map +1 -0
- package/build/steps/parse.d.ts +1 -1
- package/build/steps/variables-stepper.d.ts +7 -40
- package/build/steps/variables-stepper.d.ts.map +1 -1
- package/build/steps/variables-stepper.js +102 -42
- package/build/steps/variables-stepper.js.map +1 -1
- package/package.json +1 -1
- package/build/lib/ReadlinePrompter.d.ts +0 -9
- package/build/lib/ReadlinePrompter.d.ts.map +0 -1
- package/build/lib/ReadlinePrompter.js +0 -27
- package/build/lib/ReadlinePrompter.js.map +0 -1
- package/build/lib/create-world.d.ts +0 -3
- package/build/lib/create-world.d.ts.map +0 -1
- package/build/lib/create-world.js +0 -31
- package/build/lib/create-world.js.map +0 -1
- package/build/lib/util/executeStep.d.ts +0 -5
- package/build/lib/util/executeStep.d.ts.map +0 -1
- package/build/lib/util/executeStep.js +0 -16
- package/build/lib/util/executeStep.js.map +0 -1
package/build/steps/haibun.js
CHANGED
|
@@ -1,245 +1,134 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OK, STEP_DELAY, SCENARIO_START } from '../lib/defs.js';
|
|
1
|
+
import { OK, STEP_DELAY, ExecMode } from '../lib/defs.js';
|
|
3
2
|
import { AStepper } from '../lib/astepper.js';
|
|
4
3
|
import { Resolver } from '../phases/Resolver.js';
|
|
5
|
-
import { actionNotOK, actionOK, formattedSteppers,
|
|
6
|
-
import {
|
|
4
|
+
import { actionNotOK, actionOK, formattedSteppers, sleep } from '../lib/util/index.js';
|
|
5
|
+
import { doExecuteFeatureSteps } from '../lib/util/featureStep-executor.js';
|
|
7
6
|
import { expand } from '../lib/features.js';
|
|
8
7
|
import { asFeatures } from '../lib/resolver-features.js';
|
|
9
|
-
import { copyPreRenderedAudio, doExec, doSpawn, playAudioFile, preRenderFeatureProse } from './lib/tts.js';
|
|
10
8
|
import { EExecutionMessageType } from '../lib/interfaces/logger.js';
|
|
11
|
-
import { captureLocator } from '../lib/capture-locator.js';
|
|
12
9
|
import { endExecutonContext } from '../phases/Executor.js';
|
|
13
|
-
import { doExecuteFeatureSteps, findFeatureStepsFromStatement } from '../lib/util/resolveAndExecuteStatement.js';
|
|
14
|
-
const CAPTURE_FILENAME = 'vcapture.webm';
|
|
15
|
-
const cycles = (hb) => ({
|
|
16
|
-
async startFeature({ resolvedFeature }) {
|
|
17
|
-
if (hb.ttsCmd) {
|
|
18
|
-
hb.renderedAudio = await preRenderFeatureProse(resolvedFeature, hb.ttsCmd, hb.world.logger);
|
|
19
|
-
}
|
|
20
|
-
if (hb.captureStart) {
|
|
21
|
-
hb.getWorld().logger.debug(`Spawning screen capture using ${hb.captureStart}`);
|
|
22
|
-
doSpawn(hb.captureStart);
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
async endFeature() {
|
|
26
|
-
if (hb.captureStop) {
|
|
27
|
-
const uri = actualURI(CAPTURE_FILENAME);
|
|
28
|
-
hb.getWorld().logger.info(`Stopping vcapture ${uri} using ${hb.captureStop}`);
|
|
29
|
-
await sleep(2000);
|
|
30
|
-
await doExec(hb.captureStop, false);
|
|
31
|
-
const path = captureLocator(hb.world.options, hb.world.tag);
|
|
32
|
-
const artifact = { artifactType: 'video', path };
|
|
33
|
-
const context = {
|
|
34
|
-
incident: EExecutionMessageType.FEATURE_END,
|
|
35
|
-
artifacts: [artifact],
|
|
36
|
-
tag: hb.getWorld().tag
|
|
37
|
-
};
|
|
38
|
-
hb.getWorld().logger.log('feature video', context);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
10
|
class Haibun extends AStepper {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
TTS_CMD: {
|
|
46
|
-
desc: `TTS command that accepts text as @WHAT@ and returns a full path to stdout`,
|
|
47
|
-
parse: (input) => stringOrError(input),
|
|
48
|
-
required: false
|
|
49
|
-
},
|
|
50
|
-
TTS_PLAY: {
|
|
51
|
-
desc: `Shell command that plays an audio file using @WHAT@`,
|
|
52
|
-
parse: (input) => stringOrError(input),
|
|
53
|
-
required: false
|
|
54
|
-
},
|
|
55
|
-
CAPTURE_START: {
|
|
56
|
-
desc: `Shell command to start screen capture'`,
|
|
57
|
-
parse: (input) => stringOrError(input),
|
|
58
|
-
required: false
|
|
59
|
-
},
|
|
60
|
-
CAPTURE_STOP: {
|
|
61
|
-
desc: `Shell command to stop screen capture'`,
|
|
62
|
-
parse: (input) => stringOrError(input),
|
|
63
|
-
required: false
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
cycles = cycles(this);
|
|
67
|
-
steppers;
|
|
68
|
-
ttsCmd;
|
|
69
|
-
ttsPlay;
|
|
70
|
-
captureStart;
|
|
71
|
-
captureStop;
|
|
11
|
+
steppers = [];
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
72
13
|
async setWorld(world, steppers) {
|
|
73
|
-
this.steppers = steppers;
|
|
74
14
|
this.world = world;
|
|
75
|
-
this.
|
|
76
|
-
this.ttsPlay = getStepperOption(this, 'TTS_PLAY', world.moduleOptions);
|
|
77
|
-
this.captureStart = getStepperOption(this, 'CAPTURE_START', world.moduleOptions);
|
|
78
|
-
this.captureStop = getStepperOption(this, 'CAPTURE_STOP', world.moduleOptions);
|
|
79
|
-
if (this.captureStart && !this.captureStop || this.captureStop && !this.captureStart) {
|
|
80
|
-
throw Error(`Capture requires both CAPTURE_START and CAPTURE_STOP`);
|
|
81
|
-
}
|
|
82
|
-
return Promise.resolve();
|
|
15
|
+
this.steppers = steppers;
|
|
83
16
|
}
|
|
84
17
|
steps = {
|
|
85
18
|
prose: {
|
|
86
|
-
|
|
87
|
-
action: async (
|
|
88
|
-
return await this.maybeSay(featureStep.in);
|
|
89
|
-
}
|
|
19
|
+
match: /.+[.!?]$/,
|
|
20
|
+
action: async () => Promise.resolve(OK),
|
|
90
21
|
},
|
|
91
22
|
feature: {
|
|
92
|
-
|
|
93
|
-
action: async (
|
|
94
|
-
this.getWorld().shared.set('feature', feature);
|
|
95
|
-
return await this.maybeSay(featureStep.in);
|
|
96
|
-
},
|
|
23
|
+
gwta: 'Feature: {feature}',
|
|
24
|
+
action: async () => Promise.resolve(OK),
|
|
97
25
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
action: async (
|
|
101
|
-
this.getWorld().shared.set('scenario', scenario);
|
|
102
|
-
return await this.maybeSay(featureStep.in);
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
startStepDelay: {
|
|
106
|
-
gwta: 'step delay of (?<ms>.+)ms',
|
|
107
|
-
action: async ({ ms }) => {
|
|
108
|
-
this.getWorld().options[STEP_DELAY] = parseInt(ms, 10);
|
|
109
|
-
return Promise.resolve(OK);
|
|
110
|
-
},
|
|
26
|
+
scenario: {
|
|
27
|
+
gwta: 'Scenario: {scenario}',
|
|
28
|
+
action: async () => Promise.resolve(OK),
|
|
111
29
|
},
|
|
112
30
|
not: {
|
|
113
|
-
gwta:
|
|
114
|
-
action: async ({ what }) => {
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
31
|
+
gwta: 'not {what:statement}',
|
|
32
|
+
action: async ({ what }, featureStep) => {
|
|
33
|
+
const list = what;
|
|
34
|
+
let last;
|
|
35
|
+
for (let i = 0; i < list.length; i++) {
|
|
36
|
+
const nested = { ...list[i], seqPath: [...featureStep.seqPath, i + 1] };
|
|
37
|
+
last = await doExecuteFeatureSteps([nested], this.steppers, this.getWorld(), ExecMode.NO_CYCLES);
|
|
38
|
+
this.getWorld().runtime.stepResults.push(last);
|
|
39
|
+
if (!last.ok)
|
|
40
|
+
break;
|
|
119
41
|
}
|
|
120
|
-
|
|
42
|
+
if (!last)
|
|
43
|
+
return actionNotOK('not statement empty');
|
|
44
|
+
return last.ok ? actionNotOK('not statement was true') : OK;
|
|
121
45
|
},
|
|
122
|
-
checkAction: async ({ what }) => {
|
|
123
|
-
const whatStep = await this.getNotWhat(what);
|
|
124
|
-
return !!whatStep;
|
|
125
|
-
}
|
|
126
46
|
},
|
|
127
47
|
if: {
|
|
128
|
-
gwta:
|
|
48
|
+
gwta: 'if {when:statement}, {what:statement}',
|
|
129
49
|
action: async ({ when, what }, featureStep) => {
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return
|
|
50
|
+
const whenList = Array.isArray(when) ? when : [];
|
|
51
|
+
const whenNested = whenList.map((s, i) => ({ ...s, seqPath: [...featureStep.seqPath, i + 1] }));
|
|
52
|
+
const whenResult = await doExecuteFeatureSteps(whenNested, this.steppers, this.getWorld(), ExecMode.NO_CYCLES);
|
|
53
|
+
if (!whenResult.ok)
|
|
54
|
+
return OK;
|
|
55
|
+
const whatList = Array.isArray(what) ? what : [];
|
|
56
|
+
const offset = whenNested.length + 1;
|
|
57
|
+
let accumulatedOK = true;
|
|
58
|
+
for (let i = 0; i < whatList.length; i++) {
|
|
59
|
+
const nested = { ...whatList[i], seqPath: [...featureStep.seqPath, offset + i] };
|
|
60
|
+
const res = await doExecuteFeatureSteps([nested], this.steppers, this.getWorld(), ExecMode.CYCLES);
|
|
61
|
+
if (!res.ok) {
|
|
62
|
+
accumulatedOK = false;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
135
65
|
}
|
|
136
|
-
return
|
|
66
|
+
return accumulatedOK ? OK : actionNotOK('if body failed');
|
|
137
67
|
},
|
|
138
|
-
checkAction: async ({ when, what }, featureStep) => {
|
|
139
|
-
const { whenSteps, whatSteps } = await this.getWhenWhat(when, what, featureStep.seq);
|
|
140
|
-
return !!(whenSteps && whatSteps);
|
|
141
|
-
}
|
|
142
68
|
},
|
|
143
|
-
|
|
144
|
-
gwta:
|
|
145
|
-
action:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
return Promise.resolve(actionNotOK('ends with not ok'));
|
|
69
|
+
startStepDelay: {
|
|
70
|
+
gwta: 'step delay of {ms:number}ms',
|
|
71
|
+
action: ({ ms }) => {
|
|
72
|
+
this.getWorld().options[STEP_DELAY] = ms;
|
|
73
|
+
return OK;
|
|
150
74
|
},
|
|
151
|
-
|
|
152
|
-
|
|
75
|
+
},
|
|
76
|
+
endsWith: {
|
|
77
|
+
gwta: 'ends with {result}',
|
|
78
|
+
action: ({ result }) => (String(result).toUpperCase() === 'OK' ? actionOK({ messageContext: endExecutonContext }) : actionNotOK('ends with not ok')),
|
|
79
|
+
checkAction: ({ result }) => {
|
|
80
|
+
if (['OK', 'NOT OK'].includes((result.toUpperCase())))
|
|
153
81
|
return true;
|
|
154
|
-
}
|
|
155
82
|
throw Error('must be "OK" or "not OK"');
|
|
156
|
-
}
|
|
83
|
+
}
|
|
157
84
|
},
|
|
158
85
|
showSteps: {
|
|
159
86
|
exact: 'show steppers',
|
|
160
|
-
action:
|
|
87
|
+
action: () => {
|
|
161
88
|
const allSteppers = formattedSteppers(this.steppers);
|
|
162
89
|
this.world?.logger.info(`Steppers: ${JSON.stringify(allSteppers, null, 2)}`);
|
|
163
|
-
return
|
|
164
|
-
}
|
|
90
|
+
return actionOK({ messageContext: { incident: EExecutionMessageType.ACTION, incidentDetails: { steppers: allSteppers } } });
|
|
91
|
+
},
|
|
165
92
|
},
|
|
166
93
|
until: {
|
|
167
94
|
gwta: 'until {what} is {value}',
|
|
168
|
-
action: async ({ what, value }) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
return Promise.resolve(OK);
|
|
173
|
-
},
|
|
95
|
+
action: async ({ what, value }) => { const key = String(what); while (this.getWorld().shared.get(key) !== value) {
|
|
96
|
+
await sleep(100);
|
|
97
|
+
} return OK; },
|
|
174
98
|
},
|
|
175
99
|
pauseSeconds: {
|
|
176
|
-
gwta: 'pause for {ms}s',
|
|
177
|
-
action: async ({ ms }) => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
100
|
+
gwta: 'pause for {ms:number}s',
|
|
101
|
+
action: async ({ ms }) => { await sleep(ms * 1000); return OK; },
|
|
102
|
+
},
|
|
103
|
+
showDomains: {
|
|
104
|
+
gwta: 'show domains',
|
|
105
|
+
action: () => {
|
|
106
|
+
this.getWorld().logger.info(`Domains: ${JSON.stringify(this.getWorld().domains, null, 2)}`);
|
|
107
|
+
return OK;
|
|
108
|
+
}
|
|
182
109
|
},
|
|
183
110
|
comment: {
|
|
184
111
|
gwta: ';;{comment}',
|
|
185
|
-
action:
|
|
186
|
-
return Promise.resolve(OK);
|
|
187
|
-
},
|
|
112
|
+
action: () => OK,
|
|
188
113
|
},
|
|
189
114
|
afterEveryStepper: {
|
|
190
115
|
gwta: 'after every {stepperName}, {line}',
|
|
191
|
-
action:
|
|
192
|
-
return Promise.resolve(OK);
|
|
193
|
-
},
|
|
116
|
+
action: () => OK,
|
|
194
117
|
applyEffect: async ({ stepperName, line }, currentFeatureStep, steppers) => {
|
|
195
|
-
const newSteps = [];
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const newFeatureStep = await this.newFeatureFromEffect(line, currentFeatureStep.seq + 0.1, steppers);
|
|
118
|
+
const newSteps = [currentFeatureStep];
|
|
119
|
+
if (typeof stepperName === 'string' && currentFeatureStep.action.stepperName === stepperName) {
|
|
120
|
+
const newFeatureStep = await this.newFeatureFromEffect(String(line), currentFeatureStep.seqPath, steppers);
|
|
199
121
|
newSteps.push(newFeatureStep);
|
|
200
122
|
}
|
|
201
123
|
return newSteps;
|
|
202
|
-
}
|
|
124
|
+
},
|
|
203
125
|
},
|
|
204
126
|
};
|
|
205
|
-
async
|
|
206
|
-
if (!this.ttsCmd) {
|
|
207
|
-
return OK;
|
|
208
|
-
}
|
|
209
|
-
const dir = captureLocator(this.world.options, this.world.tag);
|
|
210
|
-
const { path, durationS } = await copyPreRenderedAudio(dir, this.renderedAudio, transcript);
|
|
211
|
-
const runtimePath = resolve(dir);
|
|
212
|
-
const artifact = { artifactType: 'speech', path, durationS, transcript };
|
|
213
|
-
if (this.ttsPlay) {
|
|
214
|
-
const playCmd = this.ttsPlay.replace(/@WHAT@/g, `"${runtimePath}/${path}"`);
|
|
215
|
-
try {
|
|
216
|
-
this.world.logger.log(`playing audio: ${playCmd}`);
|
|
217
|
-
await playAudioFile(playCmd);
|
|
218
|
-
}
|
|
219
|
-
catch (error) {
|
|
220
|
-
const stderr = error.stderr ? error.stderr.toString() : '';
|
|
221
|
-
this.world.logger.error(`Error playing audio using ${playCmd}: ${error.message}\nOutput: ${stderr}`);
|
|
222
|
-
return actionNotOK(`Error playing audio: ${error.message}\nOutput: ${stderr}`);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
await sleep(durationS * 1000);
|
|
227
|
-
}
|
|
228
|
-
return actionOK({ artifact });
|
|
229
|
-
}
|
|
230
|
-
async getWhenWhat(when, what, seq) {
|
|
231
|
-
const whenSteps = await findFeatureStepsFromStatement(when, this.steppers, this.getWorld(), '<Haibun.if-when>');
|
|
232
|
-
const whatSteps = await findFeatureStepsFromStatement(what, this.steppers, this.getWorld(), '<Haibun.if-what>', seq + 1, .1);
|
|
233
|
-
return { whenSteps, whatSteps };
|
|
234
|
-
}
|
|
235
|
-
async getNotWhat(what) {
|
|
236
|
-
return await findFeatureStepsFromStatement(what, this.steppers, this.getWorld(), '<Haibun.not>');
|
|
237
|
-
}
|
|
238
|
-
async newFeatureFromEffect(content, seq, steppers) {
|
|
127
|
+
async newFeatureFromEffect(content, parentSeqPath, steppers) {
|
|
239
128
|
const features = asFeatures([{ path: `resolved from ${content}`, content }]);
|
|
240
129
|
const expandedFeatures = await expand({ backgrounds: [], features });
|
|
241
130
|
const featureSteps = await new Resolver(steppers).findFeatureSteps(expandedFeatures[0]);
|
|
242
|
-
return { ...featureSteps[0],
|
|
131
|
+
return { ...featureSteps[0], seqPath: [...parentSeqPath, 1] };
|
|
243
132
|
}
|
|
244
133
|
}
|
|
245
134
|
export default Haibun;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"haibun.js","sourceRoot":"","sources":["../../src/steps/haibun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"haibun.js","sourceRoot":"","sources":["../../src/steps/haibun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAgB,UAAU,EAAqB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAA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AC,CAAC,EAAE,IAAI,EAAE,iBAAiB,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QAC7E,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrE,MAAM,YAAY,GAAG,MAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;QACxF,OAAO,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC;IAC/D,CAAC;CACD;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { TWorld, TFeatureStep, IStepperCycles, TStepArgs } from '../lib/defs.js';
|
|
2
|
+
import { IHasCycles, IHasOptions } from '../lib/astepper.js';
|
|
3
|
+
import { AStepper } from '../lib/astepper.js';
|
|
4
|
+
import { TRenderedAudioMap } from './lib/tts.js';
|
|
5
|
+
declare class Narrator extends AStepper implements IHasOptions, IHasCycles {
|
|
6
|
+
renderedAudio: TRenderedAudioMap;
|
|
7
|
+
options: {
|
|
8
|
+
TTS_CMD: {
|
|
9
|
+
desc: string;
|
|
10
|
+
parse: (input: string) => {
|
|
11
|
+
parseError: string;
|
|
12
|
+
result?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
result: string;
|
|
15
|
+
parseError?: undefined;
|
|
16
|
+
};
|
|
17
|
+
required: boolean;
|
|
18
|
+
};
|
|
19
|
+
TTS_PLAY: {
|
|
20
|
+
desc: string;
|
|
21
|
+
parse: (input: string) => {
|
|
22
|
+
parseError: string;
|
|
23
|
+
result?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
result: string;
|
|
26
|
+
parseError?: undefined;
|
|
27
|
+
};
|
|
28
|
+
required: boolean;
|
|
29
|
+
};
|
|
30
|
+
CAPTURE_START: {
|
|
31
|
+
desc: string;
|
|
32
|
+
parse: (input: string) => {
|
|
33
|
+
parseError: string;
|
|
34
|
+
result?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
result: string;
|
|
37
|
+
parseError?: undefined;
|
|
38
|
+
};
|
|
39
|
+
required: boolean;
|
|
40
|
+
};
|
|
41
|
+
CAPTURE_STOP: {
|
|
42
|
+
desc: string;
|
|
43
|
+
parse: (input: string) => {
|
|
44
|
+
parseError: string;
|
|
45
|
+
result?: undefined;
|
|
46
|
+
} | {
|
|
47
|
+
result: string;
|
|
48
|
+
parseError?: undefined;
|
|
49
|
+
};
|
|
50
|
+
required: boolean;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
cycles: IStepperCycles;
|
|
54
|
+
steppers: AStepper[];
|
|
55
|
+
ttsCmd: string | undefined;
|
|
56
|
+
ttsPlay: string | undefined;
|
|
57
|
+
captureStart: string | undefined;
|
|
58
|
+
captureStop: string | undefined;
|
|
59
|
+
setWorld(world: TWorld, steppers: AStepper[]): Promise<void>;
|
|
60
|
+
private rememberAndSay;
|
|
61
|
+
steps: {
|
|
62
|
+
prose: {
|
|
63
|
+
precludes: string[];
|
|
64
|
+
match: RegExp;
|
|
65
|
+
action: (_args: TStepArgs, featureStep: TFeatureStep) => Promise<import("../lib/defs.js").TNotOKActionResult | import("../lib/defs.js").TOKActionResult>;
|
|
66
|
+
};
|
|
67
|
+
feature: {
|
|
68
|
+
precludes: string[];
|
|
69
|
+
gwta: string;
|
|
70
|
+
action: ({ feature }: TStepArgs, featureStep: TFeatureStep) => Promise<import("../lib/defs.js").TNotOKActionResult | import("../lib/defs.js").TOKActionResult>;
|
|
71
|
+
};
|
|
72
|
+
scenario: {
|
|
73
|
+
precludes: string[];
|
|
74
|
+
gwta: string;
|
|
75
|
+
action: ({ scenario }: TStepArgs, featureStep: TFeatureStep) => Promise<import("../lib/defs.js").TNotOKActionResult | import("../lib/defs.js").TOKActionResult>;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
maybeSay(transcript: string): Promise<import("../lib/defs.js").TNotOKActionResult | import("../lib/defs.js").TOKActionResult>;
|
|
79
|
+
}
|
|
80
|
+
export default Narrator;
|
|
81
|
+
//# sourceMappingURL=narrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"narrator.d.ts","sourceRoot":"","sources":["../../src/steps/narrator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAM,MAAM,EAAE,YAAY,EAAE,cAAc,EAAiB,SAAS,EAAU,MAAM,gBAAgB,CAAC;AAC5G,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,OAAO,EAA+E,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA8B9H,cAAM,QAAS,SAAQ,QAAS,YAAW,WAAW,EAAE,UAAU;IACjE,aAAa,EAAE,iBAAiB,CAAM;IACtC,OAAO;;;2BACuG,MAAM;;;;;;;;;;;2BAC3B,MAAM;;;;;;;;;;;2BACf,MAAM;;;;;;;;;;;2BACR,MAAM;;;;;;;;;MAClF;IAEF,MAAM,iBAAgB;IACtB,QAAQ,EAAE,QAAQ,EAAE,CAAM;IAC1B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1B,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE;IAQlD,OAAO,CAAC,cAAc;IAKtB,KAAK;;;;4BAImB,SAAS,eAAe,YAAY;;;;;kCAK9B,SAAS,eAAe,YAAY;;;;;mCAKnC,SAAS,eAAe,YAAY;;MAEjE;IAEI,QAAQ,CAAC,UAAU,EAAE,MAAM;CAuBjC;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { OK, Origin } from '../lib/defs.js';
|
|
3
|
+
import { AStepper } from '../lib/astepper.js';
|
|
4
|
+
import { actionNotOK, actionOK, getStepperOption, sleep, stringOrError } from '../lib/util/index.js';
|
|
5
|
+
import { actualURI } from '../lib/util/actualURI.js';
|
|
6
|
+
import { copyPreRenderedAudio, doExec, doSpawn, playAudioFile, preRenderFeatureProse } from './lib/tts.js';
|
|
7
|
+
import { EExecutionMessageType } from '../lib/interfaces/logger.js';
|
|
8
|
+
import { captureLocator } from '../lib/capture-locator.js';
|
|
9
|
+
const CAPTURE_FILENAME = 'vcapture.webm';
|
|
10
|
+
const cycles = (narrator) => ({
|
|
11
|
+
async startFeature({ resolvedFeature }) {
|
|
12
|
+
if (narrator.ttsCmd) {
|
|
13
|
+
narrator.renderedAudio = await preRenderFeatureProse(resolvedFeature, narrator.ttsCmd, narrator.world.logger);
|
|
14
|
+
}
|
|
15
|
+
if (narrator.captureStart) {
|
|
16
|
+
narrator.getWorld().logger.debug(`Spawning screen capture using ${narrator.captureStart}`);
|
|
17
|
+
doSpawn(narrator.captureStart);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
async endFeature() {
|
|
21
|
+
if (narrator.captureStop) {
|
|
22
|
+
const uri = actualURI(CAPTURE_FILENAME);
|
|
23
|
+
narrator.getWorld().logger.info(`Stopping vcapture ${uri} using ${narrator.captureStop}`);
|
|
24
|
+
await sleep(2000);
|
|
25
|
+
await doExec(narrator.captureStop, false);
|
|
26
|
+
const path = captureLocator(narrator.world.options, narrator.world.tag);
|
|
27
|
+
const artifact = { artifactType: 'video', path };
|
|
28
|
+
const context = { incident: EExecutionMessageType.FEATURE_END, artifacts: [artifact], tag: narrator.getWorld().tag };
|
|
29
|
+
narrator.getWorld().logger.log('feature video', context);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
class Narrator extends AStepper {
|
|
34
|
+
renderedAudio = {};
|
|
35
|
+
options = {
|
|
36
|
+
TTS_CMD: { desc: 'TTS command that accepts text as @WHAT@ and returns a full path to stdout', parse: (input) => stringOrError(input), required: false },
|
|
37
|
+
TTS_PLAY: { desc: 'Shell command that plays an audio file using @WHAT@', parse: (input) => stringOrError(input), required: false },
|
|
38
|
+
CAPTURE_START: { desc: 'Shell command to start screen capture', parse: (input) => stringOrError(input), required: false },
|
|
39
|
+
CAPTURE_STOP: { desc: 'Shell command to stop screen capture', parse: (input) => stringOrError(input), required: false },
|
|
40
|
+
};
|
|
41
|
+
cycles = cycles(this);
|
|
42
|
+
steppers = [];
|
|
43
|
+
ttsCmd;
|
|
44
|
+
ttsPlay;
|
|
45
|
+
captureStart;
|
|
46
|
+
captureStop;
|
|
47
|
+
async setWorld(world, steppers) {
|
|
48
|
+
await super.setWorld(world, steppers);
|
|
49
|
+
this.ttsCmd = getStepperOption(this, 'TTS_CMD', world.moduleOptions);
|
|
50
|
+
this.ttsPlay = getStepperOption(this, 'TTS_PLAY', world.moduleOptions);
|
|
51
|
+
this.captureStart = getStepperOption(this, 'CAPTURE_START', world.moduleOptions);
|
|
52
|
+
this.captureStop = getStepperOption(this, 'CAPTURE_STOP', world.moduleOptions);
|
|
53
|
+
}
|
|
54
|
+
rememberAndSay(key, value, featureStep) {
|
|
55
|
+
this.getWorld().shared.set({ term: key, value, domain: 'string', origin: Origin.fallthrough }, { in: featureStep.in, seq: featureStep.seqPath, when: `${featureStep.action.stepperName}.${featureStep.action.actionName}` });
|
|
56
|
+
return this.maybeSay(value);
|
|
57
|
+
}
|
|
58
|
+
steps = {
|
|
59
|
+
prose: {
|
|
60
|
+
precludes: [`Haibun.prose`],
|
|
61
|
+
match: /.+[.!?]$/,
|
|
62
|
+
action: async (_args, featureStep) => this.maybeSay(featureStep.in),
|
|
63
|
+
},
|
|
64
|
+
feature: {
|
|
65
|
+
precludes: [`Haibun.feature`],
|
|
66
|
+
gwta: 'Feature: {feature}',
|
|
67
|
+
action: async ({ feature }, featureStep) => this.rememberAndSay('feature', feature, featureStep),
|
|
68
|
+
},
|
|
69
|
+
scenario: {
|
|
70
|
+
precludes: [`Haibun.scenario`],
|
|
71
|
+
gwta: 'Scenario: {scenario}',
|
|
72
|
+
action: async ({ scenario }, featureStep) => this.rememberAndSay('scenario', scenario, featureStep),
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
async maybeSay(transcript) {
|
|
76
|
+
if (!this.ttsCmd)
|
|
77
|
+
return OK;
|
|
78
|
+
const dir = captureLocator(this.world.options, this.world.tag);
|
|
79
|
+
const { path, durationS } = await copyPreRenderedAudio(dir, this.renderedAudio, transcript);
|
|
80
|
+
const runtimePath = resolve(dir);
|
|
81
|
+
const artifact = { artifactType: 'speech', path, durationS, transcript };
|
|
82
|
+
if (this.ttsPlay) {
|
|
83
|
+
const playCmd = this.ttsPlay.replace(/@WHAT@/g, `"${runtimePath}/${path}"`);
|
|
84
|
+
try {
|
|
85
|
+
this.world.logger.log(`playing audio: ${playCmd}`);
|
|
86
|
+
await playAudioFile(playCmd);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
const e = error;
|
|
90
|
+
const stderr = e.stderr ? String(e.stderr) : '';
|
|
91
|
+
this.world.logger.error(`Error playing audio using ${playCmd}: ${e.message}\nOutput: ${stderr}`);
|
|
92
|
+
return actionNotOK(`Error playing audio: ${e.message}\nOutput: ${stderr}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
await sleep(durationS * 1000);
|
|
97
|
+
}
|
|
98
|
+
return actionOK({ artifact });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export default Narrator;
|
|
102
|
+
//# sourceMappingURL=narrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"narrator.js","sourceRoot":"","sources":["../../src/steps/narrator.ts"],"names":[],"mappings":"AAAA,OAAO,EA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,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;QAC1F,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,WAAW,IAAI,IAAI,GAAG,CAAC,CAAC;YAC5E,IAAI,CAAC;gBACJ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAC;gBACnD,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC;YAC9B,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACzB,MAAM,CAAC,GAAG,KAA8C,CAAC;gBACzD,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,OAAO,KAAK,CAAC,CAAC,OAAO,aAAa,MAAM,EAAE,CAAC,CAAC;gBACjG,OAAO,WAAW,CAAC,wBAAwB,CAAC,CAAC,OAAO,aAAa,MAAM,EAAE,CAAC,CAAC;YAC5E,CAAC;QACF,CAAC;aAAM,CAAC;YACP,MAAM,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC/B,CAAC;CAED;AAED,eAAe,QAAQ,CAAC"}
|
package/build/steps/parse.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare const Parse: {
|
|
|
12
12
|
};
|
|
13
13
|
conformance: {
|
|
14
14
|
gwta: string;
|
|
15
|
-
action: () => Promise<import("../lib/defs.js").
|
|
15
|
+
action: () => Promise<import("../lib/defs.js").TNotOKActionResult | import("../lib/defs.js").TOKActionResult>;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
world?: import("../lib/defs.js").TWorld;
|