@agentionai/agents 0.4.2 → 0.6.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.
Files changed (47) hide show
  1. package/README.md +2 -2
  2. package/dist/agents/AgentConfig.d.ts +19 -0
  3. package/dist/agents/BaseAgent.d.ts +39 -0
  4. package/dist/agents/BaseAgent.js +100 -1
  5. package/dist/agents/anthropic/ClaudeAgent.d.ts +0 -2
  6. package/dist/agents/anthropic/ClaudeAgent.js +8 -4
  7. package/dist/agents/google/GeminiAgent.d.ts +0 -2
  8. package/dist/agents/google/GeminiAgent.js +4 -4
  9. package/dist/agents/mistral/MistralAgent.d.ts +0 -2
  10. package/dist/agents/mistral/MistralAgent.js +4 -4
  11. package/dist/agents/openai/OpenAiAgent.d.ts +0 -2
  12. package/dist/agents/openai/OpenAiAgent.js +4 -4
  13. package/dist/{vectorstore → embeddings}/OpenAIEmbeddings.d.ts +10 -2
  14. package/dist/{vectorstore → embeddings}/OpenAIEmbeddings.js +5 -1
  15. package/dist/embeddings/VoyageAIEmbeddings.d.ts +80 -0
  16. package/dist/embeddings/VoyageAIEmbeddings.js +139 -0
  17. package/dist/embeddings/index.d.ts +23 -0
  18. package/dist/embeddings/index.js +29 -0
  19. package/dist/graph/AgentGraph.d.ts +77 -0
  20. package/dist/graph/AgentGraph.js +112 -1
  21. package/dist/graph/context/ContextStore.d.ts +69 -0
  22. package/dist/graph/context/ContextStore.js +101 -0
  23. package/dist/graph/context/ContextTools.d.ts +52 -0
  24. package/dist/graph/context/ContextTools.js +148 -0
  25. package/dist/graph/context/index.d.ts +3 -0
  26. package/dist/graph/context/index.js +11 -0
  27. package/dist/graph/planning/PlanExecutor.d.ts +184 -0
  28. package/dist/graph/planning/PlanExecutor.js +396 -0
  29. package/dist/graph/planning/PlanStore.d.ts +81 -0
  30. package/dist/graph/planning/PlanStore.js +199 -0
  31. package/dist/graph/planning/PlanningTools.d.ts +45 -0
  32. package/dist/graph/planning/PlanningTools.js +178 -0
  33. package/dist/graph/planning/index.d.ts +5 -0
  34. package/dist/graph/planning/index.js +14 -0
  35. package/dist/graph/planning/types.d.ts +41 -0
  36. package/dist/graph/planning/types.js +3 -0
  37. package/dist/history/History.js +3 -0
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.js +2 -0
  40. package/dist/ingestion/IngestionPipeline.d.ts +1 -1
  41. package/dist/vectorstore/LanceDBVectorStore.d.ts +67 -2
  42. package/dist/vectorstore/LanceDBVectorStore.js +134 -23
  43. package/dist/vectorstore/index.d.ts +6 -4
  44. package/dist/vectorstore/index.js +10 -6
  45. package/package.json +12 -3
  46. /package/dist/{vectorstore → embeddings}/Embeddings.d.ts +0 -0
  47. /package/dist/{vectorstore → embeddings}/Embeddings.js +0 -0
