@ainetwork/adk 0.1.4 → 0.1.5

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.
@@ -0,0 +1,174 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkJTAXZJQ2cjs = require('./chunk-JTAXZJQ2.cjs');
4
+
5
+ // src/services/query.service.ts
6
+ var QueryService = class {
7
+
8
+
9
+
10
+
11
+
12
+ constructor(modelModule, a2aModule, mcpModule, memoryModule, prompts) {
13
+ this.modelModule = modelModule;
14
+ this.a2aModule = a2aModule;
15
+ this.mcpModule = mcpModule;
16
+ this.memoryModule = memoryModule;
17
+ this.prompts = prompts;
18
+ }
19
+ /**
20
+ * Detects the intent from a user query.
21
+ *
22
+ * @param query - The user's input query
23
+ * @returns The detected intent (currently returns the query as-is)
24
+ * @todo Implement actual intent detection logic
25
+ */
26
+ async intentTriggering(query) {
27
+ return query;
28
+ }
29
+ /**
30
+ * Fulfills the detected intent by generating a response.
31
+ *
32
+ * Manages the complete inference loop including:
33
+ * - Loading prompts and conversation history
34
+ * - Collecting available tools from modules
35
+ * - Executing model inference with tool support
36
+ * - Processing tool calls iteratively until completion
37
+ *
38
+ * @param query - The user's input query
39
+ * @param sessionId - Session identifier for context
40
+ * @param sessionHistory - Previous conversation history
41
+ * @returns Object containing process steps and final response
42
+ */
43
+ async intentFulfilling(query, sessionId, sessionHistory) {
44
+ const systemPrompt = `
45
+ Today is ${(/* @__PURE__ */ new Date()).toLocaleDateString()}.
46
+
47
+ ${_optionalChain([this, 'access', _ => _.prompts, 'optionalAccess', _2 => _2.agent]) || ""}
48
+
49
+ ${_optionalChain([this, 'access', _3 => _3.prompts, 'optionalAccess', _4 => _4.system]) || ""}
50
+ `;
51
+ const modelInstance = this.modelModule.getModel();
52
+ const messages = modelInstance.generateMessages({
53
+ query,
54
+ sessionHistory,
55
+ systemPrompt: systemPrompt.trim()
56
+ });
57
+ const tools = [];
58
+ if (this.mcpModule) {
59
+ tools.push(...this.mcpModule.getTools());
60
+ }
61
+ if (this.a2aModule) {
62
+ tools.push(...await this.a2aModule.getTools());
63
+ }
64
+ const functions = modelInstance.convertToolsToFunctions(tools);
65
+ const processList = [];
66
+ let finalMessage = "";
67
+ let didCallTool = false;
68
+ while (true) {
69
+ const response = await modelInstance.fetchWithContextMessage(
70
+ messages,
71
+ functions
72
+ );
73
+ didCallTool = false;
74
+ _chunkJTAXZJQ2cjs.loggers.intent.debug("messages", { messages });
75
+ const { content, toolCalls } = response;
76
+ _chunkJTAXZJQ2cjs.loggers.intent.debug("content", { content });
77
+ _chunkJTAXZJQ2cjs.loggers.intent.debug("tool_calls", { ...toolCalls });
78
+ if (toolCalls) {
79
+ const messagePayload = _optionalChain([this, 'access', _5 => _5.a2aModule, 'optionalAccess', _6 => _6.getMessagePayload, 'call', _7 => _7(
80
+ query,
81
+ sessionId
82
+ )]);
83
+ for (const toolCall of toolCalls) {
84
+ const toolName = toolCall.name;
85
+ didCallTool = true;
86
+ const selectedTool = tools.filter((tool) => tool.id === toolName)[0];
87
+ let toolResult = "";
88
+ if (this.mcpModule && selectedTool.protocol === "MCP" /* MCP */) {
89
+ const toolArgs = toolCall.arguments;
90
+ _chunkJTAXZJQ2cjs.loggers.intent.debug("MCP tool call", { toolName, toolArgs });
91
+ const result = await this.mcpModule.useTool(
92
+ selectedTool,
93
+ toolArgs
94
+ );
95
+ toolResult = `[Bot Called MCP Tool ${toolName} with args ${JSON.stringify(toolArgs)}]
96
+ ` + JSON.stringify(result.content, null, 2);
97
+ } else if (this.a2aModule && selectedTool.protocol === "A2A" /* A2A */) {
98
+ const result = await this.a2aModule.useTool(
99
+ selectedTool,
100
+ messagePayload,
101
+ sessionId
102
+ );
103
+ toolResult = `[Bot Called A2A Tool ${toolName}]
104
+ ${result.join("\n")}`;
105
+ } else {
106
+ _chunkJTAXZJQ2cjs.loggers.intent.warn(
107
+ `Unrecognized tool type: ${selectedTool.protocol}`
108
+ );
109
+ continue;
110
+ }
111
+ _chunkJTAXZJQ2cjs.loggers.intent.debug("toolResult", { toolResult });
112
+ processList.push(toolResult);
113
+ modelInstance.appendMessages(messages, toolResult);
114
+ }
115
+ } else if (content) {
116
+ processList.push(content);
117
+ finalMessage = content;
118
+ }
119
+ if (!didCallTool) break;
120
+ }
121
+ const botResponse = {
122
+ process: processList.join("\n"),
123
+ response: finalMessage
124
+ };
125
+ return botResponse;
126
+ }
127
+ /**
128
+ * Main entry point for processing user queries.
129
+ *
130
+ * Handles the complete query lifecycle:
131
+ * 1. Loads session history from memory
132
+ * 2. Detects intent from the query
133
+ * 3. Fulfills the intent with AI response
134
+ * 4. Updates conversation history
135
+ *
136
+ * @param query - The user's input query
137
+ * @param sessionId - Unique session identifier
138
+ * @param userId - Unique user identifier
139
+ * @returns Object containing the AI-generated response
140
+ */
141
+ async handleQuery(query, sessionId, userId) {
142
+ const queryStartAt = Date.now();
143
+ const sessionMemory = _optionalChain([this, 'access', _8 => _8.memoryModule, 'optionalAccess', _9 => _9.getSessionMemory, 'call', _10 => _10()]);
144
+ const session = !userId ? void 0 : await _optionalChain([sessionMemory, 'optionalAccess', _11 => _11.getSession, 'call', _12 => _12(sessionId, userId)]);
145
+ const intent = this.intentTriggering(query);
146
+ const result = await this.intentFulfilling(query, sessionId, session);
147
+ if (userId) {
148
+ await _optionalChain([sessionMemory, 'optionalAccess', _13 => _13.addChatToSession, 'call', _14 => _14(
149
+ sessionId,
150
+ {
151
+ role: "USER" /* USER */,
152
+ timestamp: queryStartAt,
153
+ content: { type: "text", parts: [query] }
154
+ },
155
+ userId
156
+ )]);
157
+ await _optionalChain([sessionMemory, 'optionalAccess', _15 => _15.addChatToSession, 'call', _16 => _16(
158
+ sessionId,
159
+ {
160
+ role: "MODEL" /* MODEL */,
161
+ timestamp: Date.now(),
162
+ content: { type: "text", parts: [result.response] }
163
+ },
164
+ userId
165
+ )]);
166
+ }
167
+ return { content: result.response };
168
+ }
169
+ };
170
+
171
+
172
+
173
+ exports.QueryService = QueryService;
174
+ //# sourceMappingURL=chunk-EF3XQJEL.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/shyun/comcom/ain-agent/ain-adk/dist/cjs/chunk-EF3XQJEL.cjs","../../src/services/query.service.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACmBO,IAAM,aAAA,EAAN,MAAmB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,WAAA,CACC,WAAA,EACA,SAAA,EACA,SAAA,EACA,YAAA,EACA,OAAA,EACC;AACD,IAAA,IAAA,CAAK,YAAA,EAAc,WAAA;AACnB,IAAA,IAAA,CAAK,UAAA,EAAY,SAAA;AACjB,IAAA,IAAA,CAAK,UAAA,EAAY,SAAA;AACjB,IAAA,IAAA,CAAK,aAAA,EAAe,YAAA;AACpB,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAc,gBAAA,CAAiB,KAAA,EAAe;AAE7C,IAAA,OAAO,KAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,MAAc,gBAAA,CACb,KAAA,EACA,SAAA,EACA,cAAA,EACC;AAED,IAAA,MAAM,aAAA,EAAe,CAAA;AAAA,SAAA,EAAA,iBACZ,IAAI,IAAA,CAAK,CAAA,C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A,UACxC,EAAA,KAAA,GAAA,CACC,IAAA,CAAK,UAAA,GACL,YAAA,CAAa,SAAA,IAAA,eAAA,EACZ;AACD,YAAA,MAAM,OAAA,EAAS,MAAM,IAAA,CAAK,SAAA,CAAU,OAAA;AAAA,cACnC,YAAA;AAAA,cACA,cAAA;AAAA,cACA;AAAA,YACD,CAAA;AACA,YAAA,WAAA,EAAa,CAAA,qBAAA,EAAwB,QAAQ,CAAA;AAAA,EAAM,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA;AAC9D,UAAA;AAEE,YAAA;AACP,cAAA;AACD,YAAA;AACA,YAAA;AACD,UAAA;AAEQ,UAAA;AAER,UAAA;AACA,UAAA;AACD,QAAA;AACU,MAAA;AACE,QAAA;AACZ,QAAA;AACD,MAAA;AAEK,MAAA;AACN,IAAA;AAEM,IAAA;AACI,MAAA;AACC,MAAA;AACX,IAAA;AAEO,IAAA;AACR,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgByB,EAAA;AAElB,IAAA;AACA,IAAA;AACU,IAAA;AAKD,IAAA;AAGA,IAAA;AACH,IAAA;AACL,MAAA;AACL,QAAA;AACA,QAAA;AACC,UAAA;AACA,UAAA;AACS,UAAA;AACV,QAAA;AACA,QAAA;AACD,MAAA;AACM,MAAA;AACL,QAAA;AACA,QAAA;AACC,UAAA;AACA,UAAA;AACS,UAAA;AACV,QAAA;AACA,QAAA;AACD,MAAA;AACD,IAAA;AAES,IAAA;AACV,EAAA;AACD;ADjEoB;AACA;AACA;AACA","file":"/Users/shyun/comcom/ain-agent/ain-adk/dist/cjs/chunk-EF3XQJEL.cjs","sourcesContent":[null,"import type {\n\tA2AModule,\n\tMCPModule,\n\tMemoryModule,\n\tModelModule,\n} from \"@/modules/index.js\";\nimport type { AinAgentPrompts } from \"@/types/agent.js\";\nimport { ChatRole, type SessionObject } from \"@/types/memory.js\";\nimport {\n\ttype IA2ATool,\n\ttype IAgentTool,\n\ttype IMCPTool,\n\tTOOL_PROTOCOL_TYPE,\n} from \"@/types/tool.js\";\nimport { loggers } from \"@/utils/logger.js\";\n\n/**\n * Service for processing user queries through the agent's AI pipeline.\n *\n * Orchestrates the query processing workflow including intent detection,\n * model inference, tool execution, and response generation. Manages\n * conversation context and coordinates between different modules.\n */\nexport class QueryService {\n\tprivate modelModule: ModelModule;\n\tprivate a2aModule?: A2AModule;\n\tprivate mcpModule?: MCPModule;\n\tprivate memoryModule?: MemoryModule;\n\tprivate prompts?: AinAgentPrompts;\n\n\tconstructor(\n\t\tmodelModule: ModelModule,\n\t\ta2aModule?: A2AModule,\n\t\tmcpModule?: MCPModule,\n\t\tmemoryModule?: MemoryModule,\n\t\tprompts?: AinAgentPrompts,\n\t) {\n\t\tthis.modelModule = modelModule;\n\t\tthis.a2aModule = a2aModule;\n\t\tthis.mcpModule = mcpModule;\n\t\tthis.memoryModule = memoryModule;\n\t\tthis.prompts = prompts;\n\t}\n\n\t/**\n\t * Detects the intent from a user query.\n\t *\n\t * @param query - The user's input query\n\t * @returns The detected intent (currently returns the query as-is)\n\t * @todo Implement actual intent detection logic\n\t */\n\tprivate async intentTriggering(query: string) {\n\t\t/* TODO */\n\t\treturn query;\n\t}\n\n\t/**\n\t * Fulfills the detected intent by generating a response.\n\t *\n\t * Manages the complete inference loop including:\n\t * - Loading prompts and conversation history\n\t * - Collecting available tools from modules\n\t * - Executing model inference with tool support\n\t * - Processing tool calls iteratively until completion\n\t *\n\t * @param query - The user's input query\n\t * @param sessionId - Session identifier for context\n\t * @param sessionHistory - Previous conversation history\n\t * @returns Object containing process steps and final response\n\t */\n\tprivate async intentFulfilling(\n\t\tquery: string,\n\t\tsessionId: string,\n\t\tsessionHistory: SessionObject | undefined,\n\t) {\n\t\t// 1. Load agent / system prompt from memory\n\t\tconst systemPrompt = `\nToday is ${new Date().toLocaleDateString()}.\n\n${this.prompts?.agent || \"\"}\n\n${this.prompts?.system || \"\"}\n `;\n\n\t\tconst modelInstance = this.modelModule.getModel();\n\t\tconst messages = modelInstance.generateMessages({\n\t\t\tquery,\n\t\t\tsessionHistory,\n\t\t\tsystemPrompt: systemPrompt.trim(),\n\t\t});\n\n\t\tconst tools: IAgentTool[] = [];\n\t\tif (this.mcpModule) {\n\t\t\ttools.push(...this.mcpModule.getTools());\n\t\t}\n\t\tif (this.a2aModule) {\n\t\t\ttools.push(...(await this.a2aModule.getTools()));\n\t\t}\n\t\tconst functions = modelInstance.convertToolsToFunctions(tools);\n\n\t\tconst processList: string[] = [];\n\t\tlet finalMessage = \"\";\n\t\tlet didCallTool = false;\n\n\t\twhile (true) {\n\t\t\tconst response = await modelInstance.fetchWithContextMessage(\n\t\t\t\tmessages,\n\t\t\t\tfunctions,\n\t\t\t);\n\t\t\tdidCallTool = false;\n\n\t\t\tloggers.intent.debug(\"messages\", { messages });\n\n\t\t\tconst { content, toolCalls } = response;\n\n\t\t\tloggers.intent.debug(\"content\", { content });\n\t\t\tloggers.intent.debug(\"tool_calls\", { ...toolCalls });\n\n\t\t\tif (toolCalls) {\n\t\t\t\tconst messagePayload = this.a2aModule?.getMessagePayload(\n\t\t\t\t\tquery,\n\t\t\t\t\tsessionId,\n\t\t\t\t);\n\n\t\t\t\tfor (const toolCall of toolCalls) {\n\t\t\t\t\tconst toolName = toolCall.name;\n\t\t\t\t\tdidCallTool = true;\n\t\t\t\t\tconst selectedTool = tools.filter((tool) => tool.id === toolName)[0];\n\n\t\t\t\t\tlet toolResult = \"\";\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.mcpModule &&\n\t\t\t\t\t\tselectedTool.protocol === TOOL_PROTOCOL_TYPE.MCP\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst toolArgs = toolCall.arguments as\n\t\t\t\t\t\t\t| { [x: string]: unknown }\n\t\t\t\t\t\t\t| undefined;\n\t\t\t\t\t\tloggers.intent.debug(\"MCP tool call\", { toolName, toolArgs });\n\t\t\t\t\t\tconst result = await this.mcpModule.useTool(\n\t\t\t\t\t\t\tselectedTool as IMCPTool,\n\t\t\t\t\t\t\ttoolArgs,\n\t\t\t\t\t\t);\n\t\t\t\t\t\ttoolResult =\n\t\t\t\t\t\t\t`[Bot Called MCP Tool ${toolName} with args ${JSON.stringify(toolArgs)}]\\n` +\n\t\t\t\t\t\t\tJSON.stringify(result.content, null, 2);\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tthis.a2aModule &&\n\t\t\t\t\t\tselectedTool.protocol === TOOL_PROTOCOL_TYPE.A2A\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst result = await this.a2aModule.useTool(\n\t\t\t\t\t\t\tselectedTool as IA2ATool,\n\t\t\t\t\t\t\tmessagePayload!,\n\t\t\t\t\t\t\tsessionId,\n\t\t\t\t\t\t);\n\t\t\t\t\t\ttoolResult = `[Bot Called A2A Tool ${toolName}]\\n${result.join(\"\\n\")}`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Unrecognized tool type. It cannot be happened...\n\t\t\t\t\t\tloggers.intent.warn(\n\t\t\t\t\t\t\t`Unrecognized tool type: ${selectedTool.protocol}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tloggers.intent.debug(\"toolResult\", { toolResult });\n\n\t\t\t\t\tprocessList.push(toolResult);\n\t\t\t\t\tmodelInstance.appendMessages(messages, toolResult);\n\t\t\t\t}\n\t\t\t} else if (content) {\n\t\t\t\tprocessList.push(content);\n\t\t\t\tfinalMessage = content;\n\t\t\t}\n\n\t\t\tif (!didCallTool) break;\n\t\t}\n\n\t\tconst botResponse = {\n\t\t\tprocess: processList.join(\"\\n\"),\n\t\t\tresponse: finalMessage,\n\t\t};\n\n\t\treturn botResponse;\n\t}\n\n\t/**\n\t * Main entry point for processing user queries.\n\t *\n\t * Handles the complete query lifecycle:\n\t * 1. Loads session history from memory\n\t * 2. Detects intent from the query\n\t * 3. Fulfills the intent with AI response\n\t * 4. Updates conversation history\n\t *\n\t * @param query - The user's input query\n\t * @param sessionId - Unique session identifier\n\t * @param userId - Unique user identifier\n\t * @returns Object containing the AI-generated response\n\t */\n\tpublic async handleQuery(query: string, sessionId: string, userId?: string) {\n\t\t// 1. Load session history with sessionId\n\t\tconst queryStartAt = Date.now();\n\t\tconst sessionMemory = this.memoryModule?.getSessionMemory();\n\t\tconst session = !userId\n\t\t\t? undefined\n\t\t\t: await sessionMemory?.getSession(sessionId, userId);\n\n\t\t// 2. intent triggering\n\t\tconst intent = this.intentTriggering(query);\n\n\t\t// 3. intent fulfillment\n\t\tconst result = await this.intentFulfilling(query, sessionId, session);\n\t\tif (userId) {\n\t\t\tawait sessionMemory?.addChatToSession(\n\t\t\t\tsessionId,\n\t\t\t\t{\n\t\t\t\t\trole: ChatRole.USER,\n\t\t\t\t\ttimestamp: queryStartAt,\n\t\t\t\t\tcontent: { type: \"text\", parts: [query] },\n\t\t\t\t},\n\t\t\t\tuserId,\n\t\t\t);\n\t\t\tawait sessionMemory?.addChatToSession(\n\t\t\t\tsessionId,\n\t\t\t\t{\n\t\t\t\t\trole: ChatRole.MODEL,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\tcontent: { type: \"text\", parts: [result.response] },\n\t\t\t\t},\n\t\t\t\tuserId,\n\t\t\t);\n\t\t}\n\n\t\treturn { content: result.response };\n\t}\n}\n"]}
@@ -0,0 +1,27 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkRGKCBQGZcjs = require('./chunk-RGKCBQGZ.cjs');
4
+
5
+
6
+ var _chunkEF3XQJELcjs = require('./chunk-EF3XQJEL.cjs');
7
+
8
+ // src/routes/query.routes.ts
9
+ var _express = require('express');
10
+ var createQueryRouter = (agent) => {
11
+ const router = _express.Router.call(void 0, );
12
+ const queryService = new (0, _chunkEF3XQJELcjs.QueryService)(
13
+ agent.modelModule,
14
+ agent.a2aModule,
15
+ agent.mcpModule,
16
+ agent.memoryModule,
17
+ agent.manifest.prompts
18
+ );
19
+ const queryController = new (0, _chunkRGKCBQGZcjs.QueryController)(queryService);
20
+ router.post("/query", queryController.handleQueryRequest);
21
+ return router;
22
+ };
23
+
24
+
25
+
26
+ exports.createQueryRouter = createQueryRouter;
27
+ //# sourceMappingURL=chunk-MIMZF77Q.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/shyun/comcom/ain-agent/ain-adk/dist/cjs/chunk-MIMZF77Q.cjs","../../src/routes/query.routes.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACPA,kCAAuB;AAKhB,IAAM,kBAAA,EAAoB,CAAC,KAAA,EAAA,GAA4B;AAC7D,EAAA,MAAM,OAAA,EAAS,6BAAA,CAAO;AAEtB,EAAA,MAAM,aAAA,EAAe,IAAI,mCAAA;AAAA,IACxB,KAAA,CAAM,WAAA;AAAA,IACN,KAAA,CAAM,SAAA;AAAA,IACN,KAAA,CAAM,SAAA;AAAA,IACN,KAAA,CAAM,YAAA;AAAA,IACN,KAAA,CAAM,QAAA,CAAS;AAAA,EAChB,CAAA;AACA,EAAA,MAAM,gBAAA,EAAkB,IAAI,sCAAA,CAAgB,YAAY,CAAA;AACxD,EAAA,MAAA,CAAO,IAAA,CAAK,QAAA,EAAU,eAAA,CAAgB,kBAAkB,CAAA;AAExD,EAAA,OAAO,MAAA;AACR,CAAA;ADGA;AACA;AACE;AACF,8CAAC","file":"/Users/shyun/comcom/ain-agent/ain-adk/dist/cjs/chunk-MIMZF77Q.cjs","sourcesContent":[null,"import { Router } from \"express\";\nimport { QueryController } from \"@/controllers/query.controller.js\";\nimport type { AINAgent } from \"@/index.js\";\nimport { QueryService } from \"@/services/query.service.js\";\n\nexport const createQueryRouter = (agent: AINAgent): Router => {\n\tconst router = Router();\n\n\tconst queryService = new QueryService(\n\t\tagent.modelModule,\n\t\tagent.a2aModule,\n\t\tagent.mcpModule,\n\t\tagent.memoryModule,\n\t\tagent.manifest.prompts,\n\t);\n\tconst queryController = new QueryController(queryService);\n\trouter.post(\"/query\", queryController.handleQueryRequest);\n\n\treturn router;\n};\n"]}
@@ -0,0 +1,37 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk7BZO57TGcjs = require('./chunk-7BZO57TG.cjs');
4
+
5
+
6
+ var _chunkEF3XQJELcjs = require('./chunk-EF3XQJEL.cjs');
7
+
8
+
9
+ var _chunkILGIEJCXcjs = require('./chunk-ILGIEJCX.cjs');
10
+
11
+ // src/routes/a2a.routes.ts
12
+ var _server = require('@a2a-js/sdk/server');
13
+ var _express = require('express');
14
+ var createA2ARouter = (agent) => {
15
+ const router = _express.Router.call(void 0, );
16
+ const taskStore = new (0, _server.InMemoryTaskStore)();
17
+ const queryService = new (0, _chunkEF3XQJELcjs.QueryService)(
18
+ agent.modelModule,
19
+ agent.a2aModule,
20
+ agent.mcpModule,
21
+ agent.memoryModule,
22
+ agent.manifest.prompts
23
+ );
24
+ const a2aService = new (0, _chunk7BZO57TGcjs.A2AService)(queryService);
25
+ const a2aController = new (0, _chunkILGIEJCXcjs.A2AController)(
26
+ a2aService,
27
+ taskStore,
28
+ agent.generateAgentCard
29
+ );
30
+ router.post("/a2a", a2aController.handleA2ARequest);
31
+ return router;
32
+ };
33
+
34
+
35
+
36
+ exports.createA2ARouter = createA2ARouter;
37
+ //# sourceMappingURL=chunk-VUJI446Y.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/shyun/comcom/ain-agent/ain-adk/dist/cjs/chunk-VUJI446Y.cjs","../../src/routes/a2a.routes.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,4CAAkC;AAClC,kCAAuB;AAchB,IAAM,gBAAA,EAAkB,CAAC,KAAA,EAAA,GAA4B;AAC3D,EAAA,MAAM,OAAA,EAAS,6BAAA,CAAO;AAGtB,EAAA,MAAM,UAAA,EAAY,IAAI,8BAAA,CAAkB,CAAA;AACxC,EAAA,MAAM,aAAA,EAAe,IAAI,mCAAA;AAAA,IACxB,KAAA,CAAM,WAAA;AAAA,IACN,KAAA,CAAM,SAAA;AAAA,IACN,KAAA,CAAM,SAAA;AAAA,IACN,KAAA,CAAM,YAAA;AAAA,IACN,KAAA,CAAM,QAAA,CAAS;AAAA,EAChB,CAAA;AACA,EAAA,MAAM,WAAA,EAAa,IAAI,iCAAA,CAAW,YAAY,CAAA;AAC9C,EAAA,MAAM,cAAA,EAAgB,IAAI,oCAAA;AAAA,IACzB,UAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA,CAAM;AAAA,EACP,CAAA;AAGA,EAAA,MAAA,CAAO,IAAA,CAAK,MAAA,EAAQ,aAAA,CAAc,gBAAgB,CAAA;AAElD,EAAA,OAAO,MAAA;AACR,CAAA;ADNA;AACA;AACE;AACF,0CAAC","file":"/Users/shyun/comcom/ain-agent/ain-adk/dist/cjs/chunk-VUJI446Y.cjs","sourcesContent":[null,"import { InMemoryTaskStore } from \"@a2a-js/sdk/server\";\nimport { Router } from \"express\";\nimport type { AINAgent } from \"@/index.js\";\nimport { QueryService } from \"@/services/query.service.js\";\nimport { A2AController } from \"../controllers/a2a.controller.js\";\nimport { A2AService } from \"../services/a2a.service.js\";\n\n/**\n * Creates and configures the A2A router.\n * This function is a \"composition root\" for the A2A feature,\n * creating and injecting all necessary dependencies.\n * @param intentAnalyzer The core intent analyzer.\n * @param agentCard The agent's card.\n * @returns An Express Router instance.\n */\nexport const createA2ARouter = (agent: AINAgent): Router => {\n\tconst router = Router();\n\n\t// 1. Create dependencies for the A2A feature\n\tconst taskStore = new InMemoryTaskStore();\n\tconst queryService = new QueryService(\n\t\tagent.modelModule,\n\t\tagent.a2aModule,\n\t\tagent.mcpModule,\n\t\tagent.memoryModule,\n\t\tagent.manifest.prompts,\n\t);\n\tconst a2aService = new A2AService(queryService);\n\tconst a2aController = new A2AController(\n\t\ta2aService,\n\t\ttaskStore,\n\t\tagent.generateAgentCard,\n\t);\n\n\t// 2. Define the route\n\trouter.post(\"/a2a\", a2aController.handleA2ARequest);\n\n\treturn router;\n};\n"]}
@@ -6,7 +6,7 @@ require('./chunk-MTAGYTHO.cjs');
6
6
  require('./chunk-N7NGEMKL.cjs');
