dsh-apk-vm 0.12.2 → 0.12.4

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/instances.js CHANGED
@@ -13,6 +13,7 @@ import path from 'node:path';
13
13
  import net from 'node:net';
14
14
 
15
15
  import { AndroidVm } from './android.js';
16
+ import { InstanceNameBook, sanitizeDisplayName } from './instance-names.js';
16
17
  import { createAvd, DEFAULT_SYSTEM_IMAGE } from './setup.js';
17
18
  import { ScrcpyStream } from './video-stream.js';
18
19
  import {
@@ -95,9 +96,10 @@ async function patchAvdConfig(avdName) {
95
96
  }
96
97
 
97
98
  export class ExtraVmInstance {
98
- constructor({ id, avdName, port, options, log }) {
99
+ constructor({ id, avdName, port, name, options, log }) {
99
100
  this.id = id;
100
101
  this.avdName = avdName;
102
+ this.name = sanitizeDisplayName(name) || null;
101
103
  this.port = port;
102
104
  this.logSink = typeof log === 'function' ? log : null;
103
105
  this.frame = { buffer: null, at: 0, inFlight: null };
@@ -146,6 +148,7 @@ export class ExtraVmInstance {
146
148
  ...status,
147
149
  id: this.id,
148
150
  avdName: this.avdName,
151
+ name: this.name || this.avdName,
149
152
  port: this.port,
150
153
  root: status.root === true,
151
154
  debugPrepared: status.debugPrepared === true,
@@ -379,6 +382,8 @@ export class ExtraVmInstance {
379
382
  export class InstanceManager {
380
383
  constructor(options = {}) {
381
384
  this.options = options;
385
+ this.namesFile = options.namesFile ? String(options.namesFile) : null;
386
+ this.names = new InstanceNameBook({ file: this.namesFile });
382
387
  this.sdkRoot = options.sdkRoot || null;
383
388
  this.emulatorPath = options.emulatorPath || null;
384
389
  this.adbPath = options.adbPath || null;
@@ -421,6 +426,7 @@ export class InstanceManager {
421
426
  return {
422
427
  id: instance.id,
423
428
  avdName: instance.avdName,
429
+ name: this.nameFor(instance.id, instance.avdName),
424
430
  port: instance.port,
425
431
  kind: instance.kind || 'extra',
426
432
  state: instance.vm._state || 'stopped',
@@ -443,6 +449,28 @@ export class InstanceManager {
443
449
  return this.list();
444
450
  }
445
451
 
452
+ /** Preferred display name for an instance id (custom name or fallback). */
453
+ nameFor(id, fallback = null) {
454
+ return this.names.get(id) || sanitizeDisplayName(fallback) || String(id || '');
455
+ }
456
+
457
+ /** Rename an instance (or the externally-owned default VM). */
458
+ async rename(id, name) {
459
+ const target = String(id || '').trim();
460
+ if (!target) return { ok: false, error: 'rename requires an instance id' };
461
+ const clean = sanitizeDisplayName(name);
462
+ if (!clean) return { ok: false, error: 'rename requires a non-empty name' };
463
+ if (target !== 'default' && !this.instances.has(target)) {
464
+ return { ok: false, error: `unknown instance: ${target}` };
465
+ }
466
+ const instance = this.instances.get(target);
467
+ const previous = instance ? instance.name || instance.avdName : this.names.get(target) || null;
468
+ const saved = await this.names.set(target, clean);
469
+ if (!saved.ok) return saved;
470
+ if (instance) instance.name = clean;
471
+ return { ok: true, id: target, name: clean, previous };
472
+ }
473
+
446
474
  get(id) {
447
475
  return this.instances.get(id) || null;
448
476
  }
@@ -672,10 +700,12 @@ export class InstanceManager {
672
700
  this._log(`[instances] mediaOptionsProvider failed: ${error && error.message ? error.message : error}`);
673
701
  }
674
702
  }
703
+ const displayName = sanitizeDisplayName(name) || id;
675
704
  const instance = new ExtraVmInstance({
676
705
  id,
677
706
  avdName,
678
707
  port,
708
+ name: displayName,
679
709
  options: {
680
710
  sdkRoot: this.sdkRoot || undefined,
681
711
  adbPath: this.adbPath || undefined,
@@ -701,6 +731,7 @@ export class InstanceManager {
701
731
  log: (line) => this._log(line),
702
732
  });
703
733
  this.instances.set(id, instance);
734
+ await this.names.set(id, displayName);
704
735
  this._log(`[instances] created ${id} (avd=${avdName}, port=${port})`);
705
736
  if (typeof this.onCreated === 'function') {
706
737
  try {
@@ -732,6 +763,7 @@ export class InstanceManager {
732
763
  for (const [agent, mapped] of this.agentInstances) {
733
764
  if (mapped === id) this.agentInstances.delete(agent);
734
765
  }
766
+ await this.names.delete(id);
735
767
  await instance.dispose();
736
768
  this._log(`[instances] destroyed ${id}`);
737
769
  return { ok: true, id };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-apk-vm",
3
- "version": "0.12.2",
3
+ "version": "0.12.4",
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",
@@ -30,16 +30,17 @@
30
30
  "rooted-android"
31
31
  ],
32
32
  "engines": {
33
- "node": ">=20"
33
+ "node": ">=20",
34
+ "dsh": ">=0.2.1-rc.3 || >=0.2.2-rc.1"
34
35
  },
35
36
  "publishConfig": {
36
37
  "access": "public",
37
38
  "registry": "https://registry.npmjs.org/"
38
39
  },
39
40
  "scripts": {
40
- "check": "node --check index.js && node --check client.js && node --check lib/android.js && node --check lib/apk-bundle.js && node --check lib/flows.js && node --check lib/storage.js && node --check lib/ui-inspector.js && node --check lib/x509.js && node --check lib/scrcpy.js && node --check lib/ws.js && node --check lib/setup.js && node --check lib/instances.js && node --check lib/vm-ownership.js && node --check lib/http-owner.js && node --check lib/video-stream.js && node --check lib/aab.js && node --check lib/har.js && node --check lib/ui-tests.js && node --check lib/remote.js && node --check lib/cdp.js && node --check lib/json-safe.js && node --check lib/png-annotate.js && node --check lib/image-features.js && node --check lib/control-codebook.js && node --check lib/app-skills.js && node --check lib/jdk.js && node --check lib/autosetup.js && node --check lib/activity-log.js && node --check lib/installed-apps.js && node --check lib/remote-instance.js && node --check lib/media.js && node --check lib/emulator-inventory.js && node scripts/check-version.mjs",
41
+ "check": "node --check index.js && node --check client.js && node --check lib/android.js && node --check lib/apk-bundle.js && node --check lib/flows.js && node --check lib/storage.js && node --check lib/ui-inspector.js && node --check lib/x509.js && node --check lib/scrcpy.js && node --check lib/ws.js && node --check lib/setup.js && node --check lib/instances.js && node --check lib/vm-ownership.js && node --check lib/http-owner.js && node --check lib/video-stream.js && node --check lib/aab.js && node --check lib/har.js && node --check lib/ui-tests.js && node --check lib/remote.js && node --check lib/cdp.js && node --check lib/json-safe.js && node --check lib/png-annotate.js && node --check lib/image-features.js && node --check lib/control-codebook.js && node --check lib/app-skills.js && node --check lib/jdk.js && node --check lib/autosetup.js && node --check lib/activity-log.js && node --check lib/installed-apps.js && node --check lib/remote-instance.js && node --check lib/media.js && node --check lib/emulator-inventory.js && node --check lib/instance-names.js && node scripts/check-version.mjs",
41
42
  "privacy": "node scripts/privacy-scan.mjs",
42
- "test": "node spike/ui-smoke.cjs && node spike/ui-better-sidebar-smoke.cjs && node spike/setup-smoke.mjs && node spike/jdk-test.mjs && node spike/autosetup-test.mjs && node spike/tool-core-test.mjs && node spike/activity-log-test.mjs && node spike/installed-apps-test.mjs && node spike/android/mock-device.mjs && node spike/android/resilience-test.mjs && node spike/android/launch-plan.mjs && node spike/instances-smoke.mjs && node spike/ownership-test.mjs && node spike/cdp-test.mjs && node spike/features.mjs && node spike/aab-test.mjs && node spike/har-test.mjs && node spike/ui-tests-test.mjs && node spike/remote-test.mjs && node spike/remote-instance-test.mjs && node spike/media-test.mjs && node spike/emulator-inventory-test.mjs && node spike/skill-test.mjs"
43
+ "test": "node spike/ui-smoke.cjs && node spike/ui-better-sidebar-smoke.cjs && node spike/setup-smoke.mjs && node spike/jdk-test.mjs && node spike/autosetup-test.mjs && node spike/tool-core-test.mjs && node spike/activity-log-test.mjs && node spike/installed-apps-test.mjs && node spike/instance-names-test.mjs && node spike/snapshot-recovery-test.mjs && node spike/android/mock-device.mjs && node spike/android/resilience-test.mjs && node spike/android/launch-plan.mjs && node spike/instances-smoke.mjs && node spike/ownership-test.mjs && node spike/cdp-test.mjs && node spike/features.mjs && node spike/aab-test.mjs && node spike/har-test.mjs && node spike/ui-tests-test.mjs && node spike/remote-test.mjs && node spike/remote-instance-test.mjs && node spike/media-test.mjs && node spike/emulator-inventory-test.mjs && node spike/skill-test.mjs"
43
44
  },
44
45
  "exports": {
45
46
  ".": "./index.js",
@@ -65,6 +66,7 @@
65
66
  "lib/activity-log.js",
66
67
  "lib/installed-apps.js",
67
68
  "lib/instances.js",
69
+ "lib/instance-names.js",
68
70
  "lib/vm-ownership.js",
69
71
  "lib/http-owner.js",
70
72
  "lib/video-stream.js",
@@ -93,6 +95,7 @@
93
95
  "docs/PRIVACY.md",
94
96
  "docs/SUBMISSION.md",
95
97
  "docs/LINUX-E2E.md",
98
+ "docs/AGENTS.md",
96
99
  "docs/*.png",
97
100
  "docs/*.gif",
98
101
  "scripts/privacy-scan.mjs",
@@ -106,6 +109,12 @@
106
109
  "CHANGELOG.md"
107
110
  ],
108
111
  "dsh": {
112
+ "compatibility": {
113
+ "dshReleases": {
114
+ "0.2.1-rc.3+": "compatible",
115
+ "0.2.2-rc.1+": "compatible"
116
+ }
117
+ },
109
118
  "bundle": {
110
119
  "patch": "./cordis.patch.yml"
111
120
  },