praisonai 1.2.2 → 1.2.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.
Files changed (160) hide show
  1. package/dist/agent/simple.js +1 -1
  2. package/dist/cli/commands/auto.d.ts +12 -0
  3. package/dist/cli/commands/auto.js +109 -0
  4. package/dist/cli/commands/autonomy.d.ts +5 -0
  5. package/dist/cli/commands/autonomy.js +152 -0
  6. package/dist/cli/commands/cache.d.ts +9 -0
  7. package/dist/cli/commands/cache.js +143 -0
  8. package/dist/cli/commands/chat.d.ts +14 -0
  9. package/dist/cli/commands/chat.js +127 -0
  10. package/dist/cli/commands/checkpoints.d.ts +5 -0
  11. package/dist/cli/commands/checkpoints.js +236 -0
  12. package/dist/cli/commands/context.d.ts +11 -0
  13. package/dist/cli/commands/context.js +182 -0
  14. package/dist/cli/commands/cost.d.ts +5 -0
  15. package/dist/cli/commands/cost.js +146 -0
  16. package/dist/cli/commands/db.d.ts +9 -0
  17. package/dist/cli/commands/db.js +149 -0
  18. package/dist/cli/commands/eval.d.ts +17 -0
  19. package/dist/cli/commands/eval.js +247 -0
  20. package/dist/cli/commands/external-agents.d.ts +5 -0
  21. package/dist/cli/commands/external-agents.js +169 -0
  22. package/dist/cli/commands/fast-context.d.ts +5 -0
  23. package/dist/cli/commands/fast-context.js +126 -0
  24. package/dist/cli/commands/flow.d.ts +5 -0
  25. package/dist/cli/commands/flow.js +141 -0
  26. package/dist/cli/commands/git.d.ts +5 -0
  27. package/dist/cli/commands/git.js +178 -0
  28. package/dist/cli/commands/graph-rag.d.ts +9 -0
  29. package/dist/cli/commands/graph-rag.js +131 -0
  30. package/dist/cli/commands/guardrail.d.ts +11 -0
  31. package/dist/cli/commands/guardrail.js +156 -0
  32. package/dist/cli/commands/handoff.d.ts +9 -0
  33. package/dist/cli/commands/handoff.js +133 -0
  34. package/dist/cli/commands/help.d.ts +8 -0
  35. package/dist/cli/commands/help.js +167 -0
  36. package/dist/cli/commands/image.d.ts +13 -0
  37. package/dist/cli/commands/image.js +192 -0
  38. package/dist/cli/commands/interactive.d.ts +6 -0
  39. package/dist/cli/commands/interactive.js +79 -0
  40. package/dist/cli/commands/jobs.d.ts +5 -0
  41. package/dist/cli/commands/jobs.js +282 -0
  42. package/dist/cli/commands/knowledge.d.ts +9 -0
  43. package/dist/cli/commands/knowledge.js +226 -0
  44. package/dist/cli/commands/mcp.d.ts +9 -0
  45. package/dist/cli/commands/mcp.js +243 -0
  46. package/dist/cli/commands/memory.d.ts +10 -0
  47. package/dist/cli/commands/memory.js +198 -0
  48. package/dist/cli/commands/n8n.d.ts +5 -0
  49. package/dist/cli/commands/n8n.js +137 -0
  50. package/dist/cli/commands/observability.d.ts +9 -0
  51. package/dist/cli/commands/observability.js +145 -0
  52. package/dist/cli/commands/planning.d.ts +9 -0
  53. package/dist/cli/commands/planning.js +167 -0
  54. package/dist/cli/commands/prompt-expand.d.ts +11 -0
  55. package/dist/cli/commands/prompt-expand.js +100 -0
  56. package/dist/cli/commands/providers.d.ts +9 -0
  57. package/dist/cli/commands/providers.js +98 -0
  58. package/dist/cli/commands/query-rewrite.d.ts +12 -0
  59. package/dist/cli/commands/query-rewrite.js +102 -0
  60. package/dist/cli/commands/repo-map.d.ts +5 -0
  61. package/dist/cli/commands/repo-map.js +151 -0
  62. package/dist/cli/commands/reranker.d.ts +10 -0
  63. package/dist/cli/commands/reranker.js +144 -0
  64. package/dist/cli/commands/research.d.ts +12 -0
  65. package/dist/cli/commands/research.js +108 -0
  66. package/dist/cli/commands/router.d.ts +11 -0
  67. package/dist/cli/commands/router.js +142 -0
  68. package/dist/cli/commands/run.d.ts +14 -0
  69. package/dist/cli/commands/run.js +111 -0
  70. package/dist/cli/commands/sandbox.d.ts +5 -0
  71. package/dist/cli/commands/sandbox.js +135 -0
  72. package/dist/cli/commands/scheduler.d.ts +5 -0
  73. package/dist/cli/commands/scheduler.js +260 -0
  74. package/dist/cli/commands/session.d.ts +9 -0
  75. package/dist/cli/commands/session.js +238 -0
  76. package/dist/cli/commands/skills.d.ts +9 -0
  77. package/dist/cli/commands/skills.js +256 -0
  78. package/dist/cli/commands/telemetry.d.ts +9 -0
  79. package/dist/cli/commands/telemetry.js +146 -0
  80. package/dist/cli/commands/tools.d.ts +9 -0
  81. package/dist/cli/commands/tools.js +172 -0
  82. package/dist/cli/commands/vector.d.ts +10 -0
  83. package/dist/cli/commands/vector.js +171 -0
  84. package/dist/cli/commands/version.d.ts +8 -0
  85. package/dist/cli/commands/version.js +68 -0
  86. package/dist/cli/commands/voice.d.ts +10 -0
  87. package/dist/cli/commands/voice.js +162 -0
  88. package/dist/cli/commands/workflow.d.ts +13 -0
  89. package/dist/cli/commands/workflow.js +184 -0
  90. package/dist/cli/config/index.d.ts +6 -0
  91. package/dist/cli/config/index.js +22 -0
  92. package/dist/cli/config/load.d.ts +20 -0
  93. package/dist/cli/config/load.js +229 -0
  94. package/dist/cli/config/resolve.d.ts +28 -0
  95. package/dist/cli/config/resolve.js +70 -0
  96. package/dist/cli/config/schema.d.ts +15 -0
  97. package/dist/cli/config/schema.js +65 -0
  98. package/dist/cli/features/autonomy-mode.d.ts +98 -0
  99. package/dist/cli/features/autonomy-mode.js +266 -0
  100. package/dist/cli/features/background-jobs.d.ts +155 -0
  101. package/dist/cli/features/background-jobs.js +416 -0
  102. package/dist/cli/features/checkpoints.d.ts +126 -0
  103. package/dist/cli/features/checkpoints.js +288 -0
  104. package/dist/cli/features/cost-tracker.d.ts +101 -0
  105. package/dist/cli/features/cost-tracker.js +212 -0
  106. package/dist/cli/features/external-agents.d.ts +115 -0
  107. package/dist/cli/features/external-agents.js +294 -0
  108. package/dist/cli/features/fast-context.d.ts +126 -0
  109. package/dist/cli/features/fast-context.js +310 -0
  110. package/dist/cli/features/flow-display.d.ts +100 -0
  111. package/dist/cli/features/flow-display.js +254 -0
  112. package/dist/cli/features/git-integration.d.ts +138 -0
  113. package/dist/cli/features/git-integration.js +374 -0
  114. package/dist/cli/features/index.d.ts +17 -0
  115. package/dist/cli/features/index.js +102 -0
  116. package/dist/cli/features/interactive-tui.d.ts +114 -0
  117. package/dist/cli/features/interactive-tui.js +326 -0
  118. package/dist/cli/features/n8n-integration.d.ts +108 -0
  119. package/dist/cli/features/n8n-integration.js +296 -0
  120. package/dist/cli/features/repo-map.d.ts +101 -0
  121. package/dist/cli/features/repo-map.js +350 -0
  122. package/dist/cli/features/sandbox-executor.d.ts +89 -0
  123. package/dist/cli/features/sandbox-executor.js +314 -0
  124. package/dist/cli/features/scheduler.d.ts +111 -0
  125. package/dist/cli/features/scheduler.js +298 -0
  126. package/dist/cli/features/slash-commands.d.ts +77 -0
  127. package/dist/cli/features/slash-commands.js +316 -0
  128. package/dist/cli/index.d.ts +19 -15
  129. package/dist/cli/index.js +163 -123
  130. package/dist/cli/output/errors.d.ts +32 -0
  131. package/dist/cli/output/errors.js +72 -0
  132. package/dist/cli/output/index.d.ts +6 -0
  133. package/dist/cli/output/index.js +22 -0
  134. package/dist/cli/output/json.d.ts +17 -0
  135. package/dist/cli/output/json.js +54 -0
  136. package/dist/cli/output/pretty.d.ts +21 -0
  137. package/dist/cli/output/pretty.js +106 -0
  138. package/dist/cli/runtime/env.d.ts +12 -0
  139. package/dist/cli/runtime/env.js +49 -0
  140. package/dist/cli/runtime/exit.d.ts +11 -0
  141. package/dist/cli/runtime/exit.js +49 -0
  142. package/dist/cli/runtime/index.d.ts +6 -0
  143. package/dist/cli/runtime/index.js +22 -0
  144. package/dist/cli/runtime/lazy.d.ts +18 -0
  145. package/dist/cli/runtime/lazy.js +85 -0
  146. package/dist/cli/spec/cli-spec.d.ts +87 -0
  147. package/dist/cli/spec/cli-spec.js +478 -0
  148. package/dist/cli/spec/index.d.ts +4 -0
  149. package/dist/cli/spec/index.js +20 -0
  150. package/dist/index.d.ts +4 -1
  151. package/dist/index.js +100 -7
  152. package/dist/memory/auto-memory.d.ts +136 -0
  153. package/dist/memory/auto-memory.js +301 -0
  154. package/dist/memory/file-memory.d.ts +88 -0
  155. package/dist/memory/file-memory.js +287 -0
  156. package/dist/memory/index.d.ts +2 -0
  157. package/dist/memory/index.js +11 -1
  158. package/dist/workflows/loop.d.ts +0 -0
  159. package/dist/workflows/loop.js +1 -0
  160. package/package.json +1 -1
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ /**
3
+ * Guardrail command - Content validation and safety
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.execute = execute;
40
+ const llm_guardrail_1 = require("../../guardrails/llm-guardrail");
41
+ const resolve_1 = require("../config/resolve");
42
+ const json_1 = require("../output/json");
43
+ const pretty = __importStar(require("../output/pretty"));
44
+ const cli_spec_1 = require("../spec/cli-spec");
45
+ const errors_1 = require("../output/errors");
46
+ async function execute(args, options) {
47
+ const action = args[0] || 'help';
48
+ const actionArgs = args.slice(1);
49
+ const outputFormat = options.json ? 'json' : (options.output || 'pretty');
50
+ const config = (0, resolve_1.resolveConfig)(options);
51
+ try {
52
+ switch (action) {
53
+ case 'check':
54
+ await checkContent(actionArgs, options, config, outputFormat);
55
+ break;
56
+ case 'help':
57
+ default:
58
+ await showHelp(outputFormat);
59
+ break;
60
+ }
61
+ }
62
+ catch (error) {
63
+ if (outputFormat === 'json') {
64
+ (0, json_1.outputJson)((0, json_1.formatError)(errors_1.ERROR_CODES.UNKNOWN, error instanceof Error ? error.message : String(error)));
65
+ }
66
+ else {
67
+ await pretty.error(error instanceof Error ? error.message : String(error));
68
+ }
69
+ process.exit(cli_spec_1.EXIT_CODES.RUNTIME_ERROR);
70
+ }
71
+ }
72
+ async function checkContent(args, options, config, outputFormat) {
73
+ const content = args.join(' ');
74
+ if (!content) {
75
+ if (outputFormat === 'json') {
76
+ (0, json_1.outputJson)((0, json_1.formatError)(errors_1.ERROR_CODES.MISSING_ARG, 'Please provide content to check'));
77
+ }
78
+ else {
79
+ await pretty.error('Please provide content to check');
80
+ }
81
+ process.exit(cli_spec_1.EXIT_CODES.INVALID_ARGUMENTS);
82
+ }
83
+ const startTime = Date.now();
84
+ if (outputFormat !== 'json') {
85
+ await pretty.info('Checking content...');
86
+ }
87
+ const guardrail = (0, llm_guardrail_1.createLLMGuardrail)({
88
+ name: 'cli-guardrail',
89
+ llm: config.model,
90
+ criteria: options.criteria || 'Content should be safe, appropriate, and helpful',
91
+ verbose: options.verbose
92
+ });
93
+ const result = await guardrail.check(content);
94
+ const duration = Date.now() - startTime;
95
+ if (outputFormat === 'json') {
96
+ (0, json_1.outputJson)((0, json_1.formatSuccess)({
97
+ content: content.substring(0, 100) + (content.length > 100 ? '...' : ''),
98
+ status: result.status,
99
+ score: result.score,
100
+ message: result.message,
101
+ reasoning: result.reasoning
102
+ }, {
103
+ duration_ms: duration,
104
+ model: config.model
105
+ }));
106
+ }
107
+ else {
108
+ await pretty.heading('Guardrail Check');
109
+ if (result.status === 'passed') {
110
+ await pretty.success('Content passed guardrail check');
111
+ }
112
+ else if (result.status === 'warning') {
113
+ await pretty.warn('Content has warnings');
114
+ }
115
+ else {
116
+ await pretty.error('Content failed guardrail check');
117
+ }
118
+ await pretty.plain(`Score: ${(result.score * 10).toFixed(1)}/10`);
119
+ if (result.message) {
120
+ await pretty.plain(`Message: ${result.message}`);
121
+ }
122
+ if (result.reasoning) {
123
+ await pretty.dim(`Reasoning: ${result.reasoning}`);
124
+ }
125
+ await pretty.newline();
126
+ await pretty.dim(`Checked in ${duration}ms`);
127
+ }
128
+ }
129
+ async function showHelp(outputFormat) {
130
+ const help = {
131
+ command: 'guardrail',
132
+ subcommands: [
133
+ { name: 'check <content>', description: 'Check content against guardrails' },
134
+ { name: 'help', description: 'Show this help' }
135
+ ],
136
+ flags: [
137
+ { name: '--criteria', description: 'Custom criteria for validation' }
138
+ ]
139
+ };
140
+ if (outputFormat === 'json') {
141
+ (0, json_1.outputJson)((0, json_1.formatSuccess)(help));
142
+ }
143
+ else {
144
+ await pretty.heading('Guardrail Command');
145
+ await pretty.plain('Content validation and safety checks\n');
146
+ await pretty.plain('Subcommands:');
147
+ for (const cmd of help.subcommands) {
148
+ await pretty.plain(` ${cmd.name.padEnd(25)} ${cmd.description}`);
149
+ }
150
+ await pretty.newline();
151
+ await pretty.plain('Flags:');
152
+ for (const flag of help.flags) {
153
+ await pretty.plain(` ${flag.name.padEnd(20)} ${flag.description}`);
154
+ }
155
+ }
156
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Handoff command - Agent handoff management
3
+ */
4
+ export interface HandoffOptions {
5
+ verbose?: boolean;
6
+ output?: 'json' | 'text' | 'pretty';
7
+ json?: boolean;
8
+ }
9
+ export declare function execute(args: string[], options: HandoffOptions): Promise<void>;
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ /**
3
+ * Handoff command - Agent handoff management
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.execute = execute;
40
+ const json_1 = require("../output/json");
41
+ const pretty = __importStar(require("../output/pretty"));
42
+ const cli_spec_1 = require("../spec/cli-spec");
43
+ const errors_1 = require("../output/errors");
44
+ async function execute(args, options) {
45
+ const action = args[0] || 'help';
46
+ const outputFormat = options.json ? 'json' : (options.output || 'pretty');
47
+ try {
48
+ switch (action) {
49
+ case 'info':
50
+ await showInfo(outputFormat);
51
+ break;
52
+ case 'help':
53
+ default:
54
+ await showHelp(outputFormat);
55
+ break;
56
+ }
57
+ }
58
+ catch (error) {
59
+ if (outputFormat === 'json') {
60
+ (0, json_1.outputJson)((0, json_1.formatError)(errors_1.ERROR_CODES.UNKNOWN, error instanceof Error ? error.message : String(error)));
61
+ }
62
+ else {
63
+ await pretty.error(error instanceof Error ? error.message : String(error));
64
+ }
65
+ process.exit(cli_spec_1.EXIT_CODES.RUNTIME_ERROR);
66
+ }
67
+ }
68
+ async function showInfo(outputFormat) {
69
+ const info = {
70
+ feature: 'Handoff',
71
+ description: 'Agent handoff allows seamless transfer of conversation context between agents',
72
+ capabilities: [
73
+ 'Transfer conversation to specialized agents',
74
+ 'Preserve context during handoff',
75
+ 'Filter handoffs based on conditions',
76
+ 'Chain multiple agent handoffs'
77
+ ],
78
+ sdkUsage: `
79
+ import { Handoff, handoff, handoffFilters } from 'praisonai';
80
+
81
+ // Create a handoff
82
+ const myHandoff = handoff({
83
+ target: specialistAgent,
84
+ condition: (ctx) => ctx.input.includes('technical'),
85
+ onHandoff: (ctx) => console.log('Handing off...')
86
+ });
87
+
88
+ // Use with an agent
89
+ const agent = new Agent({
90
+ handoffs: [myHandoff]
91
+ });
92
+ `
93
+ };
94
+ if (outputFormat === 'json') {
95
+ (0, json_1.outputJson)((0, json_1.formatSuccess)(info));
96
+ }
97
+ else {
98
+ await pretty.heading('Handoff Feature');
99
+ await pretty.plain(info.description);
100
+ await pretty.newline();
101
+ await pretty.plain('Capabilities:');
102
+ for (const cap of info.capabilities) {
103
+ await pretty.plain(` • ${cap}`);
104
+ }
105
+ await pretty.newline();
106
+ await pretty.dim('Use the SDK for programmatic handoff configuration');
107
+ }
108
+ }
109
+ async function showHelp(outputFormat) {
110
+ const help = {
111
+ command: 'handoff',
112
+ description: 'Agent handoff management - transfer conversations between agents',
113
+ subcommands: [
114
+ { name: 'info', description: 'Show handoff feature information' },
115
+ { name: 'help', description: 'Show this help' }
116
+ ],
117
+ note: 'Handoff is primarily a programmatic SDK feature. Use the SDK for full functionality.'
118
+ };
119
+ if (outputFormat === 'json') {
120
+ (0, json_1.outputJson)((0, json_1.formatSuccess)(help));
121
+ }
122
+ else {
123
+ await pretty.heading('Handoff Command');
124
+ await pretty.plain(help.description);
125
+ await pretty.newline();
126
+ await pretty.plain('Subcommands:');
127
+ for (const cmd of help.subcommands) {
128
+ await pretty.plain(` ${cmd.name.padEnd(20)} ${cmd.description}`);
129
+ }
130
+ await pretty.newline();
131
+ await pretty.dim(help.note);
132
+ }
133
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Help command - Show help information
3
+ */
4
+ export interface HelpOptions {
5
+ output?: 'json' | 'text' | 'pretty';
6
+ json?: boolean;
7
+ }
8
+ export declare function execute(args: string[], options: HelpOptions): Promise<void>;
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ /**
3
+ * Help command - Show help information
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.execute = execute;
40
+ const cli_spec_1 = require("../spec/cli-spec");
41
+ const json_1 = require("../output/json");
42
+ const pretty = __importStar(require("../output/pretty"));
43
+ async function execute(args, options) {
44
+ const command = args[0];
45
+ const outputFormat = options.json ? 'json' : (options.output || 'pretty');
46
+ if (command) {
47
+ await showCommandHelp(command, outputFormat);
48
+ }
49
+ else {
50
+ await showGeneralHelp(outputFormat);
51
+ }
52
+ }
53
+ async function showGeneralHelp(outputFormat) {
54
+ const commands = Object.entries(cli_spec_1.COMMANDS).map(([name, spec]) => ({
55
+ name,
56
+ description: spec.description
57
+ }));
58
+ const flags = cli_spec_1.GLOBAL_FLAGS.map(f => ({
59
+ name: f.short ? `-${f.short}, --${f.name}` : `--${f.name}`,
60
+ description: f.description,
61
+ default: f.default
62
+ }));
63
+ if (outputFormat === 'json') {
64
+ (0, json_1.outputJson)((0, json_1.formatSuccess)({
65
+ cli_spec_version: cli_spec_1.CLI_SPEC_VERSION,
66
+ commands,
67
+ global_flags: flags
68
+ }));
69
+ }
70
+ else {
71
+ await pretty.plain(`
72
+ PraisonAI TypeScript CLI v${cli_spec_1.CLI_SPEC_VERSION}
73
+
74
+ Usage:
75
+ praisonai-ts <command> [options]
76
+
77
+ Commands:`);
78
+ for (const cmd of commands) {
79
+ await pretty.plain(` ${cmd.name.padEnd(12)} ${cmd.description}`);
80
+ }
81
+ await pretty.plain(`
82
+ Global Options:`);
83
+ for (const flag of flags) {
84
+ const defaultStr = flag.default !== undefined ? ` (default: ${flag.default})` : '';
85
+ await pretty.plain(` ${flag.name.padEnd(20)} ${flag.description}${defaultStr}`);
86
+ }
87
+ await pretty.plain(`
88
+ Environment Variables:
89
+ OPENAI_API_KEY OpenAI API key
90
+ ANTHROPIC_API_KEY Anthropic API key
91
+ GOOGLE_API_KEY Google API key
92
+ PRAISONAI_MODEL Default model
93
+
94
+ Examples:
95
+ praisonai-ts chat "Hello, how are you?"
96
+ praisonai-ts chat "Write a poem" --stream
97
+ praisonai-ts run "Analyze this data" --agent my-agent.yaml
98
+ praisonai-ts providers
99
+ praisonai-ts help chat
100
+ `);
101
+ }
102
+ }
103
+ async function showCommandHelp(command, outputFormat) {
104
+ const spec = (0, cli_spec_1.getCommandSpec)(command);
105
+ if (!spec) {
106
+ await pretty.error(`Unknown command: ${command}`);
107
+ await pretty.info('Run "praisonai-ts help" to see available commands');
108
+ return;
109
+ }
110
+ const args = spec.args || [];
111
+ const flags = [...cli_spec_1.GLOBAL_FLAGS, ...(spec.flags || [])];
112
+ const subcommands = spec.subcommands ? Object.entries(spec.subcommands) : [];
113
+ if (outputFormat === 'json') {
114
+ (0, json_1.outputJson)((0, json_1.formatSuccess)({
115
+ command,
116
+ description: spec.description,
117
+ args: args.map(a => ({
118
+ name: a.name,
119
+ type: a.type,
120
+ required: a.required,
121
+ description: a.description
122
+ })),
123
+ flags: flags.map(f => ({
124
+ name: f.name,
125
+ short: f.short,
126
+ type: f.type,
127
+ default: f.default,
128
+ description: f.description
129
+ })),
130
+ subcommands: subcommands.map(([name, sub]) => ({
131
+ name,
132
+ description: sub.description
133
+ }))
134
+ }));
135
+ }
136
+ else {
137
+ await pretty.plain(`
138
+ Command: ${command}
139
+ ${spec.description}
140
+
141
+ Usage:
142
+ praisonai-ts ${command}${args.length ? ' ' + args.map(a => a.required ? `<${a.name}>` : `[${a.name}]`).join(' ') : ''} [options]`);
143
+ if (args.length > 0) {
144
+ await pretty.plain(`
145
+ Arguments:`);
146
+ for (const arg of args) {
147
+ const reqStr = arg.required ? ' (required)' : '';
148
+ await pretty.plain(` ${arg.name.padEnd(15)} ${arg.description || arg.type}${reqStr}`);
149
+ }
150
+ }
151
+ if (subcommands.length > 0) {
152
+ await pretty.plain(`
153
+ Subcommands:`);
154
+ for (const [name, sub] of subcommands) {
155
+ await pretty.plain(` ${name.padEnd(15)} ${sub.description}`);
156
+ }
157
+ }
158
+ await pretty.plain(`
159
+ Options:`);
160
+ for (const flag of flags) {
161
+ const shortStr = flag.short ? `-${flag.short}, ` : ' ';
162
+ const defaultStr = flag.default !== undefined ? ` (default: ${flag.default})` : '';
163
+ await pretty.plain(` ${shortStr}--${flag.name.padEnd(14)} ${flag.description || ''}${defaultStr}`);
164
+ }
165
+ await pretty.plain('');
166
+ }
167
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Image command - Image generation and analysis
3
+ */
4
+ export interface ImageOptions {
5
+ model?: string;
6
+ verbose?: boolean;
7
+ output?: 'json' | 'text' | 'pretty';
8
+ json?: boolean;
9
+ size?: string;
10
+ quality?: string;
11
+ style?: string;
12
+ }
13
+ export declare function execute(args: string[], options: ImageOptions): Promise<void>;
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ /**
3
+ * Image command - Image generation and analysis
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.execute = execute;
40
+ const image_1 = require("../../agent/image");
41
+ const resolve_1 = require("../config/resolve");
42
+ const json_1 = require("../output/json");
43
+ const pretty = __importStar(require("../output/pretty"));
44
+ const cli_spec_1 = require("../spec/cli-spec");
45
+ const errors_1 = require("../output/errors");
46
+ async function execute(args, options) {
47
+ const action = args[0] || 'help';
48
+ const actionArgs = args.slice(1);
49
+ const outputFormat = options.json ? 'json' : (options.output || 'pretty');
50
+ const config = (0, resolve_1.resolveConfig)(options);
51
+ try {
52
+ switch (action) {
53
+ case 'generate':
54
+ await generateImage(actionArgs, options, config, outputFormat);
55
+ break;
56
+ case 'analyze':
57
+ await analyzeImage(actionArgs, options, config, outputFormat);
58
+ break;
59
+ case 'help':
60
+ default:
61
+ await showHelp(outputFormat);
62
+ break;
63
+ }
64
+ }
65
+ catch (error) {
66
+ if (outputFormat === 'json') {
67
+ (0, json_1.outputJson)((0, json_1.formatError)(errors_1.ERROR_CODES.UNKNOWN, error instanceof Error ? error.message : String(error)));
68
+ }
69
+ else {
70
+ await pretty.error(error instanceof Error ? error.message : String(error));
71
+ }
72
+ process.exit(cli_spec_1.EXIT_CODES.RUNTIME_ERROR);
73
+ }
74
+ }
75
+ async function generateImage(args, options, config, outputFormat) {
76
+ const prompt = args.join(' ');
77
+ if (!prompt) {
78
+ if (outputFormat === 'json') {
79
+ (0, json_1.outputJson)((0, json_1.formatError)(errors_1.ERROR_CODES.MISSING_ARG, 'Please provide a prompt for image generation'));
80
+ }
81
+ else {
82
+ await pretty.error('Please provide a prompt for image generation');
83
+ }
84
+ process.exit(cli_spec_1.EXIT_CODES.INVALID_ARGUMENTS);
85
+ }
86
+ const startTime = Date.now();
87
+ if (outputFormat !== 'json') {
88
+ await pretty.info(`Generating image: "${prompt}"`);
89
+ }
90
+ const agent = (0, image_1.createImageAgent)({
91
+ llm: config.model,
92
+ verbose: options.verbose
93
+ });
94
+ const result = await agent.generate({
95
+ prompt,
96
+ size: options.size,
97
+ quality: options.quality,
98
+ style: options.style
99
+ });
100
+ const duration = Date.now() - startTime;
101
+ const urls = Array.isArray(result) ? result : [result];
102
+ if (outputFormat === 'json') {
103
+ (0, json_1.outputJson)((0, json_1.formatSuccess)({
104
+ prompt,
105
+ urls
106
+ }, {
107
+ duration_ms: duration,
108
+ model: config.model
109
+ }));
110
+ }
111
+ else {
112
+ await pretty.heading('Generated Image');
113
+ for (const url of urls) {
114
+ await pretty.plain(`URL: ${url}`);
115
+ }
116
+ await pretty.newline();
117
+ await pretty.success(`Generated in ${duration}ms`);
118
+ }
119
+ }
120
+ async function analyzeImage(args, options, config, outputFormat) {
121
+ const imageUrl = args[0];
122
+ const prompt = args.slice(1).join(' ') || 'Describe this image';
123
+ if (!imageUrl) {
124
+ if (outputFormat === 'json') {
125
+ (0, json_1.outputJson)((0, json_1.formatError)(errors_1.ERROR_CODES.MISSING_ARG, 'Please provide an image URL'));
126
+ }
127
+ else {
128
+ await pretty.error('Please provide an image URL');
129
+ }
130
+ process.exit(cli_spec_1.EXIT_CODES.INVALID_ARGUMENTS);
131
+ }
132
+ const startTime = Date.now();
133
+ if (outputFormat !== 'json') {
134
+ await pretty.info(`Analyzing image: ${imageUrl}`);
135
+ }
136
+ const agent = (0, image_1.createImageAgent)({
137
+ llm: config.model,
138
+ verbose: options.verbose
139
+ });
140
+ const result = await agent.analyze({
141
+ imageUrl,
142
+ prompt
143
+ });
144
+ const duration = Date.now() - startTime;
145
+ if (outputFormat === 'json') {
146
+ (0, json_1.outputJson)((0, json_1.formatSuccess)({
147
+ imageUrl,
148
+ prompt,
149
+ analysis: result
150
+ }, {
151
+ duration_ms: duration,
152
+ model: config.model
153
+ }));
154
+ }
155
+ else {
156
+ await pretty.heading('Image Analysis');
157
+ await pretty.plain(result);
158
+ await pretty.newline();
159
+ await pretty.success(`Analyzed in ${duration}ms`);
160
+ }
161
+ }
162
+ async function showHelp(outputFormat) {
163
+ const help = {
164
+ command: 'image',
165
+ subcommands: [
166
+ { name: 'generate <prompt>', description: 'Generate an image from text' },
167
+ { name: 'analyze <url> [question]', description: 'Analyze an image' },
168
+ { name: 'help', description: 'Show this help' }
169
+ ],
170
+ flags: [
171
+ { name: '--size', description: 'Image size (1024x1024, 1792x1024, 1024x1792)' },
172
+ { name: '--quality', description: 'Image quality (standard, hd)' },
173
+ { name: '--style', description: 'Image style (vivid, natural)' }
174
+ ]
175
+ };
176
+ if (outputFormat === 'json') {
177
+ (0, json_1.outputJson)((0, json_1.formatSuccess)(help));
178
+ }
179
+ else {
180
+ await pretty.heading('Image Command');
181
+ await pretty.plain('Generate and analyze images\n');
182
+ await pretty.plain('Subcommands:');
183
+ for (const cmd of help.subcommands) {
184
+ await pretty.plain(` ${cmd.name.padEnd(30)} ${cmd.description}`);
185
+ }
186
+ await pretty.newline();
187
+ await pretty.plain('Flags:');
188
+ for (const flag of help.flags) {
189
+ await pretty.plain(` ${flag.name.padEnd(20)} ${flag.description}`);
190
+ }
191
+ }
192
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * CLI command: interactive
3
+ * Interactive TUI mode with slash commands
4
+ */
5
+ export declare function execute(args: string[], options: Record<string, unknown>): Promise<void>;
6
+ export declare function showHelp(): void;