AS AgentScopeAPI 手册 / API Reference

SkillUtil

public class SkillUtil
源码Source io/agentscope/core/skill/util/SkillUtil.java:53–399

技能 Util,让智能体以受控方式调用外部能力。位于 io.agentscope.core.skill.util 包。核心成员包括 createFrom、createFromZip。

Utility class for creating AgentSkill instances.

This class provides factory methods to create AgentSkill objects from various sources, particularly from markdown content with YAML frontmatter.

Usage example:

`// Create skill from markdown with default source
String skillMd = "---\nname: my_skill\ndescription: Does something\n---\nContent here";
Map<String, String> resources = Map.of("file1.txt", "content1");
AgentSkill skill = SkillUtil.createFrom(skillMd, resources);

// Create skill from markdown with custom source
AgentSkill skill2 = SkillUtil.createFrom(skillMd, resources, "github");
`

方法摘要Method Summary

方法Method说明Description
public static AgentSkill createFrom(String skillMd, Map<String, String> resources)
static
创建来自。
Creates an AgentSkill from markdown with YAML frontmatter.
public static AgentSkill createFrom(String skillMd, Map<String, String> resources, String source)
static
创建来自。
Creates an AgentSkill from markdown with YAML frontmatter and custom source.
public static AgentSkill createFromZip(byte[] zipBytes)
static
创建 `createFromZip`。
Creates an AgentSkill from a skill package zip.
public static AgentSkill createFromZip(Path zipPath)
static
创建 `createFromZip`。
Creates an AgentSkill from a skill package zip file path.
public static AgentSkill createFromZip(Path zipPath, Charset charset)
static
创建 `createFromZip`。
Creates an AgentSkill from a skill package zip file path using the given charset.
public static AgentSkill createFromZip(InputStream zipStream)
static
创建 `createFromZip`。
Creates an AgentSkill from a skill package zip input stream.
public static AgentSkill createFromZip(byte[] zipBytes, String source)
static
创建 `createFromZip`。
Creates an AgentSkill from a skill package zip with custom source.
public static AgentSkill createFromZip(byte[] zipBytes, String source, Charset charset)
static
创建 `createFromZip`。
Creates an AgentSkill from a skill package zip with custom source and charset.
public static AgentSkill createFromZip(Path zipPath, String source)
static
创建 `createFromZip`。
Creates an AgentSkill from a skill package zip file path with custom source.
public static AgentSkill createFromZip(Path zipPath, String source, Charset charset)
static
创建 `createFromZip`。
Creates an AgentSkill from a skill package zip file path with custom source and charset.
public static AgentSkill createFromZip(InputStream zipStream, String source)
static
创建 `createFromZip`。
Creates an AgentSkill from a skill package zip input stream with custom source.
public static AgentSkill createFromZip(InputStream zipStream, String source, Charset charset)
static
创建 `createFromZip`。
Creates an AgentSkill from a skill package zip input stream with custom source and charset.

方法详情Method Detail

createFrom

public static AgentSkill createFrom(String skillMd, Map<String, String> resources)
static

创建来自。

Creates an AgentSkill from markdown with YAML frontmatter.

参数Parameters
名称Name类型Type说明Description
skillMdString技能 Md(类型 `String`)。Markdown content with YAML frontmatter containing name and description
resourcesMap<String, String>resources(类型 `Map`)。Supporting resources referenced by the skill (can be null)
返回Returns AgentSkill
返回AgentSkill。Created AgentSkill instance
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if name or description is missing, or if content is empty
源码Source io/agentscope/core/skill/util/SkillUtil.java:74–76

createFrom

public static AgentSkill createFrom(String skillMd, Map<String, String> resources, String source)
static

创建来自。

Creates an AgentSkill from markdown with YAML frontmatter and custom source.

参数Parameters
名称Name类型Type说明Description
skillMdString技能 Md(类型 `String`)。Markdown content with YAML frontmatter containing name and description
resourcesMap<String, String>resources(类型 `Map`)。Supporting resources referenced by the skill (can be null)
sourceString来源(类型 `String`)。Source identifier for the skill (null defaults to "custom")
返回Returns AgentSkill
返回AgentSkill。Created AgentSkill instance
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if name or description is missing, or if content is empty
源码Source io/agentscope/core/skill/util/SkillUtil.java:90–113

createFromZip

public static AgentSkill createFromZip(byte[] zipBytes)
static

创建 createFromZip。

Creates an AgentSkill from a skill package zip.

参数Parameters
名称Name类型Type说明Description
zipBytesbyte[]zip 字节(类型 `byte[]`)。Zip content as bytes
返回Returns AgentSkill
返回AgentSkill。Created AgentSkill instance
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if zipBytes is null/empty, if no SKILL.md is found, or if zip entries are invalid
源码Source io/agentscope/core/skill/util/SkillUtil.java:126–128

createFromZip

public static AgentSkill createFromZip(Path zipPath)
static

创建 createFromZip。

Creates an AgentSkill from a skill package zip file path.

参数Parameters
名称Name类型Type说明Description
zipPathPathzip 路径(类型 `Path`)。Zip file path
返回Returns AgentSkill
返回AgentSkill。Created AgentSkill instance
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if zipPath is null
  • RuntimeException 可能抛出 `RuntimeException`。if the zip file cannot be read
源码Source io/agentscope/core/skill/util/SkillUtil.java:141–143

createFromZip

public static AgentSkill createFromZip(Path zipPath, Charset charset)
static

创建 createFromZip。

Creates an AgentSkill from a skill package zip file path using the given charset.

