openbot 0.3.5 → 0.4.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.
Files changed (98) hide show
  1. package/README.md +15 -16
  2. package/dist/app/agent-ids.js +4 -0
  3. package/dist/app/cli.js +1 -1
  4. package/dist/app/config.js +0 -19
  5. package/dist/app/server.js +8 -14
  6. package/dist/assets/icon.svg +9 -3
  7. package/dist/bus/services.js +78 -132
  8. package/dist/harness/agent-invoke-run.js +44 -0
  9. package/dist/harness/agent-turn.js +99 -0
  10. package/dist/harness/channel-participants.js +40 -0
  11. package/dist/harness/constants.js +2 -0
  12. package/dist/harness/context-meter.js +97 -0
  13. package/dist/harness/context.js +98 -45
  14. package/dist/harness/dispatch.js +144 -0
  15. package/dist/harness/dispatcher.js +45 -156
  16. package/dist/harness/history.js +177 -0
  17. package/dist/harness/index.js +91 -0
  18. package/dist/harness/orchestration.js +88 -0
  19. package/dist/harness/participants.js +22 -0
  20. package/dist/harness/run-harness.js +154 -0
  21. package/dist/harness/run.js +98 -0
  22. package/dist/harness/runtime-factory.js +0 -34
  23. package/dist/harness/runtime.js +57 -0
  24. package/dist/harness/todo-dispatch.js +51 -0
  25. package/dist/harness/todos.js +5 -0
  26. package/dist/harness/turn.js +79 -0
  27. package/dist/plugins/approval/index.js +105 -149
  28. package/dist/plugins/delegation/index.js +119 -32
  29. package/dist/plugins/memory/index.js +103 -14
  30. package/dist/plugins/memory/service.js +152 -0
  31. package/dist/plugins/openbot/context.js +80 -0
  32. package/dist/plugins/openbot/history.js +98 -0
  33. package/dist/plugins/openbot/index.js +31 -0
  34. package/dist/plugins/openbot/runtime.js +317 -0
  35. package/dist/plugins/openbot/system-prompt.js +5 -0
  36. package/dist/plugins/plugin-manager/index.js +105 -0
  37. package/dist/plugins/storage/index.js +573 -0
  38. package/dist/plugins/storage/service.js +1159 -0
  39. package/dist/plugins/storage-tools/index.js +2 -2
  40. package/dist/plugins/thread-namer/index.js +72 -0
  41. package/dist/plugins/thread-naming/generate-title.js +44 -0
  42. package/dist/plugins/thread-naming/index.js +103 -0
  43. package/dist/plugins/threads/index.js +114 -0
  44. package/dist/plugins/todo/index.js +24 -25
  45. package/dist/plugins/ui/index.js +2 -32
  46. package/dist/registry/plugins.js +3 -9
  47. package/dist/services/plugins/domain.js +1 -0
  48. package/dist/services/plugins/plugin-cache.js +9 -0
  49. package/dist/services/plugins/registry.js +110 -0
  50. package/dist/services/plugins/service.js +177 -0
  51. package/dist/services/plugins/types.js +1 -0
  52. package/dist/services/process.js +29 -0
  53. package/dist/services/storage.js +41 -15
  54. package/dist/services/thread-naming.js +81 -0
  55. package/docs/agents.md +16 -10
  56. package/docs/architecture.md +2 -2
  57. package/docs/plugins.md +6 -15
  58. package/docs/templates/AGENT.example.md +7 -13
  59. package/package.json +1 -2
  60. package/src/app/agent-ids.ts +5 -0
  61. package/src/app/cli.ts +1 -1
  62. package/src/app/config.ts +1 -31
  63. package/src/app/server.ts +8 -16
  64. package/src/app/types.ts +70 -190
  65. package/src/assets/icon.svg +9 -3
  66. package/src/harness/index.ts +145 -0
  67. package/src/plugins/approval/index.ts +91 -189
  68. package/src/plugins/delegation/index.ts +136 -39
  69. package/src/plugins/memory/index.ts +112 -15
  70. package/src/{services/memory.ts → plugins/memory/service.ts} +1 -1
  71. package/src/plugins/openbot/context.ts +91 -0
  72. package/src/plugins/openbot/history.ts +107 -0
  73. package/src/plugins/openbot/index.ts +37 -0
  74. package/src/plugins/openbot/runtime.ts +384 -0
  75. package/src/plugins/openbot/system-prompt.ts +7 -0
  76. package/src/plugins/plugin-manager/index.ts +122 -0
  77. package/src/plugins/shell/index.ts +1 -1
  78. package/src/plugins/storage/index.ts +633 -0
  79. package/src/{services/storage.ts → plugins/storage/service.ts} +257 -72
  80. package/src/{bus/types.ts → services/plugins/domain.ts} +20 -7
  81. package/src/services/plugins/plugin-cache.ts +13 -0
  82. package/src/{registry/plugins.ts → services/plugins/registry.ts} +25 -27
  83. package/src/services/{plugins.ts → plugins/service.ts} +96 -2
  84. package/src/{bus/plugin.ts → services/plugins/types.ts} +3 -3
  85. package/src/bus/services.ts +0 -908
  86. package/src/harness/context.ts +0 -356
  87. package/src/harness/dispatcher.ts +0 -379
  88. package/src/harness/mcp.ts +0 -78
  89. package/src/harness/runtime-factory.ts +0 -129
  90. package/src/harness/todo-advance.ts +0 -128
  91. package/src/plugins/ai-sdk/index.ts +0 -41
  92. package/src/plugins/ai-sdk/runtime.ts +0 -468
  93. package/src/plugins/ai-sdk/system-prompt.ts +0 -18
  94. package/src/plugins/mcp/index.ts +0 -128
  95. package/src/plugins/storage-tools/index.ts +0 -90
  96. package/src/plugins/todo/index.ts +0 -64
  97. package/src/plugins/ui/index.ts +0 -227
  98. /package/src/{harness → services}/process.ts +0 -0
