overai 1.4.10 → 1.4.11

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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,196 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ const index_1 = require("../index");
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const child_process_1 = require("child_process");
41
+ const util_1 = require("util");
42
+ const readline = __importStar(require("readline"));
43
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
44
+ // 1. Define Tools for the Agent
45
+ const fileTools = [
46
+ {
47
+ name: "write_file",
48
+ description: "Write content to a file. Use this to create code files.",
49
+ parameters: {
50
+ type: "object",
51
+ properties: {
52
+ path: { type: "string", description: "File path (relative to current directory)" },
53
+ content: { type: "string", description: "Content to write to the file" }
54
+ },
55
+ required: ["path", "content"]
56
+ },
57
+ execute: async ({ path: filePath, content }) => {
58
+ try {
59
+ const fullPath = path.resolve(process.cwd(), filePath);
60
+ // Ensure directory exists
61
+ const dir = path.dirname(fullPath);
62
+ if (!fs.existsSync(dir)) {
63
+ fs.mkdirSync(dir, { recursive: true });
64
+ }
65
+ fs.writeFileSync(fullPath, content);
66
+ return `✅ File created: ${filePath}`;
67
+ }
68
+ catch (error) {
69
+ return `❌ Error writing file: ${error.message}`;
70
+ }
71
+ }
72
+ },
73
+ {
74
+ name: "run_command",
75
+ description: "Run a shell command. Use this to install dependencies, run tests, etc.",
76
+ parameters: {
77
+ type: "object",
78
+ properties: {
79
+ command: { type: "string", description: "Shell command to execute" }
80
+ },
81
+ required: ["command"]
82
+ },
83
+ execute: async ({ command }) => {
84
+ try {
85
+ console.log(`💻 Executing: ${command}`);
86
+ const { stdout, stderr } = await execAsync(command);
87
+ return `STDOUT:\n${stdout}\n\nSTDERR:\n${stderr}`;
88
+ }
89
+ catch (error) {
90
+ return `❌ Command failed: ${error.message}`;
91
+ }
92
+ }
93
+ },
94
+ {
95
+ name: "read_file",
96
+ description: "Read a file's content.",
97
+ parameters: {
98
+ type: "object",
99
+ properties: {
100
+ path: { type: "string", description: "File path to read" }
101
+ },
102
+ required: ["path"]
103
+ },
104
+ execute: async ({ path: filePath }) => {
105
+ try {
106
+ const content = fs.readFileSync(path.resolve(process.cwd(), filePath), 'utf-8');
107
+ return content;
108
+ }
109
+ catch (error) {
110
+ return `❌ Error reading file: ${error.message}`;
111
+ }
112
+ }
113
+ }
114
+ ];
115
+ const rl = readline.createInterface({
116
+ input: process.stdin,
117
+ output: process.stdout
118
+ });
119
+ async function main() {
120
+ // Check for API Key
121
+ if (!process.env.OPENAI_API_KEY) {
122
+ console.error("❌ Error: OPENAI_API_KEY environment variable is not set.");
123
+ console.error("Please set it before running this command:");
124
+ console.error(" export OPENAI_API_KEY=sk-...");
125
+ process.exit(1);
126
+ }
127
+ // 2. Create the "AutoCoder" Agent
128
+ const coder = new index_1.Agent({
129
+ name: "AutoCoder",
130
+ instructions: `You are an Elite FullStack Software Architect and Engineer.
131
+ Your goal is to scaffold and build fully functional projects based on user requirements.
132
+
133
+ CAPABILITIES:
134
+ - You can create files and directories (write_file).
135
+ - You can run system commands (run_command) like npm, pip, git, etc.
136
+ - You can read files to check content (read_file).
137
+
138
+ PROCESS:
139
+ 1. ANALYZE: Understand the user's request and technology stack (Node, Python, React, etc.).
140
+ 2. PLAN: Decide on the directory structure and necessary files.
141
+ 3. SCAFFOLD: Create the project directory and initialize it (npm init, etc.).
142
+ 4. IMPLEMENT: Create the core files (index.js, main.py, App.tsx, etc.) with working code.
143
+ 5. DEPENDENCIES: Install necessary packages.
144
+ 6. VERIFY: Run a command to prove the project works or builds successfully.
145
+
146
+ RULES:
147
+ - ALWAYS start by creating a new directory for the project to avoid cluttering the root.
148
+ - Be comprehensive: Include README.md, .gitignore, and config files.
149
+ - If something fails, try to fix it or report the specific error.
150
+ - Do not ask for permission for each step, proceed autonomously until completion.`,
151
+ llm: "gpt-4o",
152
+ tools: fileTools
153
+ });
154
+ // 3. Get User Input
155
+ const question = (query) => {
156
+ return new Promise((resolve) => rl.question(query, resolve));
157
+ };
158
+ console.log("\n🚀 **OverAI Auto-Coder** initialized.");
159
+ console.log("I can build any project for you (Node.js, Python, simple websites, scripts...).");
160
+ // If argument provided via CLI, use it. Otherwise ask.
161
+ let userRequest = process.argv.slice(2).join(" ");
162
+ if (!userRequest) {
163
+ userRequest = await question("\n🛠️ What project should I build for you? (e.g., 'A weather CLI in Python', 'A React Todo app'): ");
164
+ }
165
+ else {
166
+ console.log(`\n🛠️ Request received: "${userRequest}"`);
167
+ }
168
+ rl.close();
169
+ if (!userRequest.trim()) {
170
+ console.log("❌ No request provided. Exiting.");
171
+ return;
172
+ }
173
+ const task = `
174
+ BUILD REQUEST: "${userRequest}"
175
+
176
+ Execute this request from start to finish.
177
+ 1. Create a suitable folder name based on the request.
178
+ 2. Implement the full solution.
179
+ 3. Verify it runs.
180
+ `;
181
+ // 4. Start OverAI
182
+ const overai = new index_1.OverAI({
183
+ agents: [coder],
184
+ tasks: [task],
185
+ verbose: true
186
+ });
187
+ console.log(`\n🤖 AutoCoder starting task...\n`);
188
+ try {
189
+ await overai.start();
190
+ console.log("\n✅ Mission Complete! Check the created folder.");
191
+ }
192
+ catch (error) {
193
+ console.error("❌ Mission Failed:", error);
194
+ }
195
+ }
196
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "overai",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
4
4
  "description": "OverAI TypeScript AI Agents Framework - Build, Deploy, and Monetize AI Agents in Minutes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,8 @@
10
10
  "LICENSE"
11
11
  ],
12
12
  "bin": {
13
- "overai": "./dist/cli/index.js"
13
+ "overai": "./dist/cli/index.js",
14
+ "overai-create": "./dist/cli/create.js"
14
15
  },
15
16
  "scripts": {
16
17
  "build": "tsc",