agent-state-machine 1.2.0 → 1.3.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/README.md CHANGED
@@ -120,11 +120,16 @@ export default async function() {
120
120
  // await agent('yoda-greeter', userInfo);
121
121
 
122
122
  // Example: Parallel execution
123
- // const [a, b] = await parallel([
124
- // agent('example', { which: 'a' }),
125
- // agent('example', { which: 'b' })
123
+ // const [a, b, c] = await parallel([
124
+ // agent('yoda-greeter', { name: 'the names augustus but friends call me gus' }),
125
+ // agent('yoda-greeter', { name: 'uriah' }),
126
+ // agent('yoda-greeter', { name: 'lucas' })
126
127
  // ]);
127
128
 
129
+ // console.log('a: ' + JSON.stringify(a))
130
+ // console.log('b: ' + JSON.stringify(b))
131
+ // console.log('c: ' + JSON.stringify(c))
132
+
128
133
  notify(['project-builder', userInfo.name || userInfo + ' has been greeted!']);
129
134
 
130
135
  console.log('Workflow completed!');
@@ -356,7 +356,8 @@ Enter your response below:
356
356
  runtime.prependHistory({
357
357
  event: 'INTERACTION_REQUESTED',
358
358
  slug,
359
- targetKey
359
+ targetKey,
360
+ question: content
360
361
  });
361
362
 
362
363
  // Block and wait for user input (instead of throwing)
@@ -71,7 +71,8 @@ Enter your response below:
71
71
  event: 'INTERACTION_REQUESTED',
72
72
  slug,
73
73
  targetKey: memoryKey,
74
- file: interactionFile
74
+ file: interactionFile,
75
+ question
75
76
  });
76
77
 
77
78
  // Block and wait for user input (instead of throwing)
package/lib/setup.js CHANGED
@@ -99,11 +99,16 @@ export default async function() {
99
99
  // await agent('yoda-greeter', userInfo);
100
100
 
101
101
  // Example: Parallel execution
102
- // const [a, b] = await parallel([
103
- // agent('example', { which: 'a' }),
104
- // agent('example', { which: 'b' })
102
+ // const [a, b, c] = await parallel([
103
+ // agent('yoda-greeter', { name: 'the names augustus but friends call me gus' }),
104
+ // agent('yoda-greeter', { name: 'uriah' }),
105
+ // agent('yoda-greeter', { name: 'lucas' })
105
106
  // ]);
106
107
 
108
+ // console.log('a: ' + JSON.stringify(a))
109
+ // console.log('b: ' + JSON.stringify(b))
110
+ // console.log('c: ' + JSON.stringify(c))
111
+
107
112
  notify(['${workflowName}', userInfo.name || userInfo + ' has been greeted!']);
108
113
 
109
114
  console.log('Workflow completed!');
@@ -354,11 +359,16 @@ export default async function() {
354
359
  // await agent('yoda-greeter', userInfo);
355
360
 
356
361
  // Example: Parallel execution
357
- // const [a, b] = await parallel([
358
- // agent('example', { which: 'a' }),
359
- // agent('example', { which: 'b' })
362
+ // const [a, b, c] = await parallel([
363
+ // agent('yoda-greeter', { name: 'the names augustus but friends call me gus' }),
364
+ // agent('yoda-greeter', { name: 'uriah' }),
365
+ // agent('yoda-greeter', { name: 'lucas' })
360
366
  // ]);
361
367
 
368
+ // console.log('a: ' + JSON.stringify(a))
369
+ // console.log('b: ' + JSON.stringify(b))
370
+ // console.log('c: ' + JSON.stringify(c))
371
+
362
372
  notify(['project-builder', userInfo.name || userInfo + ' has been greeted!']);
363
373
 
364
374
  console.log('Workflow completed!');
package/lib/ui/index.html CHANGED
@@ -138,14 +138,9 @@
138
138
  </div>
139
139
  );
140
140
 
141
- // Filter for events we want to display
142
- let visibleEvents = history.filter(item =>
143
- [
144
- 'WORKFLOW_STARTED', 'WORKFLOW_COMPLETED', 'WORKFLOW_FAILED', 'WORKFLOW_RESET',
145
- 'AGENT_STARTED', 'AGENT_COMPLETED', 'AGENT_FAILED',
146
- 'INTERACTION_REQUESTED', 'INTERACTION_RESOLVED'
147
- ].includes(item.event)
148
- );
141
+ // Filter for events we want to display - NOW INCLUDES EVERYTHING
142
+ // We only filter out nulls or malformed entries if any
143
+ let visibleEvents = history;
149
144
 
150
145
  // Apply Sort
151
146
  // History from API is "Newest First" (index 0 is latest)
@@ -242,19 +237,40 @@
242
237
  );
