@besales/mcp 0.1.0 → 0.11.1
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 +272 -17
- package/dist/auth/connection-store.d.ts +58 -0
- package/dist/auth/connection-store.js +208 -0
- package/dist/auth/connection-store.js.map +1 -0
- package/dist/auth/oauth-client.d.ts +27 -2
- package/dist/auth/oauth-client.js +62 -11
- package/dist/auth/oauth-client.js.map +1 -1
- package/dist/auth/session-workspace.d.ts +2 -0
- package/dist/auth/session-workspace.js +20 -0
- package/dist/auth/session-workspace.js.map +1 -0
- package/dist/auth/token-storage.d.ts +19 -5
- package/dist/auth/token-storage.js +11 -6
- package/dist/auth/token-storage.js.map +1 -1
- package/dist/cli.d.ts +2 -7
- package/dist/cli.js +111 -33
- package/dist/cli.js.map +1 -1
- package/dist/http/api-client.d.ts +4 -13
- package/dist/http/api-client.js +18 -18
- package/dist/http/api-client.js.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/instructions/server-instructions.d.ts +15 -0
- package/dist/instructions/server-instructions.js +243 -0
- package/dist/instructions/server-instructions.js.map +1 -0
- package/dist/package-metadata.js +7 -1
- package/dist/package-metadata.js.map +1 -1
- package/dist/resources/concepts/feedback-sheets.md +77 -0
- package/dist/resources/concepts/sandbox.md +13 -0
- package/dist/resources/concepts/workbook-classification.md +241 -0
- package/dist/resources/docs/agent-behavior.md +393 -0
- package/dist/resources/docs/crm-integration.md +535 -0
- package/dist/resources/docs/files-and-uploads.md +295 -0
- package/dist/resources/docs/knowledge-base.md +521 -0
- package/dist/resources/docs/pipeline-builder.md +221 -0
- package/dist/resources/docs/pipeline-settings-deep.md +221 -0
- package/dist/resources/docs/platforms.md +513 -0
- package/dist/resources/docs/prompt-anatomy.md +298 -0
- package/dist/resources/docs/prompt-principles.md +289 -0
- package/dist/resources/registry.js +34 -12
- package/dist/resources/registry.js.map +1 -1
- package/dist/resources/workflows/compare-models.md +46 -0
- package/dist/resources/workflows/connect-crm-from-scratch.md +89 -0
- package/dist/resources/workflows/connect-datasource-from-scratch.md +92 -0
- package/dist/resources/workflows/extract-from-document.md +36 -0
- package/dist/resources/workflows/iterate-with-sandbox.md +31 -0
- package/dist/resources/workflows/platform-setup-from-scratch.md +113 -0
- package/dist/resources/workflows/production-readiness-check.md +41 -0
- package/dist/schemas/mcp-tools.json +2636 -182
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -1
- package/dist/tools/definitions/agent-design.d.ts +215 -0
- package/dist/tools/definitions/agent-design.js +643 -0
- package/dist/tools/definitions/agent-design.js.map +1 -0
- package/dist/tools/definitions/crm-platform.d.ts +211 -0
- package/dist/tools/definitions/crm-platform.js +1070 -0
- package/dist/tools/definitions/crm-platform.js.map +1 -0
- package/dist/tools/definitions/datasource.d.ts +40 -0
- package/dist/tools/definitions/datasource.js +196 -0
- package/dist/tools/definitions/datasource.js.map +1 -0
- package/dist/tools/definitions/knowledge.d.ts +215 -0
- package/dist/tools/definitions/knowledge.js +782 -0
- package/dist/tools/definitions/knowledge.js.map +1 -0
- package/dist/tools/definitions/model-comparison.d.ts +25 -0
- package/dist/tools/definitions/model-comparison.js +101 -0
- package/dist/tools/definitions/model-comparison.js.map +1 -0
- package/dist/tools/definitions/platform-setup.d.ts +412 -0
- package/dist/tools/definitions/platform-setup.js +738 -0
- package/dist/tools/definitions/platform-setup.js.map +1 -0
- package/dist/tools/definitions/session.d.ts +11 -0
- package/dist/tools/definitions/session.js +86 -0
- package/dist/tools/definitions/session.js.map +1 -0
- package/dist/tools/definitions/shared.d.ts +742 -0
- package/dist/tools/definitions/shared.js +773 -0
- package/dist/tools/definitions/shared.js.map +1 -0
- package/dist/tools/definitions.d.ts +873 -88
- package/dist/tools/definitions.js +14 -856
- package/dist/tools/definitions.js.map +1 -1
- package/dist/tools/registry.d.ts +3 -1
- package/dist/tools/registry.js +90 -11
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/result.d.ts +1 -1
- package/dist/tools/result.js +12 -4
- package/dist/tools/result.js.map +1 -1
- package/dist/utils/logger.js +2 -1
- package/dist/utils/logger.js.map +1 -1
- package/docs/host-setup.md +34 -15
- package/package.json +2 -2
- package/scripts/install-claude-desktop.js +89 -11
- package/scripts/mock-api-server.js +1 -1
- package/scripts/mock-credentials.js +49 -6
- package/dist/types/api-contract.gen.d.ts +0 -6975
- package/dist/types/api-contract.gen.js +0 -6
- package/dist/types/api-contract.gen.js.map +0 -1
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { buildKnowledgeSpaceListQuery, buildListQuery, compactObject, defineTool, knowledgeTableSourceSchema, uuidSchema, withInstructions, } from './shared.js';
|
|
3
|
+
export const knowledgeTools = [
|
|
4
|
+
// v1.5 — workbook ingestion (xlsx + Google Sheets → ICP/prompt/knowledge)
|
|
5
|
+
defineTool({
|
|
6
|
+
name: 'besales_workbook_inspect',
|
|
7
|
+
requiredFields: [],
|
|
8
|
+
defaultWorkspaceId: true,
|
|
9
|
+
schema: z
|
|
10
|
+
.object({
|
|
11
|
+
workspace_id: uuidSchema.optional(),
|
|
12
|
+
stored_file_id: uuidSchema.optional(),
|
|
13
|
+
google_sheets_url: z.string().url().optional(),
|
|
14
|
+
sample_rows_per_sheet: z.number().int().min(1).max(50).optional(),
|
|
15
|
+
max_cells_total: z.number().int().min(50).max(5000).optional(),
|
|
16
|
+
})
|
|
17
|
+
.superRefine((value, ctx) => {
|
|
18
|
+
if (!value.stored_file_id && !value.google_sheets_url) {
|
|
19
|
+
ctx.addIssue({
|
|
20
|
+
code: z.ZodIssueCode.custom,
|
|
21
|
+
message: 'Один из stored_file_id или google_sheets_url обязателен',
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (value.stored_file_id && value.google_sheets_url) {
|
|
25
|
+
ctx.addIssue({
|
|
26
|
+
code: z.ZodIssueCode.custom,
|
|
27
|
+
message: 'Передайте stored_file_id ИЛИ google_sheets_url, не оба',
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}),
|
|
31
|
+
createRequest: (input) => ({
|
|
32
|
+
path: `/workspaces/${input.workspace_id}/workbooks/inspect`,
|
|
33
|
+
body: compactObject({
|
|
34
|
+
storedFileId: input.stored_file_id,
|
|
35
|
+
googleSheetsUrl: input.google_sheets_url,
|
|
36
|
+
sampleRowsPerSheet: input.sample_rows_per_sheet,
|
|
37
|
+
maxCellsTotal: input.max_cells_total,
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
40
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
41
|
+
'Возвращена структура всех вкладок + per-column hyperlink статистика.',
|
|
42
|
+
'Пройди по содержимому ВСЕХ вкладок — не делай вывод «этого нет в файле», пока не проверил каждую.',
|
|
43
|
+
'Если контент на языке, отличном от языка диалога с пользователем — ПЕРЕД внедрением (RAG/промпт/ICP) дай пользователю краткое саммари на его языке: что нашёл и что внедряешь; по цифрам/процентам/условиям дождись подтверждения.',
|
|
44
|
+
'Классифицируй каждую вкладку по таксономии из `besales://concepts/workbook-classification`.',
|
|
45
|
+
'Для compact knowledge (≤8k chars) — сделай локальную LLM-выжимку и положи через `besales_agent_facts_set`.',
|
|
46
|
+
'Для bulk knowledge (>8k) — `besales_workbook_to_knowledge_document`.',
|
|
47
|
+
'Для диалог-индексов с amoCRM-ссылками — извлеки lead_ids regex-ом и вызывай `besales_icp_import_dialogues mode=audio audio_source_type=amocrm_leads`.',
|
|
48
|
+
'Если Google Sheets 403 (`google_sheets_not_shared`) — покажи юзеру `serviceAccountEmail` из response и попроси расшарить таблицу.',
|
|
49
|
+
'После классификации зафиксируй решения через PATCH /workbooks/:id/classification.',
|
|
50
|
+
]),
|
|
51
|
+
}),
|
|
52
|
+
defineTool({
|
|
53
|
+
name: 'besales_workbook_extract_amocrm_leads',
|
|
54
|
+
requiredFields: ['workbook_id'],
|
|
55
|
+
defaultWorkspaceId: true,
|
|
56
|
+
schema: z
|
|
57
|
+
.object({
|
|
58
|
+
workspace_id: uuidSchema.optional(),
|
|
59
|
+
workbook_id: uuidSchema,
|
|
60
|
+
sheet_title: z.string().optional(),
|
|
61
|
+
sheet_gid: z.number().int().optional(),
|
|
62
|
+
sheet_index: z.number().int().min(0).optional(),
|
|
63
|
+
include_contacts: z.boolean().optional(),
|
|
64
|
+
})
|
|
65
|
+
.superRefine((value, ctx) => {
|
|
66
|
+
if (value.sheet_title === undefined &&
|
|
67
|
+
value.sheet_gid === undefined &&
|
|
68
|
+
value.sheet_index === undefined) {
|
|
69
|
+
ctx.addIssue({
|
|
70
|
+
code: z.ZodIssueCode.custom,
|
|
71
|
+
message: 'Один из sheet_title / sheet_gid / sheet_index обязателен',
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
createRequest: (input) => ({
|
|
76
|
+
path: `/workspaces/${input.workspace_id}/workbooks/${input.workbook_id}/extract-amocrm-leads`,
|
|
77
|
+
body: compactObject({
|
|
78
|
+
sheetTitle: input.sheet_title,
|
|
79
|
+
sheetGid: input.sheet_gid,
|
|
80
|
+
sheetIndex: input.sheet_index,
|
|
81
|
+
includeContacts: input.include_contacts,
|
|
82
|
+
}),
|
|
83
|
+
}),
|
|
84
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
85
|
+
'Возвращены все amoCRM lead-ID из ВСЕЙ вкладки (без sample-лимита inspect).',
|
|
86
|
+
'Используй leads[].id для `besales_icp_import_dialogues mode=audio audio_source_type=amocrm_leads`.',
|
|
87
|
+
'Если truncated=true — вкладка длиннее 10000 строк (hard cap); часть строк не прочитана.',
|
|
88
|
+
]),
|
|
89
|
+
}),
|
|
90
|
+
defineTool({
|
|
91
|
+
name: 'besales_workbook_to_knowledge_document',
|
|
92
|
+
requiredFields: ['workbook_id'],
|
|
93
|
+
defaultWorkspaceId: true,
|
|
94
|
+
schema: z
|
|
95
|
+
.object({
|
|
96
|
+
workspace_id: uuidSchema.optional(),
|
|
97
|
+
workbook_id: uuidSchema,
|
|
98
|
+
sheet_title: z.string().optional(),
|
|
99
|
+
sheet_gid: z.number().int().optional(),
|
|
100
|
+
sheet_index: z.number().int().min(0).optional(),
|
|
101
|
+
namespace: z.string().optional(),
|
|
102
|
+
split_override: z
|
|
103
|
+
.object({
|
|
104
|
+
split_mode: z.enum(['size', 'separator']),
|
|
105
|
+
separator: z.string().optional(),
|
|
106
|
+
chunk_size: z.number().int().min(100).optional(),
|
|
107
|
+
chunk_overlap: z.number().int().min(0).optional(),
|
|
108
|
+
max_chunk_size: z.number().int().min(100).optional(),
|
|
109
|
+
})
|
|
110
|
+
.optional(),
|
|
111
|
+
replace_existing: z.boolean().optional(),
|
|
112
|
+
})
|
|
113
|
+
.superRefine((value, ctx) => {
|
|
114
|
+
if (value.sheet_title === undefined &&
|
|
115
|
+
value.sheet_gid === undefined &&
|
|
116
|
+
value.sheet_index === undefined) {
|
|
117
|
+
ctx.addIssue({
|
|
118
|
+
code: z.ZodIssueCode.custom,
|
|
119
|
+
message: 'Один из sheet_title / sheet_gid / sheet_index обязателен',
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
createRequest: (input) => ({
|
|
124
|
+
path: `/workspaces/${input.workspace_id}/workbooks/${input.workbook_id}/knowledge-document`,
|
|
125
|
+
body: compactObject({
|
|
126
|
+
sheetTitle: input.sheet_title,
|
|
127
|
+
sheetGid: input.sheet_gid,
|
|
128
|
+
sheetIndex: input.sheet_index,
|
|
129
|
+
namespace: input.namespace,
|
|
130
|
+
splitOverride: input.split_override
|
|
131
|
+
? compactObject({
|
|
132
|
+
splitMode: input.split_override.split_mode,
|
|
133
|
+
separator: input.split_override.separator,
|
|
134
|
+
chunkSize: input.split_override.chunk_size,
|
|
135
|
+
chunkOverlap: input.split_override.chunk_overlap,
|
|
136
|
+
maxChunkSize: input.split_override.max_chunk_size,
|
|
137
|
+
})
|
|
138
|
+
: undefined,
|
|
139
|
+
replaceExisting: input.replace_existing,
|
|
140
|
+
}),
|
|
141
|
+
}),
|
|
142
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
143
|
+
'KnowledgeDocument создан. Привяжи namespace к агенту через `AgentChat.knowledgeNamespaces` если не привязан (см. besales_agent_update).',
|
|
144
|
+
'response.splitDecision.reason — почему сервер выбрал такой режим чанкинга (heuristic либо override).',
|
|
145
|
+
'При повторном вызове для того же листа — старый AI_INGESTED документ заменяется (idempotency).',
|
|
146
|
+
]),
|
|
147
|
+
}),
|
|
148
|
+
// v1.5 — Knowledge Spaces (Increment 1): создание/управление namespaces для агентов
|
|
149
|
+
defineTool({
|
|
150
|
+
name: 'besales_knowledge_space_create',
|
|
151
|
+
requiredFields: ['name', 'scope_type'],
|
|
152
|
+
defaultWorkspaceId: true,
|
|
153
|
+
schema: z
|
|
154
|
+
.object({
|
|
155
|
+
workspace_id: uuidSchema.optional(),
|
|
156
|
+
name: z.string().min(1).max(100),
|
|
157
|
+
scope_type: z.enum(['WORKSPACE', 'CHANNEL']),
|
|
158
|
+
channel_id: uuidSchema.optional(),
|
|
159
|
+
access_mode: z.enum(['AUTO_QUERY', 'TOOL_ONLY']).optional(),
|
|
160
|
+
})
|
|
161
|
+
.superRefine((value, ctx) => {
|
|
162
|
+
if (value.scope_type === 'CHANNEL' && !value.channel_id) {
|
|
163
|
+
ctx.addIssue({
|
|
164
|
+
code: z.ZodIssueCode.custom,
|
|
165
|
+
message: 'channel_id обязателен для scope_type=CHANNEL',
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
if (value.scope_type === 'WORKSPACE' && value.channel_id) {
|
|
169
|
+
ctx.addIssue({
|
|
170
|
+
code: z.ZodIssueCode.custom,
|
|
171
|
+
message: 'channel_id запрещён для scope_type=WORKSPACE',
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}),
|
|
175
|
+
createRequest: (input) => ({
|
|
176
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces`,
|
|
177
|
+
body: compactObject({
|
|
178
|
+
name: input.name,
|
|
179
|
+
scope_type: input.scope_type,
|
|
180
|
+
channel_id: input.channel_id,
|
|
181
|
+
access_mode: input.access_mode,
|
|
182
|
+
}),
|
|
183
|
+
}),
|
|
184
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
185
|
+
'Knowledge space создан. id — UUID для последующих ingestion-операций.',
|
|
186
|
+
'WORKSPACE scope доступен всем каналам через besales_knowledge_space_channel_link_upsert.',
|
|
187
|
+
'CHANNEL scope привязан к channel_id жёстко (изолирован).',
|
|
188
|
+
'Дальше: загрузи документ через besales_knowledge_document_upload или Q&A (Increment 2).',
|
|
189
|
+
]),
|
|
190
|
+
}),
|
|
191
|
+
defineTool({
|
|
192
|
+
name: 'besales_knowledge_space_list',
|
|
193
|
+
requiredFields: [],
|
|
194
|
+
defaultWorkspaceId: true,
|
|
195
|
+
schema: z.object({
|
|
196
|
+
workspace_id: uuidSchema.optional(),
|
|
197
|
+
scope_type: z.enum(['WORKSPACE', 'CHANNEL']).optional(),
|
|
198
|
+
channel_id: uuidSchema.optional(),
|
|
199
|
+
}),
|
|
200
|
+
createRequest: (input) => ({
|
|
201
|
+
method: 'GET',
|
|
202
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces${buildKnowledgeSpaceListQuery(input.scope_type, input.channel_id)}`,
|
|
203
|
+
}),
|
|
204
|
+
}),
|
|
205
|
+
defineTool({
|
|
206
|
+
name: 'besales_knowledge_space_get',
|
|
207
|
+
requiredFields: ['knowledge_space_id'],
|
|
208
|
+
defaultWorkspaceId: true,
|
|
209
|
+
schema: z.object({
|
|
210
|
+
workspace_id: uuidSchema.optional(),
|
|
211
|
+
knowledge_space_id: uuidSchema,
|
|
212
|
+
}),
|
|
213
|
+
createRequest: (input) => ({
|
|
214
|
+
method: 'GET',
|
|
215
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}`,
|
|
216
|
+
}),
|
|
217
|
+
}),
|
|
218
|
+
defineTool({
|
|
219
|
+
name: 'besales_knowledge_space_patch',
|
|
220
|
+
requiredFields: ['knowledge_space_id'],
|
|
221
|
+
defaultWorkspaceId: true,
|
|
222
|
+
schema: z.object({
|
|
223
|
+
workspace_id: uuidSchema.optional(),
|
|
224
|
+
knowledge_space_id: uuidSchema,
|
|
225
|
+
name: z.string().min(1).max(100).optional(),
|
|
226
|
+
access_mode: z.enum(['AUTO_QUERY', 'TOOL_ONLY']).optional(),
|
|
227
|
+
}),
|
|
228
|
+
createRequest: (input) => ({
|
|
229
|
+
method: 'PATCH',
|
|
230
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}`,
|
|
231
|
+
body: compactObject({
|
|
232
|
+
name: input.name,
|
|
233
|
+
access_mode: input.access_mode,
|
|
234
|
+
}),
|
|
235
|
+
}),
|
|
236
|
+
}),
|
|
237
|
+
defineTool({
|
|
238
|
+
name: 'besales_knowledge_space_channel_link_upsert',
|
|
239
|
+
requiredFields: ['knowledge_space_id', 'channel_id'],
|
|
240
|
+
defaultWorkspaceId: true,
|
|
241
|
+
schema: z.object({
|
|
242
|
+
workspace_id: uuidSchema.optional(),
|
|
243
|
+
knowledge_space_id: uuidSchema,
|
|
244
|
+
channel_id: uuidSchema,
|
|
245
|
+
}),
|
|
246
|
+
createRequest: (input) => ({
|
|
247
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/channel-links`,
|
|
248
|
+
body: { channel_id: input.channel_id },
|
|
249
|
+
}),
|
|
250
|
+
}),
|
|
251
|
+
defineTool({
|
|
252
|
+
name: 'besales_knowledge_space_channel_link_remove',
|
|
253
|
+
requiredFields: ['knowledge_space_id', 'channel_id'],
|
|
254
|
+
defaultWorkspaceId: true,
|
|
255
|
+
schema: z.object({
|
|
256
|
+
workspace_id: uuidSchema.optional(),
|
|
257
|
+
knowledge_space_id: uuidSchema,
|
|
258
|
+
channel_id: uuidSchema,
|
|
259
|
+
}),
|
|
260
|
+
createRequest: (input) => ({
|
|
261
|
+
method: 'DELETE',
|
|
262
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/channel-links/${input.channel_id}`,
|
|
263
|
+
}),
|
|
264
|
+
}),
|
|
265
|
+
// v1.5 — Knowledge Documents (Increment 1): загрузка/удаление документов в space
|
|
266
|
+
defineTool({
|
|
267
|
+
name: 'besales_knowledge_document_upload',
|
|
268
|
+
requiredFields: ['knowledge_space_id', 'source_kind'],
|
|
269
|
+
defaultWorkspaceId: true,
|
|
270
|
+
schema: z
|
|
271
|
+
.object({
|
|
272
|
+
workspace_id: uuidSchema.optional(),
|
|
273
|
+
knowledge_space_id: uuidSchema,
|
|
274
|
+
source_kind: z.enum(['STORED_FILE', 'TEXT']),
|
|
275
|
+
stored_file_id: uuidSchema.optional(),
|
|
276
|
+
content: z.string().optional(),
|
|
277
|
+
filename: z.string().optional(),
|
|
278
|
+
split_override: z
|
|
279
|
+
.object({
|
|
280
|
+
split_mode: z.enum(['size', 'separator']),
|
|
281
|
+
separator: z.string().optional(),
|
|
282
|
+
chunk_size: z.number().int().min(100).optional(),
|
|
283
|
+
chunk_overlap: z.number().int().min(0).optional(),
|
|
284
|
+
max_chunk_size: z.number().int().min(100).optional(),
|
|
285
|
+
})
|
|
286
|
+
.optional(),
|
|
287
|
+
})
|
|
288
|
+
.superRefine((value, ctx) => {
|
|
289
|
+
if (value.source_kind === 'STORED_FILE' && !value.stored_file_id) {
|
|
290
|
+
ctx.addIssue({
|
|
291
|
+
code: z.ZodIssueCode.custom,
|
|
292
|
+
message: 'stored_file_id обязателен для source_kind=STORED_FILE',
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
if (value.source_kind === 'TEXT' && (!value.content || !value.filename)) {
|
|
296
|
+
ctx.addIssue({
|
|
297
|
+
code: z.ZodIssueCode.custom,
|
|
298
|
+
message: 'content и filename обязательны для source_kind=TEXT',
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}),
|
|
302
|
+
createRequest: (input) => ({
|
|
303
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/documents`,
|
|
304
|
+
body: compactObject({
|
|
305
|
+
source_kind: input.source_kind,
|
|
306
|
+
stored_file_id: input.stored_file_id,
|
|
307
|
+
content: input.content,
|
|
308
|
+
filename: input.filename,
|
|
309
|
+
split_override: input.split_override
|
|
310
|
+
? compactObject({
|
|
311
|
+
split_mode: input.split_override.split_mode,
|
|
312
|
+
separator: input.split_override.separator,
|
|
313
|
+
chunk_size: input.split_override.chunk_size,
|
|
314
|
+
chunk_overlap: input.split_override.chunk_overlap,
|
|
315
|
+
max_chunk_size: input.split_override.max_chunk_size,
|
|
316
|
+
})
|
|
317
|
+
: undefined,
|
|
318
|
+
}),
|
|
319
|
+
}),
|
|
320
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
321
|
+
'Document uploaded. Processing is async — статус движется PENDING → COMPLETED либо FAILED.',
|
|
322
|
+
'Опрашивай статус через besales_knowledge_document_get пока status=COMPLETED.',
|
|
323
|
+
'Для TEXT source_kind при повторном вызове с тем же filename — старый документ заменяется (document_replaced=true).',
|
|
324
|
+
'Binary файлы (PDF/DOCX) — загрузи сначала через POST /api/v2/files отдельно, затем передай stored_file_id сюда.',
|
|
325
|
+
]),
|
|
326
|
+
}),
|
|
327
|
+
defineTool({
|
|
328
|
+
name: 'besales_knowledge_document_list',
|
|
329
|
+
requiredFields: ['knowledge_space_id'],
|
|
330
|
+
defaultWorkspaceId: true,
|
|
331
|
+
schema: z.object({
|
|
332
|
+
workspace_id: uuidSchema.optional(),
|
|
333
|
+
knowledge_space_id: uuidSchema,
|
|
334
|
+
status: z
|
|
335
|
+
.enum([
|
|
336
|
+
'LOADED',
|
|
337
|
+
'SPLIT',
|
|
338
|
+
'EMBEDDINGS_GENERATED',
|
|
339
|
+
'VECTOR_DB_UPLOADED',
|
|
340
|
+
'COMPLETED',
|
|
341
|
+
'FAILED',
|
|
342
|
+
'TEXT_EXTRACTED',
|
|
343
|
+
'CHUNKS_SAVED',
|
|
344
|
+
])
|
|
345
|
+
.optional(),
|
|
346
|
+
page: z.number().int().min(1).optional(),
|
|
347
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
348
|
+
}),
|
|
349
|
+
createRequest: (input) => ({
|
|
350
|
+
method: 'GET',
|
|
351
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/documents${buildListQuery({ status: input.status, page: input.page, limit: input.limit })}`,
|
|
352
|
+
}),
|
|
353
|
+
}),
|
|
354
|
+
defineTool({
|
|
355
|
+
name: 'besales_knowledge_document_get',
|
|
356
|
+
requiredFields: ['knowledge_space_id', 'document_id'],
|
|
357
|
+
defaultWorkspaceId: true,
|
|
358
|
+
schema: z.object({
|
|
359
|
+
workspace_id: uuidSchema.optional(),
|
|
360
|
+
knowledge_space_id: uuidSchema,
|
|
361
|
+
document_id: uuidSchema,
|
|
362
|
+
}),
|
|
363
|
+
createRequest: (input) => ({
|
|
364
|
+
method: 'GET',
|
|
365
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/documents/${input.document_id}`,
|
|
366
|
+
}),
|
|
367
|
+
}),
|
|
368
|
+
defineTool({
|
|
369
|
+
name: 'besales_knowledge_document_delete',
|
|
370
|
+
requiredFields: ['knowledge_space_id', 'document_id', 'explicit_confirmation'],
|
|
371
|
+
defaultWorkspaceId: true,
|
|
372
|
+
schema: z.object({
|
|
373
|
+
workspace_id: uuidSchema.optional(),
|
|
374
|
+
knowledge_space_id: uuidSchema,
|
|
375
|
+
document_id: uuidSchema,
|
|
376
|
+
explicit_confirmation: z.boolean(),
|
|
377
|
+
}),
|
|
378
|
+
createRequest: (input) => ({
|
|
379
|
+
method: 'DELETE',
|
|
380
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/documents/${input.document_id}`,
|
|
381
|
+
body: { explicit_confirmation: input.explicit_confirmation },
|
|
382
|
+
}),
|
|
383
|
+
}),
|
|
384
|
+
// ----- v1.5 Increment 2: Q&A CRUD (7 tools) -----
|
|
385
|
+
defineTool({
|
|
386
|
+
name: 'besales_knowledge_qa_create',
|
|
387
|
+
requiredFields: ['knowledge_space_id', 'question'],
|
|
388
|
+
defaultWorkspaceId: true,
|
|
389
|
+
schema: z.object({
|
|
390
|
+
workspace_id: uuidSchema.optional(),
|
|
391
|
+
knowledge_space_id: uuidSchema,
|
|
392
|
+
question: z.string().min(1),
|
|
393
|
+
answer: z.string().optional(),
|
|
394
|
+
answer_chunks: z
|
|
395
|
+
.array(z.object({
|
|
396
|
+
text: z.string().optional(),
|
|
397
|
+
stored_file_id: uuidSchema.optional(),
|
|
398
|
+
buttons: z
|
|
399
|
+
.array(z.object({ name: z.string().min(1), url: z.string().min(1) }))
|
|
400
|
+
.optional(),
|
|
401
|
+
}))
|
|
402
|
+
.max(20)
|
|
403
|
+
.optional(),
|
|
404
|
+
alias: z.string().optional(),
|
|
405
|
+
mode: z.enum(['SIMPLE', 'STRICT', 'ONCE_STRICT']).optional(),
|
|
406
|
+
call_operator: z.boolean().optional(),
|
|
407
|
+
chunk_delay_seconds: z.number().int().min(1).optional(),
|
|
408
|
+
is_call_qa_only: z.boolean().optional(),
|
|
409
|
+
}),
|
|
410
|
+
createRequest: (input) => ({
|
|
411
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/qa-pairs`,
|
|
412
|
+
body: compactObject({
|
|
413
|
+
question: input.question,
|
|
414
|
+
answer: input.answer,
|
|
415
|
+
answer_chunks: input.answer_chunks,
|
|
416
|
+
alias: input.alias,
|
|
417
|
+
mode: input.mode,
|
|
418
|
+
call_operator: input.call_operator,
|
|
419
|
+
chunk_delay_seconds: input.chunk_delay_seconds,
|
|
420
|
+
is_call_qa_only: input.is_call_qa_only,
|
|
421
|
+
}),
|
|
422
|
+
}),
|
|
423
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
424
|
+
'Q&A создана. Embedding для вопроса генерируется sync — статус COMPLETED в большинстве случаев сразу.',
|
|
425
|
+
'mode=SIMPLE с одним чанком → используется с RAG; STRICT — только QA-промпт без RAG; ONCE_STRICT — первый раз STRICT, далее как контекст.',
|
|
426
|
+
'is_call_qa_only=true → QA не векторизуется, доступна только через call_qa tool.',
|
|
427
|
+
]),
|
|
428
|
+
}),
|
|
429
|
+
defineTool({
|
|
430
|
+
name: 'besales_knowledge_qa_list',
|
|
431
|
+
requiredFields: ['knowledge_space_id'],
|
|
432
|
+
defaultWorkspaceId: true,
|
|
433
|
+
schema: z.object({
|
|
434
|
+
workspace_id: uuidSchema.optional(),
|
|
435
|
+
knowledge_space_id: uuidSchema,
|
|
436
|
+
mode: z.enum(['SIMPLE', 'STRICT', 'ONCE_STRICT']).optional(),
|
|
437
|
+
page: z.number().int().min(1).optional(),
|
|
438
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
439
|
+
}),
|
|
440
|
+
createRequest: (input) => ({
|
|
441
|
+
method: 'GET',
|
|
442
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/qa-pairs${buildListQuery({ mode: input.mode, page: input.page, limit: input.limit })}`,
|
|
443
|
+
}),
|
|
444
|
+
}),
|
|
445
|
+
defineTool({
|
|
446
|
+
name: 'besales_knowledge_qa_get',
|
|
447
|
+
requiredFields: ['knowledge_space_id', 'qa_id'],
|
|
448
|
+
defaultWorkspaceId: true,
|
|
449
|
+
schema: z.object({
|
|
450
|
+
workspace_id: uuidSchema.optional(),
|
|
451
|
+
knowledge_space_id: uuidSchema,
|
|
452
|
+
qa_id: uuidSchema,
|
|
453
|
+
}),
|
|
454
|
+
createRequest: (input) => ({
|
|
455
|
+
method: 'GET',
|
|
456
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/qa-pairs/${input.qa_id}`,
|
|
457
|
+
}),
|
|
458
|
+
}),
|
|
459
|
+
defineTool({
|
|
460
|
+
name: 'besales_knowledge_qa_patch',
|
|
461
|
+
requiredFields: ['knowledge_space_id', 'qa_id'],
|
|
462
|
+
defaultWorkspaceId: true,
|
|
463
|
+
schema: z.object({
|
|
464
|
+
workspace_id: uuidSchema.optional(),
|
|
465
|
+
knowledge_space_id: uuidSchema,
|
|
466
|
+
qa_id: uuidSchema,
|
|
467
|
+
question: z.string().min(1).optional(),
|
|
468
|
+
answer: z.string().optional(),
|
|
469
|
+
answer_chunks: z
|
|
470
|
+
.array(z.object({
|
|
471
|
+
text: z.string().optional(),
|
|
472
|
+
stored_file_id: uuidSchema.optional(),
|
|
473
|
+
buttons: z
|
|
474
|
+
.array(z.object({ name: z.string().min(1), url: z.string().min(1) }))
|
|
475
|
+
.optional(),
|
|
476
|
+
}))
|
|
477
|
+
.max(20)
|
|
478
|
+
.optional(),
|
|
479
|
+
alias: z.string().optional(),
|
|
480
|
+
mode: z.enum(['SIMPLE', 'STRICT', 'ONCE_STRICT']).optional(),
|
|
481
|
+
call_operator: z.boolean().optional(),
|
|
482
|
+
chunk_delay_seconds: z.number().int().min(1).optional(),
|
|
483
|
+
is_call_qa_only: z.boolean().optional(),
|
|
484
|
+
}),
|
|
485
|
+
createRequest: (input) => ({
|
|
486
|
+
method: 'PATCH',
|
|
487
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/qa-pairs/${input.qa_id}`,
|
|
488
|
+
body: compactObject({
|
|
489
|
+
question: input.question,
|
|
490
|
+
answer: input.answer,
|
|
491
|
+
answer_chunks: input.answer_chunks,
|
|
492
|
+
alias: input.alias,
|
|
493
|
+
mode: input.mode,
|
|
494
|
+
call_operator: input.call_operator,
|
|
495
|
+
chunk_delay_seconds: input.chunk_delay_seconds,
|
|
496
|
+
is_call_qa_only: input.is_call_qa_only,
|
|
497
|
+
}),
|
|
498
|
+
}),
|
|
499
|
+
}),
|
|
500
|
+
defineTool({
|
|
501
|
+
name: 'besales_knowledge_qa_delete',
|
|
502
|
+
requiredFields: ['knowledge_space_id', 'qa_id', 'explicit_confirmation'],
|
|
503
|
+
defaultWorkspaceId: true,
|
|
504
|
+
schema: z.object({
|
|
505
|
+
workspace_id: uuidSchema.optional(),
|
|
506
|
+
knowledge_space_id: uuidSchema,
|
|
507
|
+
qa_id: uuidSchema,
|
|
508
|
+
explicit_confirmation: z.boolean(),
|
|
509
|
+
}),
|
|
510
|
+
createRequest: (input) => ({
|
|
511
|
+
method: 'DELETE',
|
|
512
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/qa-pairs/${input.qa_id}`,
|
|
513
|
+
body: { explicit_confirmation: input.explicit_confirmation },
|
|
514
|
+
}),
|
|
515
|
+
}),
|
|
516
|
+
defineTool({
|
|
517
|
+
name: 'besales_knowledge_qa_search',
|
|
518
|
+
requiredFields: ['knowledge_space_id', 'query'],
|
|
519
|
+
defaultWorkspaceId: true,
|
|
520
|
+
schema: z.object({
|
|
521
|
+
workspace_id: uuidSchema.optional(),
|
|
522
|
+
knowledge_space_id: uuidSchema,
|
|
523
|
+
query: z.string().min(1),
|
|
524
|
+
top_k: z.number().int().min(1).max(50).optional(),
|
|
525
|
+
min_score: z.number().optional(),
|
|
526
|
+
}),
|
|
527
|
+
createRequest: (input) => ({
|
|
528
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/qa-pairs/search`,
|
|
529
|
+
body: compactObject({
|
|
530
|
+
query: input.query,
|
|
531
|
+
top_k: input.top_k,
|
|
532
|
+
min_score: input.min_score,
|
|
533
|
+
}),
|
|
534
|
+
}),
|
|
535
|
+
}),
|
|
536
|
+
defineTool({
|
|
537
|
+
name: 'besales_knowledge_qa_move',
|
|
538
|
+
requiredFields: ['source_space_id', 'qa_id', 'target_space_id', 'explicit_confirmation'],
|
|
539
|
+
defaultWorkspaceId: true,
|
|
540
|
+
schema: z.object({
|
|
541
|
+
workspace_id: uuidSchema.optional(),
|
|
542
|
+
source_space_id: uuidSchema,
|
|
543
|
+
qa_id: uuidSchema,
|
|
544
|
+
target_space_id: uuidSchema,
|
|
545
|
+
explicit_confirmation: z.boolean(),
|
|
546
|
+
}),
|
|
547
|
+
createRequest: (input) => ({
|
|
548
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.source_space_id}/qa-pairs/${input.qa_id}/move`,
|
|
549
|
+
body: {
|
|
550
|
+
target_space_id: input.target_space_id,
|
|
551
|
+
explicit_confirmation: input.explicit_confirmation,
|
|
552
|
+
},
|
|
553
|
+
}),
|
|
554
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
555
|
+
'Move = delete + recreate в новом knowledge space. Возвращается новый ID — обнови ссылки в caller-коде.',
|
|
556
|
+
'Pinecone vectors переиндексируются: старый embedding удаляется из source namespace, новый создаётся в target.',
|
|
557
|
+
'Alias НЕ переносится (unique-per-workspace constraint).',
|
|
558
|
+
]),
|
|
559
|
+
}),
|
|
560
|
+
// ----- v1.5 Increment 2: Websites (4 tools) -----
|
|
561
|
+
defineTool({
|
|
562
|
+
name: 'besales_knowledge_website_add',
|
|
563
|
+
requiredFields: ['knowledge_space_id', 'url'],
|
|
564
|
+
defaultWorkspaceId: true,
|
|
565
|
+
schema: z.object({
|
|
566
|
+
workspace_id: uuidSchema.optional(),
|
|
567
|
+
knowledge_space_id: uuidSchema,
|
|
568
|
+
url: z.string().url(),
|
|
569
|
+
display_name: z.string().optional(),
|
|
570
|
+
}),
|
|
571
|
+
createRequest: (input) => ({
|
|
572
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/websites`,
|
|
573
|
+
body: compactObject({
|
|
574
|
+
url: input.url,
|
|
575
|
+
display_name: input.display_name,
|
|
576
|
+
}),
|
|
577
|
+
}),
|
|
578
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
579
|
+
'SYNC operation — может занять несколько секунд для краулинга + chunking + Pinecone upsert.',
|
|
580
|
+
'Idempotency: повторный POST с тем же URL вернёт existing site, replaced=true. FAILED перезапускается автоматически.',
|
|
581
|
+
'Status: PENDING → CRAWLING → PROCESSING → COMPLETED | FAILED.',
|
|
582
|
+
]),
|
|
583
|
+
}),
|
|
584
|
+
defineTool({
|
|
585
|
+
name: 'besales_knowledge_website_list',
|
|
586
|
+
requiredFields: ['knowledge_space_id'],
|
|
587
|
+
defaultWorkspaceId: true,
|
|
588
|
+
schema: z.object({
|
|
589
|
+
workspace_id: uuidSchema.optional(),
|
|
590
|
+
knowledge_space_id: uuidSchema,
|
|
591
|
+
status: z.enum(['PENDING', 'CRAWLING', 'PROCESSING', 'COMPLETED', 'FAILED']).optional(),
|
|
592
|
+
page: z.number().int().min(1).optional(),
|
|
593
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
594
|
+
}),
|
|
595
|
+
createRequest: (input) => ({
|
|
596
|
+
method: 'GET',
|
|
597
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/websites${buildListQuery({ status: input.status, page: input.page, limit: input.limit })}`,
|
|
598
|
+
}),
|
|
599
|
+
}),
|
|
600
|
+
defineTool({
|
|
601
|
+
name: 'besales_knowledge_website_get',
|
|
602
|
+
requiredFields: ['knowledge_space_id', 'website_id'],
|
|
603
|
+
defaultWorkspaceId: true,
|
|
604
|
+
schema: z.object({
|
|
605
|
+
workspace_id: uuidSchema.optional(),
|
|
606
|
+
knowledge_space_id: uuidSchema,
|
|
607
|
+
website_id: uuidSchema,
|
|
608
|
+
}),
|
|
609
|
+
createRequest: (input) => ({
|
|
610
|
+
method: 'GET',
|
|
611
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/websites/${input.website_id}`,
|
|
612
|
+
}),
|
|
613
|
+
}),
|
|
614
|
+
defineTool({
|
|
615
|
+
name: 'besales_knowledge_website_delete',
|
|
616
|
+
requiredFields: ['knowledge_space_id', 'website_id', 'explicit_confirmation'],
|
|
617
|
+
defaultWorkspaceId: true,
|
|
618
|
+
schema: z.object({
|
|
619
|
+
workspace_id: uuidSchema.optional(),
|
|
620
|
+
knowledge_space_id: uuidSchema,
|
|
621
|
+
website_id: uuidSchema,
|
|
622
|
+
explicit_confirmation: z.boolean(),
|
|
623
|
+
}),
|
|
624
|
+
createRequest: (input) => ({
|
|
625
|
+
method: 'DELETE',
|
|
626
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/websites/${input.website_id}`,
|
|
627
|
+
body: { explicit_confirmation: input.explicit_confirmation },
|
|
628
|
+
}),
|
|
629
|
+
}),
|
|
630
|
+
// ============================================================
|
|
631
|
+
// v1.5 Increment 3 Group A.5 — Knowledge tables (6 tools)
|
|
632
|
+
// ============================================================
|
|
633
|
+
defineTool({
|
|
634
|
+
name: 'besales_knowledge_table_link',
|
|
635
|
+
requiredFields: ['knowledge_space_id', 'source', 'display_name'],
|
|
636
|
+
defaultWorkspaceId: true,
|
|
637
|
+
schema: z.object({
|
|
638
|
+
workspace_id: uuidSchema.optional(),
|
|
639
|
+
knowledge_space_id: uuidSchema,
|
|
640
|
+
source: knowledgeTableSourceSchema,
|
|
641
|
+
display_name: z.string(),
|
|
642
|
+
header_row_index: z.number().int().min(1).optional(),
|
|
643
|
+
cache_ttl_seconds: z.number().int().min(1).optional(),
|
|
644
|
+
use_vector_index: z.boolean().optional(),
|
|
645
|
+
vector_top_k: z.number().int().min(1).optional(),
|
|
646
|
+
vector_embed_max_chars: z.number().int().min(1).optional(),
|
|
647
|
+
access: z.enum(['PUBLIC', 'PRIVATE']).optional(),
|
|
648
|
+
}),
|
|
649
|
+
createRequest: (input) => ({
|
|
650
|
+
method: 'POST',
|
|
651
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/tables`,
|
|
652
|
+
body: compactObject({
|
|
653
|
+
source: {
|
|
654
|
+
kind: input.source.kind,
|
|
655
|
+
spreadsheet_url: input.source.spreadsheet_url,
|
|
656
|
+
table_schema: input.source.table_schema,
|
|
657
|
+
},
|
|
658
|
+
display_name: input.display_name,
|
|
659
|
+
header_row_index: input.header_row_index,
|
|
660
|
+
cache_ttl_seconds: input.cache_ttl_seconds,
|
|
661
|
+
use_vector_index: input.use_vector_index,
|
|
662
|
+
vector_top_k: input.vector_top_k,
|
|
663
|
+
vector_embed_max_chars: input.vector_embed_max_chars,
|
|
664
|
+
access: input.access,
|
|
665
|
+
}),
|
|
666
|
+
}),
|
|
667
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
668
|
+
'Knowledge table связана. Если URL уже существовал, replaced=true (idempotency by namespace+url).',
|
|
669
|
+
'Для индексации в Pinecone установи use_vector_index=true и вызови besales_knowledge_table_reindex.',
|
|
670
|
+
]),
|
|
671
|
+
}),
|
|
672
|
+
defineTool({
|
|
673
|
+
name: 'besales_knowledge_table_list',
|
|
674
|
+
requiredFields: ['knowledge_space_id'],
|
|
675
|
+
defaultWorkspaceId: true,
|
|
676
|
+
schema: z.object({
|
|
677
|
+
workspace_id: uuidSchema.optional(),
|
|
678
|
+
knowledge_space_id: uuidSchema,
|
|
679
|
+
is_active: z.boolean().optional(),
|
|
680
|
+
page: z.number().int().min(1).optional(),
|
|
681
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
682
|
+
}),
|
|
683
|
+
createRequest: (input) => ({
|
|
684
|
+
method: 'GET',
|
|
685
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/tables${buildListQuery({ is_active: input.is_active, page: input.page, limit: input.limit })}`,
|
|
686
|
+
}),
|
|
687
|
+
}),
|
|
688
|
+
defineTool({
|
|
689
|
+
name: 'besales_knowledge_table_get',
|
|
690
|
+
requiredFields: ['knowledge_space_id', 'table_id'],
|
|
691
|
+
defaultWorkspaceId: true,
|
|
692
|
+
schema: z.object({
|
|
693
|
+
workspace_id: uuidSchema.optional(),
|
|
694
|
+
knowledge_space_id: uuidSchema,
|
|
695
|
+
table_id: uuidSchema,
|
|
696
|
+
}),
|
|
697
|
+
createRequest: (input) => ({
|
|
698
|
+
method: 'GET',
|
|
699
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/tables/${input.table_id}`,
|
|
700
|
+
}),
|
|
701
|
+
}),
|
|
702
|
+
defineTool({
|
|
703
|
+
name: 'besales_knowledge_table_patch',
|
|
704
|
+
requiredFields: ['knowledge_space_id', 'table_id'],
|
|
705
|
+
defaultWorkspaceId: true,
|
|
706
|
+
schema: z.object({
|
|
707
|
+
workspace_id: uuidSchema.optional(),
|
|
708
|
+
knowledge_space_id: uuidSchema,
|
|
709
|
+
table_id: uuidSchema,
|
|
710
|
+
// source присутствует только для validation (URL иммутабельный).
|
|
711
|
+
source: knowledgeTableSourceSchema.optional(),
|
|
712
|
+
display_name: z.string().optional(),
|
|
713
|
+
header_row_index: z.number().int().min(1).optional(),
|
|
714
|
+
cache_ttl_seconds: z.number().int().min(1).optional(),
|
|
715
|
+
use_vector_index: z.boolean().optional(),
|
|
716
|
+
vector_top_k: z.number().int().min(1).optional(),
|
|
717
|
+
vector_embed_max_chars: z.number().int().min(1).optional(),
|
|
718
|
+
access: z.enum(['PUBLIC', 'PRIVATE']).optional(),
|
|
719
|
+
is_active: z.boolean().optional(),
|
|
720
|
+
}),
|
|
721
|
+
createRequest: (input) => ({
|
|
722
|
+
method: 'PATCH',
|
|
723
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/tables/${input.table_id}`,
|
|
724
|
+
body: compactObject({
|
|
725
|
+
source: input.source
|
|
726
|
+
? {
|
|
727
|
+
kind: input.source.kind,
|
|
728
|
+
spreadsheet_url: input.source.spreadsheet_url,
|
|
729
|
+
table_schema: input.source.table_schema,
|
|
730
|
+
}
|
|
731
|
+
: undefined,
|
|
732
|
+
display_name: input.display_name,
|
|
733
|
+
header_row_index: input.header_row_index,
|
|
734
|
+
cache_ttl_seconds: input.cache_ttl_seconds,
|
|
735
|
+
use_vector_index: input.use_vector_index,
|
|
736
|
+
vector_top_k: input.vector_top_k,
|
|
737
|
+
vector_embed_max_chars: input.vector_embed_max_chars,
|
|
738
|
+
access: input.access,
|
|
739
|
+
is_active: input.is_active,
|
|
740
|
+
}),
|
|
741
|
+
}),
|
|
742
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
743
|
+
'source.url иммутабельный — для смены URL используй delete + create.',
|
|
744
|
+
]),
|
|
745
|
+
}),
|
|
746
|
+
defineTool({
|
|
747
|
+
name: 'besales_knowledge_table_delete',
|
|
748
|
+
requiredFields: ['knowledge_space_id', 'table_id', 'explicit_confirmation'],
|
|
749
|
+
defaultWorkspaceId: true,
|
|
750
|
+
schema: z.object({
|
|
751
|
+
workspace_id: uuidSchema.optional(),
|
|
752
|
+
knowledge_space_id: uuidSchema,
|
|
753
|
+
table_id: uuidSchema,
|
|
754
|
+
explicit_confirmation: z.boolean(),
|
|
755
|
+
}),
|
|
756
|
+
createRequest: (input) => ({
|
|
757
|
+
method: 'DELETE',
|
|
758
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/tables/${input.table_id}`,
|
|
759
|
+
body: { explicit_confirmation: input.explicit_confirmation },
|
|
760
|
+
}),
|
|
761
|
+
}),
|
|
762
|
+
defineTool({
|
|
763
|
+
name: 'besales_knowledge_table_reindex',
|
|
764
|
+
requiredFields: ['knowledge_space_id', 'table_id', 'explicit_confirmation'],
|
|
765
|
+
defaultWorkspaceId: true,
|
|
766
|
+
schema: z.object({
|
|
767
|
+
workspace_id: uuidSchema.optional(),
|
|
768
|
+
knowledge_space_id: uuidSchema,
|
|
769
|
+
table_id: uuidSchema,
|
|
770
|
+
explicit_confirmation: z.boolean(),
|
|
771
|
+
}),
|
|
772
|
+
createRequest: (input) => ({
|
|
773
|
+
method: 'POST',
|
|
774
|
+
path: `/workspaces/${input.workspace_id}/knowledge-spaces/${input.knowledge_space_id}/tables/${input.table_id}/reindex`,
|
|
775
|
+
body: { explicit_confirmation: input.explicit_confirmation },
|
|
776
|
+
}),
|
|
777
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
778
|
+
'Triggers full re-index в Pinecone (delete vectors + re-fetch CSV + re-embed + upsert). Может занять время для больших таблиц.',
|
|
779
|
+
]),
|
|
780
|
+
}),
|
|
781
|
+
];
|
|
782
|
+
//# sourceMappingURL=knowledge.js.map
|