mcp-creatio 0.3.6

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.
Files changed (370) hide show
  1. package/.dockerignore +12 -0
  2. package/.editorconfig +14 -0
  3. package/.eslintrc.cjs +18 -0
  4. package/.gitattributes +8 -0
  5. package/.github/workflows/docker-publish.yml +50 -0
  6. package/.prettierignore +3 -0
  7. package/.prettierrc +9 -0
  8. package/.vscode/launch.json +23 -0
  9. package/.vscode/mcp.json +13 -0
  10. package/.vscode/settings.json +16 -0
  11. package/Agent.md +187 -0
  12. package/Debug.md +32 -0
  13. package/Dockerfile +23 -0
  14. package/LICENSE +21 -0
  15. package/README.md +162 -0
  16. package/dist/cli.d.ts +3 -0
  17. package/dist/cli.d.ts.map +1 -0
  18. package/dist/cli.js +135 -0
  19. package/dist/cli.js.map +1 -0
  20. package/dist/config-builder.d.ts +3 -0
  21. package/dist/config-builder.d.ts.map +1 -0
  22. package/dist/config-builder.js +66 -0
  23. package/dist/config-builder.js.map +1 -0
  24. package/dist/consts.d.ts +2 -0
  25. package/dist/consts.d.ts.map +1 -0
  26. package/dist/consts.js +6 -0
  27. package/dist/consts.js.map +1 -0
  28. package/dist/creatio/auth/auth-manager.d.ts +9 -0
  29. package/dist/creatio/auth/auth-manager.d.ts.map +1 -0
  30. package/dist/creatio/auth/auth-manager.js +29 -0
  31. package/dist/creatio/auth/auth-manager.js.map +1 -0
  32. package/dist/creatio/auth/auth.d.ts +16 -0
  33. package/dist/creatio/auth/auth.d.ts.map +1 -0
  34. package/dist/creatio/auth/auth.js +20 -0
  35. package/dist/creatio/auth/auth.js.map +1 -0
  36. package/dist/creatio/auth/index.d.ts +4 -0
  37. package/dist/creatio/auth/index.d.ts.map +1 -0
  38. package/dist/creatio/auth/index.js +21 -0
  39. package/dist/creatio/auth/index.js.map +1 -0
  40. package/dist/creatio/auth/providers/base-oauth2-provider.d.ts +17 -0
  41. package/dist/creatio/auth/providers/base-oauth2-provider.d.ts.map +1 -0
  42. package/dist/creatio/auth/providers/base-oauth2-provider.js +49 -0
  43. package/dist/creatio/auth/providers/base-oauth2-provider.js.map +1 -0
  44. package/dist/creatio/auth/providers/base-provider.d.ts +15 -0
  45. package/dist/creatio/auth/providers/base-provider.d.ts.map +1 -0
  46. package/dist/creatio/auth/providers/base-provider.js +32 -0
  47. package/dist/creatio/auth/providers/base-provider.js.map +1 -0
  48. package/dist/creatio/auth/providers/index.d.ts +5 -0
  49. package/dist/creatio/auth/providers/index.d.ts.map +1 -0
  50. package/dist/creatio/auth/providers/index.js +21 -0
  51. package/dist/creatio/auth/providers/index.js.map +1 -0
  52. package/dist/creatio/auth/providers/legacy-provider.d.ts +10 -0
  53. package/dist/creatio/auth/providers/legacy-provider.d.ts.map +1 -0
  54. package/dist/creatio/auth/providers/legacy-provider.js +73 -0
  55. package/dist/creatio/auth/providers/legacy-provider.js.map +1 -0
  56. package/dist/creatio/auth/providers/oauth2-code-provider.d.ts +18 -0
  57. package/dist/creatio/auth/providers/oauth2-code-provider.d.ts.map +1 -0
  58. package/dist/creatio/auth/providers/oauth2-code-provider.js +245 -0
  59. package/dist/creatio/auth/providers/oauth2-code-provider.js.map +1 -0
  60. package/dist/creatio/auth/providers/oauth2-provider.d.ts +9 -0
  61. package/dist/creatio/auth/providers/oauth2-provider.d.ts.map +1 -0
  62. package/dist/creatio/auth/providers/oauth2-provider.js +86 -0
  63. package/dist/creatio/auth/providers/oauth2-provider.js.map +1 -0
  64. package/dist/creatio/auth/providers/type.d.ts +6 -0
  65. package/dist/creatio/auth/providers/type.d.ts.map +1 -0
  66. package/dist/creatio/auth/providers/type.js +10 -0
  67. package/dist/creatio/auth/providers/type.js.map +1 -0
  68. package/dist/creatio/client-config.d.ts +29 -0
  69. package/dist/creatio/client-config.d.ts.map +1 -0
  70. package/dist/creatio/client-config.js +3 -0
  71. package/dist/creatio/client-config.js.map +1 -0
  72. package/dist/creatio/engines/crud/crud-engine.d.ts +15 -0
  73. package/dist/creatio/engines/crud/crud-engine.d.ts.map +1 -0
  74. package/dist/creatio/engines/crud/crud-engine.js +33 -0
  75. package/dist/creatio/engines/crud/crud-engine.js.map +1 -0
  76. package/dist/creatio/engines/engine-manager.d.ts +33 -0
  77. package/dist/creatio/engines/engine-manager.d.ts.map +1 -0
  78. package/dist/creatio/engines/engine-manager.js +54 -0
  79. package/dist/creatio/engines/engine-manager.js.map +1 -0
  80. package/dist/creatio/engines/engine-registry.d.ts +15 -0
  81. package/dist/creatio/engines/engine-registry.d.ts.map +1 -0
  82. package/dist/creatio/engines/engine-registry.js +35 -0
  83. package/dist/creatio/engines/engine-registry.js.map +1 -0
  84. package/dist/creatio/engines/engine.d.ts +4 -0
  85. package/dist/creatio/engines/engine.d.ts.map +1 -0
  86. package/dist/creatio/engines/engine.js +3 -0
  87. package/dist/creatio/engines/engine.js.map +1 -0
  88. package/dist/creatio/engines/index.d.ts +8 -0
  89. package/dist/creatio/engines/index.d.ts.map +1 -0
  90. package/dist/creatio/engines/index.js +24 -0
  91. package/dist/creatio/engines/index.js.map +1 -0
  92. package/dist/creatio/engines/process/process-engine.d.ts +10 -0
  93. package/dist/creatio/engines/process/process-engine.d.ts.map +1 -0
  94. package/dist/creatio/engines/process/process-engine.js +18 -0
  95. package/dist/creatio/engines/process/process-engine.js.map +1 -0
  96. package/dist/creatio/engines/sys-settings/sys-settings-engine.d.ts +13 -0
  97. package/dist/creatio/engines/sys-settings/sys-settings-engine.d.ts.map +1 -0
  98. package/dist/creatio/engines/sys-settings/sys-settings-engine.js +27 -0
  99. package/dist/creatio/engines/sys-settings/sys-settings-engine.js.map +1 -0
  100. package/dist/creatio/engines/user/user-engine.d.ts +10 -0
  101. package/dist/creatio/engines/user/user-engine.d.ts.map +1 -0
  102. package/dist/creatio/engines/user/user-engine.js +18 -0
  103. package/dist/creatio/engines/user/user-engine.js.map +1 -0
  104. package/dist/creatio/index.d.ts +7 -0
  105. package/dist/creatio/index.d.ts.map +1 -0
  106. package/dist/creatio/index.js +23 -0
  107. package/dist/creatio/index.js.map +1 -0
  108. package/dist/creatio/provider-context.d.ts +10 -0
  109. package/dist/creatio/provider-context.d.ts.map +1 -0
  110. package/dist/creatio/provider-context.js +3 -0
  111. package/dist/creatio/provider-context.js.map +1 -0
  112. package/dist/creatio/providers/crud-provider.d.ts +40 -0
  113. package/dist/creatio/providers/crud-provider.d.ts.map +1 -0
  114. package/dist/creatio/providers/crud-provider.js +3 -0
  115. package/dist/creatio/providers/crud-provider.js.map +1 -0
  116. package/dist/creatio/providers/index.d.ts +5 -0
  117. package/dist/creatio/providers/index.d.ts.map +1 -0
  118. package/dist/creatio/providers/index.js +21 -0
  119. package/dist/creatio/providers/index.js.map +1 -0
  120. package/dist/creatio/providers/process-provider.d.ts +14 -0
  121. package/dist/creatio/providers/process-provider.d.ts.map +1 -0
  122. package/dist/creatio/providers/process-provider.js +3 -0
  123. package/dist/creatio/providers/process-provider.js.map +1 -0
  124. package/dist/creatio/providers/sys-settings-provider.d.ts +58 -0
  125. package/dist/creatio/providers/sys-settings-provider.d.ts.map +1 -0
  126. package/dist/creatio/providers/sys-settings-provider.js +3 -0
  127. package/dist/creatio/providers/sys-settings-provider.js.map +1 -0
  128. package/dist/creatio/providers/user-provider.d.ts +12 -0
  129. package/dist/creatio/providers/user-provider.d.ts.map +1 -0
  130. package/dist/creatio/providers/user-provider.js +3 -0
  131. package/dist/creatio/providers/user-provider.js.map +1 -0
  132. package/dist/creatio/services/creatio-service-context.d.ts +17 -0
  133. package/dist/creatio/services/creatio-service-context.d.ts.map +1 -0
  134. package/dist/creatio/services/creatio-service-context.js +35 -0
  135. package/dist/creatio/services/creatio-service-context.js.map +1 -0
  136. package/dist/creatio/services/http-client.d.ts +29 -0
  137. package/dist/creatio/services/http-client.d.ts.map +1 -0
  138. package/dist/creatio/services/http-client.js +136 -0
  139. package/dist/creatio/services/http-client.js.map +1 -0
  140. package/dist/creatio/services/index.d.ts +8 -0
  141. package/dist/creatio/services/index.d.ts.map +1 -0
  142. package/dist/creatio/services/index.js +24 -0
  143. package/dist/creatio/services/index.js.map +1 -0
  144. package/dist/creatio/services/metadata-store.d.ts +20 -0
  145. package/dist/creatio/services/metadata-store.d.ts.map +1 -0
  146. package/dist/creatio/services/metadata-store.js +162 -0
  147. package/dist/creatio/services/metadata-store.js.map +1 -0
  148. package/dist/creatio/services/odata-crud-provider.d.ts +21 -0
  149. package/dist/creatio/services/odata-crud-provider.d.ts.map +1 -0
  150. package/dist/creatio/services/odata-crud-provider.js +145 -0
  151. package/dist/creatio/services/odata-crud-provider.js.map +1 -0
  152. package/dist/creatio/services/process-service-provider.d.ts +11 -0
  153. package/dist/creatio/services/process-service-provider.d.ts.map +1 -0
  154. package/dist/creatio/services/process-service-provider.js +52 -0
  155. package/dist/creatio/services/process-service-provider.js.map +1 -0
  156. package/dist/creatio/services/sys-settings-service-provider.d.ts +19 -0
  157. package/dist/creatio/services/sys-settings-service-provider.d.ts.map +1 -0
  158. package/dist/creatio/services/sys-settings-service-provider.js +107 -0
  159. package/dist/creatio/services/sys-settings-service-provider.js.map +1 -0
  160. package/dist/creatio/services/user-info-provider.d.ts +10 -0
  161. package/dist/creatio/services/user-info-provider.d.ts.map +1 -0
  162. package/dist/creatio/services/user-info-provider.js +26 -0
  163. package/dist/creatio/services/user-info-provider.js.map +1 -0
  164. package/dist/index.d.ts +2 -0
  165. package/dist/index.d.ts.map +1 -0
  166. package/dist/index.js +46 -0
  167. package/dist/index.js.map +1 -0
  168. package/dist/log.d.ts +51 -0
  169. package/dist/log.d.ts.map +1 -0
  170. package/dist/log.js +137 -0
  171. package/dist/log.js.map +1 -0
  172. package/dist/server/http/creatio-oauth-handlers.d.ts +14 -0
  173. package/dist/server/http/creatio-oauth-handlers.d.ts.map +1 -0
  174. package/dist/server/http/creatio-oauth-handlers.js +137 -0
  175. package/dist/server/http/creatio-oauth-handlers.js.map +1 -0
  176. package/dist/server/http/httpServer.d.ts +23 -0
  177. package/dist/server/http/httpServer.d.ts.map +1 -0
  178. package/dist/server/http/httpServer.js +131 -0
  179. package/dist/server/http/httpServer.js.map +1 -0
  180. package/dist/server/http/index.d.ts +6 -0
  181. package/dist/server/http/index.d.ts.map +1 -0
  182. package/dist/server/http/index.js +22 -0
  183. package/dist/server/http/index.js.map +1 -0
  184. package/dist/server/http/mcp-handlers.d.ts +10 -0
  185. package/dist/server/http/mcp-handlers.d.ts.map +1 -0
  186. package/dist/server/http/mcp-handlers.js +82 -0
  187. package/dist/server/http/mcp-handlers.js.map +1 -0
  188. package/dist/server/http/mcp-oauth-handlers.d.ts +11 -0
  189. package/dist/server/http/mcp-oauth-handlers.d.ts.map +1 -0
  190. package/dist/server/http/mcp-oauth-handlers.js +106 -0
  191. package/dist/server/http/mcp-oauth-handlers.js.map +1 -0
  192. package/dist/server/http/middleware.d.ts +11 -0
  193. package/dist/server/http/middleware.d.ts.map +1 -0
  194. package/dist/server/http/middleware.js +88 -0
  195. package/dist/server/http/middleware.js.map +1 -0
  196. package/dist/server/index.d.ts +3 -0
  197. package/dist/server/index.d.ts.map +1 -0
  198. package/dist/server/index.js +19 -0
  199. package/dist/server/index.js.map +1 -0
  200. package/dist/server/mcp/filters.d.ts +2 -0
  201. package/dist/server/mcp/filters.d.ts.map +1 -0
  202. package/dist/server/mcp/filters.js +94 -0
  203. package/dist/server/mcp/filters.js.map +1 -0
  204. package/dist/server/mcp/index.d.ts +2 -0
  205. package/dist/server/mcp/index.d.ts.map +1 -0
  206. package/dist/server/mcp/index.js +18 -0
  207. package/dist/server/mcp/index.js.map +1 -0
  208. package/dist/server/mcp/prompts-data.d.ts +147 -0
  209. package/dist/server/mcp/prompts-data.d.ts.map +1 -0
  210. package/dist/server/mcp/prompts-data.js +884 -0
  211. package/dist/server/mcp/prompts-data.js.map +1 -0
  212. package/dist/server/mcp/server.d.ts +25 -0
  213. package/dist/server/mcp/server.d.ts.map +1 -0
  214. package/dist/server/mcp/server.js +233 -0
  215. package/dist/server/mcp/server.js.map +1 -0
  216. package/dist/server/mcp/tools-data.d.ts +165 -0
  217. package/dist/server/mcp/tools-data.d.ts.map +1 -0
  218. package/dist/server/mcp/tools-data.js +466 -0
  219. package/dist/server/mcp/tools-data.js.map +1 -0
  220. package/dist/server/oauth/client-manager.d.ts +6 -0
  221. package/dist/server/oauth/client-manager.d.ts.map +1 -0
  222. package/dist/server/oauth/client-manager.js +52 -0
  223. package/dist/server/oauth/client-manager.js.map +1 -0
  224. package/dist/server/oauth/index.d.ts +7 -0
  225. package/dist/server/oauth/index.d.ts.map +1 -0
  226. package/dist/server/oauth/index.js +23 -0
  227. package/dist/server/oauth/index.js.map +1 -0
  228. package/dist/server/oauth/oauth-server.d.ts +21 -0
  229. package/dist/server/oauth/oauth-server.d.ts.map +1 -0
  230. package/dist/server/oauth/oauth-server.js +146 -0
  231. package/dist/server/oauth/oauth-server.js.map +1 -0
  232. package/dist/server/oauth/storage.d.ts +31 -0
  233. package/dist/server/oauth/storage.d.ts.map +1 -0
  234. package/dist/server/oauth/storage.js +73 -0
  235. package/dist/server/oauth/storage.js.map +1 -0
  236. package/dist/server/oauth/token-manager.d.ts +13 -0
  237. package/dist/server/oauth/token-manager.d.ts.map +1 -0
  238. package/dist/server/oauth/token-manager.js +69 -0
  239. package/dist/server/oauth/token-manager.js.map +1 -0
  240. package/dist/server/oauth/types.d.ts +51 -0
  241. package/dist/server/oauth/types.d.ts.map +1 -0
  242. package/dist/server/oauth/types.js +3 -0
  243. package/dist/server/oauth/types.js.map +1 -0
  244. package/dist/server/oauth/validators.d.ts +7 -0
  245. package/dist/server/oauth/validators.d.ts.map +1 -0
  246. package/dist/server/oauth/validators.js +51 -0
  247. package/dist/server/oauth/validators.js.map +1 -0
  248. package/dist/services/index.d.ts +3 -0
  249. package/dist/services/index.d.ts.map +1 -0
  250. package/dist/services/index.js +19 -0
  251. package/dist/services/index.js.map +1 -0
  252. package/dist/services/session-context.d.ts +57 -0
  253. package/dist/services/session-context.d.ts.map +1 -0
  254. package/dist/services/session-context.js +182 -0
  255. package/dist/services/session-context.js.map +1 -0
  256. package/dist/services/token-refresh-scheduler.d.ts +16 -0
  257. package/dist/services/token-refresh-scheduler.d.ts.map +1 -0
  258. package/dist/services/token-refresh-scheduler.js +66 -0
  259. package/dist/services/token-refresh-scheduler.js.map +1 -0
  260. package/dist/types/index.d.ts +2 -0
  261. package/dist/types/index.d.ts.map +1 -0
  262. package/dist/types/index.js +18 -0
  263. package/dist/types/index.js.map +1 -0
  264. package/dist/types/network.d.ts +7 -0
  265. package/dist/types/network.d.ts.map +1 -0
  266. package/dist/types/network.js +6 -0
  267. package/dist/types/network.js.map +1 -0
  268. package/dist/utils/context.d.ts +10 -0
  269. package/dist/utils/context.d.ts.map +1 -0
  270. package/dist/utils/context.js +44 -0
  271. package/dist/utils/context.js.map +1 -0
  272. package/dist/utils/env.d.ts +3 -0
  273. package/dist/utils/env.d.ts.map +1 -0
  274. package/dist/utils/env.js +16 -0
  275. package/dist/utils/env.js.map +1 -0
  276. package/dist/utils/index.d.ts +6 -0
  277. package/dist/utils/index.d.ts.map +1 -0
  278. package/dist/utils/index.js +22 -0
  279. package/dist/utils/index.js.map +1 -0
  280. package/dist/utils/mcp.d.ts +3 -0
  281. package/dist/utils/mcp.d.ts.map +1 -0
  282. package/dist/utils/mcp.js +7 -0
  283. package/dist/utils/mcp.js.map +1 -0
  284. package/dist/utils/network.d.ts +7 -0
  285. package/dist/utils/network.d.ts.map +1 -0
  286. package/dist/utils/network.js +63 -0
  287. package/dist/utils/network.js.map +1 -0
  288. package/dist/utils/pkce.d.ts +7 -0
  289. package/dist/utils/pkce.d.ts.map +1 -0
  290. package/dist/utils/pkce.js +43 -0
  291. package/dist/utils/pkce.js.map +1 -0
  292. package/dist/version.d.ts +3 -0
  293. package/dist/version.d.ts.map +1 -0
  294. package/dist/version.js +10 -0
  295. package/dist/version.js.map +1 -0
  296. package/docs/coding-style.md +30 -0
  297. package/ecosystem.config.json +17 -0
  298. package/eslint.config.cjs +95 -0
  299. package/package.json +54 -0
  300. package/src/cli.ts +158 -0
  301. package/src/config-builder.ts +76 -0
  302. package/src/consts.ts +3 -0
  303. package/src/creatio/auth/auth-manager.ts +27 -0
  304. package/src/creatio/auth/auth.ts +31 -0
  305. package/src/creatio/auth/index.ts +3 -0
  306. package/src/creatio/auth/providers/base-oauth2-provider.ts +62 -0
  307. package/src/creatio/auth/providers/base-provider.ts +42 -0
  308. package/src/creatio/auth/providers/index.ts +4 -0
  309. package/src/creatio/auth/providers/legacy-provider.ts +70 -0
  310. package/src/creatio/auth/providers/oauth2-code-provider.ts +252 -0
  311. package/src/creatio/auth/providers/oauth2-provider.ts +91 -0
  312. package/src/creatio/auth/providers/type.ts +5 -0
  313. package/src/creatio/client-config.ts +34 -0
  314. package/src/creatio/engines/crud/crud-engine.ts +47 -0
  315. package/src/creatio/engines/engine-manager.ts +102 -0
  316. package/src/creatio/engines/engine-registry.ts +36 -0
  317. package/src/creatio/engines/engine.ts +3 -0
  318. package/src/creatio/engines/index.ts +7 -0
  319. package/src/creatio/engines/process/process-engine.ts +20 -0
  320. package/src/creatio/engines/sys-settings/sys-settings-engine.ts +41 -0
  321. package/src/creatio/engines/user/user-engine.ts +20 -0
  322. package/src/creatio/index.ts +6 -0
  323. package/src/creatio/provider-context.ts +10 -0
  324. package/src/creatio/providers/crud-provider.ts +45 -0
  325. package/src/creatio/providers/index.ts +4 -0
  326. package/src/creatio/providers/process-provider.ts +15 -0
  327. package/src/creatio/providers/sys-settings-provider.ts +63 -0
  328. package/src/creatio/providers/user-provider.ts +12 -0
  329. package/src/creatio/services/creatio-service-context.ts +38 -0
  330. package/src/creatio/services/http-client.ts +174 -0
  331. package/src/creatio/services/index.ts +7 -0
  332. package/src/creatio/services/metadata-store.ts +181 -0
  333. package/src/creatio/services/odata-crud-provider.ts +210 -0
  334. package/src/creatio/services/process-service-provider.ts +76 -0
  335. package/src/creatio/services/sys-settings-service-provider.ts +192 -0
  336. package/src/creatio/services/user-info-provider.ts +41 -0
  337. package/src/index.ts +44 -0
  338. package/src/log.ts +141 -0
  339. package/src/server/http/creatio-oauth-handlers.ts +146 -0
  340. package/src/server/http/httpServer.ts +150 -0
  341. package/src/server/http/index.ts +5 -0
  342. package/src/server/http/mcp-handlers.ts +92 -0
  343. package/src/server/http/mcp-oauth-handlers.ts +108 -0
  344. package/src/server/http/middleware.ts +91 -0
  345. package/src/server/index.ts +2 -0
  346. package/src/server/mcp/filters.ts +97 -0
  347. package/src/server/mcp/index.ts +1 -0
  348. package/src/server/mcp/prompts-data.ts +896 -0
  349. package/src/server/mcp/server.ts +331 -0
  350. package/src/server/mcp/tools-data.ts +592 -0
  351. package/src/server/oauth/client-manager.ts +47 -0
  352. package/src/server/oauth/index.ts +6 -0
  353. package/src/server/oauth/oauth-server.ts +185 -0
  354. package/src/server/oauth/storage.ts +106 -0
  355. package/src/server/oauth/token-manager.ts +80 -0
  356. package/src/server/oauth/types.ts +55 -0
  357. package/src/server/oauth/validators.ts +56 -0
  358. package/src/services/index.ts +2 -0
  359. package/src/services/session-context.ts +232 -0
  360. package/src/services/token-refresh-scheduler.ts +68 -0
  361. package/src/types/index.ts +1 -0
  362. package/src/types/network.ts +7 -0
  363. package/src/utils/context.ts +49 -0
  364. package/src/utils/env.ts +12 -0
  365. package/src/utils/index.ts +5 -0
  366. package/src/utils/mcp.ts +8 -0
  367. package/src/utils/network.ts +65 -0
  368. package/src/utils/pkce.ts +39 -0
  369. package/src/version.ts +15 -0
  370. package/tsconfig.json +28 -0
