@memberjunction/ai-cli 2.78.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.
Files changed (77) hide show
  1. package/README.md +358 -0
  2. package/bin/run +17 -0
  3. package/bin/run.js +5 -0
  4. package/dist/commands/actions/list.d.ts +11 -0
  5. package/dist/commands/actions/list.d.ts.map +1 -0
  6. package/dist/commands/actions/list.js +91 -0
  7. package/dist/commands/actions/list.js.map +1 -0
  8. package/dist/commands/actions/run.d.ts +16 -0
  9. package/dist/commands/actions/run.d.ts.map +1 -0
  10. package/dist/commands/actions/run.js +164 -0
  11. package/dist/commands/actions/run.js.map +1 -0
  12. package/dist/commands/agents/list.d.ts +11 -0
  13. package/dist/commands/agents/list.d.ts.map +1 -0
  14. package/dist/commands/agents/list.js +91 -0
  15. package/dist/commands/agents/list.js.map +1 -0
  16. package/dist/commands/agents/run.d.ts +17 -0
  17. package/dist/commands/agents/run.d.ts.map +1 -0
  18. package/dist/commands/agents/run.js +181 -0
  19. package/dist/commands/agents/run.js.map +1 -0
  20. package/dist/commands/prompts/list.d.ts +10 -0
  21. package/dist/commands/prompts/list.d.ts.map +1 -0
  22. package/dist/commands/prompts/list.js +40 -0
  23. package/dist/commands/prompts/list.js.map +1 -0
  24. package/dist/commands/prompts/run.d.ts +18 -0
  25. package/dist/commands/prompts/run.d.ts.map +1 -0
  26. package/dist/commands/prompts/run.js +101 -0
  27. package/dist/commands/prompts/run.js.map +1 -0
  28. package/dist/config.d.ts +17 -0
  29. package/dist/config.d.ts.map +1 -0
  30. package/dist/config.js +42 -0
  31. package/dist/config.js.map +1 -0
  32. package/dist/index.d.ts +11 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +29 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/lib/console-manager.d.ts +24 -0
  37. package/dist/lib/console-manager.d.ts.map +1 -0
  38. package/dist/lib/console-manager.js +68 -0
  39. package/dist/lib/console-manager.js.map +1 -0
  40. package/dist/lib/execution-logger.d.ts +52 -0
  41. package/dist/lib/execution-logger.d.ts.map +1 -0
  42. package/dist/lib/execution-logger.js +185 -0
  43. package/dist/lib/execution-logger.js.map +1 -0
  44. package/dist/lib/mj-provider.d.ts +10 -0
  45. package/dist/lib/mj-provider.d.ts.map +1 -0
  46. package/dist/lib/mj-provider.js +155 -0
  47. package/dist/lib/mj-provider.js.map +1 -0
  48. package/dist/lib/output-formatter.d.ts +47 -0
  49. package/dist/lib/output-formatter.d.ts.map +1 -0
  50. package/dist/lib/output-formatter.js +314 -0
  51. package/dist/lib/output-formatter.js.map +1 -0
  52. package/dist/lib/text-formatter.d.ts +59 -0
  53. package/dist/lib/text-formatter.d.ts.map +1 -0
  54. package/dist/lib/text-formatter.js +173 -0
  55. package/dist/lib/text-formatter.js.map +1 -0
  56. package/dist/services/ActionService.d.ts +24 -0
  57. package/dist/services/ActionService.d.ts.map +1 -0
  58. package/dist/services/ActionService.js +393 -0
  59. package/dist/services/ActionService.js.map +1 -0
  60. package/dist/services/AgentService.d.ts +25 -0
  61. package/dist/services/AgentService.d.ts.map +1 -0
  62. package/dist/services/AgentService.js +387 -0
  63. package/dist/services/AgentService.js.map +1 -0
  64. package/dist/services/ConversationService.d.ts +27 -0
  65. package/dist/services/ConversationService.d.ts.map +1 -0
  66. package/dist/services/ConversationService.js +296 -0
  67. package/dist/services/ConversationService.js.map +1 -0
  68. package/dist/services/PromptService.d.ts +32 -0
  69. package/dist/services/PromptService.d.ts.map +1 -0
  70. package/dist/services/PromptService.js +221 -0
  71. package/dist/services/PromptService.js.map +1 -0
  72. package/dist/services/ValidationService.d.ts +9 -0
  73. package/dist/services/ValidationService.d.ts.map +1 -0
  74. package/dist/services/ValidationService.js +197 -0
  75. package/dist/services/ValidationService.js.map +1 -0
  76. package/oclif.manifest.json +387 -0
  77. package/package.json +88 -0
