agent-state-machine 2.0.10 → 2.0.11

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.
Files changed (2) hide show
  1. package/bin/cli.js +33 -0
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import path from 'path';
4
4
  import fs from 'fs';
5
+ import readline from 'readline';
5
6
  import { pathToFileURL, fileURLToPath } from 'url';
6
7
  import { WorkflowRuntime } from '../lib/index.js';
7
8
  import { setup } from '../lib/setup.js';
@@ -70,6 +71,28 @@ Workflow Structure:
70
71
  `);
71
72
  }
72
73
 
74
+ async function confirmHardReset(workflowName) {
75
+ if (!process.stdin.isTTY) {
76
+ console.error('Error: Hard reset requires confirmation in a TTY.');
77
+ return false;
78
+ }
79
+
80
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
81
+ const ask = (q) => new Promise((resolve) => rl.question(q, resolve));
82
+ try {
83
+ const answer = String(
84
+ await ask(
85
+ `Hard reset deletes history, interactions, and memory for '${workflowName}'. Type 'y' to continue: `
86
+ )
87
+ )
88
+ .trim()
89
+ .toLowerCase();
90
+ return answer === 'y' || answer === 'yes';
91
+ } finally {
92
+ rl.close();
93
+ }
94
+ }
95
+
73
96
  function workflowsRoot() {
74
97
  return path.join(process.cwd(), 'workflows');
75
98
  }
@@ -327,6 +350,11 @@ async function runOrResume(
327
350
 
328
351
  const runtime = new WorkflowRuntime(workflowDir);
329
352
  if (preResetHard) {
353
+ const confirmed = await confirmHardReset(workflowName);
354
+ if (!confirmed) {
355
+ console.log('Hard reset cancelled.');
356
+ return;
357
+ }
330
358
  runtime.resetHard();
331
359
  } else if (preReset) {
332
360
  runtime.reset();
@@ -478,6 +506,11 @@ async function main() {
478
506
  {
479
507
  const workflowDir = resolveWorkflowDir(workflowName);
480
508
  const runtime = new WorkflowRuntime(workflowDir);
509
+ const confirmed = await confirmHardReset(workflowName);
510
+ if (!confirmed) {
511
+ console.log('Hard reset cancelled.');
512
+ process.exit(0);
513
+ }
481
514
  runtime.resetHard();
482
515
  }
483
516
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-state-machine",
3
- "version": "2.0.10",
3
+ "version": "2.0.11",
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",