twinclaw 1.1.1 → 1.1.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 (35) hide show
  1. package/README.md +3 -3
  2. package/dist/api/handlers/agents.js +82 -0
  3. package/dist/api/handlers/debug.js +69 -0
  4. package/dist/api/handlers/devices.js +79 -0
  5. package/dist/api/handlers/jobs.js +99 -0
  6. package/dist/api/handlers/status.js +149 -0
  7. package/dist/api/router.js +272 -2
  8. package/dist/api/runtime-event-producer.js +20 -0
  9. package/dist/api/shared.js +34 -0
  10. package/dist/api/websocket-hub.js +18 -7
  11. package/dist/config/json-config.js +393 -1
  12. package/dist/core/heartbeat.js +304 -8
  13. package/dist/core/lane-executor.js +18 -0
  14. package/dist/core/onboarding.js +2 -2
  15. package/dist/core/self-improve-cli.js +212 -0
  16. package/dist/core/simplified-onboarding.js +158 -16
  17. package/dist/index.js +61 -33
  18. package/dist/interfaces/dispatcher.js +4 -2
  19. package/dist/interfaces/whatsapp_handler.js +243 -2
  20. package/dist/services/auto-configurer.js +591 -0
  21. package/dist/services/device-pairing.js +378 -0
  22. package/dist/services/hooks.js +130 -0
  23. package/dist/services/job-scheduler.js +133 -1
  24. package/dist/services/learning-system.js +226 -0
  25. package/dist/services/self-healing.js +267 -0
  26. package/dist/services/skill-acquisition/intent-parser.js +115 -0
  27. package/dist/services/skill-acquisition/research-engine.js +319 -0
  28. package/dist/services/skill-builder.js +235 -0
  29. package/dist/services/sub-agent-service.js +215 -0
  30. package/dist/services/web-service.js +70 -0
  31. package/dist/services/webhook-service.js +127 -0
  32. package/dist/skills/builtin.js +827 -0
  33. package/dist/tools/agent-improvement.js +208 -0
  34. package/dist/types/skill-acquisition.js +4 -0
  35. package/package.json +3 -1
@@ -2,26 +2,379 @@ import * as fs from 'fs/promises';
2
2
  import { existsSync, readFileSync } from 'fs';
3
3
  import * as path from 'path';
4
4
  import { getConfigPath as getWorkspaceConfigPath, hasLegacyConfig, migrateLegacyConfig, ensureWorkspaceDir, } from './workspace.js';
