@openacp/cli 2026.402.5 → 2026.403.1

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/index.d.ts CHANGED
@@ -1,1476 +1,1493 @@
1
- import { A as AgentEvent, a as AgentCapabilities, P as PermissionRequest, b as AgentDefinition, M as McpServerConfig, S as SetConfigOptionValue, c as Attachment, I as InstalledAgent, R as RegistryAgent, d as AgentListItem, e as AvailabilityResult, f as InstallProgress, g as InstallResult, h as SessionStatus, C as ConfigOption, i as AgentSwitchEntry, j as AgentCommand, k as SessionRecord, O as OutgoingMessage, l as IChannelAdapter, N as NotificationMessage, m as StopReason, U as UsageRecord, n as UsageRecordEvent, o as IncomingMessage, D as DisplayVerbosity, p as ChannelConfig, q as AdapterCapabilities, T as ToolCallMeta, V as ViewerLinks, r as OutputMode, s as PlanEntry } from './channel-DzDoNxa7.js';
2
- export { t as AgentDistribution, u as AuthMethod, v as AuthenticateRequest, w as ChannelAdapter, x as ConfigSelectChoice, y as ConfigSelectGroup, z as ContentBlock, K as KIND_ICONS, B as ModelInfo, E as NewSessionResponse, F as PermissionOption, G as PromptResponse, H as RegistryBinaryTarget, J as RegistryDistribution, L as STATUS_ICONS, Q as SessionListItem, W as SessionListResponse, X as SessionMode, Y as SessionModeState, Z as SessionModelState, _ as TelegramPlatformData, $ as ToolUpdateMeta } from './channel-DzDoNxa7.js';
1
+ import { A as Attachment, O as OutgoingMessage, I as IChannelAdapter, N as NotificationMessage, a as AgentEvent, S as StopReason, P as PermissionRequest, U as UsageRecord, b as AgentCapabilities, c as AgentDefinition, M as McpServerConfig, d as SetConfigOptionValue, e as InstalledAgent, R as RegistryAgent, f as AgentListItem, g as AvailabilityResult, h as InstallProgress, i as InstallResult, j as SessionStatus, C as ConfigOption, k as AgentSwitchEntry, l as AgentCommand, m as SessionRecord, n as UsageRecordEvent, o as IncomingMessage, D as DisplayVerbosity, p as ChannelConfig, q as AdapterCapabilities, T as ToolCallMeta, V as ViewerLinks, r as OutputMode, s as PlanEntry } from './channel-BL33p1ZP.js';
2
+ export { t as AgentDistribution, u as AuthMethod, v as AuthenticateRequest, w as ChannelAdapter, x as ConfigSelectChoice, y as ConfigSelectGroup, z as ContentBlock, K as KIND_ICONS, B as ModelInfo, E as NewSessionResponse, F as PermissionOption, G as PromptResponse, H as RegistryBinaryTarget, J as RegistryDistribution, L as STATUS_ICONS, Q as SessionListItem, W as SessionListResponse, X as SessionMode, Y as SessionModeState, Z as SessionModelState, _ as TelegramPlatformData, $ as ToolUpdateMeta } from './channel-BL33p1ZP.js';
3
3
  import pino from 'pino';
4
4
  import * as zod from 'zod';
5
- import { z, ZodSchema } from 'zod';
5
+ import { ZodSchema, z } from 'zod';
6
6
  import { EventEmitter } from 'node:events';
7
7
  import { SetSessionConfigOptionResponse, ListSessionsResponse, LoadSessionResponse, ForkSessionResponse, PromptResponse } from '@agentclientprotocol/sdk';
8
8
  import { FastifyInstance, FastifyPluginAsync, preHandlerHookHandler, FastifyRequest, FastifyReply } from 'fastify';
9
9
  import * as http from 'node:http';
10
10
 
