@midscene/shared 1.7.6-beta-20260425023224.0 → 1.7.6
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/es/mcp/base-tools.mjs +12 -2
- package/dist/es/mcp/cli-report-session.mjs +12 -4
- package/dist/lib/mcp/base-tools.js +12 -2
- package/dist/lib/mcp/cli-report-session.js +12 -4
- package/dist/types/mcp/base-tools.d.ts +5 -1
- package/dist/types/mcp/cli-report-session.d.ts +3 -2
- package/package.json +1 -1
- package/src/mcp/base-tools.ts +22 -2
- package/src/mcp/cli-report-session.ts +17 -3
|
@@ -61,10 +61,10 @@ class BaseMidsceneTools {
|
|
|
61
61
|
return [];
|
|
62
62
|
}
|
|
63
63
|
getCliReportSessionName() {}
|
|
64
|
-
createNewCliReportSession() {
|
|
64
|
+
createNewCliReportSession(targetIdentity) {
|
|
65
65
|
const sessionName = this.getCliReportSessionName();
|
|
66
66
|
if (!sessionName) return;
|
|
67
|
-
return generateCliReportSession(sessionName);
|
|
67
|
+
return generateCliReportSession(sessionName, targetIdentity);
|
|
68
68
|
}
|
|
69
69
|
commitCliReportSession(session) {
|
|
70
70
|
if (session) writeCliReportSession(session);
|
|
@@ -74,6 +74,16 @@ class BaseMidsceneTools {
|
|
|
74
74
|
if (!sessionName) return;
|
|
75
75
|
return readCliReportSession(sessionName)?.reportFileName;
|
|
76
76
|
}
|
|
77
|
+
readCliReportAgentOptions() {
|
|
78
|
+
const reportFileName = this.readCliReportFileName();
|
|
79
|
+
if (!reportFileName) return;
|
|
80
|
+
return {
|
|
81
|
+
reportFileName,
|
|
82
|
+
reportAttributes: {
|
|
83
|
+
'data-group-id': reportFileName
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
77
87
|
async initTools() {
|
|
78
88
|
this.toolDefinitions = [];
|
|
79
89
|
const platformTools = this.preparePlatformTools();
|
|
@@ -5,6 +5,10 @@ const sessionDirName = 'cli-report-session';
|
|
|
5
5
|
function sanitizeSessionName(sessionName) {
|
|
6
6
|
return sessionName.replace(/[^a-zA-Z0-9._-]/g, '_') || 'default';
|
|
7
7
|
}
|
|
8
|
+
function sanitizeFileSegment(segment) {
|
|
9
|
+
const sanitized = segment.replace(/[^a-zA-Z0-9._-]/g, '_') || 'unknown';
|
|
10
|
+
return sanitized.slice(0, 80);
|
|
11
|
+
}
|
|
8
12
|
function ensureHtmlFileName(reportFileName) {
|
|
9
13
|
return reportFileName.endsWith('.html') ? reportFileName : `${reportFileName}.html`;
|
|
10
14
|
}
|
|
@@ -35,12 +39,16 @@ function getCliReportSessionDir() {
|
|
|
35
39
|
function getCliReportSessionPath(sessionName) {
|
|
36
40
|
return join(getCliReportSessionDir(), `${sanitizeSessionName(sessionName)}.json`);
|
|
37
41
|
}
|
|
38
|
-
function generateCliReportSession(sessionName) {
|
|
39
|
-
const
|
|
42
|
+
function generateCliReportSession(sessionName, targetIdentity) {
|
|
43
|
+
const identitySegment = targetIdentity ? `-${sanitizeFileSegment(targetIdentity)}` : '';
|
|
44
|
+
const reportFileName = `${sanitizeSessionName(sessionName)}${identitySegment}-${formatDateForFileName(new Date())}-${randomId()}`;
|
|
40
45
|
const reportPath = join(getMidsceneRunSubDir('report'), ensureHtmlFileName(reportFileName));
|
|
41
46
|
const session = {
|
|
42
47
|
version: 1,
|
|
43
48
|
sessionName,
|
|
49
|
+
...targetIdentity ? {
|
|
50
|
+
targetIdentity
|
|
51
|
+
} : {},
|
|
44
52
|
reportFileName,
|
|
45
53
|
reportPath,
|
|
46
54
|
createdAt: Date.now()
|
|
@@ -50,8 +58,8 @@ function generateCliReportSession(sessionName) {
|
|
|
50
58
|
function writeCliReportSession(session) {
|
|
51
59
|
writeFileSync(getCliReportSessionPath(session.sessionName), JSON.stringify(session, null, 2), 'utf-8');
|
|
52
60
|
}
|
|
53
|
-
function createCliReportSession(sessionName) {
|
|
54
|
-
const session = generateCliReportSession(sessionName);
|
|
61
|
+
function createCliReportSession(sessionName, targetIdentity) {
|
|
62
|
+
const session = generateCliReportSession(sessionName, targetIdentity);
|
|
55
63
|
writeCliReportSession(session);
|
|
56
64
|
return session;
|
|
57
65
|
}
|
|
@@ -89,10 +89,10 @@ class BaseMidsceneTools {
|
|
|
89
89
|
return [];
|
|
90
90
|
}
|
|
91
91
|
getCliReportSessionName() {}
|
|
92
|
-
createNewCliReportSession() {
|
|
92
|
+
createNewCliReportSession(targetIdentity) {
|
|
93
93
|
const sessionName = this.getCliReportSessionName();
|
|
94
94
|
if (!sessionName) return;
|
|
95
|
-
return (0, external_cli_report_session_js_namespaceObject.generateCliReportSession)(sessionName);
|
|
95
|
+
return (0, external_cli_report_session_js_namespaceObject.generateCliReportSession)(sessionName, targetIdentity);
|
|
96
96
|
}
|
|
97
97
|
commitCliReportSession(session) {
|
|
98
98
|
if (session) (0, external_cli_report_session_js_namespaceObject.writeCliReportSession)(session);
|
|
@@ -102,6 +102,16 @@ class BaseMidsceneTools {
|
|
|
102
102
|
if (!sessionName) return;
|
|
103
103
|
return (0, external_cli_report_session_js_namespaceObject.readCliReportSession)(sessionName)?.reportFileName;
|
|
104
104
|
}
|
|
105
|
+
readCliReportAgentOptions() {
|
|
106
|
+
const reportFileName = this.readCliReportFileName();
|
|
107
|
+
if (!reportFileName) return;
|
|
108
|
+
return {
|
|
109
|
+
reportFileName,
|
|
110
|
+
reportAttributes: {
|
|
111
|
+
'data-group-id': reportFileName
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
105
115
|
async initTools() {
|
|
106
116
|
this.toolDefinitions = [];
|
|
107
117
|
const platformTools = this.preparePlatformTools();
|
|
@@ -36,6 +36,10 @@ const sessionDirName = 'cli-report-session';
|
|
|
36
36
|
function sanitizeSessionName(sessionName) {
|
|
37
37
|
return sessionName.replace(/[^a-zA-Z0-9._-]/g, '_') || 'default';
|
|
38
38
|
}
|
|
39
|
+
function sanitizeFileSegment(segment) {
|
|
40
|
+
const sanitized = segment.replace(/[^a-zA-Z0-9._-]/g, '_') || 'unknown';
|
|
41
|
+
return sanitized.slice(0, 80);
|
|
42
|
+
}
|
|
39
43
|
function ensureHtmlFileName(reportFileName) {
|
|
40
44
|
return reportFileName.endsWith('.html') ? reportFileName : `${reportFileName}.html`;
|
|
41
45
|
}
|
|
@@ -66,12 +70,16 @@ function getCliReportSessionDir() {
|
|
|
66
70
|
function getCliReportSessionPath(sessionName) {
|
|
67
71
|
return (0, external_node_path_namespaceObject.join)(getCliReportSessionDir(), `${sanitizeSessionName(sessionName)}.json`);
|
|
68
72
|
}
|
|
69
|
-
function generateCliReportSession(sessionName) {
|
|
70
|
-
const
|
|
73
|
+
function generateCliReportSession(sessionName, targetIdentity) {
|
|
74
|
+
const identitySegment = targetIdentity ? `-${sanitizeFileSegment(targetIdentity)}` : '';
|
|
75
|
+
const reportFileName = `${sanitizeSessionName(sessionName)}${identitySegment}-${formatDateForFileName(new Date())}-${randomId()}`;
|
|
71
76
|
const reportPath = (0, external_node_path_namespaceObject.join)((0, external_common_js_namespaceObject.getMidsceneRunSubDir)('report'), ensureHtmlFileName(reportFileName));
|
|
72
77
|
const session = {
|
|
73
78
|
version: 1,
|
|
74
79
|
sessionName,
|
|
80
|
+
...targetIdentity ? {
|
|
81
|
+
targetIdentity
|
|
82
|
+
} : {},
|
|
75
83
|
reportFileName,
|
|
76
84
|
reportPath,
|
|
77
85
|
createdAt: Date.now()
|
|
@@ -81,8 +89,8 @@ function generateCliReportSession(sessionName) {
|
|
|
81
89
|
function writeCliReportSession(session) {
|
|
82
90
|
(0, external_node_fs_namespaceObject.writeFileSync)(getCliReportSessionPath(session.sessionName), JSON.stringify(session, null, 2), 'utf-8');
|
|
83
91
|
}
|
|
84
|
-
function createCliReportSession(sessionName) {
|
|
85
|
-
const session = generateCliReportSession(sessionName);
|
|
92
|
+
function createCliReportSession(sessionName, targetIdentity) {
|
|
93
|
+
const session = generateCliReportSession(sessionName, targetIdentity);
|
|
86
94
|
writeCliReportSession(session);
|
|
87
95
|
return session;
|
|
88
96
|
}
|
|
@@ -82,9 +82,13 @@ export declare abstract class BaseMidsceneTools<TAgent extends BaseAgent = BaseA
|
|
|
82
82
|
*/
|
|
83
83
|
protected preparePlatformTools(): ToolDefinition[];
|
|
84
84
|
protected getCliReportSessionName(): string | undefined;
|
|
85
|
-
protected createNewCliReportSession(): CliReportSession | undefined;
|
|
85
|
+
protected createNewCliReportSession(targetIdentity?: string): CliReportSession | undefined;
|
|
86
86
|
protected commitCliReportSession(session?: CliReportSession): void;
|
|
87
87
|
protected readCliReportFileName(): string | undefined;
|
|
88
|
+
protected readCliReportAgentOptions(): {
|
|
89
|
+
reportFileName: string;
|
|
90
|
+
reportAttributes: Record<string, string>;
|
|
91
|
+
} | undefined;
|
|
88
92
|
/**
|
|
89
93
|
* Must be implemented by subclasses to create a temporary device instance
|
|
90
94
|
* This allows getting real actionSpace without connecting to device
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export interface CliReportSession {
|
|
2
2
|
version: 1;
|
|
3
3
|
sessionName: string;
|
|
4
|
+
targetIdentity?: string;
|
|
4
5
|
reportFileName: string;
|
|
5
6
|
reportPath: string;
|
|
6
7
|
createdAt: number;
|
|
7
8
|
}
|
|
8
|
-
export declare function generateCliReportSession(sessionName: string): CliReportSession;
|
|
9
|
+
export declare function generateCliReportSession(sessionName: string, targetIdentity?: string): CliReportSession;
|
|
9
10
|
export declare function writeCliReportSession(session: CliReportSession): void;
|
|
10
|
-
export declare function createCliReportSession(sessionName: string): CliReportSession;
|
|
11
|
+
export declare function createCliReportSession(sessionName: string, targetIdentity?: string): CliReportSession;
|
|
11
12
|
export declare function readCliReportSession(sessionName: string): CliReportSession | undefined;
|
package/package.json
CHANGED
package/src/mcp/base-tools.ts
CHANGED
|
@@ -200,12 +200,14 @@ export abstract class BaseMidsceneTools<
|
|
|
200
200
|
return undefined;
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
protected createNewCliReportSession(
|
|
203
|
+
protected createNewCliReportSession(
|
|
204
|
+
targetIdentity?: string,
|
|
205
|
+
): CliReportSession | undefined {
|
|
204
206
|
const sessionName = this.getCliReportSessionName();
|
|
205
207
|
if (!sessionName) {
|
|
206
208
|
return undefined;
|
|
207
209
|
}
|
|
208
|
-
return generateCliReportSession(sessionName);
|
|
210
|
+
return generateCliReportSession(sessionName, targetIdentity);
|
|
209
211
|
}
|
|
210
212
|
|
|
211
213
|
protected commitCliReportSession(session?: CliReportSession): void {
|
|
@@ -222,6 +224,24 @@ export abstract class BaseMidsceneTools<
|
|
|
222
224
|
return readCliReportSession(sessionName)?.reportFileName;
|
|
223
225
|
}
|
|
224
226
|
|
|
227
|
+
protected readCliReportAgentOptions():
|
|
228
|
+
| {
|
|
229
|
+
reportFileName: string;
|
|
230
|
+
reportAttributes: Record<string, string>;
|
|
231
|
+
}
|
|
232
|
+
| undefined {
|
|
233
|
+
const reportFileName = this.readCliReportFileName();
|
|
234
|
+
if (!reportFileName) {
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
reportFileName,
|
|
239
|
+
reportAttributes: {
|
|
240
|
+
'data-group-id': reportFileName,
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
225
245
|
/**
|
|
226
246
|
* Must be implemented by subclasses to create a temporary device instance
|
|
227
247
|
* This allows getting real actionSpace without connecting to device
|
|
@@ -5,6 +5,7 @@ import { getMidsceneRunBaseDir, getMidsceneRunSubDir } from '../common';
|
|
|
5
5
|
export interface CliReportSession {
|
|
6
6
|
version: 1;
|
|
7
7
|
sessionName: string;
|
|
8
|
+
targetIdentity?: string;
|
|
8
9
|
reportFileName: string;
|
|
9
10
|
reportPath: string;
|
|
10
11
|
createdAt: number;
|
|
@@ -16,6 +17,11 @@ function sanitizeSessionName(sessionName: string): string {
|
|
|
16
17
|
return sessionName.replace(/[^a-zA-Z0-9._-]/g, '_') || 'default';
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
function sanitizeFileSegment(segment: string): string {
|
|
21
|
+
const sanitized = segment.replace(/[^a-zA-Z0-9._-]/g, '_') || 'unknown';
|
|
22
|
+
return sanitized.slice(0, 80);
|
|
23
|
+
}
|
|
24
|
+
|
|
19
25
|
function ensureHtmlFileName(reportFileName: string): string {
|
|
20
26
|
return reportFileName.endsWith('.html')
|
|
21
27
|
? reportFileName
|
|
@@ -58,8 +64,12 @@ function getCliReportSessionPath(sessionName: string): string {
|
|
|
58
64
|
|
|
59
65
|
export function generateCliReportSession(
|
|
60
66
|
sessionName: string,
|
|
67
|
+
targetIdentity?: string,
|
|
61
68
|
): CliReportSession {
|
|
62
|
-
const
|
|
69
|
+
const identitySegment = targetIdentity
|
|
70
|
+
? `-${sanitizeFileSegment(targetIdentity)}`
|
|
71
|
+
: '';
|
|
72
|
+
const reportFileName = `${sanitizeSessionName(sessionName)}${identitySegment}-${formatDateForFileName(new Date())}-${randomId()}`;
|
|
63
73
|
const reportPath = join(
|
|
64
74
|
getMidsceneRunSubDir('report'),
|
|
65
75
|
ensureHtmlFileName(reportFileName),
|
|
@@ -67,6 +77,7 @@ export function generateCliReportSession(
|
|
|
67
77
|
const session: CliReportSession = {
|
|
68
78
|
version: 1,
|
|
69
79
|
sessionName,
|
|
80
|
+
...(targetIdentity ? { targetIdentity } : {}),
|
|
70
81
|
reportFileName,
|
|
71
82
|
reportPath,
|
|
72
83
|
createdAt: Date.now(),
|
|
@@ -82,8 +93,11 @@ export function writeCliReportSession(session: CliReportSession): void {
|
|
|
82
93
|
);
|
|
83
94
|
}
|
|
84
95
|
|
|
85
|
-
export function createCliReportSession(
|
|
86
|
-
|
|
96
|
+
export function createCliReportSession(
|
|
97
|
+
sessionName: string,
|
|
98
|
+
targetIdentity?: string,
|
|
99
|
+
): CliReportSession {
|
|
100
|
+
const session = generateCliReportSession(sessionName, targetIdentity);
|
|
87
101
|
writeCliReportSession(session);
|
|
88
102
|
return session;
|
|
89
103
|
}
|