dsh-apk-vm 0.11.0 → 0.11.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.1
4
+
5
+ Clipboard/text tools no longer need a panel to already have a control stream; network proxy has an alias.
6
+
7
+ ### Fixed
8
+
9
+ - `clipboard_get` / `clipboard_set` and Unicode `type_text` now start the scrcpy control
10
+ stream on demand when no panel client is connected, then release it through the normal
11
+ idle timer. Clipboard reads time out with `504` instead of misreporting a stale stream
12
+ as a missing one (`409`).
13
+ - `action=network, networkAction=proxy` is accepted as an alias for the top-level `proxy`
14
+ action, including `enabled:false` / `clear:true` to disable it.
15
+
3
16
  ## 0.11.0
4
17
 
5
18
  WebView/CDP control, reliable tool JSON, CSS-coordinate input, Unicode typing and reboot-safe network state.
package/README.md CHANGED
@@ -45,7 +45,7 @@ same-origin, loopback-only debug HTTP API and an `apk_vm` Agent tool.
45
45
  > 当前 **Windows x64 与 Linux x86_64(headless)为端到端已验证平台**;macOS 仅做探测/CI
46
46
  > 覆盖,详见 `docs/LINUX-E2E.md`。
47
47
 
48
- **Status:** `0.11.0` · Apache-2.0 · no npm runtime dependencies · no build step.
48
+ **Status:** `0.11.1` · Apache-2.0 · no npm runtime dependencies · no build step.
49
49
 
50
50
  This is an open-source DSH plugin published on npm as **`dsh-apk-vm`**. Repository:
