feat: publish Agent Studio integrations and setup guide
This commit is contained in:
@@ -13,10 +13,43 @@ async function fixture() {
|
||||
const image = await attachments.add("ses_1", { name: "pixel.png", mediaType: "image/png", stream: Readable.from(Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAACXBIWXMAAAPoAAAD6AG1e1JrAAAAE0lEQVQImWP4z8DwnwGM/zMwAAAf7gP9qS/A4gAAAABJRU5ErkJggg==", "base64")) });
|
||||
const service = new ImageVideoService({ root: join(root, "tasks"), attachments, remote: {} as never, collect: () => Promise.reject(new Error("No external operations permitted")) });
|
||||
const dependencies = { imageVideo: service, sessionRegistry: { get: (id: string) => id === "ses_1" ? { sessionId: id } : undefined, disposeAll: async () => {} }, skillCatalog: { list: () => [] }, modelStore: {}, attachmentStore: attachments, approvalBroker: {} } as unknown as AppDependencies;
|
||||
return { app: buildApp(dependencies), service, draft: { attachmentId: image.attachmentId, title: "Reference", prompt: "Natural motion and ambient sound", durationSeconds: 10 } };
|
||||
return { app: buildApp(dependencies), service, dependencies, draft: { attachmentId: image.attachmentId, title: "Reference", prompt: "Natural motion and ambient sound", durationSeconds: 10 } };
|
||||
}
|
||||
|
||||
describe("image video local API", () => {
|
||||
it("does not persist a target session that disappeared during continuation", async () => {
|
||||
const { app, service, dependencies, draft } = await fixture();
|
||||
const task = await service.create("ses_1", draft);
|
||||
let lookups = 0;
|
||||
dependencies.sessionRegistry.get = id => id === "ses_new" && lookups++ === 0 ? { sessionId: id } as never : undefined;
|
||||
try {
|
||||
const result = await app.inject({ method: "POST", url: `/api/sessions/ses_new/image-video/tasks/${task.id}/continue`, payload: { confirmed: true, expectedRevision: 0 } });
|
||||
expect(result.statusCode).toBe(404);
|
||||
expect((await service.owned("ses_1", task.id)).revision).toBe(0);
|
||||
} finally { await app.close(); }
|
||||
});
|
||||
it("requires an explicit same-origin confirmation to continue an orphaned task in a live session", async () => {
|
||||
const { app, service, dependencies, draft } = await fixture();
|
||||
const task = await service.create("ses_1", draft);
|
||||
const liveSession = { sessionId: "ses_new" } as never;
|
||||
dependencies.sessionRegistry.get = id => id === "ses_new" ? liveSession : undefined;
|
||||
const url = `/api/sessions/ses_new/image-video/tasks/${task.id}/continue`;
|
||||
const payload = { confirmed: true, expectedRevision: 0 };
|
||||
try {
|
||||
expect((await app.inject({ method: "POST", url, payload: { expectedRevision: 0 } })).statusCode).toBe(400);
|
||||
expect((await app.inject({ method: "POST", url, payload: { ...payload, confirmed: false } })).statusCode).toBe(400);
|
||||
expect((await app.inject({ method: "POST", url, payload, headers: { origin: "https://evil.example" } })).statusCode).toBeGreaterThanOrEqual(400);
|
||||
expect((await app.inject({ method: "POST", url, payload, headers: { "sec-fetch-site": "cross-site" } })).statusCode).toBeGreaterThanOrEqual(400);
|
||||
expect((await app.inject({ method: "POST", url: url.replace("ses_new", "ses_unknown"), payload })).statusCode).toBe(404);
|
||||
expect((await app.inject({ method: "POST", url, payload: { ...payload, prompt: "changed" } })).statusCode).toBe(400);
|
||||
await expect(service.owned("ses_new", task.id)).rejects.toMatchObject({ code: "I2V_TASK_NOT_FOUND" });
|
||||
const result = await app.inject({ method: "POST", url, payload });
|
||||
expect(result.statusCode).toBe(200);
|
||||
expect(result.json<{ task: ImageVideoPublicTask }>().task).toMatchObject({ id: task.id, state: "draft", revision: 1 });
|
||||
expect((await service.owned("ses_new", task.id)).prompt).toBe(draft.prompt);
|
||||
expect((await service.list())).toHaveLength(1);
|
||||
} finally { await app.close(); }
|
||||
});
|
||||
it("creates locally, persists history independently from Sessions and serves registered reference ranges", async () => {
|
||||
const { app, service, draft } = await fixture();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user