snow-flow 8.3.2 → 8.4.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/OPENCODE-SETUP.md +312 -0
- package/OPENCODE-TROUBLESHOOTING.md +381 -0
- package/dist/agents/index.d.ts +2 -2
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +2 -4
- package/dist/agents/index.js.map +1 -1
- package/dist/cli.js +208 -244
- package/dist/cli.js.map +1 -1
- package/dist/memory/session-memory.d.ts +80 -0
- package/dist/memory/session-memory.d.ts.map +1 -0
- package/dist/memory/session-memory.js +468 -0
- package/dist/memory/session-memory.js.map +1 -0
- package/dist/sdk/claude-agent-sdk-integration.d.ts +4 -1
- package/dist/sdk/claude-agent-sdk-integration.d.ts.map +1 -1
- package/dist/sdk/claude-agent-sdk-integration.js.map +1 -1
- package/dist/sdk/index.d.ts +2 -7
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +2 -7
- package/dist/sdk/index.js.map +1 -1
- package/dist/snow-flow-system.d.ts +3 -7
- package/dist/snow-flow-system.d.ts.map +1 -1
- package/dist/snow-flow-system.js +59 -40
- package/dist/snow-flow-system.js.map +1 -1
- package/dist/utils/mcp-output-formatter.d.ts +128 -0
- package/dist/utils/mcp-output-formatter.d.ts.map +1 -0
- package/dist/utils/mcp-output-formatter.js +442 -0
- package/dist/utils/mcp-output-formatter.js.map +1 -0
- package/dist/utils/opencode-output-interceptor.d.ts +40 -0
- package/dist/utils/opencode-output-interceptor.d.ts.map +1 -0
- package/dist/utils/opencode-output-interceptor.js +258 -0
- package/dist/utils/opencode-output-interceptor.js.map +1 -0
- package/package.json +5 -3
- package/scripts/bulk-optimize-tools.js +486 -0
- package/scripts/cleanup-mcp-servers.js +115 -0
- package/scripts/generate-mcp-config.js +45 -0
- package/scripts/mcp-server-manager.sh +320 -0
- package/scripts/optimize-mcp-tools.ts +410 -0
- package/scripts/reset-mcp-servers.js +266 -0
- package/scripts/safe-mcp-cleanup.js +151 -0
- package/scripts/setup-mcp.js +106 -0
- package/scripts/start-mcp-proper.js +76 -0
- package/scripts/start-opencode.sh +123 -0
- package/scripts/start-sysprops-mcp.js +43 -0
- package/scripts/test-todowrite-timeout.js +108 -0
- package/scripts/update-version.js +31 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# OpenCode Setup Guide for Snow-Flow
|
|
2
|
+
|
|
3
|
+
This guide explains how to properly configure OpenCode to use Snow-Flow's MCP tools.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### 1. Copy Example Config
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
cp opencode-config.example.json opencode-config.json
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### 2. Update Environment Variables
|
|
14
|
+
|
|
15
|
+
Edit `opencode-config.json` and replace the `${VARIABLE}` placeholders with your actual values:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"$schema": "https://opencode.ai/config.json",
|
|
20
|
+
"name": "snow-flow-opencode",
|
|
21
|
+
"description": "OpenCode configuration for Snow-Flow ServiceNow development",
|
|
22
|
+
"model": {
|
|
23
|
+
"provider": "anthropic",
|
|
24
|
+
"model": "claude-sonnet-4-5-20250929",
|
|
25
|
+
"temperature": 1.0
|
|
26
|
+
},
|
|
27
|
+
"mcp": {
|
|
28
|
+
"servicenow-unified": {
|
|
29
|
+
"type": "local",
|
|
30
|
+
"command": ["node", "dist/mcp/servicenow-mcp-unified/index.js"],
|
|
31
|
+
"environment": {
|
|
32
|
+
"SNOW_INSTANCE": "your-instance.service-now.com",
|
|
33
|
+
"SNOW_CLIENT_ID": "your-client-id",
|
|
34
|
+
"SNOW_CLIENT_SECRET": "your-client-secret",
|
|
35
|
+
"SNOW_USERNAME": "your-username",
|
|
36
|
+
"SNOW_PASSWORD": "your-password"
|
|
37
|
+
},
|
|
38
|
+
"enabled": true
|
|
39
|
+
},
|
|
40
|
+
"snow-flow": {
|
|
41
|
+
"type": "local",
|
|
42
|
+
"command": ["node", "dist/mcp/snow-flow-mcp.js"],
|
|
43
|
+
"environment": {
|
|
44
|
+
"SNOW_FLOW_ENV": "production"
|
|
45
|
+
},
|
|
46
|
+
"enabled": true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"tools": {
|
|
50
|
+
"enabled": true,
|
|
51
|
+
"requireApproval": false
|
|
52
|
+
},
|
|
53
|
+
"theme": "servicenow",
|
|
54
|
+
"instructions": [
|
|
55
|
+
"AGENTS.md",
|
|
56
|
+
"CLAUDE.md",
|
|
57
|
+
".opencode/AGENTS.md"
|
|
58
|
+
],
|
|
59
|
+
"cwd": "/path/to/your/snow-flow/installation"
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 3. Build Snow-Flow
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm run build
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
This creates the `dist/` directory with the MCP server files.
|
|
70
|
+
|
|
71
|
+
### 4. Start OpenCode
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
opencode
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Critical Configuration Details
|
|
78
|
+
|
|
79
|
+
### ⚠️ Common Mistakes
|
|
80
|
+
|
|
81
|
+
1. **Using `"env"` instead of `"environment"`**
|
|
82
|
+
```json
|
|
83
|
+
// ❌ WRONG - Tools won't load!
|
|
84
|
+
"env": { "SNOW_INSTANCE": "..." }
|
|
85
|
+
|
|
86
|
+
// ✅ CORRECT
|
|
87
|
+
"environment": { "SNOW_INSTANCE": "..." }
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
2. **Wrong command path**
|
|
91
|
+
```json
|
|
92
|
+
// ❌ WRONG - File doesn't exist
|
|
93
|
+
"command": ["node", "src/mcp/servicenow-mcp-unified/index.js"]
|
|
94
|
+
|
|
95
|
+
// ✅ CORRECT - Must point to dist/ after build
|
|
96
|
+
"command": ["node", "dist/mcp/servicenow-mcp-unified/index.js"]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
3. **Forgetting to build**
|
|
100
|
+
- Always run `npm run build` after pulling updates
|
|
101
|
+
- The `dist/` directory must exist before starting OpenCode
|
|
102
|
+
|
|
103
|
+
### Environment Variables
|
|
104
|
+
|
|
105
|
+
**Required for ServiceNow MCP:**
|
|
106
|
+
- `SNOW_INSTANCE` - Your ServiceNow instance URL (e.g., `dev12345.service-now.com`)
|
|
107
|
+
- `SNOW_CLIENT_ID` - OAuth client ID
|
|
108
|
+
- `SNOW_CLIENT_SECRET` - OAuth client secret
|
|
109
|
+
- `SNOW_USERNAME` - ServiceNow username
|
|
110
|
+
- `SNOW_PASSWORD` - ServiceNow password
|
|
111
|
+
|
|
112
|
+
**Optional for Snow-Flow MCP:**
|
|
113
|
+
- `SNOW_FLOW_ENV` - Environment (default: `production`)
|
|
114
|
+
|
|
115
|
+
## Verifying MCP Tools are Loaded
|
|
116
|
+
|
|
117
|
+
### Check Tool Availability
|
|
118
|
+
|
|
119
|
+
When OpenCode starts, you should see the MCP servers loading in the logs:
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
[MCP] Loading servicenow-unified...
|
|
123
|
+
[MCP] Loaded 370+ tools from servicenow-unified
|
|
124
|
+
[MCP] Loading snow-flow...
|
|
125
|
+
[MCP] Loaded 176+ tools from snow-flow
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Test Tool Execution
|
|
129
|
+
|
|
130
|
+
In OpenCode, try a simple command:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
Create an Update Set named "Test Update Set"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The agent should:
|
|
137
|
+
1. ✅ Call `snow_update_set_manage()` function
|
|
138
|
+
2. ✅ Show the actual function call in the response
|
|
139
|
+
3. ✅ Return the Update Set sys_id
|
|
140
|
+
|
|
141
|
+
**If the agent only shows code snippets instead of calling tools, check:**
|
|
142
|
+
- Is `opencode-config.json` using `"environment"` (not `"env"`)?
|
|
143
|
+
- Did you run `npm run build` after updating Snow-Flow?
|
|
144
|
+
- Are the MCP servers enabled (`"enabled": true`)?
|
|
145
|
+
- Do the `dist/` files exist?
|
|
146
|
+
|
|
147
|
+
## MCP Tool Categories
|
|
148
|
+
|
|
149
|
+
### ServiceNow Unified MCP (370+ tools)
|
|
150
|
+
|
|
151
|
+
**Core Operations:**
|
|
152
|
+
- `snow_query_table` - Query any ServiceNow table
|
|
153
|
+
- `snow_create_record` - Create records
|
|
154
|
+
- `snow_update_record` - Update records
|
|
155
|
+
|
|
156
|
+
**Development:**
|
|
157
|
+
- `snow_update_set_manage` - Manage Update Sets (v8.2.0+)
|
|
158
|
+
- `snow_deploy` - Deploy widgets, pages, etc.
|
|
159
|
+
- `snow_pull_artifact` - Local widget sync
|
|
160
|
+
|
|
161
|
+
**UI Builder:**
|
|
162
|
+
- `snow_create_uib_page` - Create UI Builder pages
|
|
163
|
+
- `snow_add_uib_page_element` - Add components
|
|
164
|
+
- `snow_create_uib_data_broker` - Connect data sources
|
|
165
|
+
|
|
166
|
+
**Workspace:**
|
|
167
|
+
- `snow_create_complete_workspace` - Create agent workspaces
|
|
168
|
+
- `snow_create_workspace_tab` - Add tabs
|
|
169
|
+
|
|
170
|
+
### Snow-Flow MCP (176+ tools)
|
|
171
|
+
|
|
172
|
+
**Orchestration:**
|
|
173
|
+
- `swarm_init` - Initialize agent swarms
|
|
174
|
+
- `agent_spawn` - Create specialized agents
|
|
175
|
+
- `task_orchestrate` - Complex task coordination
|
|
176
|
+
|
|
177
|
+
**Memory:**
|
|
178
|
+
- `memory_search` - Search persistent memory
|
|
179
|
+
- `memory_usage` - Memory analytics
|
|
180
|
+
|
|
181
|
+
**ML (TensorFlow.js):**
|
|
182
|
+
- `neural_train` - Train neural networks
|
|
183
|
+
- `neural_patterns` - Pattern recognition
|
|
184
|
+
|
|
185
|
+
## Troubleshooting
|
|
186
|
+
|
|
187
|
+
### Problem: "Tools not available"
|
|
188
|
+
|
|
189
|
+
**Solution:**
|
|
190
|
+
1. Check `opencode-config.json` exists
|
|
191
|
+
2. Verify `"environment"` key (not `"env"`)
|
|
192
|
+
3. Run `npm run build`
|
|
193
|
+
4. Restart OpenCode
|
|
194
|
+
|
|
195
|
+
### Problem: "Agent shows code instead of calling tools"
|
|
196
|
+
|
|
197
|
+
This usually means the MCP servers aren't loaded correctly.
|
|
198
|
+
|
|
199
|
+
**Solution:**
|
|
200
|
+
1. Check OpenCode logs for MCP loading errors
|
|
201
|
+
2. Verify `dist/` directory exists
|
|
202
|
+
3. Check command paths in config
|
|
203
|
+
4. Ensure `"enabled": true`
|
|
204
|
+
|
|
205
|
+
### Problem: "Module not found" errors
|
|
206
|
+
|
|
207
|
+
**Solution:**
|
|
208
|
+
```bash
|
|
209
|
+
# Rebuild everything
|
|
210
|
+
npm run build
|
|
211
|
+
|
|
212
|
+
# Verify dist files exist
|
|
213
|
+
ls -la dist/mcp/servicenow-mcp-unified/index.js
|
|
214
|
+
ls -la dist/mcp/snow-flow-mcp.js
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Advanced Configuration
|
|
218
|
+
|
|
219
|
+
### Per-Agent Tool Control
|
|
220
|
+
|
|
221
|
+
Disable tools globally but enable for specific agents:
|
|
222
|
+
|
|
223
|
+
```json
|
|
224
|
+
{
|
|
225
|
+
"mcp": {
|
|
226
|
+
"servicenow-unified": { "enabled": true }
|
|
227
|
+
},
|
|
228
|
+
"tools": {
|
|
229
|
+
"servicenow-unified*": false // Disable all by default
|
|
230
|
+
},
|
|
231
|
+
"agent": {
|
|
232
|
+
"servicenow-dev": {
|
|
233
|
+
"tools": {
|
|
234
|
+
"servicenow-unified*": true // Enable for this agent
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Custom Tool Approval
|
|
242
|
+
|
|
243
|
+
Require approval for specific tools:
|
|
244
|
+
|
|
245
|
+
```json
|
|
246
|
+
{
|
|
247
|
+
"tools": {
|
|
248
|
+
"enabled": true,
|
|
249
|
+
"requireApproval": true,
|
|
250
|
+
"approvalPatterns": {
|
|
251
|
+
"snow_execute_background_script": true, // Always require approval
|
|
252
|
+
"snow_update_set_manage": false // Auto-approve
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Best Practices
|
|
259
|
+
|
|
260
|
+
### 1. Always Create Update Sets First
|
|
261
|
+
|
|
262
|
+
```javascript
|
|
263
|
+
// ✅ CORRECT workflow
|
|
264
|
+
const updateSet = await snow_update_set_manage({
|
|
265
|
+
action: 'create',
|
|
266
|
+
name: "Feature: X"
|
|
267
|
+
});
|
|
268
|
+
// ... develop ...
|
|
269
|
+
await snow_update_set_manage({ action: 'complete' });
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### 2. Use Specific Tools Over Generic
|
|
273
|
+
|
|
274
|
+
```javascript
|
|
275
|
+
// ❌ Generic (slower)
|
|
276
|
+
await snow_query_table({ table: 'incident' });
|
|
277
|
+
|
|
278
|
+
// ✅ Specific (faster, better features)
|
|
279
|
+
await snow_query_incidents({ filters: { active: true } });
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### 3. Use Local Sync for Widgets
|
|
283
|
+
|
|
284
|
+
```javascript
|
|
285
|
+
// ✅ CORRECT - No token limits!
|
|
286
|
+
await snow_pull_artifact({ sys_id: 'widget_sys_id' });
|
|
287
|
+
// ... edit locally ...
|
|
288
|
+
await snow_push_artifact({ sys_id: 'widget_sys_id' });
|
|
289
|
+
|
|
290
|
+
// ❌ WRONG - Token limits!
|
|
291
|
+
await snow_query_table({ table: 'sp_widget' });
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Getting Help
|
|
295
|
+
|
|
296
|
+
If you encounter issues:
|
|
297
|
+
|
|
298
|
+
1. **Check logs**: OpenCode shows detailed MCP loading logs
|
|
299
|
+
2. **Verify config**: Use `"environment"` (not `"env"`)
|
|
300
|
+
3. **Rebuild**: Always `npm run build` after updates
|
|
301
|
+
4. **GitHub Issues**: https://github.com/your-repo/snow-flow/issues
|
|
302
|
+
|
|
303
|
+
## Version Info
|
|
304
|
+
|
|
305
|
+
- **OpenCode**: Requires OpenCode v1.0+
|
|
306
|
+
- **Snow-Flow**: v8.3.0+
|
|
307
|
+
- **Node.js**: v18+ recommended
|
|
308
|
+
- **MCP Spec**: 1.0.0
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
**Last Updated**: 2025-10-22 (v8.3.0)
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
# OpenCode MCP Troubleshooting Guide
|
|
2
|
+
|
|
3
|
+
## Problem: "Tools not available" or Agent Shows Code Instead of Calling Tools
|
|
4
|
+
|
|
5
|
+
### Root Causes
|
|
6
|
+
|
|
7
|
+
There are TWO independent issues that can cause this:
|
|
8
|
+
|
|
9
|
+
1. **MCP Configuration Issue** (`"env"` vs `"environment"`)
|
|
10
|
+
2. **ServiceNow Authentication Failure** (OAuth without refresh token)
|
|
11
|
+
|
|
12
|
+
Both have been fixed in v8.3.1+!
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## ✅ Solution 1: Use Updated Configuration (v8.3.1+)
|
|
17
|
+
|
|
18
|
+
### Quick Fix
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Update to v8.3.1+
|
|
22
|
+
npm install -g snow-flow@latest
|
|
23
|
+
|
|
24
|
+
# Use the new launcher (handles everything)
|
|
25
|
+
cd your-project
|
|
26
|
+
./node_modules/snow-flow/scripts/start-opencode.sh
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The launcher will:
|
|
30
|
+
- ✅ Check .env file exists
|
|
31
|
+
- ✅ Build Snow-Flow if needed
|
|
32
|
+
- ✅ Start MCP servers automatically
|
|
33
|
+
- ✅ Run health checks
|
|
34
|
+
- ✅ Launch OpenCode with tools pre-loaded
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## ✅ Solution 2: Manual Setup (Understanding the Fix)
|
|
39
|
+
|
|
40
|
+
### Step 1: Fix Authentication
|
|
41
|
+
|
|
42
|
+
**Option A: Use Username/Password (Simpler)**
|
|
43
|
+
|
|
44
|
+
Edit your `.env` file:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# ServiceNow Configuration
|
|
48
|
+
SNOW_INSTANCE=dev123456.service-now.com
|
|
49
|
+
|
|
50
|
+
# Use username/password (NEW in v8.3.1!)
|
|
51
|
+
SNOW_USERNAME=admin
|
|
52
|
+
SNOW_PASSWORD=your-password
|
|
53
|
+
|
|
54
|
+
# OAuth can be left empty
|
|
55
|
+
SNOW_CLIENT_ID=
|
|
56
|
+
SNOW_CLIENT_SECRET=
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Option B: Fix OAuth (For Production)**
|
|
60
|
+
|
|
61
|
+
If you prefer OAuth, ensure your ServiceNow OAuth app has:
|
|
62
|
+
- ✅ Refresh Token Lifespan set (not "0")
|
|
63
|
+
- ✅ Redirect URI configured
|
|
64
|
+
- ✅ Access Token Lifespan ≥ 1800 seconds
|
|
65
|
+
|
|
66
|
+
Go to: **System OAuth** → **Application Registry** → Your OAuth App
|
|
67
|
+
|
|
68
|
+
### Step 2: Fix OpenCode Configuration
|
|
69
|
+
|
|
70
|
+
Ensure `opencode-config.json` uses `"environment"` (not `"env"`):
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"mcp": {
|
|
75
|
+
"servicenow-unified": {
|
|
76
|
+
"type": "local",
|
|
77
|
+
"command": ["node", "dist/mcp/servicenow-mcp-unified/index.js"],
|
|
78
|
+
"environment": { // ✅ CORRECT (not "env")
|
|
79
|
+
"SERVICENOW_INSTANCE_URL": "https://dev123456.service-now.com",
|
|
80
|
+
"SERVICENOW_USERNAME": "admin",
|
|
81
|
+
"SERVICENOW_PASSWORD": "your-password"
|
|
82
|
+
},
|
|
83
|
+
"enabled": true
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Step 3: Test MCP Servers Manually
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Start MCP server
|
|
93
|
+
./scripts/mcp-server-manager.sh start
|
|
94
|
+
|
|
95
|
+
# Check status
|
|
96
|
+
./scripts/mcp-server-manager.sh status
|
|
97
|
+
# Should show: "✓ MCP server is running (PID: ...)"
|
|
98
|
+
# Should show: "✓ Tools loaded: 370+"
|
|
99
|
+
|
|
100
|
+
# Run health check
|
|
101
|
+
./scripts/mcp-server-manager.sh health
|
|
102
|
+
# Should show: "✓ Health check passed - 370+ tools available"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Step 4: Launch OpenCode
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Option A: Use launcher (recommended)
|
|
109
|
+
./scripts/start-opencode.sh
|
|
110
|
+
|
|
111
|
+
# Option B: Manual launch
|
|
112
|
+
opencode
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 🔍 Diagnostic Commands
|
|
118
|
+
|
|
119
|
+
### Check if MCP Server is Running
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
./scripts/mcp-server-manager.sh status
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Good Output:**
|
|
126
|
+
```
|
|
127
|
+
✓ MCP server is running (PID: 12345)
|
|
128
|
+
✓ Tools loaded: 370
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Bad Output:**
|
|
132
|
+
```
|
|
133
|
+
✗ MCP server is not running
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Fix:** `./scripts/mcp-server-manager.sh start`
|
|
137
|
+
|
|
138
|
+
### Check Authentication
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
./scripts/mcp-server-manager.sh logs
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Good Output:**
|
|
145
|
+
```
|
|
146
|
+
[Auth] Using username/password authentication
|
|
147
|
+
[Auth] Username/password authentication successful
|
|
148
|
+
[ToolRegistry] Registered 370 tools
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**Bad Output:**
|
|
152
|
+
```
|
|
153
|
+
[Auth] OAuth token refresh failed: No refresh token available
|
|
154
|
+
[Auth] Username/password authentication failed: Invalid credentials
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Fix:**
|
|
158
|
+
- Check .env file has correct credentials
|
|
159
|
+
- For OAuth: Add SNOW_USERNAME + SNOW_PASSWORD as fallback
|
|
160
|
+
- Verify instance URL is correct (should be `dev123456.service-now.com`, NOT `https://...`)
|
|
161
|
+
|
|
162
|
+
### Test JSON-RPC Communication
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
./scripts/mcp-server-manager.sh health
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Good Output:**
|
|
169
|
+
```
|
|
170
|
+
Testing JSON-RPC communication...
|
|
171
|
+
✓ Health check passed - 370 tools available
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Bad Output:**
|
|
175
|
+
```
|
|
176
|
+
✗ Health check failed - timeout
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Fix:**
|
|
180
|
+
- Check MCP server logs: `./scripts/mcp-server-manager.sh logs`
|
|
181
|
+
- Restart server: `./scripts/mcp-server-manager.sh restart`
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Common Error Messages & Fixes
|
|
186
|
+
|
|
187
|
+
### Error: "Missing required environment variables"
|
|
188
|
+
|
|
189
|
+
**Cause:** .env file not found or MCP server can't read it
|
|
190
|
+
|
|
191
|
+
**Fix:**
|
|
192
|
+
```bash
|
|
193
|
+
# Create .env from example
|
|
194
|
+
cp .env.example .env
|
|
195
|
+
|
|
196
|
+
# Edit with your credentials
|
|
197
|
+
vi .env
|
|
198
|
+
|
|
199
|
+
# Restart MCP server
|
|
200
|
+
./scripts/mcp-server-manager.sh restart
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Error: "OAuth token refresh failed: No refresh token available"
|
|
204
|
+
|
|
205
|
+
**Cause:** OAuth configuration doesn't provide refresh tokens
|
|
206
|
+
|
|
207
|
+
**Fix:** Add username/password to .env (fallback auth method):
|
|
208
|
+
```bash
|
|
209
|
+
SNOW_USERNAME=admin
|
|
210
|
+
SNOW_PASSWORD=your-password
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Why this works:** v8.3.1+ tries OAuth first, then automatically falls back to username/password.
|
|
214
|
+
|
|
215
|
+
### Error: "Username/password authentication failed: Invalid credentials"
|
|
216
|
+
|
|
217
|
+
**Cause:** Wrong username or password
|
|
218
|
+
|
|
219
|
+
**Fix:**
|
|
220
|
+
1. Verify credentials work in ServiceNow web UI
|
|
221
|
+
2. Check for special characters (escape them in .env)
|
|
222
|
+
3. Try different user account
|
|
223
|
+
|
|
224
|
+
### Error: "Model tried to call unavailable tool '$functions.snow_update_set_manage'"
|
|
225
|
+
|
|
226
|
+
**Cause:** MCP tools not loaded in OpenCode
|
|
227
|
+
|
|
228
|
+
**Fix:**
|
|
229
|
+
1. Check `opencode-config.json` uses `"environment"` (not `"env"`)
|
|
230
|
+
2. Verify MCP servers are running: `./scripts/mcp-server-manager.sh status`
|
|
231
|
+
3. Restart OpenCode: `./scripts/start-opencode.sh`
|
|
232
|
+
|
|
233
|
+
### Error: "Connection timeout" or "ECONNREFUSED"
|
|
234
|
+
|
|
235
|
+
**Cause:** ServiceNow instance URL wrong or network issue
|
|
236
|
+
|
|
237
|
+
**Fix:**
|
|
238
|
+
1. Verify SNOW_INSTANCE in .env (should be `dev123456.service-now.com`)
|
|
239
|
+
2. Test connectivity: `ping dev123456.service-now.com`
|
|
240
|
+
3. Check firewall/VPN settings
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Authentication Flow (v8.3.1+)
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
┌─────────────────────────────────────┐
|
|
248
|
+
│ MCP Server Starts │
|
|
249
|
+
└─────────┬───────────────────────────┘
|
|
250
|
+
│
|
|
251
|
+
▼
|
|
252
|
+
┌─────────────────────────────────────┐
|
|
253
|
+
│ Try OAuth Authentication │
|
|
254
|
+
│ (if CLIENT_ID + CLIENT_SECRET) │
|
|
255
|
+
└─────────┬───────────────────────────┘
|
|
256
|
+
│
|
|
257
|
+
├─ Success ──► Use OAuth tokens
|
|
258
|
+
│
|
|
259
|
+
├─ No refresh token ─────┐
|
|
260
|
+
│ │
|
|
261
|
+
▼ ▼
|
|
262
|
+
┌─────────────────────────────────────┐
|
|
263
|
+
│ Fallback to Username/Password │
|
|
264
|
+
│ (if USERNAME + PASSWORD) │
|
|
265
|
+
└─────────┬───────────────────────────┘
|
|
266
|
+
│
|
|
267
|
+
├─ Success ──► Use Basic Auth
|
|
268
|
+
│
|
|
269
|
+
├─ Fail ─────► Error (no auth method works)
|
|
270
|
+
│
|
|
271
|
+
▼
|
|
272
|
+
Tools Available!
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## MCP Server Manager Commands
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
# Start MCP server in background
|
|
281
|
+
./scripts/mcp-server-manager.sh start
|
|
282
|
+
|
|
283
|
+
# Stop MCP server
|
|
284
|
+
./scripts/mcp-server-manager.sh stop
|
|
285
|
+
|
|
286
|
+
# Restart MCP server
|
|
287
|
+
./scripts/mcp-server-manager.sh restart
|
|
288
|
+
|
|
289
|
+
# Check status
|
|
290
|
+
./scripts/mcp-server-manager.sh status
|
|
291
|
+
|
|
292
|
+
# Run health check (tests JSON-RPC communication)
|
|
293
|
+
./scripts/mcp-server-manager.sh health
|
|
294
|
+
|
|
295
|
+
# Follow logs (Ctrl+C to exit)
|
|
296
|
+
./scripts/mcp-server-manager.sh logs
|
|
297
|
+
|
|
298
|
+
# Show help
|
|
299
|
+
./scripts/mcp-server-manager.sh help
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## OpenCode Launcher Benefits
|
|
305
|
+
|
|
306
|
+
Using `./scripts/start-opencode.sh` instead of direct `opencode`:
|
|
307
|
+
|
|
308
|
+
- ✅ Validates .env file exists
|
|
309
|
+
- ✅ Builds Snow-Flow if dist/ missing
|
|
310
|
+
- ✅ Auto-starts MCP servers
|
|
311
|
+
- ✅ Runs pre-flight health checks
|
|
312
|
+
- ✅ Creates opencode-config.json if missing
|
|
313
|
+
- ✅ Replaces ${VARIABLES} with actual values
|
|
314
|
+
- ✅ Shows clear error messages with solutions
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Still Having Issues?
|
|
319
|
+
|
|
320
|
+
### 1. Check All Logs
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
# MCP server logs
|
|
324
|
+
./scripts/mcp-server-manager.sh logs
|
|
325
|
+
|
|
326
|
+
# OpenCode logs (if available)
|
|
327
|
+
cat ~/.opencode/logs/latest.log
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### 2. Test Individual Components
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
# Test MCP server binary exists
|
|
334
|
+
ls -la dist/mcp/servicenow-mcp-unified/index.js
|
|
335
|
+
|
|
336
|
+
# Test environment variables
|
|
337
|
+
source .env && echo $SNOW_INSTANCE
|
|
338
|
+
|
|
339
|
+
# Test ServiceNow connectivity
|
|
340
|
+
curl -u "$SNOW_USERNAME:$SNOW_PASSWORD" \
|
|
341
|
+
"https://$SNOW_INSTANCE/api/now/table/sys_user?sysparm_limit=1"
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### 3. Clean Restart
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
# Stop everything
|
|
348
|
+
./scripts/mcp-server-manager.sh stop
|
|
349
|
+
|
|
350
|
+
# Rebuild
|
|
351
|
+
npm run build
|
|
352
|
+
|
|
353
|
+
# Start fresh
|
|
354
|
+
./scripts/start-opencode.sh
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### 4. Report Issue
|
|
358
|
+
|
|
359
|
+
If none of the above works, create a GitHub issue with:
|
|
360
|
+
|
|
361
|
+
- Snow-Flow version: `npm list -g snow-flow`
|
|
362
|
+
- Node.js version: `node -v`
|
|
363
|
+
- OpenCode version: `opencode --version`
|
|
364
|
+
- Output of: `./scripts/mcp-server-manager.sh health`
|
|
365
|
+
- Relevant logs (without passwords!)
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## Version Information
|
|
370
|
+
|
|
371
|
+
- **v8.3.0 and earlier**: Only OAuth supported, config used `"env"`
|
|
372
|
+
- **v8.3.1+**: OAuth + Username/Password fallback, config uses `"environment"`
|
|
373
|
+
|
|
374
|
+
**Upgrade command:**
|
|
375
|
+
```bash
|
|
376
|
+
npm install -g snow-flow@latest
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
**Last Updated:** 2025-10-22 (v8.3.1)
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* ServiceNow Agent System - Claude Agent SDK Integration v4.7.0
|
|
3
3
|
* DEPRECATED: Custom agents replaced by @anthropic-ai/claude-agent-sdk@0.1.1
|
|
4
4
|
*/
|
|
5
|
-
export { ClaudeAgentSDKIntegration
|
|
6
|
-
export type { SnowFlowAgentConfig, AgentExecutionResult,
|
|
5
|
+
export { ClaudeAgentSDKIntegration } from '../sdk/index.js';
|
|
6
|
+
export type { SnowFlowAgentConfig, AgentExecutionResult, AgentType } from '../sdk/index.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|