@wangchenglai/dsh-acp-session 0.1.0 → 0.1.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/start-acp.sh CHANGED
@@ -1,24 +1,64 @@
1
- #!/bin/bash
2
- # 启动 ACP 服务:先确保 profile 能按包名解析到本插件,再叠加 patch 启动 dsh。
3
- #
4
- # 为什么不直接改用户的 cordis.patch.yml:
5
- # 那个文件在 ~/.dsh/profiles/acp/ 下,是每个用户首次运行时生成的(NFS 持久化),
6
- # 改镜像里的模板不会影响已有用户。用 --patch 叠加,既不动用户文件,也永远是最新的。
7
- set -euo pipefail
8
-
9
- DSH_HOME="${DSH_HOME:-$HOME/.dsh}"
10
- PROFILE_DIR="$DSH_HOME/profiles/acp"
11
- PLUGIN_SRC="${DSH_ACP_SESSION_PLUGIN:-/opt/dsh-plugins/acp-session}"
12
- PROFILE_PATCH="${DSH_ACP_SESSION_PATCH:-$PLUGIN_SRC/profile-patch.yml}"
13
-
14
- mkdir -p "$PROFILE_DIR/node_modules/@wangchenglai"
15
- ln -sfn "$PLUGIN_SRC" "$PROFILE_DIR/node_modules/@wangchenglai/dsh-acp-session"
16
-
17
- # dsh 自身安装在全局 node_modules 下,再链一份作为兜底(不同版本的解析根可能不同)。
18
- GLOBAL_ROOT="$(npm root -g 2>/dev/null || true)"
19
- if [ -n "$GLOBAL_ROOT" ] && [ -d "$GLOBAL_ROOT" ] && [ -w "$GLOBAL_ROOT" ]; then
20
- mkdir -p "$GLOBAL_ROOT/@wangchenglai"
21
- ln -sfn "$PLUGIN_SRC" "$GLOBAL_ROOT/@wangchenglai/dsh-acp-session"
22
- fi
23
-
24
- exec dsh --profile acp --patch "$PROFILE_PATCH"
1
+ #!/bin/bash
2
+ # 启动 ACP 服务:先确保 profile 能按包名解析到本插件,再叠加 patch 启动 dsh。
3
+ #
4
+ # 为什么不直接改用户的 cordis.patch.yml:
5
+ # 那个文件在 ~/.dsh/profiles/acp/ 下,是每个用户首次运行时生成的(NFS 持久化),
6
+ # 改镜像里的模板不会影响已有用户。用 --patch 叠加,既不动用户文件,也永远是最新的。
7
+ set -euo pipefail
8
+
9
+ DSH_HOME="${DSH_HOME:-$HOME/.dsh}"
10
+ PROFILE_DIR="$DSH_HOME/profiles/acp"
11
+ PLUGIN_SRC="${DSH_ACP_SESSION_PLUGIN:-/opt/dsh-plugins/acp-session}"
12
+ PROFILE_PATCH="${DSH_ACP_SESSION_PATCH:-$PLUGIN_SRC/profile-patch.yml}"
13
+ USER_CONFIG="$DSH_HOME/provider.json"
14
+ USER_PATCH="$PROFILE_DIR/user-provider-patch.yml"
15
+
16
+ mkdir -p "$PROFILE_DIR/node_modules/@wangchenglai"
17
+ ln -sfn "$PLUGIN_SRC" "$PROFILE_DIR/node_modules/@wangchenglai/dsh-acp-session"
18
+
19
+ # dsh 自身安装在全局 node_modules 下,再链一份作为兜底(不同版本的解析根可能不同)。
20
+ GLOBAL_ROOT="$(npm root -g 2>/dev/null || true)"
21
+ if [ -n "$GLOBAL_ROOT" ] && [ -d "$GLOBAL_ROOT" ] && [ -w "$GLOBAL_ROOT" ]; then
22
+ mkdir -p "$GLOBAL_ROOT/@wangchenglai"
23
+ ln -sfn "$PLUGIN_SRC" "$GLOBAL_ROOT/@wangchenglai/dsh-acp-session"
24
+ fi
25
+
26
+ # 用户自定义 provider:Base URL 与模型名写在 ~/.dsh/provider.json。
27
+ # 启动时生成一个用户级 patch,覆盖 DeepSeek provider 的目录和默认模型。
28
+ rm -f "$USER_PATCH"
29
+ if [ -f "$USER_CONFIG" ]; then
30
+ python3 - "$USER_CONFIG" "$USER_PATCH" <<'PY'
31
+ import json
32
+ import sys
33
+
34
+ config_path, output_path = sys.argv[1], sys.argv[2]
35
+ try:
36
+ with open(config_path, encoding='utf-8') as handle:
37
+ data = json.load(handle)
38
+ base_url = str(data.get('base_url', '')).strip()
39
+ model = str(data.get('model', '')).strip()
40
+ if not base_url or not model:
41
+ raise SystemExit(0)
42
+
43
+ quote = lambda value: json.dumps(value, ensure_ascii=False)
44
+ with open(output_path, 'w', encoding='utf-8') as handle:
45
+ handle.write('- id: llm-deepseek\n config:\n')
46
+ handle.write(f' baseURL: {quote(base_url)}\n')
47
+ handle.write(' models:\n')
48
+ handle.write(f' - id: {quote(model)}\n')
49
+ handle.write(f' name: {quote(model)}\n')
50
+ handle.write(' contextWindow: 1000000\n')
51
+ handle.write(' inputModalities: [text]\n')
52
+ handle.write('- id: acp-session\n config:\n provider: deepseek-official\n')
53
+ handle.write(f' model: {quote(model)}\n')
54
+ except SystemExit:
55
+ raise
56
+ except Exception:
57
+ pass
58
+ PY
59
+ fi
60
+
61
+ if [ -s "$USER_PATCH" ]; then
62
+ exec dsh --profile acp --patch "$PROFILE_PATCH" --patch "$USER_PATCH"
63
+ fi
64
+ exec dsh --profile acp --patch "$PROFILE_PATCH"