Skip to content

Commit b8baa57

Browse files
committed
refactor(gui-agent): move defaultNormalizeCoords to defaultImpls.ts for better organization
1 parent b1d1579 commit b8baa57

3 files changed

Lines changed: 22 additions & 23 deletions

File tree

multimodal/gui-agent/agent-sdk/src/GUIAgent.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ import {
2121
import {
2222
assembleSystemPrompt,
2323
isSystemPromptTemplate,
24-
defaultNormalizeCoords,
2524
normalizeActionCoords,
2625
sleep,
2726
} from '@gui-agent/shared/utils';
2827
import { GUI_ADAPTED_TOOL_NAME } from './constants';
2928
import { convertToAgentUIAction, createGUIErrorResponse } from './utils';
30-
import { defaultDetailCalculator } from './defaultImpls';
29+
import { defaultNormalizeCoords, defaultDetailCalculator } from './defaultImpls';
3130

3231
const defaultLogger = new ConsoleLogger('[GUIAgent]', LogLevel.DEBUG);
3332

multimodal/gui-agent/agent-sdk/src/defaultImpls.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,27 @@
22
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
5-
import { ImageDetailCalculator } from '@gui-agent/shared/types';
5+
import { Coordinates, ImageDetailCalculator, NormalizeCoordinates } from '@gui-agent/shared/types';
6+
7+
/**
8+
* Default coordinate normalization function
9+
* Normalizes raw coordinates by dividing by 1000 (simple scaling)
10+
* @param rawCoords - The raw coordinates to normalize
11+
* @returns Object containing normalized coordinates
12+
*/
13+
export const defaultNormalizeCoords: NormalizeCoordinates = (rawCoords: Coordinates) => {
14+
if (!rawCoords.raw) {
15+
return { normalized: rawCoords };
16+
}
17+
const normalizedCoords = {
18+
...rawCoords,
19+
normalized: {
20+
x: rawCoords.raw.x / 1000,
21+
y: rawCoords.raw.y / 1000,
22+
},
23+
};
24+
return { normalized: normalizedCoords };
25+
};
626

727
/**
828
* Default implementation for detail calculation based on pixel count

multimodal/gui-agent/shared/src/utils/coordinateNormalizer.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,6 @@
55

66
import { BaseAction, Coordinates, NormalizeCoordinates } from '../types';
77

8-
/**
9-
* Default coordinate normalization function
10-
* Normalizes raw coordinates by dividing by 1000 (simple scaling)
11-
* @param rawCoords - The raw coordinates to normalize
12-
* @returns Object containing normalized coordinates
13-
*/
14-
export const defaultNormalizeCoords: NormalizeCoordinates = (rawCoords: Coordinates) => {
15-
if (!rawCoords.raw) {
16-
return { normalized: rawCoords };
17-
}
18-
const normalizedCoords = {
19-
...rawCoords,
20-
normalized: {
21-
x: rawCoords.raw.x / 1000,
22-
y: rawCoords.raw.y / 1000,
23-
},
24-
};
25-
return { normalized: normalizedCoords };
26-
};
27-
288
/**
299
* Normalizes coordinates in a BaseAction object
3010
* Processes point, start, and end coordinate fields if they exist

0 commit comments

Comments
 (0)