@agentvoy/core 0.2.0 ā 0.4.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/README.md +65 -0
- package/dist/adapters/anthropic.d.ts.map +1 -1
- package/dist/adapters/anthropic.js +75 -75
- package/dist/adapters/anthropic.js.map +1 -1
- package/dist/adapters/app-scaffold.d.ts +12 -0
- package/dist/adapters/app-scaffold.d.ts.map +1 -0
- package/dist/adapters/app-scaffold.js +49 -0
- package/dist/adapters/app-scaffold.js.map +1 -0
- package/dist/adapters/autogen.d.ts +8 -0
- package/dist/adapters/autogen.d.ts.map +1 -0
- package/dist/adapters/autogen.js +259 -0
- package/dist/adapters/autogen.js.map +1 -0
- package/dist/adapters/crewai.d.ts.map +1 -1
- package/dist/adapters/crewai.js +80 -52
- package/dist/adapters/crewai.js.map +1 -1
- package/dist/adapters/google-adk.d.ts.map +1 -1
- package/dist/adapters/google-adk.js +73 -37
- package/dist/adapters/google-adk.js.map +1 -1
- package/dist/adapters/index.js +4 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/langgraph.d.ts.map +1 -1
- package/dist/adapters/langgraph.js +41 -42
- package/dist/adapters/langgraph.js.map +1 -1
- package/dist/adapters/llamaindex.d.ts +8 -0
- package/dist/adapters/llamaindex.d.ts.map +1 -0
- package/dist/adapters/llamaindex.js +230 -0
- package/dist/adapters/llamaindex.js.map +1 -0
- package/dist/adapters/openai.d.ts.map +1 -1
- package/dist/adapters/openai.js +76 -53
- package/dist/adapters/openai.js.map +1 -1
- package/dist/deployers/api-wrapper.d.ts +11 -0
- package/dist/deployers/api-wrapper.d.ts.map +1 -0
- package/dist/deployers/api-wrapper.js +86 -0
- package/dist/deployers/api-wrapper.js.map +1 -0
- package/dist/deployers/aws-lambda.d.ts +3 -0
- package/dist/deployers/aws-lambda.d.ts.map +1 -0
- package/dist/deployers/aws-lambda.js +101 -0
- package/dist/deployers/aws-lambda.js.map +1 -0
- package/dist/deployers/docker.d.ts +3 -0
- package/dist/deployers/docker.d.ts.map +1 -0
- package/dist/deployers/docker.js +123 -0
- package/dist/deployers/docker.js.map +1 -0
- package/dist/deployers/fly-io.d.ts +3 -0
- package/dist/deployers/fly-io.d.ts.map +1 -0
- package/dist/deployers/fly-io.js +84 -0
- package/dist/deployers/fly-io.js.map +1 -0
- package/dist/deployers/gcp-cloud-run.d.ts +3 -0
- package/dist/deployers/gcp-cloud-run.d.ts.map +1 -0
- package/dist/deployers/gcp-cloud-run.js +75 -0
- package/dist/deployers/gcp-cloud-run.js.map +1 -0
- package/dist/deployers/guard-mapper.d.ts +6 -0
- package/dist/deployers/guard-mapper.d.ts.map +1 -0
- package/dist/deployers/guard-mapper.js +63 -0
- package/dist/deployers/guard-mapper.js.map +1 -0
- package/dist/deployers/index.d.ts +6 -0
- package/dist/deployers/index.d.ts.map +1 -0
- package/dist/deployers/index.js +30 -0
- package/dist/deployers/index.js.map +1 -0
- package/dist/deployers/pipeline.d.ts +9 -0
- package/dist/deployers/pipeline.d.ts.map +1 -0
- package/dist/deployers/pipeline.js +55 -0
- package/dist/deployers/pipeline.js.map +1 -0
- package/dist/deployers/railway.d.ts +3 -0
- package/dist/deployers/railway.d.ts.map +1 -0
- package/dist/deployers/railway.js +53 -0
- package/dist/deployers/railway.js.map +1 -0
- package/dist/deployers/registry.d.ts +7 -0
- package/dist/deployers/registry.d.ts.map +1 -0
- package/dist/deployers/registry.js +29 -0
- package/dist/deployers/registry.js.map +1 -0
- package/dist/deployers/streamlit-app.d.ts +10 -0
- package/dist/deployers/streamlit-app.d.ts.map +1 -0
- package/dist/deployers/streamlit-app.js +80 -0
- package/dist/deployers/streamlit-app.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +41 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +17 -1
- package/src/adapters/anthropic.ts +0 -268
- package/src/adapters/crewai.ts +0 -254
- package/src/adapters/google-adk.ts +0 -167
- package/src/adapters/index.ts +0 -21
- package/src/adapters/langgraph.ts +0 -336
- package/src/adapters/openai.ts +0 -214
- package/src/adapters/registry.ts +0 -37
- package/src/config.ts +0 -315
- package/src/index.ts +0 -54
- package/src/types.ts +0 -203
- package/tsconfig.json +0 -8
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LangGraph Adapter
|
|
3
|
-
*
|
|
4
|
-
* Scaffolds projects using LangGraph (Python) ā stateful, graph-based agent workflows.
|
|
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 langgraphAdapter: FrameworkAdapter = {
|
|
18
|
-
name: "langgraph",
|
|
19
|
-
displayName: "LangGraph",
|
|
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(),
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
path: "state.py",
|
|
34
|
-
content: generateStateFile(config),
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
path: "run.py",
|
|
38
|
-
content: generateRunFile(config),
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
path: "requirements.txt",
|
|
42
|
-
content: generateRequirements(config),
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
path: ".env.example",
|
|
46
|
-
content: generateEnvExample(config),
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
path: "agent.guard.yml",
|
|
50
|
-
content: generateDefaultConfig(
|
|
51
|
-
config.projectName,
|
|
52
|
-
"langgraph",
|
|
53
|
-
config.model.model || "gpt-4o"
|
|
54
|
-
),
|
|
55
|
-
},
|
|
56
|
-
];
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
files,
|
|
60
|
-
dependencies: {},
|
|
61
|
-
devDependencies: {},
|
|
62
|
-
scripts: {
|
|
63
|
-
start: "python run.py",
|
|
64
|
-
},
|
|
65
|
-
postInstallInstructions: [
|
|
66
|
-
"pip install -r requirements.txt",
|
|
67
|
-
"cp .env.example .env",
|
|
68
|
-
`Add your ${getApiKeyEnv(config)} to .env`,
|
|
69
|
-
"python run.py",
|
|
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
|
-
const supported = ["openai", "anthropic", "google"];
|
|
79
|
-
if (!supported.includes(config.model.provider)) {
|
|
80
|
-
warnings.push({
|
|
81
|
-
field: "model.provider",
|
|
82
|
-
message: `LangGraph works best with providers: ${supported.join(", ")}. Got "${config.model.provider}"`,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return { valid: errors.length === 0, errors, warnings };
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
getDependencies() {
|
|
90
|
-
return {
|
|
91
|
-
langgraph: ">=0.2.0",
|
|
92
|
-
langchain: ">=0.3.0",
|
|
93
|
-
"langchain-core": ">=0.3.0",
|
|
94
|
-
"python-dotenv": ">=1.0.0",
|
|
95
|
-
};
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
function getApiKeyEnv(config: ScaffoldConfig): string {
|
|
100
|
-
const envMap: Record<string, string> = {
|
|
101
|
-
openai: "OPENAI_API_KEY",
|
|
102
|
-
anthropic: "ANTHROPIC_API_KEY",
|
|
103
|
-
google: "GOOGLE_API_KEY",
|
|
104
|
-
};
|
|
105
|
-
return envMap[config.model.provider] || "API_KEY";
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function getLangChainPackage(config: ScaffoldConfig): string {
|
|
109
|
-
const pkgMap: Record<string, string> = {
|
|
110
|
-
openai: "langchain-openai",
|
|
111
|
-
anthropic: "langchain-anthropic",
|
|
112
|
-
google: "langchain-google-genai",
|
|
113
|
-
};
|
|
114
|
-
return pkgMap[config.model.provider] || "langchain-openai";
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function getLLMImport(config: ScaffoldConfig): string {
|
|
118
|
-
const importMap: Record<string, string> = {
|
|
119
|
-
openai: "from langchain_openai import ChatOpenAI",
|
|
120
|
-
anthropic: "from langchain_anthropic import ChatAnthropic",
|
|
121
|
-
google: "from langchain_google_genai import ChatGoogleGenerativeAI",
|
|
122
|
-
};
|
|
123
|
-
return importMap[config.model.provider] || "from langchain_openai import ChatOpenAI";
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function getLLMClass(config: ScaffoldConfig): string {
|
|
127
|
-
const classMap: Record<string, string> = {
|
|
128
|
-
openai: "ChatOpenAI",
|
|
129
|
-
anthropic: "ChatAnthropic",
|
|
130
|
-
google: "ChatGoogleGenerativeAI",
|
|
131
|
-
};
|
|
132
|
-
return classMap[config.model.provider] || "ChatOpenAI";
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function generateAgentFile(config: ScaffoldConfig): string {
|
|
136
|
-
const model = config.model.model || "gpt-4o";
|
|
137
|
-
const maxIterations = config.guardrails?.behavior?.max_iterations || 20;
|
|
138
|
-
const llmImport = getLLMImport(config);
|
|
139
|
-
const llmClass = getLLMClass(config);
|
|
140
|
-
|
|
141
|
-
return `"""
|
|
142
|
-
${config.projectName} ā Built with AgentVoy
|
|
143
|
-
https://github.com/agentvoy
|
|
144
|
-
|
|
145
|
-
LangGraph agent with a stateful agentic loop.
|
|
146
|
-
"""
|
|
147
|
-
|
|
148
|
-
from langchain_core.messages import HumanMessage, SystemMessage
|
|
149
|
-
from langgraph.graph import StateGraph, END
|
|
150
|
-
from langgraph.prebuilt import ToolNode
|
|
151
|
-
${llmImport}
|
|
152
|
-
|
|
153
|
-
from state import AgentState
|
|
154
|
-
from tools import get_tools
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
def create_graph():
|
|
158
|
-
"""Build the agent state graph."""
|
|
159
|
-
tools = get_tools()
|
|
160
|
-
llm = ${llmClass}(model="${model}").bind_tools(tools)
|
|
161
|
-
tool_node = ToolNode(tools)
|
|
162
|
-
|
|
163
|
-
def should_continue(state: AgentState) -> str:
|
|
164
|
-
"""Route: call tools or finish."""
|
|
165
|
-
messages = state["messages"]
|
|
166
|
-
last = messages[-1]
|
|
167
|
-
if last.tool_calls:
|
|
168
|
-
return "tools"
|
|
169
|
-
return END
|
|
170
|
-
|
|
171
|
-
def call_model(state: AgentState) -> dict:
|
|
172
|
-
"""Call the LLM with current messages."""
|
|
173
|
-
messages = state["messages"]
|
|
174
|
-
iteration = state.get("iteration", 0)
|
|
175
|
-
|
|
176
|
-
if iteration >= ${maxIterations}:
|
|
177
|
-
from langchain_core.messages import AIMessage
|
|
178
|
-
return {
|
|
179
|
-
"messages": [AIMessage(content="Max iterations reached.")],
|
|
180
|
-
"iteration": iteration,
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
response = llm.invoke(messages)
|
|
184
|
-
return {
|
|
185
|
-
"messages": [response],
|
|
186
|
-
"iteration": iteration + 1,
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
# Build the graph
|
|
190
|
-
graph = StateGraph(AgentState)
|
|
191
|
-
graph.add_node("agent", call_model)
|
|
192
|
-
graph.add_node("tools", tool_node)
|
|
193
|
-
|
|
194
|
-
graph.set_entry_point("agent")
|
|
195
|
-
graph.add_conditional_edges("agent", should_continue)
|
|
196
|
-
graph.add_edge("tools", "agent")
|
|
197
|
-
|
|
198
|
-
return graph.compile()
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
def run_agent(prompt: str) -> str:
|
|
202
|
-
"""Run the agent graph with a user prompt."""
|
|
203
|
-
app = create_graph()
|
|
204
|
-
|
|
205
|
-
initial_state = {
|
|
206
|
-
"messages": [HumanMessage(content=prompt)],
|
|
207
|
-
"iteration": 0,
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
final_state = app.invoke(initial_state)
|
|
211
|
-
messages = final_state["messages"]
|
|
212
|
-
|
|
213
|
-
# Return the last AI message text
|
|
214
|
-
for msg in reversed(messages):
|
|
215
|
-
if hasattr(msg, "content") and isinstance(msg.content, str):
|
|
216
|
-
return msg.content
|
|
217
|
-
|
|
218
|
-
return "Done."
|
|
219
|
-
`;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function generateStateFile(_config: ScaffoldConfig): string {
|
|
223
|
-
return `"""
|
|
224
|
-
Agent state definition for LangGraph.
|
|
225
|
-
"""
|
|
226
|
-
|
|
227
|
-
from typing import TypedDict, Annotated, Sequence
|
|
228
|
-
from langchain_core.messages import BaseMessage
|
|
229
|
-
import operator
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
class AgentState(TypedDict):
|
|
233
|
-
"""State passed between nodes in the graph."""
|
|
234
|
-
messages: Annotated[Sequence[BaseMessage], operator.add]
|
|
235
|
-
iteration: int
|
|
236
|
-
`;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function generateToolsFile(): string {
|
|
240
|
-
return `"""
|
|
241
|
-
Agent tools ā add your custom tools here.
|
|
242
|
-
LangGraph uses @tool decorated functions from langchain_core.
|
|
243
|
-
"""
|
|
244
|
-
|
|
245
|
-
from langchain_core.tools import tool
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
@tool
|
|
249
|
-
def search_web(query: str) -> str:
|
|
250
|
-
"""Search the web for information on a given topic.
|
|
251
|
-
|
|
252
|
-
Args:
|
|
253
|
-
query: The search query.
|
|
254
|
-
"""
|
|
255
|
-
# TODO: Implement your search logic (e.g., Tavily, Serper, Brave Search)
|
|
256
|
-
# Example with Tavily:
|
|
257
|
-
# from tavily import TavilyClient
|
|
258
|
-
# client = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])
|
|
259
|
-
# return client.search(query)["results"][0]["content"]
|
|
260
|
-
return f"Search results for: {query}"
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
@tool
|
|
264
|
-
def read_file(path: str) -> str:
|
|
265
|
-
"""Read the contents of a file.
|
|
266
|
-
|
|
267
|
-
Args:
|
|
268
|
-
path: Path to the file to read.
|
|
269
|
-
"""
|
|
270
|
-
try:
|
|
271
|
-
with open(path, "r") as f:
|
|
272
|
-
return f.read()
|
|
273
|
-
except FileNotFoundError:
|
|
274
|
-
return f"File not found: {path}"
|
|
275
|
-
except PermissionError:
|
|
276
|
-
return f"Permission denied: {path}"
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
def get_tools() -> list:
|
|
280
|
-
"""Return all available tools."""
|
|
281
|
-
return [search_web, read_file]
|
|
282
|
-
`;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
function generateRunFile(config: ScaffoldConfig): string {
|
|
286
|
-
return `"""
|
|
287
|
-
Run the ${config.projectName} agent.
|
|
288
|
-
"""
|
|
289
|
-
|
|
290
|
-
from dotenv import load_dotenv
|
|
291
|
-
from agent import run_agent
|
|
292
|
-
|
|
293
|
-
load_dotenv()
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
def main():
|
|
297
|
-
print("\\nš ${config.projectName} ā Powered by AgentVoy")
|
|
298
|
-
print("=" * 50)
|
|
299
|
-
print("Type your prompt (or 'quit' to exit):\\n")
|
|
300
|
-
|
|
301
|
-
while True:
|
|
302
|
-
try:
|
|
303
|
-
prompt = input("> ")
|
|
304
|
-
if prompt.lower() in ("quit", "exit", "q"):
|
|
305
|
-
print("\\nGoodbye!")
|
|
306
|
-
break
|
|
307
|
-
if not prompt.strip():
|
|
308
|
-
continue
|
|
309
|
-
|
|
310
|
-
print("\\nThinking...\\n")
|
|
311
|
-
result = run_agent(prompt)
|
|
312
|
-
print(f"\\n{result}\\n")
|
|
313
|
-
except KeyboardInterrupt:
|
|
314
|
-
print("\\n\\nGoodbye!")
|
|
315
|
-
break
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
if __name__ == "__main__":
|
|
319
|
-
main()
|
|
320
|
-
`;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function generateRequirements(config: ScaffoldConfig): string {
|
|
324
|
-
const langchainPkg = getLangChainPackage(config);
|
|
325
|
-
return `langgraph>=0.2.0
|
|
326
|
-
langchain>=0.3.0
|
|
327
|
-
langchain-core>=0.3.0
|
|
328
|
-
${langchainPkg}>=0.2.0
|
|
329
|
-
python-dotenv>=1.0.0
|
|
330
|
-
`;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
function generateEnvExample(config: ScaffoldConfig): string {
|
|
334
|
-
const envKey = getApiKeyEnv(config);
|
|
335
|
-
return `${envKey}=your-api-key-here\n`;
|
|
336
|
-
}
|
package/src/adapters/openai.ts
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
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
|
-
}
|
package/src/adapters/registry.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
}
|