@ank1015/llm-agents 0.0.2
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/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +117 -0
- package/dist/agents/skills/index.d.ts +37 -0
- package/dist/agents/skills/index.d.ts.map +1 -0
- package/dist/agents/skills/index.js +386 -0
- package/dist/agents/skills/index.js.map +1 -0
- package/dist/agents/system-prompt.d.ts +7 -0
- package/dist/agents/system-prompt.d.ts.map +1 -0
- package/dist/agents/system-prompt.js +106 -0
- package/dist/agents/system-prompt.js.map +1 -0
- package/dist/agents/tools.d.ts +3 -0
- package/dist/agents/tools.d.ts.map +1 -0
- package/dist/agents/tools.js +3 -0
- package/dist/agents/tools.js.map +1 -0
- package/dist/helpers/ai-image/ai-image.d.ts +75 -0
- package/dist/helpers/ai-image/ai-image.d.ts.map +1 -0
- package/dist/helpers/ai-image/ai-image.js +438 -0
- package/dist/helpers/ai-image/ai-image.js.map +1 -0
- package/dist/helpers/ai-image/index.d.ts +3 -0
- package/dist/helpers/ai-image/index.d.ts.map +1 -0
- package/dist/helpers/ai-image/index.js +2 -0
- package/dist/helpers/ai-image/index.js.map +1 -0
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +2 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/bash.d.ts +55 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +246 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/edit-diff.d.ts +63 -0
- package/dist/tools/edit-diff.d.ts.map +1 -0
- package/dist/tools/edit-diff.js +246 -0
- package/dist/tools/edit-diff.js.map +1 -0
- package/dist/tools/edit.d.ts +39 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +150 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/find.d.ts +39 -0
- package/dist/tools/find.d.ts.map +1 -0
- package/dist/tools/find.js +206 -0
- package/dist/tools/find.js.map +1 -0
- package/dist/tools/grep.d.ts +45 -0
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +244 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/index.d.ts +73 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +66 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/ls.d.ts +40 -0
- package/dist/tools/ls.d.ts.map +1 -0
- package/dist/tools/ls.js +121 -0
- package/dist/tools/ls.js.map +1 -0
- package/dist/tools/path-utils.d.ts +8 -0
- package/dist/tools/path-utils.d.ts.map +1 -0
- package/dist/tools/path-utils.js +81 -0
- package/dist/tools/path-utils.js.map +1 -0
- package/dist/tools/read.d.ts +39 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +177 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/truncate.d.ts +70 -0
- package/dist/tools/truncate.d.ts.map +1 -0
- package/dist/tools/truncate.js +205 -0
- package/dist/tools/truncate.js.map +1 -0
- package/dist/tools/utils/config.d.ts +16 -0
- package/dist/tools/utils/config.d.ts.map +1 -0
- package/dist/tools/utils/config.js +40 -0
- package/dist/tools/utils/config.js.map +1 -0
- package/dist/tools/utils/image-resize.d.ts +36 -0
- package/dist/tools/utils/image-resize.d.ts.map +1 -0
- package/dist/tools/utils/image-resize.js +183 -0
- package/dist/tools/utils/image-resize.js.map +1 -0
- package/dist/tools/utils/mime.d.ts +3 -0
- package/dist/tools/utils/mime.d.ts.map +1 -0
- package/dist/tools/utils/mime.js +41 -0
- package/dist/tools/utils/mime.js.map +1 -0
- package/dist/tools/utils/photon.d.ts +21 -0
- package/dist/tools/utils/photon.d.ts.map +1 -0
- package/dist/tools/utils/photon.js +121 -0
- package/dist/tools/utils/photon.js.map +1 -0
- package/dist/tools/utils/shell.d.ts +26 -0
- package/dist/tools/utils/shell.d.ts.map +1 -0
- package/dist/tools/utils/shell.js +177 -0
- package/dist/tools/utils/shell.js.map +1 -0
- package/dist/tools/utils/tools-manager.d.ts +3 -0
- package/dist/tools/utils/tools-manager.d.ts.map +1 -0
- package/dist/tools/utils/tools-manager.js +209 -0
- package/dist/tools/utils/tools-manager.js.map +1 -0
- package/dist/tools/write.d.ts +29 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/tools/write.js +83 -0
- package/dist/tools/write.js.map +1 -0
- package/package.json +73 -0
- package/skills/ai-images/SKILL.md +45 -0
- package/skills/ai-images/references/create.md +106 -0
- package/skills/ai-images/references/edit.md +107 -0
- package/skills/registry.json +10 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { mkdir as fsMkdir, writeFile as fsWriteFile } from 'fs/promises';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
import { Type } from '@sinclair/typebox';
|
|
4
|
+
import { resolveToCwd } from './path-utils.js';
|
|
5
|
+
const writeSchema = Type.Object({
|
|
6
|
+
path: Type.String({ description: 'Path to the file to write (relative or absolute)' }),
|
|
7
|
+
content: Type.String({ description: 'Content to write to the file' }),
|
|
8
|
+
});
|
|
9
|
+
const defaultWriteOperations = {
|
|
10
|
+
writeFile: (path, content) => fsWriteFile(path, content, 'utf-8'),
|
|
11
|
+
mkdir: (dir) => fsMkdir(dir, { recursive: true }).then(() => { }),
|
|
12
|
+
};
|
|
13
|
+
export function createWriteTool(cwd, options) {
|
|
14
|
+
const ops = options?.operations ?? defaultWriteOperations;
|
|
15
|
+
return {
|
|
16
|
+
name: 'write',
|
|
17
|
+
label: 'write',
|
|
18
|
+
description: "Write content to a file. Creates the file if it doesn't exist, overwrites if it does. Automatically creates parent directories.",
|
|
19
|
+
parameters: writeSchema,
|
|
20
|
+
execute: async (_toolCallId, { path, content }, signal) => {
|
|
21
|
+
const absolutePath = resolveToCwd(path, cwd);
|
|
22
|
+
const dir = dirname(absolutePath);
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
// Check if already aborted
|
|
25
|
+
if (signal?.aborted) {
|
|
26
|
+
reject(new Error('Operation aborted'));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
let aborted = false;
|
|
30
|
+
// Set up abort handler
|
|
31
|
+
const onAbort = () => {
|
|
32
|
+
aborted = true;
|
|
33
|
+
reject(new Error('Operation aborted'));
|
|
34
|
+
};
|
|
35
|
+
if (signal) {
|
|
36
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
37
|
+
}
|
|
38
|
+
// Perform the write operation
|
|
39
|
+
(async () => {
|
|
40
|
+
try {
|
|
41
|
+
// Create parent directories if needed
|
|
42
|
+
await ops.mkdir(dir);
|
|
43
|
+
// Check if aborted before writing
|
|
44
|
+
if (aborted) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// Write the file
|
|
48
|
+
await ops.writeFile(absolutePath, content);
|
|
49
|
+
// Check if aborted after writing
|
|
50
|
+
if (aborted) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Clean up abort handler
|
|
54
|
+
if (signal) {
|
|
55
|
+
signal.removeEventListener('abort', onAbort);
|
|
56
|
+
}
|
|
57
|
+
resolve({
|
|
58
|
+
content: [
|
|
59
|
+
{
|
|
60
|
+
type: 'text',
|
|
61
|
+
content: `Successfully wrote ${content.length} bytes to ${path}`,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
details: undefined,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
// Clean up abort handler
|
|
69
|
+
if (signal) {
|
|
70
|
+
signal.removeEventListener('abort', onAbort);
|
|
71
|
+
}
|
|
72
|
+
if (!aborted) {
|
|
73
|
+
reject(error);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
})();
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** Default write tool using process.cwd() - for backwards compatibility */
|
|
82
|
+
export const writeTool = createWriteTool(process.cwd());
|
|
83
|
+
//# sourceMappingURL=write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../src/tools/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;IACtF,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;CACtE,CAAC,CAAC;AAeH,MAAM,sBAAsB,GAAoB;IAC9C,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;IACjE,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;CACjE,CAAC;AAOF,MAAM,UAAU,eAAe,CAC7B,GAAW,EACX,OAA0B;IAE1B,MAAM,GAAG,GAAG,OAAO,EAAE,UAAU,IAAI,sBAAsB,CAAC;IAE1D,OAAO;QACL,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;QACd,WAAW,EACT,iIAAiI;QACnI,UAAU,EAAE,WAAW;QACvB,OAAO,EAAE,KAAK,EACZ,WAAmB,EACnB,EAAE,IAAI,EAAE,OAAO,EAAqC,EACpD,MAAoB,EACpB,EAAE;YACF,MAAM,YAAY,GAAG,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAC7C,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;YAElC,OAAO,IAAI,OAAO,CAChB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAClB,2BAA2B;gBAC3B,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;oBACpB,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;oBACvC,OAAO;gBACT,CAAC;gBAED,IAAI,OAAO,GAAG,KAAK,CAAC;gBAEpB,uBAAuB;gBACvB,MAAM,OAAO,GAAG,GAAG,EAAE;oBACnB,OAAO,GAAG,IAAI,CAAC;oBACf,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;gBACzC,CAAC,CAAC;gBAEF,IAAI,MAAM,EAAE,CAAC;oBACX,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC5D,CAAC;gBAED,8BAA8B;gBAC9B,CAAC,KAAK,IAAI,EAAE;oBACV,IAAI,CAAC;wBACH,sCAAsC;wBACtC,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;wBAErB,kCAAkC;wBAClC,IAAI,OAAO,EAAE,CAAC;4BACZ,OAAO;wBACT,CAAC;wBAED,iBAAiB;wBACjB,MAAM,GAAG,CAAC,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;wBAE3C,iCAAiC;wBACjC,IAAI,OAAO,EAAE,CAAC;4BACZ,OAAO;wBACT,CAAC;wBAED,yBAAyB;wBACzB,IAAI,MAAM,EAAE,CAAC;4BACX,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;wBAC/C,CAAC;wBAED,OAAO,CAAC;4BACN,OAAO,EAAE;gCACP;oCACE,IAAI,EAAE,MAAM;oCACZ,OAAO,EAAE,sBAAsB,OAAO,CAAC,MAAM,aAAa,IAAI,EAAE;iCACjE;6BACF;4BACD,OAAO,EAAE,SAAS;yBACnB,CAAC,CAAC;oBACL,CAAC;oBAAC,OAAO,KAAU,EAAE,CAAC;wBACpB,yBAAyB;wBACzB,IAAI,MAAM,EAAE,CAAC;4BACX,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;wBAC/C,CAAC;wBAED,IAAI,CAAC,OAAO,EAAE,CAAC;4BACb,MAAM,CAAC,KAAK,CAAC,CAAC;wBAChB,CAAC;oBACH,CAAC;gBACH,CAAC,CAAC,EAAE,CAAC;YACP,CAAC,CACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ank1015/llm-agents",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Node-only general-purpose agent toolkit with bundled skills and helper-backed workflows",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"skills",
|
|
17
|
+
"README.md",
|
|
18
|
+
"CHANGELOG.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "rm -rf dist coverage *.tsbuildinfo && tsc",
|
|
23
|
+
"dev": "tsc --watch",
|
|
24
|
+
"test": "pnpm run test:unit && pnpm run test:integration",
|
|
25
|
+
"test:watch": "vitest",
|
|
26
|
+
"test:unit": "vitest run tests/unit",
|
|
27
|
+
"test:integration": "vitest run tests/integration",
|
|
28
|
+
"test:coverage": "vitest run --coverage",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"lint": "eslint src tests vitest.config.ts",
|
|
31
|
+
"clean": "rm -rf dist coverage *.tsbuildinfo",
|
|
32
|
+
"prepack": "pnpm run build"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"llm",
|
|
36
|
+
"agents",
|
|
37
|
+
"ai",
|
|
38
|
+
"node",
|
|
39
|
+
"tools",
|
|
40
|
+
"skills",
|
|
41
|
+
"typescript",
|
|
42
|
+
"images"
|
|
43
|
+
],
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/ank1015/llm.git",
|
|
48
|
+
"directory": "packages/agents"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://github.com/ank1015/llm/tree/main/packages/agents",
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/ank1015/llm/issues"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@ank1015/llm-sdk": "workspace:^",
|
|
59
|
+
"@ank1015/llm-sdk-adapters": "workspace:^",
|
|
60
|
+
"@silvia-odwyer/photon-node": "^0.3.4",
|
|
61
|
+
"@sinclair/typebox": "^0.34.48",
|
|
62
|
+
"chalk": "^5.6.2",
|
|
63
|
+
"diff": "^8.0.3",
|
|
64
|
+
"file-type": "^21.3.0",
|
|
65
|
+
"glob": "^13.0.6"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@vitest/coverage-v8": "^2.1.0",
|
|
69
|
+
"@types/node": "^25.3.2",
|
|
70
|
+
"tsx": "^4.19.0",
|
|
71
|
+
"vitest": "^2.1.0"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ai-images
|
|
3
|
+
description: 'Create brand-new images or edit existing images with state-of-the-art image generation models. Use this skill when the task involves image generation, visual variations, or image transformation.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AI Images
|
|
7
|
+
|
|
8
|
+
## When To Use
|
|
9
|
+
|
|
10
|
+
Use this skill when the user wants to:
|
|
11
|
+
|
|
12
|
+
- generate a new image from a prompt
|
|
13
|
+
- create image variations from reference images
|
|
14
|
+
- edit or transform one or more existing images
|
|
15
|
+
- use the latest image models exposed through `@ank1015/llm-agents`
|
|
16
|
+
|
|
17
|
+
## Required Reading Order
|
|
18
|
+
|
|
19
|
+
1. Read this file first.
|
|
20
|
+
2. If the task is generating a new image, read [references/create.md](references/create.md).
|
|
21
|
+
3. If the task is editing or transforming an existing image, read [references/edit.md](references/edit.md).
|
|
22
|
+
4. Do not read both reference files unless the task genuinely includes both create and edit flows.
|
|
23
|
+
|
|
24
|
+
## Available Functions
|
|
25
|
+
|
|
26
|
+
- `createImage(request)`
|
|
27
|
+
- create a new image from a prompt
|
|
28
|
+
- optionally condition the generation on reference images
|
|
29
|
+
- `editImage(request)`
|
|
30
|
+
- modify or transform one or more existing images
|
|
31
|
+
- requires at least one input image
|
|
32
|
+
|
|
33
|
+
Import from the package root:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { createImage, editImage } from '@ank1015/llm-agents';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Choose The Next Reference
|
|
40
|
+
|
|
41
|
+
- Read [references/create.md](references/create.md) for request shape, model-specific create options, output behavior, and example usage of `createImage()`.
|
|
42
|
+
- Read [references/edit.md](references/edit.md) for request shape, supported inputs, model-specific edit options, output behavior, and example usage of `editImage()`.
|
|
43
|
+
|
|
44
|
+
Load only the reference that matches the current task so you do not pull unnecessary context into
|
|
45
|
+
the conversation.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Create Images
|
|
2
|
+
|
|
3
|
+
Use this reference when the user wants to generate a brand-new image or create a new image while
|
|
4
|
+
optionally conditioning on reference images.
|
|
5
|
+
|
|
6
|
+
## Import
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import { createImage } from '@ank1015/llm-agents';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Request Shape
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
await createImage({
|
|
16
|
+
provider: {
|
|
17
|
+
model: 'gpt-5.4',
|
|
18
|
+
},
|
|
19
|
+
prompt: 'A cinematic product photo of a matte black camera on a warm stone pedestal',
|
|
20
|
+
outputDir: '/absolute/output/dir',
|
|
21
|
+
outputName: 'camera-hero',
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Fields
|
|
26
|
+
|
|
27
|
+
- `provider.model`
|
|
28
|
+
- required
|
|
29
|
+
- one of `gpt-5.4`, `gemini-3.1-flash-image-preview`, `gemini-3-pro-image-preview`
|
|
30
|
+
- `provider.imageOptions`
|
|
31
|
+
- optional model-specific controls
|
|
32
|
+
- `prompt`
|
|
33
|
+
- required
|
|
34
|
+
- `outputDir`
|
|
35
|
+
- required absolute or relative directory for the final image
|
|
36
|
+
- `outputName`
|
|
37
|
+
- optional filename stem only, not a path
|
|
38
|
+
- `images`
|
|
39
|
+
- optional reference image paths or URLs
|
|
40
|
+
- useful when the model should create from existing visual context
|
|
41
|
+
- `systemPrompt`
|
|
42
|
+
- optional additional instruction layer
|
|
43
|
+
- `onUpdate`
|
|
44
|
+
- optional callback for partial, thought, and final image events
|
|
45
|
+
|
|
46
|
+
## OpenAI Options
|
|
47
|
+
|
|
48
|
+
For `gpt-5.4`, `provider.imageOptions` can include:
|
|
49
|
+
|
|
50
|
+
- `format`: `png | jpeg | webp`
|
|
51
|
+
- `quality`: `low | medium | high | auto`
|
|
52
|
+
- `background`: `transparent | opaque | auto`
|
|
53
|
+
- `size`: `1024x1024 | 1024x1536 | 1536x1024 | auto`
|
|
54
|
+
- `partialImages`: `0 | 1 | 2 | 3`
|
|
55
|
+
- `moderation`: `auto | low`
|
|
56
|
+
|
|
57
|
+
Do not use `inputFidelity` with `createImage()`.
|
|
58
|
+
|
|
59
|
+
## Google Options
|
|
60
|
+
|
|
61
|
+
For Google image models, `provider.imageOptions` can include:
|
|
62
|
+
|
|
63
|
+
- `imageSize`: `1K | 2K | 4K`
|
|
64
|
+
- `aspectRatio`
|
|
65
|
+
|
|
66
|
+
Flash model aspect ratios:
|
|
67
|
+
|
|
68
|
+
- `1:1`, `1:4`, `1:8`, `2:3`, `3:2`, `3:4`, `4:1`, `4:3`, `4:5`, `5:4`, `8:1`, `9:16`, `16:9`, `21:9`
|
|
69
|
+
|
|
70
|
+
Pro model aspect ratios:
|
|
71
|
+
|
|
72
|
+
- `1:1`, `2:3`, `3:2`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, `21:9`
|
|
73
|
+
|
|
74
|
+
## Output Behavior
|
|
75
|
+
|
|
76
|
+
- The final image is written to `outputDir/outputName.<ext>`.
|
|
77
|
+
- Intermediate outputs are written to `outputDir/outputName__updates/`.
|
|
78
|
+
- The returned value is:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
{ path: '/final/image/path.png' }
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Example With Progress Updates
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { createImage } from '@ank1015/llm-agents';
|
|
88
|
+
|
|
89
|
+
const result = await createImage({
|
|
90
|
+
provider: {
|
|
91
|
+
model: 'gemini-3-pro-image-preview',
|
|
92
|
+
imageOptions: {
|
|
93
|
+
aspectRatio: '16:9',
|
|
94
|
+
imageSize: '2K',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
prompt: 'A dramatic sunrise over a foggy mountain village, painterly but realistic',
|
|
98
|
+
outputDir: '/absolute/output/dir',
|
|
99
|
+
outputName: 'mountain-village',
|
|
100
|
+
onUpdate(update) {
|
|
101
|
+
console.log(update.stage, update.path);
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
console.log(result.path);
|
|
106
|
+
```
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Edit Images
|
|
2
|
+
|
|
3
|
+
Use this reference when the user wants to modify, transform, or extend one or more existing
|
|
4
|
+
images.
|
|
5
|
+
|
|
6
|
+
## Import
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import { editImage } from '@ank1015/llm-agents';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Request Shape
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
await editImage({
|
|
16
|
+
provider: {
|
|
17
|
+
model: 'gpt-5.4',
|
|
18
|
+
},
|
|
19
|
+
prompt: 'Turn this product photo into a premium studio ad with soft rim light',
|
|
20
|
+
images: ['/absolute/path/to/input.png'],
|
|
21
|
+
outputDir: '/absolute/output/dir',
|
|
22
|
+
outputName: 'product-ad',
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Fields
|
|
27
|
+
|
|
28
|
+
- `provider.model`
|
|
29
|
+
- required
|
|
30
|
+
- one of `gpt-5.4`, `gemini-3.1-flash-image-preview`, `gemini-3-pro-image-preview`
|
|
31
|
+
- `provider.imageOptions`
|
|
32
|
+
- optional model-specific controls
|
|
33
|
+
- `prompt`
|
|
34
|
+
- required
|
|
35
|
+
- `images`
|
|
36
|
+
- required
|
|
37
|
+
- one path/URL or an array of paths/URLs
|
|
38
|
+
- `outputDir`
|
|
39
|
+
- required
|
|
40
|
+
- `outputName`
|
|
41
|
+
- optional filename stem only
|
|
42
|
+
- `systemPrompt`
|
|
43
|
+
- optional
|
|
44
|
+
- `onUpdate`
|
|
45
|
+
- optional callback for progress artifacts
|
|
46
|
+
|
|
47
|
+
## Supported Inputs
|
|
48
|
+
|
|
49
|
+
The helper accepts:
|
|
50
|
+
|
|
51
|
+
- local image paths
|
|
52
|
+
- remote `http` / `https` image URLs
|
|
53
|
+
|
|
54
|
+
The helper infers image type from content type, file bytes, or file extension.
|
|
55
|
+
|
|
56
|
+
## OpenAI Options
|
|
57
|
+
|
|
58
|
+
For `gpt-5.4`, `provider.imageOptions` can include:
|
|
59
|
+
|
|
60
|
+
- `format`: `png | jpeg | webp`
|
|
61
|
+
- `quality`: `low | medium | high | auto`
|
|
62
|
+
- `background`: `transparent | opaque | auto`
|
|
63
|
+
- `size`: `1024x1024 | 1024x1536 | 1536x1024 | auto`
|
|
64
|
+
- `partialImages`: `0 | 1 | 2 | 3`
|
|
65
|
+
- `inputFidelity`: `low | high`
|
|
66
|
+
- `moderation`: `auto | low`
|
|
67
|
+
|
|
68
|
+
`inputFidelity` is valid here and is specific to edit flows.
|
|
69
|
+
|
|
70
|
+
## Google Options
|
|
71
|
+
|
|
72
|
+
For Google image models, `provider.imageOptions` can include:
|
|
73
|
+
|
|
74
|
+
- `imageSize`: `1K | 2K | 4K`
|
|
75
|
+
- `aspectRatio`
|
|
76
|
+
|
|
77
|
+
Use the same aspect-ratio families described in the create flow, depending on whether the model is
|
|
78
|
+
Flash or Pro.
|
|
79
|
+
|
|
80
|
+
## Output Behavior
|
|
81
|
+
|
|
82
|
+
- The final edited image is written to `outputDir/outputName.<ext>`.
|
|
83
|
+
- Intermediate outputs are written to `outputDir/outputName__updates/`.
|
|
84
|
+
- The helper throws if no final image is returned by the provider.
|
|
85
|
+
|
|
86
|
+
## Example
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { editImage } from '@ank1015/llm-agents';
|
|
90
|
+
|
|
91
|
+
const result = await editImage({
|
|
92
|
+
provider: {
|
|
93
|
+
model: 'gpt-5.4',
|
|
94
|
+
imageOptions: {
|
|
95
|
+
inputFidelity: 'high',
|
|
96
|
+
quality: 'high',
|
|
97
|
+
format: 'png',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
prompt: 'Replace the background with a clean beige studio wall and add a subtle floor shadow',
|
|
101
|
+
images: ['https://example.com/reference/product.png'],
|
|
102
|
+
outputDir: '/absolute/output/dir',
|
|
103
|
+
outputName: 'product-edit',
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
console.log(result.path);
|
|
107
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "ai-images",
|
|
4
|
+
"description": "Create brand-new images or edit existing images with state-of-the-art image generation models. Use this skill when the task involves image generation, visual variations, or image transformation.",
|
|
5
|
+
"helperProject": {
|
|
6
|
+
"runtime": "typescript",
|
|
7
|
+
"package": "@ank1015/llm-agents"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
]
|