11
- declare const LoggingSchema: z.ZodDefault<z.ZodObject<{
12
- level: z.ZodDefault<z.ZodEnum<["silent", "debug", "info", "warn", "error", "fatal"]>>;
13
- logDir: z.ZodDefault<z.ZodString>;
14
- maxFileSize: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
15
- maxFiles: z.ZodDefault<z.ZodNumber>;
16
- sessionLogRetentionDays: z.ZodDefault<z.ZodNumber>;
17
- }, "strip", z.ZodTypeAny, {
18
- level: "fatal" | "error" | "warn" | "info" | "debug" | "silent";
19
- logDir: string;
20
- maxFileSize: string | number;
21
- maxFiles: number;
22
- sessionLogRetentionDays: number;
23
- }, {
24
- level?: "fatal" | "error" | "warn" | "info" | "debug" | "silent" | undefined;
25
- logDir?: string | undefined;
26
- maxFileSize?: string | number | undefined;
27
- maxFiles?: number | undefined;
28
- sessionLogRetentionDays?: number | undefined;
29
- }>>;
30
- type LoggingConfig = z.infer<typeof LoggingSchema>;
31
- declare const TunnelSchema: z.ZodDefault<z.ZodObject<{
32
- enabled: z.ZodDefault<z.ZodBoolean>;
33
- port: z.ZodDefault<z.ZodNumber>;
34
- provider: z.ZodDefault<z.ZodEnum<["openacp", "cloudflare", "ngrok", "bore", "tailscale"]>>;
35
- options: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
36
- maxUserTunnels: z.ZodDefault<z.ZodNumber>;
37
- storeTtlMinutes: z.ZodDefault<z.ZodNumber>;
38
- auth: z.ZodDefault<z.ZodObject<{
39
- enabled: z.ZodDefault<z.ZodBoolean>;
40
- token: z.ZodOptional<z.ZodString>;
41
- }, "strip", z.ZodTypeAny, {
42
- enabled: boolean;
43
- token?: string | undefined;
44
- }, {
45
- enabled?: boolean | undefined;
46
- token?: string | undefined;
47
- }>>;
48
- }, "strip", z.ZodTypeAny, {
49
- provider: "openacp" | "cloudflare" | "ngrok" | "bore" | "tailscale";
50
- options: Record<string, unknown>;
51
- enabled: boolean;
52
- port: number;
53
- maxUserTunnels: number;
54
- storeTtlMinutes: number;
55
- auth: {
56
- enabled: boolean;
57
- token?: string | undefined;
11
+ interface AssistantCommand {
12
+ command: string;
13
+ description: string;
14
+ }
15
+ interface AssistantSection {
16
+ id: string;
17
+ title: string;
18
+ priority: number;
19
+ buildContext: () => string | null;
20
+ commands?: AssistantCommand[];
21
+ }
22
+ declare class AssistantRegistry {
23
+ private sections;
24
+ private _instanceRoot;
25
+ /** Set the instance root path used in assistant guidelines */
26
+ setInstanceRoot(root: string): void;
27
+ register(section: AssistantSection): void;
28
+ unregister(id: string): void;
29
+ buildSystemPrompt(channelId?: string): string;
30
+ }
31
+
32
+ type PluginPermission = 'events:read' | 'events:emit' | 'services:register' | 'services:use' | 'middleware:register' | 'commands:register' | 'storage:read' | 'storage:write' | 'kernel:access';
33
+ interface OpenACPPlugin {
34
+ /** Unique identifier, e.g., '@openacp/security' */
35
+ name: string;
36
+ /** Semver version */
37
+ version: string;
38
+ /** Human-readable description */
39
+ description?: string;
40
+ /** Required plugin dependencies — loaded before this plugin's setup() */
41
+ pluginDependencies?: Record<string, string>;
42
+ /** Optional dependencies — used if available, gracefully degrade if not */
43
+ optionalPluginDependencies?: Record<string, string>;
44
+ /** Override a built-in plugin (replaces it entirely) */
45
+ overrides?: string;
46
+ /** Required permissions — PluginContext enforces these */
47
+ permissions?: PluginPermission[];
48
+ /** Called during startup in dependency order */
49
+ setup(ctx: PluginContext): Promise<void>;
50
+ /** Called during shutdown in reverse order. 10s timeout. */
51
+ teardown?(): Promise<void>;
52
+ install?(ctx: InstallContext): Promise<void>;
53
+ uninstall?(ctx: InstallContext, opts: {
54
+ purge: boolean;
55
+ }): Promise<void>;
56
+ configure?(ctx: InstallContext): Promise<void>;
57
+ migrate?(ctx: MigrateContext, oldSettings: unknown, oldVersion: string): Promise<unknown>;
58
+ settingsSchema?: zod.ZodSchema;
59
+ essential?: boolean;
60
+ /** Settings keys that can be copied when creating a new instance from this one */
61
+ inheritableKeys?: string[];
62
+ }
63
+ interface PluginStorage {
64
+ get<T>(key: string): Promise<T | undefined>;
65
+ set<T>(key: string, value: T): Promise<void>;
66
+ delete(key: string): Promise<void>;
67
+ list(): Promise<string[]>;
68
+ getDataDir(): string;
69
+ }
70
+ interface SettingsAPI {
71
+ get<T = unknown>(key: string): Promise<T | undefined>;
72
+ set<T = unknown>(key: string, value: T): Promise<void>;
73
+ getAll(): Promise<Record<string, unknown>>;
74
+ setAll(settings: Record<string, unknown>): Promise<void>;
75
+ delete(key: string): Promise<void>;
76
+ clear(): Promise<void>;
77
+ has(key: string): Promise<boolean>;
78
+ }
79
+ interface TerminalIO {
80
+ text(opts: {
81
+ message: string;
82
+ placeholder?: string;
83
+ defaultValue?: string;
84
+ validate?: (value: string) => string | undefined;
85
+ }): Promise<string>;
86
+ select<T>(opts: {
87
+ message: string;
88
+ options: {
89
+ value: T;
90
+ label: string;
91
+ hint?: string;
92
+ }[];
93
+ }): Promise<T>;
94
+ confirm(opts: {
95
+ message: string;
96
+ initialValue?: boolean;
97
+ }): Promise<boolean>;
98
+ password(opts: {
99
+ message: string;
100
+ validate?: (value: string) => string | undefined;
101
+ }): Promise<string>;
102
+ multiselect<T>(opts: {
103
+ message: string;
104
+ options: {
105
+ value: T;
106
+ label: string;
107
+ hint?: string;
108
+ }[];
109
+ required?: boolean;
110
+ }): Promise<T[]>;
111
+ log: {
112
+ info(message: string): void;
113
+ success(message: string): void;
114
+ warning(message: string): void;
115
+ error(message: string): void;
116
+ step(message: string): void;
58
117
  };
59
- }, {
60
- provider?: "openacp" | "cloudflare" | "ngrok" | "bore" | "tailscale" | undefined;
61
- options?: Record<string, unknown> | undefined;
62
- enabled?: boolean | undefined;
63
- port?: number | undefined;
64
- maxUserTunnels?: number | undefined;
65
- storeTtlMinutes?: number | undefined;
66
- auth?: {
67
- enabled?: boolean | undefined;
68
- token?: string | undefined;
69
- } | undefined;
70
- }>>;
71
- type TunnelConfig = z.infer<typeof TunnelSchema>;
72
- declare const UsageSchema: z.ZodDefault<z.ZodObject<{
73
- enabled: z.ZodDefault<z.ZodBoolean>;
74
- monthlyBudget: z.ZodOptional<z.ZodNumber>;
75
- warningThreshold: z.ZodDefault<z.ZodNumber>;
76
- currency: z.ZodDefault<z.ZodString>;
77
- retentionDays: z.ZodDefault<z.ZodNumber>;
78
- }, "strip", z.ZodTypeAny, {
79
- enabled: boolean;
80
- warningThreshold: number;
81
- currency: string;
82
- retentionDays: number;
83
- monthlyBudget?: number | undefined;
84
- }, {
85
- enabled?: boolean | undefined;
86
- monthlyBudget?: number | undefined;
87
- warningThreshold?: number | undefined;
88
- currency?: string | undefined;
89
- retentionDays?: number | undefined;
90
- }>>;
91
- type UsageConfig = z.infer<typeof UsageSchema>;
92
- declare const ConfigSchema: z.ZodObject<{
93
- instanceName: z.ZodOptional<z.ZodString>;
94
- channels: z.ZodDefault<z.ZodObject<{}, "strip", z.ZodObject<{
95
- enabled: z.ZodDefault<z.ZodBoolean>;
96
- adapter: z.ZodOptional<z.ZodString>;
97
- displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
98
- outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
99
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
100
- enabled: z.ZodDefault<z.ZodBoolean>;
101
- adapter: z.ZodOptional<z.ZodString>;
102
- displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
103
- outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
104
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
105
- enabled: z.ZodDefault<z.ZodBoolean>;
106
- adapter: z.ZodOptional<z.ZodString>;
107
- displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
108
- outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
109
- }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{}, z.ZodObject<{
110
- enabled: z.ZodDefault<z.ZodBoolean>;
111
- adapter: z.ZodOptional<z.ZodString>;
112
- displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
113
- outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
114
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
115
- enabled: z.ZodDefault<z.ZodBoolean>;
116
- adapter: z.ZodOptional<z.ZodString>;
117
- displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
118
- outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
119
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
120
- enabled: z.ZodDefault<z.ZodBoolean>;
121
- adapter: z.ZodOptional<z.ZodString>;
122
- displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
123
- outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
124
- }, z.ZodTypeAny, "passthrough">>, "strip">, z.objectInputType<{}, z.ZodObject<{
125
- enabled: z.ZodDefault<z.ZodBoolean>;
126
- adapter: z.ZodOptional<z.ZodString>;
127
- displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
128
- outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
129
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
130
- enabled: z.ZodDefault<z.ZodBoolean>;
131
- adapter: z.ZodOptional<z.ZodString>;
132
- displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
133
- outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
134
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
135
- enabled: z.ZodDefault<z.ZodBoolean>;
136
- adapter: z.ZodOptional<z.ZodString>;
137
- displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
138
- outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
139
- }, z.ZodTypeAny, "passthrough">>, "strip">>>;
140
- agents: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
141
- command: z.ZodString;
142
- args: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
143
- workingDirectory: z.ZodOptional<z.ZodString>;
144
- env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
145
- }, "strip", z.ZodTypeAny, {
146
- command: string;
147
- args: string[];
148
- env: Record<string, string>;
149
- workingDirectory?: string | undefined;
150
- }, {
151
- command: string;
152
- args?: string[] | undefined;
153
- env?: Record<string, string> | undefined;
154
- workingDirectory?: string | undefined;
155
- }>>>>;
156
- defaultAgent: z.ZodString;
157
- workspace: z.ZodDefault<z.ZodObject<{
158
- baseDir: z.ZodDefault<z.ZodString>;
159
- }, "strip", z.ZodTypeAny, {
160
- baseDir: string;
161
- }, {
162
- baseDir?: string | undefined;
163
- }>>;
164
- security: z.ZodDefault<z.ZodObject<{
165
- allowedUserIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
166
- maxConcurrentSessions: z.ZodDefault<z.ZodNumber>;
167
- sessionTimeoutMinutes: z.ZodDefault<z.ZodNumber>;
168
- }, "strip", z.ZodTypeAny, {
169
- allowedUserIds: string[];
170
- maxConcurrentSessions: number;
171
- sessionTimeoutMinutes: number;
172
- }, {
173
- allowedUserIds?: string[] | undefined;
174
- maxConcurrentSessions?: number | undefined;
175
- sessionTimeoutMinutes?: number | undefined;
176
- }>>;
177
- logging: z.ZodDefault<z.ZodObject<{
178
- level: z.ZodDefault<z.ZodEnum<["silent", "debug", "info", "warn", "error", "fatal"]>>;
179
- logDir: z.ZodDefault<z.ZodString>;
180
- maxFileSize: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
181
- maxFiles: z.ZodDefault<z.ZodNumber>;
182
- sessionLogRetentionDays: z.ZodDefault<z.ZodNumber>;
183
- }, "strip", z.ZodTypeAny, {
184
- level: "fatal" | "error" | "warn" | "info" | "debug" | "silent";
185
- logDir: string;
186
- maxFileSize: string | number;
187
- maxFiles: number;
188
- sessionLogRetentionDays: number;
189
- }, {
190
- level?: "fatal" | "error" | "warn" | "info" | "debug" | "silent" | undefined;
191
- logDir?: string | undefined;
192
- maxFileSize?: string | number | undefined;
193
- maxFiles?: number | undefined;
194
- sessionLogRetentionDays?: number | undefined;
195
- }>>;
196
- runMode: z.ZodDefault<z.ZodEnum<["foreground", "daemon"]>>;
197
- autoStart: z.ZodDefault<z.ZodBoolean>;
198
- api: z.ZodDefault<z.ZodObject<{
199
- port: z.ZodDefault<z.ZodNumber>;
200
- host: z.ZodDefault<z.ZodString>;
201
- }, "strip", z.ZodTypeAny, {
202
- port: number;
203
- host: string;
204
- }, {
205
- port?: number | undefined;
206
- host?: string | undefined;
207
- }>>;
208
- sessionStore: z.ZodDefault<z.ZodObject<{
209
- ttlDays: z.ZodDefault<z.ZodNumber>;
210
- }, "strip", z.ZodTypeAny, {
211
- ttlDays: number;
212
- }, {
213
- ttlDays?: number | undefined;
214
- }>>;
215
- tunnel: z.ZodDefault<z.ZodObject<{
216
- enabled: z.ZodDefault<z.ZodBoolean>;
217
- port: z.ZodDefault<z.ZodNumber>;
218
- provider: z.ZodDefault<z.ZodEnum<["openacp", "cloudflare", "ngrok", "bore", "tailscale"]>>;
219
- options: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
220
- maxUserTunnels: z.ZodDefault<z.ZodNumber>;
221
- storeTtlMinutes: z.ZodDefault<z.ZodNumber>;
222
- auth: z.ZodDefault<z.ZodObject<{
223
- enabled: z.ZodDefault<z.ZodBoolean>;
224
- token: z.ZodOptional<z.ZodString>;
225
- }, "strip", z.ZodTypeAny, {
226
- enabled: boolean;
227
- token?: string | undefined;
228
- }, {
229
- enabled?: boolean | undefined;
230
- token?: string | undefined;
231
- }>>;
232
- }, "strip", z.ZodTypeAny, {
233
- provider: "openacp" | "cloudflare" | "ngrok" | "bore" | "tailscale";
234
- options: Record<string, unknown>;
235
- enabled: boolean;
236
- port: number;
237
- maxUserTunnels: number;
238
- storeTtlMinutes: number;
239
- auth: {
240
- enabled: boolean;
241
- token?: string | undefined;
242
- };
243
- }, {
244
- provider?: "openacp" | "cloudflare" | "ngrok" | "bore" | "tailscale" | undefined;
245
- options?: Record<string, unknown> | undefined;
246
- enabled?: boolean | undefined;
247
- port?: number | undefined;
248
- maxUserTunnels?: number | undefined;
249
- storeTtlMinutes?: number | undefined;
250
- auth?: {
251
- enabled?: boolean | undefined;
252
- token?: string | undefined;
253
- } | undefined;
254
- }>>;
255
- usage: z.ZodDefault<z.ZodObject<{
256
- enabled: z.ZodDefault<z.ZodBoolean>;
257
- monthlyBudget: z.ZodOptional<z.ZodNumber>;
258
- warningThreshold: z.ZodDefault<z.ZodNumber>;
259
- currency: z.ZodDefault<z.ZodString>;
260
- retentionDays: z.ZodDefault<z.ZodNumber>;
261
- }, "strip", z.ZodTypeAny, {
262
- enabled: boolean;
263
- warningThreshold: number;
264
- currency: string;
265
- retentionDays: number;
266
- monthlyBudget?: number | undefined;
267
- }, {
268
- enabled?: boolean | undefined;
269
- monthlyBudget?: number | undefined;
270
- warningThreshold?: number | undefined;
271
- currency?: string | undefined;
272
- retentionDays?: number | undefined;
273
- }>>;
274
- integrations: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
275
- installed: z.ZodBoolean;
276
- installedAt: z.ZodOptional<z.ZodString>;
277
- }, "strip", z.ZodTypeAny, {
278
- installed: boolean;
279
- installedAt?: string | undefined;
280
- }, {
281
- installed: boolean;
282
- installedAt?: string | undefined;
283
- }>>>;
284
- speech: z.ZodDefault<z.ZodOptional<z.ZodObject<{
285
- stt: z.ZodDefault<z.ZodObject<{
286
- provider: z.ZodDefault<z.ZodNullable<z.ZodString>>;
287
- providers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
288
- apiKey: z.ZodOptional<z.ZodString>;
289
- model: z.ZodOptional<z.ZodString>;
290
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
291
- apiKey: z.ZodOptional<z.ZodString>;
292
- model: z.ZodOptional<z.ZodString>;
293
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
294
- apiKey: z.ZodOptional<z.ZodString>;
295
- model: z.ZodOptional<z.ZodString>;
296
- }, z.ZodTypeAny, "passthrough">>>>;
297
- }, "strip", z.ZodTypeAny, {
298
- provider: string | null;
299
- providers: Record<string, z.objectOutputType<{
300
- apiKey: z.ZodOptional<z.ZodString>;
301
- model: z.ZodOptional<z.ZodString>;
302
- }, z.ZodTypeAny, "passthrough">>;
303
- }, {
304
- provider?: string | null | undefined;
305
- providers?: Record<string, z.objectInputType<{
306
- apiKey: z.ZodOptional<z.ZodString>;
307
- model: z.ZodOptional<z.ZodString>;
308
- }, z.ZodTypeAny, "passthrough">> | undefined;
309
- }>>;
310
- tts: z.ZodDefault<z.ZodObject<{
311
- provider: z.ZodDefault<z.ZodNullable<z.ZodString>>;
312
- providers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
313
- apiKey: z.ZodOptional<z.ZodString>;
314
- model: z.ZodOptional<z.ZodString>;
315
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
316
- apiKey: z.ZodOptional<z.ZodString>;
317
- model: z.ZodOptional<z.ZodString>;
318
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
319
- apiKey: z.ZodOptional<z.ZodString>;
320
- model: z.ZodOptional<z.ZodString>;
321
- }, z.ZodTypeAny, "passthrough">>>>;
322
- }, "strip", z.ZodTypeAny, {
323
- provider: string | null;
324
- providers: Record<string, z.objectOutputType<{
325
- apiKey: z.ZodOptional<z.ZodString>;
326
- model: z.ZodOptional<z.ZodString>;
327
- }, z.ZodTypeAny, "passthrough">>;
328
- }, {
329
- provider?: string | null | undefined;
330
- providers?: Record<string, z.objectInputType<{
331
- apiKey: z.ZodOptional<z.ZodString>;
332
- model: z.ZodOptional<z.ZodString>;
333
- }, z.ZodTypeAny, "passthrough">> | undefined;
334
- }>>;
335
- }, "strip", z.ZodTypeAny, {
336
- stt: {
337
- provider: string | null;
338
- providers: Record<string, z.objectOutputType<{
339
- apiKey: z.ZodOptional<z.ZodString>;
340
- model: z.ZodOptional<z.ZodString>;
341
- }, z.ZodTypeAny, "passthrough">>;
342
- };
343
- tts: {
344
- provider: string | null;
345
- providers: Record<string, z.objectOutputType<{
346
- apiKey: z.ZodOptional<z.ZodString>;
347
- model: z.ZodOptional<z.ZodString>;
348
- }, z.ZodTypeAny, "passthrough">>;
349
- };
350
- }, {
351
- stt?: {
352
- provider?: string | null | undefined;
353
- providers?: Record<string, z.objectInputType<{
354
- apiKey: z.ZodOptional<z.ZodString>;
355
- model: z.ZodOptional<z.ZodString>;
356
- }, z.ZodTypeAny, "passthrough">> | undefined;
357
- } | undefined;
358
- tts?: {
359
- provider?: string | null | undefined;
360
- providers?: Record<string, z.objectInputType<{
361
- apiKey: z.ZodOptional<z.ZodString>;
362
- model: z.ZodOptional<z.ZodString>;
363
- }, z.ZodTypeAny, "passthrough">> | undefined;
364
- } | undefined;
365
- }>>>;
366
- outputMode: z.ZodOptional<z.ZodDefault<z.ZodEnum<["low", "medium", "high"]>>>;
367
- agentSwitch: z.ZodDefault<z.ZodObject<{
368
- labelHistory: z.ZodDefault<z.ZodBoolean>;
369
- }, "strip", z.ZodTypeAny, {
370
- labelHistory: boolean;
371
- }, {
372
- labelHistory?: boolean | undefined;
373
- }>>;
374
- }, "strip", z.ZodTypeAny, {
375
- api: {
376
- port: number;
377
- host: string;
378
- };
379
- agents: Record<string, {
380
- command: string;
381
- args: string[];
382
- env: Record<string, string>;
383
- workingDirectory?: string | undefined;
384
- }>;
385
- tunnel: {
386
- provider: "openacp" | "cloudflare" | "ngrok" | "bore" | "tailscale";
387
- options: Record<string, unknown>;
388
- enabled: boolean;
389
- port: number;
390
- maxUserTunnels: number;
391
- storeTtlMinutes: number;
392
- auth: {
393
- enabled: boolean;
394
- token?: string | undefined;
395
- };
396
- };
397
- channels: {} & {
398
- [k: string]: z.objectOutputType<{
399
- enabled: z.ZodDefault<z.ZodBoolean>;
400
- adapter: z.ZodOptional<z.ZodString>;
401
- displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
402
- outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
403
- }, z.ZodTypeAny, "passthrough">;
404
- };
405
- defaultAgent: string;
406
- workspace: {
407
- baseDir: string;
408
- };
409
- security: {
410
- allowedUserIds: string[];
411
- maxConcurrentSessions: number;
412
- sessionTimeoutMinutes: number;
118
+ spinner(): {
119
+ start(message: string): void;
120
+ stop(message?: string): void;
121
+ fail(message?: string): void;
413
122
  };
414
- logging: {
415
- level: "fatal" | "error" | "warn" | "info" | "debug" | "silent";
416
- logDir: string;
417
- maxFileSize: string | number;
418
- maxFiles: number;
419
- sessionLogRetentionDays: number;
123
+ note(message: string, title?: string): void;
124
+ cancel(message?: string): void;
125
+ }
126
+ interface InstallContext {
127
+ pluginName: string;
128
+ terminal: TerminalIO;
129
+ settings: SettingsAPI;
130
+ legacyConfig?: Record<string, unknown>;
131
+ dataDir: string;
132
+ log: Logger$1;
133
+ /** Root of the OpenACP instance directory (e.g. ~/.openacp) */
134
+ instanceRoot?: string;
135
+ }
136
+ interface MigrateContext {
137
+ pluginName: string;
138
+ settings: SettingsAPI;
139
+ log: Logger$1;
140
+ }
141
+ type CommandResponse = {
142
+ type: 'text';
143
+ text: string;
144
+ } | {
145
+ type: 'menu';
146
+ title: string;
147
+ options: MenuOption[];
148
+ } | {
149
+ type: 'list';
150
+ title: string;
151
+ items: ListItem[];
152
+ } | {
153
+ type: 'confirm';
154
+ question: string;
155
+ onYes: string;
156
+ onNo: string;
157
+ } | {
158
+ type: 'error';
159
+ message: string;
160
+ } | {
161
+ type: 'silent';
162
+ } | {
163
+ type: 'delegated';
164
+ };
165
+ interface MenuItem {
166
+ id: string;
167
+ label: string;
168
+ priority: number;
169
+ group?: string;
170
+ action: {
171
+ type: 'command';
172
+ command: string;
173
+ } | {
174
+ type: 'delegate';
175
+ prompt: string;
176
+ } | {
177
+ type: 'callback';
178
+ callbackData: string;
420
179
  };
421
- runMode: "foreground" | "daemon";
422
- autoStart: boolean;
423
- sessionStore: {
424
- ttlDays: number;
180
+ visible?: () => boolean;
181
+ }
182
+ interface MenuOption {
183
+ label: string;
184
+ command: string;
185
+ hint?: string;
186
+ }
187
+ interface ListItem {
188
+ label: string;
189
+ detail?: string;
190
+ }
191
+ interface CommandArgs {
192
+ /** Raw argument string after command name */
193
+ raw: string;
194
+ /** Parsed key/value options (e.g., --flag value) */
195
+ options?: Record<string, string>;
196
+ /** Session ID where command was invoked (null if from notification/system topic) */
197
+ sessionId: string | null;
198
+ /** Channel ID ('telegram', 'discord', 'slack') */
199
+ channelId: string;
200
+ /** User ID who invoked the command */
201
+ userId: string;
202
+ /** Reply helper — sends message to the topic where command was invoked */
203
+ reply(content: string | CommandResponse | OutgoingMessage): Promise<void>;
204
+ /** Direct access to OpenACPCore instance. Available when 'kernel:access' permission is granted. */
205
+ coreAccess?: CoreAccess;
206
+ }
207
+ interface CommandDef {
208
+ /** Command name without slash, e.g., 'context' for /context */
209
+ name: string;
210
+ /** Short description shown in command list */
211
+ description: string;
212
+ /** Usage pattern, e.g., '<session-number>' */
213
+ usage?: string;
214
+ /** Whether this is a built-in system command or registered by a plugin */
215
+ category: 'system' | 'plugin';
216
+ /** Plugin that registered this command (set automatically by plugin manager) */
217
+ pluginName?: string;
218
+ /** Handler function */
219
+ handler(args: CommandArgs): Promise<CommandResponse | void>;
220
+ }
221
+ interface SessionManager$1 {
222
+ [key: string]: unknown;
223
+ }
224
+ interface ConfigManager$1 {
225
+ [key: string]: unknown;
226
+ }
227
+ interface EventBus$1 {
228
+ [key: string]: unknown;
229
+ }
230
+ /**
231
+ * Typed view of the OpenACPCore instance exposed to plugins via ctx.core.
232
+ * Plugins that need kernel:access should cast ctx.core to this interface
233
+ * instead of using `as any`. Only includes fields plugins actually need.
234
+ */
235
+ interface CoreAccess {
236
+ configManager: ConfigManager$1;
237
+ sessionManager: SessionManager$1;
238
+ adapters: Map<string, IChannelAdapter>;
239
+ }
240
+ interface Logger$1 {
241
+ trace(msg: string, ...args: unknown[]): void;
242
+ debug(msg: string, ...args: unknown[]): void;
243
+ info(msg: string, ...args: unknown[]): void;
244
+ warn(msg: string, ...args: unknown[]): void;
245
+ error(msg: string, ...args: unknown[]): void;
246
+ fatal(msg: string, ...args: unknown[]): void;
247
+ child(bindings: Record<string, unknown>): Logger$1;
248
+ }
249
+ interface PluginContext {
250
+ pluginName: string;
251
+ pluginConfig: Record<string, unknown>;
252
+ /** Subscribe to events. Auto-cleaned on teardown. Requires 'events:read'. */
253
+ on(event: string, handler: (...args: unknown[]) => void): void;
254
+ off(event: string, handler: (...args: unknown[]) => void): void;
255
+ /** Emit custom events. Event names MUST be prefixed with plugin name. Requires 'events:emit'. */
256
+ emit(event: string, payload: unknown): void;
257
+ /** Register middleware. Requires 'middleware:register'. */
258
+ registerMiddleware<H extends MiddlewareHook>(hook: H, opts: MiddlewareOptions<MiddlewarePayloadMap[H]>): void;
259
+ /** Provide a service. Requires 'services:register'. */
260
+ registerService<T>(name: string, implementation: T): void;
261
+ /** Consume a service. Requires 'services:use'. */
262
+ getService<T>(name: string): T | undefined;
263
+ /** Register slash command. Requires 'commands:register'. */
264
+ registerCommand(def: CommandDef): void;
265
+ /** Register a menu item. Requires 'commands:register'. */
266
+ registerMenuItem(item: MenuItem): void;
267
+ /** Unregister a menu item by id. Requires 'commands:register'. */
268
+ unregisterMenuItem(id: string): void;
269
+ /** Register an assistant section. Requires 'commands:register'. */
270
+ registerAssistantSection(section: AssistantSection): void;
271
+ /** Unregister an assistant section by id. Requires 'commands:register'. */
272
+ unregisterAssistantSection(id: string): void;
273
+ /** Plugin-scoped storage. Requires 'storage:read' and/or 'storage:write'. */
274
+ storage: PluginStorage;
275
+ /** Plugin-scoped logger. Always available (no permission needed). */
276
+ log: Logger$1;
277
+ /**
278
+ * Send message to a session. Requires 'services:use'.
279
+ *
280
+ * Routing: sessionId → lookup session → find adapter for session's channelId
281
+ * → [HOOK: message:outgoing] → adapter.sendMessage()
282
+ */
283
+ sendMessage(sessionId: string, content: OutgoingMessage): Promise<void>;
284
+ sessions: SessionManager$1;
285
+ config: ConfigManager$1;
286
+ eventBus: EventBus$1;
287
+ /** Direct access to OpenACPCore instance. Requires 'kernel:access'. */
288
+ core: unknown;
289
+ /**
290
+ * Root directory for this OpenACP instance (default: ~/.openacp).
291
+ * Plugins should derive file paths from this instead of hardcoding ~/.openacp.
292
+ */
293
+ instanceRoot: string;
294
+ }
295
+ interface MiddlewarePayloadMap {
296
+ 'message:incoming': {
297
+ channelId: string;
298
+ threadId: string;
299
+ userId: string;
300
+ text: string;
301
+ attachments?: Attachment[];
425
302
  };
426
- usage: {
427
- enabled: boolean;
428
- warningThreshold: number;
429
- currency: string;
430
- retentionDays: number;
431
- monthlyBudget?: number | undefined;
303
+ 'message:outgoing': {
304
+ sessionId: string;
305
+ message: OutgoingMessage;
432
306
  };
433
- integrations: Record<string, {
434
- installed: boolean;
435
- installedAt?: string | undefined;
436
- }>;
437
- speech: {
438
- stt: {
439
- provider: string | null;
440
- providers: Record<string, z.objectOutputType<{
441
- apiKey: z.ZodOptional<z.ZodString>;
442
- model: z.ZodOptional<z.ZodString>;
443
- }, z.ZodTypeAny, "passthrough">>;
444
- };
445
- tts: {
446
- provider: string | null;
447
- providers: Record<string, z.objectOutputType<{
448
- apiKey: z.ZodOptional<z.ZodString>;
449
- model: z.ZodOptional<z.ZodString>;
450
- }, z.ZodTypeAny, "passthrough">>;
451
- };
307
+ 'agent:beforePrompt': {
308
+ sessionId: string;
309
+ text: string;
310
+ attachments?: Attachment[];
452
311
  };
453
- agentSwitch: {
454
- labelHistory: boolean;
312
+ 'agent:beforeEvent': {
313
+ sessionId: string;
314
+ event: AgentEvent;
315
+ };
316
+ 'agent:afterEvent': {
317
+ sessionId: string;
318
+ event: AgentEvent;
319
+ outgoingMessage: OutgoingMessage;
320
+ };
321
+ 'turn:start': {
322
+ sessionId: string;
323
+ promptText: string;
324
+ promptNumber: number;
325
+ };
326
+ 'turn:end': {
327
+ sessionId: string;
328
+ stopReason: StopReason;
329
+ durationMs: number;
330
+ };
331
+ 'fs:beforeRead': {
332
+ sessionId: string;
333
+ path: string;
334
+ line?: number;
335
+ limit?: number;
336
+ };
337
+ 'fs:beforeWrite': {
338
+ sessionId: string;
339
+ path: string;
340
+ content: string;
341
+ };
342
+ 'terminal:beforeCreate': {
343
+ sessionId: string;
344
+ command: string;
345
+ args?: string[];
346
+ env?: Record<string, string>;
347
+ cwd?: string;
348
+ };
349
+ 'terminal:afterExit': {
350
+ sessionId: string;
351
+ terminalId: string;
352
+ command: string;
353
+ exitCode: number;
354
+ durationMs: number;
355
+ };
356
+ 'permission:beforeRequest': {
357
+ sessionId: string;
358
+ request: PermissionRequest;
359
+ autoResolve?: string;
360
+ };
361
+ 'permission:afterResolve': {
362
+ sessionId: string;
363
+ requestId: string;
364
+ decision: string;
365
+ userId: string;
366
+ durationMs: number;
367
+ };
368
+ 'session:beforeCreate': {
369
+ agentName: string;
370
+ workingDir: string;
371
+ userId: string;
372
+ channelId: string;
373
+ threadId: string;
374
+ };
375
+ 'session:afterDestroy': {
376
+ sessionId: string;
377
+ reason: string;
378
+ durationMs: number;
379
+ promptCount: number;
380
+ };
381
+ 'config:beforeChange': {
382
+ sessionId: string;
383
+ configId: string;
384
+ oldValue: unknown;
385
+ newValue: unknown;
386
+ };
387
+ 'agent:beforeCancel': {
388
+ sessionId: string;
389
+ reason?: string;
390
+ };
391
+ 'agent:beforeSwitch': {
392
+ sessionId: string;
393
+ fromAgent: string;
394
+ toAgent: string;
395
+ };
396
+ 'agent:afterSwitch': {
397
+ sessionId: string;
398
+ fromAgent: string;
399
+ toAgent: string;
400
+ resumed: boolean;
455
401
  };
456
- instanceName?: string | undefined;
457
- outputMode?: "low" | "medium" | "high" | undefined;
458
- }, {
459
- defaultAgent: string;
460
- api?: {
461
- port?: number | undefined;
462
- host?: string | undefined;
463
- } | undefined;
464
- agents?: Record<string, {
465
- command: string;
466
- args?: string[] | undefined;
467
- env?: Record<string, string> | undefined;
468
- workingDirectory?: string | undefined;
469
- }> | undefined;
470
- tunnel?: {
471
- provider?: "openacp" | "cloudflare" | "ngrok" | "bore" | "tailscale" | undefined;
472
- options?: Record<string, unknown> | undefined;
473
- enabled?: boolean | undefined;
474
- port?: number | undefined;
475
- maxUserTunnels?: number | undefined;
476
- storeTtlMinutes?: number | undefined;
477
- auth?: {
478
- enabled?: boolean | undefined;
479
- token?: string | undefined;
480
- } | undefined;
481
- } | undefined;
482
- instanceName?: string | undefined;
483
- channels?: z.objectInputType<{}, z.ZodObject<{
484
- enabled: z.ZodDefault<z.ZodBoolean>;
485
- adapter: z.ZodOptional<z.ZodString>;
486
- displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
487
- outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
488
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
489
- enabled: z.ZodDefault<z.ZodBoolean>;
490
- adapter: z.ZodOptional<z.ZodString>;
491
- displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
492
- outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
493
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
494
- enabled: z.ZodDefault<z.ZodBoolean>;
495
- adapter: z.ZodOptional<z.ZodString>;
496
- displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
497
- outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
498
- }, z.ZodTypeAny, "passthrough">>, "strip"> | undefined;
499
- outputMode?: "low" | "medium" | "high" | undefined;
500
- workspace?: {
501
- baseDir?: string | undefined;
502
- } | undefined;
503
- security?: {
504
- allowedUserIds?: string[] | undefined;
505
- maxConcurrentSessions?: number | undefined;
506
- sessionTimeoutMinutes?: number | undefined;
507
- } | undefined;
508
- logging?: {
509
- level?: "fatal" | "error" | "warn" | "info" | "debug" | "silent" | undefined;
510
- logDir?: string | undefined;
511
- maxFileSize?: string | number | undefined;
512
- maxFiles?: number | undefined;
513
- sessionLogRetentionDays?: number | undefined;
514
- } | undefined;
515
- runMode?: "foreground" | "daemon" | undefined;
516
- autoStart?: boolean | undefined;
517
- sessionStore?: {
518
- ttlDays?: number | undefined;
519
- } | undefined;
520
- usage?: {
521
- enabled?: boolean | undefined;
522
- monthlyBudget?: number | undefined;
523
- warningThreshold?: number | undefined;
524
- currency?: string | undefined;
525
- retentionDays?: number | undefined;
526
- } | undefined;
527
- integrations?: Record<string, {
528
- installed: boolean;
529
- installedAt?: string | undefined;
530
- }> | undefined;
531
- speech?: {
532
- stt?: {
533
- provider?: string | null | undefined;
534
- providers?: Record<string, z.objectInputType<{
535
- apiKey: z.ZodOptional<z.ZodString>;
536
- model: z.ZodOptional<z.ZodString>;
537
- }, z.ZodTypeAny, "passthrough">> | undefined;
538
- } | undefined;
539
- tts?: {
540
- provider?: string | null | undefined;
541
- providers?: Record<string, z.objectInputType<{
542
- apiKey: z.ZodOptional<z.ZodString>;
543
- model: z.ZodOptional<z.ZodString>;
544
- }, z.ZodTypeAny, "passthrough">> | undefined;
545
- } | undefined;
546
- } | undefined;
547
- agentSwitch?: {
548
- labelHistory?: boolean | undefined;
549
- } | undefined;
550
- }>;
551
- type Config = z.infer<typeof ConfigSchema>;
552
- declare function expandHome(p: string): string;
553
- declare class ConfigManager$1 extends EventEmitter {
554
- private config;
555
- private configPath;
556
- constructor(configPath?: string);
557
- load(): Promise<void>;
558
- get(): Config;
559
- save(updates: Record<string, unknown>, changePath?: string): Promise<void>;
560
- /**
561
- * Set a single config value by dot-path (e.g. "security.maxConcurrentSessions").
562
- * Builds the nested update object, validates, and saves.
563
- * Throws if the path contains blocked keys or the value fails Zod validation.
564
- */
565
- setPath(dotPath: string, value: unknown): Promise<void>;
566
- resolveWorkspace(input?: string): string;
567
- exists(): Promise<boolean>;
568
- getConfigPath(): string;
569
- writeNew(config: Config): Promise<void>;
570
- private applyEnvOverrides;
571
- private deepMerge;
572
402
  }
573
-
574
- type Logger$1 = pino.Logger;
575
- declare const log: {
576
- info: (...args: unknown[]) => void;
577
- warn: (...args: unknown[]) => void;
578
- error: (...args: unknown[]) => void;
579
- debug: (...args: unknown[]) => void;
580
- fatal: (...args: unknown[]) => void;
581
- child: (bindings: pino.Bindings) => pino.Logger<never, boolean>;
582
- };
583
- declare function initLogger(config: LoggingConfig): Logger$1;
584
- /** Change log level at runtime. Pino transport targets respect parent level changes automatically. */
585
- declare function setLogLevel(level: string): void;
586
- declare function createChildLogger(context: {
587
- module: string;
588
- [key: string]: unknown;
589
- }): Logger$1;
590
- declare function createSessionLogger(sessionId: string, parentLogger: Logger$1): Logger$1;
591
- declare function shutdownLogger(): Promise<void>;
592
- declare function cleanupOldSessionLogs(retentionDays: number): Promise<void>;
593
-
594
- declare function nodeToWebWritable(nodeStream: NodeJS.WritableStream): WritableStream<Uint8Array>;
595
- declare function nodeToWebReadable(nodeStream: NodeJS.ReadableStream): ReadableStream<Uint8Array>;
596
-
597
- declare class StderrCapture {
598
- private maxLines;
599
- private lines;
600
- constructor(maxLines?: number);
601
- append(chunk: string): void;
602
- getLastLines(): string;
403
+ type MiddlewareHook = keyof MiddlewarePayloadMap;
404
+ type MiddlewareFn<T> = (payload: T, next: () => Promise<T>) => Promise<T | null>;
405
+ interface MiddlewareOptions<T> {
406
+ /** Override execution order within same dependency level. Lower = earlier. */
407
+ priority?: number;
408
+ /** The middleware handler */
409
+ handler: MiddlewareFn<T>;
603
410
  }
604
-
605
- /**
606
- * A minimal, generic typed event emitter.
607
- *
608
- * Usage:
609
- * interface MyEvents {
610
- * data: (payload: string) => void
611
- * error: (err: Error) => void
612
- * }
613
- * const emitter = new TypedEmitter<MyEvents>()
614
- * emitter.on('data', (payload) => { ... })
615
- * emitter.emit('data', 'hello')
616
- */
617
- declare class TypedEmitter<T extends Record<string & keyof T, (...args: any[]) => void>> {
618
- private listeners;
619
- private paused;
620
- private buffer;
621
- on<K extends keyof T>(event: K, listener: T[K]): this;
622
- off<K extends keyof T>(event: K, listener: T[K]): this;
623
- emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): void;
624
- /**
625
- * Pause event delivery. Events emitted while paused are buffered.
626
- * Optionally pass a filter to allow specific events through even while paused.
627
- */
628
- pause(passthrough?: (event: keyof T, args: unknown[]) => boolean): void;
629
- private passthroughFn?;
630
- /** Resume event delivery and replay buffered events in order. */
631
- resume(): void;
632
- /** Discard all buffered events without delivering them. */
633
- clearBuffer(): void;
634
- get isPaused(): boolean;
635
- get bufferSize(): number;
636
- removeAllListeners(event?: keyof T): void;
637
- private deliver;
411
+ interface SecurityService {
412
+ checkAccess(userId: string): Promise<{
413
+ allowed: boolean;
414
+ reason?: string;
415
+ }>;
416
+ checkSessionLimit(userId: string): Promise<{
417
+ allowed: boolean;
418
+ reason?: string;
419
+ }>;
420
+ getUserRole(userId: string): Promise<'admin' | 'user' | 'blocked'>;
638
421
  }
639
-
640
- interface ErrorBudgetConfig {
641
- maxErrors: number;
642
- windowMs: number;
422
+ interface FileServiceInterface {
423
+ saveFile(sessionId: string, fileName: string, data: Buffer, mimeType: string): Promise<Attachment>;
424
+ resolveFile(filePath: string): Promise<Attachment | null>;
425
+ readTextFileWithRange(path: string, opts?: {
426
+ line?: number;
427
+ limit?: number;
428
+ }): Promise<string>;
429
+ extensionFromMime(mimeType: string): string;
430
+ convertOggToWav(oggData: Buffer): Promise<Buffer>;
643
431
  }
644
- declare class ErrorTracker {
645
- private errors;
646
- private disabled;
647
- private exempt;
648
- private config;
649
- onDisabled?: (pluginName: string, reason: string) => void;
650
- constructor(config?: Partial<ErrorBudgetConfig>);
651
- increment(pluginName: string): void;
652
- isDisabled(pluginName: string): boolean;
653
- reset(pluginName: string): void;
654
- setExempt(pluginName: string): void;
655
- }
656
-
657
- declare class MiddlewareChain {
658
- private chains;
659
- private errorHandler?;
660
- private errorTracker?;
661
- add(hook: string, pluginName: string, opts: {
662
- priority?: number;
663
- handler: Function;
664
- }): void;
665
- execute<T>(hook: string, payload: T, coreHandler: (p: T) => T | Promise<T>): Promise<T | null>;
666
- removeAll(pluginName: string): void;
667
- setErrorHandler(fn: (pluginName: string, error: Error) => void): void;
668
- setErrorTracker(tracker: ErrorTracker): void;
669
- }
670
-
671
- type TraceLayer = "acp" | "core" | "telegram";
672
- /**
673
- * Per-session debug trace logger. Writes JSONL files to <workingDirectory>/.log/.
674
- * Only active when OPENACP_DEBUG=true. Zero overhead when disabled.
675
- *
676
- * Note: Uses appendFileSync for simplicity. This blocks the event loop briefly per write,
677
- * which is acceptable for a debug-only tool. The DEBUG_ENABLED guard ensures zero overhead
678
- * in production.
679
- */
680
- declare class DebugTracer {
681
- private sessionId;
682
- private workingDirectory;
683
- private dirCreated;
684
- private logDir;
685
- constructor(sessionId: string, workingDirectory: string);
686
- log(layer: TraceLayer, data: Record<string, unknown>): void;
687
- /** No-op cleanup — establishes the pattern for future async implementations */
688
- destroy(): void;
689
- }
690
-
691
- interface AgentInstanceEvents {
692
- agent_event: (event: AgentEvent) => void;
693
- }
694
- declare class AgentInstance extends TypedEmitter<AgentInstanceEvents> {
695
- private connection;
696
- private child;
697
- private stderrCapture;
698
- private terminalManager;
699
- private static mcpManager;
700
- private _destroying;
701
- sessionId: string;
702
- agentName: string;
703
- promptCapabilities?: {
704
- image?: boolean;
705
- audio?: boolean;
706
- };
707
- agentCapabilities?: AgentCapabilities;
708
- /** Preserved from newSession/resumeSession response for ACP state propagation */
709
- initialSessionResponse?: {
710
- modes?: unknown;
711
- configOptions?: unknown;
712
- models?: unknown;
713
- };
714
- middlewareChain?: MiddlewareChain;
715
- debugTracer: DebugTracer | null;
716
- onPermissionRequest: (request: PermissionRequest) => Promise<string>;
717
- private constructor();
718
- private static spawnSubprocess;
719
- private setupCrashDetection;
720
- static spawn(agentDef: AgentDefinition, workingDirectory: string, mcpServers?: McpServerConfig[]): Promise<AgentInstance>;
721
- static resume(agentDef: AgentDefinition, workingDirectory: string, agentSessionId: string, mcpServers?: McpServerConfig[]): Promise<AgentInstance>;
722
- private createClient;
723
- setConfigOption(configId: string, value: SetConfigOptionValue): Promise<SetSessionConfigOptionResponse>;
724
- listSessions(cwd?: string, cursor?: string): Promise<ListSessionsResponse>;
725
- loadSession(sessionId: string, cwd: string, mcpServers?: McpServerConfig[]): Promise<LoadSessionResponse>;
726
- authenticate(methodId: string): Promise<void>;
727
- forkSession(sessionId: string, cwd: string, mcpServers?: McpServerConfig[]): Promise<ForkSessionResponse>;
728
- closeSession(sessionId: string): Promise<void>;
729
- prompt(text: string, attachments?: Attachment[]): Promise<PromptResponse>;
730
- cancel(): Promise<void>;
731
- destroy(): Promise<void>;
732
- }
733
-
734
- declare class AgentStore {
735
- private data;
736
- private filePath;
737
- constructor(filePath?: string);
738
- load(): void;
739
- exists(): boolean;
740
- getInstalled(): Record<string, InstalledAgent>;
741
- getAgent(key: string): InstalledAgent | undefined;
742
- addAgent(key: string, agent: InstalledAgent): void;
743
- removeAgent(key: string): void;
744
- hasAgent(key: string): boolean;
745
- private save;
432
+ interface NotificationService {
433
+ notify(channelId: string, notification: NotificationMessage): Promise<void>;
434
+ notifyAll(notification: NotificationMessage): Promise<void>;
746
435
  }
747
-
748
- declare class AgentCatalog {
749
- private store;
750
- private registryAgents;
751
- private cachePath;
752
- private agentsDir;
753
- constructor(store?: AgentStore, cachePath?: string, agentsDir?: string);
754
- load(): void;
755
- fetchRegistry(): Promise<void>;
756
- refreshRegistryIfStale(): Promise<void>;
757
- getRegistryAgents(): RegistryAgent[];
758
- getRegistryAgent(registryId: string): RegistryAgent | undefined;
759
- findRegistryAgent(keyOrId: string): RegistryAgent | undefined;
760
- getInstalled(): InstalledAgent[];
761
- getInstalledEntries(): Record<string, InstalledAgent>;
762
- getInstalledAgent(key: string): InstalledAgent | undefined;
763
- getAvailable(): AgentListItem[];
764
- checkAvailability(keyOrId: string): AvailabilityResult;
765
- install(keyOrId: string, progress?: InstallProgress, force?: boolean): Promise<InstallResult>;
766
- uninstall(key: string): Promise<{
436
+ interface UsageService {
437
+ trackUsage(record: UsageRecord): Promise<void>;
438
+ checkBudget(sessionId: string): Promise<{
767
439
  ok: boolean;
768
- error?: string;
440
+ percent: number;
441
+ warning?: string;
769
442
  }>;
770
- resolve(key: string): AgentDefinition | undefined;
771
- /**
772
- * Enrich installed agents (especially migrated ones) with registry data.
773
- * Fixes agents that were migrated with version:"unknown", distribution:"custom",
774
- * or generic names by matching them to registry entries.
775
- */
776
- private enrichInstalledFromRegistry;
777
- private isCacheStale;
778
- private loadRegistryFromCacheOrSnapshot;
779
443
  }
780
-
781
- declare class AgentManager {
782
- private catalog;
783
- constructor(catalog: AgentCatalog);
784
- getAvailableAgents(): AgentDefinition[];
785
- getAgent(name: string): AgentDefinition | undefined;
786
- spawn(agentName: string, workingDirectory: string): Promise<AgentInstance>;
787
- resume(agentName: string, workingDirectory: string, agentSessionId: string): Promise<AgentInstance>;
444
+ interface TTSProvider$1 {
445
+ synthesize(text: string, opts?: {
446
+ language?: string;
447
+ voice?: string;
448
+ }): Promise<Buffer>;
788
449
  }
789
-
790
- /**
791
- * Encapsulates pending permission state with a typed Promise API.
792
- */
793
- declare class PermissionGate {
794
- private request?;
795
- private resolveFn?;
796
- private rejectFn?;
797
- private settled;
798
- private timeoutTimer?;
799
- private timeoutMs;
800
- constructor(timeoutMs?: number);
801
- setPending(request: PermissionRequest): Promise<string>;
802
- resolve(optionId: string): void;
803
- reject(reason?: string): void;
804
- get isPending(): boolean;
805
- get currentRequest(): PermissionRequest | undefined;
806
- /** The request ID of the current pending request, undefined after settlement */
807
- get requestId(): string | undefined;
808
- private clearTimeout;
809
- private cleanup;
450
+ interface STTProvider$1 {
451
+ transcribe(audio: Buffer, opts?: {
452
+ language?: string;
453
+ }): Promise<string>;
810
454
  }
811
-
812
- interface STTOptions {
813
- language?: string;
814
- model?: string;
455
+ interface SpeechServiceInterface {
456
+ textToSpeech(text: string, opts?: {
457
+ language?: string;
458
+ voice?: string;
459
+ }): Promise<Buffer>;
460
+ speechToText(audio: Buffer, opts?: {
461
+ language?: string;
462
+ }): Promise<string>;
463
+ registerTTSProvider(name: string, provider: TTSProvider$1): void;
464
+ registerSTTProvider(name: string, provider: STTProvider$1): void;
815
465
  }
816
- interface STTResult {
817
- text: string;
818
- language?: string;
819
- duration?: number;
466
+ interface ContextProvider$1 {
467
+ provide(sessionId: string, opts?: {
468
+ maxTokens?: number;
469
+ }): Promise<string>;
820
470
  }
821
- interface TTSOptions {
822
- language?: string;
823
- voice?: string;
824
- model?: string;
471
+ interface ContextService {
472
+ buildContext(sessionId: string, opts?: {
473
+ maxTokens?: number;
474
+ }): Promise<string>;
475
+ registerProvider(provider: ContextProvider$1): void;
825
476
  }
826
- interface TTSResult {
827
- audioBuffer: Buffer;
828
- mimeType: string;
477
+ interface ViewerStoreInterface {
478
+ storeFile(sessionId: string, filePath: string, content: string, workingDirectory: string): string | null;
479
+ storeDiff(sessionId: string, filePath: string, oldContent: string, newContent: string, workingDirectory: string): string | null;
480
+ storeOutput(sessionId: string, label: string, output: string): string | null;
829
481
  }
830
- interface STTProvider$1 {
831
- readonly name: string;
832
- transcribe(audioBuffer: Buffer, mimeType: string, options?: STTOptions): Promise<STTResult>;
482
+ interface TunnelServiceInterface {
483
+ getPublicUrl(): string;
484
+ start(apiPort: number): Promise<string>;
485
+ stop(): Promise<void>;
486
+ getStore(): ViewerStoreInterface;
487
+ fileUrl(entryId: string): string;
488
+ diffUrl(entryId: string): string;
489
+ outputUrl(entryId: string): string;
833
490
  }
834
- interface TTSProvider$1 {
835
- readonly name: string;
836
- synthesize(text: string, options?: TTSOptions): Promise<TTSResult>;
491
+
492
+ interface ValidationResult {
493
+ valid: boolean;
494
+ errors?: string[];
837
495
  }
838
- interface SpeechProviderConfig {
839
- apiKey?: string;
840
- model?: string;
841
- [key: string]: unknown;
842
- }
843
- interface SpeechServiceConfig {
844
- stt: {
845
- provider: string | null;
846
- providers: Record<string, SpeechProviderConfig>;
847
- };
848
- tts: {
849
- provider: string | null;
850
- providers: Record<string, SpeechProviderConfig>;
851
- };
852
- }
853
-
854
- type ProviderFactory = (config: SpeechServiceConfig) => {
855
- stt: Map<string, STTProvider$1>;
856
- tts: Map<string, TTSProvider$1>;
857
- };
858
- declare class SpeechService {
859
- private config;
860
- private sttProviders;
861
- private ttsProviders;
862
- private providerFactory?;
863
- constructor(config: SpeechServiceConfig);
864
- /** Set a factory function that can recreate providers from config (for hot-reload) */
865
- setProviderFactory(factory: ProviderFactory): void;
866
- registerSTTProvider(name: string, provider: STTProvider$1): void;
867
- registerTTSProvider(name: string, provider: TTSProvider$1): void;
868
- unregisterTTSProvider(name: string): void;
869
- isSTTAvailable(): boolean;
870
- isTTSAvailable(): boolean;
871
- transcribe(audioBuffer: Buffer, mimeType: string, options?: STTOptions): Promise<STTResult>;
872
- synthesize(text: string, options?: TTSOptions): Promise<TTSResult>;
873
- updateConfig(config: SpeechServiceConfig): void;
874
- /** Re-create factory-managed providers from config. Preserves externally-registered providers (e.g. from plugins). */
875
- refreshProviders(newConfig: SpeechServiceConfig): void;
876
- }
877
-
878
- declare class GroqSTT implements STTProvider$1 {
879
- private apiKey;
880
- private defaultModel;
881
- readonly name = "groq";
882
- constructor(apiKey: string, defaultModel?: string);
883
- transcribe(audioBuffer: Buffer, mimeType: string, options?: STTOptions): Promise<STTResult>;
496
+ declare class SettingsManager {
497
+ private basePath;
498
+ constructor(basePath: string);
499
+ getBasePath(): string;
500
+ createAPI(pluginName: string): SettingsAPI;
501
+ loadSettings(pluginName: string): Promise<Record<string, unknown>>;
502
+ validateSettings(_pluginName: string, settings: unknown, schema?: ZodSchema): ValidationResult;
503
+ getSettingsPath(pluginName: string): string;
504
+ getPluginSettings(pluginName: string): Promise<Record<string, unknown>>;
505
+ updatePluginSettings(pluginName: string, updates: Record<string, unknown>): Promise<void>;
884
506
  }
885
507
 
886
- interface SessionEvents {
887
- agent_event: (event: AgentEvent) => void;
888
- permission_request: (request: PermissionRequest) => void;
889
- session_end: (reason: string) => void;
890
- status_change: (from: SessionStatus, to: SessionStatus) => void;
891
- named: (name: string) => void;
892
- error: (error: Error) => void;
893
- prompt_count_changed: (count: number) => void;
894
- }
895
- declare class Session extends TypedEmitter<SessionEvents> {
896
- id: string;
897
- channelId: string;
898
- threadId: string;
899
- agentName: string;
900
- workingDirectory: string;
901
- agentInstance: AgentInstance;
902
- agentSessionId: string;
903
- private _status;
904
- name?: string;
905
- createdAt: Date;
906
- voiceMode: "off" | "next" | "on";
907
- configOptions: ConfigOption[];
908
- clientOverrides: {
909
- bypassPermissions?: boolean;
508
+ declare const LoggingSchema: z.ZodDefault<z.ZodObject<{
509
+ level: z.ZodDefault<z.ZodEnum<["silent", "debug", "info", "warn", "error", "fatal"]>>;
510
+ logDir: z.ZodDefault<z.ZodString>;
511
+ maxFileSize: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
512
+ maxFiles: z.ZodDefault<z.ZodNumber>;
513
+ sessionLogRetentionDays: z.ZodDefault<z.ZodNumber>;
514
+ }, "strip", z.ZodTypeAny, {
515
+ level: "fatal" | "error" | "warn" | "info" | "debug" | "silent";
516
+ logDir: string;
517
+ maxFileSize: string | number;
518
+ maxFiles: number;
519
+ sessionLogRetentionDays: number;
520
+ }, {
521
+ level?: "fatal" | "error" | "warn" | "info" | "debug" | "silent" | undefined;
522
+ logDir?: string | undefined;
523
+ maxFileSize?: string | number | undefined;
524
+ maxFiles?: number | undefined;
525
+ sessionLogRetentionDays?: number | undefined;
526
+ }>>;
527
+ type LoggingConfig = z.infer<typeof LoggingSchema>;
528
+ declare const TunnelSchema: z.ZodDefault<z.ZodObject<{
529
+ enabled: z.ZodDefault<z.ZodBoolean>;
530
+ port: z.ZodDefault<z.ZodNumber>;
531
+ provider: z.ZodDefault<z.ZodEnum<["openacp", "cloudflare", "ngrok", "bore", "tailscale"]>>;
532
+ options: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
533
+ maxUserTunnels: z.ZodDefault<z.ZodNumber>;
534
+ storeTtlMinutes: z.ZodDefault<z.ZodNumber>;
535
+ auth: z.ZodDefault<z.ZodObject<{
536
+ enabled: z.ZodDefault<z.ZodBoolean>;
537
+ token: z.ZodOptional<z.ZodString>;
538
+ }, "strip", z.ZodTypeAny, {
539
+ enabled: boolean;
540
+ token?: string | undefined;
541
+ }, {
542
+ enabled?: boolean | undefined;
543
+ token?: string | undefined;
544
+ }>>;
545
+ }, "strip", z.ZodTypeAny, {
546
+ provider: "openacp" | "cloudflare" | "ngrok" | "bore" | "tailscale";
547
+ enabled: boolean;
548
+ options: Record<string, unknown>;
549
+ port: number;
550
+ maxUserTunnels: number;
551
+ storeTtlMinutes: number;
552
+ auth: {
553
+ enabled: boolean;
554
+ token?: string | undefined;
910
555
  };
911
- agentCapabilities?: AgentCapabilities;
912
- archiving: boolean;
913
- promptCount: number;
914
- firstAgent: string;
915
- agentSwitchHistory: AgentSwitchEntry[];
916
- isAssistant: boolean;
917
- log: Logger$1;
918
- middlewareChain?: MiddlewareChain;
919
- /** Latest commands emitted by the agent — buffered before bridge connects so they're not lost */
920
- latestCommands: AgentCommand[] | null;
921
- readonly permissionGate: PermissionGate;
922
- private readonly queue;
923
- private speechService?;
924
- private pendingContext;
925
- constructor(opts: {
926
- id?: string;
927
- channelId: string;
928
- agentName: string;
929
- workingDirectory: string;
930
- agentInstance: AgentInstance;
931
- speechService?: SpeechService;
932
- isAssistant?: boolean;
933
- });
934
- get status(): SessionStatus;
935
- /** Transition to active — from initializing, error, or cancelled */
936
- activate(): void;
937
- /** Transition to error — from initializing or active. Idempotent if already in error. */
938
- fail(reason: string): void;
939
- /** Transition to finished — from active only. Emits session_end for backward compat. */
940
- finish(reason?: string): void;
941
- /** Transition to cancelled — from active only (terminal session cancel) */
942
- markCancelled(): void;
943
- private transition;
944
- /** Number of prompts waiting in queue */
945
- get queueDepth(): number;
946
- get promptRunning(): boolean;
947
- setContext(markdown: string): void;
948
- setVoiceMode(mode: "off" | "next" | "on"): void;
949
- enqueuePrompt(text: string, attachments?: Attachment[]): Promise<void>;
950
- private processPrompt;
951
- private maybeTranscribeAudio;
952
- private processTTSResponse;
953
- private autoName;
954
- setInitialConfigOptions(options: ConfigOption[]): void;
955
- setAgentCapabilities(caps: AgentCapabilities | undefined): void;
956
- getConfigOption(id: string): ConfigOption | undefined;
957
- getConfigByCategory(category: string): ConfigOption | undefined;
958
- getConfigValue(id: string): string | undefined;
959
- /** Set session name explicitly and emit 'named' event */
960
- setName(name: string): void;
961
- /** Send a config option change to the agent and update local state from the response. */
962
- setConfigOption(configId: string, value: SetConfigOptionValue): Promise<void>;
963
- updateConfigOptions(options: ConfigOption[]): Promise<void>;
964
- /** Snapshot of current ACP state for persistence */
965
- toAcpStateSnapshot(): NonNullable<SessionRecord["acpState"]>;
966
- /** Check if the agent supports a specific session capability */
967
- supportsCapability(cap: 'list' | 'fork' | 'close' | 'loadSession'): boolean;
968
- /** Cancel the current prompt and clear the queue. Stays in active state. */
969
- abortPrompt(): Promise<void>;
970
- /** Search backward through agentSwitchHistory for the last entry matching agentName */
971
- findLastSwitchEntry(agentName: string): AgentSwitchEntry | undefined;
972
- /** Switch the agent instance in-place, preserving session identity */
973
- switchAgent(agentName: string, createAgent: () => Promise<AgentInstance>): Promise<void>;
974
- destroy(): Promise<void>;
975
- }
976
-
977
- /**
978
- * Serial prompt queue — ensures prompts are processed one at a time.
979
- */
980
- declare class PromptQueue {
981
- private processor;
982
- private onError?;
983
- private queue;
984
- private processing;
985
- private abortController;
986
- constructor(processor: (text: string, attachments?: Attachment[]) => Promise<void>, onError?: ((err: unknown) => void) | undefined);
987
- enqueue(text: string, attachments?: Attachment[]): Promise<void>;
988
- private process;
989
- private drainNext;
990
- clear(): void;
991
- get pending(): number;
992
- get isProcessing(): boolean;
993
- }
994
-
995
- interface AssistantCommand {
996
- command: string;
997
- description: string;
998
- }
999
- interface AssistantSection {
1000
- id: string;
1001
- title: string;
1002
- priority: number;
1003
- buildContext: () => string | null;
1004
- commands?: AssistantCommand[];
1005
- }
1006
- declare class AssistantRegistry {
1007
- private sections;
1008
- private _instanceRoot;
1009
- /** Set the instance root path used in assistant guidelines */
1010
- setInstanceRoot(root: string): void;
1011
- register(section: AssistantSection): void;
1012
- unregister(id: string): void;
1013
- buildSystemPrompt(channelId?: string): string;
1014
- }
1015
-
1016
- type PluginPermission = 'events:read' | 'events:emit' | 'services:register' | 'services:use' | 'middleware:register' | 'commands:register' | 'storage:read' | 'storage:write' | 'kernel:access';
1017
- interface OpenACPPlugin {
1018
- /** Unique identifier, e.g., '@openacp/security' */
1019
- name: string;
1020
- /** Semver version */
1021
- version: string;
1022
- /** Human-readable description */
1023
- description?: string;
1024
- /** Required plugin dependencies — loaded before this plugin's setup() */
1025
- pluginDependencies?: Record<string, string>;
1026
- /** Optional dependencies — used if available, gracefully degrade if not */
1027
- optionalPluginDependencies?: Record<string, string>;
1028
- /** Override a built-in plugin (replaces it entirely) */
1029
- overrides?: string;
1030
- /** Required permissions PluginContext enforces these */
1031
- permissions?: PluginPermission[];
1032
- /** Called during startup in dependency order */
1033
- setup(ctx: PluginContext): Promise<void>;
1034
- /** Called during shutdown in reverse order. 10s timeout. */
1035
- teardown?(): Promise<void>;
1036
- install?(ctx: InstallContext): Promise<void>;
1037
- uninstall?(ctx: InstallContext, opts: {
1038
- purge: boolean;
1039
- }): Promise<void>;
1040
- configure?(ctx: InstallContext): Promise<void>;
1041
- migrate?(ctx: MigrateContext, oldSettings: unknown, oldVersion: string): Promise<unknown>;
1042
- settingsSchema?: zod.ZodSchema;
1043
- essential?: boolean;
1044
- /** Settings keys that can be copied when creating a new instance from this one */
1045
- inheritableKeys?: string[];
1046
- }
1047
- interface PluginStorage {
1048
- get<T>(key: string): Promise<T | undefined>;
1049
- set<T>(key: string, value: T): Promise<void>;
1050
- delete(key: string): Promise<void>;
1051
- list(): Promise<string[]>;
1052
- getDataDir(): string;
1053
- }
1054
- interface SettingsAPI {
1055
- get<T = unknown>(key: string): Promise<T | undefined>;
1056
- set<T = unknown>(key: string, value: T): Promise<void>;
1057
- getAll(): Promise<Record<string, unknown>>;
1058
- setAll(settings: Record<string, unknown>): Promise<void>;
1059
- delete(key: string): Promise<void>;
1060
- clear(): Promise<void>;
1061
- has(key: string): Promise<boolean>;
1062
- }
1063
- interface TerminalIO {
1064
- text(opts: {
1065
- message: string;
1066
- placeholder?: string;
1067
- defaultValue?: string;
1068
- validate?: (value: string) => string | undefined;
1069
- }): Promise<string>;
1070
- select<T>(opts: {
1071
- message: string;
1072
- options: {
1073
- value: T;
1074
- label: string;
1075
- hint?: string;
1076
- }[];
1077
- }): Promise<T>;
1078
- confirm(opts: {
1079
- message: string;
1080
- initialValue?: boolean;
1081
- }): Promise<boolean>;
1082
- password(opts: {
1083
- message: string;
1084
- validate?: (value: string) => string | undefined;
1085
- }): Promise<string>;
1086
- multiselect<T>(opts: {
1087
- message: string;
1088
- options: {
1089
- value: T;
1090
- label: string;
1091
- hint?: string;
1092
- }[];
1093
- required?: boolean;
1094
- }): Promise<T[]>;
1095
- log: {
1096
- info(message: string): void;
1097
- success(message: string): void;
1098
- warning(message: string): void;
1099
- error(message: string): void;
1100
- step(message: string): void;
556
+ }, {
557
+ provider?: "openacp" | "cloudflare" | "ngrok" | "bore" | "tailscale" | undefined;
558
+ enabled?: boolean | undefined;
559
+ options?: Record<string, unknown> | undefined;
560
+ port?: number | undefined;
561
+ maxUserTunnels?: number | undefined;
562
+ storeTtlMinutes?: number | undefined;
563
+ auth?: {
564
+ enabled?: boolean | undefined;
565
+ token?: string | undefined;
566
+ } | undefined;
567
+ }>>;
568
+ type TunnelConfig = z.infer<typeof TunnelSchema>;
569
+ declare const UsageSchema: z.ZodDefault<z.ZodObject<{
570
+ enabled: z.ZodDefault<z.ZodBoolean>;
571
+ monthlyBudget: z.ZodOptional<z.ZodNumber>;
572
+ warningThreshold: z.ZodDefault<z.ZodNumber>;
573
+ currency: z.ZodDefault<z.ZodString>;
574
+ retentionDays: z.ZodDefault<z.ZodNumber>;
575
+ }, "strip", z.ZodTypeAny, {
576
+ enabled: boolean;
577
+ warningThreshold: number;
578
+ currency: string;
579
+ retentionDays: number;
580
+ monthlyBudget?: number | undefined;
581
+ }, {
582
+ enabled?: boolean | undefined;
583
+ monthlyBudget?: number | undefined;
584
+ warningThreshold?: number | undefined;
585
+ currency?: string | undefined;
586
+ retentionDays?: number | undefined;
587
+ }>>;
588
+ type UsageConfig = z.infer<typeof UsageSchema>;
589
+ declare const ConfigSchema: z.ZodObject<{
590
+ instanceName: z.ZodOptional<z.ZodString>;
591
+ channels: z.ZodDefault<z.ZodObject<{}, "strip", z.ZodObject<{
592
+ enabled: z.ZodDefault<z.ZodBoolean>;
593
+ adapter: z.ZodOptional<z.ZodString>;
594
+ displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
595
+ outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
596
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
597
+ enabled: z.ZodDefault<z.ZodBoolean>;
598
+ adapter: z.ZodOptional<z.ZodString>;
599
+ displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
600
+ outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
601
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
602
+ enabled: z.ZodDefault<z.ZodBoolean>;
603
+ adapter: z.ZodOptional<z.ZodString>;
604
+ displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
605
+ outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
606
+ }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{}, z.ZodObject<{
607
+ enabled: z.ZodDefault<z.ZodBoolean>;
608
+ adapter: z.ZodOptional<z.ZodString>;
609
+ displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
610
+ outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
611
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
612
+ enabled: z.ZodDefault<z.ZodBoolean>;
613
+ adapter: z.ZodOptional<z.ZodString>;
614
+ displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
615
+ outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
616
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
617
+ enabled: z.ZodDefault<z.ZodBoolean>;
618
+ adapter: z.ZodOptional<z.ZodString>;
619
+ displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
620
+ outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
621
+ }, z.ZodTypeAny, "passthrough">>, "strip">, z.objectInputType<{}, z.ZodObject<{
622
+ enabled: z.ZodDefault<z.ZodBoolean>;
623
+ adapter: z.ZodOptional<z.ZodString>;
624
+ displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
625
+ outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
626
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
627
+ enabled: z.ZodDefault<z.ZodBoolean>;
628
+ adapter: z.ZodOptional<z.ZodString>;
629
+ displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
630
+ outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
631
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
632
+ enabled: z.ZodDefault<z.ZodBoolean>;
633
+ adapter: z.ZodOptional<z.ZodString>;
634
+ displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
635
+ outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
636
+ }, z.ZodTypeAny, "passthrough">>, "strip">>>;
637
+ agents: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
638
+ command: z.ZodString;
639
+ args: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
640
+ workingDirectory: z.ZodOptional<z.ZodString>;
641
+ env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
642
+ }, "strip", z.ZodTypeAny, {
643
+ command: string;
644
+ args: string[];
645
+ env: Record<string, string>;
646
+ workingDirectory?: string | undefined;
647
+ }, {
648
+ command: string;
649
+ args?: string[] | undefined;
650
+ env?: Record<string, string> | undefined;
651
+ workingDirectory?: string | undefined;
652
+ }>>>>;
653
+ defaultAgent: z.ZodString;
654
+ workspace: z.ZodDefault<z.ZodObject<{
655
+ baseDir: z.ZodDefault<z.ZodString>;
656
+ }, "strip", z.ZodTypeAny, {
657
+ baseDir: string;
658
+ }, {
659
+ baseDir?: string | undefined;
660
+ }>>;
661
+ security: z.ZodDefault<z.ZodObject<{
662
+ allowedUserIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
663
+ maxConcurrentSessions: z.ZodDefault<z.ZodNumber>;
664
+ sessionTimeoutMinutes: z.ZodDefault<z.ZodNumber>;
665
+ }, "strip", z.ZodTypeAny, {
666
+ allowedUserIds: string[];
667
+ maxConcurrentSessions: number;
668
+ sessionTimeoutMinutes: number;
669
+ }, {
670
+ allowedUserIds?: string[] | undefined;
671
+ maxConcurrentSessions?: number | undefined;
672
+ sessionTimeoutMinutes?: number | undefined;
673
+ }>>;
674
+ logging: z.ZodDefault<z.ZodObject<{
675
+ level: z.ZodDefault<z.ZodEnum<["silent", "debug", "info", "warn", "error", "fatal"]>>;
676
+ logDir: z.ZodDefault<z.ZodString>;
677
+ maxFileSize: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
678
+ maxFiles: z.ZodDefault<z.ZodNumber>;
679
+ sessionLogRetentionDays: z.ZodDefault<z.ZodNumber>;
680
+ }, "strip", z.ZodTypeAny, {
681
+ level: "fatal" | "error" | "warn" | "info" | "debug" | "silent";
682
+ logDir: string;
683
+ maxFileSize: string | number;
684
+ maxFiles: number;
685
+ sessionLogRetentionDays: number;
686
+ }, {
687
+ level?: "fatal" | "error" | "warn" | "info" | "debug" | "silent" | undefined;
688
+ logDir?: string | undefined;
689
+ maxFileSize?: string | number | undefined;
690
+ maxFiles?: number | undefined;
691
+ sessionLogRetentionDays?: number | undefined;
692
+ }>>;
693
+ runMode: z.ZodDefault<z.ZodEnum<["foreground", "daemon"]>>;
694
+ autoStart: z.ZodDefault<z.ZodBoolean>;
695
+ api: z.ZodDefault<z.ZodObject<{
696
+ port: z.ZodDefault<z.ZodNumber>;
697
+ host: z.ZodDefault<z.ZodString>;
698
+ }, "strip", z.ZodTypeAny, {
699
+ port: number;
700
+ host: string;
701
+ }, {
702
+ port?: number | undefined;
703
+ host?: string | undefined;
704
+ }>>;
705
+ sessionStore: z.ZodDefault<z.ZodObject<{
706
+ ttlDays: z.ZodDefault<z.ZodNumber>;
707
+ }, "strip", z.ZodTypeAny, {
708
+ ttlDays: number;
709
+ }, {
710
+ ttlDays?: number | undefined;
711
+ }>>;
712
+ tunnel: z.ZodDefault<z.ZodObject<{
713
+ enabled: z.ZodDefault<z.ZodBoolean>;
714
+ port: z.ZodDefault<z.ZodNumber>;
715
+ provider: z.ZodDefault<z.ZodEnum<["openacp", "cloudflare", "ngrok", "bore", "tailscale"]>>;
716
+ options: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
717
+ maxUserTunnels: z.ZodDefault<z.ZodNumber>;
718
+ storeTtlMinutes: z.ZodDefault<z.ZodNumber>;
719
+ auth: z.ZodDefault<z.ZodObject<{
720
+ enabled: z.ZodDefault<z.ZodBoolean>;
721
+ token: z.ZodOptional<z.ZodString>;
722
+ }, "strip", z.ZodTypeAny, {
723
+ enabled: boolean;
724
+ token?: string | undefined;
725
+ }, {
726
+ enabled?: boolean | undefined;
727
+ token?: string | undefined;
728
+ }>>;
729
+ }, "strip", z.ZodTypeAny, {
730
+ provider: "openacp" | "cloudflare" | "ngrok" | "bore" | "tailscale";
731
+ enabled: boolean;
732
+ options: Record<string, unknown>;
733
+ port: number;
734
+ maxUserTunnels: number;
735
+ storeTtlMinutes: number;
736
+ auth: {
737
+ enabled: boolean;
738
+ token?: string | undefined;
739
+ };
740
+ }, {
741
+ provider?: "openacp" | "cloudflare" | "ngrok" | "bore" | "tailscale" | undefined;
742
+ enabled?: boolean | undefined;
743
+ options?: Record<string, unknown> | undefined;
744
+ port?: number | undefined;
745
+ maxUserTunnels?: number | undefined;
746
+ storeTtlMinutes?: number | undefined;
747
+ auth?: {
748
+ enabled?: boolean | undefined;
749
+ token?: string | undefined;
750
+ } | undefined;
751
+ }>>;
752
+ usage: z.ZodDefault<z.ZodObject<{
753
+ enabled: z.ZodDefault<z.ZodBoolean>;
754
+ monthlyBudget: z.ZodOptional<z.ZodNumber>;
755
+ warningThreshold: z.ZodDefault<z.ZodNumber>;
756
+ currency: z.ZodDefault<z.ZodString>;
757
+ retentionDays: z.ZodDefault<z.ZodNumber>;
758
+ }, "strip", z.ZodTypeAny, {
759
+ enabled: boolean;
760
+ warningThreshold: number;
761
+ currency: string;
762
+ retentionDays: number;
763
+ monthlyBudget?: number | undefined;
764
+ }, {
765
+ enabled?: boolean | undefined;
766
+ monthlyBudget?: number | undefined;
767
+ warningThreshold?: number | undefined;
768
+ currency?: string | undefined;
769
+ retentionDays?: number | undefined;
770
+ }>>;
771
+ integrations: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
772
+ installed: z.ZodBoolean;
773
+ installedAt: z.ZodOptional<z.ZodString>;
774
+ }, "strip", z.ZodTypeAny, {
775
+ installed: boolean;
776
+ installedAt?: string | undefined;
777
+ }, {
778
+ installed: boolean;
779
+ installedAt?: string | undefined;
780
+ }>>>;
781
+ speech: z.ZodDefault<z.ZodOptional<z.ZodObject<{
782
+ stt: z.ZodDefault<z.ZodObject<{
783
+ provider: z.ZodDefault<z.ZodNullable<z.ZodString>>;
784
+ providers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
785
+ apiKey: z.ZodOptional<z.ZodString>;
786
+ model: z.ZodOptional<z.ZodString>;
787
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
788
+ apiKey: z.ZodOptional<z.ZodString>;
789
+ model: z.ZodOptional<z.ZodString>;
790
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
791
+ apiKey: z.ZodOptional<z.ZodString>;
792
+ model: z.ZodOptional<z.ZodString>;
793
+ }, z.ZodTypeAny, "passthrough">>>>;
794
+ }, "strip", z.ZodTypeAny, {
795
+ provider: string | null;
796
+ providers: Record<string, z.objectOutputType<{
797
+ apiKey: z.ZodOptional<z.ZodString>;
798
+ model: z.ZodOptional<z.ZodString>;
799
+ }, z.ZodTypeAny, "passthrough">>;
800
+ }, {
801
+ provider?: string | null | undefined;
802
+ providers?: Record<string, z.objectInputType<{
803
+ apiKey: z.ZodOptional<z.ZodString>;
804
+ model: z.ZodOptional<z.ZodString>;
805
+ }, z.ZodTypeAny, "passthrough">> | undefined;
806
+ }>>;
807
+ tts: z.ZodDefault<z.ZodObject<{
808
+ provider: z.ZodDefault<z.ZodNullable<z.ZodString>>;
809
+ providers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
810
+ apiKey: z.ZodOptional<z.ZodString>;
811
+ model: z.ZodOptional<z.ZodString>;
812
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
813
+ apiKey: z.ZodOptional<z.ZodString>;
814
+ model: z.ZodOptional<z.ZodString>;
815
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
816
+ apiKey: z.ZodOptional<z.ZodString>;
817
+ model: z.ZodOptional<z.ZodString>;
818
+ }, z.ZodTypeAny, "passthrough">>>>;
819
+ }, "strip", z.ZodTypeAny, {
820
+ provider: string | null;
821
+ providers: Record<string, z.objectOutputType<{
822
+ apiKey: z.ZodOptional<z.ZodString>;
823
+ model: z.ZodOptional<z.ZodString>;
824
+ }, z.ZodTypeAny, "passthrough">>;
825
+ }, {
826
+ provider?: string | null | undefined;
827
+ providers?: Record<string, z.objectInputType<{
828
+ apiKey: z.ZodOptional<z.ZodString>;
829
+ model: z.ZodOptional<z.ZodString>;
830
+ }, z.ZodTypeAny, "passthrough">> | undefined;
831
+ }>>;
832
+ }, "strip", z.ZodTypeAny, {
833
+ stt: {
834
+ provider: string | null;
835
+ providers: Record<string, z.objectOutputType<{
836
+ apiKey: z.ZodOptional<z.ZodString>;
837
+ model: z.ZodOptional<z.ZodString>;
838
+ }, z.ZodTypeAny, "passthrough">>;
839
+ };
840
+ tts: {
841
+ provider: string | null;
842
+ providers: Record<string, z.objectOutputType<{
843
+ apiKey: z.ZodOptional<z.ZodString>;
844
+ model: z.ZodOptional<z.ZodString>;
845
+ }, z.ZodTypeAny, "passthrough">>;
846
+ };
847
+ }, {
848
+ stt?: {
849
+ provider?: string | null | undefined;
850
+ providers?: Record<string, z.objectInputType<{
851
+ apiKey: z.ZodOptional<z.ZodString>;
852
+ model: z.ZodOptional<z.ZodString>;
853
+ }, z.ZodTypeAny, "passthrough">> | undefined;
854
+ } | undefined;
855
+ tts?: {
856
+ provider?: string | null | undefined;
857
+ providers?: Record<string, z.objectInputType<{
858
+ apiKey: z.ZodOptional<z.ZodString>;
859
+ model: z.ZodOptional<z.ZodString>;
860
+ }, z.ZodTypeAny, "passthrough">> | undefined;
861
+ } | undefined;
862
+ }>>>;
863
+ outputMode: z.ZodOptional<z.ZodDefault<z.ZodEnum<["low", "medium", "high"]>>>;
864
+ agentSwitch: z.ZodDefault<z.ZodObject<{
865
+ labelHistory: z.ZodDefault<z.ZodBoolean>;
866
+ }, "strip", z.ZodTypeAny, {
867
+ labelHistory: boolean;
868
+ }, {
869
+ labelHistory?: boolean | undefined;
870
+ }>>;
871
+ }, "strip", z.ZodTypeAny, {
872
+ api: {
873
+ port: number;
874
+ host: string;
1101
875
  };
1102
- spinner(): {
1103
- start(message: string): void;
1104
- stop(message?: string): void;
1105
- fail(message?: string): void;
876
+ agents: Record<string, {
877
+ command: string;
878
+ args: string[];
879
+ env: Record<string, string>;
880
+ workingDirectory?: string | undefined;
881
+ }>;
882
+ tunnel: {
883
+ provider: "openacp" | "cloudflare" | "ngrok" | "bore" | "tailscale";
884
+ enabled: boolean;
885
+ options: Record<string, unknown>;
886
+ port: number;
887
+ maxUserTunnels: number;
888
+ storeTtlMinutes: number;
889
+ auth: {
890
+ enabled: boolean;
891
+ token?: string | undefined;
892
+ };
1106
893
  };
1107
- note(message: string, title?: string): void;
1108
- cancel(message?: string): void;
894
+ channels: {} & {
895
+ [k: string]: z.objectOutputType<{
896
+ enabled: z.ZodDefault<z.ZodBoolean>;
897
+ adapter: z.ZodOptional<z.ZodString>;
898
+ displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
899
+ outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
900
+ }, z.ZodTypeAny, "passthrough">;
901
+ };
902
+ usage: {
903
+ enabled: boolean;
904
+ warningThreshold: number;
905
+ currency: string;
906
+ retentionDays: number;
907
+ monthlyBudget?: number | undefined;
908
+ };
909
+ defaultAgent: string;
910
+ workspace: {
911
+ baseDir: string;
912
+ };
913
+ security: {
914
+ allowedUserIds: string[];
915
+ maxConcurrentSessions: number;
916
+ sessionTimeoutMinutes: number;
917
+ };
918
+ logging: {
919
+ level: "fatal" | "error" | "warn" | "info" | "debug" | "silent";
920
+ logDir: string;
921
+ maxFileSize: string | number;
922
+ maxFiles: number;
923
+ sessionLogRetentionDays: number;
924
+ };
925
+ runMode: "foreground" | "daemon";
926
+ autoStart: boolean;
927
+ sessionStore: {
928
+ ttlDays: number;
929
+ };
930
+ integrations: Record<string, {
931
+ installed: boolean;
932
+ installedAt?: string | undefined;
933
+ }>;
934
+ speech: {
935
+ stt: {
936
+ provider: string | null;
937
+ providers: Record<string, z.objectOutputType<{
938
+ apiKey: z.ZodOptional<z.ZodString>;
939
+ model: z.ZodOptional<z.ZodString>;
940
+ }, z.ZodTypeAny, "passthrough">>;
941
+ };
942
+ tts: {
943
+ provider: string | null;
944
+ providers: Record<string, z.objectOutputType<{
945
+ apiKey: z.ZodOptional<z.ZodString>;
946
+ model: z.ZodOptional<z.ZodString>;
947
+ }, z.ZodTypeAny, "passthrough">>;
948
+ };
949
+ };
950
+ agentSwitch: {
951
+ labelHistory: boolean;
952
+ };
953
+ instanceName?: string | undefined;
954
+ outputMode?: "low" | "medium" | "high" | undefined;
955
+ }, {
956
+ defaultAgent: string;
957
+ api?: {
958
+ port?: number | undefined;
959
+ host?: string | undefined;
960
+ } | undefined;
961
+ agents?: Record<string, {
962
+ command: string;
963
+ args?: string[] | undefined;
964
+ env?: Record<string, string> | undefined;
965
+ workingDirectory?: string | undefined;
966
+ }> | undefined;
967
+ tunnel?: {
968
+ provider?: "openacp" | "cloudflare" | "ngrok" | "bore" | "tailscale" | undefined;
969
+ enabled?: boolean | undefined;
970
+ options?: Record<string, unknown> | undefined;
971
+ port?: number | undefined;
972
+ maxUserTunnels?: number | undefined;
973
+ storeTtlMinutes?: number | undefined;
974
+ auth?: {
975
+ enabled?: boolean | undefined;
976
+ token?: string | undefined;
977
+ } | undefined;
978
+ } | undefined;
979
+ instanceName?: string | undefined;
980
+ channels?: z.objectInputType<{}, z.ZodObject<{
981
+ enabled: z.ZodDefault<z.ZodBoolean>;
982
+ adapter: z.ZodOptional<z.ZodString>;
983
+ displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
984
+ outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
985
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
986
+ enabled: z.ZodDefault<z.ZodBoolean>;
987
+ adapter: z.ZodOptional<z.ZodString>;
988
+ displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
989
+ outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
990
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
991
+ enabled: z.ZodDefault<z.ZodBoolean>;
992
+ adapter: z.ZodOptional<z.ZodString>;
993
+ displayVerbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
994
+ outputMode: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
995
+ }, z.ZodTypeAny, "passthrough">>, "strip"> | undefined;
996
+ outputMode?: "low" | "medium" | "high" | undefined;
997
+ usage?: {
998
+ enabled?: boolean | undefined;
999
+ monthlyBudget?: number | undefined;
1000
+ warningThreshold?: number | undefined;
1001
+ currency?: string | undefined;
1002
+ retentionDays?: number | undefined;
1003
+ } | undefined;
1004
+ workspace?: {
1005
+ baseDir?: string | undefined;
1006
+ } | undefined;
1007
+ security?: {
1008
+ allowedUserIds?: string[] | undefined;
1009
+ maxConcurrentSessions?: number | undefined;
1010
+ sessionTimeoutMinutes?: number | undefined;
1011
+ } | undefined;
1012
+ logging?: {
1013
+ level?: "fatal" | "error" | "warn" | "info" | "debug" | "silent" | undefined;
1014
+ logDir?: string | undefined;
1015
+ maxFileSize?: string | number | undefined;
1016
+ maxFiles?: number | undefined;
1017
+ sessionLogRetentionDays?: number | undefined;
1018
+ } | undefined;
1019
+ runMode?: "foreground" | "daemon" | undefined;
1020
+ autoStart?: boolean | undefined;
1021
+ sessionStore?: {
1022
+ ttlDays?: number | undefined;
1023
+ } | undefined;
1024
+ integrations?: Record<string, {
1025
+ installed: boolean;
1026
+ installedAt?: string | undefined;
1027
+ }> | undefined;
1028
+ speech?: {
1029
+ stt?: {
1030
+ provider?: string | null | undefined;
1031
+ providers?: Record<string, z.objectInputType<{
1032
+ apiKey: z.ZodOptional<z.ZodString>;
1033
+ model: z.ZodOptional<z.ZodString>;
1034
+ }, z.ZodTypeAny, "passthrough">> | undefined;
1035
+ } | undefined;
1036
+ tts?: {
1037
+ provider?: string | null | undefined;
1038
+ providers?: Record<string, z.objectInputType<{
1039
+ apiKey: z.ZodOptional<z.ZodString>;
1040
+ model: z.ZodOptional<z.ZodString>;
1041
+ }, z.ZodTypeAny, "passthrough">> | undefined;
1042
+ } | undefined;
1043
+ } | undefined;
1044
+ agentSwitch?: {
1045
+ labelHistory?: boolean | undefined;
1046
+ } | undefined;
1047
+ }>;
1048
+ type Config = z.infer<typeof ConfigSchema>;
1049
+ declare function expandHome(p: string): string;
1050
+ declare class ConfigManager extends EventEmitter {
1051
+ private config;
1052
+ private configPath;
1053
+ constructor(configPath?: string);
1054
+ load(): Promise<void>;
1055
+ get(): Config;
1056
+ save(updates: Record<string, unknown>, changePath?: string): Promise<void>;
1057
+ /**
1058
+ * Set a single config value by dot-path (e.g. "security.maxConcurrentSessions").
1059
+ * Builds the nested update object, validates, and saves.
1060
+ * Throws if the path contains blocked keys or the value fails Zod validation.
1061
+ */
1062
+ setPath(dotPath: string, value: unknown): Promise<void>;
1063
+ resolveWorkspace(input?: string): string;
1064
+ exists(): Promise<boolean>;
1065
+ getConfigPath(): string;
1066
+ writeNew(config: Config): Promise<void>;
1067
+ applyEnvToPluginSettings(settingsManager: SettingsManager): Promise<void>;
1068
+ private applyEnvOverrides;
1069
+ private deepMerge;
1109
1070
  }
1110
- interface InstallContext {
1111
- pluginName: string;
1112
- terminal: TerminalIO;
1113
- settings: SettingsAPI;
1114
- legacyConfig?: Record<string, unknown>;
1115
- dataDir: string;
1116
- log: Logger;
1117
- /** Root of the OpenACP instance directory (e.g. ~/.openacp) */
1118
- instanceRoot?: string;
1071
+
1072
+ type Logger = pino.Logger;
1073
+ declare const log: {
1074
+ info: (...args: unknown[]) => void;
1075
+ warn: (...args: unknown[]) => void;
1076
+ error: (...args: unknown[]) => void;
1077
+ debug: (...args: unknown[]) => void;
1078
+ fatal: (...args: unknown[]) => void;
1079
+ child: (bindings: pino.Bindings) => pino.Logger<never, boolean>;
1080
+ };
1081
+ declare function initLogger(config: LoggingConfig): Logger;
1082
+ /** Change log level at runtime. Pino transport targets respect parent level changes automatically. */
1083
+ declare function setLogLevel(level: string): void;
1084
+ declare function createChildLogger(context: {
1085
+ module: string;
1086
+ [key: string]: unknown;
1087
+ }): Logger;
1088
+ declare function createSessionLogger(sessionId: string, parentLogger: Logger): Logger;
1089
+ declare function shutdownLogger(): Promise<void>;
1090
+ declare function cleanupOldSessionLogs(retentionDays: number): Promise<void>;
1091
+
1092
+ declare function nodeToWebWritable(nodeStream: NodeJS.WritableStream): WritableStream<Uint8Array>;
1093
+ declare function nodeToWebReadable(nodeStream: NodeJS.ReadableStream): ReadableStream<Uint8Array>;
1094
+
1095
+ declare class StderrCapture {
1096
+ private maxLines;
1097
+ private lines;
1098
+ constructor(maxLines?: number);
1099
+ append(chunk: string): void;
1100
+ getLastLines(): string;
1119
1101
  }
1120
- interface MigrateContext {
1121
- pluginName: string;
1122
- settings: SettingsAPI;
1123
- log: Logger;
1102
+
1103
+ /**
1104
+ * A minimal, generic typed event emitter.
1105
+ *
1106
+ * Usage:
1107
+ * interface MyEvents {
1108
+ * data: (payload: string) => void
1109
+ * error: (err: Error) => void
1110
+ * }
1111
+ * const emitter = new TypedEmitter<MyEvents>()
1112
+ * emitter.on('data', (payload) => { ... })
1113
+ * emitter.emit('data', 'hello')
1114
+ */
1115
+ declare class TypedEmitter<T extends Record<string & keyof T, (...args: any[]) => void>> {
1116
+ private listeners;
1117
+ private paused;
1118
+ private buffer;
1119
+ on<K extends keyof T>(event: K, listener: T[K]): this;
1120
+ off<K extends keyof T>(event: K, listener: T[K]): this;
1121
+ emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): void;
1122
+ /**
1123
+ * Pause event delivery. Events emitted while paused are buffered.
1124
+ * Optionally pass a filter to allow specific events through even while paused.
1125
+ */
1126
+ pause(passthrough?: (event: keyof T, args: unknown[]) => boolean): void;
1127
+ private passthroughFn?;
1128
+ /** Resume event delivery and replay buffered events in order. */
1129
+ resume(): void;
1130
+ /** Discard all buffered events without delivering them. */
1131
+ clearBuffer(): void;
1132
+ get isPaused(): boolean;
1133
+ get bufferSize(): number;
1134
+ removeAllListeners(event?: keyof T): void;
1135
+ private deliver;
1124
1136
  }
1125
- type CommandResponse = {
1126
- type: 'text';
1127
- text: string;
1128
- } | {
1129
- type: 'menu';
1130
- title: string;
1131
- options: MenuOption[];
1132
- } | {
1133
- type: 'list';
1134
- title: string;
1135
- items: ListItem[];
1136
- } | {
1137
- type: 'confirm';
1138
- question: string;
1139
- onYes: string;
1140
- onNo: string;
1141
- } | {
1142
- type: 'error';
1143
- message: string;
1144
- } | {
1145
- type: 'silent';
1146
- } | {
1147
- type: 'delegated';
1148
- };
1149
- interface MenuItem {
1150
- id: string;
1151
- label: string;
1152
- priority: number;
1153
- group?: string;
1154
- action: {
1155
- type: 'command';
1156
- command: string;
1157
- } | {
1158
- type: 'delegate';
1159
- prompt: string;
1160
- } | {
1161
- type: 'callback';
1162
- callbackData: string;
1163
- };
1164
- visible?: () => boolean;
1137
+
1138
+ interface ErrorBudgetConfig {
1139
+ maxErrors: number;
1140
+ windowMs: number;
1165
1141
  }
1166
- interface MenuOption {
1167
- label: string;
1168
- command: string;
1169
- hint?: string;
1142
+ declare class ErrorTracker {
1143
+ private errors;
1144
+ private disabled;
1145
+ private exempt;
1146
+ private config;
1147
+ onDisabled?: (pluginName: string, reason: string) => void;
1148
+ constructor(config?: Partial<ErrorBudgetConfig>);
1149
+ increment(pluginName: string): void;
1150
+ isDisabled(pluginName: string): boolean;
1151
+ reset(pluginName: string): void;
1152
+ setExempt(pluginName: string): void;
1170
1153
  }
1171
- interface ListItem {
1172
- label: string;
1173
- detail?: string;
1154
+
1155
+ declare class MiddlewareChain {
1156
+ private chains;
1157
+ private errorHandler?;
1158
+ private errorTracker?;
1159
+ add(hook: string, pluginName: string, opts: {
1160
+ priority?: number;
1161
+ handler: Function;
1162
+ }): void;
1163
+ execute<T>(hook: string, payload: T, coreHandler: (p: T) => T | Promise<T>): Promise<T | null>;
1164
+ removeAll(pluginName: string): void;
1165
+ setErrorHandler(fn: (pluginName: string, error: Error) => void): void;
1166
+ setErrorTracker(tracker: ErrorTracker): void;
1174
1167
  }
1175
- interface CommandArgs {
1176
- /** Raw argument string after command name */
1177
- raw: string;
1178
- /** Parsed key/value options (e.g., --flag value) */
1179
- options?: Record<string, string>;
1180
- /** Session ID where command was invoked (null if from notification/system topic) */
1181
- sessionId: string | null;
1182
- /** Channel ID ('telegram', 'discord', 'slack') */
1183
- channelId: string;
1184
- /** User ID who invoked the command */
1185
- userId: string;
1186
- /** Reply helper — sends message to the topic where command was invoked */
1187
- reply(content: string | CommandResponse | OutgoingMessage): Promise<void>;
1188
- /** Direct access to OpenACPCore instance. Available when 'kernel:access' permission is granted. */
1189
- coreAccess?: CoreAccess;
1168
+
1169
+ type TraceLayer = "acp" | "core" | "telegram";
1170
+ /**
1171
+ * Per-session debug trace logger. Writes JSONL files to <workingDirectory>/.log/.
1172
+ * Only active when OPENACP_DEBUG=true. Zero overhead when disabled.
1173
+ *
1174
+ * Note: Uses appendFileSync for simplicity. This blocks the event loop briefly per write,
1175
+ * which is acceptable for a debug-only tool. The DEBUG_ENABLED guard ensures zero overhead
1176
+ * in production.
1177
+ */
1178
+ declare class DebugTracer {
1179
+ private sessionId;
1180
+ private workingDirectory;
1181
+ private dirCreated;
1182
+ private logDir;
1183
+ constructor(sessionId: string, workingDirectory: string);
1184
+ log(layer: TraceLayer, data: Record<string, unknown>): void;
1185
+ /** No-op cleanup — establishes the pattern for future async implementations */
1186
+ destroy(): void;
1190
1187
  }
1191
- interface CommandDef {
1192
- /** Command name without slash, e.g., 'context' for /context */
1193
- name: string;
1194
- /** Short description shown in command list */
1195
- description: string;
1196
- /** Usage pattern, e.g., '<session-number>' */
1197
- usage?: string;
1198
- /** Whether this is a built-in system command or registered by a plugin */
1199
- category: 'system' | 'plugin';
1200
- /** Plugin that registered this command (set automatically by plugin manager) */
1201
- pluginName?: string;
1202
- /** Handler function */
1203
- handler(args: CommandArgs): Promise<CommandResponse | void>;
1188
+
1189
+ interface AgentInstanceEvents {
1190
+ agent_event: (event: AgentEvent) => void;
1191
+ }
1192
+ declare class AgentInstance extends TypedEmitter<AgentInstanceEvents> {
1193
+ private connection;
1194
+ private child;
1195
+ private stderrCapture;
1196
+ private terminalManager;
1197
+ private static mcpManager;
1198
+ private _destroying;
1199
+ sessionId: string;
1200
+ agentName: string;
1201
+ promptCapabilities?: {
1202
+ image?: boolean;
1203
+ audio?: boolean;
1204
+ };
1205
+ agentCapabilities?: AgentCapabilities;
1206
+ /** Preserved from newSession/resumeSession response for ACP state propagation */
1207
+ initialSessionResponse?: {
1208
+ modes?: unknown;
1209
+ configOptions?: unknown;
1210
+ models?: unknown;
1211
+ };
1212
+ middlewareChain?: MiddlewareChain;
1213
+ debugTracer: DebugTracer | null;
1214
+ onPermissionRequest: (request: PermissionRequest) => Promise<string>;
1215
+ private constructor();
1216
+ private static spawnSubprocess;
1217
+ private setupCrashDetection;
1218
+ static spawn(agentDef: AgentDefinition, workingDirectory: string, mcpServers?: McpServerConfig[]): Promise<AgentInstance>;
1219
+ static resume(agentDef: AgentDefinition, workingDirectory: string, agentSessionId: string, mcpServers?: McpServerConfig[]): Promise<AgentInstance>;
1220
+ private createClient;
1221
+ setConfigOption(configId: string, value: SetConfigOptionValue): Promise<SetSessionConfigOptionResponse>;
1222
+ listSessions(cwd?: string, cursor?: string): Promise<ListSessionsResponse>;
1223
+ loadSession(sessionId: string, cwd: string, mcpServers?: McpServerConfig[]): Promise<LoadSessionResponse>;
1224
+ authenticate(methodId: string): Promise<void>;
1225
+ forkSession(sessionId: string, cwd: string, mcpServers?: McpServerConfig[]): Promise<ForkSessionResponse>;
1226
+ closeSession(sessionId: string): Promise<void>;
1227
+ prompt(text: string, attachments?: Attachment[]): Promise<PromptResponse>;
1228
+ cancel(): Promise<void>;
1229
+ destroy(): Promise<void>;
1204
1230
  }
1205
- interface SessionManager$1 {
1206
- [key: string]: unknown;
1231
+
1232
+ declare class AgentStore {
1233
+ private data;
1234
+ private filePath;
1235
+ constructor(filePath?: string);
1236
+ load(): void;
1237
+ exists(): boolean;
1238
+ getInstalled(): Record<string, InstalledAgent>;
1239
+ getAgent(key: string): InstalledAgent | undefined;
1240
+ addAgent(key: string, agent: InstalledAgent): void;
1241
+ removeAgent(key: string): void;
1242
+ hasAgent(key: string): boolean;
1243
+ private save;
1207
1244
  }
1208
- interface ConfigManager {
1209
- [key: string]: unknown;
1245
+
1246
+ declare class AgentCatalog {
1247
+ private store;
1248
+ private registryAgents;
1249
+ private cachePath;
1250
+ private agentsDir;
1251
+ constructor(store?: AgentStore, cachePath?: string, agentsDir?: string);
1252
+ load(): void;
1253
+ fetchRegistry(): Promise<void>;
1254
+ refreshRegistryIfStale(): Promise<void>;
1255
+ getRegistryAgents(): RegistryAgent[];
1256
+ getRegistryAgent(registryId: string): RegistryAgent | undefined;
1257
+ findRegistryAgent(keyOrId: string): RegistryAgent | undefined;
1258
+ getInstalled(): InstalledAgent[];
1259
+ getInstalledEntries(): Record<string, InstalledAgent>;
1260
+ getInstalledAgent(key: string): InstalledAgent | undefined;
1261
+ getAvailable(): AgentListItem[];
1262
+ checkAvailability(keyOrId: string): AvailabilityResult;
1263
+ install(keyOrId: string, progress?: InstallProgress, force?: boolean): Promise<InstallResult>;
1264
+ uninstall(key: string): Promise<{
1265
+ ok: boolean;
1266
+ error?: string;
1267
+ }>;
1268
+ resolve(key: string): AgentDefinition | undefined;
1269
+ /**
1270
+ * Enrich installed agents (especially migrated ones) with registry data.
1271
+ * Fixes agents that were migrated with version:"unknown", distribution:"custom",
1272
+ * or generic names by matching them to registry entries.
1273
+ */
1274
+ private enrichInstalledFromRegistry;
1275
+ private isCacheStale;
1276
+ private loadRegistryFromCacheOrSnapshot;
1210
1277
  }
1211
- interface EventBus$1 {
1212
- [key: string]: unknown;
1278
+
1279
+ declare class AgentManager {
1280
+ private catalog;
1281
+ constructor(catalog: AgentCatalog);
1282
+ getAvailableAgents(): AgentDefinition[];
1283
+ getAgent(name: string): AgentDefinition | undefined;
1284
+ spawn(agentName: string, workingDirectory: string): Promise<AgentInstance>;
1285
+ resume(agentName: string, workingDirectory: string, agentSessionId: string): Promise<AgentInstance>;
1213
1286
  }
1287
+
1214
1288
  /**
1215
- * Typed view of the OpenACPCore instance exposed to plugins via ctx.core.
1216
- * Plugins that need kernel:access should cast ctx.core to this interface
1217
- * instead of using `as any`. Only includes fields plugins actually need.
1289
+ * Encapsulates pending permission state with a typed Promise API.
1218
1290
  */
1219
- interface CoreAccess {
1220
- configManager: ConfigManager;
1221
- sessionManager: SessionManager$1;
1222
- adapters: Map<string, IChannelAdapter>;
1223
- }
1224
- interface Logger {
1225
- trace(msg: string, ...args: unknown[]): void;
1226
- debug(msg: string, ...args: unknown[]): void;
1227
- info(msg: string, ...args: unknown[]): void;
1228
- warn(msg: string, ...args: unknown[]): void;
1229
- error(msg: string, ...args: unknown[]): void;
1230
- fatal(msg: string, ...args: unknown[]): void;
1231
- child(bindings: Record<string, unknown>): Logger;
1232
- }
1233
- interface PluginContext {
1234
- pluginName: string;
1235
- pluginConfig: Record<string, unknown>;
1236
- /** Subscribe to events. Auto-cleaned on teardown. Requires 'events:read'. */
1237
- on(event: string, handler: (...args: unknown[]) => void): void;
1238
- off(event: string, handler: (...args: unknown[]) => void): void;
1239
- /** Emit custom events. Event names MUST be prefixed with plugin name. Requires 'events:emit'. */
1240
- emit(event: string, payload: unknown): void;
1241
- /** Register middleware. Requires 'middleware:register'. */
1242
- registerMiddleware<H extends MiddlewareHook>(hook: H, opts: MiddlewareOptions<MiddlewarePayloadMap[H]>): void;
1243
- /** Provide a service. Requires 'services:register'. */
1244
- registerService<T>(name: string, implementation: T): void;
1245
- /** Consume a service. Requires 'services:use'. */
1246
- getService<T>(name: string): T | undefined;
1247
- /** Register slash command. Requires 'commands:register'. */
1248
- registerCommand(def: CommandDef): void;
1249
- /** Register a menu item. Requires 'commands:register'. */
1250
- registerMenuItem(item: MenuItem): void;
1251
- /** Unregister a menu item by id. Requires 'commands:register'. */
1252
- unregisterMenuItem(id: string): void;
1253
- /** Register an assistant section. Requires 'commands:register'. */
1254
- registerAssistantSection(section: AssistantSection): void;
1255
- /** Unregister an assistant section by id. Requires 'commands:register'. */
1256
- unregisterAssistantSection(id: string): void;
1257
- /** Plugin-scoped storage. Requires 'storage:read' and/or 'storage:write'. */
1258
- storage: PluginStorage;
1259
- /** Plugin-scoped logger. Always available (no permission needed). */
1260
- log: Logger;
1261
- /**
1262
- * Send message to a session. Requires 'services:use'.
1263
- *
1264
- * Routing: sessionId → lookup session → find adapter for session's channelId
1265
- * → [HOOK: message:outgoing] → adapter.sendMessage()
1266
- */
1267
- sendMessage(sessionId: string, content: OutgoingMessage): Promise<void>;
1268
- sessions: SessionManager$1;
1269
- config: ConfigManager;
1270
- eventBus: EventBus$1;
1271
- /** Direct access to OpenACPCore instance. Requires 'kernel:access'. */
1272
- core: unknown;
1273
- /**
1274
- * Root directory for this OpenACP instance (default: ~/.openacp).
1275
- * Plugins should derive file paths from this instead of hardcoding ~/.openacp.
1276
- */
1277
- instanceRoot: string;
1278
- }
1279
- interface MiddlewarePayloadMap {
1280
- 'message:incoming': {
1281
- channelId: string;
1282
- threadId: string;
1283
- userId: string;
1284
- text: string;
1285
- attachments?: Attachment[];
1286
- };
1287
- 'message:outgoing': {
1288
- sessionId: string;
1289
- message: OutgoingMessage;
1290
- };
1291
- 'agent:beforePrompt': {
1292
- sessionId: string;
1293
- text: string;
1294
- attachments?: Attachment[];
1295
- };
1296
- 'agent:beforeEvent': {
1297
- sessionId: string;
1298
- event: AgentEvent;
1299
- };
1300
- 'agent:afterEvent': {
1301
- sessionId: string;
1302
- event: AgentEvent;
1303
- outgoingMessage: OutgoingMessage;
1304
- };
1305
- 'turn:start': {
1306
- sessionId: string;
1307
- promptText: string;
1308
- promptNumber: number;
1309
- };
1310
- 'turn:end': {
1311
- sessionId: string;
1312
- stopReason: StopReason;
1313
- durationMs: number;
1314
- };
1315
- 'fs:beforeRead': {
1316
- sessionId: string;
1317
- path: string;
1318
- line?: number;
1319
- limit?: number;
1320
- };
1321
- 'fs:beforeWrite': {
1322
- sessionId: string;
1323
- path: string;
1324
- content: string;
1325
- };
1326
- 'terminal:beforeCreate': {
1327
- sessionId: string;
1328
- command: string;
1329
- args?: string[];
1330
- env?: Record<string, string>;
1331
- cwd?: string;
1332
- };
1333
- 'terminal:afterExit': {
1334
- sessionId: string;
1335
- terminalId: string;
1336
- command: string;
1337
- exitCode: number;
1338
- durationMs: number;
1339
- };
1340
- 'permission:beforeRequest': {
1341
- sessionId: string;
1342
- request: PermissionRequest;
1343
- autoResolve?: string;
1344
- };
1345
- 'permission:afterResolve': {
1346
- sessionId: string;
1347
- requestId: string;
1348
- decision: string;
1349
- userId: string;
1350
- durationMs: number;
1351
- };
1352
- 'session:beforeCreate': {
1353
- agentName: string;
1354
- workingDir: string;
1355
- userId: string;
1356
- channelId: string;
1357
- threadId: string;
1358
- };
1359
- 'session:afterDestroy': {
1360
- sessionId: string;
1361
- reason: string;
1362
- durationMs: number;
1363
- promptCount: number;
1364
- };
1365
- 'config:beforeChange': {
1366
- sessionId: string;
1367
- configId: string;
1368
- oldValue: unknown;
1369
- newValue: unknown;
1370
- };
1371
- 'agent:beforeCancel': {
1372
- sessionId: string;
1373
- reason?: string;
1374
- };
1375
- 'agent:beforeSwitch': {
1376
- sessionId: string;
1377
- fromAgent: string;
1378
- toAgent: string;
1379
- };
1380
- 'agent:afterSwitch': {
1381
- sessionId: string;
1382
- fromAgent: string;
1383
- toAgent: string;
1384
- resumed: boolean;
1385
- };
1291
+ declare class PermissionGate {
1292
+ private request?;
1293
+ private resolveFn?;
1294
+ private rejectFn?;
1295
+ private settled;
1296
+ private timeoutTimer?;
1297
+ private timeoutMs;
1298
+ constructor(timeoutMs?: number);
1299
+ setPending(request: PermissionRequest): Promise<string>;
1300
+ resolve(optionId: string): void;
1301
+ reject(reason?: string): void;
1302
+ get isPending(): boolean;
1303
+ get currentRequest(): PermissionRequest | undefined;
1304
+ /** The request ID of the current pending request, undefined after settlement */
1305
+ get requestId(): string | undefined;
1306
+ private clearTimeout;
1307
+ private cleanup;
1386
1308
  }
1387
- type MiddlewareHook = keyof MiddlewarePayloadMap;
1388
- type MiddlewareFn<T> = (payload: T, next: () => Promise<T>) => Promise<T | null>;
1389
- interface MiddlewareOptions<T> {
1390
- /** Override execution order within same dependency level. Lower = earlier. */
1391
- priority?: number;
1392
- /** The middleware handler */
1393
- handler: MiddlewareFn<T>;
1309
+
1310
+ interface STTOptions {
1311
+ language?: string;
1312
+ model?: string;
1394
1313
  }
1395
- interface SecurityService {
1396
- checkAccess(userId: string): Promise<{
1397
- allowed: boolean;
1398
- reason?: string;
1399
- }>;
1400
- checkSessionLimit(userId: string): Promise<{
1401
- allowed: boolean;
1402
- reason?: string;
1403
- }>;
1404
- getUserRole(userId: string): Promise<'admin' | 'user' | 'blocked'>;
1314
+ interface STTResult {
1315
+ text: string;
1316
+ language?: string;
1317
+ duration?: number;
1405
1318
  }
1406
- interface FileServiceInterface {
1407
- saveFile(sessionId: string, fileName: string, data: Buffer, mimeType: string): Promise<Attachment>;
1408
- resolveFile(filePath: string): Promise<Attachment | null>;
1409
- readTextFileWithRange(path: string, opts?: {
1410
- line?: number;
1411
- limit?: number;
1412
- }): Promise<string>;
1413
- extensionFromMime(mimeType: string): string;
1414
- convertOggToWav(oggData: Buffer): Promise<Buffer>;
1319
+ interface TTSOptions {
1320
+ language?: string;
1321
+ voice?: string;
1322
+ model?: string;
1415
1323
  }
1416
- interface NotificationService {
1417
- notify(channelId: string, notification: NotificationMessage): Promise<void>;
1418
- notifyAll(notification: NotificationMessage): Promise<void>;
1324
+ interface TTSResult {
1325
+ audioBuffer: Buffer;
1326
+ mimeType: string;
1419
1327
  }
1420
- interface UsageService {
1421
- trackUsage(record: UsageRecord): Promise<void>;
1422
- checkBudget(sessionId: string): Promise<{
1423
- ok: boolean;
1424
- percent: number;
1425
- warning?: string;
1426
- }>;
1328
+ interface STTProvider {
1329
+ readonly name: string;
1330
+ transcribe(audioBuffer: Buffer, mimeType: string, options?: STTOptions): Promise<STTResult>;
1427
1331
  }
1428
1332
  interface TTSProvider {
1429
- synthesize(text: string, opts?: {
1430
- language?: string;
1431
- voice?: string;
1432
- }): Promise<Buffer>;
1333
+ readonly name: string;
1334
+ synthesize(text: string, options?: TTSOptions): Promise<TTSResult>;
1433
1335
  }
1434
- interface STTProvider {
1435
- transcribe(audio: Buffer, opts?: {
1436
- language?: string;
1437
- }): Promise<string>;
1336
+ interface SpeechProviderConfig {
1337
+ apiKey?: string;
1338
+ model?: string;
1339
+ [key: string]: unknown;
1438
1340
  }
1439
- interface SpeechServiceInterface {
1440
- textToSpeech(text: string, opts?: {
1441
- language?: string;
1442
- voice?: string;
1443
- }): Promise<Buffer>;
1444
- speechToText(audio: Buffer, opts?: {
1445
- language?: string;
1446
- }): Promise<string>;
1447
- registerTTSProvider(name: string, provider: TTSProvider): void;
1341
+ interface SpeechServiceConfig {
1342
+ stt: {
1343
+ provider: string | null;
1344
+ providers: Record<string, SpeechProviderConfig>;
1345
+ };
1346
+ tts: {
1347
+ provider: string | null;
1348
+ providers: Record<string, SpeechProviderConfig>;
1349
+ };
1350
+ }
1351
+
1352
+ type ProviderFactory = (config: SpeechServiceConfig) => {
1353
+ stt: Map<string, STTProvider>;
1354
+ tts: Map<string, TTSProvider>;
1355
+ };
1356
+ declare class SpeechService {
1357
+ private config;
1358
+ private sttProviders;
1359
+ private ttsProviders;
1360
+ private providerFactory?;
1361
+ constructor(config: SpeechServiceConfig);
1362
+ /** Set a factory function that can recreate providers from config (for hot-reload) */
1363
+ setProviderFactory(factory: ProviderFactory): void;
1448
1364
  registerSTTProvider(name: string, provider: STTProvider): void;
1365
+ registerTTSProvider(name: string, provider: TTSProvider): void;
1366
+ unregisterTTSProvider(name: string): void;
1367
+ isSTTAvailable(): boolean;
1368
+ isTTSAvailable(): boolean;
1369
+ transcribe(audioBuffer: Buffer, mimeType: string, options?: STTOptions): Promise<STTResult>;
1370
+ synthesize(text: string, options?: TTSOptions): Promise<TTSResult>;
1371
+ updateConfig(config: SpeechServiceConfig): void;
1372
+ /** Re-create factory-managed providers from config. Preserves externally-registered providers (e.g. from plugins). */
1373
+ refreshProviders(newConfig: SpeechServiceConfig): void;
1449
1374
  }
1450
- interface ContextProvider$1 {
1451
- provide(sessionId: string, opts?: {
1452
- maxTokens?: number;
1453
- }): Promise<string>;
1375
+
1376
+ declare class GroqSTT implements STTProvider {
1377
+ private apiKey;
1378
+ private defaultModel;
1379
+ readonly name = "groq";
1380
+ constructor(apiKey: string, defaultModel?: string);
1381
+ transcribe(audioBuffer: Buffer, mimeType: string, options?: STTOptions): Promise<STTResult>;
1454
1382
  }
1455
- interface ContextService {
1456
- buildContext(sessionId: string, opts?: {
1457
- maxTokens?: number;
1458
- }): Promise<string>;
1459
- registerProvider(provider: ContextProvider$1): void;
1383
+
1384
+ interface SessionEvents {
1385
+ agent_event: (event: AgentEvent) => void;
1386
+ permission_request: (request: PermissionRequest) => void;
1387
+ session_end: (reason: string) => void;
1388
+ status_change: (from: SessionStatus, to: SessionStatus) => void;
1389
+ named: (name: string) => void;
1390
+ error: (error: Error) => void;
1391
+ prompt_count_changed: (count: number) => void;
1460
1392
  }
1461
- interface ViewerStoreInterface {
1462
- storeFile(sessionId: string, filePath: string, content: string, workingDirectory: string): string | null;
1463
- storeDiff(sessionId: string, filePath: string, oldContent: string, newContent: string, workingDirectory: string): string | null;
1464
- storeOutput(sessionId: string, label: string, output: string): string | null;
1393
+ declare class Session extends TypedEmitter<SessionEvents> {
1394
+ id: string;
1395
+ channelId: string;
1396
+ threadId: string;
1397
+ agentName: string;
1398
+ workingDirectory: string;
1399
+ agentInstance: AgentInstance;
1400
+ agentSessionId: string;
1401
+ private _status;
1402
+ name?: string;
1403
+ createdAt: Date;
1404
+ voiceMode: "off" | "next" | "on";
1405
+ configOptions: ConfigOption[];
1406
+ clientOverrides: {
1407
+ bypassPermissions?: boolean;
1408
+ };
1409
+ agentCapabilities?: AgentCapabilities;
1410
+ archiving: boolean;
1411
+ promptCount: number;
1412
+ firstAgent: string;
1413
+ agentSwitchHistory: AgentSwitchEntry[];
1414
+ isAssistant: boolean;
1415
+ log: Logger;
1416
+ middlewareChain?: MiddlewareChain;
1417
+ /** Latest commands emitted by the agent — buffered before bridge connects so they're not lost */
1418
+ latestCommands: AgentCommand[] | null;
1419
+ readonly permissionGate: PermissionGate;
1420
+ private readonly queue;
1421
+ private speechService?;
1422
+ private pendingContext;
1423
+ constructor(opts: {
1424
+ id?: string;
1425
+ channelId: string;
1426
+ agentName: string;
1427
+ workingDirectory: string;
1428
+ agentInstance: AgentInstance;
1429
+ speechService?: SpeechService;
1430
+ isAssistant?: boolean;
1431
+ });
1432
+ get status(): SessionStatus;
1433
+ /** Transition to active — from initializing, error, or cancelled */
1434
+ activate(): void;
1435
+ /** Transition to error — from initializing or active. Idempotent if already in error. */
1436
+ fail(reason: string): void;
1437
+ /** Transition to finished — from active only. Emits session_end for backward compat. */
1438
+ finish(reason?: string): void;
1439
+ /** Transition to cancelled — from active only (terminal session cancel) */
1440
+ markCancelled(): void;
1441
+ private transition;
1442
+ /** Number of prompts waiting in queue */
1443
+ get queueDepth(): number;
1444
+ get promptRunning(): boolean;
1445
+ setContext(markdown: string): void;
1446
+ setVoiceMode(mode: "off" | "next" | "on"): void;
1447
+ enqueuePrompt(text: string, attachments?: Attachment[]): Promise<void>;
1448
+ private processPrompt;
1449
+ private maybeTranscribeAudio;
1450
+ private processTTSResponse;
1451
+ private autoName;
1452
+ setInitialConfigOptions(options: ConfigOption[]): void;
1453
+ setAgentCapabilities(caps: AgentCapabilities | undefined): void;
1454
+ getConfigOption(id: string): ConfigOption | undefined;
1455
+ getConfigByCategory(category: string): ConfigOption | undefined;
1456
+ getConfigValue(id: string): string | undefined;
1457
+ /** Set session name explicitly and emit 'named' event */
1458
+ setName(name: string): void;
1459
+ /** Send a config option change to the agent and update local state from the response. */
1460
+ setConfigOption(configId: string, value: SetConfigOptionValue): Promise<void>;
1461
+ updateConfigOptions(options: ConfigOption[]): Promise<void>;
1462
+ /** Snapshot of current ACP state for persistence */
1463
+ toAcpStateSnapshot(): NonNullable<SessionRecord["acpState"]>;
1464
+ /** Check if the agent supports a specific session capability */
1465
+ supportsCapability(cap: 'list' | 'fork' | 'close' | 'loadSession'): boolean;
1466
+ /** Cancel the current prompt and clear the queue. Stays in active state. */
1467
+ abortPrompt(): Promise<void>;
1468
+ /** Search backward through agentSwitchHistory for the last entry matching agentName */
1469
+ findLastSwitchEntry(agentName: string): AgentSwitchEntry | undefined;
1470
+ /** Switch the agent instance in-place, preserving session identity */
1471
+ switchAgent(agentName: string, createAgent: () => Promise<AgentInstance>): Promise<void>;
1472
+ destroy(): Promise<void>;
1465
1473
  }
1466
- interface TunnelServiceInterface {
1467
- getPublicUrl(): string;
1468
- start(apiPort: number): Promise<string>;
1469
- stop(): Promise<void>;
1470
- getStore(): ViewerStoreInterface;
1471
- fileUrl(entryId: string): string;
1472
- diffUrl(entryId: string): string;
1473
- outputUrl(entryId: string): string;
1474
+
1475
+ /**
1476
+ * Serial prompt queue — ensures prompts are processed one at a time.
1477
+ */
1478
+ declare class PromptQueue {
1479
+ private processor;
1480
+ private onError?;
1481
+ private queue;
1482
+ private processing;
1483
+ private abortController;
1484
+ constructor(processor: (text: string, attachments?: Attachment[]) => Promise<void>, onError?: ((err: unknown) => void) | undefined);
1485
+ enqueue(text: string, attachments?: Attachment[]): Promise<void>;
1486
+ private process;
1487
+ private drainNext;
1488
+ clear(): void;
1489
+ get pending(): number;
1490
+ get isProcessing(): boolean;
1474
1491
  }
1475
1492
 
1476
1493
  declare class MessageTransformer {
@@ -1936,7 +1953,7 @@ declare class SessionFactory {
1936
1953
  createThread?: boolean;
1937
1954
  }) => Promise<Session>;
1938
1955
  /** Injected by Core — needed for resolving default agent and workspace */
1939
- configManager?: ConfigManager$1;
1956
+ configManager?: ConfigManager;
1940
1957
  /** Injected by Core — needed for resolving agent definitions */
1941
1958
  agentCatalog?: AgentCatalog;
1942
1959
  /** Injected by Core — needed for context-aware session creation */
@@ -1970,16 +1987,26 @@ declare class SessionFactory {
1970
1987
  wireSideEffects(session: Session, deps: SideEffectDeps): void;
1971
1988
  }
1972
1989
 
1990
+ interface SecurityConfig {
1991
+ allowedUserIds: string[];
1992
+ maxConcurrentSessions: number;
1993
+ }
1973
1994
  declare class SecurityGuard {
1974
- private configManager;
1995
+ private getSecurityConfig;
1975
1996
  private sessionManager;
1976
- constructor(configManager: ConfigManager$1, sessionManager: SessionManager);
1977
- checkAccess(message: IncomingMessage): {
1997
+ constructor(getSecurityConfig: () => Promise<SecurityConfig>, sessionManager: {
1998
+ listSessions(): Array<{
1999
+ status: string;
2000
+ }>;
2001
+ });
2002
+ checkAccess(message: {
2003
+ userId: string | number;
2004
+ }): Promise<{
1978
2005
  allowed: true;
1979
2006
  } | {
1980
2007
  allowed: false;
1981
2008
  reason: string;
1982
- };
2009
+ }>;
1983
2010
  }
1984
2011
 
1985
2012
  declare class ServiceRegistry {
@@ -1996,22 +2023,6 @@ declare class ServiceRegistry {
1996
2023
  unregisterByPlugin(pluginName: string): void;
1997
2024
  }
1998
2025
 
1999
- interface ValidationResult {
2000
- valid: boolean;
2001
- errors?: string[];
2002
- }
2003
- declare class SettingsManager {
2004
- private basePath;
2005
- constructor(basePath: string);
2006
- getBasePath(): string;
2007
- createAPI(pluginName: string): SettingsAPI;
2008
- loadSettings(pluginName: string): Promise<Record<string, unknown>>;
2009
- validateSettings(_pluginName: string, settings: unknown, schema?: ZodSchema): ValidationResult;
2010
- getSettingsPath(pluginName: string): string;
2011
- getPluginSettings(pluginName: string): Promise<Record<string, unknown>>;
2012
- updatePluginSettings(pluginName: string, updates: Record<string, unknown>): Promise<void>;
2013
- }
2014
-
2015
2026
  interface PluginEntry {
2016
2027
  version: string;
2017
2028
  installedAt: string;
@@ -2051,7 +2062,7 @@ interface LifecycleManagerOpts {
2051
2062
  sessions?: unknown;
2052
2063
  config?: unknown;
2053
2064
  core?: unknown;
2054
- log?: Logger;
2065
+ log?: Logger$1;
2055
2066
  settingsManager?: SettingsManager;
2056
2067
  pluginRegistry?: PluginRegistry;
2057
2068
  /** Root directory for this OpenACP instance (default: ~/.openacp) */
@@ -2069,7 +2080,7 @@ declare class LifecycleManager {
2069
2080
  private log;
2070
2081
  settingsManager: SettingsManager | undefined;
2071
2082
  private pluginRegistry;
2072
- private instanceRoot;
2083
+ private _instanceRoot;
2073
2084
  private contexts;
2074
2085
  private loadOrder;
2075
2086
  private _loaded;
@@ -2077,6 +2088,10 @@ declare class LifecycleManager {
2077
2088
  get loadedPlugins(): string[];
2078
2089
  get failedPlugins(): string[];
2079
2090
  get registry(): PluginRegistry | undefined;
2091
+ /** Plugin definitions currently in load order (loaded + failed). */
2092
+ get plugins(): OpenACPPlugin[];
2093
+ /** Root directory of this OpenACP instance (e.g. ~/.openacp). */
2094
+ get instanceRoot(): string | undefined;
2080
2095
  constructor(opts?: LifecycleManagerOpts);
2081
2096
  private getPluginLogger;
2082
2097
  boot(plugins: OpenACPPlugin[]): Promise<void>;
@@ -2152,7 +2167,7 @@ interface InstanceContext {
2152
2167
  }
2153
2168
 
2154
2169
  declare class OpenACPCore {
2155
- configManager: ConfigManager$1;
2170
+ configManager: ConfigManager;
2156
2171
  agentCatalog: AgentCatalog;
2157
2172
  agentManager: AgentManager;
2158
2173
  sessionManager: SessionManager;
@@ -2178,7 +2193,8 @@ declare class OpenACPCore {
2178
2193
  get fileService(): FileServiceInterface;
2179
2194
  get speechService(): SpeechService;
2180
2195
  get contextManager(): ContextManager;
2181
- constructor(configManager: ConfigManager$1, ctx?: InstanceContext);
2196
+ get settingsManager(): SettingsManager | undefined;
2197
+ constructor(configManager: ConfigManager, ctx?: InstanceContext);
2182
2198
  get tunnelService(): TunnelService | undefined;
2183
2199
  set tunnelService(service: TunnelService | undefined);
2184
2200
  registerAdapter(name: string, adapter: IChannelAdapter): void;
@@ -2335,6 +2351,11 @@ interface ConfigFieldDef {
2335
2351
  options?: string[] | ((config: Config) => string[]);
2336
2352
  scope: "safe" | "sensitive";
2337
2353
  hotReload: boolean;
2354
+ /** If set, this field lives in plugin settings rather than config.json */
2355
+ plugin?: {
2356
+ name: string;
2357
+ key: string;
2358
+ };
2338
2359
  }
2339
2360
  declare const CONFIG_REGISTRY: ConfigFieldDef[];
2340
2361
  declare function getFieldDef(path: string): ConfigFieldDef | undefined;
@@ -2343,7 +2364,7 @@ declare function isHotReloadable(path: string): boolean;
2343
2364
  declare function resolveOptions(def: ConfigFieldDef, config: Config): string[] | undefined;
2344
2365
  declare function getConfigValue(config: Config, path: string): unknown;
2345
2366
 
2346
- declare function runConfigEditor(configManager: ConfigManager$1, mode?: 'file' | 'api', apiPort?: number): Promise<void>;
2367
+ declare function runConfigEditor(configManager: ConfigManager, mode?: 'file' | 'api', apiPort?: number, settingsManager?: SettingsManager): Promise<void>;
2347
2368
 
2348
2369
  declare function getPidPath(root?: string): string;
2349
2370
  declare function getStatus(pidPath?: string): {
@@ -3065,4 +3086,4 @@ declare class TelegramAdapter extends MessagingAdapter {
3065
3086
  archiveSessionTopic(sessionId: string): Promise<void>;
3066
3087
  }
3067
3088
 
3068
- export { ActivityTracker, AdapterCapabilities, AgentCapabilities, AgentCatalog, AgentCommand, AgentDefinition, AgentEvent, AgentInstance, AgentListItem, AgentManager, AgentStore, AgentSwitchEntry, type ApiConfig, type ApiServerInstance, type ApiServerOptions, type ApiServerService, type AssistantCommand, AssistantManager, AssistantRegistry, type AssistantSection, Attachment, AvailabilityResult, BaseRenderer, type BridgeDeps, CONFIG_REGISTRY, ChannelConfig, type CleanupResult, type CommandArgs, type CommandDef, CommandRegistry, type CommandResponse, type Config, type ConfigFieldDef, ConfigManager$1 as ConfigManager, ConfigOption, ContextManager, type ContextOptions, type ContextProvider, type ContextQuery, type ContextResult, type ContextService, type SessionInfo as ContextSessionInfo, type DeleteTopicResult, DisplaySpecBuilder, DisplayVerbosity, DoctorEngine, type DoctorReport, DraftManager, EntireProvider, EventBus, type EventBusEvents, FileService, type FileServiceInterface, GroqSTT, IChannelAdapter, type IRenderer, IncomingMessage, type InstallContext, InstallProgress, InstallResult, InstalledAgent, type ListItem, type Logger$1 as Logger, type LoggingConfig, McpServerConfig, type MenuItem, type MenuOption, MenuRegistry, MessageTransformer, MessagingAdapter, type MessagingAdapterConfig, type MigrateContext, NotificationManager, NotificationMessage, type NotificationService, OpenACPCore, type OpenACPPlugin, OutgoingMessage, OutputMode, OutputModeResolver, PRODUCT_GUIDE, type PendingFix, PermissionGate, PermissionRequest, PlanEntry, type PluginContext, type PluginPermission, type PluginStorage, PromptQueue, RegistryAgent, type RenderedMessage, SSEManager, type STTOptions, type STTProvider$1 as STTProvider, type STTResult, SecurityGuard, type SecurityService, SendQueue, Session, SessionBridge, type SessionCreateParams, type SessionEvents, SessionFactory, type SessionListResult, SessionManager, SessionRecord, SessionStatus, SetConfigOptionValue, type SettingsAPI, type SideEffectDeps, type SpeechProviderConfig, SpeechService, type SpeechServiceConfig, type SpeechServiceInterface, StaticServer, StderrCapture, StopReason, StreamAdapter, type TTSOptions, type TTSProvider$1 as TTSProvider, type TTSResult, TelegramAdapter, type TerminalIO, ThoughtBuffer, type ThoughtDisplaySpec, ToolCallMeta, ToolCallTracker, type ToolCardSnapshot, ToolCardState, type ToolCardStateConfig, type ToolDisplaySpec, type ToolEntry, ToolStateMap, type TopicInfo, TopicManager, type TunnelServiceInterface, TypedEmitter, type UsageConfig, UsageRecord, UsageRecordEvent, type UsageService, ViewerLinks, cleanupOldSessionLogs, createApiServer, createApiServerService, createChildLogger, createSessionLogger, expandHome, extractContentText, formatTokens, formatToolSummary, formatToolTitle, getConfigValue, getFieldDef, getPidPath, getSafeFields, getStatus, initLogger, installAutoStart, isAutoStartInstalled, isAutoStartSupported, isHotReloadable, log, nodeToWebReadable, nodeToWebWritable, progressBar, resolveOptions, resolveToolIcon, runConfigEditor, setLogLevel, shutdownLogger, splitMessage, startDaemon, stopDaemon, stripCodeFences, truncateContent, uninstallAutoStart };
3089
+ export { ActivityTracker, AdapterCapabilities, AgentCapabilities, AgentCatalog, AgentCommand, AgentDefinition, AgentEvent, AgentInstance, AgentListItem, AgentManager, AgentStore, AgentSwitchEntry, type ApiConfig, type ApiServerInstance, type ApiServerOptions, type ApiServerService, type AssistantCommand, AssistantManager, AssistantRegistry, type AssistantSection, Attachment, AvailabilityResult, BaseRenderer, type BridgeDeps, CONFIG_REGISTRY, ChannelConfig, type CleanupResult, type CommandArgs, type CommandDef, CommandRegistry, type CommandResponse, type Config, type ConfigFieldDef, ConfigManager, ConfigOption, ContextManager, type ContextOptions, type ContextProvider, type ContextQuery, type ContextResult, type ContextService, type SessionInfo as ContextSessionInfo, type DeleteTopicResult, DisplaySpecBuilder, DisplayVerbosity, DoctorEngine, type DoctorReport, DraftManager, EntireProvider, EventBus, type EventBusEvents, FileService, type FileServiceInterface, GroqSTT, IChannelAdapter, type IRenderer, IncomingMessage, type InstallContext, InstallProgress, InstallResult, InstalledAgent, type ListItem, type Logger, type LoggingConfig, McpServerConfig, type MenuItem, type MenuOption, MenuRegistry, MessageTransformer, MessagingAdapter, type MessagingAdapterConfig, type MigrateContext, NotificationManager, NotificationMessage, type NotificationService, OpenACPCore, type OpenACPPlugin, OutgoingMessage, OutputMode, OutputModeResolver, PRODUCT_GUIDE, type PendingFix, PermissionGate, PermissionRequest, PlanEntry, type PluginContext, type PluginPermission, type PluginStorage, PromptQueue, RegistryAgent, type RenderedMessage, SSEManager, type STTOptions, type STTProvider, type STTResult, SecurityGuard, type SecurityService, SendQueue, Session, SessionBridge, type SessionCreateParams, type SessionEvents, SessionFactory, type SessionListResult, SessionManager, SessionRecord, SessionStatus, SetConfigOptionValue, type SettingsAPI, type SideEffectDeps, type SpeechProviderConfig, SpeechService, type SpeechServiceConfig, type SpeechServiceInterface, StaticServer, StderrCapture, StopReason, StreamAdapter, type TTSOptions, type TTSProvider, type TTSResult, TelegramAdapter, type TerminalIO, ThoughtBuffer, type ThoughtDisplaySpec, ToolCallMeta, ToolCallTracker, type ToolCardSnapshot, ToolCardState, type ToolCardStateConfig, type ToolDisplaySpec, type ToolEntry, ToolStateMap, type TopicInfo, TopicManager, type TunnelServiceInterface, TypedEmitter, type UsageConfig, UsageRecord, UsageRecordEvent, type UsageService, ViewerLinks, cleanupOldSessionLogs, createApiServer, createApiServerService, createChildLogger, createSessionLogger, expandHome, extractContentText, formatTokens, formatToolSummary, formatToolTitle, getConfigValue, getFieldDef, getPidPath, getSafeFields, getStatus, initLogger, installAutoStart, isAutoStartInstalled, isAutoStartSupported, isHotReloadable, log, nodeToWebReadable, nodeToWebWritable, progressBar, resolveOptions, resolveToolIcon, runConfigEditor, setLogLevel, shutdownLogger, splitMessage, startDaemon, stopDaemon, stripCodeFences, truncateContent, uninstallAutoStart };