@hazeljs/agent 0.2.0-beta.8 → 0.2.0-beta.81
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/LICENSE +192 -21
- package/README.md +372 -258
- package/coverage/clover.xml +853 -576
- package/coverage/lcov-report/index.html +107 -62
- package/coverage/lcov.info +1428 -945
- package/dist/agent.module.d.ts +16 -1
- package/dist/agent.module.d.ts.map +1 -1
- package/dist/agent.module.js +14 -5
- package/dist/agent.module.js.map +1 -1
- 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/executor/agent.executor.d.ts +1 -0
- package/dist/executor/agent.executor.d.ts.map +1 -1
- package/dist/executor/agent.executor.js +19 -10
- package/dist/executor/agent.executor.js.map +1 -1
- package/dist/executor/tool.executor.d.ts +3 -1
- package/dist/executor/tool.executor.d.ts.map +1 -1
- package/dist/executor/tool.executor.js +33 -2
- package/dist/executor/tool.executor.js.map +1 -1
- 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 +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- 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/runtime/agent.runtime.d.ts +65 -2
- package/dist/runtime/agent.runtime.d.ts.map +1 -1
- package/dist/runtime/agent.runtime.js +105 -4
- package/dist/runtime/agent.runtime.js.map +1 -1
- 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 +15 -0
- package/dist/types/agent.types.d.ts.map +1 -1
- package/dist/types/agent.types.js.map +1 -1
- package/dist/types/event.types.d.ts +76 -1
- package/dist/types/event.types.d.ts.map +1 -1
- package/dist/types/event.types.js +16 -0
- package/dist/types/event.types.js.map +1 -1
- package/dist/utils/circuit-breaker.d.ts +5 -65
- package/dist/utils/circuit-breaker.d.ts.map +1 -1
- package/dist/utils/circuit-breaker.js +10 -150
- package/dist/utils/circuit-breaker.js.map +1 -1
- package/logs/combined.log +1 -1
- package/package.json +23 -8
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -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;AACH,MAAM,WAAW,UAAU;IACzB,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CA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AM,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
CHANGED
|
@@ -9,6 +9,7 @@ export * from './types/llm.types';
|
|
|
9
9
|
export * from './types/rag.types';
|
|
10
10
|
export * from './decorators/agent.decorator';
|
|
11
11
|
export * from './decorators/tool.decorator';
|
|
12
|
+
export * from './decorators/delegate.decorator';
|
|
12
13
|
export * from './registry/agent.registry';
|
|
13
14
|
export * from './registry/tool.registry';
|
|
14
15
|
export * from './state/agent.state';
|
|
@@ -26,5 +27,8 @@ export * from './utils/metrics';
|
|
|
26
27
|
export * from './utils/retry';
|
|
27
28
|
export * from './utils/circuit-breaker';
|
|
28
29
|
export * from './utils/health-check';
|
|
30
|
+
export * from './graph/agent-graph.types';
|
|
31
|
+
export * from './graph/agent-graph';
|
|
32
|
+
export * from './supervisor/supervisor';
|
|
29
33
|
export * from './agent.module';
|
|
30
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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
CHANGED
|
@@ -25,6 +25,7 @@ __exportStar(require("./types/llm.types"), exports);
|
|
|
25
25
|
__exportStar(require("./types/rag.types"), exports);
|
|
26
26
|
__exportStar(require("./decorators/agent.decorator"), exports);
|
|
27
27
|
__exportStar(require("./decorators/tool.decorator"), exports);
|
|
28
|
+
__exportStar(require("./decorators/delegate.decorator"), exports);
|
|
28
29
|
__exportStar(require("./registry/agent.registry"), exports);
|
|
29
30
|
__exportStar(require("./registry/tool.registry"), exports);
|
|
30
31
|
__exportStar(require("./state/agent.state"), exports);
|
|
@@ -42,5 +43,9 @@ __exportStar(require("./utils/metrics"), exports);
|
|
|
42
43
|
__exportStar(require("./utils/retry"), exports);
|
|
43
44
|
__exportStar(require("./utils/circuit-breaker"), exports);
|
|
44
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);
|
|
45
50
|
__exportStar(require("./agent.module"), exports);
|
|
46
51
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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;
|
|
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"}
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
* Main runtime for managing agent lifecycle and execution
|
|
4
4
|
*/
|
|
5
5
|
import { IAgentStateManager } from '../state/agent-state.interface';
|
|
6
|
-
import { AgentExecutionOptions, AgentExecutionResult, AgentContext } from '../types/agent.types';
|
|
6
|
+
import { AgentExecutionOptions, AgentExecutionResult, AgentContext, IGuardrailsService } from '../types/agent.types';
|
|
7
7
|
import { AgentEventType } from '../types/event.types';
|
|
8
8
|
import { LLMProvider } from '../types/llm.types';
|
|
9
9
|
import { RAGService } from '../types/rag.types';
|
|
10
10
|
import { MemoryManager } from '@hazeljs/rag';
|
|
11
11
|
import { LogLevel } from '../utils/logger';
|
|
12
12
|
import { HealthCheckResult } from '../utils/health-check';
|
|
13
|
+
import { AgentGraph } from '../graph/agent-graph';
|
|
14
|
+
import { SupervisorAgent } from '../supervisor/supervisor';
|
|
15
|
+
import { SupervisorConfig } from '../graph/agent-graph.types';
|
|
13
16
|
/**
|
|
14
17
|
* Agent Runtime Configuration
|
|
15
18
|
*/
|
|
@@ -18,6 +21,7 @@ export interface AgentRuntimeConfig {
|
|
|
18
21
|
memoryManager?: MemoryManager;
|
|
19
22
|
ragService?: RAGService;
|
|
20
23
|
llmProvider?: LLMProvider;
|
|
24
|
+
guardrailsService?: IGuardrailsService;
|
|
21
25
|
defaultMaxSteps?: number;
|
|
22
26
|
defaultTimeout?: number;
|
|
23
27
|
enableObservability?: boolean;
|
|
@@ -52,9 +56,16 @@ export declare class AgentRuntime {
|
|
|
52
56
|
*/
|
|
53
57
|
registerAgent(agentClass: new (...args: unknown[]) => unknown): void;
|
|
54
58
|
/**
|
|
55
|
-
* Register an agent instance
|
|
59
|
+
* Register an agent instance.
|
|
60
|
+
* Also patches any @Delegate-decorated methods so they call the target agent
|
|
61
|
+
* via this runtime rather than executing the original (stub) method body.
|
|
56
62
|
*/
|
|
57
63
|
registerAgentInstance(agentName: string, instance: unknown): void;
|
|
64
|
+
/**
|
|
65
|
+
* Replace @Delegate stub methods on an agent instance with real runtime calls.
|
|
66
|
+
* Called automatically by registerAgentInstance().
|
|
67
|
+
*/
|
|
68
|
+
private patchDelegateMethods;
|
|
58
69
|
/**
|
|
59
70
|
* Execute an agent
|
|
60
71
|
*/
|
|
@@ -143,6 +154,58 @@ export declare class AgentRuntime {
|
|
|
143
154
|
* Get pending tool approvals
|
|
144
155
|
*/
|
|
145
156
|
getPendingApprovals(): import('../types/tool.types').ToolApprovalRequest[];
|
|
157
|
+
/**
|
|
158
|
+
* Create a new `AgentGraph` builder for this runtime.
|
|
159
|
+
*
|
|
160
|
+
* @param graphId A unique identifier for the graph (used in logs/events).
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* const graph = runtime.createGraph('research-pipeline')
|
|
165
|
+
* .addNode('researcher', { type: 'agent', agentName: 'ResearchAgent' })
|
|
166
|
+
* .addNode('writer', { type: 'agent', agentName: 'WriterAgent' })
|
|
167
|
+
* .addEdge('researcher', 'writer')
|
|
168
|
+
* .addEdge('writer', '__end__')
|
|
169
|
+
* .setEntryPoint('researcher')
|
|
170
|
+
* .compile();
|
|
171
|
+
*
|
|
172
|
+
* const result = await graph.execute('Write an article about LLMs');
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
createGraph(graphId: string): AgentGraph;
|
|
176
|
+
/**
|
|
177
|
+
* Create a `SupervisorAgent` that orchestrates a team of worker agents.
|
|
178
|
+
*
|
|
179
|
+
* Requires an LLM provider to be configured on the runtime.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* const supervisor = runtime.createSupervisor({
|
|
184
|
+
* name: 'project-manager',
|
|
185
|
+
* workers: ['ResearchAgent', 'CoderAgent', 'WriterAgent'],
|
|
186
|
+
* maxRounds: 6,
|
|
187
|
+
* });
|
|
188
|
+
*
|
|
189
|
+
* const result = await supervisor.run('Build a REST API for a todo app');
|
|
190
|
+
* console.log(result.response);
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
createSupervisor(config: SupervisorConfig): SupervisorAgent;
|
|
194
|
+
/**
|
|
195
|
+
* Dynamically spawn a new agent execution and return its result.
|
|
196
|
+
* Useful inside @Tool methods when one agent needs to call another.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* @Tool({ description: 'Research and summarize a topic' })
|
|
201
|
+
* async researchAndSummarize(topic: string) {
|
|
202
|
+
* const research = await this.runtime.spawn('ResearchAgent', topic);
|
|
203
|
+
* const summary = await this.runtime.spawn('SummaryAgent', research.response ?? '');
|
|
204
|
+
* return summary.response;
|
|
205
|
+
* }
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
spawn(agentName: string, input: string, options?: AgentExecutionOptions): Promise<AgentExecutionResult>;
|
|
146
209
|
/**
|
|
147
210
|
* Shutdown the runtime
|
|
148
211
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/agent.runtime.ts"],"names":[],"mappings":"AAAA;;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