@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,738 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { agentOutputConfigSchema, agentRuntimeConfigSchema, agentScopeSchema, agentToolPatchSchema, anyObjectSchema, behaviorErrorHandlingSchema, behaviorGreetingSchema, behaviorMediaHandlingSchema, behaviorMessageFilterSchema, behaviorMessageSplittingSchema, behaviorOperatorScheduleSchema, behaviorPrivacySchema, behaviorTypingBehaviorSchema, behaviorUrlHandlingSchema, compactObject, defineTool, feedbackSheetRowSchema, followUpSequenceTypeSchema, followUpTriggerSchema, mapBehaviorErrorHandlingInput, mapBehaviorGreetingInput, mapBehaviorMediaHandlingInput, mapBehaviorOperatorScheduleInput, mapBehaviorTypingInput, mapBehaviorUrlHandlingInput, mapOutputConfigInput, mapPipelineAutoFinishInput, mapPipelineCrmBehaviorInput, mapPlatformAccessControlInput, mapPlatformBitrix24BotSettingsInput, mapPlatformCrmBehaviorInput, mapPlatformGeneralSettingsInput, mapPlatformGetcourseSettingsInput, mapPlatformInstagramCommentInput, mapPlatformSalebotSettingsInput, mapPlatformSmsgorodSettingsInput, mapPlatformVariablesConfigInput, mapPlatformWidgetMarketingInput, mapRuntimeConfigInput, modelLaneSchema, pipelineAutoFinishSchema, pipelineCrmBehaviorSchema, platformAccessControlSchema, platformBitrix24BotSettingsSchema, platformCrmBehaviorSchema, platformGeneralSettingsSchema, platformGetcourseSettingsSchema, platformInstagramCommentSchema, platformSalebotSettingsSchema, platformSetupConfirmationSchema, platformSmsgorodSettingsSchema, platformVariablesConfigSchema, platformWidgetMarketingSchema, routingRuleLeadStatusSchema, routingStrategySchema, setupConfirmation, triggerScopeSchema, uuidSchema, withInstructions, } from './shared.js';
|
|
3
|
+
export const platformSetupTools = [
|
|
4
|
+
defineTool({
|
|
5
|
+
name: 'besales_workspace_overview',
|
|
6
|
+
requiredFields: [],
|
|
7
|
+
defaultWorkspaceId: true,
|
|
8
|
+
schema: z.object({
|
|
9
|
+
workspace_id: uuidSchema.optional(),
|
|
10
|
+
}),
|
|
11
|
+
createRequest: (input) => ({
|
|
12
|
+
method: 'GET',
|
|
13
|
+
path: `/workspaces/${input.workspace_id}/overview`,
|
|
14
|
+
}),
|
|
15
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
16
|
+
'Single-shot snapshot всего workspace: platforms (с agentsCount), ICP profiles (с segments/samples counts), feedback sheets, MCP connections summary.',
|
|
17
|
+
'Используй ПЕРВЫМ когда user задаёт open-ended вопросы вида "что у меня есть?" / "покажи мою настройку" — заменяет N round-trips.',
|
|
18
|
+
'`setupCompleteness` — readiness-сигнал «что недоделано»: channelsConnected/Pending, crmConnected, hasAnchorAgent, hasKnowledge, knowledgeLinkedToChannel, hasTriggers/Followups, hasIcp, lastSandboxRunAt, suggestedNextPhase. Используй suggestedNextPhase как мягкий hint следующего фокуса (не приказ); продолжай настройку с него, а не с нуля.',
|
|
19
|
+
'После overview перейди на drill-down: `besales_platform_context_get` для конкретной платформы, `besales_agent_list` для агентов внутри неё.',
|
|
20
|
+
]),
|
|
21
|
+
}),
|
|
22
|
+
defineTool({
|
|
23
|
+
name: 'besales_platform_context_get',
|
|
24
|
+
requiredFields: ['platform_id'],
|
|
25
|
+
schema: z.object({
|
|
26
|
+
platform_id: uuidSchema,
|
|
27
|
+
}),
|
|
28
|
+
createRequest: (input) => ({
|
|
29
|
+
method: 'GET',
|
|
30
|
+
path: `/platforms/${input.platform_id}/setup/context`,
|
|
31
|
+
}),
|
|
32
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
33
|
+
'Use this sanitized context first for Platform Setup Bridge flows.',
|
|
34
|
+
'Read readiness flags, then call targeted mutation tools. Do not ask the user for workspace_id.',
|
|
35
|
+
'Prompt content changes still go through besales_prompt_* tools and besales_prompt_finalize.',
|
|
36
|
+
]),
|
|
37
|
+
}),
|
|
38
|
+
defineTool({
|
|
39
|
+
name: 'besales_agent_list',
|
|
40
|
+
requiredFields: ['platform_id'],
|
|
41
|
+
schema: z.object({
|
|
42
|
+
platform_id: uuidSchema,
|
|
43
|
+
}),
|
|
44
|
+
createRequest: (input) => ({
|
|
45
|
+
method: 'GET',
|
|
46
|
+
path: `/platforms/${input.platform_id}/agents`,
|
|
47
|
+
}),
|
|
48
|
+
}),
|
|
49
|
+
defineTool({
|
|
50
|
+
name: 'besales_agent_create',
|
|
51
|
+
requiredFields: ['platform_id', 'name', 'model_lane'],
|
|
52
|
+
schema: z.object({
|
|
53
|
+
platform_id: uuidSchema,
|
|
54
|
+
name: z.string(),
|
|
55
|
+
description: z.string().nullable().optional(),
|
|
56
|
+
model_lane: modelLaneSchema,
|
|
57
|
+
default_icp_profile_id: uuidSchema.optional(),
|
|
58
|
+
}),
|
|
59
|
+
createRequest: (input) => ({
|
|
60
|
+
path: `/platforms/${input.platform_id}/agents`,
|
|
61
|
+
body: compactObject({
|
|
62
|
+
name: input.name,
|
|
63
|
+
description: input.description,
|
|
64
|
+
modelLane: input.model_lane,
|
|
65
|
+
defaultIcpProfileId: input.default_icp_profile_id,
|
|
66
|
+
}),
|
|
67
|
+
}),
|
|
68
|
+
}),
|
|
69
|
+
defineTool({
|
|
70
|
+
name: 'besales_agent_update',
|
|
71
|
+
requiredFields: ['platform_id', 'agent_id'],
|
|
72
|
+
schema: z.object({
|
|
73
|
+
platform_id: uuidSchema,
|
|
74
|
+
agent_id: uuidSchema,
|
|
75
|
+
name: z.string().optional(),
|
|
76
|
+
description: z.string().nullable().optional(),
|
|
77
|
+
model_lane: modelLaneSchema.optional(),
|
|
78
|
+
default_icp_profile_id: uuidSchema.nullable().optional(),
|
|
79
|
+
use_global_history: z.boolean().optional(),
|
|
80
|
+
adapt_to_user_language: z.boolean().optional(),
|
|
81
|
+
// v1.5 Increment 3 Group B — typed sections.
|
|
82
|
+
runtime_config: agentRuntimeConfigSchema.optional(),
|
|
83
|
+
output_config: agentOutputConfigSchema.optional(),
|
|
84
|
+
knowledge_space_ids: z.array(uuidSchema).optional(),
|
|
85
|
+
agent_scope: agentScopeSchema.optional(),
|
|
86
|
+
}),
|
|
87
|
+
createRequest: (input) => ({
|
|
88
|
+
method: 'PATCH',
|
|
89
|
+
path: `/platforms/${input.platform_id}/agents/${input.agent_id}`,
|
|
90
|
+
body: compactObject({
|
|
91
|
+
name: input.name,
|
|
92
|
+
description: input.description,
|
|
93
|
+
modelLane: input.model_lane,
|
|
94
|
+
defaultIcpProfileId: input.default_icp_profile_id,
|
|
95
|
+
useGlobalHistory: input.use_global_history,
|
|
96
|
+
adaptToUserLanguage: input.adapt_to_user_language,
|
|
97
|
+
runtimeConfig: input.runtime_config
|
|
98
|
+
? mapRuntimeConfigInput(input.runtime_config)
|
|
99
|
+
: undefined,
|
|
100
|
+
outputConfig: input.output_config ? mapOutputConfigInput(input.output_config) : undefined,
|
|
101
|
+
knowledgeSpaceIds: input.knowledge_space_ids,
|
|
102
|
+
agentScope: input.agent_scope,
|
|
103
|
+
}),
|
|
104
|
+
}),
|
|
105
|
+
}),
|
|
106
|
+
// Phase B (2026-05-27): `besales_agent_legacy_self_analysis_set` удалён.
|
|
107
|
+
// В v2 заменён post_processors (Routing Studio Critic node) + post_processor_bindings.
|
|
108
|
+
defineTool({
|
|
109
|
+
name: 'besales_agent_tools_update',
|
|
110
|
+
requiredFields: ['platform_id', 'agent_id', 'tools'],
|
|
111
|
+
schema: z.object({
|
|
112
|
+
platform_id: uuidSchema,
|
|
113
|
+
agent_id: uuidSchema,
|
|
114
|
+
tools: z.array(agentToolPatchSchema).min(1),
|
|
115
|
+
}),
|
|
116
|
+
createRequest: (input) => ({
|
|
117
|
+
method: 'PATCH',
|
|
118
|
+
path: `/platforms/${input.platform_id}/agents/${input.agent_id}/tools`,
|
|
119
|
+
body: {
|
|
120
|
+
tools: input.tools.map((tool) => compactObject({
|
|
121
|
+
toolId: tool.tool_id,
|
|
122
|
+
priority: tool.priority,
|
|
123
|
+
isEnabled: tool.is_enabled,
|
|
124
|
+
agentSpecificConditions: tool.agent_specific_conditions,
|
|
125
|
+
})),
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
}),
|
|
129
|
+
defineTool({
|
|
130
|
+
name: 'besales_router_update',
|
|
131
|
+
requiredFields: ['platform_id'],
|
|
132
|
+
schema: z.object({
|
|
133
|
+
platform_id: uuidSchema,
|
|
134
|
+
name: z.string().optional(),
|
|
135
|
+
model: z.string().optional(),
|
|
136
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
137
|
+
max_tokens: z.number().int().min(1).nullable().optional(),
|
|
138
|
+
additional_prompt: z.string().nullable().optional(),
|
|
139
|
+
adapt_to_user_language: z.boolean().optional(),
|
|
140
|
+
skip_llm_routing: z.boolean().optional(),
|
|
141
|
+
direct_routing_agent_id: uuidSchema.nullable().optional(),
|
|
142
|
+
...platformSetupConfirmationSchema,
|
|
143
|
+
}),
|
|
144
|
+
createRequest: (input) => ({
|
|
145
|
+
method: 'PATCH',
|
|
146
|
+
path: `/platforms/${input.platform_id}/router`,
|
|
147
|
+
body: compactObject({
|
|
148
|
+
name: input.name,
|
|
149
|
+
model: input.model,
|
|
150
|
+
temperature: input.temperature,
|
|
151
|
+
maxTokens: input.max_tokens,
|
|
152
|
+
additionalPrompt: input.additional_prompt,
|
|
153
|
+
adaptToUserLanguage: input.adapt_to_user_language,
|
|
154
|
+
skipLlmRouting: input.skip_llm_routing,
|
|
155
|
+
directRoutingAgentId: input.direct_routing_agent_id,
|
|
156
|
+
...setupConfirmation(input),
|
|
157
|
+
}),
|
|
158
|
+
}),
|
|
159
|
+
}),
|
|
160
|
+
defineTool({
|
|
161
|
+
name: 'besales_routing_rule_upsert',
|
|
162
|
+
requiredFields: ['platform_id', 'routing_strategy', 'custom_router_prompt'],
|
|
163
|
+
schema: z.object({
|
|
164
|
+
platform_id: uuidSchema,
|
|
165
|
+
routing_rule_id: uuidSchema.optional(),
|
|
166
|
+
routing_strategy: routingStrategySchema,
|
|
167
|
+
deal_mode: z.string().nullable().optional(),
|
|
168
|
+
custom_variable_id: uuidSchema.nullable().optional(),
|
|
169
|
+
variable_value: z.string().nullable().optional(),
|
|
170
|
+
custom_router_prompt: z.string(),
|
|
171
|
+
is_enabled: z.boolean().optional(),
|
|
172
|
+
priority: z.number().int().min(0).optional(),
|
|
173
|
+
skip_llm: z.boolean().optional(),
|
|
174
|
+
direct_agent_id: uuidSchema.nullable().optional(),
|
|
175
|
+
lead_statuses: z.array(routingRuleLeadStatusSchema).optional(),
|
|
176
|
+
...platformSetupConfirmationSchema,
|
|
177
|
+
}),
|
|
178
|
+
createRequest: (input) => ({
|
|
179
|
+
method: input.routing_rule_id ? 'PATCH' : 'POST',
|
|
180
|
+
path: `/platforms/${input.platform_id}/router/routing-rules`,
|
|
181
|
+
body: compactObject({
|
|
182
|
+
routingRuleId: input.routing_rule_id,
|
|
183
|
+
routingStrategy: input.routing_strategy,
|
|
184
|
+
dealMode: input.deal_mode,
|
|
185
|
+
customVariableId: input.custom_variable_id,
|
|
186
|
+
variableValue: input.variable_value,
|
|
187
|
+
customRouterPrompt: input.custom_router_prompt,
|
|
188
|
+
isEnabled: input.is_enabled,
|
|
189
|
+
priority: input.priority,
|
|
190
|
+
skipLlm: input.skip_llm,
|
|
191
|
+
directAgentId: input.direct_agent_id,
|
|
192
|
+
leadStatuses: input.lead_statuses?.map((status) => compactObject({
|
|
193
|
+
leadStatusName: status.lead_status_name,
|
|
194
|
+
leadStatusPipelineCrmId: status.lead_status_pipeline_crm_id,
|
|
195
|
+
leadStatusPipelineId: status.lead_status_pipeline_id,
|
|
196
|
+
leadStatusId: status.lead_status_id,
|
|
197
|
+
})),
|
|
198
|
+
...setupConfirmation(input),
|
|
199
|
+
}),
|
|
200
|
+
}),
|
|
201
|
+
}),
|
|
202
|
+
defineTool({
|
|
203
|
+
name: 'besales_trigger_upsert',
|
|
204
|
+
requiredFields: ['platform_id', 'agent_id'],
|
|
205
|
+
schema: z.object({
|
|
206
|
+
platform_id: uuidSchema,
|
|
207
|
+
agent_id: uuidSchema,
|
|
208
|
+
trigger_id: uuidSchema.optional(),
|
|
209
|
+
name: z.string().optional(),
|
|
210
|
+
condition: z.string().optional(),
|
|
211
|
+
is_enabled: z.boolean().optional(),
|
|
212
|
+
priority: z.number().int().min(1).max(100).optional(),
|
|
213
|
+
stop_propagation: z.boolean().optional(),
|
|
214
|
+
scope: triggerScopeSchema,
|
|
215
|
+
metadata: anyObjectSchema.optional(),
|
|
216
|
+
actions: z.array(anyObjectSchema).optional(),
|
|
217
|
+
...platformSetupConfirmationSchema,
|
|
218
|
+
}),
|
|
219
|
+
createRequest: (input) => ({
|
|
220
|
+
method: input.trigger_id ? 'PATCH' : 'POST',
|
|
221
|
+
path: input.trigger_id
|
|
222
|
+
? `/platforms/${input.platform_id}/agents/${input.agent_id}/triggers/${input.trigger_id}`
|
|
223
|
+
: `/platforms/${input.platform_id}/agents/${input.agent_id}/triggers`,
|
|
224
|
+
body: compactObject({
|
|
225
|
+
name: input.name,
|
|
226
|
+
condition: input.condition,
|
|
227
|
+
isEnabled: input.is_enabled,
|
|
228
|
+
priority: input.priority,
|
|
229
|
+
stopPropagation: input.stop_propagation,
|
|
230
|
+
scope: input.scope,
|
|
231
|
+
metadata: input.metadata,
|
|
232
|
+
actions: input.actions,
|
|
233
|
+
...setupConfirmation(input),
|
|
234
|
+
}),
|
|
235
|
+
}),
|
|
236
|
+
}),
|
|
237
|
+
defineTool({
|
|
238
|
+
name: 'besales_behavior_update',
|
|
239
|
+
requiredFields: ['platform_id'],
|
|
240
|
+
schema: z
|
|
241
|
+
.object({
|
|
242
|
+
platform_id: uuidSchema,
|
|
243
|
+
// v1.5 Increment 3 Group C.1 (Phase B, 2026-05-27): только typed sections.
|
|
244
|
+
greeting: behaviorGreetingSchema.optional(),
|
|
245
|
+
media_handling: behaviorMediaHandlingSchema.optional(),
|
|
246
|
+
url_handling: behaviorUrlHandlingSchema.optional(),
|
|
247
|
+
error_handling: behaviorErrorHandlingSchema.optional(),
|
|
248
|
+
operator_schedule: behaviorOperatorScheduleSchema.optional(),
|
|
249
|
+
typing_behavior: behaviorTypingBehaviorSchema.optional(),
|
|
250
|
+
message_filters: z.array(behaviorMessageFilterSchema).optional(),
|
|
251
|
+
message_splitting: behaviorMessageSplittingSchema.optional(),
|
|
252
|
+
privacy: behaviorPrivacySchema.optional(),
|
|
253
|
+
...platformSetupConfirmationSchema,
|
|
254
|
+
})
|
|
255
|
+
.strict(),
|
|
256
|
+
createRequest: (input) => ({
|
|
257
|
+
method: 'PATCH',
|
|
258
|
+
path: `/platforms/${input.platform_id}/agent-behavior`,
|
|
259
|
+
body: compactObject({
|
|
260
|
+
greeting: input.greeting ? mapBehaviorGreetingInput(input.greeting) : undefined,
|
|
261
|
+
mediaHandling: input.media_handling
|
|
262
|
+
? mapBehaviorMediaHandlingInput(input.media_handling)
|
|
263
|
+
: undefined,
|
|
264
|
+
urlHandling: input.url_handling
|
|
265
|
+
? mapBehaviorUrlHandlingInput(input.url_handling)
|
|
266
|
+
: undefined,
|
|
267
|
+
errorHandling: input.error_handling
|
|
268
|
+
? mapBehaviorErrorHandlingInput(input.error_handling)
|
|
269
|
+
: undefined,
|
|
270
|
+
operatorSchedule: input.operator_schedule
|
|
271
|
+
? mapBehaviorOperatorScheduleInput(input.operator_schedule)
|
|
272
|
+
: undefined,
|
|
273
|
+
typingBehavior: input.typing_behavior
|
|
274
|
+
? mapBehaviorTypingInput(input.typing_behavior)
|
|
275
|
+
: undefined,
|
|
276
|
+
messageFilters: input.message_filters
|
|
277
|
+
? input.message_filters.map((filter) => ({
|
|
278
|
+
id: filter.id,
|
|
279
|
+
source: filter.source,
|
|
280
|
+
target: filter.target,
|
|
281
|
+
enabled: filter.enabled,
|
|
282
|
+
order: filter.order,
|
|
283
|
+
}))
|
|
284
|
+
: undefined,
|
|
285
|
+
messageSplitting: input.message_splitting
|
|
286
|
+
? { messageChunkSeparator: input.message_splitting.message_chunk_separator }
|
|
287
|
+
: undefined,
|
|
288
|
+
privacy: input.privacy
|
|
289
|
+
? {
|
|
290
|
+
anonymizationEnabled: input.privacy.anonymization_enabled,
|
|
291
|
+
anonymizationDisabledTypes: input.privacy.anonymization_disabled_types,
|
|
292
|
+
}
|
|
293
|
+
: undefined,
|
|
294
|
+
...setupConfirmation(input),
|
|
295
|
+
}),
|
|
296
|
+
}),
|
|
297
|
+
}),
|
|
298
|
+
defineTool({
|
|
299
|
+
name: 'besales_followup_sequence_upsert',
|
|
300
|
+
requiredFields: ['platform_id', 'name', 'type', 'trigger', 'config'],
|
|
301
|
+
schema: z.object({
|
|
302
|
+
platform_id: uuidSchema,
|
|
303
|
+
sequence_id: uuidSchema.optional(),
|
|
304
|
+
name: z.string(),
|
|
305
|
+
description: z.string().nullable().optional(),
|
|
306
|
+
type: followUpSequenceTypeSchema,
|
|
307
|
+
enabled: z.boolean().optional(),
|
|
308
|
+
trigger: followUpTriggerSchema,
|
|
309
|
+
config: anyObjectSchema,
|
|
310
|
+
...platformSetupConfirmationSchema,
|
|
311
|
+
}),
|
|
312
|
+
createRequest: (input) => ({
|
|
313
|
+
method: input.sequence_id ? 'PATCH' : 'POST',
|
|
314
|
+
path: input.sequence_id
|
|
315
|
+
? `/platforms/${input.platform_id}/follow-up/sequences/${input.sequence_id}`
|
|
316
|
+
: `/platforms/${input.platform_id}/follow-up/sequences`,
|
|
317
|
+
body: compactObject({
|
|
318
|
+
name: input.name,
|
|
319
|
+
description: input.description,
|
|
320
|
+
type: input.type,
|
|
321
|
+
enabled: input.enabled,
|
|
322
|
+
trigger: input.trigger,
|
|
323
|
+
config: input.config,
|
|
324
|
+
...setupConfirmation(input),
|
|
325
|
+
}),
|
|
326
|
+
}),
|
|
327
|
+
}),
|
|
328
|
+
defineTool({
|
|
329
|
+
name: 'besales_pipeline_settings_update',
|
|
330
|
+
requiredFields: ['platform_id'],
|
|
331
|
+
schema: z
|
|
332
|
+
.object({
|
|
333
|
+
platform_id: uuidSchema,
|
|
334
|
+
// v1.5 Increment 3 Group C.3 (Phase B, 2026-05-27): только typed sections.
|
|
335
|
+
crm_pipeline_behavior: pipelineCrmBehaviorSchema.optional(),
|
|
336
|
+
auto_finish: pipelineAutoFinishSchema.optional(),
|
|
337
|
+
...platformSetupConfirmationSchema,
|
|
338
|
+
})
|
|
339
|
+
.strict(),
|
|
340
|
+
createRequest: (input) => ({
|
|
341
|
+
method: 'PATCH',
|
|
342
|
+
path: `/platforms/${input.platform_id}/pipeline-settings`,
|
|
343
|
+
body: compactObject({
|
|
344
|
+
crmPipelineBehavior: input.crm_pipeline_behavior
|
|
345
|
+
? mapPipelineCrmBehaviorInput(input.crm_pipeline_behavior)
|
|
346
|
+
: undefined,
|
|
347
|
+
autoFinish: input.auto_finish ? mapPipelineAutoFinishInput(input.auto_finish) : undefined,
|
|
348
|
+
...setupConfirmation(input),
|
|
349
|
+
}),
|
|
350
|
+
}),
|
|
351
|
+
}),
|
|
352
|
+
defineTool({
|
|
353
|
+
name: 'besales_platform_settings_update',
|
|
354
|
+
requiredFields: ['platform_id'],
|
|
355
|
+
schema: z
|
|
356
|
+
.object({
|
|
357
|
+
platform_id: uuidSchema,
|
|
358
|
+
// v1.5 Increment 3 Group C.2 (Phase B, 2026-05-27).
|
|
359
|
+
// Flat-only fields — backward compat для existing UI clients (deprecated через 2 weeks).
|
|
360
|
+
// Новый код должен использовать generalSettings.* typed section.
|
|
361
|
+
name: z.string().nullable().optional(),
|
|
362
|
+
off_message: z.string().optional(),
|
|
363
|
+
timezone: z.string().optional(),
|
|
364
|
+
// Typed sections (single source of truth для access/variables/crm/widget/instagram).
|
|
365
|
+
access_control: platformAccessControlSchema.optional(),
|
|
366
|
+
variables_config: platformVariablesConfigSchema.optional(),
|
|
367
|
+
crm_behavior: platformCrmBehaviorSchema.optional(),
|
|
368
|
+
widget_marketing: platformWidgetMarketingSchema.optional(),
|
|
369
|
+
instagram_comment_behavior: platformInstagramCommentSchema.optional(),
|
|
370
|
+
// v1.5 Increment 4c — per-channel typed sections (hard 400 для unsupported channel type)
|
|
371
|
+
general_settings: platformGeneralSettingsSchema.optional(),
|
|
372
|
+
salebot_settings: platformSalebotSettingsSchema.optional(),
|
|
373
|
+
smsgorod_settings: platformSmsgorodSettingsSchema.optional(),
|
|
374
|
+
bitrix24_bot_settings: platformBitrix24BotSettingsSchema.optional(),
|
|
375
|
+
getcourse_settings: platformGetcourseSettingsSchema.optional(),
|
|
376
|
+
...platformSetupConfirmationSchema,
|
|
377
|
+
})
|
|
378
|
+
.strict(),
|
|
379
|
+
createRequest: (input) => ({
|
|
380
|
+
method: 'PATCH',
|
|
381
|
+
path: `/platforms/${input.platform_id}/settings`,
|
|
382
|
+
body: compactObject({
|
|
383
|
+
name: input.name,
|
|
384
|
+
offMessage: input.off_message,
|
|
385
|
+
timezone: input.timezone,
|
|
386
|
+
accessControl: input.access_control
|
|
387
|
+
? mapPlatformAccessControlInput(input.access_control)
|
|
388
|
+
: undefined,
|
|
389
|
+
variablesConfig: input.variables_config
|
|
390
|
+
? mapPlatformVariablesConfigInput(input.variables_config)
|
|
391
|
+
: undefined,
|
|
392
|
+
crmBehavior: input.crm_behavior
|
|
393
|
+
? mapPlatformCrmBehaviorInput(input.crm_behavior)
|
|
394
|
+
: undefined,
|
|
395
|
+
widgetMarketing: input.widget_marketing
|
|
396
|
+
? mapPlatformWidgetMarketingInput(input.widget_marketing)
|
|
397
|
+
: undefined,
|
|
398
|
+
instagramCommentBehavior: input.instagram_comment_behavior
|
|
399
|
+
? mapPlatformInstagramCommentInput(input.instagram_comment_behavior)
|
|
400
|
+
: undefined,
|
|
401
|
+
generalSettings: input.general_settings
|
|
402
|
+
? mapPlatformGeneralSettingsInput(input.general_settings)
|
|
403
|
+
: undefined,
|
|
404
|
+
salebotSettings: input.salebot_settings
|
|
405
|
+
? mapPlatformSalebotSettingsInput(input.salebot_settings)
|
|
406
|
+
: undefined,
|
|
407
|
+
smsgorodSettings: input.smsgorod_settings
|
|
408
|
+
? mapPlatformSmsgorodSettingsInput(input.smsgorod_settings)
|
|
409
|
+
: undefined,
|
|
410
|
+
bitrix24BotSettings: input.bitrix24_bot_settings
|
|
411
|
+
? mapPlatformBitrix24BotSettingsInput(input.bitrix24_bot_settings)
|
|
412
|
+
: undefined,
|
|
413
|
+
getcourseSettings: input.getcourse_settings
|
|
414
|
+
? mapPlatformGetcourseSettingsInput(input.getcourse_settings)
|
|
415
|
+
: undefined,
|
|
416
|
+
...setupConfirmation(input),
|
|
417
|
+
}),
|
|
418
|
+
}),
|
|
419
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
420
|
+
'Per-channel typed sections (salebot/smsgorod/bitrix24Bot/getcourse) — hard 400 при mismatched platform.type.',
|
|
421
|
+
'generalSettings.* — closes Phase B gap для name/offMessage/timezone/isActive; flat fields deprecated через 2 недели.',
|
|
422
|
+
'Response.warnings[] содержит Phase A soft-warnings для widgetMarketing/instagramCommentBehavior на mismatched channel (hard reject после 2026-06-10).',
|
|
423
|
+
]),
|
|
424
|
+
}),
|
|
425
|
+
defineTool({
|
|
426
|
+
name: 'besales_audit_revert',
|
|
427
|
+
requiredFields: ['audit_log_id'],
|
|
428
|
+
defaultWorkspaceId: true,
|
|
429
|
+
schema: z
|
|
430
|
+
.object({
|
|
431
|
+
workspace_id: uuidSchema.optional(),
|
|
432
|
+
// `platform_id` — для platform-scoped audit logs (записи через platform-setup-adapter).
|
|
433
|
+
// Если опущен — revert идёт через workspace-scoped endpoint (variables-adapter и т.п.,
|
|
434
|
+
// где audit logs пишутся с platformId=null).
|
|
435
|
+
platform_id: uuidSchema.optional(),
|
|
436
|
+
audit_log_id: uuidSchema,
|
|
437
|
+
})
|
|
438
|
+
.strict(),
|
|
439
|
+
createRequest: (input) => {
|
|
440
|
+
if (input.platform_id) {
|
|
441
|
+
return {
|
|
442
|
+
method: 'POST',
|
|
443
|
+
path: `/platforms/${input.platform_id}/audit/${input.audit_log_id}/revert`,
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
return {
|
|
447
|
+
method: 'POST',
|
|
448
|
+
path: `/workspaces/${input.workspace_id}/audit/${input.audit_log_id}/revert`,
|
|
449
|
+
};
|
|
450
|
+
},
|
|
451
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
452
|
+
'Передай `platform_id` для platform-scoped logs (audit через platform-setup-adapter).',
|
|
453
|
+
'Опусти `platform_id` для workspace-scoped logs (variables-adapter и аналоги).',
|
|
454
|
+
]),
|
|
455
|
+
}),
|
|
456
|
+
defineTool({
|
|
457
|
+
name: 'besales_feedback_sheet_link',
|
|
458
|
+
requiredFields: ['agent_id', 'source_url'],
|
|
459
|
+
schema: z.object({
|
|
460
|
+
agent_id: uuidSchema,
|
|
461
|
+
source_url: z.string().url(),
|
|
462
|
+
access_mode: z.enum(['READ_ONLY', 'EDITABLE']).default('READ_ONLY'),
|
|
463
|
+
agent_version_id: uuidSchema.optional(),
|
|
464
|
+
}),
|
|
465
|
+
createRequest: (input) => ({
|
|
466
|
+
path: `/agents/${input.agent_id}/feedback-sheets`,
|
|
467
|
+
body: compactObject({
|
|
468
|
+
sourceUrl: input.source_url,
|
|
469
|
+
accessMode: input.access_mode,
|
|
470
|
+
agentVersionId: input.agent_version_id,
|
|
471
|
+
}),
|
|
472
|
+
}),
|
|
473
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
474
|
+
'Таблица привязана к промпту. Расшарьте её на service account из поля serviceAccountEmail (Viewer для READ_ONLY, Editor для EDITABLE).',
|
|
475
|
+
'Прочитайте замечания через besales_feedback_sheet_read по feedbackSheet.id.',
|
|
476
|
+
'accessMode определяет режим: READ_ONLY — только предлагаете правки промпта; EDITABLE — дополнительно отмечаете статусы строк (Phase 2).',
|
|
477
|
+
]),
|
|
478
|
+
}),
|
|
479
|
+
defineTool({
|
|
480
|
+
name: 'besales_feedback_sheet_list',
|
|
481
|
+
requiredFields: ['agent_id'],
|
|
482
|
+
schema: z.object({
|
|
483
|
+
agent_id: uuidSchema,
|
|
484
|
+
}),
|
|
485
|
+
createRequest: (input) => ({
|
|
486
|
+
method: 'GET',
|
|
487
|
+
path: `/agents/${input.agent_id}/feedback-sheets`,
|
|
488
|
+
}),
|
|
489
|
+
}),
|
|
490
|
+
defineTool({
|
|
491
|
+
name: 'besales_feedback_sheet_read',
|
|
492
|
+
requiredFields: ['agent_id', 'feedback_sheet_id'],
|
|
493
|
+
schema: z.object({
|
|
494
|
+
agent_id: uuidSchema,
|
|
495
|
+
feedback_sheet_id: uuidSchema,
|
|
496
|
+
}),
|
|
497
|
+
createRequest: (input) => ({
|
|
498
|
+
method: 'GET',
|
|
499
|
+
path: `/agents/${input.agent_id}/feedback-sheets/${input.feedback_sheet_id}/content`,
|
|
500
|
+
}),
|
|
501
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
502
|
+
'Проанализируйте строки замечаний тестировщиков, сгруппируйте по смыслу и важности.',
|
|
503
|
+
'Для правки промпта используйте patch flow: besales_prompt_patch_start → besales_prompt_patch_apply (с операциями replace_text / insert_after_text / etc) → besales_prompt_patch_commit.',
|
|
504
|
+
'Не финализируйте промпт (besales_prompt_finalize) без подтверждения пользователя.',
|
|
505
|
+
]),
|
|
506
|
+
}),
|
|
507
|
+
defineTool({
|
|
508
|
+
name: 'besales_feedback_sheet_unlink',
|
|
509
|
+
requiredFields: ['agent_id', 'feedback_sheet_id'],
|
|
510
|
+
schema: z.object({
|
|
511
|
+
agent_id: uuidSchema,
|
|
512
|
+
feedback_sheet_id: uuidSchema,
|
|
513
|
+
}),
|
|
514
|
+
createRequest: (input) => ({
|
|
515
|
+
method: 'DELETE',
|
|
516
|
+
path: `/agents/${input.agent_id}/feedback-sheets/${input.feedback_sheet_id}`,
|
|
517
|
+
}),
|
|
518
|
+
}),
|
|
519
|
+
defineTool({
|
|
520
|
+
name: 'besales_feedback_sheet_row_update',
|
|
521
|
+
requiredFields: ['agent_id', 'feedback_sheet_id', 'rows'],
|
|
522
|
+
schema: z.object({
|
|
523
|
+
agent_id: uuidSchema,
|
|
524
|
+
feedback_sheet_id: uuidSchema,
|
|
525
|
+
rows: z.array(feedbackSheetRowSchema).min(1),
|
|
526
|
+
status_column: z.string().optional(),
|
|
527
|
+
comment_column: z.string().optional(),
|
|
528
|
+
}),
|
|
529
|
+
createRequest: (input) => ({
|
|
530
|
+
method: 'PATCH',
|
|
531
|
+
path: `/agents/${input.agent_id}/feedback-sheets/${input.feedback_sheet_id}/rows`,
|
|
532
|
+
body: compactObject({
|
|
533
|
+
rows: input.rows.map((row) => compactObject({
|
|
534
|
+
rowNumber: row.row_number,
|
|
535
|
+
rowHash: row.row_hash,
|
|
536
|
+
status: row.status,
|
|
537
|
+
comment: row.comment,
|
|
538
|
+
})),
|
|
539
|
+
statusColumn: input.status_column,
|
|
540
|
+
commentColumn: input.comment_column,
|
|
541
|
+
}),
|
|
542
|
+
}),
|
|
543
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
544
|
+
'Статусы строк записаны в таблицу с цветовой заливкой.',
|
|
545
|
+
'Если ответ — ошибка про service account, запись недоступна: работай в read-only режиме (только besales_feedback_sheet_read + предложение правок промпта).',
|
|
546
|
+
'Если ошибка 409 — строки сдвинулись: перечитай таблицу через besales_feedback_sheet_read и повтори с актуальными rowHash.',
|
|
547
|
+
]),
|
|
548
|
+
}),
|
|
549
|
+
// S4.13 — besales_facts_classify_and_migrate
|
|
550
|
+
defineTool({
|
|
551
|
+
name: 'besales_facts_classify_and_migrate',
|
|
552
|
+
requiredFields: ['agent_id'],
|
|
553
|
+
schema: z.object({
|
|
554
|
+
agent_id: uuidSchema,
|
|
555
|
+
namespace_record_id: uuidSchema.optional(),
|
|
556
|
+
}),
|
|
557
|
+
createRequest: (input) => ({
|
|
558
|
+
path: `/agents/${input.agent_id}/facts/classify-and-migrate`,
|
|
559
|
+
body: compactObject({
|
|
560
|
+
namespaceRecordId: input.namespace_record_id,
|
|
561
|
+
}),
|
|
562
|
+
}),
|
|
563
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
564
|
+
'Active facts разобраны: Q&A pairs созданы через QaService, document chunks отмечены как pending.',
|
|
565
|
+
'Мигрированные chunks перемещены в секцию `## Migrated` в AgentChat.factualContext (audit trail).',
|
|
566
|
+
'Если категория `document` — text→document loader pending, повторно вызовы безопасны (idempotent per chunk).',
|
|
567
|
+
]),
|
|
568
|
+
}),
|
|
569
|
+
// S2.5 extra — besales_agent_facts_set
|
|
570
|
+
defineTool({
|
|
571
|
+
name: 'besales_agent_facts_set',
|
|
572
|
+
requiredFields: ['agent_id', 'factual_context'],
|
|
573
|
+
schema: z.object({
|
|
574
|
+
agent_id: uuidSchema,
|
|
575
|
+
factual_context: z.string(),
|
|
576
|
+
}),
|
|
577
|
+
createRequest: (input) => ({
|
|
578
|
+
method: 'PUT',
|
|
579
|
+
path: `/agents/${input.agent_id}/facts`,
|
|
580
|
+
body: { factualContext: input.factual_context },
|
|
581
|
+
}),
|
|
582
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
583
|
+
'factualContext записан целиком (PUT-семантика, replace not patch).',
|
|
584
|
+
'Если в warnings есть `soft_limit_exceeded` (~8000 chars / 2K tokens) — рекомендую запустить `besales_facts_classify_and_migrate`.',
|
|
585
|
+
'Структура: `## Active facts` блок инъектится в системный промпт; `## Migrated` — лог миграций (не инъектится).',
|
|
586
|
+
]),
|
|
587
|
+
}),
|
|
588
|
+
// ─────────────────────────────────────────────────────────────────
|
|
589
|
+
// S3.8-integration .5 — Patch-based PromptDraft tools
|
|
590
|
+
// (Должны быть ПЕРЕД besales_prompt_lint чтобы matched contract order.)
|
|
591
|
+
// ─────────────────────────────────────────────────────────────────
|
|
592
|
+
defineTool({
|
|
593
|
+
name: 'besales_prompt_patch_start',
|
|
594
|
+
requiredFields: ['agent_id'],
|
|
595
|
+
schema: z.object({
|
|
596
|
+
agent_id: uuidSchema,
|
|
597
|
+
}),
|
|
598
|
+
createRequest: (input) => ({
|
|
599
|
+
method: 'POST',
|
|
600
|
+
path: `/agents/${input.agent_id}/prompt/drafts`,
|
|
601
|
+
}),
|
|
602
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
603
|
+
'PromptDraft создан. ID в `draft.id`. TTL 24h, resets на каждом `_apply`.',
|
|
604
|
+
'Дальше: `besales_prompt_patch_apply(draft_id, operations[])` → batch правок → `besales_prompt_patch_commit(draft_id)`.',
|
|
605
|
+
'Если `conflictsWithOtherUsers` непустой — другой пользователь редактирует тот же агент. Не блокирует, но warning.',
|
|
606
|
+
'Server-side hash → клиенту не нужно знать про activePromptContentHash.',
|
|
607
|
+
'Гигиена: правь формулировки ПО МЕСТУ в существующих секциях; не добавляй override-блоки/дубли-секции в конец (антипаттерн → тех-долг). Сначала прочти весь промпт (besales_prompt_patch_get) и найди, где правило уже есть. См. «Редактирование промпта» в serverInstructions.',
|
|
608
|
+
]),
|
|
609
|
+
}),
|
|
610
|
+
defineTool({
|
|
611
|
+
name: 'besales_prompt_patch_get',
|
|
612
|
+
requiredFields: ['agent_id', 'draft_id'],
|
|
613
|
+
schema: z.object({
|
|
614
|
+
agent_id: uuidSchema,
|
|
615
|
+
draft_id: uuidSchema,
|
|
616
|
+
}),
|
|
617
|
+
createRequest: (input) => ({
|
|
618
|
+
method: 'GET',
|
|
619
|
+
path: `/agents/${input.agent_id}/prompt/drafts/${input.draft_id}`,
|
|
620
|
+
}),
|
|
621
|
+
}),
|
|
622
|
+
defineTool({
|
|
623
|
+
name: 'besales_prompt_patch_apply',
|
|
624
|
+
requiredFields: ['agent_id', 'draft_id', 'operations'],
|
|
625
|
+
schema: z.object({
|
|
626
|
+
agent_id: uuidSchema,
|
|
627
|
+
draft_id: uuidSchema,
|
|
628
|
+
operations: z
|
|
629
|
+
.array(z.object({
|
|
630
|
+
id: z.string().optional(),
|
|
631
|
+
type: z.enum([
|
|
632
|
+
'replace_text',
|
|
633
|
+
'replace_all_text',
|
|
634
|
+
'insert_after_text',
|
|
635
|
+
'insert_before_text',
|
|
636
|
+
'remove_text',
|
|
637
|
+
'move_text_after_text',
|
|
638
|
+
]),
|
|
639
|
+
target_text: z.string().optional(),
|
|
640
|
+
anchor_text: z.string().optional(),
|
|
641
|
+
replacement_text: z.string().optional(),
|
|
642
|
+
match_variants: z.array(z.string()).optional(),
|
|
643
|
+
}))
|
|
644
|
+
.min(1),
|
|
645
|
+
}),
|
|
646
|
+
createRequest: (input) => ({
|
|
647
|
+
method: 'PATCH',
|
|
648
|
+
path: `/agents/${input.agent_id}/prompt/drafts/${input.draft_id}/operations`,
|
|
649
|
+
body: {
|
|
650
|
+
operations: input.operations.map((op) => compactObject({
|
|
651
|
+
id: op.id,
|
|
652
|
+
type: op.type,
|
|
653
|
+
targetText: op.target_text,
|
|
654
|
+
anchorText: op.anchor_text,
|
|
655
|
+
replacementText: op.replacement_text,
|
|
656
|
+
matchVariants: op.match_variants,
|
|
657
|
+
})),
|
|
658
|
+
},
|
|
659
|
+
}),
|
|
660
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
661
|
+
'Operations применены. `appliedCount` — успешно, `skippedCount` — anchor не найден или growth guard сработал (>30% size).',
|
|
662
|
+
'Если `skippedCount > 0` — проверь target_text / anchor_text на точность. matchVariants[] помогает fuzzy-match.',
|
|
663
|
+
'TTL draft сброшен на 24h.',
|
|
664
|
+
'Когда правки готовы — `besales_prompt_patch_commit(draft_id)`.',
|
|
665
|
+
]),
|
|
666
|
+
}),
|
|
667
|
+
defineTool({
|
|
668
|
+
name: 'besales_prompt_patch_commit',
|
|
669
|
+
requiredFields: ['agent_id', 'draft_id'],
|
|
670
|
+
schema: z.object({
|
|
671
|
+
agent_id: uuidSchema,
|
|
672
|
+
draft_id: uuidSchema,
|
|
673
|
+
}),
|
|
674
|
+
createRequest: (input) => ({
|
|
675
|
+
method: 'POST',
|
|
676
|
+
path: `/agents/${input.agent_id}/prompt/drafts/${input.draft_id}/commit`,
|
|
677
|
+
}),
|
|
678
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
679
|
+
'Commit: lint pass → новая PromptVersion в prompt-services → AgentChat.baseSystemPrompt обновлён.',
|
|
680
|
+
'Если ошибка 400 с `lintIssues` — поправь через `_apply` (hard_fail issues блокируют commit).',
|
|
681
|
+
'Если ошибка 409 PROMPT_DRAFT_REBASE_REQUIRED — другой commit прошёл первым. Discard этот draft и сделай новый.',
|
|
682
|
+
'Server-side hash → клиенту не нужно передавать activePromptContentHash.',
|
|
683
|
+
]),
|
|
684
|
+
}),
|
|
685
|
+
defineTool({
|
|
686
|
+
name: 'besales_prompt_patch_discard',
|
|
687
|
+
requiredFields: ['agent_id', 'draft_id'],
|
|
688
|
+
schema: z.object({
|
|
689
|
+
agent_id: uuidSchema,
|
|
690
|
+
draft_id: uuidSchema,
|
|
691
|
+
}),
|
|
692
|
+
createRequest: (input) => ({
|
|
693
|
+
method: 'DELETE',
|
|
694
|
+
path: `/agents/${input.agent_id}/prompt/drafts/${input.draft_id}`,
|
|
695
|
+
}),
|
|
696
|
+
}),
|
|
697
|
+
// S2.6 extra — besales_prompt_lint (после patches, чтобы matched catalog order)
|
|
698
|
+
defineTool({
|
|
699
|
+
name: 'besales_prompt_lint',
|
|
700
|
+
requiredFields: ['prompt_text'],
|
|
701
|
+
defaultWorkspaceId: true,
|
|
702
|
+
schema: z.object({
|
|
703
|
+
workspace_id: uuidSchema.optional(),
|
|
704
|
+
prompt_text: z.string(),
|
|
705
|
+
agent_id: uuidSchema.optional(),
|
|
706
|
+
channel: z.string().optional(),
|
|
707
|
+
agent_scope: z
|
|
708
|
+
.enum([
|
|
709
|
+
'sale',
|
|
710
|
+
'reactivation',
|
|
711
|
+
'support',
|
|
712
|
+
'onboarding',
|
|
713
|
+
'faq',
|
|
714
|
+
'qualification',
|
|
715
|
+
'complaint',
|
|
716
|
+
'other',
|
|
717
|
+
])
|
|
718
|
+
.optional(),
|
|
719
|
+
feedback_banned_terms: z.array(z.string()).optional(),
|
|
720
|
+
}),
|
|
721
|
+
createRequest: (input) => ({
|
|
722
|
+
path: `/workspaces/${input.workspace_id}/prompt-lint`,
|
|
723
|
+
body: compactObject({
|
|
724
|
+
promptText: input.prompt_text,
|
|
725
|
+
agentId: input.agent_id,
|
|
726
|
+
channel: input.channel,
|
|
727
|
+
agentScope: input.agent_scope,
|
|
728
|
+
feedbackBannedTerms: input.feedback_banned_terms,
|
|
729
|
+
}),
|
|
730
|
+
}),
|
|
731
|
+
enhanceResponse: (response) => withInstructions(response, [
|
|
732
|
+
'Standalone lint: проверка ДО `besales_prompt_finalize` (избегает цикла «finalize → 400 → fix»).',
|
|
733
|
+
'Severity: `hard_fail` блокирует finalize; `warn` — рекомендация; `info` — заметки.',
|
|
734
|
+
'Если передан `agent_id` — channel и agentScope резолвятся из AgentChat (markdown-checker и scope-consistency активны).',
|
|
735
|
+
]),
|
|
736
|
+
}),
|
|
737
|
+
];
|
|
738
|
+
//# sourceMappingURL=platform-setup.js.map
|