@silexlabs/grapesjs-ai-capabilities 0.0.3 → 0.0.4

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 CHANGED
@@ -74,6 +74,16 @@ for (const cap of capabilities) {
74
74
 
75
75
  Execution always goes through `editor.runCommand()` — this plugin does not implement `run()`.
76
76
 
77
+ ## Window global
78
+
79
+ When running in a browser, the plugin exposes the registry as `window.grapesjsAiCapabilities`. This is useful for environments that cannot use ES module imports (e.g. Tauri initialization scripts, browser console, injected scripts):
80
+
81
+ ```js
82
+ const caps = window.grapesjsAiCapabilities.getAllCapabilities()
83
+ ```
84
+
85
+ For all other cases, prefer the module imports described above.
86
+
77
87
  ## API reference
78
88
 
79
89
  The plugin keeps a single global registry. Query functions don't need the editor.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- /*! @silexlabs/grapesjs-ai-capabilities - 0.0.3 */
2
- !function(t,e){'object'==typeof exports&&'object'==typeof module?module.exports=e():'function'==typeof define&&define.amd?define([],e):'object'==typeof exports?exports["@silexlabs/grapesjs-ai-capabilities"]=e():t["@silexlabs/grapesjs-ai-capabilities"]=e()}(Object('undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:this),()=>(()=>{"use strict";var t={d:(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(t,'__esModule',{value:!0})}},e={};function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function o(t){var e=function(t,e){if("object"!=r(t)||!t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var n=o.call(t,e||"default");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==r(e)?e:e+""}function n(t,e,r){return(e=o(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,o)}return r}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach(function(e){n(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}t.r(e),t.d(e,{EVENT_READY:()=>l,PLUGIN_ID:()=>c,addCapability:()=>b,clearCapabilities:()=>h,default:()=>f,getAllCapabilities:()=>d,getCapability:()=>y,hasCapability:()=>g,removeCapability:()=>m});const c='grapesjs-ai-capabilities',u=new Map,s=['title','tags','version'];function p(t){if(null===t||'object'!=typeof t)return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}const l='ai-capabilities:ready',f=t=>{t.on('load',()=>{t.trigger(l,b)})};function b(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!t||'string'!=typeof t.id||!t.id)throw new Error('id is required and must be a non-empty string');if('string'!=typeof t.command||!t.command)throw new Error('command is required and must be a non-empty string');const r=t.description||t.prompt;if('string'!=typeof r||!r)throw new Error('description (or prompt) is required and must be a non-empty string');if(u.has(t.id)&&!e.replace)throw new Error("Capability \"".concat(t.id,"\" already exists"));if(void 0!==t.tags&&!Array.isArray(t.tags))throw new Error('tags must be an array');if(void 0!==t.inputSchema&&!p(t.inputSchema))throw new Error('inputSchema must be an object');if(void 0!==t.outputSchema&&!p(t.outputSchema))throw new Error('outputSchema must be an object');const o={id:t.id,command:t.command,description:r,inputSchema:t.inputSchema||{},outputSchema:t.outputSchema||{}};for(const e of s)void 0!==t[e]&&(o[e]=t[e]);return u.set(t.id,o),a({},o)}function y(t){const e=u.get(t);if(!e)throw new Error("Capability \"".concat(t,"\" not found"));return a({},e)}function d(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Array.from(u.values());return t.tags&&Array.isArray(t.tags)&&t.tags.length&&(e=e.filter(e=>e.tags&&t.tags.some(t=>e.tags.includes(t)))),e.map(t=>a({},t))}function m(t){return u.delete(t)}function g(t){return u.has(t)}function h(){u.clear()}return e})());
1
+ /*! @silexlabs/grapesjs-ai-capabilities - 0.0.4 */
2
+ !function(t,e){'object'==typeof exports&&'object'==typeof module?module.exports=e():'function'==typeof define&&define.amd?define([],e):'object'==typeof exports?exports["@silexlabs/grapesjs-ai-capabilities"]=e():t["@silexlabs/grapesjs-ai-capabilities"]=e()}(Object('undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:this),()=>(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(t,'__esModule',{value:!0})}},e={};function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function i(t){var e=function(t,e){if("object"!=r(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,e||"default");if("object"!=r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==r(e)?e:e+""}function o(t,e,r){return(e=i(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,i)}return r}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach(function(e){o(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}t.r(e),t.d(e,{EVENT_READY:()=>l,PLUGIN_ID:()=>c,addCapability:()=>b,clearCapabilities:()=>w,default:()=>f,getAllCapabilities:()=>y,getCapability:()=>d,hasCapability:()=>g,removeCapability:()=>m});const c='grapesjs-ai-capabilities',s=new Map,p=['title','tags','version','readOnly','destructive','idempotent','openWorld'];function u(t){if(null===t||'object'!=typeof t)return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}const l='ai-capabilities:ready',f=t=>{'undefined'!=typeof window&&(window.grapesjsAiCapabilities={addCapability:b,getCapability:d,getAllCapabilities:y,removeCapability:m,hasCapability:g,clearCapabilities:w}),t.on('load',()=>{t.trigger(l,b)})};function b(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!t||'string'!=typeof t.id||!t.id)throw new Error('id is required and must be a non-empty string');if('string'!=typeof t.command||!t.command)throw new Error('command is required and must be a non-empty string');const r=t.description||t.prompt;if('string'!=typeof r||!r)throw new Error('description (or prompt) is required and must be a non-empty string');if(s.has(t.id)&&!e.replace)throw new Error("Capability \"".concat(t.id,"\" already exists"));if(void 0!==t.tags&&!Array.isArray(t.tags))throw new Error('tags must be an array');if(void 0!==t.inputSchema&&!u(t.inputSchema))throw new Error('inputSchema must be an object');if(void 0!==t.outputSchema&&!u(t.outputSchema))throw new Error('outputSchema must be an object');const i={id:t.id,command:t.command,description:r,inputSchema:t.inputSchema||{},outputSchema:t.outputSchema||{}};for(const e of p)void 0!==t[e]&&(i[e]=t[e]);return s.set(t.id,i),a({},i)}function d(t){const e=s.get(t);if(!e)throw new Error("Capability \"".concat(t,"\" not found"));return a({},e)}function y(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Array.from(s.values());return t.tags&&Array.isArray(t.tags)&&t.tags.length&&(e=e.filter(e=>e.tags&&t.tags.some(t=>e.tags.includes(t)))),e.map(t=>a({},t))}function m(t){return s.delete(t)}function g(t){return s.has(t)}function w(){s.clear()}return e})());
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAQ,uCAAyCD,IAEjDD,EAAK,uCAAyCC,GAC/C,CATD,CASGK,OAA6B,oBAAfC,WAA6BA,WAAgC,oBAAXC,OAAyBA,OAASC,MAAQ,I,mBCR7G,IAAIC,EAAsB,CCA1BA,EAAwB,CAACR,EAASS,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAEX,EAASU,IAC5EN,OAAOQ,eAAeZ,EAASU,EAAK,CAAEG,YAAY,EAAMC,IAAKL,EAAWC,MCJ3EF,EAAwB,CAACO,EAAKC,IAAUZ,OAAOa,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFR,EAAyBR,IACH,oBAAXoB,QAA0BA,OAAOC,aAC1CjB,OAAOQ,eAAeZ,EAASoB,OAAOC,YAAa,CAAEC,MAAO,WAE7DlB,OAAOQ,eAAeZ,EAAS,aAAc,CAAEsB,OAAO,M,KCLvD,SAASC,EAAQZ,GAGf,OAAOY,EAAU,mBA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EAAOZ,OAASY,EAAOZ,KAAKV,SACzDuB,EAAeA,EAAaD,OAAOI,GAC/BA,EAAEhB,MAAQY,EAAOZ,KAAKiB,KAAKtD,GAAKqD,EAAEhB,KAAKkB,SAASvD,MAGjDkD,EAAaM,IAAIH,GAACR,EAAA,GAAUQ,GACvC,CAEO,SAASI,EAAiB5B,GAC7B,OAAOjB,EAAS8C,OAAO7B,EAC3B,CAEO,SAAS8B,EAAc9B,GAC1B,OAAOjB,EAASsB,IAAIL,EACxB,CAEO,SAAS+B,IACZhD,EAASiD,OACb,C","sources":["webpack://@silexlabs/grapesjs-ai-capabilities/webpack/universalModuleDefinition","webpack://@silexlabs/grapesjs-ai-capabilities/webpack/bootstrap","webpack://@silexlabs/grapesjs-ai-capabilities/webpack/runtime/define property getters","webpack://@silexlabs/grapesjs-ai-capabilities/webpack/runtime/hasOwnProperty shorthand","webpack://@silexlabs/grapesjs-ai-capabilities/webpack/runtime/make namespace object","webpack://@silexlabs/grapesjs-ai-capabilities/./node_modules/@babel/runtime/helpers/esm/typeof.js","webpack://@silexlabs/grapesjs-ai-capabilities/./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js","webpack://@silexlabs/grapesjs-ai-capabilities/./node_modules/@babel/runtime/helpers/esm/toPrimitive.js","webpack://@silexlabs/grapesjs-ai-capabilities/./node_modules/@babel/runtime/helpers/esm/defineProperty.js","webpack://@silexlabs/grapesjs-ai-capabilities/./src/index.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"@silexlabs/grapesjs-ai-capabilities\"] = factory();\n\telse\n\t\troot[\"@silexlabs/grapesjs-ai-capabilities\"] = factory();\n})(Object(typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : this)), () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","function _typeof(o) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {\n return typeof o;\n } : function (o) {\n return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n }, _typeof(o);\n}\nexport { _typeof as default };","import _typeof from \"./typeof.js\";\nimport toPrimitive from \"./toPrimitive.js\";\nfunction toPropertyKey(t) {\n var i = toPrimitive(t, \"string\");\n return \"symbol\" == _typeof(i) ? i : i + \"\";\n}\nexport { toPropertyKey as default };","import _typeof from \"./typeof.js\";\nfunction toPrimitive(t, r) {\n if (\"object\" != _typeof(t) || !t) return t;\n var e = t[Symbol.toPrimitive];\n if (void 0 !== e) {\n var i = e.call(t, r || \"default\");\n if (\"object\" != _typeof(i)) return i;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (\"string\" === r ? String : Number)(t);\n}\nexport { toPrimitive as default };","import toPropertyKey from \"./toPropertyKey.js\";\nfunction _defineProperty(e, r, t) {\n return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {\n value: t,\n enumerable: !0,\n configurable: !0,\n writable: !0\n }) : e[r] = t, e;\n}\nexport { _defineProperty as default };","export const PLUGIN_ID = 'grapesjs-ai-capabilities'\n\nconst registry = new Map()\nconst OPTIONAL_FIELDS = ['title', 'tags', 'version']\n\nfunction isPlainObject(v) {\n if (v === null || typeof v !== 'object') return false\n const proto = Object.getPrototypeOf(v)\n return proto === Object.prototype || proto === null\n}\n\nexport const EVENT_READY = 'ai-capabilities:ready'\n\nexport default (editor) => {\n editor.on('load', () => {\n editor.trigger(EVENT_READY, addCapability)\n })\n}\n\nexport function addCapability(def, options = {}) {\n if (!def || typeof def.id !== 'string' || !def.id) {\n throw new Error('id is required and must be a non-empty string')\n }\n if (typeof def.command !== 'string' || !def.command) {\n throw new Error('command is required and must be a non-empty string')\n }\n const description = def.description || def.prompt\n if (typeof description !== 'string' || !description) {\n throw new Error('description (or prompt) is required and must be a non-empty string')\n }\n if (registry.has(def.id) && !options.replace) {\n throw new Error(`Capability \"${def.id}\" already exists`)\n }\n if (def.tags !== undefined && !Array.isArray(def.tags)) {\n throw new Error('tags must be an array')\n }\n if (def.inputSchema !== undefined && !isPlainObject(def.inputSchema)) {\n throw new Error('inputSchema must be an object')\n }\n if (def.outputSchema !== undefined && !isPlainObject(def.outputSchema)) {\n throw new Error('outputSchema must be an object')\n }\n\n const capability = {\n id: def.id,\n command: def.command,\n description,\n inputSchema: def.inputSchema || {},\n outputSchema: def.outputSchema || {},\n }\n for (const field of OPTIONAL_FIELDS) {\n if (def[field] !== undefined) capability[field] = def[field]\n }\n registry.set(def.id, capability)\n return { ...capability }\n}\n\nexport function getCapability(id) {\n const cap = registry.get(id)\n if (!cap) {\n throw new Error(`Capability \"${id}\" not found`)\n }\n return { ...cap }\n}\n\nexport function getAllCapabilities(filter = {}) {\n let capabilities = Array.from(registry.values())\n if (filter.tags && Array.isArray(filter.tags) && filter.tags.length) {\n capabilities = capabilities.filter(c =>\n c.tags && filter.tags.some(t => c.tags.includes(t))\n )\n }\n return capabilities.map(c => ({ ...c }))\n}\n\nexport function removeCapability(id) {\n return registry.delete(id)\n}\n\nexport function hasCapability(id) {\n return registry.has(id)\n}\n\nexport function clearCapabilities() {\n registry.clear()\n}\n"],"names":["root","factory","exports","module","define","amd","Object","globalThis","window","this","__webpack_require__","definition","key","o","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","_typeof","iterator","constructor","toPropertyKey","t","i","r","e","toPrimitive","TypeError","String","Number","_defineProperty","configurable","writable","PLUGIN_ID","registry","Map","OPTIONAL_FIELDS","isPlainObject","v","proto","getPrototypeOf","EVENT_READY","editor","on","trigger","addCapability","def","options","arguments","length","undefined","id","Error","command","description","prompt","has","replace","concat","tags","Array","isArray","inputSchema","outputSchema","capability","field","set","_objectSpread","getCapability","cap","getAllCapabilities","filter","capabilities","from","values","c","some","includes","map","removeCapability","delete","hasCapability","clearCapabilities","clear"],"sourceRoot":""}
1
+ {"version":3,"file":"index.js","mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAQ,uCAAyCD,IAEjDD,EAAK,uCAAyCC,GAC/C,CATD,CASGK,OAA6B,oBAAfC,WAA6BA,WAAgC,oBAAXC,OAAyBA,OAASC,MAAQ,I,mBCR7G,IAAIC,EAAsB,CCA1BA,EAAwB,CAACR,EAASS,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAEX,EAASU,IAC5EN,OAAOQ,eAAeZ,EAASU,EAAK,CAAEG,YAAY,EAAMC,IAAKL,EAAWC,MCJ3EF,EAAwB,CAACO,EAAKC,IAAUZ,OAAOa,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFR,EAAyBR,IACH,oBAAXoB,QAA0BA,OAAOC,aAC1CjB,OAAOQ,eAAeZ,EAASoB,OAAOC,YAAa,CAAEC,MAAO,WAE7DlB,OAAOQ,eAAeZ,EAAS,aAAc,CAAEsB,OAAO,M,KCLvD,SAASC,EAAQZ,GAGf,OAAOY,EAAU,mBAAqBH,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AAAA,UAAA,GAAG,CAAC,EACrCsB,EAAeV,MAAMW,KAAK3C,EAAS4C,UAMvC,OALIH,EAAOV,MAAQC,MAAMC,QAAQQ,EAAOV,OAASU,EAAOV,KAAKV,SACzDqB,EAAeA,EAAaD,OAAOI,GAC/BA,EAAEd,MAAQU,EAAOV,KAAKe,KAAK1D,GAAKyD,EAAEd,KAAKgB,SAAS3D,MAGjDsD,EAAaM,IAAIH,GAACN,EAAA,GAAUM,GACvC,CAEO,SAAShC,EAAiBU,GAC7B,OAAOvB,EAASiD,OAAO1B,EAC3B,CAEO,SAAST,EAAcS,GAC1B,OAAOvB,EAAS4B,IAAIL,EACxB,CAEO,SAASR,IACZf,EAASkD,OACb,C","sources":["webpack://@silexlabs/grapesjs-ai-capabilities/webpack/universalModuleDefinition","webpack://@silexlabs/grapesjs-ai-capabilities/webpack/bootstrap","webpack://@silexlabs/grapesjs-ai-capabilities/webpack/runtime/define property getters","webpack://@silexlabs/grapesjs-ai-capabilities/webpack/runtime/hasOwnProperty shorthand","webpack://@silexlabs/grapesjs-ai-capabilities/webpack/runtime/make namespace object","webpack://@silexlabs/grapesjs-ai-capabilities/./node_modules/@babel/runtime/helpers/esm/typeof.js","webpack://@silexlabs/grapesjs-ai-capabilities/./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js","webpack://@silexlabs/grapesjs-ai-capabilities/./node_modules/@babel/runtime/helpers/esm/toPrimitive.js","webpack://@silexlabs/grapesjs-ai-capabilities/./node_modules/@babel/runtime/helpers/esm/defineProperty.js","webpack://@silexlabs/grapesjs-ai-capabilities/./src/index.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"@silexlabs/grapesjs-ai-capabilities\"] = factory();\n\telse\n\t\troot[\"@silexlabs/grapesjs-ai-capabilities\"] = factory();\n})(Object(typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : this)), () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","function _typeof(o) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {\n return typeof o;\n } : function (o) {\n return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n }, _typeof(o);\n}\nexport { _typeof as default };","import _typeof from \"./typeof.js\";\nimport toPrimitive from \"./toPrimitive.js\";\nfunction toPropertyKey(t) {\n var i = toPrimitive(t, \"string\");\n return \"symbol\" == _typeof(i) ? i : i + \"\";\n}\nexport { toPropertyKey as default };","import _typeof from \"./typeof.js\";\nfunction toPrimitive(t, r) {\n if (\"object\" != _typeof(t) || !t) return t;\n var e = t[Symbol.toPrimitive];\n if (void 0 !== e) {\n var i = e.call(t, r || \"default\");\n if (\"object\" != _typeof(i)) return i;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (\"string\" === r ? String : Number)(t);\n}\nexport { toPrimitive as default };","import toPropertyKey from \"./toPropertyKey.js\";\nfunction _defineProperty(e, r, t) {\n return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {\n value: t,\n enumerable: !0,\n configurable: !0,\n writable: !0\n }) : e[r] = t, e;\n}\nexport { _defineProperty as default };","export const PLUGIN_ID = 'grapesjs-ai-capabilities'\n\nconst registry = new Map()\nconst OPTIONAL_FIELDS = ['title', 'tags', 'version', 'readOnly', 'destructive', 'idempotent', 'openWorld']\n\nfunction isPlainObject(v) {\n if (v === null || typeof v !== 'object') return false\n const proto = Object.getPrototypeOf(v)\n return proto === Object.prototype || proto === null\n}\n\nexport const EVENT_READY = 'ai-capabilities:ready'\n\nexport default (editor) => {\n // Expose registry for cross-module access (desktop-bridge, MCP server)\n if (typeof window !== 'undefined') {\n window.grapesjsAiCapabilities = {\n addCapability,\n getCapability,\n getAllCapabilities,\n removeCapability,\n hasCapability,\n clearCapabilities,\n }\n }\n editor.on('load', () => {\n editor.trigger(EVENT_READY, addCapability)\n })\n}\n\nexport function addCapability(def, options = {}) {\n if (!def || typeof def.id !== 'string' || !def.id) {\n throw new Error('id is required and must be a non-empty string')\n }\n if (typeof def.command !== 'string' || !def.command) {\n throw new Error('command is required and must be a non-empty string')\n }\n const description = def.description || def.prompt\n if (typeof description !== 'string' || !description) {\n throw new Error('description (or prompt) is required and must be a non-empty string')\n }\n if (registry.has(def.id) && !options.replace) {\n throw new Error(`Capability \"${def.id}\" already exists`)\n }\n if (def.tags !== undefined && !Array.isArray(def.tags)) {\n throw new Error('tags must be an array')\n }\n if (def.inputSchema !== undefined && !isPlainObject(def.inputSchema)) {\n throw new Error('inputSchema must be an object')\n }\n if (def.outputSchema !== undefined && !isPlainObject(def.outputSchema)) {\n throw new Error('outputSchema must be an object')\n }\n\n const capability = {\n id: def.id,\n command: def.command,\n description,\n inputSchema: def.inputSchema || {},\n outputSchema: def.outputSchema || {},\n }\n for (const field of OPTIONAL_FIELDS) {\n if (def[field] !== undefined) capability[field] = def[field]\n }\n registry.set(def.id, capability)\n return { ...capability }\n}\n\nexport function getCapability(id) {\n const cap = registry.get(id)\n if (!cap) {\n throw new Error(`Capability \"${id}\" not found`)\n }\n return { ...cap }\n}\n\nexport function getAllCapabilities(filter = {}) {\n let capabilities = Array.from(registry.values())\n if (filter.tags && Array.isArray(filter.tags) && filter.tags.length) {\n capabilities = capabilities.filter(c =>\n c.tags && filter.tags.some(t => c.tags.includes(t))\n )\n }\n return capabilities.map(c => ({ ...c }))\n}\n\nexport function removeCapability(id) {\n return registry.delete(id)\n}\n\nexport function hasCapability(id) {\n return registry.has(id)\n}\n\nexport function clearCapabilities() {\n registry.clear()\n}\n"],"names":["root","factory","exports","module","define","amd","Object","globalThis","window","this","__webpack_require__","definition","key","o","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","_typeof","iterator","constructor","toPropertyKey","t","i","r","e","toPrimitive","TypeError","String","Number","_defineProperty","configurable","writable","PLUGIN_ID","registry","Map","OPTIONAL_FIELDS","isPlainObject","v","proto","getPrototypeOf","EVENT_READY","editor","grapesjsAiCapabilities","addCapability","getCapability","getAllCapabilities","removeCapability","hasCapability","clearCapabilities","on","trigger","def","options","arguments","length","undefined","id","Error","command","description","prompt","has","replace","concat","tags","Array","isArray","inputSchema","outputSchema","capability","field","set","_objectSpread","cap","filter","capabilities","from","values","c","some","includes","map","delete","clear"],"sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silexlabs/grapesjs-ai-capabilities",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Discovery and metadata layer for GrapesJS commands, enabling MCP tool exposure and external integrations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export const PLUGIN_ID = 'grapesjs-ai-capabilities'
2
2
 
3
3
  const registry = new Map()
4
- const OPTIONAL_FIELDS = ['title', 'tags', 'version']
4
+ const OPTIONAL_FIELDS = ['title', 'tags', 'version', 'readOnly', 'destructive', 'idempotent', 'openWorld']
5
5
 
6
6
  function isPlainObject(v) {
7
7
  if (v === null || typeof v !== 'object') return false
@@ -12,6 +12,17 @@ function isPlainObject(v) {
12
12
  export const EVENT_READY = 'ai-capabilities:ready'
13
13
 
14
14
  export default (editor) => {
15
+ // Expose registry for cross-module access (desktop-bridge, MCP server)
16
+ if (typeof window !== 'undefined') {
17
+ window.grapesjsAiCapabilities = {
18
+ addCapability,
19
+ getCapability,
20
+ getAllCapabilities,
21
+ removeCapability,
22
+ hasCapability,
23
+ clearCapabilities,
24
+ }
25
+ }
15
26
  editor.on('load', () => {
16
27
  editor.trigger(EVENT_READY, addCapability)
17
28
  })