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,261 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * 给模型的两个工具:看一眼这台电脑上有哪些宠物包、做一只新的(或者改现有的)。
5
- *
6
- * ## 为什么要有工具
7
- *
8
- * 宠物包是「一个目录 + 一份 pack.json + 几张图」,而素材基本都已经是电脑上的图片文件了。
9
- * 让模型自己往目录里写,它记不住放哪儿、id 什么形状、状态键叫什么;写完还得自己回一句
10
- * 「好了」,用户那边刷半天也不一定看得到。工具负责的正是这几件它记不住的事。
11
- *
12
- * ## 为什么不收 base64 为主
13
- *
14
- * 与公众号那条同一个理由:让模型把几 MB 的图抄进工具参数,抄不动也抄不对。它手里真有的是
15
- * 「那张图在这台电脑上的路径」,所以 `filePath` 是主路,`base64` 只在它手上真有字节时兜底。
16
- *
17
- * ## 能力面的边界
18
- *
19
- * 只碰这个库:id 形状卡死、图片只认单层 `.gif` / `.png`、单张与整包都有上限。**没有删除** ——
20
- * 删是人的动作(设置页那边有个按钮),不该由模型顺手做掉。
21
- *
22
- * `pack` 整份透传给 `writePack`,不在工具这一层做字段白名单:包格式以后加可选字段(彩蛋 /
23
- * 时序 / 待机池 / 点按反应 / 命中框…)时,工具这边不用跟着改一遍。判据只有一处,在 pets.js。
24
- */
25
-
26
- const { defineTool } = require('@deepseek-ai/dsh-tools');
27
-
28
- const {
29
- listPacks,
30
- writePack,
31
- isImageName,
32
- ID_RE,
33
- KNOWN_STATES,
34
- } = require('./pets.js');
35
-
36
- /** 列表里一行一只:名字、id、内置还是自己做的、状态齐不齐。 */
37
- function packLine(pack) {
38
- const tags = [pack.builtin ? '内置' : '自己做的'];
39
- tags.push(`id ${pack.id}`);
40
- // `pack.states` 到这一层已经是状态名数组(execute 那步折过),按名字查键永远是 undefined。
41
- const missing = KNOWN_STATES.filter((state) => state !== 'sleeping' && !pack.states.includes(state));
42
- tags.push(missing.length === 0 ? '五个状态都有' : `缺 ${missing.join(' / ')}(将回退到 idle)`);
43
- if (pack.author) tags.push(pack.author);
44
- return `· 《${pack.name}》${tags.join(',')}`;
45
- }
46
-
47
- /**
48
- * 注册这两个工具。
49
- *
50
- * 必须走 `ctx.inject(['tools'], …)`:宿主里 `tools` 是子代理作用域提供的服务,插件这一层
51
- * 直接读 `ctx.tools` 拿到的常常是 undefined(见 `phone/tools.js` 那一整段教训)。缺失时
52
- * 静默跳过,别把整块装配掀掉。
53
- */
54
- function installPetTools(ctx) {
55
- if (typeof ctx.inject !== 'function') return;
56
- try {
57
- ctx.inject(['tools'], mountTools);
58
- } catch (error) {
59
- // 没有 tools 注入的 profile(cordis 抛 "… without inject"):只少这两个工具,包目录与
60
- // 三条路由照常可用。其余错误照抛 —— 别把真的注册失败也当成「这个 profile 没注入」。
61
- const message = error && error.message ? error.message : String(error);
62
- if (!message.includes('without inject')) throw error;
63
- }
64
- }
65
-
66
- /** `ctx.inject` 的回调体。单独拎出来只为让上面那层 try/catch 短一点。 */
67
- function mountTools(scoped) {
68
- if (!scoped || !scoped.tools || typeof scoped.tools.register !== 'function') return;
69
-
70
- scoped.tools.register(defineTool({
71
- name: 'pet_pack_list',
72
- description: 'List the desktop-pet packages on this computer: the built-in ones that ship with the app, plus any the user made. Each line gives the id, name, whether it is built-in, and which animation states it has. Use this when the user asks what pets they have or what their pet looks like, and before writing a pack so you pick an id that is free.',
73
- parameters: {},
74
- output: {
75
- schema: {
76
- type: 'object',
77
- additionalProperties: false,
78
- properties: {
79
- packs: {
80
- type: 'array',
81
- required: true,
82
- items: {
83
- type: 'object',
84
- additionalProperties: false,
85
- properties: {
86
- id: { type: 'string' },
87
- name: { type: 'string' },
88
- builtin: { type: 'boolean' },
89
- states: { type: 'array', items: { type: 'string' } },
90
- },
91
-
92
- },
93
- },
94
- },
95
- },
96
- render: (_args, value) => {
97
- const packs = Array.isArray(value.packs) ? value.packs : [];
98
- return [{
99
- type: 'text',
100
- text: packs.length === 0
101
- ? '这台电脑上一个宠物包都还没有。用户想做一只的话,用 pet_pack_write 建一个。'
102
- : `这台电脑上有 ${packs.length} 只:\n${packs.map(packLine).join('\n')}`,
103
- }];
104
- },
105
- },
106
- execute: async () => ({
107
- packs: listPacks().map((pack) => ({
108
- id: pack.id,
109
- name: pack.name,
110
- builtin: pack.builtin,
111
- states: Object.keys(pack.states),
112
- })),
113
- }),
114
- }));
115
-
116
- scoped.tools.register(defineTool({
117
- name: 'pet_pack_write',
118
- description: 'Create or replace a desktop-pet package on this computer, so it shows up on the user\'s phone under Settings → floating pet. Use this whenever the user wants to change their pet, make a new one, or drop in their own artwork. A pack is one directory with a pack.json plus the images it references. States are idle / working / attention / done / error / sleeping (plus optional thinking / juggling / sweeping / carrying / waking / notification), and idle is required; a state you leave out falls back to idle. Pictures are GIF (animated) or PNG (static). Give each picture the PATH of the file on this computer — the host reads it — rather than its bytes; base64 is only for when you already hold the bytes. Optional richer fields: bonus (an Easter egg per state), timings (minDisplay / autoReturn), idlePool (random idle extras), reactions (tap / tickle / drag art), hitBoxes (with wideAnims / sleepingAnims), roam ({anim, faces}), sleep ({afterMs}), tiers.juggling, pixelArt, scale, contentBox, source. Existing packs with the same id are replaced wholesale, including a built-in one (warn the user before doing that). You cannot delete packs; that is the user\'s job in Settings.',
119
- parameters: {
120
- id: {
121
- type: 'string',
122
- description: 'Pack id, also the folder name: 1-64 lowercase letters, digits and dashes, not starting with a dash, e.g. deepy-whale.',
123
- },
124
- pack: {
125
- type: 'object',
126
- additionalProperties: true,
127
- description: 'The whole pack.json as an object. Required keys: name and states (with at least idle). Optional: author, license, source, pixelArt, scale, canvas {w,h}, anchor {x,baseline}, contentBox {x,y,w,h}, tiers.working / tiers.juggling [{min,file}] (largest min wins), loop [], sleepAfterMs (or the nested sleep.afterMs), bonus {state:{anims:[file],chance}}, timings {minDisplay:{state:ms},autoReturn:{state:ms}}, idlePool {everyMs:{mean,min,max},anims:[{file,ms,weight}]}, reactions {tapLeft,tapRight,tickle,drag}, hitBoxes {default,wide,sleeping,byAnim:{anim:{x,y,w,h}},wideAnims:[...],sleepingAnims:[...]}, roam {anim,faces:left|right|front}. Every file named here must be one you pass in files[].',
128
- properties: {
129
- name: { type: 'string', description: 'Shown in the picker on the phone.' },
130
- author: { type: 'string', description: 'Credited in the picker footer. Fill it in whenever the artwork is not yours.' },
131
- license: { type: 'string', description: 'License note, shown next to the author.' },
132
- source: { type: 'string', description: 'Where the artwork came from, shown in the picker footer.' },
133
- pixelArt: { type: 'boolean', description: 'Nearest-neighbour scaling. Default true.' },
134
- scale: { type: 'number', description: 'Sheet pixels per art pixel, e.g. 5 for a 5x export.' },
135
- contentBox: {
136
- type: 'object',
137
- additionalProperties: true,
138
- description: 'The idle body in art pixels {x,y,w,h}: the hit box and where bubbles sit.',
139
- },
140
- states: {
141
- type: 'object',
142
- additionalProperties: true,
143
- description: 'State name → { file }. Recognised: idle, working, attention, done, error, sleeping, plus the optional thinking / juggling / sweeping / carrying / waking / notification. At least idle is required.',
144
- },
145
- tiers: {
146
- type: 'object',
147
- additionalProperties: true,
148
- description: 'Optional. tiers.working / tiers.juggling are [{min, file}]: pick the image by how many conversations (or sub-agents) are running.',
149
- },
150
- loop: { type: 'array', items: { type: 'string' }, description: 'States that loop. Defaults to idle, working, attention.' },
151
- sleepAfterMs: { type: 'number', description: 'Idle time before switching to sleeping. Only meaningful when the sleeping state exists.' },
152
- bonus: {
153
- type: 'object',
154
- additionalProperties: true,
155
- description: 'Optional Easter egg: state → { anims: [file], chance: 0..1 }. An extra animation played instead of the state main art when the dice hit.',
156
- },
157
- timings: {
158
- type: 'object',
159
- additionalProperties: true,
160
- description: 'Optional { minDisplay: {state: ms}, autoReturn: {state: ms} }: how long a one-off state stays up and when it folds back.',
161
- },
162
- idlePool: {
163
- type: 'object',
164
- additionalProperties: true,
165
- description: 'Optional { everyMs: {mean,min,max}, anims: [{file,ms,weight}] }: random small idle animations while nothing is happening.',
166
- },
167
- reactions: {
168
- type: 'object',
169
- additionalProperties: true,
170
- description: 'Optional { tapLeft, tapRight, tickle, drag }: the animation played for each touch gesture, each a file in this pack.',
171
- },
172
- hitBoxes: {
173
- type: 'object',
174
- additionalProperties: true,
175
- description: 'Optional { default, wide, sleeping, byAnim: { anim: {x,y,w,h} }, wideAnims: [anim], sleepingAnims: [anim] } in art pixels: where the window takes touches. The host picks byAnim → sleepingAnims → wideAnims → default.',
176
- },
177
- roam: {
178
- type: 'object',
179
- additionalProperties: true,
180
- description: 'Optional { anim, faces }: the walking animation and which way it looks (left / right / front). anim must be a file in this pack.',
181
- },
182
- sleep: {
183
- type: 'object',
184
- additionalProperties: true,
185
- description: 'Optional { afterMs }: idle time before sleeping. The top-level sleepAfterMs is the older spelling; both are accepted.',
186
- },
187
- },
188
- },
189
- files: {
190
- type: 'array',
191
- description: 'The images this pack uses. Each one is written into the pack folder under that name.',
192
- items: {
193
- type: 'object',
194
- additionalProperties: false,
195
- properties: {
196
- path: { type: 'string', required: true, description: 'File name inside the pack, e.g. idle.gif. Single level, .gif or .png, no slashes.' },
197
- filePath: { type: 'string', description: 'Absolute path of the picture on this computer. This is the normal way.' },
198
- base64: { type: 'string', description: 'The image bytes, base64 encoded. Only when you already hold the bytes and have no file to point at.' },
199
- },
200
- },
201
- },
202
- },
203
- output: {
204
- schema: {
205
- type: 'object',
206
- additionalProperties: false,
207
- properties: {
208
- id: { type: 'string', required: true },
209
- name: { type: 'string', required: true },
210
- states: { type: 'array', items: { type: 'string' } },
211
- written: { type: 'array', items: { type: 'string' } },
212
- note: { type: 'string' },
213
- },
214
- },
215
- render: (_args, value) => {
216
- const lines = [`《${value.name}》存好了,id ${value.id},状态:${(value.states || []).join(' / ') || 'idle'}。`];
217
- if (Array.isArray(value.written) && value.written.length > 0) lines.push(`图片已存:${value.written.join('、')}。`);
218
- if (value.note) lines.push(value.note);
219
- return [{ type: 'text', text: lines.join('\n') }];
220
- },
221
- },
222
- execute: async (args) => {
223
- const id = typeof args.id === 'string' ? args.id.trim() : '';
224
- if (!ID_RE.test(id)) {
225
- throw new Error(`"${id}" 不是合法的宠物包 id:只认 1-64 位小写字母、数字与连字符,且不以连字符开头。`);
226
- }
227
- // 文件名先收窄一遍再交给库:这样「哪几个名字不合规矩」能在写之前就一趟说清。
228
- const files = Array.isArray(args.files) ? args.files : [];
229
- const badNames = files
230
- .map((item) => (item && typeof item.path === 'string' ? item.path.trim() : ''))
231
- .filter((name) => !isImageName(name));
232
- if (badNames.length > 0) {
233
- throw new Error(`这几个文件名不合规矩:${badNames.map((name) => `"${name}"`).join('、')}。只认单层 .gif / .png(不含斜杠),例如 idle.gif。`);
234
- }
235
-
236
- let result;
237
- try {
238
- result = await writePack({ id, pack: args.pack, files });
239
- } catch (error) {
240
- throw new Error(error && error.message ? error.message : '没能写进去。');
241
- }
242
- const { pack, rejected, written, overriddenBuiltin } = result;
243
- const notes = [];
244
- if (overriddenBuiltin) {
245
- notes.push(`这个 id 原本有一只内置的宠物,现在被这份盖住了(手机上显示的是新的这只)。内置那份没被改动。`);
246
- }
247
- if (rejected.length > 0) {
248
- notes.push(`这几张没能收进来:${rejected.join('、')}(读不到,或者不是 .gif / .png)。`);
249
- }
250
- return {
251
- id: pack.id,
252
- name: pack.name,
253
- states: Object.keys(pack.states),
254
- written,
255
- ...(notes.length > 0 ? { note: notes.join('\n') } : {}),
256
- };
257
- },
258
- }));
259
- }
260
-
261
- module.exports = { installPetTools };