dsh-miloco-bridge 0.1.4 → 0.1.6

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/lib/tools.js CHANGED
@@ -20,6 +20,7 @@
20
20
  */
21
21
 
22
22
  import { MilocoError } from './miloco-client.js'
23
+ import { normalizePushTargetMode } from './overlay.js'
23
24
  import { PERCEPTION_LEVELS } from './perception.js'
24
25
  import { noteSession } from './state.js'
25
26
 
@@ -291,11 +292,18 @@ export function createMilocoTools(options) {
291
292
 
292
293
  // ---------------------------------------------------------------- 感知
293
294
 
295
+ /**
296
+ * Perceive runs camera capture + multimodal LLM inference on the Miloco
297
+ * backend and measured 58–78 s end to end; the client-wide 30 s default
298
+ * would abort every call. Override it per-request with headroom.
299
+ */
300
+ const PERCEIVE_TIMEOUT_MS = 180_000
301
+
294
302
  tools.push(defineMilocoTool({
295
303
  name: 'miloco_perceive',
296
304
  description: '用摄像头看画面、听现场声音,并用多模态大模型回答问题。sources 传摄像头 did 列表,query 用自然语言提问'
297
305
  + '(例如"客厅现在有人吗""刚才进门的人穿的什么衣服")。只能回答画面/声音层面的问题;温度、电量一类数值要用 miloco_device_status。'
298
- + '需要该摄像头已开启感知。',
306
+ + '需要该摄像头已开启感知。注意:该调用需要抓帧并做大模型推理,通常要 1–2 分钟,属正常耗时,超时前请勿重复调用。',
299
307
  parameters: {
300
308
  sources: {
301
309
  type: 'array',
@@ -309,7 +317,11 @@ export function createMilocoTools(options) {
309
317
  const sources = Array.isArray(args.sources) ? args.sources.filter(s => typeof s === 'string' && s) : []
310
318
  if (sources.length === 0) throw new Error('缺少参数 sources:至少给一个摄像头 did')
311
319
  const query = requireString(args, 'query')
312
- return call('POST', '/api/perception/perceive', { body: { sources, query }, signal: exec?.signal })
320
+ return call('POST', '/api/perception/perceive', {
321
+ body: { sources, query },
322
+ signal: exec?.signal,
323
+ timeoutMs: PERCEIVE_TIMEOUT_MS,
324
+ })
313
325
  },
314
326
  }))
315
327
 
@@ -1369,10 +1381,16 @@ export function createMilocoTools(options) {
1369
1381
 
1370
1382
  writeTools.push(defineMilocoTool({
1371
1383
  name: 'miloco_push_target_set',
1372
- description: '修改 Miloco 主动推送的投递目标。sessionId 留空 = 投到「上一次触发 miloco 的会话」;'
1384
+ description: '修改 Miloco 主动推送的投递目标。mode=archive(默认)投到专用归档会话,'
1385
+ + '会忽略 sessionId;mode=session 投到指定会话,sessionId 留空 = 上一次触发 miloco 的会话。'
1373
1386
  + 'provider+model 留空 = 跟随那个对话自己选的模型;perceptionLevel 控制感知事件的最低优先级。',
1374
1387
  parameters: {
1375
- sessionId: { type: 'string', description: '目标对话的会话 id;留空 = 上一次触发 miloco 的会话' },
1388
+ mode: {
1389
+ type: 'string',
1390
+ enum: ['archive', 'session'],
1391
+ description: '投递方式:archive = 归档会话(默认);session = 指定会话。省略时按 sessionId 推断',
1392
+ },
1393
+ sessionId: { type: 'string', description: '目标对话的会话 id;仅 session 模式生效,留空 = 上一次触发 miloco 的会话' },
1376
1394
  provider: { type: 'string', description: '模型供应商 id;留空 = 跟随该对话自己选的模型' },
1377
1395
  model: { type: 'string', description: '模型 id;留空 = 跟随该对话自己选的模型' },
1378
1396
  reasoningEffort: { type: 'string', description: '推理强度(可选)' },
@@ -1384,6 +1402,19 @@ export function createMilocoTools(options) {
1384
1402
  async run(args) {
1385
1403
  if (!options.overlay) throw new Error('插件未启用覆盖文件,无法修改推送目标')
1386
1404
  const current = await options.overlay.current()
1405
+ const sessionArg = typeof args.sessionId === 'string' ? args.sessionId.trim() : ''
1406
+ let mode
1407
+ if (typeof args.mode === 'string') {
1408
+ mode = normalizePushTargetMode(args.mode)
1409
+ if (!mode) throw new Error('mode 只能是 archive / session')
1410
+ } else if (sessionArg) {
1411
+ mode = 'session'
1412
+ } else {
1413
+ mode = current.push.target.mode || options.pushMode || 'archive'
1414
+ }
1415
+ if (mode === 'archive' && sessionArg) {
1416
+ throw new Error('archive 模式会忽略 sessionId;要指定会话请同时传 mode=session')
1417
+ }
1387
1418
  const provider = typeof args.provider === 'string' ? args.provider.trim() : current.push.model.provider
1388
1419
  const model = typeof args.model === 'string' ? args.model.trim() : current.push.model.model
1389
1420
  if (Boolean(provider) !== Boolean(model)) {
@@ -1400,9 +1431,8 @@ export function createMilocoTools(options) {
1400
1431
  push: {
1401
1432
  token: current.push.token,
1402
1433
  target: {
1403
- sessionId: typeof args.sessionId === 'string'
1404
- ? args.sessionId.trim()
1405
- : current.push.target.sessionId,
1434
+ mode,
1435
+ sessionId: sessionArg || current.push.target.sessionId,
1406
1436
  },
1407
1437
  model: {
1408
1438
  provider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-miloco-bridge",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Unofficial DSH bridge for Xiaomi Miloco: an isolated Agent preset for Miloco tools, native tools/skills, Web settings, perception-priority filtering, and Miloco -> DSH push.",
5
5
  "keywords": [
6
6
  "dsh",
@@ -30,7 +30,12 @@
30
30
  "lib",
31
31
  "skills",
32
32
  "adapter",
33
- "docs",
33
+ "docs/ARCHITECTURE.md",
34
+ "docs/INSTALL.md",
35
+ "docs/SKILL-REWRITES.md",
36
+ "docs/TOOLS.md",
37
+ "docs/VERIFICATION.md",
38
+ "docs/images",
34
39
  "scripts",
35
40
  "install.sh",
36
41
  "cordis.patch.yml",