dsh-mobile-plugin 0.5.33 → 0.5.35
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 +17 -2
- package/dsh-mobile-credentials/lib/credentials.js +49 -2
- package/extensions/README.md +25 -21
- package/host.js +16 -1
- package/lib/git/pr.js +375 -0
- package/lib/git/read.js +1 -0
- package/lib/host-capabilities.cjs +67 -0
- package/lib/http/routing.js +25 -0
- package/lib/impl.js +34 -26
- package/lib/mirror/history-blob.cjs +184 -0
- package/lib/mirror/pusher.cjs +276 -1
- package/lib/mobile/approval-facts.js +439 -0
- package/lib/mobile/approval-memory.js +199 -0
- package/lib/mobile/approvals.js +596 -30
- package/lib/mobile/auto-review-log.js +160 -0
- package/lib/mobile/auto-review.js +172 -0
- package/lib/mobile/credential-upgrade.js +14 -0
- package/lib/mobile/device-permissions.js +86 -0
- package/lib/mobile/directory-browse.js +23 -8
- package/lib/mobile/events.js +9 -1
- package/lib/mobile/extension-catalog.js +106 -44
- package/lib/mobile/extension-data.js +6 -0
- package/lib/mobile/file-ops.js +89 -76
- package/lib/mobile/git.js +108 -2
- package/lib/mobile/live-steps.js +107 -4
- package/lib/mobile/mail.js +621 -0
- package/lib/mobile/monitor.js +6 -0
- package/lib/mobile/notification-prefs.js +205 -0
- package/lib/mobile/pairing.js +15 -2
- package/lib/mobile/permissions.js +433 -0
- package/lib/mobile/project-write-queue.js +115 -0
- package/lib/mobile/project-writes.js +61 -0
- package/lib/mobile/push-notify.js +293 -13
- package/lib/mobile/questions.js +20 -3
- package/lib/mobile/recent-failures.js +48 -0
- package/lib/mobile/relay-control.js +5 -0
- package/lib/mobile/session-cache.js +50 -0
- package/lib/mobile/session-last-turn.js +24 -22
- package/lib/mobile/session-new.js +205 -0
- package/lib/mobile/session-send.js +0 -1
- package/lib/mobile/sessions.js +12 -84
- package/lib/mobile/skill-write.js +549 -0
- package/lib/mobile/stats-collect.cjs +33 -3
- package/lib/mobile/stats-ledger.cjs +39 -2
- package/lib/mobile/stream.js +24 -3
- package/lib/mobile/supervisor-broadcast.js +58 -11
- package/lib/mobile/supervisor-tools.js +1 -1
- package/lib/mobile/third-party-extensions.js +158 -0
- package/lib/mobile/uploads.js +30 -14
- package/lib/mobile/worktree-isolation.js +479 -0
- package/lib/mobile/worktree-lifecycle.js +79 -0
- package/lib/p2p/wiring.cjs +41 -16
- package/lib/panel/index.html +15 -15
- package/lib/read-receipt.cjs +89 -5
- package/lib/relay/core.js +25 -1
- package/lib/relay/lan-proxy.js +6 -1
- package/lib/relay/preview.js +21 -1
- package/lib/relay/protocol.js +1 -0
- package/lib/relay/status.js +6 -0
- package/lib/relay/tunnel-forwarder.cjs +178 -0
- package/lib/routes/control-plane.js +35 -1
- package/lib/routes/mobile-api.js +105 -52
- package/lib/shared/via-header.js +15 -2
- package/lib/sidecar-facade-worker.cjs +15 -2
- package/lib/sidecar-facade.cjs +5 -0
- package/lib/tailcat/host-process.cjs +1 -1
- package/lib/tailcat/ingress.cjs +2 -2
- package/lib/tailcat/wiring.cjs +34 -13
- package/package.json +11 -3
- package/assets/pets/README.md +0 -9
- package/assets/pets/deepy-whale/attention.gif +0 -0
- package/assets/pets/deepy-whale/done.gif +0 -0
- package/assets/pets/deepy-whale/error.gif +0 -0
- package/assets/pets/deepy-whale/idle.gif +0 -0
- package/assets/pets/deepy-whale/pack.json +0 -54
- package/assets/pets/deepy-whale/sleeping.gif +0 -0
- package/assets/pets/deepy-whale/working-3.gif +0 -0
- package/assets/pets/deepy-whale/working.gif +0 -0
- package/knowledge/apps/alipay.md +0 -30
- package/knowledge/apps/android-settings.md +0 -30
- package/knowledge/apps/baijiahao.md +0 -30
- package/knowledge/apps/bilibili.md +0 -31
- package/knowledge/apps/boss-zhipin.md +0 -32
- package/knowledge/apps/dedao.md +0 -33
- package/knowledge/apps/douyin.md +0 -32
- package/knowledge/apps/feishu.md +0 -35
- package/knowledge/apps/gmail.md +0 -33
- package/knowledge/apps/jike.md +0 -31
- package/knowledge/apps/kuaishou.md +0 -34
- package/knowledge/apps/linkedin.md +0 -33
- package/knowledge/apps/qqmail.md +0 -30
- package/knowledge/apps/taobao.md +0 -33
- package/knowledge/apps/telegram.md +0 -27
- package/knowledge/apps/toutiao.md +0 -32
- package/knowledge/apps/uber-eats.md +0 -26
- package/knowledge/apps/uber.md +0 -27
- package/knowledge/apps/wechat.md +0 -33
- package/knowledge/apps/weibo.md +0 -31
- package/knowledge/apps/whatsapp.md +0 -27
- package/knowledge/apps/x.md +0 -32
- package/knowledge/apps/xiaohongshu.md +0 -30
- package/knowledge/apps/zhihu.md +0 -31
- package/knowledge/sites/bilibili.com/SITE.md +0 -50
- package/knowledge/sites/bilibili.com/references/view-fields.md +0 -17
- package/knowledge/sites/github.com/SITE.md +0 -51
- package/knowledge/sites/github.com/references/repo-fields.md +0 -13
- package/knowledge/sites/x.com/SITE.md +0 -47
- package/knowledge/sites/xiaohongshu.com/SITE.md +0 -48
- package/knowledge/sites/xiaohongshu.com/references/note-fields.md +0 -18
- package/knowledge/sites/youtube.com/SITE.md +0 -49
- package/knowledge/sites/youtube.com/references/innertube-fields.md +0 -14
- package/knowledge/sites/zhihu.com/SITE.md +0 -47
- package/knowledge/sites/zhihu.com/references/api-fields.md +0 -21
- package/lib/mobile/pet-tools.js +0 -261
- package/lib/mobile/pets.js +0 -755
- package/lib/mobile/phone/access.js +0 -85
- package/lib/mobile/phone/binding.js +0 -247
- package/lib/mobile/phone/confirm.js +0 -189
- package/lib/mobile/phone/evidence.js +0 -228
- package/lib/mobile/phone/gate.js +0 -290
- package/lib/mobile/phone/grounding.js +0 -314
- package/lib/mobile/phone/guard.js +0 -465
- package/lib/mobile/phone/index.js +0 -83
- package/lib/mobile/phone/irreversible.js +0 -226
- package/lib/mobile/phone/knowledge-tools.js +0 -665
- package/lib/mobile/phone/learn.js +0 -329
- package/lib/mobile/phone/pacing.js +0 -173
- package/lib/mobile/phone/redact.js +0 -237
- package/lib/mobile/phone/risk.js +0 -95
- package/lib/mobile/phone/route-hint.js +0 -164
- package/lib/mobile/phone/routes-memory.js +0 -133
- package/lib/mobile/phone/routes.js +0 -279
- package/lib/mobile/phone/service.js +0 -500
- package/lib/mobile/phone/site-commands.js +0 -271
- package/lib/mobile/phone/step-summary.js +0 -201
- package/lib/mobile/phone/stop-summary.js +0 -235
- package/lib/mobile/phone/tool-groups.js +0 -125
- package/lib/mobile/phone/tools.js +0 -2282
- package/lib/mobile/phone/untrusted.js +0 -65
- package/lib/mobile/phone-knowledge.js +0 -317
- package/lib/mobile/wechat-tools.js +0 -257
- package/lib/mobile/wechat.js +0 -514
package/lib/mobile/live-steps.js
CHANGED
|
@@ -22,13 +22,98 @@ const MAX_SESSIONS = 4;
|
|
|
22
22
|
/** 单段文本的上限:详情是给人看的,超长输出照旧截断,别把一份 20MB 的结果塞回手机。 */
|
|
23
23
|
const TEXT_MAX = 200_000;
|
|
24
24
|
|
|
25
|
-
const { liveStepTurnOf } = require('./session-cache.js');
|
|
25
|
+
const { liveStepTurnOf, liveStepWriterOf, liveStepSinkOf } = require('./session-cache.js');
|
|
26
26
|
const { reasoningText, reasoningStepSummary, toolStepSummary } = require('./step-index.js');
|
|
27
27
|
|
|
28
28
|
function bucketOf(ctx) {
|
|
29
29
|
return liveStepTurnOf(ctx);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* 「谁在往这条会话的直播副本里写」。
|
|
34
|
+
*
|
|
35
|
+
* 直播副本是**进程级、按会话共享**的一份:电脑上这条会话跑着的时候,任何一条连进来的
|
|
36
|
+
* `/session/stream` 都会把收到的增量喂进来。而同一条会话**可能同时有不止一条流**(同一个
|
|
37
|
+
* 聊天页被开着两屏——屏栈下层是保留挂载的;或重连那一刻旧连接还没在电脑这头断干净)。
|
|
38
|
+
* 若每条流都往里写,每段推理就会被接两遍,用户点开「思考」看到的是逐 token 翻倍的正文
|
|
39
|
+
* (`TheThe proxy proxy …`)。所以定一条规矩:**同一会话只认一个写入者**,它关掉之后下一个
|
|
40
|
+
* 连进来的流再接棒。其余流只读(`liveStepOf` / `liveStepsOf` 照常能读,正文不会翻倍)。
|
|
41
|
+
*
|
|
42
|
+
* 归属按 `ctx` 分(与 `liveStepTurnOf` 同一把钥匙),换轮(`turn/start` 清桶)不动它——
|
|
43
|
+
* 还是那条流在写。表本身住在 `session-cache`(模块级可变状态只能在那里)。
|
|
44
|
+
*/
|
|
45
|
+
function claimLiveWriter(ctx, sessionId, writerId) {
|
|
46
|
+
if (!ctx || typeof sessionId !== 'string' || !sessionId) return false;
|
|
47
|
+
if (typeof writerId !== 'string' || !writerId) return false;
|
|
48
|
+
const map = liveStepWriterOf(ctx);
|
|
49
|
+
const owner = map.get(sessionId);
|
|
50
|
+
if (owner !== undefined && owner !== writerId) return false;
|
|
51
|
+
map.set(sessionId, writerId);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** 释放写入权:只有当前就是自己时才清,避免晚到的旧流把新写入者顶掉。 */
|
|
56
|
+
function releaseLiveWriter(ctx, sessionId, writerId) {
|
|
57
|
+
if (!ctx || typeof sessionId !== 'string' || !sessionId) return;
|
|
58
|
+
const map = liveStepWriterOf(ctx);
|
|
59
|
+
if (map.get(sessionId) === writerId) map.delete(sessionId);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** 这一帧该不该由 `writerId` 写:没带写入者身份时(老调用 / 测试)一律放行。 */
|
|
63
|
+
function writerAllows(ctx, sessionId, writerId) {
|
|
64
|
+
if (writerId === undefined) return true;
|
|
65
|
+
const map = liveStepWriterOf(ctx);
|
|
66
|
+
const owner = map.get(sessionId);
|
|
67
|
+
// 还没人认领:这一条就当写入者认下来(正常由 stream 开流时先认领,这里只是兜底)。
|
|
68
|
+
if (owner === undefined) return claimLiveWriter(ctx, sessionId, writerId);
|
|
69
|
+
return owner === writerId;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 同一会话上开着的各条流(每条一个「收增量」的回调)。
|
|
74
|
+
*
|
|
75
|
+
* 写入者只有一条,但**所有屏都得看见同一份清单**:只读的那条流不会自己去攒,它靠写入者
|
|
76
|
+
* 把 `drainLiveSteps` 取到的那几步广播过来。少了这一程,第二屏的「过程 · 已跑 N 步」会一直
|
|
77
|
+
* 停在自己连上那一刻。
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* 挂上一条流,返回摘钩函数。
|
|
81
|
+
*
|
|
82
|
+
* `sink(frame)` 收到的是**已经算好的**整帧形状(`{ type, sessionId, full, turn, steps }`),
|
|
83
|
+
* 这里不碰 SSE、也不认客户端,只做进程内的转发。
|
|
84
|
+
*/
|
|
85
|
+
function attachLiveSteps(ctx, sessionId, sink) {
|
|
86
|
+
if (!ctx || typeof sessionId !== 'string' || !sessionId || typeof sink !== 'function') return () => {};
|
|
87
|
+
const map = liveStepSinkOf(ctx);
|
|
88
|
+
let set = map.get(sessionId);
|
|
89
|
+
if (!set) {
|
|
90
|
+
set = new Set();
|
|
91
|
+
map.set(sessionId, set);
|
|
92
|
+
}
|
|
93
|
+
set.add(sink);
|
|
94
|
+
return () => {
|
|
95
|
+
const current = map.get(sessionId);
|
|
96
|
+
if (!current) return;
|
|
97
|
+
current.delete(sink);
|
|
98
|
+
if (current.size === 0) map.delete(sessionId);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** 把一步的增量转给这条会话上开着的每一条流(`except` 是写入者自己那份,它已经在按顺序写了)。 */
|
|
103
|
+
function broadcastLiveSteps(ctx, sessionId, frame, except) {
|
|
104
|
+
if (!ctx || typeof sessionId !== 'string' || !sessionId) return;
|
|
105
|
+
const set = liveStepSinkOf(ctx).get(sessionId);
|
|
106
|
+
if (!set) return;
|
|
107
|
+
for (const sink of set) {
|
|
108
|
+
if (sink === except) continue;
|
|
109
|
+
try {
|
|
110
|
+
sink(frame);
|
|
111
|
+
} catch {
|
|
112
|
+
/* 一条流写失败不该连累别的流(它自己那条连接会按写失败收尾) */
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
32
117
|
function turnOf(ctx, sessionId) {
|
|
33
118
|
const bucket = bucketOf(ctx);
|
|
34
119
|
let turn = bucket.get(sessionId);
|
|
@@ -177,9 +262,12 @@ function resultParts(message) {
|
|
|
177
262
|
* 只有这几类事件有料:工具参数增量、推理增量、块边界、助手消息、工具结果、回合结束。
|
|
178
263
|
* 其余一概忽略。
|
|
179
264
|
*/
|
|
180
|
-
function noteLiveEvent(ctx, sessionId, event) {
|
|
265
|
+
function noteLiveEvent(ctx, sessionId, event, writerId) {
|
|
181
266
|
if (!ctx || typeof sessionId !== 'string' || !sessionId) return;
|
|
182
267
|
if (!event || typeof event !== 'object') return;
|
|
268
|
+
// 同一条会话只让一个写入者累加:别的流(多开的一屏 / 重连里还没断干净的旧连接)只读不写,
|
|
269
|
+
// 否则每段推理会被接两遍(见 liveStepWriterOf 那条注释)。
|
|
270
|
+
if (!writerAllows(ctx, sessionId, writerId)) return;
|
|
183
271
|
const data = event.data && typeof event.data === 'object' ? event.data : null;
|
|
184
272
|
if (event.type === 'turn/start') {
|
|
185
273
|
// 新的一轮开始:上一轮的过程副本作废(换掉了,就别再让人点开旧内容)。
|
|
@@ -339,9 +427,11 @@ function liveStepsTurnOf(ctx, sessionId) {
|
|
|
339
427
|
* 取走「还没告诉过手机」的那几步。
|
|
340
428
|
*
|
|
341
429
|
* 每条都是 `{ key, step }`:新的一步就是追加,同一步的状态变化就是按 `key` 替换。
|
|
430
|
+
* 只有写着(writerId 命中)的那条流来取:只读的流取会把写入者该发的增量抢走,让主屏漏步。
|
|
342
431
|
*/
|
|
343
|
-
function drainLiveSteps(ctx, sessionId) {
|
|
432
|
+
function drainLiveSteps(ctx, sessionId, writerId) {
|
|
344
433
|
if (!ctx || typeof sessionId !== 'string' || !sessionId) return [];
|
|
434
|
+
if (!writerAllows(ctx, sessionId, writerId)) return [];
|
|
345
435
|
const turn = liveStepTurnOf(ctx).get(sessionId);
|
|
346
436
|
if (!turn || turn.pending.length === 0) return [];
|
|
347
437
|
const out = turn.pending.slice();
|
|
@@ -384,6 +474,19 @@ function liveStepOf(ctx, sessionId, query) {
|
|
|
384
474
|
/** 丢掉一条会话的直播副本(会话关掉、或者换设备时用)。 */
|
|
385
475
|
function clearLiveSteps(ctx, sessionId) {
|
|
386
476
|
liveStepTurnOf(ctx).delete(sessionId);
|
|
477
|
+
liveStepWriterOf(ctx).delete(sessionId);
|
|
478
|
+
liveStepSinkOf(ctx).delete(sessionId);
|
|
387
479
|
}
|
|
388
480
|
|
|
389
|
-
module.exports = {
|
|
481
|
+
module.exports = {
|
|
482
|
+
noteLiveEvent,
|
|
483
|
+
liveStepOf,
|
|
484
|
+
liveStepsOf,
|
|
485
|
+
liveStepsTurnOf,
|
|
486
|
+
drainLiveSteps,
|
|
487
|
+
clearLiveSteps,
|
|
488
|
+
claimLiveWriter,
|
|
489
|
+
releaseLiveWriter,
|
|
490
|
+
attachLiveSteps,
|
|
491
|
+
broadcastLiveSteps,
|
|
492
|
+
};
|