@hazeljs/agent 0.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/IMPLEMENTATION_SUMMARY.md +400 -0
- package/LICENSE +192 -0
- package/PERSISTENCE.md +201 -0
- package/PRISMA_INTEGRATION.md +499 -0
- package/PRODUCTION_READINESS.md +264 -0
- package/QUICKSTART.md +135 -0
- package/README.md +541 -0
- package/STATE_VS_MEMORY.md +243 -0
- package/benchmarks/performance.benchmark.ts +157 -0
- package/coverage/clover.xml +1508 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +296 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov.info +2722 -0
- package/dist/agent.module.d.ts +57 -0
- package/dist/agent.module.d.ts.map +1 -0
- package/dist/agent.module.js +99 -0
- package/dist/agent.module.js.map +1 -0
- package/dist/context/agent.context.d.ts +27 -0
- package/dist/context/agent.context.d.ts.map +1 -0
- package/dist/context/agent.context.js +98 -0
- package/dist/context/agent.context.js.map +1 -0
- package/dist/decorators/agent.decorator.d.ts +21 -0
- package/dist/decorators/agent.decorator.d.ts.map +1 -0
- package/dist/decorators/agent.decorator.js +38 -0
- package/dist/decorators/agent.decorator.js.map +1 -0
- package/dist/decorators/delegate.decorator.d.ts +66 -0
- package/dist/decorators/delegate.decorator.d.ts.map +1 -0
- package/dist/decorators/delegate.decorator.js +108 -0
- package/dist/decorators/delegate.decorator.js.map +1 -0
- package/dist/decorators/tool.decorator.d.ts +23 -0
- package/dist/decorators/tool.decorator.d.ts.map +1 -0
- package/dist/decorators/tool.decorator.js +61 -0
- package/dist/decorators/tool.decorator.js.map +1 -0
- package/dist/events/event.emitter.d.ts +45 -0
- package/dist/events/event.emitter.d.ts.map +1 -0
- package/dist/events/event.emitter.js +96 -0
- package/dist/events/event.emitter.js.map +1 -0
- package/dist/executor/agent.executor.d.ts +58 -0
- package/dist/executor/agent.executor.d.ts.map +1 -0
- package/dist/executor/agent.executor.js +312 -0
- package/dist/executor/agent.executor.js.map +1 -0
- package/dist/executor/tool.executor.d.ts +55 -0
- package/dist/executor/tool.executor.d.ts.map +1 -0
- package/dist/executor/tool.executor.js +266 -0
- package/dist/executor/tool.executor.js.map +1 -0
- package/dist/graph/agent-graph.d.ts +131 -0
- package/dist/graph/agent-graph.d.ts.map +1 -0
- package/dist/graph/agent-graph.js +462 -0
- package/dist/graph/agent-graph.js.map +1 -0
- package/dist/graph/agent-graph.types.d.ts +210 -0
- package/dist/graph/agent-graph.types.d.ts.map +1 -0
- package/dist/graph/agent-graph.types.js +12 -0
- package/dist/graph/agent-graph.types.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/agent-system.prompt.d.ts +10 -0
- package/dist/prompts/agent-system.prompt.d.ts.map +1 -0
- package/dist/prompts/agent-system.prompt.js +18 -0
- package/dist/prompts/agent-system.prompt.js.map +1 -0
- package/dist/prompts/index.d.ts +4 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +20 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/supervisor-routing.prompt.d.ts +9 -0
- package/dist/prompts/supervisor-routing.prompt.d.ts.map +1 -0
- package/dist/prompts/supervisor-routing.prompt.js +22 -0
- package/dist/prompts/supervisor-routing.prompt.js.map +1 -0
- package/dist/prompts/supervisor-system.prompt.d.ts +9 -0
- package/dist/prompts/supervisor-system.prompt.d.ts.map +1 -0
- package/dist/prompts/supervisor-system.prompt.js +21 -0
- package/dist/prompts/supervisor-system.prompt.js.map +1 -0
- package/dist/registry/agent.registry.d.ts +49 -0
- package/dist/registry/agent.registry.d.ts.map +1 -0
- package/dist/registry/agent.registry.js +90 -0
- package/dist/registry/agent.registry.js.map +1 -0
- package/dist/registry/tool.registry.d.ts +54 -0
- package/dist/registry/tool.registry.d.ts.map +1 -0
- package/dist/registry/tool.registry.js +153 -0
- package/dist/registry/tool.registry.js.map +1 -0
- package/dist/runtime/agent.runtime.d.ts +218 -0
- package/dist/runtime/agent.runtime.d.ts.map +1 -0
- package/dist/runtime/agent.runtime.extensions.d.ts +49 -0
- package/dist/runtime/agent.runtime.extensions.d.ts.map +1 -0
- package/dist/runtime/agent.runtime.extensions.js +93 -0
- package/dist/runtime/agent.runtime.extensions.js.map +1 -0
- package/dist/runtime/agent.runtime.js +448 -0
- package/dist/runtime/agent.runtime.js.map +1 -0
- package/dist/state/agent-state.interface.d.ts +63 -0
- package/dist/state/agent-state.interface.d.ts.map +1 -0
- package/dist/state/agent-state.interface.js +7 -0
- package/dist/state/agent-state.interface.js.map +1 -0
- package/dist/state/agent.state.d.ts +67 -0
- package/dist/state/agent.state.d.ts.map +1 -0
- package/dist/state/agent.state.js +172 -0
- package/dist/state/agent.state.js.map +1 -0
- package/dist/state/database-state.manager.d.ts +63 -0
- package/dist/state/database-state.manager.d.ts.map +1 -0
- package/dist/state/database-state.manager.js +282 -0
- package/dist/state/database-state.manager.js.map +1 -0
- package/dist/state/redis-state.manager.d.ts +81 -0
- package/dist/state/redis-state.manager.d.ts.map +1 -0
- package/dist/state/redis-state.manager.js +253 -0
- package/dist/state/redis-state.manager.js.map +1 -0
- package/dist/supervisor/supervisor.d.ts +81 -0
- package/dist/supervisor/supervisor.d.ts.map +1 -0
- package/dist/supervisor/supervisor.js +220 -0
- package/dist/supervisor/supervisor.js.map +1 -0
- package/dist/types/agent.types.d.ts +166 -0
- package/dist/types/agent.types.d.ts.map +1 -0
- package/dist/types/agent.types.js +32 -0
- package/dist/types/agent.types.js.map +1 -0
- package/dist/types/event.types.d.ts +198 -0
- package/dist/types/event.types.d.ts.map +1 -0
- package/dist/types/event.types.js +46 -0
- package/dist/types/event.types.js.map +1 -0
- package/dist/types/llm.types.d.ts +66 -0
- package/dist/types/llm.types.d.ts.map +1 -0
- package/dist/types/llm.types.js +7 -0
- package/dist/types/llm.types.js.map +1 -0
- package/dist/types/rag.types.d.ts +40 -0
- package/dist/types/rag.types.d.ts.map +1 -0
- package/dist/types/rag.types.js +7 -0
- package/dist/types/rag.types.js.map +1 -0
- package/dist/types/tool.types.d.ts +118 -0
- package/dist/types/tool.types.d.ts.map +1 -0
- package/dist/types/tool.types.js +19 -0
- package/dist/types/tool.types.js.map +1 -0
- package/dist/utils/circuit-breaker.d.ts +9 -0
- package/dist/utils/circuit-breaker.d.ts.map +1 -0
- package/dist/utils/circuit-breaker.js +16 -0
- package/dist/utils/circuit-breaker.js.map +1 -0
- package/dist/utils/health-check.d.ts +71 -0
- package/dist/utils/health-check.d.ts.map +1 -0
- package/dist/utils/health-check.js +156 -0
- package/dist/utils/health-check.js.map +1 -0
- package/dist/utils/logger.d.ts +53 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +133 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/metrics.d.ts +90 -0
- package/dist/utils/metrics.d.ts.map +1 -0
- package/dist/utils/metrics.js +186 -0
- package/dist/utils/metrics.js.map +1 -0
- package/dist/utils/rate-limiter.d.ts +44 -0
- package/dist/utils/rate-limiter.d.ts.map +1 -0
- package/dist/utils/rate-limiter.js +82 -0
- package/dist/utils/rate-limiter.js.map +1 -0
- package/dist/utils/retry.d.ts +42 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +103 -0
- package/dist/utils/retry.js.map +1 -0
- package/jest.config.js +30 -0
- package/logs/combined.log +1 -0
- package/logs/error.log +0 -0
- package/package.json +74 -0
- package/prisma-schema.example.prisma +76 -0
- package/tests/setup.ts +17 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentGraph Types
|
|
3
|
+
* Type definitions for the multi-agent orchestration graph system
|
|
4
|
+
*/
|
|
5
|
+
import { AgentExecutionResult } from '../types/agent.types';
|
|
6
|
+
/** Sentinel value marking the end of a graph execution */
|
|
7
|
+
export declare const END: "__end__";
|
|
8
|
+
export type GraphEndSymbol = typeof END;
|
|
9
|
+
/** Message that flows through the graph between nodes */
|
|
10
|
+
export interface GraphMessage {
|
|
11
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
12
|
+
content: string;
|
|
13
|
+
/** The node that produced this message */
|
|
14
|
+
nodeId?: string;
|
|
15
|
+
timestamp?: Date;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The shared state object that flows through every node in the graph.
|
|
19
|
+
* Nodes read from it, transform it, and return a partial update.
|
|
20
|
+
*/
|
|
21
|
+
export interface GraphState {
|
|
22
|
+
/** The original user input that kicked off the graph */
|
|
23
|
+
input: string;
|
|
24
|
+
/** The most recent output produced by any node */
|
|
25
|
+
output?: string;
|
|
26
|
+
/** Full message history for the graph run */
|
|
27
|
+
messages: GraphMessage[];
|
|
28
|
+
/** Arbitrary key-value store for inter-node data sharing */
|
|
29
|
+
data: Record<string, unknown>;
|
|
30
|
+
/** Full AgentExecutionResult keyed by node ID */
|
|
31
|
+
nodeResults: Record<string, AgentExecutionResult>;
|
|
32
|
+
/** ID of the node currently being executed */
|
|
33
|
+
currentNode?: string;
|
|
34
|
+
/** Set if the graph encountered an unrecoverable error */
|
|
35
|
+
error?: Error;
|
|
36
|
+
/** Graph-level metadata (execution ID, options, etc.) */
|
|
37
|
+
metadata?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
/** A node that runs a registered agent by name */
|
|
40
|
+
export interface AgentNodeConfig {
|
|
41
|
+
type: 'agent';
|
|
42
|
+
/** The name of the agent as registered with AgentRuntime */
|
|
43
|
+
agentName: string;
|
|
44
|
+
/**
|
|
45
|
+
* Optional: transform graph state → agent input string.
|
|
46
|
+
* Defaults to `state.input` when not provided.
|
|
47
|
+
*/
|
|
48
|
+
inputMapper?: (state: GraphState) => string;
|
|
49
|
+
/**
|
|
50
|
+
* Optional: transform agent result + previous state → new state.
|
|
51
|
+
* Defaults to setting `state.output = result.response`.
|
|
52
|
+
*/
|
|
53
|
+
outputMapper?: (result: AgentExecutionResult, state: GraphState) => Partial<GraphState>;
|
|
54
|
+
}
|
|
55
|
+
/** A node that runs an arbitrary async function */
|
|
56
|
+
export interface FunctionNodeConfig {
|
|
57
|
+
type: 'function';
|
|
58
|
+
/** Must return a (possibly partial) GraphState update */
|
|
59
|
+
fn: (state: GraphState) => Promise<Partial<GraphState>> | Partial<GraphState>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A node that fans-out to multiple child nodes in parallel,
|
|
63
|
+
* waits for all of them, then merges their results.
|
|
64
|
+
*/
|
|
65
|
+
export interface ParallelNodeConfig {
|
|
66
|
+
type: 'parallel';
|
|
67
|
+
/** IDs of nodes to execute concurrently */
|
|
68
|
+
branches: string[];
|
|
69
|
+
/**
|
|
70
|
+
* Optional: merge all branch outputs into the final state.
|
|
71
|
+
* Defaults to concatenating each branch's `output` with a separator.
|
|
72
|
+
*/
|
|
73
|
+
mergeStrategy?: (results: ParallelBranchResult[], base: GraphState) => Partial<GraphState>;
|
|
74
|
+
}
|
|
75
|
+
export type GraphNodeConfig = AgentNodeConfig | FunctionNodeConfig | ParallelNodeConfig;
|
|
76
|
+
/** Internal node representation */
|
|
77
|
+
export interface GraphNode {
|
|
78
|
+
id: string;
|
|
79
|
+
config: GraphNodeConfig;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Router function: inspects the current state and returns the ID of the next
|
|
83
|
+
* node (or `END` to stop the graph).
|
|
84
|
+
*/
|
|
85
|
+
export type RouterFunction = (state: GraphState) => string | GraphEndSymbol;
|
|
86
|
+
export interface GraphEdge {
|
|
87
|
+
from: string;
|
|
88
|
+
/** Fixed target node ID (or END). Mutually exclusive with `condition`. */
|
|
89
|
+
to?: string | GraphEndSymbol;
|
|
90
|
+
/** Conditional routing function. Mutually exclusive with `to`. */
|
|
91
|
+
condition?: RouterFunction;
|
|
92
|
+
}
|
|
93
|
+
export interface GraphExecutionOptions {
|
|
94
|
+
sessionId?: string;
|
|
95
|
+
userId?: string;
|
|
96
|
+
/** Maximum number of node executions before aborting (default: 50) */
|
|
97
|
+
maxSteps?: number;
|
|
98
|
+
/** Timeout in ms for the entire graph run (default: 600_000) */
|
|
99
|
+
timeout?: number;
|
|
100
|
+
/** Seed data merged into `state.data` before the run starts */
|
|
101
|
+
initialData?: Record<string, unknown>;
|
|
102
|
+
}
|
|
103
|
+
/** Per-node step record within a graph execution */
|
|
104
|
+
export interface GraphStep {
|
|
105
|
+
id: string;
|
|
106
|
+
nodeId: string;
|
|
107
|
+
nodeType: GraphNodeConfig['type'];
|
|
108
|
+
/** Input string seen by this node */
|
|
109
|
+
input: string;
|
|
110
|
+
/** Output produced by this node */
|
|
111
|
+
output?: string;
|
|
112
|
+
duration: number;
|
|
113
|
+
timestamp: Date;
|
|
114
|
+
/** For parallel nodes: IDs of branches executed */
|
|
115
|
+
parallelBranches?: string[];
|
|
116
|
+
error?: string;
|
|
117
|
+
}
|
|
118
|
+
export interface GraphExecutionResult {
|
|
119
|
+
graphId: string;
|
|
120
|
+
executionId: string;
|
|
121
|
+
/** Final state after all nodes have run */
|
|
122
|
+
state: GraphState;
|
|
123
|
+
/** Convenience alias for `state.output` */
|
|
124
|
+
response?: string;
|
|
125
|
+
steps: GraphStep[];
|
|
126
|
+
/** Full agent results keyed by node ID */
|
|
127
|
+
nodeExecutions: Record<string, AgentExecutionResult>;
|
|
128
|
+
duration: number;
|
|
129
|
+
completedAt: Date;
|
|
130
|
+
success: boolean;
|
|
131
|
+
error?: Error;
|
|
132
|
+
}
|
|
133
|
+
/** Emitted for each node during a streaming graph execution */
|
|
134
|
+
export interface GraphStreamChunk {
|
|
135
|
+
executionId: string;
|
|
136
|
+
nodeId: string;
|
|
137
|
+
nodeType: GraphNodeConfig['type'];
|
|
138
|
+
/** Incremental content delta (may be empty for non-streaming nodes) */
|
|
139
|
+
chunk: string;
|
|
140
|
+
/** Full output of this node once it completes */
|
|
141
|
+
nodeOutput?: string;
|
|
142
|
+
done: boolean;
|
|
143
|
+
}
|
|
144
|
+
export interface ParallelBranchResult {
|
|
145
|
+
nodeId: string;
|
|
146
|
+
state: GraphState;
|
|
147
|
+
agentResult?: AgentExecutionResult;
|
|
148
|
+
error?: Error;
|
|
149
|
+
}
|
|
150
|
+
export interface SupervisorConfig {
|
|
151
|
+
/** Display name for this supervisor instance */
|
|
152
|
+
name: string;
|
|
153
|
+
/** Names of worker agents available for delegation */
|
|
154
|
+
workers: string[];
|
|
155
|
+
/**
|
|
156
|
+
* Optional override for the supervisor system prompt.
|
|
157
|
+
* The workers list is always appended automatically.
|
|
158
|
+
*/
|
|
159
|
+
systemPrompt?: string;
|
|
160
|
+
/** Maximum routing rounds before the supervisor gives up (default: 10) */
|
|
161
|
+
maxRounds?: number;
|
|
162
|
+
/** Model to use for supervisor routing decisions */
|
|
163
|
+
model?: string;
|
|
164
|
+
temperature?: number;
|
|
165
|
+
}
|
|
166
|
+
export interface SupervisorWorkerInfo {
|
|
167
|
+
name: string;
|
|
168
|
+
description?: string;
|
|
169
|
+
}
|
|
170
|
+
/** Routing decision returned by the LLM */
|
|
171
|
+
export interface SupervisorDecision {
|
|
172
|
+
/** 'delegate' to route to a worker, 'finish' to return a final answer */
|
|
173
|
+
action: 'delegate' | 'finish';
|
|
174
|
+
/** When action === 'delegate': target worker agent name */
|
|
175
|
+
worker?: string;
|
|
176
|
+
/** When action === 'delegate': the subtask for the worker */
|
|
177
|
+
subtask?: string;
|
|
178
|
+
/** When action === 'finish': the final response to the user */
|
|
179
|
+
response?: string;
|
|
180
|
+
/** Supervisor's internal reasoning */
|
|
181
|
+
thought?: string;
|
|
182
|
+
}
|
|
183
|
+
export interface SupervisorResult {
|
|
184
|
+
response: string;
|
|
185
|
+
rounds: SupervisorRound[];
|
|
186
|
+
totalDuration: number;
|
|
187
|
+
completedAt: Date;
|
|
188
|
+
success: boolean;
|
|
189
|
+
error?: Error;
|
|
190
|
+
}
|
|
191
|
+
export interface SupervisorRound {
|
|
192
|
+
round: number;
|
|
193
|
+
decision: SupervisorDecision;
|
|
194
|
+
workerResult?: AgentExecutionResult;
|
|
195
|
+
duration: number;
|
|
196
|
+
}
|
|
197
|
+
export interface DelegateConfig {
|
|
198
|
+
/** The agent name (as registered with AgentRuntime) to delegate to */
|
|
199
|
+
agent: string;
|
|
200
|
+
/** Human-readable description used as the tool description for the LLM */
|
|
201
|
+
description: string;
|
|
202
|
+
/**
|
|
203
|
+
* Which key in the tool call's arguments object contains the text
|
|
204
|
+
* passed as `input` to the target agent. Defaults to 'input'.
|
|
205
|
+
*/
|
|
206
|
+
inputField?: string;
|
|
207
|
+
}
|
|
208
|
+
export declare const DELEGATE_METADATA_KEY: unique symbol;
|
|
209
|
+
export declare const DELEGATES_LIST_KEY: unique symbol;
|
|
210
|
+
//# sourceMappingURL=agent-graph.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-graph.types.d.ts","sourceRoot":"","sources":["../../src/graph/agent-graph.types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,0DAA0D;AAC1D,eAAO,MAAM,GAAG,EAAG,SAAkB,CAAC;AACtC,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,CAAC;AAMxC,yDAAyD;AACzD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB;AAED;;;GAGG;AAC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ACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,yEAAyE;IACzE,MAAM,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC9B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,IAAI,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAMD,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,qBAAqB,eAA2B,CAAC;AAC9D,eAAO,MAAM,kBAAkB,eAA4B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentGraph Types
|
|
4
|
+
* Type definitions for the multi-agent orchestration graph system
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DELEGATES_LIST_KEY = exports.DELEGATE_METADATA_KEY = exports.END = void 0;
|
|
8
|
+
/** Sentinel value marking the end of a graph execution */
|
|
9
|
+
exports.END = '__end__';
|
|
10
|
+
exports.DELEGATE_METADATA_KEY = Symbol('hazel:delegate');
|
|
11
|
+
exports.DELEGATES_LIST_KEY = Symbol('hazel:delegates');
|
|
12
|
+
//# sourceMappingURL=agent-graph.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-graph.types.js","sourceRoot":"","sources":["../../src/graph/agent-graph.types.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,0DAA0D;AAC7C,QAAA,GAAG,GAAG,SAAkB,CAAC;AA0PzB,QAAA,qBAAqB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACjD,QAAA,kBAAkB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hazeljs/agent
|
|
3
|
+
* AI-native Agent Runtime for HazelJS
|
|
4
|
+
*/
|
|
5
|
+
export * from './types/agent.types';
|
|
6
|
+
export * from './types/tool.types';
|
|
7
|
+
export * from './types/event.types';
|
|
8
|
+
export * from './types/llm.types';
|
|
9
|
+
export * from './types/rag.types';
|
|
10
|
+
export * from './decorators/agent.decorator';
|
|
11
|
+
export * from './decorators/tool.decorator';
|
|
12
|
+
export * from './decorators/delegate.decorator';
|
|
13
|
+
export * from './registry/agent.registry';
|
|
14
|
+
export * from './registry/tool.registry';
|
|
15
|
+
export * from './state/agent.state';
|
|
16
|
+
export * from './state/agent-state.interface';
|
|
17
|
+
export * from './state/redis-state.manager';
|
|
18
|
+
export * from './state/database-state.manager';
|
|
19
|
+
export * from './context/agent.context';
|
|
20
|
+
export * from './executor/agent.executor';
|
|
21
|
+
export * from './executor/tool.executor';
|
|
22
|
+
export * from './events/event.emitter';
|
|
23
|
+
export * from './runtime/agent.runtime';
|
|
24
|
+
export * from './utils/rate-limiter';
|
|
25
|
+
export * from './utils/logger';
|
|
26
|
+
export * from './utils/metrics';
|
|
27
|
+
export * from './utils/retry';
|
|
28
|
+
export * from './utils/circuit-breaker';
|
|
29
|
+
export * from './utils/health-check';
|
|
30
|
+
export * from './graph/agent-graph.types';
|
|
31
|
+
export * from './graph/agent-graph';
|
|
32
|
+
export * from './supervisor/supervisor';
|
|
33
|
+
export * from './agent.module';
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAElC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AAExC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,yBAAyB,CAAC;AAExC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AAExC,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @hazeljs/agent
|
|
4
|
+
* AI-native Agent Runtime for HazelJS
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
__exportStar(require("./types/agent.types"), exports);
|
|
22
|
+
__exportStar(require("./types/tool.types"), exports);
|
|
23
|
+
__exportStar(require("./types/event.types"), exports);
|
|
24
|
+
__exportStar(require("./types/llm.types"), exports);
|
|
25
|
+
__exportStar(require("./types/rag.types"), exports);
|
|
26
|
+
__exportStar(require("./decorators/agent.decorator"), exports);
|
|
27
|
+
__exportStar(require("./decorators/tool.decorator"), exports);
|
|
28
|
+
__exportStar(require("./decorators/delegate.decorator"), exports);
|
|
29
|
+
__exportStar(require("./registry/agent.registry"), exports);
|
|
30
|
+
__exportStar(require("./registry/tool.registry"), exports);
|
|
31
|
+
__exportStar(require("./state/agent.state"), exports);
|
|
32
|
+
__exportStar(require("./state/agent-state.interface"), exports);
|
|
33
|
+
__exportStar(require("./state/redis-state.manager"), exports);
|
|
34
|
+
__exportStar(require("./state/database-state.manager"), exports);
|
|
35
|
+
__exportStar(require("./context/agent.context"), exports);
|
|
36
|
+
__exportStar(require("./executor/agent.executor"), exports);
|
|
37
|
+
__exportStar(require("./executor/tool.executor"), exports);
|
|
38
|
+
__exportStar(require("./events/event.emitter"), exports);
|
|
39
|
+
__exportStar(require("./runtime/agent.runtime"), exports);
|
|
40
|
+
__exportStar(require("./utils/rate-limiter"), exports);
|
|
41
|
+
__exportStar(require("./utils/logger"), exports);
|
|
42
|
+
__exportStar(require("./utils/metrics"), exports);
|
|
43
|
+
__exportStar(require("./utils/retry"), exports);
|
|
44
|
+
__exportStar(require("./utils/circuit-breaker"), exports);
|
|
45
|
+
__exportStar(require("./utils/health-check"), exports);
|
|
46
|
+
// Multi-agent orchestration
|
|
47
|
+
__exportStar(require("./graph/agent-graph.types"), exports);
|
|
48
|
+
__exportStar(require("./graph/agent-graph"), exports);
|
|
49
|
+
__exportStar(require("./supervisor/supervisor"), exports);
|
|
50
|
+
__exportStar(require("./agent.module"), exports);
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,sDAAoC;AACpC,qDAAmC;AACnC,sDAAoC;AACpC,oDAAkC;AAClC,oDAAkC;AAElC,+DAA6C;AAC7C,8DAA4C;AAC5C,kEAAgD;AAEhD,4DAA0C;AAC1C,2DAAyC;AAEzC,sDAAoC;AACpC,gEAA8C;AAC9C,8DAA4C;AAC5C,iEAA+C;AAC/C,0DAAwC;AAExC,4DAA0C;AAC1C,2DAAyC;AAEzC,yDAAuC;AAEvC,0DAAwC;AAExC,uDAAqC;AACrC,iDAA+B;AAC/B,kDAAgC;AAChC,gDAA8B;AAC9B,0DAAwC;AACxC,uDAAqC;AAErC,4BAA4B;AAC5B,4DAA0C;AAC1C,sDAAoC;AACpC,0DAAwC;AAExC,iDAA+B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PromptTemplate } from '@hazeljs/prompts';
|
|
2
|
+
export declare const AGENT_SYSTEM_KEY = "agent:system";
|
|
3
|
+
export interface AgentSystemVariables {
|
|
4
|
+
systemPrompt: string;
|
|
5
|
+
description: string;
|
|
6
|
+
ragContext: string;
|
|
7
|
+
}
|
|
8
|
+
declare const template: PromptTemplate<AgentSystemVariables>;
|
|
9
|
+
export { template as agentSystemPrompt };
|
|
10
|
+
//# sourceMappingURL=agent-system.prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-system.prompt.d.ts","sourceRoot":"","sources":["../../src/prompts/agent-system.prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAkB,MAAM,kBAAkB,CAAC;AAElE,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,QAAQ,sCAYb,CAAC;AAIF,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.agentSystemPrompt = exports.AGENT_SYSTEM_KEY = void 0;
|
|
4
|
+
const prompts_1 = require("@hazeljs/prompts");
|
|
5
|
+
exports.AGENT_SYSTEM_KEY = 'agent:system';
|
|
6
|
+
const template = new prompts_1.PromptTemplate(`{systemPrompt}
|
|
7
|
+
|
|
8
|
+
Agent description: {description}
|
|
9
|
+
|
|
10
|
+
Relevant context:
|
|
11
|
+
{ragContext}`, {
|
|
12
|
+
name: 'Agent System Prompt',
|
|
13
|
+
description: 'Assembles the main system prompt for an agent from its config and RAG context',
|
|
14
|
+
version: '1.0.0',
|
|
15
|
+
});
|
|
16
|
+
exports.agentSystemPrompt = template;
|
|
17
|
+
prompts_1.PromptRegistry.register(exports.AGENT_SYSTEM_KEY, template);
|
|
18
|
+
//# sourceMappingURL=agent-system.prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-system.prompt.js","sourceRoot":"","sources":["../../src/prompts/agent-system.prompt.ts"],"names":[],"mappings":";;;AAAA,8CAAkE;AAErD,QAAA,gBAAgB,GAAG,cAAc,CAAC;AAQ/C,MAAM,QAAQ,GAAG,IAAI,wBAAc,CACjC;;;;;aAKW,EACX;IACE,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,+EAA+E;IAC5F,OAAO,EAAE,OAAO;CACjB,CACF,CAAC;AAImB,qCAAiB;AAFtC,wBAAc,CAAC,QAAQ,CAAC,wBAAgB,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./agent-system.prompt"), exports);
|
|
18
|
+
__exportStar(require("./supervisor-system.prompt"), exports);
|
|
19
|
+
__exportStar(require("./supervisor-routing.prompt"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,6DAA2C;AAC3C,8DAA4C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PromptTemplate } from '@hazeljs/prompts';
|
|
2
|
+
export declare const SUPERVISOR_ROUTING_KEY = "agent:supervisor:routing";
|
|
3
|
+
export interface SupervisorRoutingVariables {
|
|
4
|
+
originalTask: string;
|
|
5
|
+
contextSummary: string;
|
|
6
|
+
}
|
|
7
|
+
declare const template: PromptTemplate<SupervisorRoutingVariables>;
|
|
8
|
+
export { template as supervisorRoutingPrompt };
|
|
9
|
+
//# sourceMappingURL=supervisor-routing.prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor-routing.prompt.d.ts","sourceRoot":"","sources":["../../src/prompts/supervisor-routing.prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAkB,MAAM,kBAAkB,CAAC;AAElE,eAAO,MAAM,sBAAsB,6BAA6B,CAAC;AAEjE,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,QAAQ,4CAgBb,CAAC;AAIF,OAAO,EAAE,QAAQ,IAAI,uBAAuB,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.supervisorRoutingPrompt = exports.SUPERVISOR_ROUTING_KEY = void 0;
|
|
4
|
+
const prompts_1 = require("@hazeljs/prompts");
|
|
5
|
+
exports.SUPERVISOR_ROUTING_KEY = 'agent:supervisor:routing';
|
|
6
|
+
const template = new prompts_1.PromptTemplate(`Original task: {originalTask}{contextSummary}
|
|
7
|
+
|
|
8
|
+
Decide the next action. Respond with ONLY a JSON object (no markdown):
|
|
9
|
+
{
|
|
10
|
+
"action": "delegate" | "finish",
|
|
11
|
+
"worker": "<worker name>", // required when action === "delegate"
|
|
12
|
+
"subtask": "<instructions>", // required when action === "delegate"
|
|
13
|
+
"response": "<final answer>", // required when action === "finish"
|
|
14
|
+
"thought": "<your reasoning>" // optional
|
|
15
|
+
}`, {
|
|
16
|
+
name: 'Supervisor Routing Decision',
|
|
17
|
+
description: 'Prompts the supervisor LLM to decide whether to delegate or finish',
|
|
18
|
+
version: '1.0.0',
|
|
19
|
+
});
|
|
20
|
+
exports.supervisorRoutingPrompt = template;
|
|
21
|
+
prompts_1.PromptRegistry.register(exports.SUPERVISOR_ROUTING_KEY, template);
|
|
22
|
+
//# sourceMappingURL=supervisor-routing.prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor-routing.prompt.js","sourceRoot":"","sources":["../../src/prompts/supervisor-routing.prompt.ts"],"names":[],"mappings":";;;AAAA,8CAAkE;AAErD,QAAA,sBAAsB,GAAG,0BAA0B,CAAC;AAOjE,MAAM,QAAQ,GAAG,IAAI,wBAAc,CACjC;;;;;;;;;EASA,EACA;IACE,IAAI,EAAE,6BAA6B;IACnC,WAAW,EAAE,oEAAoE;IACjF,OAAO,EAAE,OAAO;CACjB,CACF,CAAC;AAImB,2CAAuB;AAF5C,wBAAc,CAAC,QAAQ,CAAC,8BAAsB,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PromptTemplate } from '@hazeljs/prompts';
|
|
2
|
+
export declare const SUPERVISOR_SYSTEM_KEY = "agent:supervisor:system";
|
|
3
|
+
export interface SupervisorSystemVariables {
|
|
4
|
+
name: string;
|
|
5
|
+
workerList: string;
|
|
6
|
+
}
|
|
7
|
+
declare const template: PromptTemplate<SupervisorSystemVariables>;
|
|
8
|
+
export { template as supervisorSystemPrompt };
|
|
9
|
+
//# sourceMappingURL=supervisor-system.prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor-system.prompt.d.ts","sourceRoot":"","sources":["../../src/prompts/supervisor-system.prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAkB,MAAM,kBAAkB,CAAC;AAElE,eAAO,MAAM,qBAAqB,4BAA4B,CAAC;AAE/D,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,QAAQ,2CAeb,CAAC;AAIF,OAAO,EAAE,QAAQ,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.supervisorSystemPrompt = exports.SUPERVISOR_SYSTEM_KEY = void 0;
|
|
4
|
+
const prompts_1 = require("@hazeljs/prompts");
|
|
5
|
+
exports.SUPERVISOR_SYSTEM_KEY = 'agent:supervisor:system';
|
|
6
|
+
const template = new prompts_1.PromptTemplate(`You are "{name}", a supervisor agent responsible for orchestrating a team of specialized worker agents to complete complex tasks.
|
|
7
|
+
|
|
8
|
+
Your responsibilities:
|
|
9
|
+
1. Break down the user's task into subtasks
|
|
10
|
+
2. Delegate each subtask to the most appropriate worker
|
|
11
|
+
3. Review worker results and decide what to do next
|
|
12
|
+
4. When all subtasks are done, synthesize a final response
|
|
13
|
+
|
|
14
|
+
{workerList}`, {
|
|
15
|
+
name: 'Supervisor System Prompt',
|
|
16
|
+
description: 'Default system prompt for a supervisor agent with worker list',
|
|
17
|
+
version: '1.0.0',
|
|
18
|
+
});
|
|
19
|
+
exports.supervisorSystemPrompt = template;
|
|
20
|
+
prompts_1.PromptRegistry.register(exports.SUPERVISOR_SYSTEM_KEY, template);
|
|
21
|
+
//# sourceMappingURL=supervisor-system.prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor-system.prompt.js","sourceRoot":"","sources":["../../src/prompts/supervisor-system.prompt.ts"],"names":[],"mappings":";;;AAAA,8CAAkE;AAErD,QAAA,qBAAqB,GAAG,yBAAyB,CAAC;AAO/D,MAAM,QAAQ,GAAG,IAAI,wBAAc,CACjC;;;;;;;;aAQW,EACX;IACE,IAAI,EAAE,0BAA0B;IAChC,WAAW,EAAE,+DAA+D;IAC5E,OAAO,EAAE,OAAO;CACjB,CACF,CAAC;AAImB,0CAAsB;AAF3C,wBAAc,CAAC,QAAQ,CAAC,6BAAqB,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Registry
|
|
3
|
+
* Central registry for all agents in the system
|
|
4
|
+
*/
|
|
5
|
+
import { AgentMetadata } from '../types/agent.types';
|
|
6
|
+
/**
|
|
7
|
+
* Agent Registry - manages agent registration and lookup
|
|
8
|
+
*/
|
|
9
|
+
export declare class AgentRegistry {
|
|
10
|
+
private agents;
|
|
11
|
+
private instances;
|
|
12
|
+
/**
|
|
13
|
+
* Register an agent class
|
|
14
|
+
*/
|
|
15
|
+
register(agentClass: new (...args: unknown[]) => unknown): void;
|
|
16
|
+
/**
|
|
17
|
+
* Register an agent instance
|
|
18
|
+
*/
|
|
19
|
+
registerInstance(agentName: string, instance: unknown): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get agent metadata by name
|
|
22
|
+
*/
|
|
23
|
+
getAgent(name: string): AgentMetadata | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Get agent instance by name
|
|
26
|
+
*/
|
|
27
|
+
getInstance(name: string): unknown | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Get all registered agents
|
|
30
|
+
*/
|
|
31
|
+
getAllAgents(): AgentMetadata[];
|
|
32
|
+
/**
|
|
33
|
+
* Check if an agent is registered
|
|
34
|
+
*/
|
|
35
|
+
hasAgent(name: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Unregister an agent
|
|
38
|
+
*/
|
|
39
|
+
unregister(name: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Clear all agents
|
|
42
|
+
*/
|
|
43
|
+
clear(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Get agent count
|
|
46
|
+
*/
|
|
47
|
+
get count(): number;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=agent.registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.registry.d.ts","sourceRoot":"","sources":["../../src/registry/agent.registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAyC;IACvD,OAAO,CAAC,SAAS,CAAmC;IAEpD;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,IAAI;IAiB/D;;OAEG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI;IAW5D;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIjD;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI9C;;OAEG;IACH,YAAY,IAAI,aAAa,EAAE;IAI/B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI/B;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK9B;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;CACF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent Registry
|
|
4
|
+
* Central registry for all agents in the system
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.AgentRegistry = void 0;
|
|
8
|
+
const agent_decorator_1 = require("../decorators/agent.decorator");
|
|
9
|
+
/**
|
|
10
|
+
* Agent Registry - manages agent registration and lookup
|
|
11
|
+
*/
|
|
12
|
+
class AgentRegistry {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.agents = new Map();
|
|
15
|
+
this.instances = new Map();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Register an agent class
|
|
19
|
+
*/
|
|
20
|
+
register(agentClass) {
|
|
21
|
+
if (!(0, agent_decorator_1.isAgent)(agentClass)) {
|
|
22
|
+
throw new Error(`Class ${agentClass.name} is not decorated with @Agent`);
|
|
23
|
+
}
|
|
24
|
+
const metadata = (0, agent_decorator_1.getAgentMetadata)(agentClass);
|
|
25
|
+
if (!metadata) {
|
|
26
|
+
throw new Error(`Failed to get metadata for agent ${agentClass.name}`);
|
|
27
|
+
}
|
|
28
|
+
if (this.agents.has(metadata.name)) {
|
|
29
|
+
throw new Error(`Agent ${metadata.name} is already registered`);
|
|
30
|
+
}
|
|
31
|
+
this.agents.set(metadata.name, metadata);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Register an agent instance
|
|
35
|
+
*/
|
|
36
|
+
registerInstance(agentName, instance) {
|
|
37
|
+
if (!this.agents.has(agentName)) {
|
|
38
|
+
throw new Error(`Agent ${agentName} is not registered`);
|
|
39
|
+
}
|
|
40
|
+
this.instances.set(agentName, instance);
|
|
41
|
+
const metadata = this.agents.get(agentName);
|
|
42
|
+
metadata.instance = instance;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get agent metadata by name
|
|
46
|
+
*/
|
|
47
|
+
getAgent(name) {
|
|
48
|
+
return this.agents.get(name);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get agent instance by name
|
|
52
|
+
*/
|
|
53
|
+
getInstance(name) {
|
|
54
|
+
return this.instances.get(name);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get all registered agents
|
|
58
|
+
*/
|
|
59
|
+
getAllAgents() {
|
|
60
|
+
return Array.from(this.agents.values());
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if an agent is registered
|
|
64
|
+
*/
|
|
65
|
+
hasAgent(name) {
|
|
66
|
+
return this.agents.has(name);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Unregister an agent
|
|
70
|
+
*/
|
|
71
|
+
unregister(name) {
|
|
72
|
+
this.agents.delete(name);
|
|
73
|
+
this.instances.delete(name);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Clear all agents
|
|
77
|
+
*/
|
|
78
|
+
clear() {
|
|
79
|
+
this.agents.clear();
|
|
80
|
+
this.instances.clear();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get agent count
|
|
84
|
+
*/
|
|
85
|
+
get count() {
|
|
86
|
+
return this.agents.size;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.AgentRegistry = AgentRegistry;
|
|
90
|
+
//# sourceMappingURL=agent.registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.registry.js","sourceRoot":"","sources":["../../src/registry/agent.registry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,mEAA0E;AAE1E;;GAEG;AACH,MAAa,aAAa;IAA1B;QACU,WAAM,GAA+B,IAAI,GAAG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