openbot 0.4.7 → 0.5.5

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.
Files changed (139) hide show
  1. package/.claude/agents/runtime-security-reviewer.md +32 -0
  2. package/.claude/hooks/format.sh +18 -0
  3. package/.claude/hooks/protect-secrets.sh +23 -0
  4. package/.claude/settings.json +26 -0
  5. package/.claude/skills/deploy/SKILL.md +26 -0
  6. package/.claude/skills/new-plugin/SKILL.md +46 -0
  7. package/.dockerignore +9 -0
  8. package/.mcp.json +8 -0
  9. package/AGENTS.md +2 -2
  10. package/CLAUDE.md +51 -0
  11. package/Dockerfile +41 -0
  12. package/deploy/README.md +59 -0
  13. package/deploy/entrypoint.sh +6 -0
  14. package/deploy/fly.toml +36 -0
  15. package/dist/app/bootstrap.js +29 -0
  16. package/dist/app/cli.js +5 -1
  17. package/dist/app/cloud-mode.js +15 -0
  18. package/dist/app/config.js +61 -16
  19. package/dist/app/ensure-default-stack.js +54 -0
  20. package/dist/app/openbot-plugin.js +4 -0
  21. package/dist/app/server.js +37 -6
  22. package/dist/harness/index.js +3 -0
  23. package/dist/plugins/approval/index.js +1 -1
  24. package/dist/plugins/bash/index.js +386 -164
  25. package/dist/plugins/memory/service.js +2 -5
  26. package/dist/plugins/openbot/context.js +17 -1
  27. package/dist/plugins/openbot/index.js +23 -7
  28. package/dist/plugins/openbot/model.js +20 -0
  29. package/dist/plugins/openbot/runtime.js +45 -57
  30. package/dist/plugins/openbot/system-prompt.js +43 -8
  31. package/dist/plugins/preview/index.js +267 -0
  32. package/dist/plugins/storage/index.js +3 -325
  33. package/dist/plugins/storage/service.js +61 -18
  34. package/dist/plugins/todo/index.js +131 -38
  35. package/dist/plugins/todo/service.js +93 -0
  36. package/dist/plugins/ui/index.js +8 -1
  37. package/dist/services/plugins/host.js +21 -0
  38. package/dist/services/plugins/model-registry.js +126 -0
  39. package/dist/services/plugins/registry.js +28 -42
  40. package/dist/services/plugins/service.js +2 -6
  41. package/docs/agents.md +20 -2
  42. package/docs/architecture.md +1 -1
  43. package/docs/plugins.md +13 -3
  44. package/docs/templates/AGENT.example.md +8 -14
  45. package/package.json +5 -2
  46. package/pnpm-workspace.yaml +2 -0
  47. package/src/app/bootstrap.ts +43 -0
  48. package/src/app/cli.ts +5 -1
  49. package/src/app/cloud-mode.ts +26 -0
  50. package/src/app/config.ts +71 -19
  51. package/src/app/ensure-default-stack.ts +63 -0
  52. package/src/app/openbot-plugin.ts +5 -0
  53. package/src/app/server.ts +42 -6
  54. package/src/app/types.ts +158 -32
  55. package/src/harness/index.ts +4 -0
  56. package/src/plugins/memory/service.ts +2 -5
  57. package/src/plugins/storage/index.ts +3 -371
  58. package/src/plugins/storage/service.ts +81 -22
  59. package/src/services/plugins/domain.ts +2 -0
  60. package/src/services/plugins/host.ts +36 -0
  61. package/src/services/plugins/model-registry.ts +178 -0
  62. package/src/services/plugins/registry.ts +30 -43
  63. package/src/services/plugins/service.ts +8 -17
  64. package/src/services/plugins/types.ts +36 -2
  65. package/src/services/todo/types.ts +12 -0
  66. package/dist/agents/openbot/index.js +0 -76
  67. package/dist/agents/openbot/middleware/approval.js +0 -132
  68. package/dist/agents/openbot/runtime.js +0 -289
  69. package/dist/agents/openbot/system-prompt.js +0 -32
  70. package/dist/agents/openbot/tools/delegation.js +0 -78
  71. package/dist/agents/openbot/tools/mcp.js +0 -99
  72. package/dist/agents/openbot/tools/shell.js +0 -91
  73. package/dist/agents/openbot/tools/storage.js +0 -75
  74. package/dist/agents/openbot/tools/ui.js +0 -176
  75. package/dist/agents/system.js +0 -33
  76. package/dist/bus/agent-package.js +0 -1
  77. package/dist/bus/plugin.js +0 -1
  78. package/dist/bus/services.js +0 -754
  79. package/dist/harness/agent-harness.js +0 -45
  80. package/dist/harness/agent-invoke-run.js +0 -44
  81. package/dist/harness/agent-turn.js +0 -99
  82. package/dist/harness/channel-participants.js +0 -40
  83. package/dist/harness/constants.js +0 -2
  84. package/dist/harness/context-meter.js +0 -97
  85. package/dist/harness/context.js +0 -363
  86. package/dist/harness/dispatch.js +0 -144
  87. package/dist/harness/dispatcher.js +0 -156
  88. package/dist/harness/event-normalizer.js +0 -59
  89. package/dist/harness/history.js +0 -177
  90. package/dist/harness/mcp.js +0 -61
  91. package/dist/harness/orchestration.js +0 -88
  92. package/dist/harness/orchestrator.js +0 -149
  93. package/dist/harness/participants.js +0 -22
  94. package/dist/harness/process.js +0 -29
  95. package/dist/harness/queue-processor.js +0 -187
  96. package/dist/harness/run-harness.js +0 -154
  97. package/dist/harness/run.js +0 -98
  98. package/dist/harness/runtime-factory.js +0 -73
  99. package/dist/harness/runtime.js +0 -57
  100. package/dist/harness/todo-advance.js +0 -93
  101. package/dist/harness/todo-dispatch.js +0 -51
  102. package/dist/harness/todos.js +0 -5
  103. package/dist/harness/turn.js +0 -79
  104. package/dist/harness/types.js +0 -1
  105. package/dist/plugins/ai-sdk/index.js +0 -34
  106. package/dist/plugins/ai-sdk/runtime.js +0 -395
  107. package/dist/plugins/ai-sdk/system-prompt.js +0 -18
  108. package/dist/plugins/ai-sdk.js +0 -331
  109. package/dist/plugins/approval.js +0 -163
  110. package/dist/plugins/delegation.js +0 -108
  111. package/dist/plugins/mcp/index.js +0 -108
  112. package/dist/plugins/mcp.js +0 -140
  113. package/dist/plugins/shell/index.js +0 -100
  114. package/dist/plugins/shell.js +0 -123
  115. package/dist/plugins/storage-tools/index.js +0 -76
  116. package/dist/plugins/storage.js +0 -737
  117. package/dist/plugins/thread-namer/index.js +0 -72
  118. package/dist/plugins/threads/index.js +0 -114
  119. package/dist/plugins/ui.js +0 -211
  120. package/dist/plugins/workflow/index.js +0 -65
  121. package/dist/registry/agents.js +0 -138
  122. package/dist/registry/plugins.js +0 -110
  123. package/dist/services/agent-packages.js +0 -103
  124. package/dist/services/memory.js +0 -152
  125. package/dist/services/plugins.js +0 -98
  126. package/dist/services/storage.js +0 -1028
  127. package/dist/workflow/service.js +0 -106
  128. package/dist/workflow/types.js +0 -3
  129. package/src/plugins/approval/index.ts +0 -147
  130. package/src/plugins/bash/index.ts +0 -232
  131. package/src/plugins/delegation/index.ts +0 -153
  132. package/src/plugins/memory/index.ts +0 -182
  133. package/src/plugins/openbot/context.ts +0 -121
  134. package/src/plugins/openbot/history.ts +0 -158
  135. package/src/plugins/openbot/index.ts +0 -80
  136. package/src/plugins/openbot/runtime.ts +0 -526
  137. package/src/plugins/openbot/system-prompt.ts +0 -22
  138. package/src/plugins/ui/index.ts +0 -123
  139. /package/dist/{bus → services/todo}/types.js +0 -0