参数Parameters
名称Name类型Type说明Description
zipPathPathzip 路径(类型 `Path`)。Zip file path
charsetCharsetcharset(类型 `Charset`)。Charset used to decode zip entry names and file contents (null defaults to UTF-8). Use this when the zip was created with a non-UTF-8 charset such as GBK/GB18030 and the default overload fails during zip entry decoding with errors like `malformed input`
返回Returns AgentSkill
返回AgentSkill。Created AgentSkill instance
源码Source io/agentscope/core/skill/util/SkillUtil.java:158–160

createFromZip

public static AgentSkill createFromZip(InputStream zipStream)
static

创建 createFromZip。

Creates an AgentSkill from a skill package zip input stream.

参数Parameters
名称Name类型Type说明Description
zipStreamInputStreamzip 流(类型 `InputStream`)。Zip content stream
返回Returns AgentSkill
返回AgentSkill。Created AgentSkill instance
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if zipStream is null
源码Source io/agentscope/core/skill/util/SkillUtil.java:172–174

createFromZip

public static AgentSkill createFromZip(byte[] zipBytes, String source)
static

创建 createFromZip。

Creates an AgentSkill from a skill package zip with custom source.

参数Parameters
名称Name类型Type说明Description
zipBytesbyte[]zip 字节(类型 `byte[]`)。Zip content as bytes
sourceString来源(类型 `String`)。Source identifier for the skill (null defaults to "custom")
返回Returns AgentSkill
返回AgentSkill。Created AgentSkill instance
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if zipBytes is null/empty, if no SKILL.md is found, or if zip entries are invalid
源码Source io/agentscope/core/skill/util/SkillUtil.java:188–190

createFromZip

public static AgentSkill createFromZip(byte[] zipBytes, String source, Charset charset)
static

创建 createFromZip。

Creates an AgentSkill from a skill package zip with custom source and charset.

参数Parameters
名称Name类型Type说明Description
zipBytesbyte[]zip 字节(类型 `byte[]`)。Zip content as bytes
sourceString来源(类型 `String`)。Source identifier for the skill (null defaults to "custom")
charsetCharsetcharset(类型 `Charset`)。Charset used to decode zip entry names and file contents (null defaults to UTF-8). Use this when the zip was created with a non-UTF-8 charset such as GBK/GB18030 and the default overload fails during zip entry decoding with errors like `malformed input`
返回Returns AgentSkill
返回AgentSkill。Created AgentSkill instance
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if zipBytes is null/empty, if no SKILL.md is found, or if zip entries are invalid
源码Source io/agentscope/core/skill/util/SkillUtil.java:208–213

createFromZip

public static AgentSkill createFromZip(Path zipPath, String source)
static

创建 createFromZip。

Creates an AgentSkill from a skill package zip file path with custom source.

参数Parameters
名称Name类型Type说明Description
zipPathPathzip 路径(类型 `Path`)。Zip file path
sourceString来源(类型 `String`)。Source identifier for the skill (null defaults to "custom")
返回Returns AgentSkill
返回AgentSkill。Created AgentSkill instance
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if zipPath is null
  • RuntimeException 可能抛出 `RuntimeException`。if the zip file cannot be read
源码Source io/agentscope/core/skill/util/SkillUtil.java:227–229

createFromZip

public static AgentSkill createFromZip(Path zipPath, String source, Charset charset)
static

创建 createFromZip。

Creates an AgentSkill from a skill package zip file path with custom source and charset.

参数Parameters
名称Name类型Type说明Description
zipPathPathzip 路径(类型 `Path`)。Zip file path
sourceString来源(类型 `String`)。Source identifier for the skill (null defaults to "custom")
charsetCharsetcharset(类型 `Charset`)。Charset used to decode zip entry names and file contents (null defaults to UTF-8). Use this when the zip was created with a non-UTF-8 charset such as GBK/GB18030 and the default overload fails during zip entry decoding with errors like `malformed input`
返回Returns AgentSkill
返回AgentSkill。Created AgentSkill instance
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if zipPath is null
  • RuntimeException 可能抛出 `RuntimeException`。if the zip file cannot be read
源码Source io/agentscope/core/skill/util/SkillUtil.java:247–256

createFromZip

public static AgentSkill createFromZip(InputStream zipStream, String source)
static

创建 createFromZip。

Creates an AgentSkill from a skill package zip input stream with custom source.

参数Parameters
名称Name类型Type说明Description
zipStreamInputStreamzip 流(类型 `InputStream`)。Zip content stream
sourceString来源(类型 `String`)。Source identifier for the skill (null defaults to "custom")
返回Returns AgentSkill
返回AgentSkill。Created AgentSkill instance
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if zipStream is null
  • RuntimeException 可能抛出 `RuntimeException`。if the zip content cannot be read
源码Source io/agentscope/core/skill/util/SkillUtil.java:270–272

createFromZip

public static AgentSkill createFromZip(InputStream zipStream, String source, Charset charset)
static

创建 createFromZip。

Creates an AgentSkill from a skill package zip input stream with custom source and charset.

参数Parameters
名称Name类型Type说明Description
zipStreamInputStreamzip 流(类型 `InputStream`)。Zip content stream
sourceString来源(类型 `String`)。Source identifier for the skill (null defaults to "custom")
charsetCharsetcharset(类型 `Charset`)。Charset used to decode zip entry names and file contents (null defaults to UTF-8). Use this when the zip was created with a non-UTF-8 charset such as GBK/GB18030 and the default overload fails during zip entry decoding with errors like `malformed input`
返回Returns AgentSkill
返回AgentSkill。Created AgentSkill instance
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if zipStream is null
  • RuntimeException 可能抛出 `RuntimeException`。if the zip content cannot be read
源码Source io/agentscope/core/skill/util/SkillUtil.java:290–355
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.