agent-state-machine 1.0.2 → 1.0.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 +17 -3
- package/bin/cli.js +21 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,14 +11,28 @@ You write normal `async/await` code. The runtime handles:
|
|
|
11
11
|
|
|
12
12
|
## Install
|
|
13
13
|
|
|
14
|
+
You need to install the package **globally** to get the CLI, and **locally** in your project so your workflow can import the library.
|
|
15
|
+
|
|
16
|
+
### Global CLI
|
|
17
|
+
Provides the `state-machine` command.
|
|
18
|
+
|
|
14
19
|
```bash
|
|
15
|
-
npm
|
|
20
|
+
# npm
|
|
21
|
+
npm i -g agent-state-machine
|
|
22
|
+
|
|
23
|
+
# pnpm
|
|
24
|
+
pnpm add -g agent-state-machine
|
|
16
25
|
```
|
|
17
26
|
|
|
18
|
-
|
|
27
|
+
### Local Library
|
|
28
|
+
Required so your `workflow.js` can `import { agent, memory } from 'agent-state-machine'`.
|
|
19
29
|
|
|
20
30
|
```bash
|
|
21
|
-
npm
|
|
31
|
+
# npm
|
|
32
|
+
npm i agent-state-machine
|
|
33
|
+
|
|
34
|
+
# pnpm (for monorepos/turbo, install in root)
|
|
35
|
+
pnpm add agent-state-machine -w
|
|
22
36
|
```
|
|
23
37
|
|
|
24
38
|
Requirements: Node.js >= 16.
|
package/bin/cli.js
CHANGED
|
@@ -2,16 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import fs from 'fs';
|
|
5
|
-
import { pathToFileURL } from 'url';
|
|
5
|
+
import { pathToFileURL, fileURLToPath } from 'url';
|
|
6
6
|
import { WorkflowRuntime } from '../lib/index.js';
|
|
7
7
|
import { setup } from '../lib/setup.js';
|
|
8
8
|
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
|
|
9
12
|
const args = process.argv.slice(2);
|
|
10
13
|
const command = args[0];
|
|
11
14
|
|
|
15
|
+
function getVersion() {
|
|
16
|
+
try {
|
|
17
|
+
const pkgPath = path.join(__dirname, '../package.json');
|
|
18
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
19
|
+
return pkg.version;
|
|
20
|
+
} catch {
|
|
21
|
+
return 'unknown';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
12
25
|
function printHelp() {
|
|
13
26
|
console.log(`
|
|
14
|
-
Agent State Machine CLI (Native JS Workflows Only)
|
|
27
|
+
Agent State Machine CLI (Native JS Workflows Only) v${getVersion()}
|
|
15
28
|
|
|
16
29
|
Usage:
|
|
17
30
|
state-machine --setup <workflow-name> Create a new workflow project
|
|
@@ -27,6 +40,7 @@ Usage:
|
|
|
27
40
|
Options:
|
|
28
41
|
--setup, -s Initialize a new workflow with directory structure
|
|
29
42
|
--help, -h Show help
|
|
43
|
+
--version, -v Show version
|
|
30
44
|
|
|
31
45
|
Workflow Structure:
|
|
32
46
|
workflows/<name>/
|
|
@@ -143,6 +157,11 @@ async function runOrResume(workflowName) {
|
|
|
143
157
|
}
|
|
144
158
|
|
|
145
159
|
async function main() {
|
|
160
|
+
if (command === '--version' || command === '-v') {
|
|
161
|
+
console.log(getVersion());
|
|
162
|
+
process.exit(0);
|
|
163
|
+
}
|
|
164
|
+
|
|
146
165
|
if (!command || command === 'help' || command === '--help' || command === '-h') {
|
|
147
166
|
printHelp();
|
|
148
167
|
process.exit(0);
|