@open-wa/mcp 5.0.0-alpha.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.
@@ -0,0 +1,56 @@
1
+ /**
2
+ * MCP execution error types.
3
+ *
4
+ * Maintains the separation between protocol-level errors
5
+ * (JSON-RPC envelope issues) and tool-level errors
6
+ * (open-wa runtime invocation failures).
7
+ */
8
+
9
+ /**
10
+ * A tool execution error from the open-wa runtime.
11
+ * This should be surfaced as `isError: true` in MCP tool results,
12
+ * NOT as a JSON-RPC protocol error.
13
+ */
14
+ export class ToolExecutionError extends Error {
15
+ public readonly statusCode: number;
16
+ public readonly details?: unknown;
17
+
18
+ constructor(message: string, statusCode = 500, details?: unknown) {
19
+ super(message);
20
+ this.name = 'ToolExecutionError';
21
+ this.statusCode = statusCode;
22
+ this.details = details;
23
+ }
24
+ }
25
+
26
+ /**
27
+ * A validation error from Zod schema parsing.
28
+ * This should be surfaced as `isError: true` in MCP tool results
29
+ * with the validation details attached.
30
+ */
31
+ export class ToolValidationError extends ToolExecutionError {
32
+ constructor(message: string, details?: unknown) {
33
+ super(message, 400, details);
34
+ this.name = 'ToolValidationError';
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Thrown when the client/session is not ready for execution.
40
+ */
41
+ export class SessionNotReadyError extends ToolExecutionError {
42
+ constructor(message = 'Session is not connected or ready for execution') {
43
+ super(message, 503);
44
+ this.name = 'SessionNotReadyError';
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Thrown when authentication is missing or invalid.
50
+ */
51
+ export class AuthenticationError extends ToolExecutionError {
52
+ constructor(message = 'Authentication required. Provide a valid API key.') {
53
+ super(message, 401);
54
+ this.name = 'AuthenticationError';
55
+ }
56
+ }
@@ -0,0 +1,32 @@
1
+ export interface ClientMethodDefinitionLike {
2
+ functionName: string;
3
+ parameterOrder: string[];
4
+ wapiOverride?: string;
5
+ }
6
+
7
+ /**
8
+ * Invokes a client method by resolving its implementation from the client instance
9
+ * and mapping the payload to positional arguments if necessary.
10
+ */
11
+ export async function invokeClientMethod(
12
+ client: Record<string, (...args: any[]) => Promise<any> | any> | undefined,
13
+ def: ClientMethodDefinitionLike,
14
+ payload: unknown
15
+ ): Promise<any> {
16
+ if (!client) {
17
+ throw new Error('Client not initialized');
18
+ }
19
+
20
+ const method = client[def.functionName] ?? (def.wapiOverride ? client[def.wapiOverride] : undefined);
21
+
22
+ if (typeof method !== 'function') {
23
+ throw new Error(`Method ${def.functionName} not implemented on Client`);
24
+ }
25
+
26
+ if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
27
+ return await method.call(client);
28
+ }
29
+
30
+ const resolvedArgs = def.parameterOrder.map((key) => (payload as Record<string, unknown>)[key]);
31
+ return await method.call(client, ...resolvedArgs);
32
+ }
@@ -0,0 +1,104 @@
1
+ import type { HttpMethodDefinition } from '@open-wa/schema';
2
+ import { normalizeMethodPayload } from './args';
3
+ import { invokeClientMethod } from './invoke';
4
+
5
+ /**
6
+ * Context required to execute an Open-WA capability via any transport.
7
+ */
8
+ export interface ExecutionContext {
9
+ /**
10
+ * The active client instance or proxy.
11
+ */
12
+ client: Record<string, (...args: any[]) => Promise<any> | any> | undefined;
13
+ /**
14
+ * The metadata definition for the method being invoked.
15
+ */
16
+ definition: HttpMethodDefinition;
17
+ /**
18
+ * The raw input payload (merged query + body, or MCP arguments).
19
+ */
20
+ payload: Record<string, unknown>;
21
+ /**
22
+ * Optional diagnostic emitter for logging.
23
+ */
24
+ elasticEmitter?: {
25
+ log: (data: any) => void;
26
+ };
27
+ /**
28
+ * The unique session identifier.
29
+ */
30
+ sessionId: string;
31
+ }
32
+
33
+ /**
34
+ * Standardized result of a capability execution.
35
+ */
36
+ export interface ExecutionResult<T = any> {
37
+ success: boolean;
38
+ data?: T;
39
+ error?: string;
40
+ details?: any;
41
+ status: number;
42
+ }
43
+
44
+ /**
45
+ * The shared execution kernel for Open-WA capabilities.
46
+ * Ensures strict parity between HTTP API and MCP transport by centralizing
47
+ * normalization, validation, and invocation logic.
48
+ */
49
+ export async function executeCapability(
50
+ ctx: ExecutionContext
51
+ ): Promise<ExecutionResult> {
52
+ const { client, definition, payload, elasticEmitter, sessionId } = ctx;
53
+ const startTime = Date.now();
54
+ const methodName = definition.functionName;
55
+
56
+ try {
57
+ // 1. Normalize aliases and legacy keys
58
+ const normalizedPayload = normalizeMethodPayload(definition, payload);
59
+
60
+ // 2. Validate against Zod schema (strict)
61
+ const validated = await definition.inputSchema.parseAsync(normalizedPayload);
62
+
63
+ // 3. Invoke the client method with positional argument resolution
64
+ const result = await invokeClientMethod(client, definition, validated);
65
+
66
+ // 4. Log successful execution to monitoring if available
67
+ elasticEmitter?.log({
68
+ level: 'info',
69
+ component: 'api',
70
+ method: methodName,
71
+ sessionId,
72
+ duration: Date.now() - startTime,
73
+ statusCode: 200,
74
+ message: `Successfully executed ${methodName}`,
75
+ });
76
+
77
+ return {
78
+ success: true,
79
+ data: result,
80
+ status: 200,
81
+ };
82
+ } catch (error: any) {
83
+ const isValidationError = error?.name === 'ZodError';
84
+ const status = isValidationError ? 400 : 500;
85
+
86
+ // Log failure to monitoring
87
+ elasticEmitter?.log({
88
+ level: 'error',
89
+ component: 'api',
90
+ method: methodName,
91
+ sessionId,
92
+ duration: Date.now() - startTime,
93
+ statusCode: status,
94
+ message: error?.message || 'Internal Server Error',
95
+ });
96
+
97
+ return {
98
+ success: false,
99
+ error: isValidationError ? 'Validation Error' : (error?.message || 'Internal Server Error'),
100
+ details: isValidationError ? error.issues : undefined,
101
+ status,
102
+ };
103
+ }
104
+ }
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './manifest';
2
+ export * from './tool-naming';
3
+ export * from './execution/kernel';
4
+ export * from './execution/args';
5
+ export * from './execution/invoke';
6
+ export * from './execution/errors';
7
+ export * from './adapter/hono-mcp';
@@ -0,0 +1,91 @@
1
+ import { getHttpMethodDefinitions, type HttpMethodDefinition } from '@open-wa/schema/http-manifest';
2
+ import { getCanonicalToolName } from './tool-naming';
3
+
4
+ /**
5
+ * MCP-specific projection of a method capability.
6
+ */
7
+ export interface McpToolDefinition {
8
+ /**
9
+ * The canonical namespaced tool name for MCP.
10
+ * @example 'messages.sendText'
11
+ */
12
+ toolName: string;
13
+ /**
14
+ * The raw function name in the client.
15
+ * @example 'sendText'
16
+ */
17
+ functionName: string;
18
+ /**
19
+ * The namespaced name (method part only).
20
+ * @example 'sendText'
21
+ */
22
+ namespacedName: string;
23
+ /**
24
+ * The namespace this method belongs to.
25
+ * @example 'messages'
26
+ */
27
+ namespace: string;
28
+ /**
29
+ * Human-readable description of the tool.
30
+ */
31
+ description: string;
32
+ /**
33
+ * Zod input schema.
34
+ */
35
+ inputSchema: HttpMethodDefinition['inputSchema'];
36
+ /**
37
+ * Zod output schema.
38
+ */
39
+ outputSchema: HttpMethodDefinition['outputSchema'];
40
+ /**
41
+ * Preserved parameter order for positional resolution.
42
+ */
43
+ parameterOrder: string[];
44
+ /**
45
+ * Known aliases for this method.
46
+ */
47
+ aliases: string[];
48
+ /**
49
+ * Deprecated aliases for this method.
50
+ */
51
+ deprecatedAliases: string[];
52
+ /**
53
+ * Map of payload key aliases to canonical keys.
54
+ */
55
+ keyAliasMap: Record<string, string>;
56
+ /**
57
+ * Optional metadata hints for AI clients.
58
+ */
59
+ annotations?: {
60
+ title?: string;
61
+ readOnlyHint?: boolean;
62
+ destructiveHint?: boolean;
63
+ idempotentHint?: boolean;
64
+ };
65
+ }
66
+
67
+ /**
68
+ * Projects the schema registry into a list of canonical MCP tool definitions.
69
+ */
70
+ export function getMcpToolDefinitions(basePath = '/api'): McpToolDefinition[] {
71
+ return getHttpMethodDefinitions(basePath).map((def) => {
72
+ return {
73
+ toolName: getCanonicalToolName(def.namespace, def.namespacedName),
74
+ functionName: def.functionName,
75
+ namespacedName: def.namespacedName,
76
+ namespace: def.namespace,
77
+ description: def.description,
78
+ inputSchema: def.inputSchema,
79
+ outputSchema: def.outputSchema,
80
+ parameterOrder: def.parameterOrder,
81
+ aliases: def.aliases,
82
+ deprecatedAliases: def.deprecatedAliases,
83
+ keyAliasMap: def.keyAliasMap,
84
+ annotations: {
85
+ title: def.functionName,
86
+ // Hints can be derived from method names or hardcoded metadata in future
87
+ readOnlyHint: def.functionName.startsWith('get') || def.functionName.startsWith('is'),
88
+ },
89
+ };
90
+ });
91
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Logic for stable, namespaced MCP tool names.
3
+ */
4
+
5
+ /**
6
+ * Returns the canonical namespaced tool name for MCP.
7
+ * @example getCanonicalToolName('messages', 'sendText') -> 'messages.sendText'
8
+ */
9
+ export function getCanonicalToolName(namespace: string, methodName: string): string {
10
+ return `${namespace}.${methodName}`;
11
+ }
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Tests for MCP adapter: auth enforcement, readiness gating, and transport shape.
3
+ *
4
+ * These tests verify the adapter at the Hono layer by creating a real
5
+ * Hono app, mounting the adapter, and making requests via app.request().
6
+ */
7
+ import { describe, it, expect, vi, beforeAll } from 'vitest';
8
+ import { Hono } from 'hono';
9
+ import { createHonoMcpAdapter } from '../src/adapter/hono-mcp';
10
+ import type { Config } from '@open-wa/schema';
11
+
12
+ function createTestConfig(overrides: Partial<Config> = {}): Config {
13
+ return {
14
+ sessionId: 'test-session',
15
+ apiKey: 'test-api-key-123',
16
+ mcp: { enabled: true, path: '/mcp', exposeToolsMeta: true },
17
+ ...overrides,
18
+ } as Config;
19
+ }
20
+
21
+ describe('createHonoMcpAdapter', () => {
22
+ describe('API-key auth enforcement', () => {
23
+ it('should reject requests without API key', async () => {
24
+ const config = createTestConfig();
25
+ const app = new Hono();
26
+ const adapter = createHonoMcpAdapter({
27
+ config,
28
+ clientSource: () => ({}),
29
+ });
30
+ adapter.mount(app, '/mcp');
31
+
32
+ const res = await app.request('/mcp', {
33
+ method: 'POST',
34
+ headers: { 'Content-Type': 'application/json' },
35
+ body: JSON.stringify({ jsonrpc: '2.0', method: 'initialize', id: 1 }),
36
+ });
37
+
38
+ expect(res.status).toBe(401);
39
+ const body = await res.json();
40
+ expect(body.error).toBe('Unauthorized');
41
+ });
42
+
43
+ it('should reject requests with wrong API key', async () => {
44
+ const config = createTestConfig();
45
+ const app = new Hono();
46
+ const adapter = createHonoMcpAdapter({
47
+ config,
48
+ clientSource: () => ({}),
49
+ });
50
+ adapter.mount(app, '/mcp');
51
+
52
+ const res = await app.request('/mcp', {
53
+ method: 'POST',
54
+ headers: {
55
+ 'Content-Type': 'application/json',
56
+ 'X-API-Key': 'wrong-key',
57
+ },
58
+ body: JSON.stringify({ jsonrpc: '2.0', method: 'initialize', id: 1 }),
59
+ });
60
+
61
+ expect(res.status).toBe(401);
62
+ });
63
+
64
+ it('should accept requests with correct API key via header', async () => {
65
+ const config = createTestConfig();
66
+ const app = new Hono();
67
+ const adapter = createHonoMcpAdapter({
68
+ config,
69
+ clientSource: () => ({}),
70
+ });
71
+ adapter.mount(app, '/mcp');
72
+
73
+ const res = await app.request('/mcp', {
74
+ method: 'POST',
75
+ headers: {
76
+ 'Content-Type': 'application/json',
77
+ 'X-API-Key': 'test-api-key-123',
78
+ },
79
+ body: JSON.stringify({
80
+ jsonrpc: '2.0',
81
+ method: 'initialize',
82
+ id: 1,
83
+ params: {
84
+ protocolVersion: '2025-03-26',
85
+ capabilities: {},
86
+ clientInfo: { name: 'test', version: '1.0' },
87
+ },
88
+ }),
89
+ });
90
+
91
+ // Should not be 401 — transport takes over
92
+ expect(res.status).not.toBe(401);
93
+ });
94
+
95
+ });
96
+
97
+ describe('Streamable HTTP transport shape', () => {
98
+ it('should handle POST requests (JSON-RPC messages)', async () => {
99
+ const config = createTestConfig();
100
+ const app = new Hono();
101
+ const adapter = createHonoMcpAdapter({
102
+ config,
103
+ clientSource: () => ({}),
104
+ });
105
+ adapter.mount(app, '/mcp');
106
+
107
+ const res = await app.request('/mcp', {
108
+ method: 'POST',
109
+ headers: {
110
+ 'Content-Type': 'application/json',
111
+ 'X-API-Key': 'test-api-key-123',
112
+ },
113
+ body: JSON.stringify({
114
+ jsonrpc: '2.0',
115
+ method: 'initialize',
116
+ id: 1,
117
+ params: {
118
+ protocolVersion: '2025-03-26',
119
+ capabilities: {},
120
+ clientInfo: { name: 'test', version: '1.0' },
121
+ },
122
+ }),
123
+ });
124
+
125
+ // MCP initialization should respond (not a 404 or 405)
126
+ expect(res.status).not.toBe(404);
127
+ expect(res.status).not.toBe(405);
128
+ });
129
+
130
+ it('should handle DELETE requests (session termination)', async () => {
131
+ const config = createTestConfig();
132
+ const app = new Hono();
133
+ const adapter = createHonoMcpAdapter({
134
+ config,
135
+ clientSource: () => ({}),
136
+ });
137
+ adapter.mount(app, '/mcp');
138
+
139
+ const res = await app.request('/mcp', {
140
+ method: 'DELETE',
141
+ headers: {
142
+ 'X-API-Key': 'test-api-key-123',
143
+ },
144
+ });
145
+
146
+ // Should be handled by transport, not 404
147
+ expect(res.status).not.toBe(404);
148
+ });
149
+ });
150
+
151
+ describe('lifecycle/readiness gating', () => {
152
+ it('should block tool calls when session is not connected', async () => {
153
+ const config = createTestConfig();
154
+ const app = new Hono();
155
+ const adapter = createHonoMcpAdapter({
156
+ config,
157
+ clientSource: () => ({}),
158
+ isSessionConnected: () => false,
159
+ });
160
+ adapter.mount(app, '/mcp');
161
+
162
+ // Note: We can't easily test tools/call through the full MCP protocol
163
+ // in a unit test because it requires session initialization first.
164
+ // The readiness check is verified structurally in the adapter code.
165
+ // Integration tests would cover the full flow.
166
+ expect(adapter).toBeDefined();
167
+ });
168
+
169
+ it('should allow tool calls when apiLifecycle is immediate regardless of readiness', () => {
170
+ const config = createTestConfig({ apiLifecycle: 'immediate' } as any);
171
+ const adapter = createHonoMcpAdapter({
172
+ config,
173
+ clientSource: () => ({}),
174
+ isSessionConnected: () => false,
175
+ });
176
+
177
+ // Adapter should be created successfully with immediate lifecycle
178
+ expect(adapter).toBeDefined();
179
+ });
180
+ });
181
+ });
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Tests for the shared execution kernel.
3
+ *
4
+ * These tests verify that executeCapability produces identical
5
+ * normalization, validation, and error shaping as the HTTP path.
6
+ */
7
+ import { describe, it, expect, vi } from 'vitest';
8
+ import { executeCapability, type ExecutionContext } from '../src/execution/kernel';
9
+ import { z } from 'zod';
10
+ import type { HttpMethodDefinition } from '@open-wa/schema';
11
+
12
+ /**
13
+ * Helper to create a minimal HttpMethodDefinition-like object for testing.
14
+ */
15
+ function createMockDefinition(overrides: Partial<HttpMethodDefinition> = {}): HttpMethodDefinition {
16
+ return {
17
+ functionName: 'sendText',
18
+ namespacedName: 'sendText',
19
+ path: '/api/messages/sendText',
20
+ namespace: 'messages',
21
+ description: 'Send a text message',
22
+ httpMethod: 'POST',
23
+ inputSchema: z.object({
24
+ to: z.string(),
25
+ content: z.string(),
26
+ }),
27
+ outputSchema: z.any(),
28
+ parameterOrder: ['to', 'content'],
29
+ aliases: [],
30
+ deprecatedAliases: [],
31
+ aliasRoutes: [],
32
+ routeSignatures: [],
33
+ invocationNames: ['sendText'],
34
+ keyAliasMap: {},
35
+ ...overrides,
36
+ };
37
+ }
38
+
39
+ describe('executeCapability', () => {
40
+ it('should return success with data when invocation succeeds', async () => {
41
+ const mockClient = {
42
+ sendText: vi.fn().mockResolvedValue({ id: 'msg-123' }),
43
+ };
44
+
45
+ const result = await executeCapability({
46
+ client: mockClient,
47
+ definition: createMockDefinition(),
48
+ payload: { to: '1234567890@c.us', content: 'Hello' },
49
+ sessionId: 'test-session',
50
+ });
51
+
52
+ expect(result.success).toBe(true);
53
+ expect(result.status).toBe(200);
54
+ expect(result.data).toEqual({ id: 'msg-123' });
55
+ expect(mockClient.sendText).toHaveBeenCalled();
56
+ });
57
+
58
+ it('should return 400 for Zod validation errors', async () => {
59
+ const mockClient = {
60
+ sendText: vi.fn(),
61
+ };
62
+
63
+ const result = await executeCapability({
64
+ client: mockClient,
65
+ definition: createMockDefinition(),
66
+ payload: { to: 123, content: null } as any, // invalid types
67
+ sessionId: 'test-session',
68
+ });
69
+
70
+ expect(result.success).toBe(false);
71
+ expect(result.status).toBe(400);
72
+ expect(result.error).toBe('Validation Error');
73
+ expect(result.details).toBeDefined();
74
+ expect(mockClient.sendText).not.toHaveBeenCalled();
75
+ });
76
+
77
+ it('should return 500 for client runtime errors', async () => {
78
+ const mockClient = {
79
+ sendText: vi.fn().mockRejectedValue(new Error('WhatsApp connection lost')),
80
+ };
81
+
82
+ const result = await executeCapability({
83
+ client: mockClient,
84
+ definition: createMockDefinition(),
85
+ payload: { to: '1234567890@c.us', content: 'Hello' },
86
+ sessionId: 'test-session',
87
+ });
88
+
89
+ expect(result.success).toBe(false);
90
+ expect(result.status).toBe(500);
91
+ expect(result.error).toBe('WhatsApp connection lost');
92
+ });
93
+
94
+ it('should log success to elasticEmitter when provided', async () => {
95
+ const mockEmitter = { log: vi.fn() };
96
+ const mockClient = {
97
+ sendText: vi.fn().mockResolvedValue('ok'),
98
+ };
99
+
100
+ await executeCapability({
101
+ client: mockClient,
102
+ definition: createMockDefinition(),
103
+ payload: { to: '1234567890@c.us', content: 'Hello' },
104
+ sessionId: 'test-session',
105
+ elasticEmitter: mockEmitter,
106
+ });
107
+
108
+ expect(mockEmitter.log).toHaveBeenCalledWith(
109
+ expect.objectContaining({
110
+ level: 'info',
111
+ method: 'sendText',
112
+ statusCode: 200,
113
+ }),
114
+ );
115
+ });
116
+
117
+ it('should log errors to elasticEmitter when provided', async () => {
118
+ const mockEmitter = { log: vi.fn() };
119
+ const mockClient = {
120
+ sendText: vi.fn().mockRejectedValue(new Error('fail')),
121
+ };
122
+
123
+ await executeCapability({
124
+ client: mockClient,
125
+ definition: createMockDefinition(),
126
+ payload: { to: '1234567890@c.us', content: 'Hello' },
127
+ sessionId: 'test-session',
128
+ elasticEmitter: mockEmitter,
129
+ });
130
+
131
+ expect(mockEmitter.log).toHaveBeenCalledWith(
132
+ expect.objectContaining({
133
+ level: 'error',
134
+ method: 'sendText',
135
+ statusCode: 500,
136
+ }),
137
+ );
138
+ });
139
+
140
+ it('should handle undefined client gracefully', async () => {
141
+ const result = await executeCapability({
142
+ client: undefined,
143
+ definition: createMockDefinition(),
144
+ payload: { to: '1234567890@c.us', content: 'Hello' },
145
+ sessionId: 'test-session',
146
+ });
147
+
148
+ expect(result.success).toBe(false);
149
+ expect(result.status).toBe(500);
150
+ });
151
+ });
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Tests for MCP manifest generation from schema registry.
3
+ */
4
+ import { describe, it, expect } from 'vitest';
5
+ import { getMcpToolDefinitions, type McpToolDefinition } from '../src/manifest';
6
+ import { getCanonicalToolName } from '../src/tool-naming';
7
+
8
+ describe('getMcpToolDefinitions', () => {
9
+ let tools: McpToolDefinition[];
10
+
11
+ // We import @open-wa/schema/methods to populate the registry
12
+ beforeAll(async () => {
13
+ await import('@open-wa/schema/methods');
14
+ tools = getMcpToolDefinitions();
15
+ });
16
+
17
+ it('should return a non-empty array of tool definitions', () => {
18
+ expect(tools).toBeInstanceOf(Array);
19
+ expect(tools.length).toBeGreaterThan(0);
20
+ });
21
+
22
+ it('should produce one tool per method (no duplicates)', () => {
23
+ const names = tools.map((t) => t.toolName);
24
+ const unique = new Set(names);
25
+ expect(unique.size).toBe(names.length);
26
+ });
27
+
28
+ it('every tool should have a namespace.method toolName shape', () => {
29
+ for (const tool of tools) {
30
+ expect(tool.toolName).toMatch(/^[a-zA-Z]+\.[a-zA-Z]+/);
31
+ expect(tool.toolName).toBe(getCanonicalToolName(tool.namespace, tool.namespacedName));
32
+ }
33
+ });
34
+
35
+ it('every tool should have a valid Zod inputSchema', () => {
36
+ for (const tool of tools) {
37
+ expect(tool.inputSchema).toBeDefined();
38
+ expect(typeof tool.inputSchema.parse).toBe('function');
39
+ }
40
+ });
41
+
42
+ it('every tool should carry parameterOrder and keyAliasMap', () => {
43
+ for (const tool of tools) {
44
+ expect(tool.parameterOrder).toBeInstanceOf(Array);
45
+ expect(tool.keyAliasMap).toBeDefined();
46
+ expect(typeof tool.keyAliasMap).toBe('object');
47
+ }
48
+ });
49
+
50
+ it('should include annotations with readOnlyHint for getters', () => {
51
+ const getters = tools.filter((t) => t.functionName.startsWith('get') || t.functionName.startsWith('is'));
52
+ for (const getter of getters) {
53
+ expect(getter.annotations?.readOnlyHint).toBe(true);
54
+ }
55
+
56
+ const mutators = tools.filter((t) => t.functionName.startsWith('send'));
57
+ for (const mutator of mutators) {
58
+ expect(mutator.annotations?.readOnlyHint).toBeFalsy();
59
+ }
60
+ });
61
+ });