editmamei 0.17.4 → 0.18.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.
- package/NOTICES.md +43 -0
- package/README.md +91 -8
- package/dist/api/extendscript/_helpers.js +8 -0
- package/dist/bin/editmamei-core-darwin-arm64 +0 -0
- package/dist/bin/editmamei-core-darwin-x64 +0 -0
- package/dist/bin/editmamei-core-win-x64.exe +0 -0
- package/dist/cli/clients/json-config.js +1 -1
- package/dist/core/server.js +92 -24
- package/dist/core/tool-groups.js +178 -0
- package/dist/core/tool-tiers.js +34 -48
- package/dist/delivery/bundle.js +8 -0
- package/dist/delivery/config.js +23 -0
- package/dist/delivery/provision.js +30 -2
- package/dist/delivery/store.js +40 -1
- package/dist/detection/detect-active-doc.js +84 -0
- package/dist/detection/detection-client.js +62 -0
- package/dist/detection/face-contour-geometry.js +137 -0
- package/dist/detection/face-detector.js +34 -0
- package/dist/detection/face-feature-geometry.js +180 -0
- package/dist/detection/geometry.js +35 -0
- package/dist/detection/landmark-detection-client.js +38 -0
- package/dist/detection/landmark-detector.js +63 -0
- package/dist/detection/landmark-spec.js +29 -0
- package/dist/detection/mesh-face.js +36 -0
- package/dist/detection/object-detector.js +135 -0
- package/dist/detection/runtime.js +46 -0
- package/dist/license/env-activation.js +46 -7
- package/dist/models/dfine-s-coco-quant.onnx +0 -0
- package/dist/models/ultraface-rfb-320.onnx +0 -0
- package/dist/modules/ce/index.js +23 -5
- package/dist/perception/facets.js +148 -0
- package/dist/perception/region-precompute.js +122 -0
- package/dist/perception/region-scorer.js +151 -0
- package/dist/perception/scene-model.js +156 -0
- package/dist/perception/select-recipes.js +493 -0
- package/dist/perception/sky-ground-flood.js +234 -0
- package/dist/perception/sky-mask-transfer.js +77 -0
- package/dist/platform/macos-executor.js +0 -1
- package/dist/platform/windows-executor.js +6 -1
- package/dist/preview/coordinate-grid.js +250 -0
- package/dist/skills/editmamei-skill.zip +0 -0
- package/dist/telemetry/events.js +2 -1
- package/dist/telemetry/sanitize.js +15 -1
- package/dist/tools/adjustment-tools.js +46 -51
- package/dist/tools/detection-tools.js +209 -0
- package/dist/tools/document-tools.js +41 -30
- package/dist/tools/filter-tools.js +616 -101
- package/dist/tools/guide-tools.js +186 -0
- package/dist/tools/history-tools.js +1 -39
- package/dist/tools/image-tools.js +88 -0
- package/dist/tools/inspect-tools.js +86 -0
- package/dist/tools/layer-properties-tools.js +195 -106
- package/dist/tools/layer-tools.js +55 -14
- package/dist/tools/layer-transform-tools.js +236 -73
- package/dist/tools/metadata-tools.js +2 -32
- package/dist/tools/object-tools.js +193 -0
- package/dist/tools/overview-tools.js +69 -43
- package/dist/tools/path-tools.js +274 -0
- package/dist/tools/portrait-tools.js +146 -0
- package/dist/tools/preview-tools.js +78 -3
- package/dist/tools/retouch-tools.js +45 -33
- package/dist/tools/scene-tools.js +401 -0
- package/dist/tools/selection-tools.js +766 -228
- package/dist/tools/text-on-object-tools.js +225 -0
- package/dist/tools/text-tools.js +47 -56
- package/dist/tools/transform-canvas-tools.js +138 -0
- package/dist/tools/vector-mask-tools.js +116 -0
- package/dist/version.js +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { runScript } from '../utils/run-script.js';
|
|
2
|
+
import { validateArgs } from '../utils/validate.js';
|
|
3
|
+
const addGuideSchema = {
|
|
4
|
+
type: 'object',
|
|
5
|
+
properties: {
|
|
6
|
+
orientation: {
|
|
7
|
+
type: 'string',
|
|
8
|
+
enum: ['horizontal', 'vertical'],
|
|
9
|
+
description: "'vertical' adds a top-to-bottom guide positioned by its x coordinate; 'horizontal' adds a left-to-right guide positioned by its y coordinate.",
|
|
10
|
+
},
|
|
11
|
+
position: {
|
|
12
|
+
type: 'number',
|
|
13
|
+
description: 'Guide position in document pixels (the x for vertical, the y for horizontal).',
|
|
14
|
+
minimum: 0,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
required: ['orientation', 'position'],
|
|
18
|
+
};
|
|
19
|
+
const guideLayoutSchema = {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
columns: {
|
|
23
|
+
type: 'integer',
|
|
24
|
+
description: 'Number of evenly-spaced columns (vertical guides). 0 = none.',
|
|
25
|
+
minimum: 0,
|
|
26
|
+
default: 0,
|
|
27
|
+
},
|
|
28
|
+
rows: {
|
|
29
|
+
type: 'integer',
|
|
30
|
+
description: 'Number of evenly-spaced rows (horizontal guides). 0 = none.',
|
|
31
|
+
minimum: 0,
|
|
32
|
+
default: 0,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
const GUIDE_OPS = ['add', 'layout', 'clear'];
|
|
37
|
+
const GUIDE_INPUT_SCHEMA = {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
op: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
enum: [...GUIDE_OPS],
|
|
43
|
+
description: 'Guide operation. add: one guide at position (orientation + position px). layout: an evenly-spaced grid (columns and/or rows). clear: remove ALL guides from the document.',
|
|
44
|
+
},
|
|
45
|
+
...addGuideSchema.properties,
|
|
46
|
+
...guideLayoutSchema.properties,
|
|
47
|
+
},
|
|
48
|
+
required: ['op'],
|
|
49
|
+
};
|
|
50
|
+
export function createGuideTools(connection, snippetClient) {
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
tool: {
|
|
54
|
+
name: 'photoshop_guides',
|
|
55
|
+
description: 'Manage document guides — choose with `op`. `add` places one guide (orientation horizontal|vertical + position in px). `layout` creates an evenly-spaced grid (columns and/or rows — great for rule-of-thirds at 3×3). `clear` removes all guides. Guides are non-printing layout aids.',
|
|
56
|
+
inputSchema: GUIDE_INPUT_SCHEMA,
|
|
57
|
+
outputSchema: {
|
|
58
|
+
type: 'object',
|
|
59
|
+
properties: {
|
|
60
|
+
guide_added: { type: 'boolean' },
|
|
61
|
+
guide_layout_created: { type: 'boolean' },
|
|
62
|
+
guides_cleared: { type: 'boolean' },
|
|
63
|
+
orientation: { type: 'string' },
|
|
64
|
+
position: { type: 'number' },
|
|
65
|
+
columns: { type: 'number' },
|
|
66
|
+
rows: { type: 'number' },
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
annotations: {
|
|
70
|
+
title: 'Document Guides',
|
|
71
|
+
idempotentHint: false,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
handler: async (args) => guides(connection, snippetClient, args),
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
async function guides(connection, snippetClient, rawArgs) {
|
|
79
|
+
const op = rawArgs.op;
|
|
80
|
+
const { op: _omit, ...rest } = rawArgs;
|
|
81
|
+
switch (op) {
|
|
82
|
+
case 'add':
|
|
83
|
+
return addGuide(connection, snippetClient, rest);
|
|
84
|
+
case 'layout':
|
|
85
|
+
return addGuideLayout(connection, snippetClient, rest);
|
|
86
|
+
case 'clear':
|
|
87
|
+
return clearGuides(connection, snippetClient);
|
|
88
|
+
default:
|
|
89
|
+
return {
|
|
90
|
+
content: [
|
|
91
|
+
{
|
|
92
|
+
type: 'text',
|
|
93
|
+
text: `Error: unknown guides op "${String(op)}". Allowed: ${GUIDE_OPS.join(', ')}.`,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
isError: true,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function addGuide(connection, snippetClient, rawArgs) {
|
|
101
|
+
try {
|
|
102
|
+
const args = validateArgs(addGuideSchema, rawArgs);
|
|
103
|
+
const orientation = args.orientation;
|
|
104
|
+
const position = args.position;
|
|
105
|
+
const script = await snippetClient.build('addGuide', { orientation, position });
|
|
106
|
+
const result = await runScript(connection, script);
|
|
107
|
+
return {
|
|
108
|
+
content: [
|
|
109
|
+
{
|
|
110
|
+
type: 'text',
|
|
111
|
+
text: `Added ${orientation} guide at ${position}px\nResult: ${JSON.stringify(result)}`,
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
structuredContent: result,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
return {
|
|
119
|
+
content: [
|
|
120
|
+
{
|
|
121
|
+
type: 'text',
|
|
122
|
+
text: `Error adding guide: ${error instanceof Error ? error.message : String(error)}`,
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
isError: true,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function addGuideLayout(connection, snippetClient, rawArgs) {
|
|
130
|
+
try {
|
|
131
|
+
const args = validateArgs(guideLayoutSchema, rawArgs);
|
|
132
|
+
const columns = args.columns ?? 0;
|
|
133
|
+
const rows = args.rows ?? 0;
|
|
134
|
+
if (columns <= 0 && rows <= 0) {
|
|
135
|
+
throw new Error('op=layout requires at least one of columns / rows to be ≥ 1.');
|
|
136
|
+
}
|
|
137
|
+
const script = await snippetClient.build('addGuideLayout', { columns, rows });
|
|
138
|
+
const result = await runScript(connection, script);
|
|
139
|
+
return {
|
|
140
|
+
content: [
|
|
141
|
+
{
|
|
142
|
+
type: 'text',
|
|
143
|
+
text: `Created guide layout (${columns} columns × ${rows} rows)\nResult: ${JSON.stringify(result)}`,
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
structuredContent: result,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
return {
|
|
151
|
+
content: [
|
|
152
|
+
{
|
|
153
|
+
type: 'text',
|
|
154
|
+
text: `Error creating guide layout: ${error instanceof Error ? error.message : String(error)}`,
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
isError: true,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async function clearGuides(connection, snippetClient) {
|
|
162
|
+
try {
|
|
163
|
+
const script = await snippetClient.build('clearGuides', {});
|
|
164
|
+
const result = await runScript(connection, script);
|
|
165
|
+
return {
|
|
166
|
+
content: [
|
|
167
|
+
{
|
|
168
|
+
type: 'text',
|
|
169
|
+
text: `Cleared all guides\nResult: ${JSON.stringify(result)}`,
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
structuredContent: result,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
return {
|
|
177
|
+
content: [
|
|
178
|
+
{
|
|
179
|
+
type: 'text',
|
|
180
|
+
text: `Error clearing guides: ${error instanceof Error ? error.message : String(error)}`,
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
isError: true,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -22,10 +22,6 @@ const redoSchema = {
|
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
|
-
const emptySchema = {
|
|
26
|
-
type: 'object',
|
|
27
|
-
properties: {},
|
|
28
|
-
};
|
|
29
25
|
const HISTORY_STEP_RESULT_SCHEMA = {
|
|
30
26
|
type: 'object',
|
|
31
27
|
properties: {
|
|
@@ -66,40 +62,6 @@ export function createHistoryTools(connection, snippetClient) {
|
|
|
66
62
|
},
|
|
67
63
|
handler: async (args) => redo(connection, snippetClient, args),
|
|
68
64
|
},
|
|
69
|
-
{
|
|
70
|
-
tool: {
|
|
71
|
-
name: 'photoshop_get_history',
|
|
72
|
-
description: 'List all history states for the active document along with the current cursor position. Read-only. Useful for deciding how far back to undo or for diagnostics. Returns document context as part of the snapshot.',
|
|
73
|
-
inputSchema: emptySchema,
|
|
74
|
-
outputSchema: {
|
|
75
|
-
type: 'object',
|
|
76
|
-
properties: {
|
|
77
|
-
totalStates: { type: 'number' },
|
|
78
|
-
currentIndex: { type: 'number' },
|
|
79
|
-
currentState: { type: 'string' },
|
|
80
|
-
canUndo: { type: 'boolean' },
|
|
81
|
-
canRedo: { type: 'boolean' },
|
|
82
|
-
states: {
|
|
83
|
-
type: 'array',
|
|
84
|
-
items: {
|
|
85
|
-
type: 'object',
|
|
86
|
-
properties: {
|
|
87
|
-
name: { type: 'string' },
|
|
88
|
-
snapshot: { type: 'boolean' },
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
context: { type: 'object' },
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
annotations: {
|
|
96
|
-
title: 'Get History States',
|
|
97
|
-
readOnlyHint: true,
|
|
98
|
-
idempotentHint: true,
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
handler: async () => getHistory(connection, snippetClient),
|
|
102
|
-
},
|
|
103
65
|
];
|
|
104
66
|
}
|
|
105
67
|
async function undo(connection, snippetClient, rawArgs) {
|
|
@@ -158,7 +120,7 @@ async function redo(connection, snippetClient, rawArgs) {
|
|
|
158
120
|
};
|
|
159
121
|
}
|
|
160
122
|
}
|
|
161
|
-
async function getHistory(connection, snippetClient) {
|
|
123
|
+
export async function getHistory(connection, snippetClient) {
|
|
162
124
|
try {
|
|
163
125
|
const script = await snippetClient.build('getHistoryStates');
|
|
164
126
|
const result = await runScript(connection, script);
|
|
@@ -49,6 +49,37 @@ const cropDocumentSchema = {
|
|
|
49
49
|
},
|
|
50
50
|
required: ['left', 'top', 'right', 'bottom'],
|
|
51
51
|
};
|
|
52
|
+
const convertImageModeSchema = {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
mode: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
enum: ['grayscale', 'rgb', 'cmyk', 'lab', 'bitmap'],
|
|
58
|
+
description: 'Target document color mode. grayscale discards color (the "Discard color information?" prompt is auto-confirmed); the document is FLATTENED as part of the conversion. `bitmap` produces a 1-bit halftone-screen image (auto-converts to grayscale first) — use frequency/angle/shape.',
|
|
59
|
+
},
|
|
60
|
+
frequency: {
|
|
61
|
+
type: 'number',
|
|
62
|
+
description: 'bitmap only: halftone screen frequency in lines/inch (1-999). PS default 53.',
|
|
63
|
+
minimum: 1,
|
|
64
|
+
maximum: 999,
|
|
65
|
+
default: 53,
|
|
66
|
+
},
|
|
67
|
+
angle: {
|
|
68
|
+
type: 'number',
|
|
69
|
+
description: 'bitmap only: halftone screen angle in degrees (-180 to 180). PS default 45.',
|
|
70
|
+
minimum: -180,
|
|
71
|
+
maximum: 180,
|
|
72
|
+
default: 45,
|
|
73
|
+
},
|
|
74
|
+
shape: {
|
|
75
|
+
type: 'string',
|
|
76
|
+
enum: ['round', 'diamond', 'ellipse', 'line', 'square', 'cross'],
|
|
77
|
+
description: 'bitmap only: halftone dot shape.',
|
|
78
|
+
default: 'round',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
required: ['mode'],
|
|
82
|
+
};
|
|
52
83
|
export function createImageTools(connection, snippetClient) {
|
|
53
84
|
return [
|
|
54
85
|
{
|
|
@@ -96,6 +127,29 @@ export function createImageTools(connection, snippetClient) {
|
|
|
96
127
|
},
|
|
97
128
|
handler: async (args) => cropDocument(connection, snippetClient, args),
|
|
98
129
|
},
|
|
130
|
+
{
|
|
131
|
+
tool: {
|
|
132
|
+
name: 'photoshop_convert_image_mode',
|
|
133
|
+
description: 'Convert the document color mode (grayscale / rgb / cmyk / lab). Destructive and document-wide: the image is FLATTENED and, for grayscale, color is discarded (the confirmation prompt is auto-accepted). Use grayscale as the base for halftone / line-art workflows, or rgb to bring a CMYK/Lab doc back for normal editing. Returns updated document context.',
|
|
134
|
+
inputSchema: convertImageModeSchema,
|
|
135
|
+
outputSchema: {
|
|
136
|
+
type: 'object',
|
|
137
|
+
properties: {
|
|
138
|
+
converted: { type: 'boolean' },
|
|
139
|
+
requested_mode: { type: 'string' },
|
|
140
|
+
mode_before: { type: 'string' },
|
|
141
|
+
mode_after: { type: 'string' },
|
|
142
|
+
context: { type: 'object' },
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
annotations: {
|
|
146
|
+
title: 'Convert Image Mode (destructive)',
|
|
147
|
+
destructiveHint: true,
|
|
148
|
+
idempotentHint: true,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
handler: async (args) => convertImageMode(connection, snippetClient, args),
|
|
152
|
+
},
|
|
99
153
|
];
|
|
100
154
|
}
|
|
101
155
|
async function resizeImage(connection, snippetClient, rawArgs) {
|
|
@@ -130,6 +184,40 @@ async function resizeImage(connection, snippetClient, rawArgs) {
|
|
|
130
184
|
};
|
|
131
185
|
}
|
|
132
186
|
}
|
|
187
|
+
async function convertImageMode(connection, snippetClient, rawArgs) {
|
|
188
|
+
try {
|
|
189
|
+
const args = validateArgs(convertImageModeSchema, rawArgs);
|
|
190
|
+
const mode = args.mode;
|
|
191
|
+
const params = { mode };
|
|
192
|
+
if (mode === 'bitmap') {
|
|
193
|
+
params.frequency = args.frequency ?? 53;
|
|
194
|
+
params.angle = args.angle ?? 45;
|
|
195
|
+
params.shape = args.shape ?? 'round';
|
|
196
|
+
}
|
|
197
|
+
const script = await snippetClient.build('convertImageMode', params);
|
|
198
|
+
const result = await runScript(connection, script);
|
|
199
|
+
return {
|
|
200
|
+
content: [
|
|
201
|
+
{
|
|
202
|
+
type: 'text',
|
|
203
|
+
text: `Document converted to ${mode} mode.`,
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
structuredContent: result,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
return {
|
|
211
|
+
content: [
|
|
212
|
+
{
|
|
213
|
+
type: 'text',
|
|
214
|
+
text: `Error converting image mode: ${error instanceof Error ? error.message : String(error)}`,
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
isError: true,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
133
221
|
async function cropDocument(connection, snippetClient, rawArgs) {
|
|
134
222
|
try {
|
|
135
223
|
const args = validateArgs(cropDocumentSchema, rawArgs);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { getMetadata, getMetadataSchema } from './metadata-tools.js';
|
|
2
|
+
import { getHistory } from './history-tools.js';
|
|
3
|
+
import { getLayerTree } from './layer-tools.js';
|
|
4
|
+
import { getSelectionInfoHandler } from './selection-tools.js';
|
|
5
|
+
const INSPECT_WHATS = ['metadata', 'layer_tree', 'history', 'selection_info'];
|
|
6
|
+
const INSPECT_INPUT_SCHEMA = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
what: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
enum: [...INSPECT_WHATS],
|
|
12
|
+
description: 'Which read-only state to return. ' +
|
|
13
|
+
'metadata: document/IPTC/camera-EXIF/GPS/ACR develop settings + active context (optionally subset with `sections`; sections=["context"] is the cheap orientation probe). ' +
|
|
14
|
+
'layer_tree: the full recursive layer tree (name/kind/visibility/opacity/blend/clipping/bounds) — use whenever you need what is inside a group. ' +
|
|
15
|
+
'history: all history states + the current cursor, for deciding how far to undo. ' +
|
|
16
|
+
'selection_info: current selection bounds/coverage/edge-complexity without modifying anything.',
|
|
17
|
+
},
|
|
18
|
+
...getMetadataSchema.properties,
|
|
19
|
+
},
|
|
20
|
+
required: ['what'],
|
|
21
|
+
};
|
|
22
|
+
export function createInspectTools(connection, snippetClient) {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
tool: {
|
|
26
|
+
name: 'photoshop_inspect',
|
|
27
|
+
description: 'Read-only document inspection — choose with `what` (metadata / layer_tree / history / selection_info). This is the assess/orientation surface: call it at the start of a workflow and whenever you need fresh state. For metadata, pass `sections` to subset (e.g. ["context"] for a cheap probe). For an IMAGE-based check use photoshop_get_preview; for NUMERIC verification use photoshop_get_histogram / photoshop_compare_regions / photoshop_get_layer_bounds_diff (these stay separate, named tools on purpose). Read-only and idempotent.',
|
|
28
|
+
inputSchema: INSPECT_INPUT_SCHEMA,
|
|
29
|
+
outputSchema: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
document: { type: 'object' },
|
|
33
|
+
iptc: { type: 'object' },
|
|
34
|
+
camera: { type: 'object' },
|
|
35
|
+
gps: { type: 'object' },
|
|
36
|
+
acr: { type: 'object' },
|
|
37
|
+
source_metadata: { type: 'object' },
|
|
38
|
+
context: { type: 'object' },
|
|
39
|
+
documentName: { type: 'string' },
|
|
40
|
+
activeLayer: { type: 'string' },
|
|
41
|
+
topLevelCount: { type: 'number' },
|
|
42
|
+
tree: { type: 'array' },
|
|
43
|
+
totalStates: { type: 'number' },
|
|
44
|
+
currentIndex: { type: 'number' },
|
|
45
|
+
currentState: { type: 'string' },
|
|
46
|
+
canUndo: { type: 'boolean' },
|
|
47
|
+
canRedo: { type: 'boolean' },
|
|
48
|
+
states: { type: 'array' },
|
|
49
|
+
selection_info: { type: 'object' },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
annotations: {
|
|
53
|
+
title: 'Inspect Document State',
|
|
54
|
+
readOnlyHint: true,
|
|
55
|
+
idempotentHint: true,
|
|
56
|
+
openWorldHint: true,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
handler: async (args) => inspect(connection, snippetClient, args),
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
async function inspect(connection, snippetClient, rawArgs) {
|
|
64
|
+
const what = rawArgs.what;
|
|
65
|
+
const { what: _omit, ...rest } = rawArgs;
|
|
66
|
+
switch (what) {
|
|
67
|
+
case 'metadata':
|
|
68
|
+
return getMetadata(connection, snippetClient, rest);
|
|
69
|
+
case 'layer_tree':
|
|
70
|
+
return getLayerTree(connection, snippetClient);
|
|
71
|
+
case 'history':
|
|
72
|
+
return getHistory(connection, snippetClient);
|
|
73
|
+
case 'selection_info':
|
|
74
|
+
return getSelectionInfoHandler(connection, snippetClient);
|
|
75
|
+
default:
|
|
76
|
+
return {
|
|
77
|
+
content: [
|
|
78
|
+
{
|
|
79
|
+
type: 'text',
|
|
80
|
+
text: `Error: unknown inspect target "${String(what)}". Allowed: ${INSPECT_WHATS.join(', ')}.`,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
isError: true,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|