Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions templates/assets/actions/edit-image.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ describe("edit-image", () => {
});

it("delegates to generate-image as a source-guided full-image edit", async () => {
await action.run({
assetId: "asset-target",
instruction: "Make the background navy",
tier: "fast",
source: "chat",
});
await action.run(
{
assetId: "asset-target",
instruction: "Make the background navy",
tier: "fast",
source: "chat",
},
{ threadId: "thread-9" } as any,
);

expect(generateImageRunMock).toHaveBeenCalledWith(
expect.objectContaining({
Expand All @@ -52,7 +55,9 @@ describe("edit-image", () => {
groundingMode: "off",
includeLogo: false,
tier: "fast",
appendVariant: true,
}),
{ threadId: "thread-9" },
);
});
});
43 changes: 24 additions & 19 deletions templates/assets/actions/edit-image.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineAction } from "@agent-native/core";
import type { ActionRunContext } from "@agent-native/core/action";
import { z } from "zod";

import { IMAGE_MODELS, IMAGE_QUALITY_TIERS } from "../shared/api.js";
Expand All @@ -23,25 +24,29 @@ export default defineAction({
),
}),
parallelSafe: true,
run: async (args) => {
run: async (args, context?: ActionRunContext) => {
const asset = await getAssetOrThrow(args.assetId);
return generateImage.run({
libraryId: asset.libraryId,
collectionId: asset.collectionId ?? undefined,
prompt: args.instruction,
aspectRatio: (asset.aspectRatio ?? "16:9") as any,
imageSize: (asset.imageSize ?? "2K") as any,
model: args.model,
tier: args.tier,
intent: "edit",
styleStrength: "balanced",
referenceAssetIds: [],
includeLogo: false,
groundingMode: "off",
subjectAssetId: asset.id,
slotId: args.slotId,
source: args.source,
callerAppId: args.callerAppId,
});
return generateImage.run(
{
libraryId: asset.libraryId,
collectionId: asset.collectionId ?? undefined,
prompt: args.instruction,
aspectRatio: (asset.aspectRatio ?? "16:9") as any,
imageSize: (asset.imageSize ?? "2K") as any,
model: args.model,
tier: args.tier,
intent: "edit",
styleStrength: "balanced",
referenceAssetIds: [],
includeLogo: false,
groundingMode: "off",
subjectAssetId: asset.id,
slotId: args.slotId,
source: args.source,
callerAppId: args.callerAppId,
appendVariant: true,
},
context,
);
},
});
Loading
Loading