dsh-plugin-weapp-gateway 0.8.51 → 0.8.53
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/PROTOCOL.md +7 -0
- package/README.md +5 -0
- package/lib/client.js +2 -2
- package/lib/index.mjs +53 -26
- package/package.json +1 -1
package/PROTOCOL.md
CHANGED
|
@@ -622,6 +622,13 @@ let image = [
|
|
|
622
622
|
|
|
623
623
|
```json
|
|
624
624
|
{ "kind": "session-queue", "sessionId": "session-abc", "items": [] }
|
|
625
|
+
|
|
626
|
+
客户端也可以主动拉取当前会话队列(小程序在打开会话、发送排队消息、回到前台时使用;控制流推送丢失时靠它兜底):
|
|
627
|
+
|
|
628
|
+
→ { "type": "session-queue", "sessionId": "session-abc", "requestId": "rq-1" }
|
|
629
|
+
← { "kind": "session-queue", "sessionId": "session-abc", "items": [...], "requestId": "rq-1" }
|
|
630
|
+
|
|
631
|
+
网关直接读取 Host 的 projections.values.inbox 生成 items;旧版 Host 没有该投影时返回空数组。
|
|
625
632
|
```
|
|
626
633
|
|
|
627
634
|
- `session-queues.queues` 是全量快照,客户端必须整体替换所有 Session 的本地队列;快照里消失的 Session 也要清除。
|
package/README.md
CHANGED
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
`dsh-plugin-weapp-gateway` · DeepSeek Harness 移动客户端连接插件
|
|
8
8
|
|
|
9
|
+
### v0.8.52 · 兼容 App 下拉与方案摘要之间留出间距
|
|
10
|
+
|
|
11
|
+
- 「兼容 App(备用)」的连接方式下拉与下方「配对入口」摘要卡片之间增加间距(16px),下拉不再紧贴提示卡片。
|
|
12
|
+
- 摘要卡片的内边距、下方「配对入口地址」输入框与其余配对布局保持不变。
|
|
13
|
+
- 全量测试通过。
|
|
9
14
|
### v0.8.51 · 配对面板细节打磨
|
|
10
15
|
|
|
11
16
|
- 小程序模块去掉「鲸尾公网 · 小程序 / 中继优先,局域网兜底」说明行(上方描述文案已含同样信息)。
|
package/lib/client.js
CHANGED
|
@@ -1460,7 +1460,7 @@ window.__ModuleLoader__.load({
|
|
|
1460
1460
|
appLayerOpen
|
|
1461
1461
|
? React.createElement(React.Fragment, null,
|
|
1462
1462
|
React.createElement('p', { style: styles.muted }, '仅用于 DSH App(上游移动网关的直连方式),与上方鲸尾公网互不影响。'),
|
|
1463
|
-
React.createElement('div', { style: { display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '8px 14px', maxWidth: '100%' } },
|
|
1463
|
+
React.createElement('div', { style: { display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '8px 14px', maxWidth: '100%', marginBottom: 16 } },
|
|
1464
1464
|
React.createElement(GatewaySelect, { style: styles.input, value: appRoute, onChange: (event) => chooseAppRoute(event.target.value), disabled: !status, 'aria-label': 'App 连接方式' },
|
|
1465
1465
|
React.createElement('option', { value: 'auto' }, '自动选择'),
|
|
1466
1466
|
React.createElement('option', { value: 'lan', disabled: !lanPairingUrl(status) }, lanPairingUrl(status)
|
|
@@ -1472,7 +1472,7 @@ window.__ModuleLoader__.load({
|
|
|
1472
1472
|
(status && status.lan && status.lan.listening) ? 'Tailscale 私有网络' : 'Tailscale 私有网络 · 请先开启局域网入口'),
|
|
1473
1473
|
React.createElement('option', { value: 'custom' }, '公网或其他手动地址'))),
|
|
1474
1474
|
// 与上游一致的连接方案摘要:配对入口 + 提示。
|
|
1475
|
-
React.createElement('div', { 'aria-label': '当前连接方案', style: { margin: '
|
|
1475
|
+
React.createElement('div', { 'aria-label': '当前连接方案', style: { margin: '0 0 10px', padding: '9px 11px', borderRadius: 10, border: `1px solid ${colors.border}`, background: colors.card, fontSize: 12, lineHeight: 1.7 } },
|
|
1476
1476
|
React.createElement('div', null, React.createElement('strong', null, '配对入口'), ':', appPlan.entry),
|
|
1477
1477
|
React.createElement('div', { style: { color: appPlan.valid ? colors.muted : colors.danger } }, appPlan.note)),
|
|
1478
1478
|
React.createElement('label', { style: styles.label, htmlFor: 'mgw-pair-address' }, appRoute === 'tailscale'
|
package/lib/index.mjs
CHANGED
|
@@ -63,6 +63,7 @@ import { stringifyWireFrame } from './wire-json.mjs'
|
|
|
63
63
|
// { "type": "permission", "sessionId", "name" } -> switch preset via /permission command
|
|
64
64
|
// { "type": "context-usage", "sessionId" } -> tokenUsage + contextPressure projections
|
|
65
65
|
// { "type": "session-stats", "sessionId" } -> sessionStats + tokenUsage projections
|
|
66
|
+
// { "type": "session-queue", "sessionId" } -> queued/steering inbox items (push-loss fallback)
|
|
66
67
|
// (the input-box stats strip source)
|
|
67
68
|
// { "type": "tasks", "sessionId" } -> current todo-list projection
|
|
68
69
|
// { "type": "goal", "sessionId" } -> current goal projection
|
|
@@ -1319,6 +1320,32 @@ function requireSessionId(msg) {
|
|
|
1319
1320
|
return { value: sessionId }
|
|
1320
1321
|
}
|
|
1321
1322
|
|
|
1323
|
+
// DSH rc.1 carries pending messages in the durable inbox projection.
|
|
1324
|
+
// session/control no longer emits a separate queues baseline or queue frames.
|
|
1325
|
+
function inboxQueueItems(value, endpoint) {
|
|
1326
|
+
if (value == null) return []
|
|
1327
|
+
if (typeof value !== 'object' || Array.isArray(value)
|
|
1328
|
+
|| !Array.isArray(value['next-turn']) || !Array.isArray(value['next-step'])) {
|
|
1329
|
+
throw new Error(endpoint + ' returned an invalid inbox projection')
|
|
1330
|
+
}
|
|
1331
|
+
const convert = (messages, target) => messages.map((message) => {
|
|
1332
|
+
if (!message || typeof message !== 'object' || Array.isArray(message)
|
|
1333
|
+
|| typeof message.id !== 'string' || !message.id
|
|
1334
|
+
|| !Array.isArray(message.content)
|
|
1335
|
+
|| !message.source || typeof message.source.kind !== 'string'
|
|
1336
|
+
|| (message.source.rpcId !== undefined && typeof message.source.rpcId !== 'string')) {
|
|
1337
|
+
throw new Error(endpoint + ' returned an invalid inbox message')
|
|
1338
|
+
}
|
|
1339
|
+
return {
|
|
1340
|
+
id: message.id,
|
|
1341
|
+
placement: target === 'next-turn' ? 'queued' : message.source.kind === 'user' ? 'steering' : 'context',
|
|
1342
|
+
...(message.source.rpcId === undefined ? {} : { rpcId: message.source.rpcId }),
|
|
1343
|
+
message: { id: message.id, content: message.content },
|
|
1344
|
+
}
|
|
1345
|
+
})
|
|
1346
|
+
return [...convert(value['next-turn'], 'next-turn'), ...convert(value['next-step'], 'next-step')]
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1322
1349
|
// Goal mutations use DSH's compare-and-set reference. Returning a stale
|
|
1323
1350
|
// revision is intentionally rejected by DSH instead of overwriting a newer
|
|
1324
1351
|
// WebUI/mobile update.
|
|
@@ -1796,6 +1823,30 @@ async function handleQuery(api, host, agentDefaultModel, msg, pluginContext) {
|
|
|
1796
1823
|
if (ACCOUNT_REQUEST_TYPES.has(msg.type)) return handleAccount(api, msg)
|
|
1797
1824
|
if (PLUGIN_REQUEST_TYPES.has(msg.type)) return handlePluginQuery(api, msg, pluginContext)
|
|
1798
1825
|
if (MODEL_CONFIG_REQUEST_TYPES.has(msg.type)) return handleModelConfigQuery(api, msg, { log })
|
|
1826
|
+
if (msg.type === 'session-queue') {
|
|
1827
|
+
// The mini program asks for the queue when it opens a session / sends a queued
|
|
1828
|
+
// message: answer from the durable inbox projection so a dropped control-stream
|
|
1829
|
+
// push can never leave the queue panel permanently empty.
|
|
1830
|
+
const session = requireSessionId(msg)
|
|
1831
|
+
const requestId = typeof msg.requestId === 'string' ? { requestId: msg.requestId } : {}
|
|
1832
|
+
if (session.error) return { ...session.error, ...requestId }
|
|
1833
|
+
if (typeof api.sessions.projections !== 'function') {
|
|
1834
|
+
return { kind: 'session-queue', sessionId: session.value, items: [], ...requestId }
|
|
1835
|
+
}
|
|
1836
|
+
try {
|
|
1837
|
+
const snapshot = await api.sessions.projections({ sessionId: session.value })
|
|
1838
|
+
if (snapshot === null) throw Object.assign(new Error('session not found'), { code: 'session/not-found' })
|
|
1839
|
+
if (!['sequenced', 'migration-required'].includes(snapshot && snapshot.kind) || !snapshot.values) {
|
|
1840
|
+
throw new Error('invalid session projections')
|
|
1841
|
+
}
|
|
1842
|
+
const items = inboxQueueItems(snapshot.values.inbox, 'session-queue request')
|
|
1843
|
+
return { kind: 'session-queue', sessionId: session.value, items, ...requestId }
|
|
1844
|
+
} catch (error) {
|
|
1845
|
+
return { kind: 'error', code: (error && error.code) || 'internal',
|
|
1846
|
+
message: error && error.message ? error.message : String(error),
|
|
1847
|
+
requestType: 'session-queue', sessionId: session.value, ...requestId }
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1799
1850
|
if (msg.type === 'agent-team' || msg.type === 'subagents') {
|
|
1800
1851
|
const target = sessionTargetFromMessage(msg)
|
|
1801
1852
|
const requestIdentity = typeof msg.requestId === 'string' ? { requestId: msg.requestId } : {}
|
|
@@ -4006,7 +4057,7 @@ const plugin = {
|
|
|
4006
4057
|
msg.type === 'clawbot-control' ||
|
|
4007
4058
|
msg.type === 'defaults' || msg.type === 'set-default' ||
|
|
4008
4059
|
msg.type === 'session-stats' || msg.type === 'default-model' ||
|
|
4009
|
-
msg.type === 'save-default-model' || msg.type === 'fork' || msg.type === 'session-cancel' || msg.type === 'queue-update' ||
|
|
4060
|
+
msg.type === 'save-default-model' || msg.type === 'fork' || msg.type === 'session-cancel' || msg.type === 'queue-update' || msg.type === 'session-queue' ||
|
|
4010
4061
|
msg.type === 'session-archive' || msg.type === 'session-rename' || msg.type === 'providers' ||
|
|
4011
4062
|
msg.type === 'tasks' || msg.type === 'goal' || msg.type === 'goal-edit' ||
|
|
4012
4063
|
msg.type === 'goal-pause' || msg.type === 'goal-resume' || msg.type === 'goal-clear' ||
|
|
@@ -4383,31 +4434,7 @@ const plugin = {
|
|
|
4383
4434
|
log(`session archive state forwarded: count=${next.length}`)
|
|
4384
4435
|
}
|
|
4385
4436
|
|
|
4386
|
-
|
|
4387
|
-
// session/control no longer emits a separate queues baseline or queue frames.
|
|
4388
|
-
const queueItemsFromInbox = (value, endpoint) => {
|
|
4389
|
-
if (value == null) return []
|
|
4390
|
-
if (typeof value !== 'object' || Array.isArray(value)
|
|
4391
|
-
|| !Array.isArray(value['next-turn']) || !Array.isArray(value['next-step'])) {
|
|
4392
|
-
throw new Error(`${endpoint} returned an invalid inbox projection`)
|
|
4393
|
-
}
|
|
4394
|
-
const convert = (messages, target) => messages.map((message) => {
|
|
4395
|
-
if (!message || typeof message !== 'object' || Array.isArray(message)
|
|
4396
|
-
|| typeof message.id !== 'string' || !message.id
|
|
4397
|
-
|| !Array.isArray(message.content)
|
|
4398
|
-
|| !message.source || typeof message.source.kind !== 'string'
|
|
4399
|
-
|| (message.source.rpcId !== undefined && typeof message.source.rpcId !== 'string')) {
|
|
4400
|
-
throw new Error(`${endpoint} returned an invalid inbox message`)
|
|
4401
|
-
}
|
|
4402
|
-
return {
|
|
4403
|
-
id: message.id,
|
|
4404
|
-
placement: target === 'next-turn' ? 'queued' : message.source.kind === 'user' ? 'steering' : 'context',
|
|
4405
|
-
...(message.source.rpcId === undefined ? {} : { rpcId: message.source.rpcId }),
|
|
4406
|
-
message: { id: message.id, content: message.content },
|
|
4407
|
-
}
|
|
4408
|
-
})
|
|
4409
|
-
return [...convert(value['next-turn'], 'next-turn'), ...convert(value['next-step'], 'next-step')]
|
|
4410
|
-
}
|
|
4437
|
+
const queueItemsFromInbox = inboxQueueItems
|
|
4411
4438
|
|
|
4412
4439
|
const installSessionQueueBaseline = (projections) => {
|
|
4413
4440
|
if (!projections || typeof projections !== 'object' || Array.isArray(projections)) {
|