@relayflows/cli 0.0.1 → 1.0.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/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js CHANGED
@@ -1,4 +1,104 @@
1
1
  #!/usr/bin/env node
2
- // Placeholder for @relayflows/cli v0.0.1 — npm namespace reservation.
3
- console.error('@relayflows/cli 0.0.1 is a placeholder. Install 0.1.0+ for the real CLI.');
4
- process.exit(0);
2
+ import path from 'node:path';
3
+ import { Command } from 'commander';
4
+ import { runWorkflow, runScriptWorkflow, } from '@relayflows/core';
5
+ function logWorkflowEvent(event) {
6
+ if (event.type === 'broker:event')
7
+ return;
8
+ const prefix = event.type.startsWith('run:') ? '[run]' : '[step]';
9
+ const name = 'stepName' in event ? `${event.stepName} ` : '';
10
+ const status = event.type.split(':')[1];
11
+ const detail = 'error' in event ? `: ${event.error}` : '';
12
+ console.log(`${prefix} ${name}${status}${detail}`);
13
+ }
14
+ async function runYamlWorkflow(filePath, options) {
15
+ const result = await runWorkflow(filePath, options);
16
+ if ('valid' in result) {
17
+ const report = result;
18
+ return {
19
+ status: report.valid ? 'dry-run' : 'failed',
20
+ error: report.errors.join('; ') || undefined,
21
+ };
22
+ }
23
+ return result;
24
+ }
25
+ const program = new Command();
26
+ program
27
+ .name('relayflows')
28
+ .description('Run Agent Relay workflows from the command line')
29
+ .version('0.1.0');
30
+ program
31
+ .command('run <file>')
32
+ .description('Run a workflow file (YAML, TypeScript, or Python)')
33
+ .option('-w, --workflow <name>', 'Run a specific workflow by name (default: first, YAML only)')
34
+ .option('--dry-run', 'Validate workflow and show execution plan without running')
35
+ .option('--resume <runId>', 'Resume a previously failed workflow run from where it left off')
36
+ .option('--start-from <step>', 'Start from a specific step and skip predecessor steps')
37
+ .option('--previous-run-id <runId>', 'Use cached outputs from a previous run when starting from a step')
38
+ .action(async (filePath, options) => {
39
+ const ext = path.extname(filePath).toLowerCase();
40
+ try {
41
+ if (ext === '.yaml' || ext === '.yml') {
42
+ if (options.resume) {
43
+ console.log(`Resuming workflow run ${options.resume} from ${filePath}...`);
44
+ const result = await runYamlWorkflow(filePath, {
45
+ workflow: options.workflow,
46
+ resume: options.resume,
47
+ onEvent: logWorkflowEvent,
48
+ });
49
+ if (result.status === 'completed') {
50
+ console.log('\nWorkflow resumed and completed successfully.');
51
+ return;
52
+ }
53
+ console.error(`\nWorkflow ${result.status}${result.error ? `: ${result.error}` : ''}`);
54
+ if (result.id) {
55
+ console.error(`Run ID: ${result.id} — resume with: relayflows run ${filePath} --resume ${result.id}`);
56
+ }
57
+ process.exit(1);
58
+ }
59
+ if (options.dryRun) {
60
+ console.log(`Dry run: validating workflow from ${filePath}...`);
61
+ }
62
+ else {
63
+ console.log(`Running workflow from ${filePath}...`);
64
+ }
65
+ const result = await runYamlWorkflow(filePath, {
66
+ workflow: options.workflow,
67
+ dryRun: options.dryRun,
68
+ startFrom: options.startFrom,
69
+ previousRunId: options.previousRunId,
70
+ onEvent: logWorkflowEvent,
71
+ });
72
+ if (options.dryRun)
73
+ return;
74
+ if (result.status === 'completed') {
75
+ console.log('\nWorkflow completed successfully.');
76
+ return;
77
+ }
78
+ console.error(`\nWorkflow ${result.status}${result.error ? `: ${result.error}` : ''}`);
79
+ if (result.id) {
80
+ console.error(`Run ID: ${result.id} — resume with: relayflows run ${filePath} --resume ${result.id}`);
81
+ }
82
+ process.exit(1);
83
+ }
84
+ if (ext === '.ts' || ext === '.tsx' || ext === '.py') {
85
+ console.log(`Running workflow script ${filePath}...`);
86
+ await runScriptWorkflow(filePath, {
87
+ dryRun: options.dryRun,
88
+ resume: options.resume,
89
+ startFrom: options.startFrom,
90
+ previousRunId: options.previousRunId,
91
+ });
92
+ return;
93
+ }
94
+ console.error(`Unsupported file type: ${ext}. Use .yaml, .yml, .ts, or .py`);
95
+ process.exit(1);
96
+ }
97
+ catch (err) {
98
+ const message = err instanceof Error ? err.message : String(err);
99
+ console.error(`Error: ${message}`);
100
+ process.exit(1);
101
+ }
102
+ });
103
+ program.parseAsync(process.argv);
104
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,WAAW,EACX,iBAAiB,GAElB,MAAM,kBAAkB,CAAC;AAgB1B,SAAS,gBAAgB,CAAC,KAAoB;IAC5C,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc;QAAE,OAAO;IAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;IAClE,MAAM,IAAI,GAAG,UAAU,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7D,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AACrD,CAAC;AAED,KAAK,UAAU,eAAe,CAC5B,QAAgB,EAChB,OAAyE;IAEzE,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACpD,IAAI,OAAO,IAAI,MAAM,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,MAAyD,CAAC;QACzE,OAAO;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1,7 @@
1
1
  {
2
2
  "name": "@relayflows/cli",
3
- "version": "0.0.1",
4
- "description": "CLI for running Agent Relay workflows (npm namespace placeholder — real release ships as 0.1.0+).",
3
+ "version": "1.0.0",
4
+ "description": "Command-line interface for running Agent Relay workflows",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "relayflows": "./dist/cli.js"
@@ -23,7 +23,7 @@
23
23
  "directory": "packages/cli"
24
24
  },
25
25
  "dependencies": {
26
- "@relayflows/core": "0.0.1",
26
+ "@relayflows/core": "1.0.0",
27
27
  "commander": "^12.1.0"
28
28
  },
29
29
  "devDependencies": {