@protoboxai/sdk 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/README.md +51 -0
- package/dist/adapters/openai.d.ts +106 -0
- package/dist/adapters/openai.js +185 -0
- package/dist/client.d.ts +60 -0
- package/dist/client.js +307 -0
- package/dist/errors/index.d.ts +179 -0
- package/dist/errors/index.js +319 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +62 -0
- package/dist/live/index.d.ts +5 -0
- package/dist/live/index.js +10 -0
- package/dist/live/live-chat.d.ts +71 -0
- package/dist/live/live-chat.js +95 -0
- package/dist/live/typed-emitter.d.ts +15 -0
- package/dist/live/typed-emitter.js +40 -0
- package/dist/live/types.d.ts +24 -0
- package/dist/live/types.js +6 -0
- package/dist/modules/auth.d.ts +76 -0
- package/dist/modules/auth.js +59 -0
- package/dist/modules/chat.d.ts +164 -0
- package/dist/modules/chat.js +168 -0
- package/dist/modules/health.d.ts +45 -0
- package/dist/modules/health.js +22 -0
- package/dist/modules/knowledge.d.ts +202 -0
- package/dist/modules/knowledge.js +147 -0
- package/dist/modules/mcp.d.ts +138 -0
- package/dist/modules/mcp.js +110 -0
- package/dist/modules/prompts.d.ts +128 -0
- package/dist/modules/prompts.js +93 -0
- package/dist/modules/tools.d.ts +222 -0
- package/dist/modules/tools.js +302 -0
- package/dist/modules/toolsets.d.ts +173 -0
- package/dist/modules/toolsets.js +216 -0
- package/dist/modules/workspace.d.ts +48 -0
- package/dist/modules/workspace.js +49 -0
- package/dist/types/api.d.ts +4 -0
- package/dist/types/api.js +21 -0
- package/dist/types/config.d.ts +81 -0
- package/dist/types/config.js +3 -0
- package/dist/types/tool-calls.d.ts +60 -0
- package/dist/types/tool-calls.js +8 -0
- package/dist/types/tools.d.ts +321 -0
- package/dist/types/tools.js +9 -0
- package/dist/types/toolsets.d.ts +151 -0
- package/dist/types/toolsets.js +8 -0
- package/package.json +52 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { ChanlSDK } from "../client";
|
|
2
|
+
import { ApiResponse } from "../types/config";
|
|
3
|
+
export type KnowledgeSource = "text" | "url" | "file" | "manual" | "document" | "faq" | "api_docs" | "transcript";
|
|
4
|
+
export type ProcessingStatus = "pending" | "processing" | "completed" | "failed";
|
|
5
|
+
export interface KnowledgeMetadata {
|
|
6
|
+
category?: string;
|
|
7
|
+
tags?: string[];
|
|
8
|
+
url?: string;
|
|
9
|
+
author?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CrawlOptions {
|
|
12
|
+
/** Crawl depth: 0 = single page only, 1 = page + direct links, 2 = two levels deep */
|
|
13
|
+
depth?: number;
|
|
14
|
+
/** Maximum number of pages to crawl (limit: 50) */
|
|
15
|
+
maxPages?: number;
|
|
16
|
+
/** Only follow links on the same domain */
|
|
17
|
+
sameDomainOnly?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface ChunkingOptions {
|
|
20
|
+
/** Target chunk size in tokens (default: 512) */
|
|
21
|
+
chunkSizeTokens?: number;
|
|
22
|
+
/** Overlap between chunks in tokens (default: 50) */
|
|
23
|
+
overlapTokens?: number;
|
|
24
|
+
/** Preserve sentence boundaries (default: true) */
|
|
25
|
+
preserveSentences?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface Knowledge {
|
|
28
|
+
id: string;
|
|
29
|
+
_id?: string;
|
|
30
|
+
title: string;
|
|
31
|
+
content?: string;
|
|
32
|
+
source: KnowledgeSource;
|
|
33
|
+
processingStatus: ProcessingStatus;
|
|
34
|
+
processingProgress?: number;
|
|
35
|
+
taskId?: string;
|
|
36
|
+
folderId?: string;
|
|
37
|
+
metadata?: KnowledgeMetadata;
|
|
38
|
+
externalReferenceIds?: Record<string, string>;
|
|
39
|
+
isEnabled?: boolean;
|
|
40
|
+
chunkCount?: number;
|
|
41
|
+
tokenCount?: number;
|
|
42
|
+
createdAt?: string;
|
|
43
|
+
updatedAt?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface KnowledgeChunk {
|
|
46
|
+
id: string;
|
|
47
|
+
_id?: string;
|
|
48
|
+
knowledgeId: string;
|
|
49
|
+
content: string;
|
|
50
|
+
index: number;
|
|
51
|
+
embedding?: number[];
|
|
52
|
+
tokenCount?: number;
|
|
53
|
+
metadata?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Unified create knowledge data - supports text, URL, and file sources
|
|
57
|
+
*/
|
|
58
|
+
export interface CreateKnowledgeData {
|
|
59
|
+
/** Title of the knowledge entry */
|
|
60
|
+
title: string;
|
|
61
|
+
/** Source type: "text" for direct content, "url" for web fetch, "file" for uploads */
|
|
62
|
+
source: KnowledgeSource;
|
|
63
|
+
/** Content (required for source="text" or legacy sources) */
|
|
64
|
+
content?: string;
|
|
65
|
+
/** URL to fetch (required for source="url") */
|
|
66
|
+
url?: string;
|
|
67
|
+
/** Folder ID to organize the document */
|
|
68
|
+
folderId?: string;
|
|
69
|
+
/** Additional metadata */
|
|
70
|
+
metadata?: KnowledgeMetadata;
|
|
71
|
+
/** Whether the entry is enabled for search */
|
|
72
|
+
isEnabled?: boolean;
|
|
73
|
+
/** External reference IDs for multi-tenant filtering */
|
|
74
|
+
externalReferenceIds?: Record<string, string>;
|
|
75
|
+
/** Chunking options for document processing */
|
|
76
|
+
chunkingOptions?: ChunkingOptions;
|
|
77
|
+
/** URL crawling options (only for source="url") */
|
|
78
|
+
crawlOptions?: CrawlOptions;
|
|
79
|
+
}
|
|
80
|
+
export interface UpdateKnowledgeData {
|
|
81
|
+
title?: string;
|
|
82
|
+
content?: string;
|
|
83
|
+
folderId?: string;
|
|
84
|
+
metadata?: KnowledgeMetadata;
|
|
85
|
+
isEnabled?: boolean;
|
|
86
|
+
externalReferenceIds?: Record<string, string>;
|
|
87
|
+
}
|
|
88
|
+
export interface KnowledgeFilters {
|
|
89
|
+
search?: string;
|
|
90
|
+
source?: KnowledgeSource;
|
|
91
|
+
folderId?: string;
|
|
92
|
+
isEnabled?: boolean;
|
|
93
|
+
processingStatus?: ProcessingStatus;
|
|
94
|
+
externalReferenceIds?: Record<string, string>;
|
|
95
|
+
page?: number;
|
|
96
|
+
limit?: number;
|
|
97
|
+
}
|
|
98
|
+
export interface SearchKnowledgeData {
|
|
99
|
+
query: string;
|
|
100
|
+
/** Search mode: hybrid (default), vector, or text */
|
|
101
|
+
mode?: "hybrid" | "vector" | "text";
|
|
102
|
+
/** Maximum number of results */
|
|
103
|
+
limit?: number;
|
|
104
|
+
/** Filter by external reference IDs */
|
|
105
|
+
externalReferenceIds?: Record<string, string>;
|
|
106
|
+
/** Minimum similarity score (0-1) */
|
|
107
|
+
minScore?: number;
|
|
108
|
+
}
|
|
109
|
+
export interface SearchResult {
|
|
110
|
+
id: string;
|
|
111
|
+
knowledgeId: string;
|
|
112
|
+
title: string;
|
|
113
|
+
content: string;
|
|
114
|
+
score: number;
|
|
115
|
+
metadata?: Record<string, unknown>;
|
|
116
|
+
}
|
|
117
|
+
export interface SearchResponse {
|
|
118
|
+
results: SearchResult[];
|
|
119
|
+
query: string;
|
|
120
|
+
mode: string;
|
|
121
|
+
totalResults: number;
|
|
122
|
+
}
|
|
123
|
+
export interface KnowledgeListResponse {
|
|
124
|
+
items: Knowledge[];
|
|
125
|
+
total: number;
|
|
126
|
+
pagination?: {
|
|
127
|
+
page: number;
|
|
128
|
+
limit: number;
|
|
129
|
+
totalPages: number;
|
|
130
|
+
hasNext: boolean;
|
|
131
|
+
hasPrev: boolean;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export interface ProcessingTaskResponse {
|
|
135
|
+
id: string;
|
|
136
|
+
status: ProcessingStatus;
|
|
137
|
+
progress: number;
|
|
138
|
+
currentStep?: string;
|
|
139
|
+
documentId?: string;
|
|
140
|
+
error?: string;
|
|
141
|
+
result?: {
|
|
142
|
+
chunkCount: number;
|
|
143
|
+
wordCount: number;
|
|
144
|
+
characterCount: number;
|
|
145
|
+
processingTimeMs: number;
|
|
146
|
+
};
|
|
147
|
+
createdAt: string;
|
|
148
|
+
startedAt?: string;
|
|
149
|
+
completedAt?: string;
|
|
150
|
+
}
|
|
151
|
+
export declare class KnowledgeModule {
|
|
152
|
+
private sdk;
|
|
153
|
+
constructor(sdk: ChanlSDK);
|
|
154
|
+
/**
|
|
155
|
+
* List all knowledge entries with optional filters
|
|
156
|
+
*/
|
|
157
|
+
list(filters?: KnowledgeFilters): Promise<ApiResponse<KnowledgeListResponse>>;
|
|
158
|
+
/**
|
|
159
|
+
* Get a single knowledge entry by ID
|
|
160
|
+
*/
|
|
161
|
+
get(id: string): Promise<ApiResponse<Knowledge>>;
|
|
162
|
+
/**
|
|
163
|
+
* Create a new knowledge entry (unified endpoint)
|
|
164
|
+
*
|
|
165
|
+
* Supports three input methods:
|
|
166
|
+
* - source='text': Direct text content (sync, immediate completion)
|
|
167
|
+
* - source='url': Fetch from URL (async, returns taskId)
|
|
168
|
+
* - source='file': Upload file via multipart (async, returns taskId)
|
|
169
|
+
*
|
|
170
|
+
* For file uploads, use createFromFile() method instead.
|
|
171
|
+
*/
|
|
172
|
+
create(data: CreateKnowledgeData): Promise<ApiResponse<Knowledge>>;
|
|
173
|
+
/**
|
|
174
|
+
* Create knowledge from a file upload
|
|
175
|
+
*
|
|
176
|
+
* @param file - File buffer or Blob
|
|
177
|
+
* @param filename - Original filename
|
|
178
|
+
* @param options - Additional options (title, folderId, etc.)
|
|
179
|
+
*/
|
|
180
|
+
createFromFile(file: Buffer | Blob, filename: string, options?: Omit<CreateKnowledgeData, "source" | "content" | "url">): Promise<ApiResponse<Knowledge>>;
|
|
181
|
+
/**
|
|
182
|
+
* Update an existing knowledge entry
|
|
183
|
+
*/
|
|
184
|
+
update(id: string, data: UpdateKnowledgeData): Promise<ApiResponse<Knowledge>>;
|
|
185
|
+
/**
|
|
186
|
+
* Delete a knowledge entry
|
|
187
|
+
*/
|
|
188
|
+
delete(id: string): Promise<ApiResponse<void>>;
|
|
189
|
+
/**
|
|
190
|
+
* Search knowledge base
|
|
191
|
+
*/
|
|
192
|
+
search(data: SearchKnowledgeData): Promise<ApiResponse<SearchResponse>>;
|
|
193
|
+
/**
|
|
194
|
+
* Get processing task status
|
|
195
|
+
*/
|
|
196
|
+
getTaskStatus(taskId: string): Promise<ApiResponse<ProcessingTaskResponse>>;
|
|
197
|
+
/**
|
|
198
|
+
* Get chunks for a knowledge entry
|
|
199
|
+
*/
|
|
200
|
+
getChunks(knowledgeId: string): Promise<ApiResponse<KnowledgeChunk[]>>;
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=knowledge.d.ts.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.KnowledgeModule = void 0;
|
|
7
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// KNOWLEDGE MODULE
|
|
10
|
+
// ============================================================================
|
|
11
|
+
class KnowledgeModule {
|
|
12
|
+
constructor(sdk) {
|
|
13
|
+
this.sdk = sdk;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* List all knowledge entries with optional filters
|
|
17
|
+
*/
|
|
18
|
+
async list(filters) {
|
|
19
|
+
const queryParams = new URLSearchParams();
|
|
20
|
+
if (filters?.search) {
|
|
21
|
+
queryParams.append("search", filters.search);
|
|
22
|
+
}
|
|
23
|
+
if (filters?.source) {
|
|
24
|
+
queryParams.append("source", filters.source);
|
|
25
|
+
}
|
|
26
|
+
if (filters?.folderId) {
|
|
27
|
+
queryParams.append("folderId", filters.folderId);
|
|
28
|
+
}
|
|
29
|
+
if (filters?.isEnabled !== undefined) {
|
|
30
|
+
queryParams.append("isEnabled", String(filters.isEnabled));
|
|
31
|
+
}
|
|
32
|
+
if (filters?.processingStatus) {
|
|
33
|
+
queryParams.append("processingStatus", filters.processingStatus);
|
|
34
|
+
}
|
|
35
|
+
if (filters?.externalReferenceIds) {
|
|
36
|
+
queryParams.append("externalReferenceIds", JSON.stringify(filters.externalReferenceIds));
|
|
37
|
+
}
|
|
38
|
+
if (filters?.page) {
|
|
39
|
+
queryParams.append("page", filters.page.toString());
|
|
40
|
+
}
|
|
41
|
+
if (filters?.limit) {
|
|
42
|
+
queryParams.append("limit", filters.limit.toString());
|
|
43
|
+
}
|
|
44
|
+
const url = `/api/v1/knowledge${queryParams.toString() ? `?${queryParams.toString()}` : ""}`;
|
|
45
|
+
return this.sdk.request("GET", url);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get a single knowledge entry by ID
|
|
49
|
+
*/
|
|
50
|
+
async get(id) {
|
|
51
|
+
return this.sdk.request("GET", `/api/v1/knowledge/${id}`);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Create a new knowledge entry (unified endpoint)
|
|
55
|
+
*
|
|
56
|
+
* Supports three input methods:
|
|
57
|
+
* - source='text': Direct text content (sync, immediate completion)
|
|
58
|
+
* - source='url': Fetch from URL (async, returns taskId)
|
|
59
|
+
* - source='file': Upload file via multipart (async, returns taskId)
|
|
60
|
+
*
|
|
61
|
+
* For file uploads, use createFromFile() method instead.
|
|
62
|
+
*/
|
|
63
|
+
async create(data) {
|
|
64
|
+
return this.sdk.request("POST", "/api/v1/knowledge", data);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create knowledge from a file upload
|
|
68
|
+
*
|
|
69
|
+
* @param file - File buffer or Blob
|
|
70
|
+
* @param filename - Original filename
|
|
71
|
+
* @param options - Additional options (title, folderId, etc.)
|
|
72
|
+
*/
|
|
73
|
+
async createFromFile(file, filename, options) {
|
|
74
|
+
const formData = new form_data_1.default();
|
|
75
|
+
// Add file - use form-data package for Node.js compatibility
|
|
76
|
+
if (file instanceof Buffer) {
|
|
77
|
+
formData.append("file", file, { filename });
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// For Blob (browser), convert to buffer first
|
|
81
|
+
const arrayBuffer = await file.arrayBuffer();
|
|
82
|
+
formData.append("file", Buffer.from(arrayBuffer), { filename });
|
|
83
|
+
}
|
|
84
|
+
// Add source
|
|
85
|
+
formData.append("source", "file");
|
|
86
|
+
// Add optional fields
|
|
87
|
+
if (options?.title) {
|
|
88
|
+
formData.append("title", options.title);
|
|
89
|
+
}
|
|
90
|
+
if (options?.folderId) {
|
|
91
|
+
formData.append("folderId", options.folderId);
|
|
92
|
+
}
|
|
93
|
+
if (options?.metadata) {
|
|
94
|
+
// Filter out undefined values and only append if there's actual data
|
|
95
|
+
const cleanMetadata = Object.fromEntries(Object.entries(options.metadata).filter(([, v]) => v !== undefined));
|
|
96
|
+
if (Object.keys(cleanMetadata).length > 0) {
|
|
97
|
+
formData.append("metadata", JSON.stringify(cleanMetadata));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (options?.isEnabled !== undefined) {
|
|
101
|
+
formData.append("isEnabled", String(options.isEnabled));
|
|
102
|
+
}
|
|
103
|
+
if (options?.externalReferenceIds) {
|
|
104
|
+
formData.append("externalReferenceIds", JSON.stringify(options.externalReferenceIds));
|
|
105
|
+
}
|
|
106
|
+
if (options?.chunkingOptions) {
|
|
107
|
+
formData.append("chunkingOptions", JSON.stringify(options.chunkingOptions));
|
|
108
|
+
}
|
|
109
|
+
return this.sdk.request("POST", "/api/v1/knowledge", formData, {
|
|
110
|
+
headers: {
|
|
111
|
+
...formData.getHeaders(),
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Update an existing knowledge entry
|
|
117
|
+
*/
|
|
118
|
+
async update(id, data) {
|
|
119
|
+
return this.sdk.request("PATCH", `/api/v1/knowledge/${id}`, data);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Delete a knowledge entry
|
|
123
|
+
*/
|
|
124
|
+
async delete(id) {
|
|
125
|
+
return this.sdk.request("DELETE", `/api/v1/knowledge/${id}`);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Search knowledge base
|
|
129
|
+
*/
|
|
130
|
+
async search(data) {
|
|
131
|
+
return this.sdk.request("POST", "/api/v1/knowledge/search", data);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get processing task status
|
|
135
|
+
*/
|
|
136
|
+
async getTaskStatus(taskId) {
|
|
137
|
+
return this.sdk.request("GET", `/api/v1/knowledge/tasks/${taskId}`);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get chunks for a knowledge entry
|
|
141
|
+
*/
|
|
142
|
+
async getChunks(knowledgeId) {
|
|
143
|
+
return this.sdk.request("GET", `/api/v1/knowledge/${knowledgeId}/chunks`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.KnowledgeModule = KnowledgeModule;
|
|
147
|
+
//# sourceMappingURL=knowledge.js.map
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* McpModule - SDK module for MCP server configuration and status
|
|
3
|
+
*
|
|
4
|
+
* Provides access to MCP server configuration and health status.
|
|
5
|
+
* Used by CLI and admin UI to get ready-to-use agent configurations.
|
|
6
|
+
*/
|
|
7
|
+
import { ChanlSDK } from '../client';
|
|
8
|
+
import { ApiResponse } from '../types/config';
|
|
9
|
+
export interface AgentConfig {
|
|
10
|
+
url: string;
|
|
11
|
+
headers: Record<string, string>;
|
|
12
|
+
transport?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface AgentConfigs {
|
|
15
|
+
claude: {
|
|
16
|
+
mcpServers: {
|
|
17
|
+
chanl: AgentConfig;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
cursor: {
|
|
21
|
+
mcpServers: {
|
|
22
|
+
chanl: AgentConfig;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
generic: AgentConfig;
|
|
26
|
+
}
|
|
27
|
+
export interface McpConfigResponse {
|
|
28
|
+
serverUrl: string;
|
|
29
|
+
environment: 'production' | 'staging' | 'development';
|
|
30
|
+
status: 'active' | 'disabled';
|
|
31
|
+
toolCount: number;
|
|
32
|
+
resourceCount: number;
|
|
33
|
+
promptCount: number;
|
|
34
|
+
toolsetId?: string;
|
|
35
|
+
toolsetName?: string;
|
|
36
|
+
agentConfigs: AgentConfigs;
|
|
37
|
+
}
|
|
38
|
+
export interface McpStatusResponse {
|
|
39
|
+
healthy: boolean;
|
|
40
|
+
message: string;
|
|
41
|
+
responseTimeMs?: number;
|
|
42
|
+
error?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface McpConfigOptions {
|
|
45
|
+
toolsetId?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface McpTool {
|
|
48
|
+
name: string;
|
|
49
|
+
description?: string;
|
|
50
|
+
inputSchema: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
export interface McpToolCallResult {
|
|
53
|
+
content: Array<{
|
|
54
|
+
type: string;
|
|
55
|
+
text?: string;
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
}>;
|
|
58
|
+
isError?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export declare class McpModule {
|
|
61
|
+
private sdk;
|
|
62
|
+
constructor(sdk: ChanlSDK);
|
|
63
|
+
/**
|
|
64
|
+
* Get MCP configuration for a workspace
|
|
65
|
+
*
|
|
66
|
+
* @param options - Optional configuration options (e.g., toolsetId filter)
|
|
67
|
+
* @returns MCP configuration including server URL and agent configs
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* typescript
|
|
71
|
+
* const { data } = await sdk.mcp.getConfig('ws_123');
|
|
72
|
+
* console.log(data.serverUrl);
|
|
73
|
+
* console.log(data.agentConfigs.claude);
|
|
74
|
+
*/
|
|
75
|
+
getConfig(options?: McpConfigOptions): Promise<ApiResponse<McpConfigResponse>>;
|
|
76
|
+
/**
|
|
77
|
+
* Check MCP server health status
|
|
78
|
+
*
|
|
79
|
+
* @returns Health status of the MCP server
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* typescript
|
|
83
|
+
* const { data } = await sdk.mcp.getStatus('ws_123');
|
|
84
|
+
* if (data.healthy) {
|
|
85
|
+
* console.log('MCP server is running');
|
|
86
|
+
* }
|
|
87
|
+
*/
|
|
88
|
+
getStatus(): Promise<ApiResponse<McpStatusResponse>>;
|
|
89
|
+
/**
|
|
90
|
+
* List MCP tools available for an agent
|
|
91
|
+
*
|
|
92
|
+
* @param agentId - Agent ID to list tools for
|
|
93
|
+
* @returns List of MCP tools with their schemas
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const { data } = await sdk.mcp.listTools('ws_123', 'agent_456');
|
|
98
|
+
* for (const tool of data.tools) {
|
|
99
|
+
* console.log(tool.name, tool.description);
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
listTools(agentId: string): Promise<ApiResponse<{
|
|
104
|
+
tools: McpTool[];
|
|
105
|
+
}>>;
|
|
106
|
+
/**
|
|
107
|
+
* Call an MCP tool by name
|
|
108
|
+
*
|
|
109
|
+
* @param agentId - Agent ID that owns the tool
|
|
110
|
+
* @param toolName - Name of the tool to invoke
|
|
111
|
+
* @param args - Optional arguments to pass to the tool
|
|
112
|
+
* @returns Tool call result with content array
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const { data } = await sdk.mcp.callTool('ws_123', 'agent_456', 'get_weather', { city: 'London' });
|
|
117
|
+
* if (!data.isError) {
|
|
118
|
+
* console.log(data.content[0].text);
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
callTool(agentId: string, toolName: string, args?: Record<string, unknown>): Promise<ApiResponse<McpToolCallResult>>;
|
|
123
|
+
/**
|
|
124
|
+
* Get details and schema for a specific MCP tool
|
|
125
|
+
*
|
|
126
|
+
* @param agentId - Agent ID that owns the tool
|
|
127
|
+
* @param toolName - Name of the tool to inspect
|
|
128
|
+
* @returns Tool details including input schema
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const { data } = await sdk.mcp.getTool('ws_123', 'agent_456', 'get_weather');
|
|
133
|
+
* console.log(data.tool.inputSchema);
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
getTool(agentId: string, toolName: string): Promise<ApiResponse<McpTool>>;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* McpModule - SDK module for MCP server configuration and status
|
|
4
|
+
*
|
|
5
|
+
* Provides access to MCP server configuration and health status.
|
|
6
|
+
* Used by CLI and admin UI to get ready-to-use agent configurations.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.McpModule = void 0;
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// MCP MODULE
|
|
12
|
+
// ============================================================================
|
|
13
|
+
class McpModule {
|
|
14
|
+
constructor(sdk) {
|
|
15
|
+
this.sdk = sdk;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get MCP configuration for a workspace
|
|
19
|
+
*
|
|
20
|
+
* @param options - Optional configuration options (e.g., toolsetId filter)
|
|
21
|
+
* @returns MCP configuration including server URL and agent configs
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* typescript
|
|
25
|
+
* const { data } = await sdk.mcp.getConfig('ws_123');
|
|
26
|
+
* console.log(data.serverUrl);
|
|
27
|
+
* console.log(data.agentConfigs.claude);
|
|
28
|
+
*/
|
|
29
|
+
async getConfig(options) {
|
|
30
|
+
const queryParams = new URLSearchParams();
|
|
31
|
+
if (options?.toolsetId) {
|
|
32
|
+
queryParams.append('toolsetId', options.toolsetId);
|
|
33
|
+
}
|
|
34
|
+
const queryString = queryParams.toString();
|
|
35
|
+
const url = '/api/v1/mcp/config' + (queryString ? '?' + queryString : '');
|
|
36
|
+
return this.sdk.request('GET', url);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check MCP server health status
|
|
40
|
+
*
|
|
41
|
+
* @returns Health status of the MCP server
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* typescript
|
|
45
|
+
* const { data } = await sdk.mcp.getStatus('ws_123');
|
|
46
|
+
* if (data.healthy) {
|
|
47
|
+
* console.log('MCP server is running');
|
|
48
|
+
* }
|
|
49
|
+
*/
|
|
50
|
+
async getStatus() {
|
|
51
|
+
return this.sdk.request('GET', '/api/v1/mcp/status');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* List MCP tools available for an agent
|
|
55
|
+
*
|
|
56
|
+
* @param agentId - Agent ID to list tools for
|
|
57
|
+
* @returns List of MCP tools with their schemas
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const { data } = await sdk.mcp.listTools('ws_123', 'agent_456');
|
|
62
|
+
* for (const tool of data.tools) {
|
|
63
|
+
* console.log(tool.name, tool.description);
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
async listTools(agentId) {
|
|
68
|
+
return this.sdk.request('GET', `/api/v1/mcp/agents/${agentId}/tools`);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Call an MCP tool by name
|
|
72
|
+
*
|
|
73
|
+
* @param agentId - Agent ID that owns the tool
|
|
74
|
+
* @param toolName - Name of the tool to invoke
|
|
75
|
+
* @param args - Optional arguments to pass to the tool
|
|
76
|
+
* @returns Tool call result with content array
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const { data } = await sdk.mcp.callTool('ws_123', 'agent_456', 'get_weather', { city: 'London' });
|
|
81
|
+
* if (!data.isError) {
|
|
82
|
+
* console.log(data.content[0].text);
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
async callTool(agentId, toolName, args) {
|
|
87
|
+
return this.sdk.request('POST', `/api/v1/mcp/agents/${agentId}/tools/call`, {
|
|
88
|
+
name: toolName,
|
|
89
|
+
arguments: args,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get details and schema for a specific MCP tool
|
|
94
|
+
*
|
|
95
|
+
* @param agentId - Agent ID that owns the tool
|
|
96
|
+
* @param toolName - Name of the tool to inspect
|
|
97
|
+
* @returns Tool details including input schema
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const { data } = await sdk.mcp.getTool('ws_123', 'agent_456', 'get_weather');
|
|
102
|
+
* console.log(data.tool.inputSchema);
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
async getTool(agentId, toolName) {
|
|
106
|
+
return this.sdk.request('GET', `/api/v1/mcp/agents/${agentId}/tools/${toolName}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.McpModule = McpModule;
|
|
110
|
+
//# sourceMappingURL=mcp.js.map
|