@framers/agentos 0.13.58 → 0.13.60
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.
- package/dist/api/transferStyle.d.ts +34 -23
- package/dist/api/transferStyle.d.ts.map +1 -1
- package/dist/api/transferStyle.js +78 -84
- package/dist/api/transferStyle.js.map +1 -1
- package/dist/api/types.d.ts +24 -12
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js.map +1 -1
- package/dist/core/llm/providers/implementations/GeminiCLIProvider.d.ts +9 -8
- package/dist/core/llm/providers/implementations/GeminiCLIProvider.d.ts.map +1 -1
- package/dist/core/llm/providers/implementations/GeminiCLIProvider.js +9 -8
- package/dist/core/llm/providers/implementations/GeminiCLIProvider.js.map +1 -1
- package/dist/io/media/images/IImageProvider.d.ts +45 -0
- package/dist/io/media/images/IImageProvider.d.ts.map +1 -1
- package/dist/io/media/images/IImageProvider.js.map +1 -1
- package/dist/io/media/images/PolicyAwareImageRouter.d.ts +1 -1
- package/dist/io/media/images/PolicyAwareImageRouter.js +4 -4
- package/dist/io/media/images/PolicyAwareImageRouter.js.map +1 -1
- package/dist/io/media/images/blobPart.d.ts +37 -3
- package/dist/io/media/images/blobPart.d.ts.map +1 -1
- package/dist/io/media/images/blobPart.js +49 -3
- package/dist/io/media/images/blobPart.js.map +1 -1
- package/dist/io/media/images/providers/FalImageProvider.d.ts +38 -1
- package/dist/io/media/images/providers/FalImageProvider.d.ts.map +1 -1
- package/dist/io/media/images/providers/FalImageProvider.js +105 -7
- package/dist/io/media/images/providers/FalImageProvider.js.map +1 -1
- package/dist/io/media/images/providers/OpenAIImageProvider.d.ts +47 -1
- package/dist/io/media/images/providers/OpenAIImageProvider.d.ts.map +1 -1
- package/dist/io/media/images/providers/OpenAIImageProvider.js +118 -4
- package/dist/io/media/images/providers/OpenAIImageProvider.js.map +1 -1
- package/dist/io/media/images/providers/ReplicateImageProvider.d.ts +57 -1
- package/dist/io/media/images/providers/ReplicateImageProvider.d.ts.map +1 -1
- package/dist/io/media/images/providers/ReplicateImageProvider.js +149 -31
- package/dist/io/media/images/providers/ReplicateImageProvider.js.map +1 -1
- package/dist/io/media/images/providers/StabilityImageProvider.d.ts +33 -1
- package/dist/io/media/images/providers/StabilityImageProvider.d.ts.map +1 -1
- package/dist/io/media/images/providers/StabilityImageProvider.js +132 -5
- package/dist/io/media/images/providers/StabilityImageProvider.js.map +1 -1
- package/dist/io/media/images/styleTransfer.d.ts +67 -0
- package/dist/io/media/images/styleTransfer.d.ts.map +1 -0
- package/dist/io/media/images/styleTransfer.js +78 -0
- package/dist/io/media/images/styleTransfer.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file styleTransfer.ts
|
|
3
|
+
* What the providers' style transfers share: the prompt an editing model is
|
|
4
|
+
* sent, the check of the two images' formats, and the refusal of a model a
|
|
5
|
+
* provider's style transfer cannot run.
|
|
6
|
+
*
|
|
7
|
+
* OpenAI's edits endpoint and the FLUX.2 models change images by instruction
|
|
8
|
+
* and take no strength, so a style transfer sends them an instruction that
|
|
9
|
+
* names the two images, then the caller's prompt. `strength` picks the
|
|
10
|
+
* instruction, as `variance` picks the prompt of OpenAI's variations: below
|
|
11
|
+
* 0.5 a light restyle that keeps most of the source's own colours, otherwise
|
|
12
|
+
* a full one.
|
|
13
|
+
*/
|
|
14
|
+
import { type ImagePartType } from './blobPart.js';
|
|
15
|
+
/** The strength a style transfer uses when the call gives none. */
|
|
16
|
+
export declare const STYLE_TRANSFER_DEFAULT_STRENGTH = 0.7;
|
|
17
|
+
/** How a model is told which image is which: by index for FLUX.2, in words for OpenAI. */
|
|
18
|
+
export interface StyleTransferImageNames {
|
|
19
|
+
/** The image to restyle, sent first. */
|
|
20
|
+
source: string;
|
|
21
|
+
/** The image whose style is applied, sent second. */
|
|
22
|
+
style: string;
|
|
23
|
+
}
|
|
24
|
+
/** FLUX.2's names: "point to other reference images by their index number" (https://replicate.com/black-forest-labs/flux-2-pro). */
|
|
25
|
+
export declare const INDEXED_IMAGE_NAMES: StyleTransferImageNames;
|
|
26
|
+
/** OpenAI's names, in the order the images are sent. */
|
|
27
|
+
export declare const ORDINAL_IMAGE_NAMES: StyleTransferImageNames;
|
|
28
|
+
/**
|
|
29
|
+
* The instruction alone, for a strength from 0 to 1 (default 0.7).
|
|
30
|
+
*
|
|
31
|
+
* @param strength - How much of the reference's style to apply.
|
|
32
|
+
* @param names - How the model is told which image is which.
|
|
33
|
+
*/
|
|
34
|
+
export declare function styleTransferInstruction(strength: number | undefined, names: StyleTransferImageNames): string;
|
|
35
|
+
/**
|
|
36
|
+
* The prompt for a style transfer on an editing model: the instruction, then
|
|
37
|
+
* the caller's prompt when it has text.
|
|
38
|
+
*
|
|
39
|
+
* @param prompt - The caller's prompt.
|
|
40
|
+
* @param strength - How much of the reference's style to apply.
|
|
41
|
+
* @param names - How the model is told which image is which.
|
|
42
|
+
*/
|
|
43
|
+
export declare function styleTransferPrompt(prompt: string, strength: number | undefined, names: StyleTransferImageNames): string;
|
|
44
|
+
/**
|
|
45
|
+
* The formats of the two images, checked against those a provider takes.
|
|
46
|
+
*
|
|
47
|
+
* @param provider - The provider's name, for the error.
|
|
48
|
+
* @param accepted - The formats it takes, by media type.
|
|
49
|
+
* @param image - The source.
|
|
50
|
+
* @param styleImage - The style reference.
|
|
51
|
+
* @returns Each image's format.
|
|
52
|
+
* @throws {Error} When either image is not a PNG, JPEG, WebP or GIF, or is a
|
|
53
|
+
* format the provider does not take.
|
|
54
|
+
*/
|
|
55
|
+
export declare function styleTransferImageTypes(provider: string, accepted: readonly ImagePartType['mimeType'][], image: Buffer, styleImage: Buffer): {
|
|
56
|
+
image: ImagePartType;
|
|
57
|
+
style: ImagePartType;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The error for a model outside a provider's style-transfer models.
|
|
61
|
+
*
|
|
62
|
+
* @param provider - The provider's name.
|
|
63
|
+
* @param model - The model the call named.
|
|
64
|
+
* @param models - The models it runs, the default first.
|
|
65
|
+
*/
|
|
66
|
+
export declare function styleTransferModelError(provider: string, model: string, models: readonly string[]): Error;
|
|
67
|
+
//# sourceMappingURL=styleTransfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styleTransfer.d.ts","sourceRoot":"","sources":["../../../../src/io/media/images/styleTransfer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAmC,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEpF,mEAAmE;AACnE,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAEnD,0FAA0F;AAC1F,MAAM,WAAW,uBAAuB;IACtC,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,oIAAoI;AACpI,eAAO,MAAM,mBAAmB,EAAE,uBAAiE,CAAC;AAEpG,wDAAwD;AACxD,eAAO,MAAM,mBAAmB,EAAE,uBAAkF,CAAC;AAErH;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAK7G;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAIxH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,SAAS,aAAa,CAAC,UAAU,CAAC,EAAE,EAC9C,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,GACjB;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,aAAa,CAAA;CAAE,CAYhD;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,CAIzG"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file styleTransfer.ts
|
|
3
|
+
* What the providers' style transfers share: the prompt an editing model is
|
|
4
|
+
* sent, the check of the two images' formats, and the refusal of a model a
|
|
5
|
+
* provider's style transfer cannot run.
|
|
6
|
+
*
|
|
7
|
+
* OpenAI's edits endpoint and the FLUX.2 models change images by instruction
|
|
8
|
+
* and take no strength, so a style transfer sends them an instruction that
|
|
9
|
+
* names the two images, then the caller's prompt. `strength` picks the
|
|
10
|
+
* instruction, as `variance` picks the prompt of OpenAI's variations: below
|
|
11
|
+
* 0.5 a light restyle that keeps most of the source's own colours, otherwise
|
|
12
|
+
* a full one.
|
|
13
|
+
*/
|
|
14
|
+
import { IMAGE_PART_TYPES, imagePartType } from './blobPart.js';
|
|
15
|
+
/** The strength a style transfer uses when the call gives none. */
|
|
16
|
+
export const STYLE_TRANSFER_DEFAULT_STRENGTH = 0.7;
|
|
17
|
+
/** FLUX.2's names: "point to other reference images by their index number" (https://replicate.com/black-forest-labs/flux-2-pro). */
|
|
18
|
+
export const INDEXED_IMAGE_NAMES = { source: 'image 1', style: 'image 2' };
|
|
19
|
+
/** OpenAI's names, in the order the images are sent. */
|
|
20
|
+
export const ORDINAL_IMAGE_NAMES = { source: 'the first image', style: 'the second image' };
|
|
21
|
+
/**
|
|
22
|
+
* The instruction alone, for a strength from 0 to 1 (default 0.7).
|
|
23
|
+
*
|
|
24
|
+
* @param strength - How much of the reference's style to apply.
|
|
25
|
+
* @param names - How the model is told which image is which.
|
|
26
|
+
*/
|
|
27
|
+
export function styleTransferInstruction(strength, names) {
|
|
28
|
+
const { source, style } = names;
|
|
29
|
+
return (strength ?? STYLE_TRANSFER_DEFAULT_STRENGTH) < 0.5
|
|
30
|
+
? `Restyle ${source} lightly after ${style}: keep ${source}'s subject, composition, pose and most of its own colours, and take ${style}'s texture, brushwork and lighting.`
|
|
31
|
+
: `Restyle ${source} in the style of ${style}: keep ${source}'s subject, composition and pose, and take ${style}'s palette, brushwork, texture, lighting and medium.`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The prompt for a style transfer on an editing model: the instruction, then
|
|
35
|
+
* the caller's prompt when it has text.
|
|
36
|
+
*
|
|
37
|
+
* @param prompt - The caller's prompt.
|
|
38
|
+
* @param strength - How much of the reference's style to apply.
|
|
39
|
+
* @param names - How the model is told which image is which.
|
|
40
|
+
*/
|
|
41
|
+
export function styleTransferPrompt(prompt, strength, names) {
|
|
42
|
+
const instruction = styleTransferInstruction(strength, names);
|
|
43
|
+
const text = prompt.trim();
|
|
44
|
+
return text ? `${instruction} ${text}` : instruction;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The formats of the two images, checked against those a provider takes.
|
|
48
|
+
*
|
|
49
|
+
* @param provider - The provider's name, for the error.
|
|
50
|
+
* @param accepted - The formats it takes, by media type.
|
|
51
|
+
* @param image - The source.
|
|
52
|
+
* @param styleImage - The style reference.
|
|
53
|
+
* @returns Each image's format.
|
|
54
|
+
* @throws {Error} When either image is not a PNG, JPEG, WebP or GIF, or is a
|
|
55
|
+
* format the provider does not take.
|
|
56
|
+
*/
|
|
57
|
+
export function styleTransferImageTypes(provider, accepted, image, styleImage) {
|
|
58
|
+
const check = (bytes, which) => {
|
|
59
|
+
const type = imagePartType(bytes);
|
|
60
|
+
if (!type || !accepted.includes(type.mimeType)) {
|
|
61
|
+
const formats = accepted.map((mimeType) => IMAGE_PART_TYPES[mimeType].name).join(', ');
|
|
62
|
+
throw new Error(`${provider}'s style transfer takes ${formats}; the ${which} is ${type ? type.name : 'not a JPEG, PNG, WebP or GIF image'}.`);
|
|
63
|
+
}
|
|
64
|
+
return type;
|
|
65
|
+
};
|
|
66
|
+
return { image: check(image, 'source'), style: check(styleImage, 'style reference') };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The error for a model outside a provider's style-transfer models.
|
|
70
|
+
*
|
|
71
|
+
* @param provider - The provider's name.
|
|
72
|
+
* @param model - The model the call named.
|
|
73
|
+
* @param models - The models it runs, the default first.
|
|
74
|
+
*/
|
|
75
|
+
export function styleTransferModelError(provider, model, models) {
|
|
76
|
+
return new Error(`${provider}'s style transfer runs on ${models.join(', ')} (${models[0]} by default); ${model} is not one of them. A custom baseUrl takes any model name.`);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=styleTransfer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styleTransfer.js","sourceRoot":"","sources":["../../../../src/io/media/images/styleTransfer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAsB,MAAM,eAAe,CAAC;AAEpF,mEAAmE;AACnE,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,CAAC;AAUnD,oIAAoI;AACpI,MAAM,CAAC,MAAM,mBAAmB,GAA4B,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAEpG,wDAAwD;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAA4B,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC;AAErH;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAA4B,EAAE,KAA8B;IACnG,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAChC,OAAO,CAAC,QAAQ,IAAI,+BAA+B,CAAC,GAAG,GAAG;QACxD,CAAC,CAAC,WAAW,MAAM,kBAAkB,KAAK,UAAU,MAAM,uEAAuE,KAAK,qCAAqC;QAC3K,CAAC,CAAC,WAAW,MAAM,oBAAoB,KAAK,UAAU,MAAM,8CAA8C,KAAK,sDAAsD,CAAC;AAC1K,CAAC;AAED;;;;;;;GAOG;A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AAI,KAAK,CACd,GAAG,QAAQ,6BAA6B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,iBAAiB,KAAK,6DAA6D,CAC3J,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@framers/agentos",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.60",
|
|
4
4
|
"description": "AgentOS: open-source TypeScript framework for autonomous AI agents. Unified graph orchestration, cognitive memory, runtime tool forging, multi-tier guardrails, voice pipeline, and 11 LLM providers.",
|
|
5
5
|
"homepage": "https://agentos.sh",
|
|
6
6
|
"repository": {
|