@codebolt/codeboltjs 2.0.13 → 2.0.15
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/agentlib/agent.js +3 -7
- package/dist/agentlib/followupquestionbuilder.d.ts +75 -0
- package/dist/agentlib/followupquestionbuilder.js +193 -0
- package/dist/agentlib/llmoutputhandler.d.ts +102 -0
- package/dist/agentlib/llmoutputhandler.js +451 -0
- package/dist/agentlib/promptbuilder.d.ts +171 -17
- package/dist/agentlib/promptbuilder.js +367 -49
- package/dist/agentlib/systemprompt.js +3 -3
- package/dist/agentlib/usermessage.d.ts +1 -1
- package/dist/agentlib/usermessage.js +5 -1
- package/dist/core/Codebolt.d.ts +52 -20
- package/dist/core/Codebolt.js +43 -1
- package/dist/core/websocket.js +2 -1
- package/dist/modules/llm.d.ts +23 -3
- package/dist/modules/llm.js +20 -3
- package/dist/modules/project.d.ts +3 -3
- package/dist/modules/project.js +1 -1
- package/dist/modules/state.d.ts +5 -3
- package/dist/modules/state.js +2 -0
- package/dist/modules/task.d.ts +126 -11
- package/dist/modules/task.js +262 -20
- package/dist/notificationfunctions/agent.d.ts +48 -0
- package/dist/notificationfunctions/agent.js +115 -0
- package/dist/notificationfunctions/browser.d.ts +60 -0
- package/dist/notificationfunctions/browser.js +145 -0
- package/dist/notificationfunctions/chat.d.ts +53 -0
- package/dist/notificationfunctions/chat.js +125 -0
- package/dist/notificationfunctions/codeutils.d.ts +60 -0
- package/dist/notificationfunctions/codeutils.js +145 -0
- package/dist/notificationfunctions/crawler.d.ts +59 -0
- package/dist/notificationfunctions/crawler.js +159 -0
- package/dist/notificationfunctions/dbmemory.d.ts +50 -0
- package/dist/notificationfunctions/dbmemory.js +132 -0
- package/dist/notificationfunctions/fs.d.ts +125 -0
- package/dist/notificationfunctions/fs.js +472 -0
- package/dist/notificationfunctions/git.d.ts +174 -0
- package/dist/notificationfunctions/git.js +521 -0
- package/dist/notificationfunctions/history.d.ts +38 -0
- package/dist/notificationfunctions/history.js +97 -0
- package/dist/notificationfunctions/index.d.ts +79 -0
- package/dist/notificationfunctions/index.js +102 -0
- package/dist/notificationfunctions/llm.d.ts +39 -0
- package/dist/notificationfunctions/llm.js +99 -0
- package/dist/notificationfunctions/mcp.d.ts +67 -0
- package/dist/notificationfunctions/mcp.js +192 -0
- package/dist/notificationfunctions/search.d.ts +50 -0
- package/dist/notificationfunctions/search.js +146 -0
- package/dist/notificationfunctions/system.d.ts +25 -0
- package/dist/notificationfunctions/system.js +59 -0
- package/dist/notificationfunctions/terminal.d.ts +26 -0
- package/dist/notificationfunctions/terminal.js +64 -0
- package/dist/notificationfunctions/todo.d.ts +63 -0
- package/dist/notificationfunctions/todo.js +164 -0
- package/dist/notificationfunctions/utils.d.ts +81 -0
- package/dist/notificationfunctions/utils.js +177 -0
- package/dist/types/InternalTypes.d.ts +1 -0
- package/dist/types/commonTypes.d.ts +26 -3
- package/dist/types/index.d.ts +2 -2
- package/dist/types/libFunctionTypes.d.ts +80 -3
- package/dist/types/notificationFunctions/agent.d.ts +8 -0
- package/dist/types/notificationFunctions/agent.js +2 -0
- package/dist/types/notificationFunctions/browser.d.ts +10 -0
- package/dist/types/notificationFunctions/browser.js +2 -0
- package/dist/types/notificationFunctions/chat.d.ts +10 -0
- package/dist/types/notificationFunctions/chat.js +2 -0
- package/dist/types/notificationFunctions/codeutils.d.ts +10 -0
- package/dist/types/notificationFunctions/codeutils.js +2 -0
- package/dist/types/notificationFunctions/crawler.d.ts +10 -0
- package/dist/types/notificationFunctions/crawler.js +2 -0
- package/dist/types/notificationFunctions/dbmemory.d.ts +9 -0
- package/dist/types/notificationFunctions/dbmemory.js +2 -0
- package/dist/types/notificationFunctions/fs.d.ts +27 -0
- package/dist/types/notificationFunctions/fs.js +2 -0
- package/dist/types/notificationFunctions/git.d.ts +29 -0
- package/dist/types/notificationFunctions/git.js +2 -0
- package/dist/types/notificationFunctions/history.d.ts +10 -0
- package/dist/types/notificationFunctions/history.js +2 -0
- package/dist/types/notificationFunctions/index.d.ts +0 -0
- package/dist/types/notificationFunctions/index.js +1 -0
- package/dist/types/notificationFunctions/llm.d.ts +10 -0
- package/dist/types/notificationFunctions/llm.js +2 -0
- package/dist/types/notificationFunctions/mcp.d.ts +16 -0
- package/dist/types/notificationFunctions/mcp.js +2 -0
- package/dist/types/notificationFunctions/search.d.ts +11 -0
- package/dist/types/notificationFunctions/search.js +2 -0
- package/dist/types/notificationFunctions/system.d.ts +7 -0
- package/dist/types/notificationFunctions/system.js +2 -0
- package/dist/types/notificationFunctions/terminal.d.ts +7 -0
- package/dist/types/notificationFunctions/terminal.js +2 -0
- package/dist/types/notificationFunctions/todo.d.ts +11 -0
- package/dist/types/notificationFunctions/todo.js +2 -0
- package/dist/types/notifications/agent.d.ts +31 -0
- package/dist/types/notifications/agent.js +3 -0
- package/dist/types/notifications/browser.d.ts +53 -0
- package/dist/types/notifications/browser.js +3 -0
- package/dist/types/notifications/chat.d.ts +37 -0
- package/dist/types/notifications/chat.js +3 -0
- package/dist/types/notifications/codeutils.d.ts +55 -0
- package/dist/types/notifications/codeutils.js +3 -0
- package/dist/types/notifications/crawler.d.ts +55 -0
- package/dist/types/notifications/crawler.js +3 -0
- package/dist/types/notifications/dbmemory.d.ts +31 -0
- package/dist/types/notifications/dbmemory.js +3 -0
- package/dist/types/notifications/fs.d.ts +180 -0
- package/dist/types/notifications/fs.js +3 -0
- package/dist/types/notifications/git.d.ts +205 -0
- package/dist/types/notifications/git.js +3 -0
- package/dist/types/notifications/history.d.ts +32 -0
- package/dist/types/notifications/history.js +3 -0
- package/dist/types/notifications/llm.d.ts +45 -0
- package/dist/types/notifications/llm.js +2 -0
- package/dist/types/notifications/mcp.d.ts +63 -0
- package/dist/types/notifications/mcp.js +3 -0
- package/dist/types/notifications/search.d.ts +47 -0
- package/dist/types/notifications/search.js +3 -0
- package/dist/types/notifications/system.d.ts +20 -0
- package/dist/types/notifications/system.js +2 -0
- package/dist/types/notifications/terminal.d.ts +17 -0
- package/dist/types/notifications/terminal.js +2 -0
- package/dist/types/notifications/todo.d.ts +60 -0
- package/dist/types/notifications/todo.js +3 -0
- package/dist/types/socketMessageTypes.d.ts +3 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification Functions Module
|
|
3
|
+
*
|
|
4
|
+
* This module provides wrapper functions for all notification types defined in the
|
|
5
|
+
* src/types/notifications directory. It allows users to send various types of
|
|
6
|
+
* notifications through the WebSocket connection to the Codebolt application.
|
|
7
|
+
*
|
|
8
|
+
* The notification system covers 15 different categories:
|
|
9
|
+
* - agent: Subagent task operations and completions
|
|
10
|
+
* - browser: Web fetch and search operations
|
|
11
|
+
* - chat: User messages and agent responses
|
|
12
|
+
* - codeutils: Search operations and results
|
|
13
|
+
* - crawler: Web crawling and search operations
|
|
14
|
+
* - dbmemory: Knowledge storage and retrieval operations
|
|
15
|
+
* - fs: File and folder operations
|
|
16
|
+
* - git: Version control operations
|
|
17
|
+
* - history: Conversation summarization operations
|
|
18
|
+
* - llm: Inference requests and token counting operations
|
|
19
|
+
* - mcp: MCP server operations and tool executions
|
|
20
|
+
* - search: Search initialization and query operations
|
|
21
|
+
* - system: Agent initialization and completion states
|
|
22
|
+
* - terminal: Command execution operations
|
|
23
|
+
* - todo: Task operations and lifecycle
|
|
24
|
+
*/
|
|
25
|
+
export * from './utils';
|
|
26
|
+
export { NotificationError, NotificationErrorCodes } from './utils';
|
|
27
|
+
export * from './agent';
|
|
28
|
+
export * from './browser';
|
|
29
|
+
export * from './chat';
|
|
30
|
+
export * from './codeutils';
|
|
31
|
+
export * from './crawler';
|
|
32
|
+
export * from './dbmemory';
|
|
33
|
+
export * from './fs';
|
|
34
|
+
export * from './git';
|
|
35
|
+
export * from './history';
|
|
36
|
+
export * from './llm';
|
|
37
|
+
export * from './mcp';
|
|
38
|
+
export * from './search';
|
|
39
|
+
export * from './system';
|
|
40
|
+
export * from './terminal';
|
|
41
|
+
export * from './todo';
|
|
42
|
+
import { type AgentNotifications } from '../types/notificationFunctions/agent';
|
|
43
|
+
import { type BrowserNotifications } from '../types/notificationFunctions/browser';
|
|
44
|
+
import { type ChatNotifications } from '../types/notificationFunctions/chat';
|
|
45
|
+
import { type CodeutilsNotifications } from '../types/notificationFunctions/codeutils';
|
|
46
|
+
import { type CrawlerNotifications } from '../types/notificationFunctions/crawler';
|
|
47
|
+
import { type DbmemoryNotifications } from '../types/notificationFunctions/dbmemory';
|
|
48
|
+
import { type FsNotifications } from '../types/notificationFunctions/fs';
|
|
49
|
+
import { type GitNotifications } from '../types/notificationFunctions/git';
|
|
50
|
+
import { type HistoryNotifications } from '../types/notificationFunctions/history';
|
|
51
|
+
import { type LlmNotifications } from '../types/notificationFunctions/llm';
|
|
52
|
+
import { type McpNotifications } from '../types/notificationFunctions/mcp';
|
|
53
|
+
import { type SearchNotifications } from '../types/notificationFunctions/search';
|
|
54
|
+
import { type SystemNotifications } from '../types/notificationFunctions/system';
|
|
55
|
+
import { type TerminalNotifications } from '../types/notificationFunctions/terminal';
|
|
56
|
+
import { type TodoNotifications } from '../types/notificationFunctions/todo';
|
|
57
|
+
export interface NotificationFunctions {
|
|
58
|
+
agent: AgentNotifications;
|
|
59
|
+
browser: BrowserNotifications;
|
|
60
|
+
chat: ChatNotifications;
|
|
61
|
+
codeutils: CodeutilsNotifications;
|
|
62
|
+
crawler: CrawlerNotifications;
|
|
63
|
+
dbmemory: DbmemoryNotifications;
|
|
64
|
+
fs: FsNotifications;
|
|
65
|
+
git: GitNotifications;
|
|
66
|
+
history: HistoryNotifications;
|
|
67
|
+
llm: LlmNotifications;
|
|
68
|
+
mcp: McpNotifications;
|
|
69
|
+
search: SearchNotifications;
|
|
70
|
+
system: SystemNotifications;
|
|
71
|
+
terminal: TerminalNotifications;
|
|
72
|
+
todo: TodoNotifications;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Complete notification functions object
|
|
76
|
+
* This object contains all notification functions organized by category
|
|
77
|
+
*/
|
|
78
|
+
export declare const notificationFunctions: NotificationFunctions;
|
|
79
|
+
export default notificationFunctions;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Notification Functions Module
|
|
4
|
+
*
|
|
5
|
+
* This module provides wrapper functions for all notification types defined in the
|
|
6
|
+
* src/types/notifications directory. It allows users to send various types of
|
|
7
|
+
* notifications through the WebSocket connection to the Codebolt application.
|
|
8
|
+
*
|
|
9
|
+
* The notification system covers 15 different categories:
|
|
10
|
+
* - agent: Subagent task operations and completions
|
|
11
|
+
* - browser: Web fetch and search operations
|
|
12
|
+
* - chat: User messages and agent responses
|
|
13
|
+
* - codeutils: Search operations and results
|
|
14
|
+
* - crawler: Web crawling and search operations
|
|
15
|
+
* - dbmemory: Knowledge storage and retrieval operations
|
|
16
|
+
* - fs: File and folder operations
|
|
17
|
+
* - git: Version control operations
|
|
18
|
+
* - history: Conversation summarization operations
|
|
19
|
+
* - llm: Inference requests and token counting operations
|
|
20
|
+
* - mcp: MCP server operations and tool executions
|
|
21
|
+
* - search: Search initialization and query operations
|
|
22
|
+
* - system: Agent initialization and completion states
|
|
23
|
+
* - terminal: Command execution operations
|
|
24
|
+
* - todo: Task operations and lifecycle
|
|
25
|
+
*/
|
|
26
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
27
|
+
if (k2 === undefined) k2 = k;
|
|
28
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
29
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
30
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(o, k2, desc);
|
|
33
|
+
}) : (function(o, m, k, k2) {
|
|
34
|
+
if (k2 === undefined) k2 = k;
|
|
35
|
+
o[k2] = m[k];
|
|
36
|
+
}));
|
|
37
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
38
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.notificationFunctions = exports.NotificationErrorCodes = exports.NotificationError = void 0;
|
|
42
|
+
// Export utilities for advanced usage
|
|
43
|
+
__exportStar(require("./utils"), exports);
|
|
44
|
+
// Export error types
|
|
45
|
+
var utils_1 = require("./utils");
|
|
46
|
+
Object.defineProperty(exports, "NotificationError", { enumerable: true, get: function () { return utils_1.NotificationError; } });
|
|
47
|
+
Object.defineProperty(exports, "NotificationErrorCodes", { enumerable: true, get: function () { return utils_1.NotificationErrorCodes; } });
|
|
48
|
+
// Export all notification functions and types
|
|
49
|
+
__exportStar(require("./agent"), exports);
|
|
50
|
+
__exportStar(require("./browser"), exports);
|
|
51
|
+
__exportStar(require("./chat"), exports);
|
|
52
|
+
__exportStar(require("./codeutils"), exports);
|
|
53
|
+
__exportStar(require("./crawler"), exports);
|
|
54
|
+
__exportStar(require("./dbmemory"), exports);
|
|
55
|
+
__exportStar(require("./fs"), exports);
|
|
56
|
+
__exportStar(require("./git"), exports);
|
|
57
|
+
__exportStar(require("./history"), exports);
|
|
58
|
+
__exportStar(require("./llm"), exports);
|
|
59
|
+
__exportStar(require("./mcp"), exports);
|
|
60
|
+
__exportStar(require("./search"), exports);
|
|
61
|
+
__exportStar(require("./system"), exports);
|
|
62
|
+
__exportStar(require("./terminal"), exports);
|
|
63
|
+
__exportStar(require("./todo"), exports);
|
|
64
|
+
// Import notification objects
|
|
65
|
+
const agent_1 = require("./agent");
|
|
66
|
+
const browser_1 = require("./browser");
|
|
67
|
+
const chat_1 = require("./chat");
|
|
68
|
+
const codeutils_1 = require("./codeutils");
|
|
69
|
+
const crawler_1 = require("./crawler");
|
|
70
|
+
const dbmemory_1 = require("./dbmemory");
|
|
71
|
+
const fs_1 = require("./fs");
|
|
72
|
+
const git_1 = require("./git");
|
|
73
|
+
const history_1 = require("./history");
|
|
74
|
+
const llm_1 = require("./llm");
|
|
75
|
+
const mcp_1 = require("./mcp");
|
|
76
|
+
const search_1 = require("./search");
|
|
77
|
+
const system_1 = require("./system");
|
|
78
|
+
const terminal_1 = require("./terminal");
|
|
79
|
+
const todo_1 = require("./todo");
|
|
80
|
+
/**
|
|
81
|
+
* Complete notification functions object
|
|
82
|
+
* This object contains all notification functions organized by category
|
|
83
|
+
*/
|
|
84
|
+
exports.notificationFunctions = {
|
|
85
|
+
agent: agent_1.agentNotifications,
|
|
86
|
+
browser: browser_1.browserNotifications,
|
|
87
|
+
chat: chat_1.chatNotifications,
|
|
88
|
+
codeutils: codeutils_1.codeutilsNotifications,
|
|
89
|
+
crawler: crawler_1.crawlerNotifications,
|
|
90
|
+
dbmemory: dbmemory_1.dbmemoryNotifications,
|
|
91
|
+
fs: fs_1.fsNotifications,
|
|
92
|
+
git: git_1.gitNotifications,
|
|
93
|
+
history: history_1.historyNotifications,
|
|
94
|
+
llm: llm_1.llmNotifications,
|
|
95
|
+
mcp: mcp_1.mcpNotifications,
|
|
96
|
+
search: search_1.searchNotifications,
|
|
97
|
+
system: system_1.systemNotifications,
|
|
98
|
+
terminal: terminal_1.terminalNotifications,
|
|
99
|
+
todo: todo_1.todoNotifications
|
|
100
|
+
};
|
|
101
|
+
// Default export for the notification functions
|
|
102
|
+
exports.default = exports.notificationFunctions;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Notification Functions
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions for sending LLM-related notifications,
|
|
5
|
+
* including inference requests and token counting operations.
|
|
6
|
+
*/
|
|
7
|
+
import { LLMRequestNotification, LLMGetTokenCountRequestNotification, LLMGetTokenCountResponseNotification } from '../types/notifications/llm';
|
|
8
|
+
import { LlmNotifications } from '../types/notificationFunctions/llm';
|
|
9
|
+
/**
|
|
10
|
+
* Sends an LLM inference request notification
|
|
11
|
+
* @param data - LLM inference data containing messages, tools, and other parameters
|
|
12
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
13
|
+
*/
|
|
14
|
+
export declare function sendInferenceRequest(data: LLMRequestNotification['data'], toolUseId?: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Sends an LLM inference response notification
|
|
17
|
+
* @param content - The inference result or error details
|
|
18
|
+
* @param isError - Whether this is an error response
|
|
19
|
+
* @param toolUseId - The toolUseId from the original request
|
|
20
|
+
*/
|
|
21
|
+
export declare function sendInferenceResponse(content: string | any, isError?: boolean, toolUseId?: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Sends an LLM get token count request notification
|
|
24
|
+
* @param data - Token count request data containing text and optional model/encoding
|
|
25
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
26
|
+
*/
|
|
27
|
+
export declare function getTokenCount(data: LLMGetTokenCountRequestNotification['data'], toolUseId?: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Sends an LLM get token count response notification
|
|
30
|
+
* @param content - The token count result or error details
|
|
31
|
+
* @param isError - Whether this is an error response
|
|
32
|
+
* @param toolUseId - The toolUseId from the original request
|
|
33
|
+
* @param data - Optional additional data containing token count details
|
|
34
|
+
*/
|
|
35
|
+
export declare function sendTokenCountResponse(content: string | any, isError?: boolean, toolUseId?: string, data?: LLMGetTokenCountResponseNotification['data']): void;
|
|
36
|
+
/**
|
|
37
|
+
* LLM notification functions object
|
|
38
|
+
*/
|
|
39
|
+
export declare const llmNotifications: LlmNotifications;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LLM Notification Functions
|
|
4
|
+
*
|
|
5
|
+
* This module provides functions for sending LLM-related notifications,
|
|
6
|
+
* including inference requests and token counting operations.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.llmNotifications = exports.sendTokenCountResponse = exports.getTokenCount = exports.sendInferenceResponse = exports.sendInferenceRequest = void 0;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
// ===== LLM INFERENCE FUNCTIONS =====
|
|
12
|
+
/**
|
|
13
|
+
* Sends an LLM inference request notification
|
|
14
|
+
* @param data - LLM inference data containing messages, tools, and other parameters
|
|
15
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
16
|
+
*/
|
|
17
|
+
function sendInferenceRequest(data, toolUseId) {
|
|
18
|
+
const notification = {
|
|
19
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
20
|
+
type: "llmnotify",
|
|
21
|
+
action: "inferenceRequest",
|
|
22
|
+
data
|
|
23
|
+
};
|
|
24
|
+
(0, utils_1.sendNotification)(notification, 'llm-inference-request');
|
|
25
|
+
}
|
|
26
|
+
exports.sendInferenceRequest = sendInferenceRequest;
|
|
27
|
+
/**
|
|
28
|
+
* Sends an LLM inference response notification
|
|
29
|
+
* @param content - The inference result or error details
|
|
30
|
+
* @param isError - Whether this is an error response
|
|
31
|
+
* @param toolUseId - The toolUseId from the original request
|
|
32
|
+
*/
|
|
33
|
+
function sendInferenceResponse(content, isError = false, toolUseId) {
|
|
34
|
+
if (!toolUseId) {
|
|
35
|
+
console.error('[LlmNotifications] toolUseId is required for response notifications');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const notification = {
|
|
39
|
+
toolUseId,
|
|
40
|
+
type: "llmnotify",
|
|
41
|
+
action: "inferenceResult",
|
|
42
|
+
content,
|
|
43
|
+
isError
|
|
44
|
+
};
|
|
45
|
+
(0, utils_1.sendNotification)(notification, 'llm-inference-response');
|
|
46
|
+
}
|
|
47
|
+
exports.sendInferenceResponse = sendInferenceResponse;
|
|
48
|
+
// ===== LLM TOKEN COUNT FUNCTIONS =====
|
|
49
|
+
/**
|
|
50
|
+
* Sends an LLM get token count request notification
|
|
51
|
+
* @param data - Token count request data containing text and optional model/encoding
|
|
52
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
53
|
+
*/
|
|
54
|
+
function getTokenCount(data, toolUseId) {
|
|
55
|
+
// Validate required fields
|
|
56
|
+
if (!(0, utils_1.validateRequiredFields)(data, ['text'], 'llm-token-count')) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const notification = {
|
|
60
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
61
|
+
type: "llmnotify",
|
|
62
|
+
action: "getTokenCountRequest",
|
|
63
|
+
data
|
|
64
|
+
};
|
|
65
|
+
(0, utils_1.sendNotification)(notification, 'llm-token-count-request');
|
|
66
|
+
}
|
|
67
|
+
exports.getTokenCount = getTokenCount;
|
|
68
|
+
/**
|
|
69
|
+
* Sends an LLM get token count response notification
|
|
70
|
+
* @param content - The token count result or error details
|
|
71
|
+
* @param isError - Whether this is an error response
|
|
72
|
+
* @param toolUseId - The toolUseId from the original request
|
|
73
|
+
* @param data - Optional additional data containing token count details
|
|
74
|
+
*/
|
|
75
|
+
function sendTokenCountResponse(content, isError = false, toolUseId, data) {
|
|
76
|
+
if (!toolUseId) {
|
|
77
|
+
console.error('[LlmNotifications] toolUseId is required for response notifications');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const notification = {
|
|
81
|
+
toolUseId,
|
|
82
|
+
type: "llmnotify",
|
|
83
|
+
action: "getTokenCountResult",
|
|
84
|
+
content,
|
|
85
|
+
isError,
|
|
86
|
+
...(data && { data })
|
|
87
|
+
};
|
|
88
|
+
(0, utils_1.sendNotification)(notification, 'llm-token-count-response');
|
|
89
|
+
}
|
|
90
|
+
exports.sendTokenCountResponse = sendTokenCountResponse;
|
|
91
|
+
/**
|
|
92
|
+
* LLM notification functions object
|
|
93
|
+
*/
|
|
94
|
+
exports.llmNotifications = {
|
|
95
|
+
sendInferenceRequest,
|
|
96
|
+
sendInferenceResponse,
|
|
97
|
+
getTokenCount,
|
|
98
|
+
sendTokenCountResponse
|
|
99
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Notification Functions
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions for sending MCP-related notifications,
|
|
5
|
+
* including MCP server operations and tool executions.
|
|
6
|
+
*/
|
|
7
|
+
import { McpNotifications } from '../types/notificationFunctions/mcp';
|
|
8
|
+
/**
|
|
9
|
+
* Sends a get enabled MCP servers request notification
|
|
10
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
11
|
+
*/
|
|
12
|
+
export declare function GetEnabledMCPServersRequestNotify(toolUseId?: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Sends a get enabled MCP servers result notification
|
|
15
|
+
* @param content - The result content or error details
|
|
16
|
+
* @param isError - Whether this is an error response
|
|
17
|
+
* @param toolUseId - The toolUseId from the original request
|
|
18
|
+
*/
|
|
19
|
+
export declare function GetEnabledMCPServersResultNotify(content: string | any, isError?: boolean, toolUseId?: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Sends a list tools from MCP servers request notification
|
|
22
|
+
* @param toolboxes - Array of toolbox names to list tools from
|
|
23
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
24
|
+
*/
|
|
25
|
+
export declare function ListToolsFromMCPServersRequestNotify(toolboxes: string[], toolUseId?: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Sends a list tools from MCP servers result notification
|
|
28
|
+
* @param content - The result content or error details
|
|
29
|
+
* @param isError - Whether this is an error response
|
|
30
|
+
* @param toolUseId - The toolUseId from the original request
|
|
31
|
+
*/
|
|
32
|
+
export declare function ListToolsFromMCPServersResultNotify(content: string | any, isError?: boolean, toolUseId?: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Sends a get tools request notification
|
|
35
|
+
* @param tools - Array of tools with toolbox and toolName
|
|
36
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
37
|
+
*/
|
|
38
|
+
export declare function GetToolsRequestNotify(tools: {
|
|
39
|
+
toolbox: string;
|
|
40
|
+
toolName: string;
|
|
41
|
+
}[], toolUseId?: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Sends a get tools result notification
|
|
44
|
+
* @param content - The result content or error details
|
|
45
|
+
* @param isError - Whether this is an error response
|
|
46
|
+
* @param toolUseId - The toolUseId from the original request
|
|
47
|
+
*/
|
|
48
|
+
export declare function GetToolsResultNotify(content: string | any, isError?: boolean, toolUseId?: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Sends an execute tool request notification
|
|
51
|
+
* @param toolbox - The toolbox name
|
|
52
|
+
* @param toolName - The tool name to execute
|
|
53
|
+
* @param params - The parameters for the tool execution
|
|
54
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
55
|
+
*/
|
|
56
|
+
export declare function ExecuteToolRequestNotify(toolbox: string, toolName: string, params: any, toolUseId?: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Sends an execute tool result notification
|
|
59
|
+
* @param content - The result content or error details
|
|
60
|
+
* @param isError - Whether this is an error response
|
|
61
|
+
* @param toolUseId - The toolUseId from the original request
|
|
62
|
+
*/
|
|
63
|
+
export declare function ExecuteToolResultNotify(content: string | any, isError?: boolean, toolUseId?: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* MCP notification functions object
|
|
66
|
+
*/
|
|
67
|
+
export declare const mcpNotifications: McpNotifications;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP Notification Functions
|
|
4
|
+
*
|
|
5
|
+
* This module provides functions for sending MCP-related notifications,
|
|
6
|
+
* including MCP server operations and tool executions.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.mcpNotifications = exports.ExecuteToolResultNotify = exports.ExecuteToolRequestNotify = exports.GetToolsResultNotify = exports.GetToolsRequestNotify = exports.ListToolsFromMCPServersResultNotify = exports.ListToolsFromMCPServersRequestNotify = exports.GetEnabledMCPServersResultNotify = exports.GetEnabledMCPServersRequestNotify = void 0;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
// ===== GET ENABLED MCP SERVERS FUNCTIONS =====
|
|
12
|
+
/**
|
|
13
|
+
* Sends a get enabled MCP servers request notification
|
|
14
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
15
|
+
*/
|
|
16
|
+
function GetEnabledMCPServersRequestNotify(toolUseId) {
|
|
17
|
+
const notification = {
|
|
18
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
19
|
+
type: "mcpnotify",
|
|
20
|
+
action: "getEnabledMCPServersRequest",
|
|
21
|
+
data: {}
|
|
22
|
+
};
|
|
23
|
+
(0, utils_1.sendNotification)(notification, 'mcp-get-enabled-servers');
|
|
24
|
+
}
|
|
25
|
+
exports.GetEnabledMCPServersRequestNotify = GetEnabledMCPServersRequestNotify;
|
|
26
|
+
/**
|
|
27
|
+
* Sends a get enabled MCP servers result notification
|
|
28
|
+
* @param content - The result content or error details
|
|
29
|
+
* @param isError - Whether this is an error response
|
|
30
|
+
* @param toolUseId - The toolUseId from the original request
|
|
31
|
+
*/
|
|
32
|
+
function GetEnabledMCPServersResultNotify(content, isError = false, toolUseId) {
|
|
33
|
+
if (!toolUseId) {
|
|
34
|
+
console.error('[McpNotifications] toolUseId is required for response notifications');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const notification = {
|
|
38
|
+
toolUseId,
|
|
39
|
+
type: "mcpnotify",
|
|
40
|
+
action: "getEnabledMCPServersResult",
|
|
41
|
+
content,
|
|
42
|
+
isError
|
|
43
|
+
};
|
|
44
|
+
(0, utils_1.sendNotification)(notification, 'mcp-get-enabled-servers-result');
|
|
45
|
+
}
|
|
46
|
+
exports.GetEnabledMCPServersResultNotify = GetEnabledMCPServersResultNotify;
|
|
47
|
+
// ===== LIST TOOLS FROM MCP SERVERS FUNCTIONS =====
|
|
48
|
+
/**
|
|
49
|
+
* Sends a list tools from MCP servers request notification
|
|
50
|
+
* @param toolboxes - Array of toolbox names to list tools from
|
|
51
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
52
|
+
*/
|
|
53
|
+
function ListToolsFromMCPServersRequestNotify(toolboxes, toolUseId) {
|
|
54
|
+
// Validate required fields
|
|
55
|
+
if (!(0, utils_1.validateRequiredFields)({ toolboxes }, ['toolboxes'], 'mcp-list-tools')) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const notification = {
|
|
59
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
60
|
+
type: "mcpnotify",
|
|
61
|
+
action: "listToolsFromMCPServersRequest",
|
|
62
|
+
data: {
|
|
63
|
+
toolboxes: toolboxes
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
(0, utils_1.sendNotification)(notification, 'mcp-list-tools');
|
|
67
|
+
}
|
|
68
|
+
exports.ListToolsFromMCPServersRequestNotify = ListToolsFromMCPServersRequestNotify;
|
|
69
|
+
/**
|
|
70
|
+
* Sends a list tools from MCP servers result notification
|
|
71
|
+
* @param content - The result content or error details
|
|
72
|
+
* @param isError - Whether this is an error response
|
|
73
|
+
* @param toolUseId - The toolUseId from the original request
|
|
74
|
+
*/
|
|
75
|
+
function ListToolsFromMCPServersResultNotify(content, isError = false, toolUseId) {
|
|
76
|
+
if (!toolUseId) {
|
|
77
|
+
console.error('[McpNotifications] toolUseId is required for response notifications');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const notification = {
|
|
81
|
+
toolUseId,
|
|
82
|
+
type: "mcpnotify",
|
|
83
|
+
action: "listToolsFromMCPServersResult",
|
|
84
|
+
content,
|
|
85
|
+
isError
|
|
86
|
+
};
|
|
87
|
+
(0, utils_1.sendNotification)(notification, 'mcp-list-tools-result');
|
|
88
|
+
}
|
|
89
|
+
exports.ListToolsFromMCPServersResultNotify = ListToolsFromMCPServersResultNotify;
|
|
90
|
+
// ===== GET TOOLS FUNCTIONS =====
|
|
91
|
+
/**
|
|
92
|
+
* Sends a get tools request notification
|
|
93
|
+
* @param tools - Array of tools with toolbox and toolName
|
|
94
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
95
|
+
*/
|
|
96
|
+
function GetToolsRequestNotify(tools, toolUseId) {
|
|
97
|
+
// Validate required fields
|
|
98
|
+
if (!(0, utils_1.validateRequiredFields)({ tools }, ['tools'], 'mcp-get-tools')) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const notification = {
|
|
102
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
103
|
+
type: "mcpnotify",
|
|
104
|
+
action: "getToolsRequest",
|
|
105
|
+
data: {
|
|
106
|
+
tools: tools
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
(0, utils_1.sendNotification)(notification, 'mcp-get-tools');
|
|
110
|
+
}
|
|
111
|
+
exports.GetToolsRequestNotify = GetToolsRequestNotify;
|
|
112
|
+
/**
|
|
113
|
+
* Sends a get tools result notification
|
|
114
|
+
* @param content - The result content or error details
|
|
115
|
+
* @param isError - Whether this is an error response
|
|
116
|
+
* @param toolUseId - The toolUseId from the original request
|
|
117
|
+
*/
|
|
118
|
+
function GetToolsResultNotify(content, isError = false, toolUseId) {
|
|
119
|
+
if (!toolUseId) {
|
|
120
|
+
console.error('[McpNotifications] toolUseId is required for response notifications');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const notification = {
|
|
124
|
+
toolUseId,
|
|
125
|
+
type: "mcpnotify",
|
|
126
|
+
action: "getToolsResult",
|
|
127
|
+
content,
|
|
128
|
+
isError
|
|
129
|
+
};
|
|
130
|
+
(0, utils_1.sendNotification)(notification, 'mcp-get-tools-result');
|
|
131
|
+
}
|
|
132
|
+
exports.GetToolsResultNotify = GetToolsResultNotify;
|
|
133
|
+
// ===== EXECUTE TOOL FUNCTIONS =====
|
|
134
|
+
/**
|
|
135
|
+
* Sends an execute tool request notification
|
|
136
|
+
* @param toolbox - The toolbox name
|
|
137
|
+
* @param toolName - The tool name to execute
|
|
138
|
+
* @param params - The parameters for the tool execution
|
|
139
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
140
|
+
*/
|
|
141
|
+
function ExecuteToolRequestNotify(toolbox, toolName, params, toolUseId) {
|
|
142
|
+
// Validate required fields
|
|
143
|
+
if (!(0, utils_1.validateRequiredFields)({ toolbox, toolName, params }, ['toolbox', 'toolName', 'params'], 'mcp-execute-tool')) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const notification = {
|
|
147
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
148
|
+
type: "mcpnotify",
|
|
149
|
+
action: "executeToolRequest",
|
|
150
|
+
data: {
|
|
151
|
+
toolbox: toolbox,
|
|
152
|
+
toolName: toolName,
|
|
153
|
+
params: params
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
(0, utils_1.sendNotification)(notification, 'mcp-execute-tool');
|
|
157
|
+
}
|
|
158
|
+
exports.ExecuteToolRequestNotify = ExecuteToolRequestNotify;
|
|
159
|
+
/**
|
|
160
|
+
* Sends an execute tool result notification
|
|
161
|
+
* @param content - The result content or error details
|
|
162
|
+
* @param isError - Whether this is an error response
|
|
163
|
+
* @param toolUseId - The toolUseId from the original request
|
|
164
|
+
*/
|
|
165
|
+
function ExecuteToolResultNotify(content, isError = false, toolUseId) {
|
|
166
|
+
if (!toolUseId) {
|
|
167
|
+
console.error('[McpNotifications] toolUseId is required for response notifications');
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const notification = {
|
|
171
|
+
toolUseId,
|
|
172
|
+
type: "mcpnotify",
|
|
173
|
+
action: "executeToolResult",
|
|
174
|
+
content,
|
|
175
|
+
isError
|
|
176
|
+
};
|
|
177
|
+
(0, utils_1.sendNotification)(notification, 'mcp-execute-tool-result');
|
|
178
|
+
}
|
|
179
|
+
exports.ExecuteToolResultNotify = ExecuteToolResultNotify;
|
|
180
|
+
/**
|
|
181
|
+
* MCP notification functions object
|
|
182
|
+
*/
|
|
183
|
+
exports.mcpNotifications = {
|
|
184
|
+
GetEnabledMCPServersRequestNotify,
|
|
185
|
+
GetEnabledMCPServersResultNotify,
|
|
186
|
+
ListToolsFromMCPServersRequestNotify,
|
|
187
|
+
ListToolsFromMCPServersResultNotify,
|
|
188
|
+
GetToolsRequestNotify,
|
|
189
|
+
GetToolsResultNotify,
|
|
190
|
+
ExecuteToolRequestNotify,
|
|
191
|
+
ExecuteToolResultNotify
|
|
192
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search Notification Functions
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions for sending search-related notifications,
|
|
5
|
+
* including search initialization and query operations.
|
|
6
|
+
*/
|
|
7
|
+
import { SearchNotifications } from '../types/notificationFunctions/search';
|
|
8
|
+
/**
|
|
9
|
+
* Sends a search init request notification
|
|
10
|
+
* @param engine - Optional search engine to initialize
|
|
11
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
12
|
+
*/
|
|
13
|
+
export declare function SearchInitRequestNotify(engine?: string, toolUseId?: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Sends a search init result notification
|
|
16
|
+
* @param content - The result content or error details
|
|
17
|
+
* @param isError - Whether this is an error response
|
|
18
|
+
* @param toolUseId - The toolUseId from the original request
|
|
19
|
+
*/
|
|
20
|
+
export declare function SearchInitResultNotify(content: string | any, isError?: boolean, toolUseId?: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Sends a search request notification
|
|
23
|
+
* @param query - The search query string
|
|
24
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
25
|
+
*/
|
|
26
|
+
export declare function SearchRequestNotify(query: string, toolUseId?: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Sends a search result notification
|
|
29
|
+
* @param content - The search result content or error details
|
|
30
|
+
* @param isError - Whether this is an error response
|
|
31
|
+
* @param toolUseId - The toolUseId from the original request
|
|
32
|
+
*/
|
|
33
|
+
export declare function SearchResultNotify(content: string | any, isError?: boolean, toolUseId?: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Sends a get first link request notification
|
|
36
|
+
* @param query - The search query to get the first link for
|
|
37
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
38
|
+
*/
|
|
39
|
+
export declare function GetFirstLinkRequestNotify(query: string, toolUseId?: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Sends a get first link result notification
|
|
42
|
+
* @param content - The first link result content or error details
|
|
43
|
+
* @param isError - Whether this is an error response
|
|
44
|
+
* @param toolUseId - The toolUseId from the original request
|
|
45
|
+
*/
|
|
46
|
+
export declare function GetFirstLinkResultNotify(content: string | any, isError?: boolean, toolUseId?: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Search notification functions object
|
|
49
|
+
*/
|
|
50
|
+
export declare const searchNotifications: SearchNotifications;
|