praisonai 1.0.19 → 1.2.0
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/context.d.ts +68 -0
- package/dist/agent/context.js +119 -0
- package/dist/agent/enhanced.d.ts +92 -0
- package/dist/agent/enhanced.js +267 -0
- package/dist/agent/handoff.d.ts +82 -0
- package/dist/agent/handoff.js +124 -0
- package/dist/agent/image.d.ts +51 -0
- package/dist/agent/image.js +93 -0
- package/dist/agent/prompt-expander.d.ts +40 -0
- package/dist/agent/prompt-expander.js +84 -0
- package/dist/agent/query-rewriter.d.ts +38 -0
- package/dist/agent/query-rewriter.js +79 -0
- package/dist/agent/research.d.ts +52 -0
- package/dist/agent/research.js +118 -0
- package/dist/agent/router.d.ts +77 -0
- package/dist/agent/router.js +113 -0
- package/dist/agent/simple.js +1 -1
- package/dist/agent/types.js +2 -2
- package/dist/auto/index.d.ts +56 -0
- package/dist/auto/index.js +142 -0
- package/dist/cli/index.d.ts +20 -0
- package/dist/cli/index.js +150 -0
- package/dist/db/index.d.ts +23 -0
- package/dist/db/index.js +72 -0
- package/dist/db/memory-adapter.d.ts +42 -0
- package/dist/db/memory-adapter.js +146 -0
- package/dist/db/types.d.ts +113 -0
- package/dist/db/types.js +5 -0
- package/dist/eval/index.d.ts +61 -0
- package/dist/eval/index.js +157 -0
- package/dist/guardrails/index.d.ts +82 -0
- package/dist/guardrails/index.js +202 -0
- package/dist/guardrails/llm-guardrail.d.ts +40 -0
- package/dist/guardrails/llm-guardrail.js +91 -0
- package/dist/index.d.ts +26 -1
- package/dist/index.js +122 -1
- package/dist/knowledge/chunking.d.ts +55 -0
- package/dist/knowledge/chunking.js +157 -0
- package/dist/knowledge/rag.d.ts +80 -0
- package/dist/knowledge/rag.js +147 -0
- package/dist/llm/openai.js +1 -1
- package/dist/llm/providers/anthropic.d.ts +33 -0
- package/dist/llm/providers/anthropic.js +291 -0
- package/dist/llm/providers/base.d.ts +25 -0
- package/dist/llm/providers/base.js +43 -0
- package/dist/llm/providers/google.d.ts +27 -0
- package/dist/llm/providers/google.js +275 -0
- package/dist/llm/providers/index.d.ts +43 -0
- package/dist/llm/providers/index.js +116 -0
- package/dist/llm/providers/openai.d.ts +18 -0
- package/dist/llm/providers/openai.js +203 -0
- package/dist/llm/providers/types.d.ts +94 -0
- package/dist/llm/providers/types.js +5 -0
- package/dist/memory/memory.d.ts +92 -0
- package/dist/memory/memory.js +169 -0
- package/dist/observability/index.d.ts +86 -0
- package/dist/observability/index.js +166 -0
- package/dist/planning/index.d.ts +133 -0
- package/dist/planning/index.js +228 -0
- package/dist/session/index.d.ts +111 -0
- package/dist/session/index.js +250 -0
- package/dist/skills/index.d.ts +70 -0
- package/dist/skills/index.js +233 -0
- package/dist/telemetry/index.d.ts +102 -0
- package/dist/telemetry/index.js +187 -0
- package/dist/tools/decorator.d.ts +91 -0
- package/dist/tools/decorator.js +165 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/mcpSse.d.ts +41 -0
- package/dist/tools/mcpSse.js +108 -0
- package/dist/workflows/index.d.ts +97 -0
- package/dist/workflows/index.js +216 -0
- package/package.json +5 -2
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Guardrails - Input/output validation and safety checks
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.builtinGuardrails = exports.GuardrailManager = exports.Guardrail = void 0;
|
|
7
|
+
exports.guardrail = guardrail;
|
|
8
|
+
/**
|
|
9
|
+
* Guardrail class
|
|
10
|
+
*/
|
|
11
|
+
class Guardrail {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.name = config.name;
|
|
14
|
+
this.description = config.description || `Guardrail: ${config.name}`;
|
|
15
|
+
this.check = config.check;
|
|
16
|
+
this.onFail = config.onFail || 'block';
|
|
17
|
+
}
|
|
18
|
+
async run(content, context) {
|
|
19
|
+
try {
|
|
20
|
+
return await this.check(content, context);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return {
|
|
24
|
+
status: 'failed',
|
|
25
|
+
message: `Guardrail error: ${error.message}`,
|
|
26
|
+
details: { error: error.message },
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.Guardrail = Guardrail;
|
|
32
|
+
/**
|
|
33
|
+
* Create a guardrail
|
|
34
|
+
*/
|
|
35
|
+
function guardrail(config) {
|
|
36
|
+
return new Guardrail(config);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Guardrail Manager - Run multiple guardrails
|
|
40
|
+
*/
|
|
41
|
+
class GuardrailManager {
|
|
42
|
+
constructor() {
|
|
43
|
+
this.guardrails = [];
|
|
44
|
+
}
|
|
45
|
+
add(g) {
|
|
46
|
+
this.guardrails.push(g);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
async runAll(content, context) {
|
|
50
|
+
const results = [];
|
|
51
|
+
let passed = true;
|
|
52
|
+
for (const g of this.guardrails) {
|
|
53
|
+
const result = await g.run(content, context);
|
|
54
|
+
results.push({ name: g.name, result });
|
|
55
|
+
if (result.status === 'failed') {
|
|
56
|
+
passed = false;
|
|
57
|
+
if (g.onFail === 'block') {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return { passed, results };
|
|
63
|
+
}
|
|
64
|
+
get count() {
|
|
65
|
+
return this.guardrails.length;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.GuardrailManager = GuardrailManager;
|
|
69
|
+
/**
|
|
70
|
+
* Built-in guardrails
|
|
71
|
+
*/
|
|
72
|
+
exports.builtinGuardrails = {
|
|
73
|
+
/**
|
|
74
|
+
* Check for maximum length
|
|
75
|
+
*/
|
|
76
|
+
maxLength: (maxChars) => {
|
|
77
|
+
return guardrail({
|
|
78
|
+
name: 'max_length',
|
|
79
|
+
description: `Ensure content is under ${maxChars} characters`,
|
|
80
|
+
check: (content) => {
|
|
81
|
+
if (content.length > maxChars) {
|
|
82
|
+
return {
|
|
83
|
+
status: 'failed',
|
|
84
|
+
message: `Content exceeds maximum length of ${maxChars} characters`,
|
|
85
|
+
details: { length: content.length, max: maxChars },
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return { status: 'passed' };
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* Check for minimum length
|
|
94
|
+
*/
|
|
95
|
+
minLength: (minChars) => {
|
|
96
|
+
return guardrail({
|
|
97
|
+
name: 'min_length',
|
|
98
|
+
description: `Ensure content is at least ${minChars} characters`,
|
|
99
|
+
check: (content) => {
|
|
100
|
+
if (content.length < minChars) {
|
|
101
|
+
return {
|
|
102
|
+
status: 'failed',
|
|
103
|
+
message: `Content is below minimum length of ${minChars} characters`,
|
|
104
|
+
details: { length: content.length, min: minChars },
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return { status: 'passed' };
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* Check for blocked words
|
|
113
|
+
*/
|
|
114
|
+
blockedWords: (words) => {
|
|
115
|
+
return guardrail({
|
|
116
|
+
name: 'blocked_words',
|
|
117
|
+
description: 'Check for blocked words',
|
|
118
|
+
check: (content) => {
|
|
119
|
+
const lowerContent = content.toLowerCase();
|
|
120
|
+
const found = words.filter(w => lowerContent.includes(w.toLowerCase()));
|
|
121
|
+
if (found.length > 0) {
|
|
122
|
+
return {
|
|
123
|
+
status: 'failed',
|
|
124
|
+
message: `Content contains blocked words`,
|
|
125
|
+
details: { blockedWords: found },
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return { status: 'passed' };
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
/**
|
|
133
|
+
* Check for required words
|
|
134
|
+
*/
|
|
135
|
+
requiredWords: (words) => {
|
|
136
|
+
return guardrail({
|
|
137
|
+
name: 'required_words',
|
|
138
|
+
description: 'Check for required words',
|
|
139
|
+
check: (content) => {
|
|
140
|
+
const lowerContent = content.toLowerCase();
|
|
141
|
+
const missing = words.filter(w => !lowerContent.includes(w.toLowerCase()));
|
|
142
|
+
if (missing.length > 0) {
|
|
143
|
+
return {
|
|
144
|
+
status: 'failed',
|
|
145
|
+
message: `Content missing required words`,
|
|
146
|
+
details: { missingWords: missing },
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return { status: 'passed' };
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* Regex pattern check
|
|
155
|
+
*/
|
|
156
|
+
pattern: (regex, mustMatch = true) => {
|
|
157
|
+
return guardrail({
|
|
158
|
+
name: 'pattern',
|
|
159
|
+
description: `Check content against pattern: ${regex}`,
|
|
160
|
+
check: (content) => {
|
|
161
|
+
const matches = regex.test(content);
|
|
162
|
+
if (mustMatch && !matches) {
|
|
163
|
+
return {
|
|
164
|
+
status: 'failed',
|
|
165
|
+
message: `Content does not match required pattern`,
|
|
166
|
+
details: { pattern: regex.toString() },
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
if (!mustMatch && matches) {
|
|
170
|
+
return {
|
|
171
|
+
status: 'failed',
|
|
172
|
+
message: `Content matches forbidden pattern`,
|
|
173
|
+
details: { pattern: regex.toString() },
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return { status: 'passed' };
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
* JSON validity check
|
|
182
|
+
*/
|
|
183
|
+
validJson: () => {
|
|
184
|
+
return guardrail({
|
|
185
|
+
name: 'valid_json',
|
|
186
|
+
description: 'Ensure content is valid JSON',
|
|
187
|
+
check: (content) => {
|
|
188
|
+
try {
|
|
189
|
+
JSON.parse(content);
|
|
190
|
+
return { status: 'passed' };
|
|
191
|
+
}
|
|
192
|
+
catch (e) {
|
|
193
|
+
return {
|
|
194
|
+
status: 'failed',
|
|
195
|
+
message: 'Content is not valid JSON',
|
|
196
|
+
details: { error: e.message },
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLMGuardrail - LLM-based content validation
|
|
3
|
+
*/
|
|
4
|
+
export interface LLMGuardrailConfig {
|
|
5
|
+
name: string;
|
|
6
|
+
criteria: string;
|
|
7
|
+
llm?: string;
|
|
8
|
+
threshold?: number;
|
|
9
|
+
verbose?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface LLMGuardrailResult {
|
|
12
|
+
status: 'passed' | 'failed' | 'warning';
|
|
13
|
+
score: number;
|
|
14
|
+
message?: string;
|
|
15
|
+
reasoning?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* LLMGuardrail - Use LLM to validate content against criteria
|
|
19
|
+
*/
|
|
20
|
+
export declare class LLMGuardrail {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly criteria: string;
|
|
23
|
+
private provider;
|
|
24
|
+
private threshold;
|
|
25
|
+
private verbose;
|
|
26
|
+
constructor(config: LLMGuardrailConfig);
|
|
27
|
+
/**
|
|
28
|
+
* Check content against criteria
|
|
29
|
+
*/
|
|
30
|
+
check(content: string): Promise<LLMGuardrailResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Run guardrail (alias for check)
|
|
33
|
+
*/
|
|
34
|
+
run(content: string): Promise<LLMGuardrailResult>;
|
|
35
|
+
private parseResponse;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create an LLMGuardrail
|
|
39
|
+
*/
|
|
40
|
+
export declare function createLLMGuardrail(config: LLMGuardrailConfig): LLMGuardrail;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LLMGuardrail - LLM-based content validation
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LLMGuardrail = void 0;
|
|
7
|
+
exports.createLLMGuardrail = createLLMGuardrail;
|
|
8
|
+
const providers_1 = require("../llm/providers");
|
|
9
|
+
/**
|
|
10
|
+
* LLMGuardrail - Use LLM to validate content against criteria
|
|
11
|
+
*/
|
|
12
|
+
class LLMGuardrail {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
this.name = config.name;
|
|
15
|
+
this.criteria = config.criteria;
|
|
16
|
+
this.provider = (0, providers_1.createProvider)(config.llm || 'openai/gpt-4o-mini');
|
|
17
|
+
this.threshold = config.threshold ?? 0.7;
|
|
18
|
+
this.verbose = config.verbose ?? false;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Check content against criteria
|
|
22
|
+
*/
|
|
23
|
+
async check(content) {
|
|
24
|
+
const prompt = `Evaluate the following content against this criteria:
|
|
25
|
+
|
|
26
|
+
Criteria: ${this.criteria}
|
|
27
|
+
|
|
28
|
+
Content: ${content}
|
|
29
|
+
|
|
30
|
+
Respond with a JSON object containing:
|
|
31
|
+
- score: number from 0 to 1 (1 = fully meets criteria)
|
|
32
|
+
- passed: boolean
|
|
33
|
+
- reasoning: brief explanation
|
|
34
|
+
|
|
35
|
+
JSON response:`;
|
|
36
|
+
try {
|
|
37
|
+
const result = await this.provider.generateText({
|
|
38
|
+
messages: [{ role: 'user', content: prompt }]
|
|
39
|
+
});
|
|
40
|
+
const parsed = this.parseResponse(result.text);
|
|
41
|
+
if (this.verbose) {
|
|
42
|
+
console.log(`[LLMGuardrail:${this.name}] Score: ${parsed.score}, Passed: ${parsed.status}`);
|
|
43
|
+
}
|
|
44
|
+
return parsed;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return {
|
|
48
|
+
status: 'warning',
|
|
49
|
+
score: 0.5,
|
|
50
|
+
message: `Guardrail check failed: ${error.message}`
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Run guardrail (alias for check)
|
|
56
|
+
*/
|
|
57
|
+
async run(content) {
|
|
58
|
+
return this.check(content);
|
|
59
|
+
}
|
|
60
|
+
parseResponse(response) {
|
|
61
|
+
try {
|
|
62
|
+
const jsonMatch = response.match(/\{[\s\S]*\}/);
|
|
63
|
+
if (jsonMatch) {
|
|
64
|
+
const parsed = JSON.parse(jsonMatch[0]);
|
|
65
|
+
const score = typeof parsed.score === 'number' ? parsed.score : 0.5;
|
|
66
|
+
return {
|
|
67
|
+
status: score >= this.threshold ? 'passed' : 'failed',
|
|
68
|
+
score,
|
|
69
|
+
reasoning: parsed.reasoning
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
// Parse failed
|
|
75
|
+
}
|
|
76
|
+
// Fallback parsing
|
|
77
|
+
const hasPositive = /pass|good|valid|accept|meets/i.test(response);
|
|
78
|
+
return {
|
|
79
|
+
status: hasPositive ? 'passed' : 'failed',
|
|
80
|
+
score: hasPositive ? 0.8 : 0.3,
|
|
81
|
+
reasoning: response.substring(0, 200)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.LLMGuardrail = LLMGuardrail;
|
|
86
|
+
/**
|
|
87
|
+
* Create an LLMGuardrail
|
|
88
|
+
*/
|
|
89
|
+
function createLLMGuardrail(config) {
|
|
90
|
+
return new LLMGuardrail(config);
|
|
91
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,29 @@ export * from './knowledge';
|
|
|
3
3
|
export * from './llm';
|
|
4
4
|
export * from './memory';
|
|
5
5
|
export * from './process';
|
|
6
|
-
export
|
|
6
|
+
export { Tool, BaseTool, FunctionTool, tool, ToolRegistry, getRegistry, registerTool, getTool, type ToolConfig, type ToolContext, type ToolParameters } from './tools';
|
|
7
|
+
export * from './tools/arxivTools';
|
|
8
|
+
export * from './tools/mcpSse';
|
|
9
|
+
export * from './session';
|
|
10
|
+
export * from './db';
|
|
11
|
+
export * from './workflows';
|
|
12
|
+
export * from './guardrails';
|
|
13
|
+
export { Handoff, handoff, handoffFilters, type HandoffConfig, type HandoffContext, type HandoffResult } from './agent/handoff';
|
|
14
|
+
export { RouterAgent, createRouter, routeConditions, type RouterConfig, type RouteConfig, type RouteContext } from './agent/router';
|
|
15
|
+
export { ContextAgent, createContextAgent, type ContextAgentConfig, type ContextMessage } from './agent/context';
|
|
16
|
+
export { KnowledgeBase, createKnowledgeBase, type Document, type SearchResult, type EmbeddingProvider, type KnowledgeBaseConfig } from './knowledge/rag';
|
|
17
|
+
export { accuracyEval, performanceEval, reliabilityEval, EvalSuite, type EvalResult, type PerformanceResult, type AccuracyEvalConfig, type PerformanceEvalConfig, type ReliabilityEvalConfig } from './eval';
|
|
18
|
+
export { MemoryObservabilityAdapter, ConsoleObservabilityAdapter, setObservabilityAdapter, getObservabilityAdapter, type ObservabilityAdapter, type TraceContext, type SpanContext, type SpanData, type TraceData } from './observability';
|
|
19
|
+
export { SkillManager, createSkillManager, parseSkillFile, type Skill, type SkillMetadata, type SkillDiscoveryOptions } from './skills';
|
|
20
|
+
export { chat, listProviders, version, help } from './cli';
|
|
21
|
+
export { Memory, createMemory, type MemoryEntry, type MemoryConfig, type SearchResult as MemorySearchResult } from './memory/memory';
|
|
22
|
+
export { TelemetryCollector, getTelemetry, enableTelemetry, disableTelemetry, cleanupTelemetry, type TelemetryEvent, type TelemetryConfig } from './telemetry';
|
|
23
|
+
export { AutoAgents, createAutoAgents, type AgentConfig, type TaskConfig, type TeamStructure, type AutoAgentsConfig } from './auto';
|
|
24
|
+
export { ImageAgent, createImageAgent, type ImageAgentConfig, type ImageGenerationConfig, type ImageAnalysisConfig } from './agent/image';
|
|
25
|
+
export { DeepResearchAgent, createDeepResearchAgent, type DeepResearchConfig, type ResearchResponse, type Citation, type ReasoningStep } from './agent/research';
|
|
26
|
+
export { QueryRewriterAgent, createQueryRewriterAgent, type QueryRewriterConfig, type RewriteResult, type RewriteStrategy } from './agent/query-rewriter';
|
|
27
|
+
export { PromptExpanderAgent, createPromptExpanderAgent, type PromptExpanderConfig, type ExpandResult, type ExpandStrategy } from './agent/prompt-expander';
|
|
28
|
+
export { Chunking, createChunking, type ChunkingConfig, type Chunk, type ChunkStrategy } from './knowledge/chunking';
|
|
29
|
+
export { LLMGuardrail, createLLMGuardrail, type LLMGuardrailConfig, type LLMGuardrailResult } from './guardrails/llm-guardrail';
|
|
30
|
+
export { Plan, PlanStep, TodoList, TodoItem, PlanStorage, createPlan, createTodoList, createPlanStorage, type PlanConfig, type PlanStepConfig, type TodoItemConfig, type PlanStatus, type TodoStatus } from './planning';
|
|
31
|
+
export { createProvider, getDefaultProvider, parseModelString, isProviderAvailable, getAvailableProviders, OpenAIProvider, AnthropicProvider, GoogleProvider, BaseProvider, type LLMProvider, type ProviderConfig, type ProviderFactory, type GenerateTextOptions, type GenerateTextResult, type StreamTextOptions, type StreamChunk, type GenerateObjectOptions, type GenerateObjectResult, type TokenUsage, type Message as ProviderMessage, type ToolCall, type ToolDefinition as ProviderToolDefinition, } from './llm/providers';
|
package/dist/index.js
CHANGED
|
@@ -14,10 +14,131 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Chunking = exports.createPromptExpanderAgent = exports.PromptExpanderAgent = exports.createQueryRewriterAgent = exports.QueryRewriterAgent = exports.createDeepResearchAgent = exports.DeepResearchAgent = exports.createImageAgent = exports.ImageAgent = exports.createAutoAgents = exports.AutoAgents = exports.cleanupTelemetry = exports.disableTelemetry = exports.enableTelemetry = exports.getTelemetry = exports.TelemetryCollector = exports.createMemory = exports.Memory = exports.help = exports.version = exports.listProviders = exports.chat = exports.parseSkillFile = exports.createSkillManager = exports.SkillManager = exports.getObservabilityAdapter = exports.setObservabilityAdapter = exports.ConsoleObservabilityAdapter = exports.MemoryObservabilityAdapter = exports.EvalSuite = exports.reliabilityEval = exports.performanceEval = exports.accuracyEval = exports.createKnowledgeBase = exports.KnowledgeBase = exports.createContextAgent = exports.ContextAgent = exports.routeConditions = exports.createRouter = exports.RouterAgent = exports.handoffFilters = exports.handoff = exports.Handoff = exports.getTool = exports.registerTool = exports.getRegistry = exports.ToolRegistry = exports.tool = exports.FunctionTool = exports.BaseTool = void 0;
|
|
18
|
+
exports.BaseProvider = exports.GoogleProvider = exports.AnthropicProvider = exports.OpenAIProvider = exports.getAvailableProviders = exports.isProviderAvailable = exports.parseModelString = exports.getDefaultProvider = exports.createProvider = exports.createPlanStorage = exports.createTodoList = exports.createPlan = exports.PlanStorage = exports.TodoItem = exports.TodoList = exports.PlanStep = exports.Plan = exports.createLLMGuardrail = exports.LLMGuardrail = exports.createChunking = void 0;
|
|
17
19
|
// Export all public modules
|
|
18
20
|
__exportStar(require("./agent"), exports);
|
|
19
21
|
__exportStar(require("./knowledge"), exports);
|
|
20
22
|
__exportStar(require("./llm"), exports);
|
|
21
23
|
__exportStar(require("./memory"), exports);
|
|
22
24
|
__exportStar(require("./process"), exports);
|
|
23
|
-
|
|
25
|
+
// Export tools (excluding conflicting types)
|
|
26
|
+
var tools_1 = require("./tools");
|
|
27
|
+
Object.defineProperty(exports, "BaseTool", { enumerable: true, get: function () { return tools_1.BaseTool; } });
|
|
28
|
+
Object.defineProperty(exports, "FunctionTool", { enumerable: true, get: function () { return tools_1.FunctionTool; } });
|
|
29
|
+
Object.defineProperty(exports, "tool", { enumerable: true, get: function () { return tools_1.tool; } });
|
|
30
|
+
Object.defineProperty(exports, "ToolRegistry", { enumerable: true, get: function () { return tools_1.ToolRegistry; } });
|
|
31
|
+
Object.defineProperty(exports, "getRegistry", { enumerable: true, get: function () { return tools_1.getRegistry; } });
|
|
32
|
+
Object.defineProperty(exports, "registerTool", { enumerable: true, get: function () { return tools_1.registerTool; } });
|
|
33
|
+
Object.defineProperty(exports, "getTool", { enumerable: true, get: function () { return tools_1.getTool; } });
|
|
34
|
+
__exportStar(require("./tools/arxivTools"), exports);
|
|
35
|
+
__exportStar(require("./tools/mcpSse"), exports);
|
|
36
|
+
// Export session management
|
|
37
|
+
__exportStar(require("./session"), exports);
|
|
38
|
+
// Export database adapters
|
|
39
|
+
__exportStar(require("./db"), exports);
|
|
40
|
+
// Export workflows
|
|
41
|
+
__exportStar(require("./workflows"), exports);
|
|
42
|
+
// Export guardrails
|
|
43
|
+
__exportStar(require("./guardrails"), exports);
|
|
44
|
+
// Export handoff
|
|
45
|
+
var handoff_1 = require("./agent/handoff");
|
|
46
|
+
Object.defineProperty(exports, "Handoff", { enumerable: true, get: function () { return handoff_1.Handoff; } });
|
|
47
|
+
Object.defineProperty(exports, "handoff", { enumerable: true, get: function () { return handoff_1.handoff; } });
|
|
48
|
+
Object.defineProperty(exports, "handoffFilters", { enumerable: true, get: function () { return handoff_1.handoffFilters; } });
|
|
49
|
+
// Export router agent
|
|
50
|
+
var router_1 = require("./agent/router");
|
|
51
|
+
Object.defineProperty(exports, "RouterAgent", { enumerable: true, get: function () { return router_1.RouterAgent; } });
|
|
52
|
+
Object.defineProperty(exports, "createRouter", { enumerable: true, get: function () { return router_1.createRouter; } });
|
|
53
|
+
Object.defineProperty(exports, "routeConditions", { enumerable: true, get: function () { return router_1.routeConditions; } });
|
|
54
|
+
// Export context agent
|
|
55
|
+
var context_1 = require("./agent/context");
|
|
56
|
+
Object.defineProperty(exports, "ContextAgent", { enumerable: true, get: function () { return context_1.ContextAgent; } });
|
|
57
|
+
Object.defineProperty(exports, "createContextAgent", { enumerable: true, get: function () { return context_1.createContextAgent; } });
|
|
58
|
+
// Export knowledge base (RAG)
|
|
59
|
+
var rag_1 = require("./knowledge/rag");
|
|
60
|
+
Object.defineProperty(exports, "KnowledgeBase", { enumerable: true, get: function () { return rag_1.KnowledgeBase; } });
|
|
61
|
+
Object.defineProperty(exports, "createKnowledgeBase", { enumerable: true, get: function () { return rag_1.createKnowledgeBase; } });
|
|
62
|
+
// Export evaluation framework
|
|
63
|
+
var eval_1 = require("./eval");
|
|
64
|
+
Object.defineProperty(exports, "accuracyEval", { enumerable: true, get: function () { return eval_1.accuracyEval; } });
|
|
65
|
+
Object.defineProperty(exports, "performanceEval", { enumerable: true, get: function () { return eval_1.performanceEval; } });
|
|
66
|
+
Object.defineProperty(exports, "reliabilityEval", { enumerable: true, get: function () { return eval_1.reliabilityEval; } });
|
|
67
|
+
Object.defineProperty(exports, "EvalSuite", { enumerable: true, get: function () { return eval_1.EvalSuite; } });
|
|
68
|
+
// Export observability
|
|
69
|
+
var observability_1 = require("./observability");
|
|
70
|
+
Object.defineProperty(exports, "MemoryObservabilityAdapter", { enumerable: true, get: function () { return observability_1.MemoryObservabilityAdapter; } });
|
|
71
|
+
Object.defineProperty(exports, "ConsoleObservabilityAdapter", { enumerable: true, get: function () { return observability_1.ConsoleObservabilityAdapter; } });
|
|
72
|
+
Object.defineProperty(exports, "setObservabilityAdapter", { enumerable: true, get: function () { return observability_1.setObservabilityAdapter; } });
|
|
73
|
+
Object.defineProperty(exports, "getObservabilityAdapter", { enumerable: true, get: function () { return observability_1.getObservabilityAdapter; } });
|
|
74
|
+
// Export skills
|
|
75
|
+
var skills_1 = require("./skills");
|
|
76
|
+
Object.defineProperty(exports, "SkillManager", { enumerable: true, get: function () { return skills_1.SkillManager; } });
|
|
77
|
+
Object.defineProperty(exports, "createSkillManager", { enumerable: true, get: function () { return skills_1.createSkillManager; } });
|
|
78
|
+
Object.defineProperty(exports, "parseSkillFile", { enumerable: true, get: function () { return skills_1.parseSkillFile; } });
|
|
79
|
+
// Export CLI
|
|
80
|
+
var cli_1 = require("./cli");
|
|
81
|
+
Object.defineProperty(exports, "chat", { enumerable: true, get: function () { return cli_1.chat; } });
|
|
82
|
+
Object.defineProperty(exports, "listProviders", { enumerable: true, get: function () { return cli_1.listProviders; } });
|
|
83
|
+
Object.defineProperty(exports, "version", { enumerable: true, get: function () { return cli_1.version; } });
|
|
84
|
+
Object.defineProperty(exports, "help", { enumerable: true, get: function () { return cli_1.help; } });
|
|
85
|
+
// Export Memory
|
|
86
|
+
var memory_1 = require("./memory/memory");
|
|
87
|
+
Object.defineProperty(exports, "Memory", { enumerable: true, get: function () { return memory_1.Memory; } });
|
|
88
|
+
Object.defineProperty(exports, "createMemory", { enumerable: true, get: function () { return memory_1.createMemory; } });
|
|
89
|
+
// Export Telemetry
|
|
90
|
+
var telemetry_1 = require("./telemetry");
|
|
91
|
+
Object.defineProperty(exports, "TelemetryCollector", { enumerable: true, get: function () { return telemetry_1.TelemetryCollector; } });
|
|
92
|
+
Object.defineProperty(exports, "getTelemetry", { enumerable: true, get: function () { return telemetry_1.getTelemetry; } });
|
|
93
|
+
Object.defineProperty(exports, "enableTelemetry", { enumerable: true, get: function () { return telemetry_1.enableTelemetry; } });
|
|
94
|
+
Object.defineProperty(exports, "disableTelemetry", { enumerable: true, get: function () { return telemetry_1.disableTelemetry; } });
|
|
95
|
+
Object.defineProperty(exports, "cleanupTelemetry", { enumerable: true, get: function () { return telemetry_1.cleanupTelemetry; } });
|
|
96
|
+
// Export AutoAgents
|
|
97
|
+
var auto_1 = require("./auto");
|
|
98
|
+
Object.defineProperty(exports, "AutoAgents", { enumerable: true, get: function () { return auto_1.AutoAgents; } });
|
|
99
|
+
Object.defineProperty(exports, "createAutoAgents", { enumerable: true, get: function () { return auto_1.createAutoAgents; } });
|
|
100
|
+
// Export ImageAgent
|
|
101
|
+
var image_1 = require("./agent/image");
|
|
102
|
+
Object.defineProperty(exports, "ImageAgent", { enumerable: true, get: function () { return image_1.ImageAgent; } });
|
|
103
|
+
Object.defineProperty(exports, "createImageAgent", { enumerable: true, get: function () { return image_1.createImageAgent; } });
|
|
104
|
+
// Export DeepResearchAgent
|
|
105
|
+
var research_1 = require("./agent/research");
|
|
106
|
+
Object.defineProperty(exports, "DeepResearchAgent", { enumerable: true, get: function () { return research_1.DeepResearchAgent; } });
|
|
107
|
+
Object.defineProperty(exports, "createDeepResearchAgent", { enumerable: true, get: function () { return research_1.createDeepResearchAgent; } });
|
|
108
|
+
// Export QueryRewriterAgent
|
|
109
|
+
var query_rewriter_1 = require("./agent/query-rewriter");
|
|
110
|
+
Object.defineProperty(exports, "QueryRewriterAgent", { enumerable: true, get: function () { return query_rewriter_1.QueryRewriterAgent; } });
|
|
111
|
+
Object.defineProperty(exports, "createQueryRewriterAgent", { enumerable: true, get: function () { return query_rewriter_1.createQueryRewriterAgent; } });
|
|
112
|
+
// Export PromptExpanderAgent
|
|
113
|
+
var prompt_expander_1 = require("./agent/prompt-expander");
|
|
114
|
+
Object.defineProperty(exports, "PromptExpanderAgent", { enumerable: true, get: function () { return prompt_expander_1.PromptExpanderAgent; } });
|
|
115
|
+
Object.defineProperty(exports, "createPromptExpanderAgent", { enumerable: true, get: function () { return prompt_expander_1.createPromptExpanderAgent; } });
|
|
116
|
+
// Export Chunking
|
|
117
|
+
var chunking_1 = require("./knowledge/chunking");
|
|
118
|
+
Object.defineProperty(exports, "Chunking", { enumerable: true, get: function () { return chunking_1.Chunking; } });
|
|
119
|
+
Object.defineProperty(exports, "createChunking", { enumerable: true, get: function () { return chunking_1.createChunking; } });
|
|
120
|
+
// Export LLMGuardrail
|
|
121
|
+
var llm_guardrail_1 = require("./guardrails/llm-guardrail");
|
|
122
|
+
Object.defineProperty(exports, "LLMGuardrail", { enumerable: true, get: function () { return llm_guardrail_1.LLMGuardrail; } });
|
|
123
|
+
Object.defineProperty(exports, "createLLMGuardrail", { enumerable: true, get: function () { return llm_guardrail_1.createLLMGuardrail; } });
|
|
124
|
+
// Export Planning
|
|
125
|
+
var planning_1 = require("./planning");
|
|
126
|
+
Object.defineProperty(exports, "Plan", { enumerable: true, get: function () { return planning_1.Plan; } });
|
|
127
|
+
Object.defineProperty(exports, "PlanStep", { enumerable: true, get: function () { return planning_1.PlanStep; } });
|
|
128
|
+
Object.defineProperty(exports, "TodoList", { enumerable: true, get: function () { return planning_1.TodoList; } });
|
|
129
|
+
Object.defineProperty(exports, "TodoItem", { enumerable: true, get: function () { return planning_1.TodoItem; } });
|
|
130
|
+
Object.defineProperty(exports, "PlanStorage", { enumerable: true, get: function () { return planning_1.PlanStorage; } });
|
|
131
|
+
Object.defineProperty(exports, "createPlan", { enumerable: true, get: function () { return planning_1.createPlan; } });
|
|
132
|
+
Object.defineProperty(exports, "createTodoList", { enumerable: true, get: function () { return planning_1.createTodoList; } });
|
|
133
|
+
Object.defineProperty(exports, "createPlanStorage", { enumerable: true, get: function () { return planning_1.createPlanStorage; } });
|
|
134
|
+
// Export providers with explicit names to avoid conflicts
|
|
135
|
+
var providers_1 = require("./llm/providers");
|
|
136
|
+
Object.defineProperty(exports, "createProvider", { enumerable: true, get: function () { return providers_1.createProvider; } });
|
|
137
|
+
Object.defineProperty(exports, "getDefaultProvider", { enumerable: true, get: function () { return providers_1.getDefaultProvider; } });
|
|
138
|
+
Object.defineProperty(exports, "parseModelString", { enumerable: true, get: function () { return providers_1.parseModelString; } });
|
|
139
|
+
Object.defineProperty(exports, "isProviderAvailable", { enumerable: true, get: function () { return providers_1.isProviderAvailable; } });
|
|
140
|
+
Object.defineProperty(exports, "getAvailableProviders", { enumerable: true, get: function () { return providers_1.getAvailableProviders; } });
|
|
141
|
+
Object.defineProperty(exports, "OpenAIProvider", { enumerable: true, get: function () { return providers_1.OpenAIProvider; } });
|
|
142
|
+
Object.defineProperty(exports, "AnthropicProvider", { enumerable: true, get: function () { return providers_1.AnthropicProvider; } });
|
|
143
|
+
Object.defineProperty(exports, "GoogleProvider", { enumerable: true, get: function () { return providers_1.GoogleProvider; } });
|
|
144
|
+
Object.defineProperty(exports, "BaseProvider", { enumerable: true, get: function () { return providers_1.BaseProvider; } });
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chunking - Text chunking utilities for RAG
|
|
3
|
+
*/
|
|
4
|
+
export type ChunkStrategy = 'size' | 'sentence' | 'paragraph' | 'semantic';
|
|
5
|
+
export interface ChunkingConfig {
|
|
6
|
+
chunkSize?: number;
|
|
7
|
+
overlap?: number;
|
|
8
|
+
strategy?: ChunkStrategy;
|
|
9
|
+
separator?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface Chunk {
|
|
12
|
+
content: string;
|
|
13
|
+
index: number;
|
|
14
|
+
startOffset: number;
|
|
15
|
+
endOffset: number;
|
|
16
|
+
metadata?: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Chunking class for splitting text into chunks
|
|
20
|
+
*/
|
|
21
|
+
export declare class Chunking {
|
|
22
|
+
private chunkSize;
|
|
23
|
+
private overlap;
|
|
24
|
+
private strategy;
|
|
25
|
+
private separator;
|
|
26
|
+
constructor(config?: ChunkingConfig);
|
|
27
|
+
/**
|
|
28
|
+
* Chunk text based on configured strategy
|
|
29
|
+
*/
|
|
30
|
+
chunk(text: string): Chunk[];
|
|
31
|
+
/**
|
|
32
|
+
* Chunk by fixed size with overlap
|
|
33
|
+
*/
|
|
34
|
+
chunkBySize(text: string): Chunk[];
|
|
35
|
+
/**
|
|
36
|
+
* Chunk by sentences
|
|
37
|
+
*/
|
|
38
|
+
chunkBySentence(text: string): Chunk[];
|
|
39
|
+
/**
|
|
40
|
+
* Chunk by paragraphs
|
|
41
|
+
*/
|
|
42
|
+
chunkByParagraph(text: string): Chunk[];
|
|
43
|
+
/**
|
|
44
|
+
* Chunk by semantic boundaries (simplified)
|
|
45
|
+
*/
|
|
46
|
+
chunkBySemantic(text: string): Chunk[];
|
|
47
|
+
/**
|
|
48
|
+
* Merge small chunks
|
|
49
|
+
*/
|
|
50
|
+
mergeSmallChunks(chunks: Chunk[], minSize?: number): Chunk[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a Chunking instance
|
|
54
|
+
*/
|
|
55
|
+
export declare function createChunking(config?: ChunkingConfig): Chunking;
|