agent-nuvira 1.18.0 โ†’ 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +1 -1
  2. package/dist/agents/inspect-module.d.ts +115 -0
  3. package/dist/agents/inspect-module.d.ts.map +1 -0
  4. package/dist/agents/inspect-module.js +180 -0
  5. package/dist/agents/inspect-module.js.map +1 -0
  6. package/dist/agents/module-registry.d.ts +128 -0
  7. package/dist/agents/module-registry.d.ts.map +1 -0
  8. package/dist/agents/module-registry.js +282 -0
  9. package/dist/agents/module-registry.js.map +1 -0
  10. package/dist/agents/orchestrator.d.ts +10 -1
  11. package/dist/agents/orchestrator.d.ts.map +1 -1
  12. package/dist/agents/orchestrator.js +71 -73
  13. package/dist/agents/orchestrator.js.map +1 -1
  14. package/dist/agents/report-module.d.ts +152 -0
  15. package/dist/agents/report-module.d.ts.map +1 -0
  16. package/dist/agents/report-module.js +365 -0
  17. package/dist/agents/report-module.js.map +1 -0
  18. package/dist/agents/utils/file-tree.d.ts +4 -0
  19. package/dist/agents/utils/file-tree.d.ts.map +1 -1
  20. package/dist/agents/utils/file-tree.js +2 -2
  21. package/dist/agents/utils/file-tree.js.map +1 -1
  22. package/dist/index.d.ts +10 -0
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +10 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/learning/recover-module.d.ts +181 -0
  27. package/dist/learning/recover-module.d.ts.map +1 -0
  28. package/dist/learning/recover-module.js +170 -0
  29. package/dist/learning/recover-module.js.map +1 -0
  30. package/dist/observability/event-bus.d.ts +260 -0
  31. package/dist/observability/event-bus.d.ts.map +1 -0
  32. package/dist/observability/event-bus.js +621 -0
  33. package/dist/observability/event-bus.js.map +1 -0
  34. package/package.json +1 -1
package/README.md CHANGED
@@ -1339,7 +1339,7 @@ npx tsc --noEmit
1339
1339
 
1340
1340
  **Phases 1โ€“3 (25 phases) are complete.** Phase 4 (Industry Standards & Autonomous Polish) is in progress. See [UPGRADE_ROADMAP.md](./UPGRADE_ROADMAP.md) for the full implementation journey.
1341
1341
 
1342
- > ๐Ÿ“Š **Product strategy and pitch materials:** [PRODUCT_STRATEGY.md](./PRODUCT_STRATEGY.md) โ€” Competitive landscape, positioning map, OKR framework, and risk register. [PITCH_DECK.md](./PITCH_DECK.md) โ€” 10-slide investor presentation outline with talking points and data.
1342
+ > ๐Ÿ“Š **Architecture, strategy & contribution materials:** [ARCHITECTURE.md](./ARCHITECTURE.md) โ€” Modular execution engine design with 7 module specifications, extensibility/observability systems, and phased migration plan. [ARCHITECTURE_DIAGRAMS.md](./ARCHITECTURE_DIAGRAMS.md) โ€” Mermaid-rendered versions of all architecture diagrams (Module Architecture, Extensibility, Safe Execution, Data Flow, Observability Bus). [PRODUCT_STRATEGY.md](./PRODUCT_STRATEGY.md) โ€” Competitive landscape, positioning map, OKR framework, and risk register. [PITCH_DECK.md](./PITCH_DECK.md) โ€” 10-slide investor presentation outline with talking points and data. [CONTRIBUTING.md](./CONTRIBUTING.md) โ€” Quick-reference contributor guide with docs map, dev setup, and contribution workflow.
1343
1343
 
1344
1344
  | Phase | Feature | Status |
1345
1345
  |---|---|---|
