class LoadSkill implements Tool, Transient

Constants

protected MAX_BYTES

The maximum number of bytes that may be read from a bundled file.

Properties

static protected Skill>> $discoveredSkills

The skills discovered in the configured cached paths, keyed by directory.

protected null|Skill> $skills

The resolved skills, keyed by name.

Methods

__construct(array $sources = [])

Create a new skill loading tool instance.

static array
mergeInto(array $tools, HasSkills $agent)

Add the agent's skills to the tools, merging them into a skill loading tool the agent already declares.

Stringable|string
description()

Get the description of the tool's purpose.

Stringable|string
handle(Request $request)

Execute the tool.

array
schema(JsonSchema $schema)

Get the tool's schema definition.

string
instructions(Skill $skill)

Get the skill's instructions and the files bundled alongside them.

string
resource(Skill $skill, string $path)

Read a file bundled with the given skill.

string|null
read(Skill $skill, string $path)

Read a file from the skill's directory, reading one byte past the limit so oversized files are detected.

array
resources(Skill $skill)

Get the paths of the files bundled with the given skill.

skills()

Resolve every skill available to the tool, keyed by name.

discover(string $directory)

Discover the skills stored in the given directory.

withSkills(iterable $sources)

Get a copy of the tool that also loads the given skills.

static void
flushState()

Flush all static state.

Details

at line 49
__construct(array $sources = [])

Create a new skill loading tool instance.

Parameters

array $sources

at line 59
static array mergeInto(array $tools, HasSkills $agent)

Add the agent's skills to the tools, merging them into a skill loading tool the agent already declares.

Parameters

array $tools
HasSkills $agent

Return Value

array

at line 81
Stringable|string description()

Get the description of the tool's purpose.

Return Value

Stringable|string

at line 92
Stringable|string handle(Request $request)

Execute the tool.

Parameters

Request $request

Return Value

Stringable|string

at line 112
array schema(JsonSchema $schema)

Get the tool's schema definition.

Parameters

JsonSchema $schema

Return Value

array

at line 131
protected string instructions(Skill $skill)

Get the skill's instructions and the files bundled alongside them.

Parameters

Skill $skill

Return Value

string

at line 144
protected string resource(Skill $skill, string $path)

Read a file bundled with the given skill.

Parameters

Skill $skill
string $path

Return Value

string

at line 161
protected string|null read(Skill $skill, string $path)

Read a file from the skill's directory, reading one byte past the limit so oversized files are detected.

Parameters

Skill $skill
string $path

Return Value

string|null

at line 178
protected array resources(Skill $skill)

Get the paths of the files bundled with the given skill.

Parameters

Skill $skill

Return Value

array

at line 201
protected Collection skills()

Resolve every skill available to the tool, keyed by name.

Return Value

Collection

at line 219
protected Collection discover(string $directory)

Discover the skills stored in the given directory.

Parameters

string $directory

Return Value

Collection

at line 247
protected LoadSkill withSkills(iterable $sources)

Get a copy of the tool that also loads the given skills.

Parameters

iterable $sources

Return Value

LoadSkill

at line 260
static void flushState()

Flush all static state.

Return Value

void