doer-agent 0.6.9 → 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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doer-agent",
3
- "version": "0.6.9",
3
+ "version": "0.7.0",
4
4
  "description": "Reverse-polling agent runtime for doer",
5
5
  "type": "module",
6
6
  "main": "dist/agent.js",