7
7
 
8
8
 
9
- var _chunkTWUZNIBNcjs = require('./chunk-TWUZNIBN.cjs');
9
+ var _chunkMIMZF77Qcjs = require('./chunk-MIMZF77Q.cjs');
10
10
  require('./chunk-V5RSN2DY.cjs');
11
11
  require('./chunk-J3BFUVZS.cjs');
12
12
  require('./chunk-RGKCBQGZ.cjs');
@@ -19,9 +19,9 @@ require('./chunk-DX2JH3FJ.cjs');
19
19
  var _chunkDYRSSHDIcjs = require('./chunk-DYRSSHDI.cjs');
20
20
 
21
21
 
22
- var _chunkD75FARQ5cjs = require('./chunk-D75FARQ5.cjs');
22
+ var _chunkVUJI446Ycjs = require('./chunk-VUJI446Y.cjs');
23
23
  require('./chunk-7BZO57TG.cjs');
24
- require('./chunk-573HTYTZ.cjs');
24
+ require('./chunk-EF3XQJEL.cjs');
25
25
  require('./chunk-3IGIYVGA.cjs');
26
26
  require('./chunk-ILGIEJCX.cjs');
27
27
  require('./chunk-LPXYZH22.cjs');
@@ -705,10 +705,10 @@ var AINAgent = (_class = class {
705
705
  res.status(_httpstatuscodes.StatusCodes.NOT_FOUND).send("No agent card");
706
706
  }
707
707
  });
