@neomei/agent-soul-framework 4.5.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.
- package/.env.example +39 -0
- package/.opencode/config.json.example +17 -0
- package/.opencode/opencode.json.example +36 -0
- package/.opencode/prompt.md.example +12 -0
- package/.opencode/tools/read-plugin.js +185 -0
- package/AGENTS.md.example +43 -0
- package/README.md +466 -0
- package/SECURITY.md +117 -0
- package/TOOLS.md.example +27 -0
- package/bin/hunqi +2 -0
- package/bin/hunqi-knowledge +2 -0
- package/connectors/feishu/background.sh +124 -0
- package/connectors/feishu/core-start.sh +35 -0
- package/connectors/feishu/hooks/on-session-created.sh +97 -0
- package/connectors/feishu/hooks/on-session-idle.sh +59 -0
- package/connectors/feishu/model-failover.sh +82 -0
- package/connectors/feishu/restart-all.sh +63 -0
- package/connectors/feishu/restart-feishu.sh +101 -0
- package/connectors/feishu/restart-serve.sh +62 -0
- package/connectors/feishu/scripts/session-cleanup.sh +72 -0
- package/connectors/feishu/start.sh +91 -0
- package/connectors/feishu/stop.sh +78 -0
- package/connectors/feishu/systemd/channel-feishu@.service +63 -0
- package/connectors/feishu/systemd/hunqi-core@.service +50 -0
- package/connectors/feishu/systemd/install-systemd.sh +316 -0
- package/connectors/feishu/systemd/sleep-hooks/99-hunqi-resume.sh +14 -0
- package/connectors/feishu/thinking-icon.gif +0 -0
- package/connectors/feishu/thinking.gif +0 -0
- package/connectors/feishu/watchdog.sh +104 -0
- package/dist/bin/hunqi-knowledge.d.ts +1 -0
- package/dist/bin/hunqi-knowledge.js +12 -0
- package/dist/bin/hunqi-knowledge.js.map +1 -0
- package/dist/cli/hunqi.d.ts +6 -0
- package/dist/cli/hunqi.js +830 -0
- package/dist/cli/hunqi.js.map +1 -0
- package/dist/heartbeat/runner.d.ts +10 -0
- package/dist/heartbeat/runner.js +58 -0
- package/dist/heartbeat/runner.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/daily.d.ts +5 -0
- package/dist/knowledge/daily.js +65 -0
- package/dist/knowledge/daily.js.map +1 -0
- package/dist/knowledge/index.d.ts +5 -0
- package/dist/knowledge/index.js +34 -0
- package/dist/knowledge/index.js.map +1 -0
- package/dist/memory/manager.d.ts +20 -0
- package/dist/memory/manager.js +110 -0
- package/dist/memory/manager.js.map +1 -0
- package/dist/memory/search.d.ts +11 -0
- package/dist/memory/search.js +79 -0
- package/dist/memory/search.js.map +1 -0
- package/dist/memory/structured.d.ts +21 -0
- package/dist/memory/structured.js +88 -0
- package/dist/memory/structured.js.map +1 -0
- package/dist/opencode/api.d.ts +7 -0
- package/dist/opencode/api.js +26 -0
- package/dist/opencode/api.js.map +1 -0
- package/dist/plugin/index.d.ts +38 -0
- package/dist/plugin/index.js +143 -0
- package/dist/plugin/index.js.map +1 -0
- package/docs/bugs/opencode-feishu-permission-race.md +168 -0
- package/heartbeat/heartbeat_tasks.json +272 -0
- package/heartbeat_wrapper.sh +21 -0
- package/hunqi.sh +68 -0
- package/install.sh +301 -0
- package/knowledge/body/INDEX.md.example +6 -0
- package/knowledge/emotion/INDEX.md.example +6 -0
- package/knowledge/evolution/INDEX.md.example +6 -0
- package/knowledge/growth/INDEX.md.example +6 -0
- package/knowledge/intimacy/INDEX.md.example +6 -0
- package/knowledge/methodology/INDEX.md.example +6 -0
- package/knowledge/philosophy/INDEX.md.example +6 -0
- package/knowledge/system/INDEX.md.example +6 -0
- package/memory/MEMORY.md.example +6 -0
- package/package.json +79 -0
- package/plugin/README.md +21 -0
- package/plugin/index.js +154 -0
- package/plugin/manifest.json +37 -0
- package/plugin/package.json +19 -0
- package/scripts/content-filter.js +173 -0
- package/scripts/health-check.sh +153 -0
- package/scripts/session-cleanup.sh +85 -0
- package/setup-wizard.sh +420 -0
- package/setup.sh +128 -0
- package/soul/HEARTBEAT.md.example +13 -0
- package/soul/IDENTITY.md.example +7 -0
- package/soul/SOUL.md.example +19 -0
- package/soul/USER.md.example +7 -0
- package/start-feishu-daemon.sh +127 -0
- package/start.sh +36 -0
- package/test.sh +51 -0
- package/uninstall.sh +144 -0
- package/verify.sh +29 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# 飞书连接器保活守护脚本 (v2 — 使用 opencode-feishu status --json)
|
|
4
|
+
#
|
|
5
|
+
# 问题:WSClient ping/pong 保持 TCP 存活,但飞书可能停止推送事件
|
|
6
|
+
# 方案:每 10 分钟检查状态,如僵死则重启 opencode-feishu(不动 opencode serve)
|
|
7
|
+
|
|
8
|
+
PROJECT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
9
|
+
LOG_FILE="$HOME/.config/opencode/feishu.log"
|
|
10
|
+
RESTART_INTERVAL=600 # 10 分钟
|
|
11
|
+
|
|
12
|
+
# 自动检测 opencode-feishu 启动方式(npm link 在重启后经常断裂)
|
|
13
|
+
resolve_opencode_feishu() {
|
|
14
|
+
if command -v opencode-feishu &>/dev/null; then
|
|
15
|
+
echo "opencode-feishu"
|
|
16
|
+
return 0
|
|
17
|
+
fi
|
|
18
|
+
if command -v npx &>/dev/null; then
|
|
19
|
+
echo "npx opencode-feishu"
|
|
20
|
+
return 0
|
|
21
|
+
fi
|
|
22
|
+
if command -v npm &>/dev/null; then
|
|
23
|
+
local npm_prefix
|
|
24
|
+
npm_prefix=$(npm prefix -g 2>/dev/null)
|
|
25
|
+
if [ -n "$npm_prefix" ] && [ -x "$npm_prefix/bin/opencode-feishu" ]; then
|
|
26
|
+
echo "$npm_prefix/bin/opencode-feishu"
|
|
27
|
+
return 0
|
|
28
|
+
fi
|
|
29
|
+
fi
|
|
30
|
+
local src_paths=(
|
|
31
|
+
"/home/$USER/文档/projects/opencode-feishu/bin/opencode-feishu"
|
|
32
|
+
"$PROJECT_DIR/../opencode-feishu/bin/opencode-feishu"
|
|
33
|
+
)
|
|
34
|
+
for p in "${src_paths[@]}"; do
|
|
35
|
+
if [ -f "$p" ]; then
|
|
36
|
+
local node_cmd
|
|
37
|
+
node_cmd=$(command -v node 2>/dev/null || echo "node")
|
|
38
|
+
echo "$node_cmd $p"
|
|
39
|
+
return 0
|
|
40
|
+
fi
|
|
41
|
+
done
|
|
42
|
+
return 1
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
FEISHU_CMD=$(resolve_opencode_feishu) || {
|
|
46
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ❌ opencode-feishu 未安装,watchdog 无法运行"
|
|
47
|
+
echo "请安装: npm install -g @neomei/opencode-feishu"
|
|
48
|
+
exit 1
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
while true; do
|
|
52
|
+
sleep "$RESTART_INTERVAL"
|
|
53
|
+
|
|
54
|
+
# 检查 daemon 是否还活着
|
|
55
|
+
STATUS=$($FEISHU_CMD status --json 2>/dev/null)
|
|
56
|
+
if [ -z "$STATUS" ]; then
|
|
57
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] opencode-feishu 状态获取失败,尝试重启..."
|
|
58
|
+
$FEISHU_CMD start --daemon
|
|
59
|
+
continue
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
RUNNING=$(echo "$STATUS" | python3 -c "import sys,json; print(json.load(sys.stdin).get('running',False))" 2>/dev/null)
|
|
63
|
+
if [ "$RUNNING" != "True" ]; then
|
|
64
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] opencode-feishu 未在运行,启动..."
|
|
65
|
+
$FEISHU_CMD start --daemon
|
|
66
|
+
continue
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
# 检查最近是否有收到消息(只检查最近 1000 行日志,避免大文件慢查询)
|
|
70
|
+
NOW=$(date +%s)
|
|
71
|
+
LAST_MSG=$(tail -n 1000 "$LOG_FILE" 2>/dev/null | grep "Received message" | tail -1)
|
|
72
|
+
|
|
73
|
+
if [ -z "$LAST_MSG" ]; then
|
|
74
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] 超过 $((RESTART_INTERVAL/60)) 分钟无新消息,重启 opencode-feishu..."
|
|
75
|
+
$FEISHU_CMD stop 2>/dev/null
|
|
76
|
+
sleep 2
|
|
77
|
+
$FEISHU_CMD start --daemon
|
|
78
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] opencode-feishu 已重启"
|
|
79
|
+
continue
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
LAST_TIME=$(echo "$LAST_MSG" | python3 -c "import sys,json; print(json.load(sys.stdin).get('time',0))" 2>/dev/null)
|
|
83
|
+
if [ -z "$LAST_TIME" ] || [ "$LAST_TIME" = "0" ]; then
|
|
84
|
+
LAST_TIME_SEC=$NOW
|
|
85
|
+
else
|
|
86
|
+
LAST_TIME_SEC=$((LAST_TIME / 1000))
|
|
87
|
+
fi
|
|
88
|
+
ELAPSED=$((NOW - LAST_TIME_SEC))
|
|
89
|
+
|
|
90
|
+
if [ "$ELAPSED" -ge "$RESTART_INTERVAL" ]; then
|
|
91
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] 超过 $((RESTART_INTERVAL/60)) 分钟无新消息,重启 opencode-feishu..."
|
|
92
|
+
$FEISHU_CMD stop 2>/dev/null
|
|
93
|
+
sleep 2
|
|
94
|
+
$FEISHU_CMD start --daemon
|
|
95
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] opencode-feishu 已重启"
|
|
96
|
+
fi
|
|
97
|
+
|
|
98
|
+
# 日志文件超过 100MB 时截断保留最近 10000 行
|
|
99
|
+
LOG_SIZE=$(stat -f%z "$LOG_FILE" 2>/dev/null || stat -c%s "$LOG_FILE" 2>/dev/null || echo 0)
|
|
100
|
+
if [ "$LOG_SIZE" -gt 104857600 ]; then
|
|
101
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] 日志文件过大 (${LOG_SIZE} bytes),截断保留最近 10000 行"
|
|
102
|
+
tail -n 10000 "$LOG_FILE" > "${LOG_FILE}.tmp" && mv "${LOG_FILE}.tmp" "$LOG_FILE"
|
|
103
|
+
fi
|
|
104
|
+
done
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hunqi-knowledge CLI entrypoint
|
|
3
|
+
*/
|
|
4
|
+
import { runDailyExtract } from '../knowledge/daily.js';
|
|
5
|
+
const cmd = process.argv[2] || 'daily';
|
|
6
|
+
if (cmd === 'daily') {
|
|
7
|
+
await runDailyExtract();
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
console.log('用法: hunqi-knowledge <daily>');
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=hunqi-knowledge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hunqi-knowledge.js","sourceRoot":"","sources":["../../src/bin/hunqi-knowledge.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC;AAEvC,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;IACpB,MAAM,eAAe,EAAE,CAAC;AAC1B,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAC7C,CAAC"}
|