@midscene/shared 1.2.1-beta-20260109060244.0 → 1.2.1-beta-20260109075435.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.
|
@@ -63,6 +63,28 @@ class BaseMidsceneTools {
|
|
|
63
63
|
}
|
|
64
64
|
];
|
|
65
65
|
}
|
|
66
|
+
buildTextResult(text) {
|
|
67
|
+
return {
|
|
68
|
+
content: [
|
|
69
|
+
{
|
|
70
|
+
type: 'text',
|
|
71
|
+
text
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
createDisconnectHandler(platformName) {
|
|
77
|
+
return async ()=>{
|
|
78
|
+
if (!this.agent) return this.buildTextResult('No active connection to disconnect');
|
|
79
|
+
try {
|
|
80
|
+
await this.agent.destroy?.();
|
|
81
|
+
} catch (error) {
|
|
82
|
+
debug('Failed to destroy agent during disconnect:', error);
|
|
83
|
+
}
|
|
84
|
+
this.agent = void 0;
|
|
85
|
+
return this.buildTextResult(`Disconnected from ${platformName}`);
|
|
86
|
+
};
|
|
87
|
+
}
|
|
66
88
|
constructor(){
|
|
67
89
|
_define_property(this, "mcpServer", void 0);
|
|
68
90
|
_define_property(this, "agent", void 0);
|
|
@@ -91,6 +91,28 @@ class BaseMidsceneTools {
|
|
|
91
91
|
}
|
|
92
92
|
];
|
|
93
93
|
}
|
|
94
|
+
buildTextResult(text) {
|
|
95
|
+
return {
|
|
96
|
+
content: [
|
|
97
|
+
{
|
|
98
|
+
type: 'text',
|
|
99
|
+
text
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
createDisconnectHandler(platformName) {
|
|
105
|
+
return async ()=>{
|
|
106
|
+
if (!this.agent) return this.buildTextResult('No active connection to disconnect');
|
|
107
|
+
try {
|
|
108
|
+
await this.agent.destroy?.();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
debug('Failed to destroy agent during disconnect:', error);
|
|
111
|
+
}
|
|
112
|
+
this.agent = void 0;
|
|
113
|
+
return this.buildTextResult(`Disconnected from ${platformName}`);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
94
116
|
constructor(){
|
|
95
117
|
_define_property(this, "mcpServer", void 0);
|
|
96
118
|
_define_property(this, "agent", void 0);
|
|
@@ -56,4 +56,24 @@ export declare abstract class BaseMidsceneTools<TAgent extends BaseAgent = BaseA
|
|
|
56
56
|
data: string;
|
|
57
57
|
mimeType: string;
|
|
58
58
|
}[];
|
|
59
|
+
/**
|
|
60
|
+
* Helper: Build a simple text result for tool responses
|
|
61
|
+
*/
|
|
62
|
+
protected buildTextResult(text: string): {
|
|
63
|
+
content: {
|
|
64
|
+
type: "text";
|
|
65
|
+
text: string;
|
|
66
|
+
}[];
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Create a disconnect handler for releasing platform resources
|
|
70
|
+
* @param platformName Human-readable platform name for the response message
|
|
71
|
+
* @returns Handler function that destroys the agent and returns appropriate response
|
|
72
|
+
*/
|
|
73
|
+
protected createDisconnectHandler(platformName: string): () => Promise<{
|
|
74
|
+
content: {
|
|
75
|
+
type: "text";
|
|
76
|
+
text: string;
|
|
77
|
+
}[];
|
|
78
|
+
}>;
|
|
59
79
|
}
|
package/package.json
CHANGED
package/src/mcp/base-tools.ts
CHANGED
|
@@ -169,4 +169,35 @@ export abstract class BaseMidsceneTools<TAgent extends BaseAgent = BaseAgent>
|
|
|
169
169
|
},
|
|
170
170
|
];
|
|
171
171
|
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Helper: Build a simple text result for tool responses
|
|
175
|
+
*/
|
|
176
|
+
protected buildTextResult(text: string) {
|
|
177
|
+
return {
|
|
178
|
+
content: [{ type: 'text' as const, text }],
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Create a disconnect handler for releasing platform resources
|
|
184
|
+
* @param platformName Human-readable platform name for the response message
|
|
185
|
+
* @returns Handler function that destroys the agent and returns appropriate response
|
|
186
|
+
*/
|
|
187
|
+
protected createDisconnectHandler(platformName: string) {
|
|
188
|
+
return async () => {
|
|
189
|
+
if (!this.agent) {
|
|
190
|
+
return this.buildTextResult('No active connection to disconnect');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
await this.agent.destroy?.();
|
|
195
|
+
} catch (error) {
|
|
196
|
+
debug('Failed to destroy agent during disconnect:', error);
|
|
197
|
+
}
|
|
198
|
+
this.agent = undefined;
|
|
199
|
+
|
|
200
|
+
return this.buildTextResult(`Disconnected from ${platformName}`);
|
|
201
|
+
};
|
|
202
|
+
}
|
|
172
203
|
}
|