praisonai 1.2.2 → 1.2.4
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,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pretty output formatting for CLI
|
|
4
|
+
* Uses optional dependencies (chalk, boxen, ora) with fallbacks
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.success = success;
|
|
8
|
+
exports.error = error;
|
|
9
|
+
exports.warn = warn;
|
|
10
|
+
exports.info = info;
|
|
11
|
+
exports.heading = heading;
|
|
12
|
+
exports.dim = dim;
|
|
13
|
+
exports.highlight = highlight;
|
|
14
|
+
exports.plain = plain;
|
|
15
|
+
exports.newline = newline;
|
|
16
|
+
exports.table = table;
|
|
17
|
+
exports.keyValue = keyValue;
|
|
18
|
+
const lazy_1 = require("../runtime/lazy");
|
|
19
|
+
let chalkInstance = null;
|
|
20
|
+
let chalkLoaded = false;
|
|
21
|
+
async function getChalk() {
|
|
22
|
+
if (chalkLoaded)
|
|
23
|
+
return chalkInstance;
|
|
24
|
+
chalkLoaded = true;
|
|
25
|
+
try {
|
|
26
|
+
const chalk = await (0, lazy_1.tryLoadOptional)('chalk');
|
|
27
|
+
chalkInstance = chalk?.default || null;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
chalkInstance = null;
|
|
31
|
+
}
|
|
32
|
+
return chalkInstance;
|
|
33
|
+
}
|
|
34
|
+
// Fallback functions when chalk is not available
|
|
35
|
+
const noColor = (s) => s;
|
|
36
|
+
async function success(message) {
|
|
37
|
+
const chalk = await getChalk();
|
|
38
|
+
const prefix = chalk ? chalk.green('✓') : '✓';
|
|
39
|
+
console.log(`${prefix} ${message}`);
|
|
40
|
+
}
|
|
41
|
+
async function error(message) {
|
|
42
|
+
const chalk = await getChalk();
|
|
43
|
+
const prefix = chalk ? chalk.red('✗') : '✗';
|
|
44
|
+
console.error(`${prefix} ${message}`);
|
|
45
|
+
}
|
|
46
|
+
async function warn(message) {
|
|
47
|
+
const chalk = await getChalk();
|
|
48
|
+
const prefix = chalk ? chalk.yellow('⚠') : '⚠';
|
|
49
|
+
console.warn(`${prefix} ${message}`);
|
|
50
|
+
}
|
|
51
|
+
async function info(message) {
|
|
52
|
+
const chalk = await getChalk();
|
|
53
|
+
const prefix = chalk ? chalk.blue('ℹ') : 'ℹ';
|
|
54
|
+
console.log(`${prefix} ${message}`);
|
|
55
|
+
}
|
|
56
|
+
async function heading(message) {
|
|
57
|
+
const chalk = await getChalk();
|
|
58
|
+
const text = chalk ? chalk.bold(message) : message;
|
|
59
|
+
console.log(`\n${text}\n`);
|
|
60
|
+
}
|
|
61
|
+
async function dim(message) {
|
|
62
|
+
const chalk = await getChalk();
|
|
63
|
+
const text = chalk ? chalk.gray(message) : message;
|
|
64
|
+
console.log(text);
|
|
65
|
+
}
|
|
66
|
+
async function highlight(message) {
|
|
67
|
+
const chalk = await getChalk();
|
|
68
|
+
const text = chalk ? chalk.cyan(message) : message;
|
|
69
|
+
console.log(text);
|
|
70
|
+
}
|
|
71
|
+
function plain(message) {
|
|
72
|
+
console.log(message);
|
|
73
|
+
}
|
|
74
|
+
function newline() {
|
|
75
|
+
console.log();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Print a table (simple ASCII fallback)
|
|
79
|
+
*/
|
|
80
|
+
function table(headers, rows) {
|
|
81
|
+
// Calculate column widths
|
|
82
|
+
const widths = headers.map((h, i) => {
|
|
83
|
+
const maxRowWidth = Math.max(...rows.map(r => (r[i] || '').length));
|
|
84
|
+
return Math.max(h.length, maxRowWidth);
|
|
85
|
+
});
|
|
86
|
+
// Print header
|
|
87
|
+
const headerLine = headers.map((h, i) => h.padEnd(widths[i])).join(' ');
|
|
88
|
+
console.log(headerLine);
|
|
89
|
+
console.log('-'.repeat(headerLine.length));
|
|
90
|
+
// Print rows
|
|
91
|
+
for (const row of rows) {
|
|
92
|
+
const line = row.map((cell, i) => (cell || '').padEnd(widths[i])).join(' ');
|
|
93
|
+
console.log(line);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Print a key-value list
|
|
98
|
+
*/
|
|
99
|
+
async function keyValue(items) {
|
|
100
|
+
const chalk = await getChalk();
|
|
101
|
+
const maxKeyLen = Math.max(...Object.keys(items).map(k => k.length));
|
|
102
|
+
for (const [key, value] of Object.entries(items)) {
|
|
103
|
+
const keyStr = chalk ? chalk.cyan(key.padEnd(maxKeyLen)) : key.padEnd(maxKeyLen);
|
|
104
|
+
console.log(` ${keyStr} ${value}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable handling for CLI
|
|
3
|
+
*/
|
|
4
|
+
export interface EnvConfig {
|
|
5
|
+
model?: string;
|
|
6
|
+
profile?: string;
|
|
7
|
+
verbose?: boolean;
|
|
8
|
+
configPath?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function loadEnvConfig(): EnvConfig;
|
|
11
|
+
export declare function hasApiKey(provider: 'openai' | 'anthropic' | 'google'): boolean;
|
|
12
|
+
export declare function getApiKey(provider: 'openai' | 'anthropic' | 'google'): string | undefined;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Environment variable handling for CLI
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadEnvConfig = loadEnvConfig;
|
|
7
|
+
exports.hasApiKey = hasApiKey;
|
|
8
|
+
exports.getApiKey = getApiKey;
|
|
9
|
+
const cli_spec_1 = require("../spec/cli-spec");
|
|
10
|
+
function loadEnvConfig() {
|
|
11
|
+
const config = {};
|
|
12
|
+
const model = process.env[cli_spec_1.ENV_VARS.PRAISONAI_MODEL];
|
|
13
|
+
if (model)
|
|
14
|
+
config.model = model;
|
|
15
|
+
const profile = process.env[cli_spec_1.ENV_VARS.PRAISONAI_PROFILE];
|
|
16
|
+
if (profile)
|
|
17
|
+
config.profile = profile;
|
|
18
|
+
const verbose = process.env[cli_spec_1.ENV_VARS.PRAISONAI_VERBOSE];
|
|
19
|
+
if (verbose)
|
|
20
|
+
config.verbose = verbose.toLowerCase() === 'true';
|
|
21
|
+
const configPath = process.env[cli_spec_1.ENV_VARS.PRAISONAI_CONFIG];
|
|
22
|
+
if (configPath)
|
|
23
|
+
config.configPath = configPath;
|
|
24
|
+
return config;
|
|
25
|
+
}
|
|
26
|
+
function hasApiKey(provider) {
|
|
27
|
+
switch (provider) {
|
|
28
|
+
case 'openai':
|
|
29
|
+
return !!process.env[cli_spec_1.ENV_VARS.OPENAI_API_KEY];
|
|
30
|
+
case 'anthropic':
|
|
31
|
+
return !!process.env[cli_spec_1.ENV_VARS.ANTHROPIC_API_KEY];
|
|
32
|
+
case 'google':
|
|
33
|
+
return !!process.env[cli_spec_1.ENV_VARS.GOOGLE_API_KEY];
|
|
34
|
+
default:
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function getApiKey(provider) {
|
|
39
|
+
switch (provider) {
|
|
40
|
+
case 'openai':
|
|
41
|
+
return process.env[cli_spec_1.ENV_VARS.OPENAI_API_KEY];
|
|
42
|
+
case 'anthropic':
|
|
43
|
+
return process.env[cli_spec_1.ENV_VARS.ANTHROPIC_API_KEY];
|
|
44
|
+
case 'google':
|
|
45
|
+
return process.env[cli_spec_1.ENV_VARS.GOOGLE_API_KEY];
|
|
46
|
+
default:
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exit code handling for CLI
|
|
3
|
+
*/
|
|
4
|
+
import { ExitCode } from '../spec/cli-spec';
|
|
5
|
+
export declare function exit(code: ExitCode): never;
|
|
6
|
+
export declare function exitSuccess(): never;
|
|
7
|
+
export declare function exitError(message?: string): never;
|
|
8
|
+
export declare function exitInvalidArgs(message?: string): never;
|
|
9
|
+
export declare function exitConfigError(message?: string): never;
|
|
10
|
+
export declare function exitNetworkError(message?: string): never;
|
|
11
|
+
export declare function exitAuthError(message?: string): never;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Exit code handling for CLI
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.exit = exit;
|
|
7
|
+
exports.exitSuccess = exitSuccess;
|
|
8
|
+
exports.exitError = exitError;
|
|
9
|
+
exports.exitInvalidArgs = exitInvalidArgs;
|
|
10
|
+
exports.exitConfigError = exitConfigError;
|
|
11
|
+
exports.exitNetworkError = exitNetworkError;
|
|
12
|
+
exports.exitAuthError = exitAuthError;
|
|
13
|
+
const cli_spec_1 = require("../spec/cli-spec");
|
|
14
|
+
function exit(code) {
|
|
15
|
+
process.exit(code);
|
|
16
|
+
}
|
|
17
|
+
function exitSuccess() {
|
|
18
|
+
exit(cli_spec_1.EXIT_CODES.SUCCESS);
|
|
19
|
+
}
|
|
20
|
+
function exitError(message) {
|
|
21
|
+
if (message) {
|
|
22
|
+
console.error(message);
|
|
23
|
+
}
|
|
24
|
+
exit(cli_spec_1.EXIT_CODES.RUNTIME_ERROR);
|
|
25
|
+
}
|
|
26
|
+
function exitInvalidArgs(message) {
|
|
27
|
+
if (message) {
|
|
28
|
+
console.error(`Error: ${message}`);
|
|
29
|
+
}
|
|
30
|
+
exit(cli_spec_1.EXIT_CODES.INVALID_ARGUMENTS);
|
|
31
|
+
}
|
|
32
|
+
function exitConfigError(message) {
|
|
33
|
+
if (message) {
|
|
34
|
+
console.error(`Config Error: ${message}`);
|
|
35
|
+
}
|
|
36
|
+
exit(cli_spec_1.EXIT_CODES.CONFIG_ERROR);
|
|
37
|
+
}
|
|
38
|
+
function exitNetworkError(message) {
|
|
39
|
+
if (message) {
|
|
40
|
+
console.error(`Network Error: ${message}`);
|
|
41
|
+
}
|
|
42
|
+
exit(cli_spec_1.EXIT_CODES.NETWORK_ERROR);
|
|
43
|
+
}
|
|
44
|
+
function exitAuthError(message) {
|
|
45
|
+
if (message) {
|
|
46
|
+
console.error(`Auth Error: ${message}`);
|
|
47
|
+
}
|
|
48
|
+
exit(cli_spec_1.EXIT_CODES.AUTH_ERROR);
|
|
49
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Runtime utilities index
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./env"), exports);
|
|
21
|
+
__exportStar(require("./exit"), exports);
|
|
22
|
+
__exportStar(require("./lazy"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy loading utilities for CLI commands
|
|
3
|
+
* Ensures startup time stays <100ms by only loading command code when invoked
|
|
4
|
+
*/
|
|
5
|
+
export type CommandModule = {
|
|
6
|
+
execute: (args: string[], options: Record<string, unknown>) => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
export declare function loadCommand(command: string): Promise<CommandModule>;
|
|
9
|
+
export declare function clearCommandCache(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Lazy load optional dependencies
|
|
12
|
+
* Returns undefined if not available
|
|
13
|
+
*/
|
|
14
|
+
export declare function tryLoadOptional<T>(moduleName: string): Promise<T | undefined>;
|
|
15
|
+
/**
|
|
16
|
+
* Check if an optional dependency is available
|
|
17
|
+
*/
|
|
18
|
+
export declare function hasOptionalDep(moduleName: string): Promise<boolean>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Lazy loading utilities for CLI commands
|
|
4
|
+
* Ensures startup time stays <100ms by only loading command code when invoked
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.loadCommand = loadCommand;
|
|
41
|
+
exports.clearCommandCache = clearCommandCache;
|
|
42
|
+
exports.tryLoadOptional = tryLoadOptional;
|
|
43
|
+
exports.hasOptionalDep = hasOptionalDep;
|
|
44
|
+
const cli_spec_1 = require("../spec/cli-spec");
|
|
45
|
+
const commandCache = new Map();
|
|
46
|
+
async function loadCommand(command) {
|
|
47
|
+
if (!(0, cli_spec_1.validateCommand)(command)) {
|
|
48
|
+
throw new Error(`Unknown command: ${command}`);
|
|
49
|
+
}
|
|
50
|
+
// Check cache first
|
|
51
|
+
if (commandCache.has(command)) {
|
|
52
|
+
return commandCache.get(command);
|
|
53
|
+
}
|
|
54
|
+
// Lazy import the command module
|
|
55
|
+
const module = await Promise.resolve(`${`../commands/${command}`}`).then(s => __importStar(require(s)));
|
|
56
|
+
commandCache.set(command, module);
|
|
57
|
+
return module;
|
|
58
|
+
}
|
|
59
|
+
function clearCommandCache() {
|
|
60
|
+
commandCache.clear();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Lazy load optional dependencies
|
|
64
|
+
* Returns undefined if not available
|
|
65
|
+
*/
|
|
66
|
+
async function tryLoadOptional(moduleName) {
|
|
67
|
+
try {
|
|
68
|
+
return await Promise.resolve(`${moduleName}`).then(s => __importStar(require(s)));
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Check if an optional dependency is available
|
|
76
|
+
*/
|
|
77
|
+
async function hasOptionalDep(moduleName) {
|
|
78
|
+
try {
|
|
79
|
+
await Promise.resolve(`${moduleName}`).then(s => __importStar(require(s)));
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PraisonAI CLI Specification - TypeScript Runtime
|
|
3
|
+
* Parsed and validated spec from cli-spec.v1.yaml
|
|
4
|
+
*/
|
|
5
|
+
export declare const CLI_SPEC_VERSION = "1.0.0";
|
|
6
|
+
export interface CommandArg {
|
|
7
|
+
name: string;
|
|
8
|
+
type: 'string' | 'integer' | 'boolean';
|
|
9
|
+
required: boolean;
|
|
10
|
+
position?: number;
|
|
11
|
+
description?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CommandFlag {
|
|
14
|
+
name: string;
|
|
15
|
+
short?: string;
|
|
16
|
+
type: 'string' | 'integer' | 'boolean';
|
|
17
|
+
default?: string | number | boolean;
|
|
18
|
+
enum?: string[];
|
|
19
|
+
description?: string;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface Subcommand {
|
|
23
|
+
description: string;
|
|
24
|
+
args?: CommandArg[];
|
|
25
|
+
flags?: CommandFlag[];
|
|
26
|
+
}
|
|
27
|
+
export interface Command {
|
|
28
|
+
description: string;
|
|
29
|
+
args?: CommandArg[];
|
|
30
|
+
flags?: CommandFlag[];
|
|
31
|
+
subcommands?: Record<string, Subcommand>;
|
|
32
|
+
}
|
|
33
|
+
export declare const COMMANDS: Record<string, Command>;
|
|
34
|
+
export declare const GLOBAL_FLAGS: CommandFlag[];
|
|
35
|
+
export declare const EXIT_CODES: {
|
|
36
|
+
readonly SUCCESS: 0;
|
|
37
|
+
readonly RUNTIME_ERROR: 1;
|
|
38
|
+
readonly INVALID_ARGUMENTS: 2;
|
|
39
|
+
readonly CONFIG_ERROR: 3;
|
|
40
|
+
readonly NETWORK_ERROR: 4;
|
|
41
|
+
readonly AUTH_ERROR: 5;
|
|
42
|
+
};
|
|
43
|
+
export type ExitCode = typeof EXIT_CODES[keyof typeof EXIT_CODES];
|
|
44
|
+
export interface SuccessOutput<T = unknown> {
|
|
45
|
+
success: true;
|
|
46
|
+
data: T;
|
|
47
|
+
meta?: {
|
|
48
|
+
duration_ms?: number;
|
|
49
|
+
model?: string;
|
|
50
|
+
tokens?: {
|
|
51
|
+
input?: number;
|
|
52
|
+
output?: number;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export interface ErrorOutput {
|
|
57
|
+
success: false;
|
|
58
|
+
error: {
|
|
59
|
+
code: string;
|
|
60
|
+
message: string;
|
|
61
|
+
details?: Record<string, unknown>;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export type CLIOutput<T = unknown> = SuccessOutput<T> | ErrorOutput;
|
|
65
|
+
export declare const ENV_VARS: {
|
|
66
|
+
readonly PRAISONAI_MODEL: "PRAISONAI_MODEL";
|
|
67
|
+
readonly PRAISONAI_PROFILE: "PRAISONAI_PROFILE";
|
|
68
|
+
readonly PRAISONAI_VERBOSE: "PRAISONAI_VERBOSE";
|
|
69
|
+
readonly PRAISONAI_CONFIG: "PRAISONAI_CONFIG";
|
|
70
|
+
readonly OPENAI_API_KEY: "OPENAI_API_KEY";
|
|
71
|
+
readonly ANTHROPIC_API_KEY: "ANTHROPIC_API_KEY";
|
|
72
|
+
readonly GOOGLE_API_KEY: "GOOGLE_API_KEY";
|
|
73
|
+
};
|
|
74
|
+
export declare const CONFIG_FILES: readonly [".praisonai.yaml", ".praisonai.json"];
|
|
75
|
+
export interface ConfigSchema {
|
|
76
|
+
model?: string;
|
|
77
|
+
verbose?: boolean;
|
|
78
|
+
stream?: boolean;
|
|
79
|
+
profiles?: Record<string, {
|
|
80
|
+
model?: string;
|
|
81
|
+
verbose?: boolean;
|
|
82
|
+
stream?: boolean;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
export declare function validateCommand(command: string): command is keyof typeof COMMANDS;
|
|
86
|
+
export declare function getCommandSpec(command: string): Command | undefined;
|
|
87
|
+
export declare function getAllFlags(command: string): CommandFlag[];
|