@@ -0,0 +1,884 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ALL_PROMPTS = exports.SYS_SETTINGS_PROMPT = exports.TAGGING_PROMPT = exports.CONTACTID_PROMPT = exports.DATETIME_PROMPT = exports.CREATE_ACTIVITY_PROMPT = void 0;
4
+ const DEFAULT_ACTIVITY_IDS = {
5
+ TYPE_TASK: 'fbe0acdc-cfc0-df11-b00f-001d60e938c6',
6
+ CATEGORY_TODO: 'f2c0ce0e-cfc1-df11-b00f-001d60e938c6',
7
+ STATUS_NOT_STARTED: '384d4b84-58e6-df11-971b-001d60e938c6',
8
+ PRIORITY_MEDIUM: 'ab96fa02-7fe6-df11-971b-001d60e938c6',
9
+ };
10
+ const ACTIVITY_TYPE_TABLE = `
11
+ | User says / intent | TypeId → Type (fixed) | Category (set via ActivityCategoryId) |
12
+ |--------------------|-----------------------|---------------------------------------|
13
+ | task / todo (default) | Task | To do |
14
+ | meeting / meet / sync | Task | Meeting |
15
+ | call / phone | Task | Call |
16
+ | email / mail | Task | Email |
17
+
18
+ 💡 We deliberately keep Type always = Task for speed. Change only if user explicitly insists: "Use real meeting type".
19
+ `.trim();
20
+ const CREATE_ACTIVITY_WORKFLOW = `
21
+ # 🆕 Create Activity in Creatio (Optimized 99% Case)
22
+
23
+ ⚠️⚠️⚠️ FIRST STEP - ALWAYS CALL get-current-user-info FIRST! ⚠️⚠️⚠️
24
+
25
+ Before creating ANY activity, you MUST:
26
+ 1. Call 'get-current-user-info' tool (no parameters)
27
+ 2. Extract contactId from response
28
+ 3. Store contactId in memory
29
+ 4. Use contactId as OwnerId and AuthorId in the activity
30
+
31
+ DO NOT skip this step! Activities require valid OwnerId and AuthorId (both = contactId).
32
+
33
+ ## Why Simplified?
34
+ Business usage: almost all activities should just appear in calendar quickly. So we hardcode **Type = Task** and only adjust the **Category** to reflect intent (meeting / call / email / todo). This minimizes API calls and cognitive load.
35
+
36
+ If user explicitly insists: "Use real meeting type" / "Set actual Call type" → THEN switch to extended lookup mode (ActivityType + ActivityCategory must match). Otherwise stay in fast mode.
37
+
38
+ ⚠️ ABSOLUTE RULE:
39
+ Always set **TypeId = Task** for intents like "meeting", "meet", "sync", "call", "phone", "email", "mail", "todo", "task" UNLESS (and only unless) the user explicitly demands a non-Task type using phrases such as:
40
+ "real meeting type", "actual meeting type", "true call type", "use real ActivityType", "not a task", "change the Type itself", "use Visit type", "use Call type id".
41
+
42
+ Plain requests like "create a meeting", "schedule a call", "create email follow-up" DO *NOT* justify changing Type. Treat them as Category changes only.
43
+
44
+ 🚫 NEVER perform ActivityType lookups for Meeting/Call/Email unless escalation trigger is present. Doing so wastes calls and breaks the 99% optimization goal.
45
+
46
+ ❌ WRONG (for ordinary meeting request): Query ActivityType 'Visit' then set TypeId=Visit.
47
+ ✅ RIGHT: Keep TypeId=Task; lookup only ActivityCategory 'Meeting'.
48
+
49
+ ---
50
+ ## 📋 STEP 1: Parse Intent → Decide Category (Type fixed = Task)
51
+
52
+ Ask (if unclear): "What kind of activity? (task / meeting / call / email)". Default = task.
53
+
54
+ ${ACTIVITY_TYPE_TABLE}
55
+
56
+ GUIDs we already have (hardcoded):
57
+ - TypeId (Task): ${DEFAULT_ACTIVITY_IDS.TYPE_TASK}
58
+ - Default Category (To do): ${DEFAULT_ACTIVITY_IDS.CATEGORY_TODO}
59
+ - Default Status (Not started): ${DEFAULT_ACTIVITY_IDS.STATUS_NOT_STARTED}
60
+ - Default Priority (Medium): ${DEFAULT_ACTIVITY_IDS.PRIORITY_MEDIUM}
61
+
62
+ If category ≠ To do (e.g. Meeting / Call / Email) and you don't have its GUID cached:
63
+ 1. Query ActivityCategory by Name (e.g. filter: "Name eq 'Meeting'") select Id top 1
64
+ 2. Use returned Id as ActivityCategoryId
65
+
66
+ Do NOT query ActivityType unless user demands non-Task type explicitly.
67
+
68
+ ---
69
+ ## 👤 STEP 2: Resolve ContactId (Owner/Author) - USE get-current-user-info!
70
+
71
+ 🎯 **DEFAULT BEHAVIOR: Activities are ALWAYS created for the current user!**
72
+
73
+ Unless the user **explicitly** requests to create an activity for someone else (e.g., "create a task for John", "schedule meeting for Anna"),
74
+ **ALWAYS** use the current user's ContactId as both OwnerId and AuthorId.
75
+
76
+ ### Get Current User ContactId:
77
+
78
+ **MANDATORY FIRST CALL:** Use \`get-current-user-info\` tool:
79
+
80
+ STEP 1: Call \`get-current-user-info\` (no parameters) ← DO THIS NOW if not done yet!
81
+ STEP 2: Extract \`contactId\` from response
82
+ STEP 3: Use contactId for OwnerId & AuthorId
83
+
84
+ **Alternative (Legacy):** Query SysAdminUnit once for ContactId (NOT Id!). Store and reuse.
85
+
86
+ ⚠️ CRITICAL:
87
+ - Never use SysAdminUnit.Id for Owner/Author fields. Always use ContactId!
88
+ - By default, OwnerId = AuthorId = current user's ContactId
89
+ - Only change if user explicitly says "for [other person]"
90
+
91
+ See /contactid-guide prompt for detailed explanation.
92
+
93
+ ---
94
+ ## ⏰ STEP 3: Timezone Handling
95
+
96
+ Always confirm timezone → convert to UTC → ISO 8601 with Z. See /datetime-guide for full details.
97
+
98
+ ---
99
+ ## 🔨 STEP 4: Construct Payload
100
+
101
+ Base payload:
102
+ \`\`\`json
103
+ {
104
+ "entity": "Activity",
105
+ "data": {
106
+ "Title": "<title>",
107
+ "TypeId": "${DEFAULT_ACTIVITY_IDS.TYPE_TASK}",
108
+ "ActivityCategoryId": "<category-guid>",
109
+ "StartDate": "<utc-start>",
110
+ "DueDate": "<utc-due>",
111
+ "StatusId": "${DEFAULT_ACTIVITY_IDS.STATUS_NOT_STARTED}",
112
+ "OwnerId": "<contactId>",
113
+ "AuthorId": "<contactId>",
114
+ "PriorityId": "${DEFAULT_ACTIVITY_IDS.PRIORITY_MEDIUM}",
115
+ "ShowInScheduler": true
116
+ }
117
+ }
118
+ \`\`\`
119
+
120
+ **CRITICAL:** Always set \`"ShowInScheduler": true\` for meetings/calls/events so they appear in the calendar!
121
+ Only set to false if user explicitly requests the activity to be hidden from calendar.
122
+
123
+ If user supplies duration only (e.g. 30m) → compute DueDate = StartDate + duration.
124
+
125
+ ---
126
+ ## 👥 STEP 5: Add Participants (Optional)
127
+
128
+ If user requests to add participants to a meeting/call/activity:
129
+ - User says: "add John to the meeting", "invite Anna", "add participant [Name]"
130
+
131
+ ### How to Add Participants:
132
+
133
+ 1. **Find the Contact:** Query Contact entity by Name to get ContactId
134
+ \`\`\`json
135
+ {
136
+ "entity": "Contact",
137
+ "filter": "contains(Name, 'John')",
138
+ "select": ["Id", "Name"],
139
+ "top": 1
140
+ }
141
+ \`\`\`
142
+
143
+ 2. **Create ActivityParticipant record:**
144
+ \`\`\`json
145
+ {
146
+ "entity": "ActivityParticipant",
147
+ "data": {
148
+ "ActivityId": "<activity-guid>",
149
+ "ParticipantId": "<contact-guid>"
150
+ }
151
+ }
152
+ \`\`\`
153
+
154
+ ⚠️ **IMPORTANT:**
155
+ - ActivityId = GUID of the Activity (meeting/call/task)
156
+ - ParticipantId = ContactId of the person to add
157
+ - **NO other fields needed!** Just these two fields are sufficient.
158
+ - You can add multiple participants by creating multiple ActivityParticipant records
159
+
160
+ ### Example:
161
+ User: "Add John and Mary to tomorrow's meeting"
162
+ 1. Create Activity → get activityId
163
+ 2. Find Contact "John" → get johnContactId
164
+ 3. Create ActivityParticipant { ActivityId: activityId, ParticipantId: johnContactId }
165
+ 4. Find Contact "Mary" → get maryContactId
166
+ 5. Create ActivityParticipant { ActivityId: activityId, ParticipantId: maryContactId }
167
+
168
+ ---
169
+ ## ✅ Example (Meeting intent, fast mode)
170
+
171
+ User: "Schedule meeting tomorrow 14:00" → ask timezone → user: "UTC+2" → 14:00 UTC+2 = 12:00Z.
172
+ 1. Resolve ContactId (SysAdminUnit query once)
173
+ 2. Lookup ActivityCategory 'Meeting' (if not cached)
174
+ 3. Create with Type=Task, Category=Meeting
175
+
176
+ ---
177
+ ## 🔁 Escalation to Extended Mode (Rare)
178
+ Trigger only if user supplies explicit escalation phrase (contains one of: "real", "actual", "true", "non-task", "not a task", "use real type", "use Visit type", "use Call type", "change the TypeId"). Simple intent words (meeting/call/email) are NOT escalation.
179
+ If triggered:
180
+ 1. Query ActivityType by Name (Call / Email / Visit)
181
+ 2. Query matching ActivityCategory
182
+ 3. Replace TypeId with looked up Id. (Ensure combination is valid.)
183
+
184
+ ---
185
+ ## 🚨 Common Mistakes
186
+ ❌ Unnecessary lookups for Meeting/Call when fast mode sufficient
187
+ ❌ Using SysAdminUnit.Id instead of ContactId
188
+ ❌ Skipping timezone confirmation
189
+ ❌ Forgetting Z suffix
190
+ ❌ Mismatching explicit non-Task request (ignore only if user accepts fast mode)
191
+ ❌ Adding extra fields to ActivityParticipant (only ActivityId + ParticipantId needed!)
192
+ ❌ Forgetting to create ActivityParticipant records when user asks to add participants
193
+
194
+ ---
195
+ ## 🧠 Decision Heuristics
196
+ If user is vague: default Category = To do.
197
+ If keywords: "meeting", "meet", "sync" → Meeting category.
198
+ "call", "phone" → Call category.
199
+ "email", "mail" → Email category.
200
+ Explicit: "task" / nothing → To do.
201
+
202
+ Return the minimal number of read calls (cache category GUIDs when first resolved in session).
203
+ `.trim();
204
+ const DATETIME_GUIDE = `
205
+ # ⏰ DateTime and Timezone Guide for Creatio
206
+
207
+ ## The Problem
208
+ You do NOT automatically know the user's timezone!
209
+ Dates in Creatio must be stored in UTC with ISO 8601 format.
210
+
211
+ ---
212
+
213
+ ## ✅ The Solution: Always Ask!
214
+
215
+ ### Step 1: Identify Date/Time from User
216
+ User says: "Create meeting tomorrow at 2pm"
217
+ - Tomorrow = calculate date
218
+ - 2pm = time in **user's local timezone**
219
+
220
+ ### Step 2: Ask for Timezone
221
+ **You:** "What timezone are you in?"
222
+
223
+ **User might say:**
224
+ - "UTC+3" or "GMT+3"
225
+ - "Europe/Kiev" or "Europe/Warsaw"
226
+ - "EST" or "PST"
227
+ - "My local time is 2pm now" (calculate offset)
228
+
229
+ ### Step 3: Convert to UTC
230
+ Formula: **UTC = Local Time - Offset**
231
+
232
+ Examples:
233
+ - 2pm UTC+3 → 2pm - 3h = **11am UTC**
234
+ - 9am UTC-5 (EST) → 9am - (-5h) = 9am + 5h = **2pm UTC**
235
+ - 10pm UTC+0 → **10pm UTC** (no conversion)
236
+
237
+ ### Step 4: Format as ISO 8601 with Z suffix
238
+ Format: \`YYYY-MM-DDTHH:mm:ss**Z**\`
239
+
240
+ Examples:
241
+ - \`2024-01-16T11:00:00Z\`
242
+ - \`2024-12-25T14:30:00Z\`
243
+ - \`2025-03-01T00:00:00Z\`
244
+
245
+ **The Z suffix means UTC!** Never omit it.
246
+
247
+ ---
248
+
249
+ ## 📋 Common Timezone Reference
250
+
251
+ | Timezone | Offset | Example: 2pm local → UTC |
252
+ |-------------------|---------|--------------------------|
253
+ | UTC+0 (London) | +0 | 2pm → 2pm UTC |
254
+ | UTC+1 (Paris) | +1 | 2pm → 1pm UTC |
255
+ | UTC+2 (Kyiv) | +2 | 2pm → 12pm UTC |
256
+ | UTC+3 (Moscow) | +3 | 2pm → 11am UTC |
257
+ | UTC-5 (EST/NY) | -5 | 2pm → 7pm UTC |
258
+ | UTC-8 (PST/LA) | -8 | 2pm → 10pm UTC |
259
+
260
+ ---
261
+
262
+ ## 💡 Conversation Examples
263
+
264
+ ### Example 1: Clear timezone
265
+ **User:** "Create task tomorrow at 9am EST"
266
+ **You:** *(recognize EST = UTC-5)*
267
+ - Tomorrow = 2024-01-16
268
+ - 9am EST = 9am + 5h = 2pm UTC
269
+ - Store: \`"StartDate": "2024-01-16T14:00:00Z"\`
270
+
271
+ ### Example 2: Ask for clarification
272
+ **User:** "Meeting at 3pm"
273
+ **You:** "What timezone are you in?"
274
+ **User:** "UTC+3"
275
+ **You:** *(calculate)*
276
+ - 3pm UTC+3 = 3pm - 3h = 12pm UTC
277
+ - Store: \`"StartDate": "2024-01-16T12:00:00Z"\`
278
+
279
+ ### Example 3: Relative time
280
+ **User:** "Create task in 2 hours"
281
+ **You:** "What timezone?"
282
+ **User:** "It's 4pm here, UTC+2"
283
+ **You:** *(calculate)*
284
+ - Now: 4pm UTC+2 = 2pm UTC
285
+ - In 2 hours: 2pm + 2h = 4pm UTC
286
+ - Store: \`"StartDate": "2024-01-16T16:00:00Z"\`
287
+
288
+ ---
289
+
290
+ ## 🚨 Critical Rules
291
+
292
+ 1. ⚠️ **ALWAYS ask timezone** - never assume!
293
+ 2. ⚠️ **ALWAYS use Z suffix** - indicates UTC
294
+ 3. ⚠️ **Subtract offset for east** (UTC+) - e.g., UTC+3 → subtract 3
295
+ 4. ⚠️ **Add offset for west** (UTC-) - e.g., UTC-5 → add 5
296
+ 5. ⚠️ **Store in UTC** - Creatio expects UTC, not local time
297
+
298
+ ---
299
+
300
+ ## 🎯 Quick Checklist
301
+
302
+ Before storing ANY date in Creatio:
303
+ - [ ] Asked user for timezone?
304
+ - [ ] Converted local time to UTC?
305
+ - [ ] Used ISO 8601 format?
306
+ - [ ] Added Z suffix?
307
+ - [ ] Double-checked offset direction?
308
+
309
+ If all ✅ → Good to go!
310
+ `.trim();
311
+ const CONTACTID_GUIDE = `
312
+ # 👤 ContactId Rule - UNIVERSAL for ALL Creatio Entities
313
+
314
+ ## 🚨 CRITICAL RULE (Read This First!)
315
+
316
+ In Creatio, there are TWO types of IDs:
317
+
318
+ 1. **SysAdminUnit.Id** = User account ID (for login/permissions)
319
+ 2. **SysAdminUnit.ContactId** = Contact ID (for CRM records)
320
+
321
+ ### For CRM fields, ALWAYS use ContactId!
322
+
323
+ This applies to **ALL entities**, not just Activity:
324
+ - Activity.OwnerId = ContactId ✅
325
+ - Activity.AuthorId = ContactId ✅
326
+ - Lead.OwnerId = ContactId ✅
327
+ - Opportunity.OwnerId = ContactId ✅
328
+ - Case.OwnerId = ContactId ✅
329
+ - Account.OwnerId = ContactId ✅
330
+
331
+ ---
332
+
333
+ ## 🎯 The Workflow (RECOMMENDED!)
334
+
335
+ ### 🔑 DEFAULT RULE: Current User by Default!
336
+
337
+ **ALWAYS assume activities/tasks/leads/opportunities are for the CURRENT USER unless explicitly told otherwise!**
338
+
339
+ Examples:
340
+ - ❌ "Create task" → DO NOT ask "for whom?" → Create for current user!
341
+ - ❌ "Schedule meeting tomorrow" → DO NOT ask "whose meeting?" → Current user's meeting!
342
+ - ✅ "Create task for John" → Only THEN create for someone else
343
+ - ✅ "Schedule meeting with Anna as owner" → Only THEN change owner
344
+
345
+ **This is the expected behavior! Don't annoy users by asking obvious questions.**
346
+
347
+ ### Step 1: Use get-current-user-info Tool (BEST METHOD!)
348
+
349
+ **RECOMMENDED:** Use the dedicated tool to get user information:
350
+
351
+ Call \`get-current-user-info\` tool (no parameters needed)
352
+
353
+ **Returns:**
354
+ \`\`\`json
355
+ {
356
+ "userId": "410006e1-ca4e-4502-a9ec-e54d922d2c00",
357
+ "contactId": "76929f8c-7e15-4c64-bdb0-adc62d383727", // ← USE THIS!
358
+ "userName": "Current User",
359
+ "cultureName": "en-US"
360
+ }
361
+ \`\`\`
362
+
363
+ **Why this is better:**
364
+ - ✅ Single call, all info
365
+ - ✅ No need to know username
366
+ - ✅ Gets ContactId directly
367
+ - ✅ More reliable
368
+ - ✅ Use contactId for ALL Owner/Author fields by default
369
+
370
+ ### Alternative: Query SysAdminUnit (Legacy Method)
371
+
372
+ If you need to query manually:
373
+
374
+ \`\`\`json
375
+ {
376
+ "entity": "SysAdminUnit",
377
+ "filter": "Name eq '<your_username>'",
378
+ "select": ["ContactId"],
379
+ "top": 1
380
+ }
381
+ \`\`\`
382
+
383
+ **Returns:**
384
+ \`\`\`json
385
+ [{
386
+ "ContactId": "76929f8c-7e15-4c64-bfb1-40c705d25fcd"
387
+ }]
388
+ \`\`\`
389
+
390
+ ### Step 2: Store ContactId in Memory
391
+
392
+ Remember the ContactId for the entire conversation:
393
+
394
+ \`\`\`typescript
395
+ const currentUserContactId = "76929f8c-7e15-4c64-bfb1-40c705d25fcd";
396
+ \`\`\`
397
+
398
+ ### Step 3: Use This ContactId EVERYWHERE
399
+
400
+ For **ANY** entity that has owner/author/creator fields:
401
+
402
+ \`\`\`json
403
+ {
404
+ "entity": "Activity",
405
+ "data": {
406
+ "OwnerId": currentUserContactId, // ← ContactId
407
+ "AuthorId": currentUserContactId // ← ContactId
408
+ }
409
+ }
410
+ \`\`\`
411
+
412
+ \`\`\`json
413
+ {
414
+ "entity": "Lead",
415
+ "data": {
416
+ "OwnerId": currentUserContactId // ← ContactId
417
+ }
418
+ }
419
+ \`\`\`
420
+
421
+ \`\`\`json
422
+ {
423
+ "entity": "Opportunity",
424
+ "data": {
425
+ "OwnerId": currentUserContactId // ← ContactId
426
+ }
427
+ }
428
+ \`\`\`
429
+
430
+ ---
431
+
432
+ ## ❌ Common Mistake
433
+
434
+ ### WRONG (using SysAdminUnit.Id):
435
+ \`\`\`json
436
+ // Step 1: Query SysAdminUnit
437
+ read("SysAdminUnit", "Name eq '<your_username>'", ["Id"], 1)
438
+ // → Returns: [{ "Id": "410006e1-ca4e-4502-a9ec-e54d922d2c00" }]
439
+
440
+ // Step 2: Use .Id (WRONG!)
441
+ create("Activity", {
442
+ "OwnerId": "410006e1-ca4e-4502-a9ec-e54d922d2c00" // ❌ This is user ID!
443
+ })
444
+ // → ERROR: Invalid reference or constraint violation!
445
+ \`\`\`
446
+
447
+ ### ✅ CORRECT (using ContactId):
448
+ \`\`\`json
449
+ // Step 1: Query SysAdminUnit
450
+ read("SysAdminUnit", "Name eq '<your_username>'", ["ContactId"], 1)
451
+ // → Returns: [{ "ContactId": "76929f8c-7e15-4c64-bfb1-40c705d25fcd" }]
452
+
453
+ // Step 2: Use .ContactId (CORRECT!)
454
+ create("Activity", {
455
+ "OwnerId": "76929f8c-7e15-4c64-bfb1-40c705d25fcd" // ✅ This is contact ID!
456
+ })
457
+ // → SUCCESS!
458
+ \`\`\`
459
+
460
+ ---
461
+
462
+ ## 🔍 Visual Explanation
463
+
464
+ \`\`\`
465
+ SysAdminUnit "<your_username>":
466
+ ├─ Id: "410006e1..." ← USER account (for system/permissions)
467
+ │ └─ Used for: Login, roles, access rights
468
+
469
+ └─ ContactId: "76929f8c..." ← CONTACT record (for CRM)
470
+ └─ Used for: Activities, Leads, Opportunities, Owners, Authors
471
+
472
+ Contact "John Doe":
473
+ └─ Id: "76929f8c..." ← Same as SysAdminUnit.ContactId!
474
+ └─ This is the CRM person record
475
+ \`\`\`
476
+
477
+ ---
478
+
479
+ ## 📋 When to Use Each ID
480
+
481
+ | Field Type | Use This | Example Entity |
482
+ |-------------------------------|-----------------|------------------------|
483
+ | OwnerId | **ContactId** | Activity, Lead, Case |
484
+ | AuthorId | **ContactId** | Activity |
485
+ | CreatedById | **ContactId** | Any entity |
486
+ | ModifiedById | **ContactId** | Any entity |
487
+ | ContactId (in Activity) | **ContactId** | Activity |
488
+ | ParticipantId | **ContactId** | ActivityParticipant |
489
+ | ResponsibleId | **ContactId** | Lead, Opportunity |
490
+ | System permissions/roles | **Id** | SysAdminUnit relations |
491
+
492
+ **Rule of thumb:** If it's a CRM field → **ContactId**. Always.
493
+
494
+ ---
495
+
496
+ ## 🎯 Best Practice
497
+
498
+ At the **start of any workflow** that needs user identity:
499
+
500
+ 1. Query \`SysAdminUnit\` once
501
+ 2. Select \`["ContactId"]\`
502
+ 3. Store in variable
503
+ 4. Use everywhere
504
+
505
+ **Don't query multiple times!** One query per session is enough.
506
+
507
+ ---
508
+
509
+ ## ⚠️ What If I Used Wrong ID?
510
+
511
+ You'll see errors like:
512
+ - "Foreign key constraint violation"
513
+ - "Invalid reference"
514
+ - "Record not found"
515
+ - Owner field is empty or points to wrong person
516
+
517
+ **Solution:** Go back and use ContactId instead of Id!
518
+
519
+ ---
520
+
521
+ ## 💡 Summary
522
+
523
+ - **SysAdminUnit.Id** = User account (system)
524
+ - **SysAdminUnit.ContactId** = Contact person (CRM)
525
+ - **For CRM fields** → ALWAYS use ContactId
526
+ - **Query once** → Use everywhere
527
+ - **This rule applies** → ALL entities in Creatio
528
+
529
+ Remember: **ContactId, not Id!** 🎯
530
+ `.trim();
531
+ const TAGGING_GUIDE = `
532
+ # 🏷️ Tagging Records in Creatio
533
+
534
+ ## 🚨 CRITICAL DECISION: Which Tag System?
535
+
536
+ Creatio has TWO tagging systems that may coexist:
537
+
538
+ ### 1️⃣ LEGACY System (Entity-Specific) - **DEFAULT & RECOMMENDED**
539
+ - Uses: \`<Entity>Tag\` and \`<Entity>InTag\` tables
540
+ - Examples: \`ActivityTag\` + \`ActivityInTag\`, \`AccountTag\` + \`AccountInTag\`
541
+ - Fields: \`TagId\` (from <Entity>Tag), \`EntityId\` (record GUID)
542
+ - **Use this by DEFAULT unless user explicitly asks for universal tags!**
543
+
544
+ ### 2️⃣ NEW System (Universal)
545
+ - Uses: \`Tag\` and \`TagInRecord\` tables
546
+ - Fields: \`TagId\`, \`RecordId\`, \`RecordSchemaName\`
547
+ - Only use if user specifically says "use universal tags" or "use new tag system"
548
+
549
+ ---
550
+
551
+ ## ⚡ Quick Decision Flow
552
+
553
+ **MANDATORY behavior:**
554
+ 1. Check if \`<Entity>Tag\` exists (e.g., \`ActivityTag\`)
555
+ 2. If BOTH systems exist (Legacy AND Universal):
556
+ → **ALWAYS ASK USER**: "Which tagging system should I use: legacy (ActivityTag/ActivityInTag) or universal (Tag/TagInRecord)?"
557
+ → Wait for explicit user response - NO DEFAULT!
558
+ → User must choose: "legacy" or "universal"
559
+ 3. If ONLY legacy exists → Use legacy (no question needed)
560
+ 4. If ONLY universal exists → Use universal (no question needed)
561
+
562
+ **CRITICAL:** Never auto-choose when both systems are available! Always ask and wait for clear answer!
563
+
564
+ ---
565
+
566
+ ## 📋 STEP-BY-STEP WORKFLOW
567
+
568
+ ### Step 1: Identify Target Entity & Record
569
+ - Extract entity name (Activity, Contact, Account, etc.)
570
+ - Get record GUID (from context or ask user)
571
+ - Store as: \`entityName\`, \`recordId\`
572
+
573
+ ### Step 2: Choose System (MANDATORY CHECK!)
574
+
575
+ **Always perform this check:**
576
+
577
+ 1. Try describe-entity on \`<Entity>Tag\` (e.g., "ActivityTag")
578
+ 2. Try describe-entity on \`Tag\`
579
+ 3. Determine availability:
580
+ - BOTH exist → **ASK USER MANDATORY**: "I found both tagging systems. Which one should I use: legacy (<Entity>Tag) or universal (Tag)?"
581
+ - ONLY legacy exists → Use legacy automatically
582
+ - ONLY universal exists → Use universal automatically
583
+ - NEITHER exists → Error (cannot tag)
584
+
585
+ **User response handling:**
586
+ - "legacy" / "old" / "entity-specific" / "<Entity>Tag" → useLegacy = true
587
+ - "universal" / "new" / "Tag" / "TagInRecord" → useLegacy = false
588
+ - If unclear response → Ask again for clarification
589
+
590
+ **NEVER skip the question when both systems are present!**
591
+ **NEVER assume a default - wait for explicit user choice!**
592
+
593
+ ### Step 3: Resolve or Create Tag
594
+
595
+ **Tag name can be ANY value provided by user** (e.g., "VIP", "Urgent", "Follow-up", "Important", etc.)
596
+
597
+ **For LEGACY system:**
598
+ 1. Try to find existing tag: read <Entity>Tag where Name eq '<TagName>' select Id top 1
599
+ 2. If not found, create it: create <Entity>Tag with Name: "<TagName>"
600
+ 3. Returns tag Id (GUID)
601
+
602
+ **For UNIVERSAL system:**
603
+ 1. Try to find existing tag: read Tag where Name eq '<TagName>' and EntitySchemaName eq '<Entity>' select Id top 1
604
+ 2. If not found, create it: create Tag with Name: "<TagName>", EntitySchemaName: "<Entity>"
605
+ 3. Returns tag Id (GUID)
606
+
607
+ ### Step 4: Check if Already Tagged
608
+ Avoid duplicate links!
609
+
610
+ **LEGACY:**
611
+ - read <Entity>InTag where TagId eq <tag-guid> and EntityId eq <record-guid> select Id top 1
612
+
613
+ **UNIVERSAL:**
614
+ - read TagInRecord where TagId eq <tag-guid> and RecordId eq <record-guid> select Id top 1
615
+
616
+ ### Step 5: Create Link (if not exists)
617
+
618
+ **LEGACY:**
619
+ - create <Entity>InTag with TagId: <tag-guid>, EntityId: <record-guid>
620
+
621
+ **UNIVERSAL:**
622
+ - create TagInRecord with TagId: <tag-guid>, RecordId: <record-guid>, RecordSchemaName: "<Entity>"
623
+
624
+ ---
625
+
626
+ ## 💡 Examples
627
+
628
+ ### Example 1: Add "VIP" tag to Activity (Standard Request)
629
+
630
+ User: "Add tag VIP to this meeting"
631
+
632
+ LLM Actions:
633
+ 1. Detect: Entity = Activity, recordId from context
634
+ 2. Check: ActivityTag exists? YES. Tag exists? YES (BOTH found!)
635
+ 3. ASK USER: "Which tagging system should I use: legacy (ActivityTag) or universal (Tag)?"
636
+ 4. User: "legacy"
637
+ 5. Query: ActivityTag where Name='VIP' (found: "9dd32c9f...")
638
+ 6. Check: ActivityInTag link exists? NO
639
+ 7. Create: ActivityInTag with TagId: "9dd32c9f...", EntityId: "meeting-id"
640
+ 8. Report: "Added VIP tag to meeting using legacy system"
641
+
642
+ ### Example 2: User explicitly wants universal system
643
+
644
+ User: "Add tag Important using the new universal tag system"
645
+
646
+ LLM Actions:
647
+ 1. User specified "new universal" (useLegacy = false, skip question!)
648
+ 2. Query: Tag where Name='Important' and EntitySchemaName='Activity'
649
+ 3. If not found: Create Tag with Name: "Important", EntitySchemaName: "Activity"
650
+ 4. Create: TagInRecord with TagId, RecordId, RecordSchemaName: "Activity"
651
+ 5. Report: "Added Important tag using universal system"
652
+
653
+ ### Example 3: Legacy system doesn't exist
654
+
655
+ User: "Add tag to CustomEntity"
656
+
657
+ LLM Actions:
658
+ 1. Check: CustomEntityTag exists? NO
659
+ 2. Auto-fallback: Use universal system
660
+ 3. Query/Create in Tag table
661
+ 4. Link via TagInRecord
662
+
663
+ ---
664
+
665
+ ## 🚨 Common Mistakes to Avoid
666
+
667
+ ❌ **WRONG:** Auto-choosing system when both exist
668
+ ✅ **RIGHT:** ALWAYS ask user when both legacy and universal are available
669
+
670
+ ❌ **WRONG:** Creating duplicate tags without checking
671
+ ✅ **RIGHT:** Always check existence first
672
+
673
+ ❌ **WRONG:** Not checking if link already exists
674
+ ✅ **RIGHT:** Query <Entity>InTag or TagInRecord before creating
675
+
676
+ ❌ **WRONG:** Skipping the mandatory question
677
+ ✅ **RIGHT:** If both systems exist, MUST ask user which one to use
678
+
679
+ ---
680
+
681
+ ## 📊 Quick Reference Table
682
+
683
+ | Entity | Tag Table | Link Table | Tag Field | Record Field |
684
+ |-----------|----------------|-------------------|-----------|--------------|
685
+ | Activity | ActivityTag | ActivityInTag | TagId | EntityId |
686
+ | Account | AccountTag | AccountInTag | TagId | EntityId |
687
+ | Contact | ContactTag | ContactInTag | TagId | EntityId |
688
+ | Lead | LeadTag | LeadInTag | TagId | EntityId |
689
+ | Case | CaseTag | CaseInTag | TagId | EntityId |
690
+ | *Universal* | Tag | TagInRecord | TagId | RecordId |
691
+
692
+ ---
693
+
694
+ ## ✅ Final Checklist
695
+
696
+ Before creating a tag link:
697
+ - [ ] Entity and record GUID identified
698
+ - [ ] System auto-detected (legacy preferred)
699
+ - [ ] Tag resolved or created in correct table
700
+ - [ ] Existing link checked (no duplicates)
701
+ - [ ] Link created in correct table
702
+ - [ ] User notified of success
703
+
704
+ ---
705
+
706
+ ## 🎯 Remember
707
+
708
+ **The Golden Rule:** When BOTH systems exist - ALWAYS ASK USER (no defaults!)
709
+
710
+ Question format: "I found both tagging systems for <Entity>. Which should I use: legacy (<Entity>Tag) or universal (Tag)?"
711
+
712
+ **Wait for explicit answer!** Do not proceed until user chooses.
713
+
714
+ Only skip question if:
715
+ - ONLY legacy exists → Use legacy automatically
716
+ - ONLY universal exists → Use universal automatically
717
+ - User already specified in original request (e.g., "use new tag system")
718
+
719
+ **Tag names:** Can be ANY value user provides (VIP, Urgent, Important, Follow-up, etc.)
720
+
721
+ **DO NOT assume or auto-choose when both are present!**
722
+ `.trim();
723
+ const SYS_SETTINGS_VALUE_TYPES_TABLE = `
724
+ | valueTypeName | Display label |
725
+ | ------------- | ----------------------- |
726
+ | Binary | BLOB |
727
+ | Boolean | Boolean |
728
+ | DateTime | Date/Time |
729
+ | Date | Date |
730
+ | Time | Time |
731
+ | Integer | Integer |
732
+ | Money | Currency (0.01) |
733
+ | Float | Decimal |
734
+ | Lookup | Lookup |
735
+ | ShortText | Text (50 characters) |
736
+ | MediumText | Text (250 characters) |
737
+ | LongText | Text (500 characters) |
738
+ | Text | Text |
739
+ | MaxSizeText | Unlimited length text |
740
+ | SecureText | Encrypted string |
741
+ `.trim();
742
+ const SYS_SETTINGS_GUIDE = `
743
+ # ⚙️ Creating Creatio System Settings
744
+
745
+ ## Supported valueTypeName values
746
+ Always use the **value** column (not the display label) when filling \`definition.valueTypeName\`.
747
+
748
+ ${SYS_SETTINGS_VALUE_TYPES_TABLE}
749
+
750
+ ## Discovering existing system settings
751
+ To inspect what system settings already exist (names, codes, value types, cache flags, etc.), query the
752
+ \`VwSysSetting\` view via the standard \`read\` tool. Example:
753
+
754
+ \`\`\`json
755
+ {
756
+ "entity": "VwSysSetting",
757
+ "select": [
758
+ "Id",
759
+ "Name",
760
+ "Code",
761
+ "Description",
762
+ "ValueTypeName",
763
+ "IsPersonal",
764
+ "IsCacheable"
765
+ ],
766
+ "top": 50
767
+ }
768
+ \`\`\`
769
+
770
+ Filter by \`Code\` or \`Name\` to narrow results (e.g., \`"filters":{"all":[{"field":"Code","op":"contains","value":"Product"}]}\`).
771
+ This is the fastest way to learn which settings already exist before inserting new ones.
772
+
773
+ ## Lookup referenceSchemaUId
774
+ - Required only when \`valueTypeName = "Lookup"\`.
775
+ - Set \`definition.referenceSchemaUId\` to the EntitySchema UId of the lookup target.
776
+ - Fetch the UId from \`VwWorkspaceObjects\` by filtering on the schema name.
777
+
778
+ ### Example MCP read request
779
+ \`\`\`json
780
+ {
781
+ "entity": "VwWorkspaceObjects",
782
+ "filters": {
783
+ "all": [
784
+ { "field": "Name", "op": "eq", "value": "Account" }
785
+ ]
786
+ },
787
+ "select": ["UId", "Name", "Caption"]
788
+ }
789
+ \`\`\`
790
+
791
+ Use the returned \`UId\` as \`referenceSchemaUId\` inside the \`create-sys-setting\` tool payload.
792
+
793
+ ## Quick workflow reminder
794
+ 1. Insert sys setting metadata via \`create-sys-setting\`.
795
+ 2. Optionally include \`initialValue\` to write the first value immediately.
796
+ 3. For additional updates later, call \`set-sys-settings-value\`.
797
+ `.trim();
798
+ exports.CREATE_ACTIVITY_PROMPT = {
799
+ name: 'create-activity-guide',
800
+ title: 'Create Activity in Creatio',
801
+ description: 'Complete step-by-step guide for creating Activities (tasks/meetings/calls) in Creatio',
802
+ argsSchema: {},
803
+ callback: () => ({
804
+ messages: [
805
+ {
806
+ role: 'user',
807
+ content: {
808
+ type: 'text',
809
+ text: CREATE_ACTIVITY_WORKFLOW,
810
+ },
811
+ },
812
+ ],
813
+ }),
814
+ };
815
+ exports.DATETIME_PROMPT = {
816
+ name: 'datetime-guide',
817
+ title: 'DateTime and Timezone Guide',
818
+ description: 'How to ask users for timezone and convert to UTC for Creatio',
819
+ argsSchema: {},
820
+ callback: () => ({
821
+ messages: [
822
+ {
823
+ role: 'user',
824
+ content: {
825
+ type: 'text',
826
+ text: DATETIME_GUIDE,
827
+ },
828
+ },
829
+ ],
830
+ }),
831
+ };
832
+ exports.CONTACTID_PROMPT = {
833
+ name: 'contactid-guide',
834
+ title: 'ContactId Rule for All Entities',
835
+ description: 'CRITICAL: Always use SysAdminUnit.ContactId (not .Id!) for all CRM fields across all entities',
836
+ argsSchema: {},
837
+ callback: () => ({
838
+ messages: [
839
+ {
840
+ role: 'user',
841
+ content: {
842
+ type: 'text',
843
+ text: CONTACTID_GUIDE,
844
+ },
845
+ },
846
+ ],
847
+ }),
848
+ };
849
+ exports.TAGGING_PROMPT = {
850
+ name: 'tagging-guide',
851
+ title: 'Tagging Records (New & Legacy Systems)',
852
+ description: 'Guide for adding tags to records using Tag/TagInRecord or legacy <Entity>Tag / <Entity>InTag tables',
853
+ argsSchema: {},
854
+ callback: () => ({
855
+ messages: [
856
+ {
857
+ role: 'user',
858
+ content: { type: 'text', text: TAGGING_GUIDE },
859
+ },
860
+ ],
861
+ }),
862
+ };
863
+ exports.SYS_SETTINGS_PROMPT = {
864
+ name: 'sys-settings-guide',
865
+ title: 'Creatio System Settings Guide',
866
+ description: 'Value type options and lookup reference instructions for create-sys-setting / set-sys-settings-value workflows',
867
+ argsSchema: {},
868
+ callback: () => ({
869
+ messages: [
870
+ {
871
+ role: 'user',
872
+ content: { type: 'text', text: SYS_SETTINGS_GUIDE },
873
+ },
874
+ ],
875
+ }),
876
+ };
877
+ exports.ALL_PROMPTS = [
878
+ exports.CREATE_ACTIVITY_PROMPT,
879
+ exports.DATETIME_PROMPT,
880
+ exports.CONTACTID_PROMPT,
881
+ exports.TAGGING_PROMPT,
882
+ exports.SYS_SETTINGS_PROMPT,
883
+ ];
884
+ //# sourceMappingURL=prompts-data.js.map