doer-agent 0.6.8 → 0.7.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.
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
import { StringCodec } from "nats";
|
|
2
2
|
const codexAppRpcCodec = StringCodec();
|
|
3
|
+
function recordValue(value) {
|
|
4
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
5
|
+
}
|
|
6
|
+
function stripLargeThreadTurnItemFields(method, value) {
|
|
7
|
+
if (method !== "thread/turns/list") {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
const response = recordValue(value);
|
|
11
|
+
if (!response || !Array.isArray(response.data)) {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
...response,
|
|
16
|
+
data: response.data.map((turnValue) => {
|
|
17
|
+
const turn = recordValue(turnValue);
|
|
18
|
+
if (!turn || !Array.isArray(turn.items)) {
|
|
19
|
+
return turnValue;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
...turn,
|
|
23
|
+
items: turn.items.map((itemValue) => {
|
|
24
|
+
const item = recordValue(itemValue);
|
|
25
|
+
if (!item || item.type !== "imageGeneration" || typeof item.result !== "string") {
|
|
26
|
+
return itemValue;
|
|
27
|
+
}
|
|
28
|
+
const withoutResult = { ...item };
|
|
29
|
+
delete withoutResult.result;
|
|
30
|
+
return withoutResult;
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
3
36
|
function normalizeCodexAppRpcRequest(args) {
|
|
4
37
|
const requestId = typeof args.request.requestId === "string" ? args.request.requestId.trim() : "";
|
|
5
38
|
const requestAgentId = typeof args.request.agentId === "string" ? args.request.agentId.trim() : "";
|
|
@@ -21,7 +54,7 @@ async function handleCodexAppRpcMessage(args) {
|
|
|
21
54
|
const payload = JSON.parse(codexAppRpcCodec.decode(args.msg.data));
|
|
22
55
|
const request = normalizeCodexAppRpcRequest({ request: payload, agentId: args.agentId });
|
|
23
56
|
requestId = request.requestId;
|
|
24
|
-
const result = await args.manager.request(request.method, request.params);
|
|
57
|
+
const result = stripLargeThreadTurnItemFields(request.method, await args.manager.request(request.method, request.params));
|
|
25
58
|
args.msg.respond(codexAppRpcCodec.encode(JSON.stringify({
|
|
26
59
|
requestId,
|
|
27
60
|
ok: true,
|
|
@@ -97,6 +97,7 @@ async function showMobileNotification(args) {
|
|
|
97
97
|
title: args.title,
|
|
98
98
|
text: args.text,
|
|
99
99
|
notificationId: args.notificationId,
|
|
100
|
+
url: args.url,
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
async function getMobileLogs(args) {
|
|
@@ -283,10 +284,11 @@ async function main() {
|
|
|
283
284
|
deviceId: z.string().optional().describe("Mobile device id. Defaults to the first registered mobile agent."),
|
|
284
285
|
title: z.string().min(1).describe("Notification title."),
|
|
285
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."),
|
|
286
288
|
notificationId: z.number().int().optional().describe("Optional Android notification id. Reusing an id updates the existing notification."),
|
|
287
289
|
},
|
|
288
|
-
}, async ({ deviceId, title, text, notificationId }) => {
|
|
289
|
-
const result = await showMobileNotification({ deviceId, title, text, notificationId });
|
|
290
|
+
}, async ({ deviceId, title, text, url, notificationId }) => {
|
|
291
|
+
const result = await showMobileNotification({ deviceId, title, text, url, notificationId });
|
|
290
292
|
return {
|
|
291
293
|
content: [{ type: "text", text: formatJson(result) }],
|
|
292
294
|
structuredContent: result,
|