@wilnertech/halopsa-mcp-server 1.0.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/.env.example +19 -0
- package/LICENSE +21 -0
- package/README.md +270 -0
- package/dist/api/client.d.ts +85 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +297 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/errors.d.ts +60 -0
- package/dist/api/errors.d.ts.map +1 -0
- package/dist/api/errors.js +188 -0
- package/dist/api/errors.js.map +1 -0
- package/dist/cache/memory-cache.d.ts +89 -0
- package/dist/cache/memory-cache.d.ts.map +1 -0
- package/dist/cache/memory-cache.js +175 -0
- package/dist/cache/memory-cache.js.map +1 -0
- package/dist/cache/prewarm.d.ts +12 -0
- package/dist/cache/prewarm.d.ts.map +1 -0
- package/dist/cache/prewarm.js +55 -0
- package/dist/cache/prewarm.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +141 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/common.d.ts +212 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/common.js +127 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/tools/assets.d.ts +482 -0
- package/dist/tools/assets.d.ts.map +1 -0
- package/dist/tools/assets.js +732 -0
- package/dist/tools/assets.js.map +1 -0
- package/dist/tools/batch-operations.d.ts +125 -0
- package/dist/tools/batch-operations.d.ts.map +1 -0
- package/dist/tools/batch-operations.js +207 -0
- package/dist/tools/batch-operations.js.map +1 -0
- package/dist/tools/clients.d.ts +145 -0
- package/dist/tools/clients.d.ts.map +1 -0
- package/dist/tools/clients.js +148 -0
- package/dist/tools/clients.js.map +1 -0
- package/dist/tools/reference-data.d.ts +118 -0
- package/dist/tools/reference-data.d.ts.map +1 -0
- package/dist/tools/reference-data.js +103 -0
- package/dist/tools/reference-data.js.map +1 -0
- package/dist/tools/registrations.d.ts +7 -0
- package/dist/tools/registrations.d.ts.map +1 -0
- package/dist/tools/registrations.js +61 -0
- package/dist/tools/registrations.js.map +1 -0
- package/dist/tools/registry.d.ts +67 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +71 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/sites.d.ts +188 -0
- package/dist/tools/sites.d.ts.map +1 -0
- package/dist/tools/sites.js +258 -0
- package/dist/tools/sites.js.map +1 -0
- package/dist/tools/users.d.ts +317 -0
- package/dist/tools/users.d.ts.map +1 -0
- package/dist/tools/users.js +489 -0
- package/dist/tools/users.js.map +1 -0
- package/dist/types/halopsa.d.ts +212 -0
- package/dist/types/halopsa.d.ts.map +1 -0
- package/dist/types/halopsa.js +8 -0
- package/dist/types/halopsa.js.map +1 -0
- package/dist/utils/formatter.d.ts +18 -0
- package/dist/utils/formatter.d.ts.map +1 -0
- package/dist/utils/formatter.js +178 -0
- package/dist/utils/formatter.js.map +1 -0
- package/dist/utils/similarity.d.ts +25 -0
- package/dist/utils/similarity.d.ts.map +1 -0
- package/dist/utils/similarity.js +90 -0
- package/dist/utils/similarity.js.map +1 -0
- package/dist/utils/zod-to-schema.d.ts +29 -0
- package/dist/utils/zod-to-schema.d.ts.map +1 -0
- package/dist/utils/zod-to-schema.js +182 -0
- package/dist/utils/zod-to-schema.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HaloPSA Client (Top-Level Organization) tools with token optimization
|
|
3
|
+
* Provides read operations for clients with caching
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { formatResponse } from '../utils/formatter.js';
|
|
7
|
+
import { TTL } from '../cache/memory-cache.js';
|
|
8
|
+
import { FormatOptionsSchema } from '../schemas/common.js';
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Zod Schemas for Input Validation
|
|
11
|
+
// =============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* List clients schema
|
|
14
|
+
*/
|
|
15
|
+
export const ListClientsArgsSchema = z.object({
|
|
16
|
+
search: z.string().optional()
|
|
17
|
+
.describe('Search term'),
|
|
18
|
+
toplevel_id: z.number().int().optional()
|
|
19
|
+
.describe('Filter by top-level client ID'),
|
|
20
|
+
count: z.number().int().min(1).max(100).optional()
|
|
21
|
+
.describe('Number of results per page (max 100, default 50)'),
|
|
22
|
+
page_no: z.number().int().min(1).optional()
|
|
23
|
+
.describe('Page number (1-indexed, default 1)'),
|
|
24
|
+
includeactive: z.boolean().optional()
|
|
25
|
+
.describe('Include active clients (default true)'),
|
|
26
|
+
includeinactive: z.boolean().optional()
|
|
27
|
+
.describe('Include inactive clients (default false)'),
|
|
28
|
+
format_options: FormatOptionsSchema,
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Get single client schema
|
|
32
|
+
*/
|
|
33
|
+
export const GetClientArgsSchema = z.object({
|
|
34
|
+
client_id: z.number().int()
|
|
35
|
+
.describe('HaloPSA client ID'),
|
|
36
|
+
format_options: FormatOptionsSchema,
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Search clients by name schema
|
|
40
|
+
*/
|
|
41
|
+
export const SearchClientsArgsSchema = z.object({
|
|
42
|
+
name: z.string().min(1)
|
|
43
|
+
.describe('Client name to search for'),
|
|
44
|
+
includeactive: z.boolean().optional()
|
|
45
|
+
.describe('Include active clients (default true)'),
|
|
46
|
+
includeinactive: z.boolean().optional()
|
|
47
|
+
.describe('Include inactive clients (default false)'),
|
|
48
|
+
format_options: FormatOptionsSchema,
|
|
49
|
+
});
|
|
50
|
+
// =============================================================================
|
|
51
|
+
// Tool Implementations
|
|
52
|
+
// =============================================================================
|
|
53
|
+
/**
|
|
54
|
+
* List clients with optional filtering and token optimization
|
|
55
|
+
* Uses 5-minute cache TTL
|
|
56
|
+
*/
|
|
57
|
+
export async function listClients(client, args) {
|
|
58
|
+
const params = {};
|
|
59
|
+
// Build query parameters
|
|
60
|
+
if (args.search !== undefined) {
|
|
61
|
+
params.search = args.search;
|
|
62
|
+
}
|
|
63
|
+
if (args.toplevel_id !== undefined) {
|
|
64
|
+
params.toplevel_id = args.toplevel_id;
|
|
65
|
+
}
|
|
66
|
+
if (args.count !== undefined) {
|
|
67
|
+
params.count = args.count;
|
|
68
|
+
}
|
|
69
|
+
if (args.page_no !== undefined) {
|
|
70
|
+
params.page_no = args.page_no;
|
|
71
|
+
}
|
|
72
|
+
if (args.includeactive !== undefined) {
|
|
73
|
+
params.includeactive = args.includeactive;
|
|
74
|
+
}
|
|
75
|
+
if (args.includeinactive !== undefined) {
|
|
76
|
+
params.includeinactive = args.includeinactive;
|
|
77
|
+
}
|
|
78
|
+
const formatOptions = args.format_options || {};
|
|
79
|
+
const response = await client.getCached('/Client', params, {
|
|
80
|
+
enabled: true,
|
|
81
|
+
ttl: TTL.CLIENT_LIST,
|
|
82
|
+
keyPrefix: 'clients:list',
|
|
83
|
+
});
|
|
84
|
+
return formatResponse(response.clients, formatOptions, { record_count: response.record_count });
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get a single client by ID with full details
|
|
88
|
+
*/
|
|
89
|
+
export async function getClient(client, args) {
|
|
90
|
+
const formatOptions = args.format_options || {};
|
|
91
|
+
const response = await client.get(`/Client/${args.client_id}`);
|
|
92
|
+
return formatResponse(response, formatOptions);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Search clients by name
|
|
96
|
+
* Useful for finding client IDs before creating assets/users
|
|
97
|
+
*/
|
|
98
|
+
export async function searchClients(client, args) {
|
|
99
|
+
const params = {
|
|
100
|
+
search: args.name,
|
|
101
|
+
count: 100,
|
|
102
|
+
};
|
|
103
|
+
if (args.includeactive !== undefined) {
|
|
104
|
+
params.includeactive = args.includeactive;
|
|
105
|
+
}
|
|
106
|
+
if (args.includeinactive !== undefined) {
|
|
107
|
+
params.includeinactive = args.includeinactive;
|
|
108
|
+
}
|
|
109
|
+
const formatOptions = args.format_options || {};
|
|
110
|
+
// No caching for search results
|
|
111
|
+
const response = await client.get('/Client', params);
|
|
112
|
+
if (response.clients.length === 0) {
|
|
113
|
+
return JSON.stringify({
|
|
114
|
+
search_term: args.name,
|
|
115
|
+
matches: [],
|
|
116
|
+
count: 0,
|
|
117
|
+
message: 'No clients found matching search term',
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
const result = {
|
|
121
|
+
search_term: args.name,
|
|
122
|
+
matches: JSON.parse(formatResponse(response.clients, formatOptions)),
|
|
123
|
+
count: response.clients.length,
|
|
124
|
+
};
|
|
125
|
+
return JSON.stringify(result, null, 2);
|
|
126
|
+
}
|
|
127
|
+
// =============================================================================
|
|
128
|
+
// Tool Definitions (for ToolRegistry)
|
|
129
|
+
// =============================================================================
|
|
130
|
+
export const listClientsTool = {
|
|
131
|
+
name: 'list_halopsa_clients',
|
|
132
|
+
description: 'List HaloPSA clients (top-level organizations) with caching (5min TTL) and token optimization',
|
|
133
|
+
schema: ListClientsArgsSchema,
|
|
134
|
+
handler: listClients,
|
|
135
|
+
};
|
|
136
|
+
export const getClientTool = {
|
|
137
|
+
name: 'get_halopsa_client',
|
|
138
|
+
description: 'Get a single HaloPSA client by ID with full details',
|
|
139
|
+
schema: GetClientArgsSchema,
|
|
140
|
+
handler: getClient,
|
|
141
|
+
};
|
|
142
|
+
export const searchClientsTool = {
|
|
143
|
+
name: 'search_halopsa_clients',
|
|
144
|
+
description: 'Search HaloPSA clients by name. Useful for finding client IDs.',
|
|
145
|
+
schema: SearchClientsArgsSchema,
|
|
146
|
+
handler: searchClients,
|
|
147
|
+
};
|
|
148
|
+
//# sourceMappingURL=clients.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients.js","sourceRoot":"","sources":["../../src/tools/clients.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,EAAE,cAAc,EAAsB,MAAM,uBAAuB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Provides read-only access to asset types, statuses, and other reference data
|
|
4
|
+
* Uses 1-hour cache TTL (reference data rarely changes)
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import type { HaloPSAAPIClient } from '../api/client.js';
|
|
8
|
+
import type { ZodToolDefinition } from './registry.js';
|
|
9
|
+
/**
|
|
10
|
+
* List asset types schema
|
|
11
|
+
*/
|
|
12
|
+
export declare const ListAssetTypesArgsSchema: z.ZodObject<{
|
|
13
|
+
format_options: z.ZodOptional<z.ZodObject<{
|
|
14
|
+
format: z.ZodOptional<z.ZodEnum<["compact", "standard", "detailed"]>>;
|
|
15
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
16
|
+
omit_empty: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
format?: "compact" | "standard" | "detailed" | undefined;
|
|
19
|
+
fields?: string[] | undefined;
|
|
20
|
+
omit_empty?: boolean | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
format?: "compact" | "standard" | "detailed" | undefined;
|
|
23
|
+
fields?: string[] | undefined;
|
|
24
|
+
omit_empty?: boolean | undefined;
|
|
25
|
+
}>>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
format_options?: {
|
|
28
|
+
format?: "compact" | "standard" | "detailed" | undefined;
|
|
29
|
+
fields?: string[] | undefined;
|
|
30
|
+
omit_empty?: boolean | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
format_options?: {
|
|
34
|
+
format?: "compact" | "standard" | "detailed" | undefined;
|
|
35
|
+
fields?: string[] | undefined;
|
|
36
|
+
omit_empty?: boolean | undefined;
|
|
37
|
+
} | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* List asset statuses schema
|
|
41
|
+
*/
|
|
42
|
+
export declare const ListAssetStatusesArgsSchema: z.ZodObject<{
|
|
43
|
+
format_options: z.ZodOptional<z.ZodObject<{
|
|
44
|
+
format: z.ZodOptional<z.ZodEnum<["compact", "standard", "detailed"]>>;
|
|
45
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
46
|
+
omit_empty: z.ZodOptional<z.ZodBoolean>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
format?: "compact" | "standard" | "detailed" | undefined;
|
|
49
|
+
fields?: string[] | undefined;
|
|
50
|
+
omit_empty?: boolean | undefined;
|
|
51
|
+
}, {
|
|
52
|
+
format?: "compact" | "standard" | "detailed" | undefined;
|
|
53
|
+
fields?: string[] | undefined;
|
|
54
|
+
omit_empty?: boolean | undefined;
|
|
55
|
+
}>>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
format_options?: {
|
|
58
|
+
format?: "compact" | "standard" | "detailed" | undefined;
|
|
59
|
+
fields?: string[] | undefined;
|
|
60
|
+
omit_empty?: boolean | undefined;
|
|
61
|
+
} | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
format_options?: {
|
|
64
|
+
format?: "compact" | "standard" | "detailed" | undefined;
|
|
65
|
+
fields?: string[] | undefined;
|
|
66
|
+
omit_empty?: boolean | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* List contact types schema
|
|
71
|
+
*/
|
|
72
|
+
export declare const ListContactTypesArgsSchema: z.ZodObject<{
|
|
73
|
+
format_options: z.ZodOptional<z.ZodObject<{
|
|
74
|
+
format: z.ZodOptional<z.ZodEnum<["compact", "standard", "detailed"]>>;
|
|
75
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
76
|
+
omit_empty: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
format?: "compact" | "standard" | "detailed" | undefined;
|
|
79
|
+
fields?: string[] | undefined;
|
|
80
|
+
omit_empty?: boolean | undefined;
|
|
81
|
+
}, {
|
|
82
|
+
format?: "compact" | "standard" | "detailed" | undefined;
|
|
83
|
+
fields?: string[] | undefined;
|
|
84
|
+
omit_empty?: boolean | undefined;
|
|
85
|
+
}>>;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
format_options?: {
|
|
88
|
+
format?: "compact" | "standard" | "detailed" | undefined;
|
|
89
|
+
fields?: string[] | undefined;
|
|
90
|
+
omit_empty?: boolean | undefined;
|
|
91
|
+
} | undefined;
|
|
92
|
+
}, {
|
|
93
|
+
format_options?: {
|
|
94
|
+
format?: "compact" | "standard" | "detailed" | undefined;
|
|
95
|
+
fields?: string[] | undefined;
|
|
96
|
+
omit_empty?: boolean | undefined;
|
|
97
|
+
} | undefined;
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* List all asset types (reference data)
|
|
101
|
+
* Uses 1-hour cache TTL
|
|
102
|
+
*/
|
|
103
|
+
export declare function listAssetTypes(client: HaloPSAAPIClient, args: z.infer<typeof ListAssetTypesArgsSchema>): Promise<string>;
|
|
104
|
+
/**
|
|
105
|
+
* List all asset statuses (reference data)
|
|
106
|
+
* CRITICAL: status_id=1 (Active) determines billing eligibility
|
|
107
|
+
* Uses 1-hour cache TTL
|
|
108
|
+
*/
|
|
109
|
+
export declare function listAssetStatuses(client: HaloPSAAPIClient, args: z.infer<typeof ListAssetStatusesArgsSchema>): Promise<string>;
|
|
110
|
+
/**
|
|
111
|
+
* List all contact types (reference data)
|
|
112
|
+
* Uses 1-hour cache TTL
|
|
113
|
+
*/
|
|
114
|
+
export declare function listContactTypes(client: HaloPSAAPIClient, args: z.infer<typeof ListContactTypesArgsSchema>): Promise<string>;
|
|
115
|
+
export declare const listAssetTypesTool: ZodToolDefinition;
|
|
116
|
+
export declare const listAssetStatusesTool: ZodToolDefinition;
|
|
117
|
+
export declare const listContactTypesTool: ZodToolDefinition;
|
|
118
|
+
//# sourceMappingURL=reference-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference-data.d.ts","sourceRoot":"","sources":["../../src/tools/reference-data.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAiCvD;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;EAEnC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;EAEtC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;EAErC,CAAC;AAMH;;;GAGG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,GAC7C,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,GAChD,OAAO,CAAC,MAAM,CAAC,CA2BjB;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,GAC/C,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAMD,eAAO,MAAM,kBAAkB,EAAE,iBAKhC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,iBAKnC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,iBAKlC,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HaloPSA Reference Data tools with token optimization
|
|
3
|
+
* Provides read-only access to asset types, statuses, and other reference data
|
|
4
|
+
* Uses 1-hour cache TTL (reference data rarely changes)
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { formatResponse } from '../utils/formatter.js';
|
|
8
|
+
import { TTL } from '../cache/memory-cache.js';
|
|
9
|
+
import { FormatOptionsSchema } from '../schemas/common.js';
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// Zod Schemas for Input Validation
|
|
12
|
+
// =============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* List asset types schema
|
|
15
|
+
*/
|
|
16
|
+
export const ListAssetTypesArgsSchema = z.object({
|
|
17
|
+
format_options: FormatOptionsSchema,
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* List asset statuses schema
|
|
21
|
+
*/
|
|
22
|
+
export const ListAssetStatusesArgsSchema = z.object({
|
|
23
|
+
format_options: FormatOptionsSchema,
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* List contact types schema
|
|
27
|
+
*/
|
|
28
|
+
export const ListContactTypesArgsSchema = z.object({
|
|
29
|
+
format_options: FormatOptionsSchema,
|
|
30
|
+
});
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// Tool Implementations
|
|
33
|
+
// =============================================================================
|
|
34
|
+
/**
|
|
35
|
+
* List all asset types (reference data)
|
|
36
|
+
* Uses 1-hour cache TTL
|
|
37
|
+
*/
|
|
38
|
+
export async function listAssetTypes(client, args) {
|
|
39
|
+
const formatOptions = args.format_options || {};
|
|
40
|
+
const response = await client.getCached('/AssetType', { count: 500 }, {
|
|
41
|
+
enabled: true,
|
|
42
|
+
ttl: TTL.ASSET_TYPES,
|
|
43
|
+
keyPrefix: 'assettypes:all',
|
|
44
|
+
});
|
|
45
|
+
return formatResponse(response.assettypes, formatOptions, { record_count: response.record_count });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* List all asset statuses (reference data)
|
|
49
|
+
* CRITICAL: status_id=1 (Active) determines billing eligibility
|
|
50
|
+
* Uses 1-hour cache TTL
|
|
51
|
+
*/
|
|
52
|
+
export async function listAssetStatuses(client, args) {
|
|
53
|
+
const formatOptions = args.format_options || {};
|
|
54
|
+
const response = await client.getCached('/Lookup', { lookuptype: 'assetstatus', count: 100 }, {
|
|
55
|
+
enabled: true,
|
|
56
|
+
ttl: TTL.ASSET_STATUSES,
|
|
57
|
+
keyPrefix: 'assetstatuses:all',
|
|
58
|
+
});
|
|
59
|
+
// Add billing note to each status
|
|
60
|
+
const statusesWithNotes = response.assetstatuses.map((status) => ({
|
|
61
|
+
...status,
|
|
62
|
+
billing_eligible: status.id === 1, // Only Active status counts for billing
|
|
63
|
+
billing_note: status.id === 1
|
|
64
|
+
? 'COUNTS toward billing'
|
|
65
|
+
: 'Does NOT count toward billing',
|
|
66
|
+
}));
|
|
67
|
+
return formatResponse(statusesWithNotes, formatOptions, { record_count: response.record_count });
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* List all contact types (reference data)
|
|
71
|
+
* Uses 1-hour cache TTL
|
|
72
|
+
*/
|
|
73
|
+
export async function listContactTypes(client, args) {
|
|
74
|
+
const formatOptions = args.format_options || {};
|
|
75
|
+
const response = await client.getCached('/Lookup', { lookuptype: 'contacttype', count: 100 }, {
|
|
76
|
+
enabled: true,
|
|
77
|
+
ttl: TTL.CONTACT_TYPES,
|
|
78
|
+
keyPrefix: 'contacttypes:all',
|
|
79
|
+
});
|
|
80
|
+
return formatResponse(response.contacttypes, formatOptions, { record_count: response.record_count });
|
|
81
|
+
}
|
|
82
|
+
// =============================================================================
|
|
83
|
+
// Tool Definitions (for ToolRegistry)
|
|
84
|
+
// =============================================================================
|
|
85
|
+
export const listAssetTypesTool = {
|
|
86
|
+
name: 'list_halopsa_asset_types',
|
|
87
|
+
description: 'List all HaloPSA asset types (reference data) with caching (1hour TTL)',
|
|
88
|
+
schema: ListAssetTypesArgsSchema,
|
|
89
|
+
handler: listAssetTypes,
|
|
90
|
+
};
|
|
91
|
+
export const listAssetStatusesTool = {
|
|
92
|
+
name: 'list_halopsa_asset_statuses',
|
|
93
|
+
description: 'List all HaloPSA asset statuses with billing eligibility notes. CRITICAL: status_id=1 (Active) counts for billing.',
|
|
94
|
+
schema: ListAssetStatusesArgsSchema,
|
|
95
|
+
handler: listAssetStatuses,
|
|
96
|
+
};
|
|
97
|
+
export const listContactTypesTool = {
|
|
98
|
+
name: 'list_halopsa_contact_types',
|
|
99
|
+
description: 'List all HaloPSA contact types (reference data) with caching (1hour TTL)',
|
|
100
|
+
schema: ListContactTypesArgsSchema,
|
|
101
|
+
handler: listContactTypes,
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=reference-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference-data.js","sourceRoot":"","sources":["../../src/tools/reference-data.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,OAAO,EAAE,cAAc,EAAsB,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAqB3D,gFAAgF;AAChF,mCAAmC;AACnC,gFAAgF;AAEhF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,cAAc,EAAE,mBAAmB;CACpC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,cAAc,EAAE,mBAAmB;CACpC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,cAAc,EAAE,mBAAmB;CACpC,CAAC,CAAC;AAEH,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,KAAK,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C;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAwB,EACxB,IAAgD;IAEhD,MAAM,aAAa,GAAkB,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC;IAE/D,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS,CACrC,SAAS,EACT,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,EAAE,EACzC;QACE,OAAO,EAAE,IAAI;QACb,GAAG,EAAE,GAAG,CAAC,aAAa;QACtB,SAAS,EAAE,kBAAkB;KAC9B,CACF,CAAC;IAEF,OAAO,cAAc,CACnB,QAAQ,CAAC,YAAY,EACrB,aAAa,EACb,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE,CACxC,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,sCAAsC;AACtC,gFAAgF;AAEhF,MAAM,CAAC,MAAM,kBAAkB,GAAsB;IACnD,IAAI,EAAE,0BAA0B;IAChC,WAAW,EAAE,wEAAwE;IACrF,MAAM,EAAE,wBAAwB;IAChC,OAAO,EAAE,cAAc;CACxB,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACtD,IAAI,EAAE,6BAA6B;IACnC,WAAW,EAAE,oHAAoH;IACjI,MAAM,EAAE,2BAA2B;IACnC,OAAO,EAAE,iBAAiB;CAC3B,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,IAAI,EAAE,4BAA4B;IAClC,WAAW,EAAE,0EAA0E;IACvF,MAAM,EAAE,0BAA0B;IAClC,OAAO,EAAE,gBAAgB;CAC1B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central tool registration — imports all 31 ZodToolDefinition exports
|
|
3
|
+
* and registers them with a ToolRegistry instance.
|
|
4
|
+
*/
|
|
5
|
+
import type { ToolRegistry } from './registry.js';
|
|
6
|
+
export declare function registerAllTools(registry: ToolRegistry): void;
|
|
7
|
+
//# sourceMappingURL=registrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registrations.d.ts","sourceRoot":"","sources":["../../src/tools/registrations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAiGlD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAI7D"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central tool registration — imports all 31 ZodToolDefinition exports
|
|
3
|
+
* and registers them with a ToolRegistry instance.
|
|
4
|
+
*/
|
|
5
|
+
// Asset tools (11)
|
|
6
|
+
import { listAssetsTool, getAssetTool, searchAssetsBySerialTool, searchAssetsByHostnameTool, createAssetTool, updateAssetTool, deleteAssetTool, listAssetCustomFieldsTool, getAssetFieldSchemaTool, findAssetMatchTool, scanAssetDuplicatesTool, } from './assets.js';
|
|
7
|
+
// User tools (7)
|
|
8
|
+
import { listUsersTool, getUserTool, searchUsersByEmailTool, createUserTool, updateUserTool, findUserMatchTool, scanUserDuplicatesTool, } from './users.js';
|
|
9
|
+
// Site tools (4)
|
|
10
|
+
import { listSitesTool, getSiteTool, createSiteTool, findSiteMatchTool, } from './sites.js';
|
|
11
|
+
// Client tools (3)
|
|
12
|
+
import { listClientsTool, getClientTool, searchClientsTool, } from './clients.js';
|
|
13
|
+
// Reference data tools (3)
|
|
14
|
+
import { listAssetTypesTool, listAssetStatusesTool, listContactTypesTool, } from './reference-data.js';
|
|
15
|
+
// Batch operations tools (3)
|
|
16
|
+
import { getAssetsBatchTool, getUsersBatchTool, getSitesBatchTool, } from './batch-operations.js';
|
|
17
|
+
const allTools = [
|
|
18
|
+
// Assets (11)
|
|
19
|
+
listAssetsTool,
|
|
20
|
+
getAssetTool,
|
|
21
|
+
searchAssetsBySerialTool,
|
|
22
|
+
searchAssetsByHostnameTool,
|
|
23
|
+
createAssetTool,
|
|
24
|
+
updateAssetTool,
|
|
25
|
+
deleteAssetTool,
|
|
26
|
+
listAssetCustomFieldsTool,
|
|
27
|
+
getAssetFieldSchemaTool,
|
|
28
|
+
findAssetMatchTool,
|
|
29
|
+
scanAssetDuplicatesTool,
|
|
30
|
+
// Users (7)
|
|
31
|
+
listUsersTool,
|
|
32
|
+
getUserTool,
|
|
33
|
+
searchUsersByEmailTool,
|
|
34
|
+
createUserTool,
|
|
35
|
+
updateUserTool,
|
|
36
|
+
findUserMatchTool,
|
|
37
|
+
scanUserDuplicatesTool,
|
|
38
|
+
// Sites (4)
|
|
39
|
+
listSitesTool,
|
|
40
|
+
getSiteTool,
|
|
41
|
+
createSiteTool,
|
|
42
|
+
findSiteMatchTool,
|
|
43
|
+
// Clients (3)
|
|
44
|
+
listClientsTool,
|
|
45
|
+
getClientTool,
|
|
46
|
+
searchClientsTool,
|
|
47
|
+
// Reference data (3)
|
|
48
|
+
listAssetTypesTool,
|
|
49
|
+
listAssetStatusesTool,
|
|
50
|
+
listContactTypesTool,
|
|
51
|
+
// Batch operations (3)
|
|
52
|
+
getAssetsBatchTool,
|
|
53
|
+
getUsersBatchTool,
|
|
54
|
+
getSitesBatchTool,
|
|
55
|
+
];
|
|
56
|
+
export function registerAllTools(registry) {
|
|
57
|
+
for (const tool of allTools) {
|
|
58
|
+
registry.registerZod(tool);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=registrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registrations.js","sourceRoot":"","sources":["../../src/tools/registrations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,mBAAmB;AACnB,OAAO,EACL,cAAc,EACd,YAAY,EACZ,wBAAwB,EACxB,0BAA0B,EAC1B,eAAe,EACf,eAAe,EACf,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AA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|
|
2
|
+
* Generic tool registry for HaloPSA MCP server tools.
|
|
3
|
+
* Maps tool names to schemas and handler functions.
|
|
4
|
+
*
|
|
5
|
+
* Supports two registration paths:
|
|
6
|
+
* - register() : legacy manual JSON Schema (backward compat during migration)
|
|
7
|
+
* - registerZod() : Zod-first registration with automatic schema conversion
|
|
8
|
+
* and input parsing (replaces coerceArgs per-tool)
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import type { HaloPSAAPIClient } from '../api/client.js';
|
|
12
|
+
/**
|
|
13
|
+
* Legacy tool definition with hand-written JSON Schema.
|
|
14
|
+
* Retained for backward compatibility; will be removed after Phase 4.
|
|
15
|
+
*/
|
|
16
|
+
export interface ToolDefinition {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: 'object';
|
|
21
|
+
properties: Record<string, unknown>;
|
|
22
|
+
required?: string[];
|
|
23
|
+
};
|
|
24
|
+
handler: (client: HaloPSAAPIClient, args: Record<string, unknown>) => Promise<string>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Zod-first tool definition.
|
|
28
|
+
* The schema drives both JSON Schema generation (for MCP) and runtime
|
|
29
|
+
* input parsing/coercion (replacing manual coerceArgs).
|
|
30
|
+
*/
|
|
31
|
+
export interface ZodToolDefinition {
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
schema: z.ZodObject<z.ZodRawShape>;
|
|
35
|
+
handler: (client: HaloPSAAPIClient, args: any) => Promise<string>;
|
|
36
|
+
}
|
|
37
|
+
export declare class ToolRegistry {
|
|
38
|
+
private tools;
|
|
39
|
+
/**
|
|
40
|
+
* Register a tool with a hand-written JSON Schema.
|
|
41
|
+
* Backward compatible path -- use registerZod() for new tools.
|
|
42
|
+
*/
|
|
43
|
+
register(tool: ToolDefinition): void;
|
|
44
|
+
/**
|
|
45
|
+
* Register a tool using a Zod schema.
|
|
46
|
+
* Converts the schema to JSON Schema for MCP and wraps the handler
|
|
47
|
+
* to parse/coerce input before dispatching.
|
|
48
|
+
*/
|
|
49
|
+
registerZod(tool: ZodToolDefinition): void;
|
|
50
|
+
getToolSchemas(): Array<{
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
inputSchema: unknown;
|
|
54
|
+
}>;
|
|
55
|
+
dispatch(client: HaloPSAAPIClient, name: string, args: Record<string, unknown>): Promise<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Remove a tool from the registry by name.
|
|
58
|
+
* Returns true if the tool existed and was removed, false otherwise.
|
|
59
|
+
*/
|
|
60
|
+
unregister(name: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Check whether a tool with the given name is registered.
|
|
63
|
+
*/
|
|
64
|
+
has(name: string): boolean;
|
|
65
|
+
get size(): number;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;IACF,OAAO,EAAE,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACvF;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAEnC,OAAO,EAAE,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACnE;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAA0C;IAEvD;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAOpC;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI;IAc1C,cAAc,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,CAAC;IAQ9E,QAAQ,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAQtG;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic tool registry for HaloPSA MCP server tools.
|
|
3
|
+
* Maps tool names to schemas and handler functions.
|
|
4
|
+
*
|
|
5
|
+
* Supports two registration paths:
|
|
6
|
+
* - register() : legacy manual JSON Schema (backward compat during migration)
|
|
7
|
+
* - registerZod() : Zod-first registration with automatic schema conversion
|
|
8
|
+
* and input parsing (replaces coerceArgs per-tool)
|
|
9
|
+
*/
|
|
10
|
+
import { zodToJsonSchema } from '../utils/zod-to-schema.js';
|
|
11
|
+
export class ToolRegistry {
|
|
12
|
+
tools = new Map();
|
|
13
|
+
/**
|
|
14
|
+
* Register a tool with a hand-written JSON Schema.
|
|
15
|
+
* Backward compatible path -- use registerZod() for new tools.
|
|
16
|
+
*/
|
|
17
|
+
register(tool) {
|
|
18
|
+
if (this.tools.has(tool.name)) {
|
|
19
|
+
throw new Error(`Tool already registered: ${tool.name}`);
|
|
20
|
+
}
|
|
21
|
+
this.tools.set(tool.name, tool);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Register a tool using a Zod schema.
|
|
25
|
+
* Converts the schema to JSON Schema for MCP and wraps the handler
|
|
26
|
+
* to parse/coerce input before dispatching.
|
|
27
|
+
*/
|
|
28
|
+
registerZod(tool) {
|
|
29
|
+
const inputSchema = zodToJsonSchema(tool.schema);
|
|
30
|
+
this.register({
|
|
31
|
+
name: tool.name,
|
|
32
|
+
description: tool.description,
|
|
33
|
+
inputSchema,
|
|
34
|
+
handler: (client, args) => {
|
|
35
|
+
const parsed = tool.schema.parse(args);
|
|
36
|
+
return tool.handler(client, parsed);
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
getToolSchemas() {
|
|
41
|
+
return Array.from(this.tools.values()).map(({ name, description, inputSchema }) => ({
|
|
42
|
+
name,
|
|
43
|
+
description,
|
|
44
|
+
inputSchema,
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
async dispatch(client, name, args) {
|
|
48
|
+
const tool = this.tools.get(name);
|
|
49
|
+
if (!tool) {
|
|
50
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
51
|
+
}
|
|
52
|
+
return tool.handler(client, args);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Remove a tool from the registry by name.
|
|
56
|
+
* Returns true if the tool existed and was removed, false otherwise.
|
|
57
|
+
*/
|
|
58
|
+
unregister(name) {
|
|
59
|
+
return this.tools.delete(name);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Check whether a tool with the given name is registered.
|
|
63
|
+
*/
|
|
64
|
+
has(name) {
|
|
65
|
+
return this.tools.has(name);
|
|
66
|
+
}
|
|
67
|
+
get size() {
|
|
68
|
+
return this.tools.size;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AA8B5D,MAAM,OAAO,YAAY;IACf,KAAK,GAAgC,IAAI,GAAG,EAAE,CAAC;IAEvD;;;OAGG;IACH,QAAQ,CAAC,IAAoB;QAC3B,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3D,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,IAAuB;QACjC,MAAM,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEjD,IAAI,CAAC,QAAQ,CAAC;YACZ,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW;YACX,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;gBACxB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACvC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACtC,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,cAAc;QACZ,OAAO,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