autonomous-agents 0.1.0 → 2.0.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/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +9 -0
- package/README.md +260 -96
- package/dist/actions.d.ts +136 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +303 -0
- package/dist/actions.js.map +1 -0
- package/dist/agent.d.ts +49 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +452 -0
- package/dist/agent.js.map +1 -0
- package/dist/goals.d.ts +138 -0
- package/dist/goals.d.ts.map +1 -0
- package/dist/goals.js +342 -0
- package/dist/goals.js.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics.d.ts +245 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +436 -0
- package/dist/metrics.js.map +1 -0
- package/dist/role.d.ts +122 -0
- package/dist/role.d.ts.map +1 -0
- package/dist/role.js +393 -0
- package/dist/role.js.map +1 -0
- package/dist/team.d.ts +152 -0
- package/dist/team.d.ts.map +1 -0
- package/dist/team.js +347 -0
- package/dist/team.js.map +1 -0
- package/dist/types.d.ts +327 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +27 -36
- package/src/actions.ts +366 -0
- package/src/agent.ts +548 -0
- package/src/goals.ts +435 -0
- package/src/index.ts +135 -0
- package/src/metrics.ts +591 -0
- package/src/role.ts +422 -0
- package/src/team.ts +466 -0
- package/src/types.ts +356 -0
- package/test/actions.test.ts +522 -0
- package/test/agent.test.ts +490 -0
- package/test/goals.test.ts +570 -0
- package/test/metrics.test.ts +707 -0
- package/test/role.test.ts +423 -0
- package/test/team.test.ts +708 -0
- package/tsconfig.json +9 -0
package/dist/actions.js
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actions - Core action functions for autonomous agents
|
|
3
|
+
*
|
|
4
|
+
* These are standalone functions that can be used independently
|
|
5
|
+
* or as part of an agent's capabilities.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { generateObject } from 'ai-functions';
|
|
10
|
+
/**
|
|
11
|
+
* Execute a task using AI
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { do as doTask } from 'autonomous-agents'
|
|
16
|
+
*
|
|
17
|
+
* const result = await doTask('Analyze customer feedback and provide insights', {
|
|
18
|
+
* feedback: ['Great product!', 'Needs improvement', 'Love the features'],
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export async function doAction(task, context, options) {
|
|
23
|
+
const result = await generateObject({
|
|
24
|
+
model: options?.model || 'sonnet',
|
|
25
|
+
schema: options?.schema || { result: 'The result of the task' },
|
|
26
|
+
system: options?.system || 'You are a helpful AI assistant. Execute tasks accurately and thoroughly.',
|
|
27
|
+
prompt: `Task: ${task}\n\nContext: ${JSON.stringify(context || {})}`,
|
|
28
|
+
temperature: options?.temperature ?? 0.7,
|
|
29
|
+
});
|
|
30
|
+
return result.object.result || result.object;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Ask a question and get an answer
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { ask } from 'autonomous-agents'
|
|
38
|
+
*
|
|
39
|
+
* const answer = await ask('What are the key benefits of our product?', {
|
|
40
|
+
* product: 'AI Assistant',
|
|
41
|
+
* features: ['smart automation', 'natural language', 'context awareness'],
|
|
42
|
+
* })
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export async function ask(question, context, options) {
|
|
46
|
+
const result = await generateObject({
|
|
47
|
+
model: options?.model || 'sonnet',
|
|
48
|
+
schema: options?.schema || {
|
|
49
|
+
answer: 'The answer to the question',
|
|
50
|
+
reasoning: 'Supporting reasoning',
|
|
51
|
+
},
|
|
52
|
+
system: options?.system || 'You are a knowledgeable AI assistant. Provide clear, accurate answers.',
|
|
53
|
+
prompt: `Question: ${question}\n\nContext: ${JSON.stringify(context || {})}`,
|
|
54
|
+
temperature: options?.temperature ?? 0.7,
|
|
55
|
+
});
|
|
56
|
+
const response = result.object;
|
|
57
|
+
return response.answer;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Make a decision between options
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { decide } from 'autonomous-agents'
|
|
65
|
+
*
|
|
66
|
+
* const choice = await decide(
|
|
67
|
+
* ['option A', 'option B', 'option C'],
|
|
68
|
+
* 'Which option has the highest ROI?'
|
|
69
|
+
* )
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export async function decide(options, context, settings) {
|
|
73
|
+
const result = await generateObject({
|
|
74
|
+
model: settings?.model || 'sonnet',
|
|
75
|
+
schema: {
|
|
76
|
+
decision: options.join(' | '),
|
|
77
|
+
reasoning: 'Reasoning for this decision',
|
|
78
|
+
confidence: 'Confidence level 0-100 (number)',
|
|
79
|
+
},
|
|
80
|
+
system: settings?.system || 'You are a strategic decision-maker. Evaluate options carefully and provide clear reasoning.',
|
|
81
|
+
prompt: `Make a decision between these options:\n${options.map((o, i) => `${i + 1}. ${o}`).join('\n')}\n\nContext: ${context || 'No additional context'}`,
|
|
82
|
+
temperature: settings?.temperature ?? 0.7,
|
|
83
|
+
});
|
|
84
|
+
const response = result.object;
|
|
85
|
+
return response.decision;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Request approval for an action or decision
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* import { approve } from 'autonomous-agents'
|
|
93
|
+
*
|
|
94
|
+
* const approval = await approve({
|
|
95
|
+
* title: 'Budget Request',
|
|
96
|
+
* description: 'Request $50k for marketing campaign',
|
|
97
|
+
* data: { amount: 50000, campaign: 'Q1 Launch' },
|
|
98
|
+
* approver: 'manager@company.com',
|
|
99
|
+
* priority: 'high',
|
|
100
|
+
* })
|
|
101
|
+
*
|
|
102
|
+
* if (approval.status === 'approved') {
|
|
103
|
+
* // Proceed with the action
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export async function approve(request) {
|
|
108
|
+
return executeApproval(request);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Execute approval request (internal implementation)
|
|
112
|
+
*/
|
|
113
|
+
export async function executeApproval(request) {
|
|
114
|
+
// Generate approval UI based on channel
|
|
115
|
+
const uiSchema = getApprovalUISchema(request.channel || 'web');
|
|
116
|
+
const result = await generateObject({
|
|
117
|
+
model: 'sonnet',
|
|
118
|
+
schema: uiSchema,
|
|
119
|
+
system: `Generate ${request.channel || 'web'} UI/content for an approval request.`,
|
|
120
|
+
prompt: `Approval Request: ${request.title}
|
|
121
|
+
|
|
122
|
+
Description: ${request.description}
|
|
123
|
+
|
|
124
|
+
Data to be approved:
|
|
125
|
+
${JSON.stringify(request.data, null, 2)}
|
|
126
|
+
|
|
127
|
+
Priority: ${request.priority || 'medium'}
|
|
128
|
+
Approver: ${request.approver || 'any authorized approver'}
|
|
129
|
+
|
|
130
|
+
${request.responseSchema ? `Expected response format:\n${JSON.stringify(request.responseSchema)}` : ''}
|
|
131
|
+
|
|
132
|
+
Generate the appropriate UI/content to collect approval or rejection with optional notes.`,
|
|
133
|
+
});
|
|
134
|
+
// In a real implementation, this would:
|
|
135
|
+
// 1. Send the generated UI to the specified channel
|
|
136
|
+
// 2. Wait for human response (with timeout)
|
|
137
|
+
// 3. Return the validated response
|
|
138
|
+
// For now, return a pending approval with generated artifacts
|
|
139
|
+
return {
|
|
140
|
+
status: 'pending',
|
|
141
|
+
response: undefined,
|
|
142
|
+
timestamp: new Date(),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get approval UI schema based on channel
|
|
147
|
+
*/
|
|
148
|
+
function getApprovalUISchema(channel) {
|
|
149
|
+
const schemas = {
|
|
150
|
+
slack: {
|
|
151
|
+
blocks: ['Slack BlockKit blocks as JSON array'],
|
|
152
|
+
text: 'Plain text fallback',
|
|
153
|
+
},
|
|
154
|
+
email: {
|
|
155
|
+
subject: 'Email subject line',
|
|
156
|
+
html: 'Email HTML body with approval buttons',
|
|
157
|
+
text: 'Plain text fallback',
|
|
158
|
+
},
|
|
159
|
+
web: {
|
|
160
|
+
component: 'React component code for approval form',
|
|
161
|
+
schema: 'JSON schema for the form fields',
|
|
162
|
+
},
|
|
163
|
+
sms: {
|
|
164
|
+
text: 'SMS message text (max 160 chars)',
|
|
165
|
+
responseFormat: 'Expected response format',
|
|
166
|
+
},
|
|
167
|
+
custom: {
|
|
168
|
+
data: 'Structured data for custom implementation',
|
|
169
|
+
instructions: 'Instructions for the approver',
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
return schemas[channel] || schemas.custom;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Generate content using AI
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* import { generate } from 'autonomous-agents'
|
|
180
|
+
*
|
|
181
|
+
* const content = await generate({
|
|
182
|
+
* model: 'sonnet',
|
|
183
|
+
* schema: {
|
|
184
|
+
* title: 'Blog post title',
|
|
185
|
+
* content: 'Blog post content',
|
|
186
|
+
* tags: ['List of tags'],
|
|
187
|
+
* },
|
|
188
|
+
* prompt: 'Write a blog post about AI automation',
|
|
189
|
+
* })
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
export async function generate(options) {
|
|
193
|
+
const result = await generateObject({
|
|
194
|
+
model: options.model || 'sonnet',
|
|
195
|
+
schema: (options.schema || { result: 'Generated content' }),
|
|
196
|
+
system: options.system || 'You are a creative AI assistant. Generate high-quality content.',
|
|
197
|
+
prompt: options.prompt || '',
|
|
198
|
+
temperature: options.temperature ?? 0.8,
|
|
199
|
+
});
|
|
200
|
+
return result.object;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Type checking and validation
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* import { is } from 'autonomous-agents'
|
|
208
|
+
*
|
|
209
|
+
* const isValid = await is(
|
|
210
|
+
* { email: 'test@example.com' },
|
|
211
|
+
* 'valid email address'
|
|
212
|
+
* )
|
|
213
|
+
*
|
|
214
|
+
* const matchesSchema = await is(
|
|
215
|
+
* { name: 'John', age: 30 },
|
|
216
|
+
* { name: 'string', age: 'number' }
|
|
217
|
+
* )
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
export async function is(value, type) {
|
|
221
|
+
const schema = typeof type === 'string'
|
|
222
|
+
? { isValid: `Is this value a valid ${type}? (boolean)`, reason: 'Explanation' }
|
|
223
|
+
: { isValid: 'Does this value match the schema? (boolean)', reason: 'Explanation' };
|
|
224
|
+
const result = await generateObject({
|
|
225
|
+
model: 'sonnet',
|
|
226
|
+
schema,
|
|
227
|
+
system: 'You are a type validator. Determine if the value matches the expected type or schema.',
|
|
228
|
+
prompt: `Value: ${JSON.stringify(value)}\n\nExpected type: ${typeof type === 'string' ? type : JSON.stringify(type)}`,
|
|
229
|
+
temperature: 0,
|
|
230
|
+
});
|
|
231
|
+
return result.object.isValid;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Send a notification
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* import { notify } from 'autonomous-agents'
|
|
239
|
+
*
|
|
240
|
+
* await notify({
|
|
241
|
+
* message: 'Task completed successfully!',
|
|
242
|
+
* channel: 'slack',
|
|
243
|
+
* recipients: ['#general'],
|
|
244
|
+
* priority: 'high',
|
|
245
|
+
* data: { taskId: '123', duration: '5 minutes' },
|
|
246
|
+
* })
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
export async function notify(options) {
|
|
250
|
+
const { message, channel = 'web', recipients = [], priority = 'medium', data = {}, } = options;
|
|
251
|
+
// Generate channel-specific notification format
|
|
252
|
+
const notificationSchema = getNotificationSchema(channel);
|
|
253
|
+
const result = await generateObject({
|
|
254
|
+
model: 'sonnet',
|
|
255
|
+
schema: notificationSchema,
|
|
256
|
+
system: `Generate ${channel} notification content.`,
|
|
257
|
+
prompt: `Notification message: ${message}
|
|
258
|
+
|
|
259
|
+
Recipients: ${recipients.join(', ') || 'default recipients'}
|
|
260
|
+
Priority: ${priority}
|
|
261
|
+
|
|
262
|
+
Additional data:
|
|
263
|
+
${JSON.stringify(data, null, 2)}
|
|
264
|
+
|
|
265
|
+
Generate the appropriate ${channel} notification format.`,
|
|
266
|
+
});
|
|
267
|
+
// In a real implementation, this would send via the specified channel
|
|
268
|
+
console.log(`[Notification] [${channel}] ${message}`, result.object);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Get notification schema based on channel
|
|
272
|
+
*/
|
|
273
|
+
function getNotificationSchema(channel) {
|
|
274
|
+
const schemas = {
|
|
275
|
+
slack: {
|
|
276
|
+
blocks: ['Slack BlockKit blocks'],
|
|
277
|
+
text: 'Plain text fallback',
|
|
278
|
+
},
|
|
279
|
+
email: {
|
|
280
|
+
subject: 'Email subject',
|
|
281
|
+
html: 'Email HTML body',
|
|
282
|
+
text: 'Plain text version',
|
|
283
|
+
},
|
|
284
|
+
web: {
|
|
285
|
+
title: 'Notification title',
|
|
286
|
+
message: 'Notification message',
|
|
287
|
+
type: 'success | info | warning | error',
|
|
288
|
+
},
|
|
289
|
+
sms: {
|
|
290
|
+
text: 'SMS message (max 160 chars)',
|
|
291
|
+
},
|
|
292
|
+
custom: {
|
|
293
|
+
format: 'Custom notification format',
|
|
294
|
+
content: 'Notification content',
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
return schemas[channel] || schemas.custom;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Export the 'do' function with an alias to avoid keyword conflict
|
|
301
|
+
*/
|
|
302
|
+
export { doAction as do };
|
|
303
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAA6C,MAAM,cAAc,CAAA;AAQxF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,IAAY,EACZ,OAAiB,EACjB,OAA2B;IAE3B,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC;QAClC,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,QAAQ;QACjC,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,EAAE,MAAM,EAAE,wBAAwB,EAAE;QAC/D,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,0EAA0E;QACrG,MAAM,EAAE,SAAS,IAAI,gBAAgB,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE;QACpE,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,GAAG;KACzC,CAAC,CAAA;IAEF,OAAQ,MAAM,CAAC,MAA8B,CAAC,MAAM,IAAI,MAAM,CAAC,MAAiB,CAAA;AAClF,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CACvB,QAAgB,EAChB,OAAiB,EACjB,OAA2B;IAE3B,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC;QAClC,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,QAAQ;QACjC,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI;YACzB,MAAM,EAAE,4BAA4B;YACpC,SAAS,EAAE,sBAAsB;SAClC;QACD,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,wEAAwE;QACnG,MAA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ACzC;QACD,GAAG,EAAE;YACH,IAAI,EAAE,6BAA6B;SACpC;QACD,MAAM,EAAE;YACN,MAAM,EAAE,4BAA4B;YACpC,OAAO,EAAE,sBAAsB;SAChC;KACF,CAAA;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAO,CAAA;AAC5C,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,CAAA"}
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent - Create an autonomous agent
|
|
3
|
+
*
|
|
4
|
+
* Agents are autonomous AI workers that can execute tasks, make decisions,
|
|
5
|
+
* and collaborate with other agents and humans.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { Agent, AgentConfig } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Create an autonomous agent
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Agent, Role } from 'autonomous-agents'
|
|
16
|
+
*
|
|
17
|
+
* const agent = Agent({
|
|
18
|
+
* name: 'ProductAgent',
|
|
19
|
+
* role: Role({
|
|
20
|
+
* name: 'Product Manager',
|
|
21
|
+
* description: 'Manages product strategy and roadmap',
|
|
22
|
+
* skills: ['product strategy', 'user research', 'roadmap planning'],
|
|
23
|
+
* }),
|
|
24
|
+
* mode: 'autonomous',
|
|
25
|
+
* goals: [
|
|
26
|
+
* { id: 'g1', description: 'Define Q1 product roadmap', target: '100%' }
|
|
27
|
+
* ],
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* // Execute a task
|
|
31
|
+
* const result = await agent.do('Create a product brief for new feature X')
|
|
32
|
+
*
|
|
33
|
+
* // Ask a question
|
|
34
|
+
* const answer = await agent.ask('What are the top 3 customer pain points?')
|
|
35
|
+
*
|
|
36
|
+
* // Make a decision
|
|
37
|
+
* const decision = await agent.decide(['feature A', 'feature B', 'feature C'], 'Which should we prioritize?')
|
|
38
|
+
*
|
|
39
|
+
* // Request approval
|
|
40
|
+
* const approval = await agent.approve({
|
|
41
|
+
* title: 'Budget Request',
|
|
42
|
+
* description: 'Request $50k budget for user research',
|
|
43
|
+
* data: { amount: 50000, purpose: 'User research study' },
|
|
44
|
+
* approver: 'manager@company.com',
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function Agent(config: AgentConfig): Agent;
|
|
49
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EAMZ,MAAM,YAAY,CAAA;AAGnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,KAAK,CA2YhD"}
|