openbot 0.2.13 → 0.3.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/agents/openbot/index.js +76 -0
- package/dist/agents/openbot/middleware/approval.js +132 -0
- package/dist/agents/openbot/runtime.js +289 -0
- package/dist/agents/openbot/system-prompt.js +32 -0
- package/dist/agents/openbot/tools/delegation.js +78 -0
- package/dist/agents/openbot/tools/mcp.js +99 -0
- package/dist/agents/openbot/tools/shell.js +91 -0
- package/dist/agents/openbot/tools/storage.js +75 -0
- package/dist/agents/openbot/tools/ui.js +176 -0
- package/dist/agents/system.js +20 -93
- package/dist/app/cli.js +1 -1
- package/dist/app/config.js +4 -1
- package/dist/app/server.js +15 -8
- package/dist/bus/agent-package.js +1 -0
- package/dist/bus/plugin.js +1 -0
- package/dist/bus/services.js +600 -0
- package/dist/bus/types.js +1 -0
- package/dist/harness/context.js +131 -0
- package/dist/harness/event-normalizer.js +59 -0
- package/dist/harness/orchestrator.js +27 -227
- package/dist/harness/process.js +25 -3
- package/dist/harness/queue-processor.js +227 -0
- package/dist/harness/runtime-factory.js +103 -0
- package/dist/plugins/ai-sdk/index.js +37 -0
- package/dist/plugins/ai-sdk/runtime.js +330 -0
- package/dist/plugins/ai-sdk/system-prompt.js +3 -0
- package/dist/plugins/ai-sdk.js +277 -87
- package/dist/plugins/approval/index.js +159 -0
- package/dist/plugins/approval.js +163 -0
- package/dist/plugins/delegation/index.js +79 -0
- package/dist/plugins/delegation.js +67 -11
- package/dist/plugins/mcp/index.js +108 -0
- package/dist/plugins/shell/index.js +99 -0
- package/dist/plugins/shell.js +123 -0
- package/dist/plugins/storage-tools/index.js +85 -0
- package/dist/plugins/storage.js +240 -5
- package/dist/plugins/ui/index.js +184 -0
- package/dist/plugins/ui.js +185 -21
- package/dist/registry/agents.js +138 -0
- package/dist/registry/plugins.js +91 -50
- package/dist/services/agent-packages.js +103 -0
- package/dist/services/plugins.js +98 -0
- package/dist/services/storage.js +360 -94
- package/docs/agents.md +39 -66
- package/docs/architecture.md +1 -1
- package/docs/plugins.md +70 -58
- package/docs/templates/AGENT.example.md +57 -0
- package/package.json +3 -2
- package/src/app/cli.ts +1 -1
- package/src/app/config.ts +14 -4
- package/src/app/server.ts +23 -10
- package/src/app/types.ts +385 -16
- package/src/assets/icon.svg +4 -1
- package/src/bus/plugin.ts +67 -0
- package/src/bus/services.ts +666 -0
- package/src/bus/types.ts +147 -0
- package/src/harness/context.ts +160 -0
- package/src/harness/event-normalizer.ts +82 -0
- package/src/harness/orchestrator.ts +35 -273
- package/src/harness/process.ts +28 -4
- package/src/harness/queue-processor.ts +309 -0
- package/src/harness/runtime-factory.ts +125 -0
- package/src/plugins/ai-sdk/index.ts +44 -0
- package/src/plugins/ai-sdk/runtime.ts +410 -0
- package/src/plugins/ai-sdk/system-prompt.ts +4 -0
- package/src/plugins/approval/index.ts +228 -0
- package/src/plugins/delegation/index.ts +94 -0
- package/src/plugins/mcp/index.ts +128 -0
- package/src/plugins/shell/index.ts +123 -0
- package/src/plugins/storage-tools/index.ts +101 -0
- package/src/plugins/ui/index.ts +227 -0
- package/src/registry/plugins.ts +106 -55
- package/src/services/plugins.ts +133 -0
- package/src/services/storage.ts +465 -137
- package/src/agents/system.ts +0 -112
- package/src/plugins/ai-sdk.ts +0 -197
- package/src/plugins/delegation.ts +0 -60
- package/src/plugins/mcp.ts +0 -154
- package/src/plugins/storage.ts +0 -725
- package/src/plugins/ui.ts +0 -57
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { exec } from 'node:child_process';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
import { DEFAULT_PLUGINS_DIR, DEFAULT_BASE_DIR, loadConfig, resolvePath, } from '../app/config.js';
|
|
7
|
+
import { invalidatePlugin } from '../registry/plugins.js';
|
|
8
|
+
const execAsync = promisify(exec);
|
|
9
|
+
const getPluginsDir = () => {
|
|
10
|
+
const config = loadConfig();
|
|
11
|
+
const baseDir = resolvePath(config.baseDir || DEFAULT_BASE_DIR);
|
|
12
|
+
return path.join(baseDir, DEFAULT_PLUGINS_DIR);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Lifecycle for community-built plugins distributed via npm.
|
|
16
|
+
* Each plugin is installed to `<plugins>/<npm-name>/` and is identified
|
|
17
|
+
* everywhere (AGENT.md `plugins[].id`, registry, runtime resolution) by its
|
|
18
|
+
* npm name. Scoped packages (`@scope/foo`) live under `<plugins>/@scope/foo/`.
|
|
19
|
+
*/
|
|
20
|
+
export const pluginService = {
|
|
21
|
+
isInstalled: async (packageName) => {
|
|
22
|
+
const finalPath = path.join(getPluginsDir(), packageName);
|
|
23
|
+
return existsSync(path.join(finalPath, 'dist', 'index.js'));
|
|
24
|
+
},
|
|
25
|
+
install: async ({ packageName, version }) => {
|
|
26
|
+
const pluginsDir = getPluginsDir();
|
|
27
|
+
await fs.mkdir(pluginsDir, { recursive: true });
|
|
28
|
+
const finalPath = path.join(pluginsDir, packageName);
|
|
29
|
+
if (existsSync(path.join(finalPath, 'package.json'))) {
|
|
30
|
+
try {
|
|
31
|
+
const pkgJson = JSON.parse(await fs.readFile(path.join(finalPath, 'package.json'), 'utf-8'));
|
|
32
|
+
if (!version || pkgJson.version === version) {
|
|
33
|
+
console.log(`[plugins] ${packageName}${version ? `@${version}` : ''} is already installed.`);
|
|
34
|
+
return { name: pkgJson.name, version: pkgJson.version };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// corrupted; reinstall below
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const target = version ? `${packageName}@${version}` : packageName;
|
|
42
|
+
console.log(`[plugins] Installing ${target} to ${pluginsDir}...`);
|
|
43
|
+
const tempDir = path.join(pluginsDir, '.tmp_' + Date.now());
|
|
44
|
+
try {
|
|
45
|
+
await fs.mkdir(tempDir, { recursive: true });
|
|
46
|
+
await execAsync(`npm install ${target} --no-save --prefix "${tempDir}"`);
|
|
47
|
+
const installedPath = path.join(tempDir, 'node_modules', packageName);
|
|
48
|
+
if (!existsSync(installedPath)) {
|
|
49
|
+
throw new Error(`npm did not produce ${installedPath}`);
|
|
50
|
+
}
|
|
51
|
+
await fs.mkdir(path.dirname(finalPath), { recursive: true });
|
|
52
|
+
await fs.rm(finalPath, { recursive: true, force: true });
|
|
53
|
+
await fs.rename(installedPath, finalPath);
|
|
54
|
+
console.log(`[plugins] Running npm install in ${finalPath}...`);
|
|
55
|
+
try {
|
|
56
|
+
await execAsync(`npm install`, { cwd: finalPath });
|
|
57
|
+
console.log(`[plugins] npm install completed in ${finalPath}`);
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
console.warn(`[plugins] Failed to run npm install in ${finalPath}:`, e);
|
|
61
|
+
}
|
|
62
|
+
const pkgJson = JSON.parse(await fs.readFile(path.join(finalPath, 'package.json'), 'utf-8'));
|
|
63
|
+
invalidatePlugin(packageName);
|
|
64
|
+
return { name: pkgJson.name, version: pkgJson.version };
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error(`[plugins] Failed to install ${packageName}:`, error);
|
|
68
|
+
throw new Error(`Failed to install plugin ${packageName}: ${error.message}`);
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
await fs.rm(tempDir, { recursive: true, force: true }).catch(() => { });
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
uninstall: async (packageName) => {
|
|
75
|
+
const pluginsDir = getPluginsDir();
|
|
76
|
+
const pluginPath = path.join(pluginsDir, packageName);
|
|
77
|
+
try {
|
|
78
|
+
await fs.rm(pluginPath, { recursive: true, force: true });
|
|
79
|
+
invalidatePlugin(packageName);
|
|
80
|
+
console.log(`[plugins] Uninstalled plugin ${packageName}`);
|
|
81
|
+
if (packageName.startsWith('@')) {
|
|
82
|
+
const scopeDir = path.dirname(pluginPath);
|
|
83
|
+
try {
|
|
84
|
+
const remaining = await fs.readdir(scopeDir);
|
|
85
|
+
if (remaining.length === 0)
|
|
86
|
+
await fs.rmdir(scopeDir);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// ignore
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
console.error(`[plugins] Failed to uninstall ${packageName}:`, error);
|
|
95
|
+
throw new Error(`Failed to uninstall plugin ${packageName}: ${error.message}`);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
};
|