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.
Files changed (142) hide show
  1. package/README.md +17 -2
  2. package/dsh-mobile-credentials/lib/credentials.js +49 -2
  3. package/extensions/README.md +25 -21
  4. package/host.js +16 -1
  5. package/lib/git/pr.js +375 -0
  6. package/lib/git/read.js +1 -0
  7. package/lib/host-capabilities.cjs +67 -0
  8. package/lib/http/routing.js +25 -0
  9. package/lib/impl.js +34 -26
  10. package/lib/mirror/history-blob.cjs +184 -0
  11. package/lib/mirror/pusher.cjs +276 -1
  12. package/lib/mobile/approval-facts.js +439 -0
  13. package/lib/mobile/approval-memory.js +199 -0
  14. package/lib/mobile/approvals.js +596 -30
  15. package/lib/mobile/auto-review-log.js +160 -0
  16. package/lib/mobile/auto-review.js +172 -0
  17. package/lib/mobile/credential-upgrade.js +14 -0
  18. package/lib/mobile/device-permissions.js +86 -0
  19. package/lib/mobile/directory-browse.js +23 -8
  20. package/lib/mobile/events.js +9 -1
  21. package/lib/mobile/extension-catalog.js +106 -44
  22. package/lib/mobile/extension-data.js +6 -0
  23. package/lib/mobile/file-ops.js +89 -76
  24. package/lib/mobile/git.js +108 -2
  25. package/lib/mobile/live-steps.js +107 -4
  26. package/lib/mobile/mail.js +621 -0
  27. package/lib/mobile/monitor.js +6 -0
  28. package/lib/mobile/notification-prefs.js +205 -0
  29. package/lib/mobile/pairing.js +15 -2
  30. package/lib/mobile/permissions.js +433 -0
  31. package/lib/mobile/project-write-queue.js +115 -0
  32. package/lib/mobile/project-writes.js +61 -0
  33. package/lib/mobile/push-notify.js +293 -13
  34. package/lib/mobile/questions.js +20 -3
  35. package/lib/mobile/recent-failures.js +48 -0
  36. package/lib/mobile/relay-control.js +5 -0
  37. package/lib/mobile/session-cache.js +50 -0
  38. package/lib/mobile/session-last-turn.js +24 -22
  39. package/lib/mobile/session-new.js +205 -0
  40. package/lib/mobile/session-send.js +0 -1
  41. package/lib/mobile/sessions.js +12 -84
  42. package/lib/mobile/skill-write.js +549 -0
  43. package/lib/mobile/stats-collect.cjs +33 -3
  44. package/lib/mobile/stats-ledger.cjs +39 -2
  45. package/lib/mobile/stream.js +24 -3
  46. package/lib/mobile/supervisor-broadcast.js +58 -11
  47. package/lib/mobile/supervisor-tools.js +1 -1
  48. package/lib/mobile/third-party-extensions.js +158 -0
  49. package/lib/mobile/uploads.js +30 -14
  50. package/lib/mobile/worktree-isolation.js +479 -0
  51. package/lib/mobile/worktree-lifecycle.js +79 -0
  52. package/lib/p2p/wiring.cjs +41 -16
  53. package/lib/panel/index.html +15 -15
  54. package/lib/read-receipt.cjs +89 -5
  55. package/lib/relay/core.js +25 -1
  56. package/lib/relay/lan-proxy.js +6 -1
  57. package/lib/relay/preview.js +21 -1
  58. package/lib/relay/protocol.js +1 -0
  59. package/lib/relay/status.js +6 -0
  60. package/lib/relay/tunnel-forwarder.cjs +178 -0
  61. package/lib/routes/control-plane.js +35 -1
  62. package/lib/routes/mobile-api.js +105 -52
  63. package/lib/shared/via-header.js +15 -2
  64. package/lib/sidecar-facade-worker.cjs +15 -2
  65. package/lib/sidecar-facade.cjs +5 -0
  66. package/lib/tailcat/host-process.cjs +1 -1
  67. package/lib/tailcat/ingress.cjs +2 -2
  68. package/lib/tailcat/wiring.cjs +34 -13
  69. package/package.json +11 -3
  70. package/assets/pets/README.md +0 -9
  71. package/assets/pets/deepy-whale/attention.gif +0 -0
  72. package/assets/pets/deepy-whale/done.gif +0 -0
  73. package/assets/pets/deepy-whale/error.gif +0 -0
  74. package/assets/pets/deepy-whale/idle.gif +0 -0
  75. package/assets/pets/deepy-whale/pack.json +0 -54
  76. package/assets/pets/deepy-whale/sleeping.gif +0 -0
  77. package/assets/pets/deepy-whale/working-3.gif +0 -0
  78. package/assets/pets/deepy-whale/working.gif +0 -0
  79. package/knowledge/apps/alipay.md +0 -30
  80. package/knowledge/apps/android-settings.md +0 -30
  81. package/knowledge/apps/baijiahao.md +0 -30
  82. package/knowledge/apps/bilibili.md +0 -31
  83. package/knowledge/apps/boss-zhipin.md +0 -32
  84. package/knowledge/apps/dedao.md +0 -33
  85. package/knowledge/apps/douyin.md +0 -32
  86. package/knowledge/apps/feishu.md +0 -35
  87. package/knowledge/apps/gmail.md +0 -33
  88. package/knowledge/apps/jike.md +0 -31
  89. package/knowledge/apps/kuaishou.md +0 -34
  90. package/knowledge/apps/linkedin.md +0 -33
  91. package/knowledge/apps/qqmail.md +0 -30
  92. package/knowledge/apps/taobao.md +0 -33
  93. package/knowledge/apps/telegram.md +0 -27
  94. package/knowledge/apps/toutiao.md +0 -32
  95. package/knowledge/apps/uber-eats.md +0 -26
  96. package/knowledge/apps/uber.md +0 -27
  97. package/knowledge/apps/wechat.md +0 -33
  98. package/knowledge/apps/weibo.md +0 -31
  99. package/knowledge/apps/whatsapp.md +0 -27
  100. package/knowledge/apps/x.md +0 -32
  101. package/knowledge/apps/xiaohongshu.md +0 -30
  102. package/knowledge/apps/zhihu.md +0 -31
  103. package/knowledge/sites/bilibili.com/SITE.md +0 -50
  104. package/knowledge/sites/bilibili.com/references/view-fields.md +0 -17
  105. package/knowledge/sites/github.com/SITE.md +0 -51
  106. package/knowledge/sites/github.com/references/repo-fields.md +0 -13
  107. package/knowledge/sites/x.com/SITE.md +0 -47
  108. package/knowledge/sites/xiaohongshu.com/SITE.md +0 -48
  109. package/knowledge/sites/xiaohongshu.com/references/note-fields.md +0 -18
  110. package/knowledge/sites/youtube.com/SITE.md +0 -49
  111. package/knowledge/sites/youtube.com/references/innertube-fields.md +0 -14
  112. package/knowledge/sites/zhihu.com/SITE.md +0 -47
  113. package/knowledge/sites/zhihu.com/references/api-fields.md +0 -21
  114. package/lib/mobile/pet-tools.js +0 -261
  115. package/lib/mobile/pets.js +0 -755
  116. package/lib/mobile/phone/access.js +0 -85
  117. package/lib/mobile/phone/binding.js +0 -247
  118. package/lib/mobile/phone/confirm.js +0 -189
  119. package/lib/mobile/phone/evidence.js +0 -228
  120. package/lib/mobile/phone/gate.js +0 -290
  121. package/lib/mobile/phone/grounding.js +0 -314
  122. package/lib/mobile/phone/guard.js +0 -465
  123. package/lib/mobile/phone/index.js +0 -83
  124. package/lib/mobile/phone/irreversible.js +0 -226
  125. package/lib/mobile/phone/knowledge-tools.js +0 -665
  126. package/lib/mobile/phone/learn.js +0 -329
  127. package/lib/mobile/phone/pacing.js +0 -173
  128. package/lib/mobile/phone/redact.js +0 -237
  129. package/lib/mobile/phone/risk.js +0 -95
  130. package/lib/mobile/phone/route-hint.js +0 -164
  131. package/lib/mobile/phone/routes-memory.js +0 -133
  132. package/lib/mobile/phone/routes.js +0 -279
  133. package/lib/mobile/phone/service.js +0 -500
  134. package/lib/mobile/phone/site-commands.js +0 -271
  135. package/lib/mobile/phone/step-summary.js +0 -201
  136. package/lib/mobile/phone/stop-summary.js +0 -235
  137. package/lib/mobile/phone/tool-groups.js +0 -125
  138. package/lib/mobile/phone/tools.js +0 -2282
  139. package/lib/mobile/phone/untrusted.js +0 -65
  140. package/lib/mobile/phone-knowledge.js +0 -317
  141. package/lib/mobile/wechat-tools.js +0 -257
  142. package/lib/mobile/wechat.js +0 -514