708
- this.app.use(_chunkTWUZNIBNcjs.createQueryRouter.call(void 0, this));
708
+ this.app.use(_chunkMIMZF77Qcjs.createQueryRouter.call(void 0, this));
709
709
  this.app.use(_chunk74J4UIJ4cjs.createApiRouter.call(void 0, this));
710
710
  if (this.isValidUrl(this.manifest.url)) {
711
- this.app.use(_chunkD75FARQ5cjs.createA2ARouter.call(void 0, this));
711
+ this.app.use(_chunkVUJI446Ycjs.createA2ARouter.call(void 0, this));
712
712
  }
713
713
  }}
714
714
  /**
@@ -1,13 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkD75FARQ5cjs = require('../chunk-D75FARQ5.cjs');
3
+ var _chunkVUJI446Ycjs = require('../chunk-VUJI446Y.cjs');
4
4
  require('../chunk-7BZO57TG.cjs');
5
- require('../chunk-573HTYTZ.cjs');
5
+ require('../chunk-EF3XQJEL.cjs');
6
6
  require('../chunk-3IGIYVGA.cjs');
7
7
  require('../chunk-ILGIEJCX.cjs');
8
8
  require('../chunk-LPXYZH22.cjs');
9
9
  require('../chunk-JTAXZJQ2.cjs');
10
10
 
11
11
 
12
- exports.createA2ARouter = _chunkD75FARQ5cjs.createA2ARouter;
12
+ exports.createA2ARouter = _chunkVUJI446Ycjs.createA2ARouter;
13
13
  //# sourceMappingURL=a2a.routes.cjs.map
@@ -10,16 +10,16 @@ var _chunkMTAGYTHOcjs = require('../chunk-MTAGYTHO.cjs');
10
10
  var _chunkN7NGEMKLcjs = require('../chunk-N7NGEMKL.cjs');
11
11
 
12
12
 
13
- var _chunkTWUZNIBNcjs = require('../chunk-TWUZNIBN.cjs');
13
+ var _chunkMIMZF77Qcjs = require('../chunk-MIMZF77Q.cjs');
14
14
  require('../chunk-V5RSN2DY.cjs');
15
15
  require('../chunk-J3BFUVZS.cjs');
16
16
  require('../chunk-RGKCBQGZ.cjs');
17
17
  require('../chunk-DX2JH3FJ.cjs');
18
18
 
19
19
 
20
- var _chunkD75FARQ5cjs = require('../chunk-D75FARQ5.cjs');
20
+ var _chunkVUJI446Ycjs = require('../chunk-VUJI446Y.cjs');
21
21
  require('../chunk-7BZO57TG.cjs');
22
- require('../chunk-573HTYTZ.cjs');
22
+ require('../chunk-EF3XQJEL.cjs');
23
23
  require('../chunk-3IGIYVGA.cjs');
24
24
  require('../chunk-ILGIEJCX.cjs');
25
25
  require('../chunk-LPXYZH22.cjs');
@@ -30,5 +30,5 @@ require('../chunk-JTAXZJQ2.cjs');
30
30
 
31
31
 
32
32
 
33
- exports.createA2ARouter = _chunkD75FARQ5cjs.createA2ARouter; exports.createApiRouter = _chunk74J4UIJ4cjs.createApiRouter; exports.createModelApiRouter = _chunkN7NGEMKLcjs.createModelApiRouter; exports.createQueryRouter = _chunkTWUZNIBNcjs.createQueryRouter; exports.createSessionApiRouter = _chunkMTAGYTHOcjs.createSessionApiRouter;
33
+ exports.createA2ARouter = _chunkVUJI446Ycjs.createA2ARouter; exports.createApiRouter = _chunk74J4UIJ4cjs.createApiRouter; exports.createModelApiRouter = _chunkN7NGEMKLcjs.createModelApiRouter; exports.createQueryRouter = _chunkMIMZF77Qcjs.createQueryRouter; exports.createSessionApiRouter = _chunkMTAGYTHOcjs.createSessionApiRouter;
34
34
  //# sourceMappingURL=index.cjs.map
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkTWUZNIBNcjs = require('../chunk-TWUZNIBN.cjs');
3
+ var _chunkMIMZF77Qcjs = require('../chunk-MIMZF77Q.cjs');
4
4
  require('../chunk-RGKCBQGZ.cjs');
5
- require('../chunk-573HTYTZ.cjs');
5
+ require('../chunk-EF3XQJEL.cjs');
6
6
  require('../chunk-3IGIYVGA.cjs');
7
7
  require('../chunk-LPXYZH22.cjs');
8
8
  require('../chunk-JTAXZJQ2.cjs');
9
9
 
10
10
 
11
- exports.createQueryRouter = _chunkTWUZNIBNcjs.createQueryRouter;
11
+ exports.createQueryRouter = _chunkMIMZF77Qcjs.createQueryRouter;
12
12
  //# sourceMappingURL=query.routes.cjs.map
@@ -3,12 +3,12 @@
3
3
  var _chunk7BZO57TGcjs = require('../chunk-7BZO57TG.cjs');
4
4
 
5
5
 
6
- var _chunk573HTYTZcjs = require('../chunk-573HTYTZ.cjs');
6
+ var _chunkEF3XQJELcjs = require('../chunk-EF3XQJEL.cjs');
7
7
  require('../chunk-3IGIYVGA.cjs');
8
8
  require('../chunk-LPXYZH22.cjs');
9
9
  require('../chunk-JTAXZJQ2.cjs');
10
10
 
11
11
 
12
12
 
13
- exports.A2AService = _chunk7BZO57TGcjs.A2AService; exports.QueryService = _chunk573HTYTZcjs.QueryService;
13
+ exports.A2AService = _chunk7BZO57TGcjs.A2AService; exports.QueryService = _chunkEF3XQJELcjs.QueryService;
14
14
  //# sourceMappingURL=index.cjs.map
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk573HTYTZcjs = require('../chunk-573HTYTZ.cjs');
3
+ var _chunkEF3XQJELcjs = require('../chunk-EF3XQJEL.cjs');
4
4
  require('../chunk-3IGIYVGA.cjs');
5
5
  require('../chunk-LPXYZH22.cjs');
6
6
  require('../chunk-JTAXZJQ2.cjs');
7
7
 
8
8
 
9
- exports.QueryService = _chunk573HTYTZcjs.QueryService;
9
+ exports.QueryService = _chunkEF3XQJELcjs.QueryService;
10
10
  //# sourceMappingURL=query.service.cjs.map
@@ -135,19 +135,16 @@ ${result.join("\n")}`;
135
135
  *
136
136
  * @param query - The user's input query
137
137
  * @param sessionId - Unique session identifier
138
+ * @param userId - Unique user identifier
138
139
  * @returns Object containing the AI-generated response
139
140
  */
