mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Tool result refactor (return an object instead of a string)
This commit is contained in:
40 files changed
+315
-276
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
import type { Tool } from './Tool';
|
||||
import type { Tool, ToolResult } from './Tool';
|
||||
import type { JSRuntimeFS } from '../JSRuntime';
|
||||
import { findSkill, readSkillContent } from '../plugins';
|
||||
|
||||
@@ -24,7 +24,7 @@ export class SkillTool implements Tool<SkillParams> {
|
||||
this.projectPath = projectPath;
|
||||
}
|
||||
|
||||
async execute(args: SkillParams): Promise<string> {
|
||||
async execute(args: SkillParams): Promise<ToolResult> {
|
||||
const { name } = args;
|
||||
|
||||
try {
|
||||
@@ -38,7 +38,8 @@ export class SkillTool implements Tool<SkillParams> {
|
||||
// Read and return the skill content
|
||||
const content = await readSkillContent(this.fs, skill);
|
||||
|
||||
return `# Skill: ${skill.name}
|
||||
return {
|
||||
content: `# Skill: ${skill.name}
|
||||
|
||||
**Source**: ${skill.plugin === 'project' ? 'Project' : `Plugin: ${skill.plugin}`}
|
||||
**Description**: ${skill.description}
|
||||
@@ -46,7 +47,8 @@ export class SkillTool implements Tool<SkillParams> {
|
||||
|
||||
---
|
||||
|
||||
${content}`;
|
||||
${content}`
|
||||
};
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw error;
|
||||
|
||||
Reference in new issue
Block a user