editmamei 1.3.0 → 1.5.0

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 (39) hide show
  1. package/README.md +10 -9
  2. package/dist/bin/editmamei-core-darwin-arm64 +0 -0
  3. package/dist/bin/editmamei-core-darwin-x64 +0 -0
  4. package/dist/bin/editmamei-core-win-x64.exe +0 -0
  5. package/dist/cli/help.js +1 -1
  6. package/dist/core/server.js +112 -15
  7. package/dist/core/tool-groups.js +4 -3
  8. package/dist/core/tool-registry.js +3 -1
  9. package/dist/core/tool-tiers.js +2 -1
  10. package/dist/install-channel.js +52 -2
  11. package/dist/kernel/kernel.js +1 -0
  12. package/dist/kernel/module-lifecycle.js +44 -17
  13. package/dist/modules/ce/index.js +7 -0
  14. package/dist/perception/facets.js +4 -3
  15. package/dist/perception/region-scorer.js +1 -1
  16. package/dist/perception/scene-model.js +1 -1
  17. package/dist/perception/select-recipes.js +14 -3
  18. package/dist/platform/launch-readiness.js +25 -0
  19. package/dist/platform/macos-runner.js +18 -8
  20. package/dist/platform/script-queue.js +5 -19
  21. package/dist/platform/windows-runner.js +18 -8
  22. package/dist/skills/editmamei-skill.zip +0 -0
  23. package/dist/telemetry/activity.js +149 -0
  24. package/dist/telemetry/client.js +125 -8
  25. package/dist/telemetry/events.js +48 -3
  26. package/dist/tools/detection-tools.js +4 -4
  27. package/dist/tools/document-tools.js +23 -1
  28. package/dist/tools/preview-tools.js +1 -1
  29. package/dist/tools/scene-tools.js +8 -6
  30. package/dist/tools/selection-tools.js +155 -109
  31. package/dist/tools/sequence-tools.js +435 -0
  32. package/dist/update/check.js +24 -10
  33. package/dist/utils/operation-timeouts.js +92 -0
  34. package/dist/utils/run-script.js +25 -1
  35. package/dist/utils/session-log.js +18 -4
  36. package/dist/utils/tool-budget-context.js +14 -0
  37. package/dist/utils/xmp-crs.js +682 -0
  38. package/dist/version.js +1 -1
  39. package/package.json +10 -4
@@ -51,6 +51,10 @@ export const ERROR_CLASS_TABLE = [
51
51
  errorClass: 'file_io',
52
52
  pattern: /\b(ENOENT|EBUSY|EACCES|EPERM|EMFILE|ENOSPC)\b/,
53
53
  },
54
+ {
55
+ errorClass: 'unknown_discriminator',
56
+ pattern: /unknown [^"]{1,40}"[^"]*"\. Allowed: /i,
57
+ },
54
58
  {
55
59
  errorClass: 'schema_validation',
56
60
  pattern: /\bvalidat|required.*field|missing required argument|must be.*type|invalid (input|argument)/i,
@@ -76,6 +80,7 @@ export const ERROR_CLASS_TABLE = [
76
80
  errorClass: 'wrong_layer_kind',
77
81
  pattern: /pixel layer|text layer|smart object layer|layer kind|rasterize it first/i,
78
82
  },
83
+ { errorClass: 'channel_not_visible', pattern: /histogram for visible channels/i },
79
84
  { errorClass: 'ps_command_unavailable', pattern: /not currently available/i },
80
85
  { errorClass: 'timeout', pattern: /timed? ?out|Script execution timeout|exceeded.*bytes/i },
81
86
  {
@@ -85,6 +90,10 @@ export const ERROR_CLASS_TABLE = [
85
90
  { errorClass: 'ai_selection_no_result', pattern: /returned no result/i },
86
91
  { errorClass: 'ps_general_error', pattern: /general photoshop error/i },
87
92
  { errorClass: 'ps_no_such_element', pattern: /no such element/i },
93
+ {
94
+ errorClass: 'extendscript_reference_error',
95
+ pattern: /\b[A-Za-z_$][\w$]*\s+is undefined\s*$/,
96
+ },
88
97
  { errorClass: 'write_not_verified', pattern: /did not verify/i },
89
98
  { errorClass: 'ps_empty_error', pattern: /:\s*$/ },
90
99
  { errorClass: 'ps_op_failed', pattern: /failed[: (]/i },
@@ -98,6 +107,11 @@ export function classifyError(error) {
98
107
  }
99
108
  return 'other';
100
109
  }
110
+ export const NO_ERROR_TEXT_CLASS = 'no_error_text';
111
+ export const ALL_ERROR_CLASSES = [
112
+ ...ERROR_CLASS_TABLE.map((entry) => entry.errorClass),
113
+ NO_ERROR_TEXT_CLASS,
114
+ ];
101
115
  export function elideImagePayloads(value) {
102
116
  if (Array.isArray(value))
103
117
  return value.map(elideImagePayloads);
@@ -253,7 +267,7 @@ export class SessionLog {
253
267
  this.metaEmitted = true;
254
268
  await this.writeLine(JSON.stringify(this.buildMetaEntry()));
255
269
  }
256
- async append(entry, result) {
270
+ async append(entry, result, resultBytes) {
257
271
  if (!this.metaEmitted) {
258
272
  await this.emitMeta();
259
273
  }
@@ -263,14 +277,14 @@ export class SessionLog {
263
277
  const callKey = JSON.stringify({ tool: entry.tool, args: sanitizedArgs });
264
278
  const retrySignal = callKey === this.lastCallKey;
265
279
  this.lastCallKey = callKey;
266
- const resultBytes = computeResultBytes(result);
280
+ const finalResultBytes = resultBytes !== undefined ? resultBytes : computeResultBytes(result);
267
281
  let hoisted = {};
268
282
  try {
269
283
  hoisted = hoistContextScalars(result);
270
284
  }
271
285
  catch {
272
286
  }
273
- const errorClass = classifyError(entry.error);
287
+ const errorClass = entry.success ? null : (classifyError(entry.error) ?? NO_ERROR_TEXT_CLASS);
274
288
  const captureResult = process.env.EDITMAMEI_LOG_RESULTS === '1' && result !== undefined
275
289
  ? this.sanitizeValue(elideImagePayloads(result))
276
290
  : undefined;
@@ -288,7 +302,7 @@ export class SessionLog {
288
302
  edition: EDITION,
289
303
  platform: process.platform,
290
304
  ps_version: this.psVersion,
291
- result_bytes: resultBytes,
305
+ result_bytes: finalResultBytes,
292
306
  ...hoisted,
293
307
  ...(errorClass !== null ? { error_class: errorClass } : {}),
294
308
  retry_signal: retrySignal,
@@ -0,0 +1,14 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ const storage = new AsyncLocalStorage();
3
+ export function budgetContextFor(toolName, budgetMs, now = Date.now()) {
4
+ const ownDeadline = now + budgetMs;
5
+ const outer = storage.getStore();
6
+ const deadline = outer ? Math.min(ownDeadline, outer.deadline) : ownDeadline;
7
+ return { toolName, budgetMs, deadline };
8
+ }
9
+ export function runWithToolBudget(context, fn) {
10
+ return storage.run(context, fn);
11
+ }
12
+ export function currentToolBudget() {
13
+ return storage.getStore();
14
+ }