@openacp/cli 2026.330.3 → 2026.331.2

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 (173) hide show
  1. package/README.md +19 -1
  2. package/dist/cli.d.ts +11 -0
  3. package/dist/cli.js +25134 -278
  4. package/dist/cli.js.map +1 -1
  5. package/dist/data/registry-snapshot.json +1 -1
  6. package/dist/index.d.ts +259 -30
  7. package/dist/index.js +17632 -404
  8. package/dist/index.js.map +1 -1
  9. package/package.json +2 -2
  10. package/dist/adapter-AWSI4GML.js +0 -13
  11. package/dist/adapter-AWSI4GML.js.map +0 -1
  12. package/dist/agent-catalog-SZQQERV7.js +0 -10
  13. package/dist/agent-catalog-SZQQERV7.js.map +0 -1
  14. package/dist/agent-dependencies-ED2ZTUHG.js +0 -23
  15. package/dist/agent-dependencies-ED2ZTUHG.js.map +0 -1
  16. package/dist/agent-registry-YOGP656W.js +0 -8
  17. package/dist/agent-registry-YOGP656W.js.map +0 -1
  18. package/dist/agent-store-5UHZH2XI.js +0 -8
  19. package/dist/agent-store-5UHZH2XI.js.map +0 -1
  20. package/dist/api-client-XTLRRFPX.js +0 -13
  21. package/dist/api-client-XTLRRFPX.js.map +0 -1
  22. package/dist/api-server-5VNYFWJE.js +0 -7
  23. package/dist/api-server-5VNYFWJE.js.map +0 -1
  24. package/dist/api-server-JLBDKCU4.js +0 -10
  25. package/dist/api-server-JLBDKCU4.js.map +0 -1
  26. package/dist/autostart-CUPZMKKC.js +0 -22
  27. package/dist/autostart-CUPZMKKC.js.map +0 -1
  28. package/dist/chunk-237WYH6H.js +0 -235
  29. package/dist/chunk-237WYH6H.js.map +0 -1
  30. package/dist/chunk-2HEFALTZ.js +0 -44
  31. package/dist/chunk-2HEFALTZ.js.map +0 -1
  32. package/dist/chunk-2KT6TROD.js +0 -129
  33. package/dist/chunk-2KT6TROD.js.map +0 -1
  34. package/dist/chunk-2R5XM3ES.js +0 -154
  35. package/dist/chunk-2R5XM3ES.js.map +0 -1
  36. package/dist/chunk-3EWTPOF7.js +0 -51
  37. package/dist/chunk-3EWTPOF7.js.map +0 -1
  38. package/dist/chunk-3NAFXVQM.js +0 -67
  39. package/dist/chunk-3NAFXVQM.js.map +0 -1
  40. package/dist/chunk-4WXALZA3.js +0 -45
  41. package/dist/chunk-4WXALZA3.js.map +0 -1
  42. package/dist/chunk-566W6INH.js +0 -83
  43. package/dist/chunk-566W6INH.js.map +0 -1
  44. package/dist/chunk-5HKQCYOI.js +0 -145
  45. package/dist/chunk-5HKQCYOI.js.map +0 -1
  46. package/dist/chunk-5OCGO27U.js +0 -125
  47. package/dist/chunk-5OCGO27U.js.map +0 -1
  48. package/dist/chunk-5WGVYX3C.js +0 -55
  49. package/dist/chunk-5WGVYX3C.js.map +0 -1
  50. package/dist/chunk-7ZCQF6QM.js +0 -27
  51. package/dist/chunk-7ZCQF6QM.js.map +0 -1
  52. package/dist/chunk-AFKX424Q.js +0 -92
  53. package/dist/chunk-AFKX424Q.js.map +0 -1
  54. package/dist/chunk-APS6UEFU.js +0 -259
  55. package/dist/chunk-APS6UEFU.js.map +0 -1
  56. package/dist/chunk-BTJHGSLM.js +0 -1116
  57. package/dist/chunk-BTJHGSLM.js.map +0 -1
  58. package/dist/chunk-CDAUYTVP.js +0 -41
  59. package/dist/chunk-CDAUYTVP.js.map +0 -1
  60. package/dist/chunk-FCTC7KDT.js +0 -101
  61. package/dist/chunk-FCTC7KDT.js.map +0 -1
  62. package/dist/chunk-FNRSWA2K.js +0 -1
  63. package/dist/chunk-FNRSWA2K.js.map +0 -1
  64. package/dist/chunk-GEOXPGCO.js +0 -650
  65. package/dist/chunk-GEOXPGCO.js.map +0 -1
  66. package/dist/chunk-IZ5UEZF7.js +0 -138
  67. package/dist/chunk-IZ5UEZF7.js.map +0 -1
  68. package/dist/chunk-KDU3ZEWT.js +0 -97
  69. package/dist/chunk-KDU3ZEWT.js.map +0 -1
  70. package/dist/chunk-LGFWH3AE.js +0 -26
  71. package/dist/chunk-LGFWH3AE.js.map +0 -1
  72. package/dist/chunk-MITTQMGZ.js +0 -543
  73. package/dist/chunk-MITTQMGZ.js.map +0 -1
  74. package/dist/chunk-MLF4W5R6.js +0 -101
  75. package/dist/chunk-MLF4W5R6.js.map +0 -1
  76. package/dist/chunk-MPGEHTGE.js +0 -679
  77. package/dist/chunk-MPGEHTGE.js.map +0 -1
  78. package/dist/chunk-OYSAN7UX.js +0 -15
  79. package/dist/chunk-OYSAN7UX.js.map +0 -1
  80. package/dist/chunk-PA6MNBG4.js +0 -190
  81. package/dist/chunk-PA6MNBG4.js.map +0 -1
  82. package/dist/chunk-QWVHCTCA.js +0 -172
  83. package/dist/chunk-QWVHCTCA.js.map +0 -1
  84. package/dist/chunk-R6KZYF7D.js +0 -231
  85. package/dist/chunk-R6KZYF7D.js.map +0 -1
  86. package/dist/chunk-S64CB6J3.js +0 -98
  87. package/dist/chunk-S64CB6J3.js.map +0 -1
  88. package/dist/chunk-TMVTSWVH.js +0 -228
  89. package/dist/chunk-TMVTSWVH.js.map +0 -1
  90. package/dist/chunk-UCIZM5SW.js +0 -3917
  91. package/dist/chunk-UCIZM5SW.js.map +0 -1
  92. package/dist/chunk-UWH7KIAA.js +0 -701
  93. package/dist/chunk-UWH7KIAA.js.map +0 -1
  94. package/dist/chunk-V2YZWYXT.js +0 -484
  95. package/dist/chunk-V2YZWYXT.js.map +0 -1
  96. package/dist/chunk-W26AUH5B.js +0 -61
  97. package/dist/chunk-W26AUH5B.js.map +0 -1
  98. package/dist/chunk-W4LK6WJP.js +0 -446
  99. package/dist/chunk-W4LK6WJP.js.map +0 -1
  100. package/dist/chunk-WQCJTU2C.js +0 -84
  101. package/dist/chunk-WQCJTU2C.js.map +0 -1
  102. package/dist/chunk-XBZIHNKV.js +0 -6410
  103. package/dist/chunk-XBZIHNKV.js.map +0 -1
  104. package/dist/chunk-ZSLHHQPQ.js +0 -282
  105. package/dist/chunk-ZSLHHQPQ.js.map +0 -1
  106. package/dist/config-KN6NKKPF.js +0 -20
  107. package/dist/config-KN6NKKPF.js.map +0 -1
  108. package/dist/config-editor-76RVZS4B.js +0 -10
  109. package/dist/config-editor-76RVZS4B.js.map +0 -1
  110. package/dist/config-registry-ZXAIJNYB.js +0 -17
  111. package/dist/config-registry-ZXAIJNYB.js.map +0 -1
  112. package/dist/context-NXXW62NJ.js +0 -9
  113. package/dist/context-NXXW62NJ.js.map +0 -1
  114. package/dist/core-plugins-BPZY7SEB.js +0 -22
  115. package/dist/core-plugins-BPZY7SEB.js.map +0 -1
  116. package/dist/daemon-XFEMMJSZ.js +0 -29
  117. package/dist/daemon-XFEMMJSZ.js.map +0 -1
  118. package/dist/dev-loader-7P3HZCIA.js +0 -37
  119. package/dist/dev-loader-7P3HZCIA.js.map +0 -1
  120. package/dist/doctor-AV6AUO22.js +0 -9
  121. package/dist/doctor-AV6AUO22.js.map +0 -1
  122. package/dist/file-service-HHB3JQIO.js +0 -8
  123. package/dist/file-service-HHB3JQIO.js.map +0 -1
  124. package/dist/install-cloudflared-JRJ4BSOM.js +0 -32
  125. package/dist/install-cloudflared-JRJ4BSOM.js.map +0 -1
  126. package/dist/install-context-EHYV5WRY.js +0 -77
  127. package/dist/install-context-EHYV5WRY.js.map +0 -1
  128. package/dist/install-jq-ISTGT263.js +0 -31
  129. package/dist/install-jq-ISTGT263.js.map +0 -1
  130. package/dist/integrate-JIEZYDOR.js +0 -371
  131. package/dist/integrate-JIEZYDOR.js.map +0 -1
  132. package/dist/log-YZ243M5G.js +0 -25
  133. package/dist/log-YZ243M5G.js.map +0 -1
  134. package/dist/main-VEJCG5PY.js +0 -654
  135. package/dist/main-VEJCG5PY.js.map +0 -1
  136. package/dist/menu-ALFN37IR.js +0 -15
  137. package/dist/menu-ALFN37IR.js.map +0 -1
  138. package/dist/notifications-MO23S7S3.js +0 -8
  139. package/dist/notifications-MO23S7S3.js.map +0 -1
  140. package/dist/plugin-create-EHL76ZZG.js +0 -966
  141. package/dist/plugin-create-EHL76ZZG.js.map +0 -1
  142. package/dist/plugin-installer-VSTYZSXC.js +0 -9
  143. package/dist/plugin-installer-VSTYZSXC.js.map +0 -1
  144. package/dist/plugin-registry-6J3YSFHF.js +0 -7
  145. package/dist/plugin-registry-6J3YSFHF.js.map +0 -1
  146. package/dist/plugin-search-MGKAL5JM.js +0 -39
  147. package/dist/plugin-search-MGKAL5JM.js.map +0 -1
  148. package/dist/post-upgrade-Y26S2ZQ7.js +0 -79
  149. package/dist/post-upgrade-Y26S2ZQ7.js.map +0 -1
  150. package/dist/read-text-file-DJBTITIB.js +0 -7
  151. package/dist/read-text-file-DJBTITIB.js.map +0 -1
  152. package/dist/registry-client-GTBWLXYU.js +0 -7
  153. package/dist/registry-client-GTBWLXYU.js.map +0 -1
  154. package/dist/security-2BA265LN.js +0 -8
  155. package/dist/security-2BA265LN.js.map +0 -1
  156. package/dist/settings-manager-B4UN2LAC.js +0 -7
  157. package/dist/settings-manager-B4UN2LAC.js.map +0 -1
  158. package/dist/setup-DISPNDEK.js +0 -802
  159. package/dist/setup-DISPNDEK.js.map +0 -1
  160. package/dist/speech-SG62JYIF.js +0 -9
  161. package/dist/speech-SG62JYIF.js.map +0 -1
  162. package/dist/suggest-RST5VOHB.js +0 -36
  163. package/dist/suggest-RST5VOHB.js.map +0 -1
  164. package/dist/telegram-L3YM6SQJ.js +0 -7
  165. package/dist/telegram-L3YM6SQJ.js.map +0 -1
  166. package/dist/tunnel-HWJ27WDH.js +0 -7
  167. package/dist/tunnel-HWJ27WDH.js.map +0 -1
  168. package/dist/tunnel-service-ZMO4THKE.js +0 -1261
  169. package/dist/tunnel-service-ZMO4THKE.js.map +0 -1
  170. package/dist/validators-GITLOFXC.js +0 -11
  171. package/dist/validators-GITLOFXC.js.map +0 -1
  172. package/dist/version-AXXV6IV2.js +0 -15
  173. package/dist/version-AXXV6IV2.js.map +0 -1
