loki-mode 5.42.2 → 5.46.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.
@@ -0,0 +1,572 @@
1
+ # OpenClaw Integration
2
+
3
+ Multi-agent coordination protocol integration for Loki Mode (v5.38.0).
4
+
5
+ ## Overview
6
+
7
+ OpenClaw is a standardized protocol for multi-agent coordination across different AI systems. Loki Mode's OpenClaw bridge enables:
8
+
9
+ - **Cross-system orchestration** - Coordinate Loki Mode agents with other agent frameworks
10
+ - **Standardized communication** - Common message format for agent-to-agent communication
11
+ - **Shared task queues** - Distribute work across multiple orchestrators
12
+ - **State synchronization** - Keep agent state consistent across systems
13
+
14
+ Compatible with:
15
+ - AutoGPT
16
+ - MetaGPT
17
+ - CrewAI
18
+ - LangGraph agents
19
+ - Custom agent frameworks implementing the OpenClaw protocol
20
+
21
+ ## Quick Start
22
+
23
+ ```bash
24
+ # Enable OpenClaw bridge
25
+ export LOKI_OPENCLAW_ENABLED=true
26
+ export LOKI_OPENCLAW_ENDPOINT=http://openclaw-server:8080
27
+
28
+ # Start with OpenClaw integration
29
+ loki start --openclaw ./prd.md
30
+ ```
31
+
32
+ ## Configuration
33
+
34
+ ### Environment Variables
35
+
36
+ | Variable | Default | Description |
37
+ |----------|---------|-------------|
38
+ | `LOKI_OPENCLAW_ENABLED` | `false` | Enable OpenClaw bridge |
39
+ | `LOKI_OPENCLAW_ENDPOINT` | - | OpenClaw server endpoint URL (required) |
40
+ | `LOKI_OPENCLAW_AGENT_ID` | `loki-{pid}` | Unique agent ID for this Loki instance |
41
+ | `LOKI_OPENCLAW_NAMESPACE` | `default` | Namespace for multi-tenant deployments |
42
+ | `LOKI_OPENCLAW_HEARTBEAT` | `30` | Heartbeat interval in seconds |
43
+ | `LOKI_OPENCLAW_TIMEOUT` | `120` | Message timeout in seconds |
44
+
45
+ ### Configuration File
46
+
47
+ ```yaml
48
+ # .loki/config.yaml
49
+ openclaw:
50
+ enabled: true
51
+ endpoint: http://openclaw-server:8080
52
+ agent_id: loki-primary
53
+ namespace: production
54
+ heartbeat_interval: 30
55
+ message_timeout: 120
56
+ features:
57
+ task_sharing: true
58
+ state_sync: true
59
+ capabilities_discovery: true
60
+ ```
61
+
62
+ ## OpenClaw Protocol
63
+
64
+ ### Message Format
65
+
66
+ OpenClaw uses JSON messages over HTTP/WebSocket:
67
+
68
+ ```json
69
+ {
70
+ "protocol_version": "1.0",
71
+ "message_type": "task_offer",
72
+ "agent_id": "loki-12345",
73
+ "namespace": "default",
74
+ "timestamp": "2026-02-15T14:30:00Z",
75
+ "payload": {
76
+ "task_id": "task-abc123",
77
+ "task_type": "code_review",
78
+ "priority": "high",
79
+ "deadline": "2026-02-15T16:00:00Z",
80
+ "requirements": {
81
+ "model": "opus",
82
+ "skills": ["code_review", "security_audit"]
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
88
+ ### Message Types
89
+
90
+ | Type | Direction | Description |
91
+ |------|-----------|-------------|
92
+ | `register` | Loki → OpenClaw | Agent registration with capabilities |
93
+ | `heartbeat` | Loki → OpenClaw | Keep-alive signal |
94
+ | `task_offer` | OpenClaw → Loki | Task offered for execution |
95
+ | `task_accept` | Loki → OpenClaw | Accept task offer |
96
+ | `task_reject` | Loki → OpenClaw | Reject task offer |
97
+ | `task_update` | Loki → OpenClaw | Progress update |
98
+ | `task_complete` | Loki → OpenClaw | Task completion |
99
+ | `state_sync` | Bidirectional | State synchronization |
100
+ | `capability_query` | OpenClaw → Loki | Query agent capabilities |
101
+
102
+ ## Agent Registration
103
+
104
+ When OpenClaw bridge starts, Loki Mode registers with the OpenClaw server:
105
+
106
+ ```json
107
+ {
108
+ "message_type": "register",
109
+ "agent_id": "loki-12345",
110
+ "payload": {
111
+ "name": "Loki Mode",
112
+ "version": "5.42.2",
113
+ "provider": "claude",
114
+ "capabilities": [
115
+ "full_stack_development",
116
+ "code_review",
117
+ "testing",
118
+ "deployment",
119
+ "business_operations"
120
+ ],
121
+ "agent_types": [
122
+ "eng-frontend", "eng-backend", "eng-qa",
123
+ "ops-devops", "ops-sre", "biz-marketing"
124
+ ],
125
+ "max_concurrent_tasks": 10,
126
+ "supported_models": ["opus", "sonnet", "haiku"]
127
+ }
128
+ }
129
+ ```
130
+
131
+ ## Task Coordination
132
+
133
+ ### Receiving Tasks
134
+
135
+ Loki Mode receives tasks from OpenClaw:
136
+
137
+ ```json
138
+ {
139
+ "message_type": "task_offer",
140
+ "payload": {
141
+ "task_id": "external-task-123",
142
+ "task_type": "code_review",
143
+ "description": "Review authentication module",
144
+ "files": ["src/auth.py", "tests/test_auth.py"],
145
+ "priority": "high",
146
+ "deadline": "2026-02-15T16:00:00Z"
147
+ }
148
+ }
149
+ ```
150
+
151
+ Loki Mode evaluates and responds:
152
+
153
+ ```json
154
+ {
155
+ "message_type": "task_accept",
156
+ "payload": {
157
+ "task_id": "external-task-123",
158
+ "assigned_agent": "review-code",
159
+ "estimated_duration": 600
160
+ }
161
+ }
162
+ ```
163
+
164
+ ### Offering Tasks
165
+
166
+ Loki Mode can offer tasks to other agents via OpenClaw:
167
+
168
+ ```json
169
+ {
170
+ "message_type": "task_offer",
171
+ "payload": {
172
+ "task_id": "loki-task-456",
173
+ "task_type": "data_analysis",
174
+ "description": "Analyze user behavior logs",
175
+ "requirements": {
176
+ "skills": ["data_science", "ml"],
177
+ "estimated_cost": 0.50
178
+ }
179
+ }
180
+ }
181
+ ```
182
+
183
+ ## State Synchronization
184
+
185
+ ### Shared State
186
+
187
+ Loki Mode synchronizes key state with OpenClaw:
188
+
189
+ - Active agents and their status
190
+ - Task queue (pending, in-progress, completed)
191
+ - Session metadata (iteration, cost, uptime)
192
+ - Resource utilization (memory, CPU, tokens)
193
+
194
+ ```json
195
+ {
196
+ "message_type": "state_sync",
197
+ "payload": {
198
+ "session_status": "running",
199
+ "iteration": 42,
200
+ "agents_active": 12,
201
+ "tasks_pending": 5,
202
+ "tasks_in_progress": 8,
203
+ "tasks_completed": 127,
204
+ "cost_usd": 2.34
205
+ }
206
+ }
207
+ ```
208
+
209
+ ### Conflict Resolution
210
+
211
+ When state conflicts occur:
212
+
213
+ 1. **Last-write-wins** - Default strategy
214
+ 2. **Merge** - For additive operations (task queue append)
215
+ 3. **Reject** - For conflicting updates (agent status)
216
+
217
+ ## Capability Discovery
218
+
219
+ Other agents can query Loki Mode's capabilities:
220
+
221
+ ```json
222
+ {
223
+ "message_type": "capability_query",
224
+ "payload": {
225
+ "query_type": "supports_task_type",
226
+ "task_type": "frontend_development"
227
+ }
228
+ }
229
+ ```
230
+
231
+ Response:
232
+
233
+ ```json
234
+ {
235
+ "message_type": "capability_response",
236
+ "payload": {
237
+ "supported": true,
238
+ "agent_types": ["eng-frontend"],
239
+ "confidence": 0.95,
240
+ "estimated_cost": 0.10
241
+ }
242
+ }
243
+ ```
244
+
245
+ ## API Endpoints
246
+
247
+ Loki Mode exposes OpenClaw endpoints on the dashboard server:
248
+
249
+ ```bash
250
+ # Get OpenClaw status
251
+ GET http://localhost:57374/api/openclaw/status
252
+
253
+ # Send message to OpenClaw server
254
+ POST http://localhost:57374/api/openclaw/send
255
+ {
256
+ "message_type": "task_offer",
257
+ "payload": {...}
258
+ }
259
+
260
+ # Query capabilities
261
+ GET http://localhost:57374/api/openclaw/capabilities
262
+
263
+ # Get received messages
264
+ GET http://localhost:57374/api/openclaw/messages?limit=50
265
+ ```
266
+
267
+ ## CLI Commands
268
+
269
+ ```bash
270
+ # Check OpenClaw connection status
271
+ loki openclaw status
272
+
273
+ # Send test message
274
+ loki openclaw test
275
+
276
+ # List received messages
277
+ loki openclaw messages
278
+
279
+ # Query registered agents
280
+ loki openclaw agents
281
+
282
+ # Disconnect from OpenClaw
283
+ loki openclaw disconnect
284
+ ```
285
+
286
+ ## Examples
287
+
288
+ ### Multi-System Workflow
289
+
290
+ ```
291
+ MetaGPT (Planning)
292
+
293
+ Sends task via OpenClaw
294
+
295
+ Loki Mode (Implementation)
296
+
297
+ Sends result via OpenClaw
298
+
299
+ AutoGPT (Testing)
300
+
301
+ Sends report via OpenClaw
302
+
303
+ CrewAI (Deployment)
304
+ ```
305
+
306
+ ### Task Distribution
307
+
308
+ ```yaml
309
+ # Distribute tasks across multiple Loki instances
310
+ openclaw:
311
+ enabled: true
312
+ endpoint: http://openclaw-lb:8080
313
+ features:
314
+ task_sharing: true
315
+
316
+ # Loki instance 1 (frontend)
317
+ agents:
318
+ - eng-frontend
319
+ - eng-mobile
320
+
321
+ # Loki instance 2 (backend)
322
+ agents:
323
+ - eng-backend
324
+ - eng-database
325
+
326
+ # Loki instance 3 (ops)
327
+ agents:
328
+ - ops-devops
329
+ - ops-sre
330
+ ```
331
+
332
+ ### Cross-Framework Integration
333
+
334
+ ```python
335
+ # AutoGPT sending task to Loki via OpenClaw
336
+ import requests
337
+
338
+ openclaw_url = "http://openclaw-server:8080/tasks"
339
+ task = {
340
+ "task_type": "code_review",
341
+ "description": "Review API implementation",
342
+ "files": ["api/routes.py"],
343
+ "target_agent": "loki-12345"
344
+ }
345
+
346
+ response = requests.post(openclaw_url, json=task)
347
+ print(f"Task sent: {response.json()}")
348
+
349
+ # Wait for completion
350
+ task_id = response.json()["task_id"]
351
+ while True:
352
+ status = requests.get(f"{openclaw_url}/{task_id}").json()
353
+ if status["status"] == "completed":
354
+ print(f"Result: {status['result']}")
355
+ break
356
+ time.sleep(10)
357
+ ```
358
+
359
+ ## OpenClaw Server Setup
360
+
361
+ ### Docker Deployment
362
+
363
+ ```yaml
364
+ # docker-compose.yml
365
+ version: '3.8'
366
+ services:
367
+ openclaw-server:
368
+ image: openclaw/server:latest
369
+ ports:
370
+ - "8080:8080"
371
+ environment:
372
+ - OPENCLAW_LOG_LEVEL=info
373
+ - OPENCLAW_AUTH_ENABLED=false
374
+ volumes:
375
+ - openclaw-data:/data
376
+
377
+ loki-mode-1:
378
+ image: asklokesh/loki-mode:latest
379
+ environment:
380
+ - LOKI_OPENCLAW_ENABLED=true
381
+ - LOKI_OPENCLAW_ENDPOINT=http://openclaw-server:8080
382
+ - LOKI_OPENCLAW_AGENT_ID=loki-frontend
383
+ depends_on:
384
+ - openclaw-server
385
+
386
+ loki-mode-2:
387
+ image: asklokesh/loki-mode:latest
388
+ environment:
389
+ - LOKI_OPENCLAW_ENABLED=true
390
+ - LOKI_OPENCLAW_ENDPOINT=http://openclaw-server:8080
391
+ - LOKI_OPENCLAW_AGENT_ID=loki-backend
392
+ depends_on:
393
+ - openclaw-server
394
+
395
+ volumes:
396
+ openclaw-data:
397
+ ```
398
+
399
+ ### Kubernetes Deployment
400
+
401
+ ```yaml
402
+ apiVersion: v1
403
+ kind: Service
404
+ metadata:
405
+ name: openclaw-server
406
+ spec:
407
+ selector:
408
+ app: openclaw
409
+ ports:
410
+ - port: 8080
411
+ ---
412
+ apiVersion: apps/v1
413
+ kind: Deployment
414
+ metadata:
415
+ name: openclaw-server
416
+ spec:
417
+ replicas: 3
418
+ selector:
419
+ matchLabels:
420
+ app: openclaw
421
+ template:
422
+ metadata:
423
+ labels:
424
+ app: openclaw
425
+ spec:
426
+ containers:
427
+ - name: openclaw
428
+ image: openclaw/server:latest
429
+ ports:
430
+ - containerPort: 8080
431
+ env:
432
+ - name: OPENCLAW_REDIS_URL
433
+ value: redis://redis:6379
434
+ ```
435
+
436
+ ## Security
437
+
438
+ ### Authentication
439
+
440
+ ```bash
441
+ # Enable OpenClaw authentication
442
+ export LOKI_OPENCLAW_AUTH_TOKEN=your-secret-token
443
+
444
+ # Or use mutual TLS
445
+ export LOKI_OPENCLAW_TLS_CERT=/path/to/client-cert.pem
446
+ export LOKI_OPENCLAW_TLS_KEY=/path/to/client-key.pem
447
+ export LOKI_OPENCLAW_TLS_CA=/path/to/ca-cert.pem
448
+ ```
449
+
450
+ ### Authorization
451
+
452
+ ```yaml
453
+ openclaw:
454
+ authorization:
455
+ enabled: true
456
+ allowed_agents:
457
+ - autogpt-production
458
+ - metagpt-staging
459
+ allowed_namespaces:
460
+ - production
461
+ - staging
462
+ ```
463
+
464
+ ### Encryption
465
+
466
+ ```bash
467
+ # Use HTTPS for OpenClaw endpoint
468
+ export LOKI_OPENCLAW_ENDPOINT=https://openclaw-server:8443
469
+
470
+ # Enable message encryption
471
+ export LOKI_OPENCLAW_ENCRYPT_MESSAGES=true
472
+ export LOKI_OPENCLAW_ENCRYPTION_KEY=your-encryption-key
473
+ ```
474
+
475
+ ## Monitoring
476
+
477
+ ### Metrics
478
+
479
+ OpenClaw bridge exposes metrics:
480
+
481
+ ```
482
+ loki_openclaw_connected{agent_id="loki-12345"} 1
483
+ loki_openclaw_messages_sent_total{type="task_offer"} 42
484
+ loki_openclaw_messages_received_total{type="task_accept"} 38
485
+ loki_openclaw_tasks_completed_total 35
486
+ loki_openclaw_latency_seconds{operation="send"} 0.015
487
+ ```
488
+
489
+ ### Health Checks
490
+
491
+ ```bash
492
+ # Check OpenClaw connection
493
+ curl http://localhost:57374/api/openclaw/health
494
+
495
+ # Response
496
+ {
497
+ "connected": true,
498
+ "server": "http://openclaw-server:8080",
499
+ "last_heartbeat": "2026-02-15T14:30:00Z",
500
+ "latency_ms": 15,
501
+ "messages_pending": 0
502
+ }
503
+ ```
504
+
505
+ ## Troubleshooting
506
+
507
+ ### Connection Issues
508
+
509
+ ```bash
510
+ # Test OpenClaw server connectivity
511
+ curl http://openclaw-server:8080/health
512
+
513
+ # Check Loki OpenClaw status
514
+ loki openclaw status
515
+
516
+ # View connection logs
517
+ loki enterprise audit tail --event openclaw.connect
518
+
519
+ # Reconnect manually
520
+ loki openclaw reconnect
521
+ ```
522
+
523
+ ### Message Delivery Failures
524
+
525
+ ```bash
526
+ # Check message queue
527
+ loki openclaw messages --status failed
528
+
529
+ # Retry failed messages
530
+ loki openclaw retry
531
+
532
+ # View OpenClaw logs
533
+ docker logs openclaw-server
534
+ ```
535
+
536
+ ### Performance Issues
537
+
538
+ ```bash
539
+ # Check message latency
540
+ curl http://localhost:57374/metrics | grep loki_openclaw_latency
541
+
542
+ # Monitor message queue size
543
+ loki openclaw status | grep messages_pending
544
+
545
+ # Increase heartbeat interval to reduce traffic
546
+ export LOKI_OPENCLAW_HEARTBEAT=60
547
+ ```
548
+
549
+ ## Best Practices
550
+
551
+ 1. **Use namespaces** to isolate environments (dev, staging, production)
552
+ 2. **Enable authentication** in production deployments
553
+ 3. **Monitor message latency** and set appropriate timeouts
554
+ 4. **Implement retry logic** for transient failures
555
+ 5. **Use task priorities** for critical workloads
556
+ 6. **Set up health checks** for automatic reconnection
557
+ 7. **Log all OpenClaw messages** for audit trail
558
+
559
+ ## Limitations
560
+
561
+ - OpenClaw protocol is still evolving (v1.0 spec)
562
+ - Not all agent frameworks support OpenClaw yet
563
+ - Message size limited to 1MB
564
+ - Synchronous task completion only (async planned for v2.0)
565
+ - No built-in conflict resolution for complex state updates
566
+
567
+ ## See Also
568
+
569
+ - [Agent Types](../references/agent-types.md) - 41 Loki Mode agent types
570
+ - [GitHub Integration](../skills/github-integration.md) - Issue and PR automation
571
+ - [Enterprise Features](../wiki/Enterprise-Features.md) - Multi-project orchestration
572
+ - [API Reference](../wiki/API-Reference.md) - Complete API documentation