51
51
  [github.com/yuxiaole-bili/dsh-apk-vm](https://github.com/yuxiaole-bili/dsh-apk-vm).
package/client.js CHANGED
@@ -30,7 +30,7 @@ window.__ModuleLoader__.load({
30
30
  var SWIPE_THRESHOLD_PX = 24;
31
31
  var FRAME_INTERVAL_MS = 500;
32
32
  var STATE_INTERVAL_MS = 2000;
33
- var CLIENT_VERSION = '0.11.0';
33
+ var CLIENT_VERSION = '0.11.1';
34
34
 
35
35
  /* ------------------------------------------------------------------ *
36
36
  * Optional dsh-better-sidebar integration.
package/index.js CHANGED
@@ -664,6 +664,17 @@ export function apply(ctx, config = {}) {
664
664
  return st.startPromise;
665
665
  }
666
666
 
667
+ // Clipboard/text tools must work even when no panel client is connected.
668
+ // Start the scrcpy control stream lazily, then let the normal idle timer stop it.
669
+ async function ensureControlSession() {
670
+ const st = await ensureScrcpy();
671
+ const session = st && st.session;
672
+ if (!session || session.state !== 'running') {
673
+ throw new Error('H.264 control stream is not running');
674
+ }
675
+ return session;
676
+ }
677
+
667
678
  function handleScrcpyClient(client) {
668
679
  const st = getScrcpyState();
669
680
  st.clients.add(client);
@@ -2579,10 +2590,12 @@ export function apply(ctx, config = {}) {
2579
2590
  });
2580
2591
 
2581
2592
  register('/apk-vm/clipboard', async (req, res) => {
2582
- const session = scrcpyState && scrcpyState.session;
2583
2593
  if (req.method === 'GET') {
2584
- if (!session || session.state !== 'running') {
2585
- sendError(res, 409, 'H.264 control stream is not running');
2594
+ let session;
2595
+ try {
2596
+ session = await ensureControlSession();
2597
+ } catch (error) {
2598
+ sendError(res, 409, error && error.message ? error.message : String(error));
2586
2599
  return;
2587
2600
  }
2588
2601
  try {
@@ -2590,6 +2603,8 @@ export function apply(ctx, config = {}) {
2590
2603
  sendJson(res, 200, { ok: true, text });
2591
2604
  } catch (error) {
2592
2605
  sendError(res, 504, error && error.message ? error.message : String(error));
2606
+ } finally {
2607
+ scheduleScrcpyIdleStop();
2593
2608
  }
2594
2609
  return;
2595
2610
  }
@@ -2597,17 +2612,28 @@ export function apply(ctx, config = {}) {
2597
2612
  sendError(res, 405, 'GET or POST only');
2598
2613
  return;
2599
2614
  }
2600
- if (!session || session.state !== 'running') {
2601
- sendError(res, 409, 'H.264 control stream is not running');
2615
+ let body;
2616
+ try {
2617
+ body = await readJsonBody(req);
2618
+ } catch (error) {
2619
+ sendError(res, 400, error && error.message ? error.message : String(error));
2602
2620
  return;
2603
2621
  }
2604
- const body = await readJsonBody(req);
2605
2622
  if (typeof body.text !== 'string') {
2606
2623
  sendError(res, 400, 'text must be a string');
2607
2624
  return;
2608
2625
  }
2609
- const result = await session.setClipboard(body.text, { paste: body.paste === true });
2610
- sendJson(res, 200, { ok: true, ...result });
2626
+ try {
2627
+ const session = await ensureControlSession();
2628
+ try {
2629
+ const result = await session.setClipboard(body.text, { paste: body.paste === true });
2630
+ sendJson(res, 200, { ok: true, ...result });
2631
+ } finally {
2632
+ scheduleScrcpyIdleStop();
2633
+ }
2634
+ } catch (error) {
2635
+ sendError(res, 409, error && error.message ? error.message : String(error));
2636
+ }
2611
2637
  });
2612
2638
 
2613
2639
  register('/apk-vm/stream', async (req, res) => {
@@ -3276,20 +3302,29 @@ export function apply(ctx, config = {}) {
3276
3302
  return vm.input(payload);
3277
3303
  },
3278
3304
  getClipboard: async () => {
3279
- const session = scrcpyState && scrcpyState.session;
3280
- if (!session || session.state !== 'running') throw new Error('H.264 control stream is not running');
3281
- return session.requestClipboard(2000);
3305
+ const session = await ensureControlSession();
3306
+ try {
3307
+ return await session.requestClipboard(2000);
3308
+ } finally {
3309
+ scheduleScrcpyIdleStop();
3310
+ }
3282
3311
  },
3283
3312
  setClipboard: async (text, paste) => {
3284
- const session = scrcpyState && scrcpyState.session;
3285
- if (!session || session.state !== 'running') throw new Error('H.264 control stream is not running');
3286
- return session.setClipboard(text, { paste: paste === true });
3313
+ const session = await ensureControlSession();
3314
+ try {
3315
+ return await session.setClipboard(text, { paste: paste === true });
3316
+ } finally {
3317
+ scheduleScrcpyIdleStop();
3318
+ }
3287
3319
  },
3288
3320
  typeText: async (text) => {
3289
- const session = scrcpyState && scrcpyState.session;
3290
- if (!session || session.state !== 'running') throw new Error('H.264 control stream is not running');
3291
- const count = await session.sendText(String(text));
3292
- return { ok: true, chars: String(text).length, messages: count };
3321
+ const session = await ensureControlSession();
3322
+ try {
3323
+ const count = await session.sendText(String(text));
3324
+ return { ok: true, chars: String(text).length, messages: count };
3325
+ } finally {
3326
+ scheduleScrcpyIdleStop();
3327
+ }
3293
3328
  },
3294
3329
  install: (apkPath) => installApkFromPath(apkPath),
3295
3330
  pushFile: (local, remote) => vm.pushFile(local, remote),
@@ -3797,7 +3832,7 @@ export function apply(ctx, config = {}) {
3797
3832
  storageAction: { type: 'string', description: 'clean_storage: temp|snapshots|orphan-avds.' },
3798
3833
  avdName: { type: 'string', description: 'clean_storage snapshots: target AVD (defaults to the active AVD).' },
3799
3834
  confirm: { type: 'boolean', description: 'clean_storage: required true for snapshot or orphan AVD deletion.' },
3800
- networkAction: { type: 'string', description: 'network: info|mode|dns|hosts|test|validate|pcap|forward-add|forward-remove|reverse-add|reverse-remove|reverse-list.' },
3835
+ networkAction: { type: 'string', description: 'network: info|mode|dns|hosts|test|validate|pcap|proxy|forward-add|forward-remove|reverse-add|reverse-remove|reverse-list.' },
3801
3836
  networkMode: { type: 'string', description: 'network mode: isolated|shared.' },
3802
3837
  localPort: { type: 'integer', description: 'port forward: host loopback port.' },
3803
3838
  remotePort: { type: 'integer', description: 'port forward: guest service port.' },
@@ -4201,6 +4236,16 @@ export function apply(ctx, config = {}) {
4201
4236
  }
4202
4237
  if (action === 'network') {
4203
4238
  const networkAction = String(args.networkAction || 'info').toLowerCase();
4239
+ // `proxy` already exists as a top-level action; accept it here too because
4240
+ // callers naturally try `action=network, networkAction=proxy`.
4241
+ if (networkAction === 'proxy') {
4242
+ if (args.enabled === false || args.clear === true) {
4243
+ const result = await api.setProxy({ enabled: false });
4244
+ return { ok: true, summary: 'proxy cleared', result };
4245
+ }
4246
+ const result = await api.setProxy({ host: args.host, port: args.port, bypass: args.bypass, enabled: true });
4247
+ return { ok: true, summary: result.proxy ? `proxy=${result.proxy}` : 'proxy set', result };
4248
+ }
4204
4249
  if (networkAction === 'mode') {
4205
4250
  const result = api.setNetworkMode(args.networkMode || args.mode);
4206
4251
  return { ok: true, summary: `network mode: ${result.mode}`, result };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-apk-vm",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "type": "module",
5
5
  "description": "Local AOSP Android VM for DeepSeek Harness: preview rooted APKs at up to 60 fps, automate UIAutomator flows, and give each Agent an isolated VM.",
6
6
  "license": "Apache-2.0",