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,294 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* External Agents - Integration adapters for external AI CLI tools
|
|
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.GenericExternalAgent = exports.AiderAgent = exports.CodexCliAgent = exports.GeminiCliAgent = exports.ClaudeCodeAgent = exports.BaseExternalAgent = void 0;
|
|
40
|
+
exports.getExternalAgentRegistry = getExternalAgentRegistry;
|
|
41
|
+
exports.createExternalAgent = createExternalAgent;
|
|
42
|
+
exports.externalAgentAsTool = externalAgentAsTool;
|
|
43
|
+
/**
|
|
44
|
+
* Base class for external agent integrations
|
|
45
|
+
*/
|
|
46
|
+
class BaseExternalAgent {
|
|
47
|
+
constructor(config) {
|
|
48
|
+
this.config = {
|
|
49
|
+
timeout: 300000, // 5 minutes default
|
|
50
|
+
...config
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get the agent name
|
|
55
|
+
*/
|
|
56
|
+
getName() {
|
|
57
|
+
return this.config.name;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Execute a command and return result
|
|
61
|
+
*/
|
|
62
|
+
async runCommand(args) {
|
|
63
|
+
const { spawn } = await Promise.resolve().then(() => __importStar(require('child_process')));
|
|
64
|
+
const startTime = Date.now();
|
|
65
|
+
return new Promise((resolve) => {
|
|
66
|
+
const proc = spawn(this.config.command, args, {
|
|
67
|
+
cwd: this.config.cwd || process.cwd(),
|
|
68
|
+
env: { ...process.env, ...this.config.env },
|
|
69
|
+
timeout: this.config.timeout,
|
|
70
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
71
|
+
});
|
|
72
|
+
let stdout = '';
|
|
73
|
+
let stderr = '';
|
|
74
|
+
proc.stdout?.on('data', (data) => {
|
|
75
|
+
stdout += data.toString();
|
|
76
|
+
});
|
|
77
|
+
proc.stderr?.on('data', (data) => {
|
|
78
|
+
stderr += data.toString();
|
|
79
|
+
});
|
|
80
|
+
proc.on('close', (code) => {
|
|
81
|
+
resolve({
|
|
82
|
+
success: code === 0,
|
|
83
|
+
output: stdout,
|
|
84
|
+
error: stderr || undefined,
|
|
85
|
+
exitCode: code || 0,
|
|
86
|
+
duration: Date.now() - startTime
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
proc.on('error', (error) => {
|
|
90
|
+
resolve({
|
|
91
|
+
success: false,
|
|
92
|
+
output: '',
|
|
93
|
+
error: error.message,
|
|
94
|
+
exitCode: 1,
|
|
95
|
+
duration: Date.now() - startTime
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Check if a command exists
|
|
102
|
+
*/
|
|
103
|
+
async commandExists(command) {
|
|
104
|
+
const { spawn } = await Promise.resolve().then(() => __importStar(require('child_process')));
|
|
105
|
+
return new Promise((resolve) => {
|
|
106
|
+
const proc = spawn('which', [command], { stdio: 'pipe' });
|
|
107
|
+
proc.on('close', (code) => resolve(code === 0));
|
|
108
|
+
proc.on('error', () => resolve(false));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.BaseExternalAgent = BaseExternalAgent;
|
|
113
|
+
/**
|
|
114
|
+
* Claude Code CLI integration
|
|
115
|
+
*/
|
|
116
|
+
class ClaudeCodeAgent extends BaseExternalAgent {
|
|
117
|
+
constructor(cwd) {
|
|
118
|
+
super({
|
|
119
|
+
name: 'claude-code',
|
|
120
|
+
command: 'claude',
|
|
121
|
+
cwd
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async isAvailable() {
|
|
125
|
+
return this.commandExists('claude');
|
|
126
|
+
}
|
|
127
|
+
async execute(prompt) {
|
|
128
|
+
return this.runCommand(['--print', prompt]);
|
|
129
|
+
}
|
|
130
|
+
async executeWithSession(prompt, sessionId) {
|
|
131
|
+
const args = ['--print'];
|
|
132
|
+
if (sessionId) {
|
|
133
|
+
args.push('--continue', sessionId);
|
|
134
|
+
}
|
|
135
|
+
args.push(prompt);
|
|
136
|
+
return this.runCommand(args);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.ClaudeCodeAgent = ClaudeCodeAgent;
|
|
140
|
+
/**
|
|
141
|
+
* Gemini CLI integration
|
|
142
|
+
*/
|
|
143
|
+
class GeminiCliAgent extends BaseExternalAgent {
|
|
144
|
+
constructor(cwd, model = 'gemini-2.5-pro') {
|
|
145
|
+
super({
|
|
146
|
+
name: 'gemini-cli',
|
|
147
|
+
command: 'gemini',
|
|
148
|
+
cwd
|
|
149
|
+
});
|
|
150
|
+
this.model = model;
|
|
151
|
+
}
|
|
152
|
+
async isAvailable() {
|
|
153
|
+
return this.commandExists('gemini');
|
|
154
|
+
}
|
|
155
|
+
async execute(prompt) {
|
|
156
|
+
return this.runCommand(['-m', this.model, prompt]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.GeminiCliAgent = GeminiCliAgent;
|
|
160
|
+
/**
|
|
161
|
+
* OpenAI Codex CLI integration
|
|
162
|
+
*/
|
|
163
|
+
class CodexCliAgent extends BaseExternalAgent {
|
|
164
|
+
constructor(cwd) {
|
|
165
|
+
super({
|
|
166
|
+
name: 'codex-cli',
|
|
167
|
+
command: 'codex',
|
|
168
|
+
cwd
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
async isAvailable() {
|
|
172
|
+
return this.commandExists('codex');
|
|
173
|
+
}
|
|
174
|
+
async execute(prompt) {
|
|
175
|
+
return this.runCommand(['exec', '--full-auto', prompt]);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.CodexCliAgent = CodexCliAgent;
|
|
179
|
+
/**
|
|
180
|
+
* Aider CLI integration
|
|
181
|
+
*/
|
|
182
|
+
class AiderAgent extends BaseExternalAgent {
|
|
183
|
+
constructor(cwd) {
|
|
184
|
+
super({
|
|
185
|
+
name: 'aider',
|
|
186
|
+
command: 'aider',
|
|
187
|
+
cwd
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
async isAvailable() {
|
|
191
|
+
return this.commandExists('aider');
|
|
192
|
+
}
|
|
193
|
+
async execute(prompt) {
|
|
194
|
+
return this.runCommand(['--message', prompt, '--yes']);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
exports.AiderAgent = AiderAgent;
|
|
198
|
+
/**
|
|
199
|
+
* Generic external agent for any CLI tool
|
|
200
|
+
*/
|
|
201
|
+
class GenericExternalAgent extends BaseExternalAgent {
|
|
202
|
+
constructor(config) {
|
|
203
|
+
super(config);
|
|
204
|
+
this.promptArg = config.promptArg || '';
|
|
205
|
+
}
|
|
206
|
+
async isAvailable() {
|
|
207
|
+
return this.commandExists(this.config.command);
|
|
208
|
+
}
|
|
209
|
+
async execute(prompt) {
|
|
210
|
+
const args = [...(this.config.args || [])];
|
|
211
|
+
if (this.promptArg) {
|
|
212
|
+
args.push(this.promptArg, prompt);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
args.push(prompt);
|
|
216
|
+
}
|
|
217
|
+
return this.runCommand(args);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
exports.GenericExternalAgent = GenericExternalAgent;
|
|
221
|
+
/**
|
|
222
|
+
* External Agent Registry
|
|
223
|
+
*/
|
|
224
|
+
class ExternalAgentRegistry {
|
|
225
|
+
constructor() {
|
|
226
|
+
this.agents = new Map();
|
|
227
|
+
// Register built-in agents
|
|
228
|
+
this.register('claude', () => new ClaudeCodeAgent());
|
|
229
|
+
this.register('gemini', () => new GeminiCliAgent());
|
|
230
|
+
this.register('codex', () => new CodexCliAgent());
|
|
231
|
+
this.register('aider', () => new AiderAgent());
|
|
232
|
+
}
|
|
233
|
+
register(name, factory) {
|
|
234
|
+
this.agents.set(name, factory);
|
|
235
|
+
}
|
|
236
|
+
get(name) {
|
|
237
|
+
const factory = this.agents.get(name);
|
|
238
|
+
return factory ? factory() : undefined;
|
|
239
|
+
}
|
|
240
|
+
list() {
|
|
241
|
+
return Array.from(this.agents.keys());
|
|
242
|
+
}
|
|
243
|
+
async getAvailable() {
|
|
244
|
+
const available = [];
|
|
245
|
+
for (const [name, factory] of this.agents) {
|
|
246
|
+
const agent = factory();
|
|
247
|
+
if (await agent.isAvailable()) {
|
|
248
|
+
available.push(name);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return available;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
let registry = null;
|
|
255
|
+
function getExternalAgentRegistry() {
|
|
256
|
+
if (!registry) {
|
|
257
|
+
registry = new ExternalAgentRegistry();
|
|
258
|
+
}
|
|
259
|
+
return registry;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Create an external agent by name
|
|
263
|
+
*/
|
|
264
|
+
function createExternalAgent(name, cwd) {
|
|
265
|
+
const reg = getExternalAgentRegistry();
|
|
266
|
+
switch (name) {
|
|
267
|
+
case 'claude':
|
|
268
|
+
return new ClaudeCodeAgent(cwd);
|
|
269
|
+
case 'gemini':
|
|
270
|
+
return new GeminiCliAgent(cwd);
|
|
271
|
+
case 'codex':
|
|
272
|
+
return new CodexCliAgent(cwd);
|
|
273
|
+
case 'aider':
|
|
274
|
+
return new AiderAgent(cwd);
|
|
275
|
+
default:
|
|
276
|
+
return reg.get(name);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Convert external agent to tool for use with PraisonAI agents
|
|
281
|
+
*/
|
|
282
|
+
function externalAgentAsTool(agent) {
|
|
283
|
+
return {
|
|
284
|
+
name: `external_${agent.getName()}`,
|
|
285
|
+
description: `Execute a prompt using the ${agent.getName()} external agent`,
|
|
286
|
+
execute: async (input) => {
|
|
287
|
+
const result = await agent.execute(input);
|
|
288
|
+
if (!result.success) {
|
|
289
|
+
throw new Error(result.error || 'External agent execution failed');
|
|
290
|
+
}
|
|
291
|
+
return result.output;
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fast Context - Fast retrieval and summarization pipeline
|
|
3
|
+
* Minimizes tokens and latency with deterministic caching
|
|
4
|
+
*/
|
|
5
|
+
export interface FastContextConfig {
|
|
6
|
+
maxTokens?: number;
|
|
7
|
+
cacheEnabled?: boolean;
|
|
8
|
+
cacheTTL?: number;
|
|
9
|
+
summarizer?: (text: string, maxTokens: number) => Promise<string>;
|
|
10
|
+
embeddingProvider?: {
|
|
11
|
+
embed: (text: string) => Promise<number[]>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface ContextSource {
|
|
15
|
+
id: string;
|
|
16
|
+
type: 'memory' | 'knowledge' | 'file' | 'custom';
|
|
17
|
+
content: string;
|
|
18
|
+
relevance?: number;
|
|
19
|
+
metadata?: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
export interface FastContextResult {
|
|
22
|
+
context: string;
|
|
23
|
+
sources: ContextSource[];
|
|
24
|
+
tokenCount: number;
|
|
25
|
+
cached: boolean;
|
|
26
|
+
latencyMs: number;
|
|
27
|
+
}
|
|
28
|
+
export interface CacheEntry {
|
|
29
|
+
result: FastContextResult;
|
|
30
|
+
timestamp: number;
|
|
31
|
+
hits: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Fast Context class for efficient context retrieval
|
|
35
|
+
*/
|
|
36
|
+
export declare class FastContext {
|
|
37
|
+
private config;
|
|
38
|
+
private cache;
|
|
39
|
+
private sources;
|
|
40
|
+
constructor(config?: FastContextConfig);
|
|
41
|
+
/**
|
|
42
|
+
* Register a context source
|
|
43
|
+
*/
|
|
44
|
+
registerSource(id: string, type: ContextSource['type'], contents: string[], metadata?: Record<string, any>): void;
|
|
45
|
+
/**
|
|
46
|
+
* Register memory as a source
|
|
47
|
+
*/
|
|
48
|
+
registerMemory(memory: {
|
|
49
|
+
getAll: () => Array<{
|
|
50
|
+
content: string;
|
|
51
|
+
metadata?: any;
|
|
52
|
+
}>;
|
|
53
|
+
}): void;
|
|
54
|
+
/**
|
|
55
|
+
* Register knowledge base as a source
|
|
56
|
+
*/
|
|
57
|
+
registerKnowledge(knowledge: {
|
|
58
|
+
search: (query: string, limit?: number) => Promise<Array<{
|
|
59
|
+
content: string;
|
|
60
|
+
score: number;
|
|
61
|
+
}>>;
|
|
62
|
+
}): void;
|
|
63
|
+
/**
|
|
64
|
+
* Get context for a query
|
|
65
|
+
*/
|
|
66
|
+
getContext(query: string): Promise<FastContextResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Gather relevant sources for a query
|
|
69
|
+
*/
|
|
70
|
+
private gatherRelevantSources;
|
|
71
|
+
/**
|
|
72
|
+
* Score relevance using embeddings
|
|
73
|
+
*/
|
|
74
|
+
private scoreRelevance;
|
|
75
|
+
/**
|
|
76
|
+
* Simple text-based relevance scoring
|
|
77
|
+
*/
|
|
78
|
+
private scoreRelevanceSimple;
|
|
79
|
+
/**
|
|
80
|
+
* Build context from sources within token limit
|
|
81
|
+
*/
|
|
82
|
+
private buildContext;
|
|
83
|
+
/**
|
|
84
|
+
* Get cache key for query
|
|
85
|
+
*/
|
|
86
|
+
private getCacheKey;
|
|
87
|
+
/**
|
|
88
|
+
* Get from cache
|
|
89
|
+
*/
|
|
90
|
+
private getFromCache;
|
|
91
|
+
/**
|
|
92
|
+
* Add to cache
|
|
93
|
+
*/
|
|
94
|
+
private addToCache;
|
|
95
|
+
/**
|
|
96
|
+
* Clear cache
|
|
97
|
+
*/
|
|
98
|
+
clearCache(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Get cache stats
|
|
101
|
+
*/
|
|
102
|
+
getCacheStats(): {
|
|
103
|
+
size: number;
|
|
104
|
+
totalHits: number;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Estimate token count
|
|
108
|
+
*/
|
|
109
|
+
private estimateTokens;
|
|
110
|
+
/**
|
|
111
|
+
* Cosine similarity
|
|
112
|
+
*/
|
|
113
|
+
private cosineSimilarity;
|
|
114
|
+
/**
|
|
115
|
+
* Clear all sources
|
|
116
|
+
*/
|
|
117
|
+
clearSources(): void;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Create a fast context instance
|
|
121
|
+
*/
|
|
122
|
+
export declare function createFastContext(config?: FastContextConfig): FastContext;
|
|
123
|
+
/**
|
|
124
|
+
* Quick context retrieval
|
|
125
|
+
*/
|
|
126
|
+
export declare function getQuickContext(query: string, sources: string[], maxTokens?: number): Promise<string>;
|