macro-agent 0.1.6 → 0.1.7

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.
@@ -1,2672 +0,0 @@
1
- import { PermissionMode, Session, AgentHandle, ExtendedSessionUpdate } from 'acp-factory';
2
- import { Stream, StartTaskResult, WorkerTask } from 'git-cascade';
3
- import Database from 'better-sqlite3';
4
- import { MessageContent, Importance, Message, AgentInbox } from 'agent-inbox';
5
- import { Express } from 'express';
6
-
7
- /**
8
- * Primitive type definitions
9
- */
10
- type AgentId$1 = string;
11
- type SessionId = string;
12
- type TaskId$1 = string;
13
- type EventId = string;
14
- type Timestamp = number;
15
-
16
- /**
17
- * Agent-related type definitions
18
- */
19
-
20
- type AgentState = "spawning" | "running" | "stopped" | "failed";
21
- type StopReason = "completed" | "failed" | "stopped" | "timeout" | "cancelled";
22
- interface AgentConfig$1 {
23
- model?: string;
24
- timeout?: number;
25
- resource_limits?: {
26
- max_tokens?: number;
27
- max_children?: number;
28
- [key: string]: unknown;
29
- };
30
- }
31
- interface Agent {
32
- id: AgentId$1;
33
- /** Optional display name (set via rename, not derived from events) */
34
- name?: string;
35
- session_id: SessionId;
36
- /** Session ID from the underlying agent provider (e.g., Claude Code UUID for --resume) */
37
- provider_session_id?: string;
38
- parent: AgentId$1 | null;
39
- lineage: AgentId$1[];
40
- state: AgentState;
41
- stop_reason?: StopReason;
42
- task: string;
43
- task_id?: TaskId$1;
44
- role?: string;
45
- /** Team instance ID this agent belongs to (set by TeamManager) */
46
- team_instance?: string;
47
- config: AgentConfig$1;
48
- cwd: string;
49
- plan: Array<{
50
- content: string;
51
- priority: string;
52
- status: string;
53
- }>;
54
- /** Arbitrary metadata (persisted out-of-band, not derived from events) */
55
- metadata?: Record<string, unknown>;
56
- created_at: Timestamp;
57
- started_at?: Timestamp;
58
- stopped_at?: Timestamp;
59
- /** Last time this agent emitted an event (for health monitoring) */
60
- last_activity_at?: Timestamp;
61
- }
62
-
63
- /**
64
- * MergeQueue Types
65
- *
66
- * Types for the merge queue layer that coordinates parallel worker merges.
67
- *
68
- * @module workspace/merge-queue/types
69
- * @implements [[s-bcqm]] Merge Queue Schema section
70
- */
71
- /**
72
- * Merge request status values.
73
- *
74
- * - pending: Waiting in queue to be processed
75
- * - processing: Currently being merged by integrator
76
- * - merged: Successfully merged into integration branch
77
- * - conflict: Merge conflicts detected, needs resolution
78
- * - abandoned: Worker abandoned, merge request cancelled
79
- */
80
- type MergeRequestStatus = 'pending' | 'processing' | 'merged' | 'conflict' | 'abandoned';
81
- /**
82
- * Merge request record.
83
- *
84
- * Represents a worker's completed work waiting to be merged
85
- * into the integration branch.
86
- */
87
- interface MergeRequest {
88
- /** Unique identifier for the merge request */
89
- id: string;
90
- /** Stream (integration branch) this MR targets */
91
- streamId: string;
92
- /** Dataplane task ID this MR completes */
93
- taskId: string;
94
- /** Git branch containing the worker's changes */
95
- workerBranch: string;
96
- /** Agent ID of the worker that submitted this MR */
97
- workerAgentId: string;
98
- /** Current status of the merge request */
99
- status: MergeRequestStatus;
100
- /** Priority (lower = higher priority, default 100) */
101
- priority: number;
102
- /** Position in queue for manual reordering (null = auto) */
103
- position: number | null;
104
- /** Timestamp when MR was submitted */
105
- submittedAt: number;
106
- /** Timestamp when processing started */
107
- startedAt: number | null;
108
- /** Timestamp when merge completed (or conflict detected) */
109
- completedAt: number | null;
110
- /** Commit hash of the merge commit (when merged) */
111
- mergeCommit: string | null;
112
- /** Files with conflicts (when status = conflict) */
113
- conflictFiles: string[] | null;
114
- /** Task ID of resolver worker (when status = conflict) */
115
- resolverTaskId: string | null;
116
- /** Optional metadata */
117
- metadata: Record<string, unknown>;
118
- }
119
- /**
120
- * Options for submitting a merge request.
121
- */
122
- interface SubmitMergeRequestOptions {
123
- /** Stream (integration branch) to merge into */
124
- streamId: string;
125
- /** Dataplane task ID this completes */
126
- taskId: string;
127
- /** Git branch containing the worker's changes */
128
- workerBranch: string;
129
- /** Agent ID of the worker submitting */
130
- workerAgentId: string;
131
- /** Priority (default: 100) */
132
- priority?: number;
133
- /** Optional metadata */
134
- metadata?: Record<string, unknown>;
135
- }
136
- /**
137
- * Options for listing merge requests.
138
- */
139
- interface ListMergeRequestsOptions {
140
- /** Filter by status */
141
- status?: MergeRequestStatus;
142
- /** Limit number of results */
143
- limit?: number;
144
- }
145
- /**
146
- * MergeQueue event types.
147
- */
148
- type MergeQueueEventType = 'mr:submitted' | 'mr:processing' | 'mr:merged' | 'mr:conflict' | 'mr:abandoned' | 'mr:resolved';
149
- /**
150
- * MergeQueue event payload.
151
- */
152
- interface MergeQueueEvent {
153
- type: MergeQueueEventType;
154
- timestamp: number;
155
- data: Record<string, unknown>;
156
- }
157
- /**
158
- * Callback for merge queue events.
159
- */
160
- type MergeQueueEventCallback = (event: MergeQueueEvent) => void;
161
- /**
162
- * MergeQueue interface.
163
- *
164
- * Coordinates merging of parallel worker branches into the integration branch.
165
- * Workers submit completed work; Integrator processes sequentially.
166
- */
167
- interface MergeQueueInterface {
168
- /**
169
- * Submit a merge request to the queue.
170
- *
171
- * @param options - Submit options
172
- * @returns Merge request ID
173
- */
174
- submit(options: SubmitMergeRequestOptions): string;
175
- /**
176
- * Get the next pending merge request for a stream.
177
- *
178
- * Returns the highest priority (lowest number), oldest pending request.
179
- *
180
- * @param streamId - Stream ID
181
- * @returns Next merge request or null if none pending
182
- */
183
- getNext(streamId: string): MergeRequest | null;
184
- /**
185
- * Mark a merge request as processing.
186
- *
187
- * @param mrId - Merge request ID
188
- */
189
- markProcessing(mrId: string): void;
190
- /**
191
- * Mark a merge request as successfully merged.
192
- *
193
- * @param mrId - Merge request ID
194
- * @param mergeCommit - Commit hash of the merge commit
195
- */
196
- markMerged(mrId: string, mergeCommit: string): void;
197
- /**
198
- * Mark a merge request as having conflicts.
199
- *
200
- * @param mrId - Merge request ID
201
- * @param conflictFiles - List of files with conflicts
202
- * @param resolverTaskId - Optional task ID of resolver worker
203
- */
204
- markConflict(mrId: string, conflictFiles: string[], resolverTaskId?: string): void;
205
- /**
206
- * Mark a merge request as abandoned.
207
- *
208
- * @param mrId - Merge request ID
209
- */
210
- markAbandoned(mrId: string): void;
211
- /**
212
- * Mark a conflicted merge request as resolved and merged.
213
- *
214
- * Called after a resolver worker completes and the integrator
215
- * performs an inline merge of the resolver's branch.
216
- *
217
- * @param mrId - Merge request ID (must be in 'conflict' status)
218
- * @param mergeCommit - Commit hash from the resolver's inline merge
219
- * @param resolverBranch - Branch the resolver worked on (for audit)
220
- */
221
- markResolverComplete(mrId: string, mergeCommit: string, resolverBranch?: string): void;
222
- /**
223
- * Get a merge request by ID.
224
- *
225
- * @param mrId - Merge request ID
226
- * @returns Merge request or null if not found
227
- */
228
- get(mrId: string): MergeRequest | null;
229
- /**
230
- * Get pending merge requests for a stream.
231
- *
232
- * @param streamId - Stream ID
233
- * @param options - List options
234
- * @returns List of pending merge requests
235
- */
236
- getPending(streamId: string, options?: ListMergeRequestsOptions): MergeRequest[];
237
- /**
238
- * Get merge request by task ID.
239
- *
240
- * @param taskId - Task ID
241
- * @returns Merge request or null if not found
242
- */
243
- getByTask(taskId: string): MergeRequest | null;
244
- /**
245
- * Get the number of pending merge requests for a stream.
246
- *
247
- * @param streamId - Stream ID
248
- * @returns Queue depth
249
- */
250
- getQueueDepth(streamId: string): number;
251
- /**
252
- * Reposition a merge request in the queue.
253
- *
254
- * @param mrId - Merge request ID
255
- * @param newPosition - New position (1-indexed)
256
- */
257
- reposition(mrId: string, newPosition: number): void;
258
- /**
259
- * Change the priority of a merge request.
260
- *
261
- * @param mrId - Merge request ID
262
- * @param newPriority - New priority value
263
- */
264
- bumpPriority(mrId: string, newPriority: number): void;
265
- /**
266
- * Subscribe to merge queue events.
267
- *
268
- * @param callback - Event callback
269
- * @returns Unsubscribe function
270
- */
271
- onEvent(callback: MergeQueueEventCallback): () => void;
272
- /**
273
- * Close the merge queue and release resources.
274
- */
275
- close(): void;
276
- }
277
-
278
- /**
279
- * Workspace Types
280
- *
281
- * Types for workspace management, including Workspace, StreamConfig,
282
- * and related interfaces for the WorkspaceManager.
283
- *
284
- * @module workspace/types
285
- * @implements [[s-7ktd]] Workspace types section
286
- */
287
-
288
- /**
289
- * Agent identifier type
290
- */
291
- type AgentId = string;
292
- /**
293
- * Stream identifier type
294
- */
295
- type StreamId = string;
296
- /**
297
- * Task identifier type
298
- */
299
- type TaskId = string;
300
- /**
301
- * Agent role types that require workspaces
302
- */
303
- type WorkspaceRole = 'worker' | 'integrator' | 'coordinator';
304
- /**
305
- * Workspace represents an isolated git worktree assigned to an agent.
306
- *
307
- * @see [[s-7ktd]] Workspace by Role section
308
- */
309
- interface Workspace {
310
- /** Agent that owns this workspace */
311
- agentId: AgentId;
312
- /** Filesystem path to the worktree */
313
- path: string;
314
- /** Branch name in the worktree */
315
- branch: string;
316
- /** Stream (integration branch) this workspace belongs to */
317
- streamId: StreamId;
318
- /** Role of the agent using this workspace */
319
- role: WorkspaceRole;
320
- /** Timestamp when workspace was created */
321
- createdAt: number;
322
- }
323
- /**
324
- * Worker-specific workspace with task information.
325
- *
326
- * @see [[s-7ktd]] Worker Workspace section
327
- */
328
- interface WorkerWorkspace extends Workspace {
329
- role: 'worker';
330
- /** Task assigned to this worker */
331
- taskId: TaskId;
332
- /** Base branch the worker branched from */
333
- baseBranch: string;
334
- }
335
- /**
336
- * Integrator-specific workspace for merge processing.
337
- *
338
- * @see [[s-7ktd]] Integrator Workspace section
339
- */
340
- interface IntegratorWorkspace extends Workspace {
341
- role: 'integrator';
342
- /** Coordinator this integrator serves */
343
- coordinatorId: AgentId;
344
- /** Target integration branch for merges */
345
- integrationBranch: string;
346
- }
347
- /**
348
- * Coordinator-specific workspace on the integration branch.
349
- *
350
- * @see [[s-7ktd]] Coordinator Workspace section
351
- */
352
- interface CoordinatorWorkspace extends Workspace {
353
- role: 'coordinator';
354
- /** Paths to child workspaces for visibility */
355
- childWorkspacePaths: Map<AgentId, string>;
356
- }
357
- /**
358
- * Configuration for creating an integration stream.
359
- */
360
- interface StreamConfig {
361
- /** Name for the stream (used in branch naming) */
362
- name: string;
363
- /** Branch to fork from (default: 'main') */
364
- forkFrom?: string;
365
- /** Optional metadata to attach to the stream */
366
- metadata?: Record<string, unknown>;
367
- }
368
- /**
369
- * Options for creating a task.
370
- */
371
- interface CreateTaskOptions$1 {
372
- /** Title/description of the task */
373
- title: string;
374
- /** Priority level (lower = higher priority) */
375
- priority?: number;
376
- /** Optional metadata */
377
- metadata?: Record<string, unknown>;
378
- }
379
- /**
380
- * WorkspaceManager interface for managing agent workspaces.
381
- *
382
- * Bridges macro-agent roles to dataplane streams and worktrees.
383
- *
384
- * @see [[s-7ktd]] WorkspaceManager API section
385
- */
386
- interface WorkspaceManager {
387
- /**
388
- * Create an integration stream for a coordinator.
389
- *
390
- * @param coordinatorId - ID of the coordinator agent
391
- * @param config - Stream configuration
392
- * @returns Stream ID
393
- */
394
- createIntegrationStream(coordinatorId: AgentId, config: StreamConfig): StreamId;
395
- /**
396
- * Get a stream by ID.
397
- *
398
- * @param streamId - Stream ID
399
- * @returns Stream or null if not found
400
- */
401
- getStream(streamId: StreamId): Stream | null;
402
- /**
403
- * Create a workspace for a worker agent.
404
- *
405
- * @param workerId - ID of the worker agent
406
- * @param taskId - ID of the task to work on
407
- * @param streamId - ID of the integration stream
408
- * @returns Worker workspace
409
- */
410
- createWorkerWorkspace(workerId: AgentId, taskId: TaskId, streamId: StreamId): WorkerWorkspace;
411
- /**
412
- * Create a workspace for an integrator agent.
413
- *
414
- * @param integratorId - ID of the integrator agent
415
- * @param streamId - ID of the integration stream
416
- * @returns Integrator workspace
417
- */
418
- createIntegratorWorkspace(integratorId: AgentId, streamId: StreamId): IntegratorWorkspace;
419
- /**
420
- * Create a workspace for a coordinator agent.
421
- *
422
- * @param coordinatorId - ID of the coordinator agent
423
- * @param streamId - ID of the integration stream
424
- * @returns Coordinator workspace
425
- */
426
- createCoordinatorWorkspace(coordinatorId: AgentId, streamId: StreamId): CoordinatorWorkspace;
427
- /**
428
- * Deallocate a workspace and release resources.
429
- *
430
- * @param agentId - ID of the agent whose workspace to deallocate
431
- */
432
- deallocateWorkspace(agentId: AgentId): void;
433
- /**
434
- * Create a task under a stream.
435
- *
436
- * @param streamId - ID of the integration stream
437
- * @param options - Task creation options
438
- * @returns Task ID
439
- */
440
- createTask(streamId: StreamId, options: CreateTaskOptions$1): TaskId;
441
- /**
442
- * Claim a task for a worker.
443
- *
444
- * @param taskId - ID of the task to claim
445
- * @param workerId - ID of the worker agent
446
- * @param worktree - Path to the worker's worktree
447
- * @returns Start task result with branch info
448
- */
449
- claimTask(taskId: TaskId, workerId: AgentId, worktree: string): StartTaskResult;
450
- /**
451
- * Get the next available task for a stream.
452
- *
453
- * @param streamId - ID of the integration stream
454
- * @returns Next task or null if none available
455
- */
456
- getNextTask(streamId: StreamId): WorkerTask | null;
457
- /**
458
- * Get workspace for an agent.
459
- *
460
- * @param agentId - ID of the agent
461
- * @returns Workspace or null if not found
462
- */
463
- getWorkspace(agentId: AgentId): Workspace | null;
464
- /**
465
- * Get the stream ID for an agent.
466
- *
467
- * @param agentId - ID of the agent
468
- * @returns Stream ID or null if not found
469
- */
470
- getStreamForAgent(agentId: AgentId): StreamId | null;
471
- /**
472
- * Register a child workspace path with a coordinator.
473
- *
474
- * @param coordinatorId - ID of the coordinator
475
- * @param childId - ID of the child agent
476
- * @param childPath - Filesystem path to child's workspace
477
- */
478
- registerChildWorkspace(coordinatorId: AgentId, childId: AgentId, childPath: string): void;
479
- /**
480
- * Get the merge queue for coordinating worker merges.
481
- *
482
- * The merge queue is shared across all streams and uses the same
483
- * database as the dataplane adapter.
484
- *
485
- * @returns MergeQueue instance
486
- */
487
- getMergeQueue(): MergeQueueInterface;
488
- /**
489
- * Close the workspace manager and release resources.
490
- */
491
- close(): void;
492
- }
493
-
494
- /**
495
- * AgentManager type definitions
496
- */
497
-
498
- /**
499
- * Options for spawning a new agent
500
- */
501
- interface SpawnAgentOptions {
502
- /** Task description for the agent */
503
- task: string;
504
- /** Optional task ID (auto-generated if not provided) */
505
- task_id?: TaskId$1;
506
- /** Parent agent ID (null for head managers) */
507
- parent?: AgentId$1 | null;
508
- /** Working directory for the agent */
509
- cwd?: string;
510
- /** Permission mode for tool calls */
511
- permissionMode?: PermissionMode;
512
- /** Whether parent should subscribe to this agent's subtree */
513
- subscribeParent?: boolean;
514
- /** Additional topics for the agent to subscribe to */
515
- topics?: string[];
516
- /** Custom configuration passed to agent */
517
- config?: AgentConfig;
518
- /** Optional agent type (defaults to "claude-code") */
519
- agentType?: string;
520
- /**
521
- * Custom prompt content injected as the role instructions section.
522
- * When set, replaces resolvedRole.systemPrompt in prompt assembly.
523
- * Used by team templates to provide static role prompts.
524
- */
525
- customPrompt?: string;
526
- /**
527
- * Interaction pattern sections to append after the role prompt.
528
- * Auto-generated by TeamRuntime based on team config (pull mode, etc.).
529
- */
530
- interactionPatterns?: string[];
531
- /**
532
- * Agent role name (e.g., 'worker', 'coordinator', 'integrator', 'monitor').
533
- * If not provided, role is inferred from parent presence.
534
- */
535
- role?: string;
536
- /** Team instance ID this agent belongs to (set by TeamManager interceptor) */
537
- team_instance?: string;
538
- /**
539
- * Stream ID to join (for workers and integrators).
540
- * Required for workers and integrators when using workspace isolation.
541
- */
542
- streamId?: StreamId;
543
- /**
544
- * Stream configuration for creating a new integration stream.
545
- * Used by coordinators to create their integration branch.
546
- */
547
- streamConfig?: StreamConfig;
548
- /**
549
- * Dataplane task ID to claim (for workers).
550
- * If provided, the worker will claim this task and work on it.
551
- */
552
- dataplaneTaskId?: string;
553
- /**
554
- * Resolved capabilities for this agent's role.
555
- * Injected by TeamRuntime spawn interceptor for capability-based workspace dispatch.
556
- */
557
- capabilities?: string[];
558
- }
559
- /**
560
- * Options for continuing a terminated agent
561
- */
562
- interface ContinueAgentOptions {
563
- /** Maximum number of conversation turns to include in context (default: 50) */
564
- maxMessages?: number;
565
- /** Override the task description for the continuation */
566
- task?: string;
567
- /** Additional context to prepend to the continuation prompt */
568
- additionalContext?: string;
569
- }
570
- /**
571
- * Custom agent configuration
572
- */
573
- interface AgentConfig {
574
- /** Model to use (if configurable) */
575
- model?: string;
576
- /** Maximum tokens per response */
577
- maxTokens?: number;
578
- /** Temperature for responses */
579
- temperature?: number;
580
- /** Additional environment variables */
581
- env?: Record<string, string>;
582
- /** MCP servers to connect */
583
- mcpServers?: MCPServerConfig[];
584
- }
585
- /**
586
- * MCP server configuration
587
- */
588
- interface MCPServerConfig {
589
- name: string;
590
- command: string;
591
- args?: string[];
592
- env?: Record<string, string>;
593
- }
594
- /**
595
- * Result of spawning an agent
596
- */
597
- interface SpawnedAgent {
598
- /** Agent ID */
599
- id: AgentId$1;
600
- /** Session ID from acp-factory */
601
- session_id: string;
602
- /** Agent state from materialized view */
603
- agent: Agent;
604
- /** Active session for interaction */
605
- session: Session;
606
- /** Workspace assigned to the agent (if any) */
607
- workspace?: Workspace;
608
- /** Stream ID the agent belongs to (if any) */
609
- streamId?: StreamId;
610
- }
611
- /**
612
- * Filter options for listing agents
613
- */
614
- interface AgentFilter {
615
- /** Filter by state */
616
- state?: AgentState;
617
- /** Filter by parent */
618
- parent?: AgentId$1 | null;
619
- /** Filter by task ID */
620
- task_id?: TaskId$1;
621
- /** Only head managers (no parent) */
622
- headManagersOnly?: boolean;
623
- }
624
- /**
625
- * Agent hierarchy node
626
- */
627
- interface AgentHierarchyNode {
628
- agent: Agent;
629
- children: AgentHierarchyNode[];
630
- }
631
- /**
632
- * Full agent hierarchy from root
633
- */
634
- interface AgentHierarchy {
635
- root: AgentHierarchyNode;
636
- depth: number;
637
- totalAgents: number;
638
- }
639
- /**
640
- * Options for getHierarchy
641
- */
642
- interface HierarchyOptions {
643
- /** Maximum depth to traverse (undefined = full tree) */
644
- depth?: number;
645
- }
646
- /**
647
- * Active session info tracked in memory
648
- */
649
- interface ActiveSession {
650
- /** Agent ID */
651
- agentId: AgentId$1;
652
- /** acp-factory agent handle (process) */
653
- handle: AgentHandle;
654
- /** acp-factory session */
655
- session: Session;
656
- /** When the session was created */
657
- createdAt: Timestamp;
658
- /** Whether session is currently prompting */
659
- isPrompting: boolean;
660
- }
661
- /**
662
- * Stop reason for agent termination
663
- * Named AgentStopReason to avoid conflict with ACP SDK's StopReason
664
- */
665
- type AgentStopReason = "completed" | "failed" | "cancelled" | "timeout" | "parent_stopped" | "system";
666
- /**
667
- * Options for creating a head manager
668
- */
669
- interface HeadManagerOptions {
670
- /** Working directory */
671
- cwd: string;
672
- /** Optional custom system prompt */
673
- systemPrompt?: string;
674
- /** Permission mode */
675
- permissionMode?: PermissionMode;
676
- /** Initial topics to subscribe to */
677
- topics?: string[];
678
- /** Resume a specific session by ID */
679
- sessionId?: string;
680
- /** Force creation of a new session, ignoring existing ones */
681
- forceNew?: boolean;
682
- }
683
- /**
684
- * Context for generating system prompts
685
- */
686
- interface SystemPromptContext {
687
- /** Agent ID */
688
- agentId: AgentId$1;
689
- /** Task description */
690
- task: string;
691
- /** Task ID if assigned */
692
- taskId?: TaskId$1;
693
- /** Parent agent ID */
694
- parentId?: AgentId$1 | null;
695
- /** Whether this is a head manager */
696
- isHeadManager: boolean;
697
- /** Agent lineage (ancestors) */
698
- lineage: AgentId$1[];
699
- /** Available MCP tools */
700
- mcpTools?: string[];
701
- /** Agent role name (e.g., 'worker', 'coordinator') */
702
- role?: string;
703
- /** Workspace assigned to the agent */
704
- workspace?: Workspace;
705
- /** Stream ID the agent belongs to */
706
- streamId?: StreamId;
707
- }
708
- /**
709
- * Agent lifecycle events (for callbacks)
710
- */
711
- type AgentLifecycleEvent = {
712
- type: "spawned";
713
- agent: Agent;
714
- } | {
715
- type: "started";
716
- agent: Agent;
717
- } | {
718
- type: "stopped";
719
- agent: Agent;
720
- reason: AgentStopReason;
721
- } | {
722
- type: "status";
723
- agent: Agent;
724
- status: string;
725
- };
726
- /**
727
- * Callback for agent lifecycle events
728
- */
729
- type AgentLifecycleCallback = (event: AgentLifecycleEvent) => void;
730
- /**
731
- * Agent manager error
732
- */
733
- declare class AgentManagerError extends Error {
734
- readonly code: AgentManagerErrorCode;
735
- readonly agentId?: AgentId$1 | undefined;
736
- constructor(message: string, code: AgentManagerErrorCode, agentId?: AgentId$1 | undefined);
737
- }
738
- type AgentManagerErrorCode = "AGENT_NOT_FOUND" | "SESSION_NOT_FOUND" | "SPAWN_FAILED" | "ALREADY_RUNNING" | "NOT_RUNNING" | "INVALID_STATE" | "PERMISSION_DENIED" | "CAPABILITY_DENIED" | "SHUTDOWN_IN_PROGRESS" | "FORK_NOT_SUPPORTED";
739
-
740
- /**
741
- * Role System Type Definitions
742
- *
743
- * Implements the composable role system from s-60tc:
744
- * - Capability-based permissions
745
- * - Enforcement mechanisms (workspace, tools, lifecycle, protocol, permissions)
746
- * - Role definition and registry interfaces
747
- */
748
- /** File operation capabilities */
749
- type FileCapability = "file.read" | "file.write" | "file.delete";
750
- /** Git operation capabilities */
751
- type GitCapability = "git.commit" | "git.merge" | "git.push" | "git.branch.create" | "git.branch.delete";
752
- /** Agent management capabilities */
753
- type AgentCapability = "agent.spawn.worker" | "agent.spawn.integrator" | "agent.spawn.monitor" | "agent.spawn.custom" | "agent.terminate";
754
- /** Lifecycle capabilities */
755
- type LifecycleCapability = "lifecycle.done" | "lifecycle.persistent" | "lifecycle.daemon";
756
- /** Task management capabilities (via TaskBackend, see s-8472) */
757
- type TaskCapability = "task.create" | "task.assign" | "task.update" | "task.close" | "task.claim";
758
- /** Execution capabilities */
759
- type ExecCapability = "exec.command" | "exec.build" | "exec.test" | "exec.lint";
760
- /** Communication capabilities */
761
- type MsgCapability = "msg.send" | "msg.broadcast" | "msg.subscribe";
762
- /** Workspace capabilities */
763
- type WorkspaceCapability = "workspace.worktree" | "workspace.stream" | "workspace.integrate";
764
- /** All capability types combined, plus wildcard */
765
- type Capability = FileCapability | GitCapability | AgentCapability | LifecycleCapability | TaskCapability | ExecCapability | MsgCapability | WorkspaceCapability | "*";
766
- /**
767
- * Workspace Enforcement
768
- * Controls filesystem access and isolation.
769
- */
770
- interface WorkspaceEnforcement {
771
- /** Workspace type */
772
- type: "own" | "shared" | "mount" | "none";
773
- /** For 'own' type: branch naming pattern */
774
- branchPattern?: string;
775
- /** For 'own' type: cleanup workspace on agent termination */
776
- cleanupOnTerminate?: boolean;
777
- /** For 'own' type: can read child workspace paths (Coordinator) */
778
- canViewChildWorkspaces?: boolean;
779
- /** For 'shared' type: role names to share with */
780
- sharedWith?: string[];
781
- /** For 'mount' type: branch/path to mount */
782
- mountTarget?: string;
783
- /** For 'mount' type: read-only access */
784
- readonly?: boolean;
785
- }
786
- /**
787
- * Tool Enforcement
788
- * Controls which MCP tools are available.
789
- */
790
- interface ToolEnforcement {
791
- /** Mode for tool filtering */
792
- mode: "capability" | "allowlist" | "denylist" | "all";
793
- /** For allowlist/denylist modes: explicit tool names */
794
- tools?: string[];
795
- }
796
- /**
797
- * Lifecycle Enforcement
798
- * Controls agent lifecycle behavior.
799
- */
800
- interface LifecycleEnforcement {
801
- /** Lifecycle type */
802
- type: "ephemeral" | "persistent" | "daemon" | "event-driven";
803
- /** For ephemeral: terminate when task completes */
804
- taskBound?: boolean;
805
- /** For ephemeral: timeout in milliseconds (default: 30 min for workers) */
806
- maxDurationMs?: number;
807
- /** For event-driven: terminate when parent terminates */
808
- parentBound?: boolean;
809
- /** For all types: terminate children on done */
810
- cascadeTerminate?: boolean;
811
- /** For all types: clean own workspace on done */
812
- selfCleanup?: boolean;
813
- }
814
- /**
815
- * Protocol Enforcement
816
- * Controls message routing and subscriptions.
817
- */
818
- interface ProtocolEnforcement {
819
- /** Message patterns to receive */
820
- subscriptions: string[];
821
- /** Message patterns allowed to send */
822
- canEmit: string[];
823
- }
824
- /**
825
- * Capability restriction for fine-grained control
826
- */
827
- interface CapabilityRestriction {
828
- /** Scope restriction (e.g., "own-workspace" vs "any") */
829
- scope?: string;
830
- /** Rate limit (max calls per minute) */
831
- rateLimit?: number;
832
- /** Requires human approval */
833
- requireApproval?: boolean;
834
- }
835
- /**
836
- * Permission Enforcement
837
- * Controls capability-level permissions with optional restrictions.
838
- */
839
- interface PermissionEnforcement {
840
- /** List of capability IDs */
841
- capabilities: Capability[];
842
- /** Optional restrictions on capabilities */
843
- restrictions?: Record<string, CapabilityRestriction>;
844
- }
845
- /**
846
- * Role Definition
847
- * Combines capabilities with enforcement mechanisms.
848
- */
849
- interface RoleDefinition {
850
- /** Unique role identifier (supports dot-notation like 'worker.resolver') */
851
- name: string;
852
- /** Human-readable name */
853
- displayName?: string;
854
- /** Role purpose description */
855
- description?: string;
856
- /** List of capability IDs */
857
- capabilities: Capability[];
858
- /** Workspace enforcement configuration */
859
- workspace?: WorkspaceEnforcement;
860
- /** Tool enforcement configuration */
861
- tools?: ToolEnforcement;
862
- /** Lifecycle enforcement configuration */
863
- lifecycle?: LifecycleEnforcement;
864
- /** Protocol enforcement configuration */
865
- protocol?: ProtocolEnforcement;
866
- /** Permission enforcement configuration */
867
- permissions?: PermissionEnforcement;
868
- /** Inherit from another role */
869
- extends?: string;
870
- /** Role-specific system prompt */
871
- systemPrompt?: string;
872
- /** Path to prompt template file */
873
- promptTemplate?: string;
874
- }
875
- /**
876
- * Role Configuration
877
- * Extends RoleDefinition with override behavior for configuration files.
878
- */
879
- interface RoleConfig extends RoleDefinition {
880
- /** Override behavior (only for roles matching built-in names) */
881
- override?: "replace" | "merge";
882
- }
883
- /**
884
- * Role Registry Interface
885
- * Manages role definitions with layered resolution.
886
- */
887
- interface RoleRegistry {
888
- /** Get a role by name (exact match, no inheritance) */
889
- getRole(name: string): RoleDefinition | undefined;
890
- /** Register a role definition */
891
- registerRole(role: RoleDefinition): void;
892
- /** List all registered roles */
893
- listRoles(): RoleDefinition[];
894
- /** Resolve a role with inheritance and fallback */
895
- resolveRole(name: string): RoleDefinition;
896
- /** Check if a role has a specific capability */
897
- hasCapability(roleName: string, capability: Capability): boolean;
898
- }
899
-
900
- /**
901
- * AgentStore — Minimal SQLite store for agent lifecycle and session state.
902
- *
903
- * Replaces the heavy EventStore + TinyBase materialized views with
904
- * simple CRUD on two tables: agents and sessions.
905
- *
906
- * @module agent/agent-store
907
- */
908
-
909
- /**
910
- * Agent record stored in SQLite. Minimal lifecycle state only —
911
- * messages live in agent-inbox, tasks live in opentasks.
912
- */
913
- interface AgentRecord {
914
- id: AgentId$1;
915
- name?: string;
916
- role: string;
917
- state: AgentState;
918
- stop_reason?: StopReason;
919
- parent_id: AgentId$1 | null;
920
- lineage: AgentId$1[];
921
- team?: string;
922
- scope: string;
923
- task: string;
924
- task_id?: string;
925
- cwd: string;
926
- capabilities: string[];
927
- workspace_path?: string;
928
- workspace_stream_id?: string;
929
- config?: Record<string, unknown>;
930
- metadata?: Record<string, unknown>;
931
- created_at: Timestamp;
932
- started_at?: Timestamp;
933
- stopped_at?: Timestamp;
934
- last_activity_at?: Timestamp;
935
- }
936
- /**
937
- * Session record mapping agent IDs to acp-factory sessions.
938
- */
939
- interface SessionRecord {
940
- agent_id: AgentId$1;
941
- session_id: SessionId;
942
- provider_session_id?: string;
943
- created_at: Timestamp;
944
- }
945
- /**
946
- * Filter options for listing agents.
947
- */
948
- interface AgentStoreFilter {
949
- state?: AgentState;
950
- role?: string;
951
- team?: string;
952
- parent_id?: AgentId$1 | null;
953
- scope?: string;
954
- }
955
- type ChangeCallback = (event: {
956
- type: "put" | "update" | "remove";
957
- agentId: string;
958
- }) => void;
959
- declare class AgentStore {
960
- private db;
961
- private changeListeners;
962
- constructor(dbPath?: string);
963
- /**
964
- * Subscribe to agent store changes. Returns an unsubscribe function.
965
- */
966
- onChange(callback: ChangeCallback): () => void;
967
- private notifyChange;
968
- putAgent(agent: AgentRecord): void;
969
- getAgent(id: AgentId$1): AgentRecord | null;
970
- listAgents(filter?: AgentStoreFilter): AgentRecord[];
971
- updateAgent(id: AgentId$1, updates: Partial<AgentRecord>): void;
972
- removeAgent(id: AgentId$1): void;
973
- getChildren(parentId: AgentId$1): AgentRecord[];
974
- getDescendants(agentId: AgentId$1): AgentRecord[];
975
- getAncestors(agentId: AgentId$1): AgentRecord[];
976
- putSession(session: SessionRecord): void;
977
- getSession(agentId: AgentId$1): SessionRecord | null;
978
- removeSession(agentId: AgentId$1): void;
979
- close(): void;
980
- /** Get the underlying database (for advanced use / testing). */
981
- get database(): Database.Database;
982
- private rowToAgent;
983
- }
984
-
985
- /**
986
- * Adapter interfaces for subsystem integration.
987
- *
988
- * InboxAdapter wraps agent-inbox for messaging.
989
- * TasksAdapter wraps opentasks for task management.
990
- *
991
- * These are the only two touch points between macro-agent
992
- * and the external subsystems.
993
- *
994
- * @module adapters/types
995
- */
996
-
997
- /**
998
- * Event emitted when a message is delivered to an agent's inbox.
999
- */
1000
- interface InboxDeliveryEvent {
1001
- /** Recipient agent ID */
1002
- agentId: string;
1003
- /** Recipient kind (to, cc, bcc) */
1004
- recipientKind: "to" | "cc" | "bcc";
1005
- /** The delivered message */
1006
- message: Message;
1007
- }
1008
- /**
1009
- * Signal filter: returns false to suppress delivery to a specific agent.
1010
- * Used by TeamRuntime to enforce subscription-based signal filtering.
1011
- */
1012
- type SignalFilterFn = (from: string, to: string, message: Message) => boolean;
1013
- /**
1014
- * Emission validator: returns a rejection reason string to block the send,
1015
- * or null to allow it. Used by TeamRuntime to enforce per-role emission rules.
1016
- */
1017
- type EmissionValidatorFn = (from: string, message: Message) => string | null;
1018
- /**
1019
- * Options for registering an agent with agent-inbox.
1020
- */
1021
- interface RegisterAgentOptions {
1022
- name?: string;
1023
- role: string;
1024
- scope: string;
1025
- metadata?: Record<string, unknown>;
1026
- }
1027
- /**
1028
- * Options for sending a message through agent-inbox.
1029
- */
1030
- interface SendMessageOptions {
1031
- threadTag?: string;
1032
- importance?: Importance;
1033
- scope?: string;
1034
- subject?: string;
1035
- inReplyTo?: string;
1036
- }
1037
- /**
1038
- * Delivery event handler callback.
1039
- */
1040
- type DeliveryHandler = (event: InboxDeliveryEvent) => void;
1041
- /**
1042
- * InboxAdapter — macro-agent's interface to agent-inbox.
1043
- *
1044
- * Owns adapter-side signal filtering and emission validation.
1045
- * Embeds agent-inbox in-process for zero-latency event access,
1046
- * with IPC server running for agent MCP subprocesses.
1047
- */
1048
- interface InboxAdapter {
1049
- /** Register an agent in agent-inbox's storage and warm registry. */
1050
- registerAgent(agentId: string, opts: RegisterAgentOptions): Promise<void>;
1051
- /** Deregister an agent (set status to offline). */
1052
- deregisterAgent(agentId: string): Promise<void>;
1053
- /**
1054
- * Send a message. Emission validation runs before forwarding
1055
- * to agent-inbox. Returns the message ID on success.
1056
- *
1057
- * @throws if emission validator rejects the send.
1058
- */
1059
- send(from: string, to: string | string[], content: MessageContent | string, opts?: SendMessageOptions): Promise<string>;
1060
- /**
1061
- * Subscribe to delivery events. Signal filtering runs before
1062
- * invoking the handler — filtered messages are silently dropped.
1063
- */
1064
- onDelivery(handler: DeliveryHandler): void;
1065
- /** Remove a delivery handler. */
1066
- offDelivery(handler: DeliveryHandler): void;
1067
- /** Check an agent's inbox. */
1068
- checkInbox(agentId: string, opts?: {
1069
- unreadOnly?: boolean;
1070
- limit?: number;
1071
- }): Promise<Message[]>;
1072
- /** Read a message thread by tag. */
1073
- readThread(threadTag: string, scope?: string): Promise<Message[]>;
1074
- /** Install a signal filter (replaces any existing filter). */
1075
- setSignalFilter(filter: SignalFilterFn): void;
1076
- /** Install an emission validator (replaces any existing validator). */
1077
- setEmissionValidator(validator: EmissionValidatorFn): void;
1078
- /** Add a named signal filter (for multi-team). */
1079
- addSignalFilter(id: string, filter: SignalFilterFn): void;
1080
- /** Remove a named signal filter. */
1081
- removeSignalFilter(id: string): void;
1082
- /** Add a named emission validator (for multi-team). */
1083
- addEmissionValidator(id: string, validator: EmissionValidatorFn): void;
1084
- /** Remove a named emission validator. */
1085
- removeEmissionValidator(id: string): void;
1086
- /** The IPC socket path for agent subprocesses to connect to. */
1087
- readonly socketPath: string;
1088
- /** Stop the embedded agent-inbox (IPC server, storage, etc.). */
1089
- stop(): Promise<void>;
1090
- }
1091
- /**
1092
- * Task status values used by macro-agent.
1093
- * Maps to opentasks canonical statuses.
1094
- */
1095
- type TaskStatus = "open" | "in_progress" | "blocked" | "closed";
1096
- /**
1097
- * Semantic actions for task state transitions.
1098
- */
1099
- type TaskAction = "start" | "complete" | "fail" | "block" | "reopen";
1100
- /**
1101
- * Options for creating a task.
1102
- */
1103
- interface CreateTaskOptions {
1104
- title: string;
1105
- content?: string;
1106
- assignee?: string;
1107
- parent?: string;
1108
- tags?: string[];
1109
- priority?: number;
1110
- }
1111
- /**
1112
- * Options for querying tasks.
1113
- */
1114
- interface TaskQueryOptions {
1115
- status?: TaskStatus;
1116
- assignee?: string;
1117
- tags?: string[];
1118
- limit?: number;
1119
- }
1120
- /**
1121
- * Simplified task record returned by the adapter.
1122
- * Flattened from opentasks' graph node model.
1123
- */
1124
- interface TaskRecord {
1125
- id: string;
1126
- title: string;
1127
- content?: string;
1128
- status: TaskStatus;
1129
- assignee?: string;
1130
- parent?: string;
1131
- tags?: string[];
1132
- priority?: number;
1133
- claimed_by?: string;
1134
- created_at?: string;
1135
- closed_at?: string;
1136
- metadata?: Record<string, unknown>;
1137
- }
1138
- /**
1139
- * TasksAdapter — macro-agent's interface to opentasks.
1140
- *
1141
- * Wraps OpenTasksClient via IPC to the opentasks daemon.
1142
- * macro-agent ensures the daemon is running at boot.
1143
- */
1144
- interface TasksAdapter {
1145
- /** Create a new task. Returns the task ID. */
1146
- createTask(opts: CreateTaskOptions): Promise<string>;
1147
- /** Assign a task to an agent. */
1148
- assignTask(taskId: string, agentId: string): Promise<void>;
1149
- /** Transition a task to a new state via semantic action. */
1150
- transitionTask(taskId: string, action: TaskAction): Promise<void>;
1151
- /** Get a single task by ID. */
1152
- getTask(taskId: string): Promise<TaskRecord>;
1153
- /** Query tasks ready to work on (no active blockers). */
1154
- queryReady(opts?: {
1155
- tags?: string[];
1156
- limit?: number;
1157
- }): Promise<TaskRecord[]>;
1158
- /** List tasks with optional filters. */
1159
- listTasks(filter?: TaskQueryOptions): Promise<TaskRecord[]>;
1160
- /** Add a blocking dependency: blockerId blocks taskId. */
1161
- addBlocker(taskId: string, blockerId: string): Promise<void>;
1162
- /** Remove a blocking dependency. */
1163
- removeBlocker(taskId: string, blockerId: string): Promise<void>;
1164
- /** Claim the next available task matching the filter. */
1165
- claimTask(agentId: string, filter?: {
1166
- tags?: string[];
1167
- }): Promise<TaskRecord | null>;
1168
- /** Release a claimed task back to the pool. */
1169
- unclaimTask(taskId: string): Promise<void>;
1170
- /** List tasks available for claiming. */
1171
- listClaimable(filter?: {
1172
- tags?: string[];
1173
- limit?: number;
1174
- }): Promise<TaskRecord[]>;
1175
- /** Connect to the opentasks daemon. Auto-starts if needed. */
1176
- connect(): Promise<void>;
1177
- /** Disconnect from the opentasks daemon. */
1178
- disconnect(): void;
1179
- /** Whether the adapter is connected to the daemon. */
1180
- readonly connected: boolean;
1181
- }
1182
-
1183
- /**
1184
- * AgentManager - Interface and types for managing agent lifecycle and sessions
1185
- *
1186
- * The V1 implementation has been removed. The V2 implementation lives in
1187
- * agent-manager-v2.ts and is wired via boot-v2.ts.
1188
- *
1189
- * This file retains:
1190
- * - The AgentManager interface (used everywhere)
1191
- * - The AgentManagerConfig interface
1192
- * - The SpawnInterceptor type
1193
- * - A re-export of createAgentManagerV2 as createAgentManager for backward compat
1194
- */
1195
-
1196
- interface AgentManager {
1197
- /**
1198
- * Spawn a new agent with the given options.
1199
- * Creates the acp-factory session and emits spawn event.
1200
- */
1201
- spawn(options: SpawnAgentOptions): Promise<SpawnedAgent>;
1202
- /**
1203
- * Terminate an agent and clean up its session.
1204
- * Emits terminate event and updates task status if assigned.
1205
- */
1206
- terminate(agentId: AgentId$1, reason: AgentStopReason): Promise<void>;
1207
- /**
1208
- * Resume a stopped agent by loading its existing session.
1209
- * @param permissionMode - Optional permission mode override (defaults to the agent manager's default)
1210
- */
1211
- resume(agentId: AgentId$1, permissionMode?: PermissionMode): Promise<SpawnedAgent>;
1212
- /**
1213
- * Continue a terminated agent by spawning a new agent with the same
1214
- * role and task, injecting the prior conversation context as a
1215
- * resume prefix in the system prompt.
1216
- *
1217
- * @param agentId - ID of the agent to continue
1218
- * @param options - Continuation options
1219
- * @returns The newly spawned continuation agent
1220
- */
1221
- continueAgent(agentId: AgentId$1, options?: ContinueAgentOptions): Promise<SpawnedAgent>;
1222
- /**
1223
- * Fork an agent's session, creating a new agent with the same
1224
- * conversation history. Uses forkWithFlush for active sessions
1225
- * or loadSession for stopped agents with persisted sessions.
1226
- *
1227
- * @param sourceAgentId - ID of the agent to fork from
1228
- * @param options - Fork options (name, prompt, cwd)
1229
- */
1230
- forkAgent(sourceAgentId: AgentId$1, options?: {
1231
- name?: string;
1232
- prompt?: string;
1233
- cwd?: string;
1234
- }): Promise<SpawnedAgent>;
1235
- /**
1236
- * Get agent by ID from materialized view.
1237
- */
1238
- get(agentId: AgentId$1): Agent | null;
1239
- /**
1240
- * List agents with optional filters.
1241
- */
1242
- list(filter?: AgentFilter): Agent[];
1243
- /**
1244
- * Get direct children of an agent.
1245
- */
1246
- getChildren(agentId: AgentId$1): Agent[];
1247
- /**
1248
- * Get full hierarchy tree starting from an agent.
1249
- * @param options.depth - Maximum depth to traverse (undefined = full tree)
1250
- */
1251
- getHierarchy(agentId: AgentId$1, options?: HierarchyOptions): AgentHierarchy | null;
1252
- /**
1253
- * Get or create a head manager for the given workspace.
1254
- * Head managers are root agents with no parent.
1255
- */
1256
- getOrCreateHeadManager(options: HeadManagerOptions): Promise<SpawnedAgent>;
1257
- /**
1258
- * List all head managers.
1259
- */
1260
- listHeadManagers(): Agent[];
1261
- /**
1262
- * Send a prompt to an agent and stream responses.
1263
- */
1264
- prompt(agentId: AgentId$1, message: string): AsyncIterable<ExtendedSessionUpdate>;
1265
- /**
1266
- * Send a prompt to an agent and automatically follow up to ensure done() is called.
1267
- * Returns when the agent calls done() or after maxFollowUps attempts.
1268
- *
1269
- * @param agentId - Agent ID to prompt
1270
- * @param message - Initial prompt message
1271
- * @param options - Follow-up options
1272
- * @returns Result indicating whether done() was called
1273
- */
1274
- promptUntilDone(agentId: AgentId$1, message: string, options?: {
1275
- /** Maximum number of follow-up prompts (default: 2) */
1276
- maxFollowUps?: number;
1277
- /** Callback for each update during prompting */
1278
- onUpdate?: (update: ExtendedSessionUpdate) => void;
1279
- }): Promise<{
1280
- doneCalled: boolean;
1281
- doneStatus?: string;
1282
- updates: ExtendedSessionUpdate[];
1283
- }>;
1284
- /**
1285
- * Get the active session for an agent.
1286
- */
1287
- getSession(agentId: AgentId$1): Session | null;
1288
- /**
1289
- * Check if an agent has an active session.
1290
- */
1291
- hasActiveSession(agentId: AgentId$1): boolean;
1292
- /**
1293
- * Check if an agent is currently processing a prompt.
1294
- * Returns false if no session or session is idle.
1295
- */
1296
- isPrompting(agentId: AgentId$1): boolean;
1297
- /**
1298
- * Check if an agent's session supports context injection.
1299
- * Returns false if no session or injection not supported.
1300
- */
1301
- supportsInjection(agentId: AgentId$1): Promise<boolean>;
1302
- /**
1303
- * Check if an agent's underlying process is still running.
1304
- * Returns false if no session or process has exited.
1305
- */
1306
- isProcessRunning(agentId: AgentId$1): boolean;
1307
- /**
1308
- * Respond to a permission request for an agent's session.
1309
- * Used when running in interactive permission mode.
1310
- *
1311
- * @param agentId - Agent ID whose session has the pending permission
1312
- * @param requestId - The permission request ID
1313
- * @param optionId - The selected option ID (e.g., 'allow_once')
1314
- * @returns true if permission was found and responded to
1315
- */
1316
- respondToPermission(agentId: AgentId$1, requestId: string, optionId: string): boolean;
1317
- /**
1318
- * Cancel a permission request for an agent's session.
1319
- *
1320
- * @param agentId - Agent ID whose session has the pending permission
1321
- * @param requestId - The permission request ID
1322
- * @returns true if permission was found and cancelled
1323
- */
1324
- cancelPermission(agentId: AgentId$1, requestId: string): boolean;
1325
- /**
1326
- * Change the permission mode for a running agent at runtime.
1327
- * Takes effect on the next permission request.
1328
- *
1329
- * @param agentId - Agent ID to change permission mode for
1330
- * @param mode - New permission mode
1331
- * @returns true if the mode was changed successfully
1332
- */
1333
- setPermissionMode(agentId: AgentId$1, mode: PermissionMode): boolean;
1334
- /**
1335
- * Get the current permission mode for a running agent.
1336
- *
1337
- * @param agentId - Agent ID to query
1338
- * @returns The current permission mode, or null if no active session
1339
- */
1340
- getPermissionMode(agentId: AgentId$1): PermissionMode | null;
1341
- /**
1342
- * Register a callback for agent lifecycle events.
1343
- */
1344
- onLifecycleEvent(callback: AgentLifecycleCallback): () => void;
1345
- /**
1346
- * Set a spawn interceptor that transforms SpawnAgentOptions before spawning.
1347
- * Used by TeamRuntime to inject team topics, prompts, MCP servers, and env vars.
1348
- */
1349
- setSpawnInterceptor(interceptor: SpawnInterceptor | null): void;
1350
- /**
1351
- * Get the RoleRegistry used by this AgentManager.
1352
- */
1353
- getRoleRegistry(): RoleRegistry;
1354
- /**
1355
- * Set the runtime OpenTasks socket path for propagation to child agents.
1356
- * Used when createTaskBackend() discovers the daemon socket path after
1357
- * AgentManager is already created.
1358
- */
1359
- setOpenTasksSocketPath(socketPath: string): void;
1360
- /**
1361
- * Set the MAP server URL for propagation to child agents via SWARM_MAP_SERVER.
1362
- * When set, spawned agents with cc-swarm hooks will connect to macro-agent's
1363
- * local MAP server instead of directly to an external hub.
1364
- */
1365
- setMapServerUrl(url: string): void;
1366
- /**
1367
- * Configure swarmkit integrations (minimem, skill-tree, sessionlog).
1368
- * Called by boot-v2 after system initialization.
1369
- */
1370
- setIntegrationConfigs(configs: {
1371
- minimem?: {
1372
- enabled: boolean;
1373
- dir?: string;
1374
- provider?: string;
1375
- global?: boolean;
1376
- };
1377
- skilltree?: {
1378
- enabled: boolean;
1379
- basePath?: string;
1380
- defaultProfile?: string;
1381
- };
1382
- sessionlog?: {
1383
- enabled: boolean;
1384
- sync?: string;
1385
- };
1386
- }): void;
1387
- /**
1388
- * Set a compiled skill-tree loadout for a role.
1389
- * Called by TeamRuntime during team bootstrap.
1390
- */
1391
- setSkillLoadout(role: string, content: string): void;
1392
- /**
1393
- * Set the MAP sidecar reference for trajectory reporting.
1394
- * Called by boot-v2 after the sidecar is created.
1395
- * Enables session-end checkpoint emission on terminate.
1396
- */
1397
- setSidecar(sidecar: {
1398
- connected: boolean;
1399
- reportCheckpoint(cp: any): Promise<any>;
1400
- } | null): void;
1401
- /**
1402
- * Close all active sessions and clean up resources.
1403
- */
1404
- close(): Promise<void>;
1405
- }
1406
- interface AgentManagerConfig {
1407
- /** Default permission mode for spawned agents */
1408
- defaultPermissionMode?: PermissionMode;
1409
- /** Default agent type (defaults to "claude-code") */
1410
- defaultAgentType?: string;
1411
- /** Default working directory */
1412
- defaultCwd?: string;
1413
- /**
1414
- * Optional WorkspaceManager for workspace isolation.
1415
- * When provided, agents with workspace-enabled roles will get
1416
- * isolated git worktrees.
1417
- */
1418
- workspaceManager?: WorkspaceManager;
1419
- /**
1420
- * Optional RoleRegistry for capability enforcement.
1421
- * When provided, spawn operations will check if the parent agent
1422
- * has the required capability to spawn the requested child role.
1423
- * Defaults to DefaultRoleRegistry if not provided.
1424
- */
1425
- roleRegistry?: RoleRegistry;
1426
- /**
1427
- * Optional server URL for MCP thin-client mode.
1428
- * When set, spawned agents use ephemeral MAP WebSocket calls instead
1429
- * of creating local service stacks.
1430
- */
1431
- serverUrl?: string;
1432
- /**
1433
- * Server authentication token for MCP thin-client connections.
1434
- * Passed to spawned agents as MACRO_SERVER_TOKEN env var.
1435
- */
1436
- serverToken?: string;
1437
- /**
1438
- * OpenTasks socket path to propagate to child MCP subprocesses.
1439
- * Sourced from merged config. Falls back to OPENTASKS_SOCKET_PATH env var.
1440
- */
1441
- openTasksSocketPath?: string;
1442
- }
1443
- /**
1444
- * Function that transforms SpawnAgentOptions before an agent is spawned.
1445
- * Used by TeamRuntime to inject team-specific configuration.
1446
- */
1447
- type SpawnInterceptor = (options: SpawnAgentOptions) => SpawnAgentOptions | Promise<SpawnAgentOptions>;
1448
-
1449
- /**
1450
- * MAP Sidecar Types
1451
- *
1452
- * Configuration, interfaces, and wire format types for the MAP hub sidecar.
1453
- * The sidecar connects macro-agent to an OpenHive MAP hub for agent observability,
1454
- * trajectory reporting, task bridging, and cross-swarm coordination.
1455
- *
1456
- * @module map/types
1457
- */
1458
-
1459
- interface MAPSidecarConfig {
1460
- /** MAP hub WebSocket URL (e.g., "ws://localhost:8080" or "wss://hub.openhive.dev") */
1461
- server: string;
1462
- /** Authentication token (appended as ?token= query param) */
1463
- token?: string;
1464
- /** MAP scope for broadcasting events (default: "swarm:macro-agent") */
1465
- scope?: string;
1466
- /** System ID for federation (default: "macro-agent") */
1467
- systemId?: string;
1468
- /** Opaque credential for server-driven auth (verified mode) */
1469
- credential?: string;
1470
- /** Agent name for MAP registration (default: "macro-agent-sidecar") */
1471
- agentName?: string;
1472
- /** Trajectory sync level */
1473
- trajectorySyncLevel?: "off" | "lifecycle" | "metrics" | "full";
1474
- /** Mesh transport (agentic-mesh P2P) */
1475
- mesh?: {
1476
- enabled?: boolean;
1477
- peerId?: string;
1478
- };
1479
- /** Reconnection settings (SDK-level) */
1480
- reconnection?: {
1481
- enabled?: boolean;
1482
- maxRetries?: number;
1483
- baseDelayMs?: number;
1484
- maxDelayMs?: number;
1485
- };
1486
- /** Slow reconnect interval after SDK retries exhausted (ms, default: 60000) */
1487
- reconnectIntervalMs?: number;
1488
- }
1489
- interface MAPSidecarDeps {
1490
- agentManager: AgentManager;
1491
- agentStore: AgentStore;
1492
- inboxAdapter: InboxAdapter;
1493
- tasksAdapter: TasksAdapter;
1494
- }
1495
- interface MAPSidecar {
1496
- /** Start the sidecar (connect to hub, subscribe to events) */
1497
- start(): Promise<void>;
1498
- /** Stop the sidecar (disconnect, unsubscribe) */
1499
- stop(): Promise<void>;
1500
- /** Whether the sidecar is connected to the hub */
1501
- readonly connected: boolean;
1502
- /** Report a trajectory checkpoint manually */
1503
- reportCheckpoint(checkpoint: TrajectoryCheckpointPayload): Promise<TrajectoryCheckpointResult | null>;
1504
- }
1505
- /**
1506
- * Trajectory checkpoint payload — matches cc-swarm wire format.
1507
- * Top-level fields are snake_case per the OpenHive trajectory protocol.
1508
- */
1509
- interface TrajectoryCheckpointPayload {
1510
- /** Checkpoint ID (e.g., "<sessionId>-step<N>") */
1511
- id: string;
1512
- /** Session identifier */
1513
- session_id: string;
1514
- /** Agent name (e.g., "macro-agent-sidecar") */
1515
- agent: string;
1516
- /** Git branch (nullable) */
1517
- branch: string | null;
1518
- /** Files touched in this checkpoint period */
1519
- files_touched: string[];
1520
- /** Total checkpoint count in session */
1521
- checkpoints_count: number;
1522
- /** Token usage metrics (when sync level >= "metrics") */
1523
- token_usage?: {
1524
- input_tokens?: number;
1525
- output_tokens?: number;
1526
- cache_creation_tokens?: number;
1527
- cache_read_tokens?: number;
1528
- api_call_count?: number;
1529
- };
1530
- /** Additional metadata */
1531
- metadata?: {
1532
- project?: string;
1533
- projectPath?: string;
1534
- template?: string;
1535
- firstPrompt?: string;
1536
- phase?: string;
1537
- [key: string]: unknown;
1538
- };
1539
- }
1540
- /** Response from trajectory/checkpoint extension call */
1541
- interface TrajectoryCheckpointResult {
1542
- ok: boolean;
1543
- resource_id?: string;
1544
- created?: boolean;
1545
- checkpoint_id?: string;
1546
- }
1547
- /** Configuration for the MAP server that accepts inbound connections */
1548
- interface MapServerConfig {
1549
- /** Port for MAP WebSocket server (default: 3002) */
1550
- port?: number;
1551
- /** Host to bind (default: "127.0.0.1") */
1552
- host?: string;
1553
- /** WebSocket path (default: "/map") */
1554
- path?: string;
1555
- /** Server name for MAP protocol (default: "macro-agent") */
1556
- name?: string;
1557
- }
1558
- /** MAP server instance for accepting inbound MAP connections */
1559
- interface MAPServerInstance {
1560
- /** Start the server */
1561
- start(): Promise<void>;
1562
- /** Stop the server */
1563
- stop(): Promise<void>;
1564
- /** Get the WebSocket URL */
1565
- getUrl(): string;
1566
- /** Get number of active connections */
1567
- getConnectionCount(): number;
1568
- }
1569
-
1570
- /**
1571
- * InboxAdapter — Wraps agent-inbox for macro-agent's messaging needs.
1572
- *
1573
- * Embeds agent-inbox in-process (hybrid model):
1574
- * - macro-agent gets zero-latency event access via inbox.events
1575
- * - Agent MCP subprocesses connect via IPC socket
1576
- *
1577
- * Owns adapter-side policy enforcement:
1578
- * - Signal filtering (before delivery to handler)
1579
- * - Emission validation (before forwarding to inbox)
1580
- *
1581
- * @module adapters/inbox-adapter
1582
- */
1583
-
1584
- interface InboxAdapterConfig {
1585
- /** Path to SQLite database for inbox persistence. */
1586
- sqlitePath?: string;
1587
- /** IPC socket path for agent subprocesses. */
1588
- socketPath: string;
1589
- /** Default scope for standalone agents (default: "default"). */
1590
- defaultScope?: string;
1591
- /** Federation config for cross-instance communication. */
1592
- federation?: {
1593
- systemId?: string;
1594
- peers?: Array<{
1595
- systemId: string;
1596
- url?: string;
1597
- meshPeerId?: string;
1598
- }>;
1599
- trust?: {
1600
- allowedServers?: string[];
1601
- };
1602
- };
1603
- }
1604
- declare class DefaultInboxAdapter implements InboxAdapter {
1605
- private inbox;
1606
- private handlers;
1607
- private signalFilters;
1608
- private emissionValidators;
1609
- private readonly config;
1610
- private readonly defaultScope;
1611
- constructor(config: InboxAdapterConfig);
1612
- /**
1613
- * Initialize the embedded agent-inbox instance.
1614
- * Must be called before any other methods.
1615
- */
1616
- initialize(): Promise<void>;
1617
- get socketPath(): string;
1618
- registerAgent(agentId: string, opts: RegisterAgentOptions): Promise<void>;
1619
- deregisterAgent(agentId: string): Promise<void>;
1620
- send(from: string, to: string | string[], content: MessageContent | string, opts?: SendMessageOptions): Promise<string>;
1621
- onDelivery(handler: DeliveryHandler): void;
1622
- offDelivery(handler: DeliveryHandler): void;
1623
- checkInbox(agentId: string, opts?: {
1624
- unreadOnly?: boolean;
1625
- limit?: number;
1626
- }): Promise<Message[]>;
1627
- readThread(threadTag: string, scope?: string): Promise<Message[]>;
1628
- setSignalFilter(filter: SignalFilterFn): void;
1629
- setEmissionValidator(validator: EmissionValidatorFn): void;
1630
- addSignalFilter(id: string, filter: SignalFilterFn): void;
1631
- removeSignalFilter(id: string): void;
1632
- addEmissionValidator(id: string, validator: EmissionValidatorFn): void;
1633
- removeEmissionValidator(id: string): void;
1634
- stop(): Promise<void>;
1635
- /** Get the underlying AgentInbox instance (for advanced use). */
1636
- getInbox(): AgentInbox;
1637
- private requireInbox;
1638
- private handleDeliveryEvent;
1639
- }
1640
-
1641
- /**
1642
- * TasksAdapter — Wraps opentasks client for macro-agent's task management.
1643
- *
1644
- * Connects to the opentasks daemon via IPC. Uses autoConnect to
1645
- * auto-start the daemon if it's not running.
1646
- *
1647
- * Translates between macro-agent's domain types and opentasks'
1648
- * graph model (nodes, edges, semantic actions).
1649
- *
1650
- * @module adapters/tasks-adapter
1651
- */
1652
-
1653
- interface TasksAdapterConfig {
1654
- /** Path to opentasks daemon socket (auto-discovered if not set). */
1655
- socketPath?: string;
1656
- /** Request timeout in milliseconds (default: 30000). */
1657
- timeout?: number;
1658
- }
1659
- declare class DefaultTasksAdapter implements TasksAdapter {
1660
- private client;
1661
- private readonly config;
1662
- private _connected;
1663
- constructor(config?: TasksAdapterConfig);
1664
- get connected(): boolean;
1665
- connect(): Promise<void>;
1666
- disconnect(): void;
1667
- createTask(opts: CreateTaskOptions): Promise<string>;
1668
- assignTask(taskId: string, agentId: string): Promise<void>;
1669
- transitionTask(taskId: string, action: TaskAction): Promise<void>;
1670
- getTask(taskId: string): Promise<TaskRecord>;
1671
- queryReady(opts?: {
1672
- tags?: string[];
1673
- limit?: number;
1674
- }): Promise<TaskRecord[]>;
1675
- listTasks(filter?: TaskQueryOptions): Promise<TaskRecord[]>;
1676
- addBlocker(taskId: string, blockerId: string): Promise<void>;
1677
- removeBlocker(taskId: string, blockerId: string): Promise<void>;
1678
- claimTask(agentId: string, filter?: {
1679
- tags?: string[];
1680
- }): Promise<TaskRecord | null>;
1681
- unclaimTask(taskId: string): Promise<void>;
1682
- listClaimable(filter?: {
1683
- tags?: string[];
1684
- limit?: number;
1685
- }): Promise<TaskRecord[]>;
1686
- private requireClient;
1687
- private nodeToTaskRecord;
1688
- }
1689
-
1690
- /**
1691
- * Control Socket Server
1692
- *
1693
- * NDJSON over UNIX socket. Exposes AgentManager lifecycle operations
1694
- * to MCP subprocesses. Runs in the main macro-agent process.
1695
- *
1696
- * Protocol: One JSON object per line. Request → Response.
1697
- * Same pattern as agent-inbox's IPC server.
1698
- *
1699
- * @module control/control-server
1700
- */
1701
-
1702
- interface ControlServerConfig {
1703
- socketPath: string;
1704
- }
1705
- interface AgentHealthStatus {
1706
- healthy: boolean;
1707
- lastSeen: number;
1708
- pid: number;
1709
- }
1710
- declare class ControlServer {
1711
- private server;
1712
- private readonly socketPath;
1713
- private readonly agentManager;
1714
- private readonly heartbeats;
1715
- private readonly connections;
1716
- constructor(agentManager: AgentManager, config: ControlServerConfig);
1717
- start(): Promise<void>;
1718
- stop(): Promise<void>;
1719
- private handleConnection;
1720
- private handleLine;
1721
- private handleSpawn;
1722
- private handleTerminate;
1723
- private handleGetAgent;
1724
- private handleListAgents;
1725
- private handleGetChildren;
1726
- private handleGetHierarchy;
1727
- private handleHealthCheck;
1728
- getHealthStatus(agentId: string): AgentHealthStatus | null;
1729
- getUnhealthyAgents(timeoutMs: number): Array<{
1730
- agentId: string;
1731
- lastSeen: number;
1732
- pid: number;
1733
- }>;
1734
- }
1735
-
1736
- /**
1737
- * Core Trigger System Types
1738
- *
1739
- * Defines the foundational types for the trigger system including
1740
- * trigger events, sources, payloads, and delivery results.
1741
- *
1742
- * @module trigger/types
1743
- */
1744
-
1745
- /**
1746
- * Sources that can generate trigger events
1747
- */
1748
- type TriggerSource = {
1749
- type: "cron";
1750
- jobId: string;
1751
- jobName: string;
1752
- } | {
1753
- type: "webhook";
1754
- endpointId: string;
1755
- method: string;
1756
- path: string;
1757
- } | {
1758
- type: "system";
1759
- eventType: string;
1760
- } | {
1761
- type: "channel";
1762
- channelType: string;
1763
- channelId: string;
1764
- } | {
1765
- type: "internal";
1766
- component: string;
1767
- };
1768
- /**
1769
- * Payload variants for trigger events
1770
- */
1771
- type TriggerPayload = {
1772
- kind: "text";
1773
- content: string;
1774
- } | {
1775
- kind: "json";
1776
- data: Record<string, unknown>;
1777
- } | {
1778
- kind: "activity";
1779
- activityType: string;
1780
- details?: Record<string, unknown>;
1781
- };
1782
- /**
1783
- * Wake mode determines how the trigger is delivered to the agent
1784
- *
1785
- * - "now": Immediately wake the agent using inject/interrupt chain
1786
- * - "next-prompt": Queue the event to be delivered on agent's next prompt
1787
- */
1788
- type TriggerWakeMode = "now" | "next-prompt";
1789
- /**
1790
- * Target specification for trigger routing
1791
- */
1792
- type TriggerTarget = {
1793
- type: "head";
1794
- } | {
1795
- type: "agent";
1796
- agentId: AgentId$1;
1797
- } | {
1798
- type: "role";
1799
- role: string;
1800
- } | {
1801
- type: "task";
1802
- taskId: TaskId$1;
1803
- } | {
1804
- type: "broadcast";
1805
- channel: string;
1806
- } | {
1807
- type: "ai-router";
1808
- };
1809
- /**
1810
- * Routing hints for trigger delivery
1811
- */
1812
- interface TriggerRoutingHint {
1813
- /** Primary target specification */
1814
- target?: TriggerTarget;
1815
- /** Fallback target if primary fails */
1816
- fallbackTarget?: TriggerTarget;
1817
- /** Custom routing strategy name */
1818
- strategyName?: string;
1819
- /** Whether to spawn new agent if target not found */
1820
- spawnIfNotFound?: boolean;
1821
- /** Spawn configuration if spawning is allowed */
1822
- spawnConfig?: {
1823
- task: string;
1824
- role?: string;
1825
- parentId?: AgentId$1;
1826
- };
1827
- }
1828
- /**
1829
- * Priority levels for trigger events
1830
- */
1831
- type TriggerPriority = "low" | "normal" | "high" | "urgent";
1832
- /**
1833
- * A trigger event to be routed to agents
1834
- */
1835
- interface TriggerEvent {
1836
- /** Unique event ID */
1837
- id: string;
1838
- /** Source of the trigger */
1839
- source: TriggerSource;
1840
- /** Payload content */
1841
- payload: TriggerPayload;
1842
- /** Wake mode for delivery */
1843
- wakeMode: TriggerWakeMode;
1844
- /** Event creation timestamp */
1845
- timestamp: number;
1846
- /** Routing configuration */
1847
- routing?: TriggerRoutingHint;
1848
- /** Priority level */
1849
- priority?: TriggerPriority;
1850
- /** Optional metadata */
1851
- metadata?: Record<string, unknown>;
1852
- }
1853
- /**
1854
- * Method used to deliver the trigger
1855
- */
1856
- type TriggerDeliveryMethod = "queued" | "inject" | "interrupt" | "wake" | "spawn" | "broadcast";
1857
- /**
1858
- * Result of trigger delivery attempt
1859
- */
1860
- interface TriggerDeliveryResult {
1861
- /** Whether delivery succeeded */
1862
- success: boolean;
1863
- /** Agent(s) that received the trigger */
1864
- deliveredTo: AgentId$1[];
1865
- /** Delivery method used */
1866
- method: TriggerDeliveryMethod;
1867
- /** Whether a new agent was spawned */
1868
- spawned?: boolean;
1869
- /** ID of spawned agent if applicable */
1870
- spawnedAgentId?: AgentId$1;
1871
- /** Error message if failed */
1872
- error?: string;
1873
- /** Additional metadata */
1874
- metadata?: Record<string, unknown>;
1875
- }
1876
- /**
1877
- * Minimal TriggerRouter interface for routing trigger events.
1878
- * The full V1 router module was removed in the V2 cutover.
1879
- */
1880
- interface TriggerRouter {
1881
- /** Route a trigger event to target agents */
1882
- route(event: TriggerEvent): Promise<TriggerDeliveryResult>;
1883
- }
1884
-
1885
- /**
1886
- * System Event Queue Types
1887
- *
1888
- * Types for the per-agent ephemeral event queue that stores
1889
- * pending system events to be delivered on the next prompt.
1890
- *
1891
- * @module trigger/queue/types
1892
- */
1893
-
1894
- /**
1895
- * A system event queued for an agent
1896
- */
1897
- interface QueuedSystemEvent {
1898
- /** Event text/content */
1899
- text: string;
1900
- /** Timestamp when queued */
1901
- ts: number;
1902
- /** Source identifier for deduplication */
1903
- sourceKey?: string;
1904
- /** Priority for ordering */
1905
- priority?: "low" | "normal" | "high" | "urgent";
1906
- }
1907
- /**
1908
- * Options for enqueueing a system event
1909
- */
1910
- interface EnqueueOptions {
1911
- /** Target agent ID */
1912
- agentId: AgentId$1;
1913
- /** Optional context key for change detection */
1914
- contextKey?: string | null;
1915
- /** Optional source key for deduplication */
1916
- sourceKey?: string;
1917
- /** Priority level */
1918
- priority?: "low" | "normal" | "high" | "urgent";
1919
- }
1920
- /**
1921
- * Options for draining the queue
1922
- */
1923
- interface DrainOptions {
1924
- /** Whether to include priority in sorting */
1925
- sortByPriority?: boolean;
1926
- /** Maximum number of events to drain */
1927
- limit?: number;
1928
- }
1929
- /**
1930
- * System event queue interface
1931
- *
1932
- * Manages per-agent ephemeral event queues. Events are queued
1933
- * and drained into the agent's next prompt.
1934
- */
1935
- interface SystemEventQueue {
1936
- /**
1937
- * Enqueue an event for an agent
1938
- * @param text - Event text content
1939
- * @param options - Enqueue options including agent ID
1940
- */
1941
- enqueue(text: string, options: EnqueueOptions): void;
1942
- /**
1943
- * Drain all events for an agent (returns and clears queue)
1944
- * @param agentId - Target agent ID
1945
- * @param options - Optional drain options
1946
- * @returns Array of queued events
1947
- */
1948
- drain(agentId: AgentId$1, options?: DrainOptions): QueuedSystemEvent[];
1949
- /**
1950
- * Drain events as text strings only
1951
- * @param agentId - Target agent ID
1952
- * @param options - Optional drain options
1953
- * @returns Array of event text strings
1954
- */
1955
- drainText(agentId: AgentId$1, options?: DrainOptions): string[];
1956
- /**
1957
- * Peek at queued events without removing them
1958
- * @param agentId - Target agent ID
1959
- * @returns Array of event text strings
1960
- */
1961
- peek(agentId: AgentId$1): string[];
1962
- /**
1963
- * Check if agent has queued events
1964
- * @param agentId - Target agent ID
1965
- * @returns True if events are queued
1966
- */
1967
- hasEvents(agentId: AgentId$1): boolean;
1968
- /**
1969
- * Get count of queued events for an agent
1970
- * @param agentId - Target agent ID
1971
- * @returns Number of queued events
1972
- */
1973
- getEventCount(agentId: AgentId$1): number;
1974
- /**
1975
- * Check if context has changed since last enqueue
1976
- * @param agentId - Target agent ID
1977
- * @param contextKey - Context key to check
1978
- * @returns True if context has changed
1979
- */
1980
- isContextChanged(agentId: AgentId$1, contextKey?: string | null): boolean;
1981
- /**
1982
- * Clear queue for a specific agent
1983
- * @param agentId - Target agent ID
1984
- */
1985
- clear(agentId: AgentId$1): void;
1986
- /**
1987
- * Clear all queues (for testing/reset)
1988
- */
1989
- reset(): void;
1990
- /**
1991
- * Get all agent IDs with pending events
1992
- * @returns Array of agent IDs
1993
- */
1994
- getAgentsWithEvents(): AgentId$1[];
1995
- }
1996
-
1997
- /**
1998
- * Trigger Wake System Types
1999
- *
2000
- * Types for the wake manager that handles polling agents
2001
- * with pending events and delivering them.
2002
- *
2003
- * ## Wake System Architecture
2004
- *
2005
- * There are two wake mechanisms in macro-agent:
2006
- *
2007
- * 1. **Single-Agent Wake** (agent/wake.ts, activity/types.ts)
2008
- * - For immediately waking a single agent with an Activity
2009
- * - Priority-driven (urgent/high/normal/low)
2010
- * - Uses inject/interrupt fallback chain
2011
- * - Returns `WakeResult` (success: boolean, method: WakeMethod)
2012
- *
2013
- * 2. **Batch Wake Cycles** (trigger/wake/*)
2014
- * - For periodic delivery of queued system events
2015
- * - Heartbeat-based polling with coalescing
2016
- * - Processes all agents with pending events
2017
- * - Returns `WakeCycleStatus` (status: ran/skipped/failed)
2018
- *
2019
- * Use single-agent wake for: Immediate message delivery, activity notifications
2020
- * Use batch wake cycles for: Scheduled event delivery, system-wide polling
2021
- *
2022
- * @module trigger/wake/types
2023
- */
2024
-
2025
- /**
2026
- * Wake request for immediate agent activation
2027
- */
2028
- interface WakeRequest {
2029
- /** Reason for the wake request */
2030
- reason: string;
2031
- /** Source component requesting wake */
2032
- source?: string;
2033
- /** Optional specific agent to wake */
2034
- agentId?: AgentId$1;
2035
- /** Coalesce delay in ms (default: 250) */
2036
- coalesceMs?: number;
2037
- }
2038
- /**
2039
- * Status of a batch wake cycle.
2040
- *
2041
- * Note: This is different from `WakeResult` in activity/types.ts which
2042
- * represents the outcome of waking a single agent.
2043
- */
2044
- interface WakeCycleStatus {
2045
- status: "ran" | "skipped" | "failed";
2046
- /** Duration if ran */
2047
- durationMs?: number;
2048
- /** Reason if skipped or failed */
2049
- reason?: string;
2050
- /** Agents that were woken */
2051
- wokenAgents?: AgentId$1[];
2052
- }
2053
- /**
2054
- * Wake manager interface
2055
- */
2056
- interface TriggerWakeManager {
2057
- /**
2058
- * Request an immediate wake cycle
2059
- * @param request - Wake request details
2060
- */
2061
- requestWakeNow(request?: WakeRequest): void;
2062
- /**
2063
- * Check if a wake is pending
2064
- * @returns True if wake is scheduled
2065
- */
2066
- hasPendingWake(): boolean;
2067
- /**
2068
- * Run a single wake cycle immediately
2069
- * @param opts - Optional reason for the cycle
2070
- * @returns Wake cycle status
2071
- */
2072
- runWakeCycle(opts?: {
2073
- reason?: string;
2074
- }): Promise<WakeCycleStatus>;
2075
- /**
2076
- * Start the wake manager (enables heartbeat if configured)
2077
- */
2078
- start(): void;
2079
- /**
2080
- * Stop the wake manager
2081
- */
2082
- stop(): void;
2083
- /**
2084
- * Check if manager is running
2085
- */
2086
- isRunning(): boolean;
2087
- /**
2088
- * Get pending wake reason if any
2089
- */
2090
- getPendingReason(): string | null;
2091
- }
2092
-
2093
- /**
2094
- * Cron Service Types
2095
- *
2096
- * Types for the cron scheduler that manages time-based triggers.
2097
- *
2098
- * @module trigger/sources/cron/types
2099
- */
2100
-
2101
- /**
2102
- * One-shot schedule - runs once at a specific time
2103
- */
2104
- interface AtSchedule {
2105
- kind: "at";
2106
- /** Unix timestamp in milliseconds */
2107
- atMs: number;
2108
- }
2109
- /**
2110
- * Recurring interval schedule
2111
- */
2112
- interface EverySchedule {
2113
- kind: "every";
2114
- /** Interval in milliseconds */
2115
- everyMs: number;
2116
- /** Optional anchor time for alignment */
2117
- anchorMs?: number;
2118
- }
2119
- /**
2120
- * Cron expression schedule
2121
- */
2122
- interface CronExprSchedule {
2123
- kind: "cron";
2124
- /** Cron expression (5 or 6 fields) */
2125
- expr: string;
2126
- /** Timezone (IANA format, e.g., "America/New_York") */
2127
- tz?: string;
2128
- }
2129
- /**
2130
- * Union of all schedule types
2131
- */
2132
- type CronSchedule = AtSchedule | EverySchedule | CronExprSchedule;
2133
- /**
2134
- * System event payload - injects text into agent's context
2135
- */
2136
- interface SystemEventPayload {
2137
- kind: "systemEvent";
2138
- /** Text to inject as system event */
2139
- text: string;
2140
- }
2141
- /**
2142
- * Agent prompt payload - sends a full prompt to agent
2143
- */
2144
- interface AgentPromptPayload {
2145
- kind: "agentPrompt";
2146
- /** Message to send to agent */
2147
- message: string;
2148
- /** Optional timeout in seconds */
2149
- timeoutSeconds?: number;
2150
- /** Optional model override */
2151
- model?: string;
2152
- }
2153
- /**
2154
- * Union of job payload types
2155
- */
2156
- type CronJobPayload = SystemEventPayload | AgentPromptPayload;
2157
- /**
2158
- * Job execution state
2159
- */
2160
- interface CronJobState {
2161
- /** Next scheduled run time */
2162
- nextRunAtMs?: number;
2163
- /** Currently running since (undefined if not running) */
2164
- runningAtMs?: number;
2165
- /** Last run time */
2166
- lastRunAtMs?: number;
2167
- /** Last run status */
2168
- lastStatus?: "ok" | "error" | "skipped";
2169
- /** Last error message if failed */
2170
- lastError?: string;
2171
- /** Last run duration in ms */
2172
- lastDurationMs?: number;
2173
- /** Run count */
2174
- runCount?: number;
2175
- }
2176
- /**
2177
- * Session target for job execution
2178
- */
2179
- type CronSessionTarget = "main" | "isolated";
2180
- /**
2181
- * Full cron job definition
2182
- */
2183
- interface CronJob {
2184
- /** Unique job ID */
2185
- id: string;
2186
- /** Human-readable name */
2187
- name: string;
2188
- /** Optional description */
2189
- description?: string;
2190
- /** Whether job is enabled */
2191
- enabled: boolean;
2192
- /** Delete job after successful run (for one-shot jobs) */
2193
- deleteAfterRun?: boolean;
2194
- /** Creation timestamp */
2195
- createdAtMs: number;
2196
- /** Last update timestamp */
2197
- updatedAtMs: number;
2198
- /** Schedule specification */
2199
- schedule: CronSchedule;
2200
- /** Session target */
2201
- sessionTarget: CronSessionTarget;
2202
- /** Wake mode for trigger delivery */
2203
- wakeMode: TriggerWakeMode;
2204
- /** Job payload */
2205
- payload: CronJobPayload;
2206
- /** Optional routing hints */
2207
- routing?: TriggerRoutingHint;
2208
- /** Optional target agent ID (overrides routing) */
2209
- targetAgentId?: AgentId$1;
2210
- /** Job state */
2211
- state: CronJobState;
2212
- /** Optional metadata */
2213
- metadata?: Record<string, unknown>;
2214
- }
2215
- /**
2216
- * Input for creating a cron job
2217
- */
2218
- type CronJobCreate = Omit<CronJob, "id" | "createdAtMs" | "updatedAtMs" | "state"> & {
2219
- /** Optional initial state */
2220
- state?: Partial<CronJobState>;
2221
- };
2222
- /**
2223
- * Input for updating a cron job
2224
- */
2225
- type CronJobPatch = Partial<Omit<CronJob, "id" | "createdAtMs" | "state">> & {
2226
- /** Partial state update */
2227
- state?: Partial<CronJobState>;
2228
- };
2229
- /**
2230
- * Filter options for listing jobs
2231
- */
2232
- interface CronJobFilter {
2233
- /** Include disabled jobs */
2234
- includeDisabled?: boolean;
2235
- /** Filter by name pattern */
2236
- namePattern?: string;
2237
- /** Filter by session target */
2238
- sessionTarget?: CronSessionTarget;
2239
- }
2240
- /**
2241
- * Cron service interface
2242
- */
2243
- interface CronService {
2244
- /**
2245
- * Start the cron service
2246
- */
2247
- start(): Promise<void>;
2248
- /**
2249
- * Stop the cron service
2250
- */
2251
- stop(): Promise<void>;
2252
- /**
2253
- * Check if service is running
2254
- */
2255
- isRunning(): boolean;
2256
- /**
2257
- * List all jobs
2258
- */
2259
- list(filter?: CronJobFilter): Promise<CronJob[]>;
2260
- /**
2261
- * Get a job by ID
2262
- */
2263
- get(id: string): Promise<CronJob | null>;
2264
- /**
2265
- * Add a new job
2266
- */
2267
- add(input: CronJobCreate): Promise<CronJob>;
2268
- /**
2269
- * Update an existing job
2270
- */
2271
- update(id: string, patch: CronJobPatch): Promise<CronJob>;
2272
- /**
2273
- * Remove a job
2274
- */
2275
- remove(id: string): Promise<void>;
2276
- /**
2277
- * Enable a job
2278
- */
2279
- enable(id: string): Promise<CronJob>;
2280
- /**
2281
- * Disable a job
2282
- */
2283
- disable(id: string): Promise<CronJob>;
2284
- /**
2285
- * Manually run a job
2286
- */
2287
- run(id: string, opts?: {
2288
- force?: boolean;
2289
- }): Promise<void>;
2290
- /**
2291
- * Trigger a job immediately (alias for run with force: true)
2292
- */
2293
- triggerNow(id: string): Promise<void>;
2294
- /**
2295
- * Get next scheduled run time across all jobs
2296
- */
2297
- getNextRunTime(): number | null;
2298
- }
2299
-
2300
- /**
2301
- * Webhook Types
2302
- *
2303
- * Types for the webhook trigger source that handles
2304
- * incoming HTTP requests.
2305
- *
2306
- * @module trigger/sources/webhook/types
2307
- */
2308
-
2309
- /**
2310
- * HTTP methods supported for webhooks
2311
- */
2312
- type WebhookMethod = "POST" | "PUT" | "PATCH" | "GET" | "DELETE";
2313
- /**
2314
- * Webhook endpoint configuration
2315
- */
2316
- interface WebhookEndpoint {
2317
- /** Unique endpoint ID */
2318
- id: string;
2319
- /** Human-readable name */
2320
- name: string;
2321
- /** Optional description */
2322
- description?: string;
2323
- /** Allowed HTTP methods */
2324
- methods: WebhookMethod[];
2325
- /** Path pattern (e.g., "/hooks/github") */
2326
- path: string;
2327
- /** Whether endpoint is enabled */
2328
- enabled: boolean;
2329
- /** Secret for signature validation */
2330
- secret?: string;
2331
- /** Wake mode for triggers */
2332
- wakeMode: TriggerWakeMode;
2333
- /** Default routing hints */
2334
- routing?: TriggerRoutingHint;
2335
- /** Creation timestamp */
2336
- createdAtMs: number;
2337
- /** Last update timestamp */
2338
- updatedAtMs: number;
2339
- /** Optional metadata */
2340
- metadata?: Record<string, unknown>;
2341
- }
2342
- /**
2343
- * Input for creating a webhook endpoint
2344
- */
2345
- type WebhookEndpointCreate = Omit<WebhookEndpoint, "id" | "createdAtMs" | "updatedAtMs">;
2346
- /**
2347
- * Input for updating a webhook endpoint
2348
- */
2349
- type WebhookEndpointPatch = Partial<Omit<WebhookEndpoint, "id" | "createdAtMs">>;
2350
- /**
2351
- * Parsed webhook request
2352
- */
2353
- interface WebhookRequest {
2354
- /** Endpoint that matched */
2355
- endpointId: string;
2356
- /** HTTP method */
2357
- method: WebhookMethod;
2358
- /** Request path */
2359
- path: string;
2360
- /** Query parameters */
2361
- query: Record<string, string | string[]>;
2362
- /** Request headers */
2363
- headers: Record<string, string | string[] | undefined>;
2364
- /** Request body (parsed JSON or raw string) */
2365
- body: unknown;
2366
- /** Raw body for signature validation */
2367
- rawBody?: string;
2368
- /** Timestamp of request */
2369
- timestamp: number;
2370
- /** Client IP address */
2371
- clientIp?: string;
2372
- }
2373
- /**
2374
- * Webhook handler interface
2375
- */
2376
- interface WebhookHandler {
2377
- /**
2378
- * List all registered endpoints
2379
- */
2380
- listEndpoints(): Promise<WebhookEndpoint[]>;
2381
- /**
2382
- * Get an endpoint by ID
2383
- */
2384
- getEndpoint(id: string): Promise<WebhookEndpoint | null>;
2385
- /**
2386
- * Register a new endpoint
2387
- */
2388
- registerEndpoint(input: WebhookEndpointCreate): Promise<WebhookEndpoint>;
2389
- /**
2390
- * Update an endpoint
2391
- */
2392
- updateEndpoint(id: string, patch: WebhookEndpointPatch): Promise<WebhookEndpoint>;
2393
- /**
2394
- * Remove an endpoint
2395
- */
2396
- removeEndpoint(id: string): Promise<void>;
2397
- /**
2398
- * Handle an incoming webhook request
2399
- */
2400
- handleRequest(request: WebhookRequest): Promise<WebhookHandleResult>;
2401
- /**
2402
- * Validate a webhook signature
2403
- */
2404
- validateSignature(endpointId: string, signature: string, body: string): Promise<boolean>;
2405
- }
2406
- /**
2407
- * Result of handling a webhook request
2408
- */
2409
- interface WebhookHandleResult {
2410
- success: boolean;
2411
- /** Trigger ID if created */
2412
- triggerId?: string;
2413
- /** Error message if failed */
2414
- error?: string;
2415
- /** HTTP status code to return */
2416
- statusCode: number;
2417
- /** Response body */
2418
- responseBody?: unknown;
2419
- }
2420
-
2421
- /**
2422
- * Trigger System V2 Factory
2423
- *
2424
- * Rewired to use InboxAdapter instead of EventStore/MessageRouter.
2425
- * Connects inbox delivery events to WakeManager for agent wake decisions.
2426
- *
2427
- * Key changes from V1:
2428
- * - InboxAdapter.onDelivery → WakeManager delivery chain
2429
- * - RoutingContext uses AgentStore instead of EventStore
2430
- * - RoutingContext uses InboxAdapter instead of MessageRouter
2431
- * - WakeManager unchanged (only depends on AgentManager interface)
2432
- * - SystemEventQueue unchanged (no external deps)
2433
- * - CronService/WebhookHandler unchanged (only depend on router + wake)
2434
- *
2435
- * @module trigger/trigger-system-v2
2436
- */
2437
-
2438
- interface TriggerSystemV2 {
2439
- readonly queue: SystemEventQueue;
2440
- readonly router: TriggerRouterV2;
2441
- readonly wakeManager: TriggerWakeManager;
2442
- readonly cronService: CronService;
2443
- readonly webhookHandler: WebhookHandler;
2444
- start(): Promise<void>;
2445
- stop(): Promise<void>;
2446
- isRunning(): boolean;
2447
- }
2448
- /**
2449
- * Context provided to routing strategies for making decisions.
2450
- * V2 version uses AgentStore + InboxAdapter instead of EventStore + MessageRouter.
2451
- */
2452
- interface RoutingContext {
2453
- agentStore: AgentStore;
2454
- agentManager: AgentManager;
2455
- inboxAdapter: InboxAdapter;
2456
- systemEventQueue: SystemEventQueue;
2457
- }
2458
- /**
2459
- * Routing decision returned by a strategy.
2460
- */
2461
- interface RoutingDecision {
2462
- targetAgents: string[];
2463
- spawnNew?: {
2464
- task: string;
2465
- role?: string;
2466
- parentId?: string;
2467
- };
2468
- additionalContext?: string;
2469
- wakeModeOverride?: "now" | "next-prompt";
2470
- reason?: string;
2471
- defer?: boolean;
2472
- deferReason?: string;
2473
- }
2474
- /**
2475
- * Pluggable routing strategy interface.
2476
- * Implement this to create custom routing strategies for trigger delivery.
2477
- */
2478
- interface RoutingStrategy {
2479
- readonly name: string;
2480
- readonly description?: string;
2481
- /** Determine routing for a trigger event. */
2482
- route(event: TriggerEvent, context: RoutingContext): Promise<RoutingDecision>;
2483
- /** Check if this strategy can handle the event (optional). */
2484
- canHandle?(event: TriggerEvent): boolean;
2485
- /** Initialize the strategy (optional). */
2486
- initialize?(context: RoutingContext): Promise<void>;
2487
- /** Cleanup the strategy (optional). */
2488
- cleanup?(): Promise<void>;
2489
- }
2490
- /**
2491
- * V2 Trigger Router with pluggable strategy support.
2492
- */
2493
- interface TriggerRouterV2 extends TriggerRouter {
2494
- registerStrategy(strategy: RoutingStrategy): void;
2495
- unregisterStrategy(name: string): void;
2496
- getStrategy(name: string): RoutingStrategy | undefined;
2497
- listStrategies(): string[];
2498
- setDefaultStrategy(name: string): void;
2499
- getDefaultStrategy(): string;
2500
- }
2501
-
2502
- /**
2503
- * REST API request/response types.
2504
- *
2505
- * @module api/types
2506
- */
2507
-
2508
- interface ApiServer {
2509
- /** Express application instance */
2510
- app: Express;
2511
- /** Start listening */
2512
- start(): Promise<void>;
2513
- /** Stop the server */
2514
- stop(): Promise<void>;
2515
- }
2516
-
2517
- /**
2518
- * WebSocket ACP Server — Multi-client WebSocket transport for the ACP protocol.
2519
- *
2520
- * Accepts WebSocket connections, creates a bidirectional Stream for each,
2521
- * and wires up an AgentSideConnection with the macro-agent ACP handler.
2522
- *
2523
- * Also provides a /health HTTP endpoint.
2524
- *
2525
- * @module acp/websocket-server
2526
- */
2527
-
2528
- interface WebSocketACPServer {
2529
- /** Start listening for connections */
2530
- start(): Promise<void>;
2531
- /** Stop the server and close all connections */
2532
- stop(): Promise<void>;
2533
- /** Number of active WebSocket connections */
2534
- getConnectionCount(): number;
2535
- /** The URL the server is listening on */
2536
- getUrl(): string;
2537
- }
2538
-
2539
- interface BootV2Config {
2540
- /** Working directory (default: process.cwd()) */
2541
- cwd?: string;
2542
- /** Base directory for data storage (default: ~/.macro-agent) */
2543
- baseDir?: string;
2544
- /** Default permission mode for spawned agents */
2545
- defaultPermissionMode?: PermissionMode;
2546
- /** Default agent type (default: "claude-code") */
2547
- defaultAgentType?: string;
2548
- /** Role registry (default: DefaultRoleRegistry with built-in roles) */
2549
- roleRegistry?: RoleRegistry;
2550
- /** Workspace manager for git worktree isolation */
2551
- workspaceManager?: WorkspaceManager;
2552
- /** Inbox adapter config overrides */
2553
- inbox?: Partial<InboxAdapterConfig>;
2554
- /** Tasks adapter config overrides */
2555
- tasks?: Partial<TasksAdapterConfig>;
2556
- /** Trigger system config */
2557
- trigger?: {
2558
- enableHeartbeat?: boolean;
2559
- heartbeatIntervalMs?: number;
2560
- };
2561
- /** Server URL for MCP thin-client mode */
2562
- serverUrl?: string;
2563
- /** Server token for thin-client auth */
2564
- serverToken?: string;
2565
- /** REST API server config */
2566
- api?: {
2567
- enabled?: boolean;
2568
- port?: number;
2569
- host?: string;
2570
- };
2571
- /** ACP WebSocket server config */
2572
- acp?: {
2573
- enabled?: boolean;
2574
- port?: number;
2575
- host?: string;
2576
- path?: string;
2577
- };
2578
- /** Federation config for cross-instance communication */
2579
- federation?: {
2580
- systemId: string;
2581
- peers?: Array<{
2582
- systemId: string;
2583
- url?: string;
2584
- meshPeerId?: string;
2585
- }>;
2586
- trust?: {
2587
- allowedSystems?: string[];
2588
- };
2589
- };
2590
- /** MAP server config (accept inbound connections from TUI/clients) */
2591
- mapServer?: {
2592
- enabled?: boolean;
2593
- port?: number;
2594
- host?: string;
2595
- path?: string;
2596
- name?: string;
2597
- };
2598
- /** MAP sidecar config (connect to OpenHive hub) */
2599
- map?: {
2600
- enabled?: boolean;
2601
- server?: string;
2602
- token?: string;
2603
- scope?: string;
2604
- systemId?: string;
2605
- credential?: string;
2606
- agentName?: string;
2607
- trajectorySyncLevel?: "off" | "lifecycle" | "metrics" | "full";
2608
- reconnectIntervalMs?: number;
2609
- reconnection?: {
2610
- enabled?: boolean;
2611
- maxRetries?: number;
2612
- baseDelayMs?: number;
2613
- maxDelayMs?: number;
2614
- };
2615
- };
2616
- /** minimem (agent memory) — registers as MCP server for all agents */
2617
- minimem?: {
2618
- enabled?: boolean;
2619
- dir?: string;
2620
- provider?: string;
2621
- global?: boolean;
2622
- };
2623
- /** skill-tree (per-role skills) — compiles loadouts at team start, injects into prompts */
2624
- skilltree?: {
2625
- enabled?: boolean;
2626
- basePath?: string;
2627
- defaultProfile?: string;
2628
- };
2629
- /** sessionlog — enriches trajectory checkpoints with session state data */
2630
- sessionlog?: {
2631
- enabled?: boolean;
2632
- sync?: "off" | "lifecycle" | "metrics" | "full";
2633
- };
2634
- /** agentic-mesh — P2P encrypted transport for MAP sidecar */
2635
- mesh?: {
2636
- enabled?: boolean;
2637
- peerId?: string;
2638
- };
2639
- }
2640
- interface MacroAgentSystemV2 {
2641
- /** Agent lifecycle manager */
2642
- agentManager: AgentManager;
2643
- /** Agent lifecycle store */
2644
- agentStore: AgentStore;
2645
- /** Messaging adapter (embedded agent-inbox) */
2646
- inboxAdapter: InboxAdapter;
2647
- /** Task management adapter (opentasks client) */
2648
- tasksAdapter: TasksAdapter;
2649
- /** Trigger system (wake, cron, webhooks) */
2650
- triggerSystem: TriggerSystemV2;
2651
- /** Control server (lifecycle RPC for MCP subprocesses) */
2652
- controlServer: ControlServer;
2653
- /** Role registry */
2654
- roleRegistry: RoleRegistry;
2655
- /** Control socket path (for MCP subprocess connection) */
2656
- controlSocketPath: string;
2657
- /** REST API server (if enabled) */
2658
- apiServer?: ApiServer;
2659
- /** ACP WebSocket server (if enabled) */
2660
- acpServer?: WebSocketACPServer;
2661
- /** MAP server for inbound connections (if enabled) */
2662
- mapServerInstance?: MAPServerInstance;
2663
- /** MAP sidecar for outbound hub connection (if enabled) */
2664
- mapSidecar?: MAPSidecar;
2665
- /** Sessionlog sync level for trajectory checkpoint gating */
2666
- _sessionlogSyncLevel?: string;
2667
- /** Shut down all components */
2668
- shutdown(): Promise<void>;
2669
- }
2670
- declare function bootV2(config?: BootV2Config): Promise<MacroAgentSystemV2>;
2671
-
2672
- export { type AgentId$1 as A, type BootV2Config as B, type Capability as C, DefaultInboxAdapter as D, type EventId as E, type SessionId as F, type AgentConfig as G, type HeadManagerOptions as H, type InboxAdapter as I, type SpawnAgentOptions as J, type SpawnInterceptor as K, type SpawnedAgent as L, type MAPSidecarDeps as M, type StopReason as N, type TrajectoryCheckpointPayload as O, type TrajectoryCheckpointResult as P, type Workspace as Q, type RoleRegistry as R, type SystemPromptContext as S, type Timestamp as T, bootV2 as U, type WorkspaceManager as W, type TaskId$1 as a, AgentStore as b, type TasksAdapter as c, type AgentManager as d, type RoleConfig as e, type RoleDefinition as f, type MAPSidecarConfig as g, type MAPSidecar as h, type MacroAgentSystemV2 as i, type MapServerConfig as j, type MAPServerInstance as k, type ActiveSession as l, type Agent as m, type AgentConfig$1 as n, type AgentFilter as o, type AgentHierarchy as p, type AgentHierarchyNode as q, type AgentLifecycleCallback as r, type AgentLifecycleEvent as s, type MCPServerConfig as t, type AgentManagerConfig as u, AgentManagerError as v, type AgentManagerErrorCode as w, type AgentState as x, type AgentStopReason as y, DefaultTasksAdapter as z };