doer-agent 0.6.7 → 0.6.9
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/mobile-mcp-server.js +73 -9
- package/package.json +1 -1
|
@@ -42,6 +42,23 @@ async function requestJson(path) {
|
|
|
42
42
|
}
|
|
43
43
|
return data;
|
|
44
44
|
}
|
|
45
|
+
async function postJson(path, body) {
|
|
46
|
+
const config = getConfig();
|
|
47
|
+
const response = await fetch(`${config.serverBaseUrl}${path}`, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: {
|
|
50
|
+
Authorization: `Bearer ${config.agentToken}`,
|
|
51
|
+
Accept: "application/json",
|
|
52
|
+
"Content-Type": "application/json",
|
|
53
|
+
},
|
|
54
|
+
body: JSON.stringify(body),
|
|
55
|
+
});
|
|
56
|
+
const data = await response.json().catch(() => ({}));
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
throw new Error(typeof data.error === "string" ? data.error : `Doer server returned ${response.status}`);
|
|
59
|
+
}
|
|
60
|
+
return data;
|
|
61
|
+
}
|
|
45
62
|
async function listMobileAgents() {
|
|
46
63
|
const config = getConfig();
|
|
47
64
|
const data = await requestJson(`/api/users/${encodeURIComponent(config.userId)}/agents/${encodeURIComponent(config.agentId)}/mobile-agents`);
|
|
@@ -64,6 +81,25 @@ async function getMobileInfo(deviceId) {
|
|
|
64
81
|
const resolvedDeviceId = await resolveDeviceId(deviceId);
|
|
65
82
|
return await requestJson(`/api/users/${encodeURIComponent(config.userId)}/agents/${encodeURIComponent(config.agentId)}/mobile-agents/${encodeURIComponent(resolvedDeviceId)}/info`);
|
|
66
83
|
}
|
|
84
|
+
async function getMobileActiveNotifications(deviceId) {
|
|
85
|
+
const config = getConfig();
|
|
86
|
+
const resolvedDeviceId = await resolveDeviceId(deviceId);
|
|
87
|
+
const data = await requestJson(`/api/users/${encodeURIComponent(config.userId)}/agents/${encodeURIComponent(config.agentId)}/mobile-agents/${encodeURIComponent(resolvedDeviceId)}/active-notifications`);
|
|
88
|
+
return {
|
|
89
|
+
...data,
|
|
90
|
+
notifications: Array.isArray(data.notifications) ? data.notifications : [],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
async function showMobileNotification(args) {
|
|
94
|
+
const config = getConfig();
|
|
95
|
+
const resolvedDeviceId = await resolveDeviceId(args.deviceId);
|
|
96
|
+
return await postJson(`/api/users/${encodeURIComponent(config.userId)}/agents/${encodeURIComponent(config.agentId)}/mobile-agents/${encodeURIComponent(resolvedDeviceId)}/show-notification`, {
|
|
97
|
+
title: args.title,
|
|
98
|
+
text: args.text,
|
|
99
|
+
notificationId: args.notificationId,
|
|
100
|
+
url: args.url,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
67
103
|
async function getMobileLogs(args) {
|
|
68
104
|
const config = getConfig();
|
|
69
105
|
const resolvedDeviceId = await resolveDeviceId(args.deviceId);
|
|
@@ -139,9 +175,9 @@ async function main() {
|
|
|
139
175
|
capabilities: {
|
|
140
176
|
tools: {},
|
|
141
177
|
},
|
|
142
|
-
instructions: "Inspect mobile
|
|
178
|
+
instructions: "Inspect and control mobile devices paired with the current Doer agent. Use list/get/read/search tools for device context, and show tools for user-visible mobile actions.",
|
|
143
179
|
});
|
|
144
|
-
server.registerTool("
|
|
180
|
+
server.registerTool("mobile_list_devices", {
|
|
145
181
|
description: "List mobile agents paired with the current Doer agent.",
|
|
146
182
|
inputSchema: {},
|
|
147
183
|
}, async () => {
|
|
@@ -151,7 +187,7 @@ async function main() {
|
|
|
151
187
|
structuredContent: { mobileAgents },
|
|
152
188
|
};
|
|
153
189
|
});
|
|
154
|
-
server.registerTool("
|
|
190
|
+
server.registerTool("mobile_get_device_info", {
|
|
155
191
|
description: "Read info for a mobile agent. Defaults to the first registered device.",
|
|
156
192
|
inputSchema: {
|
|
157
193
|
deviceId: z.string().optional().describe("Mobile device id. Defaults to the first registered mobile agent."),
|
|
@@ -163,7 +199,7 @@ async function main() {
|
|
|
163
199
|
structuredContent: result,
|
|
164
200
|
};
|
|
165
201
|
});
|
|
166
|
-
server.registerTool("
|
|
202
|
+
server.registerTool("mobile_read_event_logs", {
|
|
167
203
|
description: "Read a cursor-based page of mobile log events from the device-local SQLite log.",
|
|
168
204
|
inputSchema: {
|
|
169
205
|
afterSeq: z.number().int().min(0).optional().describe("Return events newer than this seq, in ascending order."),
|
|
@@ -178,7 +214,7 @@ async function main() {
|
|
|
178
214
|
structuredContent: page,
|
|
179
215
|
};
|
|
180
216
|
});
|
|
181
|
-
server.registerTool("
|
|
217
|
+
server.registerTool("mobile_search_event_logs", {
|
|
182
218
|
description: "Search the device-local mobile SQLite event log by kind, text query, cursor, and observed time range.",
|
|
183
219
|
inputSchema: {
|
|
184
220
|
afterSeq: z.number().int().min(0).optional().describe("Return matching events newer than this seq, in ascending order."),
|
|
@@ -197,7 +233,7 @@ async function main() {
|
|
|
197
233
|
structuredContent: page,
|
|
198
234
|
};
|
|
199
235
|
});
|
|
200
|
-
server.registerTool("
|
|
236
|
+
server.registerTool("mobile_get_latest_location", {
|
|
201
237
|
description: "Return the latest location event from recent mobile logs.",
|
|
202
238
|
inputSchema: {
|
|
203
239
|
deviceId: z.string().optional().describe("Mobile device id. Defaults to the first registered mobile agent."),
|
|
@@ -211,7 +247,7 @@ async function main() {
|
|
|
211
247
|
structuredContent: { location },
|
|
212
248
|
};
|
|
213
249
|
});
|
|
214
|
-
server.registerTool("
|
|
250
|
+
server.registerTool("mobile_search_location_logs", {
|
|
215
251
|
description: "Return time-range location events recorded by the mobile agent.",
|
|
216
252
|
inputSchema: {
|
|
217
253
|
afterSeq: z.number().int().min(0).optional().describe("Return location events newer than this seq, in ascending order."),
|
|
@@ -230,8 +266,36 @@ async function main() {
|
|
|
230
266
|
structuredContent: result,
|
|
231
267
|
};
|
|
232
268
|
});
|
|
233
|
-
server.registerTool("
|
|
234
|
-
description: "Return
|
|
269
|
+
server.registerTool("mobile_get_active_notifications", {
|
|
270
|
+
description: "Return the current active notification snapshot from a mobile device without storing it in the log.",
|
|
271
|
+
inputSchema: {
|
|
272
|
+
deviceId: z.string().optional().describe("Mobile device id. Defaults to the first registered mobile agent."),
|
|
273
|
+
},
|
|
274
|
+
}, async ({ deviceId }) => {
|
|
275
|
+
const snapshot = await getMobileActiveNotifications(deviceId);
|
|
276
|
+
return {
|
|
277
|
+
content: [{ type: "text", text: formatJson(snapshot) }],
|
|
278
|
+
structuredContent: snapshot,
|
|
279
|
+
};
|
|
280
|
+
});
|
|
281
|
+
server.registerTool("mobile_show_alert_notification", {
|
|
282
|
+
description: "Show a high-priority notification on a mobile device through the Doer mobile agent.",
|
|
283
|
+
inputSchema: {
|
|
284
|
+
deviceId: z.string().optional().describe("Mobile device id. Defaults to the first registered mobile agent."),
|
|
285
|
+
title: z.string().min(1).describe("Notification title."),
|
|
286
|
+
text: z.string().min(1).describe("Notification body text."),
|
|
287
|
+
url: z.string().nullable().optional().describe("Optional URL or deep link to open when the notification is tapped."),
|
|
288
|
+
notificationId: z.number().int().optional().describe("Optional Android notification id. Reusing an id updates the existing notification."),
|
|
289
|
+
},
|
|
290
|
+
}, async ({ deviceId, title, text, url, notificationId }) => {
|
|
291
|
+
const result = await showMobileNotification({ deviceId, title, text, url, notificationId });
|
|
292
|
+
return {
|
|
293
|
+
content: [{ type: "text", text: formatJson(result) }],
|
|
294
|
+
structuredContent: result,
|
|
295
|
+
};
|
|
296
|
+
});
|
|
297
|
+
server.registerTool("mobile_search_notification_logs", {
|
|
298
|
+
description: "Return recent notification events stored in mobile logs.",
|
|
235
299
|
inputSchema: {
|
|
236
300
|
deviceId: z.string().optional().describe("Mobile device id. Defaults to the first registered mobile agent."),
|
|
237
301
|
limit: z.number().int().min(1).max(1000).optional().describe("How many recent events to scan."),
|