loki-mode 5.51.0 → 5.52.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.
- package/README.md +4 -56
- package/SKILL.md +2 -2
- package/VERSION +1 -1
- package/autonomy/hooks/validate-bash.sh +5 -2
- package/dashboard/__init__.py +1 -1
- package/dashboard/server.py +1 -1
- package/docs/INSTALLATION.md +1 -1
- package/docs/alternative-installations.md +3 -3
- package/docs/certification/01-core-concepts/lab.md +174 -0
- package/docs/certification/01-core-concepts/lesson.md +182 -0
- package/docs/certification/01-core-concepts/quiz.md +93 -0
- package/docs/certification/02-enterprise-features/lab.md +154 -0
- package/docs/certification/02-enterprise-features/lesson.md +202 -0
- package/docs/certification/02-enterprise-features/quiz.md +93 -0
- package/docs/certification/03-advanced-patterns/lab.md +138 -0
- package/docs/certification/03-advanced-patterns/lesson.md +199 -0
- package/docs/certification/03-advanced-patterns/quiz.md +93 -0
- package/docs/certification/04-production-deployment/lab.md +160 -0
- package/docs/certification/04-production-deployment/lesson.md +261 -0
- package/docs/certification/04-production-deployment/quiz.md +93 -0
- package/docs/certification/05-troubleshooting/lab.md +254 -0
- package/docs/certification/05-troubleshooting/lesson.md +266 -0
- package/docs/certification/05-troubleshooting/quiz.md +93 -0
- package/docs/certification/README.md +80 -0
- package/docs/certification/answer-key.md +117 -0
- package/docs/certification/certification-exam.md +471 -0
- package/docs/certification/sample-prds/microservices-platform.md +100 -0
- package/docs/certification/sample-prds/saas-dashboard.md +60 -0
- package/docs/certification/sample-prds/todo-app.md +44 -0
- package/mcp/__init__.py +1 -1
- package/mcp/server.py +230 -0
- package/package.json +1 -1
- package/src/plugins/agent-plugin.js +123 -0
- package/src/plugins/gate-plugin.js +153 -0
- package/src/plugins/index.js +116 -0
- package/src/plugins/integration-plugin.js +174 -0
- package/src/plugins/loader.js +275 -0
- package/src/plugins/mcp-plugin.js +190 -0
- package/src/plugins/schemas/agent.json +59 -0
- package/src/plugins/schemas/integration.json +62 -0
- package/src/plugins/schemas/mcp_tool.json +73 -0
- package/src/plugins/schemas/quality_gate.json +52 -0
- package/src/plugins/validator.js +297 -0
- /package/dashboard/{secrets.py → app_secrets.py} +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Module 2 Lab: Configure Enterprise Features
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
|
|
5
|
+
Enable and verify enterprise features: audit logging, OTEL observability, token authentication, and dashboard TLS.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- Loki Mode installed (`npm install -g loki-mode`)
|
|
10
|
+
- `loki doctor` passing
|
|
11
|
+
- `jq` installed for JSON inspection
|
|
12
|
+
|
|
13
|
+
## Step 1: Verify Audit Logging Is Active
|
|
14
|
+
|
|
15
|
+
Audit logging is enabled by default. Verify its status:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
loki enterprise status
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The output should show audit logging as enabled.
|
|
22
|
+
|
|
23
|
+
Start a session briefly to generate audit entries:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Create a minimal project directory
|
|
27
|
+
mkdir -p /tmp/enterprise-lab && cd /tmp/enterprise-lab
|
|
28
|
+
git init
|
|
29
|
+
|
|
30
|
+
# Check audit status
|
|
31
|
+
loki enterprise audit status
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Note:** Viewing actual audit log entries requires a running session that has performed agent actions. The audit log records actions taken during `loki start`.
|
|
35
|
+
|
|
36
|
+
## Step 2: Explore Audit Configuration
|
|
37
|
+
|
|
38
|
+
Review the available audit environment variables:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# These are the key audit variables:
|
|
42
|
+
# LOKI_AUDIT_DISABLED=true -- Disable audit logging
|
|
43
|
+
# LOKI_AUDIT_SYSLOG_HOST -- Enable syslog forwarding
|
|
44
|
+
# LOKI_AUDIT_SYSLOG_PORT -- Syslog port (default: 514)
|
|
45
|
+
# LOKI_AUDIT_SYSLOG_PROTO -- Syslog protocol: udp or tcp
|
|
46
|
+
# LOKI_AUDIT_LEVEL -- Minimum severity to log
|
|
47
|
+
# LOKI_AUDIT_EXCLUDE_EVENTS -- Comma-separated events to skip
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
To temporarily disable audit logging (not recommended for production):
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
LOKI_AUDIT_DISABLED=true loki enterprise status
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Step 3: Check OTEL Readiness
|
|
57
|
+
|
|
58
|
+
OTEL is lazy-loaded. Verify the conditional loading behavior:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Without OTEL endpoint -- should report no OTEL
|
|
62
|
+
loki enterprise status
|
|
63
|
+
|
|
64
|
+
# To enable OTEL (requires a running OTLP collector):
|
|
65
|
+
# export LOKI_OTEL_ENDPOINT=http://localhost:4318
|
|
66
|
+
# loki start ./prd.md
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Note:** Actually sending OTEL data requires a running OTLP-compatible collector (such as the OpenTelemetry Collector, Jaeger, or Grafana Tempo) on the specified endpoint.
|
|
70
|
+
|
|
71
|
+
## Step 4: Generate an API Token
|
|
72
|
+
|
|
73
|
+
Enable enterprise authentication and generate a token:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Enable token auth
|
|
77
|
+
export LOKI_ENTERPRISE_AUTH=true
|
|
78
|
+
|
|
79
|
+
# Generate a token
|
|
80
|
+
loki enterprise token generate lab-test-token
|
|
81
|
+
|
|
82
|
+
# Generate with expiration
|
|
83
|
+
loki enterprise token generate lab-expires --expires 7
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Note:** Token authentication requires the dashboard API server to be running (`loki dashboard start` or `loki serve`). Without a running server, token generation creates the token but there is no API to authenticate against.
|
|
87
|
+
|
|
88
|
+
## Step 5: Start and Inspect the Dashboard
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Start the dashboard server
|
|
92
|
+
loki dashboard start
|
|
93
|
+
|
|
94
|
+
# Check if it is running
|
|
95
|
+
loki dashboard status
|
|
96
|
+
|
|
97
|
+
# Get the URL
|
|
98
|
+
loki dashboard url
|
|
99
|
+
|
|
100
|
+
# Open in browser (macOS/Linux)
|
|
101
|
+
loki dashboard open
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The dashboard should be accessible at `http://localhost:57374`.
|
|
105
|
+
|
|
106
|
+
## Step 6: Inspect Metrics
|
|
107
|
+
|
|
108
|
+
While the dashboard is running:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# View Prometheus-format metrics
|
|
112
|
+
loki metrics
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
This outputs metrics in OpenMetrics format suitable for Prometheus scraping.
|
|
116
|
+
|
|
117
|
+
## Step 7: Review SIEM Integration Options
|
|
118
|
+
|
|
119
|
+
Read the SIEM integration documentation:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# The full guide is at docs/siem-integration.md in the Loki Mode installation
|
|
123
|
+
# Key platforms supported:
|
|
124
|
+
# - Splunk
|
|
125
|
+
# - IBM QRadar
|
|
126
|
+
# - Elastic SIEM
|
|
127
|
+
# - Datadog Security Monitoring
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
To configure syslog forwarding (requires an actual syslog server):
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
export LOKI_AUDIT_SYSLOG_HOST=your-syslog-server.example.com
|
|
134
|
+
export LOKI_AUDIT_SYSLOG_PORT=514
|
|
135
|
+
export LOKI_AUDIT_SYSLOG_PROTO=tcp
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Verification Checklist
|
|
139
|
+
|
|
140
|
+
- [ ] `loki enterprise status` shows audit logging enabled
|
|
141
|
+
- [ ] You understand the difference between `LOKI_AUDIT_DISABLED` and `LOKI_ENTERPRISE_AUDIT`
|
|
142
|
+
- [ ] You know which environment variable activates OTEL (`LOKI_OTEL_ENDPOINT`)
|
|
143
|
+
- [ ] You can generate an enterprise token with `loki enterprise token generate`
|
|
144
|
+
- [ ] `loki dashboard status` correctly reports whether the dashboard is running
|
|
145
|
+
- [ ] `loki metrics` outputs Prometheus-format metrics
|
|
146
|
+
|
|
147
|
+
## Cleanup
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
loki dashboard stop
|
|
151
|
+
cd ~
|
|
152
|
+
rm -rf /tmp/enterprise-lab
|
|
153
|
+
unset LOKI_ENTERPRISE_AUTH
|
|
154
|
+
```
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# Module 2: Enterprise Features
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Loki Mode includes enterprise features for audit logging, observability, authentication, and SIEM integration. These features are controlled via environment variables and can be enabled incrementally.
|
|
6
|
+
|
|
7
|
+
## Audit Logging
|
|
8
|
+
|
|
9
|
+
Audit logging records all agent actions for compliance and forensic analysis. As of v5.38.0, audit logging is **enabled by default**. It can be disabled with `LOKI_AUDIT_DISABLED=true`.
|
|
10
|
+
|
|
11
|
+
### Configuration
|
|
12
|
+
|
|
13
|
+
| Variable | Default | Description |
|
|
14
|
+
|----------|---------|-------------|
|
|
15
|
+
| `LOKI_AUDIT_DISABLED` | `false` | Set to `true` to disable audit logging |
|
|
16
|
+
| `LOKI_ENTERPRISE_AUDIT` | `false` | Legacy variable to force audit on (superseded by default-on behavior) |
|
|
17
|
+
| `LOKI_AUDIT_LOG` | `true` | Enable/disable audit log file writing |
|
|
18
|
+
|
|
19
|
+
### CLI Commands
|
|
20
|
+
|
|
21
|
+
The `loki audit` command provides access to the audit log:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
loki audit # Show recent audit entries
|
|
25
|
+
loki audit help # Show audit subcommands
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The `loki enterprise` command manages enterprise features:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
loki enterprise status # Show enterprise feature status
|
|
32
|
+
loki enterprise help # Show available enterprise commands
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Audit Log Contents
|
|
36
|
+
|
|
37
|
+
Audit entries record:
|
|
38
|
+
- Timestamp of each agent action
|
|
39
|
+
- Agent identity and type
|
|
40
|
+
- Action taken (file read, file write, command execution, etc.)
|
|
41
|
+
- Target resource (file path, endpoint, etc.)
|
|
42
|
+
- Outcome (success/failure)
|
|
43
|
+
|
|
44
|
+
## SIEM Integration (v5.38.0)
|
|
45
|
+
|
|
46
|
+
Loki Mode can forward audit logs to enterprise SIEM systems via syslog. Supported platforms include Splunk, IBM QRadar, Elastic SIEM, Datadog Security Monitoring, and others. Full configuration details are in `docs/siem-integration.md`.
|
|
47
|
+
|
|
48
|
+
### Syslog Forwarding
|
|
49
|
+
|
|
50
|
+
Enable syslog forwarding by setting these environment variables:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
export LOKI_AUDIT_SYSLOG_HOST=syslog.example.com
|
|
54
|
+
export LOKI_AUDIT_SYSLOG_PORT=514
|
|
55
|
+
export LOKI_AUDIT_SYSLOG_PROTO=udp
|
|
56
|
+
|
|
57
|
+
loki start ./prd.md
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
| Variable | Default | Description |
|
|
61
|
+
|----------|---------|-------------|
|
|
62
|
+
| `LOKI_AUDIT_SYSLOG_HOST` | (none) | Syslog server hostname or IP |
|
|
63
|
+
| `LOKI_AUDIT_SYSLOG_PORT` | `514` | Syslog server port |
|
|
64
|
+
| `LOKI_AUDIT_SYSLOG_PROTO` | `udp` | Protocol: `udp` or `tcp` |
|
|
65
|
+
| `LOKI_SYSLOG_FACILITY` | `local0` | Syslog facility (local0-local7) |
|
|
66
|
+
| `LOKI_SYSLOG_SEVERITY` | `info` | Minimum severity to forward |
|
|
67
|
+
|
|
68
|
+
### Filtering
|
|
69
|
+
|
|
70
|
+
Control audit log verbosity:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
export LOKI_AUDIT_LEVEL=warning # Minimum severity
|
|
74
|
+
export LOKI_AUDIT_EXCLUDE_EVENTS=api.request,api.response # Skip noisy events
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## OpenTelemetry (OTEL) Observability
|
|
78
|
+
|
|
79
|
+
Loki Mode supports OpenTelemetry for distributed tracing and metrics. OTEL is **lazy-loaded** -- it only initializes when `LOKI_OTEL_ENDPOINT` is set.
|
|
80
|
+
|
|
81
|
+
### Enabling OTEL
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
export LOKI_OTEL_ENDPOINT=http://localhost:4318
|
|
85
|
+
loki start ./prd.md
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
When OTEL is not configured, Loki Mode uses no-op stubs that add zero overhead. When enabled, it exports traces and metrics to the configured OTLP endpoint.
|
|
89
|
+
|
|
90
|
+
The OTEL implementation is in `src/observability/otel.js` with a conditional loader in `src/observability/index.js`. A bridge process (`src/observability/otel-bridge.js`) can forward events from the file-based event bus to OTEL.
|
|
91
|
+
|
|
92
|
+
### Prometheus Metrics
|
|
93
|
+
|
|
94
|
+
The `loki metrics` command exposes Prometheus/OpenMetrics formatted metrics from the dashboard:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
loki metrics # Display all metrics
|
|
98
|
+
loki metrics --help # Show options
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
These metrics can be scraped by Prometheus or any OpenMetrics-compatible collector.
|
|
102
|
+
|
|
103
|
+
## Token Authentication (Enterprise)
|
|
104
|
+
|
|
105
|
+
Loki Mode supports token-based API authentication for the dashboard API server. This is opt-in and requires `LOKI_ENTERPRISE_AUTH=true`.
|
|
106
|
+
|
|
107
|
+
### Enabling Authentication
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
export LOKI_ENTERPRISE_AUTH=true
|
|
111
|
+
loki start ./prd.md
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Managing Tokens
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Generate a new API token
|
|
118
|
+
loki enterprise token generate my-token-name
|
|
119
|
+
|
|
120
|
+
# Generate with specific options
|
|
121
|
+
loki enterprise token generate my-token --scopes '*' --expires 30
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
When authentication is enabled, all dashboard API requests must include a valid token.
|
|
125
|
+
|
|
126
|
+
## OIDC Integration
|
|
127
|
+
|
|
128
|
+
For organizations using SSO, Loki Mode supports OIDC (OpenID Connect) authentication:
|
|
129
|
+
|
|
130
|
+
| Variable | Description |
|
|
131
|
+
|----------|-------------|
|
|
132
|
+
| `LOKI_OIDC_ISSUER` | OIDC issuer URL (e.g., `https://accounts.google.com`) |
|
|
133
|
+
| `LOKI_OIDC_CLIENT_ID` | OIDC client/application ID |
|
|
134
|
+
| `LOKI_OIDC_AUDIENCE` | Expected JWT audience (defaults to client_id) |
|
|
135
|
+
|
|
136
|
+
These variables are documented in the `autonomy/run.sh` header. OIDC validation requires a running dashboard API server.
|
|
137
|
+
|
|
138
|
+
## Dashboard
|
|
139
|
+
|
|
140
|
+
The Loki Mode dashboard provides a web-based UI for monitoring sessions, viewing task queues, inspecting memory, and observing agent activity.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
loki dashboard start # Start the dashboard server
|
|
144
|
+
loki dashboard stop # Stop the dashboard server
|
|
145
|
+
loki dashboard status # Check if dashboard is running
|
|
146
|
+
loki dashboard open # Open dashboard in browser
|
|
147
|
+
loki dashboard url # Print the dashboard URL
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The dashboard runs on port 57374 by default (`LOKI_DASHBOARD_PORT`). TLS can be enabled with:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
export LOKI_TLS_CERT=/path/to/cert.pem
|
|
154
|
+
export LOKI_TLS_KEY=/path/to/key.pem
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Security Controls
|
|
158
|
+
|
|
159
|
+
Loki Mode provides several security controls for enterprise environments:
|
|
160
|
+
|
|
161
|
+
| Variable | Default | Description |
|
|
162
|
+
|----------|---------|-------------|
|
|
163
|
+
| `LOKI_SANDBOX_MODE` | `false` | Run in Docker sandbox for isolation |
|
|
164
|
+
| `LOKI_ALLOWED_PATHS` | (all) | Comma-separated paths agents can modify |
|
|
165
|
+
| `LOKI_BLOCKED_COMMANDS` | `rm -rf /` | Comma-separated blocked shell commands |
|
|
166
|
+
| `LOKI_MAX_PARALLEL_AGENTS` | `10` | Limit concurrent agent spawning |
|
|
167
|
+
| `LOKI_STAGED_AUTONOMY` | `false` | Require approval before execution |
|
|
168
|
+
| `LOKI_PROMPT_INJECTION` | `false` | Allow prompt injection via `HUMAN_INPUT.md` (disabled by default for security) |
|
|
169
|
+
|
|
170
|
+
### Docker Sandbox
|
|
171
|
+
|
|
172
|
+
Run Loki Mode in an isolated Docker container:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
loki sandbox start # Start sandbox container
|
|
176
|
+
loki sandbox stop # Stop sandbox container
|
|
177
|
+
loki sandbox status # Check sandbox status
|
|
178
|
+
loki sandbox shell # Open shell in sandbox
|
|
179
|
+
loki sandbox logs # View sandbox logs
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Or via the start command:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
loki start --sandbox ./prd.md
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Notifications
|
|
189
|
+
|
|
190
|
+
Loki Mode supports notifications to external services:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
loki notify test # Send a test notification
|
|
194
|
+
loki notify slack # Send to Slack
|
|
195
|
+
loki notify discord # Send to Discord
|
|
196
|
+
loki notify webhook # Send to a webhook URL
|
|
197
|
+
loki notify status # Check notification configuration
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Summary
|
|
201
|
+
|
|
202
|
+
Enterprise features in Loki Mode are designed to be opt-in and incrementally adoptable. Audit logging is on by default. OTEL, SIEM integration, token authentication, and OIDC are activated through environment variables. The dashboard provides a web UI for monitoring, and Docker sandbox mode provides execution isolation.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Module 2 Quiz: Enterprise Features
|
|
2
|
+
|
|
3
|
+
Answer each question by selecting the best option (A, B, C, or D).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**Question 1:** What is the default state of audit logging in Loki Mode (v5.38.0+)?
|
|
8
|
+
|
|
9
|
+
A) Disabled, must be explicitly enabled
|
|
10
|
+
B) Enabled by default, can be disabled with `LOKI_AUDIT_DISABLED=true`
|
|
11
|
+
C) Only enabled when running in Docker sandbox
|
|
12
|
+
D) Only enabled when `LOKI_ENTERPRISE_AUDIT=true` is set
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
**Question 2:** Which environment variable enables OpenTelemetry in Loki Mode?
|
|
17
|
+
|
|
18
|
+
A) `LOKI_OTEL_ENABLED=true`
|
|
19
|
+
B) `LOKI_TELEMETRY=true`
|
|
20
|
+
C) `LOKI_OTEL_ENDPOINT=http://localhost:4318`
|
|
21
|
+
D) `OTEL_EXPORTER_ENDPOINT=http://localhost:4318`
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
**Question 3:** What is the default port for the Loki Mode dashboard?
|
|
26
|
+
|
|
27
|
+
A) 3000
|
|
28
|
+
B) 8080
|
|
29
|
+
C) 57374
|
|
30
|
+
D) 9090
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
**Question 4:** Which environment variable enables token-based API authentication?
|
|
35
|
+
|
|
36
|
+
A) `LOKI_AUTH_ENABLED=true`
|
|
37
|
+
B) `LOKI_ENTERPRISE_AUTH=true`
|
|
38
|
+
C) `LOKI_TOKEN_AUTH=true`
|
|
39
|
+
D) `LOKI_API_AUTH=true`
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
**Question 5:** What protocol options does Loki Mode support for syslog forwarding?
|
|
44
|
+
|
|
45
|
+
A) HTTP and HTTPS only
|
|
46
|
+
B) UDP and TCP
|
|
47
|
+
C) gRPC and HTTP
|
|
48
|
+
D) MQTT and AMQP
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
**Question 6:** What happens when `LOKI_OTEL_ENDPOINT` is NOT set?
|
|
53
|
+
|
|
54
|
+
A) Loki Mode refuses to start
|
|
55
|
+
B) OTEL uses a default localhost endpoint
|
|
56
|
+
C) Loki Mode uses no-op stubs with zero overhead
|
|
57
|
+
D) OTEL data is written to a local file
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
**Question 7:** Which command generates an API token for the dashboard?
|
|
62
|
+
|
|
63
|
+
A) `loki auth token create`
|
|
64
|
+
B) `loki enterprise token generate my-token`
|
|
65
|
+
C) `loki dashboard auth --new-token`
|
|
66
|
+
D) `loki config auth token`
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
**Question 8:** How do you enable TLS for the Loki Mode dashboard?
|
|
71
|
+
|
|
72
|
+
A) Set `LOKI_DASHBOARD_TLS=true`
|
|
73
|
+
B) Set `LOKI_TLS_CERT` and `LOKI_TLS_KEY` to PEM file paths
|
|
74
|
+
C) Pass `--tls` flag to `loki dashboard start`
|
|
75
|
+
D) TLS is always enabled by default
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
**Question 9:** What does `LOKI_PROMPT_INJECTION` control?
|
|
80
|
+
|
|
81
|
+
A) Whether agents can execute shell commands
|
|
82
|
+
B) Whether the `HUMAN_INPUT.md` file can inject directives into a running session
|
|
83
|
+
C) Whether API tokens expire automatically
|
|
84
|
+
D) Whether OTEL traces include prompt content
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
**Question 10:** Which command checks the status of all enterprise features?
|
|
89
|
+
|
|
90
|
+
A) `loki config show`
|
|
91
|
+
B) `loki enterprise status`
|
|
92
|
+
C) `loki doctor --enterprise`
|
|
93
|
+
D) `loki status --enterprise`
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Module 3 Lab: Advanced Patterns
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
|
|
5
|
+
Practice structured agent prompting, explore the specialist review configuration, and examine the compound learning system.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- Loki Mode installed (`npm install -g loki-mode`)
|
|
10
|
+
- Familiarity with Module 1 (core concepts) and Module 2 (enterprise features)
|
|
11
|
+
- `jq` installed for JSON inspection
|
|
12
|
+
|
|
13
|
+
## Step 1: Examine the Specialist Review Configuration
|
|
14
|
+
|
|
15
|
+
Read the quality gates documentation to understand how specialists are selected:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Locate the skill file (path depends on your installation)
|
|
19
|
+
# If installed globally via npm:
|
|
20
|
+
SKILL_DIR=$(npm root -g)/loki-mode
|
|
21
|
+
|
|
22
|
+
# Read the specialist review pool configuration
|
|
23
|
+
cat "$SKILL_DIR/skills/quality-gates.md" | head -100
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Key points to verify:
|
|
27
|
+
- 5 specialists defined with trigger keywords
|
|
28
|
+
- architecture-strategist is always selected
|
|
29
|
+
- Selection is based on keyword matching against the diff
|
|
30
|
+
|
|
31
|
+
## Step 2: Write a Structured Agent Prompt
|
|
32
|
+
|
|
33
|
+
Create a file called `structured-prompt-example.md` demonstrating the GOAL/CONSTRAINTS/CONTEXT/OUTPUT template:
|
|
34
|
+
|
|
35
|
+
```markdown
|
|
36
|
+
## GOAL
|
|
37
|
+
Implement a rate-limiting middleware for Express.js.
|
|
38
|
+
Success: Middleware limits requests to 100/minute per IP, returns 429 on excess.
|
|
39
|
+
|
|
40
|
+
## CONSTRAINTS
|
|
41
|
+
- No external rate-limiting libraries
|
|
42
|
+
- Use in-memory storage (Map with TTL cleanup)
|
|
43
|
+
- Must not block the event loop
|
|
44
|
+
- Response time overhead < 5ms
|
|
45
|
+
|
|
46
|
+
## CONTEXT
|
|
47
|
+
- Existing middleware pattern: src/middleware/auth.ts
|
|
48
|
+
- Express app entry point: src/app.ts
|
|
49
|
+
- No existing rate limiting in codebase
|
|
50
|
+
|
|
51
|
+
## OUTPUT
|
|
52
|
+
- [ ] Middleware implementation in src/middleware/rate-limit.ts
|
|
53
|
+
- [ ] Unit tests in tests/middleware/rate-limit.test.ts
|
|
54
|
+
- [ ] Integration into app.ts route chain
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This is the format used when dispatching any agent via the Task tool. Each section serves a purpose: GOAL defines success criteria, CONSTRAINTS set boundaries, CONTEXT points to relevant files, and OUTPUT lists deliverables.
|
|
58
|
+
|
|
59
|
+
## Step 3: Explore Compound Learning
|
|
60
|
+
|
|
61
|
+
Examine the compound learning CLI commands:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# List extracted solutions (if any exist)
|
|
65
|
+
loki compound list
|
|
66
|
+
|
|
67
|
+
# View statistics
|
|
68
|
+
loki compound stats
|
|
69
|
+
|
|
70
|
+
# Search for solutions by keyword
|
|
71
|
+
loki compound search "authentication"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Solutions are stored in `~/.loki/solutions/{category}/{slug}.md` with YAML frontmatter containing title, tags, symptoms, root cause, and prevention guidance.
|
|
75
|
+
|
|
76
|
+
**Note:** Compound learning populates over time as Loki Mode completes tasks. A fresh installation will have no solutions until sessions have run and produced novel insights.
|
|
77
|
+
|
|
78
|
+
## Step 4: Examine the Memory Retrieval Weights
|
|
79
|
+
|
|
80
|
+
Review how task-aware memory retrieval works. The weight configurations are in `memory/engine.py`:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
SKILL_DIR=$(npm root -g)/loki-mode
|
|
84
|
+
|
|
85
|
+
# View the task strategy weights
|
|
86
|
+
head -60 "$SKILL_DIR/memory/engine.py"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
You should see weight configurations like:
|
|
90
|
+
|
|
91
|
+
| Task Type | Episodic | Semantic | Skills | Anti-patterns |
|
|
92
|
+
|-----------|----------|----------|--------|---------------|
|
|
93
|
+
| exploration | 0.6 | 0.3 | 0.1 | 0.0 |
|
|
94
|
+
| implementation | 0.15 | 0.5 | 0.35 | 0.0 |
|
|
95
|
+
| debugging | 0.4 | 0.2 | 0.0 | 0.4 |
|
|
96
|
+
|
|
97
|
+
This demonstrates how the system prioritizes different memory types based on what the agent is currently doing.
|
|
98
|
+
|
|
99
|
+
## Step 5: Understand the Event Bus
|
|
100
|
+
|
|
101
|
+
Loki Mode includes an event bus for inter-component communication. Examine the event emission helper:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
SKILL_DIR=$(npm root -g)/loki-mode
|
|
105
|
+
|
|
106
|
+
# View the bash event emitter
|
|
107
|
+
cat "$SKILL_DIR/events/emit.sh" | head -30
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Events are emitted during operations like memory loading, session start/stop, and task completion. The dashboard and OTEL bridge consume these events for real-time monitoring.
|
|
111
|
+
|
|
112
|
+
## Step 6: Review the Hooks System
|
|
113
|
+
|
|
114
|
+
The hooks system runs quality checks on file operations. Review the configuration in the testing skill:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
SKILL_DIR=$(npm root -g)/loki-mode
|
|
118
|
+
cat "$SKILL_DIR/skills/testing.md"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Look for the `hooks_system` section which defines triggers for:
|
|
122
|
+
- `on_file_write` -- lint, typecheck, secrets scan
|
|
123
|
+
- `on_task_complete` -- contract tests, spec validation
|
|
124
|
+
- `on_phase_complete` -- memory consolidation, metrics, checkpoint
|
|
125
|
+
|
|
126
|
+
## Verification Checklist
|
|
127
|
+
|
|
128
|
+
- [ ] You can write a structured prompt with GOAL/CONSTRAINTS/CONTEXT/OUTPUT sections
|
|
129
|
+
- [ ] You understand how the 5 specialist reviewers are selected (keyword matching + architecture-strategist always included)
|
|
130
|
+
- [ ] You can use `loki compound` commands to explore extracted solutions
|
|
131
|
+
- [ ] You understand the task-aware memory retrieval weight system
|
|
132
|
+
- [ ] You know the three hook trigger points (file write, task complete, phase complete)
|
|
133
|
+
|
|
134
|
+
## Cleanup
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
rm -f structured-prompt-example.md
|
|
138
|
+
```
|