openbot 0.1.9 → 0.1.10
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/agent.js +21 -16
- package/dist/cli.js +1 -1
- package/dist/handlers/init.js +1 -1
- package/dist/server.js +5 -8
- package/package.json +2 -2
package/dist/agent.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import os from "node:os";
|
|
1
2
|
import { melony } from "melony";
|
|
2
3
|
import { shellPlugin, shellToolDefinitions } from "@melony/plugin-shell";
|
|
3
4
|
import { browserPlugin, browserToolDefinitions } from "@melony/plugin-browser";
|
|
4
5
|
import { fileSystemPlugin, fileSystemToolDefinitions } from "@melony/plugin-file-system";
|
|
5
6
|
import { metaAgentPlugin, metaAgentToolDefinitions, buildSystemPrompt } from "@melony/plugin-meta-agent";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { aiSDKPlugin } from "@melony/plugin-ai-sdk";
|
|
8
|
+
import { openai } from "@ai-sdk/openai";
|
|
9
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
8
10
|
import { initHandler } from "./handlers/init.js";
|
|
9
11
|
import { loadConfig, resolvePath, DEFAULT_BASE_DIR } from "./config.js";
|
|
12
|
+
import path from "node:path";
|
|
10
13
|
/**
|
|
11
14
|
* Parse model string to extract provider and model ID
|
|
12
15
|
* Supports formats: "provider:model", "provider/model", or just "model" (defaults to openai)
|
|
@@ -61,32 +64,34 @@ export async function createOpenBot(options) {
|
|
|
61
64
|
...metaAgentToolDefinitions,
|
|
62
65
|
};
|
|
63
66
|
// Create the appropriate LLM plugin based on provider
|
|
64
|
-
let
|
|
67
|
+
let model;
|
|
65
68
|
if (provider === "anthropic") {
|
|
66
69
|
if (!anthropicKey) {
|
|
67
70
|
console.warn("Warning: Anthropic model selected but ANTHROPIC_API_KEY is not set");
|
|
68
71
|
}
|
|
69
|
-
|
|
70
|
-
apiKey: anthropicKey,
|
|
71
|
-
model: modelId,
|
|
72
|
-
system: systemPrompt,
|
|
73
|
-
toolDefinitions,
|
|
74
|
-
});
|
|
72
|
+
model = anthropic(modelId);
|
|
75
73
|
}
|
|
76
74
|
else {
|
|
77
75
|
if (!openaiKey) {
|
|
78
76
|
console.warn("Warning: OpenAI model selected but OPENAI_API_KEY is not set");
|
|
79
77
|
}
|
|
80
|
-
|
|
81
|
-
apiKey: openaiKey,
|
|
82
|
-
model: modelId,
|
|
83
|
-
system: systemPrompt,
|
|
84
|
-
toolDefinitions,
|
|
85
|
-
});
|
|
78
|
+
model = openai(modelId);
|
|
86
79
|
}
|
|
80
|
+
const llmPlugin = aiSDKPlugin({
|
|
81
|
+
model: model,
|
|
82
|
+
system: systemPrompt,
|
|
83
|
+
toolDefinitions,
|
|
84
|
+
});
|
|
85
|
+
// Use a dedicated directory for the agent's browser data to avoid conflicts with your main Chrome.
|
|
86
|
+
// Using the root Chrome directory causes conflicts and can log you out of your main browser.
|
|
87
|
+
const userDataDir = path.join(os.homedir(), ".openbot", "browser-data");
|
|
87
88
|
return melony()
|
|
88
89
|
.use(shellPlugin({ cwd: process.cwd() }))
|
|
89
|
-
.use(browserPlugin({
|
|
90
|
+
.use(browserPlugin({
|
|
91
|
+
headless: true, // Set to false once to log in manually if needed
|
|
92
|
+
userDataDir: userDataDir,
|
|
93
|
+
channel: 'chrome'
|
|
94
|
+
}))
|
|
90
95
|
.use(fileSystemPlugin({
|
|
91
96
|
baseDir: "/", // Global access
|
|
92
97
|
}))
|
package/dist/cli.js
CHANGED
package/dist/handlers/init.js
CHANGED
package/dist/server.js
CHANGED
|
@@ -16,6 +16,11 @@ program
|
|
|
16
16
|
const config = loadConfig();
|
|
17
17
|
const PORT = Number(options.port ?? config.port ?? process.env.PORT ?? 4001);
|
|
18
18
|
const app = express();
|
|
19
|
+
// Initialize the bot instance once at startup
|
|
20
|
+
const openBot = await createOpenBot({
|
|
21
|
+
openaiApiKey: options.openaiApiKey,
|
|
22
|
+
anthropicApiKey: options.anthropicApiKey,
|
|
23
|
+
});
|
|
19
24
|
// In-memory state store (use a real database for production)
|
|
20
25
|
const stateStore = new Map();
|
|
21
26
|
app.use(cors());
|
|
@@ -29,10 +34,6 @@ program
|
|
|
29
34
|
});
|
|
30
35
|
app.get("/api/init", async (req, res) => {
|
|
31
36
|
const platform = req.query.platform || "web";
|
|
32
|
-
const openBot = await createOpenBot({
|
|
33
|
-
openaiApiKey: options.openaiApiKey,
|
|
34
|
-
anthropicApiKey: options.anthropicApiKey,
|
|
35
|
-
});
|
|
36
37
|
const response = await openBot.jsonResponse({
|
|
37
38
|
type: "init",
|
|
38
39
|
data: { platform }
|
|
@@ -52,10 +53,6 @@ program
|
|
|
52
53
|
Connection: "keep-alive",
|
|
53
54
|
});
|
|
54
55
|
res.flushHeaders?.();
|
|
55
|
-
const openBot = await createOpenBot({
|
|
56
|
-
openaiApiKey: options.openaiApiKey,
|
|
57
|
-
anthropicApiKey: options.anthropicApiKey,
|
|
58
|
-
});
|
|
59
56
|
const runtime = openBot.build();
|
|
60
57
|
const runId = body.runId ?? "default";
|
|
61
58
|
const state = stateStore.get(runId) ?? {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openbot",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"express": "^4.19.2",
|
|
18
18
|
"zod": "^4.3.5",
|
|
19
19
|
"@melony/plugin-ai-sdk": "0.1.2",
|
|
20
|
+
"@melony/plugin-file-system": "0.1.1",
|
|
20
21
|
"@melony/plugin-browser": "0.1.1",
|
|
21
22
|
"@melony/plugin-meta-agent": "0.1.1",
|
|
22
23
|
"@melony/plugin-shell": "0.1.1",
|
|
23
|
-
"@melony/plugin-file-system": "0.1.1",
|
|
24
24
|
"melony": "0.2.5"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|