editmamei 0.22.1 → 0.22.2

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.
Binary file
Binary file
@@ -11,11 +11,13 @@ import { Session } from './session.js';
11
11
  import { SessionLog, classifyError } from '../utils/session-log.js';
12
12
  import { loadSettings, applyTelemetryEnvOverrides, applyUpdateCheckEnvOverride, } from './settings.js';
13
13
  import { TelemetryClient } from '../telemetry/client.js';
14
+ import { resolveInstallChannel } from '../install-channel.js';
14
15
  import { checkForUpdate, shouldCheckForUpdate } from '../update/check.js';
15
16
  import { join, dirname } from 'node:path';
16
17
  import { pathToFileURL } from 'node:url';
17
18
  import { GoSnippetClient, resolveProBinaryPath, coreBinaryName } from '../api/snippet-client.js';
18
19
  import { isProEntitled } from '../license/entitlement.js';
20
+ import { createPingLicenseRefresher } from '../license/ping-refresh.js';
19
21
  import { loadVerifiedModule, readInstalledModule, installedPath, PRO_SKU, } from '../delivery/store.js';
20
22
  import { provisionModules } from '../delivery/provision.js';
21
23
  import { readLicense } from '../license/store.js';
@@ -25,6 +27,15 @@ import { listTemplates } from '../utils/template-storage.js';
25
27
  import { Kernel } from '../kernel/kernel.js';
26
28
  import { HOST_MIN_ABI } from '../kernel/host-api.js';
27
29
  import { ceModule } from '../modules/ce/index.js';
30
+ export function classifyModuleOutcome(inputs) {
31
+ if (inputs.proModuleLoaded && inputs.skipReason === null)
32
+ return 'loaded';
33
+ if (inputs.skipReason === 'corrupt')
34
+ return 'skipped_corrupt';
35
+ if (inputs.skipReason === 'incompatible')
36
+ return 'skipped_incompatible';
37
+ return inputs.entitled ? 'absent' : 'lapsed';
38
+ }
28
39
  let logScriptOnErrorWarned = false;
