digital-workers 0.1.1 → 2.0.2

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.
Files changed (83) hide show
  1. package/.turbo/turbo-build.log +5 -0
  2. package/CHANGELOG.md +17 -0
  3. package/README.md +290 -106
  4. package/dist/actions.d.ts +95 -0
  5. package/dist/actions.d.ts.map +1 -0
  6. package/dist/actions.js +437 -0
  7. package/dist/actions.js.map +1 -0
  8. package/dist/approve.d.ts +49 -0
  9. package/dist/approve.d.ts.map +1 -0
  10. package/dist/approve.js +235 -0
  11. package/dist/approve.js.map +1 -0
  12. package/dist/ask.d.ts +42 -0
  13. package/dist/ask.d.ts.map +1 -0
  14. package/dist/ask.js +227 -0
  15. package/dist/ask.js.map +1 -0
  16. package/dist/decide.d.ts +62 -0
  17. package/dist/decide.d.ts.map +1 -0
  18. package/dist/decide.js +245 -0
  19. package/dist/decide.js.map +1 -0
  20. package/dist/do.d.ts +63 -0
  21. package/dist/do.d.ts.map +1 -0
  22. package/dist/do.js +228 -0
  23. package/dist/do.js.map +1 -0
  24. package/dist/generate.d.ts +61 -0
  25. package/dist/generate.d.ts.map +1 -0
  26. package/dist/generate.js +299 -0
  27. package/dist/generate.js.map +1 -0
  28. package/dist/goals.d.ts +89 -0
  29. package/dist/goals.d.ts.map +1 -0
  30. package/dist/goals.js +206 -0
  31. package/dist/goals.js.map +1 -0
  32. package/dist/index.d.ts +68 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +69 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/is.d.ts +54 -0
  37. package/dist/is.d.ts.map +1 -0
  38. package/dist/is.js +318 -0
  39. package/dist/is.js.map +1 -0
  40. package/dist/kpis.d.ts +103 -0
  41. package/dist/kpis.d.ts.map +1 -0
  42. package/dist/kpis.js +271 -0
  43. package/dist/kpis.js.map +1 -0
  44. package/dist/notify.d.ts +47 -0
  45. package/dist/notify.d.ts.map +1 -0
  46. package/dist/notify.js +220 -0
  47. package/dist/notify.js.map +1 -0
  48. package/dist/role.d.ts +53 -0
  49. package/dist/role.d.ts.map +1 -0
  50. package/dist/role.js +111 -0
  51. package/dist/role.js.map +1 -0
  52. package/dist/team.d.ts +61 -0
  53. package/dist/team.d.ts.map +1 -0
  54. package/dist/team.js +131 -0
  55. package/dist/team.js.map +1 -0
  56. package/dist/transports.d.ts +164 -0
  57. package/dist/transports.d.ts.map +1 -0
  58. package/dist/transports.js +358 -0
  59. package/dist/transports.js.map +1 -0
  60. package/dist/types.d.ts +693 -0
  61. package/dist/types.d.ts.map +1 -0
  62. package/dist/types.js +72 -0
  63. package/dist/types.js.map +1 -0
  64. package/package.json +27 -61
  65. package/src/actions.ts +615 -0
  66. package/src/approve.ts +317 -0
  67. package/src/ask.ts +304 -0
  68. package/src/decide.ts +295 -0
  69. package/src/do.ts +275 -0
  70. package/src/generate.ts +364 -0
  71. package/src/goals.ts +220 -0
  72. package/src/index.ts +118 -0
  73. package/src/is.ts +372 -0
  74. package/src/kpis.ts +348 -0
  75. package/src/notify.ts +303 -0
  76. package/src/role.ts +116 -0
  77. package/src/team.ts +142 -0
  78. package/src/transports.ts +504 -0
  79. package/src/types.ts +843 -0
  80. package/test/actions.test.ts +546 -0
  81. package/test/standalone.test.ts +299 -0
  82. package/test/types.test.ts +460 -0
  83. package/tsconfig.json +9 -0