@@ -1,654 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- corePlugins
4
- } from "./chunk-2HEFALTZ.js";
5
- import "./chunk-237WYH6H.js";
6
- import {
7
- SettingsManager
8
- } from "./chunk-MLF4W5R6.js";
9
- import "./chunk-3EWTPOF7.js";
10
- import "./chunk-PA6MNBG4.js";
11
- import "./chunk-KDU3ZEWT.js";
12
- import "./chunk-5OCGO27U.js";
13
- import "./chunk-3NAFXVQM.js";
14
- import "./chunk-UWH7KIAA.js";
15
- import "./chunk-TMVTSWVH.js";
16
- import "./chunk-5WGVYX3C.js";
17
- import {
18
- CommandRegistry,
19
- OpenACPCore
20
- } from "./chunk-UCIZM5SW.js";
21
- import "./chunk-V2YZWYXT.js";
22
- import "./chunk-566W6INH.js";
23
- import "./chunk-7ZCQF6QM.js";
24
- import "./chunk-FNRSWA2K.js";
25
- import "./chunk-ZSLHHQPQ.js";
26
- import "./chunk-LGFWH3AE.js";
27
- import "./chunk-OYSAN7UX.js";
28
- import "./chunk-IZ5UEZF7.js";
29
- import "./chunk-MITTQMGZ.js";
30
- import "./chunk-APS6UEFU.js";
31
- import "./chunk-2KT6TROD.js";
32
- import {
33
- ConfigManager,
34
- OPENACP_DIR,
35
- PLUGINS_DATA_DIR,
36
- REGISTRY_PATH
37
- } from "./chunk-W4LK6WJP.js";
38
- import {
39
- cleanupOldSessionLogs,
40
- initLogger,
41
- log,
42
- muteLogger,
43
- shutdownLogger,
44
- unmuteLogger
45
- } from "./chunk-R6KZYF7D.js";
46
- import {
47
- PluginRegistry
48
- } from "./chunk-W26AUH5B.js";
49
-
50
- // src/main.ts
51
- import path from "path";
52
-
53
- // src/core/commands/session.ts
54
- function registerSessionCommands(registry, _core) {
55
- registry.register({
56
- name: "new",
57
- description: "Start a new session",
58
- usage: "[agent-name]",
59
- category: "system",
60
- handler: async () => {
61
- return { type: "silent" };
62
- }
63
- });
64
- registry.register({
65
- name: "cancel",
66
- description: "Cancel the current agent turn",
67
- category: "system",
68
- handler: async () => {
69
- return { type: "silent" };
70
- }
71
- });
72
- registry.register({
73
- name: "status",
74
- description: "Show current session status",
75
- category: "system",
76
- handler: async () => {
77
- return { type: "silent" };
78
- }
79
- });
80
- registry.register({
81
- name: "sessions",
82
- description: "List all active sessions",
83
- category: "system",
84
- handler: async () => {
85
- return { type: "silent" };
86
- }
87
- });
88
- registry.register({
89
- name: "clear",
90
- description: "Clear session history",
91
- category: "system",
92
- handler: async () => {
93
- return { type: "silent" };
94
- }
95
- });
96
- registry.register({
97
- name: "newchat",
98
- description: "New chat, same agent & workspace",
99
- category: "system",
100
- handler: async () => {
101
- return { type: "silent" };
102
- }
103
- });
104
- registry.register({
105
- name: "resume",
106
- description: "Resume a previous session",
107
- usage: "<session-number>",
108
- category: "system",
109
- handler: async () => {
110
- return { type: "silent" };
111
- }
112
- });
113
- registry.register({
114
- name: "handoff",
115
- description: "Hand off session to another agent",
116
- usage: "<agent-name>",
117
- category: "system",
118
- handler: async () => {
119
- return { type: "silent" };
120
- }
121
- });
122
- }
123
-
124
- // src/core/commands/agents.ts
125
- function registerAgentCommands(registry, _core) {
126
- registry.register({
127
- name: "agents",
128
- description: "List available agents",
129
- category: "system",
130
- handler: async () => {
131
- return { type: "text", text: "No agents configured." };
132
- }
133
- });
134
- registry.register({
135
- name: "install",
136
- description: "Install a plugin",
137
- usage: "<plugin-name>",
138
- category: "system",
139
- handler: async (args) => {
140
- const plugin = args.raw.trim();
141
- if (!plugin) {
142
- return { type: "error", message: "Usage: /install <plugin-name>" };
143
- }
144
- return { type: "text", text: `Installing plugin: ${plugin}...` };
145
- }
146
- });
147
- }
148
-
149
- // src/core/commands/admin.ts
150
- function registerAdminCommands(registry, _core) {
151
- registry.register({
152
- name: "restart",
153
- description: "Restart the server",
154
- category: "system",
155
- handler: async () => {
156
- return { type: "silent" };
157
- }
158
- });
159
- registry.register({
160
- name: "update",
161
- description: "Check for and apply updates",
162
- category: "system",
163
- handler: async () => {
164
- return { type: "text", text: "Checking for updates..." };
165
- }
166
- });
167
- registry.register({
168
- name: "doctor",
169
- description: "Run system diagnostics",
170
- category: "system",
171
- handler: async () => {
172
- return { type: "text", text: "Running diagnostics..." };
173
- }
174
- });
175
- registry.register({
176
- name: "integrate",
177
- description: "Set up a new channel integration",
178
- usage: "<channel>",
179
- category: "system",
180
- handler: async (args) => {
181
- const channel = args.raw.trim();
182
- if (!channel) {
183
- return {
184
- type: "menu",
185
- title: "Available Integrations",
186
- options: [
187
- { label: "Telegram", command: "/integrate telegram" },
188
- { label: "Discord", command: "/integrate discord" }
189
- ]
190
- };
191
- }
192
- return { type: "text", text: `Setting up ${channel} integration...` };
193
- }
194
- });
195
- }
196
-
197
- // src/core/commands/help.ts
198
- function registerHelpCommand(registry, _core) {
199
- registry.register({
200
- name: "help",
201
- description: "Show available commands",
202
- usage: "[command]",
203
- category: "system",
204
- handler: async (args) => {
205
- const query = args.raw.trim();
206
- if (query) {
207
- const cmd = registry.get(query);
208
- if (!cmd) {
209
- return { type: "error", message: `Unknown command: /${query}` };
210
- }
211
- let text = `/${cmd.name}`;
212
- if (cmd.usage) text += ` ${cmd.usage}`;
213
- text += `
214
- ${cmd.description}`;
215
- return { type: "text", text };
216
- }
217
- const systemCmds = registry.getByCategory("system");
218
- const pluginCmds = registry.getByCategory("plugin");
219
- const lines = [];
220
- if (systemCmds.length > 0) {
221
- lines.push("System Commands:");
222
- for (const cmd of systemCmds) {
223
- const usage = cmd.usage ? ` ${cmd.usage}` : "";
224
- lines.push(` /${cmd.name}${usage} \u2014 ${cmd.description}`);
225
- }
226
- }
227
- if (pluginCmds.length > 0) {
228
- if (lines.length > 0) lines.push("");
229
- lines.push("Plugin Commands:");
230
- for (const cmd of pluginCmds) {
231
- const usage = cmd.usage ? ` ${cmd.usage}` : "";
232
- lines.push(` /${cmd.name}${usage} \u2014 ${cmd.description}`);
233
- }
234
- }
235
- if (lines.length === 0) {
236
- return { type: "text", text: "No commands registered." };
237
- }
238
- return { type: "text", text: lines.join("\n") };
239
- }
240
- });
241
- }
242
-
243
- // src/core/commands/menu.ts
244
- function registerMenuCommand(registry, _core) {
245
- registry.register({
246
- name: "menu",
247
- description: "Show the main menu",
248
- category: "system",
249
- handler: async () => {
250
- return {
251
- type: "menu",
252
- title: "Main Menu",
253
- options: [
254
- { label: "New Session", command: "/new" },
255
- { label: "Active Sessions", command: "/sessions" },
256
- { label: "Available Agents", command: "/agents" },
257
- { label: "Usage", command: "/usage" },
258
- { label: "Help", command: "/help" }
259
- ]
260
- };
261
- }
262
- });
263
- }
264
-
265
- // src/core/commands/index.ts
266
- function registerSystemCommands(registry, core) {
267
- registerSessionCommands(registry, core);
268
- registerAgentCommands(registry, core);
269
- registerAdminCommands(registry, core);
270
- registerHelpCommand(registry, core);
271
- registerMenuCommand(registry, core);
272
- }
273
-
274
- // src/main.ts
275
- import fs from "fs";
276
- var RESTART_EXIT_CODE = 75;
277
- var shuttingDown = false;
278
- async function startServer(opts) {
279
- if (process.argv.includes("--daemon-child")) {
280
- const { writePidFile, readPidFile, getPidPath, shouldAutoStart } = await import("./daemon-XFEMMJSZ.js");
281
- if (!shouldAutoStart()) {
282
- process.exit(0);
283
- }
284
- const pidPath = getPidPath();
285
- const existingPid = readPidFile(pidPath);
286
- if (existingPid !== null && existingPid !== process.pid) {
287
- try {
288
- process.kill(existingPid, 0);
289
- console.error(`Another OpenACP instance is already running (PID ${existingPid}). Exiting.`);
290
- process.exit(1);
291
- } catch {
292
- }
293
- }
294
- writePidFile(pidPath, process.pid);
295
- }
296
- const settingsManager = new SettingsManager(PLUGINS_DATA_DIR);
297
- const pluginRegistry = new PluginRegistry(REGISTRY_PATH);
298
- await pluginRegistry.load();
299
- const configManager = new ConfigManager();
300
- const configExists = await configManager.exists();
301
- if (!configExists) {
302
- const { runSetup } = await import("./setup-DISPNDEK.js");
303
- const shouldStart = await runSetup(configManager, { settingsManager, pluginRegistry });
304
- if (!shouldStart) process.exit(0);
305
- }
306
- await configManager.load();
307
- const config = configManager.get();
308
- initLogger(config.logging);
309
- log.debug({ configPath: configManager.getConfigPath() }, "Config loaded");
310
- if (pluginRegistry.list().size === 0) {
311
- await autoRegisterBuiltinPlugins(settingsManager, pluginRegistry, configManager);
312
- }
313
- const isForegroundTTY = !!(process.stdout.isTTY && !process.env.NO_COLOR && config.runMode !== "daemon");
314
- if (isForegroundTTY) {
315
- const { printStartBanner } = await import("./setup-DISPNDEK.js");
316
- await printStartBanner();
317
- }
318
- let spinner;
319
- if (isForegroundTTY) {
320
- muteLogger();
321
- const ora = (await import("ora")).default;
322
- spinner = ora({ text: "Starting OpenACP...", spinner: "dots" }).start();
323
- }
324
- try {
325
- const { runPostUpgradeChecks } = await import("./post-upgrade-Y26S2ZQ7.js");
326
- await runPostUpgradeChecks(config);
327
- } catch (err) {
328
- log.warn({ err }, "Post-upgrade check failed");
329
- }
330
- cleanupOldSessionLogs(config.logging.sessionLogRetentionDays).catch(
331
- (err) => log.warn({ err }, "Session log cleanup failed")
332
- );
333
- const core = new OpenACPCore(configManager);
334
- const commandRegistry = new CommandRegistry();
335
- const serviceRegistry = core.lifecycleManager.serviceRegistry;
336
- serviceRegistry.register("command-registry", commandRegistry, "core");
337
- registerSystemCommands(commandRegistry, core);
338
- try {
339
- core.eventBus.emit("kernel:booted");
340
- core.lifecycleManager.settingsManager = settingsManager;
341
- core.lifecycleManager.pluginRegistry = pluginRegistry;
342
- await core.lifecycleManager.boot(corePlugins);
343
- try {
344
- const communityPlugins = [];
345
- const npmPlugins = pluginRegistry.listBySource("npm");
346
- const localPlugins = pluginRegistry.listBySource("local");
347
- const allCommunityEntries = new Map([...npmPlugins, ...localPlugins]);
348
- for (const [name, entry] of allCommunityEntries) {
349
- if (!entry.enabled) continue;
350
- try {
351
- let modulePath;
352
- if (name.startsWith("/") || name.startsWith(".")) {
353
- const resolved = path.resolve(name);
354
- const pkgPath = path.join(resolved, "package.json");
355
- const pkg = JSON.parse(await fs.promises.readFile(pkgPath, "utf-8"));
356
- modulePath = path.join(resolved, pkg.main || "dist/index.js");
357
- } else {
358
- const nodeModulesDir = path.join(OPENACP_DIR, "plugins", "node_modules");
359
- let pkgDir = path.join(nodeModulesDir, name);
360
- if (!fs.existsSync(path.join(pkgDir, "package.json"))) {
361
- let found = false;
362
- const scopes = fs.existsSync(nodeModulesDir) ? fs.readdirSync(nodeModulesDir).filter((d) => d.startsWith("@")) : [];
363
- for (const scope of scopes) {
364
- const scopeDir = path.join(nodeModulesDir, scope);
365
- const pkgs = fs.readdirSync(scopeDir);
366
- for (const pkg2 of pkgs) {
367
- const candidateDir = path.join(scopeDir, pkg2);
368
- const candidatePkgPath = path.join(candidateDir, "package.json");
369
- if (fs.existsSync(candidatePkgPath)) {
370
- try {
371
- const candidatePkg = JSON.parse(fs.readFileSync(candidatePkgPath, "utf-8"));
372
- const pluginName = candidatePkg.openacp?.pluginName;
373
- if (pluginName === name) {
374
- pkgDir = candidateDir;
375
- found = true;
376
- break;
377
- }
378
- } catch {
379
- }
380
- }
381
- }
382
- if (found) break;
383
- }
384
- }
385
- const pkgJsonPath = path.join(pkgDir, "package.json");
386
- const pkg = JSON.parse(await fs.promises.readFile(pkgJsonPath, "utf-8"));
387
- modulePath = path.join(pkgDir, pkg.main || "dist/index.js");
388
- }
389
- log.debug({ plugin: name, modulePath }, "Loading community plugin");
390
- const mod = await import(modulePath);
391
- const plugin = mod.default;
392
- if (!plugin || !plugin.name || !plugin.setup) {
393
- log.warn({ plugin: name }, "Community plugin has invalid exports (missing name or setup), skipping");
394
- continue;
395
- }
396
- communityPlugins.push(plugin);
397
- } catch (err) {
398
- log.warn({ err, plugin: name }, "Failed to load community plugin, skipping");
399
- }
400
- }
401
- if (communityPlugins.length > 0) {
402
- log.debug({ plugins: communityPlugins.map((p) => p.name) }, "Booting community plugins");
403
- await core.lifecycleManager.boot(communityPlugins);
404
- }
405
- } catch (err) {
406
- log.warn({ err }, "Community plugin loading failed");
407
- }
408
- if (opts?.devPluginPath) {
409
- const { DevPluginLoader } = await import("./dev-loader-7P3HZCIA.js");
410
- const devLoader = new DevPluginLoader(opts.devPluginPath);
411
- try {
412
- const devPlugin = await devLoader.load();
413
- await core.lifecycleManager.boot([devPlugin]);
414
- log.info({ plugin: devPlugin.name, version: devPlugin.version }, "Dev plugin loaded");
415
- if (!opts.noWatch) {
416
- const distPath = devLoader.getDistPath();
417
- let reloadTimer = null;
418
- fs.watch(distPath, { recursive: true }, (_eventType, filename) => {
419
- if (!filename?.endsWith(".js")) return;
420
- if (reloadTimer) clearTimeout(reloadTimer);
421
- reloadTimer = setTimeout(async () => {
422
- try {
423
- log.info({ filename }, "Dev plugin changed, reloading...");
424
- await core.lifecycleManager.unloadPlugin(devPlugin.name);
425
- const reloaded = await devLoader.load();
426
- await core.lifecycleManager.boot([reloaded]);
427
- log.info({ plugin: reloaded.name, version: reloaded.version }, "Dev plugin reloaded");
428
- } catch (err) {
429
- log.error({ err }, "Dev plugin reload failed");
430
- }
431
- }, 500);
432
- });
433
- log.info({ distPath }, "Watching dev plugin for changes");
434
- }
435
- } catch (err) {
436
- log.error({ err, pluginPath: opts.devPluginPath }, "Failed to load dev plugin");
437
- }
438
- }
439
- for (const { name } of serviceRegistry.list()) {
440
- if (!name.startsWith("adapter:")) continue;
441
- const adapterName = name.slice("adapter:".length);
442
- const adapter = serviceRegistry.get(name);
443
- if (adapter) {
444
- core.registerAdapter(adapterName, adapter);
445
- log.info({ adapter: adapterName }, "Adapter registered");
446
- }
447
- }
448
- const tunnelSvc = serviceRegistry.get("tunnel");
449
- if (tunnelSvc) {
450
- core.tunnelService = tunnelSvc;
451
- }
452
- core.eventBus.emit("system:commands-ready", { commands: commandRegistry.getAll() });
453
- core.eventBus.emit("system:ready");
454
- } catch (err) {
455
- if (spinner) {
456
- spinner.fail("Plugin boot failed");
457
- spinner = void 0;
458
- }
459
- unmuteLogger();
460
- log.error({ err }, "Plugin boot failed");
461
- }
462
- if (core.adapters.size === 0) {
463
- log.error("No channels enabled. Enable at least one channel in config.");
464
- process.exit(1);
465
- }
466
- const shutdown = async (signal, exitCode = 0) => {
467
- if (shuttingDown) return;
468
- shuttingDown = true;
469
- log.info({ signal, exitCode }, "Signal received, shutting down");
470
- try {
471
- try {
472
- const nm = serviceRegistry.get("notifications");
473
- if (nm) {
474
- await nm.notifyAll({
475
- sessionId: "system",
476
- type: "error",
477
- summary: "OpenACP is shutting down"
478
- });
479
- }
480
- } catch {
481
- }
482
- await core.sessionManager.shutdownAll();
483
- await core.lifecycleManager.shutdown();
484
- } catch (err) {
485
- log.error({ err }, "Error during shutdown");
486
- }
487
- const isDaemon = process.argv.includes("--daemon-child");
488
- if (isDaemon) {
489
- const { removePidFile, getPidPath } = await import("./daemon-XFEMMJSZ.js");
490
- removePidFile(getPidPath());
491
- }
492
- if (exitCode === RESTART_EXIT_CODE) {
493
- if (isDaemon) {
494
- const { spawn: spawnChild } = await import("child_process");
495
- const { expandHome } = await import("./config-KN6NKKPF.js");
496
- const fs2 = await import("fs");
497
- const pathMod = await import("path");
498
- const cliPath = pathMod.resolve(process.argv[1]);
499
- const resolvedLogDir = expandHome(config.logging.logDir);
500
- fs2.mkdirSync(resolvedLogDir, { recursive: true });
501
- const logFile = pathMod.join(resolvedLogDir, "openacp.log");
502
- const out = fs2.openSync(logFile, "a");
503
- const err = fs2.openSync(logFile, "a");
504
- const child = spawnChild(process.execPath, [cliPath, "--daemon-child"], {
505
- detached: true,
506
- stdio: ["ignore", out, err],
507
- env: { ...process.env, OPENACP_SKIP_UPDATE_CHECK: "1" }
508
- });
509
- fs2.closeSync(out);
510
- fs2.closeSync(err);
511
- child.unref();
512
- log.info({ newPid: child.pid }, "Respawned daemon for restart");
513
- } else if (!process.env.OPENACP_DEV_LOOP) {
514
- const { spawn: spawnChild } = await import("child_process");
515
- const child = spawnChild(process.execPath, process.argv.slice(1), {
516
- stdio: "inherit",
517
- env: { ...process.env, OPENACP_SKIP_UPDATE_CHECK: "1" }
518
- });
519
- await shutdownLogger();
520
- child.on("exit", (code) => process.exit(code ?? 0));
521
- return;
522
- }
523
- }
524
- await shutdownLogger();
525
- process.exit(exitCode);
526
- };
527
- core.requestRestart = () => shutdown("restart", RESTART_EXIT_CODE);
528
- process.on("SIGINT", () => shutdown("SIGINT"));
529
- process.on("SIGTERM", () => shutdown("SIGTERM"));
530
- process.on("uncaughtException", (err) => {
531
- log.error({ err }, "Uncaught exception");
532
- });
533
- process.on("unhandledRejection", (err) => {
534
- log.error({ err }, "Unhandled rejection");
535
- });
536
- await core.start();
537
- if (isForegroundTTY) {
538
- if (spinner) spinner.stop();
539
- const ok = (msg) => console.log(`\x1B[32m\u2713\x1B[0m ${msg}`);
540
- ok("Config loaded");
541
- ok("Dependencies checked");
542
- const tunnelSvc = core.lifecycleManager.serviceRegistry.get("tunnel");
543
- if (tunnelSvc) {
544
- const tunnelUrl = tunnelSvc.getPublicUrl();
545
- const tunnelErr = tunnelSvc.getStartError();
546
- if (tunnelErr) {
547
- console.log(`\x1B[33m\u26A0\x1B[0m Tunnel failed (${tunnelErr}) \u2014 viewer links unavailable`);
548
- } else {
549
- ok(`Tunnel ready \u2192 ${tunnelUrl}`);
550
- }
551
- }
552
- for (const [name] of core.adapters) ok(`${name.charAt(0).toUpperCase() + name.slice(1)} connected`);
553
- const apiPort = config.api?.port ?? 21420;
554
- if (core.lifecycleManager.serviceRegistry.get("api-server")) ok(`API server on port ${apiPort}`);
555
- console.log(`
556
- OpenACP is running. Press Ctrl+C to stop.
557
- `);
558
- unmuteLogger();
559
- }
560
- log.debug({ agents: Object.keys(config.agents) }, "OpenACP started");
561
- }
562
- async function autoRegisterBuiltinPlugins(settingsManager, pluginRegistry, configManager) {
563
- const allPlugins = [
564
- { name: "@openacp/security", version: "1.0.0", description: "User access control and session limits" },
565
- { name: "@openacp/file-service", version: "1.0.0", description: "File storage and management" },
566
- { name: "@openacp/context", version: "1.0.0", description: "Conversation context management" },
567
- { name: "@openacp/speech", version: "1.0.0", description: "Text-to-speech and speech-to-text" },
568
- { name: "@openacp/notifications", version: "1.0.0", description: "Cross-session notification routing" },
569
- { name: "@openacp/tunnel", version: "1.0.0", description: "Expose local services via tunnel" },
570
- { name: "@openacp/api-server", version: "1.0.0", description: "REST API + SSE streaming server" },
571
- { name: "@openacp/telegram", version: "1.0.0", description: "Telegram adapter with forum topics" }
572
- ];
573
- let legacyConfig;
574
- try {
575
- const cfg = configManager.get();
576
- if (cfg && typeof cfg === "object") {
577
- legacyConfig = cfg;
578
- }
579
- } catch {
580
- }
581
- if (legacyConfig) {
582
- const pluginModules = await Promise.allSettled([
583
- import("./security-2BA265LN.js"),
584
- import("./file-service-HHB3JQIO.js"),
585
- import("./context-NXXW62NJ.js"),
586
- import("./speech-SG62JYIF.js"),
587
- import("./notifications-MO23S7S3.js"),
588
- import("./tunnel-HWJ27WDH.js"),
589
- import("./api-server-5VNYFWJE.js"),
590
- import("./telegram-L3YM6SQJ.js")
591
- ]);
592
- for (const result of pluginModules) {
593
- if (result.status !== "fulfilled") continue;
594
- const plugin = result.value.default;
595
- if (plugin?.install) {
596
- try {
597
- const existing = await settingsManager.loadSettings(plugin.name);
598
- if (Object.keys(existing).length > 0) continue;
599
- const { createInstallContext } = await import("./install-context-EHYV5WRY.js");
600
- const ctx = createInstallContext({
601
- pluginName: plugin.name,
602
- settingsManager,
603
- basePath: PLUGINS_DATA_DIR,
604
- legacyConfig
605
- });
606
- ctx.terminal = createSilentTerminal();
607
- await plugin.install(ctx);
608
- } catch {
609
- }
610
- }
611
- }
612
- }
613
- for (const p of allPlugins) {
614
- pluginRegistry.register(p.name, {
615
- version: p.version,
616
- source: "builtin",
617
- enabled: true,
618
- settingsPath: settingsManager.getSettingsPath(p.name),
619
- description: p.description
620
- });
621
- }
622
- await pluginRegistry.save();
623
- log.info("Built-in plugins registered in plugin registry");
624
- }
625
- function createSilentTerminal() {
626
- const noop = () => {
627
- };
628
- const abort = () => {
629
- throw new Error("Silent migration: no interactive input available");
630
- };
631
- return {
632
- text: async () => abort(),
633
- select: async () => abort(),
634
- confirm: async () => abort(),
635
- password: async () => abort(),
636
- multiselect: async () => abort(),
637
- log: { info: noop, success: noop, warning: noop, error: noop, step: noop },
638
- spinner: () => ({ start: noop, stop: noop, fail: noop }),
639
- note: noop,
640
- cancel: noop
641
- };
642
- }
643
- var isDirectExecution = process.argv[1]?.endsWith("main.js");
644
- if (isDirectExecution) {
645
- startServer().catch((err) => {
646
- log.error({ err }, "Fatal error");
647
- process.exit(1);
648
- });
649
- }
650
- export {
651
- RESTART_EXIT_CODE,
652
- startServer
653
- };
654
- //# sourceMappingURL=main-VEJCG5PY.js.map