package/README.md ADDED
@@ -0,0 +1,358 @@
1
+ # @memberjunction/ai-cli
2
+
3
+ MemberJunction AI agent and action execution CLI
4
+
5
+ [![Status](https://img.shields.io/badge/status-deprecated-orange)](https://github.com/MemberJunction/MJ)
6
+ [![Version](https://img.shields.io/badge/version-2.53.0-blue)](https://github.com/MemberJunction/MJ)
7
+
8
+ > ⚠️ **DEPRECATION NOTICE**: The standalone `mj-ai` CLI is now deprecated. All AI functionality has been integrated into the main MemberJunction CLI. Please use `mj ai` commands instead. See the [Migration Guide](#migration-guide) below.
9
+
10
+ ## Overview
11
+
12
+ A fully functional command-line interface for executing MemberJunction AI agents, actions, and direct prompts. The CLI provides seamless integration with the MJ infrastructure, supporting both interactive and programmatic execution of AI workflows.
13
+
14
+ **Current Status: ✅ Production Ready**
15
+ - ✅ Database integration and metadata loading
16
+ - ✅ 20+ AI agents available for execution
17
+ - ✅ 30+ actions with parameter validation
18
+ - ✅ Direct prompt execution with any AI model
19
+ - ✅ Interactive chat mode with agents
20
+ - ✅ Comprehensive error handling and logging
21
+ - ✅ Multiple output formats (compact, table, JSON)
22
+ - ✅ Real-time progress tracking with visual indicators
23
+ - ✅ Advanced text formatting for improved readability
24
+ - ✅ Full conversation context in chat mode
25
+
26
+ ## Installation
27
+
28
+ This package is part of the MemberJunction workspace. Install dependencies from the repository root:
29
+
30
+ ```bash
31
+ npm install
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ The CLI provides commands for executing AI agents, actions, and direct prompts:
37
+
38
+ ### Agent Commands
39
+
40
+ Execute AI agents with natural language prompts:
41
+
42
+ ```bash
43
+ # List available agents (20+ agents ready)
44
+ ./packages/AI/AICLI/bin/run agents:list --output=compact
45
+
46
+ # Execute an agent with a prompt
47
+ ./packages/AI/AICLI/bin/run agents:run -a "Skip: Requirements Expert" -p "Create a dashboard for sales metrics"
48
+
49
+ # Start interactive chat with an agent
50
+ ./packages/AI/AICLI/bin/run agents:run -a "Child Component Generator Sub-agent" --chat
51
+
52
+ # Execute with verbose output and custom timeout
53
+ ./packages/AI/AICLI/bin/run agents:run -a "Skip: Technical Design Expert" -p "Build a React component" --verbose --timeout=600000
54
+ ```
55
+
56
+ ### Action Commands
57
+
58
+ Execute individual actions with parameters:
59
+
60
+ ```bash
61
+ # List available actions (30+ actions ready)
62
+ ./packages/AI/AICLI/bin/run actions:list --output=table
63
+
64
+ # Execute weather lookup
65
+ ./packages/AI/AICLI/bin/run actions:run -n "Get Weather" --param "Location=Boston"
66
+
67
+ # Get stock price information
68
+ ./packages/AI/AICLI/bin/run actions:run -n "Get Stock Price" --param "Ticker=AAPL"
69
+
70
+ # Execute with multiple parameters
71
+ ./packages/AI/AICLI/bin/run actions:run -n "Send Single Message" \
72
+ --param "To=user@example.com" \
73
+ --param "Subject=Test Message" \
74
+ --param "Body=Hello from MJ CLI" \
75
+ --param "MessageType=Email" \
76
+ --param "Provider=SendGrid"
77
+
78
+ # Validate action without executing
79
+ ./packages/AI/AICLI/bin/run actions:run -n "Calculate Expression" --param "Expression=2+2*3" --dry-run
80
+ ```
81
+
82
+ ### Prompt Commands
83
+
84
+ Execute direct prompts with any available AI model:
85
+
86
+ ```bash
87
+ # List available AI models
88
+ ./packages/AI/AICLI/bin/run prompts:list
89
+
90
+ # Execute a direct prompt
91
+ ./packages/AI/AICLI/bin/run prompts:run -p "Explain machine learning in simple terms"
92
+
93
+ # Use a specific model
94
+ ./packages/AI/AICLI/bin/run prompts:run -p "Write a Python function" --model "gpt-4"
95
+
96
+ # Use system prompt and parameters
97
+ ./packages/AI/AICLI/bin/run prompts:run -p "Generate a haiku" \
98
+ --system "You are a poet" \
99
+ --temperature 0.3 \
100
+ --max-tokens 100
101
+ ```
102
+
103
+ ### Output Formats
104
+
105
+ All commands support multiple output formats:
106
+
107
+ ```bash
108
+ # Compact output (default) - clean, formatted text with colors
109
+ ./packages/AI/AICLI/bin/run agents:list --output=compact
110
+
111
+ # Table output - structured tabular format
112
+ ./packages/AI/AICLI/bin/run agents:list --output=table
113
+
114
+ # JSON output - machine-readable format
115
+ ./packages/AI/AICLI/bin/run agents:list --output=json
116
+ ```
117
+
118
+ ### Global Options
119
+
120
+ - `--verbose, -v`: Show detailed execution information including timing and IDs
121
+ - `--timeout <ms>`: Override default timeout (default: 300000ms / 5 minutes)
122
+ - `--dry-run`: Validate configuration and parameters without executing
123
+ - `--output <format>`: Output format (compact, json, table)
124
+ - `--help`: Show command-specific help and examples
125
+
126
+ ## Features
127
+
128
+ ### Progress Tracking
129
+
130
+ The CLI provides real-time progress updates during agent execution:
131
+
132
+ **Non-verbose mode**: Compact progress indicators on a single line
133
+ ```
134
+ 🚀 [ 0%] initialization: Initializing agent...
135
+ ✓ [ 10%] validation: Validating agent configuration
136
+ 💭 [ 30%] prompt execution: Running agent's initial prompt...
137
+ 🧠 [ 70%] decision processing: Analyzing response
138
+ ✨ [ 95%] finalization: Finalizing agent execution
139
+ ```
140
+
141
+ **Verbose mode**: Detailed progress with metadata
142
+ ```
143
+ 🚀 [ 0%] initialization - Initializing Demo Loop Agent agent and preparing execution environment
144
+ {"agentRun":null}
145
+
146
+ ✓ [ 10%] validation - Validating agent configuration and loading prompts
147
+ ```
148
+
149
+ ### Text Formatting
150
+
151
+ Long agent responses are automatically formatted for better readability:
152
+ - **Word wrapping** at console width (default 80 characters)
153
+ - **Paragraph preservation** maintains original structure
154
+ - **List formatting** with proper indentation for bullets and numbered lists
155
+ - **Code highlighting** in gray for code blocks
156
+ - **JSON formatting** with syntax highlighting for structured data
157
+
158
+ ### Interactive Chat Mode
159
+
160
+ The chat mode maintains full conversation context:
161
+ - Previous messages are sent with each new prompt
162
+ - Agent maintains context across the entire conversation
163
+ - Supports natural back-and-forth dialogue
164
+ - Exit with "exit", "quit", or Ctrl+C
165
+
166
+ ## Architecture
167
+
168
+ The CLI follows the MetadataSync pattern with:
169
+
170
+ - **Service Layer**: AgentService, ActionService, ValidationService
171
+ - **Infrastructure**: MJ Provider with database integration
172
+ - **Logging**: Comprehensive execution tracking with file output
173
+ - **Error Handling**: User-friendly error messages with next steps
174
+ - **Configuration**: Automatic mj.config.cjs detection and loading
175
+ - **Text Formatting**: Advanced console output formatting with TextFormatter
176
+ - **Progress Tracking**: Real-time execution status with visual indicators
177
+
178
+ ### Design Decisions
179
+
180
+ **Why No oclif Init Hooks:**
181
+ The CLI intentionally does not use oclif init hooks for database initialization. Init hooks have significant limitations:
182
+ - Don't run during help/version commands
183
+ - Early database failures would break even `--help`
184
+ - More restrictive error handling
185
+ - Commands are imported before hooks run
186
+
187
+ Instead, we use **service-based initialization** which provides:
188
+ - Better error isolation and debugging
189
+ - Lazy initialization (only when needed)
190
+ - Reliable help/version commands
191
+ - Comprehensive error messages with actionable steps
192
+
193
+ **Future Enhancement Option:**
194
+ A Base Command Pattern could reduce code duplication while maintaining current benefits:
195
+ ```typescript
196
+ export abstract class BaseCommand extends Command {
197
+ protected async initMJ(): Promise<void> {
198
+ // Shared initialization logic
199
+ }
200
+ }
201
+ ```
202
+ This would be a better alternative than init hooks for shared functionality.
203
+
204
+ ## Configuration
205
+
206
+ The CLI uses the standard MemberJunction configuration from `mj.config.cjs` in the repository root.
207
+
208
+ **✅ Currently Working With:**
209
+ - SQL Server database connection
210
+ - User authentication and context
211
+ - AI model and provider settings
212
+ - Metadata caching and performance optimization
213
+
214
+ **Required Configuration in mj.config.cjs:**
215
+ - Database connection settings (host, port, database, user, password)
216
+ - AI model configuration for agent execution
217
+ - User authentication setup
218
+
219
+ ## Development
220
+
221
+ ### Building the Package
222
+
223
+ ```bash
224
+ cd packages/AI/AICLI
225
+ npm run build
226
+ ```
227
+
228
+ ### Running in Development
229
+
230
+ ```bash
231
+ # From repository root (recommended)
232
+ ./packages/AI/AICLI/bin/run agents:list
233
+
234
+ # Or from package directory
235
+ cd packages/AI/AICLI
236
+ ./bin/run agents:list
237
+ ```
238
+
239
+ ### Testing Commands
240
+
241
+ ```bash
242
+ # Test help system
243
+ ./packages/AI/AICLI/bin/run --help
244
+ ./packages/AI/AICLI/bin/run agents:run --help
245
+
246
+ # Test basic connectivity
247
+ ./packages/AI/AICLI/bin/run agents:list --output=json | jq length
248
+
249
+ # Test validation without execution
250
+ ./packages/AI/AICLI/bin/run actions:run -n "Calculate Expression" --param "Expression=1+1" --dry-run
251
+ ```
252
+
253
+ ## Performance
254
+
255
+ Current performance benchmarks:
256
+ - **Metadata Loading**: ~700ms (includes full entity and relationship mapping)
257
+ - **Agent Listing**: Instant after metadata load
258
+ - **Action Discovery**: Instant after metadata load
259
+ - **Database Connection**: <100ms on subsequent calls
260
+
261
+ ## Logging
262
+
263
+ Execution logs are stored in `.mj-ai/logs/` directory with comprehensive tracking:
264
+
265
+ **What's Logged:**
266
+ - Execution steps and timing
267
+ - Agent/action responses and parameters
268
+ - Error details and stack traces
269
+ - Performance metrics and database query times
270
+ - User context and configuration details
271
+
272
+ **Log Files Created:**
273
+ - `{timestamp}_{execution-id}_execution.log`: Detailed step-by-step logs
274
+ - Performance metrics and execution summary
275
+
276
+ **Example Log Location:**
277
+ ```
278
+ .mj-ai/logs/2025-06-21_18-36-13_ftwxjeywx_execution.log
279
+ ```
280
+
281
+ ## Troubleshooting
282
+
283
+ ### Common Issues
284
+
285
+ **1. "No mj.config.cjs configuration found"**
286
+ - Ensure you're running from the MJ repository root
287
+ - Verify mj.config.cjs exists and has database settings
288
+
289
+ **2. Database Connection Errors**
290
+ - Check database server is running
291
+ - Verify credentials in mj.config.cjs
292
+ - Ensure network connectivity to database
293
+
294
+ **3. Permission Errors**
295
+ - Verify user has execute permissions on ./bin/run
296
+ - Check database user permissions for metadata access
297
+
298
+ ### Getting Help
299
+
300
+ ```bash
301
+ # Command-specific help
302
+ ./packages/AI/AICLI/bin/run agents:run --help
303
+ ./packages/AI/AICLI/bin/run actions:run --help
304
+
305
+ # Global help
306
+ ./packages/AI/AICLI/bin/run --help
307
+ ```
308
+
309
+ ## Migration Guide
310
+
311
+ The AI CLI functionality has been integrated into the main MemberJunction CLI. To migrate:
312
+
313
+ ### Command Changes
314
+
315
+ | Old Command (mj-ai) | New Command (mj) |
316
+ |---------------------|------------------|
317
+ | `mj-ai agents:list` | `mj ai agents list` |
318
+ | `mj-ai agents:run` | `mj ai agents run` |
319
+ | `mj-ai actions:list` | `mj ai actions list` |
320
+ | `mj-ai actions:run` | `mj ai actions run` |
321
+ | `mj-ai prompts:list` | `mj ai prompts list` |
322
+ | `mj-ai prompts:run` | `mj ai prompts run` |
323
+
324
+ ### Examples
325
+
326
+ ```bash
327
+ # Old way
328
+ mj-ai agents:run -a "Skip: Requirements Expert" -p "Create a dashboard"
329
+
330
+ # New way
331
+ mj ai agents run -a "Skip: Requirements Expert" -p "Create a dashboard"
332
+
333
+ # Old way
334
+ mj-ai actions:run -n "Get Weather" --param "Location=Boston"
335
+
336
+ # New way
337
+ mj ai actions run -n "Get Weather" --param "Location=Boston"
338
+ ```
339
+
340
+ ### Installation
341
+
342
+ Instead of using this package directly, install the main MJ CLI:
343
+
344
+ ```bash
345
+ npm install -g @memberjunction/cli
346
+ ```
347
+
348
+ ### Configuration
349
+
350
+ No changes needed - both CLIs use the same `mj.config.cjs` file.
351
+
352
+ ### Support Timeline
353
+
354
+ - **Now**: Both `mj-ai` and `mj ai` commands work
355
+ - **3 months**: `mj-ai` will show deprecation warnings
356
+ - **6 months**: `mj-ai` package will be archived
357
+
358
+ For the latest documentation, see the [MJ CLI README](https://github.com/MemberJunction/MJ/tree/main/packages/MJCLI).
package/bin/run ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+
3
+ const oclif = require('@oclif/core')
4
+
5
+ const path = require('path')
6
+ const project = path.join(__dirname, '..', 'tsconfig.json')
7
+
8
+ // In dev mode -> use ts-node and dev plugins
9
+ process.env.NODE_ENV = 'development'
10
+
11
+ require('ts-node').register({project})
12
+
13
+ // In dev mode, always show stack traces
14
+ oclif.settings.debug = true;
15
+
16
+ // Start the CLI
17
+ oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ const oclif = require('@oclif/core')
4
+
5
+ oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
@@ -0,0 +1,11 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class ActionsList extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ };
8
+ run(): Promise<void>;
9
+ private cleanup;
10
+ }
11
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/actions/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAM7C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,OAAO;IAC9C,MAAM,CAAC,WAAW,SAA4B;IAE9C,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,KAAK;;MAMV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAyCZ,OAAO;CAQtB"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const core_1 = require("@oclif/core");
30
+ const ora_classic_1 = __importDefault(require("ora-classic"));
31
+ const ActionService_1 = require("../../services/ActionService");
32
+ const output_formatter_1 = require("../../lib/output-formatter");
33
+ const ValidationService_1 = require("../../services/ValidationService");
34
+ class ActionsList extends core_1.Command {
35
+ static description = 'List available actions';
36
+ static examples = [
37
+ '<%= config.bin %> <%= command.id %>',
38
+ '<%= config.bin %> <%= command.id %> --output=json',
39
+ '<%= config.bin %> <%= command.id %> --output=table',
40
+ ];
41
+ static flags = {
42
+ output: core_1.Flags.string({
43
+ description: 'Output format',
44
+ options: ['compact', 'json', 'table'],
45
+ default: 'table'
46
+ })
47
+ };
48
+ async run() {
49
+ const { flags } = await this.parse(ActionsList);
50
+ const spinner = (0, ora_classic_1.default)('Loading available actions...');
51
+ try {
52
+ const validator = new ValidationService_1.ValidationService();
53
+ const outputFormat = validator.validateOutputFormat(flags.output);
54
+ spinner.start();
55
+ const actionService = new ActionService_1.ActionService();
56
+ await actionService.initialize();
57
+ const actions = await actionService.listActions();
58
+ spinner.stop();
59
+ const formatter = new output_formatter_1.OutputFormatter(outputFormat);
60
+ this.log(formatter.formatActionList(actions));
61
+ // Clean up resources
62
+ await this.cleanup();
63
+ // Force exit after successful completion
64
+ setImmediate(() => process.exit(0));
65
+ }
66
+ catch (error) {
67
+ if (spinner.isSpinning) {
68
+ spinner.fail('Failed to load actions');
69
+ }
70
+ // If it's a formatted error message, show it cleanly
71
+ if (error.message.startsWith('❌')) {
72
+ this.log(error.message);
73
+ this.exit(1);
74
+ }
75
+ else {
76
+ this.error(error.message);
77
+ }
78
+ }
79
+ }
80
+ async cleanup() {
81
+ try {
82
+ const { closeMJProvider } = await Promise.resolve().then(() => __importStar(require('../../lib/mj-provider')));
83
+ await closeMJProvider();
84
+ }
85
+ catch (error) {
86
+ // Ignore cleanup errors to not interfere with main execution
87
+ }
88
+ }
89
+ }
90
+ exports.default = ActionsList;
91
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/actions/list.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAA6C;AAC7C,8DAA8B;AAC9B,gEAA6D;AAC7D,iEAA6D;AAC7D,wEAAqE;AAErE,MAAqB,WAAY,SAAQ,cAAO;IAC9C,MAAM,CAAC,WAAW,GAAG,wBAAwB,CAAC;IAE9C,MAAM,CAAC,QAAQ,GAAG;QAChB,qCAAqC;QACrC,mDAAmD;QACnD,oDAAoD;KACrD,CAAC;IAEF,MAAM,CAAC,KAAK,GAAG;QACb,MAAM,EAAE,YAAK,CAAC,MAAM,CAAC;YACnB,WAAW,EAAE,eAAe;YAC5B,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC;YACrC,OAAO,EAAE,OAAO;SACjB,CAAC;KACH,CAAC;IAEF,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAChD,MAAM,OAAO,GAAG,IAAA,qBAAG,EAAC,8BAA8B,CAAC,CAAC;QAEpD,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAI,qCAAiB,EAAE,CAAC;YAC1C,MAAM,YAAY,GAAG,SAAS,CAAC,oBAAoB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAElE,OAAO,CAAC,KAAK,EAAE,CAAC;YAEhB,MAAM,aAAa,GAAG,IAAI,6BAAa,EAAE,CAAC;YAC1C,MAAM,aAAa,CAAC,UAAU,EAAE,CAAC;YAEjC,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,WAAW,EAAE,CAAC;YAElD,OAAO,CAAC,IAAI,EAAE,CAAC;YAEf,MAAM,SAAS,GAAG,IAAI,kCAAe,CAAC,YAAY,CAAC,CAAC;YACpD,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;YAE9C,qBAAqB;YACrB,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YAErB,yCAAyC;YACzC,YAAY,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YACzC,CAAC;YAED,qDAAqD;YACrD,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAClC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACxB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACf,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,OAAO;QACnB,IAAI,CAAC;YACH,MAAM,EAAE,eAAe,EAAE,GAAG,wDAAa,uBAAuB,GAAC,CAAC;YAClE,MAAM,eAAe,EAAE,CAAC;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,6DAA6D;QAC/D,CAAC;IACH,CAAC;;AAjEH,8BAkEC"}
@@ -0,0 +1,16 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class ActionsRun extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ param: import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ timeout: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ 'dry-run': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
12
+ };
13
+ run(): Promise<void>;
14
+ private cleanup;
15
+ }
16
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/actions/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAO7C,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,OAAO;IAC7C,MAAM,CAAC,WAAW,SAAyC;IAE3D,MAAM,CAAC,QAAQ,WAKb;IAEF,MAAM,CAAC,KAAK;;;;;;;MA2BV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAuGZ,OAAO;CAQtB"}
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const core_1 = require("@oclif/core");
30
+ const chalk_1 = __importDefault(require("chalk"));
31
+ const ora_classic_1 = __importDefault(require("ora-classic"));
32
+ const ActionService_1 = require("../../services/ActionService");
33
+ const ValidationService_1 = require("../../services/ValidationService");
34
+ const output_formatter_1 = require("../../lib/output-formatter");
35
+ class ActionsRun extends core_1.Command {
36
+ static description = 'Execute individual actions directly';
37
+ static examples = [
38
+ '<%= config.bin %> <%= command.id %> -n "Get Weather" --param "Location=Boston"',
39
+ '<%= config.bin %> <%= command.id %> -n "Send Email" --param "To=user@example.com" --param "Subject=Test"',
40
+ '<%= config.bin %> <%= command.id %> --output=json',
41
+ '<%= config.bin %> <%= command.id %> -n "Calculate" --param "Numbers=[1,2,3]" --verbose',
42
+ ];
43
+ static flags = {
44
+ name: core_1.Flags.string({
45
+ char: 'n',
46
+ description: 'Name of the action to execute',
47
+ required: false
48
+ }),
49
+ param: core_1.Flags.string({
50
+ description: 'Action parameter (key=value format, can be used multiple times)',
51
+ multiple: true,
52
+ default: []
53
+ }),
54
+ verbose: core_1.Flags.boolean({
55
+ char: 'v',
56
+ description: 'Show detailed execution information'
57
+ }),
58
+ timeout: core_1.Flags.integer({
59
+ description: 'Override default timeout (milliseconds)',
60
+ default: 300000
61
+ }),
62
+ 'dry-run': core_1.Flags.boolean({
63
+ description: 'Validate without executing'
64
+ }),
65
+ output: core_1.Flags.string({
66
+ description: 'Output format',
67
+ options: ['compact', 'json', 'table'],
68
+ default: 'compact'
69
+ })
70
+ };
71
+ async run() {
72
+ const { flags } = await this.parse(ActionsRun);
73
+ const spinner = (0, ora_classic_1.default)();
74
+ try {
75
+ // Validate inputs
76
+ const validator = new ValidationService_1.ValidationService();
77
+ const outputFormat = validator.validateOutputFormat(flags.output);
78
+ const timeout = validator.validateTimeout(flags.timeout);
79
+ const parameters = validator.parseParameters(flags.param);
80
+ await validator.validateActionInput(flags.name, parameters);
81
+ // Show available actions if none specified
82
+ if (!flags.name) {
83
+ spinner.start('Loading available actions...');
84
+ const actionService = new ActionService_1.ActionService();
85
+ await actionService.initialize();
86
+ const actions = await actionService.listActions();
87
+ spinner.stop();
88
+ const formatter = new output_formatter_1.OutputFormatter(outputFormat);
89
+ this.log(formatter.formatActionList(actions));
90
+ return;
91
+ }
92
+ if (flags['dry-run']) {
93
+ spinner.start('Validating action and parameters...');
94
+ const actionService = new ActionService_1.ActionService();
95
+ await actionService.initialize();
96
+ // Try to find the action to validate it exists
97
+ const action = await actionService.findAction(flags.name);
98
+ spinner.stop();
99
+ if (!action) {
100
+ this.error(`Action "${flags.name}" not found. Use 'mj-ai actions:list' to see available actions.`);
101
+ }
102
+ this.log(chalk_1.default.green('✓ Validation passed - dry run complete'));
103
+ this.log(chalk_1.default.dim(`Action: ${flags.name}`));
104
+ if (Object.keys(parameters).length > 0) {
105
+ this.log(chalk_1.default.dim(`Parameters:`));
106
+ Object.entries(parameters).forEach(([key, value]) => {
107
+ const valueStr = typeof value === 'object' ? JSON.stringify(value) : String(value);
108
+ const displayValue = valueStr.length > 50 ? valueStr.substring(0, 50) + '...' : valueStr;
109
+ this.log(chalk_1.default.dim(` ${key}: ${displayValue}`));
110
+ });
111
+ }
112
+ else {
113
+ this.log(chalk_1.default.dim(`Parameters: None`));
114
+ }
115
+ this.log(chalk_1.default.dim(`Timeout: ${timeout}ms`));
116
+ return;
117
+ }
118
+ // Execute action
119
+ spinner.start(`Executing action: ${flags.name}...`);
120
+ const actionService = new ActionService_1.ActionService();
121
+ await actionService.initialize();
122
+ const result = await actionService.executeAction(flags.name, {
123
+ verbose: flags.verbose,
124
+ timeout: timeout,
125
+ parameters: parameters
126
+ });
127
+ spinner.stop();
128
+ const formatter = new output_formatter_1.OutputFormatter(outputFormat);
129
+ this.log(formatter.formatActionResult(result));
130
+ // Clean up resources
131
+ await this.cleanup();
132
+ // Exit with error code if execution failed
133
+ if (!result.success) {
134
+ this.exit(1);
135
+ }
136
+ // Force exit after successful completion
137
+ setImmediate(() => process.exit(0));
138
+ }
139
+ catch (error) {
140
+ if (spinner.isSpinning) {
141
+ spinner.fail('Operation failed');
142
+ }
143
+ // If it's a formatted error message, show it cleanly
144
+ if (error.message.startsWith('❌')) {
145
+ this.log(error.message);
146
+ this.exit(1);
147
+ }
148
+ else {
149
+ this.error(error.message);
150
+ }
151
+ }
152
+ }
153
+ async cleanup() {
154
+ try {
155
+ const { closeMJProvider } = await Promise.resolve().then(() => __importStar(require('../../lib/mj-provider')));
156
+ await closeMJProvider();
157
+ }
158
+ catch (error) {
159
+ // Ignore cleanup errors to not interfere with main execution
160
+ }
161
+ }
162
+ }
163
+ exports.default = ActionsRun;
164
+ //# sourceMappingURL=run.js.map