@n1creator/openacp-cli 2026.712.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/README.md +326 -0
- package/dist/channel-Cowirs76.d.ts +816 -0
- package/dist/cli.d.ts +32 -0
- package/dist/cli.js +36438 -0
- package/dist/cli.js.map +1 -0
- package/dist/data/registry-snapshot.json +851 -0
- package/dist/index.d.ts +5204 -0
- package/dist/index.js +21205 -0
- package/dist/index.js.map +1 -0
- package/dist/testing.d.ts +5 -0
- package/dist/testing.js +17749 -0
- package/dist/testing.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,816 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Controls how much detail is shown in agent output.
|
|
3
|
+
* - `"low"` — minimal: hides thoughts, usage, noisy tool calls
|
|
4
|
+
* - `"medium"` — balanced: shows tool summaries, hides noise
|
|
5
|
+
* - `"high"` — full: shows everything including tool output and thoughts
|
|
6
|
+
*/
|
|
7
|
+
type OutputMode = "low" | "medium" | "high";
|
|
8
|
+
/** @deprecated Use OutputMode instead */
|
|
9
|
+
type DisplayVerbosity = OutputMode;
|
|
10
|
+
/** Maps tool call status strings to emoji icons for display. */
|
|
11
|
+
declare const STATUS_ICONS: Record<string, string>;
|
|
12
|
+
/** Maps tool kind strings to emoji icons for display. */
|
|
13
|
+
declare const KIND_ICONS: Record<string, string>;
|
|
14
|
+
/** Links to the web viewer for file contents or diffs. */
|
|
15
|
+
interface ViewerLinks {
|
|
16
|
+
file?: string;
|
|
17
|
+
diff?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Metadata extracted from a tool_call agent event.
|
|
21
|
+
* Carried on OutgoingMessage.metadata for rendering by adapters.
|
|
22
|
+
*/
|
|
23
|
+
interface ToolCallMeta {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
/** Semantic kind (read, edit, execute, search, etc.) used for icon/label selection. */
|
|
27
|
+
kind?: string;
|
|
28
|
+
status?: string;
|
|
29
|
+
content?: unknown;
|
|
30
|
+
rawInput?: unknown;
|
|
31
|
+
viewerLinks?: ViewerLinks;
|
|
32
|
+
viewerFilePath?: string;
|
|
33
|
+
/** Agent-provided summary override (takes precedence over auto-generated summary). */
|
|
34
|
+
displaySummary?: string;
|
|
35
|
+
/** Agent-provided title override (takes precedence over auto-generated title). */
|
|
36
|
+
displayTitle?: string;
|
|
37
|
+
/** Agent-provided kind override (takes precedence over inferred kind). */
|
|
38
|
+
displayKind?: string;
|
|
39
|
+
}
|
|
40
|
+
/** Metadata for a tool_update event — same as ToolCallMeta but status is required. */
|
|
41
|
+
interface ToolUpdateMeta extends ToolCallMeta {
|
|
42
|
+
status: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Immutable context for a single user-prompt → agent-response cycle ("turn").
|
|
47
|
+
*
|
|
48
|
+
* Sealed when a prompt is dequeued from the PromptQueue and cleared after the turn
|
|
49
|
+
* completes. Bridges use this to route agent events to the correct adapter when
|
|
50
|
+
* multiple adapters are attached to the same session.
|
|
51
|
+
*/
|
|
52
|
+
interface TurnContext {
|
|
53
|
+
/** Unique identifier for this turn — shared between message:queued and message:processing events. */
|
|
54
|
+
turnId: string;
|
|
55
|
+
/** The adapter that originated this prompt. */
|
|
56
|
+
sourceAdapterId: string;
|
|
57
|
+
/** Where to send the response: null = silent (suppress), undefined = same as source, string = explicit target. */
|
|
58
|
+
responseAdapterId?: string | null;
|
|
59
|
+
/** The raw user prompt before any middleware modifications. */
|
|
60
|
+
userPrompt: string;
|
|
61
|
+
/** The final prompt text sent to the agent after all middleware transformations. */
|
|
62
|
+
finalPrompt: string;
|
|
63
|
+
/** File or media attachments included with the prompt. */
|
|
64
|
+
attachments?: Attachment[];
|
|
65
|
+
/** Caller-supplied metadata for this turn (e.g., identity, source info). */
|
|
66
|
+
meta?: TurnMeta;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Routing hints attached to an incoming prompt — carried through the queue
|
|
70
|
+
* and used to construct TurnContext when the prompt is dequeued.
|
|
71
|
+
*/
|
|
72
|
+
interface TurnRouting {
|
|
73
|
+
sourceAdapterId: string;
|
|
74
|
+
responseAdapterId?: string | null;
|
|
75
|
+
}
|
|
76
|
+
/** Identity and display info for the user who sent the turn. */
|
|
77
|
+
interface TurnSender {
|
|
78
|
+
userId: string;
|
|
79
|
+
identityId: string;
|
|
80
|
+
displayName?: string;
|
|
81
|
+
username?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get the effective response adapter for a turn.
|
|
85
|
+
* - null → silent (no adapter renders)
|
|
86
|
+
* - undefined → fallback to sourceAdapterId
|
|
87
|
+
* - string → explicit target
|
|
88
|
+
*/
|
|
89
|
+
declare function getEffectiveTarget(ctx: TurnContext): string | null;
|
|
90
|
+
/**
|
|
91
|
+
* Create a new TurnContext. Called when a prompt is dequeued from the queue.
|
|
92
|
+
* If a pre-generated turnId is provided (from enqueuePrompt), it is used; otherwise a new one is generated.
|
|
93
|
+
*/
|
|
94
|
+
declare function createTurnContext(sourceAdapterId: string, responseAdapterId: string | null | undefined, turnId: string | undefined, userPrompt: string, finalPrompt: string, attachments?: Attachment[], meta?: TurnMeta): TurnContext;
|
|
95
|
+
declare function isSystemEvent(event: AgentEvent): boolean;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Per-turn context bag threaded through all turn-lifecycle middleware hooks.
|
|
99
|
+
*
|
|
100
|
+
* Core fills in `turnId`; plugins attach arbitrary keys at any hook and read
|
|
101
|
+
* them at subsequent hooks in the same turn. The object is mutable by design —
|
|
102
|
+
* plugins collaborating through meta should use namespaced keys to avoid clashes
|
|
103
|
+
* (e.g., `meta['workspace.sender']` not `meta.sender`).
|
|
104
|
+
*/
|
|
105
|
+
interface TurnMeta {
|
|
106
|
+
/** The turn's unique ID — same value passed to session.enqueuePrompt(). */
|
|
107
|
+
turnId: string;
|
|
108
|
+
[key: string]: unknown;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* A file attachment sent to or received from an agent.
|
|
112
|
+
*
|
|
113
|
+
* Agents receive attachments as content blocks in their prompt input.
|
|
114
|
+
* `originalFilePath` preserves the user's original path before any
|
|
115
|
+
* conversion (e.g., audio transcoding or image resizing).
|
|
116
|
+
*/
|
|
117
|
+
interface Attachment {
|
|
118
|
+
type: 'image' | 'audio' | 'file';
|
|
119
|
+
filePath: string;
|
|
120
|
+
fileName: string;
|
|
121
|
+
mimeType: string;
|
|
122
|
+
size: number;
|
|
123
|
+
originalFilePath?: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* A message arriving from a channel adapter (Telegram, Slack, SSE, etc.)
|
|
127
|
+
* destined for a session's agent.
|
|
128
|
+
*
|
|
129
|
+
* `routing` controls how the message is dispatched when multiple adapters
|
|
130
|
+
* are attached to the same session (e.g., which adapter should receive the response).
|
|
131
|
+
*/
|
|
132
|
+
interface IncomingMessage {
|
|
133
|
+
channelId: string;
|
|
134
|
+
threadId: string;
|
|
135
|
+
userId: string;
|
|
136
|
+
text: string;
|
|
137
|
+
attachments?: Attachment[];
|
|
138
|
+
routing?: TurnRouting;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* A message flowing from the agent back to channel adapters for display.
|
|
142
|
+
*
|
|
143
|
+
* The `type` field determines how the adapter renders the message:
|
|
144
|
+
* - text/thought/plan/error — rendered as formatted text blocks
|
|
145
|
+
* - tool_call/tool_update — rendered as collapsible tool activity
|
|
146
|
+
* - usage — token/cost summary (typically shown in a status bar)
|
|
147
|
+
* - attachment — binary content (image, audio, file)
|
|
148
|
+
* - session_end — signals the agent turn is complete
|
|
149
|
+
* - ACP Phase 2 types (mode_change, config_update, etc.) — interactive controls
|
|
150
|
+
*/
|
|
151
|
+
interface OutgoingMessage {
|
|
152
|
+
type: "text" | "thought" | "tool_call" | "tool_update" | "plan" | "usage" | "session_end" | "error" | "attachment" | "system_message" | "mode_change" | "config_update" | "model_update" | "user_replay" | "resource" | "resource_link";
|
|
153
|
+
text: string;
|
|
154
|
+
metadata?: Record<string, unknown>;
|
|
155
|
+
attachment?: Attachment;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* A permission request sent by the agent when it needs user approval.
|
|
159
|
+
*
|
|
160
|
+
* The agent blocks until the user picks one of the `options`.
|
|
161
|
+
* PermissionGate holds the request, emits it to adapters via SessionEv,
|
|
162
|
+
* and resumes the agent with the chosen option when resolved.
|
|
163
|
+
*/
|
|
164
|
+
interface PermissionRequest {
|
|
165
|
+
id: string;
|
|
166
|
+
description: string;
|
|
167
|
+
options: PermissionOption[];
|
|
168
|
+
}
|
|
169
|
+
/** A single choice within a permission request (e.g., "Allow once", "Deny"). */
|
|
170
|
+
interface PermissionOption {
|
|
171
|
+
id: string;
|
|
172
|
+
label: string;
|
|
173
|
+
/** Whether this option grants the requested permission. */
|
|
174
|
+
isAllow: boolean;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* A notification pushed to the user outside of the normal message flow.
|
|
178
|
+
*
|
|
179
|
+
* Used for background alerts when the user isn't actively watching the session
|
|
180
|
+
* (e.g., agent completed, permission needed, budget warning).
|
|
181
|
+
*/
|
|
182
|
+
interface NotificationMessage {
|
|
183
|
+
sessionId: string;
|
|
184
|
+
sessionName?: string;
|
|
185
|
+
type: "completed" | "error" | "permission" | "input_required" | "budget_warning";
|
|
186
|
+
summary: string;
|
|
187
|
+
/** URL to jump directly to the session in the adapter UI. */
|
|
188
|
+
deepLink?: string;
|
|
189
|
+
}
|
|
190
|
+
/** A command exposed by the agent, surfaced as interactive buttons in the chat UI. */
|
|
191
|
+
interface AgentCommand {
|
|
192
|
+
name: string;
|
|
193
|
+
description: string;
|
|
194
|
+
input?: unknown;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Union of all events that an AgentInstance can emit during a prompt turn.
|
|
198
|
+
*
|
|
199
|
+
* Each variant maps to an ACP protocol event. AgentInstance translates raw
|
|
200
|
+
* ACP SDK events into these normalized types, which then flow through
|
|
201
|
+
* middleware (Hook.AGENT_BEFORE_EVENT) and into SessionBridge for rendering.
|
|
202
|
+
*/
|
|
203
|
+
type AgentEvent =
|
|
204
|
+
/** Streamed text content from the agent's response. */
|
|
205
|
+
{
|
|
206
|
+
type: "text";
|
|
207
|
+
content: string;
|
|
208
|
+
}
|
|
209
|
+
/** Agent's internal reasoning (displayed in a collapsible block). */
|
|
210
|
+
| {
|
|
211
|
+
type: "thought";
|
|
212
|
+
content: string;
|
|
213
|
+
}
|
|
214
|
+
/** Agent started or completed a tool invocation. */
|
|
215
|
+
| {
|
|
216
|
+
type: "tool_call";
|
|
217
|
+
id: string;
|
|
218
|
+
name: string;
|
|
219
|
+
kind?: string;
|
|
220
|
+
status: string;
|
|
221
|
+
content?: unknown;
|
|
222
|
+
locations?: unknown;
|
|
223
|
+
rawInput?: unknown;
|
|
224
|
+
rawOutput?: unknown;
|
|
225
|
+
meta?: unknown;
|
|
226
|
+
}
|
|
227
|
+
/** Progress update for an in-flight tool call (partial output, status change). */
|
|
228
|
+
| {
|
|
229
|
+
type: "tool_update";
|
|
230
|
+
id: string;
|
|
231
|
+
name?: string;
|
|
232
|
+
kind?: string;
|
|
233
|
+
status: string;
|
|
234
|
+
content?: unknown;
|
|
235
|
+
locations?: unknown;
|
|
236
|
+
rawInput?: unknown;
|
|
237
|
+
rawOutput?: unknown;
|
|
238
|
+
meta?: unknown;
|
|
239
|
+
}
|
|
240
|
+
/** Agent's execution plan with prioritized steps. */
|
|
241
|
+
| {
|
|
242
|
+
type: "plan";
|
|
243
|
+
entries: PlanEntry[];
|
|
244
|
+
}
|
|
245
|
+
/** Token usage and cost report for the current turn. */
|
|
246
|
+
| {
|
|
247
|
+
type: "usage";
|
|
248
|
+
tokensUsed?: number;
|
|
249
|
+
contextSize?: number;
|
|
250
|
+
cost?: {
|
|
251
|
+
amount: number;
|
|
252
|
+
currency: string;
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
/** Agent updated its available slash commands. */
|
|
256
|
+
| {
|
|
257
|
+
type: "commands_update";
|
|
258
|
+
commands: AgentCommand[];
|
|
259
|
+
}
|
|
260
|
+
/** Agent produced an image as output (base64-encoded). */
|
|
261
|
+
| {
|
|
262
|
+
type: "image_content";
|
|
263
|
+
data: string;
|
|
264
|
+
mimeType: string;
|
|
265
|
+
}
|
|
266
|
+
/** Agent produced audio as output (base64-encoded). */
|
|
267
|
+
| {
|
|
268
|
+
type: "audio_content";
|
|
269
|
+
data: string;
|
|
270
|
+
mimeType: string;
|
|
271
|
+
}
|
|
272
|
+
/** Agent ended the session (no more prompts accepted). */
|
|
273
|
+
| {
|
|
274
|
+
type: "session_end";
|
|
275
|
+
reason: string;
|
|
276
|
+
}
|
|
277
|
+
/** Agent-level error (non-fatal — session may continue). */
|
|
278
|
+
| {
|
|
279
|
+
type: "error";
|
|
280
|
+
message: string;
|
|
281
|
+
}
|
|
282
|
+
/** System message injected by OpenACP (not from the agent itself). */
|
|
283
|
+
| {
|
|
284
|
+
type: "system_message";
|
|
285
|
+
message: string;
|
|
286
|
+
}
|
|
287
|
+
/** Agent updated session metadata (title, timestamps). */
|
|
288
|
+
| {
|
|
289
|
+
type: "session_info_update";
|
|
290
|
+
title?: string;
|
|
291
|
+
updatedAt?: string;
|
|
292
|
+
_meta?: Record<string, unknown>;
|
|
293
|
+
}
|
|
294
|
+
/** Agent updated its config options (modes, models, toggles). */
|
|
295
|
+
| {
|
|
296
|
+
type: "config_option_update";
|
|
297
|
+
options: ConfigOption[];
|
|
298
|
+
}
|
|
299
|
+
/** Echoed user message chunk — used for cross-adapter input visibility. */
|
|
300
|
+
| {
|
|
301
|
+
type: "user_message_chunk";
|
|
302
|
+
content: string;
|
|
303
|
+
}
|
|
304
|
+
/** Agent returned a resource's content (file, data). */
|
|
305
|
+
| {
|
|
306
|
+
type: "resource_content";
|
|
307
|
+
uri: string;
|
|
308
|
+
name: string;
|
|
309
|
+
text?: string;
|
|
310
|
+
blob?: string;
|
|
311
|
+
mimeType?: string;
|
|
312
|
+
}
|
|
313
|
+
/** Agent returned a link to a resource (without inline content). */
|
|
314
|
+
| {
|
|
315
|
+
type: "resource_link";
|
|
316
|
+
uri: string;
|
|
317
|
+
name: string;
|
|
318
|
+
mimeType?: string;
|
|
319
|
+
title?: string;
|
|
320
|
+
description?: string;
|
|
321
|
+
size?: number;
|
|
322
|
+
}
|
|
323
|
+
/** Signals that TTS output should be stripped from the response. */
|
|
324
|
+
| {
|
|
325
|
+
type: "tts_strip";
|
|
326
|
+
};
|
|
327
|
+
/** A single step in an agent's execution plan. */
|
|
328
|
+
interface PlanEntry {
|
|
329
|
+
content: string;
|
|
330
|
+
status: "pending" | "in_progress" | "completed";
|
|
331
|
+
priority: "high" | "medium" | "low";
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Static definition of an agent — the command, args, and environment
|
|
335
|
+
* needed to spawn its subprocess.
|
|
336
|
+
*/
|
|
337
|
+
interface AgentDefinition {
|
|
338
|
+
name: string;
|
|
339
|
+
command: string;
|
|
340
|
+
args: string[];
|
|
341
|
+
workingDirectory?: string;
|
|
342
|
+
env?: Record<string, string>;
|
|
343
|
+
/** Override the default init timeout (ms) for this agent's ACP handshake. */
|
|
344
|
+
initTimeoutMs?: number;
|
|
345
|
+
}
|
|
346
|
+
/** How the agent is distributed and installed. */
|
|
347
|
+
type AgentDistribution = "npx" | "uvx" | "binary" | "custom";
|
|
348
|
+
/** An agent that has been installed locally and is ready to spawn. */
|
|
349
|
+
interface InstalledAgent {
|
|
350
|
+
registryId: string | null;
|
|
351
|
+
name: string;
|
|
352
|
+
version: string;
|
|
353
|
+
distribution: AgentDistribution;
|
|
354
|
+
command: string;
|
|
355
|
+
args: string[];
|
|
356
|
+
env: Record<string, string>;
|
|
357
|
+
workingDirectory?: string;
|
|
358
|
+
installedAt: string;
|
|
359
|
+
/** Absolute path to the binary on disk (only for "binary" distribution). */
|
|
360
|
+
binaryPath: string | null;
|
|
361
|
+
/** Override the default init timeout (ms) for this agent's ACP handshake. */
|
|
362
|
+
initTimeoutMs?: number;
|
|
363
|
+
}
|
|
364
|
+
/** Platform-specific binary download target from the agent registry. */
|
|
365
|
+
interface RegistryBinaryTarget {
|
|
366
|
+
archive: string;
|
|
367
|
+
cmd: string;
|
|
368
|
+
args?: string[];
|
|
369
|
+
env?: Record<string, string>;
|
|
370
|
+
}
|
|
371
|
+
/** Distribution methods available for a registry agent. */
|
|
372
|
+
interface RegistryDistribution {
|
|
373
|
+
npx?: {
|
|
374
|
+
package: string;
|
|
375
|
+
args?: string[];
|
|
376
|
+
env?: Record<string, string>;
|
|
377
|
+
};
|
|
378
|
+
uvx?: {
|
|
379
|
+
package: string;
|
|
380
|
+
args?: string[];
|
|
381
|
+
env?: Record<string, string>;
|
|
382
|
+
};
|
|
383
|
+
/** Platform → arch → binary target mapping. */
|
|
384
|
+
binary?: Record<string, RegistryBinaryTarget>;
|
|
385
|
+
}
|
|
386
|
+
/** An agent entry from the remote agent registry. */
|
|
387
|
+
interface RegistryAgent {
|
|
388
|
+
id: string;
|
|
389
|
+
name: string;
|
|
390
|
+
version: string;
|
|
391
|
+
description: string;
|
|
392
|
+
repository?: string;
|
|
393
|
+
website?: string;
|
|
394
|
+
authors?: string[];
|
|
395
|
+
license?: string;
|
|
396
|
+
icon?: string;
|
|
397
|
+
distribution: RegistryDistribution;
|
|
398
|
+
}
|
|
399
|
+
/** Merged view of a registry agent with local install status. */
|
|
400
|
+
interface AgentListItem {
|
|
401
|
+
key: string;
|
|
402
|
+
registryId: string;
|
|
403
|
+
name: string;
|
|
404
|
+
version: string;
|
|
405
|
+
description?: string;
|
|
406
|
+
distribution: AgentDistribution;
|
|
407
|
+
installed: boolean;
|
|
408
|
+
available: boolean;
|
|
409
|
+
/** Runtime dependencies that are missing on this machine. */
|
|
410
|
+
missingDeps?: string[];
|
|
411
|
+
}
|
|
412
|
+
/** Result of checking whether an agent can run on this machine. */
|
|
413
|
+
interface AvailabilityResult {
|
|
414
|
+
available: boolean;
|
|
415
|
+
reason?: string;
|
|
416
|
+
missing?: Array<{
|
|
417
|
+
label: string;
|
|
418
|
+
installHint: string;
|
|
419
|
+
}>;
|
|
420
|
+
}
|
|
421
|
+
/** Callbacks for reporting agent installation progress to the UI. */
|
|
422
|
+
interface InstallProgress {
|
|
423
|
+
onStart(agentId: string, agentName: string): void | Promise<void>;
|
|
424
|
+
onStep(step: string): void | Promise<void>;
|
|
425
|
+
onDownloadProgress(percent: number): void | Promise<void>;
|
|
426
|
+
onSuccess(agentName: string): void | Promise<void>;
|
|
427
|
+
onError(error: string, hint?: string): void | Promise<void>;
|
|
428
|
+
}
|
|
429
|
+
/** Result of an agent install operation. */
|
|
430
|
+
interface InstallResult {
|
|
431
|
+
ok: boolean;
|
|
432
|
+
agentKey: string;
|
|
433
|
+
error?: string;
|
|
434
|
+
hint?: string;
|
|
435
|
+
setupSteps?: string[];
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Session lifecycle status.
|
|
439
|
+
*
|
|
440
|
+
* Valid transitions:
|
|
441
|
+
* initializing → active | error
|
|
442
|
+
* active → error | finished | cancelled
|
|
443
|
+
* error → active | cancelled (recovery or user cancels)
|
|
444
|
+
* cancelled → active (user resumes)
|
|
445
|
+
* finished → (terminal — no transitions)
|
|
446
|
+
*/
|
|
447
|
+
type SessionStatus = "initializing" | "active" | "cancelled" | "finished" | "error";
|
|
448
|
+
/** Record of an agent switch within a session (for history tracking). */
|
|
449
|
+
interface AgentSwitchEntry {
|
|
450
|
+
agentName: string;
|
|
451
|
+
agentSessionId: string;
|
|
452
|
+
switchedAt: string;
|
|
453
|
+
promptCount: number;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Persisted session state — serialized to the session store (JSON file).
|
|
457
|
+
*
|
|
458
|
+
* Generic parameter `P` is the primary adapter's platform-specific data
|
|
459
|
+
* (e.g., TelegramPlatformData). Additional adapters store data in `platforms`.
|
|
460
|
+
*/
|
|
461
|
+
interface SessionRecord<P = Record<string, unknown>> {
|
|
462
|
+
sessionId: string;
|
|
463
|
+
agentSessionId: string;
|
|
464
|
+
originalAgentSessionId?: string;
|
|
465
|
+
agentName: string;
|
|
466
|
+
workingDir: string;
|
|
467
|
+
channelId: string;
|
|
468
|
+
status: SessionStatus;
|
|
469
|
+
createdAt: string;
|
|
470
|
+
lastActiveAt: string;
|
|
471
|
+
name?: string;
|
|
472
|
+
isAssistant?: boolean;
|
|
473
|
+
dangerousMode?: boolean;
|
|
474
|
+
clientOverrides?: {
|
|
475
|
+
bypassPermissions?: boolean;
|
|
476
|
+
};
|
|
477
|
+
outputMode?: OutputMode;
|
|
478
|
+
platform: P;
|
|
479
|
+
/** Per-adapter platform data. Key = adapterId, value = adapter-specific data. */
|
|
480
|
+
platforms?: Record<string, Record<string, unknown>>;
|
|
481
|
+
/** Adapters currently attached to this session. Defaults to [channelId] for old records. */
|
|
482
|
+
attachedAdapters?: string[];
|
|
483
|
+
firstAgent?: string;
|
|
484
|
+
currentPromptCount?: number;
|
|
485
|
+
agentSwitchHistory?: AgentSwitchEntry[];
|
|
486
|
+
/** userId of the user who created this session (from identity system). */
|
|
487
|
+
createdBy?: string;
|
|
488
|
+
/** userId[] of all users who have sent messages in this session. */
|
|
489
|
+
participants?: string[];
|
|
490
|
+
acpState?: {
|
|
491
|
+
configOptions?: ConfigOption[];
|
|
492
|
+
agentCapabilities?: AgentCapabilities;
|
|
493
|
+
currentMode?: string;
|
|
494
|
+
availableModes?: SessionMode[];
|
|
495
|
+
currentModel?: string;
|
|
496
|
+
availableModels?: ModelInfo[];
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
/** Telegram-specific data stored per session in the session record. */
|
|
500
|
+
interface TelegramPlatformData {
|
|
501
|
+
topicId: number;
|
|
502
|
+
skillMsgId?: number;
|
|
503
|
+
controlMsgId?: number;
|
|
504
|
+
}
|
|
505
|
+
/** A single token usage data point for cost tracking. */
|
|
506
|
+
interface UsageRecord {
|
|
507
|
+
id: string;
|
|
508
|
+
sessionId: string;
|
|
509
|
+
agentName: string;
|
|
510
|
+
tokensUsed: number;
|
|
511
|
+
contextSize: number;
|
|
512
|
+
cost?: {
|
|
513
|
+
amount: number;
|
|
514
|
+
currency: string;
|
|
515
|
+
};
|
|
516
|
+
timestamp: string;
|
|
517
|
+
}
|
|
518
|
+
/** Usage event emitted on the EventBus for the usage-tracking plugin. */
|
|
519
|
+
interface UsageRecordEvent {
|
|
520
|
+
sessionId: string;
|
|
521
|
+
agentName: string;
|
|
522
|
+
timestamp: string;
|
|
523
|
+
tokensUsed: number;
|
|
524
|
+
contextSize: number;
|
|
525
|
+
cost?: {
|
|
526
|
+
amount: number;
|
|
527
|
+
currency: string;
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
/** An agent operating mode (e.g., "code", "architect", "ask"). */
|
|
531
|
+
interface SessionMode {
|
|
532
|
+
id: string;
|
|
533
|
+
name: string;
|
|
534
|
+
description?: string;
|
|
535
|
+
}
|
|
536
|
+
/** Current mode and all available modes for a session. */
|
|
537
|
+
interface SessionModeState {
|
|
538
|
+
currentModeId: string;
|
|
539
|
+
availableModes: SessionMode[];
|
|
540
|
+
}
|
|
541
|
+
/** A single choice within a select-type config option. */
|
|
542
|
+
interface ConfigSelectChoice {
|
|
543
|
+
value: string;
|
|
544
|
+
name: string;
|
|
545
|
+
description?: string;
|
|
546
|
+
}
|
|
547
|
+
/** A named group of select choices (for categorized dropdowns). */
|
|
548
|
+
interface ConfigSelectGroup {
|
|
549
|
+
group: string;
|
|
550
|
+
name: string;
|
|
551
|
+
options: ConfigSelectChoice[];
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Agent-exposed configuration options surfaced as interactive controls in chat.
|
|
555
|
+
*
|
|
556
|
+
* These are settings the agent advertises via the ACP config_option_update event.
|
|
557
|
+
* Adapters render them as select menus, toggles, etc. in the chat UI.
|
|
558
|
+
* When the user changes a value, OpenACP sends a setConfigOption request to the agent.
|
|
559
|
+
*/
|
|
560
|
+
type ConfigOption = {
|
|
561
|
+
id: string;
|
|
562
|
+
name: string;
|
|
563
|
+
description?: string;
|
|
564
|
+
category?: string;
|
|
565
|
+
type: "select";
|
|
566
|
+
currentValue: string;
|
|
567
|
+
options: (ConfigSelectChoice | ConfigSelectGroup)[];
|
|
568
|
+
_meta?: Record<string, unknown>;
|
|
569
|
+
} | {
|
|
570
|
+
id: string;
|
|
571
|
+
name: string;
|
|
572
|
+
description?: string;
|
|
573
|
+
category?: string;
|
|
574
|
+
type: "boolean";
|
|
575
|
+
currentValue: boolean;
|
|
576
|
+
_meta?: Record<string, unknown>;
|
|
577
|
+
};
|
|
578
|
+
/** Value payload for updating a config option on the agent. */
|
|
579
|
+
type SetConfigOptionValue = {
|
|
580
|
+
type: "select";
|
|
581
|
+
value: string;
|
|
582
|
+
} | {
|
|
583
|
+
type: "boolean";
|
|
584
|
+
value: boolean;
|
|
585
|
+
};
|
|
586
|
+
/** An AI model available for the agent to use. */
|
|
587
|
+
interface ModelInfo {
|
|
588
|
+
id: string;
|
|
589
|
+
name: string;
|
|
590
|
+
description?: string;
|
|
591
|
+
}
|
|
592
|
+
/** Current model and all available models for a session. */
|
|
593
|
+
interface SessionModelState {
|
|
594
|
+
currentModelId: string;
|
|
595
|
+
availableModels: ModelInfo[];
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Capabilities advertised by the agent in its initialize response.
|
|
599
|
+
*
|
|
600
|
+
* These determine which ACP features the agent supports — OpenACP uses
|
|
601
|
+
* them to enable/disable UI features (e.g., session list, fork, MCP).
|
|
602
|
+
*/
|
|
603
|
+
interface AgentCapabilities {
|
|
604
|
+
name: string;
|
|
605
|
+
title?: string;
|
|
606
|
+
version?: string;
|
|
607
|
+
/** Whether the agent supports loading (resuming) existing sessions. */
|
|
608
|
+
loadSession?: boolean;
|
|
609
|
+
promptCapabilities?: {
|
|
610
|
+
image?: boolean;
|
|
611
|
+
audio?: boolean;
|
|
612
|
+
embeddedContext?: boolean;
|
|
613
|
+
};
|
|
614
|
+
sessionCapabilities?: {
|
|
615
|
+
list?: boolean;
|
|
616
|
+
fork?: boolean;
|
|
617
|
+
close?: boolean;
|
|
618
|
+
};
|
|
619
|
+
mcp?: {
|
|
620
|
+
http?: boolean;
|
|
621
|
+
sse?: boolean;
|
|
622
|
+
};
|
|
623
|
+
authMethods?: AuthMethod[];
|
|
624
|
+
}
|
|
625
|
+
/** Response from the agent when creating a new session. */
|
|
626
|
+
interface NewSessionResponse {
|
|
627
|
+
sessionId: string;
|
|
628
|
+
modes?: SessionModeState;
|
|
629
|
+
configOptions?: ConfigOption[];
|
|
630
|
+
models?: SessionModelState;
|
|
631
|
+
}
|
|
632
|
+
/** Authentication method supported by the agent. */
|
|
633
|
+
type AuthMethod = {
|
|
634
|
+
type: "agent";
|
|
635
|
+
} | {
|
|
636
|
+
type: "env_var";
|
|
637
|
+
name: string;
|
|
638
|
+
description?: string;
|
|
639
|
+
} | {
|
|
640
|
+
type: "terminal";
|
|
641
|
+
};
|
|
642
|
+
/** Request to authenticate with a specific method. */
|
|
643
|
+
interface AuthenticateRequest {
|
|
644
|
+
methodId: string;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Reason why the agent stopped generating.
|
|
648
|
+
*
|
|
649
|
+
* - end_turn: agent completed its response normally
|
|
650
|
+
* - max_tokens / max_turn_requests: hit a limit
|
|
651
|
+
* - refusal: agent declined the request
|
|
652
|
+
* - cancelled / interrupted: user or system stopped the prompt
|
|
653
|
+
* - error: agent encountered an error
|
|
654
|
+
*/
|
|
655
|
+
type StopReason = "end_turn" | "max_tokens" | "max_turn_requests" | "refusal" | "cancelled" | "error" | "interrupted";
|
|
656
|
+
/** Final response from the agent after a prompt completes. */
|
|
657
|
+
interface PromptResponse {
|
|
658
|
+
stopReason: StopReason;
|
|
659
|
+
_meta?: Record<string, unknown>;
|
|
660
|
+
}
|
|
661
|
+
/** A content block within a prompt message sent to the agent. */
|
|
662
|
+
type ContentBlock = {
|
|
663
|
+
type: "text";
|
|
664
|
+
text: string;
|
|
665
|
+
} | {
|
|
666
|
+
type: "image";
|
|
667
|
+
data: string;
|
|
668
|
+
mimeType: string;
|
|
669
|
+
uri?: string;
|
|
670
|
+
} | {
|
|
671
|
+
type: "audio";
|
|
672
|
+
data: string;
|
|
673
|
+
mimeType: string;
|
|
674
|
+
} | {
|
|
675
|
+
type: "resource";
|
|
676
|
+
resource: {
|
|
677
|
+
uri: string;
|
|
678
|
+
text?: string;
|
|
679
|
+
blob?: string;
|
|
680
|
+
mimeType?: string;
|
|
681
|
+
};
|
|
682
|
+
} | {
|
|
683
|
+
type: "resource_link";
|
|
684
|
+
uri: string;
|
|
685
|
+
name: string;
|
|
686
|
+
mimeType?: string;
|
|
687
|
+
title?: string;
|
|
688
|
+
description?: string;
|
|
689
|
+
size?: number;
|
|
690
|
+
};
|
|
691
|
+
/** A session entry returned by the agent's session list endpoint. */
|
|
692
|
+
interface SessionListItem {
|
|
693
|
+
sessionId: string;
|
|
694
|
+
title?: string;
|
|
695
|
+
createdAt: string;
|
|
696
|
+
updatedAt?: string;
|
|
697
|
+
_meta?: Record<string, unknown>;
|
|
698
|
+
}
|
|
699
|
+
/** Paginated response from the agent's session list endpoint. */
|
|
700
|
+
interface SessionListResponse {
|
|
701
|
+
sessions: SessionListItem[];
|
|
702
|
+
nextCursor?: string;
|
|
703
|
+
}
|
|
704
|
+
/** Configuration for connecting to an MCP (Model Context Protocol) server. */
|
|
705
|
+
type McpServerConfig = {
|
|
706
|
+
type?: "stdio";
|
|
707
|
+
name: string;
|
|
708
|
+
command: string;
|
|
709
|
+
args?: string[];
|
|
710
|
+
env?: Record<string, string>;
|
|
711
|
+
} | {
|
|
712
|
+
type: "http";
|
|
713
|
+
name: string;
|
|
714
|
+
url: string;
|
|
715
|
+
headers?: Record<string, string>;
|
|
716
|
+
} | {
|
|
717
|
+
type: "sse";
|
|
718
|
+
name: string;
|
|
719
|
+
url: string;
|
|
720
|
+
headers?: Record<string, string>;
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Configuration for an adapter channel (Telegram, Slack, etc.).
|
|
725
|
+
* Each adapter defines its own fields beyond `enabled`.
|
|
726
|
+
*/
|
|
727
|
+
interface ChannelConfig {
|
|
728
|
+
enabled: boolean;
|
|
729
|
+
[key: string]: unknown;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Declares what a messaging platform supports. Core uses these to decide
|
|
733
|
+
* whether to attempt features like streaming, file uploads, or voice.
|
|
734
|
+
*/
|
|
735
|
+
interface AdapterCapabilities {
|
|
736
|
+
streaming: boolean;
|
|
737
|
+
richFormatting: boolean;
|
|
738
|
+
threads: boolean;
|
|
739
|
+
reactions: boolean;
|
|
740
|
+
fileUpload: boolean;
|
|
741
|
+
voice: boolean;
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Contract for a messaging platform adapter.
|
|
745
|
+
*
|
|
746
|
+
* A "channel" in OpenACP is identified by an adapter name (e.g. "telegram", "slack").
|
|
747
|
+
* Each session binds to a channel + thread ID — together they form a unique conversation
|
|
748
|
+
* location. The adapter is responsible for platform-specific I/O: sending messages,
|
|
749
|
+
* creating threads/topics, handling permission buttons, etc.
|
|
750
|
+
*
|
|
751
|
+
* Core calls adapter methods via SessionBridge (for agent events) or directly
|
|
752
|
+
* (for session lifecycle operations like thread creation and archiving).
|
|
753
|
+
*/
|
|
754
|
+
interface IChannelAdapter {
|
|
755
|
+
readonly name: string;
|
|
756
|
+
readonly capabilities: AdapterCapabilities;
|
|
757
|
+
start(): Promise<void>;
|
|
758
|
+
stop(): Promise<void>;
|
|
759
|
+
sendMessage(sessionId: string, content: OutgoingMessage): Promise<void>;
|
|
760
|
+
sendPermissionRequest(sessionId: string, request: PermissionRequest): Promise<void>;
|
|
761
|
+
sendNotification(notification: NotificationMessage): Promise<void>;
|
|
762
|
+
/** Create a thread/topic for a session. Returns the platform-specific thread ID. */
|
|
763
|
+
createSessionThread(sessionId: string, name: string): Promise<string>;
|
|
764
|
+
renameSessionThread(sessionId: string, newName: string): Promise<void>;
|
|
765
|
+
deleteSessionThread?(sessionId: string): Promise<void>;
|
|
766
|
+
archiveSessionTopic?(sessionId: string): Promise<void>;
|
|
767
|
+
stripTTSBlock?(sessionId: string): Promise<void>;
|
|
768
|
+
sendSkillCommands?(sessionId: string, commands: AgentCommand[]): Promise<void>;
|
|
769
|
+
cleanupSkillCommands?(sessionId: string): Promise<void>;
|
|
770
|
+
/** Flush skill commands that were queued before threadId was available. */
|
|
771
|
+
flushPendingSkillCommands?(sessionId: string): Promise<void>;
|
|
772
|
+
cleanupSessionState?(sessionId: string): Promise<void>;
|
|
773
|
+
/** Send a notification directly to a user by platform ID. Best-effort delivery. */
|
|
774
|
+
sendUserNotification?(platformId: string, message: NotificationMessage, options?: {
|
|
775
|
+
via?: 'dm' | 'thread' | 'topic';
|
|
776
|
+
topicId?: string;
|
|
777
|
+
sessionId?: string;
|
|
778
|
+
platformMention?: {
|
|
779
|
+
platformUsername?: string;
|
|
780
|
+
platformId: string;
|
|
781
|
+
};
|
|
782
|
+
}): Promise<void>;
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Original base class for channel adapters. Provides default no-op implementations
|
|
786
|
+
* for optional IChannelAdapter methods so subclasses only need to implement the
|
|
787
|
+
* methods they care about.
|
|
788
|
+
*
|
|
789
|
+
* This class predates the adapter-primitives package. It has since been superseded
|
|
790
|
+
* by MessagingAdapter and StreamAdapter, which add structured send queuing, streaming
|
|
791
|
+
* support, and platform-specific rendering out of the box.
|
|
792
|
+
*
|
|
793
|
+
* @deprecated Use MessagingAdapter or StreamAdapter instead. Kept for backward compat during migration.
|
|
794
|
+
*/
|
|
795
|
+
declare abstract class ChannelAdapter<TCore = unknown> implements IChannelAdapter {
|
|
796
|
+
readonly core: TCore;
|
|
797
|
+
protected config: ChannelConfig;
|
|
798
|
+
abstract readonly name: string;
|
|
799
|
+
readonly capabilities: AdapterCapabilities;
|
|
800
|
+
constructor(core: TCore, config: ChannelConfig);
|
|
801
|
+
abstract start(): Promise<void>;
|
|
802
|
+
abstract stop(): Promise<void>;
|
|
803
|
+
abstract sendMessage(sessionId: string, content: OutgoingMessage): Promise<void>;
|
|
804
|
+
abstract sendPermissionRequest(sessionId: string, request: PermissionRequest): Promise<void>;
|
|
805
|
+
abstract sendNotification(notification: NotificationMessage): Promise<void>;
|
|
806
|
+
abstract createSessionThread(sessionId: string, name: string): Promise<string>;
|
|
807
|
+
abstract renameSessionThread(sessionId: string, newName: string): Promise<void>;
|
|
808
|
+
deleteSessionThread(_sessionId: string): Promise<void>;
|
|
809
|
+
sendSkillCommands(_sessionId: string, _commands: AgentCommand[]): Promise<void>;
|
|
810
|
+
cleanupSkillCommands(_sessionId: string): Promise<void>;
|
|
811
|
+
cleanupSessionState(_sessionId: string): Promise<void>;
|
|
812
|
+
archiveSessionTopic(_sessionId: string): Promise<void>;
|
|
813
|
+
sendUserNotification(_platformId: string, _message: NotificationMessage, _options?: any): Promise<void>;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
export { type SessionMode as $, type Attachment as A, ChannelAdapter as B, type ConfigOption as C, type DisplayVerbosity as D, type ConfigSelectChoice as E, type ConfigSelectGroup as F, type ContentBlock as G, type ModelInfo as H, type IChannelAdapter as I, type NewSessionResponse as J, KIND_ICONS as K, type PermissionOption as L, type McpServerConfig as M, type NotificationMessage as N, type OutgoingMessage as O, type PermissionRequest as P, type PromptResponse as Q, type RegistryAgent as R, type StopReason as S, type TurnMeta as T, type UsageRecord as U, type ViewerLinks as V, type RegistryBinaryTarget as W, type RegistryDistribution as X, STATUS_ICONS as Y, type SessionListItem as Z, type SessionListResponse as _, type AgentEvent as a, type SessionModeState as a0, type SessionModelState as a1, type TelegramPlatformData as a2, type ToolUpdateMeta as a3, createTurnContext as a4, getEffectiveTarget as a5, isSystemEvent as a6, type SessionStatus as b, type AgentCapabilities as c, type AgentDefinition as d, type SetConfigOptionValue as e, type InstalledAgent as f, type AgentListItem as g, type AvailabilityResult as h, type InstallProgress as i, type InstallResult as j, type TurnContext as k, type TurnRouting as l, type AgentSwitchEntry as m, type AgentCommand as n, type SessionRecord as o, type UsageRecordEvent as p, type TurnSender as q, type IncomingMessage as r, type ChannelConfig as s, type AdapterCapabilities as t, type ToolCallMeta as u, type OutputMode as v, type PlanEntry as w, type AgentDistribution as x, type AuthMethod as y, type AuthenticateRequest as z };
|