@agentionai/agents 0.4.1 → 0.6.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.
- package/README.md +2 -2
- package/dist/agents/Agent.d.ts +1 -1
- package/dist/core.d.ts +0 -1
- package/dist/core.js +2 -1
- package/dist/{vectorstore → embeddings}/OpenAIEmbeddings.d.ts +10 -2
- package/dist/{vectorstore → embeddings}/OpenAIEmbeddings.js +5 -1
- package/dist/embeddings/VoyageAIEmbeddings.d.ts +80 -0
- package/dist/embeddings/VoyageAIEmbeddings.js +138 -0
- package/dist/embeddings/index.d.ts +23 -0
- package/dist/embeddings/index.js +29 -0
- package/dist/graph/AgentGraph.d.ts +77 -0
- package/dist/graph/AgentGraph.js +112 -1
- package/dist/graph/context/ContextStore.d.ts +69 -0
- package/dist/graph/context/ContextStore.js +101 -0
- package/dist/graph/context/ContextTools.d.ts +52 -0
- package/dist/graph/context/ContextTools.js +148 -0
- package/dist/graph/context/index.d.ts +3 -0
- package/dist/graph/context/index.js +11 -0
- package/dist/graph/planning/PlanExecutor.d.ts +172 -0
- package/dist/graph/planning/PlanExecutor.js +341 -0
- package/dist/graph/planning/PlanStore.d.ts +81 -0
- package/dist/graph/planning/PlanStore.js +195 -0
- package/dist/graph/planning/PlanningTools.d.ts +45 -0
- package/dist/graph/planning/PlanningTools.js +178 -0
- package/dist/graph/planning/index.d.ts +5 -0
- package/dist/graph/planning/index.js +14 -0
- package/dist/graph/planning/types.d.ts +41 -0
- package/dist/graph/planning/types.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/ingestion/IngestionPipeline.d.ts +1 -1
- package/dist/vectorstore/LanceDBVectorStore.d.ts +67 -2
- package/dist/vectorstore/LanceDBVectorStore.js +134 -23
- package/dist/vectorstore/index.d.ts +6 -4
- package/dist/vectorstore/index.js +10 -6
- package/package.json +12 -3
- /package/dist/{vectorstore → embeddings}/Embeddings.d.ts +0 -0
- /package/dist/{vectorstore → embeddings}/Embeddings.js +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple key-value store for sharing data between agents in a graph.
|
|
3
|
+
* Accessed via tools with descriptive keys.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const store = new ContextStore({ userId: '123' });
|
|
8
|
+
* store.set('research_findings', { topic: 'AI', summary: '...' });
|
|
9
|
+
* const findings = store.get<{ topic: string; summary: string }>('research_findings');
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare class ContextStore {
|
|
13
|
+
private store;
|
|
14
|
+
/**
|
|
15
|
+
* Create a new ContextStore with optional initial values.
|
|
16
|
+
* @param initial - Initial key-value pairs to populate the store
|
|
17
|
+
*/
|
|
18
|
+
constructor(initial?: Record<string, unknown>);
|
|
19
|
+
/**
|
|
20
|
+
* Set a value with a descriptive key.
|
|
21
|
+
* @param key - A descriptive key for this value (e.g., "research_findings", "user_preferences")
|
|
22
|
+
* @param value - The value to store
|
|
23
|
+
*/
|
|
24
|
+
set<T>(key: string, value: T): void;
|
|
25
|
+
/**
|
|
26
|
+
* Get a value by key.
|
|
27
|
+
* @param key - The key to retrieve
|
|
28
|
+
* @returns The value if found, undefined otherwise
|
|
29
|
+
*/
|
|
30
|
+
get<T>(key: string): T | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a key exists in the store.
|
|
33
|
+
* @param key - The key to check
|
|
34
|
+
* @returns True if the key exists
|
|
35
|
+
*/
|
|
36
|
+
has(key: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Delete a key from the store.
|
|
39
|
+
* @param key - The key to delete
|
|
40
|
+
* @returns True if the key was deleted, false if it didn't exist
|
|
41
|
+
*/
|
|
42
|
+
delete(key: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Get all keys in the store.
|
|
45
|
+
* @returns Array of all keys
|
|
46
|
+
*/
|
|
47
|
+
keys(): string[];
|
|
48
|
+
/**
|
|
49
|
+
* Get the number of entries in the store.
|
|
50
|
+
* @returns The number of entries
|
|
51
|
+
*/
|
|
52
|
+
get size(): number;
|
|
53
|
+
/**
|
|
54
|
+
* Get all entries as a plain object.
|
|
55
|
+
* @returns Object with all key-value pairs
|
|
56
|
+
*/
|
|
57
|
+
toObject(): Record<string, unknown>;
|
|
58
|
+
/**
|
|
59
|
+
* Clear all entries from the store.
|
|
60
|
+
*/
|
|
61
|
+
clear(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Create a clone of this context store.
|
|
64
|
+
* Note: This performs a shallow clone of values.
|
|
65
|
+
* @returns A new ContextStore with the same entries
|
|
66
|
+
*/
|
|
67
|
+
clone(): ContextStore;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=ContextStore.d.ts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextStore = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Simple key-value store for sharing data between agents in a graph.
|
|
6
|
+
* Accessed via tools with descriptive keys.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const store = new ContextStore({ userId: '123' });
|
|
11
|
+
* store.set('research_findings', { topic: 'AI', summary: '...' });
|
|
12
|
+
* const findings = store.get<{ topic: string; summary: string }>('research_findings');
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
class ContextStore {
|
|
16
|
+
/**
|
|
17
|
+
* Create a new ContextStore with optional initial values.
|
|
18
|
+
* @param initial - Initial key-value pairs to populate the store
|
|
19
|
+
*/
|
|
20
|
+
constructor(initial) {
|
|
21
|
+
this.store = new Map();
|
|
22
|
+
if (initial) {
|
|
23
|
+
for (const [key, value] of Object.entries(initial)) {
|
|
24
|
+
this.store.set(key, value);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Set a value with a descriptive key.
|
|
30
|
+
* @param key - A descriptive key for this value (e.g., "research_findings", "user_preferences")
|
|
31
|
+
* @param value - The value to store
|
|
32
|
+
*/
|
|
33
|
+
set(key, value) {
|
|
34
|
+
this.store.set(key, value);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get a value by key.
|
|
38
|
+
* @param key - The key to retrieve
|
|
39
|
+
* @returns The value if found, undefined otherwise
|
|
40
|
+
*/
|
|
41
|
+
get(key) {
|
|
42
|
+
return this.store.get(key);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Check if a key exists in the store.
|
|
46
|
+
* @param key - The key to check
|
|
47
|
+
* @returns True if the key exists
|
|
48
|
+
*/
|
|
49
|
+
has(key) {
|
|
50
|
+
return this.store.has(key);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Delete a key from the store.
|
|
54
|
+
* @param key - The key to delete
|
|
55
|
+
* @returns True if the key was deleted, false if it didn't exist
|
|
56
|
+
*/
|
|
57
|
+
delete(key) {
|
|
58
|
+
return this.store.delete(key);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get all keys in the store.
|
|
62
|
+
* @returns Array of all keys
|
|
63
|
+
*/
|
|
64
|
+
keys() {
|
|
65
|
+
return Array.from(this.store.keys());
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get the number of entries in the store.
|
|
69
|
+
* @returns The number of entries
|
|
70
|
+
*/
|
|
71
|
+
get size() {
|
|
72
|
+
return this.store.size;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get all entries as a plain object.
|
|
76
|
+
* @returns Object with all key-value pairs
|
|
77
|
+
*/
|
|
78
|
+
toObject() {
|
|
79
|
+
const obj = {};
|
|
80
|
+
for (const [key, value] of this.store) {
|
|
81
|
+
obj[key] = value;
|
|
82
|
+
}
|
|
83
|
+
return obj;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Clear all entries from the store.
|
|
87
|
+
*/
|
|
88
|
+
clear() {
|
|
89
|
+
this.store.clear();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create a clone of this context store.
|
|
93
|
+
* Note: This performs a shallow clone of values.
|
|
94
|
+
* @returns A new ContextStore with the same entries
|
|
95
|
+
*/
|
|
96
|
+
clone() {
|
|
97
|
+
return new ContextStore(this.toObject());
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.ContextStore = ContextStore;
|
|
101
|
+
//# sourceMappingURL=ContextStore.js.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Tool } from "../../tools/Tool";
|
|
2
|
+
import { ContextStore } from "./ContextStore";
|
|
3
|
+
/**
|
|
4
|
+
* Create a tool for agents to read from shared context.
|
|
5
|
+
*
|
|
6
|
+
* @param store - The ContextStore to read from
|
|
7
|
+
* @returns A Tool that retrieves values from the context store
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const store = new ContextStore();
|
|
12
|
+
* const getTool = createContextGetTool(store);
|
|
13
|
+
* agent.addTools([getTool]);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function createContextGetTool(store: ContextStore): Tool<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Create a tool for agents to write to shared context.
|
|
19
|
+
*
|
|
20
|
+
* @param store - The ContextStore to write to
|
|
21
|
+
* @returns A Tool that stores values in the context store
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const store = new ContextStore();
|
|
26
|
+
* const setTool = createContextSetTool(store);
|
|
27
|
+
* agent.addTools([setTool]);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function createContextSetTool(store: ContextStore): Tool<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Create a tool for agents to list available context keys.
|
|
33
|
+
*
|
|
34
|
+
* @param store - The ContextStore to list keys from
|
|
35
|
+
* @returns A Tool that lists all keys in the context store
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const store = new ContextStore();
|
|
40
|
+
* const listTool = createContextListTool(store);
|
|
41
|
+
* agent.addTools([listTool]);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function createContextListTool(store: ContextStore): Tool<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Create a tool for agents to delete a key from context.
|
|
47
|
+
*
|
|
48
|
+
* @param store - The ContextStore to delete from
|
|
49
|
+
* @returns A Tool that deletes keys from the context store
|
|
50
|
+
*/
|
|
51
|
+
export declare function createContextDeleteTool(store: ContextStore): Tool<string>;
|
|
52
|
+
//# sourceMappingURL=ContextTools.d.ts.map
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createContextGetTool = createContextGetTool;
|
|
4
|
+
exports.createContextSetTool = createContextSetTool;
|
|
5
|
+
exports.createContextListTool = createContextListTool;
|
|
6
|
+
exports.createContextDeleteTool = createContextDeleteTool;
|
|
7
|
+
const Tool_1 = require("../../tools/Tool");
|
|
8
|
+
/**
|
|
9
|
+
* Create a tool for agents to read from shared context.
|
|
10
|
+
*
|
|
11
|
+
* @param store - The ContextStore to read from
|
|
12
|
+
* @returns A Tool that retrieves values from the context store
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const store = new ContextStore();
|
|
17
|
+
* const getTool = createContextGetTool(store);
|
|
18
|
+
* agent.addTools([getTool]);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function createContextGetTool(store) {
|
|
22
|
+
return new Tool_1.Tool({
|
|
23
|
+
name: "context_get",
|
|
24
|
+
description: "Get a value from shared context by its descriptive key. Use list_context_keys first to see available keys.",
|
|
25
|
+
inputSchema: {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
key: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "The descriptive key to retrieve",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
required: ["key"],
|
|
34
|
+
},
|
|
35
|
+
execute: async (input) => {
|
|
36
|
+
const value = store.get(input.key);
|
|
37
|
+
if (value === undefined) {
|
|
38
|
+
return JSON.stringify({
|
|
39
|
+
error: `Key "${input.key}" not found`,
|
|
40
|
+
availableKeys: store.keys(),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return JSON.stringify({ key: input.key, value });
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a tool for agents to write to shared context.
|
|
49
|
+
*
|
|
50
|
+
* @param store - The ContextStore to write to
|
|
51
|
+
* @returns A Tool that stores values in the context store
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const store = new ContextStore();
|
|
56
|
+
* const setTool = createContextSetTool(store);
|
|
57
|
+
* agent.addTools([setTool]);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
function createContextSetTool(store) {
|
|
61
|
+
return new Tool_1.Tool({
|
|
62
|
+
name: "context_set",
|
|
63
|
+
description: 'Store a value in shared context with a descriptive key. Use clear, descriptive keys like "research_findings", "user_preferences", "analysis_results".',
|
|
64
|
+
inputSchema: {
|
|
65
|
+
type: "object",
|
|
66
|
+
properties: {
|
|
67
|
+
key: {
|
|
68
|
+
type: "string",
|
|
69
|
+
description: "A descriptive key for this value",
|
|
70
|
+
},
|
|
71
|
+
value: {
|
|
72
|
+
type: "string",
|
|
73
|
+
description: "The value to store (JSON string for complex data)",
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
required: ["key", "value"],
|
|
77
|
+
},
|
|
78
|
+
execute: async (input) => {
|
|
79
|
+
// Try to parse JSON, otherwise store as string
|
|
80
|
+
let parsedValue = input.value;
|
|
81
|
+
try {
|
|
82
|
+
parsedValue = JSON.parse(input.value);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Keep as string if not valid JSON
|
|
86
|
+
}
|
|
87
|
+
store.set(input.key, parsedValue);
|
|
88
|
+
return JSON.stringify({ success: true, key: input.key });
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create a tool for agents to list available context keys.
|
|
94
|
+
*
|
|
95
|
+
* @param store - The ContextStore to list keys from
|
|
96
|
+
* @returns A Tool that lists all keys in the context store
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const store = new ContextStore();
|
|
101
|
+
* const listTool = createContextListTool(store);
|
|
102
|
+
* agent.addTools([listTool]);
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
function createContextListTool(store) {
|
|
106
|
+
return new Tool_1.Tool({
|
|
107
|
+
name: "list_context_keys",
|
|
108
|
+
description: "List all available keys in the shared context.",
|
|
109
|
+
inputSchema: {
|
|
110
|
+
type: "object",
|
|
111
|
+
properties: {},
|
|
112
|
+
},
|
|
113
|
+
execute: async () => {
|
|
114
|
+
return JSON.stringify({ keys: store.keys() });
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Create a tool for agents to delete a key from context.
|
|
120
|
+
*
|
|
121
|
+
* @param store - The ContextStore to delete from
|
|
122
|
+
* @returns A Tool that deletes keys from the context store
|
|
123
|
+
*/
|
|
124
|
+
function createContextDeleteTool(store) {
|
|
125
|
+
return new Tool_1.Tool({
|
|
126
|
+
name: "context_delete",
|
|
127
|
+
description: "Delete a key from the shared context.",
|
|
128
|
+
inputSchema: {
|
|
129
|
+
type: "object",
|
|
130
|
+
properties: {
|
|
131
|
+
key: {
|
|
132
|
+
type: "string",
|
|
133
|
+
description: "The key to delete",
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
required: ["key"],
|
|
137
|
+
},
|
|
138
|
+
execute: async (input) => {
|
|
139
|
+
const existed = store.delete(input.key);
|
|
140
|
+
return JSON.stringify({
|
|
141
|
+
success: true,
|
|
142
|
+
deleted: existed,
|
|
143
|
+
key: input.key,
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=ContextTools.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createContextDeleteTool = exports.createContextListTool = exports.createContextSetTool = exports.createContextGetTool = exports.ContextStore = void 0;
|
|
4
|
+
var ContextStore_1 = require("./ContextStore");
|
|
5
|
+
Object.defineProperty(exports, "ContextStore", { enumerable: true, get: function () { return ContextStore_1.ContextStore; } });
|
|
6
|
+
var ContextTools_1 = require("./ContextTools");
|
|
7
|
+
Object.defineProperty(exports, "createContextGetTool", { enumerable: true, get: function () { return ContextTools_1.createContextGetTool; } });
|
|
8
|
+
Object.defineProperty(exports, "createContextSetTool", { enumerable: true, get: function () { return ContextTools_1.createContextSetTool; } });
|
|
9
|
+
Object.defineProperty(exports, "createContextListTool", { enumerable: true, get: function () { return ContextTools_1.createContextListTool; } });
|
|
10
|
+
Object.defineProperty(exports, "createContextDeleteTool", { enumerable: true, get: function () { return ContextTools_1.createContextDeleteTool; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { BaseAgent } from "../../agents/BaseAgent";
|
|
2
|
+
import { BaseExecutor, GraphNode } from "../BaseExecutor";
|
|
3
|
+
import { PlanStore } from "./PlanStore";
|
|
4
|
+
import { PlanStep } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Options for PlanExecutor
|
|
7
|
+
*/
|
|
8
|
+
export interface PlanExecutorOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Maximum number of steps to execute.
|
|
11
|
+
* @default 50
|
|
12
|
+
*/
|
|
13
|
+
maxSteps?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of steps to execute concurrently.
|
|
16
|
+
* Set to 1 for sequential execution (default).
|
|
17
|
+
* Set to higher values to execute independent steps in parallel.
|
|
18
|
+
* @default 1
|
|
19
|
+
*/
|
|
20
|
+
concurrency?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to stop execution when a step fails.
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
stopOnFailure?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Callback invoked when planning phase completes.
|
|
28
|
+
*/
|
|
29
|
+
onPlanCreated?: (goal: string, steps: PlanStep[]) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Callback invoked before each step starts.
|
|
32
|
+
*/
|
|
33
|
+
onStepStart?: (step: PlanStep, stepNumber: number, totalSteps: number) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Callback invoked after each step completes.
|
|
36
|
+
*/
|
|
37
|
+
onStepComplete?: (step: PlanStep, result: string, stepNumber: number) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Callback invoked when a step fails.
|
|
40
|
+
*/
|
|
41
|
+
onStepFailed?: (step: PlanStep, error: Error, stepNumber: number) => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Result of a plan execution.
|
|
45
|
+
*/
|
|
46
|
+
export interface PlanExecutionResult {
|
|
47
|
+
success: boolean;
|
|
48
|
+
goal: string;
|
|
49
|
+
totalSteps: number;
|
|
50
|
+
completedSteps: number;
|
|
51
|
+
failedSteps: number;
|
|
52
|
+
summary: string;
|
|
53
|
+
/**
|
|
54
|
+
* Clean, consolidated output for chaining to next graph node.
|
|
55
|
+
* Contains a rollup of all step results in a format ready for downstream processing.
|
|
56
|
+
*/
|
|
57
|
+
finalOutput: string;
|
|
58
|
+
/**
|
|
59
|
+
* Detailed results for each step (useful for debugging/inspection).
|
|
60
|
+
*/
|
|
61
|
+
stepResults: Array<{
|
|
62
|
+
step: PlanStep;
|
|
63
|
+
result?: string;
|
|
64
|
+
error?: string;
|
|
65
|
+
}>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Orchestrates plan-based execution with clear separation of concerns:
|
|
69
|
+
* 1. Planning Phase: Uses a planning agent to create a plan
|
|
70
|
+
* 2. Execution Phase: Assigns workers (agents or graph nodes) to execute each step
|
|
71
|
+
* 3. Completion: Compiles results and returns summary
|
|
72
|
+
*
|
|
73
|
+
* The PlanExecutor acts as the orchestrator, tracking progress and delegating
|
|
74
|
+
* work to specialized workers. Planning and execution are separate phases.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const planStore = AgentGraph.createPlanStore();
|
|
79
|
+
* const contextStore = AgentGraph.createContextStore();
|
|
80
|
+
*
|
|
81
|
+
* // Planning agent creates the plan
|
|
82
|
+
* const planner = new ClaudeAgent({
|
|
83
|
+
* tools: AgentGraph.createPlanningTools(planStore),
|
|
84
|
+
* description: 'You are a planning agent. Create a detailed plan with clear steps.',
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* // Worker agent executes individual steps
|
|
88
|
+
* const worker = new ClaudeAgent({
|
|
89
|
+
* tools: AgentGraph.createContextTools(contextStore),
|
|
90
|
+
* description: 'You execute a single step. Store results in context.',
|
|
91
|
+
* });
|
|
92
|
+
*
|
|
93
|
+
* const executor = new PlanExecutor(planStore, planner, worker, {
|
|
94
|
+
* onStepComplete: (step, result, num) => {
|
|
95
|
+
* console.log(`Completed step ${num}: ${step.description}`);
|
|
96
|
+
* },
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* const result = await executor.execute('Research and summarize quantum computing');
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare class PlanExecutor extends BaseExecutor<string, string> {
|
|
103
|
+
private planStore;
|
|
104
|
+
private planningAgent;
|
|
105
|
+
private worker;
|
|
106
|
+
private lastResult?;
|
|
107
|
+
private options;
|
|
108
|
+
/**
|
|
109
|
+
* Create a new PlanExecutor.
|
|
110
|
+
*
|
|
111
|
+
* @param planStore - The plan store to track plan state
|
|
112
|
+
* @param planningAgent - Agent responsible for creating the plan
|
|
113
|
+
* @param worker - Agent or GraphNode that executes individual steps
|
|
114
|
+
* @param options - Configuration options
|
|
115
|
+
*/
|
|
116
|
+
constructor(planStore: PlanStore, planningAgent: BaseAgent, worker: GraphNode<string, string> | BaseAgent, options?: PlanExecutorOptions);
|
|
117
|
+
/**
|
|
118
|
+
* Execute the plan:
|
|
119
|
+
* 1. Planning Phase: Ask planning agent to create a plan
|
|
120
|
+
* 2. Execution Phase: Execute each step with the worker
|
|
121
|
+
* 3. Completion: Return finalOutput (for chaining)
|
|
122
|
+
*
|
|
123
|
+
* Returns the finalOutput string for easy chaining in pipelines.
|
|
124
|
+
* Use getLastResult() to access the full PlanExecutionResult with details.
|
|
125
|
+
*/
|
|
126
|
+
execute(input: string): Promise<string>;
|
|
127
|
+
/**
|
|
128
|
+
* Get the detailed result from the last execution.
|
|
129
|
+
* Contains full plan details, step results, and metadata.
|
|
130
|
+
*/
|
|
131
|
+
getLastResult(): PlanExecutionResult | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Phase 1: Planning
|
|
134
|
+
* Instructs the planning agent to create a plan based on the task.
|
|
135
|
+
*/
|
|
136
|
+
private planningPhase;
|
|
137
|
+
/**
|
|
138
|
+
* Phase 2: Execution
|
|
139
|
+
* Executes each step in the plan using the worker.
|
|
140
|
+
*/
|
|
141
|
+
private executionPhase;
|
|
142
|
+
/**
|
|
143
|
+
* Create a prompt for the planning agent.
|
|
144
|
+
*/
|
|
145
|
+
private createPlanningPrompt;
|
|
146
|
+
/**
|
|
147
|
+
* Create input for a step execution.
|
|
148
|
+
*/
|
|
149
|
+
private createStepInput;
|
|
150
|
+
/**
|
|
151
|
+
* Compile the final result from step results.
|
|
152
|
+
*/
|
|
153
|
+
private compileResult;
|
|
154
|
+
/**
|
|
155
|
+
* Create a clean, consolidated output from all step results.
|
|
156
|
+
* This output is designed for chaining to the next graph node.
|
|
157
|
+
*/
|
|
158
|
+
private createFinalOutput;
|
|
159
|
+
/**
|
|
160
|
+
* Check if a worker is a BaseAgent.
|
|
161
|
+
*/
|
|
162
|
+
private isAgent;
|
|
163
|
+
/**
|
|
164
|
+
* Extract token usage from an agent if available.
|
|
165
|
+
*/
|
|
166
|
+
private extractTokenUsage;
|
|
167
|
+
/**
|
|
168
|
+
* Get the plan store.
|
|
169
|
+
*/
|
|
170
|
+
getPlanStore(): PlanStore;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=PlanExecutor.d.ts.map
|