openbot 0.1.7 → 0.1.8
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 +63 -30
- package/dist/handlers/init.js +6 -4
- package/package.json +8 -8
package/dist/agent.js
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
|
-
import os from "node:os";
|
|
2
1
|
import { melony } from "melony";
|
|
3
2
|
import { shellPlugin, shellToolDefinitions } from "@melony/plugin-shell";
|
|
4
3
|
import { browserPlugin, browserToolDefinitions } from "@melony/plugin-browser";
|
|
5
4
|
import { fileSystemPlugin, fileSystemToolDefinitions } from "@melony/plugin-file-system";
|
|
6
5
|
import { metaAgentPlugin, metaAgentToolDefinitions, buildSystemPrompt } from "@melony/plugin-meta-agent";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { anthropic } from "@ai-sdk/anthropic";
|
|
6
|
+
import { openaiPlugin } from "@melony/plugin-openai";
|
|
7
|
+
import { anthropicPlugin } from "@melony/plugin-anthropic";
|
|
10
8
|
import { initHandler } from "./handlers/init.js";
|
|
11
9
|
import { loadConfig, resolvePath, DEFAULT_BASE_DIR } from "./config.js";
|
|
10
|
+
/**
|
|
11
|
+
* Parse model string to extract provider and model ID
|
|
12
|
+
* Supports formats: "provider:model", "provider/model", or just "model" (defaults to openai)
|
|
13
|
+
*/
|
|
14
|
+
function parseModelString(modelString) {
|
|
15
|
+
// Check for provider:model format
|
|
16
|
+
if (modelString.includes(":")) {
|
|
17
|
+
const [provider, modelId] = modelString.split(":");
|
|
18
|
+
if (provider === "openai" || provider === "anthropic") {
|
|
19
|
+
return { provider, modelId };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// Check for provider/model format
|
|
23
|
+
if (modelString.includes("/")) {
|
|
24
|
+
const [provider, modelId] = modelString.split("/");
|
|
25
|
+
if (provider === "openai" || provider === "anthropic") {
|
|
26
|
+
return { provider, modelId };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Auto-detect provider based on model name
|
|
30
|
+
if (modelString.startsWith("claude") || modelString.startsWith("claude-")) {
|
|
31
|
+
return { provider: "anthropic", modelId: modelString };
|
|
32
|
+
}
|
|
33
|
+
// Default to OpenAI
|
|
34
|
+
return { provider: "openai", modelId: modelString };
|
|
35
|
+
}
|
|
12
36
|
/**
|
|
13
37
|
* Create the OpenBot meta-agent
|
|
14
38
|
* This bot has self-modification capabilities, skill management, and persistent identity
|
|
@@ -25,42 +49,51 @@ export async function createOpenBot(options) {
|
|
|
25
49
|
}
|
|
26
50
|
const baseDir = config.baseDir || DEFAULT_BASE_DIR;
|
|
27
51
|
const resolvedBaseDir = resolvePath(baseDir);
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
52
|
+
// Parse model configuration
|
|
53
|
+
const { provider, modelId } = parseModelString(config.model || "gpt-4o-mini");
|
|
54
|
+
// Build dynamic system prompt from identity files and skills
|
|
55
|
+
const systemPrompt = await buildSystemPrompt(resolvedBaseDir);
|
|
56
|
+
// Tool definitions shared by both providers
|
|
57
|
+
const toolDefinitions = {
|
|
58
|
+
...shellToolDefinitions,
|
|
59
|
+
...browserToolDefinitions,
|
|
60
|
+
...fileSystemToolDefinitions,
|
|
61
|
+
...metaAgentToolDefinitions,
|
|
62
|
+
};
|
|
63
|
+
// Create the appropriate LLM plugin based on provider
|
|
64
|
+
let llmPlugin;
|
|
65
|
+
if (provider === "anthropic") {
|
|
66
|
+
if (!anthropicKey) {
|
|
67
|
+
console.warn("Warning: Anthropic model selected but ANTHROPIC_API_KEY is not set");
|
|
38
68
|
}
|
|
39
|
-
|
|
40
|
-
|
|
69
|
+
llmPlugin = anthropicPlugin({
|
|
70
|
+
apiKey: anthropicKey,
|
|
71
|
+
model: modelId,
|
|
72
|
+
system: systemPrompt,
|
|
73
|
+
toolDefinitions,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
if (!openaiKey) {
|
|
78
|
+
console.warn("Warning: OpenAI model selected but OPENAI_API_KEY is not set");
|
|
41
79
|
}
|
|
80
|
+
llmPlugin = openaiPlugin({
|
|
81
|
+
apiKey: openaiKey,
|
|
82
|
+
model: modelId,
|
|
83
|
+
system: systemPrompt,
|
|
84
|
+
toolDefinitions,
|
|
85
|
+
});
|
|
42
86
|
}
|
|
43
|
-
// Build dynamic system prompt from identity files and skills
|
|
44
|
-
const systemPrompt = await buildSystemPrompt(resolvedBaseDir);
|
|
45
87
|
return melony()
|
|
46
|
-
.use(shellPlugin({ cwd:
|
|
88
|
+
.use(shellPlugin({ cwd: process.cwd() }))
|
|
47
89
|
.use(browserPlugin({ headless: true }))
|
|
48
90
|
.use(fileSystemPlugin({
|
|
49
|
-
baseDir:
|
|
91
|
+
baseDir: "/", // Global access
|
|
50
92
|
}))
|
|
51
93
|
.use(metaAgentPlugin({
|
|
52
94
|
baseDir: resolvedBaseDir,
|
|
53
95
|
allowSoulModification: false, // Protect core values
|
|
54
96
|
}))
|
|
55
|
-
.use(
|
|
56
|
-
model,
|
|
57
|
-
system: systemPrompt,
|
|
58
|
-
toolDefinitions: {
|
|
59
|
-
...shellToolDefinitions,
|
|
60
|
-
...browserToolDefinitions,
|
|
61
|
-
...fileSystemToolDefinitions,
|
|
62
|
-
...metaAgentToolDefinitions,
|
|
63
|
-
}
|
|
64
|
-
}))
|
|
97
|
+
.use(llmPlugin)
|
|
65
98
|
.on("init", initHandler);
|
|
66
99
|
}
|
package/dist/handlers/init.js
CHANGED
|
@@ -6,11 +6,13 @@ export async function* initHandler(event) {
|
|
|
6
6
|
const thredUI = {
|
|
7
7
|
type: "thread",
|
|
8
8
|
props: {
|
|
9
|
-
placeholder: "Ask me anything...",
|
|
10
|
-
welcomeTitle: "
|
|
11
|
-
welcomeMessage: "I'm your
|
|
9
|
+
placeholder: "Ask me anything about your system or projects...",
|
|
10
|
+
welcomeTitle: "OpenBot System Agent",
|
|
11
|
+
welcomeMessage: "I'm your global system assistant. I have access to your file system and shell. How can I help you today?",
|
|
12
12
|
suggestions: [
|
|
13
|
-
"What
|
|
13
|
+
"What is in my current directory?",
|
|
14
|
+
"Check system status",
|
|
15
|
+
"Who am I?",
|
|
14
16
|
]
|
|
15
17
|
},
|
|
16
18
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openbot",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"openbot-server": "./dist/server.js"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
11
|
+
"@ai-sdk/anthropic": "^3.0.33",
|
|
12
12
|
"@ai-sdk/openai": "^3.0.13",
|
|
13
13
|
"@types/cors": "^2.8.19",
|
|
14
14
|
"commander": "^14.0.2",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"dotenv": "^16.4.5",
|
|
17
17
|
"express": "^4.19.2",
|
|
18
18
|
"zod": "^4.3.5",
|
|
19
|
-
"@melony/plugin-ai-sdk": "0.1.
|
|
20
|
-
"@melony/plugin-
|
|
21
|
-
"@melony/plugin-
|
|
22
|
-
"
|
|
23
|
-
"@melony/plugin-
|
|
24
|
-
"melony": "0.
|
|
19
|
+
"@melony/plugin-ai-sdk": "0.1.2",
|
|
20
|
+
"@melony/plugin-file-system": "0.1.1",
|
|
21
|
+
"@melony/plugin-meta-agent": "0.1.1",
|
|
22
|
+
"melony": "0.2.5",
|
|
23
|
+
"@melony/plugin-browser": "0.1.1",
|
|
24
|
+
"@melony/plugin-shell": "0.1.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/express": "^4.17.21",
|