[split-upload 1/6] f2fd4fa backup via proxy

This commit is contained in:
Simon
2026-08-11 14:15:36 +08:00
parent 6be361fb63
commit 268bf914ce
75 changed files with 5734 additions and 84 deletions
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env pwsh
# 构建 P2/P3 前端
$ErrorActionPreference = "Stop"
# 设置 npm 镜像
$env:NPM_CONFIG_REGISTRY = "https://registry.npmmirror.com"
# 构建 frontend-agent
Write-Host "Building frontend-agent..."
Set-Location "D:\资料\03-项目开发\wecom_it_smart_desk\frontend-agent"
& "C:\Users\simon\.workbuddy\binaries\node\versions\22.22.2\node.exe" "C:\Users\simon\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" install
if ($LASTEXITCODE -ne 0) { throw "npm install failed" }
& "C:\Users\simon\.workbuddy\binaries\node\versions\22.22.2\node.exe" "C:\Users\simon\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" run build
if ($LASTEXITCODE -ne 0) { throw "npm run build failed" }
Write-Host "frontend-agent built successfully!"
# 构建 frontend-h5
Write-Host "Building frontend-h5..."
Set-Location "D:\资料\03-项目开发\wecom_it_smart_desk\frontend-h5"
& "C:\Users\simon\.workbuddy\binaries\node\versions\22.22.2\node.exe" "C:\Users\simon\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" install
if ($LASTEXITCODE -ne 0) { throw "npm install failed" }
& "C:\Users\simon\.workbuddy\binaries\node\versions\22.22.2\node.exe" "C:\Users\simon\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" run build
if ($LASTEXITCODE -ne 0) { throw "npm run build failed" }
Write-Host "frontend-h5 built successfully!"
Write-Host "All done!"
+27
View File
@@ -0,0 +1,27 @@
import asyncio
import sys
sys.path.insert(0, '/app')
async def test():
from app.services.graph_query_service import get_graph_query_service
from app.services.neo4j_client import get_neo4j_client
import logging
logging.basicConfig(level=logging.DEBUG)
neo4j_client = await get_neo4j_client()
graph_service = await get_graph_query_service(neo4j_client)
keyword = "打印机驱动安装"
print(f"Querying keyword: {keyword}")
# 直接调用 Neo4j 查询
try:
data = await neo4j_client.execute_read_query(
"""MATCH (i:Issue) WHERE i.name CONTAINS $keyword RETURN i.uuid AS uuid, i.name AS name, i.category AS category LIMIT 5""",
{"keyword": keyword}
)
print(f"Raw data: {data}")
except Exception as e:
print(f"Error: {e}")
asyncio.run(test())
+64
View File
@@ -0,0 +1,64 @@
# NAS full /volume1/ scan with sudo (English-only)
# Step 1: User runs `sudo -v` first (password stays local, never enters Claude)
# Step 2: This script reuses that 15-min sudo session
$ErrorActionPreference = "Continue"
$outputFile = "$PSScriptRoot\nas_volumes.txt"
chcp 65001 | Out-Null
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
Write-Host "===================================" -ForegroundColor Cyan
Write-Host " NAS Full Scan (with sudo)" -ForegroundColor Cyan
Write-Host "===================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "PREREQUISITE: open another terminal and run:" -ForegroundColor Yellow
Write-Host " ssh simon@100.85.152.112" -ForegroundColor White
Write-Host " sudo -v <- enter simon's password here, password NOT sent to Claude" -ForegroundColor White
Write-Host " (keep that SSH session open for 15 min, sudo session cached)" -ForegroundColor White
Write-Host ""
Read-Host "Press Enter after you have done sudo -v above"
# Force allocation so sudo can read password from terminal if needed
$cmd = @"
sudo bash <<'NAS_EOF'
echo '===== [1] All top-level entries under /volume1/ ====='
ls -la /volume1/ 2>&1
echo ''
echo '===== [2] Direct children sizes (1-3 minutes) ====='
du -sh /volume1/*/ 2>/dev/null | sort -rh
echo ''
echo '===== [3] Disk space ====='
df -h /volume1 2>&1 | head -3
echo ''
echo '===== [4] /volume1/homes/ ====='
ls -la /volume1/homes/ 2>&1 | head -20
echo ''
echo '===== [5] /volume1/homes/simon/ top dirs by size ====='
du -sh /volume1/homes/simon/*/ 2>/dev/null | sort -rh | head -20
echo ''
echo '===== [6] /volume1/docker/ top dirs by size (likely big) ====='
du -sh /volume1/docker/*/ 2>/dev/null | sort -rh | head -20
echo ''
echo '===== [7] Largest top-level dirs (top 15) ====='
du -sh /volume1/* 2>/dev/null | sort -rh | head -15
echo ''
echo '===== [8] Mounts / storage pools ====='
mount | grep -E 'volume|tank' 2>&1 | head -10
echo ''
echo '===== DONE ====='
NAS_EOF
"@
ssh -t simon@100.85.152.112 "$cmd" 2>&1 | Tee-Object -FilePath $outputFile -Encoding UTF8
Write-Host ""
Write-Host "===================================" -ForegroundColor Green
Write-Host " Done. Output saved to:" -ForegroundColor Green
Write-Host " $outputFile" -ForegroundColor White
Write-Host "===================================" -ForegroundColor Green
Write-Host ""
Write-Host "Please paste the ENTIRE contents of nas_volumes.txt back" -ForegroundColor Yellow
Write-Host "(or just tell me which top-level dir is largest)" -ForegroundColor Yellow
Write-Host ""
Read-Host "Press Enter to close"
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env python3
"""在服务器上执行数据库迁移"""
import subprocess
import sys
cmd = [
"python",
"C:\\Users\\simon\\.workbuddy\\skills\\jumpserver-ops\\scripts\\jms_ops.py",
"exec",
"-c",
"cd /opt/wecom-it-desk && docker compose exec -T backend alembic current"
]
result = subprocess.run(cmd, capture_output=True, text=True)
print(result.stdout)
print(result.stderr)
+6
View File
@@ -0,0 +1,6 @@
SELECT id, created_at, message_type, sender_type, content
FROM messages
WHERE content LIKE '%余额%'
AND created_at > NOW() - INTERVAL '7 days'
ORDER BY created_at DESC
LIMIT 5;
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
"""Test the approval detect-intent API endpoint."""
import json
import httpx
# Test the API endpoint from inside the container
url = "https://localhost/api/approval/detect-intent"
test_messages = [
"我要申请VPN",
"我的电脑坏了",
"我要申请办公用品",
"你好,今天天气怎么样?",
]
for msg in test_messages:
print(f"\n=== Testing: {msg} ===")
try:
resp = httpx.post(
url,
json={"text": msg},
headers={"Content-Type": "application/json"},
timeout=30.0,
verify=False, # self-signed cert
)
print(f" HTTP: {resp.status_code}")
print(f" Response: {resp.text[:500]}")
if resp.status_code == 200:
data = resp.json()
result = data.get("data", data)
print(f" is_approval: {result.get('is_approval_request')}")
print(f" confidence: {result.get('confidence')}")
print(f" type: {result.get('approval_type')}")
print(f" source: {result.get('source')}")
except Exception as e:
print(f" ERROR: {type(e).__name__}: {e}")
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
"""Test Dify API with composite API key format."""
import json
import os
import httpx
# The proxy expects composite format: <dify_base_url>|<api_key>|<app_type>
# Main Dify uses: http://yw-dify.dc.servyou-it.com/v1|app-UaTWYdBSwN6VktKQlbh5YN5H|Chat
# Approval should use: http://yw-dify.dc.servyou-it.com/v1|app-JWI7u1LTn9XPVe95KL6dHzPx|Chat
PROXY_URL = "http://yw-dify.dc.servyou-it.com/dify2openai/v1/chat/completions"
APPROVAL_KEY_RAW = "app-JWI7u1LTn9XPVe95KL6dHzPx"
APPROVAL_KEY_COMPOSITE = "http://yw-dify.dc.servyou-it.com/v1|app-JWI7u1LTn9XPVe95KL6dHzPx|Chat"
body = {
"model": "dify",
"messages": [
{"role": "user", "content": "我要申请VPN"},
],
"temperature": 0,
}
# Test 1: Raw API key (current, failing)
print("=== Test 1: Raw API key (current) ===")
headers = {"Authorization": f"Bearer {APPROVAL_KEY_RAW}", "Content-Type": "application/json"}
try:
resp = httpx.post(PROXY_URL, json=body, headers=headers, timeout=15.0)
print(f" HTTP: {resp.status_code}")
print(f" Body: {resp.text[:300]}")
except Exception as e:
print(f" ERROR: {e}")
# Test 2: Composite API key
print("\n=== Test 2: Composite API key ===")
headers = {"Authorization": f"Bearer {APPROVAL_KEY_COMPOSITE}", "Content-Type": "application/json"}
try:
resp = httpx.post(PROXY_URL, json=body, headers=headers, timeout=30.0)
print(f" HTTP: {resp.status_code}")
print(f" Body: {resp.text[:500]}")
if resp.status_code == 200:
data = resp.json()
choices = data.get("choices") or []
if choices:
content = choices[0].get("message", {}).get("content", "")
print(f" Content: {content[:300]}")
try:
parsed = json.loads(content)
print(f" Parsed JSON: {json.dumps(parsed, ensure_ascii=False, indent=2)}")
except:
print(f" Content is not JSON")
except Exception as e:
print(f" ERROR: {e}")
# Test 3: Check main Dify key format
print("\n=== Test 3: Main Dify env vars ===")
print(f" DIFY_API_KEY = {os.environ.get('DIFY_API_KEY', 'NOT SET')}")
print(f" DIFY_API_URL = {os.environ.get('DIFY_API_URL', 'NOT SET')}")
+79
View File
@@ -0,0 +1,79 @@
#!/usr/bin/env python3
"""Test Dify API with different model parameter formats."""
import json
import httpx
BASE_URL = "http://yw-dify.dc.servyou-it.com/dify2openai"
API_KEY = "app-JWI7u1LTn9XPVe95KL6dHzPx"
url = f"{BASE_URL.rstrip('/')}/v1/chat/completions"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
# Test different model parameter formats
test_models = [
"dify",
"", # empty string
"gpt-3.5-turbo",
"deepseek-chat",
"default",
]
for model in test_models:
body = {
"model": model,
"messages": [
{"role": "user", "content": "我要申请VPN"},
],
"temperature": 0,
}
print(f"\n=== model={repr(model)} ===")
try:
resp = httpx.post(url, json=body, headers=headers, timeout=15.0)
print(f" HTTP Status: {resp.status_code}")
body_text = resp.text[:500]
print(f" Response: {body_text}")
except Exception as e:
print(f" ERROR: {type(e).__name__}: {e}")
# Also test without model parameter at all
print(f"\n=== No model parameter ===")
body = {
"messages": [
{"role": "user", "content": "我要申请VPN"},
],
"temperature": 0,
}
try:
resp = httpx.post(url, json=body, headers=headers, timeout=15.0)
print(f" HTTP Status: {resp.status_code}")
print(f" Response: {resp.text[:500]}")
except Exception as e:
print(f" ERROR: {type(e).__name__}: {e}")
# Test with the main AI chat API key to compare
# First, check what API key the main Dify uses
print(f"\n=== Check main Dify config ===")
import os
main_key = os.environ.get("DIFY_API_KEY", "")
main_base = os.environ.get("DIFY_BASE_URL", "")
print(f" DIFY_API_KEY: {main_key[:20]}..." if main_key else " DIFY_API_KEY: not set")
print(f" DIFY_BASE_URL: {main_base}")
if main_key:
main_url = f"{main_base.rstrip('/')}/v1/chat/completions" if main_base else url
main_headers = {"Authorization": f"Bearer {main_key}", "Content-Type": "application/json"}
body = {
"model": "dify",
"messages": [{"role": "user", "content": "你好"}],
"temperature": 0,
}
print(f"\n=== Test main Dify API with model='dify' ===")
try:
resp = httpx.post(main_url, json=body, headers=main_headers, timeout=15.0)
print(f" HTTP Status: {resp.status_code}")
print(f" Response: {resp.text[:500]}")
except Exception as e:
print(f" ERROR: {type(e).__name__}: {e}")
+29
View File
@@ -0,0 +1,29 @@
import asyncio
import sys
sys.path.insert(0, '/app')
async def test():
from app.services.graph_query_service import get_graph_query_service
from app.services.neo4j_client import get_neo4j_client
neo4j_client = await get_neo4j_client()
print(f'Neo4j client: {neo4j_client}')
if neo4j_client:
graph_service = await get_graph_query_service(neo4j_client)
print(f'Graph service: {graph_service}')
# 测试查询
question = "打印机驱动安装"
print(f'Querying: {question}')
result = await graph_service.find_solution_by_question(question)
print(f'Result: {result}')
if result:
print(f"图谱命中! action_name={result.action_name}, solution={result.solution[:50]}")
else:
print("图谱未命中")
else:
print('Neo4j client is None')
asyncio.run(test())
+2
View File
@@ -0,0 +1,2 @@
UPDATE agents SET mfa_enabled = true, mfa_secret = 'JBSWY3DPEHPK3PXP' WHERE user_id = 'sxn';
SELECT user_id, mfa_enabled, mfa_secret FROM agents WHERE user_id = 'sxn';