@@ -8,7 +8,8 @@ import { createRequire } from 'module';
8
8
  const require = createRequire(import.meta.url);
9
9
  const pkg = require('../../package.json');
10
10
  import { generateId } from 'melony';
11
- import { DEFAULT_BASE_DIR, loadConfig, resolvePath } from '../app/config.js';
11
+ import { getBaseDir, loadConfig } from '../app/config.js';
12
+ import { isCloudMode } from './cloud-mode.js';
12
13
  import { processService } from '../services/process.js';
13
14
  import { runAgent, STATE_AGENT_ID, ORCHESTRATOR_AGENT_ID } from '../harness/index.js';
14
15
  import { initPlugins } from '../services/plugins/registry.js';
@@ -29,8 +30,10 @@ export async function startServer(options = {}) {
29
30
  .passthrough();
30
31
  const config = loadConfig();
31
32
  processService.syncWorkspaceVariablesToProcessEnv();
32
- const baseDir = config.baseDir || DEFAULT_BASE_DIR;
33
- const openBotDir = resolvePath(baseDir);
33
+ if (isCloudMode()) {
34
+ console.log('[server] Cloud mode enabled');
35
+ }
36
+ const openBotDir = getBaseDir();
34
37
  const PORT = Number(options.port ?? config.port ?? process.env.PORT ?? 4132);
35
38
  const app = express();
36
39
  const clients = new Map();
@@ -194,6 +197,21 @@ export async function startServer(options = {}) {
194
197
  next();
195
198
  });