@@ -0,0 +1,122 @@
1
+ import type { Plugin } from '../../services/plugins/types.js';
2
+ import { STATE_AGENT_ID } from '../../app/agent-ids.js';
3
+ import { OpenBotEvent } from '../../app/types.js';
4
+ import {
5
+ pluginService,
6
+ resolveMarketplaceAgentList,
7
+ } from '../../services/plugins/service.js';
8
+
9
+ /**
10
+ * `plugin-manager` — marketplace listing, npm plugin install/uninstall, and
11
+ * installing agents from the registry. Wired on the **`state`** built-in agent
12
+ * via its default `pluginRefs`.
13
+ *
14
+ * Handlers register only when `agentId === state` so attaching this plugin to
15
+ * other agents via AGENT.md does not widen infra privileges.
16
+ */
17
+
18
+ export const pluginManagerPlugin: Plugin = {
19
+ id: 'plugin-manager',
20
+ name: 'Plugin manager',
21
+ description:
22
+ 'Marketplace listings, npm-based plugin lifecycle, and agent installs from marketplace metadata.',
23
+ factory: ({ agentId, storage }) => {
24
+ if (agentId !== STATE_AGENT_ID) {
25
+ return () => {};
26
+ }
27
+
28
+ return (builder) => {
29
+ builder.on('action:plugin:install', async function* (event) {
30
+ try {
31
+ const { name, version } = event.data;
32
+ const result = await pluginService.install({ packageName: name, version });
33
+ yield {
34
+ type: 'action:plugin:install:result',
35
+ data: { success: true, plugin: result },
36
+ } as OpenBotEvent;
37
+ } catch (error) {
38
+ yield {
39
+ type: 'action:plugin:install:result',
40
+ data: { success: false, error: (error as Error).message },
41
+ } as OpenBotEvent;
42
+ }
43
+ });
44
+
45
+ builder.on('action:plugin:uninstall', async function* (event) {
46
+ try {
47
+ await pluginService.uninstall(event.data.id);
48
+ yield { type: 'action:plugin:uninstall:result', data: { success: true } };
49
+ } catch (error) {
50
+ yield {
51
+ type: 'action:plugin:uninstall:result',
52
+ data: { success: false, error: (error as Error).message },
53
+ } as OpenBotEvent;
54
+ }
55
+ });
56
+
57
+ builder.on('action:marketplace:list', async function* () {
58
+ const agents = await resolveMarketplaceAgentList();
59
+ yield {
60
+ type: 'action:marketplace:list:result',
61
+ data: { success: true, agents },
62
+ } as OpenBotEvent;
63
+ });
64
+
65
+ builder.on('action:agent:install', async function* (event) {
66
+ try {
67
+ const {
68
+ agentId: newAgentId,
69
+ name,
70
+ description,
71
+ image,
72
+ instructions,
73
+ plugins,
74
+ } = event.data;
75
+
76
+ for (const ref of plugins) {
77
+ const installed = await pluginService.isInstalled(ref.id);
78
+ if (!installed && ref.id.includes('/') === false && ref.id.includes('-plugin-') === false) {
79
+ continue;
80
+ }
81
+ if (!installed) {
82
+ try {
83
+ await pluginService.install({ packageName: ref.id });
84
+ } catch (err) {
85
+ console.warn(`[plugins] Failed to pre-install plugin ${ref.id}`, err);
86
+ }
87
+ }
88
+ }
89
+
90
+ await storage.createAgent({
91
+ agentId: newAgentId,
92
+ name,
93
+ description,
94
+ image,
95
+ instructions,
96
+ plugins,
97
+ });
98
+ yield {
99
+ type: 'action:agent:install:result',
100
+ data: { success: true, agentId: newAgentId },
101
+ } as OpenBotEvent;
102
+ yield {
103
+ type: 'agent:output',
104
+ data: {
105
+ content: `Successfully installed agent **${name}** (${newAgentId}) from marketplace.`,
106
+ },
107
+ meta: { agentId: 'system' },
108
+ } as OpenBotEvent;
109
+ } catch (error) {
110
+ yield {
111
+ type: 'action:agent:install:result',
112
+ data: {
113
+ success: false,
114
+ agentId: event.data.agentId,
115
+ error: error instanceof Error ? error.message : 'Unknown error',
116
+ },
117
+ } as OpenBotEvent;
118
+ }
119
+ });
120
+ };
121
+ },
122
+ };
@@ -1,7 +1,7 @@
1
1
  import { MelonyPlugin } from 'melony';
2
2
  import { z } from 'zod';
3
3
  import { spawn } from 'node:child_process';
4
- import type { Plugin } from '../../bus/plugin.js';
4
+ import type { Plugin } from '../../services/plugins/types.js';
5
5
  import { OpenBotEvent, OpenBotState } from '../../app/types.js';
6
6
 
7
7
  const shellToolDefinitions = {