243
238
  }
244
239
 
245
- // 4. Interaction Requested
246
- if (item.event === 'INTERACTION_REQUESTED') {
240
+ // 4. Interaction / Prompt Requested
241
+ if (item.event === 'INTERACTION_REQUESTED' || item.event === 'PROMPT_REQUESTED') {
242
+ const isPrompt = item.event === 'PROMPT_REQUESTED';
247
243
  return (
248
244
  <div key={idx} className="flex justify-center">
249
245
  <div className="bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 border-dashed rounded-lg px-6 py-4 text-center max-w-md w-full">
250
- <div className="text-[10px] text-zinc-400 dark:text-zinc-600 uppercase font-bold tracking-widest mb-1">Human Intervention Needed</div>
251
- <div className="text-xs text-zinc-600 dark:text-zinc-400 italic">Waiting for response to "{item.slug}"...</div>
246
+ <div className="text-[10px] text-zinc-400 dark:text-zinc-600 uppercase font-bold tracking-widest mb-1">
247
+ {isPrompt ? 'User Input Requested' : 'Human Intervention Needed'}
248
+ </div>
249
+ <div className="text-xs text-zinc-600 dark:text-zinc-400 italic">
250
+ {item.question ? `"${item.question}"` : `Waiting for response to "${item.slug}"...`}
251
+ </div>
252
+ </div>
253
+ </div>
254
+ );
255
+ }
256
+
257
+ // 5. Prompt Answered
258
+ if (item.event === 'PROMPT_ANSWERED') {
259
+ return (
260
+ <div key={idx} className="flex justify-center">
261
+ <div className="bg-green-50 dark:bg-green-950/20 border border-green-200 dark:border-green-900/50 rounded-lg px-4 py-2 text-center max-w-md w-full">
262
+ <div className="text-[10px] text-green-600 dark:text-green-400 uppercase font-bold tracking-widest mb-1">
263
+ User Answered
264
+ </div>
265
+ <div className="text-xs text-green-700 dark:text-green-300 italic font-medium">
266
+ "{item.answer}"
267
+ </div>
252
268
  </div>
253
269
  </div>
254
270
  );
255
271
  }
256
272
 
257
- // 5. Agent Completed / Interaction Resolved (The Bubbles)
273
+ // 6. Agent Completed / Interaction Resolved (The Bubbles)
258
274
  if (item.event === 'AGENT_COMPLETED' || item.event === 'INTERACTION_RESOLVED') {
259
275
  return (
260
276
  <div key={idx} className="flex flex-col space-y-4">
@@ -304,7 +320,26 @@
304
320
  );
305
321
  }
306
322
 
307
- return null;
323
+ // 7. CATCH-ALL for Unknown Events
324
+ // If we made it here, it's an event we didn't explicitly handle.
325
+ // Render it generically.
326
+ return (
327
+ <div key={idx} className="flex justify-center px-4">
328
+ <div className="bg-gray-100 dark:bg-zinc-900/50 border border-gray-200 dark:border-zinc-800 rounded-lg px-4 py-3 text-xs w-full max-w-2xl font-mono overflow-x-auto">
329
+ <div className="text-[9px] text-gray-400 dark:text-zinc-600 uppercase tracking-widest mb-1 flex justify-between">
330
+ <span>{item.event}</span>
331
+ <span>{formatTime(item.timestamp)}</span>
332
+ </div>
333
+ <div className="text-gray-600 dark:text-zinc-400 whitespace-pre-wrap">
334
+ {JSON.stringify(item, (key, value) => {
335
+ // Exclude redundant keys to keep it clean
336
+ if (key === 'event' || key === 'timestamp') return undefined;
337
+ return value;
338
+ }, 2).replace(/^{|}$/g, '').trim()}
339
+ </div>
340
+ </div>
341
+ </div>
342
+ );
308
343
  })}
309
344
  </div>
310
345
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-state-machine",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
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",