@univerjs-pro/mcp 0.10.12 → 0.10.13

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.
@@ -1,4 +1,4 @@
1
- import { Disposable, ILogService } from '@univerjs/core';
1
+ import { Disposable, IConfigService, ILogService, Injector } from '@univerjs/core';
2
2
  import { z } from 'zod';
3
3
  import { MCPEventService } from '../services/mcp-event.service';
4
4
  /**
@@ -38,8 +38,10 @@ export declare const IMCPToolRegistry: import('@wendellhu/redi').IdentifierDecor
38
38
  export declare class MCPToolRegistryController extends Disposable implements IMCPToolRegistry {
39
39
  private readonly _logService;
40
40
  private readonly _mcpEventService;
41
+ readonly _injector: Injector;
42
+ private readonly _configService;
41
43
  private readonly _tools;
42
- constructor(_logService: ILogService, _mcpEventService: MCPEventService);
44
+ constructor(_logService: ILogService, _mcpEventService: MCPEventService, _injector: Injector, _configService: IConfigService);
43
45
  /**
44
46
  * Register a tool for MCP calls
45
47
  */
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Safe JSON stringification utilities for MCP protocol
3
+ * Handles circular references and complex objects with minimal overhead
4
+ */
5
+ /**
6
+ * Safely stringify JSON with strict filtering for complex objects
7
+ * Only allows basic types, plain Objects, and Arrays to be serialized
8
+ * All other types are converted to descriptive strings at the first level
9
+ * @param value - The value to stringify
10
+ * @param space - Optional spacing for formatting
11
+ * @returns JSON string with safe handling of complex objects
12
+ */
13
+ export declare function safeJsonStringify(value: any, space?: string | number): string;
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(_0x5377fb,_0xeba218){const _0x26ee1f=_0x145b,_0x659f83=_0x5377fb();while(!![]){try{const _0xf01aa7=-parseInt(_0x26ee1f(0x190))/0x1+-parseInt(_0x26ee1f(0x1ac))/0x2+-parseInt(_0x26ee1f(0x186))/0x3+parseInt(_0x26ee1f(0x19d))/0x4*(parseInt(_0x26ee1f(0x184))/0x5)+-parseInt(_0x26ee1f(0x1b2))/0x6+-parseInt(_0x26ee1f(0x1ad))/0x7*(parseInt(_0x26ee1f(0x1a2))/0x8)+parseInt(_0x26ee1f(0x19a))/0x9*(parseInt(_0x26ee1f(0x188))/0xa);if(_0xf01aa7===_0xeba218)break;else _0x659f83['push'](_0x659f83['shift']());}catch(_0x50eb61){_0x659f83['push'](_0x659f83['shift']());}}}(_0x22df,0xecca2),function(_0x1ae06f,_0x5ba99a){const _0x5b93b9=_0x145b;typeof exports==_0x5b93b9(0x1a4)&&typeof module<'u'?_0x5ba99a(require('@univerjs-pro/mcp'),require('@univerjs/core/facade'),require('@univerjs/core')):typeof define==_0x5b93b9(0x199)&&define[_0x5b93b9(0x191)]?define([_0x5b93b9(0x1a1),_0x5b93b9(0x1b0),_0x5b93b9(0x1b4)],_0x5ba99a):(_0x1ae06f=typeof globalThis<'u'?globalThis:_0x1ae06f||self,_0x5ba99a(_0x1ae06f[_0x5b93b9(0x18e)],_0x1ae06f[_0x5b93b9(0x1a5)],_0x1ae06f['UniverCore']));}(this,function(_0x575755,_0xb78d21,_0x3260d){'use strict';const _0x54adce=_0x145b;class _0x1a0417{get[_0x54adce(0x1a8)](){const _0x2d5d2a=_0x54adce;return _0x575755[_0x2d5d2a(0x18d)][_0x2d5d2a(0x1a8)];}get[_0x54adce(0x195)](){const _0x50f694=_0x54adce;return _0x575755['MCPEventId'][_0x50f694(0x195)];}get[_0x54adce(0x1b3)](){const _0x41c201=_0x54adce;return _0x575755[_0x41c201(0x18d)][_0x41c201(0x1b3)];}get['McpToolCallFailed'](){const _0x33a868=_0x54adce;return _0x575755[_0x33a868(0x18d)][_0x33a868(0x19e)];}}_0xb78d21[_0x54adce(0x1a3)]['extend'](_0x1a0417);class _0x5568ea extends _0xb78d21[_0x54adce(0x1a7)]{[_0x54adce(0x19b)](_0x20af0b){const _0x332e4e=_0x54adce;this[_0x332e4e(0x18a)](_0x20af0b);}[_0x54adce(0x18a)](_0x36d9e9){const _0x231e4e=_0x54adce,_0x289512=_0x36d9e9[_0x231e4e(0x1ae)](_0x575755[_0x231e4e(0x1a0)]);this['registerEventHandler'](this[_0x231e4e(0x193)][_0x231e4e(0x1a8)],()=>_0x3260d[_0x231e4e(0x1b1)](_0x289512['event$'][_0x231e4e(0x197)](_0x190a8c=>{const _0x203bef=_0x231e4e;_0x190a8c['type']===_0x575755[_0x203bef(0x18d)][_0x203bef(0x1a8)]&&this[_0x203bef(0x189)](this[_0x203bef(0x193)][_0x203bef(0x1a8)],_0x190a8c['data']);}))),this['registerEventHandler'](this[_0x231e4e(0x193)][_0x231e4e(0x195)],()=>_0x3260d['toDisposable'](_0x289512['event$'][_0x231e4e(0x197)](_0xe32fe4=>{const _0x591314=_0x231e4e;_0xe32fe4['type']===_0x575755[_0x591314(0x18d)]['McpToolCallReceived']&&this[_0x591314(0x189)](this[_0x591314(0x193)][_0x591314(0x195)],_0xe32fe4[_0x591314(0x194)]);}))),this[_0x231e4e(0x1ab)](this[_0x231e4e(0x193)][_0x231e4e(0x1b3)],()=>_0x3260d[_0x231e4e(0x1b1)](_0x289512[_0x231e4e(0x19c)][_0x231e4e(0x197)](_0x2a0163=>{const _0x436652=_0x231e4e;_0x2a0163['type']===_0x575755[_0x436652(0x18d)]['McpToolCallExecuted']&&this[_0x436652(0x189)](this[_0x436652(0x193)][_0x436652(0x1b3)],_0x2a0163[_0x436652(0x194)]);}))),this[_0x231e4e(0x1ab)](this['Event'][_0x231e4e(0x19e)],()=>_0x3260d['toDisposable'](_0x289512[_0x231e4e(0x19c)]['subscribe'](_0x3836dc=>{const _0x23c574=_0x231e4e;_0x3836dc[_0x23c574(0x187)]===_0x575755[_0x23c574(0x18d)][_0x23c574(0x19e)]&&this[_0x23c574(0x189)](this[_0x23c574(0x193)][_0x23c574(0x19e)],_0x3836dc['data']);})));}[_0x54adce(0x192)](_0x5ef1e4,_0x1bc2f0){const _0x3610e2=_0x54adce;return this['_injector'][_0x3610e2(0x1ae)](_0x575755[_0x3610e2(0x18f)])['validateToolCall'](_0x5ef1e4,_0x1bc2f0);}[_0x54adce(0x1a9)](){const _0x1a9c25=_0x54adce;return this[_0x1a9c25(0x185)]['get'](_0x575755[_0x1a9c25(0x18f)])[_0x1a9c25(0x19f)]();}[_0x54adce(0x196)](_0x2f1db0,_0x303f61){const _0x38a234=_0x54adce;return this['_injector'][_0x38a234(0x1ae)](_0x575755[_0x38a234(0x18f)])['executeTool'](_0x2f1db0,_0x303f61);}[_0x54adce(0x1b5)](){const _0x3628c0=_0x54adce;return this[_0x3628c0(0x185)][_0x3628c0(0x1ae)](_0x575755[_0x3628c0(0x18c)])['getConnectionStatus']();}[_0x54adce(0x1a6)](){const _0xa13661=_0x54adce;this['_injector'][_0xa13661(0x1ae)](_0x575755[_0xa13661(0x18c)])[_0xa13661(0x1af)]();}[_0x54adce(0x18b)](){const _0x3a4ef4=_0x54adce;this[_0x3a4ef4(0x185)][_0x3a4ef4(0x1ae)](_0x575755['MCPConnectionController'])[_0x3a4ef4(0x1aa)]();}}_0xb78d21['FUniver'][_0x54adce(0x198)](_0x5568ea);}));function _0x145b(_0x5a95f4,_0x55e40b){const _0x22df38=_0x22df();return _0x145b=function(_0x145bb0,_0x246eff){_0x145bb0=_0x145bb0-0x184;let _0x4ab635=_0x22df38[_0x145bb0];return _0x4ab635;},_0x145b(_0x5a95f4,_0x55e40b);}function _0x22df(){const _0x3346fc=['function','6381mpEcWz','_initialize','event$','4iIcLPo','McpToolCallFailed','getAllTools','MCPEventService','@univerjs-pro/mcp','2296120mhDpDs','FEventName','object','UniverCoreFacade','connectMCP','FUniver','McpConnectionStatusChanged','getAllMCPTools','disconnect','registerEventHandler','1976772xJmUAE','35BkIeIK','get','connect','@univerjs/core/facade','toDisposable','5043156GRLevL','McpToolCallExecuted','@univerjs/core','getMCPConnectionStatus','458165Jikuan','_injector','160548GSnUiY','type','76730uSJWQV','fireEvent','_registerMCPFacadeEvents','disconnectMCP','MCPConnectionController','MCPEventId','UniverProMcp','IMCPToolRegistry','1244397SlCXYi','amd','validateMCPToolCall','Event','data','McpToolCallReceived','callMCPTool','subscribe','extend'];_0x22df=function(){return _0x3346fc;};return _0x22df();}
1
+ function _0x4d63(_0x5d3806,_0x26ff2f){const _0x720a84=_0x720a();return _0x4d63=function(_0x4d631a,_0x37afa4){_0x4d631a=_0x4d631a-0xd1;let _0x294907=_0x720a84[_0x4d631a];return _0x294907;},_0x4d63(_0x5d3806,_0x26ff2f);}function _0x720a(){const _0x2d8897=['McpToolCallReceived','McpToolCallExecuted','13058kJUaxd','209Ntbjpw','validateMCPToolCall','extend','1364484kyHmUt','284NGRUlv','getAllTools','5698338EUwrtQ','7HGizZe','Event','object','UniverProMcp','disconnectMCP','callMCPTool','@univerjs/core/facade','1295224nkzEBO','MCPEventService','2873055sqyCfZ','_registerMCPFacadeEvents','25524zhGKFm','405378ELhhwF','FUniver','@univerjs-pro/mcp','57sSHVgE','toDisposable','_initialize','_injector','registerEventHandler','connect','connectMCP','fireEvent','data','disconnect','McpToolCallFailed','MCPEventId','function','MCPConnectionController','subscribe','110crvryi','IMCPToolRegistry','event$','McpConnectionStatusChanged','getMCPConnectionStatus','type','get'];_0x720a=function(){return _0x2d8897;};return _0x720a();}(function(_0x4e756d,_0x2f6806){const _0x2f8d10=_0x4d63,_0x78bc92=_0x4e756d();while(!![]){try{const _0x39ee41=-parseInt(_0x2f8d10(0xf3))/0x1*(parseInt(_0x2f8d10(0xdc))/0x2)+parseInt(_0x2f8d10(0xef))/0x3*(-parseInt(_0x2f8d10(0xe1))/0x4)+parseInt(_0x2f8d10(0xed))/0x5+parseInt(_0x2f8d10(0xe3))/0x6*(-parseInt(_0x2f8d10(0xe4))/0x7)+parseInt(_0x2f8d10(0xeb))/0x8+-parseInt(_0x2f8d10(0xf0))/0x9*(parseInt(_0x2f8d10(0xd3))/0xa)+parseInt(_0x2f8d10(0xdd))/0xb*(parseInt(_0x2f8d10(0xe0))/0xc);if(_0x39ee41===_0x2f6806)break;else _0x78bc92['push'](_0x78bc92['shift']());}catch(_0x466d82){_0x78bc92['push'](_0x78bc92['shift']());}}}(_0x720a,0x74195),function(_0x584250,_0x5c1a7c){const _0x15eba3=_0x4d63;typeof exports==_0x15eba3(0xe6)&&typeof module<'u'?_0x5c1a7c(require('@univerjs-pro/mcp'),require('@univerjs/core/facade'),require('@univerjs/core')):typeof define==_0x15eba3(0xff)&&define['amd']?define([_0x15eba3(0xf2),_0x15eba3(0xea),'@univerjs/core'],_0x5c1a7c):(_0x584250=typeof globalThis<'u'?globalThis:_0x584250||self,_0x5c1a7c(_0x584250[_0x15eba3(0xe7)],_0x584250['UniverCoreFacade'],_0x584250['UniverCore']));}(this,function(_0x1a9b5d,_0x2ba270,_0x4dbc0e){'use strict';const _0x17b341=_0x4d63;class _0x1bd628{get[_0x17b341(0xd6)](){const _0x24b3ed=_0x17b341;return _0x1a9b5d['MCPEventId'][_0x24b3ed(0xd6)];}get[_0x17b341(0xda)](){return _0x1a9b5d['MCPEventId']['McpToolCallReceived'];}get[_0x17b341(0xdb)](){const _0x4b6aca=_0x17b341;return _0x1a9b5d[_0x4b6aca(0xfe)][_0x4b6aca(0xdb)];}get[_0x17b341(0xfd)](){const _0x8f055a=_0x17b341;return _0x1a9b5d['MCPEventId'][_0x8f055a(0xfd)];}}_0x2ba270['FEventName'][_0x17b341(0xdf)](_0x1bd628);class _0xe8adb3 extends _0x2ba270['FUniver']{[_0x17b341(0xf5)](_0x2a0853){const _0x23d128=_0x17b341;this[_0x23d128(0xee)](_0x2a0853);}[_0x17b341(0xee)](_0x52c9de){const _0x2429a0=_0x17b341,_0x5543bc=_0x52c9de[_0x2429a0(0xd9)](_0x1a9b5d[_0x2429a0(0xec)]);this['registerEventHandler'](this[_0x2429a0(0xe5)]['McpConnectionStatusChanged'],()=>_0x4dbc0e['toDisposable'](_0x5543bc[_0x2429a0(0xd5)][_0x2429a0(0xd2)](_0x53d7b7=>{const _0x109696=_0x2429a0;_0x53d7b7[_0x109696(0xd8)]===_0x1a9b5d[_0x109696(0xfe)][_0x109696(0xd6)]&&this[_0x109696(0xfa)](this[_0x109696(0xe5)][_0x109696(0xd6)],_0x53d7b7['data']);}))),this['registerEventHandler'](this[_0x2429a0(0xe5)][_0x2429a0(0xda)],()=>_0x4dbc0e['toDisposable'](_0x5543bc[_0x2429a0(0xd5)][_0x2429a0(0xd2)](_0x1237cf=>{const _0x2b5599=_0x2429a0;_0x1237cf[_0x2b5599(0xd8)]===_0x1a9b5d[_0x2b5599(0xfe)][_0x2b5599(0xda)]&&this[_0x2b5599(0xfa)](this['Event']['McpToolCallReceived'],_0x1237cf[_0x2b5599(0xfb)]);}))),this[_0x2429a0(0xf7)](this[_0x2429a0(0xe5)]['McpToolCallExecuted'],()=>_0x4dbc0e['toDisposable'](_0x5543bc[_0x2429a0(0xd5)][_0x2429a0(0xd2)](_0x3bacd0=>{const _0x99dab6=_0x2429a0;_0x3bacd0[_0x99dab6(0xd8)]===_0x1a9b5d[_0x99dab6(0xfe)][_0x99dab6(0xdb)]&&this['fireEvent'](this[_0x99dab6(0xe5)][_0x99dab6(0xdb)],_0x3bacd0[_0x99dab6(0xfb)]);}))),this['registerEventHandler'](this[_0x2429a0(0xe5)][_0x2429a0(0xfd)],()=>_0x4dbc0e[_0x2429a0(0xf4)](_0x5543bc[_0x2429a0(0xd5)][_0x2429a0(0xd2)](_0x236a9d=>{const _0x1e8d5b=_0x2429a0;_0x236a9d[_0x1e8d5b(0xd8)]===_0x1a9b5d['MCPEventId']['McpToolCallFailed']&&this[_0x1e8d5b(0xfa)](this[_0x1e8d5b(0xe5)][_0x1e8d5b(0xfd)],_0x236a9d['data']);})));}[_0x17b341(0xde)](_0x4db0a3,_0x4ed2a8){const _0x1f830f=_0x17b341;return this[_0x1f830f(0xf6)][_0x1f830f(0xd9)](_0x1a9b5d[_0x1f830f(0xd4)])['validateToolCall'](_0x4db0a3,_0x4ed2a8);}['getAllMCPTools'](){const _0x4081cb=_0x17b341;return this[_0x4081cb(0xf6)][_0x4081cb(0xd9)](_0x1a9b5d['IMCPToolRegistry'])[_0x4081cb(0xe2)]();}[_0x17b341(0xe9)](_0x597a18,_0x2f1f98){const _0x1412fa=_0x17b341;return this[_0x1412fa(0xf6)][_0x1412fa(0xd9)](_0x1a9b5d[_0x1412fa(0xd4)])['executeTool'](_0x597a18,_0x2f1f98);}[_0x17b341(0xd7)](){const _0x2c19bb=_0x17b341;return this[_0x2c19bb(0xf6)][_0x2c19bb(0xd9)](_0x1a9b5d[_0x2c19bb(0xd1)])['getConnectionStatus']();}[_0x17b341(0xf9)](){const _0x3b0506=_0x17b341;this[_0x3b0506(0xf6)][_0x3b0506(0xd9)](_0x1a9b5d[_0x3b0506(0xd1)])[_0x3b0506(0xf8)]();}[_0x17b341(0xe8)](){const _0x1fcffb=_0x17b341;this[_0x1fcffb(0xf6)][_0x1fcffb(0xd9)](_0x1a9b5d[_0x1fcffb(0xd1)])[_0x1fcffb(0xfc)]();}}_0x2ba270[_0x17b341(0xf1)]['extend'](_0xe8adb3);}));