dank-ai 1.0.9 → 1.0.10
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/lib/project.js +0 -136
- package/package.json +1 -1
package/lib/project.js
CHANGED
|
@@ -12,7 +12,6 @@ class DankProject {
|
|
|
12
12
|
this.name = name;
|
|
13
13
|
this.options = {
|
|
14
14
|
configFile: 'dank.config.js',
|
|
15
|
-
agentsDir: 'agents',
|
|
16
15
|
outputDir: 'output',
|
|
17
16
|
template: 'basic',
|
|
18
17
|
...options
|
|
@@ -27,7 +26,6 @@ class DankProject {
|
|
|
27
26
|
const projectDir = this.projectPath;
|
|
28
27
|
|
|
29
28
|
// Create directory structure
|
|
30
|
-
await fs.ensureDir(path.join(projectDir, this.options.agentsDir));
|
|
31
29
|
await fs.ensureDir(path.join(projectDir, this.options.outputDir));
|
|
32
30
|
|
|
33
31
|
// Create example config file
|
|
@@ -139,140 +137,6 @@ module.exports = {
|
|
|
139
137
|
})
|
|
140
138
|
.addHandler('error', (error) => {
|
|
141
139
|
console.error('[Prompt Agent] System error:', error);
|
|
142
|
-
}),
|
|
143
|
-
|
|
144
|
-
// Example 2: HTTP API Agent with Tool Events
|
|
145
|
-
createAgent('api-agent')
|
|
146
|
-
.setLLM('openai', {
|
|
147
|
-
apiKey: process.env.OPENAI_API_KEY,
|
|
148
|
-
model: 'gpt-4',
|
|
149
|
-
temperature: 0.3
|
|
150
|
-
})
|
|
151
|
-
.setPrompt('You are a specialized API assistant that helps with data processing and analysis.')
|
|
152
|
-
.setBaseImage('nodejs-20')
|
|
153
|
-
.setPromptingServer({
|
|
154
|
-
protocol: 'http',
|
|
155
|
-
port: 3001
|
|
156
|
-
})
|
|
157
|
-
.setResources({
|
|
158
|
-
memory: '1g',
|
|
159
|
-
cpu: 2
|
|
160
|
-
})
|
|
161
|
-
// HTTP API routes
|
|
162
|
-
.get('/health', (req, res) => {
|
|
163
|
-
res.json({ status: 'healthy', timestamp: new Date().toISOString() });
|
|
164
|
-
})
|
|
165
|
-
.post('/analyze', (req, res) => {
|
|
166
|
-
res.json({
|
|
167
|
-
message: 'Data analysis endpoint',
|
|
168
|
-
data: req.body,
|
|
169
|
-
timestamp: new Date().toISOString()
|
|
170
|
-
});
|
|
171
|
-
})
|
|
172
|
-
.get('/status', (req, res) => {
|
|
173
|
-
res.json({
|
|
174
|
-
agent: 'api-agent',
|
|
175
|
-
status: 'running',
|
|
176
|
-
uptime: process.uptime()
|
|
177
|
-
});
|
|
178
|
-
})
|
|
179
|
-
// Tool event handlers for HTTP requests
|
|
180
|
-
.addHandler('tool:http-server:call', (data) => {
|
|
181
|
-
console.log('[API Agent] HTTP Request:', {
|
|
182
|
-
method: data.method,
|
|
183
|
-
path: data.path,
|
|
184
|
-
headers: data.headers,
|
|
185
|
-
body: data.body,
|
|
186
|
-
timestamp: data.timestamp
|
|
187
|
-
});
|
|
188
|
-
})
|
|
189
|
-
.addHandler('tool:http-server:response', (data) => {
|
|
190
|
-
console.log('[API Agent] HTTP Response:', {
|
|
191
|
-
statusCode: data.statusCode,
|
|
192
|
-
headers: data.headers,
|
|
193
|
-
body: data.body,
|
|
194
|
-
processingTime: data.processingTime,
|
|
195
|
-
timestamp: data.timestamp
|
|
196
|
-
});
|
|
197
|
-
})
|
|
198
|
-
.addHandler('tool:http-server:error', (data) => {
|
|
199
|
-
console.error('[API Agent] HTTP Error:', {
|
|
200
|
-
error: data.error,
|
|
201
|
-
method: data.method,
|
|
202
|
-
path: data.path,
|
|
203
|
-
timestamp: data.timestamp
|
|
204
|
-
});
|
|
205
|
-
})
|
|
206
|
-
.addHandler('output', (data) => {
|
|
207
|
-
console.log('[API Agent] System output:', data);
|
|
208
|
-
})
|
|
209
|
-
.addHandler('error', (error) => {
|
|
210
|
-
console.error('[API Agent] System error:', error);
|
|
211
|
-
}),
|
|
212
|
-
|
|
213
|
-
// Example 3: Multi-Modal Agent with All Features
|
|
214
|
-
createAgent('multi-agent')
|
|
215
|
-
.setLLM('openai', {
|
|
216
|
-
apiKey: process.env.OPENAI_API_KEY,
|
|
217
|
-
model: 'gpt-4',
|
|
218
|
-
temperature: 0.5
|
|
219
|
-
})
|
|
220
|
-
.setPrompt('You are a versatile AI assistant that can handle both direct prompts and API requests. You excel at creative tasks and problem-solving.')
|
|
221
|
-
.setBaseImage('nodejs-20')
|
|
222
|
-
.setPromptingServer({
|
|
223
|
-
protocol: 'http',
|
|
224
|
-
port: 3002
|
|
225
|
-
})
|
|
226
|
-
.setResources({
|
|
227
|
-
memory: '2g',
|
|
228
|
-
cpu: 2
|
|
229
|
-
})
|
|
230
|
-
// Agent image configuration for Docker builds
|
|
231
|
-
.setAgentImageConfig({
|
|
232
|
-
registry: 'ghcr.io',
|
|
233
|
-
namespace: 'mycompany',
|
|
234
|
-
tag: 'latest'
|
|
235
|
-
})
|
|
236
|
-
// HTTP API routes
|
|
237
|
-
.get('/creative', (req, res) => {
|
|
238
|
-
res.json({
|
|
239
|
-
message: 'Creative writing endpoint',
|
|
240
|
-
timestamp: new Date().toISOString()
|
|
241
|
-
});
|
|
242
|
-
})
|
|
243
|
-
.post('/solve', (req, res) => {
|
|
244
|
-
res.json({
|
|
245
|
-
message: 'Problem solving endpoint',
|
|
246
|
-
data: req.body,
|
|
247
|
-
timestamp: new Date().toISOString()
|
|
248
|
-
});
|
|
249
|
-
})
|
|
250
|
-
// Comprehensive event handling
|
|
251
|
-
.addHandler('request_output:start', (data) => {
|
|
252
|
-
console.log('[Multi Agent] Processing request:', data.conversationId);
|
|
253
|
-
return {
|
|
254
|
-
prompt: \`[Multi-Modal Assistant] \${data.prompt}\\n\\nPlease provide a comprehensive and creative response.\`
|
|
255
|
-
};
|
|
256
|
-
})
|
|
257
|
-
.addHandler('request_output:end', (data) => {
|
|
258
|
-
console.log('[Multi Agent] Response completed in:', data.processingTime + 'ms');
|
|
259
|
-
return {
|
|
260
|
-
response: \`\${data.response}\\n\\n✨ Enhanced by Multi-Modal Dank Agent\`
|
|
261
|
-
};
|
|
262
|
-
})
|
|
263
|
-
.addHandler('tool:http-server:*', (data) => {
|
|
264
|
-
console.log('[Multi Agent] HTTP Activity:', {
|
|
265
|
-
type: data.type,
|
|
266
|
-
method: data.method,
|
|
267
|
-
path: data.path,
|
|
268
|
-
timestamp: data.timestamp
|
|
269
|
-
});
|
|
270
|
-
})
|
|
271
|
-
.addHandler('output', (data) => {
|
|
272
|
-
console.log('[Multi Agent] System output:', data);
|
|
273
|
-
})
|
|
274
|
-
.addHandler('error', (error) => {
|
|
275
|
-
console.error('[Multi Agent] System error:', error);
|
|
276
140
|
})
|
|
277
141
|
]
|
|
278
142
|
};
|