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/src/types.ts
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for autonomous-agents
|
|
3
|
+
*
|
|
4
|
+
* Primitives for building and orchestrating autonomous AI agents that operate
|
|
5
|
+
* within a company boundary using the digital-workers interface.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { AIFunctionDefinition, AIGenerateOptions, SimpleSchema } from 'ai-functions'
|
|
9
|
+
|
|
10
|
+
// Re-export for use in other files
|
|
11
|
+
export type { AIFunctionDefinition }
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Agent execution mode determines how the agent processes tasks
|
|
15
|
+
*/
|
|
16
|
+
export type AgentMode = 'autonomous' | 'supervised' | 'manual'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Agent status during execution
|
|
20
|
+
*/
|
|
21
|
+
export type AgentStatus = 'idle' | 'thinking' | 'acting' | 'waiting' | 'completed' | 'error'
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Priority levels for tasks and decisions
|
|
25
|
+
*/
|
|
26
|
+
export type Priority = 'low' | 'medium' | 'high' | 'urgent'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Decision approval status
|
|
30
|
+
*/
|
|
31
|
+
export type ApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired'
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Role definition for an agent or human worker
|
|
35
|
+
*/
|
|
36
|
+
export interface Role {
|
|
37
|
+
/** Unique role identifier */
|
|
38
|
+
id: string
|
|
39
|
+
/** Role name (e.g., "Product Manager", "Software Engineer") */
|
|
40
|
+
name: string
|
|
41
|
+
/** Role description and responsibilities */
|
|
42
|
+
description: string
|
|
43
|
+
/** Skills and capabilities required for this role */
|
|
44
|
+
skills: string[]
|
|
45
|
+
/** Permissions and access levels */
|
|
46
|
+
permissions?: string[]
|
|
47
|
+
/** Tools available to this role */
|
|
48
|
+
tools?: AIFunctionDefinition[]
|
|
49
|
+
/** Expected outputs from this role */
|
|
50
|
+
outputs?: string[]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Team composition and coordination
|
|
55
|
+
*/
|
|
56
|
+
export interface Team {
|
|
57
|
+
/** Unique team identifier */
|
|
58
|
+
id: string
|
|
59
|
+
/** Team name */
|
|
60
|
+
name: string
|
|
61
|
+
/** Team description and purpose */
|
|
62
|
+
description?: string
|
|
63
|
+
/** Team members (agents and humans) */
|
|
64
|
+
members: TeamMember[]
|
|
65
|
+
/** Team goals */
|
|
66
|
+
goals?: Goal[]
|
|
67
|
+
/** Shared context for the team */
|
|
68
|
+
context?: Record<string, unknown>
|
|
69
|
+
/** Communication channels */
|
|
70
|
+
channels?: CommunicationChannel[]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Team member representation
|
|
75
|
+
*/
|
|
76
|
+
export interface TeamMember {
|
|
77
|
+
/** Member ID (agent or human) */
|
|
78
|
+
id: string
|
|
79
|
+
/** Member name */
|
|
80
|
+
name: string
|
|
81
|
+
/** Member role on the team */
|
|
82
|
+
role: Role
|
|
83
|
+
/** Member type */
|
|
84
|
+
type: 'agent' | 'human'
|
|
85
|
+
/** Member status */
|
|
86
|
+
status?: 'active' | 'inactive' | 'away'
|
|
87
|
+
/** Member availability */
|
|
88
|
+
availability?: 'available' | 'busy' | 'offline'
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Communication channel for team collaboration
|
|
93
|
+
*/
|
|
94
|
+
export interface CommunicationChannel {
|
|
95
|
+
/** Channel identifier */
|
|
96
|
+
id: string
|
|
97
|
+
/** Channel type */
|
|
98
|
+
type: 'slack' | 'email' | 'web' | 'sms' | 'custom'
|
|
99
|
+
/** Channel configuration */
|
|
100
|
+
config: Record<string, unknown>
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Goal definition with measurable outcomes
|
|
105
|
+
*/
|
|
106
|
+
export interface Goal {
|
|
107
|
+
/** Unique goal identifier */
|
|
108
|
+
id: string
|
|
109
|
+
/** Goal description */
|
|
110
|
+
description: string
|
|
111
|
+
/** Target outcome or metric */
|
|
112
|
+
target: string | number
|
|
113
|
+
/** Current progress */
|
|
114
|
+
progress?: string | number
|
|
115
|
+
/** Goal deadline */
|
|
116
|
+
deadline?: Date
|
|
117
|
+
/** Goal priority */
|
|
118
|
+
priority?: Priority
|
|
119
|
+
/** Goal status */
|
|
120
|
+
status?: 'active' | 'completed' | 'blocked' | 'cancelled'
|
|
121
|
+
/** Sub-goals */
|
|
122
|
+
subgoals?: Goal[]
|
|
123
|
+
/** Success criteria */
|
|
124
|
+
successCriteria?: string[]
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Agent configuration and behavior
|
|
129
|
+
*/
|
|
130
|
+
export interface AgentConfig {
|
|
131
|
+
/** Agent name */
|
|
132
|
+
name: string
|
|
133
|
+
/** Agent description and purpose */
|
|
134
|
+
description?: string
|
|
135
|
+
/** Agent role */
|
|
136
|
+
role: Role
|
|
137
|
+
/** Agent execution mode */
|
|
138
|
+
mode?: AgentMode
|
|
139
|
+
/** Agent goals */
|
|
140
|
+
goals?: Goal[]
|
|
141
|
+
/** Agent tools (functions) */
|
|
142
|
+
tools?: AIFunctionDefinition[]
|
|
143
|
+
/** Agent memory/context */
|
|
144
|
+
context?: Record<string, unknown>
|
|
145
|
+
/** Model to use for agent reasoning */
|
|
146
|
+
model?: string
|
|
147
|
+
/** System prompt for the agent */
|
|
148
|
+
system?: string
|
|
149
|
+
/** Maximum iterations per task */
|
|
150
|
+
maxIterations?: number
|
|
151
|
+
/** Temperature for AI generation */
|
|
152
|
+
temperature?: number
|
|
153
|
+
/** Team the agent belongs to */
|
|
154
|
+
team?: Team
|
|
155
|
+
/** Approval requirements */
|
|
156
|
+
requiresApproval?: boolean
|
|
157
|
+
/** Human supervisor (for supervised mode) */
|
|
158
|
+
supervisor?: string
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Agent instance with methods and state
|
|
163
|
+
*/
|
|
164
|
+
export interface Agent {
|
|
165
|
+
/** Agent configuration */
|
|
166
|
+
config: AgentConfig
|
|
167
|
+
/** Agent current status */
|
|
168
|
+
status: AgentStatus
|
|
169
|
+
/** Agent state/memory */
|
|
170
|
+
state: Record<string, unknown>
|
|
171
|
+
|
|
172
|
+
/** Execute a task */
|
|
173
|
+
do: <TResult = unknown>(task: string, context?: unknown) => Promise<TResult>
|
|
174
|
+
|
|
175
|
+
/** Ask a question */
|
|
176
|
+
ask: <TResult = unknown>(question: string, context?: unknown) => Promise<TResult>
|
|
177
|
+
|
|
178
|
+
/** Make a decision */
|
|
179
|
+
decide: <T extends string>(options: T[], context?: string) => Promise<T>
|
|
180
|
+
|
|
181
|
+
/** Request approval */
|
|
182
|
+
approve: <TResult = unknown>(request: ApprovalRequest) => Promise<ApprovalResult<TResult>>
|
|
183
|
+
|
|
184
|
+
/** Generate content */
|
|
185
|
+
generate: (options: AIGenerateOptions) => Promise<unknown>
|
|
186
|
+
|
|
187
|
+
/** Type checking/validation */
|
|
188
|
+
is: (value: unknown, type: string | SimpleSchema) => Promise<boolean>
|
|
189
|
+
|
|
190
|
+
/** Send notification */
|
|
191
|
+
notify: (message: string, channel?: string) => Promise<void>
|
|
192
|
+
|
|
193
|
+
/** Update agent state */
|
|
194
|
+
setState: (key: string, value: unknown) => void
|
|
195
|
+
|
|
196
|
+
/** Get agent state */
|
|
197
|
+
getState: <T = unknown>(key: string) => T | undefined
|
|
198
|
+
|
|
199
|
+
/** Get agent history */
|
|
200
|
+
getHistory: () => AgentHistoryEntry[]
|
|
201
|
+
|
|
202
|
+
/** Reset agent state */
|
|
203
|
+
reset: () => void
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Approval request structure
|
|
208
|
+
*/
|
|
209
|
+
export interface ApprovalRequest {
|
|
210
|
+
/** Request title/summary */
|
|
211
|
+
title: string
|
|
212
|
+
/** Detailed description */
|
|
213
|
+
description: string
|
|
214
|
+
/** Data to be approved */
|
|
215
|
+
data: unknown
|
|
216
|
+
/** Priority level */
|
|
217
|
+
priority?: Priority
|
|
218
|
+
/** Approver (user ID, email, or role) */
|
|
219
|
+
approver?: string
|
|
220
|
+
/** Timeout in milliseconds */
|
|
221
|
+
timeout?: number
|
|
222
|
+
/** Channel for approval request */
|
|
223
|
+
channel?: 'slack' | 'email' | 'web' | 'sms' | 'custom'
|
|
224
|
+
/** Expected response schema */
|
|
225
|
+
responseSchema?: SimpleSchema
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Approval result
|
|
230
|
+
*/
|
|
231
|
+
export interface ApprovalResult<T = unknown> {
|
|
232
|
+
/** Approval status */
|
|
233
|
+
status: ApprovalStatus
|
|
234
|
+
/** Response data */
|
|
235
|
+
response?: T
|
|
236
|
+
/** Who approved/rejected */
|
|
237
|
+
approver?: string
|
|
238
|
+
/** When the decision was made */
|
|
239
|
+
timestamp?: Date
|
|
240
|
+
/** Optional notes */
|
|
241
|
+
notes?: string
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Agent history entry
|
|
246
|
+
*/
|
|
247
|
+
export interface AgentHistoryEntry {
|
|
248
|
+
/** Timestamp */
|
|
249
|
+
timestamp: Date
|
|
250
|
+
/** Action type */
|
|
251
|
+
type: 'task' | 'question' | 'decision' | 'approval' | 'notification' | 'error'
|
|
252
|
+
/** Action description */
|
|
253
|
+
action: string
|
|
254
|
+
/** Input data */
|
|
255
|
+
input?: unknown
|
|
256
|
+
/** Output result */
|
|
257
|
+
output?: unknown
|
|
258
|
+
/** Error if any */
|
|
259
|
+
error?: string
|
|
260
|
+
/** Duration in milliseconds */
|
|
261
|
+
duration?: number
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Key Performance Indicator
|
|
266
|
+
*/
|
|
267
|
+
export interface KPI {
|
|
268
|
+
/** KPI identifier */
|
|
269
|
+
id: string
|
|
270
|
+
/** KPI name */
|
|
271
|
+
name: string
|
|
272
|
+
/** KPI description */
|
|
273
|
+
description?: string
|
|
274
|
+
/** Current value */
|
|
275
|
+
value: number | string
|
|
276
|
+
/** Target value */
|
|
277
|
+
target?: number | string
|
|
278
|
+
/** Unit of measurement */
|
|
279
|
+
unit?: string
|
|
280
|
+
/** Measurement frequency */
|
|
281
|
+
frequency?: 'daily' | 'weekly' | 'monthly' | 'quarterly' | 'yearly'
|
|
282
|
+
/** Trend direction */
|
|
283
|
+
trend?: 'up' | 'down' | 'stable'
|
|
284
|
+
/** Historical data */
|
|
285
|
+
history?: Array<{ timestamp: Date; value: number | string }>
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Objectives and Key Results
|
|
290
|
+
*/
|
|
291
|
+
export interface OKR {
|
|
292
|
+
/** OKR identifier */
|
|
293
|
+
id: string
|
|
294
|
+
/** Objective statement */
|
|
295
|
+
objective: string
|
|
296
|
+
/** Objective description */
|
|
297
|
+
description?: string
|
|
298
|
+
/** Key results */
|
|
299
|
+
keyResults: KeyResult[]
|
|
300
|
+
/** Time period */
|
|
301
|
+
period?: string
|
|
302
|
+
/** Owner (agent, team, or person) */
|
|
303
|
+
owner?: string
|
|
304
|
+
/** Status */
|
|
305
|
+
status?: 'active' | 'completed' | 'at-risk' | 'cancelled'
|
|
306
|
+
/** Overall progress (0-100) */
|
|
307
|
+
progress?: number
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Key Result within an OKR
|
|
312
|
+
*/
|
|
313
|
+
export interface KeyResult {
|
|
314
|
+
/** Key result identifier */
|
|
315
|
+
id: string
|
|
316
|
+
/** Key result description */
|
|
317
|
+
description: string
|
|
318
|
+
/** Current value */
|
|
319
|
+
current: number | string
|
|
320
|
+
/** Target value */
|
|
321
|
+
target: number | string
|
|
322
|
+
/** Unit of measurement */
|
|
323
|
+
unit?: string
|
|
324
|
+
/** Progress (0-100) */
|
|
325
|
+
progress?: number
|
|
326
|
+
/** Status */
|
|
327
|
+
status?: 'on-track' | 'at-risk' | 'off-track' | 'completed'
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Goals configuration
|
|
332
|
+
*/
|
|
333
|
+
export interface GoalsConfig {
|
|
334
|
+
/** Goals list */
|
|
335
|
+
goals: Goal[]
|
|
336
|
+
/** Strategy or context */
|
|
337
|
+
strategy?: string
|
|
338
|
+
/** Time horizon */
|
|
339
|
+
timeHorizon?: string
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Notification options
|
|
344
|
+
*/
|
|
345
|
+
export interface NotificationOptions {
|
|
346
|
+
/** Message to send */
|
|
347
|
+
message: string
|
|
348
|
+
/** Notification channel */
|
|
349
|
+
channel?: 'slack' | 'email' | 'web' | 'sms' | 'custom'
|
|
350
|
+
/** Recipients */
|
|
351
|
+
recipients?: string[]
|
|
352
|
+
/** Priority */
|
|
353
|
+
priority?: Priority
|
|
354
|
+
/** Additional data */
|
|
355
|
+
data?: Record<string, unknown>
|
|
356
|
+
}
|