@agentrouter-top/relay-dsh-plugin-codex 0.2.2-agentrouter.4 → 0.2.2-agentrouter.6

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.
@@ -2908,7 +2908,7 @@ var CodexDshAdapter = class extends LlmAdapter {
2908
2908
  this.appendActivity(agent, threadId, turnId, withCommandOutput(state, key, item), "completed", state);
2909
2909
  return [];
2910
2910
  }
2911
- if (isCodexActivityItem(item)) this.appendActivity(agent, threadId, turnId, item, "completed", state);
2911
+ if (isCodexActivityItem(item) && item.type !== "imageGeneration") this.appendActivity(agent, threadId, turnId, item, "completed", state);
2912
2912
  if (item.type === "mcpToolCall" && item.status === "completed") {
2913
2913
  const images = (Array.isArray(item.result?.content) ? item.result.content : []).map((entry, contentIndex) => ({
2914
2914
  entry,
@@ -2959,11 +2959,22 @@ var CodexDshAdapter = class extends LlmAdapter {
2959
2959
  return chunks;
2960
2960
  }
2961
2961
  if (item.type === "imageGeneration" || item.type === "imageView") {
2962
- if (!this.attachments) return [];
2962
+ if (!this.attachments || item.type === "imageGeneration" && [
2963
+ "failed",
2964
+ "cancelled",
2965
+ "canceled"
2966
+ ].includes(item.status)) {
2967
+ if (item.type === "imageGeneration") this.appendActivity(agent, threadId, turnId, {
2968
+ ...item,
2969
+ status: "failed"
2970
+ }, "completed", state);
2971
+ return [];
2972
+ }
2963
2973
  const roots = [resolve(agent.session.header.cwd ?? process.cwd()), resolve(this.codexHome ?? resolve(homedir(), ".codex"), "generated_images")];
2964
2974
  const index = state.nextIndex++;
2965
2975
  try {
2966
2976
  const attachment = item.type === "imageGeneration" ? await importCodexGeneratedImage(item, roots, this.attachments) : await importCodexImage(item.path, roots, this.attachments);
2977
+ if (item.type === "imageGeneration") this.appendActivity(agent, threadId, turnId, item, "completed", state, attachment.attachmentId);
2967
2978
  return [{
2968
2979
  type: "block-start",
2969
2980
  index,
@@ -2977,6 +2988,10 @@ var CodexDshAdapter = class extends LlmAdapter {
2977
2988
  }
2978
2989
  }];
2979
2990
  } catch (error) {
2991
+ if (item.type === "imageGeneration") this.appendActivity(agent, threadId, turnId, {
2992
+ ...item,
2993
+ status: "failed"
2994
+ }, "completed", state);
2980
2995
  const label = basename(item.path ?? item.savedPath ?? `codex-${item.id}`);
2981
2996
  const reason = imagePreviewFailureReason(error);
2982
2997
  this.logger.warn?.("Codex image preview unavailable", {
@@ -3002,7 +3017,7 @@ var CodexDshAdapter = class extends LlmAdapter {
3002
3017
  }
3003
3018
  return [];
3004
3019
  }
3005
- appendActivity(agent, threadId, turnId, item, phase, state) {
3020
+ appendActivity(agent, threadId, turnId, item, phase, state, imageAttachmentId) {
3006
3021
  const id = activityItemId(item);
3007
3022
  if (!id) return;
3008
3023
  const merged = mergeActivityItem(state.activityItems.get(id) ?? {}, item);
@@ -3041,7 +3056,7 @@ var CodexDshAdapter = class extends LlmAdapter {
3041
3056
  state.startedActivities.add(id);
3042
3057
  }
3043
3058
  if (phase === "completed" && !state.completedActivities.has(id)) {
3044
- const payload = activityPayload(threadId, turnId, merged, "completed");
3059
+ const payload = activityPayload(threadId, turnId, merged, "completed", imageAttachmentId);
3045
3060
  const callId = toolCallId(`relay-codex:${JSON.stringify([
3046
3061
  threadId,
3047
3062
  turnId,
@@ -3379,8 +3394,12 @@ function permissionConfiguration(events) {
3379
3394
  function reasoningText(item) {
3380
3395
  return [...item.summary ?? [], ...item.content ?? []].filter(Boolean).join("\n\n");
3381
3396
  }
3382
- function activityPayload(threadId, turnId, item, phase) {
3397
+ function activityPayload(threadId, turnId, item, phase, imageAttachmentId) {
3383
3398
  const activity = normalizeCodexActivity(item, phase);
3399
+ if (item.type === "imageGeneration") activity.imageGeneration = {
3400
+ version: 1,
3401
+ ...typeof imageAttachmentId === "string" ? { attachmentId: imageAttachmentId } : {}
3402
+ };
3384
3403
  return {
3385
3404
  version: 1,
3386
3405
  threadId,