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.
- package/dist/agent/simple.js +1 -1
- package/dist/cli/commands/auto.d.ts +12 -0
- package/dist/cli/commands/auto.js +109 -0
- package/dist/cli/commands/autonomy.d.ts +5 -0
- package/dist/cli/commands/autonomy.js +152 -0
- package/dist/cli/commands/cache.d.ts +9 -0
- package/dist/cli/commands/cache.js +143 -0
- package/dist/cli/commands/chat.d.ts +14 -0
- package/dist/cli/commands/chat.js +127 -0
- package/dist/cli/commands/checkpoints.d.ts +5 -0
- package/dist/cli/commands/checkpoints.js +236 -0
- package/dist/cli/commands/context.d.ts +11 -0
- package/dist/cli/commands/context.js +182 -0
- package/dist/cli/commands/cost.d.ts +5 -0
- package/dist/cli/commands/cost.js +146 -0
- package/dist/cli/commands/db.d.ts +9 -0
- package/dist/cli/commands/db.js +149 -0
- package/dist/cli/commands/eval.d.ts +17 -0
- package/dist/cli/commands/eval.js +247 -0
- package/dist/cli/commands/external-agents.d.ts +5 -0
- package/dist/cli/commands/external-agents.js +169 -0
- package/dist/cli/commands/fast-context.d.ts +5 -0
- package/dist/cli/commands/fast-context.js +126 -0
- package/dist/cli/commands/flow.d.ts +5 -0
- package/dist/cli/commands/flow.js +141 -0
- package/dist/cli/commands/git.d.ts +5 -0
- package/dist/cli/commands/git.js +178 -0
- package/dist/cli/commands/graph-rag.d.ts +9 -0
- package/dist/cli/commands/graph-rag.js +131 -0
- package/dist/cli/commands/guardrail.d.ts +11 -0
- package/dist/cli/commands/guardrail.js +156 -0
- package/dist/cli/commands/handoff.d.ts +9 -0
- package/dist/cli/commands/handoff.js +133 -0
- package/dist/cli/commands/help.d.ts +8 -0
- package/dist/cli/commands/help.js +167 -0
- package/dist/cli/commands/image.d.ts +13 -0
- package/dist/cli/commands/image.js +192 -0
- package/dist/cli/commands/interactive.d.ts +6 -0
- package/dist/cli/commands/interactive.js +79 -0
- package/dist/cli/commands/jobs.d.ts +5 -0
- package/dist/cli/commands/jobs.js +282 -0
- package/dist/cli/commands/knowledge.d.ts +9 -0
- package/dist/cli/commands/knowledge.js +226 -0
- package/dist/cli/commands/mcp.d.ts +9 -0
- package/dist/cli/commands/mcp.js +243 -0
- package/dist/cli/commands/memory.d.ts +10 -0
- package/dist/cli/commands/memory.js +198 -0
- package/dist/cli/commands/n8n.d.ts +5 -0
- package/dist/cli/commands/n8n.js +137 -0
- package/dist/cli/commands/observability.d.ts +9 -0
- package/dist/cli/commands/observability.js +145 -0
- package/dist/cli/commands/planning.d.ts +9 -0
- package/dist/cli/commands/planning.js +167 -0
- package/dist/cli/commands/prompt-expand.d.ts +11 -0
- package/dist/cli/commands/prompt-expand.js +100 -0
- package/dist/cli/commands/providers.d.ts +9 -0
- package/dist/cli/commands/providers.js +98 -0
- package/dist/cli/commands/query-rewrite.d.ts +12 -0
- package/dist/cli/commands/query-rewrite.js +102 -0
- package/dist/cli/commands/repo-map.d.ts +5 -0
- package/dist/cli/commands/repo-map.js +151 -0
- package/dist/cli/commands/reranker.d.ts +10 -0
- package/dist/cli/commands/reranker.js +144 -0
- package/dist/cli/commands/research.d.ts +12 -0
- package/dist/cli/commands/research.js +108 -0
- package/dist/cli/commands/router.d.ts +11 -0
- package/dist/cli/commands/router.js +142 -0
- package/dist/cli/commands/run.d.ts +14 -0
- package/dist/cli/commands/run.js +111 -0
- package/dist/cli/commands/sandbox.d.ts +5 -0
- package/dist/cli/commands/sandbox.js +135 -0
- package/dist/cli/commands/scheduler.d.ts +5 -0
- package/dist/cli/commands/scheduler.js +260 -0
- package/dist/cli/commands/session.d.ts +9 -0
- package/dist/cli/commands/session.js +238 -0
- package/dist/cli/commands/skills.d.ts +9 -0
- package/dist/cli/commands/skills.js +256 -0
- package/dist/cli/commands/telemetry.d.ts +9 -0
- package/dist/cli/commands/telemetry.js +146 -0
- package/dist/cli/commands/tools.d.ts +9 -0
- package/dist/cli/commands/tools.js +172 -0
- package/dist/cli/commands/vector.d.ts +10 -0
- package/dist/cli/commands/vector.js +171 -0
- package/dist/cli/commands/version.d.ts +8 -0
- package/dist/cli/commands/version.js +68 -0
- package/dist/cli/commands/voice.d.ts +10 -0
- package/dist/cli/commands/voice.js +162 -0
- package/dist/cli/commands/workflow.d.ts +13 -0
- package/dist/cli/commands/workflow.js +184 -0
- package/dist/cli/config/index.d.ts +6 -0
- package/dist/cli/config/index.js +22 -0
- package/dist/cli/config/load.d.ts +20 -0
- package/dist/cli/config/load.js +229 -0
- package/dist/cli/config/resolve.d.ts +28 -0
- package/dist/cli/config/resolve.js +70 -0
- package/dist/cli/config/schema.d.ts +15 -0
- package/dist/cli/config/schema.js +65 -0
- package/dist/cli/features/autonomy-mode.d.ts +98 -0
- package/dist/cli/features/autonomy-mode.js +266 -0
- package/dist/cli/features/background-jobs.d.ts +155 -0
- package/dist/cli/features/background-jobs.js +416 -0
- package/dist/cli/features/checkpoints.d.ts +126 -0
- package/dist/cli/features/checkpoints.js +288 -0
- package/dist/cli/features/cost-tracker.d.ts +101 -0
- package/dist/cli/features/cost-tracker.js +212 -0
- package/dist/cli/features/external-agents.d.ts +115 -0
- package/dist/cli/features/external-agents.js +294 -0
- package/dist/cli/features/fast-context.d.ts +126 -0
- package/dist/cli/features/fast-context.js +310 -0
- package/dist/cli/features/flow-display.d.ts +100 -0
- package/dist/cli/features/flow-display.js +254 -0
- package/dist/cli/features/git-integration.d.ts +138 -0
- package/dist/cli/features/git-integration.js +374 -0
- package/dist/cli/features/index.d.ts +17 -0
- package/dist/cli/features/index.js +102 -0
- package/dist/cli/features/interactive-tui.d.ts +114 -0
- package/dist/cli/features/interactive-tui.js +326 -0
- package/dist/cli/features/n8n-integration.d.ts +108 -0
- package/dist/cli/features/n8n-integration.js +296 -0
- package/dist/cli/features/repo-map.d.ts +101 -0
- package/dist/cli/features/repo-map.js +350 -0
- package/dist/cli/features/sandbox-executor.d.ts +89 -0
- package/dist/cli/features/sandbox-executor.js +314 -0
- package/dist/cli/features/scheduler.d.ts +111 -0
- package/dist/cli/features/scheduler.js +298 -0
- package/dist/cli/features/slash-commands.d.ts +77 -0
- package/dist/cli/features/slash-commands.js +316 -0
- package/dist/cli/index.d.ts +19 -15
- package/dist/cli/index.js +163 -123
- package/dist/cli/output/errors.d.ts +32 -0
- package/dist/cli/output/errors.js +72 -0
- package/dist/cli/output/index.d.ts +6 -0
- package/dist/cli/output/index.js +22 -0
- package/dist/cli/output/json.d.ts +17 -0
- package/dist/cli/output/json.js +54 -0
- package/dist/cli/output/pretty.d.ts +21 -0
- package/dist/cli/output/pretty.js +106 -0
- package/dist/cli/runtime/env.d.ts +12 -0
- package/dist/cli/runtime/env.js +49 -0
- package/dist/cli/runtime/exit.d.ts +11 -0
- package/dist/cli/runtime/exit.js +49 -0
- package/dist/cli/runtime/index.d.ts +6 -0
- package/dist/cli/runtime/index.js +22 -0
- package/dist/cli/runtime/lazy.d.ts +18 -0
- package/dist/cli/runtime/lazy.js +85 -0
- package/dist/cli/spec/cli-spec.d.ts +87 -0
- package/dist/cli/spec/cli-spec.js +478 -0
- package/dist/cli/spec/index.d.ts +4 -0
- package/dist/cli/spec/index.js +20 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +100 -7
- package/dist/memory/auto-memory.d.ts +136 -0
- package/dist/memory/auto-memory.js +301 -0
- package/dist/memory/file-memory.d.ts +88 -0
- package/dist/memory/file-memory.js +287 -0
- package/dist/memory/index.d.ts +2 -0
- package/dist/memory/index.js +11 -1
- package/dist/workflows/loop.d.ts +0 -0
- package/dist/workflows/loop.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DB command - Database adapter 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 'adapters':
|
|
53
|
+
await listAdapters(outputFormat);
|
|
54
|
+
break;
|
|
55
|
+
case 'help':
|
|
56
|
+
default:
|
|
57
|
+
await showHelp(outputFormat);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (outputFormat === 'json') {
|
|
63
|
+
(0, json_1.outputJson)((0, json_1.formatError)(errors_1.ERROR_CODES.UNKNOWN, error instanceof Error ? error.message : String(error)));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
await pretty.error(error instanceof Error ? error.message : String(error));
|
|
67
|
+
}
|
|
68
|
+
process.exit(cli_spec_1.EXIT_CODES.RUNTIME_ERROR);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function showInfo(outputFormat) {
|
|
72
|
+
const info = {
|
|
73
|
+
feature: 'Database Adapters',
|
|
74
|
+
description: 'Database adapters for persistence and session storage',
|
|
75
|
+
adapters: [
|
|
76
|
+
{ name: 'SQLiteAdapter', description: 'SQLite database adapter' },
|
|
77
|
+
{ name: 'UpstashRedisAdapter', description: 'Upstash Redis adapter' },
|
|
78
|
+
{ name: 'MemoryRedisAdapter', description: 'In-memory Redis-compatible adapter' },
|
|
79
|
+
{ name: 'NeonPostgresAdapter', description: 'Neon PostgreSQL adapter' },
|
|
80
|
+
{ name: 'MemoryPostgresAdapter', description: 'In-memory PostgreSQL-compatible adapter' },
|
|
81
|
+
{ name: 'PostgresSessionStorage', description: 'PostgreSQL session storage' }
|
|
82
|
+
],
|
|
83
|
+
capabilities: [
|
|
84
|
+
'Store conversation history',
|
|
85
|
+
'Persist agent state',
|
|
86
|
+
'Session management',
|
|
87
|
+
'Message storage and retrieval',
|
|
88
|
+
'Trace logging'
|
|
89
|
+
]
|
|
90
|
+
};
|
|
91
|
+
if (outputFormat === 'json') {
|
|
92
|
+
(0, json_1.outputJson)((0, json_1.formatSuccess)(info));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
await pretty.heading('Database Adapters');
|
|
96
|
+
await pretty.plain(info.description);
|
|
97
|
+
await pretty.newline();
|
|
98
|
+
await pretty.plain('Available Adapters:');
|
|
99
|
+
for (const a of info.adapters) {
|
|
100
|
+
await pretty.plain(` • ${a.name}: ${a.description}`);
|
|
101
|
+
}
|
|
102
|
+
await pretty.newline();
|
|
103
|
+
await pretty.plain('Capabilities:');
|
|
104
|
+
for (const cap of info.capabilities) {
|
|
105
|
+
await pretty.plain(` • ${cap}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async function listAdapters(outputFormat) {
|
|
110
|
+
const adapters = [
|
|
111
|
+
{ name: 'sqlite', description: 'SQLite database', available: true },
|
|
112
|
+
{ name: 'redis', description: 'Redis (Upstash)', available: true },
|
|
113
|
+
{ name: 'postgres', description: 'PostgreSQL (Neon)', available: true },
|
|
114
|
+
{ name: 'memory', description: 'In-memory adapters', available: true }
|
|
115
|
+
];
|
|
116
|
+
if (outputFormat === 'json') {
|
|
117
|
+
(0, json_1.outputJson)((0, json_1.formatSuccess)({ adapters }));
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
await pretty.heading('Database Adapters');
|
|
121
|
+
for (const a of adapters) {
|
|
122
|
+
const status = a.available ? '✓' : '✗';
|
|
123
|
+
await pretty.plain(` ${status} ${a.name.padEnd(15)} ${a.description}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async function showHelp(outputFormat) {
|
|
128
|
+
const help = {
|
|
129
|
+
command: 'db',
|
|
130
|
+
description: 'Database adapter management',
|
|
131
|
+
subcommands: [
|
|
132
|
+
{ name: 'info', description: 'Show database adapter information' },
|
|
133
|
+
{ name: 'adapters', description: 'List available database adapters' },
|
|
134
|
+
{ name: 'help', description: 'Show this help' }
|
|
135
|
+
]
|
|
136
|
+
};
|
|
137
|
+
if (outputFormat === 'json') {
|
|
138
|
+
(0, json_1.outputJson)((0, json_1.formatSuccess)(help));
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
await pretty.heading('Database Command');
|
|
142
|
+
await pretty.plain(help.description);
|
|
143
|
+
await pretty.newline();
|
|
144
|
+
await pretty.plain('Subcommands:');
|
|
145
|
+
for (const cmd of help.subcommands) {
|
|
146
|
+
await pretty.plain(` ${cmd.name.padEnd(20)} ${cmd.description}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Eval command - Evaluate agent performance
|
|
3
|
+
*/
|
|
4
|
+
export interface EvalOptions {
|
|
5
|
+
input?: string;
|
|
6
|
+
expected?: string;
|
|
7
|
+
iterations?: number;
|
|
8
|
+
warmup?: number;
|
|
9
|
+
'expected-tools'?: string;
|
|
10
|
+
model?: string;
|
|
11
|
+
verbose?: boolean;
|
|
12
|
+
profile?: string;
|
|
13
|
+
config?: string;
|
|
14
|
+
output?: 'json' | 'text' | 'pretty';
|
|
15
|
+
json?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function execute(args: string[], options: EvalOptions): Promise<void>;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Eval command - Evaluate agent performance
|
|
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 agent_1 = require("../../agent");
|
|
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 subcommand = args[0];
|
|
48
|
+
if (!subcommand || !['accuracy', 'performance', 'reliability'].includes(subcommand)) {
|
|
49
|
+
if (options.json || options.output === 'json') {
|
|
50
|
+
(0, json_1.printError)(errors_1.ERROR_CODES.INVALID_ARGS, 'Please specify a subcommand: accuracy, performance, or reliability');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
await pretty.error('Please specify a subcommand: accuracy, performance, or reliability');
|
|
54
|
+
}
|
|
55
|
+
process.exit(cli_spec_1.EXIT_CODES.INVALID_ARGUMENTS);
|
|
56
|
+
}
|
|
57
|
+
const config = (0, resolve_1.resolveConfig)({
|
|
58
|
+
configPath: options.config,
|
|
59
|
+
profile: options.profile,
|
|
60
|
+
model: options.model,
|
|
61
|
+
verbose: options.verbose
|
|
62
|
+
});
|
|
63
|
+
const outputFormat = options.json ? 'json' : (options.output || 'pretty');
|
|
64
|
+
try {
|
|
65
|
+
switch (subcommand) {
|
|
66
|
+
case 'accuracy':
|
|
67
|
+
await runAccuracyEval(options, config, outputFormat);
|
|
68
|
+
break;
|
|
69
|
+
case 'performance':
|
|
70
|
+
await runPerformanceEval(options, config, outputFormat);
|
|
71
|
+
break;
|
|
72
|
+
case 'reliability':
|
|
73
|
+
await runReliabilityEval(options, config, outputFormat);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const cliError = (0, errors_1.normalizeError)(error);
|
|
79
|
+
if (outputFormat === 'json') {
|
|
80
|
+
(0, json_1.outputJson)((0, json_1.formatError)(cliError.code, cliError.message, cliError.details));
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
await pretty.error(cliError.message);
|
|
84
|
+
if (config.verbose && error instanceof Error && error.stack) {
|
|
85
|
+
await pretty.dim(error.stack);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
process.exit(cliError.exitCode);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function runAccuracyEval(options, config, outputFormat) {
|
|
92
|
+
if (!options.input) {
|
|
93
|
+
throw new Error('--input is required for accuracy evaluation');
|
|
94
|
+
}
|
|
95
|
+
if (!options.expected) {
|
|
96
|
+
throw new Error('--expected is required for accuracy evaluation');
|
|
97
|
+
}
|
|
98
|
+
const iterations = options.iterations || 1;
|
|
99
|
+
const results = [];
|
|
100
|
+
const startTime = Date.now();
|
|
101
|
+
const agent = new agent_1.Agent({
|
|
102
|
+
name: 'Eval Agent',
|
|
103
|
+
instructions: 'You are a helpful AI assistant.',
|
|
104
|
+
llm: config.model,
|
|
105
|
+
verbose: config.verbose
|
|
106
|
+
});
|
|
107
|
+
for (let i = 0; i < iterations; i++) {
|
|
108
|
+
const output = await agent.start(options.input);
|
|
109
|
+
// Simple similarity check (in production, use LLM-as-judge)
|
|
110
|
+
const similarity = calculateSimilarity(output, options.expected);
|
|
111
|
+
const score = Math.round(similarity * 10);
|
|
112
|
+
results.push({
|
|
113
|
+
iteration: i + 1,
|
|
114
|
+
output,
|
|
115
|
+
score,
|
|
116
|
+
passed: score >= 7
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
const duration = Date.now() - startTime;
|
|
120
|
+
const avgScore = results.reduce((sum, r) => sum + r.score, 0) / results.length;
|
|
121
|
+
const passRate = results.filter(r => r.passed).length / results.length;
|
|
122
|
+
if (outputFormat === 'json') {
|
|
123
|
+
(0, json_1.outputJson)((0, json_1.formatSuccess)({
|
|
124
|
+
type: 'accuracy',
|
|
125
|
+
results,
|
|
126
|
+
summary: {
|
|
127
|
+
avg_score: avgScore,
|
|
128
|
+
pass_rate: passRate,
|
|
129
|
+
iterations
|
|
130
|
+
}
|
|
131
|
+
}, { duration_ms: duration, model: config.model }));
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
await pretty.heading('Accuracy Evaluation Results');
|
|
135
|
+
await pretty.keyValue({
|
|
136
|
+
'Iterations': iterations,
|
|
137
|
+
'Average Score': avgScore.toFixed(2),
|
|
138
|
+
'Pass Rate': `${(passRate * 100).toFixed(1)}%`,
|
|
139
|
+
'Duration': `${duration}ms`
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function runPerformanceEval(options, config, outputFormat) {
|
|
144
|
+
const iterations = options.iterations || 10;
|
|
145
|
+
const warmup = options.warmup || 2;
|
|
146
|
+
const results = [];
|
|
147
|
+
const agent = new agent_1.Agent({
|
|
148
|
+
name: 'Perf Agent',
|
|
149
|
+
instructions: 'You are a helpful AI assistant.',
|
|
150
|
+
llm: config.model,
|
|
151
|
+
verbose: false // Disable verbose for performance testing
|
|
152
|
+
});
|
|
153
|
+
const testPrompt = 'Say "hello" and nothing else.';
|
|
154
|
+
// Warmup runs
|
|
155
|
+
for (let i = 0; i < warmup; i++) {
|
|
156
|
+
await agent.start(testPrompt);
|
|
157
|
+
}
|
|
158
|
+
// Actual runs
|
|
159
|
+
for (let i = 0; i < iterations; i++) {
|
|
160
|
+
const start = Date.now();
|
|
161
|
+
await agent.start(testPrompt);
|
|
162
|
+
const duration = Date.now() - start;
|
|
163
|
+
results.push({
|
|
164
|
+
iteration: i + 1,
|
|
165
|
+
duration_ms: duration
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
const durations = results.map(r => r.duration_ms);
|
|
169
|
+
const avg = durations.reduce((a, b) => a + b, 0) / durations.length;
|
|
170
|
+
const min = Math.min(...durations);
|
|
171
|
+
const max = Math.max(...durations);
|
|
172
|
+
const sorted = [...durations].sort((a, b) => a - b);
|
|
173
|
+
const p95 = sorted[Math.floor(sorted.length * 0.95)];
|
|
174
|
+
if (outputFormat === 'json') {
|
|
175
|
+
(0, json_1.outputJson)((0, json_1.formatSuccess)({
|
|
176
|
+
type: 'performance',
|
|
177
|
+
results,
|
|
178
|
+
summary: {
|
|
179
|
+
avg_ms: avg,
|
|
180
|
+
min_ms: min,
|
|
181
|
+
max_ms: max,
|
|
182
|
+
p95_ms: p95,
|
|
183
|
+
iterations,
|
|
184
|
+
warmup_runs: warmup
|
|
185
|
+
}
|
|
186
|
+
}, { model: config.model }));
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
await pretty.heading('Performance Evaluation Results');
|
|
190
|
+
await pretty.keyValue({
|
|
191
|
+
'Iterations': iterations,
|
|
192
|
+
'Warmup Runs': warmup,
|
|
193
|
+
'Avg Duration': `${avg.toFixed(2)}ms`,
|
|
194
|
+
'Min Duration': `${min}ms`,
|
|
195
|
+
'Max Duration': `${max}ms`,
|
|
196
|
+
'P95 Duration': `${p95}ms`
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async function runReliabilityEval(options, config, outputFormat) {
|
|
201
|
+
const expectedTools = options['expected-tools']?.split(',').map(t => t.trim()) || [];
|
|
202
|
+
if (expectedTools.length === 0) {
|
|
203
|
+
throw new Error('--expected-tools is required for reliability evaluation');
|
|
204
|
+
}
|
|
205
|
+
// For now, simulate reliability check
|
|
206
|
+
// In production, this would track actual tool calls
|
|
207
|
+
const results = {
|
|
208
|
+
expected: expectedTools,
|
|
209
|
+
called: expectedTools, // Simulated
|
|
210
|
+
missing: [],
|
|
211
|
+
unexpected: []
|
|
212
|
+
};
|
|
213
|
+
const passed = results.missing.length === 0;
|
|
214
|
+
if (outputFormat === 'json') {
|
|
215
|
+
(0, json_1.outputJson)((0, json_1.formatSuccess)({
|
|
216
|
+
type: 'reliability',
|
|
217
|
+
status: passed ? 'PASSED' : 'FAILED',
|
|
218
|
+
results
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
await pretty.heading('Reliability Evaluation Results');
|
|
223
|
+
if (passed) {
|
|
224
|
+
await pretty.success('All expected tools were called');
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
await pretty.error(`Missing tool calls: ${results.missing.join(', ')}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Simple string similarity calculation
|
|
233
|
+
*/
|
|
234
|
+
function calculateSimilarity(str1, str2) {
|
|
235
|
+
const s1 = str1.toLowerCase().trim();
|
|
236
|
+
const s2 = str2.toLowerCase().trim();
|
|
237
|
+
if (s1 === s2)
|
|
238
|
+
return 1;
|
|
239
|
+
if (s1.includes(s2) || s2.includes(s1))
|
|
240
|
+
return 0.9;
|
|
241
|
+
// Simple word overlap
|
|
242
|
+
const words1 = new Set(s1.split(/\s+/));
|
|
243
|
+
const words2 = new Set(s2.split(/\s+/));
|
|
244
|
+
const intersection = [...words1].filter(w => words2.has(w));
|
|
245
|
+
const union = new Set([...words1, ...words2]);
|
|
246
|
+
return intersection.length / union.size;
|
|
247
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CLI command: external-agents
|
|
4
|
+
* Integration with external AI CLI tools
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.execute = execute;
|
|
8
|
+
const external_agents_1 = require("../features/external-agents");
|
|
9
|
+
async function execute(args, options) {
|
|
10
|
+
const subcommand = args[0] || 'help';
|
|
11
|
+
const isJson = Boolean(options.output === 'json' || options.json);
|
|
12
|
+
switch (subcommand) {
|
|
13
|
+
case 'list':
|
|
14
|
+
await handleList(isJson);
|
|
15
|
+
break;
|
|
16
|
+
case 'check':
|
|
17
|
+
await handleCheck(args.slice(1), isJson);
|
|
18
|
+
break;
|
|
19
|
+
case 'run':
|
|
20
|
+
await handleRun(args.slice(1), options, isJson);
|
|
21
|
+
break;
|
|
22
|
+
case 'help':
|
|
23
|
+
default:
|
|
24
|
+
showHelp(isJson);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function handleList(isJson) {
|
|
28
|
+
const registry = (0, external_agents_1.getExternalAgentRegistry)();
|
|
29
|
+
const all = registry.list();
|
|
30
|
+
const available = await registry.getAvailable();
|
|
31
|
+
if (isJson) {
|
|
32
|
+
console.log(JSON.stringify({
|
|
33
|
+
success: true,
|
|
34
|
+
agents: all,
|
|
35
|
+
available
|
|
36
|
+
}, null, 2));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.log('External Agents:\n');
|
|
40
|
+
for (const name of all) {
|
|
41
|
+
const status = available.includes(name) ? '✓' : '✗';
|
|
42
|
+
console.log(` ${status} ${name}`);
|
|
43
|
+
}
|
|
44
|
+
console.log(`\n${available.length}/${all.length} available`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function handleCheck(args, isJson) {
|
|
48
|
+
const name = args[0];
|
|
49
|
+
if (!name) {
|
|
50
|
+
console.error('Error: Agent name is required');
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
const agent = (0, external_agents_1.createExternalAgent)(name);
|
|
54
|
+
if (!agent) {
|
|
55
|
+
if (isJson) {
|
|
56
|
+
console.log(JSON.stringify({ success: false, error: `Unknown agent: ${name}` }));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
console.error(`Unknown agent: ${name}`);
|
|
60
|
+
}
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
const available = await agent.isAvailable();
|
|
64
|
+
if (isJson) {
|
|
65
|
+
console.log(JSON.stringify({ success: true, agent: name, available }));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
if (available) {
|
|
69
|
+
console.log(`✓ ${name} is available`);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.log(`✗ ${name} is not available (CLI not found)`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async function handleRun(args, options, isJson) {
|
|
77
|
+
const name = args[0];
|
|
78
|
+
const prompt = args.slice(1).join(' ');
|
|
79
|
+
if (!name) {
|
|
80
|
+
console.error('Error: Agent name is required');
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
if (!prompt) {
|
|
84
|
+
console.error('Error: Prompt is required');
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
const cwd = options.cwd;
|
|
88
|
+
const agent = (0, external_agents_1.createExternalAgent)(name, cwd);
|
|
89
|
+
if (!agent) {
|
|
90
|
+
if (isJson) {
|
|
91
|
+
console.log(JSON.stringify({ success: false, error: `Unknown agent: ${name}` }));
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
console.error(`Unknown agent: ${name}`);
|
|
95
|
+
}
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
if (!await agent.isAvailable()) {
|
|
99
|
+
if (isJson) {
|
|
100
|
+
console.log(JSON.stringify({ success: false, error: `${name} CLI not available` }));
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
console.error(`${name} CLI not available`);
|
|
104
|
+
}
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
const result = await agent.execute(prompt);
|
|
108
|
+
if (isJson) {
|
|
109
|
+
console.log(JSON.stringify(result, null, 2));
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
if (result.success) {
|
|
113
|
+
console.log(result.output);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
console.error(`Error: ${result.error}`);
|
|
117
|
+
process.exit(result.exitCode);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function showHelp(isJson) {
|
|
122
|
+
const help = {
|
|
123
|
+
command: 'external-agents',
|
|
124
|
+
description: 'Integration with external AI CLI tools',
|
|
125
|
+
subcommands: {
|
|
126
|
+
list: 'List all external agents and availability',
|
|
127
|
+
check: 'Check if an agent is available',
|
|
128
|
+
run: 'Run a prompt with an external agent'
|
|
129
|
+
},
|
|
130
|
+
agents: {
|
|
131
|
+
claude: 'Claude Code CLI',
|
|
132
|
+
gemini: 'Gemini CLI',
|
|
133
|
+
codex: 'OpenAI Codex CLI',
|
|
134
|
+
aider: 'Aider CLI'
|
|
135
|
+
},
|
|
136
|
+
flags: {
|
|
137
|
+
'--cwd': 'Working directory for the agent',
|
|
138
|
+
'--json': 'Output in JSON format'
|
|
139
|
+
},
|
|
140
|
+
examples: [
|
|
141
|
+
'praisonai-ts external-agents list',
|
|
142
|
+
'praisonai-ts external-agents check claude',
|
|
143
|
+
'praisonai-ts external-agents run claude "Explain this code"',
|
|
144
|
+
'praisonai-ts external-agents run gemini "Refactor this function" --cwd ./src'
|
|
145
|
+
]
|
|
146
|
+
};
|
|
147
|
+
if (isJson) {
|
|
148
|
+
console.log(JSON.stringify(help, null, 2));
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
console.log('External Agents - AI CLI tool integration\n');
|
|
152
|
+
console.log('Subcommands:');
|
|
153
|
+
for (const [cmd, desc] of Object.entries(help.subcommands)) {
|
|
154
|
+
console.log(` ${cmd.padEnd(12)} ${desc}`);
|
|
155
|
+
}
|
|
156
|
+
console.log('\nSupported Agents:');
|
|
157
|
+
for (const [agent, desc] of Object.entries(help.agents)) {
|
|
158
|
+
console.log(` ${agent.padEnd(12)} ${desc}`);
|
|
159
|
+
}
|
|
160
|
+
console.log('\nFlags:');
|
|
161
|
+
for (const [flag, desc] of Object.entries(help.flags)) {
|
|
162
|
+
console.log(` ${flag.padEnd(12)} ${desc}`);
|
|
163
|
+
}
|
|
164
|
+
console.log('\nExamples:');
|
|
165
|
+
for (const ex of help.examples) {
|
|
166
|
+
console.log(` ${ex}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|