agent-state-machine 2.1.0 → 2.1.2

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.
@@ -42,12 +42,12 @@ export async function askHuman(question, options = {}) {
42
42
  event: 'PROMPT_REQUESTED',
43
43
  slug,
44
44
  targetKey: memoryKey,
45
- question: prompt,
46
45
  type: interaction?.type || 'text',
47
46
  prompt,
48
47
  options: interaction?.options,
49
48
  allowCustom: interaction?.allowCustom,
50
49
  multiSelect: interaction?.multiSelect,
50
+ placeholder: interaction?.placeholder,
51
51
  validation: interaction?.validation,
52
52
  confirmLabel: interaction?.confirmLabel,
53
53
  cancelLabel: interaction?.cancelLabel,
@@ -57,7 +57,7 @@ export async function askHuman(question, options = {}) {
57
57
  // Check if we're in TTY mode (interactive terminal)
58
58
  if (process.stdin.isTTY && process.stdout.isTTY) {
59
59
  // Interactive mode - prompt directly, with remote support
60
- const answer = await askQuestionWithRemote(runtime, question, slug, memoryKey);
60
+ const answer = await askQuestionWithRemote(runtime, question, slug, memoryKey, interaction);
61
61
  console.log('');
62
62
 
63
63
  const normalizedAnswer = normalizePromptAnswer(answer);
@@ -115,7 +115,7 @@ ${question}
115
115
  * Interactive terminal question with remote support
116
116
  * Allows both local TTY input and remote browser responses
117
117
  */
118
- function askQuestionWithRemote(runtime, question, slug, memoryKey) {
118
+ function askQuestionWithRemote(runtime, question, slug, memoryKey, interaction = null) {
119
119
  return new Promise((resolve) => {
120
120
  let resolved = false;
121
121
 
@@ -146,13 +146,33 @@ function askQuestionWithRemote(runtime, question, slug, memoryKey) {
146
146
  });
147
147
 
148
148
  // Show remote URL if available
149
- let prompt = `\n${C.cyan}${C.bold}${question}${C.reset}`;
149
+ let promptText = `\n${C.cyan}${C.bold}${question}${C.reset}`;
150
+
151
+ // Show placeholder if provided
152
+ if (interaction?.placeholder) {
153
+ promptText += `\n${C.dim}(e.g., ${interaction.placeholder})${C.reset}`;
154
+ }
155
+
156
+ // Show validation hints if provided
157
+ if (interaction?.validation) {
158
+ const hints = [];
159
+ if (interaction.validation.minLength) {
160
+ hints.push(`min ${interaction.validation.minLength} chars`);
161
+ }
162
+ if (interaction.validation.maxLength) {
163
+ hints.push(`max ${interaction.validation.maxLength} chars`);
164
+ }
165
+ if (hints.length > 0) {
166
+ promptText += `\n${C.dim}[${hints.join(', ')}]${C.reset}`;
167
+ }
168
+ }
169
+
150
170
  if (runtime.remoteEnabled && runtime.remoteUrl) {
151
- prompt += `\n${C.dim}(Remote: ${runtime.remoteUrl})${C.reset}`;
171
+ promptText += `\n${C.dim}(Remote: ${runtime.remoteUrl})${C.reset}`;
152
172
  }
153
- prompt += `\n${C.yellow}> ${C.reset}`;
173
+ promptText += `\n${C.yellow}> ${C.reset}`;
154
174
 
155
- rl.question(prompt, (answer) => {
175
+ rl.question(promptText, (answer) => {
156
176
  if (resolved) return;
157
177
  cleanup();
158
178
  rl.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-state-machine",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
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",
@@ -25,7 +25,7 @@ import {
25
25
  import {
26
26
  createInteraction,
27
27
  parseResponse,
28
- formatPrompt
28
+ formatInteractionPrompt as formatPrompt
29
29
  } from './scripts/interaction-helpers.js';
30
30
 
31
31
  // Derive workflow directory dynamically