@@ -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,3 @@
1
+ export { ContextStore } from "./ContextStore";
2
+ export { createContextGetTool, createContextSetTool, createContextListTool, createContextDeleteTool, } from "./ContextTools";
3
+ //# sourceMappingURL=index.d.ts.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,184 @@
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
+ * Maximum number of previous step results to include in worker context.
28
+ * This prevents context overflow by limiting how much history is passed to each step.
29
+ * Set to 0 to include no previous steps (workers should use context_get to retrieve data).
30
+ * Set to a small number (1-3) to include only recent context.
31
+ * @default 0 (workers request context explicitly)
32
+ */
33
+ maxContextSteps?: number;
34
+ /**
35
+ * Callback invoked when planning phase completes.
36
+ */
37
+ onPlanCreated?: (goal: string, steps: PlanStep[]) => void;
38
+ /**
39
+ * Callback invoked before each step starts.
40
+ */
41
+ onStepStart?: (step: PlanStep, stepNumber: number, totalSteps: number) => void;
42
+ /**
43
+ * Callback invoked after each step completes.
44
+ */
45
+ onStepComplete?: (step: PlanStep, result: string, stepNumber: number) => void;
46
+ /**
47
+ * Callback invoked when a step fails.
48
+ */
49
+ onStepFailed?: (step: PlanStep, error: Error, stepNumber: number) => void;
50
+ }
51
+ /**
52
+ * Result of a plan execution.
53
+ */
54
+ export interface PlanExecutionResult {
55
+ success: boolean;
56
+ goal: string;
57
+ totalSteps: number;
58
+ completedSteps: number;
59
+ failedSteps: number;
60
+ summary: string;
61
+ /**
62
+ * Clean, consolidated output for chaining to next graph node.
63
+ * Contains a rollup of all step results in a format ready for downstream processing.
64
+ */
65
+ finalOutput: string;
66
+ /**
67
+ * Detailed results for each step (useful for debugging/inspection).
68
+ */
69
+ stepResults: Array<{
70
+ step: PlanStep;
71
+ result?: string;
72
+ error?: string;
73
+ }>;
74
+ }
75
+ /**
76
+ * Orchestrates plan-based execution with clear separation of concerns:
77
+ * 1. Planning Phase: Uses a planning agent to create a plan
78
+ * 2. Execution Phase: Assigns workers (agents or graph nodes) to execute each step
79
+ * 3. Completion: Compiles results and returns summary
80
+ *
81
+ * The PlanExecutor acts as the orchestrator, tracking progress and delegating
82
+ * work to specialized workers. Planning and execution are separate phases.
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const planStore = AgentGraph.createPlanStore();
87
+ * const contextStore = AgentGraph.createContextStore();
88
+ *
89
+ * // Planning agent creates the plan
90
+ * const planner = new ClaudeAgent({
91
+ * tools: AgentGraph.createPlanningTools(planStore),
92
+ * description: 'You are a planning agent. Create a detailed plan with clear steps.',
93
+ * });
94
+ *
95
+ * // Worker agent executes individual steps
96
+ * const worker = new ClaudeAgent({
97
+ * tools: AgentGraph.createContextTools(contextStore),
98
+ * description: 'You execute a single step. Store results in context.',
99
+ * });
100
+ *
101
+ * const executor = new PlanExecutor(planStore, planner, worker, {
102
+ * onStepComplete: (step, result, num) => {
103
+ * console.log(`Completed step ${num}: ${step.description}`);
104
+ * },
105
+ * });
106
+ *
107
+ * const result = await executor.execute('Research and summarize quantum computing');
108
+ * ```
109
+ */
110
+ export declare class PlanExecutor extends BaseExecutor<string, string> {
111
+ private planStore;
112
+ private planningAgent;
113
+ private worker;
114
+ private lastResult?;
115
+ private options;
116
+ /**
117
+ * Create a new PlanExecutor.
118
+ *
119
+ * @param planStore - The plan store to track plan state
120
+ * @param planningAgent - Agent responsible for creating the plan
121
+ * @param worker - Agent or GraphNode that executes individual steps
122
+ * @param options - Configuration options
123
+ */
124
+ constructor(planStore: PlanStore, planningAgent: BaseAgent, worker: GraphNode<string, string> | BaseAgent, options?: PlanExecutorOptions);
125
+ /**
126
+ * Execute the plan:
127
+ * 1. Planning Phase: Ask planning agent to create a plan
128
+ * 2. Execution Phase: Execute each step with the worker
129
+ * 3. Completion: Return finalOutput (for chaining)
130
+ *
131
+ * Returns the finalOutput string for easy chaining in pipelines.
132
+ * Use getLastResult() to access the full PlanExecutionResult with details.
133
+ */
134
+ execute(input: string): Promise<string>;
135
+ /**
136
+ * Get the detailed result from the last execution.
137
+ * Contains full plan details, step results, and metadata.
138
+ */
139
+ getLastResult(): PlanExecutionResult | undefined;
140
+ /**
141
+ * Phase 1: Planning
142
+ * Instructs the planning agent to create a plan based on the task.
143
+ */
144
+ private planningPhase;
145
+ /**
146
+ * Phase 2: Execution
147
+ * Executes each step in the plan using the worker.
148
+ */
149
+ private executionPhase;
150
+ /**
151
+ * Create a prompt for the planning agent.
152
+ */
153
+ private createPlanningPrompt;
154
+ /**
155
+ * Create input for a step execution.
156
+ *
157
+ * By default, only includes the current step information.
158
+ * Workers should use context_get to retrieve data from previous steps.
159
+ * This prevents token overflow from accumulating context.
160
+ */
161
+ private createStepInput;
162
+ /**
163
+ * Compile the final result from step results.
164
+ */
165
+ private compileResult;
166
+ /**
167
+ * Create a clean, consolidated output from all step results.
168
+ * This output is designed for chaining to the next graph node.
169
+ */
170
+ private createFinalOutput;
171
+ /**
172
+ * Check if a worker is a BaseAgent.
173
+ */
174
+ private isAgent;
175
+ /**
176
+ * Extract token usage from an agent if available.
177
+ */
178
+ private extractTokenUsage;
179
+ /**
180
+ * Get the plan store.
181
+ */
182
+ getPlanStore(): PlanStore;
183
+ }
184
+ //# sourceMappingURL=PlanExecutor.d.ts.map