29
40
  function warnLogScriptOnErrorOnce(logger) {
30
41
  if (logScriptOnErrorWarned)
@@ -40,8 +51,8 @@ export function __resetLogScriptOnErrorWarnForTests() {
40
51
  logScriptOnErrorWarned = false;
41
52
  }
42
53
  const FIRST_RUN_DISCLOSURE = 'First run: Editmamei collects anonymous, content-free usage telemetry (tool name, ' +
43
- 'success, duration, version/edition/OS/PS-version) to find what breaks. It never sends ' +
44
- 'image content, file paths, or personal data. Opt out anytime: ' +
54
+ 'success, duration, version/edition/OS/PS-version, install channel) to find what breaks. ' +
55
+ 'It never sends image content, file paths, or personal data. Opt out anytime: ' +
45
56
  '`editmamei config set telemetry.usage false` (or edit ~/.editmamei/settings.json). ' +
46
57
  'Opt in to sanitized diagnostics: `editmamei config set telemetry.diagnostics true`.';
47
58
  export class EditmameiServer {
@@ -57,6 +68,7 @@ export class EditmameiServer {
57
68
  psVersion = null;
58
69
  updateInfo = null;
59
70
  snippetClient = new GoSnippetClient();
71
+ refreshLicenseOnPing = createPingLicenseRefresher();
60
72
  constructor() {
61
73
  this.logger = new Logger('EditmameiServer');
62
74
  this.session = new Session();
@@ -67,6 +79,9 @@ export class EditmameiServer {
67
79
  this.telemetry = new TelemetryClient({
68
80
  settings: effectiveSettings,
69
81
  getPsVersion: () => this.psVersion,
82
+ edition: isProEntitled() ? 'pro' : 'community',
83
+ channel: resolveInstallChannel(),
84
+ getModuleStatus: () => this.computeModuleStatus(),
70
85
  });
71
86
  if (created)
72
87
  this.logger.info(FIRST_RUN_DISCLOSURE);
@@ -250,6 +265,21 @@ export class EditmameiServer {
250
265
  this.moduleSkipReason = 'incompatible';
251
266
  }
252
267
  }
268
+ computeModuleStatus() {
269
+ if (!readLicense())
270
+ return null;
271
+ const installed = readInstalledModule(PRO_SKU);
272
+ return {
273
+ module: PRO_SKU,
274
+ outcome: classifyModuleOutcome({
275
+ proModuleLoaded: this.proModule !== null,
276
+ skipReason: this.moduleSkipReason,
277
+ entitled: isProEntitled(),
278
+ }),
279
+ module_version: installed?.version ?? null,
280
+ abi: installed?.abi ?? null,
281
+ };
282
+ }
253
283
  async reprovisionIfModuleSkipped(delivery = {}) {
254
284
  const reason = this.moduleSkipReason;
255
285
  if (reason === null)
@@ -369,6 +399,7 @@ export class EditmameiServer {
369
399
  }
370
400
  }
371
401
  async pingPhotoshop() {
402
+ this.refreshLicenseOnPing();
372
403
  const connection = this.session.getConnection();
373
404
  const isConnected = await connection.ping();
374
405
  if (!isConnected) {
@@ -7,6 +7,7 @@ const logger = new Logger('License');
7
7
  export const GRACE_MS = 30 * 24 * 60 * 60 * 1000;
8
8
  export const REFRESH_AFTER_MS = 7 * 24 * 60 * 60 * 1000;
9
9
  export const EXPIRED_REFRESH_TIMEOUT_MS = 5_000;
10
+ export const CLOCK_SKEW_TOLERANCE_MS = 24 * 60 * 60 * 1000;
10
11
  export function evaluateEntitlement(rec, now) {
11
12
  if (!rec)
12
13
  return { entitled: false, reason: 'no-license' };
@@ -77,9 +78,10 @@ export async function refreshIfStale(ops = {}) {
77
78
  return;
78
79
  const last = Date.parse(rec.last_validated_at);
79
80
  const age = Number.isFinite(last) ? now - last : Infinity;
80
- if (age <= REFRESH_AFTER_MS)
81
+ const clockSkewed = age < -CLOCK_SKEW_TOLERANCE_MS;
82
+ if (!clockSkewed && age <= REFRESH_AFTER_MS)
81
83
  return;
82
- if (age <= GRACE_MS) {
84
+ if (clockSkewed || age <= GRACE_MS) {
83
85
  refresh(ops).catch((err) => {
84
86
  logger.warn(`Background license refresh failed (grace covers offline use): ` +
85
87
  `${err instanceof Error ? err.message : String(err)}`);
@@ -0,0 +1,14 @@
1
+ import { refreshIfStale } from './entitlement.js';
2
+ export function createPingLicenseRefresher(refresh = refreshIfStale) {
3
+ let fired = false;
4
+ return () => {
5
+ if (fired)
6
+ return;
7
+ fired = true;
8
+ try {
9
+ void refresh().catch(() => { });
10
+ }
11
+ catch {
12
+ }
13
+ };
14
+ }
@@ -103,7 +103,6 @@ export class MacOSExecutor {
103
103
  throw new Error('jsxPath contains a character that would break AppleScript interpolation');
104
104
  }
105
105
  return `tell application "${this.appName}"
106
- \tactivate
107
106
  \tdo javascript "$.evalFile(decodeURI('${encodeURI(posixPath)}'))"
108
107
  end tell`;
109
108
  }
Binary file
@@ -1,7 +1,8 @@
1
1
  import { Logger } from '../utils/logger.js';
2
2
  import { EDITION } from '../edition.js';
3
3
  import { VERSION } from '../version.js';
4
- import { buildDiagnosticEvent, buildSessionStart, buildSessionSummary, buildUsageEvent, dayBucket, isContentSafe, PS_VERSION_UNKNOWN, } from './events.js';
4
+ import { resolveInstallChannel } from '../install-channel.js';
5
+ import { buildDiagnosticEvent, buildModuleStatus, buildSessionStart, buildSessionSummary, buildUsageEvent, dayBucket, isContentSafe, PS_VERSION_UNKNOWN, } from './events.js';
5
6
  import { sanitizeMessage, sanitizeSnippet, sanitizeStderrTail } from './sanitize.js';
6
7
  import { httpTransport, resolveEndpoint } from './transport.js';
7
8
  import { appendOutboxSync, clearOutbox, clearSessionState, readOutbox, readSessionState, writeSessionStateSync, } from './outbox.js';
@@ -23,6 +24,7 @@ export class TelemetryClient {
23
24
  maxBatchSize;
24
25
  active;
25
26
  outboxOpts;
27
+ getModuleStatus;
26
28
  queue = [];
27
29
  timer = null;
28
30
  shutdownPromise = null;
@@ -39,11 +41,13 @@ export class TelemetryClient {
39
41
  this.maxBatchSize = opts.maxBatchSize ?? MAX_BATCH_SIZE;
40
42
  this.active = opts.active ?? (EDITION !== 'dev' && !isTestEnv());
41
43
  this.outboxOpts = opts.outboxDir ? { dir: opts.outboxDir } : {};
44
+ this.getModuleStatus = opts.getModuleStatus ?? (() => null);
42
45
  this.dims = {
43
46
  install_id: this.settings.telemetry.install_id,
44
47
  editmamei_version: VERSION,
45
- edition: EDITION,
48
+ edition: opts.edition ?? EDITION,
46
49
  platform: process.platform,
50
+ channel: opts.channel ?? resolveInstallChannel(),
47
51
  getPsVersion: opts.getPsVersion,
48
52
  };
49
53
  }
@@ -57,6 +61,9 @@ export class TelemetryClient {
57
61
  this.timer.unref?.();
58
62
  if (this.settings.telemetry.usage) {
59
63
  this.enqueue(buildSessionStart(this.dims, this.now()));
64
+ const moduleStatus = this.getModuleStatus();
65
+ if (moduleStatus)
66
+ this.enqueue(buildModuleStatus(this.dims, moduleStatus, this.now()));
60
67
  void this.flush();
61
68
  }
62
69
  }
@@ -55,6 +55,22 @@ export function buildSessionStart(dims, now) {
55
55
  edition: dims.edition,
56
56
  platform: dims.platform,
57
57
  ps_version: psVersionOf(dims),
58
+ channel: dims.channel,
59
+ };
60
+ }
61
+ export function buildModuleStatus(dims, status, now) {
62
+ return {
63
+ v: TELEMETRY_SCHEMA_VERSION,
64
+ type: 'module_status',
65
+ install_id: dims.install_id,
66
+ ts_bucket: dayBucket(now),
67
+ editmamei_version: dims.editmamei_version,
68
+ edition: dims.edition,
69
+ platform: dims.platform,
70
+ module: status.module,
71
+ outcome: status.outcome,
72
+ module_version: status.module_version,
73
+ abi: status.abi,
58
74
  };
59
75
  }
60
76
  export function buildDiagnosticEvent(dims, diag, now) {
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.22.1';
1
+ export const VERSION = '0.22.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "editmamei",
3
- "version": "0.22.1",
3
+ "version": "0.22.2",
4
4
  "description": "Editmamei — Unlock Photoshop with natural-language photo editing (Community Edition)",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@modelcontextprotocol/sdk": "^1.0.4",
44
- "adm-zip": "^0.5.17",
44
+ "adm-zip": "^0.6.0",
45
45
  "jpeg-js": "^0.4.4",
46
46
  "onnxruntime-web": "1.27.0"
47
47
  }