@ai.ntellect/core 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -44
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/index.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
@@ -5,10 +5,15 @@
|
|
5
5
|
## Features
|
6
6
|
|
7
7
|
- **GraphFlow** – Graph-based execution engine for automating business processes
|
8
|
+
- **AI Agents** – Built-in support for LLM-powered agents with memory and tools
|
8
9
|
- **Event-Driven** – Nodes can react to real-time events and trigger actions dynamically
|
9
10
|
- **Modular** – Plug-and-play modules and adapters for memory, scheduling, and external APIs
|
10
11
|
- **Extensible** – Custom nodes, adapters, and interactions with third-party services
|
11
12
|
- **Observable** – Complete state and event monitoring
|
13
|
+
- **Type-Safe** – Built with TypeScript for robust type checking
|
14
|
+
- **Schema Validation** – Integrated Zod schema validation
|
15
|
+
- **Retry Mechanisms** – Built-in retry strategies for resilient workflows
|
16
|
+
- **Event Correlation** – Advanced event handling with correlation strategies
|
12
17
|
|
13
18
|
## Installation
|
14
19
|
|
@@ -31,70 +36,125 @@ npm -v
|
|
31
36
|
npm install @ai.ntellect/core zod
|
32
37
|
```
|
33
38
|
|
34
|
-
##
|
39
|
+
## Quick Start
|
40
|
+
|
41
|
+
### 1. Basic Workflow
|
35
42
|
|
36
43
|
```typescript
|
37
44
|
import { GraphFlow } from "@ai.ntellect/core";
|
38
45
|
import { z } from "zod";
|
39
46
|
|
40
|
-
//
|
41
|
-
const
|
42
|
-
|
47
|
+
// Define schema
|
48
|
+
const EmailSchema = z.object({
|
49
|
+
to: z.string(),
|
50
|
+
subject: z.string(),
|
51
|
+
content: z.string(),
|
52
|
+
status: z.string().default("pending"),
|
43
53
|
});
|
44
54
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
55
|
+
// Create workflow
|
56
|
+
const emailFlow = new GraphFlow("email", {
|
57
|
+
name: "email",
|
58
|
+
schema: EmailSchema,
|
59
|
+
context: {
|
60
|
+
to: "",
|
61
|
+
subject: "",
|
62
|
+
content: "",
|
63
|
+
status: "pending",
|
64
|
+
},
|
52
65
|
nodes: [
|
53
66
|
{
|
54
|
-
name: "
|
67
|
+
name: "send",
|
55
68
|
execute: async (context) => {
|
56
|
-
console.log(context.
|
69
|
+
console.log(`Sending email to ${context.to}`);
|
70
|
+
// Logic to send email
|
71
|
+
context.status = "sent";
|
57
72
|
},
|
58
|
-
next: [],
|
59
73
|
},
|
60
74
|
],
|
61
75
|
});
|
76
|
+
```
|
77
|
+
|
78
|
+
### 2. AI-Powered Assistant
|
79
|
+
|
80
|
+
```typescript
|
81
|
+
import { Agent } from "@ai.ntellect/core";
|
82
|
+
|
83
|
+
const assistant = new Agent({
|
84
|
+
role: "Email Assistant",
|
85
|
+
goal: "Help users send emails efficiently",
|
86
|
+
backstory: "I am an AI assistant specialized in email communications",
|
87
|
+
tools: [emailFlow],
|
88
|
+
llmConfig: {
|
89
|
+
provider: "openai",
|
90
|
+
model: "gpt-4",
|
91
|
+
apiKey: "YOUR_API_KEY",
|
92
|
+
},
|
93
|
+
});
|
62
94
|
|
63
|
-
//
|
64
|
-
|
65
|
-
|
66
|
-
|
95
|
+
// Use the assistant
|
96
|
+
const result = await assistant.process(
|
97
|
+
"Send an email to john@example.com about tomorrow's meeting"
|
98
|
+
);
|
67
99
|
```
|
68
100
|
|
69
|
-
## Features
|
101
|
+
## Advanced Features
|
70
102
|
|
71
|
-
### Event
|
103
|
+
### Event Handling
|
72
104
|
|
73
105
|
```typescript
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
}
|
106
|
+
const workflow = new GraphFlow("notification", {
|
107
|
+
nodes: [
|
108
|
+
{
|
109
|
+
name: "waitForEvent",
|
110
|
+
events: ["emailSent"],
|
111
|
+
execute: async (context, event) => {
|
112
|
+
console.log(`Email sent to ${event.payload.recipient}`);
|
113
|
+
},
|
114
|
+
},
|
115
|
+
],
|
116
|
+
});
|
82
117
|
|
83
118
|
// Emit events
|
84
|
-
|
119
|
+
workflow.emit("emailSent", { recipient: "john@example.com" });
|
85
120
|
```
|
86
121
|
|
87
|
-
###
|
122
|
+
### Retry Mechanisms
|
88
123
|
|
89
124
|
```typescript
|
90
|
-
|
91
|
-
|
125
|
+
const node = {
|
126
|
+
name: "sendEmail",
|
127
|
+
execute: async (context) => {
|
128
|
+
// Email sending logic
|
129
|
+
},
|
130
|
+
retry: {
|
131
|
+
maxAttempts: 3,
|
132
|
+
delay: 1000,
|
133
|
+
onRetryFailed: async (error, context) => {
|
134
|
+
console.error(`Failed to send email to ${context.to}`);
|
135
|
+
},
|
136
|
+
},
|
137
|
+
};
|
138
|
+
```
|
92
139
|
|
93
|
-
|
94
|
-
graph.observe().property("counter").subscribe(console.log);
|
140
|
+
### State Observation
|
95
141
|
|
96
|
-
|
97
|
-
|
142
|
+
```typescript
|
143
|
+
// Observe specific properties
|
144
|
+
workflow
|
145
|
+
.observe()
|
146
|
+
.property("status")
|
147
|
+
.subscribe((status) => {
|
148
|
+
console.log(`Email status changed to: ${status}`);
|
149
|
+
});
|
150
|
+
|
151
|
+
// Observe specific nodes
|
152
|
+
workflow
|
153
|
+
.observe()
|
154
|
+
.node("sendEmail")
|
155
|
+
.subscribe((state) => {
|
156
|
+
console.log(`Send email node state:`, state);
|
157
|
+
});
|
98
158
|
```
|
99
159
|
|
100
160
|
## Documentation
|
@@ -103,14 +163,14 @@ For complete documentation, visit our [GitBook](https://ai-ntellect.gitbook.io/c
|
|
103
163
|
|
104
164
|
## Contributing
|
105
165
|
|
106
|
-
|
166
|
+
We welcome contributions! To get started:
|
167
|
+
|
168
|
+
1. Fork the repository
|
169
|
+
2. Create a feature branch
|
170
|
+
3. Submit a pull request
|
107
171
|
|
108
|
-
|
109
|
-
- Explore the [GitBook documentation](https://ai-ntellect.gitbook.io/core)
|
110
|
-
- Open an issue on GitHub
|
172
|
+
Join our [Discord community](https://discord.gg/kEc5gWXJ) for discussions and support.
|
111
173
|
|
112
|
-
##
|
174
|
+
## License
|
113
175
|
|
114
|
-
|
115
|
-
- Community: [Discord](https://discord.gg/kEc5gWXJ)
|
116
|
-
- GitHub Repository: [@ai.ntellect/core](https://github.com/ai-ntellect/core)
|
176
|
+
MIT
|
package/dist/index.d.ts
CHANGED
@@ -11,6 +11,7 @@
|
|
11
11
|
* - Utility functions for action schema generation and header building
|
12
12
|
*/
|
13
13
|
export * from "./modules/agent/agent";
|
14
|
+
export * from "./modules/agent/prompt-builder";
|
14
15
|
export * from "./graph/controller";
|
15
16
|
export * from "./graph/event-manager";
|
16
17
|
export * from "./graph/index";
|
@@ -20,6 +21,7 @@ export * from "./graph/visualizer";
|
|
20
21
|
export * from "./interfaces";
|
21
22
|
export * from "./modules/agenda";
|
22
23
|
export * from "./modules/embedding";
|
24
|
+
export * from "./modules/memory";
|
23
25
|
export * from "./types";
|
24
26
|
export * from "./utils/generate-action-schema";
|
25
27
|
export * from "./utils/header-builder";
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,uBAAuB,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAE/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,SAAS,CAAC;AAExB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
@@ -27,6 +27,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
__exportStar(require("./modules/agent/agent"), exports);
|
30
|
+
__exportStar(require("./modules/agent/prompt-builder"), exports);
|
30
31
|
__exportStar(require("./graph/controller"), exports);
|
31
32
|
__exportStar(require("./graph/event-manager"), exports);
|
32
33
|
__exportStar(require("./graph/index"), exports);
|
@@ -36,6 +37,7 @@ __exportStar(require("./graph/visualizer"), exports);
|
|
36
37
|
__exportStar(require("./interfaces"), exports);
|
37
38
|
__exportStar(require("./modules/agenda"), exports);
|
38
39
|
__exportStar(require("./modules/embedding"), exports);
|
40
|
+
__exportStar(require("./modules/memory"), exports);
|
39
41
|
__exportStar(require("./types"), exports);
|
40
42
|
__exportStar(require("./utils/generate-action-schema"), exports);
|
41
43
|
__exportStar(require("./utils/header-builder"), exports);
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;AAEH,wDAAsC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;AAEH,wDAAsC;AACtC,iEAA+C;AAE/C,qDAAmC;AACnC,wDAAsC;AACtC,gDAA8B;AAC9B,+CAA6B;AAC7B,mDAAiC;AACjC,qDAAmC;AAEnC,+CAA6B;AAC7B,mDAAiC;AACjC,sDAAoC;AACpC,mDAAiC;AAEjC,0CAAwB;AAExB,iEAA+C;AAC/C,yDAAuC"}
|
package/index.ts
CHANGED
@@ -12,6 +12,7 @@
|
|
12
12
|
*/
|
13
13
|
|
14
14
|
export * from "./modules/agent/agent";
|
15
|
+
export * from "./modules/agent/prompt-builder";
|
15
16
|
|
16
17
|
export * from "./graph/controller";
|
17
18
|
export * from "./graph/event-manager";
|
@@ -23,6 +24,7 @@ export * from "./graph/visualizer";
|
|
23
24
|
export * from "./interfaces";
|
24
25
|
export * from "./modules/agenda";
|
25
26
|
export * from "./modules/embedding";
|
27
|
+
export * from "./modules/memory";
|
26
28
|
|
27
29
|
export * from "./types";
|
28
30
|
|