agentflow-core 0.1.4 → 0.2.1

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/dist/cli.js CHANGED
@@ -1,11 +1,31 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- runTraced
4
- } from "./chunk-TT5DLU73.js";
3
+ runTraced,
4
+ startLive
5
+ } from "./chunk-FJVQYJFB.js";
5
6
 
6
7
  // src/cli.ts
7
8
  import { basename } from "path";
8
- function parseArgs(argv) {
9
+ function printHelp() {
10
+ console.log(`
11
+ AgentFlow CLI \u2014 execution tracing and live monitoring for AI agent systems.
12
+
13
+ Usage:
14
+ agentflow <command> [options]
15
+
16
+ Commands:
17
+ run [options] -- <cmd> Wrap a command with automatic execution tracing
18
+ live [dir] [options] Real-time terminal monitor (auto-detects any JSON/JSONL)
19
+
20
+ Run \`agentflow <command> --help\` for command-specific options.
21
+
22
+ Examples:
23
+ agentflow run --traces-dir ./traces -- python -m myagent process
24
+ agentflow live ./data
25
+ agentflow live ./data -R --refresh 5
26
+ `.trim());
27
+ }
28
+ function parseRunArgs(argv) {
9
29
  const result = {
10
30
  tracesDir: "./traces",
11
31
  watchDirs: [],
@@ -63,9 +83,9 @@ function parseArgs(argv) {
63
83
  result.command = commandArgs;
64
84
  return result;
65
85
  }
66
- function printUsage() {
86
+ function printRunUsage() {
67
87
  console.log(`
68
- AgentFlow CLI \u2014 Wrap any command with automatic execution tracing.
88
+ AgentFlow Run \u2014 wrap any command with automatic execution tracing.
69
89
 
70
90
  Usage:
71
91
  agentflow run [options] -- <command>
@@ -79,21 +99,20 @@ Options:
79
99
  --help Show this help message
80
100
 
81
101
  Examples:
82
- agentflow run -- python -m alfred process
83
- agentflow run --watch-dir /home/trader/.alfred/data -- python -m alfred process
84
- agentflow run --traces-dir ./my-traces --agent-id alfred -- node worker.js
102
+ agentflow run -- python -m myagent process
103
+ agentflow run --watch-dir ./data -- python worker.py
104
+ agentflow run --traces-dir ./my-traces --agent-id recon -- node agent.js
85
105
  `.trim());
86
106
  }
87
- async function main() {
88
- const argv = process.argv.slice(2);
89
- if (argv.length === 0 || argv.includes("--help") || argv.includes("-h")) {
90
- printUsage();
107
+ async function runCommand(argv) {
108
+ if (argv.includes("--help") || argv.includes("-h")) {
109
+ printRunUsage();
91
110
  process.exit(0);
92
111
  }
93
- const parsed = parseArgs(argv);
112
+ const parsed = parseRunArgs(argv);
94
113
  if (parsed.command.length === 0) {
95
114
  console.error("Error: No command specified. Use -- to separate agentflow flags from the command.");
96
- console.error("Example: agentflow run -- python -m alfred process");
115
+ console.error("Example: agentflow run -- python -m myagent process");
97
116
  process.exit(1);
98
117
  }
99
118
  const commandStr = parsed.command.join(" ");
@@ -139,4 +158,28 @@ async function main() {
139
158
  process.exit(1);
140
159
  }
141
160
  }
161
+ async function main() {
162
+ const argv = process.argv.slice(2);
163
+ if (argv.length === 0 || argv[0] !== "run" && argv[0] !== "live" && (argv.includes("--help") || argv.includes("-h"))) {
164
+ printHelp();
165
+ process.exit(0);
166
+ }
167
+ const subcommand = argv[0];
168
+ switch (subcommand) {
169
+ case "run":
170
+ await runCommand(argv);
171
+ break;
172
+ case "live":
173
+ startLive(argv);
174
+ break;
175
+ default:
176
+ if (!subcommand?.startsWith("-")) {
177
+ startLive(["live", ...argv]);
178
+ } else {
179
+ printHelp();
180
+ process.exit(1);
181
+ }
182
+ break;
183
+ }
184
+ }
142
185
  main();