@agentvoy/core 0.1.0
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/dist/adapters/crewai.d.ts +8 -0
- package/dist/adapters/crewai.d.ts.map +1 -0
- package/dist/adapters/crewai.js +229 -0
- package/dist/adapters/crewai.js.map +1 -0
- package/dist/adapters/google-adk.d.ts +8 -0
- package/dist/adapters/google-adk.d.ts.map +1 -0
- package/dist/adapters/google-adk.js +146 -0
- package/dist/adapters/google-adk.js.map +1 -0
- package/dist/adapters/index.d.ts +7 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +23 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/openai.d.ts +8 -0
- package/dist/adapters/openai.d.ts.map +1 -0
- package/dist/adapters/openai.js +193 -0
- package/dist/adapters/openai.js.map +1 -0
- package/dist/adapters/registry.d.ts +13 -0
- package/dist/adapters/registry.d.ts.map +1 -0
- package/dist/adapters/registry.js +35 -0
- package/dist/adapters/registry.js.map +1 -0
- package/dist/config.d.ts +28 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +284 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +152 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +23 -0
- package/src/adapters/crewai.ts +254 -0
- package/src/adapters/google-adk.ts +167 -0
- package/src/adapters/index.ts +17 -0
- package/src/adapters/openai.ts +214 -0
- package/src/adapters/registry.ts +37 -0
- package/src/config.ts +315 -0
- package/src/index.ts +54 -0
- package/src/types.ts +203 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CrewAI Adapter
|
|
3
|
+
*
|
|
4
|
+
* Scaffolds projects using CrewAI (Python).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
FrameworkAdapter,
|
|
9
|
+
ScaffoldConfig,
|
|
10
|
+
ScaffoldResult,
|
|
11
|
+
AgentGuardConfig,
|
|
12
|
+
ValidationResult,
|
|
13
|
+
GeneratedFile,
|
|
14
|
+
} from "../types.js";
|
|
15
|
+
import { generateDefaultConfig } from "../config.js";
|
|
16
|
+
|
|
17
|
+
export const crewaiAdapter: FrameworkAdapter = {
|
|
18
|
+
name: "crewai",
|
|
19
|
+
displayName: "CrewAI",
|
|
20
|
+
language: "python",
|
|
21
|
+
|
|
22
|
+
async scaffold(config: ScaffoldConfig): Promise<ScaffoldResult> {
|
|
23
|
+
const files: GeneratedFile[] = [
|
|
24
|
+
{
|
|
25
|
+
path: "crew.py",
|
|
26
|
+
content: generateCrewFile(config),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
path: "agents.py",
|
|
30
|
+
content: generateAgentsFile(config),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
path: "tasks.py",
|
|
34
|
+
content: generateTasksFile(config),
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
path: "tools.py",
|
|
38
|
+
content: generateToolsFile(),
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
path: "run.py",
|
|
42
|
+
content: generateRunFile(config),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
path: "requirements.txt",
|
|
46
|
+
content: generateRequirements(),
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
path: ".env.example",
|
|
50
|
+
content: generateEnvExample(config),
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
path: "agent.guard.yml",
|
|
54
|
+
content: generateDefaultConfig(
|
|
55
|
+
config.projectName,
|
|
56
|
+
config.model.provider,
|
|
57
|
+
config.model.model
|
|
58
|
+
),
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
files,
|
|
64
|
+
dependencies: {},
|
|
65
|
+
devDependencies: {},
|
|
66
|
+
scripts: {
|
|
67
|
+
start: "python run.py",
|
|
68
|
+
},
|
|
69
|
+
postInstallInstructions: [
|
|
70
|
+
"pip install -r requirements.txt",
|
|
71
|
+
"cp .env.example .env",
|
|
72
|
+
"Add your API key to .env",
|
|
73
|
+
"python run.py",
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
validateConfig(config: AgentGuardConfig): ValidationResult {
|
|
79
|
+
const errors: { field: string; message: string }[] = [];
|
|
80
|
+
const warnings: { field: string; message: string }[] = [];
|
|
81
|
+
|
|
82
|
+
const supported = ["openai", "anthropic", "google", "ollama", "groq"];
|
|
83
|
+
if (!supported.includes(config.model.provider)) {
|
|
84
|
+
warnings.push({
|
|
85
|
+
field: "model.provider",
|
|
86
|
+
message: `CrewAI supports: ${supported.join(", ")}. Got "${config.model.provider}" ā this may require additional configuration.`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return { valid: errors.length === 0, errors, warnings };
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
getDependencies() {
|
|
94
|
+
return {
|
|
95
|
+
crewai: ">=0.80.0",
|
|
96
|
+
"crewai-tools": ">=0.14.0",
|
|
97
|
+
"python-dotenv": ">=1.0.0",
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
function generateCrewFile(config: ScaffoldConfig): string {
|
|
103
|
+
return `"""
|
|
104
|
+
${config.projectName} Crew ā Built with AgentVoy
|
|
105
|
+
https://github.com/agentvoy
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
from crewai import Crew, Process
|
|
109
|
+
from agents import researcher, writer
|
|
110
|
+
from tasks import research_task, write_task
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def create_crew() -> Crew:
|
|
114
|
+
"""Create the crew with AgentVoy guardrails."""
|
|
115
|
+
crew = Crew(
|
|
116
|
+
agents=[researcher, writer],
|
|
117
|
+
tasks=[research_task, write_task],
|
|
118
|
+
process=Process.sequential,
|
|
119
|
+
verbose=True,
|
|
120
|
+
)
|
|
121
|
+
return crew
|
|
122
|
+
`;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function generateAgentsFile(config: ScaffoldConfig): string {
|
|
126
|
+
const model = config.model.model || "gpt-4o";
|
|
127
|
+
|
|
128
|
+
return `"""
|
|
129
|
+
Agent definitions for ${config.projectName}.
|
|
130
|
+
"""
|
|
131
|
+
|
|
132
|
+
from crewai import Agent
|
|
133
|
+
from tools import search_tool
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
researcher = Agent(
|
|
137
|
+
role="Research Analyst",
|
|
138
|
+
goal="Find accurate and comprehensive information on the given topic",
|
|
139
|
+
backstory="""You are an experienced research analyst with a keen eye
|
|
140
|
+
for detail. You excel at finding relevant information and synthesizing
|
|
141
|
+
it into clear insights.""",
|
|
142
|
+
tools=[search_tool],
|
|
143
|
+
llm="${model}",
|
|
144
|
+
verbose=True,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
writer = Agent(
|
|
148
|
+
role="Content Writer",
|
|
149
|
+
goal="Create clear, engaging content based on research findings",
|
|
150
|
+
backstory="""You are a skilled writer who transforms complex research
|
|
151
|
+
into readable, well-structured content. You focus on clarity and
|
|
152
|
+
accuracy.""",
|
|
153
|
+
llm="${model}",
|
|
154
|
+
verbose=True,
|
|
155
|
+
)
|
|
156
|
+
`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function generateTasksFile(config: ScaffoldConfig): string {
|
|
160
|
+
return `"""
|
|
161
|
+
Task definitions for ${config.projectName}.
|
|
162
|
+
"""
|
|
163
|
+
|
|
164
|
+
from crewai import Task
|
|
165
|
+
from agents import researcher, writer
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
research_task = Task(
|
|
169
|
+
description="""Research the following topic thoroughly: {topic}
|
|
170
|
+
|
|
171
|
+
Provide:
|
|
172
|
+
- Key facts and findings
|
|
173
|
+
- Relevant statistics
|
|
174
|
+
- Expert opinions or notable perspectives
|
|
175
|
+
""",
|
|
176
|
+
expected_output="A detailed research summary with key findings and sources.",
|
|
177
|
+
agent=researcher,
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
write_task = Task(
|
|
181
|
+
description="""Using the research provided, write a clear and engaging
|
|
182
|
+
summary about: {topic}
|
|
183
|
+
|
|
184
|
+
The output should be well-structured and accessible to a general audience.
|
|
185
|
+
""",
|
|
186
|
+
expected_output="A well-written article or summary based on the research.",
|
|
187
|
+
agent=writer,
|
|
188
|
+
)
|
|
189
|
+
`;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function generateToolsFile(): string {
|
|
193
|
+
return `"""
|
|
194
|
+
Agent tools ā add your custom tools here.
|
|
195
|
+
"""
|
|
196
|
+
|
|
197
|
+
from crewai.tools import tool
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
@tool("Search")
|
|
201
|
+
def search_tool(query: str) -> str:
|
|
202
|
+
"""Search for information on a given topic."""
|
|
203
|
+
# TODO: Implement your search logic (e.g., using SerperDev, Tavily, etc.)
|
|
204
|
+
return f"Search results for: {query}"
|
|
205
|
+
`;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function generateRunFile(config: ScaffoldConfig): string {
|
|
209
|
+
return `"""
|
|
210
|
+
Run the ${config.projectName} crew.
|
|
211
|
+
"""
|
|
212
|
+
|
|
213
|
+
from dotenv import load_dotenv
|
|
214
|
+
from crew import create_crew
|
|
215
|
+
|
|
216
|
+
load_dotenv()
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def main():
|
|
220
|
+
print("\\nš ${config.projectName} ā Powered by AgentVoy")
|
|
221
|
+
print("=" * 50)
|
|
222
|
+
|
|
223
|
+
topic = input("\\nEnter a topic to research: ")
|
|
224
|
+
if not topic.strip():
|
|
225
|
+
print("No topic provided. Exiting.")
|
|
226
|
+
return
|
|
227
|
+
|
|
228
|
+
crew = create_crew()
|
|
229
|
+
result = crew.kickoff(inputs={"topic": topic})
|
|
230
|
+
|
|
231
|
+
print("\\n" + "=" * 50)
|
|
232
|
+
print("RESULT:")
|
|
233
|
+
print("=" * 50)
|
|
234
|
+
print(result)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
if __name__ == "__main__":
|
|
238
|
+
main()
|
|
239
|
+
`;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function generateRequirements(): string {
|
|
243
|
+
return `crewai>=0.80.0
|
|
244
|
+
crewai-tools>=0.14.0
|
|
245
|
+
python-dotenv>=1.0.0
|
|
246
|
+
`;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function generateEnvExample(config: ScaffoldConfig): string {
|
|
250
|
+
const envVar =
|
|
251
|
+
config.model.api_key_env ||
|
|
252
|
+
`${config.model.provider.toUpperCase()}_API_KEY`;
|
|
253
|
+
return `${envVar}=your-api-key-here\n`;
|
|
254
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Agent Development Kit (ADK) Adapter
|
|
3
|
+
*
|
|
4
|
+
* Scaffolds projects using Google's ADK (Python).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
FrameworkAdapter,
|
|
9
|
+
ScaffoldConfig,
|
|
10
|
+
ScaffoldResult,
|
|
11
|
+
AgentGuardConfig,
|
|
12
|
+
ValidationResult,
|
|
13
|
+
GeneratedFile,
|
|
14
|
+
} from "../types.js";
|
|
15
|
+
import { generateDefaultConfig } from "../config.js";
|
|
16
|
+
|
|
17
|
+
export const googleAdkAdapter: FrameworkAdapter = {
|
|
18
|
+
name: "google-adk",
|
|
19
|
+
displayName: "Google ADK",
|
|
20
|
+
language: "python",
|
|
21
|
+
|
|
22
|
+
async scaffold(config: ScaffoldConfig): Promise<ScaffoldResult> {
|
|
23
|
+
const agentDir = config.projectName.replace(/-/g, "_");
|
|
24
|
+
|
|
25
|
+
const files: GeneratedFile[] = [
|
|
26
|
+
{
|
|
27
|
+
path: `${agentDir}/__init__.py`,
|
|
28
|
+
content: "",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
path: `${agentDir}/agent.py`,
|
|
32
|
+
content: generateAgentFile(config),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
path: `${agentDir}/tools.py`,
|
|
36
|
+
content: generateToolsFile(config),
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
path: "requirements.txt",
|
|
40
|
+
content: generateRequirements(),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
path: ".env.example",
|
|
44
|
+
content: "GOOGLE_API_KEY=your-api-key-here\n",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
path: "agent.guard.yml",
|
|
48
|
+
content: generateDefaultConfig(
|
|
49
|
+
config.projectName,
|
|
50
|
+
"google",
|
|
51
|
+
config.model.model || "gemini-2.0-flash"
|
|
52
|
+
),
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
files,
|
|
58
|
+
dependencies: {},
|
|
59
|
+
devDependencies: {},
|
|
60
|
+
scripts: {
|
|
61
|
+
start: `adk run ${agentDir}`,
|
|
62
|
+
web: `adk web ${agentDir}`,
|
|
63
|
+
},
|
|
64
|
+
postInstallInstructions: [
|
|
65
|
+
"pip install -r requirements.txt",
|
|
66
|
+
"cp .env.example .env",
|
|
67
|
+
"Add your GOOGLE_API_KEY to .env",
|
|
68
|
+
`adk run ${agentDir}`,
|
|
69
|
+
`Or use the web UI: adk web ${agentDir}`,
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
validateConfig(config: AgentGuardConfig): ValidationResult {
|
|
75
|
+
const errors: { field: string; message: string }[] = [];
|
|
76
|
+
const warnings: { field: string; message: string }[] = [];
|
|
77
|
+
|
|
78
|
+
if (config.model.provider !== "google") {
|
|
79
|
+
warnings.push({
|
|
80
|
+
field: "model.provider",
|
|
81
|
+
message: `Google ADK works best with provider "google", got "${config.model.provider}"`,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return { valid: errors.length === 0, errors, warnings };
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
getDependencies() {
|
|
89
|
+
return {
|
|
90
|
+
"google-adk": ">=1.0.0",
|
|
91
|
+
"python-dotenv": ">=1.0.0",
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
function generateAgentFile(config: ScaffoldConfig): string {
|
|
97
|
+
const model = config.model.model || "gemini-2.0-flash";
|
|
98
|
+
|
|
99
|
+
return `"""
|
|
100
|
+
${config.projectName} ā Built with AgentVoy
|
|
101
|
+
https://github.com/agentvoy
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
from google.adk.agents import Agent
|
|
105
|
+
from .tools import search_web, read_file
|
|
106
|
+
|
|
107
|
+
root_agent = Agent(
|
|
108
|
+
name="${config.projectName}",
|
|
109
|
+
model="${model}",
|
|
110
|
+
description="AI agent created with AgentVoy",
|
|
111
|
+
instruction="""You are a helpful AI assistant.
|
|
112
|
+
|
|
113
|
+
Follow these guidelines:
|
|
114
|
+
- Be concise and accurate
|
|
115
|
+
- Ask for clarification when the request is ambiguous
|
|
116
|
+
- Respect the guardrails defined in agent.guard.yml
|
|
117
|
+
""",
|
|
118
|
+
tools=[search_web, read_file],
|
|
119
|
+
)
|
|
120
|
+
`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function generateToolsFile(_config: ScaffoldConfig): string {
|
|
124
|
+
return `"""
|
|
125
|
+
Agent tools ā add your custom tools here.
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
from google.adk.tools import FunctionTool
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def search_web(query: str) -> dict:
|
|
132
|
+
"""Search the web for information.
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
query: The search query string.
|
|
136
|
+
|
|
137
|
+
Returns:
|
|
138
|
+
A dictionary with search results.
|
|
139
|
+
"""
|
|
140
|
+
# TODO: Implement your search logic
|
|
141
|
+
return {"results": f"Search results for: {query}"}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def read_file(path: str) -> dict:
|
|
145
|
+
"""Read the contents of a file.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
path: Path to the file to read.
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
A dictionary with the file contents or an error message.
|
|
152
|
+
"""
|
|
153
|
+
try:
|
|
154
|
+
with open(path, "r") as f:
|
|
155
|
+
return {"content": f.read()}
|
|
156
|
+
except FileNotFoundError:
|
|
157
|
+
return {"error": f"File not found: {path}"}
|
|
158
|
+
except PermissionError:
|
|
159
|
+
return {"error": f"Permission denied: {path}"}
|
|
160
|
+
`;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function generateRequirements(): string {
|
|
164
|
+
return `google-adk>=1.0.0
|
|
165
|
+
python-dotenv>=1.0.0
|
|
166
|
+
`;
|
|
167
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework Adapters
|
|
3
|
+
*
|
|
4
|
+
* Auto-registers all built-in adapters on import.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { registerAdapter, getAdapter, listAdapters, listFrameworks, hasAdapter } from "./registry.js";
|
|
8
|
+
|
|
9
|
+
import { registerAdapter } from "./registry.js";
|
|
10
|
+
import { openaiAdapter } from "./openai.js";
|
|
11
|
+
import { googleAdkAdapter } from "./google-adk.js";
|
|
12
|
+
import { crewaiAdapter } from "./crewai.js";
|
|
13
|
+
|
|
14
|
+
// Register built-in adapters
|
|
15
|
+
registerAdapter(openaiAdapter);
|
|
16
|
+
registerAdapter(googleAdkAdapter);
|
|
17
|
+
registerAdapter(crewaiAdapter);
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Agents SDK Adapter
|
|
3
|
+
*
|
|
4
|
+
* Scaffolds projects using the OpenAI Agents SDK (Python).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
FrameworkAdapter,
|
|
9
|
+
ScaffoldConfig,
|
|
10
|
+
ScaffoldResult,
|
|
11
|
+
AgentGuardConfig,
|
|
12
|
+
ValidationResult,
|
|
13
|
+
GeneratedFile,
|
|
14
|
+
} from "../types.js";
|
|
15
|
+
import { generateDefaultConfig } from "../config.js";
|
|
16
|
+
|
|
17
|
+
export const openaiAdapter: FrameworkAdapter = {
|
|
18
|
+
name: "openai",
|
|
19
|
+
displayName: "OpenAI Agents SDK",
|
|
20
|
+
language: "python",
|
|
21
|
+
|
|
22
|
+
async scaffold(config: ScaffoldConfig): Promise<ScaffoldResult> {
|
|
23
|
+
const files: GeneratedFile[] = [
|
|
24
|
+
{
|
|
25
|
+
path: "agent.py",
|
|
26
|
+
content: generateAgentFile(config),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
path: "tools.py",
|
|
30
|
+
content: generateToolsFile(config),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
path: "run.py",
|
|
34
|
+
content: generateRunFile(config),
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
path: "requirements.txt",
|
|
38
|
+
content: generateRequirements(),
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
path: ".env.example",
|
|
42
|
+
content: "OPENAI_API_KEY=your-api-key-here\n",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
path: "agent.guard.yml",
|
|
46
|
+
content: generateDefaultConfig(
|
|
47
|
+
config.projectName,
|
|
48
|
+
config.model.provider,
|
|
49
|
+
config.model.model
|
|
50
|
+
),
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
files,
|
|
56
|
+
dependencies: {},
|
|
57
|
+
devDependencies: {},
|
|
58
|
+
scripts: {
|
|
59
|
+
start: "python run.py",
|
|
60
|
+
},
|
|
61
|
+
postInstallInstructions: [
|
|
62
|
+
"pip install -r requirements.txt",
|
|
63
|
+
"cp .env.example .env",
|
|
64
|
+
"Add your OPENAI_API_KEY to .env",
|
|
65
|
+
"python run.py",
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
validateConfig(config: AgentGuardConfig): ValidationResult {
|
|
71
|
+
const errors: { field: string; message: string }[] = [];
|
|
72
|
+
const warnings: { field: string; message: string }[] = [];
|
|
73
|
+
|
|
74
|
+
if (config.model.provider !== "openai") {
|
|
75
|
+
warnings.push({
|
|
76
|
+
field: "model.provider",
|
|
77
|
+
message: `OpenAI adapter works best with provider "openai", got "${config.model.provider}"`,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return { valid: errors.length === 0, errors, warnings };
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
getDependencies() {
|
|
85
|
+
return {
|
|
86
|
+
"openai-agents": ">=0.1.0",
|
|
87
|
+
"python-dotenv": ">=1.0.0",
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
function generateAgentFile(config: ScaffoldConfig): string {
|
|
93
|
+
const guardConfig = config.guardrails?.behavior;
|
|
94
|
+
const maxTurns = guardConfig?.max_iterations || 20;
|
|
95
|
+
|
|
96
|
+
return `"""
|
|
97
|
+
${config.projectName} ā Built with AgentVoy
|
|
98
|
+
https://github.com/agentvoy
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
from agents import Agent, Runner
|
|
102
|
+
from tools import get_tools
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def create_agent() -> Agent:
|
|
106
|
+
"""Create and configure the agent with AgentVoy guardrails."""
|
|
107
|
+
tools = get_tools()
|
|
108
|
+
|
|
109
|
+
agent = Agent(
|
|
110
|
+
name="${config.projectName}",
|
|
111
|
+
instructions="""You are a helpful AI assistant.
|
|
112
|
+
|
|
113
|
+
Follow these guidelines:
|
|
114
|
+
- Be concise and accurate
|
|
115
|
+
- Ask for clarification when the request is ambiguous
|
|
116
|
+
- Respect the guardrails defined in agent.guard.yml
|
|
117
|
+
""",
|
|
118
|
+
model="${config.model.model || "gpt-4o"}",
|
|
119
|
+
tools=tools,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
return agent
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
async def run_agent(prompt: str) -> str:
|
|
126
|
+
"""Run the agent with the given prompt."""
|
|
127
|
+
agent = create_agent()
|
|
128
|
+
result = await Runner.run(
|
|
129
|
+
agent,
|
|
130
|
+
prompt,
|
|
131
|
+
max_turns=${maxTurns},
|
|
132
|
+
)
|
|
133
|
+
return result.final_output
|
|
134
|
+
`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function generateToolsFile(_config: ScaffoldConfig): string {
|
|
138
|
+
return `"""
|
|
139
|
+
Agent tools ā add your custom tools here.
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
from agents import function_tool
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
@function_tool
|
|
146
|
+
def search_web(query: str) -> str:
|
|
147
|
+
"""Search the web for information."""
|
|
148
|
+
# TODO: Implement your search logic
|
|
149
|
+
return f"Search results for: {query}"
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
@function_tool
|
|
153
|
+
def read_file(path: str) -> str:
|
|
154
|
+
"""Read the contents of a file."""
|
|
155
|
+
try:
|
|
156
|
+
with open(path, "r") as f:
|
|
157
|
+
return f.read()
|
|
158
|
+
except FileNotFoundError:
|
|
159
|
+
return f"File not found: {path}"
|
|
160
|
+
except PermissionError:
|
|
161
|
+
return f"Permission denied: {path}"
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def get_tools() -> list:
|
|
165
|
+
"""Return all available tools."""
|
|
166
|
+
return [search_web, read_file]
|
|
167
|
+
`;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function generateRunFile(config: ScaffoldConfig): string {
|
|
171
|
+
return `"""
|
|
172
|
+
Run the ${config.projectName} agent.
|
|
173
|
+
"""
|
|
174
|
+
|
|
175
|
+
import asyncio
|
|
176
|
+
import os
|
|
177
|
+
from dotenv import load_dotenv
|
|
178
|
+
from agent import run_agent
|
|
179
|
+
|
|
180
|
+
load_dotenv()
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
async def main():
|
|
184
|
+
print("\\nš ${config.projectName} ā Powered by AgentVoy")
|
|
185
|
+
print("=" * 50)
|
|
186
|
+
print("Type your prompt (or 'quit' to exit):\\n")
|
|
187
|
+
|
|
188
|
+
while True:
|
|
189
|
+
try:
|
|
190
|
+
prompt = input("> ")
|
|
191
|
+
if prompt.lower() in ("quit", "exit", "q"):
|
|
192
|
+
print("\\nGoodbye!")
|
|
193
|
+
break
|
|
194
|
+
if not prompt.strip():
|
|
195
|
+
continue
|
|
196
|
+
|
|
197
|
+
print("\\nThinking...\\n")
|
|
198
|
+
result = await run_agent(prompt)
|
|
199
|
+
print(f"\\n{result}\\n")
|
|
200
|
+
except KeyboardInterrupt:
|
|
201
|
+
print("\\n\\nGoodbye!")
|
|
202
|
+
break
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
if __name__ == "__main__":
|
|
206
|
+
asyncio.run(main())
|
|
207
|
+
`;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function generateRequirements(): string {
|
|
211
|
+
return `openai-agents>=0.1.0
|
|
212
|
+
python-dotenv>=1.0.0
|
|
213
|
+
`;
|
|
214
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework Adapter Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all supported agent framework adapters.
|
|
5
|
+
* Each adapter knows how to scaffold a project for its framework.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Framework, FrameworkAdapter } from "../types.js";
|
|
9
|
+
|
|
10
|
+
const adapters = new Map<Framework, FrameworkAdapter>();
|
|
11
|
+
|
|
12
|
+
export function registerAdapter(adapter: FrameworkAdapter): void {
|
|
13
|
+
adapters.set(adapter.name, adapter);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getAdapter(framework: Framework): FrameworkAdapter {
|
|
17
|
+
const adapter = adapters.get(framework);
|
|
18
|
+
if (!adapter) {
|
|
19
|
+
const available = Array.from(adapters.keys()).join(", ");
|
|
20
|
+
throw new Error(
|
|
21
|
+
`Unknown framework: "${framework}". Available: ${available}`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return adapter;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function listAdapters(): FrameworkAdapter[] {
|
|
28
|
+
return Array.from(adapters.values());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function listFrameworks(): Framework[] {
|
|
32
|
+
return Array.from(adapters.keys());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function hasAdapter(framework: Framework): boolean {
|
|
36
|
+
return adapters.has(framework);
|
|
37
|
+
}
|