5
+ export const BUILTIN_WINDOWS_SKILLS = [
6
+ {
7
+ id: 'powershell',
8
+ name: 'PowerShell',
9
+ description: 'Execute PowerShell commands and scripts',
10
+ enabled: true,
11
+ category: 'system',
12
+ command: 'powershell',
13
+ os: 'windows',
14
+ },
15
+ {
16
+ id: 'cmd',
17
+ name: 'CMD',
18
+ description: 'Execute Windows CMD commands',
19
+ enabled: true,
20
+ category: 'system',
21
+ command: 'cmd',
22
+ os: 'windows',
23
+ },
24
+ {
25
+ id: 'clipboard',
26
+ name: 'Clipboard',
27
+ description: 'Read/write Windows clipboard',
28
+ enabled: true,
29
+ category: 'utilities',
30
+ os: 'windows',
31
+ },
32
+ {
33
+ id: 'files',
34
+ name: 'File Operations',
35
+ description: 'Windows file management (copy, move, delete, search)',
36
+ enabled: true,
37
+ category: 'utilities',
38
+ os: 'windows',
39
+ },
40
+ {
41
+ id: 'notepad',
42
+ name: 'Notepad',
43
+ description: 'Open and edit text files with Notepad',
44
+ enabled: true,
45
+ category: 'utilities',
46
+ command: 'notepad',
47
+ os: 'windows',
48
+ },
49
+ {
50
+ id: 'excel',
51
+ name: 'Microsoft Excel',
52
+ description: 'Interact with Excel spreadsheets via COM',
53
+ enabled: false,
54
+ category: 'office',
55
+ requires: ['pywin32'],
56
+ os: 'windows',
57
+ },
58
+ {
59
+ id: 'outlook',
60
+ name: 'Microsoft Outlook',
61
+ description: 'Send emails and manage calendar via Outlook COM',
62
+ enabled: false,
63
+ category: 'office',
64
+ requires: ['pywin32'],
65
+ os: 'windows',
66
+ },
67
+ {
68
+ id: 'teams',
69
+ name: 'Microsoft Teams',
70
+ description: 'Send messages and manage Teams via API',
71
+ enabled: false,
72
+ category: 'communication',
73
+ requires: ['msgraph-sdk'],
74
+ os: 'windows',
75
+ },
76
+ {
77
+ id: 'edge',
78
+ name: 'Microsoft Edge',
79
+ description: 'Control Edge browser for web automation',
80
+ enabled: false,
81
+ category: 'utilities',
82
+ requires: ['playwright'],
83
+ os: 'windows',
84
+ },
85
+ {
86
+ id: 'chrome',
87
+ name: 'Google Chrome',
88
+ description: 'Control Chrome browser for web automation',
89
+ enabled: false,
90
+ category: 'utilities',
91
+ requires: ['playwright'],
92
+ os: 'windows',
93
+ },
94
+ {
95
+ id: 'wsl',
96
+ name: 'WSL',
97
+ description: 'Execute commands in Windows Subsystem for Linux',
98
+ enabled: false,
99
+ category: 'development',
100
+ requires: ['wsl'],
101
+ os: 'windows',
102
+ },
103
+ {
104
+ id: 'git',
105
+ name: 'Git',
106
+ description: 'Execute Git commands for version control',
107
+ enabled: false,
108
+ category: 'development',
109
+ command: 'git',
110
+ requires: ['git'],
111
+ os: 'windows',
112
+ },
113
+ {
114
+ id: 'node',
115
+ name: 'Node.js',
116
+ description: 'Execute Node.js scripts and npm commands',
117
+ enabled: false,
118
+ category: 'development',
119
+ command: 'node',
120
+ requires: ['node'],
121
+ os: 'all',
122
+ },
123
+ {
124
+ id: 'python',
125
+ name: 'Python',
126
+ description: 'Execute Python scripts',
127
+ enabled: false,
128
+ category: 'development',
129
+ command: 'python',
130
+ requires: ['python'],
131
+ os: 'all',
132
+ },
133
+ {
134
+ id: 'registry',
135
+ name: 'Windows Registry',
136
+ description: 'Read/write Windows Registry keys',
137
+ enabled: false,
138
+ category: 'system',
139
+ os: 'windows',
140
+ },
141
+ {
142
+ id: 'services',
143
+ name: 'Windows Services',
144
+ description: 'Manage Windows services (start, stop, restart)',
145
+ enabled: false,
146
+ category: 'system',
147
+ command: 'sc',
148
+ os: 'windows',
149
+ },
150
+ {
151
+ id: 'taskmgr',
152
+ name: 'Task Manager',
153
+ description: 'Manage running processes and applications',
154
+ enabled: false,
155
+ category: 'system',
156
+ command: 'tasklist',
157
+ os: 'windows',
158
+ },
159
+ {
160
+ id: 'screenshot',
161
+ name: 'Screenshot',
162
+ description: 'Take screenshots of the desktop',
163
+ enabled: false,
164
+ category: 'utilities',
165
+ os: 'windows',
166
+ },
167
+ {
168
+ id: 'audio',
169
+ name: 'Audio Control',
170
+ description: 'Control system audio (volume, mute)',
171
+ enabled: false,
172
+ category: 'utilities',
173
+ os: 'windows',
174
+ },
175
+ {
176
+ id: 'wifi',
177
+ name: 'WiFi Management',
178
+ description: 'Manage WiFi connections',
179
+ enabled: false,
180
+ category: 'system',
181
+ command: 'netsh wlan',
182
+ os: 'windows',
183
+ },
184
+ {
185
+ id: 'bluetooth',
186
+ name: 'Bluetooth',
187
+ description: 'Manage Bluetooth devices',
188
+ enabled: false,
189
+ category: 'system',
190
+ os: 'windows',
191
+ },
192
+ {
193
+ id: 'windows-update',
194
+ name: 'Windows Update',
195
+ description: 'Check and manage Windows updates',
196
+ enabled: false,
197
+ category: 'system',
198
+ os: 'windows',
199
+ },
200
+ {
201
+ id: 'defender',
202
+ name: 'Windows Defender',
203
+ description: 'Manage Windows Defender antivirus',
204
+ enabled: false,
205
+ category: 'system',
206
+ command: 'MpDefender',
207
+ os: 'windows',
208
+ },
209
+ {
210
+ id: 'terminal',
211
+ name: 'Windows Terminal',
212
+ description: 'Open Windows Terminal',
213
+ enabled: false,
214
+ category: 'system',
215
+ command: 'wt',
216
+ os: 'windows',
217
+ },
218
+ {
219
+ id: 'explorer',
220
+ name: 'File Explorer',
221
+ description: 'Open and manage Windows Explorer',
222
+ enabled: false,
223
+ category: 'utilities',
224
+ command: 'explorer',
225
+ os: 'windows',
226
+ },
227
+ {
228
+ id: 'calculator',
229
+ name: 'Calculator',
230
+ description: 'Open Windows Calculator',
231
+ enabled: false,
232
+ category: 'utilities',
233
+ command: 'calc',
234
+ os: 'windows',
235
+ },
236
+ {
237
+ id: 'snipping-tool',
238
+ name: 'Snipping Tool',
239
+ description: 'Open Snipping Tool for screenshots',
240
+ enabled: false,
241
+ category: 'utilities',
242
+ command: 'snippingtool',
243
+ os: 'windows',
244
+ },
245
+ {
246
+ id: 'powershell-ise',
247
+ name: 'PowerShell ISE',
248
+ description: 'Open PowerShell ISE script editor',
249
+ enabled: false,
250
+ category: 'development',
251
+ command: 'powershell_ise',
252
+ os: 'windows',
253
+ },
254
+ {
255
+ id: 'vscode',
256
+ name: 'VS Code',
257
+ description: 'Open Visual Studio Code',
258
+ enabled: false,
259
+ category: 'development',
260
+ command: 'code',
261
+ requires: ['vscode'],
262
+ os: 'all',
263
+ },
264
+ {
265
+ id: 'docker',
266
+ name: 'Docker',
267
+ description: 'Manage Docker containers',
268
+ enabled: false,
269
+ category: 'development',
270
+ command: 'docker',
271
+ requires: ['docker'],
272
+ os: 'windows',
273
+ },
274
+ {
275
+ id: 'venv',
276
+ name: 'Python Virtual Environments',
277
+ description: 'Create and manage Python venv',
278
+ enabled: false,
279
+ category: 'development',
280
+ requires: ['python'],
281
+ os: 'all',
282
+ },
283
+ {
284
+ id: 'summarize',
285
+ name: 'Summarize',
286
+ description: 'Summarize or extract text from URLs, podcasts, and local files',
287
+ enabled: true,
288
+ category: 'productivity',
289
+ os: 'all',
290
+ autoInstall: true,
291
+ },
292
+ {
293
+ id: 'web-search',
294
+ name: 'Web Search',
295
+ description: 'Search the web using Brave Search API',
296
+ enabled: true,
297
+ category: 'productivity',
298
+ os: 'all',
299
+ autoInstall: true,
300
+ },
301
+ {
302
+ id: 'web-fetch',
303
+ name: 'Web Fetch',
304
+ description: 'Fetch and parse web pages',
305
+ enabled: true,
306
+ category: 'productivity',
307
+ os: 'all',
308
+ autoInstall: true,
309
+ },
310
+ ];
311
+ export const MODEL_PROVIDERS = [
312
+ { id: 'openai', name: 'OpenAI (Codex OAuth + API key)', baseUrl: 'https://api.openai.com/v1', defaultModel: 'gpt-4o', supportsStreaming: true, supportsFunctionCalling: true, contextWindow: 128000 },
313
+ { id: 'anthropic', name: 'Anthropic', baseUrl: 'https://api.anthropic.com/v1', defaultModel: 'claude-sonnet-4-20250514', supportsStreaming: true, supportsFunctionCalling: true, contextWindow: 200000 },
314
+ { id: 'chutes', name: 'Chutes', baseUrl: 'https://api.chutes.ai/v1', defaultModel: 'Qwen/Qwen2.5-72B-Instruct', supportsStreaming: true, contextWindow: 32768 },
315
+ { id: 'vllm', name: 'vLLM', baseUrl: 'http://localhost:8000/v1', defaultModel: 'meta-llama/Llama-3.1-70B-Instruct', supportsStreaming: true, supportsFunctionCalling: true, contextWindow: 128000 },
316
+ { id: 'minimax', name: 'MiniMax', baseUrl: 'https://api.minimax.chat/v1', defaultModel: 'abab6.5s-chat', supportsStreaming: true, contextWindow: 245760 },
317
+ { id: 'moonshot', name: 'Moonshot AI (Kimi K2.5)', baseUrl: 'https://api.moonshot.cn/v1', defaultModel: 'moonshot-v1-8k', supportsStreaming: true, contextWindow: 128000 },
318
+ { id: 'google', name: 'Google', baseUrl: 'https://generativelanguage.googleapis.com/v1', defaultModel: 'gemini-2.0-flash-exp', supportsStreaming: true, contextWindow: 1000000 },
319
+ { id: 'xai', name: 'xAI (Grok)', baseUrl: 'https://api.x.ai/v1', defaultModel: 'grok-2-1212', supportsStreaming: true, contextWindow: 131072 },
320
+ { id: 'openrouter', name: 'OpenRouter', baseUrl: 'https://openrouter.ai/api/v1', defaultModel: 'anthropic/claude-sonnet-4-20250514', supportsStreaming: true, supportsFunctionCalling: true, contextWindow: 200000 },
321
+ { id: 'qwen', name: 'Qwen', baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1', defaultModel: 'qwen-plus', supportsStreaming: true, contextWindow: 131072 },
322
+ { id: 'zai', name: 'Z.AI', baseUrl: 'https://api.zai.net/v1', defaultModel: 'zai/llama-3.3-70b-instruct', supportsStreaming: true, contextWindow: 128000 },
323
+ { id: 'qianfan', name: 'Qianfan', baseUrl: 'https://qianfan.baidubce.com/v3', defaultModel: 'ernie-4.0-8k', supportsStreaming: true, contextWindow: 32000 },
324
+ { id: 'copilot', name: 'Copilot', baseUrl: 'https://api.github.com', defaultModel: 'gpt-4o', supportsStreaming: true, contextWindow: 128000 },
325
+ { id: 'vercel', name: 'Vercel AI Gateway', baseUrl: '', defaultModel: 'gpt-4o', supportsStreaming: true, supportsFunctionCalling: true },
326
+ { id: 'opencode', name: 'OpenCode Zen', baseUrl: 'https://api.opencode.cn/v1', defaultModel: 'deepseek-chat', supportsStreaming: true, contextWindow: 64000 },
327
+ { id: 'xiaomi', name: 'Xiaomi', baseUrl: 'https://api.xiaomi.com/v1', defaultModel: 'MiMo-7B-Instruct', supportsStreaming: true, contextWindow: 32768 },
328
+ { id: 'synthetic', name: 'Synthetic', baseUrl: '', defaultModel: '', supportsStreaming: false },
329
+ { id: 'together', name: 'Together AI', baseUrl: 'https://api.together.ai/v1', defaultModel: 'meta-llama/Llama-3.3-70B-Instruct', supportsStreaming: true, contextWindow: 128000 },
330
+ { id: 'huggingface', name: 'Hugging Face', baseUrl: 'https://api-inference.huggingface.co', defaultModel: 'meta-llama/Llama-3.1-70B-Instruct', supportsStreaming: false, contextWindow: 128000 },
331
+ { id: 'venice', name: 'Venice AI', baseUrl: 'https://api.venice.ai/api/v1', defaultModel: 'qwen2.5-72b', supportsStreaming: true, contextWindow: 131072 },
332
+ { id: 'litellm', name: 'LiteLLM', baseUrl: '', defaultModel: '', supportsStreaming: true },
333
+ { id: 'cloudflare', name: 'Cloudflare AI Gateway', baseUrl: '', defaultModel: '@cf/meta/llama-3.1-70b-instruct', supportsStreaming: false, contextWindow: 128000 },
334
+ { id: 'modal', name: 'Modal', baseUrl: 'https://api.us-west-2.modal.direct/v1', defaultModel: 'zai-org/GLM-5-FP8', supportsStreaming: true, contextWindow: 200000 },
335
+ { id: 'custom', name: 'Custom Provider', baseUrl: '', defaultModel: '', supportsStreaming: true },
336
+ ];
5
337
  export const DEFAULT_CONFIG = {
6
338
  runtime: {
7
339
  apiSecret: '',
8
- apiPort: 3100,
340
+ apiPort: 67420,
9
341
  secretVaultRequired: [],
10
342
  },
343
+ gateway: {
344
+ mode: 'local',
345
+ bind: 'loopback',
346
+ auth: {
347
+ mode: 'hmac',
348
+ token: '',
349
+ },
350
+ tailscale: {
351
+ mode: 'off',
352
+ resetOnExit: false,
353
+ },
354
+ },
11
355
  models: {
12
356
  modalApiKey: '',
13
357
  openRouterApiKey: '',
14
358
  geminiApiKey: '',
359
+ definitions: [],
360
+ primaryModel: '',
361
+ fallbackModels: [],
15
362
  },
16
363
  messaging: {
17
364
  telegram: {
18
365
  enabled: false,
19
366
  botToken: '',
20
367
  userId: null,
368
+ dmPolicy: 'allowlist',
369
+ groupPolicy: 'allowlist',
370
+ allowFrom: [],
21
371
  },
22
372
  whatsapp: {
23
373
  enabled: false,
24
374
  phoneNumber: '',
375
+ dmPolicy: 'allowlist',
376
+ groupPolicy: 'allowlist',
377
+ allowFrom: [],
25
378
  },
26
379
  voice: {
27
380
  groqApiKey: '',
@@ -55,6 +408,45 @@ export const DEFAULT_CONFIG = {
55
408
  allow: [],
56
409
  deny: [],
57
410
  },
411
+ web: {
412
+ search: {
413
+ enabled: false,
414
+ apiKey: '',
415
+ provider: 'brave',
416
+ },
417
+ fetch: {
418
+ enabled: true,
419
+ userAgent: 'TwinClaw/1.0',
420
+ timeout: 30000,
421
+ },
422
+ },
423
+ hooks: {
424
+ boot: [],
425
+ shutdown: [],
426
+ 'session-start': [],
427
+ 'session-end': [],
428
+ 'command-exec': [],
429
+ 'command-result': [],
430
+ 'message-received': [],
431
+ 'message-sent': [],
432
+ error: [],
433
+ },
434
+ skills: {
435
+ enabled: true,
436
+ builtin: BUILTIN_WINDOWS_SKILLS,
437
+ custom: [],
438
+ },
439
+ context: {
440
+ pruning: {
441
+ mode: 'cache-ttl',
442
+ ttl: '6h',
443
+ keepLastAssistants: 3,
444
+ },
445
+ compaction: {
446
+ enabled: true,
447
+ prompt: 'Extract key decisions and important information from this conversation.',
448
+ },
449
+ },
58
450
  };
59
451
  export function getConfigPath(overridePath) {
60
452
  if (overridePath)