modality-kit 0.8.10 → 0.9.0

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/dist/index.js CHANGED
@@ -21,8 +21,10 @@ var setupAITools = (aiTools, mcpServer) => {
21
21
  if (mcpServer) {
22
22
  Object.entries(aiTools).forEach(([toolName, aiTool]) => {
23
23
  let name = aiTool.name != null ? aiTool.name : toolName;
24
+ const { inputSchema, ...restAITool } = aiTool;
24
25
  mcpServer.addTool({
25
- ...aiTool,
26
+ ...restAITool,
27
+ parameters: inputSchema,
26
28
  name
27
29
  });
28
30
  });
@@ -3,11 +3,11 @@ declare const positionSchema: z.ZodObject<{
3
3
  line: z.ZodNumber;
4
4
  col: z.ZodNumber;
5
5
  }, "strip", z.ZodTypeAny, {
6
- col: number;
7
6
  line: number;
8
- }, {
9
7
  col: number;
8
+ }, {
10
9
  line: number;
10
+ col: number;
11
11
  }>;
12
12
  export declare const symbolKinds: readonly ["File", "Module", "Namespace", "Package", "Class", "Method", "Property", "Field", "Constructor", "Enum", "Interface", "Function", "Variable", "Constant", "String", "Number", "Boolean", "Array", "Object", "Key", "Null", "EnumMember", "Struct", "Event", "Operator", "TypeParameter"];
13
13
  export declare const symbolKindSchema: z.ZodEnum<["File", "Module", "Namespace", "Package", "Class", "Method", "Property", "Field", "Constructor", "Enum", "Interface", "Function", "Variable", "Constant", "String", "Number", "Boolean", "Array", "Object", "Key", "Null", "EnumMember", "Struct", "Event", "Operator", "TypeParameter"]>;
@@ -17,39 +17,39 @@ export declare const rangeSchema: z.ZodObject<{
17
17
  line: z.ZodNumber;
18
18
  col: z.ZodNumber;
19
19
  }, "strip", z.ZodTypeAny, {
20
- col: number;
21
20
  line: number;
22
- }, {
23
21
  col: number;
22
+ }, {
24
23
  line: number;
24
+ col: number;
25
25
  }>;
26
26
  end: z.ZodObject<{
27
27
  line: z.ZodNumber;
28
28
  col: z.ZodNumber;
29
29
  }, "strip", z.ZodTypeAny, {
30
- col: number;
31
30
  line: number;
32
- }, {
33
31
  col: number;
32
+ }, {
34
33
  line: number;
34
+ col: number;
35
35
  }>;
36
36
  }, "strip", z.ZodTypeAny, {
37
37
  start: {
38
- col: number;
39
38
  line: number;
39
+ col: number;
40
40
  };
41
41
  end: {
42
- col: number;
43
42
  line: number;
43
+ col: number;
44
44
  };
45
45
  }, {
46
46
  start: {
47
- col: number;
48
47
  line: number;
48
+ col: number;
49
49
  };
50
50
  end: {
51
- col: number;
52
51
  line: number;
52
+ col: number;
53
53
  };
54
54
  }>;
55
55
  export type Position = z.infer<typeof positionSchema>;
@@ -92,12 +92,12 @@ declare const fileEntrySchema: z.ZodObject<{
92
92
  type: z.ZodEnum<["file", "directory"]>;
93
93
  lastModified: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
94
94
  }, "strip", z.ZodTypeAny, {
95
- path: string;
96
95
  type: "file" | "directory";
96
+ path: string;
97
97
  lastModified?: number | null | undefined;
98
98
  }, {
99
- path: string;
100
99
  type: "file" | "directory";
100
+ path: string;
101
101
  lastModified?: number | null | undefined;
102
102
  }>;
103
103
  export type FileEntryType = z.infer<typeof fileEntrySchema>;
@@ -9,7 +9,7 @@ export interface AITool {
9
9
  name?: string;
10
10
  annotations?: any;
11
11
  description: string;
12
- parameters: any;
12
+ inputSchema: any;
13
13
  execute: AIToolExecutor;
14
14
  }
15
15
  /**
@@ -1,4 +1,4 @@
1
- import { FastMCP } from "fastmcp";
1
+ import type { FastMCP } from "fastmcp";
2
2
  import type { AITools } from "./schemas/schemas_tool_config.ts";
3
3
  /**
4
4
  * Setup function that optionally registers AITools with MCP server
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.8.10",
2
+ "version": "0.9.0",
3
3
  "name": "modality-kit",
4
4
  "repository": {
5
5
  "type": "git",
@@ -11,33 +11,23 @@
11
11
  "author": "Hill <hill@kimo.com>",
12
12
  "license": "ISC",
13
13
  "devDependencies": {
14
- "@happy-dom/global-registrator": "^18.0.1",
15
- "@types/browser-or-node": "^1.3.2",
16
14
  "@types/bun": "^1.2.19",
17
15
  "fastmcp": "^3.12.0",
18
16
  "typescript": "^5.8.3",
19
17
  "zod": "3.x"
20
18
  },
21
19
  "exports": {
22
- ".": {
23
- "require": "./dist/index.js",
24
- "import": "./dist/index.js",
25
- "types": "./dist/types/index.d.ts"
26
- },
27
- "./browser": {
28
- "require": "./dist/browser.js",
29
- "import": "./dist/browser.js",
30
- "types": "./dist/types/browser.d.ts"
31
- }
20
+ "require": "./dist/index.js",
21
+ "import": "./dist/index.js",
22
+ "types": "./dist/types/index.d.ts"
32
23
  },
33
24
  "scripts": {
34
25
  "update-compile-sh": "yo reshow:compile-sh",
35
26
  "build:clean": "find ./dist -name '*.*' | xargs rm -rf",
36
- "dev": "bunx concurrently 'bunx --watch tsc -p ./' 'bun build:src -- --watch --sourcemap=inline'",
37
27
  "build:types": "bunx tsc -p ./",
38
28
  "build:src": "bun build src/index.ts --outdir dist",
39
- "build:browser": "bun build src/browser.ts --outdir dist --format cjs --target browser --external @valibot/to-json-schema --external sury --external effect",
40
- "build": "bun run build:clean && bun run build:src && bun run build:browser && bun run build:types",
29
+ "build": "bun run build:clean && bun run build:src && bun run build:types",
30
+ "dev": "bunx concurrently 'bunx --watch tsc -p ./' 'bun build:src -- --watch --sourcemap=inline'",
41
31
  "test": "bun test",
42
32
  "prepublishOnly": "npm run build && npm run test"
43
33
  },
package/dist/browser.js DELETED
@@ -1,263 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __moduleCache = /* @__PURE__ */ new WeakMap;
6
- var __toCommonJS = (from) => {
7
- var entry = __moduleCache.get(from), desc;
8
- if (entry)
9
- return entry;
10
- entry = __defProp({}, "__esModule", { value: true });
11
- if (from && typeof from === "object" || typeof from === "function")
12
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- }));
16
- __moduleCache.set(from, entry);
17
- return entry;
18
- };
19
- var __export = (target, all) => {
20
- for (var name in all)
21
- __defProp(target, name, {
22
- get: all[name],
23
- enumerable: true,
24
- configurable: true,
25
- set: (newValue) => all[name] = () => newValue
26
- });
27
- };
28
-
29
- // src/browser.ts
30
- var exports_browser = {};
31
- __export(exports_browser, {
32
- render: () => render,
33
- registerStore: () => registerStore,
34
- ReactiveComponent: () => ReactiveComponent
35
- });
36
- module.exports = __toCommonJS(exports_browser);
37
-
38
- // src/ReactiveComponent.ts
39
- class ReactiveComponent extends HTMLElement {
40
- #state;
41
- #isRendering = false;
42
- #pendingUpdate = false;
43
- #hasRendered = false;
44
- #shadow;
45
- #options;
46
- #delegatedEventListeners = {};
47
- #eventTypes = [
48
- "click",
49
- "dblclick",
50
- "mousedown",
51
- "mouseup",
52
- "mousemove",
53
- "mouseover",
54
- "mouseout",
55
- "focus",
56
- "blur",
57
- "change",
58
- "input",
59
- "submit",
60
- "keydown",
61
- "keyup",
62
- "keypress"
63
- ];
64
- _stores;
65
- _storeListeners;
66
- constructor(options = {}) {
67
- super();
68
- this.#options = options;
69
- this.#state = options.initialState || {};
70
- }
71
- get state() {
72
- return Object.freeze({ ...this.#state });
73
- }
74
- setState(updator, _action, prevState) {
75
- const oldState = prevState || { ...this.#state };
76
- let newUpdates;
77
- if (typeof updator === "function") {
78
- newUpdates = updator(this.#state);
79
- } else {
80
- newUpdates = updator;
81
- }
82
- const newState = { ...this.#state, ...newUpdates };
83
- if (this.#options.shouldUpdate && !this.#options.shouldUpdate(newState, oldState)) {
84
- return this.#state;
85
- } else {
86
- this.#state = newState;
87
- this.#scheduleUpdate(oldState);
88
- return newState;
89
- }
90
- }
91
- forceUpdate() {
92
- this.#scheduleUpdate({ ...this.#state });
93
- }
94
- #scheduleUpdate(previousState) {
95
- if (this.#isRendering || this.#pendingUpdate) {
96
- return;
97
- }
98
- this.#pendingUpdate = true;
99
- queueMicrotask(() => {
100
- if (this.#pendingUpdate && this.isConnected) {
101
- this.#performUpdate(previousState);
102
- }
103
- });
104
- }
105
- #performUpdate(previousState) {
106
- this.#isRendering = true;
107
- this.#pendingUpdate = false;
108
- const wasFirstRender = !this.#hasRendered;
109
- const prevState = previousState || { ...this.#state };
110
- try {
111
- this.#updateDOM();
112
- this.#hasRendered = true;
113
- if (!wasFirstRender && typeof this.componentDidUpdate === "function") {
114
- this.componentDidUpdate(this.#state, prevState);
115
- }
116
- } catch (error) {
117
- console.error("Error during component update:", error);
118
- } finally {
119
- this.#isRendering = false;
120
- }
121
- }
122
- static #trustedTypesPolicy = (() => {
123
- if (typeof window !== "undefined" && window.trustedTypes && window.trustedTypes.createPolicy) {
124
- try {
125
- return window.trustedTypes.createPolicy("reactive-component", {
126
- createHTML: (string) => string
127
- });
128
- } catch (e) {
129
- console.warn("Failed to create trusted types policy:", e);
130
- return null;
131
- }
132
- }
133
- return null;
134
- })();
135
- #safeSetInnerHTML(element, html) {
136
- if (ReactiveComponent.#trustedTypesPolicy) {
137
- element.innerHTML = ReactiveComponent.#trustedTypesPolicy.createHTML(html);
138
- } else {
139
- element.innerHTML = html;
140
- }
141
- }
142
- #updateDOM() {
143
- if (!this.#shadow) {
144
- this.#shadow = this.shadowRoot || this.attachShadow({ mode: "open" });
145
- this.#setupEventDelegation();
146
- }
147
- if (typeof window !== "undefined" && window.trustedTypes && window.trustedTypes.emptyHTML) {
148
- this.#shadow.innerHTML = window.trustedTypes.emptyHTML;
149
- } else {
150
- while (this.#shadow.firstChild) {
151
- this.#shadow.removeChild(this.#shadow.firstChild);
152
- }
153
- }
154
- const renderResult = this.render();
155
- if (typeof renderResult === "string") {
156
- const template = document.createElement("template");
157
- this.#safeSetInnerHTML(template, renderResult);
158
- this.#shadow.appendChild(template.content.cloneNode(true));
159
- } else if (renderResult instanceof DocumentFragment || renderResult instanceof Element) {
160
- this.#shadow.appendChild(renderResult);
161
- }
162
- }
163
- #setupEventDelegation() {
164
- this.#eventTypes.forEach((eventType) => {
165
- const listener = (e) => {
166
- this.#handleDelegatedEvent(e);
167
- };
168
- this.#delegatedEventListeners[eventType] = listener;
169
- const usePassive = !["mousedown", "keydown", "submit"].includes(eventType);
170
- this.#shadow.addEventListener(eventType, listener, {
171
- passive: usePassive
172
- });
173
- });
174
- }
175
- #handleDelegatedEvent(e) {
176
- const eventType = e.type;
177
- const target = e.target;
178
- if (!target)
179
- return;
180
- const handlerAttribute = `data-${eventType}`;
181
- const elementsWithHandlers = this.#shadow.querySelectorAll(`[${handlerAttribute}]`);
182
- Array.from(elementsWithHandlers).forEach((element) => {
183
- if (target.isSameNode(element) || element.contains(target)) {
184
- const handlerName = element.getAttribute(handlerAttribute);
185
- if (handlerName && typeof this[handlerName] === "function") {
186
- this[handlerName](e);
187
- }
188
- }
189
- });
190
- }
191
- connectedCallback() {
192
- if (this._stores && this._stores.length > 0) {
193
- this._storeListeners = [];
194
- this._stores.forEach((store) => {
195
- const boundSetState = this.setState.bind(this);
196
- store.addListener(boundSetState);
197
- this._storeListeners.push({ store, listener: boundSetState });
198
- const initialState = store.getState();
199
- this.setState(initialState);
200
- });
201
- }
202
- this.#performUpdate();
203
- if (typeof this.componentDidMount === "function") {
204
- this.componentDidMount();
205
- }
206
- }
207
- disconnectedCallback() {
208
- if (this.#shadow && Object.keys(this.#delegatedEventListeners).length > 0) {
209
- this.#eventTypes.forEach((eventType) => {
210
- const listener = this.#delegatedEventListeners[eventType];
211
- if (listener) {
212
- this.#shadow.removeEventListener(eventType, listener);
213
- }
214
- });
215
- this.#delegatedEventListeners = {};
216
- }
217
- if (this._storeListeners && this._storeListeners.length > 0) {
218
- this._storeListeners.forEach(({ store, listener }) => {
219
- store.removeListener(listener);
220
- });
221
- this._storeListeners = [];
222
- }
223
- }
224
- }
225
- function render(componentName, props = {}, stores) {
226
- const element = document.createElement(componentName);
227
- const { appendTo = document.body, ...restProps } = props;
228
- Object.keys(restProps).forEach((key) => {
229
- const value = restProps[key];
230
- if (value != null) {
231
- const stringValue = typeof value === "object" ? JSON.stringify(value) : String(value);
232
- element.setAttribute(key, stringValue);
233
- }
234
- });
235
- if (stores && stores.length > 0) {
236
- element._stores = stores;
237
- }
238
- if (appendTo instanceof HTMLElement) {
239
- appendTo.appendChild(element);
240
- }
241
- return element;
242
- }
243
- var lazyStores = { current: {} };
244
- function registerStore(componentName, stores) {
245
- const connectionSectionElement = document.querySelector("connection-section");
246
- if (connectionSectionElement) {
247
- connectionSectionElement._stores = stores;
248
- } else {
249
- lazyStores.current[componentName] = stores;
250
- }
251
- }
252
- if (typeof document !== "undefined") {
253
- document.addEventListener("DOMContentLoaded", () => {
254
- const promise = Object.keys(lazyStores.current).map(async (componentName) => {
255
- const connectionSectionElement = document.querySelector(componentName);
256
- if (connectionSectionElement) {
257
- connectionSectionElement._stores = lazyStores.current[componentName];
258
- delete lazyStores.current[componentName];
259
- }
260
- });
261
- Promise.all(promise);
262
- });
263
- }
@@ -1,64 +0,0 @@
1
- /**
2
- * ReactiveComponent - Base class for React-like Web Components
3
- * Adds state management and automatic re-rendering capabilities
4
- */
5
- interface ReactiveComponentOptions<T> {
6
- initialState?: T;
7
- shouldUpdate?: (newState: T, oldState: T) => boolean;
8
- }
9
- type StateCallbackHandler<TState> = (prevState: TState) => Partial<TState>;
10
- type StateType<TState> = Partial<TState> | StateCallbackHandler<TState> | TState;
11
- /**
12
- * Base class for reactive web components
13
- */
14
- export declare abstract class ReactiveComponent<TState = any> extends HTMLElement {
15
- #private;
16
- _stores?: Array<any>;
17
- _storeListeners?: Array<{
18
- store: any;
19
- listener: Function;
20
- }>;
21
- constructor(options?: ReactiveComponentOptions<TState>);
22
- /**
23
- * Get current state (immutable)
24
- */
25
- get state(): Readonly<TState>;
26
- /**
27
- * Update state and trigger re-render (React-like setState)
28
- * Also compatible with reshow-flux-base listener: setState(state, action, prevState)
29
- */
30
- setState(updator: StateType<TState>, _action?: any, prevState?: TState): TState;
31
- /**
32
- * Force a re-render without state change
33
- */
34
- forceUpdate(): void;
35
- /**
36
- * Lifecycle method - called when component is connected
37
- */
38
- connectedCallback(): void;
39
- /**
40
- * Lifecycle method - called when component is disconnected
41
- */
42
- disconnectedCallback(): void;
43
- /**
44
- * Optional lifecycle method - called after component updates
45
- * Override this method to perform side effects after the component updates
46
- */
47
- componentDidUpdate?(newState: TState, previousState: TState): void;
48
- /**
49
- * Optional lifecycle method - called after component is mounted (first render)
50
- * Override this method to perform setup logic after the component is added to DOM
51
- */
52
- componentDidMount?(): void;
53
- /**
54
- * Abstract render method - must be implemented by subclasses
55
- */
56
- abstract render(): string | DocumentFragment | Element;
57
- }
58
- export type { ReactiveComponentOptions };
59
- /**
60
- * Generic render function for ReactiveHTMLElement components
61
- * Creates and displays a component with specified componentName and optional stores
62
- */
63
- export declare function render<T extends ReactiveComponent>(componentName: string, props?: Record<string, any>, stores?: Array<any>): T;
64
- export declare function registerStore(componentName: string, stores: Array<any>): void;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export { ReactiveComponent, render, registerStore } from "./ReactiveComponent";