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,296 @@
1
+ "use strict";
2
+ /**
3
+ * N8N Integration - Webhook triggers and workflow export for n8n
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.N8NIntegration = void 0;
40
+ exports.createN8NIntegration = createN8NIntegration;
41
+ exports.triggerN8NWebhook = triggerN8NWebhook;
42
+ /**
43
+ * N8N Integration class
44
+ */
45
+ class N8NIntegration {
46
+ constructor(config = {}) {
47
+ this.config = {
48
+ baseUrl: config.baseUrl || process.env.N8N_BASE_URL || 'http://localhost:5678',
49
+ apiKey: config.apiKey || process.env.N8N_API_KEY,
50
+ webhookPath: config.webhookPath || '/webhook',
51
+ ...config
52
+ };
53
+ }
54
+ /**
55
+ * Trigger a webhook
56
+ */
57
+ async triggerWebhook(webhookId, payload) {
58
+ const url = `${this.config.baseUrl}${this.config.webhookPath}/${webhookId}`;
59
+ try {
60
+ const response = await fetch(url, {
61
+ method: 'POST',
62
+ headers: {
63
+ 'Content-Type': 'application/json',
64
+ ...(this.config.apiKey ? { 'X-N8N-API-KEY': this.config.apiKey } : {})
65
+ },
66
+ body: JSON.stringify(payload)
67
+ });
68
+ if (!response.ok) {
69
+ const error = await response.text();
70
+ return { success: false, error: `HTTP ${response.status}: ${error}` };
71
+ }
72
+ const data = await response.json().catch(() => ({}));
73
+ return { success: true, response: data };
74
+ }
75
+ catch (error) {
76
+ return { success: false, error: error.message };
77
+ }
78
+ }
79
+ /**
80
+ * Create a webhook payload for agent events
81
+ */
82
+ createAgentEventPayload(event, agentId, data) {
83
+ return {
84
+ event,
85
+ data: {
86
+ agentId,
87
+ ...data
88
+ },
89
+ timestamp: new Date().toISOString(),
90
+ source: 'praisonai'
91
+ };
92
+ }
93
+ /**
94
+ * Export PraisonAI workflow to n8n format
95
+ */
96
+ exportWorkflow(name, steps) {
97
+ const nodes = [];
98
+ const connections = {};
99
+ // Add trigger node
100
+ nodes.push({
101
+ id: 'trigger',
102
+ name: 'Webhook Trigger',
103
+ type: 'n8n-nodes-base.webhook',
104
+ position: [250, 300],
105
+ parameters: {
106
+ httpMethod: 'POST',
107
+ path: name.toLowerCase().replace(/\s+/g, '-'),
108
+ responseMode: 'onReceived'
109
+ }
110
+ });
111
+ let prevNodeId = 'trigger';
112
+ let yPosition = 300;
113
+ for (let i = 0; i < steps.length; i++) {
114
+ const step = steps[i];
115
+ const nodeId = `node_${i}`;
116
+ yPosition += 150;
117
+ // Map step type to n8n node type
118
+ const nodeType = this.mapStepTypeToN8N(step.type);
119
+ nodes.push({
120
+ id: nodeId,
121
+ name: step.name,
122
+ type: nodeType,
123
+ position: [250, yPosition],
124
+ parameters: this.mapStepParameters(step)
125
+ });
126
+ // Add connection from previous node
127
+ if (!connections[prevNodeId]) {
128
+ connections[prevNodeId] = { main: [[]] };
129
+ }
130
+ connections[prevNodeId].main[0].push({
131
+ node: nodeId,
132
+ type: 'main',
133
+ index: 0
134
+ });
135
+ prevNodeId = nodeId;
136
+ }
137
+ // Add response node
138
+ const responseNodeId = 'response';
139
+ nodes.push({
140
+ id: responseNodeId,
141
+ name: 'Response',
142
+ type: 'n8n-nodes-base.respondToWebhook',
143
+ position: [250, yPosition + 150],
144
+ parameters: {
145
+ respondWith: 'json',
146
+ responseBody: '={{ $json }}'
147
+ }
148
+ });
149
+ connections[prevNodeId] = {
150
+ main: [[{ node: responseNodeId, type: 'main', index: 0 }]]
151
+ };
152
+ return {
153
+ name,
154
+ nodes,
155
+ connections,
156
+ settings: {
157
+ executionOrder: 'v1'
158
+ }
159
+ };
160
+ }
161
+ /**
162
+ * Map PraisonAI step type to n8n node type
163
+ */
164
+ mapStepTypeToN8N(type) {
165
+ const mapping = {
166
+ agent: 'n8n-nodes-base.httpRequest',
167
+ tool: 'n8n-nodes-base.function',
168
+ condition: 'n8n-nodes-base.if'
169
+ };
170
+ return mapping[type] || 'n8n-nodes-base.noOp';
171
+ }
172
+ /**
173
+ * Map step parameters to n8n format
174
+ */
175
+ mapStepParameters(step) {
176
+ switch (step.type) {
177
+ case 'agent':
178
+ return {
179
+ method: 'POST',
180
+ url: '={{ $env.PRAISONAI_API_URL }}/agent/execute',
181
+ sendBody: true,
182
+ bodyParameters: {
183
+ parameters: [
184
+ { name: 'input', value: '={{ $json.input }}' }
185
+ ]
186
+ },
187
+ ...step.config
188
+ };
189
+ case 'tool':
190
+ return {
191
+ functionCode: `
192
+ // Tool execution
193
+ const input = $input.all();
194
+ // Add your tool logic here
195
+ return input;
196
+ `.trim(),
197
+ ...step.config
198
+ };
199
+ case 'condition':
200
+ return {
201
+ conditions: {
202
+ boolean: [
203
+ {
204
+ value1: '={{ $json.success }}',
205
+ value2: true
206
+ }
207
+ ]
208
+ },
209
+ ...step.config
210
+ };
211
+ default:
212
+ return step.config || {};
213
+ }
214
+ }
215
+ /**
216
+ * Generate n8n workflow JSON string
217
+ */
218
+ exportWorkflowJSON(name, steps) {
219
+ const workflow = this.exportWorkflow(name, steps);
220
+ return JSON.stringify(workflow, null, 2);
221
+ }
222
+ /**
223
+ * Import n8n workflow and convert to PraisonAI format
224
+ */
225
+ importWorkflow(n8nWorkflow) {
226
+ const steps = [];
227
+ // Skip trigger and response nodes
228
+ const workflowNodes = n8nWorkflow.nodes.filter(n => !n.type.includes('webhook') && !n.type.includes('respondToWebhook'));
229
+ for (const node of workflowNodes) {
230
+ steps.push({
231
+ name: node.name,
232
+ type: this.mapN8NTypeToStep(node.type),
233
+ config: node.parameters
234
+ });
235
+ }
236
+ return steps;
237
+ }
238
+ /**
239
+ * Map n8n node type to PraisonAI step type
240
+ */
241
+ mapN8NTypeToStep(n8nType) {
242
+ if (n8nType.includes('httpRequest'))
243
+ return 'agent';
244
+ if (n8nType.includes('function') || n8nType.includes('code'))
245
+ return 'tool';
246
+ if (n8nType.includes('if') || n8nType.includes('switch'))
247
+ return 'condition';
248
+ return 'tool';
249
+ }
250
+ /**
251
+ * Create a webhook listener (for local development)
252
+ */
253
+ async createWebhookListener(port, handler) {
254
+ const http = await Promise.resolve().then(() => __importStar(require('http')));
255
+ const server = http.createServer(async (req, res) => {
256
+ if (req.method !== 'POST') {
257
+ res.writeHead(405);
258
+ res.end('Method not allowed');
259
+ return;
260
+ }
261
+ let body = '';
262
+ req.on('data', chunk => { body += chunk; });
263
+ req.on('end', async () => {
264
+ try {
265
+ const payload = JSON.parse(body);
266
+ const result = await handler(payload);
267
+ res.writeHead(200, { 'Content-Type': 'application/json' });
268
+ res.end(JSON.stringify(result));
269
+ }
270
+ catch (error) {
271
+ res.writeHead(500);
272
+ res.end(JSON.stringify({ error: error.message }));
273
+ }
274
+ });
275
+ });
276
+ server.listen(port);
277
+ console.log(`N8N webhook listener started on port ${port}`);
278
+ return {
279
+ close: () => server.close()
280
+ };
281
+ }
282
+ }
283
+ exports.N8NIntegration = N8NIntegration;
284
+ /**
285
+ * Create an n8n integration instance
286
+ */
287
+ function createN8NIntegration(config) {
288
+ return new N8NIntegration(config);
289
+ }
290
+ /**
291
+ * Quick function to trigger an n8n webhook
292
+ */
293
+ async function triggerN8NWebhook(webhookId, payload, config) {
294
+ const integration = createN8NIntegration(config);
295
+ return integration.triggerWebhook(webhookId, payload);
296
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Repo Map - Repository structure visualization and symbol extraction
3
+ */
4
+ export interface RepoMapConfig {
5
+ rootPath: string;
6
+ maxDepth?: number;
7
+ ignorePatterns?: string[];
8
+ includeSymbols?: boolean;
9
+ maxFiles?: number;
10
+ }
11
+ export interface FileInfo {
12
+ path: string;
13
+ relativePath: string;
14
+ size: number;
15
+ isDirectory: boolean;
16
+ children?: FileInfo[];
17
+ symbols?: SymbolInfo[];
18
+ }
19
+ export interface SymbolInfo {
20
+ name: string;
21
+ type: 'function' | 'class' | 'method' | 'variable' | 'interface' | 'type' | 'export';
22
+ line: number;
23
+ exported?: boolean;
24
+ }
25
+ export interface RepoMapResult {
26
+ root: string;
27
+ tree: FileInfo;
28
+ totalFiles: number;
29
+ totalDirectories: number;
30
+ symbols: SymbolInfo[];
31
+ summary: string;
32
+ }
33
+ /**
34
+ * Default ignore patterns
35
+ */
36
+ export declare const DEFAULT_IGNORE_PATTERNS: string[];
37
+ /**
38
+ * RepoMap class for repository analysis
39
+ */
40
+ export declare class RepoMap {
41
+ private config;
42
+ private fs;
43
+ private path;
44
+ constructor(config: RepoMapConfig);
45
+ /**
46
+ * Generate repository map
47
+ */
48
+ generate(): Promise<RepoMapResult>;
49
+ /**
50
+ * Scan a directory recursively
51
+ */
52
+ private scanDirectory;
53
+ /**
54
+ * Check if path should be ignored
55
+ */
56
+ private shouldIgnore;
57
+ /**
58
+ * Check if file is a code file
59
+ */
60
+ private isCodeFile;
61
+ /**
62
+ * Extract symbols from a file
63
+ */
64
+ private extractSymbols;
65
+ /**
66
+ * Extract symbols from JavaScript/TypeScript
67
+ */
68
+ private extractJSSymbols;
69
+ /**
70
+ * Extract symbols from Python
71
+ */
72
+ private extractPythonSymbols;
73
+ /**
74
+ * Count files and directories
75
+ */
76
+ private countItems;
77
+ /**
78
+ * Collect all symbols from tree
79
+ */
80
+ private collectSymbols;
81
+ /**
82
+ * Generate text summary
83
+ */
84
+ private generateSummary;
85
+ /**
86
+ * Render tree as text
87
+ */
88
+ private renderTree;
89
+ /**
90
+ * Get tree as simple text format
91
+ */
92
+ getTreeText(): Promise<string>;
93
+ }
94
+ /**
95
+ * Create a repo map instance
96
+ */
97
+ export declare function createRepoMap(config: RepoMapConfig): RepoMap;
98
+ /**
99
+ * Quick function to get repo tree
100
+ */
101
+ export declare function getRepoTree(rootPath: string, maxDepth?: number): Promise<string>;