@@ -0,0 +1,115 @@
1
+ /**
2
+ * InspectModule โ€” Scans the codebase to discover relevant files, extract
3
+ * structural context, and identify dependencies. Phase 5 of the architecture
4
+ * migration: wrap ContextGathererAgent in the modular InspectModule interface.
5
+ *
6
+ * @see ARCHITECTURE.md ยง3.2 โ€” Inspect Module specification
7
+ */
8
+ import type { EventBus } from '../observability/event-bus.js';
9
+ /**
10
+ * A discovered file artifact with its content.
11
+ * Prefixed with "Inspect" to avoid collision with agent.ts's Artifact type.
12
+ */
13
+ export interface InspectArtifact {
14
+ /** Relative path from the project root */
15
+ path: string;
16
+ /** Full file contents */
17
+ content: string;
18
+ /** Human-readable description (e.g. 'src/index.ts (12.5k characters)') */
19
+ description: string;
20
+ }
21
+ /** Statistics about the inspection run */
22
+ export interface InspectionStats {
23
+ /** Total files in the project */
24
+ totalFiles: number;
25
+ /** Files that were inspected / read */
26
+ inspectedFiles: number;
27
+ /** Number of errors encountered during inspection */
28
+ errors: number;
29
+ /** Whether the LLM-based classification fell back to keyword scanning */
30
+ llmFallbackUsed: boolean;
31
+ }
32
+ /** Result of a codebase inspection */
33
+ export interface InspectionResult {
34
+ /** Discovered file artifacts with full contents */
35
+ artifacts: InspectArtifact[];
36
+ /** Text representation of the project file tree */
37
+ fileTree: string;
38
+ /** File paths that are relevant to the goal */
39
+ relevantPaths: string[];
40
+ /** Inspection statistics */
41
+ stats: InspectionStats;
42
+ }
43
+ /** Parameters for the InspectModule.inspect() method */
44
+ export interface InspectParams {
45
+ /** The user's goal / task description */
46
+ goal: string;
47
+ /** Working directory of the project */
48
+ workingDirectory: string;
49
+ /** Optional list of task plan descriptions for context */
50
+ taskDescriptions?: string[];
51
+ /** Maximum number of files to inspect (default: 10) */
52
+ maxFiles?: number;
53
+ }
54
+ /**
55
+ * PlanStep-like interface for dependency-aware planning.
56
+ * A minimal version of what the PlanModule produces.
57
+ */
58
+ export interface PlanStepRef {
59
+ id: string;
60
+ description: string;
61
+ }
62
+ /**
63
+ * InspectModule โ€” Scan the codebase to discover relevant files, extract
64
+ * structural context, and identify dependencies.
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const module = new DefaultInspectModule();
69
+ * const result = await module.inspect({
70
+ * goal: 'Add JWT auth',
71
+ * workingDirectory: '/project',
72
+ * });
73
+ * console.log(result.artifacts.length); // Files discovered
74
+ * ```
75
+ */
76
+ export interface InspectModule {
77
+ /**
78
+ * Scan the codebase for files relevant to the given goal.
79
+ * Uses LLM-based classification with keyword fallback.
80
+ */
81
+ inspect(params: InspectParams): Promise<InspectionResult>;
82
+ /**
83
+ * Synchronous fallback โ€” scans files by keyword matching against the goal.
84
+ * Used when the LLM call fails or times out.
85
+ */
86
+ scanByKeywords(goal: string, workingDir: string): string[];
87
+ }
88
+ /**
89
+ * DefaultInspectModule โ€” Built-in inspect module implementation.
90
+ *
91
+ * Wraps the existing keyword-scanning logic (previously private to
92
+ * ContextGathererAgent) into the modular InspectModule interface.
93
+ * The LLM-based file identification is delegated to the agent system
94
+ * via the callLLM parameter โ€” when no callLLM is provided, only
95
+ * keyword-based scanning is used.
96
+ */
97
+ export declare class DefaultInspectModule implements InspectModule {
98
+ /** The event bus for emitting observability events */
99
+ private eventBus;
100
+ constructor(eventBus?: EventBus);
101
+ /**
102
+ * Scan the codebase for files relevant to the given goal.
103
+ */
104
+ inspect(params: InspectParams): Promise<InspectionResult>;
105
+ /**
106
+ * Synchronous fallback โ€” scan files by keyword matching against the goal.
107
+ * Used when the LLM call fails or as the base implementation.
108
+ */
109
+ scanByKeywords(goal: string, workingDir: string): string[];
110
+ /** Walk the directory tree and score files by keyword relevance */
111
+ private walkAndScore;
112
+ /** Format byte count to human-readable string */
113
+ private formatSize;
114
+ }
115
+ //# sourceMappingURL=inspect-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect-module.d.ts","sourceRoot":"","sources":["../../src/agents/inspect-module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAK9D;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,sCAAsC;AACtC,MAAM,WAAW,gBAAgB;IAC/B,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Scans the codebase to discover relevant files, extract
3
+ * structural context, and identify dependencies. Phase 5 of the architecture
4
+ * migration: wrap ContextGathererAgent in the modular InspectModule interface.
5
+ *
6
+ * @see ARCHITECTURE.md ยง3.2 โ€” Inspect Module specification
7
+ */
8
+ import { join, relative } from 'node:path';
9
+ import { existsSync, readFileSync, statSync, readdirSync } from 'node:fs';
10
+ import { getEventBus, EventNames } from '../observability/event-bus.js';
11
+ import { buildProjectFileTree } from './utils/file-tree.js';
12
+ // โ”€โ”€โ”€ Constants โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
13
+ // Reuse constants from the shared file-tree utility to avoid duplication
14
+ import { SOURCE_EXTENSIONS, IGNORE_DIRS } from './utils/file-tree.js';
15
+ /** Maximum characters per file when reading */
16
+ const MAX_FILE_CHARS = 100_000;
17
+ // โ”€โ”€โ”€ Default InspectModule โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
18
+ /**
19
+ * DefaultInspectModule โ€” Built-in inspect module implementation.
20
+ *
21
+ * Wraps the existing keyword-scanning logic (previously private to
22
+ * ContextGathererAgent) into the modular InspectModule interface.
23
+ * The LLM-based file identification is delegated to the agent system
24
+ * via the callLLM parameter โ€” when no callLLM is provided, only
25
+ * keyword-based scanning is used.
26
+ */
27
+ export class DefaultInspectModule {
28
+ /** The event bus for emitting observability events */
29
+ eventBus;
30
+ constructor(eventBus) {
31
+ this.eventBus = eventBus ?? getEventBus();
32
+ }
33
+ /**
34
+ * Scan the codebase for files relevant to the given goal.
35
+ */
36
+ async inspect(params) {
37
+ const { goal, workingDirectory, taskDescriptions, maxFiles = 10 } = params;
38
+ // โ”€โ”€ Emit: scanning started โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
39
+ this.eventBus.emit(EventNames.INSPECT_SCANNING, {
40
+ directory: workingDirectory,
41
+ goal,
42
+ }, 'inspect-module');
43
+ // 1. Build the project file tree
44
+ const fileTree = await buildProjectFileTree(workingDirectory);
45
+ const totalFiles = fileTree.split('\n').filter((l) => l.includes('๐Ÿ“„')).length;
46
+ // 2. Use keyword scanning to identify relevant paths
47
+ // (Phase 5 uses keyword scanning as the base implementation.
48
+ // TODO: Phase 6 โ€” emit INSPECT_LLM_CLASSIFY when LLM-based classification is added.)
49
+ const relevantPaths = this.scanByKeywords(goal, workingDirectory);
50
+ // Limit to maxFiles
51
+ const limitedPaths = relevantPaths.slice(0, maxFiles);
52
+ // 3. Read the identified files
53
+ const artifacts = [];
54
+ const errors = [];
55
+ for (const filePath of limitedPaths) {
56
+ const absolutePath = join(workingDirectory, filePath);
57
+ if (!existsSync(absolutePath) || !statSync(absolutePath).isFile()) {
58
+ errors.push(`File not found: ${filePath}`);
59
+ continue;
60
+ }
61
+ try {
62
+ const size = statSync(absolutePath).size;
63
+ if (size > MAX_FILE_CHARS) {
64
+ errors.push(`File too large: ${filePath} (${this.formatSize(size)})`);
65
+ continue;
66
+ }
67
+ const content = readFileSync(absolutePath, 'utf-8');
68
+ // โ”€โ”€ Emit: file found event โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
69
+ this.eventBus.emit(EventNames.INSPECT_FILE_FOUND, {
70
+ path: filePath,
71
+ extension: filePath.slice(filePath.lastIndexOf('.')),
72
+ size,
73
+ }, 'inspect-module');
74
+ artifacts.push({
75
+ path: filePath,
76
+ content,
77
+ description: `${filePath} (${this.formatSize(content.length)} characters)`,
78
+ });
79
+ }
80
+ catch {
81
+ errors.push(`Could not read: ${filePath}`);
82
+ }
83
+ }
84
+ const stats = {
85
+ totalFiles,
86
+ inspectedFiles: artifacts.length,
87
+ errors: errors.length,
88
+ // Phase 5 always uses keyword scanning; Phase 6+ will set this based
89
+ // on whether the LLM classifier fell back to keyword matching.
90
+ llmFallbackUsed: true,
91
+ };
92
+ // โ”€โ”€ Emit: completed event โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
93
+ this.eventBus.emit(EventNames.INSPECT_COMPLETED, {
94
+ artifactCount: artifacts.length,
95
+ errors: errors.length,
96
+ totalFiles,
97
+ }, 'inspect-module');
98
+ return {
99
+ artifacts,
100
+ fileTree,
101
+ relevantPaths: limitedPaths,
102
+ stats,
103
+ };
104
+ }
105
+ /**
106
+ * Synchronous fallback โ€” scan files by keyword matching against the goal.
107
+ * Used when the LLM call fails or as the base implementation.
108
+ */
109
+ scanByKeywords(goal, workingDir) {
110
+ const stopWords = new Set([
111
+ 'the', 'a', 'an', 'in', 'to', 'for', 'of', 'and', 'or', 'is',
112
+ 'add', 'fix', 'update', 'change', 'remove', 'create', 'implement',
113
+ 'with', 'on', 'at', 'by', 'from', 'as', 'be', 'this', 'that',
114
+ ]);
115
+ const keywords = goal
116
+ .toLowerCase()
117
+ .split(/[\s,.-]+/)
118
+ .filter((w) => w.length > 2 && !stopWords.has(w));
119
+ if (keywords.length === 0)
120
+ return [];
121
+ const scored = this.walkAndScore(workingDir, keywords, 0);
122
+ return scored
123
+ .sort((a, b) => b.score - a.score)
124
+ .filter((s) => s.score > 0)
125
+ .slice(0, 10)
126
+ .map((s) => s.path);
127
+ }
128
+ // โ”€โ”€โ”€ Private Helpers โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
129
+ /** Walk the directory tree and score files by keyword relevance */
130
+ walkAndScore(dir, keywords, depth, baseDir) {
131
+ const root = baseDir ?? dir;
132
+ if (depth > 5)
133
+ return [];
134
+ const results = [];
135
+ let entries;
136
+ try {
137
+ entries = readdirSync(dir, { withFileTypes: true });
138
+ }
139
+ catch {
140
+ return [];
141
+ }
142
+ for (const entry of entries) {
143
+ if (IGNORE_DIRS.has(entry.name))
144
+ continue;
145
+ const entryPath = join(dir, entry.name);
146
+ if (entry.isDirectory()) {
147
+ const subResults = this.walkAndScore(entryPath, keywords, depth + 1, root);
148
+ results.push(...subResults);
149
+ }
150
+ else if (entry.isFile()) {
151
+ const ext = entry.name.slice(entry.name.lastIndexOf('.'));
152
+ if (!SOURCE_EXTENSIONS.has(ext))
153
+ continue;
154
+ let score = 0;
155
+ const lowerName = entry.name.toLowerCase();
156
+ const lowerPath = entryPath.toLowerCase();
157
+ for (const kw of keywords) {
158
+ if (lowerName.includes(kw))
159
+ score += 3;
160
+ else if (lowerPath.includes(kw))
161
+ score += 1;
162
+ }
163
+ if (score > 0) {
164
+ const relPath = relative(root, entryPath);
165
+ results.push({ path: relPath, score });
166
+ }
167
+ }
168
+ }
169
+ return results;
170
+ }
171
+ /** Format byte count to human-readable string */
172
+ formatSize(bytes) {
173
+ if (bytes < 1024)
174
+ return String(bytes);
175
+ if (bytes < 1024 * 1024)
176
+ return `${(bytes / 1024).toFixed(1)}k`;
177
+ return `${(bytes / (1024 * 1024)).toFixed(1)}M`;
178
+ }
179
+ }
180
+ //# sourceMappingURL=inspect-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect-module.js","sourceRoot":"","sources":["../../src/agents/inspect-module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,oBAAoB,EAAgB,MAAM,sBAAsB,CAAC;AA4F1E,+EAA+E;AAE/E,yEAAyE;AACzE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEtE,+CAA+C;AAC/C,MAAM,cAAc,GAAG,OAAO,CAAC;AAE/B,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,OAAO,oBAAoB;IAC/B,sDAAsD;IAC9C,QAAQ,CAAW;IAE3B,YAAY,QAAmB;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,WAAW,EAAE,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,MAAqB;QACjC,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;QAE3E,oEAAoE;QACpE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,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AE,KAAK,IAAI,CAAC,CAAC;gBAC9C,CAAC;gBAED,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;oBACd,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;oBAC1C,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;gBACzC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,iDAAiD;IACzC,UAAU,CAAC,KAAa;QAC9B,IAAI,KAAK,GAAG,IAAI;YAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;YAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;QAChE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAClD,CAAC;CACF"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * ModuleRegistry โ€” Plugin-based module loading system for the agent execution engine.
3
+ *
4
+ * Replaces the hardcoded `createAgent()` switch statement with a registry that
5
+ * allows modules (agents) to be registered, discovered, and loaded at runtime.
6
+ * Built-in agents are pre-registered; custom agents can be added by plugins
7
+ * or via the SDK's `registerAgent()` function.
8
+ *
9
+ * @see ARCHITECTURE.md ยง4.1 โ€” Extensibility System
10
+ */
11
+ import { Agent } from './agent.js';
12
+ import type { EventBus } from '../observability/event-bus.js';
13
+ /** Factory function that creates a new Agent instance */
14
+ export type AgentFactory = () => Agent;
15
+ /** Metadata about a registered module */
16
+ export interface ModuleMetadata {
17
+ /** The agent type string used in task plans (e.g. 'planner', 'writer') */
18
+ agentType: string;
19
+ /** Human-readable name of the agent (e.g. 'Planner', 'Writer') */
20
+ name: string;
21
+ /** Short description of what this agent does */
22
+ description: string;
23
+ /** Emoji icon for the spinner / UI display */
24
+ icon: string;
25
+ /** Whether this module is built-in (true) or added by a plugin (false) */
26
+ isBuiltin: boolean;
27
+ }
28
+ /** Error thrown when a module lookup fails */
29
+ export declare class ModuleNotFoundError extends Error {
30
+ constructor(agentType: string);
31
+ }
32
+ /**
33
+ * ModuleRegistry โ€” Central registry for agent modules.
34
+ *
35
+ * Manages a collection of agent factories with metadata. Supports lookup,
36
+ * listing, and dynamic registration at runtime.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const registry = ModuleRegistry.createWithBuiltins();
41
+ * const planner = registry.getModule('planner'); // โ†’ PlannerAgent instance
42
+ * ```
43
+ */
44
+ export declare class ModuleRegistry {
45
+ /** Agent factory functions, keyed by agentType */
46
+ private factories;
47
+ /** Module metadata, keyed by agentType */
48
+ private metadata;
49
+ /** The event bus for emitting observability events */
50
+ private eventBus;
51
+ constructor(eventBus?: EventBus);
52
+ /**
53
+ * Register an agent module with the registry.
54
+ *
55
+ * @param agentType - The agent type string used in task plans
56
+ * @param factory - Factory function that returns a new Agent instance
57
+ * @param meta - Metadata describing the module
58
+ *
59
+ * @throws {Error} If `agentType` is already registered (use `override` to replace)
60
+ */
61
+ register(agentType: string, factory: AgentFactory, meta: Omit<ModuleMetadata, 'agentType' | 'isBuiltin'> & {
62
+ isBuiltin?: boolean;
63
+ }): void;
64
+ /**
65
+ * Register an agent module, silently replacing any existing registration.
66
+ * Useful for plugin overrides and hot-reload scenarios.
67
+ */
68
+ registerOrOverride(agentType: string, factory: AgentFactory, meta: Omit<ModuleMetadata, 'agentType' | 'isBuiltin'> & {
69
+ isBuiltin?: boolean;
70
+ }): void;
71
+ /**
72
+ * Unregister an agent module.
73
+ * Safe to call for non-existent agent types (no-op).
74
+ */
75
+ unregister(agentType: string): boolean;
76
+ /**
77
+ * Get an Agent instance for the given agent type.
78
+ *
79
+ * @param agentType - The agent type string (e.g. 'planner', 'writer')
80
+ * @returns A new Agent instance
81
+ * @throws {ModuleNotFoundError} If no module is registered for `agentType`
82
+ */
83
+ getModule(agentType: string): Agent;
84
+ /**
85
+ * Check if an agent type is registered.
86
+ */
87
+ hasModule(agentType: string): boolean;
88
+ /**
89
+ * Get metadata for a registered agent type.
90
+ * Returns undefined if the agent type is not registered.
91
+ */
92
+ getMetadata(agentType: string): ModuleMetadata | undefined;
93
+ /**
94
+ * List all registered modules, optionally filtered by a predicate.
95
+ */
96
+ listModules(filter?: (meta: ModuleMetadata) => boolean): ModuleMetadata[];
97
+ /**
98
+ * Get the icon for an agent type, or a default icon if not found.
99
+ */
100
+ getIcon(agentType: string): string;
101
+ /**
102
+ * Get the number of registered modules.
103
+ */
104
+ get size(): number;
105
+ /**
106
+ * Create a ModuleRegistry pre-populated with all built-in agents.
107
+ */
108
+ static createWithBuiltins(eventBus?: EventBus): ModuleRegistry;
109
+ }
110
+ /**
111
+ * Get or create the global ModuleRegistry singleton.
112
+ *
113
+ * First call creates a registry with all built-in agents pre-registered.
114
+ * Subsequent calls return the same instance.
115
+ * Use `resetModuleRegistry()` to clear and re-initialize (useful in tests).
116
+ */
117
+ export declare function getModuleRegistry(): ModuleRegistry;
118
+ /**
119
+ * Reset the global module registry.
120
+ * Primarily useful in tests to get a clean slate.
121
+ */
122
+ export declare function resetModuleRegistry(): void;
123
+ /**
124
+ * Set the global module registry (for dependency injection in tests).
125
+ * Returns the previous registry instance (or null).
126
+ */
127
+ export declare function setModuleRegistry(registry: ModuleRegistry): ModuleRegistry | null;
128
+ //# sourceMappingURL=module-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-registry.d.ts","sourceRoot":"","sources":["../../src/agents/module-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAenC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAI9D,yDAAyD;AACzD,MAAM,MAAM,YAAY,GAAG,MAAM,KAA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