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,314 @@
1
+ "use strict";
2
+ /**
3
+ * Sandbox Executor - Safe command execution with restrictions
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.SandboxExecutor = exports.CommandValidator = exports.DEFAULT_BLOCKED_PATHS = exports.DEFAULT_BLOCKED_COMMANDS = void 0;
40
+ exports.createSandboxExecutor = createSandboxExecutor;
41
+ exports.sandboxExec = sandboxExec;
42
+ /**
43
+ * Default blocked commands (dangerous operations)
44
+ */
45
+ exports.DEFAULT_BLOCKED_COMMANDS = [
46
+ 'rm -rf /',
47
+ 'rm -rf /*',
48
+ 'rm -rf ~',
49
+ 'rm -rf ~/*',
50
+ 'mkfs',
51
+ 'dd if=/dev/zero',
52
+ 'dd if=/dev/random',
53
+ ':(){ :|:& };:',
54
+ 'chmod -R 777 /',
55
+ 'chown -R',
56
+ 'sudo rm',
57
+ 'sudo dd',
58
+ 'sudo mkfs',
59
+ 'shutdown',
60
+ 'reboot',
61
+ 'halt',
62
+ 'poweroff',
63
+ 'init 0',
64
+ 'init 6'
65
+ ];
66
+ /**
67
+ * Default blocked paths
68
+ */
69
+ exports.DEFAULT_BLOCKED_PATHS = [
70
+ '/etc/passwd',
71
+ '/etc/shadow',
72
+ '/etc/sudoers',
73
+ '/root',
74
+ '~/.ssh',
75
+ '~/.gnupg',
76
+ '~/.aws',
77
+ '~/.config/gcloud',
78
+ '/var/log',
79
+ '/boot',
80
+ '/sys',
81
+ '/proc'
82
+ ];
83
+ /**
84
+ * Command validator
85
+ */
86
+ class CommandValidator {
87
+ constructor(config = {}) {
88
+ this.blockedCommands = config.blockedCommands || exports.DEFAULT_BLOCKED_COMMANDS;
89
+ this.blockedPaths = config.blockedPaths || exports.DEFAULT_BLOCKED_PATHS;
90
+ this.allowedCommands = config.allowedCommands;
91
+ }
92
+ /**
93
+ * Validate a command
94
+ */
95
+ validate(command) {
96
+ const normalized = command.toLowerCase().trim();
97
+ // Check allowlist first if specified
98
+ if (this.allowedCommands) {
99
+ const baseCmd = normalized.split(/\s+/)[0];
100
+ if (!this.allowedCommands.includes(baseCmd)) {
101
+ return { valid: false, reason: `Command '${baseCmd}' not in allowlist` };
102
+ }
103
+ }
104
+ // Check blocked commands
105
+ for (const blocked of this.blockedCommands) {
106
+ if (normalized.includes(blocked.toLowerCase())) {
107
+ return { valid: false, reason: `Blocked command pattern: ${blocked}` };
108
+ }
109
+ }
110
+ // Check blocked paths
111
+ for (const blockedPath of this.blockedPaths) {
112
+ const expandedPath = blockedPath.replace('~', process.env.HOME || '');
113
+ if (normalized.includes(expandedPath.toLowerCase())) {
114
+ return { valid: false, reason: `Blocked path: ${blockedPath}` };
115
+ }
116
+ }
117
+ // Check for shell injection patterns
118
+ const dangerousPatterns = [
119
+ /;\s*rm\s/i,
120
+ /\|\s*rm\s/i,
121
+ /`.*`/,
122
+ /\$\(.*\)/,
123
+ />\s*\/dev\/sd/i,
124
+ />\s*\/dev\/null.*2>&1.*&/i
125
+ ];
126
+ for (const pattern of dangerousPatterns) {
127
+ if (pattern.test(command)) {
128
+ return { valid: false, reason: 'Potentially dangerous pattern detected' };
129
+ }
130
+ }
131
+ return { valid: true };
132
+ }
133
+ }
134
+ exports.CommandValidator = CommandValidator;
135
+ /**
136
+ * Sandbox Executor class
137
+ */
138
+ class SandboxExecutor {
139
+ constructor(config = {}) {
140
+ this.config = {
141
+ mode: 'basic',
142
+ timeout: 30000,
143
+ maxOutputSize: 1024 * 1024, // 1MB
144
+ cwd: process.cwd(),
145
+ ...config
146
+ };
147
+ this.validator = new CommandValidator(this.config);
148
+ }
149
+ /**
150
+ * Execute a command in the sandbox
151
+ */
152
+ async execute(command) {
153
+ const startTime = Date.now();
154
+ // Disabled mode - no execution
155
+ if (this.config.mode === 'disabled') {
156
+ return {
157
+ success: false,
158
+ stdout: '',
159
+ stderr: 'Sandbox execution is disabled',
160
+ exitCode: 1,
161
+ duration: 0
162
+ };
163
+ }
164
+ // Validate command
165
+ const validation = this.validator.validate(command);
166
+ if (!validation.valid) {
167
+ return {
168
+ success: false,
169
+ stdout: '',
170
+ stderr: `Command rejected: ${validation.reason}`,
171
+ exitCode: 1,
172
+ duration: 0
173
+ };
174
+ }
175
+ try {
176
+ const result = await this.spawn(command);
177
+ return {
178
+ ...result,
179
+ duration: Date.now() - startTime
180
+ };
181
+ }
182
+ catch (error) {
183
+ return {
184
+ success: false,
185
+ stdout: '',
186
+ stderr: error.message,
187
+ exitCode: 1,
188
+ duration: Date.now() - startTime
189
+ };
190
+ }
191
+ }
192
+ /**
193
+ * Spawn the command
194
+ */
195
+ async spawn(command) {
196
+ const { spawn } = await Promise.resolve().then(() => __importStar(require('child_process')));
197
+ return new Promise((resolve) => {
198
+ const env = this.buildEnv();
199
+ const proc = spawn('sh', ['-c', command], {
200
+ cwd: this.config.cwd,
201
+ env,
202
+ timeout: this.config.timeout,
203
+ stdio: ['pipe', 'pipe', 'pipe']
204
+ });
205
+ let stdout = '';
206
+ let stderr = '';
207
+ let truncated = false;
208
+ const maxSize = this.config.maxOutputSize || 1024 * 1024;
209
+ proc.stdout?.on('data', (data) => {
210
+ if (stdout.length < maxSize) {
211
+ stdout += data.toString();
212
+ if (stdout.length > maxSize) {
213
+ stdout = stdout.slice(0, maxSize);
214
+ truncated = true;
215
+ }
216
+ }
217
+ });
218
+ proc.stderr?.on('data', (data) => {
219
+ if (stderr.length < maxSize) {
220
+ stderr += data.toString();
221
+ if (stderr.length > maxSize) {
222
+ stderr = stderr.slice(0, maxSize);
223
+ truncated = true;
224
+ }
225
+ }
226
+ });
227
+ proc.on('close', (code) => {
228
+ resolve({
229
+ success: code === 0,
230
+ stdout,
231
+ stderr,
232
+ exitCode: code || 0,
233
+ truncated
234
+ });
235
+ });
236
+ proc.on('error', (error) => {
237
+ resolve({
238
+ success: false,
239
+ stdout,
240
+ stderr: error.message,
241
+ exitCode: 1
242
+ });
243
+ });
244
+ });
245
+ }
246
+ /**
247
+ * Build environment variables based on sandbox mode
248
+ */
249
+ buildEnv() {
250
+ const baseEnv = { ...process.env, ...this.config.env };
251
+ switch (this.config.mode) {
252
+ case 'strict':
253
+ // Minimal environment
254
+ return {
255
+ PATH: '/usr/local/bin:/usr/bin:/bin',
256
+ HOME: process.env.HOME || '',
257
+ USER: process.env.USER || '',
258
+ SHELL: '/bin/sh',
259
+ TERM: 'dumb',
260
+ ...this.config.env
261
+ };
262
+ case 'network-isolated':
263
+ // No network access (requires additional OS-level setup)
264
+ return {
265
+ ...baseEnv,
266
+ http_proxy: 'http://localhost:0',
267
+ https_proxy: 'http://localhost:0',
268
+ HTTP_PROXY: 'http://localhost:0',
269
+ HTTPS_PROXY: 'http://localhost:0',
270
+ no_proxy: '',
271
+ NO_PROXY: ''
272
+ };
273
+ case 'basic':
274
+ default:
275
+ return baseEnv;
276
+ }
277
+ }
278
+ /**
279
+ * Check if a command would be allowed
280
+ */
281
+ wouldAllow(command) {
282
+ if (this.config.mode === 'disabled') {
283
+ return { allowed: false, reason: 'Sandbox execution is disabled' };
284
+ }
285
+ const validation = this.validator.validate(command);
286
+ return { allowed: validation.valid, reason: validation.reason };
287
+ }
288
+ /**
289
+ * Get current sandbox mode
290
+ */
291
+ getMode() {
292
+ return this.config.mode;
293
+ }
294
+ /**
295
+ * Update sandbox mode
296
+ */
297
+ setMode(mode) {
298
+ this.config.mode = mode;
299
+ }
300
+ }
301
+ exports.SandboxExecutor = SandboxExecutor;
302
+ /**
303
+ * Create a sandbox executor
304
+ */
305
+ function createSandboxExecutor(config) {
306
+ return new SandboxExecutor(config);
307
+ }
308
+ /**
309
+ * Quick execute with default sandbox
310
+ */
311
+ async function sandboxExec(command, config) {
312
+ const executor = createSandboxExecutor(config);
313
+ return executor.execute(command);
314
+ }
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Agent Scheduler - Cron-like scheduling for agent tasks
3
+ */
4
+ export interface ScheduleConfig {
5
+ id?: string;
6
+ name: string;
7
+ cron?: string;
8
+ interval?: number;
9
+ task: () => Promise<any>;
10
+ enabled?: boolean;
11
+ maxRuns?: number;
12
+ onComplete?: (result: any) => void;
13
+ onError?: (error: Error) => void;
14
+ }
15
+ export interface ScheduledTask {
16
+ id: string;
17
+ name: string;
18
+ cron?: string;
19
+ interval?: number;
20
+ enabled: boolean;
21
+ lastRun?: Date;
22
+ nextRun?: Date;
23
+ runCount: number;
24
+ maxRuns?: number;
25
+ status: 'idle' | 'running' | 'completed' | 'error';
26
+ lastError?: string;
27
+ }
28
+ export interface SchedulerStats {
29
+ totalTasks: number;
30
+ activeTasks: number;
31
+ totalRuns: number;
32
+ errors: number;
33
+ }
34
+ /**
35
+ * Scheduler class
36
+ */
37
+ export declare class Scheduler {
38
+ private tasks;
39
+ private running;
40
+ private stats;
41
+ /**
42
+ * Add a scheduled task
43
+ */
44
+ add(config: ScheduleConfig): string;
45
+ /**
46
+ * Remove a task
47
+ */
48
+ remove(id: string): boolean;
49
+ /**
50
+ * Enable a task
51
+ */
52
+ enable(id: string): boolean;
53
+ /**
54
+ * Disable a task
55
+ */
56
+ disable(id: string): boolean;
57
+ /**
58
+ * Start the scheduler
59
+ */
60
+ start(): void;
61
+ /**
62
+ * Stop the scheduler
63
+ */
64
+ stop(): void;
65
+ /**
66
+ * Schedule a task's next run
67
+ */
68
+ private scheduleTask;
69
+ /**
70
+ * Run a task
71
+ */
72
+ private runTask;
73
+ /**
74
+ * Run a task immediately
75
+ */
76
+ runNow(id: string): Promise<any>;
77
+ /**
78
+ * Get task info
79
+ */
80
+ getTask(id: string): ScheduledTask | undefined;
81
+ /**
82
+ * Get all tasks
83
+ */
84
+ getAllTasks(): ScheduledTask[];
85
+ /**
86
+ * Get scheduler stats
87
+ */
88
+ getStats(): SchedulerStats;
89
+ /**
90
+ * Check if scheduler is running
91
+ */
92
+ isRunning(): boolean;
93
+ }
94
+ /**
95
+ * Create a scheduler instance
96
+ */
97
+ export declare function createScheduler(): Scheduler;
98
+ /**
99
+ * Helper to create common cron expressions
100
+ */
101
+ export declare const cronExpressions: {
102
+ everyMinute: string;
103
+ every5Minutes: string;
104
+ every15Minutes: string;
105
+ everyHour: string;
106
+ everyDay: string;
107
+ everyWeek: string;
108
+ everyMonth: string;
109
+ weekdays: string;
110
+ weekends: string;
111
+ };