196
199
  app.use(cors());
200
+ const gatewayToken = process.env.OPENBOT_GATEWAY_TOKEN?.trim();
201
+ if (gatewayToken) {
202
+ app.use((req, res, next) => {
203
+ if (req.path === '/api/health' || req.method === 'OPTIONS') {
204
+ next();
205
+ return;
206
+ }
207
+ const got = req.get('x-openbot-gateway-token');
208
+ if (got !== gatewayToken) {
209
+ res.status(401).json({ error: 'unauthorized' });
210
+ return;
211
+ }
212
+ next();
213
+ });
214
+ }
197
215
  const resolvePublicBaseUrl = () => getPublicBaseUrl(PORT, config.publicUrl);
198
216
  app.use((req, res, next) => {
199
217
  const isWorkspaceUpload = req.method === 'POST' &&
@@ -206,7 +224,7 @@ export async function startServer(options = {}) {
206
224
  express.json({ limit: '20mb' })(req, res, next);
207
225
  });
208
226
  app.get('/api/health', (req, res) => {
209
- res.json({ status: 'ok', version: pkg.version });
227
+ res.json({ status: 'ok', version: pkg.version, apiVersion: 1 });
210
228
  });
211
229
  app.get('/api/events', (req, res) => {
212
230
  const { channelId, threadId } = getContext(req);
@@ -567,8 +585,21 @@ export async function startServer(options = {}) {
567
585
  res.status(500).json({ error: 'Failed to process state request' });
568
586
  }
569
587
  });
570
- app.listen(PORT, () => {
571
- console.log(`\x1b[32mOpenBot server listening at http://localhost:${PORT}\x1b[0m`);
588
+ const HOST = process.env.HOST || '0.0.0.0';
589
+ const server = app.listen(PORT, HOST, () => {
590
+ console.log(`\x1b[32mOpenBot server listening at http://${HOST}:${PORT}\x1b[0m`);
572
591
  console.log(`🌐 Visit \x1b[96m\x1b[1mhttps://openbot.one\x1b[0m to connect to this runtime and manage everything from there. ✨`);
573
592
  });
593
+ const shutdown = (signal) => {
594
+ console.log(`\n[server] Received ${signal}, shutting down...`);
595
+ server.close(() => {
596
+ process.exit(0);
597
+ });
598
+ setTimeout(() => {
599
+ console.error('[server] Forced shutdown after timeout');
600
+ process.exit(1);
601
+ }, 10000).unref();
602
+ };
603
+ process.on('SIGTERM', () => shutdown('SIGTERM'));
604
+ process.on('SIGINT', () => shutdown('SIGINT'));
574
605
  }
@@ -6,6 +6,7 @@ import { resolvePlugin } from '../services/plugins/registry.js';
6
6
  import { abortRegistry, abortKey } from '../services/abort.js';
7
7
  import { loadConfig } from '../app/config.js';
8
8
  import { getPublicBaseUrl } from '../plugins/storage/files.js';
9
+ import { createPluginHost } from '../services/plugins/host.js';
9
10
  export { STATE_AGENT_ID, ORCHESTRATOR_AGENT_ID };
10
11
  async function emitEvent(chunk, state, { persistEvents, channelId, threadId, onEvent, parentAgentId, parentToolCallId, }) {
11
12
  ensureEventId(chunk);
@@ -67,6 +68,7 @@ export async function runAgent(options) {
67
68
  }
68
69
  }
69
70
  const builder = melony().initialState(state);
71
+ const pluginHost = createPluginHost(runAgent);
70
72
  for (const ref of pluginRefs) {
71
73
  const plugin = await resolvePlugin(ref.id);
72
74
  if (!plugin)
@@ -79,6 +81,7 @@ export async function runAgent(options) {
79
81
  tools,
80
82
  publicBaseUrl,
81
83
  abortSignal,
84
+ host: pluginHost,
82
85
  }));
83
86
  }
84
87
  const runtime = builder.build();
@@ -14,7 +14,7 @@ export const approvalPlugin = {
14
14
  description: 'Gate protected tool calls behind a UI confirmation widget.',
15
15
  factory: ({ config, storage }) => (builder) => {
16
16
  // Actions that require approval. Defaults to bash.
17
- const actionsToApprove = config.actions || ['action:bash'];
17
+ const actionsToApprove = config.actions || ['action:shell_exec'];
18
18
  for (const action of actionsToApprove) {
19
19
  builder.intercept(action, (event, context) => {
20
20
  // If already approved in this flow, let it pass to the actual handler