digital-workers 2.0.2 → 2.1.3

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 (69) hide show
  1. package/.turbo/turbo-build.log +4 -5
  2. package/CHANGELOG.md +31 -0
  3. package/LICENSE +21 -0
  4. package/README.md +134 -180
  5. package/dist/actions.d.ts.map +1 -1
  6. package/dist/actions.js +1 -0
  7. package/dist/actions.js.map +1 -1
  8. package/dist/agent-comms.d.ts +438 -0
  9. package/dist/agent-comms.d.ts.map +1 -0
  10. package/dist/agent-comms.js +666 -0
  11. package/dist/agent-comms.js.map +1 -0
  12. package/dist/capability-tiers.d.ts +230 -0
  13. package/dist/capability-tiers.d.ts.map +1 -0
  14. package/dist/capability-tiers.js +388 -0
  15. package/dist/capability-tiers.js.map +1 -0
  16. package/dist/cascade-context.d.ts +523 -0
  17. package/dist/cascade-context.d.ts.map +1 -0
  18. package/dist/cascade-context.js +494 -0
  19. package/dist/cascade-context.js.map +1 -0
  20. package/dist/error-escalation.d.ts +416 -0
  21. package/dist/error-escalation.d.ts.map +1 -0
  22. package/dist/error-escalation.js +656 -0
  23. package/dist/error-escalation.js.map +1 -0
  24. package/dist/index.d.ts +10 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +34 -0
  27. package/dist/index.js.map +1 -1
  28. package/dist/load-balancing.d.ts +395 -0
  29. package/dist/load-balancing.d.ts.map +1 -0
  30. package/dist/load-balancing.js +905 -0
  31. package/dist/load-balancing.js.map +1 -0
  32. package/dist/types.d.ts +8 -0
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/types.js +1 -0
  35. package/dist/types.js.map +1 -1
  36. package/package.json +14 -14
  37. package/src/actions.js +436 -0
  38. package/src/actions.ts +9 -8
  39. package/src/agent-comms.ts +1238 -0
  40. package/src/approve.js +234 -0
  41. package/src/ask.js +226 -0
  42. package/src/capability-tiers.ts +545 -0
  43. package/src/cascade-context.ts +648 -0
  44. package/src/decide.js +244 -0
  45. package/src/do.js +227 -0
  46. package/src/error-escalation.ts +1135 -0
  47. package/src/generate.js +298 -0
  48. package/src/goals.js +205 -0
  49. package/src/index.js +68 -0
  50. package/src/index.ts +223 -0
  51. package/src/is.js +317 -0
  52. package/src/kpis.js +270 -0
  53. package/src/load-balancing.ts +1381 -0
  54. package/src/notify.js +219 -0
  55. package/src/role.js +110 -0
  56. package/src/team.js +130 -0
  57. package/src/transports.js +357 -0
  58. package/src/types.js +71 -0
  59. package/src/types.ts +8 -0
  60. package/test/actions.test.js +401 -0
  61. package/test/agent-comms.test.ts +1397 -0
  62. package/test/capability-tiers.test.ts +631 -0
  63. package/test/cascade-context.test.ts +692 -0
  64. package/test/error-escalation.test.ts +1205 -0
  65. package/test/load-balancing-thread-safety.test.ts +464 -0
  66. package/test/load-balancing.test.ts +1145 -0
  67. package/test/standalone.test.js +250 -0
  68. package/test/types.test.js +371 -0
  69. package/test/types.test.ts +35 -0
package/src/actions.ts CHANGED
@@ -325,13 +325,14 @@ export function withWorkers($: WorkflowContext): WorkflowContext & WorkerContext
325
325
  message: string,
326
326
  options: NotifyOptions = {}
327
327
  ): Promise<NotifyResult> {
328
- return $.do<NotifyActionData, NotifyResult>('Worker.notify', {
328
+ // Workflow handler returns NotifyResult; $.do passes through the result
329
+ return $.do<NotifyResult>('Worker.notify', {
329
330
  actor: 'system',
330
331
  object: target,
331
332
  action: 'notify',
332
333
  message,
333
334
  ...options,
334
- })
335
+ } as NotifyActionData)
335
336
  },
336
337
 
337
338
  async ask<T = string>(
@@ -339,13 +340,13 @@ export function withWorkers($: WorkflowContext): WorkflowContext & WorkerContext
339
340
  question: string,
340
341
  options: AskOptions = {}
341
342
  ): Promise<AskResult<T>> {
342
- return $.do<AskActionData, AskResult<T>>('Worker.ask', {
343
+ return $.do<AskResult<T>>('Worker.ask', {
343
344
  actor: 'system',
344
345
  object: target,
345
346
  action: 'ask',
346
347
  question,
347
348
  ...options,
348
- })
349
+ } as AskActionData)
349
350
  },
350
351
 
351
352
  async approve(
@@ -360,24 +361,24 @@ export function withWorkers($: WorkflowContext): WorkflowContext & WorkerContext
360
361
  ? { id: target.id, type: 'type' in target ? target.type : undefined, name: 'name' in target ? target.name : undefined }
361
362
  : 'system'
362
363
 
363
- return $.do<ApproveActionData, ApprovalResult>('Worker.approve', {
364
+ return $.do<ApprovalResult>('Worker.approve', {
364
365
  actor,
365
366
  object: target,
366
367
  action: 'approve',
367
368
  request,
368
369
  ...options,
369
- })
370
+ } as ApproveActionData)
370
371
  },
371
372
 
372
373
  async decide<T = string>(
373
374
  options: DecideOptions<T>
374
375
  ): Promise<DecideResult<T>> {
375
- return $.do<DecideActionData, DecideResult<T>>('Worker.decide', {
376
+ return $.do<DecideResult<T>>('Worker.decide', {
376
377
  actor: 'ai',
377
378
  object: 'decision',
378
379
  action: 'decide',
379
380
  ...options,
380
- })
381
+ } as DecideActionData)
381
382
  },
382
383
  }
383
384