digital-workers 0.1.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.
Files changed (2) hide show
  1. package/README.md +153 -0
  2. package/package.json +69 -0
package/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # digital-workers
2
+
3
+ [![npm version](https://img.shields.io/npm/v/digital-workers.svg)](https://www.npmjs.com/package/digital-workers)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Enhanced autonomous digital workers with event loop, KPI tracking, and communication capabilities. This package builds on the `autonomous-agents` infrastructure to create digital workers with advanced features.
7
+
8
+ ## Purpose
9
+
10
+ The `digital-workers` package extends the autonomous agents concept by providing:
11
+
12
+ - Constant event loop for regular evaluation of KPIs against OKRs
13
+ - Context and memory management for long-running tasks
14
+ - Plan creation and execution for achieving objectives
15
+ - Multi-channel communication capabilities (Slack, Teams, Email, Phone)
16
+ - Enhanced autonomy through continuous self-evaluation
17
+
18
+ ## How It Builds on autonomous-agents
19
+
20
+ The `digital-workers` package uses the function-based `Agent` from `autonomous-agents` as its foundation, adding:
21
+
22
+ - **Event Loop**: Continuous evaluation and adjustment based on KPIs
23
+ - **Enhanced Context**: Maintains richer context and memory for improved decision-making
24
+ - **Communication Channels**: Integrated support for multiple communication platforms
25
+ - **KPI Tracking**: Automated tracking and evaluation of key performance indicators
26
+ - **OKR Alignment**: Ensures actions align with organizational objectives and key results
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ # Using npm
32
+ npm install digital-workers
33
+
34
+ # Using yarn
35
+ yarn add digital-workers
36
+
37
+ # Using pnpm
38
+ pnpm add digital-workers
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ ### Basic Usage
44
+
45
+ ```typescript
46
+ import { Worker } from 'digital-workers'
47
+
48
+ // Create a digital worker for customer support
49
+ const supportWorker = Worker({
50
+ name: 'Support Assistant',
51
+ description: 'Handles customer support inquiries and resolves issues',
52
+ id: 'support-worker-1',
53
+ initialContext: {
54
+ department: 'Customer Support',
55
+ specialization: 'Technical Issues'
56
+ },
57
+ initialPlans: [
58
+ {
59
+ name: 'Handle New Tickets',
60
+ steps: ['Review ticket', 'Categorize issue', 'Respond with solution or escalate']
61
+ }
62
+ ],
63
+ communication: {
64
+ slack: {
65
+ token: process.env.SLACK_TOKEN,
66
+ channels: ['support', 'escalations']
67
+ },
68
+ email: {
69
+ smtp: process.env.SMTP_CONFIG,
70
+ address: 'support@example.com'
71
+ }
72
+ },
73
+ eventLoop: {
74
+ frequency: '*/15 * * * *', // Cron expression for every 15 minutes
75
+ kpis: ['responseTime', 'resolutionRate', 'customerSatisfaction'],
76
+ okrs: {
77
+ responseTime: { target: '< 30 minutes', weight: 0.3 },
78
+ resolutionRate: { target: '> 85%', weight: 0.4 },
79
+ customerSatisfaction: { target: '> 4.5/5', weight: 0.3 }
80
+ }
81
+ }
82
+ })
83
+
84
+ // Execute a task
85
+ const result = await supportWorker.execute({
86
+ action: 'respondToTicket',
87
+ ticketId: '12345',
88
+ message: 'Thank you for your inquiry. Here is the solution...'
89
+ })
90
+
91
+ // Update worker context
92
+ await supportWorker.updateContext({
93
+ currentLoad: 'high',
94
+ priorityIssues: ['server-outage', 'payment-processing']
95
+ })
96
+
97
+ // Send a message via configured channels
98
+ await supportWorker.sendMessage('slack', {
99
+ channel: 'support',
100
+ message: 'New high-priority issue detected: server outage'
101
+ })
102
+ ```
103
+
104
+ ## API Reference
105
+
106
+ ### Worker(config)
107
+
108
+ Creates a new digital worker with the provided configuration.
109
+
110
+ **Parameters:**
111
+
112
+ - `config` (WorkerConfig): The configuration for the worker
113
+
114
+ **Returns:**
115
+
116
+ - (WorkerInstance): A digital worker instance
117
+
118
+ ### WorkerConfig
119
+
120
+ The configuration object for creating a worker.
121
+
122
+ | Property | Type | Description |
123
+ | -------------- | ----------------------- | ------------------------------------------------- |
124
+ | name | string | The name of the worker |
125
+ | description | string | Description of the worker's purpose |
126
+ | id | string (optional) | Unique identifier for the worker |
127
+ | initialContext | object (optional) | Initial context data for the worker |
128
+ | initialPlans | Plan[] (optional) | Initial plans for the worker to execute |
129
+ | communication | CommunicationConfig | Configuration for communication channels |
130
+ | eventLoop | EventLoopConfig | Configuration for the event loop and KPI tracking |
131
+
132
+ ### WorkerInstance
133
+
134
+ The worker instance returned by the Worker function.
135
+
136
+ | Property/Method | Type | Description |
137
+ | --------------- | --------------------------------------------------- | ----------------------------------------------------- |
138
+ | id | string | Unique identifier for the worker |
139
+ | agent | AutonomousAgent | The underlying autonomous agent |
140
+ | context | object | Current context data for the worker |
141
+ | plans | Plan[] | Current plans for the worker |
142
+ | execute | (input: any) => Promise<any> | Executes an action using the underlying agent |
143
+ | updateContext | (newContext: any) => Promise<void> | Updates the worker's context |
144
+ | sendMessage | (channel: string, message: any) => Promise<void> | Sends a message via the specified communication channel |
145
+
146
+ ## Dependencies
147
+
148
+ - autonomous-agents: For the underlying agent functionality
149
+ - Node.js 18+: For native features like fetch API
150
+
151
+ ## License
152
+
153
+ MIT
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "digital-workers",
3
+ "version": "0.1.1",
4
+ "description": "Enhanced autonomous digital workers with event loop, KPI tracking, and communication capabilities",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "keywords": [
12
+ "agent",
13
+ "autonomous",
14
+ "ai",
15
+ "digital-worker",
16
+ "kpi",
17
+ "okr"
18
+ ],
19
+ "author": "Drivly",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/drivly/primitives.org.ai.git",
24
+ "directory": "packages/digital-workers"
25
+ },
26
+ "homepage": "https://mdx.org.ai",
27
+ "bugs": {
28
+ "url": "https://github.com/drivly/primitives.org.ai/issues"
29
+ },
30
+ "dependencies": {
31
+ "node-cron": "^3.0.3",
32
+ "autonomous-agents": "0.1.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^22.15.3",
36
+ "@types/node-cron": "^3.0.11",
37
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
38
+ "@typescript-eslint/parser": "^6.0.0",
39
+ "eslint": "^8.56.0",
40
+ "prettier": "^3.2.5",
41
+ "tsup": "^8.0.0",
42
+ "typescript": "^5.0.0",
43
+ "vitest": "^3.1.3"
44
+ },
45
+ "engines": {
46
+ "node": ">=18"
47
+ },
48
+ "tsup": {
49
+ "entry": [
50
+ "src/index.ts"
51
+ ],
52
+ "format": [
53
+ "cjs",
54
+ "esm"
55
+ ],
56
+ "dts": true,
57
+ "splitting": false,
58
+ "sourcemap": true,
59
+ "clean": true
60
+ },
61
+ "scripts": {
62
+ "build": "tsup",
63
+ "dev": "tsup --watch",
64
+ "lint": "eslint src/**/*.ts",
65
+ "test": "vitest run",
66
+ "test:watch": "vitest",
67
+ "format": "prettier --write \"src/**/*.ts\" --semi false --single-quote true --jsx-single-quote true --print-width 160 --tab-width 2"
68
+ }
69
+ }