@@ -0,0 +1,299 @@
1
+ /**
2
+ * Tests for standalone worker functions
3
+ */
4
+
5
+ import { describe, it, expect } from 'vitest'
6
+ import { Team } from '../src/team.js'
7
+ import { Role } from '../src/role.js'
8
+ import { Goals } from '../src/goals.js'
9
+ import { WorkerVerbs } from '../src/types.js'
10
+ import type { Worker, WorkerRef } from '../src/types.js'
11
+
12
+ // Test fixtures
13
+ const alice: WorkerRef = {
14
+ id: 'alice',
15
+ name: 'Alice',
16
+ type: 'human',
17
+ role: 'Senior Engineer',
18
+ }
19
+
20
+ const bob: WorkerRef = {
21
+ id: 'bob',
22
+ name: 'Bob',
23
+ type: 'human',
24
+ role: 'Engineer',
25
+ }
26
+
27
+ const codeBot: WorkerRef = {
28
+ id: 'code_bot',
29
+ name: 'Code Reviewer',
30
+ type: 'agent',
31
+ role: 'Code Reviewer',
32
+ }
33
+
34
+ describe('Team', () => {
35
+ it('should create a team', () => {
36
+ const team = Team({
37
+ id: 'eng',
38
+ name: 'Engineering',
39
+ members: [alice, bob],
40
+ contacts: { slack: '#engineering' },
41
+ })
42
+
43
+ expect(team.id).toBe('eng')
44
+ expect(team.name).toBe('Engineering')
45
+ expect(team.members).toHaveLength(2)
46
+ })
47
+
48
+ it('should support lead', () => {
49
+ const team = Team({
50
+ id: 'eng',
51
+ name: 'Engineering',
52
+ members: [alice, bob],
53
+ contacts: {},
54
+ lead: alice,
55
+ })
56
+
57
+ expect(team.lead?.id).toBe('alice')
58
+ })
59
+
60
+ it('should support goals', () => {
61
+ const team = Team({
62
+ id: 'eng',
63
+ name: 'Engineering',
64
+ members: [alice],
65
+ contacts: {},
66
+ goals: ['Ship v2.0', 'Reduce tech debt'],
67
+ })
68
+
69
+ expect(team.goals).toHaveLength(2)
70
+ })
71
+
72
+ describe('Team.addMember', () => {
73
+ it('should add a member', () => {
74
+ const team = Team({
75
+ id: 'eng',
76
+ name: 'Engineering',
77
+ members: [alice],
78
+ contacts: {},
79
+ })
80
+
81
+ const updated = Team.addMember(team, bob)
82
+
83
+ expect(updated.members).toHaveLength(2)
84
+ expect(updated.members[1]).toBe(bob)
85
+ })
86
+ })
87
+
88
+ describe('Team.removeMember', () => {
89
+ it('should remove a member', () => {
90
+ const team = Team({
91
+ id: 'eng',
92
+ name: 'Engineering',
93
+ members: [alice, bob],
94
+ contacts: {},
95
+ })
96
+
97
+ const updated = Team.removeMember(team, 'bob')
98
+
99
+ expect(updated.members).toHaveLength(1)
100
+ expect(updated.members[0].id).toBe('alice')
101
+ })
102
+ })
103
+
104
+ describe('Team.aiMembers', () => {
105
+ it('should filter AI members', () => {
106
+ const team = Team({
107
+ id: 'mixed',
108
+ name: 'Mixed Team',
109
+ members: [alice, bob, codeBot],
110
+ contacts: {},
111
+ })
112
+
113
+ const aiMembers = Team.aiMembers(team)
114
+
115
+ expect(aiMembers).toHaveLength(1)
116
+ expect(aiMembers[0].id).toBe('code_bot')
117
+ })
118
+ })
119
+
120
+ describe('Team.humanMembers', () => {
121
+ it('should filter human members', () => {
122
+ const team = Team({
123
+ id: 'mixed',
124
+ name: 'Mixed Team',
125
+ members: [alice, bob, codeBot],
126
+ contacts: {},
127
+ })
128
+
129
+ const humans = Team.humanMembers(team)
130
+
131
+ expect(humans).toHaveLength(2)
132
+ })
133
+ })
134
+
135
+ describe('Team.byRole', () => {
136
+ it('should filter by role', () => {
137
+ const team = Team({
138
+ id: 'eng',
139
+ name: 'Engineering',
140
+ members: [alice, bob],
141
+ contacts: {},
142
+ })
143
+
144
+ const engineers = Team.byRole(team, 'Engineer')
145
+
146
+ expect(engineers).toHaveLength(1)
147
+ expect(engineers[0].id).toBe('bob')
148
+ })
149
+ })
150
+ })
151
+
152
+ describe('Role', () => {
153
+ it('should create a role', () => {
154
+ const role = Role({
155
+ name: 'Software Engineer',
156
+ description: 'Builds software',
157
+ responsibilities: ['Write code', 'Review PRs'],
158
+ })
159
+
160
+ expect(role.name).toBe('Software Engineer')
161
+ expect(role.responsibilities).toHaveLength(2)
162
+ })
163
+
164
+ it('should support skills and permissions', () => {
165
+ const role = Role({
166
+ name: 'Tech Lead',
167
+ description: 'Leads technical decisions',
168
+ responsibilities: ['Architecture', 'Code review'],
169
+ skills: ['System design', 'Mentoring'],
170
+ permissions: ['approve-deploys', 'manage-team'],
171
+ })
172
+
173
+ expect(role.skills).toHaveLength(2)
174
+ expect(role.permissions).toHaveLength(2)
175
+ })
176
+
177
+ it('should support role type', () => {
178
+ const aiRole = Role({
179
+ name: 'AI Reviewer',
180
+ description: 'Automated code review',
181
+ responsibilities: ['Review PRs'],
182
+ type: 'ai',
183
+ })
184
+
185
+ expect(aiRole.type).toBe('ai')
186
+ })
187
+ })
188
+
189
+ describe('Goals', () => {
190
+ it('should create goals', () => {
191
+ const goals = Goals({
192
+ shortTerm: ['Ship feature X', 'Fix critical bugs'],
193
+ longTerm: ['Achieve 100% test coverage'],
194
+ })
195
+
196
+ expect(goals.shortTerm).toHaveLength(2)
197
+ expect(goals.longTerm).toHaveLength(1)
198
+ })
199
+
200
+ it('should support strategic goals', () => {
201
+ const goals = Goals({
202
+ shortTerm: ['Sprint goals'],
203
+ longTerm: ['Quarterly goals'],
204
+ strategic: ['Annual goals'],
205
+ })
206
+
207
+ expect(goals.strategic).toHaveLength(1)
208
+ })
209
+
210
+ it('should support metrics', () => {
211
+ const goals = Goals({
212
+ shortTerm: ['Improve velocity'],
213
+ longTerm: ['Scale team'],
214
+ metrics: [
215
+ {
216
+ name: 'Velocity',
217
+ description: 'Story points per sprint',
218
+ current: 42,
219
+ target: 50,
220
+ unit: 'points',
221
+ trend: 'up',
222
+ },
223
+ ],
224
+ })
225
+
226
+ expect(goals.metrics).toHaveLength(1)
227
+ expect(goals.metrics?.[0].current).toBe(42)
228
+ })
229
+ })
230
+
231
+ describe('WorkerVerbs', () => {
232
+ it('should have all verb definitions', () => {
233
+ expect(WorkerVerbs.notify).toBeDefined()
234
+ expect(WorkerVerbs.ask).toBeDefined()
235
+ expect(WorkerVerbs.approve).toBeDefined()
236
+ expect(WorkerVerbs.decide).toBeDefined()
237
+ expect(WorkerVerbs.do).toBeDefined()
238
+ })
239
+
240
+ describe('notify verb', () => {
241
+ it('should have correct conjugation', () => {
242
+ const verb = WorkerVerbs.notify
243
+
244
+ expect(verb.action).toBe('notify')
245
+ expect(verb.actor).toBe('notifier')
246
+ expect(verb.act).toBe('notifies')
247
+ expect(verb.activity).toBe('notifying')
248
+ expect(verb.result).toBe('notification')
249
+ expect(verb.reverse.at).toBe('notifiedAt')
250
+ expect(verb.reverse.by).toBe('notifiedBy')
251
+ })
252
+ })
253
+
254
+ describe('ask verb', () => {
255
+ it('should have correct conjugation', () => {
256
+ const verb = WorkerVerbs.ask
257
+
258
+ expect(verb.action).toBe('ask')
259
+ expect(verb.actor).toBe('asker')
260
+ expect(verb.activity).toBe('asking')
261
+ expect(verb.result).toBe('question')
262
+ })
263
+ })
264
+
265
+ describe('approve verb', () => {
266
+ it('should have correct conjugation', () => {
267
+ const verb = WorkerVerbs.approve
268
+
269
+ expect(verb.action).toBe('approve')
270
+ expect(verb.actor).toBe('approver')
271
+ expect(verb.activity).toBe('approving')
272
+ expect(verb.result).toBe('approval')
273
+ expect(verb.inverse).toBe('reject')
274
+ })
275
+ })
276
+
277
+ describe('decide verb', () => {
278
+ it('should have correct conjugation', () => {
279
+ const verb = WorkerVerbs.decide
280
+
281
+ expect(verb.action).toBe('decide')
282
+ expect(verb.actor).toBe('decider')
283
+ expect(verb.activity).toBe('deciding')
284
+ expect(verb.result).toBe('decision')
285
+ })
286
+ })
287
+
288
+ describe('do verb', () => {
289
+ it('should have correct conjugation', () => {
290
+ const verb = WorkerVerbs.do
291
+
292
+ expect(verb.action).toBe('do')
293
+ expect(verb.actor).toBe('doer')
294
+ expect(verb.activity).toBe('doing')
295
+ expect(verb.result).toBe('task')
296
+ expect(verb.reverse.at).toBe('doneAt')
297
+ })
298
+ })
299
+ })