doer-agent 0.2.9 → 0.3.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.
Files changed (2) hide show
  1. package/dist/agent.js +42 -4
  2. package/package.json +1 -1
package/dist/agent.js CHANGED
@@ -286,6 +286,25 @@ function normalizeEnvPatch(value) {
286
286
  }
287
287
  return out;
288
288
  }
289
+ function normalizeRunImagePaths(value) {
290
+ if (!Array.isArray(value)) {
291
+ return [];
292
+ }
293
+ const seen = new Set();
294
+ const out = [];
295
+ for (const item of value) {
296
+ if (typeof item !== "string") {
297
+ continue;
298
+ }
299
+ const normalized = item.trim();
300
+ if (!normalized || seen.has(normalized)) {
301
+ continue;
302
+ }
303
+ seen.add(normalized);
304
+ out.push(normalized);
305
+ }
306
+ return out;
307
+ }
289
308
  async function prepareTaskRuntimeConfig(args) {
290
309
  const bundle = await postJson(`${args.serverBaseUrl}/api/agent/tasks/${encodeURIComponent(args.taskId)}/runtime-config`, {
291
310
  userId: args.userId,
@@ -408,6 +427,7 @@ function normalizeRunRpcRequest(args) {
408
427
  }
409
428
  const runId = typeof args.request.runId === "string" && args.request.runId.trim() ? args.request.runId.trim() : null;
410
429
  const prompt = typeof args.request.prompt === "string" && args.request.prompt.trim() ? args.request.prompt.trim() : null;
430
+ const imagePaths = normalizeRunImagePaths(args.request.imagePaths);
411
431
  const sessionId = typeof args.request.sessionId === "string" && args.request.sessionId.trim() ? args.request.sessionId.trim() : null;
412
432
  const model = normalizeCodexModel(args.request.model);
413
433
  if (action === "start" && !prompt) {
@@ -426,6 +446,7 @@ function normalizeRunRpcRequest(args) {
426
446
  action,
427
447
  runId,
428
448
  prompt,
449
+ imagePaths,
429
450
  sessionId,
430
451
  model,
431
452
  cwd,
@@ -1185,13 +1206,14 @@ function normalizeCodexModel(value) {
1185
1206
  function buildManagedCodexArgs(args) {
1186
1207
  const promptArgs = ["--", args.prompt];
1187
1208
  const fixedArgs = ["--dangerously-bypass-approvals-and-sandbox"];
1209
+ const imageArgs = args.imagePaths.flatMap((imagePath) => ["--image", imagePath]);
1188
1210
  return [
1189
1211
  ...fixedArgs,
1190
1212
  "--model",
1191
1213
  args.model,
1192
1214
  ...(args.sessionId
1193
- ? ["exec", "resume", "--json", args.sessionId, ...promptArgs]
1194
- : ["exec", "--json", ...promptArgs]),
1215
+ ? ["exec", "resume", "--json", ...imageArgs, args.sessionId, ...promptArgs]
1216
+ : ["exec", "--json", ...imageArgs, ...promptArgs]),
1195
1217
  ];
1196
1218
  }
1197
1219
  function buildLocalCodexCliCommand(args) {
@@ -1962,6 +1984,7 @@ async function handleRunRpcMessage(args) {
1962
1984
  sessionId: request.sessionId,
1963
1985
  codexArgs: buildManagedCodexArgs({
1964
1986
  prompt: request.prompt ?? "",
1987
+ imagePaths: request.imagePaths,
1965
1988
  sessionId: request.sessionId,
1966
1989
  model: request.model,
1967
1990
  }),
@@ -2611,9 +2634,19 @@ function sanitizeSessionRpcRawLine(line) {
2611
2634
  }
2612
2635
  try {
2613
2636
  const parsed = JSON.parse(line);
2614
- if (!isObjectRecord(parsed) || !isObjectRecord(parsed.payload) || parsed.type !== "response_item") {
2637
+ if (!isObjectRecord(parsed)) {
2638
+ return line;
2639
+ }
2640
+ if (parsed.type === "compacted" || parsed.type === "turn_context" || parsed.type === "session_meta") {
2641
+ return null;
2642
+ }
2643
+ if (!isObjectRecord(parsed.payload) || parsed.type !== "response_item") {
2615
2644
  return line;
2616
2645
  }
2646
+ const payloadType = typeof parsed.payload.type === "string" ? parsed.payload.type : "";
2647
+ if (payloadType === "message" || payloadType === "reasoning") {
2648
+ return null;
2649
+ }
2617
2650
  return JSON.stringify({
2618
2651
  ...parsed,
2619
2652
  payload: sanitizeSessionRpcPayload(parsed.payload),
@@ -3007,9 +3040,14 @@ async function getAgentSessionRawRows(args) {
3007
3040
  let lineNumber = startLineIndex + 1;
3008
3041
  for (const line of lines) {
3009
3042
  if (line.trim()) {
3043
+ const sanitized = sanitizeSessionRpcRawLine(line);
3044
+ if (!sanitized) {
3045
+ lineNumber += 1;
3046
+ continue;
3047
+ }
3010
3048
  rawRows.push({
3011
3049
  id: lineNumber,
3012
- raw: sanitizeSessionRpcRawLine(line),
3050
+ raw: sanitized,
3013
3051
  });
3014
3052
  }
3015
3053
  lineNumber += 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doer-agent",
3
- "version": "0.2.9",
3
+ "version": "0.3.0",
4
4
  "description": "Reverse-polling agent runtime for doer",
5
5
  "type": "module",
6
6
  "main": "dist/agent.js",