sophhub 0.4.40 → 0.4.42
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/package.json +1 -1
- package/skills/image-description/skill.json +9 -2
- package/skills/image-description/src/pyproject.toml +1 -1
- package/skills/image-description/src/scripts/ana_image.py +30 -4
- package/skills/sophnet-oss/skill.json +13 -2
- package/skills/sophnet-oss/src/SKILL.md +32 -47
- package/skills/sophnet-oss/src/pyproject.toml +1 -1
package/package.json
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "image-description",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"types": [
|
|
5
5
|
"store"
|
|
6
6
|
],
|
|
7
7
|
"displayName": "图片描述",
|
|
8
8
|
"description": "生成图片描述",
|
|
9
9
|
"changelog": [
|
|
10
|
+
{
|
|
11
|
+
"changes": [
|
|
12
|
+
"ana_image.py:HTTP 200 但无法提取非空 content 时 stderr 报错并 exit 1,移除 json.dumps fallback"
|
|
13
|
+
],
|
|
14
|
+
"date": "2026-06-10",
|
|
15
|
+
"version": "1.0.3"
|
|
16
|
+
},
|
|
10
17
|
{
|
|
11
18
|
"changes": [
|
|
12
19
|
"SKILL:补充何时使用、输出契约与注意事项;脚本:异常输出至 stderr、非零退出,错误文案补充 data URL"
|
|
@@ -30,5 +37,5 @@
|
|
|
30
37
|
}
|
|
31
38
|
],
|
|
32
39
|
"createdAt": "2026-04-21",
|
|
33
|
-
"updatedAt": "2026-
|
|
40
|
+
"updatedAt": "2026-06-10"
|
|
34
41
|
}
|
|
@@ -88,10 +88,36 @@ def call_vlm(image_input: str) -> str:
|
|
|
88
88
|
except urllib.error.URLError as exc:
|
|
89
89
|
raise RuntimeError(f"URLError: {exc.reason}") from exc
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
return _extract_description(data)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _extract_description(data: dict) -> str:
|
|
95
|
+
error = data.get("error")
|
|
96
|
+
if isinstance(error, dict):
|
|
97
|
+
message = error.get("message")
|
|
98
|
+
if isinstance(message, str) and message.strip():
|
|
99
|
+
raise RuntimeError(f"图片描述失败:API 返回错误:{message.strip()}")
|
|
100
|
+
raise RuntimeError(
|
|
101
|
+
f"图片描述失败:API 返回错误:{json.dumps(error, ensure_ascii=False)}"
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
choices = data.get("choices")
|
|
105
|
+
if not isinstance(choices, list) or not choices:
|
|
106
|
+
raise RuntimeError("图片描述失败:模型未返回 choices")
|
|
107
|
+
|
|
108
|
+
first = choices[0]
|
|
109
|
+
if not isinstance(first, dict):
|
|
110
|
+
raise RuntimeError("图片描述失败:choices[0] 格式异常")
|
|
111
|
+
|
|
112
|
+
message = first.get("message")
|
|
113
|
+
if not isinstance(message, dict):
|
|
114
|
+
raise RuntimeError("图片描述失败:响应中缺少 message")
|
|
115
|
+
|
|
116
|
+
content = message.get("content")
|
|
117
|
+
if not isinstance(content, str) or not content.strip():
|
|
118
|
+
raise RuntimeError("图片描述失败:模型返回空描述")
|
|
119
|
+
|
|
120
|
+
return content.strip()
|
|
95
121
|
|
|
96
122
|
|
|
97
123
|
def build_parser():
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sophnet-oss",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"types": [
|
|
5
5
|
"builtin"
|
|
6
6
|
],
|
|
7
7
|
"displayName": "OSS链接生成",
|
|
8
8
|
"description": "将文件转换为一个可供下载的文件链接",
|
|
9
9
|
"changelog": [
|
|
10
|
+
{
|
|
11
|
+
"changes": [
|
|
12
|
+
"SKILL.md 全文中文化,精简 description 为中文「功能+触发场景」格式",
|
|
13
|
+
"Signed URL 章节新增 credential 日期不可修改、禁止重复参数约束",
|
|
14
|
+
"合并 Processing Mode 与禁止操作章节,输出模板固定化防止 LLM 篡改链接",
|
|
15
|
+
"新增 design.md 设计文档,含架构流程图和职责划分表",
|
|
16
|
+
"修复 pyproject.toml 版本号与 skill.json 同步"
|
|
17
|
+
],
|
|
18
|
+
"date": "2026-06-09",
|
|
19
|
+
"version": "1.1.1"
|
|
20
|
+
},
|
|
10
21
|
{
|
|
11
22
|
"changes": [
|
|
12
23
|
"补充签名下载链接必须完整保留查询参数的使用约束"
|
|
@@ -23,5 +34,5 @@
|
|
|
23
34
|
}
|
|
24
35
|
],
|
|
25
36
|
"createdAt": "2026-04-09",
|
|
26
|
-
"updatedAt": "2026-
|
|
37
|
+
"updatedAt": "2026-06-09"
|
|
27
38
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sophnet-oss
|
|
3
|
-
description:
|
|
3
|
+
description: 将本地文件路径转换为可下载链接(24小时有效)。当用户要求把文件转成链接、获取文件URL、分享文件时使用。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# File Path to URL
|
|
@@ -13,32 +13,23 @@ description: Convert a local file path to a downloadable URL (valid for 24 hours
|
|
|
13
13
|
|
|
14
14
|
- **必须**使用脚本输出的 `DOWNLOAD_URL` **完整字符串**(一字不改)填入下文展示模板中的下载链接,或原样写入下游。
|
|
15
15
|
- **禁止**去掉 `?` 及后续查询参数、禁止截取签名片段、禁止尝试「换成更短的裸 URL」或做任何 URL「美化」。
|
|
16
|
-
- 签名 URL 的参数中,**`x-oss-signature-version` 和 `x-oss-credential`
|
|
16
|
+
- 签名 URL 的参数中,**`x-oss-signature-version` 和 `x-oss-credential` 不可省略**,分别为签名算法的版本标识和访问凭证标识,缺失任一参数均会导致签名校验失败。**`x-oss-credential` 内嵌的日期不可修改**,禁止插入重复的 credential 参数。
|
|
17
17
|
- 若裸域名路径在无签名时可访问,那是偶然行为;本 skill **不以裸链为准**,仅以脚本输出的带签名 URL 为准。
|
|
18
18
|
- 向用户展示时沿用下文「转换成功后」的固定格式即可;**不要改模板结构**,只保证链接内容为完整签名 URL。
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## 前置条件
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- **NO sub-tasks** - Never spawn background sessions or use sessions_spawn
|
|
25
|
-
- **NO task splitting** - Complete the conversion in one continuous run
|
|
26
|
-
- **NO parallel execution** - Convert one file at a time
|
|
27
|
-
|
|
28
|
-
## Prerequisites
|
|
29
|
-
|
|
30
|
-
- Python packages: sophnet-tools
|
|
22
|
+
- Python 包:`sophnet-tools`(需预先安装在系统 Python 环境中)
|
|
31
23
|
|
|
32
24
|
## Usage
|
|
33
25
|
|
|
34
|
-
|
|
26
|
+
当用户要求将文件路径转换为 URL 时:
|
|
35
27
|
|
|
36
|
-
1.
|
|
37
|
-
2.
|
|
28
|
+
1. **提取文件路径**:从用户输入或日志中提取(见下文「路径提取」)。
|
|
29
|
+
2. **运行脚本**:
|
|
38
30
|
|
|
39
31
|
```bash
|
|
40
|
-
|
|
41
|
-
python {baseDir}/scripts/upload_file.py \
|
|
32
|
+
python3 {baseDir}/scripts/upload_file.py \
|
|
42
33
|
--file /absolute/path/to/file \
|
|
43
34
|
--timeout 120
|
|
44
35
|
```
|
|
@@ -48,72 +39,66 @@ uv run --with sophnet-tools \
|
|
|
48
39
|
- `--file`: 要转换为 URL 的本地文件路径(必填)
|
|
49
40
|
- `--timeout`: 请求超时秒数(默认 120,大文件可适当增大)
|
|
50
41
|
|
|
51
|
-
##
|
|
42
|
+
## 输出
|
|
52
43
|
|
|
53
|
-
|
|
44
|
+
脚本输出结构化键值对:
|
|
54
45
|
|
|
46
|
+
成功时:
|
|
55
47
|
```
|
|
56
48
|
FILE_PATH=/absolute/path/to/file
|
|
57
49
|
UPLOAD_STATUS=uploaded
|
|
58
50
|
DOWNLOAD_URL=https://...signed-url...
|
|
59
51
|
```
|
|
60
52
|
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
失败时:
|
|
63
54
|
```
|
|
64
55
|
FILE_PATH=/absolute/path/to/file
|
|
65
56
|
UPLOAD_STATUS=failed
|
|
66
|
-
ERROR
|
|
57
|
+
ERROR=错误描述
|
|
67
58
|
```
|
|
68
59
|
|
|
69
|
-
|
|
60
|
+
**转换成功后,向用户展示为(固定模板,不可修改结构):**
|
|
70
61
|
|
|
71
62
|
```
|
|
72
63
|
文件路径已转换为可访问链接:
|
|
73
64
|
|
|
74
65
|
文件路径:/absolute/path/to/file
|
|
75
|
-
|
|
66
|
+
下载链接:<完整 DOWNLOAD_URL,一字不改>
|
|
76
67
|
|
|
77
68
|
⏰ 链接有效期:24小时
|
|
78
69
|
```
|
|
79
70
|
|
|
80
|
-
##
|
|
71
|
+
## 路径提取
|
|
81
72
|
|
|
82
|
-
|
|
73
|
+
当用户通过聊天提供文件时,从日志中查找以下模式:
|
|
83
74
|
|
|
84
75
|
```
|
|
85
76
|
Resolved relative path: "media/inbound/images/xxx.pdf" -> "/absolute/path/to/workspace/media/inbound/images/xxx.pdf"
|
|
86
77
|
```
|
|
87
78
|
|
|
88
|
-
|
|
79
|
+
取 `->` 右侧的绝对路径传入脚本。优先从上述日志中取解析后的路径,再回退到用户输入。
|
|
89
80
|
|
|
90
|
-
|
|
81
|
+
## 示例流程
|
|
91
82
|
|
|
92
|
-
|
|
83
|
+
用户:"把这个文件转成链接" / "给我这个文件的 URL"
|
|
93
84
|
|
|
94
|
-
|
|
85
|
+
1. 从日志 pattern(`Resolved relative path: "..." -> "/absolute/..."`)或用户输入提取文件路径
|
|
86
|
+
2. 执行:`python3 {baseDir}/scripts/upload_file.py --file /absolute/path/to/file --timeout 120`
|
|
87
|
+
3. 解析输出,按固定模板向用户展示下载链接
|
|
95
88
|
|
|
96
|
-
|
|
97
|
-
2. Run: `uv run --with sophnet-tools python {baseDir}/scripts/upload_file.py --file /absolute/path/to/file --timeout 120`
|
|
98
|
-
3. Parse the output and display the URL to the user
|
|
99
|
-
|
|
100
|
-
## Notes
|
|
89
|
+
## 注意事项
|
|
101
90
|
|
|
102
91
|
- 返回的 URL 有效期为 **24 小时**
|
|
103
92
|
- 任意类型文件均可转换(无扩展名限制)
|
|
104
93
|
- 大文件可增大 `--timeout`(默认 120 秒)
|
|
105
94
|
- 始终使用绝对路径以保证可靠
|
|
95
|
+
- **严格串行执行**:禁止并发、禁止拆分子任务、禁止后台运行,一次只转换一个文件
|
|
96
|
+
- **不修改签名 URL**:`DOWNLOAD_URL` 必须原样使用,不截取、不"美化"、不修改任何参数
|
|
106
97
|
|
|
107
|
-
## ⚠️
|
|
108
|
-
|
|
109
|
-
**Do NOT:**
|
|
110
|
-
|
|
111
|
-
- Spawn sub-agent sessions (sessions_spawn)
|
|
112
|
-
- Run multiple parallel conversions
|
|
113
|
-
- Split the task into separate operations
|
|
114
|
-
- Use background processes
|
|
115
|
-
|
|
116
|
-
**ONLY:**
|
|
98
|
+
## ⚠️ 禁止操作
|
|
117
99
|
|
|
118
|
-
-
|
|
119
|
-
-
|
|
100
|
+
- 禁止派生子会话(sessions_spawn)
|
|
101
|
+
- 禁止并发转换多个文件
|
|
102
|
+
- 禁止将任务拆分为多个步骤
|
|
103
|
+
- 禁止使用后台进程
|
|
104
|
+
- 禁止修改 `DOWNLOAD_URL` 中的任何字符(含查询参数)
|