@kir_sleeping/dsh-relay 0.3.0 → 0.4.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/README.md +11 -7
- package/client.js +3 -3
- package/docs/demo.html +874 -0
- package/docs/integration.md +428 -0
- package/docs/reference.md +161 -0
- package/docs/usage.md +130 -0
- package/index.js +103 -45
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
dsh-relay 是一个 DSH 入口中继器,把 DSH 的调用能力开放给本机应用。
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
让你的任何应用轻松调用 DSH。
|
|
9
9
|
|
|
10
10
|
应用不需要内置 AI、不需要自己管会话、不需要理解 agent 的内部结构——像调一个普通 HTTP API 一样把任务交出去,拿回结果。所有调用共享同一份上下文,所以 agent 在邮件应用里知道你在便签里写过什么。
|
|
11
11
|
|
|
@@ -64,19 +64,21 @@ dsh plugin add @kir_sleeping/dsh-relay
|
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
66
|
# 1. 申请凭证。这一步会在主机上弹系统确认框,用户点「允许」才继续
|
|
67
|
-
curl -s -X POST http://127.0.0.1:3080/x/relay/
|
|
67
|
+
curl -s -X POST http://127.0.0.1:3080/x/relay/enroll \
|
|
68
68
|
-H 'Content-Type: application/json' -d '{"source":"my-app"}'
|
|
69
|
-
# → {"source":"my-app","
|
|
69
|
+
# → {"source":"my-app","token":"…","level":1}
|
|
70
70
|
|
|
71
|
-
# 2.
|
|
71
|
+
# 2. 提交。token 放头里,source 在 body
|
|
72
72
|
curl -s -X POST http://127.0.0.1:3080/x/relay/submit \
|
|
73
73
|
-H 'Content-Type: application/json' \
|
|
74
|
-
-
|
|
74
|
+
-H 'Authorization: Bearer <token>' \
|
|
75
|
+
-d '{"content":"请只回复 OK","source":"my-app","trigger":"user","wait":true,"timeout":60}'
|
|
75
76
|
|
|
76
77
|
# 3. 或者流式
|
|
77
78
|
curl -N -X POST http://127.0.0.1:3080/x/relay/submit \
|
|
78
79
|
-H 'Content-Type: application/json' \
|
|
79
|
-
-
|
|
80
|
+
-H 'Authorization: Bearer <token>' \
|
|
81
|
+
-d '{"content":"介绍一下这个项目","source":"my-app","trigger":"user","stream":true,"timeout":120}'
|
|
80
82
|
```
|
|
81
83
|
|
|
82
84
|
## 文档
|
|
@@ -88,6 +90,8 @@ curl -N -X POST http://127.0.0.1:3080/x/relay/submit \
|
|
|
88
90
|
| [docs/reference.md](https://github.com/kir-sleeping/DSH-relay/blob/main/docs/reference.md) | 改插件的人 | 内部结构、不变式、扩展点 |
|
|
89
91
|
| [docs/demo.html](https://github.com/kir-sleeping/DSH-relay/blob/main/docs/demo.html) | 写外部接入的人 | 可运行的单文件示例:收件箱 + 每日小报 + 流式对话 |
|
|
90
92
|
|
|
93
|
+
这份包已经装在本机的话,同样的文件就在包的 `docs/` 目录下,**直接读本地文件,不用联网**。
|
|
94
|
+
|
|
91
95
|
## AGENT
|
|
92
96
|
|
|
93
97
|
如果你是 agent,建议先看 [usage.md](https://github.com/kir-sleeping/DSH-relay/blob/main/docs/usage.md):教用户怎么用、为什么会出现那些弹窗、不想反复弹窗该怎么做。
|
|
@@ -96,7 +100,7 @@ curl -N -X POST http://127.0.0.1:3080/x/relay/submit \
|
|
|
96
100
|
|
|
97
101
|
---
|
|
98
102
|
|
|
99
|
-
> 本 README
|
|
103
|
+
> 本 README 和 `docs/` 都随包分发。上面的链接指向 GitHub,是为了在 npm 页面上点得开;本机装好后直接读文件更快。
|
|
100
104
|
|
|
101
105
|
## License
|
|
102
106
|
|
package/client.js
CHANGED
|
@@ -115,16 +115,16 @@ window.__ModuleLoader__.load({
|
|
|
115
115
|
h('select', {
|
|
116
116
|
style: styles.select,
|
|
117
117
|
value: String(row.level),
|
|
118
|
-
disabled: busy || !row.
|
|
118
|
+
disabled: busy || !row.hasToken,
|
|
119
119
|
onChange: (event) => {
|
|
120
120
|
const level = Number(event.currentTarget.value)
|
|
121
121
|
if (level !== row.level) run('/sources/level', { source: row.source, level })
|
|
122
122
|
},
|
|
123
123
|
}, LEVELS.map((option) => h('option', { key: option.value, value: String(option.value) }, option.label)))),
|
|
124
|
-
h('td', { style: styles.td }, row.
|
|
124
|
+
h('td', { style: styles.td }, row.hasToken ? '已持有' : '—'),
|
|
125
125
|
h('td', { style: styles.td },
|
|
126
126
|
h('div', { style: styles.actions },
|
|
127
|
-
row.
|
|
127
|
+
row.hasToken
|
|
128
128
|
? h('button', { style: styles.button, disabled: busy, onClick: () => run('/sources/reset', { source: row.source }) }, '重置凭证')
|
|
129
129
|
: h('button', { style: styles.button, disabled: busy, onClick: () => run('/sources/clear', { source: row.source }) }, '解除禁止'),
|
|
130
130
|
h('button', { style: styles.button, disabled: busy, onClick: () => run('/sources/delete', { source: row.source }) }, '删除')))))
|