agent-state-machine 1.3.2 → 1.3.3

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/README.md CHANGED
@@ -101,8 +101,8 @@ export default async function() {
101
101
  console.log('Starting project-builder workflow...');
102
102
 
103
103
  // Example: Get user input (saved to memory)
104
- const answer = await initialPrompt('Where do you live?');
105
- console.log('Example prompt answer:', answer);
104
+ const userLocation = await initialPrompt('Where do you live?');
105
+ console.log('Example prompt answer:', userLocation);
106
106
 
107
107
  const userInfo = await agent('yoda-name-collector');
108
108
  memory.userInfo = userInfo;
@@ -113,7 +113,7 @@ export default async function() {
113
113
  console.log('Example agent memory.userInfo:', memory.userInfo || userInfo);
114
114
 
115
115
  // Context is provided automatically
116
- const { greeting } = await agent('yoda-greeter');
116
+ const { greeting } = await agent('yoda-greeter', { userLocation });
117
117
  console.log('Example agent greeting:', greeting);
118
118
 
119
119
  // Or you can provide context manually
@@ -342,13 +342,10 @@ async function handleInteraction(runtime, interaction) {
342
342
  const filePath = path.join(runtime.interactionsDir, `${slug}.md`);
343
343
 
344
344
  // Create interaction file
345
- const fileContent = `# ${slug}
345
+ const fileContent = `<!-- Note: Edit this file directly and press 'y' in the terminal when finished. Safe to clear this file. -->
346
+ # ${slug}
346
347
 
347
348
  ${content}
348
-
349
- ---
350
- Enter your response below:
351
-
352
349
  `;
353
350
 
354
351
  fs.writeFileSync(filePath, fileContent);
@@ -56,13 +56,10 @@ export async function initialPrompt(question, options = {}) {
56
56
  // Non-TTY mode - create interaction file and wait inline
57
57
  const interactionFile = path.join(runtime.interactionsDir, `${slug}.md`);
58
58
 
59
- const fileContent = `# ${slug}
59
+ const fileContent = `<!-- Note: Edit this file directly and press 'y' in the terminal when finished. Safe to clear this file. -->
60
+ # ${slug}
60
61
 
61
62
  ${question}
62
-
63
- ---
64
- Enter your response below:
65
-
66
63
  `;
67
64
 
68
65
  fs.writeFileSync(interactionFile, fileContent);
@@ -252,17 +252,10 @@ export class WorkflowRuntime {
252
252
  }
253
253
 
254
254
  const content = fs.readFileSync(filePath, 'utf-8');
255
+ const response = content.trim();
255
256
 
256
- // Extract response after separator line
257
- const separator = '---';
258
- const parts = content.split(separator);
259
- if (parts.length < 2) {
260
- throw new Error(`Interaction file missing separator: ${filePath}`);
261
- }
262
-
263
- const response = parts.slice(1).join(separator).trim();
264
- if (!response || response === 'Enter your response below:') {
265
- throw new Error(`Interaction response is empty. Please fill in: ${filePath}`);
257
+ if (!response) {
258
+ throw new Error(`Interaction file is empty: ${filePath}`);
266
259
  }
267
260
 
268
261
  // Store in memory for reference
@@ -380,3 +373,7 @@ export class WorkflowRuntime {
380
373
  console.log(`\n✓ Workflow '${this.workflowName}' hard reset (history and interactions cleared)`);
381
374
  }
382
375
  }
376
+
377
+ function escapeRegExp(string) {
378
+ return string.replace(/[.*+?^${}()|[\\]/g, '\\$&'); // $& means the whole matched string
379
+ }
package/lib/setup.js CHANGED
@@ -80,8 +80,8 @@ export default async function() {
80
80
  console.log('Starting ${workflowName} workflow...');
81
81
 
82
82
  // Example: Get user input (saved to memory)
83
- const answer = await initialPrompt('Where do you live?');
84
- console.log('Example prompt answer:', answer);
83
+ const userLocation = await initialPrompt('Where do you live?');
84
+ console.log('Example prompt answer:', userLocation);
85
85
 
86
86
  const userInfo = await agent('yoda-name-collector');
87
87
  memory.userInfo = userInfo;
@@ -92,7 +92,7 @@ export default async function() {
92
92
  console.log('Example agent memory.userInfo:', memory.userInfo || userInfo);
93
93
 
94
94
  // Context is provided automatically
95
- const { greeting } = await agent('yoda-greeter');
95
+ const { greeting } = await agent('yoda-greeter', { userLocation });
96
96
  console.log('Example agent greeting:', greeting);
97
97
 
98
98
  // Or you can provide context manually
@@ -171,7 +171,7 @@ output: greeting
171
171
 
172
172
  # Greeting Task
173
173
 
174
- Generate a friendly greeting for {{name}} in a yoda style. Prompt user for their actual {{name}} if you dont have it.
174
+ Generate a friendly greeting for {{name}} from {{location}} in a yoda style. Prompt user for their actual {{name}} if you dont have it.
175
175
 
176
176
  Once you have it create a yoda-greeting.md file in root dir with the greeting.
177
177
 
@@ -345,8 +345,8 @@ export default async function() {
345
345
  console.log('Starting project-builder workflow...');
346
346
 
347
347
  // Example: Get user input (saved to memory)
348
- const answer = await initialPrompt('Where do you live?');
349
- console.log('Example prompt answer:', answer);
348
+ const userLocation = await initialPrompt('Where do you live?');
349
+ console.log('Example prompt answer:', userLocation);
350
350
 
351
351
  const userInfo = await agent('yoda-name-collector');
352
352
  memory.userInfo = userInfo;
@@ -357,7 +357,7 @@ export default async function() {
357
357
  console.log('Example agent memory.userInfo:', memory.userInfo || userInfo);
358
358
 
359
359
  // Context is provided automatically
360
- const { greeting } = await agent('yoda-greeter');
360
+ const { greeting } = await agent('yoda-greeter', { userLocation });
361
361
  console.log('Example agent greeting:', greeting);
362
362
 
363
363
  // Or you can provide context manually
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-state-machine",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "type": "module",
5
5
  "description": "A workflow orchestrator for running agents and scripts in sequence with state management",
6
6
  "main": "lib/index.js",