@talesofai/neta-skills 0.14.0 → 0.14.1
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 +9 -0
- package/bin/apis/index.js +20 -3
- package/bin/commands/character_elementum/list_my_characters.cmd.js +1 -2
- package/bin/commands/character_elementum/list_my_elementum.cmd.js +1 -2
- package/bin/commands/creative/remove_background.cmd.en_us.yml +2 -0
- package/bin/commands/creative/remove_background.cmd.js +20 -1
- package/bin/commands/creative/remove_background.cmd.zh_cn.yml +2 -0
- package/bin/commands/load.js +2 -1
- package/bin/commands/premium/get_current_premium_plan.cmd.js +4 -2
- package/package.json +1 -1
- package/skills/neta-creative/SKILL.md +1 -1
- package/skills/neta-creative/references/image-generation.md +1 -1
- package/skills/zh_cn/neta-creative/SKILL.md +1 -1
- package/skills/zh_cn/neta-creative/references/image-generation.md +1 -1
package/CHANGELOG.md
CHANGED
package/bin/apis/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { handleAxiosError } from "../utils/errors.js";
|
|
1
|
+
import axios, { AxiosError } from "axios";
|
|
2
|
+
import { catchErrorResponse, handleAxiosError } from "../utils/errors.js";
|
|
3
3
|
import { createActivityApis } from "./activity.js";
|
|
4
4
|
import { createArtifactApis } from "./artifact.js";
|
|
5
5
|
import { createAudioApis } from "./audio.js";
|
|
@@ -19,14 +19,31 @@ import { createUserApis } from "./user.js";
|
|
|
19
19
|
import { createVerseApis } from "./verse.js";
|
|
20
20
|
export const createApis = (option) => {
|
|
21
21
|
const baseUrl = option.baseUrl;
|
|
22
|
+
const logger = option.logger;
|
|
22
23
|
const client = axios.create({
|
|
23
24
|
adapter: "fetch",
|
|
24
25
|
baseURL: baseUrl,
|
|
25
26
|
headers: {
|
|
26
27
|
...option.headers,
|
|
27
28
|
},
|
|
29
|
+
timeout: 10 * 1000,
|
|
28
30
|
});
|
|
29
|
-
client.interceptors.
|
|
31
|
+
client.interceptors.request.use((config) => {
|
|
32
|
+
const now = Date.now();
|
|
33
|
+
config.start_time = now;
|
|
34
|
+
logger.debug("[api] request: %s %s", config.method, config.url);
|
|
35
|
+
return config;
|
|
36
|
+
});
|
|
37
|
+
client.interceptors.response.use((response) => {
|
|
38
|
+
const now = Date.now();
|
|
39
|
+
const startTime = response.config.start_time ?? now;
|
|
40
|
+
const duration = now - startTime;
|
|
41
|
+
logger.debug("[api] response: %s %s %s %dms", response.config.method, response.status, response.config.url, duration);
|
|
42
|
+
return response;
|
|
43
|
+
}, (error) => {
|
|
44
|
+
if (error instanceof AxiosError) {
|
|
45
|
+
logger.debug("[api] response error: %s %s %s %s", error.request?.method, error.request?.url, error.response?.status, catchErrorResponse(error.response?.data));
|
|
46
|
+
}
|
|
30
47
|
handleAxiosError(error);
|
|
31
48
|
});
|
|
32
49
|
const tcp = createTcpApis(client);
|
|
@@ -16,9 +16,8 @@ export const listMyCharacters = createCommand({
|
|
|
16
16
|
title: meta.title,
|
|
17
17
|
description: meta.description,
|
|
18
18
|
inputSchema: listMyCharactersParameters,
|
|
19
|
-
}, async ({ keyword, page_index, page_size }, { apis }) => {
|
|
19
|
+
}, async ({ keyword, page_index, page_size }, { apis, user }) => {
|
|
20
20
|
// Get current user info to obtain UUID
|
|
21
|
-
const user = await apis.user.me();
|
|
22
21
|
if (!user) {
|
|
23
22
|
throw new Error("Failed to get user info. Please check your NETA_TOKEN.");
|
|
24
23
|
}
|
|
@@ -16,9 +16,8 @@ export const listMyElementum = createCommand({
|
|
|
16
16
|
title: meta.title,
|
|
17
17
|
description: meta.description,
|
|
18
18
|
inputSchema: listMyElementumParameters,
|
|
19
|
-
}, async ({ keyword, page_index, page_size }, { apis }) => {
|
|
19
|
+
}, async ({ keyword, page_index, page_size }, { apis, user }) => {
|
|
20
20
|
// Get current user info to obtain UUID
|
|
21
|
-
const user = await apis.user.me();
|
|
22
21
|
if (!user) {
|
|
23
22
|
throw new Error("Failed to get user info. Please check your NETA_TOKEN.");
|
|
24
23
|
}
|
|
@@ -2,6 +2,8 @@ remove_background:
|
|
|
2
2
|
name: remove_background
|
|
3
3
|
title: Remove Image Background
|
|
4
4
|
description: Remove the background of an input image while preserving the main subject, and return an image with a transparent background.
|
|
5
|
+
parameters:
|
|
6
|
+
input_image: The UUID of the input image artifact.
|
|
5
7
|
|
|
6
8
|
remove_background_nocrop:
|
|
7
9
|
name: remove_background_nocrop
|
|
@@ -7,6 +7,9 @@ const meta = parseMeta(Type.Object({
|
|
|
7
7
|
name: Type.String(),
|
|
8
8
|
title: Type.String(),
|
|
9
9
|
description: Type.String(),
|
|
10
|
+
parameters: Type.Object({
|
|
11
|
+
input_image: Type.String(),
|
|
12
|
+
}),
|
|
10
13
|
}),
|
|
11
14
|
remove_background_nocrop: Type.Object({
|
|
12
15
|
name: Type.String(),
|
|
@@ -15,7 +18,9 @@ const meta = parseMeta(Type.Object({
|
|
|
15
18
|
}),
|
|
16
19
|
}), import.meta);
|
|
17
20
|
const removeBackgroundV1Parameters = Type.Object({
|
|
18
|
-
input_image: Type.String(
|
|
21
|
+
input_image: Type.String({
|
|
22
|
+
description: meta.remove_background.parameters.input_image,
|
|
23
|
+
}),
|
|
19
24
|
});
|
|
20
25
|
export const removeBackground = createCommand({
|
|
21
26
|
name: meta.remove_background.name,
|
|
@@ -24,6 +29,13 @@ export const removeBackground = createCommand({
|
|
|
24
29
|
inputSchema: removeBackgroundV1Parameters,
|
|
25
30
|
}, async ({ input_image }, { apis, log }) => {
|
|
26
31
|
const createTask = async () => {
|
|
32
|
+
const artifacts = await apis.artifact.artifactDetail([input_image]);
|
|
33
|
+
if (!artifacts ||
|
|
34
|
+
!artifacts[0] ||
|
|
35
|
+
artifacts[0].modality !== "PICTURE" ||
|
|
36
|
+
artifacts[0].status !== "SUCCESS") {
|
|
37
|
+
throw new Error("Input is not a valid picture artifact UUID");
|
|
38
|
+
}
|
|
27
39
|
return apis.artifact.postProcess(input_image, "0_null/抠图SEG", {
|
|
28
40
|
entrance: "PICTURE,CLI",
|
|
29
41
|
});
|
|
@@ -52,6 +64,13 @@ export const removeBackgroundNoCrop = createCommand({
|
|
|
52
64
|
inputSchema: removeBackgroundV1Parameters,
|
|
53
65
|
}, async ({ input_image }, { apis, log }) => {
|
|
54
66
|
const createTask = async () => {
|
|
67
|
+
const artifacts = await apis.artifact.artifactDetail([input_image]);
|
|
68
|
+
if (!artifacts ||
|
|
69
|
+
!artifacts[0] ||
|
|
70
|
+
artifacts[0].modality !== "PICTURE" ||
|
|
71
|
+
artifacts[0].status !== "SUCCESS") {
|
|
72
|
+
throw new Error("Input is not a valid picture artifact UUID");
|
|
73
|
+
}
|
|
55
74
|
return apis.artifact.postProcess(input_image, "0_null/抠图SEG", {
|
|
56
75
|
entrance: "PICTURE,CLI",
|
|
57
76
|
});
|
package/bin/commands/load.js
CHANGED
|
@@ -90,6 +90,7 @@ export const buildCommands = async (cli) => {
|
|
|
90
90
|
? api_base_url
|
|
91
91
|
: (process.env["NETA_API_BASE_URL"] ?? "https://api.talesofai.com");
|
|
92
92
|
const apis = createApis({
|
|
93
|
+
logger,
|
|
93
94
|
baseUrl,
|
|
94
95
|
headers: {
|
|
95
96
|
"x-token": process.env["NETA_TOKEN"] ?? "",
|
|
@@ -105,7 +106,7 @@ export const buildCommands = async (cli) => {
|
|
|
105
106
|
const type = cmd.inputSchema ?? Type.Object({});
|
|
106
107
|
const input = Value.Parse(type, args);
|
|
107
108
|
if (IS_DEV) {
|
|
108
|
-
logger.debug("command
|
|
109
|
+
logger.debug("[command] %s, params: %o", cmd.name, input);
|
|
109
110
|
}
|
|
110
111
|
const result = await cmd
|
|
111
112
|
.execute(input, {
|
|
@@ -17,11 +17,13 @@ export const getCurrentPremiumPlan = createCommand({
|
|
|
17
17
|
name: meta.name,
|
|
18
18
|
title: meta.title,
|
|
19
19
|
description: meta.description,
|
|
20
|
-
}, async (_, { apis }) => {
|
|
20
|
+
}, async (_, { apis, user }) => {
|
|
21
21
|
if (!apis.baseUrl.endsWith("talesofai.com")) {
|
|
22
22
|
throw new Error("This command is not supported in the current region");
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
if (!user) {
|
|
25
|
+
throw new Error("Not authenticated. Please check your NETA_TOKEN.");
|
|
26
|
+
}
|
|
25
27
|
const level = user.properties?.vip_level ?? 0;
|
|
26
28
|
return {
|
|
27
29
|
plan: PlanningMap[level],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@talesofai/neta-skills",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "Neta API pi coding agent skills for interacting with Neta API to generate images, videos, songs, and manage characters/elements.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -52,7 +52,7 @@ Combine an audio track and video to create a full MV.
|
|
|
52
52
|
**Remove background**
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
npx -y @talesofai/neta-skills@latest remove_background --input_image "
|
|
55
|
+
npx -y @talesofai/neta-skills@latest remove_background --input_image "image_artifact_uuid"
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
### Character queries
|
|
@@ -124,7 +124,7 @@ npx -y @talesofai/neta-skills@latest make_image --prompt "@character_name, shy e
|
|
|
124
124
|
### Background Removal
|
|
125
125
|
|
|
126
126
|
```bash
|
|
127
|
-
npx -y @talesofai/neta-skills@latest remove_background --input_image "
|
|
127
|
+
npx -y @talesofai/neta-skills@latest remove_background --input_image "image_artifact_uuid"
|
|
128
128
|
```
|
|
129
129
|
---
|
|
130
130
|
|
|
@@ -44,7 +44,7 @@ npx -y @talesofai/neta-skills@latest make_song --prompt "风格描述" --lyrics
|
|
|
44
44
|
|
|
45
45
|
**移除背景**
|
|
46
46
|
```bash
|
|
47
|
-
npx -y @talesofai/neta-skills@latest remove_background --input_image "
|
|
47
|
+
npx -y @talesofai/neta-skills@latest remove_background --input_image "image_artifact_uuid"
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
### 角色查询
|
|
@@ -124,7 +124,7 @@ npx -y @talesofai/neta-skills@latest make_image --prompt "@角色名,害羞表
|
|
|
124
124
|
### 去背景(抠图)
|
|
125
125
|
|
|
126
126
|
```bash
|
|
127
|
-
npx -y @talesofai/neta-skills@latest remove_background --input_image "
|
|
127
|
+
npx -y @talesofai/neta-skills@latest remove_background --input_image "image_artifact_uuid"
|
|
128
128
|
```
|
|
129
129
|
---
|
|
130
130
|
|