@@ -1,226 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * 不可逆动作判定:纯函数,只回答「这一下点下去是不是收不回来」,不做任何动作。
5
- *
6
- * 给 tools 层做单步提示、给 batch 做熔断用。判据刻意窄:只有 **tap** 且能读到「点的是哪个
7
- * 按钮的文字」才算数。读不到文字(只有 ref、只有坐标而没 target)就判不了,宁可放过也不
8
- * 误判 —— 把整屏文字当成这一下的目标,会把「聊天页里恰好有『删除』两个字」判成删除,
9
- * 那比漏判更烦人(每次点都停下来问)。
10
- *
11
- * ## 从 Mika 借来的三条判据(词表与阈值按我们自己的口径重定,没有照抄)
12
- *
13
- * 1. **订单状态不算动作。** 词前面紧挨着「待」「已」、或后面跟着状态/入口一类的尾巴
14
- * (成功、记录、明细、方式、列表、中心、入口、码、售后),这条词就不是一个可点的动作,
15
- * 而是状态或入口:`待付款`、`付款成功`、`订单记录`、`付款方式` 一律不算。我们只认
16
- * 「这一下点下去会改世界」的那种写法,宁可漏判一次也不把每个列表页都拦下来。
17
- * 2. **优惠金额不算应付金额。** 紧挨着 优惠 / 减 / 抵扣 / 运费 / 券 / 红包 / 已省(或前面带
18
- * 负号)的金额不参与金额核对;否则「满25减3」会被当成「应付 25」。
19
- * 3. **金额与合计识别单列出来。** `payableAmounts` / `hasTotalLabel` / `TOTAL_LABELS` 给
20
- * gate 核对「申报的金额在屏上」用;只有合计/实付/应付/总计/总价/小计/总额这类字样,或带
21
- * 币种/元的数,才算金额。单独一个价格、待遇、区间不是应付金额。
22
- *
23
- * 与 Mika 的差别:Mika 的 `IrreversibleDetector.kt` 六百多行,认回车/组合键/横滑/资源 ID/
24
- * 下拉/拖拽/看图找点等十几种信号;我们只有 tap 的那一条路,其余信号在手机执行器里由
25
- * `ScreenTree` 压平后本来就拿不到。所以这里只搬规则、不搬那六百行:状态前缀/后缀、优惠排除、
26
- * 合计识别这三条最容易被误判的补进来,词表仍用我们自己那份(下单、购买、付款、发送、提交、
27
- * 删除等),阈值(状态尾巴、优惠窗口、英文整词)都按上面重定。
28
- *
29
- * 输出的 kind 仍只有 payment / submit / send / delete / none —— 下单、购买、付款这类收钱的
30
- * 都归 payment(对熔断来说它们是一回事:都花钱)。
31
- */
32
-
33
- /** 只有点屏幕才有「点的是哪个按钮」这回事。 */
34
- const TAP_ACTIONS = new Set(['tap']);
35
-
36
- /**
37
- * 词表按 kind 分组,顺序即优先级:先看样子最重的付款 / 下单,再提交、发送、删除。
38
- * 中文按包含判;纯英文词按单词边界判,免得 order 在 reorder、delete 在 undelete 里误命中。
39
- */
40
- const WORD_TABLE = [
41
- {
42
- kind: 'payment',
43
- words: [
44
- '支付', '付款', '买单', '买單', '下单', '下單', '购买', '購買',
45
- '结算', '結算', '订单', '訂單', '收银台', '收銀台',
46
- 'pay', 'payment', 'order', 'buy', 'purchase', 'checkout',
47
- ],
48
- },
49
- {
50
- kind: 'submit',
51
- words: ['提交', '确认提交', '確認提交', '送出', 'submit'],
52
- },
53
- {
54
- kind: 'send',
55
- words: ['发送', '傳送', '传送', '发布', '發布', '发表', '發表', 'send', 'post'],
56
- },
57
- {
58
- kind: 'delete',
59
- words: ['删除', '刪除', '清空', '移除', 'delete', 'remove', 'clear'],
60
- },
61
- ];
62
-
63
- /** 这些字段可能装着「点的是哪个按钮」的文字;按顺序取,取到非空就用。 */
64
- const LABEL_FIELDS = [
65
- 'text', 'target', 'label', 'name', 'description', 'desc',
66
- 'contentDescription', 'title', 'content', 'value',
67
- ];
68
-
69
- /** 紧挨在词前面时,说明它是一个状态而不是动作:「待付款」「已付款」。 */
70
- const STATUS_PREFIXES = new Set(['待', '已']);
71
-
72
- /** 紧跟在词后面(跳过标点后)时,说明它是状态或入口:「付款成功」「订单记录」「付款方式」。 */
73
- const STATUS_SUFFIXES = ['成功', '记录', '明细', '方式', '列表', '中心', '入口', '码', '售后'];
74
-
75
- /** 合计一类的字样:这后面的数才是应付金额。 */
76
- const TOTAL_LABELS = ['合计', '实付', '应付', '总计', '总价', '小计', '总额', '待付款金额'];
77
-
78
- /** 紧挨在金额前面的优惠一类字样:这类金额不是应付金额。 */
79
- const DISCOUNTS = ['优惠', '减', '抵扣', '运费', '券', '红包', '已省'];
80
- /** 往前看几个字判断是不是优惠金额。 */
81
- const DISCOUNT_WINDOW = 4;
82
-
83
- /** 带币种(¥/¥/$/$)或「元」的金额;小数允许 . 或 , 作分隔。 */
84
- const CURRENCY = /[¥¥$$]\s*(\d+(?:[.,]\d+)?)|(\d+(?:[.,]\d+)?)\s*元/g;
85
-
86
- function isEnglishWord(word) {
87
- return /^[a-z]+$/.test(word);
88
- }
89
-
90
- /** 去掉标点后的后续文字,用来判状态尾巴。 */
91
- function afterWord(text, end) {
92
- return text.slice(end).replace(/^[^\p{L}\p{N}]+/u, '');
93
- }
94
-
95
- /** 这一处词是不是一个「动作」,而不是状态/入口(见文件头第 1 条)。 */
96
- function isActionOccurrence(label, word, index) {
97
- if (index > 0 && STATUS_PREFIXES.has(label[index - 1])) return false;
98
- const rest = afterWord(label, index + word.length);
99
- return !STATUS_SUFFIXES.some((suffix) => rest.startsWith(suffix));
100
- }
101
-
102
- /** 在一个文字里找第一个命中的词,返回 {kind, word} 或 null。 */
103
- function matchLabel(label) {
104
- const lower = label.toLowerCase();
105
- for (const group of WORD_TABLE) {
106
- for (const word of group.words) {
107
- if (isEnglishWord(word)) {
108
- // 英文按整词匹配,避免 order 命中 reorder / preorder。
109
- if (new RegExp(`\\b${word}\\b`, 'i').test(lower)) return { kind: group.kind, word };
110
- continue;
111
- }
112
- // 中文可能有多个出现位置,逐个判是不是动作(跳过「待付款」「付款成功」这类)。
113
- let from = 0;
114
- let index = label.indexOf(word, from);
115
- while (index !== -1) {
116
- if (isActionOccurrence(label, word, index)) return { kind: group.kind, word };
117
- from = index + 1;
118
- index = label.indexOf(word, from);
119
- }
120
- }
121
- }
122
- return null;
123
- }
124
-
125
- /** 从参数里能读到的、像「被点元素文字」的那几条。 */
126
- function labelsOf(args) {
127
- const out = [];
128
- for (const key of LABEL_FIELDS) {
129
- const value = args[key];
130
- if (typeof value === 'string') {
131
- const text = value.trim();
132
- if (text) out.push(text);
133
- }
134
- }
135
- return out;
136
- }
137
-
138
- /** 一个孤零零的短串才可能是按钮文字;长段多行的是整屏,不能当目标。 */
139
- function looksLikeLabel(text) {
140
- const trimmed = text.trim();
141
- if (!trimmed || trimmed.length > 32) return false;
142
- return !/[\r\n]/.test(trimmed);
143
- }
144
-
145
- function none(reason) {
146
- return { irreversible: false, kind: 'none', reason };
147
- }
148
-
149
- /**
150
- * 从一段文字里认出带币种/元的金额(去掉优惠一类、带负号的)。给 gate 核对金额用。
151
- * @returns {number[]} 数字数组
152
- */
153
- function payableAmounts(text) {
154
- if (typeof text !== 'string' || !text) return [];
155
- const out = [];
156
- CURRENCY.lastIndex = 0;
157
- let m;
158
- while ((m = CURRENCY.exec(text)) !== null) {
159
- const raw = (m[1] || m[2] || '').replace(/,/g, '');
160
- const value = Number(raw);
161
- if (!Number.isFinite(value)) continue;
162
- const before = text.slice(Math.max(0, m.index - DISCOUNT_WINDOW), m.index);
163
- if (DISCOUNTS.some((w) => before.includes(w))) continue;
164
- if (before.trimEnd().endsWith('-')) continue;
165
- out.push(value);
166
- }
167
- return out;
168
- }
169
-
170
- /** 这段文字里有没有「合计/实付/应付/总计…」这类字样(金额核对是否绑定用它)。 */
171
- function hasTotalLabel(text) {
172
- if (typeof text !== 'string' || !text) return false;
173
- return TOTAL_LABELS.some((label) => text.includes(label));
174
- }
175
-
176
- /**
177
- * judge({ action, args, screenText }) → { irreversible, kind, reason }。
178
- *
179
- * `screenText` 只在「既没 ref / 坐标、也没有任何文字字段」且它本身像个按钮短串时才当目标文字;
180
- * 有 ref 或坐标却没有文字时一律判不了 —— 这是「ref 点按不误判」那条要求的落点。
181
- */
182
- function judge(input) {
183
- const { action, args, screenText } = input || {};
184
- const a = args && typeof args === 'object' ? args : {};
185
-
186
- if (typeof action !== 'string' || !TAP_ACTIONS.has(action)) {
187
- return none('只判 tap:别的动作没有「点的是哪个按钮」这回事');
188
- }
189
-
190
- const hasRef = typeof a.ref === 'string' && a.ref.trim() !== '';
191
- const hasPoint = Number.isFinite(a.x) && Number.isFinite(a.y);
192
- let labels = labelsOf(a);
193
-
194
- if (labels.length === 0) {
195
- if (hasRef || hasPoint) {
196
- return none('只有 ref / 坐标、没有说话文字,判定不了');
197
- }
198
- if (typeof screenText === 'string' && looksLikeLabel(screenText)) {
199
- labels = [screenText.trim()];
200
- }
201
- }
202
-
203
- if (labels.length === 0) return none('没有可判的文字');
204
-
205
- for (const label of labels) {
206
- const hit = matchLabel(label);
207
- if (hit) {
208
- return {
209
- irreversible: true,
210
- kind: hit.kind,
211
- reason: `「${label}」命中不可逆词「${hit.word}」`,
212
- };
213
- }
214
- }
215
- return none('没有命中不可逆词表');
216
- }
217
-
218
- module.exports = {
219
- judge,
220
- // 下面几个给守卫和 gate 直接用真值表,不重复实现匹配逻辑。
221
- WORD_TABLE,
222
- matchLabel,
223
- payableAmounts,
224
- hasTotalLabel,
225
- TOTAL_LABELS,
226
- };