140
141
  async handleQuery(query, sessionId, userId) {
141
142
  const queryStartAt = Date.now();
142
143
  const sessionMemory = this.memoryModule?.getSessionMemory();
143
- const sessionHistory = await sessionMemory?.getSession(sessionId, userId);
144
+ const session = !userId ? void 0 : await sessionMemory?.getSession(sessionId, userId);
144
145
  const intent = this.intentTriggering(query);
145
- const result = await this.intentFulfilling(
146
- query,
147
- sessionId,
148
- sessionHistory
149
- );
150
- if (sessionId) {
146
+ const result = await this.intentFulfilling(query, sessionId, session);
147
+ if (userId) {
151
148
  await sessionMemory?.addChatToSession(
152
149
  sessionId,
153
150
  {
@@ -174,4 +171,4 @@ ${result.join("\n")}`;
174
171
  export {
175
172
  QueryService
176
173
  };
177
- //# sourceMappingURL=chunk-2K5L4GFC.js.map
174
+ //# sourceMappingURL=chunk-356AV44C.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/query.service.ts"],"sourcesContent":["import type {\n\tA2AModule,\n\tMCPModule,\n\tMemoryModule,\n\tModelModule,\n} from \"@/modules/index.js\";\nimport type { AinAgentPrompts } from \"@/types/agent.js\";\nimport { ChatRole, type SessionObject } from \"@/types/memory.js\";\nimport {\n\ttype IA2ATool,\n\ttype IAgentTool,\n\ttype IMCPTool,\n\tTOOL_PROTOCOL_TYPE,\n} from \"@/types/tool.js\";\nimport { loggers } from \"@/utils/logger.js\";\n\n/**\n * Service for processing user queries through the agent's AI pipeline.\n *\n * Orchestrates the query processing workflow including intent detection,\n * model inference, tool execution, and response generation. Manages\n * conversation context and coordinates between different modules.\n */\nexport class QueryService {\n\tprivate modelModule: ModelModule;\n\tprivate a2aModule?: A2AModule;\n\tprivate mcpModule?: MCPModule;\n\tprivate memoryModule?: MemoryModule;\n\tprivate prompts?: AinAgentPrompts;\n\n\tconstructor(\n\t\tmodelModule: ModelModule,\n\t\ta2aModule?: A2AModule,\n\t\tmcpModule?: MCPModule,\n\t\tmemoryModule?: MemoryModule,\n\t\tprompts?: AinAgentPrompts,\n\t) {\n\t\tthis.modelModule = modelModule;\n\t\tthis.a2aModule = a2aModule;\n\t\tthis.mcpModule = mcpModule;\n\t\tthis.memoryModule = memoryModule;\n\t\tthis.prompts = prompts;\n\t}\n\n\t/**\n\t * Detects the intent from a user query.\n\t *\n\t * @param query - The user's input query\n\t * @returns The detected intent (currently returns the query as-is)\n\t * @todo Implement actual intent detection logic\n\t */\n\tprivate async intentTriggering(query: string) {\n\t\t/* TODO */\n\t\treturn query;\n\t}\n\n\t/**\n\t * Fulfills the detected intent by generating a response.\n\t *\n\t * Manages the complete inference loop including:\n\t * - Loading prompts and conversation history\n\t * - Collecting available tools from modules\n\t * - Executing model inference with tool support\n\t * - Processing tool calls iteratively until completion\n\t *\n\t * @param query - The user's input query\n\t * @param sessionId - Session identifier for context\n\t * @param sessionHistory - Previous conversation history\n\t * @returns Object containing process steps and final response\n\t */\n\tprivate async intentFulfilling(\n\t\tquery: string,\n\t\tsessionId: string,\n\t\tsessionHistory: SessionObject | undefined,\n\t) {\n\t\t// 1. Load agent / system prompt from memory\n\t\tconst systemPrompt = `\nToday is ${new Date().toLocaleDateString()}.\n\n${this.prompts?.agent || \"\"}\n\n${this.prompts?.system || \"\"}\n `;\n\n\t\tconst modelInstance = this.modelModule.getModel();\n\t\tconst messages = modelInstance.generateMessages({\n\t\t\tquery,\n\t\t\tsessionHistory,\n\t\t\tsystemPrompt: systemPrompt.trim(),\n\t\t});\n\n\t\tconst tools: IAgentTool[] = [];\n\t\tif (this.mcpModule) {\n\t\t\ttools.push(...this.mcpModule.getTools());\n\t\t}\n\t\tif (this.a2aModule) {\n\t\t\ttools.push(...(await this.a2aModule.getTools()));\n\t\t}\n\t\tconst functions = modelInstance.convertToolsToFunctions(tools);\n\n\t\tconst processList: string[] = [];\n\t\tlet finalMessage = \"\";\n\t\tlet didCallTool = false;\n\n\t\twhile (true) {\n\t\t\tconst response = await modelInstance.fetchWithContextMessage(\n\t\t\t\tmessages,\n\t\t\t\tfunctions,\n\t\t\t);\n\t\t\tdidCallTool = false;\n\n\t\t\tloggers.intent.debug(\"messages\", { messages });\n\n\t\t\tconst { content, toolCalls } = response;\n\n\t\t\tloggers.intent.debug(\"content\", { content });\n\t\t\tloggers.intent.debug(\"tool_calls\", { ...toolCalls });\n\n\t\t\tif (toolCalls) {\n\t\t\t\tconst messagePayload = this.a2aModule?.getMessagePayload(\n\t\t\t\t\tquery,\n\t\t\t\t\tsessionId,\n\t\t\t\t);\n\n\t\t\t\tfor (const toolCall of toolCalls) {\n\t\t\t\t\tconst toolName = toolCall.name;\n\t\t\t\t\tdidCallTool = true;\n\t\t\t\t\tconst selectedTool = tools.filter((tool) => tool.id === toolName)[0];\n\n\t\t\t\t\tlet toolResult = \"\";\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.mcpModule &&\n\t\t\t\t\t\tselectedTool.protocol === TOOL_PROTOCOL_TYPE.MCP\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst toolArgs = toolCall.arguments as\n\t\t\t\t\t\t\t| { [x: string]: unknown }\n\t\t\t\t\t\t\t| undefined;\n\t\t\t\t\t\tloggers.intent.debug(\"MCP tool call\", { toolName, toolArgs });\n\t\t\t\t\t\tconst result = await this.mcpModule.useTool(\n\t\t\t\t\t\t\tselectedTool as IMCPTool,\n\t\t\t\t\t\t\ttoolArgs,\n\t\t\t\t\t\t);\n\t\t\t\t\t\ttoolResult =\n\t\t\t\t\t\t\t`[Bot Called MCP Tool ${toolName} with args ${JSON.stringify(toolArgs)}]\\n` +\n\t\t\t\t\t\t\tJSON.stringify(result.content, null, 2);\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tthis.a2aModule &&\n\t\t\t\t\t\tselectedTool.protocol === TOOL_PROTOCOL_TYPE.A2A\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst result = await this.a2aModule.useTool(\n\t\t\t\t\t\t\tselectedTool as IA2ATool,\n\t\t\t\t\t\t\tmessagePayload!,\n\t\t\t\t\t\t\tsessionId,\n\t\t\t\t\t\t);\n\t\t\t\t\t\ttoolResult = `[Bot Called A2A Tool ${toolName}]\\n${result.join(\"\\n\")}`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Unrecognized tool type. It cannot be happened...\n\t\t\t\t\t\tloggers.intent.warn(\n\t\t\t\t\t\t\t`Unrecognized tool type: ${selectedTool.protocol}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tloggers.intent.debug(\"toolResult\", { toolResult });\n\n\t\t\t\t\tprocessList.push(toolResult);\n\t\t\t\t\tmodelInstance.appendMessages(messages, toolResult);\n\t\t\t\t}\n\t\t\t} else if (content) {\n\t\t\t\tprocessList.push(content);\n\t\t\t\tfinalMessage = content;\n\t\t\t}\n\n\t\t\tif (!didCallTool) break;\n\t\t}\n\n\t\tconst botResponse = {\n\t\t\tprocess: processList.join(\"\\n\"),\n\t\t\tresponse: finalMessage,\n\t\t};\n\n\t\treturn botResponse;\n\t}\n\n\t/**\n\t * Main entry point for processing user queries.\n\t *\n\t * Handles the complete query lifecycle:\n\t * 1. Loads session history from memory\n\t * 2. Detects intent from the query\n\t * 3. Fulfills the intent with AI response\n\t * 4. Updates conversation history\n\t *\n\t * @param query - The user's input query\n\t * @param sessionId - Unique session identifier\n\t * @returns Object containing the AI-generated response\n\t */\n\tpublic async handleQuery(query: string, sessionId: string, userId?: string) {\n\t\t// 1. Load session history with sessionId\n\t\tconst queryStartAt = Date.now();\n\t\tconst sessionMemory = this.memoryModule?.getSessionMemory();\n\t\tconst sessionHistory = await sessionMemory?.getSession(sessionId, userId);\n\n\t\t// 2. intent triggering\n\t\tconst intent = this.intentTriggering(query);\n\n\t\t// 3. intent fulfillment\n\t\tconst result = await this.intentFulfilling(\n\t\t\tquery,\n\t\t\tsessionId,\n\t\t\tsessionHistory,\n\t\t);\n\t\tif (sessionId) {\n\t\t\tawait sessionMemory?.addChatToSession(\n\t\t\t\tsessionId,\n\t\t\t\t{\n\t\t\t\t\trole: ChatRole.USER,\n\t\t\t\t\ttimestamp: queryStartAt,\n\t\t\t\t\tcontent: { type: \"text\", parts: [query] },\n\t\t\t\t},\n\t\t\t\tuserId,\n\t\t\t);\n\t\t\tawait sessionMemory?.addChatToSession(\n\t\t\t\tsessionId,\n\t\t\t\t{\n\t\t\t\t\trole: ChatRole.MODEL,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\tcontent: { type: \"text\", parts: [result.response] },\n\t\t\t\t},\n\t\t\t\tuserId,\n\t\t\t);\n\t\t}\n\n\t\treturn { content: result.response };\n\t}\n}\n"],"mappings":";;;;;AAuBO,IAAM,eAAN,MAAmB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,YACC,aACA,WACA,WACA,cACA,SACC;AACD,SAAK,cAAc;AACnB,SAAK,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AAE3E,UAAM,eAAe,KAAK,IAAI;AAC9B,UAAM,gBAAgB,KAAK,cAAc,iBAAiB;AAC1D,UAAM,iBAAiB,MAAM,eAAe,WAAW,WAAW,MAAM;AAGxE,UAAM,SAAS,KAAK,iBAAiB,KAAK;AAG1C,UAAM,SAAS,MAAM,KAAK;AAAA,MACzB;AAAA,MACA;AAAA,MACA;AAAA,IACD;AACA,QAAI,WAAW;AACd,YAAM,eAAe;AAAA,QACpB;AAAA,QACA;AAAA,UACC;AAAA,UACA,WAAW;AAAA,UACX,SAAS,EAAE,MAAM,QAAQ,OAAO,CAAC,KAAK,EAAE;AAAA,QACzC;AAAA,QACA;AAAA,MACD;AACA,YAAM,eAAe;AAAA,QACpB;AAAA,QACA;AAAA,UACC;AAAA,UACA,WAAW,KAAK,IAAI;AAAA,UACpB,SAAS,EAAE,MAAM,QAAQ,OAAO,CAAC,OAAO,QAAQ,EAAE;AAAA,QACnD;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAEA,WAAO,EAAE,SAAS,OAAO,SAAS;AAAA,EACnC;AACD;","names":[]}
1
+ {"version":3,"sources":["../../src/services/query.service.ts"],"sourcesContent":["import type {\n\tA2AModule,\n\tMCPModule,\n\tMemoryModule,\n\tModelModule,\n} from \"@/modules/index.js\";\nimport type { AinAgentPrompts } from \"@/types/agent.js\";\nimport { ChatRole, type SessionObject } from \"@/types/memory.js\";\nimport {\n\ttype IA2ATool,\n\ttype IAgentTool,\n\ttype IMCPTool,\n\tTOOL_PROTOCOL_TYPE,\n} from \"@/types/tool.js\";\nimport { loggers } from \"@/utils/logger.js\";\n\n/**\n * Service for processing user queries through the agent's AI pipeline.\n *\n * Orchestrates the query processing workflow including intent detection,\n * model inference, tool execution, and response generation. Manages\n * conversation context and coordinates between different modules.\n */\nexport class QueryService {\n\tprivate modelModule: ModelModule;\n\tprivate a2aModule?: A2AModule;\n\tprivate mcpModule?: MCPModule;\n\tprivate memoryModule?: MemoryModule;\n\tprivate prompts?: AinAgentPrompts;\n\n\tconstructor(\n\t\tmodelModule: ModelModule,\n\t\ta2aModule?: A2AModule,\n\t\tmcpModule?: MCPModule,\n\t\tmemoryModule?: MemoryModule,\n\t\tprompts?: AinAgentPrompts,\n\t) {\n\t\tthis.modelModule = modelModule;\n\t\tthis.a2aModule = a2aModule;\n\t\tthis.mcpModule = mcpModule;\n\t\tthis.memoryModule = memoryModule;\n\t\tthis.prompts = prompts;\n\t}\n\n\t/**\n\t * Detects the intent from a user query.\n\t *\n\t * @param query - The user's input query\n\t * @returns The detected intent (currently returns the query as-is)\n\t * @todo Implement actual intent detection logic\n\t */\n\tprivate async intentTriggering(query: string) {\n\t\t/* TODO */\n\t\treturn query;\n\t}\n\n\t/**\n\t * Fulfills the detected intent by generating a response.\n\t *\n\t * Manages the complete inference loop including:\n\t * - Loading prompts and conversation history\n\t * - Collecting available tools from modules\n\t * - Executing model inference with tool support\n\t * - Processing tool calls iteratively until completion\n\t *\n\t * @param query - The user's input query\n\t * @param sessionId - Session identifier for context\n\t * @param sessionHistory - Previous conversation history\n\t * @returns Object containing process steps and final response\n\t */\n\tprivate async intentFulfilling(\n\t\tquery: string,\n\t\tsessionId: string,\n\t\tsessionHistory: SessionObject | undefined,\n\t) {\n\t\t// 1. Load agent / system prompt from memory\n\t\tconst systemPrompt = `\nToday is ${new Date().toLocaleDateString()}.\n\n${this.prompts?.agent || \"\"}\n\n${this.prompts?.system || \"\"}\n `;\n\n\t\tconst modelInstance = this.modelModule.getModel();\n\t\tconst messages = modelInstance.generateMessages({\n\t\t\tquery,\n\t\t\tsessionHistory,\n\t\t\tsystemPrompt: systemPrompt.trim(),\n\t\t});\n\n\t\tconst tools: IAgentTool[] = [];\n\t\tif (this.mcpModule) {\n\t\t\ttools.push(...this.mcpModule.getTools());\n\t\t}\n\t\tif (this.a2aModule) {\n\t\t\ttools.push(...(await this.a2aModule.getTools()));\n\t\t}\n\t\tconst functions = modelInstance.convertToolsToFunctions(tools);\n\n\t\tconst processList: string[] = [];\n\t\tlet finalMessage = \"\";\n\t\tlet didCallTool = false;\n\n\t\twhile (true) {\n\t\t\tconst response = await modelInstance.fetchWithContextMessage(\n\t\t\t\tmessages,\n\t\t\t\tfunctions,\n\t\t\t);\n\t\t\tdidCallTool = false;\n\n\t\t\tloggers.intent.debug(\"messages\", { messages });\n\n\t\t\tconst { content, toolCalls } = response;\n\n\t\t\tloggers.intent.debug(\"content\", { content });\n\t\t\tloggers.intent.debug(\"tool_calls\", { ...toolCalls });\n\n\t\t\tif (toolCalls) {\n\t\t\t\tconst messagePayload = this.a2aModule?.getMessagePayload(\n\t\t\t\t\tquery,\n\t\t\t\t\tsessionId,\n\t\t\t\t);\n\n\t\t\t\tfor (const toolCall of toolCalls) {\n\t\t\t\t\tconst toolName = toolCall.name;\n\t\t\t\t\tdidCallTool = true;\n\t\t\t\t\tconst selectedTool = tools.filter((tool) => tool.id === toolName)[0];\n\n\t\t\t\t\tlet toolResult = \"\";\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.mcpModule &&\n\t\t\t\t\t\tselectedTool.protocol === TOOL_PROTOCOL_TYPE.MCP\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst toolArgs = toolCall.arguments as\n\t\t\t\t\t\t\t| { [x: string]: unknown }\n\t\t\t\t\t\t\t| undefined;\n\t\t\t\t\t\tloggers.intent.debug(\"MCP tool call\", { toolName, toolArgs });\n\t\t\t\t\t\tconst result = await this.mcpModule.useTool(\n\t\t\t\t\t\t\tselectedTool as IMCPTool,\n\t\t\t\t\t\t\ttoolArgs,\n\t\t\t\t\t\t);\n\t\t\t\t\t\ttoolResult =\n\t\t\t\t\t\t\t`[Bot Called MCP Tool ${toolName} with args ${JSON.stringify(toolArgs)}]\\n` +\n\t\t\t\t\t\t\tJSON.stringify(result.content, null, 2);\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tthis.a2aModule &&\n\t\t\t\t\t\tselectedTool.protocol === TOOL_PROTOCOL_TYPE.A2A\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst result = await this.a2aModule.useTool(\n\t\t\t\t\t\t\tselectedTool as IA2ATool,\n\t\t\t\t\t\t\tmessagePayload!,\n\t\t\t\t\t\t\tsessionId,\n\t\t\t\t\t\t);\n\t\t\t\t\t\ttoolResult = `[Bot Called A2A Tool ${toolName}]\\n${result.join(\"\\n\")}`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Unrecognized tool type. It cannot be happened...\n\t\t\t\t\t\tloggers.intent.warn(\n\t\t\t\t\t\t\t`Unrecognized tool type: ${selectedTool.protocol}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tloggers.intent.debug(\"toolResult\", { toolResult });\n\n\t\t\t\t\tprocessList.push(toolResult);\n\t\t\t\t\tmodelInstance.appendMessages(messages, toolResult);\n\t\t\t\t}\n\t\t\t} else if (content) {\n\t\t\t\tprocessList.push(content);\n\t\t\t\tfinalMessage = content;\n\t\t\t}\n\n\t\t\tif (!didCallTool) break;\n\t\t}\n\n\t\tconst botResponse = {\n\t\t\tprocess: processList.join(\"\\n\"),\n\t\t\tresponse: finalMessage,\n\t\t};\n\n\t\treturn botResponse;\n\t}\n\n\t/**\n\t * Main entry point for processing user queries.\n\t *\n\t * Handles the complete query lifecycle:\n\t * 1. Loads session history from memory\n\t * 2. Detects intent from the query\n\t * 3. Fulfills the intent with AI response\n\t * 4. Updates conversation history\n\t *\n\t * @param query - The user's input query\n\t * @param sessionId - Unique session identifier\n\t * @param userId - Unique user identifier\n\t * @returns Object containing the AI-generated response\n\t */\n\tpublic async handleQuery(query: string, sessionId: string, userId?: string) {\n\t\t// 1. Load session history with sessionId\n\t\tconst queryStartAt = Date.now();\n\t\tconst sessionMemory = this.memoryModule?.getSessionMemory();\n\t\tconst session = !userId\n\t\t\t? undefined\n\t\t\t: await sessionMemory?.getSession(sessionId, userId);\n\n\t\t// 2. intent triggering\n\t\tconst intent = this.intentTriggering(query);\n\n\t\t// 3. intent fulfillment\n\t\tconst result = await this.intentFulfilling(query, sessionId, session);\n\t\tif (userId) {\n\t\t\tawait sessionMemory?.addChatToSession(\n\t\t\t\tsessionId,\n\t\t\t\t{\n\t\t\t\t\trole: ChatRole.USER,\n\t\t\t\t\ttimestamp: queryStartAt,\n\t\t\t\t\tcontent: { type: \"text\", parts: [query] },\n\t\t\t\t},\n\t\t\t\tuserId,\n\t\t\t);\n\t\t\tawait sessionMemory?.addChatToSession(\n\t\t\t\tsessionId,\n\t\t\t\t{\n\t\t\t\t\trole: ChatRole.MODEL,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\tcontent: { type: \"text\", parts: [result.response] },\n\t\t\t\t},\n\t\t\t\tuserId,\n\t\t\t);\n\t\t}\n\n\t\treturn { content: result.response };\n\t}\n}\n"],"mappings":";;;;;AAuBO,IAAM,eAAN,MAAmB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,YACC,aACA,WACA,WACA,cACA,SACC;AACD,SAAK,cAAc;AACnB,SAAK,YAAY;AACjB,SAAK,YAAY;AACjB,SAAK,eAAe;AACpB,SAAK,UAAU;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAc,iBAAiB,OAAe;AAE7C,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,MAAc,iBACb,OACA,WACA,gBACC;AAED,UAAM,eAAe;AAAA,YACZ,oBAAI,KAAK,GAAE,mBAAmB,CAAC;AAAA;AAAA,EAExC,KAAK,SAAS,SAAS,EAAE;AAAA;AAAA,EAEzB,KAAK,SAAS,UAAU,EAAE;AAAA;AAG1B,UAAM,gBAAgB,KAAK,YAAY,SAAS;AAChD,UAAM,WAAW,cAAc,iBAAiB;AAAA,MAC/C;AAAA,MACA;AAAA,MACA,cAAc,aAAa,KAAK;AA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,QACnD;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAEA,WAAO,EAAE,SAAS,OAAO,SAAS;AAAA,EACnC;AACD;","names":[]}
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-AQ5YZERE.js";
4
4
  import {
5
5
  QueryService
6
- } from "./chunk-2K5L4GFC.js";
6
+ } from "./chunk-356AV44C.js";
7
7
  import {
8
8
  A2AController
9
9
  } from "./chunk-EODMRV4H.js";
@@ -34,4 +34,4 @@ var createA2ARouter = (agent) => {
34
34
  export {
35
35
  createA2ARouter
36
36
  };
37
- //# sourceMappingURL=chunk-OIIR42TQ.js.map
37
+ //# sourceMappingURL=chunk-B3R4A2NL.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-WIJDRP2A.js";
4
4
  import {
5
5
  QueryService
6
- } from "./chunk-2K5L4GFC.js";
6
+ } from "./chunk-356AV44C.js";
7
7
 
8
8
  // src/routes/query.routes.ts
9
9
  import { Router } from "express";
@@ -24,4 +24,4 @@ var createQueryRouter = (agent) => {
24
24
  export {
25
25
  createQueryRouter
26
26
  };
27
- //# sourceMappingURL=chunk-EJIQKPIV.js.map
27
+ //# sourceMappingURL=chunk-O5OBYREI.js.map
package/dist/esm/index.js CHANGED
@@ -6,7 +6,7 @@ import "./chunk-RSSLUA2N.js";
6
6
  import "./chunk-2Z7GJVJJ.js";
7
7
  import {
8
8
  createQueryRouter
9
- } from "./chunk-EJIQKPIV.js";
9
+ } from "./chunk-O5OBYREI.js";
10
10
  import "./chunk-UA44VKFE.js";
11
11
  import "./chunk-RB4IFZJA.js";
12
12
  import "./chunk-WIJDRP2A.js";
@@ -19,9 +19,9 @@ import {
19
19
  } from "./chunk-ILFWNK3W.js";
20
20
  import {
21
21
  createA2ARouter
22
- } from "./chunk-OIIR42TQ.js";
22
+ } from "./chunk-B3R4A2NL.js";
23
23
  import "./chunk-AQ5YZERE.js";
24
- import "./chunk-2K5L4GFC.js";
24
+ import "./chunk-356AV44C.js";
25
25
  import "./chunk-F727XG4N.js";
26
26
  import "./chunk-EODMRV4H.js";
27
27
  import "./chunk-FI2UQLVC.js";
@@ -12,10 +12,10 @@ interface IMemory {
12
12
  * Session memory interface
13
13
  */
14
14
  interface ISessionMemory extends IMemory {
15
- getSession(sessionId: string, userId?: string): Promise<SessionObject | undefined>;
16
- createSession(sessionId: string, userId?: string): Promise<void>;
17
- addChatToSession(sessionId: string, chat: ChatObject, userId?: string): Promise<void>;
18
- deleteSession(sessionId: string, userId?: string): Promise<void>;
15
+ getSession(sessionId: string, userId: string): Promise<SessionObject | undefined>;
16
+ createSession(sessionId: string, userId: string): Promise<void>;
17
+ addChatToSession(sessionId: string, chat: ChatObject, userId: string): Promise<void>;
18
+ deleteSession(sessionId: string, userId: string): Promise<void>;
19
19
  listSessions(userId: string): Promise<string[]>;
20
20
  }
21
21
  /**
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createA2ARouter
3
- } from "../chunk-OIIR42TQ.js";
3
+ } from "../chunk-B3R4A2NL.js";
4
4
  import "../chunk-AQ5YZERE.js";
5
- import "../chunk-2K5L4GFC.js";
5
+ import "../chunk-356AV44C.js";
6
6
  import "../chunk-F727XG4N.js";
7
7
  import "../chunk-EODMRV4H.js";
8
8
  import "../chunk-FI2UQLVC.js";
@@ -10,16 +10,16 @@ import {
10
10
  } from "../chunk-2Z7GJVJJ.js";
11
11
  import {
12
12
  createQueryRouter
13
- } from "../chunk-EJIQKPIV.js";
13
+ } from "../chunk-O5OBYREI.js";
14
14
  import "../chunk-UA44VKFE.js";
15
15
  import "../chunk-RB4IFZJA.js";
16
16
  import "../chunk-WIJDRP2A.js";
17
17
  import "../chunk-FL3JRQM4.js";
18
18
  import {
19
19
  createA2ARouter
20
- } from "../chunk-OIIR42TQ.js";
20
+ } from "../chunk-B3R4A2NL.js";
21
21
  import "../chunk-AQ5YZERE.js";
22
- import "../chunk-2K5L4GFC.js";
22
+ import "../chunk-356AV44C.js";
23
23
  import "../chunk-F727XG4N.js";
24
24
  import "../chunk-EODMRV4H.js";
25
25
  import "../chunk-FI2UQLVC.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createQueryRouter
3
- } from "../chunk-EJIQKPIV.js";
3
+ } from "../chunk-O5OBYREI.js";
4
4
  import "../chunk-WIJDRP2A.js";
5
- import "../chunk-2K5L4GFC.js";
5
+ import "../chunk-356AV44C.js";
6
6
  import "../chunk-F727XG4N.js";
7
7
  import "../chunk-FI2UQLVC.js";
8
8
  import "../chunk-64GEXWSE.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunk-AQ5YZERE.js";
4
4
  import {
5
5
  QueryService
6
- } from "../chunk-2K5L4GFC.js";
6
+ } from "../chunk-356AV44C.js";
7
7
  import "../chunk-F727XG4N.js";
8
8
  import "../chunk-FI2UQLVC.js";
9
9
  import "../chunk-64GEXWSE.js";
@@ -64,6 +64,7 @@ declare class QueryService {
64
64
  *
65
65
  * @param query - The user's input query
66
66
  * @param sessionId - Unique session identifier
67
+ * @param userId - Unique user identifier
67
68
  * @returns Object containing the AI-generated response
68
69
  */
69
70
  handleQuery(query: string, sessionId: string, userId?: string): Promise<{
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  QueryService
3
- } from "../chunk-2K5L4GFC.js";
3
+ } from "../chunk-356AV44C.js";
4
4
  import "../chunk-F727XG4N.js";
5
5
  import "../chunk-FI2UQLVC.js";
6
6
  import "../chunk-64GEXWSE.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ainetwork/adk",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "AI Network Agent Development Kit",
5
5
  "repository": "git@github.com:ainetwork-ai/ain-adk.git",
6
6
  "author": "AI Network (https://ainetwork.ai)",