@agenticc/core 1.0.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/LICENSE +21 -0
- package/README.md +370 -0
- package/README.zh-CN.md +372 -0
- package/dist/audit/index.d.ts +9 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +9 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/audit/logger.d.ts +211 -0
- package/dist/audit/logger.d.ts.map +1 -0
- package/dist/audit/logger.js +268 -0
- package/dist/audit/logger.js.map +1 -0
- package/dist/audit/query.d.ts +164 -0
- package/dist/audit/query.d.ts.map +1 -0
- package/dist/audit/query.js +250 -0
- package/dist/audit/query.js.map +1 -0
- package/dist/conversation/context-builder.d.ts +119 -0
- package/dist/conversation/context-builder.d.ts.map +1 -0
- package/dist/conversation/context-builder.js +252 -0
- package/dist/conversation/context-builder.js.map +1 -0
- package/dist/conversation/index.d.ts +10 -0
- package/dist/conversation/index.d.ts.map +1 -0
- package/dist/conversation/index.js +10 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/conversation/message-store.d.ts +231 -0
- package/dist/conversation/message-store.d.ts.map +1 -0
- package/dist/conversation/message-store.js +404 -0
- package/dist/conversation/message-store.js.map +1 -0
- package/dist/conversation/session.d.ts +201 -0
- package/dist/conversation/session.d.ts.map +1 -0
- package/dist/conversation/session.js +285 -0
- package/dist/conversation/session.js.map +1 -0
- package/dist/core/agent.d.ts +277 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +674 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/agentic-loop.d.ts +98 -0
- package/dist/core/agentic-loop.d.ts.map +1 -0
- package/dist/core/agentic-loop.js +496 -0
- package/dist/core/agentic-loop.js.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +14 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/intent-parser.d.ts +101 -0
- package/dist/core/intent-parser.d.ts.map +1 -0
- package/dist/core/intent-parser.js +221 -0
- package/dist/core/intent-parser.js.map +1 -0
- package/dist/core/plan-generator.d.ts +133 -0
- package/dist/core/plan-generator.d.ts.map +1 -0
- package/dist/core/plan-generator.js +294 -0
- package/dist/core/plan-generator.js.map +1 -0
- package/dist/core/plugin-manager.d.ts +120 -0
- package/dist/core/plugin-manager.d.ts.map +1 -0
- package/dist/core/plugin-manager.js +369 -0
- package/dist/core/plugin-manager.js.map +1 -0
- package/dist/core/response-handler.d.ts +141 -0
- package/dist/core/response-handler.d.ts.map +1 -0
- package/dist/core/response-handler.js +384 -0
- package/dist/core/response-handler.js.map +1 -0
- package/dist/core/tool-executor.d.ts +143 -0
- package/dist/core/tool-executor.d.ts.map +1 -0
- package/dist/core/tool-executor.js +354 -0
- package/dist/core/tool-executor.js.map +1 -0
- package/dist/core/tool-registry.d.ts +133 -0
- package/dist/core/tool-registry.d.ts.map +1 -0
- package/dist/core/tool-registry.js +252 -0
- package/dist/core/tool-registry.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/chunker.d.ts +78 -0
- package/dist/knowledge/chunker.d.ts.map +1 -0
- package/dist/knowledge/chunker.js +233 -0
- package/dist/knowledge/chunker.js.map +1 -0
- package/dist/knowledge/embedder.d.ts +93 -0
- package/dist/knowledge/embedder.d.ts.map +1 -0
- package/dist/knowledge/embedder.js +205 -0
- package/dist/knowledge/embedder.js.map +1 -0
- package/dist/knowledge/index.d.ts +10 -0
- package/dist/knowledge/index.d.ts.map +1 -0
- package/dist/knowledge/index.js +11 -0
- package/dist/knowledge/index.js.map +1 -0
- package/dist/knowledge/loaders/index.d.ts +10 -0
- package/dist/knowledge/loaders/index.d.ts.map +1 -0
- package/dist/knowledge/loaders/index.js +10 -0
- package/dist/knowledge/loaders/index.js.map +1 -0
- package/dist/knowledge/loaders/markdown.d.ts +88 -0
- package/dist/knowledge/loaders/markdown.d.ts.map +1 -0
- package/dist/knowledge/loaders/markdown.js +205 -0
- package/dist/knowledge/loaders/markdown.js.map +1 -0
- package/dist/knowledge/loaders/yaml.d.ts +112 -0
- package/dist/knowledge/loaders/yaml.d.ts.map +1 -0
- package/dist/knowledge/loaders/yaml.js +368 -0
- package/dist/knowledge/loaders/yaml.js.map +1 -0
- package/dist/knowledge/retriever.d.ts +144 -0
- package/dist/knowledge/retriever.d.ts.map +1 -0
- package/dist/knowledge/retriever.js +399 -0
- package/dist/knowledge/retriever.js.map +1 -0
- package/dist/knowledge/store.d.ts +146 -0
- package/dist/knowledge/store.d.ts.map +1 -0
- package/dist/knowledge/store.js +420 -0
- package/dist/knowledge/store.js.map +1 -0
- package/dist/llm/adapter.d.ts +194 -0
- package/dist/llm/adapter.d.ts.map +1 -0
- package/dist/llm/adapter.js +42 -0
- package/dist/llm/adapter.js.map +1 -0
- package/dist/llm/adapters/anyrouter.d.ts +84 -0
- package/dist/llm/adapters/anyrouter.d.ts.map +1 -0
- package/dist/llm/adapters/anyrouter.js +372 -0
- package/dist/llm/adapters/anyrouter.js.map +1 -0
- package/dist/llm/adapters/claude.d.ts +66 -0
- package/dist/llm/adapters/claude.d.ts.map +1 -0
- package/dist/llm/adapters/claude.js +323 -0
- package/dist/llm/adapters/claude.js.map +1 -0
- package/dist/llm/adapters/index.d.ts +12 -0
- package/dist/llm/adapters/index.d.ts.map +1 -0
- package/dist/llm/adapters/index.js +12 -0
- package/dist/llm/adapters/index.js.map +1 -0
- package/dist/llm/adapters/mimo.d.ts +85 -0
- package/dist/llm/adapters/mimo.d.ts.map +1 -0
- package/dist/llm/adapters/mimo.js +316 -0
- package/dist/llm/adapters/mimo.js.map +1 -0
- package/dist/llm/adapters/openai.d.ts +53 -0
- package/dist/llm/adapters/openai.d.ts.map +1 -0
- package/dist/llm/adapters/openai.js +293 -0
- package/dist/llm/adapters/openai.js.map +1 -0
- package/dist/llm/adapters/qwen.d.ts +53 -0
- package/dist/llm/adapters/qwen.d.ts.map +1 -0
- package/dist/llm/adapters/qwen.js +299 -0
- package/dist/llm/adapters/qwen.js.map +1 -0
- package/dist/llm/adapters/siliconflow.d.ts +69 -0
- package/dist/llm/adapters/siliconflow.d.ts.map +1 -0
- package/dist/llm/adapters/siliconflow.js +331 -0
- package/dist/llm/adapters/siliconflow.js.map +1 -0
- package/dist/llm/index.d.ts +9 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +12 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/manager.d.ts +97 -0
- package/dist/llm/manager.d.ts.map +1 -0
- package/dist/llm/manager.js +337 -0
- package/dist/llm/manager.js.map +1 -0
- package/dist/test-utils/arbitraries.d.ts +230 -0
- package/dist/test-utils/arbitraries.d.ts.map +1 -0
- package/dist/test-utils/arbitraries.js +280 -0
- package/dist/test-utils/arbitraries.js.map +1 -0
- package/dist/test-utils/cleanup.d.ts +184 -0
- package/dist/test-utils/cleanup.d.ts.map +1 -0
- package/dist/test-utils/cleanup.js +282 -0
- package/dist/test-utils/cleanup.js.map +1 -0
- package/dist/test-utils/config.d.ts +80 -0
- package/dist/test-utils/config.d.ts.map +1 -0
- package/dist/test-utils/config.js +94 -0
- package/dist/test-utils/config.js.map +1 -0
- package/dist/test-utils/index.d.ts +10 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/test-utils/index.js +36 -0
- package/dist/test-utils/index.js.map +1 -0
- package/dist/test-utils/mocks.d.ts +170 -0
- package/dist/test-utils/mocks.d.ts.map +1 -0
- package/dist/test-utils/mocks.js +281 -0
- package/dist/test-utils/mocks.js.map +1 -0
- package/dist/types/config.d.ts +170 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +120 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/knowledge.d.ts +95 -0
- package/dist/types/knowledge.d.ts.map +1 -0
- package/dist/types/knowledge.js +7 -0
- package/dist/types/knowledge.js.map +1 -0
- package/dist/types/loop.d.ts +148 -0
- package/dist/types/loop.d.ts.map +1 -0
- package/dist/types/loop.js +16 -0
- package/dist/types/loop.js.map +1 -0
- package/dist/types/plugin.d.ts +137 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +15 -0
- package/dist/types/plugin.js.map +1 -0
- package/dist/types/response.d.ts +186 -0
- package/dist/types/response.d.ts.map +1 -0
- package/dist/types/response.js +99 -0
- package/dist/types/response.js.map +1 -0
- package/dist/types/streaming.d.ts +478 -0
- package/dist/types/streaming.d.ts.map +1 -0
- package/dist/types/streaming.js +483 -0
- package/dist/types/streaming.js.map +1 -0
- package/dist/types/tool.d.ts +118 -0
- package/dist/types/tool.d.ts.map +1 -0
- package/dist/types/tool.js +42 -0
- package/dist/types/tool.js.map +1 -0
- package/dist/utils/error.d.ts +22 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +36 -0
- package/dist/utils/error.js.map +1 -0
- package/package.json +102 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the configuration interfaces for the Agent, LLM providers,
|
|
5
|
+
* and other system components.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* All LLM task types as a constant array
|
|
9
|
+
*/
|
|
10
|
+
export const LLM_TASKS = [
|
|
11
|
+
'intent_parsing',
|
|
12
|
+
'knowledge_retrieval',
|
|
13
|
+
'tool_calling',
|
|
14
|
+
'response_generation',
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Default configuration values
|
|
18
|
+
*/
|
|
19
|
+
export const DEFAULT_CONFIG = {
|
|
20
|
+
knowledge: {
|
|
21
|
+
embedding: {
|
|
22
|
+
model: 'text-embedding-ada-002',
|
|
23
|
+
dimension: 1536,
|
|
24
|
+
},
|
|
25
|
+
search: {
|
|
26
|
+
defaultTopK: 5,
|
|
27
|
+
minScore: 0.7,
|
|
28
|
+
defaultMethod: 'hybrid',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
behavior: {
|
|
32
|
+
timeoutMs: 30000,
|
|
33
|
+
maxIterations: 10,
|
|
34
|
+
requireConfirmation: true,
|
|
35
|
+
confidenceThreshold: 0.8,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Validates an LLMProviderConfig
|
|
40
|
+
*/
|
|
41
|
+
export function validateLLMProviderConfig(config) {
|
|
42
|
+
const errors = [];
|
|
43
|
+
if (!config.provider) {
|
|
44
|
+
errors.push('LLM provider is required');
|
|
45
|
+
}
|
|
46
|
+
if (!config.apiKey) {
|
|
47
|
+
errors.push('API key is required');
|
|
48
|
+
}
|
|
49
|
+
if (!config.model) {
|
|
50
|
+
errors.push('Model is required');
|
|
51
|
+
}
|
|
52
|
+
if (config.temperature !== undefined && (config.temperature < 0 || config.temperature > 2)) {
|
|
53
|
+
errors.push('Temperature must be between 0 and 2');
|
|
54
|
+
}
|
|
55
|
+
if (config.maxTokens !== undefined && config.maxTokens < 1) {
|
|
56
|
+
errors.push('Max tokens must be at least 1');
|
|
57
|
+
}
|
|
58
|
+
return errors;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Validates an LLMConfig
|
|
62
|
+
*/
|
|
63
|
+
export function validateLLMConfig(config) {
|
|
64
|
+
const errors = [];
|
|
65
|
+
if (!config.mode) {
|
|
66
|
+
errors.push('LLM mode is required');
|
|
67
|
+
}
|
|
68
|
+
if (!config.default) {
|
|
69
|
+
errors.push('Default LLM configuration is required');
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
errors.push(...validateLLMProviderConfig(config.default).map((e) => `default: ${e}`));
|
|
73
|
+
}
|
|
74
|
+
if (config.fallback) {
|
|
75
|
+
errors.push(...validateLLMProviderConfig(config.fallback).map((e) => `fallback: ${e}`));
|
|
76
|
+
}
|
|
77
|
+
if (config.mode === 'multi' && config.taskAssignment) {
|
|
78
|
+
for (const [task, taskConfig] of Object.entries(config.taskAssignment)) {
|
|
79
|
+
if (taskConfig) {
|
|
80
|
+
errors.push(...validateLLMProviderConfig(taskConfig).map((e) => `${task}: ${e}`));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return errors;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Validates a complete AgentConfig
|
|
88
|
+
*/
|
|
89
|
+
export function validateAgentConfig(config) {
|
|
90
|
+
const errors = [];
|
|
91
|
+
if (!config.llm) {
|
|
92
|
+
errors.push('LLM configuration is required');
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
errors.push(...validateLLMConfig(config.llm).map((e) => `llm.${e}`));
|
|
96
|
+
}
|
|
97
|
+
// Database is now optional (deprecated)
|
|
98
|
+
if (config.database && !config.database.url) {
|
|
99
|
+
errors.push('Database URL is required if database config is provided');
|
|
100
|
+
}
|
|
101
|
+
return errors;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Gets the LLM configuration for a specific task
|
|
105
|
+
*/
|
|
106
|
+
export function getLLMConfigForTask(config, task) {
|
|
107
|
+
if (config.mode === 'single') {
|
|
108
|
+
return config.default;
|
|
109
|
+
}
|
|
110
|
+
// Multi-LLM mode: check task assignment
|
|
111
|
+
const taskConfig = config.taskAssignment?.[task === 'intent_parsing'
|
|
112
|
+
? 'intentParsing'
|
|
113
|
+
: task === 'knowledge_retrieval'
|
|
114
|
+
? 'knowledgeRetrieval'
|
|
115
|
+
: task === 'tool_calling'
|
|
116
|
+
? 'toolCalling'
|
|
117
|
+
: 'responseGeneration'];
|
|
118
|
+
return taskConfig ?? config.default;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuBH;;GAEG;AACH,MAAM,CAAC,MAAM,S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mB;IACrD,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QAChB,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,wCAAwC;IACxC,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QAC5C,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAiB,EAAE,IAAa;IAClE,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,wCAAwC;IACxC,MAAM,UAAU,GACd,MAAM,CAAC,cAAc,EAAE,CACrB,IAAI,KAAK,gBAAgB;QACvB,CAAC,CAAC,eAAe;QACjB,CAAC,CAAC,IAAI,KAAK,qBAAqB;YAC9B,CAAC,CAAC,oBAAoB;YACtB,CAAC,CAAC,IAAI,KAAK,cAAc;gBACvB,CAAC,CAAC,aAAa;gBACf,CAAC,CAAC,oBAAoB,CAC7B,CAAC;IAEJ,OAAO,UAAU,IAAI,MAAM,CAAC,OAAO,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge System Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the interfaces for the knowledge base and retrieval system.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Document input for adding to knowledge base
|
|
8
|
+
*/
|
|
9
|
+
export interface DocumentInput {
|
|
10
|
+
/** Category for organizing documents */
|
|
11
|
+
category: string;
|
|
12
|
+
/** Optional title */
|
|
13
|
+
title?: string;
|
|
14
|
+
/** Document content */
|
|
15
|
+
content: string;
|
|
16
|
+
/** Optional metadata */
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Stored document with ID and timestamps
|
|
21
|
+
*/
|
|
22
|
+
export interface Document {
|
|
23
|
+
/** Unique document ID */
|
|
24
|
+
id: string;
|
|
25
|
+
/** Category for organizing documents */
|
|
26
|
+
category: string;
|
|
27
|
+
/** Optional title */
|
|
28
|
+
title?: string;
|
|
29
|
+
/** Document content */
|
|
30
|
+
content: string;
|
|
31
|
+
/** Optional metadata */
|
|
32
|
+
metadata?: Record<string, unknown>;
|
|
33
|
+
/** Creation timestamp */
|
|
34
|
+
createdAt: Date;
|
|
35
|
+
/** Last update timestamp */
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Search options for knowledge retrieval
|
|
40
|
+
*/
|
|
41
|
+
export interface SearchOptions {
|
|
42
|
+
/** Filter by category */
|
|
43
|
+
category?: string;
|
|
44
|
+
/** Number of results to return */
|
|
45
|
+
topK?: number;
|
|
46
|
+
/** Search method */
|
|
47
|
+
method?: 'keyword' | 'semantic' | 'hybrid';
|
|
48
|
+
/** Minimum similarity score */
|
|
49
|
+
minScore?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Search result with relevance score
|
|
53
|
+
*/
|
|
54
|
+
export interface SearchResult {
|
|
55
|
+
/** The matched document */
|
|
56
|
+
document: Document;
|
|
57
|
+
/** Relevance score (0-1) */
|
|
58
|
+
score: number;
|
|
59
|
+
/** Confidence level */
|
|
60
|
+
confidence: 'high' | 'medium' | 'low';
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Knowledge assessment result
|
|
64
|
+
*/
|
|
65
|
+
export interface KnowledgeAssessment {
|
|
66
|
+
/** Whether knowledge is sufficient */
|
|
67
|
+
status: 'sufficient' | 'insufficient' | 'ambiguous';
|
|
68
|
+
/** Confidence in the assessment */
|
|
69
|
+
confidence: number;
|
|
70
|
+
/** Topic that's missing (if insufficient) */
|
|
71
|
+
missingTopic?: string;
|
|
72
|
+
/** Alternative interpretations (if ambiguous) */
|
|
73
|
+
alternatives?: Array<{
|
|
74
|
+
interpretation: string;
|
|
75
|
+
confidence: number;
|
|
76
|
+
}>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Knowledge base interface
|
|
80
|
+
*/
|
|
81
|
+
export interface KnowledgeBase {
|
|
82
|
+
/** Add a document to the knowledge base */
|
|
83
|
+
addDocument(doc: DocumentInput): Promise<string>;
|
|
84
|
+
/** Get a document by ID */
|
|
85
|
+
getDocument(id: string): Promise<Document | null>;
|
|
86
|
+
/** Delete a document */
|
|
87
|
+
deleteDocument(id: string): Promise<boolean>;
|
|
88
|
+
/** Search the knowledge base */
|
|
89
|
+
search(query: string, options?: SearchOptions): Promise<SearchResult[]>;
|
|
90
|
+
/** List all categories */
|
|
91
|
+
listCategories(): Promise<string[]>;
|
|
92
|
+
/** Get documents by category */
|
|
93
|
+
getDocumentsByCategory(category: string): Promise<Document[]>;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=knowledge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge.d.ts","sourceRoot":"","sources":["../../src/types/knowledge.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAA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CAAC;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,2CAA2C;IAC3C,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,2BAA2B;IAC3B,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAClD,wBAAwB;IACxB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C,gCAAgC;IAChC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACxE,0BAA0B;IAC1B,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACpC,gCAAgC;IAChC,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;CAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge.js","sourceRoot":"","sources":["../../src/types/knowledge.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic Loop Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the interfaces for the Agent's agentic loop execution system.
|
|
5
|
+
* The agentic loop allows LLM to autonomously decide tool calls and iterate until task completion.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolResult } from './tool.js';
|
|
8
|
+
import type { StreamEvent } from './streaming.js';
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for the agentic loop
|
|
11
|
+
*/
|
|
12
|
+
export interface LoopConfig {
|
|
13
|
+
/**
|
|
14
|
+
* Maximum number of iterations before forcing termination
|
|
15
|
+
* Default: 10
|
|
16
|
+
*/
|
|
17
|
+
maxIterations: number;
|
|
18
|
+
/**
|
|
19
|
+
* Timeout for each iteration in milliseconds
|
|
20
|
+
* Default: 30000 (30 seconds)
|
|
21
|
+
*/
|
|
22
|
+
iterationTimeout: number;
|
|
23
|
+
/**
|
|
24
|
+
* Whether to allow parallel tool calls when LLM requests multiple tools
|
|
25
|
+
* Default: true
|
|
26
|
+
*/
|
|
27
|
+
parallelToolCalls: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to continue on tool execution errors
|
|
30
|
+
* If true, error results are fed back to LLM for recovery
|
|
31
|
+
* Default: true
|
|
32
|
+
*/
|
|
33
|
+
continueOnError: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Default loop configuration
|
|
37
|
+
*/
|
|
38
|
+
export declare const DEFAULT_LOOP_CONFIG: LoopConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Status of the agentic loop
|
|
41
|
+
*/
|
|
42
|
+
export type LoopStatus = 'running' | 'completed' | 'max_iterations' | 'timeout' | 'error' | 'cancelled';
|
|
43
|
+
/**
|
|
44
|
+
* Record of a tool call made during the loop
|
|
45
|
+
*/
|
|
46
|
+
export interface ToolCallRecord {
|
|
47
|
+
/** Unique ID for this tool call */
|
|
48
|
+
id: string;
|
|
49
|
+
/** Name of the tool called */
|
|
50
|
+
toolName: string;
|
|
51
|
+
/** Arguments passed to the tool */
|
|
52
|
+
arguments: Record<string, unknown>;
|
|
53
|
+
/** Result of the tool execution */
|
|
54
|
+
result: ToolResult;
|
|
55
|
+
/** Timestamp when the call was made */
|
|
56
|
+
timestamp: Date;
|
|
57
|
+
/** Duration of the call in milliseconds */
|
|
58
|
+
duration: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Message in the loop conversation
|
|
62
|
+
*/
|
|
63
|
+
export interface LoopMessage {
|
|
64
|
+
/** Role of the message sender */
|
|
65
|
+
role: 'user' | 'assistant' | 'tool' | 'system';
|
|
66
|
+
/** Message content */
|
|
67
|
+
content: string;
|
|
68
|
+
/** Tool calls requested by assistant (if any) */
|
|
69
|
+
toolCalls?: LLMToolCall[];
|
|
70
|
+
/** Tool call ID this message responds to (for tool role) */
|
|
71
|
+
toolCallId?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Tool call requested by LLM
|
|
75
|
+
*/
|
|
76
|
+
export interface LLMToolCall {
|
|
77
|
+
/** Unique ID for this tool call */
|
|
78
|
+
id: string;
|
|
79
|
+
/** Type of the call (always 'function' for now) */
|
|
80
|
+
type: 'function';
|
|
81
|
+
/** Function details */
|
|
82
|
+
function: {
|
|
83
|
+
/** Name of the function to call */
|
|
84
|
+
name: string;
|
|
85
|
+
/** JSON string of arguments */
|
|
86
|
+
arguments: string;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Current state of the agentic loop
|
|
91
|
+
*/
|
|
92
|
+
export interface LoopState {
|
|
93
|
+
/** Current iteration number (0-indexed) */
|
|
94
|
+
iteration: number;
|
|
95
|
+
/** All messages in the conversation */
|
|
96
|
+
messages: LoopMessage[];
|
|
97
|
+
/** All tool calls made during the loop */
|
|
98
|
+
toolCalls: ToolCallRecord[];
|
|
99
|
+
/** Current status */
|
|
100
|
+
status: LoopStatus;
|
|
101
|
+
/** Error message if status is 'error' */
|
|
102
|
+
error?: string;
|
|
103
|
+
/** Start time of the loop */
|
|
104
|
+
startTime: Date;
|
|
105
|
+
/** End time of the loop (if completed) */
|
|
106
|
+
endTime?: Date;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Result of the agentic loop execution
|
|
110
|
+
*/
|
|
111
|
+
export interface LoopResult {
|
|
112
|
+
/** Final status of the loop */
|
|
113
|
+
status: LoopStatus;
|
|
114
|
+
/** Final response content from LLM */
|
|
115
|
+
content: string;
|
|
116
|
+
/** All tool calls made during execution */
|
|
117
|
+
toolCalls: ToolCallRecord[];
|
|
118
|
+
/** Number of iterations executed */
|
|
119
|
+
iterations: number;
|
|
120
|
+
/** Total duration in milliseconds */
|
|
121
|
+
duration: number;
|
|
122
|
+
/** Error message if failed */
|
|
123
|
+
error?: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Options for a single loop run
|
|
127
|
+
*/
|
|
128
|
+
export interface LoopRunOptions {
|
|
129
|
+
/** Override max iterations for this run */
|
|
130
|
+
maxIterations?: number;
|
|
131
|
+
/** Override timeout for this run */
|
|
132
|
+
timeout?: number;
|
|
133
|
+
/** System prompt to prepend */
|
|
134
|
+
systemPrompt?: string;
|
|
135
|
+
/** Abort signal for cancellation */
|
|
136
|
+
abortSignal?: AbortSignal;
|
|
137
|
+
/** Callback for streaming events */
|
|
138
|
+
onEvent?: (event: StreamEvent) => void;
|
|
139
|
+
/** Session ID for streaming events */
|
|
140
|
+
sessionId?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Historical messages to inject before current user message.
|
|
143
|
+
* Used for stateless operation where history is loaded from database.
|
|
144
|
+
* Messages are injected after system prompt, before current user message.
|
|
145
|
+
*/
|
|
146
|
+
history?: LoopMessage[];
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/types/loop.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAE3B;;;;OAIG;IACH,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAKjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,SAAS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IACf,6BAA6B;IAC7B,SAAS,EAAE,IAAI,CAAC;IAChB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,+BAA+B;IAC/B,MAAM,EAAE,UAAU,CAAC;IACnB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oCAAoC;IACpC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,oCAAoC;IACpC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;CACzB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic Loop Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the interfaces for the Agent's agentic loop execution system.
|
|
5
|
+
* The agentic loop allows LLM to autonomously decide tool calls and iterate until task completion.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default loop configuration
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_LOOP_CONFIG = {
|
|
11
|
+
maxIterations: 10,
|
|
12
|
+
iterationTimeout: 30000,
|
|
13
|
+
parallelToolCalls: true,
|
|
14
|
+
continueOnError: true,
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=loop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/types/loop.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmCH;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAe;IAC7C,aAAa,EAAE,EAAE;IACjB,gBAAgB,EAAE,KAAK;IACvB,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,IAAI;CACtB,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin System Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the interfaces for the Agent's plugin-based tool extension system.
|
|
5
|
+
* Plugins provide a modular way to extend Agent capabilities with dependency injection.
|
|
6
|
+
*/
|
|
7
|
+
import type { Tool, ToolLogger } from './tool.js';
|
|
8
|
+
import type { KnowledgeBase } from './knowledge.js';
|
|
9
|
+
/**
|
|
10
|
+
* Plugin context for dependency injection
|
|
11
|
+
* Provides access to shared services and resources
|
|
12
|
+
*/
|
|
13
|
+
export interface PluginContext {
|
|
14
|
+
/** Logger for plugin operations */
|
|
15
|
+
logger: ToolLogger;
|
|
16
|
+
/** Knowledge base access */
|
|
17
|
+
knowledgeBase: KnowledgeBase;
|
|
18
|
+
/** Application configuration */
|
|
19
|
+
config: AppConfig;
|
|
20
|
+
/** Custom services injected by the host application */
|
|
21
|
+
services: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Application configuration available to plugins
|
|
25
|
+
*/
|
|
26
|
+
export interface AppConfig {
|
|
27
|
+
/** Environment (development, production, test) */
|
|
28
|
+
env: string;
|
|
29
|
+
/** Debug mode flag */
|
|
30
|
+
debug: boolean;
|
|
31
|
+
/** Custom configuration values */
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Plugin definition interface
|
|
36
|
+
* Plugins provide tools and optional lifecycle hooks
|
|
37
|
+
*/
|
|
38
|
+
export interface AgentPlugin {
|
|
39
|
+
/** Unique plugin identifier */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Plugin version (semver format) */
|
|
42
|
+
version: string;
|
|
43
|
+
/** Human-readable description */
|
|
44
|
+
description: string;
|
|
45
|
+
/** Namespace for tool names (e.g., 'boss' -> 'boss_get_stats') */
|
|
46
|
+
namespace?: string;
|
|
47
|
+
/** Plugin dependencies (names of other plugins that must be loaded first) */
|
|
48
|
+
dependencies?: string[];
|
|
49
|
+
/** Tools provided by this plugin */
|
|
50
|
+
tools: Tool[];
|
|
51
|
+
/**
|
|
52
|
+
* Called when the plugin is loaded (before tools are registered)
|
|
53
|
+
* Use for initialization, resource allocation, etc.
|
|
54
|
+
* @alias initialize
|
|
55
|
+
*/
|
|
56
|
+
onLoad?(context: PluginContext): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Called when the plugin is loaded (before tools are registered)
|
|
59
|
+
* Use for initialization, resource allocation, etc.
|
|
60
|
+
* @alias onLoad
|
|
61
|
+
*/
|
|
62
|
+
initialize?(context: PluginContext): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Called when the plugin is unloaded (after tools are unregistered)
|
|
65
|
+
* Use for cleanup, resource release, etc.
|
|
66
|
+
* @alias cleanup
|
|
67
|
+
*/
|
|
68
|
+
onUnload?(): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Called when the plugin is unloaded (after tools are unregistered)
|
|
71
|
+
* Use for cleanup, resource release, etc.
|
|
72
|
+
* @alias onUnload
|
|
73
|
+
*/
|
|
74
|
+
cleanup?(): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Optional health check for the plugin
|
|
77
|
+
* Returns true if the plugin is functioning correctly
|
|
78
|
+
*/
|
|
79
|
+
healthCheck?(): Promise<boolean>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Plugin factory function type
|
|
83
|
+
* Recommended pattern for creating plugins with dependency injection
|
|
84
|
+
*/
|
|
85
|
+
export type PluginFactory<TDeps = unknown> = (deps: TDeps) => AgentPlugin;
|
|
86
|
+
/**
|
|
87
|
+
* Plugin status information
|
|
88
|
+
*/
|
|
89
|
+
export type PluginStatus = 'loaded' | 'loading' | 'error' | 'unloaded';
|
|
90
|
+
/**
|
|
91
|
+
* Plugin information returned by listPlugins
|
|
92
|
+
*/
|
|
93
|
+
export interface PluginInfo {
|
|
94
|
+
/** Plugin name */
|
|
95
|
+
name: string;
|
|
96
|
+
/** Plugin version */
|
|
97
|
+
version: string;
|
|
98
|
+
/** Plugin description */
|
|
99
|
+
description: string;
|
|
100
|
+
/** Plugin namespace */
|
|
101
|
+
namespace?: string;
|
|
102
|
+
/** Number of tools provided */
|
|
103
|
+
toolCount: number;
|
|
104
|
+
/** Tool names (with namespace prefix if applicable) */
|
|
105
|
+
toolNames: string[];
|
|
106
|
+
/** Current status */
|
|
107
|
+
status: PluginStatus;
|
|
108
|
+
/** Error message if status is 'error' */
|
|
109
|
+
error?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Options for plugin manager behavior
|
|
113
|
+
*/
|
|
114
|
+
export interface PluginManagerOptions {
|
|
115
|
+
/**
|
|
116
|
+
* Strategy for handling tool name conflicts
|
|
117
|
+
* - 'error': Throw an error (default)
|
|
118
|
+
* - 'replace': Replace existing tool
|
|
119
|
+
* - 'skip': Skip the conflicting tool
|
|
120
|
+
*/
|
|
121
|
+
conflictStrategy: 'error' | 'replace' | 'skip';
|
|
122
|
+
/**
|
|
123
|
+
* Whether to automatically add namespace prefix to tool names
|
|
124
|
+
* Default: true
|
|
125
|
+
*/
|
|
126
|
+
autoNamespace: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Whether to validate plugin definitions strictly
|
|
129
|
+
* Default: true
|
|
130
|
+
*/
|
|
131
|
+
strictValidation: boolean;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Default plugin manager options
|
|
135
|
+
*/
|
|
136
|
+
export declare const DEFAULT_PLUGIN_MANAGER_OPTIONS: PluginManagerOptions;
|
|
137
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,MAAM,EAAE,UAAU,CAAC;IACnB,4BAA4B;IAC5B,aAAa,EAAE,aAAa,CAAC;IAC7B,gCAAgC;IAChC,MAAM,EAAE,SAAS,CAAC;IAClB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,kDAAkD;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,sBAAsB;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,kCAAkC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,oCAAoC;IACpC,KAAK,EAAE,IAAI,EAAE,CAAC;IAEd;;;;OAIG;IACH,MAAM,CAAC,CAAC,OAAO,EAAE,aAAa,GAAG,OAA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0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin System Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the interfaces for the Agent's plugin-based tool extension system.
|
|
5
|
+
* Plugins provide a modular way to extend Agent capabilities with dependency injection.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default plugin manager options
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_PLUGIN_MANAGER_OPTIONS = {
|
|
11
|
+
conflictStrategy: 'error',
|
|
12
|
+
autoNamespace: true,
|
|
13
|
+
strictValidation: true,
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgJH;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAyB;IAClE,gBAAgB,EAAE,OAAO;IACzB,aAAa,EAAE,IAAI;IACnB,gBAAgB,EAAE,IAAI;CACvB,CAAC"}
|