@openacp/cli 2026.331.1 → 2026.331.3

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