@vinkius-core/mcp-fusion-aws 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/dist/AwsClient.d.ts +109 -0
- package/dist/AwsClient.d.ts.map +1 -0
- package/dist/AwsClient.js +220 -0
- package/dist/AwsClient.js.map +1 -0
- package/dist/LambdaDiscovery.d.ts +31 -0
- package/dist/LambdaDiscovery.d.ts.map +1 -0
- package/dist/LambdaDiscovery.js +61 -0
- package/dist/LambdaDiscovery.js.map +1 -0
- package/dist/StepFunctionDiscovery.d.ts +32 -0
- package/dist/StepFunctionDiscovery.d.ts.map +1 -0
- package/dist/StepFunctionDiscovery.js +71 -0
- package/dist/StepFunctionDiscovery.js.map +1 -0
- package/dist/ToolSynthesizer.d.ts +61 -0
- package/dist/ToolSynthesizer.d.ts.map +1 -0
- package/dist/ToolSynthesizer.js +294 -0
- package/dist/ToolSynthesizer.js.map +1 -0
- package/dist/createAwsConnector.d.ts +47 -0
- package/dist/createAwsConnector.d.ts.map +1 -0
- package/dist/createAwsConnector.js +117 -0
- package/dist/createAwsConnector.js.map +1 -0
- package/dist/defineAwsTool.d.ts +29 -0
- package/dist/defineAwsTool.d.ts.map +1 -0
- package/dist/defineAwsTool.js +86 -0
- package/dist/defineAwsTool.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +157 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +26 -0
- package/dist/types.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { LambdaInvokeResult, SfnSyncResult, SfnAsyncResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Minimal wrapper around the AWS SDK Lambda and Step Functions clients.
|
|
4
|
+
*
|
|
5
|
+
* Accepts pre-configured adapter instances (IoC for enterprise).
|
|
6
|
+
* Adapters abstract away the AWS SDK Command pattern, letting
|
|
7
|
+
* the rest of the codebase focus on business logic.
|
|
8
|
+
*
|
|
9
|
+
* **Why adapters instead of raw SDK clients?**
|
|
10
|
+
* AWS SDK v3 uses `client.send(new Command(input))`.
|
|
11
|
+
* Adapters encapsulate this pattern, keeping the surface clean
|
|
12
|
+
* and testable via simple interface mocks.
|
|
13
|
+
*/
|
|
14
|
+
export declare class AwsClient {
|
|
15
|
+
private readonly lambda;
|
|
16
|
+
private readonly sfn;
|
|
17
|
+
constructor(lambda: LambdaAdapter | undefined, sfn: SfnAdapter | undefined);
|
|
18
|
+
/** List all Lambda functions (paginated) */
|
|
19
|
+
listLambdaFunctions(): Promise<LambdaFunctionSummary[]>;
|
|
20
|
+
/** Get tags for a Lambda function by ARN */
|
|
21
|
+
getLambdaTags(arn: string): Promise<Record<string, string>>;
|
|
22
|
+
/** Invoke a Lambda function synchronously (RequestResponse) */
|
|
23
|
+
invokeLambda(arn: string, payload: unknown): Promise<LambdaInvokeResult>;
|
|
24
|
+
/** List all Step Functions state machines (paginated) */
|
|
25
|
+
listStateMachines(): Promise<SfnStateMachineSummary[]>;
|
|
26
|
+
/** Get tags for a Step Function */
|
|
27
|
+
getStateMachineTags(arn: string): Promise<Record<string, string>>;
|
|
28
|
+
/** Describe a Step Function state machine */
|
|
29
|
+
describeStateMachine(arn: string): Promise<{
|
|
30
|
+
description: string;
|
|
31
|
+
type: string;
|
|
32
|
+
}>;
|
|
33
|
+
/** Start a synchronous execution (Express Step Functions) */
|
|
34
|
+
startSyncExecution(arn: string, input: unknown): Promise<SfnSyncResult>;
|
|
35
|
+
/** Start an asynchronous execution (Standard Step Functions) */
|
|
36
|
+
startExecution(arn: string, input: unknown): Promise<SfnAsyncResult>;
|
|
37
|
+
private requireLambda;
|
|
38
|
+
private requireSfn;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Adapter interface for Lambda SDK interactions.
|
|
42
|
+
* Users create these via `createLambdaAdapter()`.
|
|
43
|
+
*/
|
|
44
|
+
export interface LambdaAdapter {
|
|
45
|
+
listFunctions(): Promise<LambdaFunctionSummary[]>;
|
|
46
|
+
listTags(arn: string): Promise<Record<string, string>>;
|
|
47
|
+
invoke(arn: string, payload: unknown): Promise<LambdaInvokeResult>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Adapter interface for Step Functions SDK interactions.
|
|
51
|
+
* Users create these via `createSfnAdapter()`.
|
|
52
|
+
*/
|
|
53
|
+
export interface SfnAdapter {
|
|
54
|
+
listStateMachines(): Promise<SfnStateMachineSummary[]>;
|
|
55
|
+
listTags(arn: string): Promise<Record<string, string>>;
|
|
56
|
+
describe(arn: string): Promise<{
|
|
57
|
+
description: string;
|
|
58
|
+
type: string;
|
|
59
|
+
}>;
|
|
60
|
+
startSync(arn: string, input: unknown): Promise<SfnSyncResult>;
|
|
61
|
+
startAsync(arn: string, input: unknown): Promise<SfnAsyncResult>;
|
|
62
|
+
}
|
|
63
|
+
/** Summarized Lambda function from discovery */
|
|
64
|
+
export interface LambdaFunctionSummary {
|
|
65
|
+
readonly functionName: string;
|
|
66
|
+
readonly functionArn: string;
|
|
67
|
+
readonly description: string;
|
|
68
|
+
readonly runtime: string;
|
|
69
|
+
}
|
|
70
|
+
/** Summarized Step Function state machine from discovery */
|
|
71
|
+
export interface SfnStateMachineSummary {
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly stateMachineArn: string;
|
|
74
|
+
/** State machine type — available from ListStateMachines directly */
|
|
75
|
+
readonly type: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Create a Lambda adapter from a real AWS SDK v3 `LambdaClient`.
|
|
79
|
+
*
|
|
80
|
+
* Uses `client.send(new Command())` pattern — compatible with the real SDK.
|
|
81
|
+
* Requires `@aws-sdk/client-lambda` to be installed (Command classes
|
|
82
|
+
* are dynamically imported at runtime).
|
|
83
|
+
*
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { LambdaClient } from '@aws-sdk/client-lambda';
|
|
86
|
+
* const adapter = await createLambdaAdapter(new LambdaClient({ region: 'us-east-1' }));
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function createLambdaAdapter(client: AwsSdkClientLike): Promise<LambdaAdapter>;
|
|
90
|
+
/**
|
|
91
|
+
* Create a Step Functions adapter from a real AWS SDK v3 `SFNClient`.
|
|
92
|
+
*
|
|
93
|
+
* Uses `client.send(new Command())` pattern — compatible with the real SDK.
|
|
94
|
+
* Requires `@aws-sdk/client-sfn` to be installed.
|
|
95
|
+
*
|
|
96
|
+
* ```typescript
|
|
97
|
+
* import { SFNClient } from '@aws-sdk/client-sfn';
|
|
98
|
+
* const adapter = await createSfnAdapter(new SFNClient({ region: 'us-east-1' }));
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare function createSfnAdapter(client: AwsSdkClientLike): Promise<SfnAdapter>;
|
|
102
|
+
/**
|
|
103
|
+
* Minimal duck-type for an AWS SDK v3 client.
|
|
104
|
+
* Both `LambdaClient` and `SFNClient` satisfy this interface.
|
|
105
|
+
*/
|
|
106
|
+
export interface AwsSdkClientLike {
|
|
107
|
+
send(command: unknown): Promise<unknown>;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=AwsClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AwsClient.d.ts","sourceRoot":"","sources":["../src/AwsClient.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,kBAAkB,EAClB,aAAa,EACb,cAAc,EACjB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;GAWG;AACH,qBAAa,SAAS;IAGd,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBADH,MAAM,EAAE,aAAa,GAAG,SAAS,EACjC,GAAG,EAAE,UAAU,GAAG,SAAS;IAKhD,4CAA4C;IACtC,mBAAmB,IAAI,OAAO,CAAC,qBAAqB,EAAE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|
|
2
|
+
// AwsClient — Wrapper for AWS SDK Lambda & Step Functions APIs
|
|
3
|
+
// ============================================================================
|
|
4
|
+
/**
|
|
5
|
+
* Minimal wrapper around the AWS SDK Lambda and Step Functions clients.
|
|
6
|
+
*
|
|
7
|
+
* Accepts pre-configured adapter instances (IoC for enterprise).
|
|
8
|
+
* Adapters abstract away the AWS SDK Command pattern, letting
|
|
9
|
+
* the rest of the codebase focus on business logic.
|
|
10
|
+
*
|
|
11
|
+
* **Why adapters instead of raw SDK clients?**
|
|
12
|
+
* AWS SDK v3 uses `client.send(new Command(input))`.
|
|
13
|
+
* Adapters encapsulate this pattern, keeping the surface clean
|
|
14
|
+
* and testable via simple interface mocks.
|
|
15
|
+
*/
|
|
16
|
+
export class AwsClient {
|
|
17
|
+
lambda;
|
|
18
|
+
sfn;
|
|
19
|
+
constructor(lambda, sfn) {
|
|
20
|
+
this.lambda = lambda;
|
|
21
|
+
this.sfn = sfn;
|
|
22
|
+
}
|
|
23
|
+
// ── Lambda ───────────────────────────────────────────
|
|
24
|
+
/** List all Lambda functions (paginated) */
|
|
25
|
+
async listLambdaFunctions() {
|
|
26
|
+
return this.requireLambda().listFunctions();
|
|
27
|
+
}
|
|
28
|
+
/** Get tags for a Lambda function by ARN */
|
|
29
|
+
async getLambdaTags(arn) {
|
|
30
|
+
return this.requireLambda().listTags(arn);
|
|
31
|
+
}
|
|
32
|
+
/** Invoke a Lambda function synchronously (RequestResponse) */
|
|
33
|
+
async invokeLambda(arn, payload) {
|
|
34
|
+
return this.requireLambda().invoke(arn, payload);
|
|
35
|
+
}
|
|
36
|
+
// ── Step Functions ────────────────────────────────────
|
|
37
|
+
/** List all Step Functions state machines (paginated) */
|
|
38
|
+
async listStateMachines() {
|
|
39
|
+
return this.requireSfn().listStateMachines();
|
|
40
|
+
}
|
|
41
|
+
/** Get tags for a Step Function */
|
|
42
|
+
async getStateMachineTags(arn) {
|
|
43
|
+
return this.requireSfn().listTags(arn);
|
|
44
|
+
}
|
|
45
|
+
/** Describe a Step Function state machine */
|
|
46
|
+
async describeStateMachine(arn) {
|
|
47
|
+
return this.requireSfn().describe(arn);
|
|
48
|
+
}
|
|
49
|
+
/** Start a synchronous execution (Express Step Functions) */
|
|
50
|
+
async startSyncExecution(arn, input) {
|
|
51
|
+
return this.requireSfn().startSync(arn, input);
|
|
52
|
+
}
|
|
53
|
+
/** Start an asynchronous execution (Standard Step Functions) */
|
|
54
|
+
async startExecution(arn, input) {
|
|
55
|
+
return this.requireSfn().startAsync(arn, input);
|
|
56
|
+
}
|
|
57
|
+
// ── Internal ─────────────────────────────────────────
|
|
58
|
+
requireLambda() {
|
|
59
|
+
if (!this.lambda) {
|
|
60
|
+
throw new Error('AwsClient: Lambda adapter not configured. ' +
|
|
61
|
+
'Pass a LambdaAdapter via createLambdaAdapter() in your connector config.');
|
|
62
|
+
}
|
|
63
|
+
return this.lambda;
|
|
64
|
+
}
|
|
65
|
+
requireSfn() {
|
|
66
|
+
if (!this.sfn) {
|
|
67
|
+
throw new Error('AwsClient: Step Functions adapter not configured. ' +
|
|
68
|
+
'Pass an SfnAdapter via createSfnAdapter() in your connector config.');
|
|
69
|
+
}
|
|
70
|
+
return this.sfn;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// ── Adapter Factories ────────────────────────────────────
|
|
74
|
+
/**
|
|
75
|
+
* Create a Lambda adapter from a real AWS SDK v3 `LambdaClient`.
|
|
76
|
+
*
|
|
77
|
+
* Uses `client.send(new Command())` pattern — compatible with the real SDK.
|
|
78
|
+
* Requires `@aws-sdk/client-lambda` to be installed (Command classes
|
|
79
|
+
* are dynamically imported at runtime).
|
|
80
|
+
*
|
|
81
|
+
* ```typescript
|
|
82
|
+
* import { LambdaClient } from '@aws-sdk/client-lambda';
|
|
83
|
+
* const adapter = await createLambdaAdapter(new LambdaClient({ region: 'us-east-1' }));
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export async function createLambdaAdapter(client) {
|
|
87
|
+
const { ListFunctionsCommand, ListTagsCommand, InvokeCommand, } = await import('@aws-sdk/client-lambda');
|
|
88
|
+
return {
|
|
89
|
+
async listFunctions() {
|
|
90
|
+
const functions = [];
|
|
91
|
+
let marker;
|
|
92
|
+
do {
|
|
93
|
+
const response = await client.send(new ListFunctionsCommand({ Marker: marker }));
|
|
94
|
+
const fns = response.Functions ?? [];
|
|
95
|
+
for (const fn of fns) {
|
|
96
|
+
functions.push({
|
|
97
|
+
functionName: fn.FunctionName ?? '',
|
|
98
|
+
functionArn: fn.FunctionArn ?? '',
|
|
99
|
+
description: fn.Description ?? '',
|
|
100
|
+
runtime: fn.Runtime ?? 'unknown',
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
marker = response.NextMarker;
|
|
104
|
+
} while (marker);
|
|
105
|
+
return functions;
|
|
106
|
+
},
|
|
107
|
+
async listTags(arn) {
|
|
108
|
+
const response = await client.send(new ListTagsCommand({ Resource: arn }));
|
|
109
|
+
return response.Tags ?? {};
|
|
110
|
+
},
|
|
111
|
+
async invoke(arn, payload) {
|
|
112
|
+
const response = await client.send(new InvokeCommand({
|
|
113
|
+
FunctionName: arn,
|
|
114
|
+
InvocationType: 'RequestResponse',
|
|
115
|
+
Payload: new TextEncoder().encode(JSON.stringify(payload ?? {})),
|
|
116
|
+
}));
|
|
117
|
+
const rawPayload = response.Payload
|
|
118
|
+
? new TextDecoder().decode(response.Payload)
|
|
119
|
+
: 'null';
|
|
120
|
+
let parsed;
|
|
121
|
+
try {
|
|
122
|
+
parsed = JSON.parse(rawPayload);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
parsed = rawPayload;
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
statusCode: response.StatusCode ?? 200,
|
|
129
|
+
payload: parsed,
|
|
130
|
+
functionError: response.FunctionError,
|
|
131
|
+
logResult: response.LogResult,
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Create a Step Functions adapter from a real AWS SDK v3 `SFNClient`.
|
|
138
|
+
*
|
|
139
|
+
* Uses `client.send(new Command())` pattern — compatible with the real SDK.
|
|
140
|
+
* Requires `@aws-sdk/client-sfn` to be installed.
|
|
141
|
+
*
|
|
142
|
+
* ```typescript
|
|
143
|
+
* import { SFNClient } from '@aws-sdk/client-sfn';
|
|
144
|
+
* const adapter = await createSfnAdapter(new SFNClient({ region: 'us-east-1' }));
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export async function createSfnAdapter(client) {
|
|
148
|
+
const { ListStateMachinesCommand, ListTagsForResourceCommand, DescribeStateMachineCommand, StartSyncExecutionCommand, StartExecutionCommand, } = await import('@aws-sdk/client-sfn');
|
|
149
|
+
return {
|
|
150
|
+
async listStateMachines() {
|
|
151
|
+
const machines = [];
|
|
152
|
+
let nextToken;
|
|
153
|
+
do {
|
|
154
|
+
const response = await client.send(new ListStateMachinesCommand({ nextToken }));
|
|
155
|
+
const sms = response.stateMachines ?? [];
|
|
156
|
+
for (const sm of sms) {
|
|
157
|
+
machines.push({
|
|
158
|
+
name: sm.name ?? '',
|
|
159
|
+
stateMachineArn: sm.stateMachineArn ?? '',
|
|
160
|
+
type: sm.type ?? 'STANDARD',
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
nextToken = response.nextToken;
|
|
164
|
+
} while (nextToken);
|
|
165
|
+
return machines;
|
|
166
|
+
},
|
|
167
|
+
async listTags(arn) {
|
|
168
|
+
const response = await client.send(new ListTagsForResourceCommand({ resourceArn: arn }));
|
|
169
|
+
const tags = {};
|
|
170
|
+
const rawTags = response.tags ?? [];
|
|
171
|
+
for (const tag of rawTags) {
|
|
172
|
+
tags[tag.key] = tag.value;
|
|
173
|
+
}
|
|
174
|
+
return tags;
|
|
175
|
+
},
|
|
176
|
+
async describe(arn) {
|
|
177
|
+
const response = await client.send(new DescribeStateMachineCommand({ stateMachineArn: arn }));
|
|
178
|
+
return {
|
|
179
|
+
description: response.description ?? '',
|
|
180
|
+
type: response.type ?? 'STANDARD',
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
async startSync(arn, input) {
|
|
184
|
+
const response = await client.send(new StartSyncExecutionCommand({
|
|
185
|
+
stateMachineArn: arn,
|
|
186
|
+
input: JSON.stringify(input ?? {}),
|
|
187
|
+
}));
|
|
188
|
+
let output;
|
|
189
|
+
const rawOutput = response.output;
|
|
190
|
+
try {
|
|
191
|
+
output = rawOutput ? JSON.parse(rawOutput) : null;
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
output = rawOutput;
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
status: (response.status ?? 'FAILED'),
|
|
198
|
+
output,
|
|
199
|
+
error: response.error,
|
|
200
|
+
cause: response.cause,
|
|
201
|
+
executionArn: response.executionArn ?? '',
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
async startAsync(arn, input) {
|
|
205
|
+
const response = await client.send(new StartExecutionCommand({
|
|
206
|
+
stateMachineArn: arn,
|
|
207
|
+
input: JSON.stringify(input ?? {}),
|
|
208
|
+
}));
|
|
209
|
+
// startDate is a Date object from the SDK — convert to ISO string
|
|
210
|
+
const startDate = response.startDate instanceof Date
|
|
211
|
+
? response.startDate.toISOString()
|
|
212
|
+
: new Date().toISOString();
|
|
213
|
+
return {
|
|
214
|
+
executionArn: response.executionArn ?? '',
|
|
215
|
+
startDate,
|
|
216
|
+
};
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=AwsClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AwsClient.js","sourceRoot":"","sources":["../src/AwsClient.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,+DAA+D;AAC/D,+EAA+E;AAQ/E;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,SAAS;IAGG;IACA;IAFrB,YACqB,MAAiC,EACjC,GAA2B;QAD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K,IAAI,EAAE,CAAC;aACrC,CAAC,CACqB,CAAC;YAE5B,kEAAkE;YAClE,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,YAAY,IAAI;gBAChD,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE;gBAClC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAE/B,OAAO;gBACH,YAAY,EAAE,QAAQ,CAAC,YAAY,IAAI,EAAE;gBACzC,SAAS;aACZ,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AwsClient } from './AwsClient.js';
|
|
2
|
+
import type { AwsLambdaConfig } from './types.js';
|
|
3
|
+
export interface LambdaDiscoveryOptions {
|
|
4
|
+
/** Tag filter — only functions matching ALL tags are included.
|
|
5
|
+
* Default: `{ 'mcp:expose': 'true' }` */
|
|
6
|
+
readonly tagFilter?: Readonly<Record<string, string>> | undefined;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Discovers Lambda functions tagged with `mcp:expose = true`
|
|
10
|
+
* and extracts MCP-relevant metadata from their tags.
|
|
11
|
+
*
|
|
12
|
+
* Tag convention:
|
|
13
|
+
* - `mcp:expose` — opt-in (required)
|
|
14
|
+
* - `mcp:group` — groups multiple Lambdas into a single MCP tool
|
|
15
|
+
* - `mcp:action` — action name within a group (default: 'execute')
|
|
16
|
+
* - `mcp:readOnly` — marks the action as read-only
|
|
17
|
+
* - `mcp:destructive` — marks the action as destructive
|
|
18
|
+
*/
|
|
19
|
+
export declare class LambdaDiscovery {
|
|
20
|
+
private readonly client;
|
|
21
|
+
private readonly options;
|
|
22
|
+
private readonly tagFilter;
|
|
23
|
+
constructor(client: AwsClient, options?: LambdaDiscoveryOptions);
|
|
24
|
+
/** Discover all tagged Lambda functions and return their configs */
|
|
25
|
+
discover(): Promise<AwsLambdaConfig[]>;
|
|
26
|
+
/** Check if tags match the required tag filter */
|
|
27
|
+
private matchesTagFilter;
|
|
28
|
+
/** Extract AwsLambdaConfig from a function summary + its tags */
|
|
29
|
+
private extractConfig;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=LambdaDiscovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LambdaDiscovery.d.ts","sourceRoot":"","sources":["../src/LambdaDiscovery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAyB,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,MAAM,WAAW,sBAAsB;IACnC;8CAC0C;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;CACrE;AAED;;;;;;;;;;GAUG;AACH,qBAAa,eAAe;IAIpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ5B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmC;gBAGxC,MAAM,EAAE,SAAS,EACjB,OAAO,GAAE,sBAA2B;IAKzD,oEAAoE;IAC9D,QAAQ,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAiB5C,kDAAkD;IAClD,OAAO,CAAC,gBAAgB;IAOxB,iEAAiE;IACjE,OAAO,CAAC,aAAa;CAgBxB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// LambdaDiscovery — Discover Lambda functions via AWS tags
|
|
3
|
+
// ============================================================================
|
|
4
|
+
import { MCP_TAGS, DEFAULT_TAG_FILTER, DEFAULT_ACTION_NAME } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Discovers Lambda functions tagged with `mcp:expose = true`
|
|
7
|
+
* and extracts MCP-relevant metadata from their tags.
|
|
8
|
+
*
|
|
9
|
+
* Tag convention:
|
|
10
|
+
* - `mcp:expose` — opt-in (required)
|
|
11
|
+
* - `mcp:group` — groups multiple Lambdas into a single MCP tool
|
|
12
|
+
* - `mcp:action` — action name within a group (default: 'execute')
|
|
13
|
+
* - `mcp:readOnly` — marks the action as read-only
|
|
14
|
+
* - `mcp:destructive` — marks the action as destructive
|
|
15
|
+
*/
|
|
16
|
+
export class LambdaDiscovery {
|
|
17
|
+
client;
|
|
18
|
+
options;
|
|
19
|
+
tagFilter;
|
|
20
|
+
constructor(client, options = {}) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
this.options = options;
|
|
23
|
+
this.tagFilter = options.tagFilter ?? DEFAULT_TAG_FILTER;
|
|
24
|
+
}
|
|
25
|
+
/** Discover all tagged Lambda functions and return their configs */
|
|
26
|
+
async discover() {
|
|
27
|
+
const allFunctions = await this.client.listLambdaFunctions();
|
|
28
|
+
const configs = [];
|
|
29
|
+
for (const fn of allFunctions) {
|
|
30
|
+
const tags = await this.client.getLambdaTags(fn.functionArn);
|
|
31
|
+
if (this.matchesTagFilter(tags)) {
|
|
32
|
+
configs.push(this.extractConfig(fn, tags));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return configs;
|
|
36
|
+
}
|
|
37
|
+
// ── Internal ──────────────────────────────────────────
|
|
38
|
+
/** Check if tags match the required tag filter */
|
|
39
|
+
matchesTagFilter(tags) {
|
|
40
|
+
for (const [key, value] of Object.entries(this.tagFilter)) {
|
|
41
|
+
if (tags[key] !== value)
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
/** Extract AwsLambdaConfig from a function summary + its tags */
|
|
47
|
+
extractConfig(fn, tags) {
|
|
48
|
+
return {
|
|
49
|
+
functionName: fn.functionName,
|
|
50
|
+
functionArn: fn.functionArn,
|
|
51
|
+
description: fn.description,
|
|
52
|
+
runtime: fn.runtime,
|
|
53
|
+
group: tags[MCP_TAGS.GROUP],
|
|
54
|
+
actionName: tags[MCP_TAGS.ACTION] ?? DEFAULT_ACTION_NAME,
|
|
55
|
+
readOnly: tags[MCP_TAGS.READ_ONLY] === 'true',
|
|
56
|
+
destructive: tags[MCP_TAGS.DESTRUCTIVE] === 'true',
|
|
57
|
+
tags,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=LambdaDiscovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LambdaDiscovery.js","sourceRoot":"","sources":["../src/LambdaDiscovery.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2DAA2D;AAC3D,+EAA+E;AAI/E,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAQ/E;;;;;;;;;;GAUG;AACH,MAAM,OAAO,eAAe;IAIH;IACA;IAJJ,SAAS,CAAmC;IAE7D,YACqB,MAAiB,EACjB,UAAkC,EAAE;QADpC,WAAM,GAAN,MAAM,CAAW;QACjB,YAAO,GAAP,OAAO,CAA6B;QAErD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,kBAAkB,CAAC;IAC7D,CAAC;IAED,oEAAoE;IACpE,KAAK,CAAC,QAAQ;QACV,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC7D,MAAM,OAAO,GAAsB,EAAE,CAAC;QAEtC,KAAK,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;YAE7D,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC9B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;YAC/C,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,yDAAyD;IAEzD,kDAAkD;IAC1C,gBAAgB,CAAC,IAA4B;QACjD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACxD,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK;gBAAE,OAAO,KAAK,CAAC;QAC1C,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,iEAAiE;IACzD,aAAa,CACjB,EAAyB,EACzB,IAA4B;QAE5B,OAAO;YACH,YAAY,EAAE,EAAE,CAAC,YAAY;YAC7B,WAAW,EAAE,EAAE,CAAC,WAAW;YAC3B,WAAW,EAAE,EAAE,CAAC,WAAW;YAC3B,OAAO,EAAE,EAAE,CAAC,OAAO;YACnB,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC3B,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,mBAAmB;YACxD,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,MAAM;YAC7C,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,MAAM;YAClD,IAAI;SACP,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AwsClient } from './AwsClient.js';
|
|
2
|
+
import type { AwsStepFunctionConfig } from './types.js';
|
|
3
|
+
export interface SfnDiscoveryOptions {
|
|
4
|
+
/** Tag filter — only state machines matching ALL tags are included.
|
|
5
|
+
* Default: `{ 'mcp:expose': 'true' }` */
|
|
6
|
+
readonly tagFilter?: Readonly<Record<string, string>> | undefined;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Discovers Step Functions state machines tagged with `mcp:expose = true`
|
|
10
|
+
* and extracts MCP-relevant metadata.
|
|
11
|
+
*
|
|
12
|
+
* **Optimization:** `type` (EXPRESS/STANDARD) is read from ListStateMachines
|
|
13
|
+
* directly — no extra `DescribeStateMachine` call needed just for type detection.
|
|
14
|
+
* `DescribeStateMachine` is only called to fetch the `description` field.
|
|
15
|
+
*
|
|
16
|
+
* Additional tags:
|
|
17
|
+
* - `mcp:sfn-type` — 'express' for sync or 'standard' for async (LRO pattern)
|
|
18
|
+
* - `mcp:group` / `mcp:action` — grouping (same as Lambda)
|
|
19
|
+
*/
|
|
20
|
+
export declare class StepFunctionDiscovery {
|
|
21
|
+
private readonly client;
|
|
22
|
+
private readonly options;
|
|
23
|
+
private readonly tagFilter;
|
|
24
|
+
constructor(client: AwsClient, options?: SfnDiscoveryOptions);
|
|
25
|
+
/** Discover all tagged state machines and return their configs */
|
|
26
|
+
discover(): Promise<AwsStepFunctionConfig[]>;
|
|
27
|
+
/** Check if tags match the required tag filter */
|
|
28
|
+
private matchesTagFilter;
|
|
29
|
+
/** Extract AwsStepFunctionConfig from a state machine summary + tags */
|
|
30
|
+
private extractConfig;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=StepFunctionDiscovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepFunctionDiscovery.d.ts","sourceRoot":"","sources":["../src/StepFunctionDiscovery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAA0B,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGxD,MAAM,WAAW,mBAAmB;IAChC;8CAC0C;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;CACrE;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,qBAAqB;IAI1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ5B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmC;gBAGxC,MAAM,EAAE,SAAS,EACjB,OAAO,GAAE,mBAAwB;IAKtD,kEAAkE;IAC5D,QAAQ,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAoBlD,kDAAkD;IAClD,OAAO,CAAC,gBAAgB;IAOxB,wEAAwE;IACxE,OAAO,CAAC,aAAa;CAyBxB"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// StepFunctionDiscovery — Discover SFN state machines via AWS tags
|
|
3
|
+
// ============================================================================
|
|
4
|
+
import { MCP_TAGS, DEFAULT_TAG_FILTER, DEFAULT_ACTION_NAME } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Discovers Step Functions state machines tagged with `mcp:expose = true`
|
|
7
|
+
* and extracts MCP-relevant metadata.
|
|
8
|
+
*
|
|
9
|
+
* **Optimization:** `type` (EXPRESS/STANDARD) is read from ListStateMachines
|
|
10
|
+
* directly — no extra `DescribeStateMachine` call needed just for type detection.
|
|
11
|
+
* `DescribeStateMachine` is only called to fetch the `description` field.
|
|
12
|
+
*
|
|
13
|
+
* Additional tags:
|
|
14
|
+
* - `mcp:sfn-type` — 'express' for sync or 'standard' for async (LRO pattern)
|
|
15
|
+
* - `mcp:group` / `mcp:action` — grouping (same as Lambda)
|
|
16
|
+
*/
|
|
17
|
+
export class StepFunctionDiscovery {
|
|
18
|
+
client;
|
|
19
|
+
options;
|
|
20
|
+
tagFilter;
|
|
21
|
+
constructor(client, options = {}) {
|
|
22
|
+
this.client = client;
|
|
23
|
+
this.options = options;
|
|
24
|
+
this.tagFilter = options.tagFilter ?? DEFAULT_TAG_FILTER;
|
|
25
|
+
}
|
|
26
|
+
/** Discover all tagged state machines and return their configs */
|
|
27
|
+
async discover() {
|
|
28
|
+
const allMachines = await this.client.listStateMachines();
|
|
29
|
+
const configs = [];
|
|
30
|
+
for (const sm of allMachines) {
|
|
31
|
+
const tags = await this.client.getStateMachineTags(sm.stateMachineArn);
|
|
32
|
+
if (this.matchesTagFilter(tags)) {
|
|
33
|
+
// Only call describeStateMachine for the description field.
|
|
34
|
+
// `type` is already available from ListStateMachines response.
|
|
35
|
+
const details = await this.client.describeStateMachine(sm.stateMachineArn);
|
|
36
|
+
configs.push(this.extractConfig(sm, tags, details.description));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return configs;
|
|
40
|
+
}
|
|
41
|
+
// ── Internal ──────────────────────────────────────────
|
|
42
|
+
/** Check if tags match the required tag filter */
|
|
43
|
+
matchesTagFilter(tags) {
|
|
44
|
+
for (const [key, value] of Object.entries(this.tagFilter)) {
|
|
45
|
+
if (tags[key] !== value)
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
/** Extract AwsStepFunctionConfig from a state machine summary + tags */
|
|
51
|
+
extractConfig(sm, tags, description) {
|
|
52
|
+
// Determine execution type: tag overrides API type
|
|
53
|
+
const sfnTypeTag = tags[MCP_TAGS.SFN_TYPE]?.toLowerCase();
|
|
54
|
+
const executionType = sfnTypeTag === 'express' ? 'express'
|
|
55
|
+
: sfnTypeTag === 'standard' ? 'standard'
|
|
56
|
+
: sm.type === 'EXPRESS' ? 'express'
|
|
57
|
+
: 'standard';
|
|
58
|
+
return {
|
|
59
|
+
name: sm.name,
|
|
60
|
+
stateMachineArn: sm.stateMachineArn,
|
|
61
|
+
description,
|
|
62
|
+
executionType,
|
|
63
|
+
group: tags[MCP_TAGS.GROUP],
|
|
64
|
+
actionName: tags[MCP_TAGS.ACTION] ?? DEFAULT_ACTION_NAME,
|
|
65
|
+
readOnly: tags[MCP_TAGS.READ_ONLY] === 'true',
|
|
66
|
+
destructive: tags[MCP_TAGS.DESTRUCTIVE] === 'true',
|
|
67
|
+
tags,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=StepFunctionDiscovery.js.map
|
|
@@ -0,0 +1 @@
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,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACxD,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK;gBAAE,OAAO,KAAK,CAAC;QAC1C,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,wEAAwE;IAChE,aAAa,CACjB,EAA0B,EAC1B,IAA4B,EAC5B,WAAmB;QAEnB,mDAAmD;QACnD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;QAC1D,MAAM,aAAa,GACf,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS;YAChC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU;gBACxC,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS;oBACnC,CAAC,CAAC,UAAU,CAAC;QAErB,OAAO;YACH,IAAI,EAAE,EAAE,CAAC,IAAI;YACb,eAAe,EAAE,EAAE,CAAC,eAAe;YACnC,WAAW;YACX,aAAa;YACb,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC3B,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,mBAAmB;YACxD,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,MAAM;YAC7C,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,MAAM;YAClD,IAAI;SACP,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { AwsLambdaConfig, AwsStepFunctionConfig } from './types.js';
|
|
2
|
+
import type { AwsClient } from './AwsClient.js';
|
|
3
|
+
/**
|
|
4
|
+
* Synthesized tool definition ready for `defineTool()`.
|
|
5
|
+
*
|
|
6
|
+
* This is the intermediate format between discovery and registration.
|
|
7
|
+
* The `config` object matches `ToolConfig` from `@vinkius-core/mcp-fusion`.
|
|
8
|
+
*/
|
|
9
|
+
export interface SynthesizedToolConfig {
|
|
10
|
+
/** Tool name (snake_case) */
|
|
11
|
+
readonly name: string;
|
|
12
|
+
/** Config object for defineTool() — contains description, actions/groups */
|
|
13
|
+
readonly config: {
|
|
14
|
+
readonly description: string;
|
|
15
|
+
readonly tags: readonly string[];
|
|
16
|
+
readonly actions: Readonly<Record<string, SynthesizedAction>>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface SynthesizedAction {
|
|
20
|
+
readonly description: string;
|
|
21
|
+
readonly readOnly?: boolean | undefined;
|
|
22
|
+
readonly destructive?: boolean | undefined;
|
|
23
|
+
readonly handler: (ctx: unknown, args: Record<string, unknown>) => Promise<unknown>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convert a function/resource name to a valid snake_case tool name.
|
|
27
|
+
*
|
|
28
|
+
* "CreateUser" → "create_user"
|
|
29
|
+
* "my-awesome-lambda" → "my_awesome_lambda"
|
|
30
|
+
* "get_users_v2" → "get_users_v2"
|
|
31
|
+
*
|
|
32
|
+
* @throws {Error} If the resulting name is empty after conversion
|
|
33
|
+
*/
|
|
34
|
+
export declare function toToolName(resourceName: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Synthesize tool configs from discovered Lambda functions.
|
|
37
|
+
*
|
|
38
|
+
* **Grouping logic:**
|
|
39
|
+
* - Lambdas with the same `mcp:group` tag → grouped into ONE tool with N actions
|
|
40
|
+
* - Lambdas without `mcp:group` → standalone tools with single `execute` action
|
|
41
|
+
*
|
|
42
|
+
* @throws {Error} If two Lambdas in the same group share an action name
|
|
43
|
+
* @returns Array of tool configs ready for defineTool()
|
|
44
|
+
*/
|
|
45
|
+
export declare function synthesizeLambdaTools(lambdas: readonly AwsLambdaConfig[], client: AwsClient): SynthesizedToolConfig[];
|
|
46
|
+
/**
|
|
47
|
+
* Synthesize tool configs from discovered Step Functions.
|
|
48
|
+
*
|
|
49
|
+
* Same grouping logic as Lambda.
|
|
50
|
+
* Execution type determines handler behavior:
|
|
51
|
+
* - EXPRESS → `startSyncExecution` (blocks, returns output)
|
|
52
|
+
* - STANDARD → `startExecution` (fire-and-forget, returns LRO with cognitive rule)
|
|
53
|
+
*
|
|
54
|
+
* @throws {Error} If two state machines in the same group share an action name
|
|
55
|
+
*/
|
|
56
|
+
export declare function synthesizeStepFunctionTools(stateMachines: readonly AwsStepFunctionConfig[], client: AwsClient): SynthesizedToolConfig[];
|
|
57
|
+
/**
|
|
58
|
+
* Synthesize all tools from both Lambda and Step Function configs.
|
|
59
|
+
*/
|
|
60
|
+
export declare function synthesizeAll(lambdas: readonly AwsLambdaConfig[], stepFunctions: readonly AwsStepFunctionConfig[], client: AwsClient): SynthesizedToolConfig[];
|
|
61
|
+
//# sourceMappingURL=ToolSynthesizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolSynthesizer.d.ts","sourceRoot":"","sources":["../src/ToolSynthesizer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IAClC,6BAA6B;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE;QACb,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;QACjC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;KACjE,CAAC;CACL;AAED,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,E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