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
@@ -10,7 +10,7 @@ class Agent {
10
10
  this.name = config.name || `Agent_${Math.random().toString(36).substr(2, 9)}`;
11
11
  this.verbose = config.verbose ?? process.env.PRAISON_VERBOSE !== 'false';
12
12
  this.pretty = config.pretty ?? process.env.PRAISON_PRETTY === 'true';
13
- this.llm = config.llm || 'gpt-5-nano';
13
+ this.llm = config.llm || 'gpt-4o-mini';
14
14
  this.markdown = config.markdown ?? true;
15
15
  this.stream = config.stream ?? true;
16
16
  this.tools = config.tools;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Auto command - AutoAgents for automatic agent generation
3
+ */
4
+ export interface AutoOptions {
5
+ model?: string;
6
+ verbose?: boolean;
7
+ output?: 'json' | 'text' | 'pretty';
8
+ json?: boolean;
9
+ pattern?: string;
10
+ agents?: number;
11
+ }
12
+ export declare function execute(args: string[], options: AutoOptions): Promise<void>;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ /**
3
+ * Auto command - AutoAgents for automatic agent generation
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 auto_1 = require("../../auto");
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 topic = args.join(' ');
48
+ const outputFormat = options.json ? 'json' : (options.output || 'pretty');
49
+ const config = (0, resolve_1.resolveConfig)(options);
50
+ if (!topic) {
51
+ if (outputFormat === 'json') {
52
+ (0, json_1.outputJson)((0, json_1.formatError)(errors_1.ERROR_CODES.MISSING_ARG, 'Please provide a topic for auto-generation'));
53
+ }
54
+ else {
55
+ await pretty.error('Please provide a topic for auto-generation');
56
+ await pretty.dim('Usage: praisonai-ts auto "Create a research team"');
57
+ }
58
+ process.exit(cli_spec_1.EXIT_CODES.INVALID_ARGUMENTS);
59
+ }
60
+ const startTime = Date.now();
61
+ try {
62
+ if (outputFormat !== 'json') {
63
+ await pretty.info(`Generating agents for: "${topic}"`);
64
+ }
65
+ const autoAgents = (0, auto_1.createAutoAgents)({
66
+ llm: config.model,
67
+ pattern: options.pattern,
68
+ verbose: options.verbose
69
+ });
70
+ const result = await autoAgents.generate(topic);
71
+ const duration = Date.now() - startTime;
72
+ if (outputFormat === 'json') {
73
+ (0, json_1.outputJson)((0, json_1.formatSuccess)({
74
+ topic,
75
+ agents: result.agents,
76
+ tasks: result.tasks,
77
+ pattern: result.pattern
78
+ }, {
79
+ duration_ms: duration,
80
+ model: config.model
81
+ }));
82
+ }
83
+ else {
84
+ await pretty.heading('Generated Team');
85
+ await pretty.plain(`Pattern: ${result.pattern}`);
86
+ await pretty.newline();
87
+ await pretty.plain('Agents:');
88
+ for (const agent of result.agents) {
89
+ await pretty.plain(` • ${agent.name}: ${agent.role}`);
90
+ }
91
+ await pretty.newline();
92
+ await pretty.plain('Tasks:');
93
+ for (const task of result.tasks) {
94
+ await pretty.plain(` • ${task.description?.substring(0, 60)}...`);
95
+ }
96
+ await pretty.newline();
97
+ await pretty.success(`Generated in ${duration}ms`);
98
+ }
99
+ }
100
+ catch (error) {
101
+ if (outputFormat === 'json') {
102
+ (0, json_1.outputJson)((0, json_1.formatError)(errors_1.ERROR_CODES.UNKNOWN, error instanceof Error ? error.message : String(error)));
103
+ }
104
+ else {
105
+ await pretty.error(error instanceof Error ? error.message : String(error));
106
+ }
107
+ process.exit(cli_spec_1.EXIT_CODES.RUNTIME_ERROR);
108
+ }
109
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * CLI command: autonomy
3
+ * Autonomy mode management for agent actions
4
+ */
5
+ export declare function execute(args: string[], options: Record<string, unknown>): Promise<void>;
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ /**
3
+ * CLI command: autonomy
4
+ * Autonomy mode management for agent actions
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.execute = execute;
8
+ const autonomy_mode_1 = require("../features/autonomy-mode");
9
+ let manager = null;
10
+ function getManager() {
11
+ if (!manager) {
12
+ manager = (0, autonomy_mode_1.createAutonomyManager)();
13
+ }
14
+ return manager;
15
+ }
16
+ async function execute(args, options) {
17
+ const subcommand = args[0] || 'help';
18
+ const isJson = Boolean(options.output === 'json' || options.json);
19
+ switch (subcommand) {
20
+ case 'status':
21
+ await handleStatus(isJson);
22
+ break;
23
+ case 'set':
24
+ await handleSet(args.slice(1), isJson);
25
+ break;
26
+ case 'policies':
27
+ await handlePolicies(args.slice(1), isJson);
28
+ break;
29
+ case 'reset':
30
+ await handleReset(isJson);
31
+ break;
32
+ case 'help':
33
+ default:
34
+ showHelp(isJson);
35
+ }
36
+ }
37
+ async function handleStatus(isJson) {
38
+ const mgr = getManager();
39
+ const summary = mgr.getSummary();
40
+ const mode = mgr.getMode();
41
+ const actionCount = mgr.getActionCount();
42
+ if (isJson) {
43
+ console.log(JSON.stringify({
44
+ success: true,
45
+ mode,
46
+ actionCount,
47
+ policies: autonomy_mode_1.MODE_POLICIES[mode]
48
+ }, null, 2));
49
+ }
50
+ else {
51
+ console.log(summary);
52
+ }
53
+ }
54
+ async function handleSet(args, isJson) {
55
+ const mode = args[0];
56
+ if (!mode || !['suggest', 'auto_edit', 'full_auto'].includes(mode)) {
57
+ console.error('Error: Valid mode required (suggest, auto_edit, full_auto)');
58
+ process.exit(1);
59
+ }
60
+ const mgr = getManager();
61
+ mgr.setMode(mode);
62
+ if (isJson) {
63
+ console.log(JSON.stringify({ success: true, mode }));
64
+ }
65
+ else {
66
+ console.log(`✓ Autonomy mode set to: ${mode}`);
67
+ console.log('\nPolicies for this mode:');
68
+ for (const policy of autonomy_mode_1.MODE_POLICIES[mode]) {
69
+ const status = policy.requiresApproval ? '⚠️ requires approval' : '✓ auto-approved';
70
+ console.log(` ${policy.action}: ${status}`);
71
+ }
72
+ }
73
+ }
74
+ async function handlePolicies(args, isJson) {
75
+ const mode = args[0] || 'suggest';
76
+ if (!['suggest', 'auto_edit', 'full_auto'].includes(mode)) {
77
+ console.error('Error: Valid mode required (suggest, auto_edit, full_auto)');
78
+ process.exit(1);
79
+ }
80
+ const policies = autonomy_mode_1.MODE_POLICIES[mode];
81
+ if (isJson) {
82
+ console.log(JSON.stringify({ success: true, mode, policies }, null, 2));
83
+ }
84
+ else {
85
+ console.log(`Policies for mode: ${mode}\n`);
86
+ for (const policy of policies) {
87
+ const status = policy.requiresApproval ? '⚠️ requires approval' : '✓ auto-approved';
88
+ console.log(` ${policy.action.padEnd(20)} ${status}`);
89
+ }
90
+ }
91
+ }
92
+ async function handleReset(isJson) {
93
+ const mgr = getManager();
94
+ mgr.clearRemembered();
95
+ mgr.resetActionCount();
96
+ mgr.setMode('suggest');
97
+ if (isJson) {
98
+ console.log(JSON.stringify({ success: true, message: 'Autonomy state reset' }));
99
+ }
100
+ else {
101
+ console.log('✓ Autonomy state reset');
102
+ console.log(' Mode: suggest');
103
+ console.log(' Remembered decisions: cleared');
104
+ console.log(' Action count: 0');
105
+ }
106
+ }
107
+ function showHelp(isJson) {
108
+ const help = {
109
+ command: 'autonomy',
110
+ description: 'Autonomy mode management for agent actions',
111
+ subcommands: {
112
+ status: 'Show current autonomy status',
113
+ set: 'Set autonomy mode',
114
+ policies: 'Show policies for a mode',
115
+ reset: 'Reset autonomy state'
116
+ },
117
+ modes: {
118
+ suggest: 'Requires approval for most actions (default)',
119
+ auto_edit: 'Auto-approves file edits, requires approval for others',
120
+ full_auto: 'Auto-approves most actions (use with caution)'
121
+ },
122
+ flags: {
123
+ '--json': 'Output in JSON format'
124
+ },
125
+ examples: [
126
+ 'praisonai-ts autonomy status',
127
+ 'praisonai-ts autonomy set suggest',
128
+ 'praisonai-ts autonomy set auto_edit',
129
+ 'praisonai-ts autonomy set full_auto',
130
+ 'praisonai-ts autonomy policies suggest',
131
+ 'praisonai-ts autonomy reset'
132
+ ]
133
+ };
134
+ if (isJson) {
135
+ console.log(JSON.stringify(help, null, 2));
136
+ }
137
+ else {
138
+ console.log('Autonomy - Agent action approval management\n');
139
+ console.log('Subcommands:');
140
+ for (const [cmd, desc] of Object.entries(help.subcommands)) {
141
+ console.log(` ${cmd.padEnd(12)} ${desc}`);
142
+ }
143
+ console.log('\nModes:');
144
+ for (const [mode, desc] of Object.entries(help.modes)) {
145
+ console.log(` ${mode.padEnd(12)} ${desc}`);
146
+ }
147
+ console.log('\nExamples:');
148
+ for (const ex of help.examples) {
149
+ console.log(` ${ex}`);
150
+ }
151
+ }
152
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Cache command - Caching management
3
+ */
4
+ export interface CacheOptions {
5
+ verbose?: boolean;
6
+ output?: 'json' | 'text' | 'pretty';
7
+ json?: boolean;
8
+ }
9
+ export declare function execute(args: string[], options: CacheOptions): Promise<void>;
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ /**
3
+ * Cache command - Caching 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 'providers':
53
+ await listProviders(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: 'Cache',
74
+ description: 'Caching system for LLM responses and computations',
75
+ providers: [
76
+ { name: 'MemoryCache', description: 'In-memory cache (default)' },
77
+ { name: 'FileCache', description: 'File-based persistent cache' }
78
+ ],
79
+ capabilities: [
80
+ 'Cache LLM responses',
81
+ 'Reduce API costs',
82
+ 'Improve response times',
83
+ 'TTL-based expiration',
84
+ 'Configurable cache keys'
85
+ ]
86
+ };
87
+ if (outputFormat === 'json') {
88
+ (0, json_1.outputJson)((0, json_1.formatSuccess)(info));
89
+ }
90
+ else {
91
+ await pretty.heading('Cache');
92
+ await pretty.plain(info.description);
93
+ await pretty.newline();
94
+ await pretty.plain('Providers:');
95
+ for (const p of info.providers) {
96
+ await pretty.plain(` • ${p.name}: ${p.description}`);
97
+ }
98
+ await pretty.newline();
99
+ await pretty.plain('Capabilities:');
100
+ for (const cap of info.capabilities) {
101
+ await pretty.plain(` • ${cap}`);
102
+ }
103
+ }
104
+ }
105
+ async function listProviders(outputFormat) {
106
+ const providers = [
107
+ { name: 'memory', description: 'In-memory cache', available: true },
108
+ { name: 'file', description: 'File-based cache', available: true }
109
+ ];
110
+ if (outputFormat === 'json') {
111
+ (0, json_1.outputJson)((0, json_1.formatSuccess)({ providers }));
112
+ }
113
+ else {
114
+ await pretty.heading('Cache Providers');
115
+ for (const p of providers) {
116
+ const status = p.available ? '✓' : '✗';
117
+ await pretty.plain(` ${status} ${p.name.padEnd(15)} ${p.description}`);
118
+ }
119
+ }
120
+ }
121
+ async function showHelp(outputFormat) {
122
+ const help = {
123
+ command: 'cache',
124
+ description: 'Caching management for LLM responses',
125
+ subcommands: [
126
+ { name: 'info', description: 'Show cache feature information' },
127
+ { name: 'providers', description: 'List available cache providers' },
128
+ { name: 'help', description: 'Show this help' }
129
+ ]
130
+ };
131
+ if (outputFormat === 'json') {
132
+ (0, json_1.outputJson)((0, json_1.formatSuccess)(help));
133
+ }
134
+ else {
135
+ await pretty.heading('Cache Command');
136
+ await pretty.plain(help.description);
137
+ await pretty.newline();
138
+ await pretty.plain('Subcommands:');
139
+ for (const cmd of help.subcommands) {
140
+ await pretty.plain(` ${cmd.name.padEnd(20)} ${cmd.description}`);
141
+ }
142
+ }
143
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Chat command - Chat with an AI agent
3
+ */
4
+ export interface ChatOptions {
5
+ model?: string;
6
+ stream?: boolean;
7
+ session?: string;
8
+ verbose?: boolean;
9
+ profile?: string;
10
+ config?: string;
11
+ output?: 'json' | 'text' | 'pretty';
12
+ json?: boolean;
13
+ }
14
+ export declare function execute(args: string[], options: ChatOptions): Promise<void>;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ /**
3
+ * Chat command - Chat with an AI agent
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 providers_1 = require("../../llm/providers");
41
+ const session_1 = require("../../session");
42
+ const resolve_1 = require("../config/resolve");
43
+ const json_1 = require("../output/json");
44
+ const pretty = __importStar(require("../output/pretty"));
45
+ const cli_spec_1 = require("../spec/cli-spec");
46
+ const errors_1 = require("../output/errors");
47
+ async function execute(args, options) {
48
+ const prompt = args[0];
49
+ if (!prompt) {
50
+ if (options.json || options.output === 'json') {
51
+ (0, json_1.printError)(errors_1.ERROR_CODES.MISSING_ARG, 'Please provide a prompt');
52
+ }
53
+ else {
54
+ await pretty.error('Please provide a prompt');
55
+ }
56
+ process.exit(cli_spec_1.EXIT_CODES.INVALID_ARGUMENTS);
57
+ }
58
+ // Resolve config with precedence
59
+ const config = (0, resolve_1.resolveConfig)({
60
+ configPath: options.config,
61
+ profile: options.profile,
62
+ model: options.model,
63
+ verbose: options.verbose,
64
+ stream: options.stream
65
+ });
66
+ const startTime = Date.now();
67
+ const outputFormat = options.json ? 'json' : (options.output || 'pretty');
68
+ try {
69
+ const provider = (0, providers_1.createProvider)(config.model);
70
+ const session = new session_1.Session({ id: options.session });
71
+ session.addMessage({ role: 'user', content: prompt });
72
+ let responseText = '';
73
+ let inputTokens = 0;
74
+ let outputTokens = 0;
75
+ if (config.stream && outputFormat !== 'json') {
76
+ // Streaming mode (only for non-JSON output)
77
+ const stream = await provider.streamText({
78
+ messages: [{ role: 'user', content: prompt }],
79
+ onToken: (token) => {
80
+ process.stdout.write(token);
81
+ responseText += token;
82
+ }
83
+ });
84
+ for await (const chunk of stream) {
85
+ // Stream is consumed by onToken
86
+ }
87
+ console.log(); // New line after streaming
88
+ }
89
+ else {
90
+ // Non-streaming mode
91
+ const result = await provider.generateText({
92
+ messages: [{ role: 'user', content: prompt }]
93
+ });
94
+ responseText = result.text;
95
+ inputTokens = result.usage?.promptTokens || 0;
96
+ outputTokens = result.usage?.completionTokens || 0;
97
+ if (outputFormat === 'json') {
98
+ const duration = Date.now() - startTime;
99
+ (0, json_1.outputJson)((0, json_1.formatSuccess)({ response: responseText }, {
100
+ duration_ms: duration,
101
+ model: config.model,
102
+ tokens: {
103
+ input: inputTokens,
104
+ output: outputTokens
105
+ }
106
+ }));
107
+ }
108
+ else {
109
+ console.log(responseText);
110
+ }
111
+ }
112
+ session.addMessage({ role: 'assistant', content: responseText });
113
+ }
114
+ catch (error) {
115
+ const cliError = (0, errors_1.normalizeError)(error);
116
+ if (outputFormat === 'json') {
117
+ (0, json_1.outputJson)((0, json_1.formatError)(cliError.code, cliError.message, cliError.details));
118
+ }
119
+ else {
120
+ await pretty.error(cliError.message);
121
+ if (config.verbose && error instanceof Error && error.stack) {
122
+ await pretty.dim(error.stack);
123
+ }
124
+ }
125
+ process.exit(cliError.exitCode);
126
+ }
127
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * CLI command: checkpoints
3
+ * Session state checkpointing and recovery
4
+ */
5
+ export declare function execute(args: string[], options: Record<string, unknown>): Promise<void>;