This repository has been archived by the owner on Jul 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
103 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"license": "GPL-3.0", | ||
"workspaces": [ | ||
"packages/*", | ||
"skills/*", | ||
"skill/*", | ||
"docs", | ||
"server" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { parseEnv, z } from "znv"; | ||
import { SkillListSchema } from "./schema"; | ||
|
||
export const { SKILLS } = parseEnv(process.env, { | ||
SKILLS: { | ||
schema: z.string().transform((value) => SkillListSchema.parse(JSON.parse(value))), | ||
description: "Skills configuration" | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { DynamicTool, type ToolInterface } from '@ava/lang' | ||
import { SKILLS } from './config' | ||
import { http } from './provider/http' | ||
|
||
export const createDynamicToolkit = async (): Promise<ToolInterface[]> => { | ||
return SKILLS.map((skill) => { | ||
console.info(`[Dynamic Skill] creating dynamic tool for ${skill.name} at ${skill.url}`) | ||
|
||
return new DynamicTool({ | ||
name: skill.name, | ||
description: skill.description, | ||
returnDirect: skill.returnDirect, | ||
async func(body) { | ||
const response = await http.post(skill.url, { | ||
body, | ||
responseType: 'json' | ||
}).text() | ||
|
||
return response | ||
} | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@ava/skill-dynamic", | ||
"module": "index.ts", | ||
"type": "module", | ||
"version": "0.0.0", | ||
"devDependencies": { | ||
"@types/bun": "latest" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"@ava/lang": "workspace:../../packages/lang", | ||
"got": "^14.2.1", | ||
"znv": "^0.4.0", | ||
"zod": "^3.23.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import got from "got" | ||
import { version } from "../package.json" | ||
|
||
export const http = got.extend({ | ||
headers: { | ||
"User-Agent": `ava-dynamic-skill/${version}`, | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { z } from "zod"; | ||
|
||
export const SkillSchema = z.object({ | ||
name: z.string(), | ||
description: z.string(), | ||
// schema: z.optional(z.any()).describe('JSON schema if the skill requires input'), | ||
returnDirect: z.boolean().optional().describe('Whether the skill returns the result directly or not').default(false), | ||
url: z.string().url().describe('HTTP POST URL to send the data to'), | ||
}) | ||
export type Skill = z.infer<typeof SkillSchema> | ||
|
||
export const SkillListSchema = z.array(SkillSchema) | ||
export type SkillList = z.infer<typeof SkillListSchema> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../../tsconfig.json" | ||
} |