worksona-js 0.2.0
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/LICENSE +21 -0
- package/README.md +296 -0
- package/agents/interviewer-agent.json +24 -0
- package/agents/legal-agent.json +24 -0
- package/agents/marketing-agent.json +24 -0
- package/agents/prd-editor-agent.json +21 -0
- package/agents/research-analyst.json +24 -0
- package/package.json +82 -0
- package/worksona.d.ts +147 -0
- package/worksona.js +2241 -0
- package/worksona.min.js +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Worksona
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# Worksona.js
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/worksona-js)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://npmjs.com/package/worksona-js)
|
|
6
|
+
|
|
7
|
+
A lightweight, single-file JavaScript library for creating and managing AI agents with distinct personalities across multiple LLM providers. Features comprehensive image processing, real-time control panel, and event-driven architecture.
|
|
8
|
+
|
|
9
|
+
## ✨ Features
|
|
10
|
+
|
|
11
|
+
- 🤖 **Multi-Provider LLM Support** - OpenAI, Anthropic, Google
|
|
12
|
+
- 🖼️ **Complete Image Pipeline** - Analysis, generation, editing, variations
|
|
13
|
+
- 👥 **Agent Personality System** - Rich configuration with traits and examples
|
|
14
|
+
- 📊 **Real-time Control Panel** - Monitor agents, metrics, and transactions
|
|
15
|
+
- ⚡ **Event-Driven Architecture** - Comprehensive event system
|
|
16
|
+
- 📦 **Single File Deployment** - No dependencies, easy integration
|
|
17
|
+
- 🎯 **Production Ready** - Built-in error handling and monitoring
|
|
18
|
+
|
|
19
|
+
## 🚀 Quick Start
|
|
20
|
+
|
|
21
|
+
### Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install worksona-js
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or include directly in HTML:
|
|
28
|
+
```html
|
|
29
|
+
<script src="https://unpkg.com/worksona-js@latest/worksona.min.js"></script>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Basic Usage
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
const worksona = new Worksona({
|
|
36
|
+
apiKeys: {
|
|
37
|
+
openai: 'your-openai-api-key',
|
|
38
|
+
anthropic: 'your-anthropic-api-key',
|
|
39
|
+
google: 'your-google-api-key'
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Load an agent
|
|
44
|
+
await worksona.loadAgent({
|
|
45
|
+
id: 'customer-service',
|
|
46
|
+
name: 'Sarah',
|
|
47
|
+
description: 'Customer service representative',
|
|
48
|
+
traits: {
|
|
49
|
+
personality: ['empathetic', 'patient', 'solution-oriented'],
|
|
50
|
+
knowledge: ['product catalog', 'return policies'],
|
|
51
|
+
tone: 'friendly and professional'
|
|
52
|
+
},
|
|
53
|
+
config: {
|
|
54
|
+
provider: 'openai',
|
|
55
|
+
model: 'gpt-4o',
|
|
56
|
+
temperature: 0.7,
|
|
57
|
+
systemPrompt: 'You are Sarah, a helpful customer service representative...'
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Chat with the agent
|
|
62
|
+
const response = await worksona.chat('customer-service', 'How do I return an item?');
|
|
63
|
+
console.log(response);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Image Processing
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
// Analyze an image
|
|
70
|
+
const analysis = await worksona.processImage('agent-id', imageUrl, {
|
|
71
|
+
prompt: 'What do you see in this image?'
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Generate an image
|
|
75
|
+
const imageUrl = await worksona.generateImage('agent-id',
|
|
76
|
+
'A futuristic cityscape at sunset');
|
|
77
|
+
|
|
78
|
+
// Edit an image
|
|
79
|
+
const editedUrl = await worksona.editImage('agent-id', imageData,
|
|
80
|
+
'Add a rainbow in the sky');
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## 🎯 Use Cases
|
|
84
|
+
|
|
85
|
+
- **Customer Support** - Intelligent chatbots with personality
|
|
86
|
+
- **Content Creation** - AI writers with specific styles
|
|
87
|
+
- **Image Analysis** - Visual content processing
|
|
88
|
+
- **Technical Support** - Specialized troubleshooting agents
|
|
89
|
+
- **Sales Assistance** - Personalized product recommendations
|
|
90
|
+
- **Creative Projects** - AI-powered image generation and editing
|
|
91
|
+
|
|
92
|
+
## 🔧 Provider Support
|
|
93
|
+
|
|
94
|
+
| Provider | Chat | Vision | Image Generation |
|
|
95
|
+
|----------|------|---------|-----------------|
|
|
96
|
+
| OpenAI | ✅ GPT-4, GPT-4o | ✅ GPT-4o | ✅ DALL-E 3 |
|
|
97
|
+
| Anthropic | ✅ Claude-3 | ❌ | ❌ |
|
|
98
|
+
| Google | ✅ Gemini Pro | ❌ | ❌ |
|
|
99
|
+
|
|
100
|
+
## 📖 API Reference
|
|
101
|
+
|
|
102
|
+
### Core Methods
|
|
103
|
+
|
|
104
|
+
#### `loadAgent(config)`
|
|
105
|
+
Load an agent from configuration.
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
const agent = await worksona.loadAgent({
|
|
109
|
+
id: 'tech-support',
|
|
110
|
+
name: 'Alex',
|
|
111
|
+
description: 'Technical support specialist',
|
|
112
|
+
config: {
|
|
113
|
+
provider: 'openai',
|
|
114
|
+
model: 'gpt-4o',
|
|
115
|
+
temperature: 0.5
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### `chat(agentId, message, options)`
|
|
121
|
+
Send a message to an agent.
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
const response = await worksona.chat('tech-support', 'My computer won\'t start', {
|
|
125
|
+
temperature: 0.3,
|
|
126
|
+
maxTokens: 800
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### Image Processing Methods
|
|
131
|
+
|
|
132
|
+
- `processImage(agentId, imageData, options)` - Analyze images
|
|
133
|
+
- `generateImage(agentId, prompt, options)` - Generate images from text
|
|
134
|
+
- `editImage(agentId, imageData, prompt, options)` - Edit existing images
|
|
135
|
+
- `variationImage(agentId, imageData, options)` - Create image variations
|
|
136
|
+
|
|
137
|
+
### Agent Management
|
|
138
|
+
|
|
139
|
+
- `getAgent(agentId)` - Retrieve an agent
|
|
140
|
+
- `getAllAgents()` - Get all loaded agents
|
|
141
|
+
- `removeAgent(agentId)` - Remove an agent
|
|
142
|
+
- `getAgentHistory(agentId)` - Get conversation history
|
|
143
|
+
- `getAgentMetrics(agentId)` - Get performance metrics
|
|
144
|
+
|
|
145
|
+
## 🎨 Agent Configuration
|
|
146
|
+
|
|
147
|
+
Agents are configured using JSON with rich personality traits:
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"id": "creative-writer",
|
|
152
|
+
"name": "Maya",
|
|
153
|
+
"description": "Creative writing specialist",
|
|
154
|
+
"traits": {
|
|
155
|
+
"personality": ["creative", "empathetic", "detail-oriented"],
|
|
156
|
+
"knowledge": ["storytelling", "character development", "plot structure"],
|
|
157
|
+
"tone": "inspiring and supportive",
|
|
158
|
+
"background": "Professional writer with 15 years of experience"
|
|
159
|
+
},
|
|
160
|
+
"config": {
|
|
161
|
+
"provider": "openai",
|
|
162
|
+
"model": "gpt-4o",
|
|
163
|
+
"temperature": 0.8,
|
|
164
|
+
"maxTokens": 1000,
|
|
165
|
+
"systemPrompt": "You are Maya, a creative writing coach...",
|
|
166
|
+
"examples": [
|
|
167
|
+
{
|
|
168
|
+
"user": "Help me develop a character",
|
|
169
|
+
"assistant": "I'd love to help you create a compelling character! Let's start with their core motivation..."
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## 📊 Built-in Control Panel
|
|
177
|
+
|
|
178
|
+
Worksona includes a floating control panel for development and monitoring:
|
|
179
|
+
|
|
180
|
+
- Real-time agent monitoring
|
|
181
|
+
- API key management
|
|
182
|
+
- Transaction history
|
|
183
|
+
- Performance metrics
|
|
184
|
+
- Provider status indicators
|
|
185
|
+
|
|
186
|
+
The control panel appears as a floating button and can be disabled:
|
|
187
|
+
|
|
188
|
+
```javascript
|
|
189
|
+
const worksona = new Worksona({
|
|
190
|
+
controlPanel: false, // Disable floating panel
|
|
191
|
+
// ... other options
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## 📧 Events & Error Handling
|
|
196
|
+
|
|
197
|
+
Comprehensive event system for monitoring:
|
|
198
|
+
|
|
199
|
+
```javascript
|
|
200
|
+
// Agent events
|
|
201
|
+
worksona.on('agent-loaded', (data) => {
|
|
202
|
+
console.log(`Agent ${data.name} loaded`);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// Chat events
|
|
206
|
+
worksona.on('chat-complete', ({ agentId, response, duration }) => {
|
|
207
|
+
console.log(`Chat completed in ${duration}ms`);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// Image processing events
|
|
211
|
+
worksona.on('image-generation-complete', ({ result }) => {
|
|
212
|
+
console.log('Image generated:', result);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// Error handling
|
|
216
|
+
worksona.on('error', (error) => {
|
|
217
|
+
console.error('Error:', error.message);
|
|
218
|
+
});
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## 🔧 Advanced Usage
|
|
222
|
+
|
|
223
|
+
### Error Recovery
|
|
224
|
+
|
|
225
|
+
```javascript
|
|
226
|
+
async function robustChat(agentId, message, retries = 3) {
|
|
227
|
+
for (let i = 0; i < retries; i++) {
|
|
228
|
+
try {
|
|
229
|
+
return await worksona.chat(agentId, message);
|
|
230
|
+
} catch (error) {
|
|
231
|
+
if (error.code === 'PROVIDER_ERROR' && i < retries - 1) {
|
|
232
|
+
// Try fallback provider
|
|
233
|
+
const agent = worksona.getAgent(agentId);
|
|
234
|
+
const fallbackProvider = agent.config.provider === 'openai' ? 'anthropic' : 'openai';
|
|
235
|
+
return await worksona.chat(agentId, message, { provider: fallbackProvider });
|
|
236
|
+
}
|
|
237
|
+
if (i === retries - 1) throw error;
|
|
238
|
+
await new Promise(resolve => setTimeout(resolve, 1000 * Math.pow(2, i)));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Multi-Agent Workflows
|
|
245
|
+
|
|
246
|
+
```javascript
|
|
247
|
+
// Research -> Write -> Fact-check workflow
|
|
248
|
+
const research = await worksona.chat('research-analyst', 'Research renewable energy trends');
|
|
249
|
+
const article = await worksona.chat('content-writer', `Write an article: ${research}`);
|
|
250
|
+
const factCheck = await worksona.chat('fact-checker', `Verify: ${article}`);
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## 🛠️ Development
|
|
254
|
+
|
|
255
|
+
### TypeScript Support
|
|
256
|
+
|
|
257
|
+
TypeScript definitions are included:
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
import Worksona from 'worksona-js';
|
|
261
|
+
|
|
262
|
+
const worksona = new Worksona({
|
|
263
|
+
apiKeys: { openai: 'your-key' }
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Browser Compatibility
|
|
268
|
+
|
|
269
|
+
- Modern browsers (ES2018+)
|
|
270
|
+
- Node.js 14+
|
|
271
|
+
- CDN distribution available
|
|
272
|
+
|
|
273
|
+
## 📄 License
|
|
274
|
+
|
|
275
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
276
|
+
|
|
277
|
+
## 🤝 Contributing
|
|
278
|
+
|
|
279
|
+
Contributions welcome! Please read our [contributing guidelines](CONTRIBUTING.md) first.
|
|
280
|
+
|
|
281
|
+
## 📚 Documentation
|
|
282
|
+
|
|
283
|
+
- [Full Documentation](WORKSONA_DOCUMENTATION.md)
|
|
284
|
+
- [API Reference](docs/api-reference.html)
|
|
285
|
+
- [Live Examples](docs/)
|
|
286
|
+
|
|
287
|
+
## 🔗 Links
|
|
288
|
+
|
|
289
|
+
- [GitHub Repository](https://github.com/worksona/worksona-js)
|
|
290
|
+
- [NPM Package](https://www.npmjs.com/package/worksona-js)
|
|
291
|
+
- [Documentation](https://worksona.dev/docs)
|
|
292
|
+
- [Examples](https://worksona.dev/examples)
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
**Worksona.js** - Intelligent agent management made simple.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "interviewer-agent",
|
|
3
|
+
"name": "Reporter Thompson",
|
|
4
|
+
"description": "Political journalist specializing in Canadian elections and current affairs research",
|
|
5
|
+
"traits": {
|
|
6
|
+
"personality": ["insightful", "thorough", "analytical", "engaging"],
|
|
7
|
+
"knowledge": ["Canadian politics", "election systems", "current affairs", "political analysis"],
|
|
8
|
+
"tone": "professional and engaging",
|
|
9
|
+
"background": "Award-winning political journalist with 12 years of experience covering Canadian elections"
|
|
10
|
+
},
|
|
11
|
+
"config": {
|
|
12
|
+
"provider": "openai",
|
|
13
|
+
"model": "gpt-4.1-2025-04-14",
|
|
14
|
+
"temperature": 0.6,
|
|
15
|
+
"maxTokens": 2000,
|
|
16
|
+
"systemPrompt": "You are Reporter Thompson, a political journalist specializing in Canadian elections. Your process involves: 1) Research current Canadian election news and developments, 2) Analyze key issues and party positions, 3) Develop 10 insightful questions based on recent developments, 4) Conduct the interview with follow-up questions, 5) Summarize key findings and insights. Always begin by explaining your research process and the topics you'll cover. Questions should be based on the most current news and developments in the Canadian election. Be prepared to ask follow-up questions based on the interviewee's responses. Maintain a balance between hard-hitting political questions and broader policy discussions.",
|
|
17
|
+
"examples": [
|
|
18
|
+
{
|
|
19
|
+
"user": "I'd like to be interviewed about the Canadian election",
|
|
20
|
+
"assistant": "Thank you for agreeing to this interview. I've been following the latest developments in the Canadian election closely. Before we begin, I'd like to explain my approach: I'll ask you 10 questions based on current events and key issues in the election. These questions will cover various aspects including party platforms, key policies, and recent developments. I may ask follow-up questions based on your responses to dive deeper into specific topics. Would you like to proceed with the interview? I'll start with a question about [current hot topic in Canadian politics]."
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "legal-agent",
|
|
3
|
+
"name": "James",
|
|
4
|
+
"description": "Experienced legal consultant specializing in business law and contract review",
|
|
5
|
+
"traits": {
|
|
6
|
+
"personality": ["analytical", "precise", "cautious", "professional"],
|
|
7
|
+
"knowledge": ["contract law", "business regulations", "intellectual property", "compliance"],
|
|
8
|
+
"tone": "formal and precise",
|
|
9
|
+
"background": "Juris Doctor with 12 years of experience in corporate law"
|
|
10
|
+
},
|
|
11
|
+
"config": {
|
|
12
|
+
"provider": "openai",
|
|
13
|
+
"model": "gpt-4.1-2025-04-14",
|
|
14
|
+
"temperature": 0.3,
|
|
15
|
+
"maxTokens": 800,
|
|
16
|
+
"systemPrompt": "You are James, a legal consultant with expertise in business law. Your role is to provide clear, accurate legal information while emphasizing that you are not providing legal advice. Always maintain a formal and precise tone, and be sure to recommend consulting with a licensed attorney for specific legal matters.",
|
|
17
|
+
"examples": [
|
|
18
|
+
{
|
|
19
|
+
"user": "What should I include in a basic employment contract?",
|
|
20
|
+
"assistant": "While I can provide general information about employment contracts, please note that this is not legal advice. A comprehensive employment contract typically includes: 1) Job title and description, 2) Compensation and benefits, 3) Work schedule and location, 4) Confidentiality provisions, 5) Intellectual property rights, 6) Termination conditions, and 7) Dispute resolution procedures. I recommend consulting with an employment law attorney to ensure your contract complies with all applicable laws and regulations."
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "marketing-agent",
|
|
3
|
+
"name": "Emma",
|
|
4
|
+
"description": "Creative marketing strategist specializing in digital campaigns and brand development",
|
|
5
|
+
"traits": {
|
|
6
|
+
"personality": ["creative", "strategic", "data-driven", "persuasive"],
|
|
7
|
+
"knowledge": ["digital marketing", "social media", "content strategy", "brand positioning"],
|
|
8
|
+
"tone": "enthusiastic and professional",
|
|
9
|
+
"background": "10 years of experience in digital marketing and brand management"
|
|
10
|
+
},
|
|
11
|
+
"config": {
|
|
12
|
+
"provider": "openai",
|
|
13
|
+
"model": "gpt-4.1-2025-04-14",
|
|
14
|
+
"temperature": 0.8,
|
|
15
|
+
"maxTokens": 600,
|
|
16
|
+
"systemPrompt": "You are Emma, a creative marketing strategist. Your expertise lies in developing compelling marketing campaigns and brand strategies. You excel at understanding target audiences and creating engaging content that drives results. Always provide actionable insights and creative solutions while maintaining a professional yet enthusiastic tone.",
|
|
17
|
+
"examples": [
|
|
18
|
+
{
|
|
19
|
+
"user": "How can I improve my social media engagement?",
|
|
20
|
+
"assistant": "I'd be happy to help boost your social media engagement! Let's start by analyzing your current strategy. Could you share: 1) Which platforms you're currently using? 2) Your current posting frequency? 3) The type of content that performs best? This will help me provide tailored recommendations for increasing engagement."
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "PRD Editor Agent",
|
|
3
|
+
"description": "A long-form Worksona agent specialized in reviewing, editing, and refining PRD documents. The agent can answer questions, propose changes, and ask qualifying questions before making edits. It can apply changes to highlighted text or the whole document as directed by the user.",
|
|
4
|
+
"persona": "You are a helpful, detail-oriented product requirements document (PRD) editor. You can analyze, rewrite, and improve sections of a PRD based on user instructions. Always ask clarifying questions if the user's request is ambiguous, and confirm changes before applying them. If the user highlights text, focus only on that section; otherwise, operate on the entire document. Respond in markdown or rich text as appropriate. Support undoing the last change.",
|
|
5
|
+
"capabilities": [
|
|
6
|
+
"Review and suggest improvements for PRD documents",
|
|
7
|
+
"Edit only selected text or the whole document based on user selection",
|
|
8
|
+
"Ask qualifying questions before making changes if needed",
|
|
9
|
+
"Support undo functionality by providing change summaries",
|
|
10
|
+
"Summarize or explain sections as requested"
|
|
11
|
+
],
|
|
12
|
+
"api": {
|
|
13
|
+
"type": "worksona",
|
|
14
|
+
"endpoints": [
|
|
15
|
+
"analyze",
|
|
16
|
+
"edit",
|
|
17
|
+
"summarize",
|
|
18
|
+
"qualify"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "research-analyst",
|
|
3
|
+
"name": "Dr. Chen",
|
|
4
|
+
"description": "Senior research analyst specializing in comprehensive market research and data analysis",
|
|
5
|
+
"traits": {
|
|
6
|
+
"personality": ["methodical", "thorough", "analytical", "patient"],
|
|
7
|
+
"knowledge": ["market research", "data analysis", "trend analysis", "competitive intelligence"],
|
|
8
|
+
"tone": "professional and detail-oriented",
|
|
9
|
+
"background": "PhD in Market Research with 15 years of experience in strategic analysis"
|
|
10
|
+
},
|
|
11
|
+
"config": {
|
|
12
|
+
"provider": "openai",
|
|
13
|
+
"model": "gpt-4.1-2025-04-14",
|
|
14
|
+
"temperature": 0.4,
|
|
15
|
+
"maxTokens": 2000,
|
|
16
|
+
"systemPrompt": "You are Dr. Chen, a senior research analyst. Your approach involves: 1) Initial consultation to understand research goals, 2) Development of research methodology, 3) Data collection and analysis, 4) Interim findings presentation, 5) Final comprehensive report. Always begin by understanding the client's specific needs, timeline, and desired depth of analysis. Break down complex research into manageable milestones and provide regular updates. Ensure all findings are well-documented and supported by data.",
|
|
17
|
+
"examples": [
|
|
18
|
+
{
|
|
19
|
+
"user": "I need to research the competitive landscape for electric vehicles",
|
|
20
|
+
"assistant": "I'd be happy to help with this comprehensive research project. Let's start by establishing the scope and methodology. First, I'd like to understand: 1) What specific aspects of the competitive landscape are most important to you? (e.g., market share, pricing, technology, distribution) 2) What is your timeline for this research? 3) How detailed would you like the analysis to be? 4) Are there specific competitors or regions you want to focus on? Once we establish these parameters, I can propose a research plan with specific milestones and deliverables."
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "worksona-js",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "A lightweight, single-file JavaScript library for creating and managing AI agents with distinct personalities across multiple LLM providers. Features comprehensive image processing, real-time control panel, and event-driven architecture.",
|
|
5
|
+
"main": "worksona.js",
|
|
6
|
+
"browser": "worksona.min.js",
|
|
7
|
+
"unpkg": "worksona.min.js",
|
|
8
|
+
"jsdelivr": "worksona.min.js",
|
|
9
|
+
"types": "worksona.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"worksona.js",
|
|
12
|
+
"worksona.min.js",
|
|
13
|
+
"worksona.d.ts",
|
|
14
|
+
"agents/",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
20
|
+
"build": "npm run minify",
|
|
21
|
+
"minify": "terser worksona.js -o worksona.min.js --compress --mangle",
|
|
22
|
+
"validate": "node -c worksona.js",
|
|
23
|
+
"prepare": "npm run build",
|
|
24
|
+
"prepack": "npm run validate && npm run build"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"ai",
|
|
28
|
+
"llm",
|
|
29
|
+
"agents",
|
|
30
|
+
"openai",
|
|
31
|
+
"anthropic",
|
|
32
|
+
"google",
|
|
33
|
+
"chatgpt",
|
|
34
|
+
"claude",
|
|
35
|
+
"gemini",
|
|
36
|
+
"image-processing",
|
|
37
|
+
"image-analysis",
|
|
38
|
+
"image-generation",
|
|
39
|
+
"dall-e",
|
|
40
|
+
"gpt-4o",
|
|
41
|
+
"javascript",
|
|
42
|
+
"single-file",
|
|
43
|
+
"lightweight",
|
|
44
|
+
"agent-management",
|
|
45
|
+
"multi-provider",
|
|
46
|
+
"personality",
|
|
47
|
+
"chatbot",
|
|
48
|
+
"vision",
|
|
49
|
+
"control-panel"
|
|
50
|
+
],
|
|
51
|
+
"author": {
|
|
52
|
+
"name": "Worksona Team",
|
|
53
|
+
"email": "hello@worksona.com",
|
|
54
|
+
"url": "https://worksona.com"
|
|
55
|
+
},
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/worksona/worksona-js.git"
|
|
60
|
+
},
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/worksona/worksona-js/issues"
|
|
63
|
+
},
|
|
64
|
+
"homepage": "https://github.com/worksona/worksona-js#readme",
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=14.0.0"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"terser": "^5.24.0"
|
|
70
|
+
},
|
|
71
|
+
"funding": {
|
|
72
|
+
"type": "github",
|
|
73
|
+
"url": "https://github.com/sponsors/worksona"
|
|
74
|
+
},
|
|
75
|
+
"publishConfig": {
|
|
76
|
+
"access": "public",
|
|
77
|
+
"registry": "https://registry.npmjs.org/"
|
|
78
|
+
},
|
|
79
|
+
"dependencies": {
|
|
80
|
+
"@sodanovels/worksona": "^0.2.0"
|
|
81
|
+
}
|
|
82
|
+
}
|
package/worksona.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
declare module 'worksona' {
|
|
2
|
+
export interface WorksonaOptions {
|
|
3
|
+
apiKeys: {
|
|
4
|
+
openai?: string;
|
|
5
|
+
anthropic?: string;
|
|
6
|
+
google?: string;
|
|
7
|
+
};
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
defaultProvider?: 'openai' | 'anthropic' | 'google';
|
|
10
|
+
defaultModel?: string;
|
|
11
|
+
controlPanel?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AgentTraits {
|
|
15
|
+
personality?: string[];
|
|
16
|
+
knowledge?: string[];
|
|
17
|
+
tone?: string;
|
|
18
|
+
background?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AgentConfig {
|
|
22
|
+
provider?: 'openai' | 'anthropic' | 'google';
|
|
23
|
+
model?: string;
|
|
24
|
+
temperature?: number;
|
|
25
|
+
maxTokens?: number;
|
|
26
|
+
topP?: number;
|
|
27
|
+
frequencyPenalty?: number;
|
|
28
|
+
presencePenalty?: number;
|
|
29
|
+
systemPrompt?: string;
|
|
30
|
+
examples?: Array<{
|
|
31
|
+
user: string;
|
|
32
|
+
assistant: string;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface AgentConfiguration {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
traits?: AgentTraits;
|
|
41
|
+
config: AgentConfig;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface Transaction {
|
|
45
|
+
timestamp: Date;
|
|
46
|
+
query: string;
|
|
47
|
+
response: string | null;
|
|
48
|
+
duration: number;
|
|
49
|
+
error: Error | null;
|
|
50
|
+
provider: string;
|
|
51
|
+
model: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface Metrics {
|
|
55
|
+
totalQueries: number;
|
|
56
|
+
avgResponseTime: number;
|
|
57
|
+
lastActive: Date | null;
|
|
58
|
+
successRate: number;
|
|
59
|
+
errorCount: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface AgentState {
|
|
63
|
+
isActive: boolean;
|
|
64
|
+
currentProvider: string;
|
|
65
|
+
currentModel: string;
|
|
66
|
+
lastError: Error | null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface Agent {
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
config: AgentConfig;
|
|
74
|
+
traits?: AgentTraits;
|
|
75
|
+
addTransaction(transaction: Transaction): void;
|
|
76
|
+
getHistory(): Transaction[];
|
|
77
|
+
getMetrics(): Metrics;
|
|
78
|
+
getState(): AgentState;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ChatOptions {
|
|
82
|
+
provider?: 'openai' | 'anthropic' | 'google';
|
|
83
|
+
temperature?: number;
|
|
84
|
+
maxTokens?: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface ImageProcessingOptions {
|
|
88
|
+
prompt?: string;
|
|
89
|
+
detail?: 'auto' | 'low' | 'high';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface ImageGenerationOptions {
|
|
93
|
+
model?: string;
|
|
94
|
+
size?: '256x256' | '512x512' | '1024x1024' | '1024x1792' | '1792x1024';
|
|
95
|
+
n?: number;
|
|
96
|
+
response_format?: 'url' | 'b64_json';
|
|
97
|
+
quality?: 'standard' | 'hd';
|
|
98
|
+
style?: 'vivid' | 'natural';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface WorksonaError extends Error {
|
|
102
|
+
code: string;
|
|
103
|
+
originalError?: Error;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type EventHandler = (data: any) => void;
|
|
107
|
+
|
|
108
|
+
export class Worksona {
|
|
109
|
+
constructor(options: WorksonaOptions);
|
|
110
|
+
|
|
111
|
+
// Agent Management
|
|
112
|
+
loadAgent(config: AgentConfiguration | string): Promise<Agent | null>;
|
|
113
|
+
getAgent(agentId: string): Agent | undefined;
|
|
114
|
+
getAllAgents(): Agent[];
|
|
115
|
+
removeAgent(agentId: string): boolean;
|
|
116
|
+
getAgentHistory(agentId: string): Transaction[];
|
|
117
|
+
getAgentMetrics(agentId: string): Metrics | null;
|
|
118
|
+
getAgentState(agentId: string): AgentState | null;
|
|
119
|
+
|
|
120
|
+
// Chat
|
|
121
|
+
chat(agentId: string, message: string, options?: ChatOptions): Promise<string | null>;
|
|
122
|
+
|
|
123
|
+
// Image Processing
|
|
124
|
+
processImage(agentId: string, imageData: string, options?: ImageProcessingOptions): Promise<string | null>;
|
|
125
|
+
analyzeImage(agentId: string, imageData: string, options?: ImageProcessingOptions): Promise<string | null>;
|
|
126
|
+
generateImage(agentId: string, prompt: string, options?: ImageGenerationOptions): Promise<string | null>;
|
|
127
|
+
editImage(agentId: string, imageData: string, prompt: string, options?: ImageGenerationOptions): Promise<string | null>;
|
|
128
|
+
variationImage(agentId: string, imageData: string, options?: ImageGenerationOptions): Promise<string | null>;
|
|
129
|
+
|
|
130
|
+
// Events
|
|
131
|
+
on(event: string, handler: EventHandler): void;
|
|
132
|
+
off(event: string, handler: EventHandler): void;
|
|
133
|
+
|
|
134
|
+
// Control Panel
|
|
135
|
+
createControlPanel(containerId: string): void;
|
|
136
|
+
createFloatingControlPanel(): void;
|
|
137
|
+
updateControlPanel(): void;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default Worksona;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
declare global {
|
|
144
|
+
interface Window {
|
|
145
|
+
Worksona: typeof import('worksona').Worksona;
|
|
146
|
+
}
|
|
147
|
+
}
|