node-red-contrib-ai-agent 0.0.3 → 0.0.5

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.
@@ -0,0 +1,149 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('ai-memory-inmem', {
3
+ category: 'AI Agent',
4
+ paletteLabel: 'AI Memory (In-Mem)',
5
+ color: "#a6bbcf",
6
+ defaults: {
7
+ name: { value: "" },
8
+ maxItems: {
9
+ value: 1000,
10
+ required: true,
11
+ validate: RED.validators.number()
12
+ }
13
+ },
14
+ inputs: 1,
15
+ outputs: 1,
16
+ icon: "font-awesome/fa-microchip",
17
+ label: function() {
18
+ return this.name || "AI Memory (In-Mem)";
19
+ },
20
+ labelStyle: function() {
21
+ return this.name ? "node_label_italic" : "";
22
+ },
23
+ oneditprepare: function() {
24
+ // Initialize any UI components here
25
+ $("#node-input-maxItems").spinner({
26
+ min: 1,
27
+ max: 100000
28
+ });
29
+ },
30
+ oneditsave: function() {
31
+ // Handle save if needed
32
+ },
33
+ oneditcancel: function() {
34
+ // Cleanup if needed
35
+ }
36
+ });
37
+ </script>
38
+
39
+ <script type="text/html" data-template-name="ai-memory-inmem">
40
+ <div class="form-row">
41
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
42
+ <input type="text" id="node-input-name" placeholder="Name">
43
+ </div>
44
+ <div class="form-row">
45
+ <label for="node-input-maxItems"><i class="fa fa-database"></i> Max Items</label>
46
+ <input type="number" id="node-input-maxItems" min="1" max="100000" value="1000">
47
+ </div>
48
+ <div class="form-tips">
49
+ <p>Note: Memories will be lost when Node-RED restarts.</p>
50
+ </div>
51
+ </script>
52
+
53
+ <script type="text/html" data-help-name="ai-memory-inmem">
54
+ <p>Stores AI memories in memory (volatile).</p>
55
+ <h3>Memory Operations</h3>
56
+ <p>Use different topics to perform memory operations:</p>
57
+ <dl>
58
+ <dt>store</dt>
59
+ <dd>
60
+ <p>Store a new memory item</p>
61
+ <pre>
62
+ {
63
+ "topic": "store",
64
+ "payload": {
65
+ "content": "The memory content",
66
+ "type": "optional type",
67
+ "metadata": {
68
+ "any": "additional data"
69
+ }
70
+ }
71
+ }</pre>
72
+ </dd>
73
+
74
+ <dt>search</dt>
75
+ <dd>
76
+ <p>Search through existing memories</p>
77
+ <pre>
78
+ {
79
+ "topic": "search",
80
+ "payload": "search term"
81
+ }</pre>
82
+ </dd>
83
+
84
+ <dt>count</dt>
85
+ <dd>
86
+ <p>Get the number of stored memories</p>
87
+ <pre>
88
+ {
89
+ "topic": "count"
90
+ }</pre>
91
+ </dd>
92
+
93
+ <dt>(no topic)</dt>
94
+ <dd>
95
+ <p>Get all stored memories</p>
96
+ <pre>
97
+ {
98
+ "payload": "any value"
99
+ }</pre>
100
+ </dd>
101
+ </dl>
102
+
103
+ <h3>Output Format</h3>
104
+ <dl>
105
+ <dt>store</dt>
106
+ <dd>
107
+ <pre>
108
+ {
109
+ "stored": true,
110
+ "memory": {
111
+ "content": "...",
112
+ "type": "...",
113
+ "metadata": { ... },
114
+ "timestamp": "..."
115
+ }
116
+ }</pre>
117
+ </dd>
118
+
119
+ <dt>search</dt>
120
+ <dd>
121
+ <pre>
122
+ {
123
+ "results": [ ... ],
124
+ "count": number
125
+ }</pre>
126
+ </dd>
127
+
128
+ <dt>count</dt>
129
+ <dd>
130
+ <pre>
131
+ {
132
+ "count": number
133
+ }</pre>
134
+ </dd>
135
+
136
+ <dt>(no topic)</dt>
137
+ <dd>
138
+ <pre>
139
+ {
140
+ "memories": [ ... ]
141
+ }</pre>
142
+ </dd>
143
+ </dl>
144
+
145
+ <h3>Details</h3>
146
+ <p>This node stores memories in memory only. All data will be lost when Node-RED restarts.</p>
147
+ <p>Use this for temporary storage or when persistence is not required.</p>
148
+ <p>Each memory item automatically gets a timestamp when stored.</p>
149
+ </script>
@@ -0,0 +1,41 @@
1
+ module.exports = function(RED) {
2
+ 'use strict';
3
+
4
+ function MemoryInMemNode(config) {
5
+ RED.nodes.createNode(this, config);
6
+ const node = this;
7
+
8
+ // Configuration
9
+ node.name = config.name || 'AI Memory (In-Mem)';
10
+ node.maxItems = parseInt(config.maxItems) || 1000;
11
+
12
+ // Status
13
+ node.status({fill:"green",shape:"dot",text:"Ready"});
14
+
15
+ // Handle incoming messages
16
+ node.on('input', function(msg) {
17
+ try {
18
+ // Initialize or reset aimemory
19
+ msg.aimemory = {
20
+ type: 'inmemory',
21
+ maxItems: node.maxItems,
22
+ context: []
23
+ };
24
+
25
+ node.send(msg);
26
+ node.status({fill:"green",shape:"dot",text:"ready"});
27
+ } catch (err) {
28
+ node.error("Error in memory node: " + err.message, msg);
29
+ node.status({fill:"red",shape:"ring",text:"Error"});
30
+ }
31
+ });
32
+
33
+ // No cleanup needed since we don't maintain state
34
+ node.on('close', function() {
35
+ node.status({});
36
+ });
37
+ }
38
+
39
+ // Register the node type
40
+ RED.nodes.registerType("ai-memory-inmem", MemoryInMemNode);
41
+ };