@agentionai/agents 0.4.2 → 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/{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
package/README.md
CHANGED
|
@@ -86,14 +86,14 @@ import { GeminiAgent, Tool } from '@agentionai/agents/gemini';
|
|
|
86
86
|
const weatherTool = new Tool({
|
|
87
87
|
name: 'get_weather',
|
|
88
88
|
description: 'Get the current weather for a location',
|
|
89
|
-
|
|
89
|
+
inputSchema: {
|
|
90
90
|
type: 'object',
|
|
91
91
|
properties: {
|
|
92
92
|
location: { type: 'string', description: 'City name' },
|
|
93
93
|
},
|
|
94
94
|
required: ['location'],
|
|
95
95
|
},
|
|
96
|
-
|
|
96
|
+
execute: async ({ location }) => {
|
|
97
97
|
// In production, call a weather API
|
|
98
98
|
return JSON.stringify({
|
|
99
99
|
location,
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* OpenAI embeddings implementation.
|
|
3
3
|
*
|
|
4
|
-
* @requires openai - Uses the OpenAI SDK (
|
|
4
|
+
* @requires openai - Uses the OpenAI SDK (peer dependency, dynamically imported)
|
|
5
5
|
*/
|
|
6
6
|
import { Embeddings } from "./Embeddings";
|
|
7
|
+
/**
|
|
8
|
+
* Available OpenAI embedding models with their dimensions.
|
|
9
|
+
*/
|
|
10
|
+
export type OpenAIEmbeddingModel = "text-embedding-3-small" | "text-embedding-3-large" | "text-embedding-ada-002";
|
|
7
11
|
/**
|
|
8
12
|
* Configuration for OpenAI embeddings.
|
|
9
13
|
*/
|
|
@@ -11,7 +15,7 @@ export interface OpenAIEmbeddingsConfig {
|
|
|
11
15
|
/** OpenAI API key (defaults to OPENAI_API_KEY env var) */
|
|
12
16
|
apiKey?: string;
|
|
13
17
|
/** Model to use for embeddings */
|
|
14
|
-
model?:
|
|
18
|
+
model?: OpenAIEmbeddingModel | string;
|
|
15
19
|
/** Number of dimensions (only for text-embedding-3-* models) */
|
|
16
20
|
dimensions?: number;
|
|
17
21
|
/** Base URL for API (for proxies or compatible APIs) */
|
|
@@ -20,10 +24,14 @@ export interface OpenAIEmbeddingsConfig {
|
|
|
20
24
|
/**
|
|
21
25
|
* OpenAI embeddings provider.
|
|
22
26
|
*
|
|
27
|
+
* Supports all OpenAI embedding models including text-embedding-3-small,
|
|
28
|
+
* text-embedding-3-large, and text-embedding-ada-002.
|
|
29
|
+
*
|
|
23
30
|
* @example
|
|
24
31
|
* ```typescript
|
|
25
32
|
* const embeddings = new OpenAIEmbeddings({
|
|
26
33
|
* model: 'text-embedding-3-small',
|
|
34
|
+
* dimensions: 512, // Optional: reduce dimensions for faster search
|
|
27
35
|
* });
|
|
28
36
|
*
|
|
29
37
|
* const vectors = await embeddings.embed(['Hello world', 'Goodbye world']);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* OpenAI embeddings implementation.
|
|
4
4
|
*
|
|
5
|
-
* @requires openai - Uses the OpenAI SDK (
|
|
5
|
+
* @requires openai - Uses the OpenAI SDK (peer dependency, dynamically imported)
|
|
6
6
|
*/
|
|
7
7
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
8
|
if (k2 === undefined) k2 = k;
|
|
@@ -49,10 +49,14 @@ const MODEL_DIMENSIONS = {
|
|
|
49
49
|
/**
|
|
50
50
|
* OpenAI embeddings provider.
|
|
51
51
|
*
|
|
52
|
+
* Supports all OpenAI embedding models including text-embedding-3-small,
|
|
53
|
+
* text-embedding-3-large, and text-embedding-ada-002.
|
|
54
|
+
*
|
|
52
55
|
* @example
|
|
53
56
|
* ```typescript
|
|
54
57
|
* const embeddings = new OpenAIEmbeddings({
|
|
55
58
|
* model: 'text-embedding-3-small',
|
|
59
|
+
* dimensions: 512, // Optional: reduce dimensions for faster search
|
|
56
60
|
* });
|
|
57
61
|
*
|
|
58
62
|
* const vectors = await embeddings.embed(['Hello world', 'Goodbye world']);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VoyageAI embeddings implementation.
|
|
3
|
+
*
|
|
4
|
+
* @requires voyageai - Uses the VoyageAI SDK (peer dependency, dynamically imported)
|
|
5
|
+
*/
|
|
6
|
+
import { Embeddings } from "./Embeddings";
|
|
7
|
+
/**
|
|
8
|
+
* Available VoyageAI embedding models with their dimensions and rate limits.
|
|
9
|
+
*/
|
|
10
|
+
export type VoyageAIEmbeddingModel = "voyage-4-large" | "voyage-3-large" | "voyage-context-3" | "voyage-code-3" | "voyage-4" | "voyage-3.5" | "voyage-4-lite" | "voyage-3.5-lite";
|
|
11
|
+
/**
|
|
12
|
+
* Available VoyageAI multimodal models.
|
|
13
|
+
*/
|
|
14
|
+
export type VoyageAIMultimodalModel = "voyage-multimodal-3.5" | "voyage-multimodal-3";
|
|
15
|
+
/**
|
|
16
|
+
* Configuration for VoyageAI embeddings.
|
|
17
|
+
*/
|
|
18
|
+
export interface VoyageAIEmbeddingsConfig {
|
|
19
|
+
/** VoyageAI API key (defaults to VOYAGE_API_KEY env var) */
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
/** Model to use for embeddings */
|
|
22
|
+
model?: VoyageAIEmbeddingModel | VoyageAIMultimodalModel | string;
|
|
23
|
+
/** Input type for optimization (default: "document") */
|
|
24
|
+
inputType?: "query" | "document";
|
|
25
|
+
/** Optional truncation mode */
|
|
26
|
+
truncation?: boolean;
|
|
27
|
+
/** Base URL for API (for proxies or compatible APIs) */
|
|
28
|
+
baseURL?: string;
|
|
29
|
+
/** Maximum number of retries (default: 2) */
|
|
30
|
+
maxRetries?: number;
|
|
31
|
+
/** Timeout in seconds (default: 60) */
|
|
32
|
+
timeoutInSeconds?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* VoyageAI embeddings provider.
|
|
36
|
+
*
|
|
37
|
+
* Supports VoyageAI's embedding models including voyage-4, voyage-3.5, voyage-code-3,
|
|
38
|
+
* and multimodal models. Features automatic retries with exponential backoff.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const embeddings = new VoyageAIEmbeddings({
|
|
43
|
+
* model: 'voyage-4',
|
|
44
|
+
* inputType: 'document', // or 'query' for search queries
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* const vectors = await embeddings.embed(['Hello world', 'Goodbye world']);
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example With custom configuration
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const embeddings = new VoyageAIEmbeddings({
|
|
53
|
+
* model: 'voyage-code-3',
|
|
54
|
+
* maxRetries: 3,
|
|
55
|
+
* timeoutInSeconds: 30,
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare class VoyageAIEmbeddings extends Embeddings {
|
|
60
|
+
readonly name = "voyageai";
|
|
61
|
+
readonly model: string;
|
|
62
|
+
readonly dimensions: number;
|
|
63
|
+
private apiKey;
|
|
64
|
+
private inputType;
|
|
65
|
+
private truncation?;
|
|
66
|
+
private baseURL?;
|
|
67
|
+
private maxRetries;
|
|
68
|
+
private timeoutInSeconds;
|
|
69
|
+
constructor(config?: VoyageAIEmbeddingsConfig);
|
|
70
|
+
/**
|
|
71
|
+
* Generate embeddings for multiple texts using VoyageAI API.
|
|
72
|
+
*/
|
|
73
|
+
embed(texts: string[]): Promise<number[][]>;
|
|
74
|
+
/**
|
|
75
|
+
* Generate embedding for a search query.
|
|
76
|
+
* Overrides the default to use inputType: "query" for better search results.
|
|
77
|
+
*/
|
|
78
|
+
embedQuery(query: string): Promise<number[]>;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=VoyageAIEmbeddings.d.ts.map
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* VoyageAI embeddings implementation.
|
|
4
|
+
*
|
|
5
|
+
* @requires voyageai - Uses the VoyageAI SDK (peer dependency, dynamically imported)
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.VoyageAIEmbeddings = void 0;
|
|
42
|
+
const Embeddings_1 = require("./Embeddings");
|
|
43
|
+
/** Default dimensions for each model */
|
|
44
|
+
const MODEL_DIMENSIONS = {
|
|
45
|
+
"voyage-4-large": 1024,
|
|
46
|
+
"voyage-3-large": 1024,
|
|
47
|
+
"voyage-context-3": 1024,
|
|
48
|
+
"voyage-code-3": 1024,
|
|
49
|
+
"voyage-4": 1024,
|
|
50
|
+
"voyage-3.5": 1024,
|
|
51
|
+
"voyage-4-lite": 1024,
|
|
52
|
+
"voyage-3.5-lite": 1024,
|
|
53
|
+
"voyage-multimodal-3.5": 1024,
|
|
54
|
+
"voyage-multimodal-3": 1024,
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* VoyageAI embeddings provider.
|
|
58
|
+
*
|
|
59
|
+
* Supports VoyageAI's embedding models including voyage-4, voyage-3.5, voyage-code-3,
|
|
60
|
+
* and multimodal models. Features automatic retries with exponential backoff.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const embeddings = new VoyageAIEmbeddings({
|
|
65
|
+
* model: 'voyage-4',
|
|
66
|
+
* inputType: 'document', // or 'query' for search queries
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* const vectors = await embeddings.embed(['Hello world', 'Goodbye world']);
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example With custom configuration
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const embeddings = new VoyageAIEmbeddings({
|
|
75
|
+
* model: 'voyage-code-3',
|
|
76
|
+
* maxRetries: 3,
|
|
77
|
+
* timeoutInSeconds: 30,
|
|
78
|
+
* });
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
class VoyageAIEmbeddings extends Embeddings_1.Embeddings {
|
|
82
|
+
constructor(config = {}) {
|
|
83
|
+
super();
|
|
84
|
+
this.name = "voyageai";
|
|
85
|
+
this.model = config.model ?? "voyage-4";
|
|
86
|
+
this.apiKey = config.apiKey ?? process.env.VOYAGE_API_KEY ?? "";
|
|
87
|
+
this.inputType = config.inputType ?? "document";
|
|
88
|
+
this.truncation = config.truncation;
|
|
89
|
+
this.baseURL = config.baseURL;
|
|
90
|
+
this.maxRetries = config.maxRetries ?? 2;
|
|
91
|
+
this.timeoutInSeconds = config.timeoutInSeconds ?? 60;
|
|
92
|
+
// Determine dimensions
|
|
93
|
+
this.dimensions = MODEL_DIMENSIONS[this.model] ?? 1024;
|
|
94
|
+
if (!this.apiKey) {
|
|
95
|
+
throw new Error("VoyageAI API key is required. Set VOYAGE_API_KEY env var or pass apiKey in config.");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Generate embeddings for multiple texts using VoyageAI API.
|
|
100
|
+
*/
|
|
101
|
+
async embed(texts) {
|
|
102
|
+
if (texts.length === 0) {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
// Dynamic import to keep voyageai optional at module load time
|
|
106
|
+
const { VoyageAIClient } = await Promise.resolve().then(() => __importStar(require("voyageai")));
|
|
107
|
+
const client = new VoyageAIClient({
|
|
108
|
+
apiKey: this.apiKey,
|
|
109
|
+
});
|
|
110
|
+
const params = {
|
|
111
|
+
input: texts,
|
|
112
|
+
model: this.model,
|
|
113
|
+
inputType: this.inputType,
|
|
114
|
+
};
|
|
115
|
+
if (this.truncation !== undefined) {
|
|
116
|
+
params.truncation = this.truncation;
|
|
117
|
+
}
|
|
118
|
+
const response = await client.embed(params, {
|
|
119
|
+
maxRetries: this.maxRetries,
|
|
120
|
+
timeoutInSeconds: this.timeoutInSeconds,
|
|
121
|
+
});
|
|
122
|
+
// VoyageAI returns embeddings in order
|
|
123
|
+
return response.data?.map((item) => item.embedding) ?? [];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Generate embedding for a search query.
|
|
127
|
+
* Overrides the default to use inputType: "query" for better search results.
|
|
128
|
+
*/
|
|
129
|
+
async embedQuery(query) {
|
|
130
|
+
const originalInputType = this.inputType;
|
|
131
|
+
this.inputType = "query";
|
|
132
|
+
const result = await this.embedOne(query);
|
|
133
|
+
this.inputType = originalInputType;
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.VoyageAIEmbeddings = VoyageAIEmbeddings;
|
|
138
|
+
//# sourceMappingURL=VoyageAIEmbeddings.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embeddings module for generating vector representations of text.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { OpenAIEmbeddings, VoyageAIEmbeddings } from "@agentionai/agents/embeddings";
|
|
7
|
+
*
|
|
8
|
+
* // OpenAI embeddings
|
|
9
|
+
* const openaiEmbeddings = new OpenAIEmbeddings({
|
|
10
|
+
* model: "text-embedding-3-small",
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* // VoyageAI embeddings
|
|
14
|
+
* const voyageEmbeddings = new VoyageAIEmbeddings({
|
|
15
|
+
* model: "voyage-4",
|
|
16
|
+
* inputType: "document",
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export { Embeddings, EmbeddingOptions } from "./Embeddings";
|
|
21
|
+
export { OpenAIEmbeddings, OpenAIEmbeddingsConfig, OpenAIEmbeddingModel, } from "./OpenAIEmbeddings";
|
|
22
|
+
export { VoyageAIEmbeddings, VoyageAIEmbeddingsConfig, VoyageAIEmbeddingModel, VoyageAIMultimodalModel, } from "./VoyageAIEmbeddings";
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Embeddings module for generating vector representations of text.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { OpenAIEmbeddings, VoyageAIEmbeddings } from "@agentionai/agents/embeddings";
|
|
8
|
+
*
|
|
9
|
+
* // OpenAI embeddings
|
|
10
|
+
* const openaiEmbeddings = new OpenAIEmbeddings({
|
|
11
|
+
* model: "text-embedding-3-small",
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* // VoyageAI embeddings
|
|
15
|
+
* const voyageEmbeddings = new VoyageAIEmbeddings({
|
|
16
|
+
* model: "voyage-4",
|
|
17
|
+
* inputType: "document",
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.VoyageAIEmbeddings = exports.OpenAIEmbeddings = exports.Embeddings = void 0;
|
|
23
|
+
var Embeddings_1 = require("./Embeddings");
|
|
24
|
+
Object.defineProperty(exports, "Embeddings", { enumerable: true, get: function () { return Embeddings_1.Embeddings; } });
|
|
25
|
+
var OpenAIEmbeddings_1 = require("./OpenAIEmbeddings");
|
|
26
|
+
Object.defineProperty(exports, "OpenAIEmbeddings", { enumerable: true, get: function () { return OpenAIEmbeddings_1.OpenAIEmbeddings; } });
|
|
27
|
+
var VoyageAIEmbeddings_1 = require("./VoyageAIEmbeddings");
|
|
28
|
+
Object.defineProperty(exports, "VoyageAIEmbeddings", { enumerable: true, get: function () { return VoyageAIEmbeddings_1.VoyageAIEmbeddings; } });
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseAgent } from "../agents/BaseAgent";
|
|
2
|
+
import { Tool } from "../tools/Tool";
|
|
2
3
|
import { GraphNode } from "./BaseExecutor";
|
|
3
4
|
import { MapExecutor, MapExecutorOptions } from "./MapExecutor";
|
|
4
5
|
import { ParallelExecutor, ParallelExecutorOptions } from "./ParallelExecutor";
|
|
@@ -6,6 +7,8 @@ import { Pipeline } from "./Pipeline";
|
|
|
6
7
|
import { RouterExecutor, RouterExecutorOptions, Route } from "./RouterExecutor";
|
|
7
8
|
import { SequentialExecutor, SequentialExecutorOptions } from "./SequentialExecutor";
|
|
8
9
|
import { VotingSystem, VotingSystemOptions } from "./VotingSystem";
|
|
10
|
+
import { ContextStore } from "./context";
|
|
11
|
+
import { PlanStore, PlanExecutor, PlanExecutorOptions } from "./planning";
|
|
9
12
|
export { GraphNode } from "./BaseExecutor";
|
|
10
13
|
export { SequentialExecutor, SequentialExecutorOptions, } from "./SequentialExecutor";
|
|
11
14
|
export { ParallelExecutor, ParallelExecutorOptions } from "./ParallelExecutor";
|
|
@@ -15,6 +18,8 @@ export { VotingSystem, VotingSystemOptions, VotingInput } from "./VotingSystem";
|
|
|
15
18
|
export { RouterExecutor, RouterExecutorOptions, Route } from "./RouterExecutor";
|
|
16
19
|
export { BaseExecutor, PipelineContext, ContextualInput, NodeInput, NodeOutput, MetricsCollector, NodeExecutionMetrics, MetricsTokenUsage, GraphNodeType, } from "./BaseExecutor";
|
|
17
20
|
export { PipelineMetrics, PipelineStructure, getMetricsCollector, setMetricsCollector, createMetricsCollector, } from "./GraphMetrics";
|
|
21
|
+
export { ContextStore, createContextGetTool, createContextSetTool, createContextListTool, createContextDeleteTool, } from "./context";
|
|
22
|
+
export { Plan, PlanStep, PlanStepStatus, PlanStatus, PlanStore, createPlanTool, createViewPlanTool, createUpdateStepTool, createGetNextStepTool, createAddStepTool, PlanExecutor, PlanExecutorOptions, } from "./planning";
|
|
18
23
|
/**
|
|
19
24
|
* Factory class for building agent graphs and workflows.
|
|
20
25
|
* Provides static methods to create various execution patterns.
|
|
@@ -95,5 +100,77 @@ export declare class AgentGraph {
|
|
|
95
100
|
* ```
|
|
96
101
|
*/
|
|
97
102
|
static router(router: BaseAgent, routes: Route[], options?: RouterExecutorOptions): RouterExecutor;
|
|
103
|
+
/**
|
|
104
|
+
* Creates a shared context store for passing data between agents.
|
|
105
|
+
*
|
|
106
|
+
* @param initial - Optional initial key-value pairs
|
|
107
|
+
* @returns ContextStore instance
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const context = AgentGraph.createContextStore({ userId: '123' });
|
|
112
|
+
* const tools = AgentGraph.createContextTools(context);
|
|
113
|
+
* const agent = Agent.create({ ..., tools });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
static createContextStore(initial?: Record<string, unknown>): ContextStore;
|
|
117
|
+
/**
|
|
118
|
+
* Creates context tools for an agent to read/write shared context.
|
|
119
|
+
* Includes: context_get, context_set, list_context_keys, context_delete
|
|
120
|
+
*
|
|
121
|
+
* @param store - The ContextStore to interact with
|
|
122
|
+
* @returns Array of context tools
|
|
123
|
+
*/
|
|
124
|
+
static createContextTools(store: ContextStore): Tool<string>[];
|
|
125
|
+
/**
|
|
126
|
+
* Creates a plan store for managing execution plans.
|
|
127
|
+
*
|
|
128
|
+
* @returns PlanStore instance
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const planStore = AgentGraph.createPlanStore();
|
|
133
|
+
* const tools = AgentGraph.createPlanningTools(planStore);
|
|
134
|
+
* const agent = Agent.create({ ..., tools });
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
static createPlanStore(): PlanStore;
|
|
138
|
+
/**
|
|
139
|
+
* Creates planning tools for an agent to create and manage plans.
|
|
140
|
+
* Includes: create_plan, view_plan, update_step, get_next_step, add_step
|
|
141
|
+
*
|
|
142
|
+
* @param store - The PlanStore to interact with
|
|
143
|
+
* @returns Array of planning tools
|
|
144
|
+
*/
|
|
145
|
+
static createPlanningTools(store: PlanStore): Tool<string>[];
|
|
146
|
+
/**
|
|
147
|
+
* Creates a plan executor with separation of planning and execution.
|
|
148
|
+
*
|
|
149
|
+
* @param planStore - The PlanStore to track plan progress
|
|
150
|
+
* @param planningAgent - Agent responsible for creating the plan
|
|
151
|
+
* @param worker - Agent or GraphNode that executes individual steps
|
|
152
|
+
* @param options - Configuration options
|
|
153
|
+
* @returns PlanExecutor instance
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const planStore = AgentGraph.createPlanStore();
|
|
158
|
+
* const contextStore = AgentGraph.createContextStore();
|
|
159
|
+
*
|
|
160
|
+
* const planner = new ClaudeAgent({
|
|
161
|
+
* tools: AgentGraph.createPlanningTools(planStore),
|
|
162
|
+
* description: 'Create a detailed plan.',
|
|
163
|
+
* });
|
|
164
|
+
*
|
|
165
|
+
* const worker = new ClaudeAgent({
|
|
166
|
+
* tools: AgentGraph.createContextTools(contextStore),
|
|
167
|
+
* description: 'Execute individual steps.',
|
|
168
|
+
* });
|
|
169
|
+
*
|
|
170
|
+
* const executor = AgentGraph.planExecutor(planStore, planner, worker);
|
|
171
|
+
* const result = await executor.execute('Research quantum computing');
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
static planExecutor(planStore: PlanStore, planningAgent: BaseAgent, worker: GraphNode<string, string> | BaseAgent, options?: PlanExecutorOptions): PlanExecutor;
|
|
98
175
|
}
|
|
99
176
|
//# sourceMappingURL=AgentGraph.d.ts.map
|
package/dist/graph/AgentGraph.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AgentGraph = exports.createMetricsCollector = exports.setMetricsCollector = exports.getMetricsCollector = exports.MetricsCollector = exports.BaseExecutor = exports.RouterExecutor = exports.VotingSystem = exports.MapExecutor = exports.Pipeline = exports.ParallelExecutor = exports.SequentialExecutor = void 0;
|
|
3
|
+
exports.AgentGraph = exports.PlanExecutor = exports.createAddStepTool = exports.createGetNextStepTool = exports.createUpdateStepTool = exports.createViewPlanTool = exports.createPlanTool = exports.PlanStore = exports.createContextDeleteTool = exports.createContextListTool = exports.createContextSetTool = exports.createContextGetTool = exports.ContextStore = exports.createMetricsCollector = exports.setMetricsCollector = exports.getMetricsCollector = exports.MetricsCollector = exports.BaseExecutor = exports.RouterExecutor = exports.VotingSystem = exports.MapExecutor = exports.Pipeline = exports.ParallelExecutor = exports.SequentialExecutor = void 0;
|
|
4
4
|
const MapExecutor_1 = require("./MapExecutor");
|
|
5
5
|
const ParallelExecutor_1 = require("./ParallelExecutor");
|
|
6
6
|
const Pipeline_1 = require("./Pipeline");
|
|
7
7
|
const RouterExecutor_1 = require("./RouterExecutor");
|
|
8
8
|
const SequentialExecutor_1 = require("./SequentialExecutor");
|
|
9
9
|
const VotingSystem_1 = require("./VotingSystem");
|
|
10
|
+
const context_1 = require("./context");
|
|
11
|
+
const planning_1 = require("./planning");
|
|
10
12
|
var SequentialExecutor_2 = require("./SequentialExecutor");
|
|
11
13
|
Object.defineProperty(exports, "SequentialExecutor", { enumerable: true, get: function () { return SequentialExecutor_2.SequentialExecutor; } });
|
|
12
14
|
var ParallelExecutor_2 = require("./ParallelExecutor");
|
|
@@ -26,6 +28,22 @@ var GraphMetrics_1 = require("./GraphMetrics");
|
|
|
26
28
|
Object.defineProperty(exports, "getMetricsCollector", { enumerable: true, get: function () { return GraphMetrics_1.getMetricsCollector; } });
|
|
27
29
|
Object.defineProperty(exports, "setMetricsCollector", { enumerable: true, get: function () { return GraphMetrics_1.setMetricsCollector; } });
|
|
28
30
|
Object.defineProperty(exports, "createMetricsCollector", { enumerable: true, get: function () { return GraphMetrics_1.createMetricsCollector; } });
|
|
31
|
+
// Context exports
|
|
32
|
+
var context_2 = require("./context");
|
|
33
|
+
Object.defineProperty(exports, "ContextStore", { enumerable: true, get: function () { return context_2.ContextStore; } });
|
|
34
|
+
Object.defineProperty(exports, "createContextGetTool", { enumerable: true, get: function () { return context_2.createContextGetTool; } });
|
|
35
|
+
Object.defineProperty(exports, "createContextSetTool", { enumerable: true, get: function () { return context_2.createContextSetTool; } });
|
|
36
|
+
Object.defineProperty(exports, "createContextListTool", { enumerable: true, get: function () { return context_2.createContextListTool; } });
|
|
37
|
+
Object.defineProperty(exports, "createContextDeleteTool", { enumerable: true, get: function () { return context_2.createContextDeleteTool; } });
|
|
38
|
+
// Planning exports
|
|
39
|
+
var planning_2 = require("./planning");
|
|
40
|
+
Object.defineProperty(exports, "PlanStore", { enumerable: true, get: function () { return planning_2.PlanStore; } });
|
|
41
|
+
Object.defineProperty(exports, "createPlanTool", { enumerable: true, get: function () { return planning_2.createPlanTool; } });
|
|
42
|
+
Object.defineProperty(exports, "createViewPlanTool", { enumerable: true, get: function () { return planning_2.createViewPlanTool; } });
|
|
43
|
+
Object.defineProperty(exports, "createUpdateStepTool", { enumerable: true, get: function () { return planning_2.createUpdateStepTool; } });
|
|
44
|
+
Object.defineProperty(exports, "createGetNextStepTool", { enumerable: true, get: function () { return planning_2.createGetNextStepTool; } });
|
|
45
|
+
Object.defineProperty(exports, "createAddStepTool", { enumerable: true, get: function () { return planning_2.createAddStepTool; } });
|
|
46
|
+
Object.defineProperty(exports, "PlanExecutor", { enumerable: true, get: function () { return planning_2.PlanExecutor; } });
|
|
29
47
|
/**
|
|
30
48
|
* Factory class for building agent graphs and workflows.
|
|
31
49
|
* Provides static methods to create various execution patterns.
|
|
@@ -110,6 +128,99 @@ class AgentGraph {
|
|
|
110
128
|
static router(router, routes, options = {}) {
|
|
111
129
|
return new RouterExecutor_1.RouterExecutor(router, routes, options);
|
|
112
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Creates a shared context store for passing data between agents.
|
|
133
|
+
*
|
|
134
|
+
* @param initial - Optional initial key-value pairs
|
|
135
|
+
* @returns ContextStore instance
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const context = AgentGraph.createContextStore({ userId: '123' });
|
|
140
|
+
* const tools = AgentGraph.createContextTools(context);
|
|
141
|
+
* const agent = Agent.create({ ..., tools });
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
static createContextStore(initial) {
|
|
145
|
+
return new context_1.ContextStore(initial);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Creates context tools for an agent to read/write shared context.
|
|
149
|
+
* Includes: context_get, context_set, list_context_keys, context_delete
|
|
150
|
+
*
|
|
151
|
+
* @param store - The ContextStore to interact with
|
|
152
|
+
* @returns Array of context tools
|
|
153
|
+
*/
|
|
154
|
+
static createContextTools(store) {
|
|
155
|
+
return [
|
|
156
|
+
(0, context_1.createContextGetTool)(store),
|
|
157
|
+
(0, context_1.createContextSetTool)(store),
|
|
158
|
+
(0, context_1.createContextListTool)(store),
|
|
159
|
+
(0, context_1.createContextDeleteTool)(store),
|
|
160
|
+
];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Creates a plan store for managing execution plans.
|
|
164
|
+
*
|
|
165
|
+
* @returns PlanStore instance
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const planStore = AgentGraph.createPlanStore();
|
|
170
|
+
* const tools = AgentGraph.createPlanningTools(planStore);
|
|
171
|
+
* const agent = Agent.create({ ..., tools });
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
static createPlanStore() {
|
|
175
|
+
return new planning_1.PlanStore();
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Creates planning tools for an agent to create and manage plans.
|
|
179
|
+
* Includes: create_plan, view_plan, update_step, get_next_step, add_step
|
|
180
|
+
*
|
|
181
|
+
* @param store - The PlanStore to interact with
|
|
182
|
+
* @returns Array of planning tools
|
|
183
|
+
*/
|
|
184
|
+
static createPlanningTools(store) {
|
|
185
|
+
return [
|
|
186
|
+
(0, planning_1.createPlanTool)(store),
|
|
187
|
+
(0, planning_1.createViewPlanTool)(store),
|
|
188
|
+
(0, planning_1.createUpdateStepTool)(store),
|
|
189
|
+
(0, planning_1.createGetNextStepTool)(store),
|
|
190
|
+
(0, planning_1.createAddStepTool)(store),
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Creates a plan executor with separation of planning and execution.
|
|
195
|
+
*
|
|
196
|
+
* @param planStore - The PlanStore to track plan progress
|
|
197
|
+
* @param planningAgent - Agent responsible for creating the plan
|
|
198
|
+
* @param worker - Agent or GraphNode that executes individual steps
|
|
199
|
+
* @param options - Configuration options
|
|
200
|
+
* @returns PlanExecutor instance
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* const planStore = AgentGraph.createPlanStore();
|
|
205
|
+
* const contextStore = AgentGraph.createContextStore();
|
|
206
|
+
*
|
|
207
|
+
* const planner = new ClaudeAgent({
|
|
208
|
+
* tools: AgentGraph.createPlanningTools(planStore),
|
|
209
|
+
* description: 'Create a detailed plan.',
|
|
210
|
+
* });
|
|
211
|
+
*
|
|
212
|
+
* const worker = new ClaudeAgent({
|
|
213
|
+
* tools: AgentGraph.createContextTools(contextStore),
|
|
214
|
+
* description: 'Execute individual steps.',
|
|
215
|
+
* });
|
|
216
|
+
*
|
|
217
|
+
* const executor = AgentGraph.planExecutor(planStore, planner, worker);
|
|
218
|
+
* const result = await executor.execute('Research quantum computing');
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
static planExecutor(planStore, planningAgent, worker, options = {}) {
|
|
222
|
+
return new planning_1.PlanExecutor(planStore, planningAgent, worker, options);
|
|
223
|
+
}
|
|
113
224
|
}
|
|
114
225
|
exports.AgentGraph = AgentGraph;
|
|
115
226
|
//# sourceMappingURL=AgentGraph.js.map
|
|
@@ -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
|