@hyperframes/studio 0.8.19 → 0.8.21

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 (45) hide show
  1. package/dist/assets/hyperframes-player-CIXNA_bj.js +460 -0
  2. package/dist/assets/{index-Dd0fsIIL.js → index-44gfDvkh.js} +1 -1
  3. package/dist/assets/{index-DxccOrkZ.js → index-9VfE7bZe.js} +1 -1
  4. package/dist/assets/{index-Bjd2hioj.js → index-CgGY8dAv.js} +164 -164
  5. package/dist/index.d.ts +28 -0
  6. package/dist/index.html +1 -1
  7. package/dist/index.js +1206 -234
  8. package/dist/index.js.map +1 -1
  9. package/package.json +7 -7
  10. package/src/App.tsx +2 -0
  11. package/src/contexts/StudioContext.tsx +10 -0
  12. package/src/hooks/useEditorSave.test.tsx +81 -3
  13. package/src/hooks/useEditorSave.ts +31 -6
  14. package/src/hooks/useGsapInteractionFailureTelemetry.test.tsx +48 -16
  15. package/src/hooks/useGsapInteractionFailureTelemetry.ts +5 -2
  16. package/src/hooks/useStudioContextValue.ts +9 -0
  17. package/src/player/hooks/timelineSyncHydration.test.ts +96 -0
  18. package/src/player/hooks/timelineSyncHydration.ts +47 -1
  19. package/src/player/hooks/useExpandedTimelineElements.test.ts +43 -0
  20. package/src/player/hooks/useExpandedTimelineElements.ts +52 -29
  21. package/src/player/hooks/useTimelineSyncCallbacks.ts +4 -0
  22. package/src/player/store/playerStore.ts +17 -2
  23. package/src/player/store/timelineElement.ts +21 -0
  24. package/src/utils/studioFileVersion.test.ts +37 -1
  25. package/src/utils/studioFileVersion.ts +12 -2
  26. package/src/utils/studioSaveDiagnostics.test.ts +29 -0
  27. package/src/utils/studioSaveDiagnostics.ts +4 -0
  28. package/src/webmcp/StudioAgentTools.tsx +105 -10
  29. package/src/webmcp/toolResult.ts +1 -1
  30. package/src/webmcp/tools/animationTools.test.ts +244 -0
  31. package/src/webmcp/tools/animationTools.ts +276 -0
  32. package/src/webmcp/tools/contentTools.test.ts +275 -0
  33. package/src/webmcp/tools/contentTools.ts +217 -0
  34. package/src/webmcp/tools/frameTools.test.ts +136 -0
  35. package/src/webmcp/tools/frameTools.ts +133 -0
  36. package/src/webmcp/tools/inspectTools.test.ts +197 -0
  37. package/src/webmcp/tools/inspectTools.ts +208 -0
  38. package/src/webmcp/tools/selectionTools.test.ts +164 -0
  39. package/src/webmcp/tools/selectionTools.ts +154 -0
  40. package/src/webmcp/tools/transformTools.test.ts +179 -0
  41. package/src/webmcp/tools/transformTools.ts +205 -0
  42. package/src/webmcp/useStudioAgentTools.test.tsx +71 -22
  43. package/src/webmcp/useStudioAgentTools.ts +195 -1
  44. package/src/webmcp/webmcpTestUtils.ts +91 -0
  45. package/dist/assets/hyperframes-player-BA-QO9CQ.js +0 -459
@@ -0,0 +1,154 @@
1
+ /**
2
+ * `studio_select` and `studio_seek`: pointing the human and the agent at the
3
+ * same thing.
4
+ *
5
+ * Selection is shared state, not a per-call argument. That is deliberate and it
6
+ * is also forced: most of Studio's edit handlers read the ambient React
7
+ * selection, and `applyDomSelection` only schedules a state update, so
8
+ * selecting and committing inside ONE call would write to whatever was selected
9
+ * before. Two tool calls are separated by a render, so the contract is select
10
+ * first, then act, which is also how a human works: click, then type.
11
+ */
12
+
13
+ import type { DomEditSelection } from "../../components/editor/domEditingTypes";
14
+ import { mintElementHandle, patchTargetAddress, resolveElementHandle } from "../handles";
15
+ import { toolFailure, toolOk, type ToolResult } from "../toolResult";
16
+
17
+ export interface SelectionToolDeps {
18
+ /** The preview iframe's document, or null before it mounts. */
19
+ getPreviewDocument: () => Document | null;
20
+ buildSelection: (element: HTMLElement) => Promise<DomEditSelection | null>;
21
+ applySelection: (selection: DomEditSelection) => void;
22
+ /** Out-of-loop seek. `requestSeek`, not `setCurrentTime`. */
23
+ requestSeek: (time: number) => void;
24
+ readPlayhead: () => { currentTime: number; duration: number; isPlaying: boolean };
25
+ }
26
+
27
+ export interface StudioSelectResult {
28
+ handle: string | null;
29
+ label: string;
30
+ tagName: string;
31
+ box: { x: number; y: number; width: number; height: number };
32
+ }
33
+
34
+ export async function studioSelect(
35
+ deps: SelectionToolDeps,
36
+ handle: string,
37
+ ): Promise<ToolResult<StudioSelectResult>> {
38
+ if (typeof handle !== "string" || !handle.trim()) {
39
+ return toolFailure("invalid", "handle must be a non-empty string", "Call studio_look first.");
40
+ }
41
+
42
+ // Three distinct failures, deliberately not collapsed: "the preview is not up
43
+ // yet" is a wait, "no such element" is a stale handle, and "could not build a
44
+ // selection" is an element Studio cannot drive. The agent's next move differs
45
+ // for each.
46
+ const doc = deps.getPreviewDocument();
47
+ if (!doc) {
48
+ return toolFailure(
49
+ "blocked",
50
+ "the preview is not mounted yet",
51
+ "Wait for the composition to load, then retry.",
52
+ );
53
+ }
54
+
55
+ const element = resolveElementHandle(doc, handle);
56
+ if (!element) {
57
+ return toolFailure(
58
+ "invalid",
59
+ `no element matches handle ${handle}`,
60
+ "The composition may have changed. Call studio_look for current handles.",
61
+ );
62
+ }
63
+
64
+ const selection = await deps.buildSelection(element);
65
+ if (!selection) {
66
+ return toolFailure(
67
+ "blocked",
68
+ `${handle} resolved to an element Studio cannot select`,
69
+ "Try a parent or child element from studio_look.",
70
+ );
71
+ }
72
+
73
+ deps.applySelection(selection);
74
+ return toolOk<StudioSelectResult>({
75
+ handle: mintElementHandle(patchTargetAddress(selection)),
76
+ label: selection.label,
77
+ tagName: selection.tagName,
78
+ box: selection.boundingBox,
79
+ });
80
+ }
81
+
82
+ export interface StudioSeekResult {
83
+ /** Where the playhead ACTUALLY landed, which may differ from the request. */
84
+ playhead: number;
85
+ duration: number;
86
+ isPlaying: boolean;
87
+ moved: boolean;
88
+ }
89
+
90
+ export function studioSeek(deps: SelectionToolDeps, time: number): ToolResult<StudioSeekResult> {
91
+ if (typeof time !== "number" || !Number.isFinite(time)) {
92
+ return toolFailure("invalid", "time must be a finite number of seconds");
93
+ }
94
+
95
+ const before = deps.readPlayhead();
96
+ // Deliberately NOT clamped here. `seek()` already clamps against the
97
+ // adapter's duration, which can differ from the store's, and a second clamp
98
+ // would give that invariant two owners that can disagree. Report where it
99
+ // landed instead.
100
+ deps.requestSeek(time);
101
+ const after = deps.readPlayhead();
102
+
103
+ // `requestSeek` is fire-and-forget: it cannot report that no adapter was
104
+ // mounted to receive it. Reading back is the only way to avoid claiming a
105
+ // seek that never happened.
106
+ const moved = after.currentTime !== before.currentTime;
107
+ if (!moved && before.currentTime !== time) {
108
+ return toolFailure(
109
+ "blocked",
110
+ `the playhead did not move; it is still at ${after.currentTime}`,
111
+ "The preview may not be ready. Check studio_look, then retry.",
112
+ );
113
+ }
114
+
115
+ return toolOk<StudioSeekResult>({
116
+ playhead: after.currentTime,
117
+ duration: after.duration,
118
+ isPlaying: after.isPlaying,
119
+ moved,
120
+ });
121
+ }
122
+
123
+ export const STUDIO_SELECT_INPUT_SCHEMA = {
124
+ type: "object",
125
+ properties: {
126
+ handle: { type: "string", description: "An element handle from studio_look." },
127
+ },
128
+ required: ["handle"],
129
+ additionalProperties: false,
130
+ } as const;
131
+
132
+ export const STUDIO_SELECT_DESCRIPTION = [
133
+ "Select an element in HyperFrames Studio, exactly as clicking it would:",
134
+ "the human sees the same selection box and inspector.",
135
+ "Takes a handle from studio_look. Most editing tools act on the CURRENT selection,",
136
+ "so call this first, then the edit.",
137
+ "Returns `ok: true` with the resulting selection, or `ok: false` with `kind`, `reason` and a `hint`.",
138
+ ].join(" ");
139
+
140
+ export const STUDIO_SEEK_INPUT_SCHEMA = {
141
+ type: "object",
142
+ properties: {
143
+ time: { type: "number", minimum: 0, description: "Playhead position in seconds." },
144
+ },
145
+ required: ["time"],
146
+ additionalProperties: false,
147
+ } as const;
148
+
149
+ export const STUDIO_SEEK_DESCRIPTION = [
150
+ "Move the playhead to a time in seconds. Pauses playback.",
151
+ "Out-of-range times are clamped by the player, so check the returned `playhead`",
152
+ "for where it actually landed rather than assuming it matched your request.",
153
+ "Returns `ok: true`, or `ok: false` with `kind`, `reason` and a `hint`.",
154
+ ].join(" ");
@@ -0,0 +1,179 @@
1
+ // @vitest-environment jsdom
2
+ import { describe, expect, it, vi } from "vitest";
3
+ import {
4
+ studioTransform,
5
+ type ElementBox,
6
+ type StudioTransformResult,
7
+ type TransformToolDeps,
8
+ } from "./transformTools";
9
+ import { expectFailure, expectOk, previewElement, selectionFor } from "../webmcpTestUtils";
10
+
11
+ /**
12
+ * A stand-in for the rendered box. happy-dom and jsdom report all-zero rects,
13
+ * so the box is injected rather than measured; these tests are about what the
14
+ * tool concludes from a box, not about layout.
15
+ */
16
+ function boxStore(initial: ElementBox) {
17
+ const box = { ...initial };
18
+ return {
19
+ read: () => ({ ...box }),
20
+ set: (next: Partial<ElementBox>) => Object.assign(box, next),
21
+ };
22
+ }
23
+
24
+ function transformDeps(overrides: Partial<TransformToolDeps> = {}): TransformToolDeps {
25
+ const element = previewElement('<h1 id="headline">Ship it</h1>', "headline");
26
+ return {
27
+ getCurrentSelection: () => selectionFor(element),
28
+ getWriteBlockedReason: () => null,
29
+ readBox: () => ({ x: 0, y: 0, width: 100, height: 50 }),
30
+ moveTo: async () => undefined,
31
+ resizeTo: async () => undefined,
32
+ rotateTo: async () => undefined,
33
+ ...overrides,
34
+ };
35
+ }
36
+
37
+ describe("studioTransform", () => {
38
+ it("reports the box read back, not the box requested", async () => {
39
+ const store = boxStore({ x: 0, y: 0, width: 100, height: 50 });
40
+ // The handler lands somewhere other than asked, which is what a clamp or a
41
+ // layout constraint does.
42
+ const resizeTo = vi.fn(async () => store.set({ width: 300, height: 120 }));
43
+
44
+ const result = await studioTransform(transformDeps({ readBox: store.read, resizeTo }), {
45
+ width: 999,
46
+ height: 999,
47
+ });
48
+
49
+ const ok = expectOk<StudioTransformResult>(result);
50
+ expect(ok.box.width).toBe(300);
51
+ expect(ok.box.height).toBe(120);
52
+ expect(ok.applied).toContain("resize");
53
+ });
54
+
55
+ it("reports a silent no-op as unchanged instead of success", async () => {
56
+ // handleGsapAwarePathOffsetCommit is `if (gsapCommitMutation) {...}` with no
57
+ // else branch. Without GSAP it resolves having written nothing, and echoing
58
+ // the request back would be a lie the agent builds on.
59
+ const store = boxStore({ x: 10, y: 10, width: 100, height: 50 });
60
+ const moveTo = vi.fn(async () => undefined);
61
+
62
+ const result = expectFailure(
63
+ await studioTransform(transformDeps({ readBox: store.read, moveTo }), { x: 500, y: 400 }),
64
+ );
65
+
66
+ expect(moveTo).toHaveBeenCalled();
67
+ expect(result.kind).toBe("blocked");
68
+ expect(result.reason).toMatch(/did not move/);
69
+ expect(result.hint).toMatch(/GSAP/);
70
+ });
71
+
72
+ it("separates what landed from what did not, in one call", async () => {
73
+ const store = boxStore({ x: 0, y: 0, width: 100, height: 50 });
74
+ const resizeTo = vi.fn(async () => store.set({ width: 200, height: 80 }));
75
+ const moveTo = vi.fn(async () => undefined);
76
+
77
+ const result = await studioTransform(transformDeps({ readBox: store.read, resizeTo, moveTo }), {
78
+ x: 40,
79
+ y: 40,
80
+ width: 200,
81
+ height: 80,
82
+ });
83
+
84
+ const ok = expectOk<StudioTransformResult>(result);
85
+ expect(ok.applied).toEqual(["resize"]);
86
+ expect(ok.unchanged.move).toMatch(/did not move/);
87
+ });
88
+
89
+ it("re-reads between operations so a later one sees the earlier result", async () => {
90
+ const store = boxStore({ x: 0, y: 0, width: 100, height: 50 });
91
+ const resizeTo = vi.fn(async () => store.set({ width: 200, height: 80 }));
92
+ const moveTo = vi.fn(async () => store.set({ x: 40, y: 40 }));
93
+
94
+ const result = await studioTransform(transformDeps({ readBox: store.read, resizeTo, moveTo }), {
95
+ x: 40,
96
+ y: 40,
97
+ width: 200,
98
+ height: 80,
99
+ });
100
+
101
+ // Move is judged against the box AFTER the resize. Comparing against the
102
+ // original would credit the resize's change to the move.
103
+ const ok = expectOk<StudioTransformResult>(result);
104
+ expect(ok.applied).toEqual(["resize", "move"]);
105
+ expect(ok.unchanged).toEqual({});
106
+ });
107
+
108
+ it("reports rotation as dispatched rather than verified", async () => {
109
+ // `rotate` is an individual transform property and does not appear in the
110
+ // computed transform, so there is no honest box-derived signal for it.
111
+ const rotateTo = vi.fn(async () => undefined);
112
+
113
+ const result = await studioTransform(transformDeps({ rotateTo }), { rotate: 15 });
114
+
115
+ const ok = expectOk<StudioTransformResult>(result);
116
+ expect(rotateTo).toHaveBeenCalledWith(expect.anything(), { angle: 15 });
117
+ expect(ok.applied).toEqual(["rotate"]);
118
+ });
119
+
120
+ it("refuses to write while a conflict is waiting for the user", async () => {
121
+ const moveTo = vi.fn();
122
+
123
+ const result = expectFailure(
124
+ await studioTransform(
125
+ transformDeps({ getWriteBlockedReason: () => "Auto-save is paused", moveTo }),
126
+ { x: 10, y: 10 },
127
+ ),
128
+ );
129
+
130
+ expect(result.kind).toBe("blocked");
131
+ expect(moveTo).not.toHaveBeenCalled();
132
+ });
133
+
134
+ it("requires x and y together, and width and height together", async () => {
135
+ const moveTo = vi.fn();
136
+ const resizeTo = vi.fn();
137
+ const deps = transformDeps({ moveTo, resizeTo });
138
+
139
+ expect(expectFailure(await studioTransform(deps, { x: 10 })).reason).toMatch(/together/);
140
+ expect(expectFailure(await studioTransform(deps, { width: 10 })).reason).toMatch(/together/);
141
+ expect(moveTo).not.toHaveBeenCalled();
142
+ expect(resizeTo).not.toHaveBeenCalled();
143
+ });
144
+
145
+ it("rejects a negative size and an empty request", async () => {
146
+ const deps = transformDeps();
147
+
148
+ expect(expectFailure(await studioTransform(deps, { width: -1, height: 10 })).kind).toBe(
149
+ "invalid",
150
+ );
151
+ expect(expectFailure(await studioTransform(deps, {})).reason).toMatch(/at least one/);
152
+ });
153
+
154
+ it("rejects non-finite numbers rather than passing them to a handler", async () => {
155
+ const moveTo = vi.fn();
156
+
157
+ const result = expectFailure(
158
+ await studioTransform(transformDeps({ moveTo }), { x: Number.NaN, y: 10 }),
159
+ );
160
+
161
+ expect(result.kind).toBe("invalid");
162
+ expect(moveTo).not.toHaveBeenCalled();
163
+ });
164
+
165
+ it("fails when nothing is selected", async () => {
166
+ const moveTo = vi.fn();
167
+
168
+ const result = expectFailure(
169
+ await studioTransform(transformDeps({ getCurrentSelection: () => null, moveTo }), {
170
+ x: 1,
171
+ y: 1,
172
+ }),
173
+ );
174
+
175
+ expect(result.kind).toBe("invalid");
176
+ expect(result.hint).toMatch(/studio_select/);
177
+ expect(moveTo).not.toHaveBeenCalled();
178
+ });
179
+ });
@@ -0,0 +1,205 @@
1
+ /**
2
+ * `studio_transform`: move, resize and rotate, as a drag would.
3
+ *
4
+ * This tool reads the element's box back after every write and reports what
5
+ * ACTUALLY changed. That is not belt-and-braces, it is the only thing standing
6
+ * between an agent and a silent lie, because two of the three handlers can do
7
+ * nothing and resolve:
8
+ *
9
+ * - The handlers exposed on `DomEditActionsValue` are the GSAP-AWARE wrappers
10
+ * (`useDomEditSession.ts` aliases them), not the CSS ones in
11
+ * `useDomGeometryCommits.ts`.
12
+ * - `handleGsapAwarePathOffsetCommit` and `handleGsapAwareRotationCommit` are
13
+ * `if (gsapCommitMutation) { ...intercept... }` with NO else branch. In a
14
+ * composition with no GSAP they return having done nothing. The adjacent
15
+ * comments confirm that is deliberate: there is no CSS fallback to write to.
16
+ * - `handleGsapAwareBoxSizeCommit` is different. It runs through
17
+ * `runGestureTransaction` with a scale route and a width/height route, so
18
+ * resize works more generally than the other two.
19
+ *
20
+ * Read back, do not assume.
21
+ */
22
+
23
+ import type { DomEditSelection } from "../../components/editor/domEditingTypes";
24
+ import { toolFailure, toolOk, type ToolFailure, type ToolResult } from "../toolResult";
25
+
26
+ export interface ElementBox {
27
+ x: number;
28
+ y: number;
29
+ width: number;
30
+ height: number;
31
+ }
32
+
33
+ export interface TransformToolDeps {
34
+ getCurrentSelection: () => DomEditSelection | null;
35
+ getWriteBlockedReason: () => string | null;
36
+ /** The element's box as it renders right now. */
37
+ readBox: (selection: DomEditSelection) => ElementBox;
38
+ moveTo: (selection: DomEditSelection, next: { x: number; y: number }) => Promise<void>;
39
+ resizeTo: (selection: DomEditSelection, next: { width: number; height: number }) => Promise<void>;
40
+ rotateTo: (selection: DomEditSelection, next: { angle: number }) => Promise<void>;
41
+ }
42
+
43
+ export interface StudioTransformInput {
44
+ x?: unknown;
45
+ y?: unknown;
46
+ width?: unknown;
47
+ height?: unknown;
48
+ rotate?: unknown;
49
+ }
50
+
51
+ export interface StudioTransformResult {
52
+ /** The box as it renders after the write, read back, not echoed. */
53
+ box: ElementBox;
54
+ applied: string[];
55
+ /** Requested operations whose effect could not be observed, with why. */
56
+ unchanged: Record<string, string>;
57
+ }
58
+
59
+ const NO_OP_HINT =
60
+ "Move and rotate are written as GSAP code; a composition with no GSAP timeline has nothing to write to. studio_inspect reports the element's animations.";
61
+
62
+ function readNumber(value: unknown): number | null {
63
+ return typeof value === "number" && Number.isFinite(value) ? value : null;
64
+ }
65
+
66
+ function guard(deps: TransformToolDeps): ToolFailure | null {
67
+ const blocked = deps.getWriteBlockedReason();
68
+ if (blocked) return toolFailure("blocked", blocked, "Resolve it in Studio, then retry.");
69
+ if (!deps.getCurrentSelection()) {
70
+ return toolFailure("invalid", "nothing is selected", "Call studio_select first.");
71
+ }
72
+ return null;
73
+ }
74
+
75
+ interface TransformRequest {
76
+ move: { x: number; y: number } | null;
77
+ size: { width: number; height: number } | null;
78
+ rotate: number | null;
79
+ }
80
+
81
+ /**
82
+ * Both or neither. Accepting one axis alone would mean inventing the other from
83
+ * the current value, which moves the element somewhere the caller did not ask
84
+ * for.
85
+ */
86
+ function parsePair(
87
+ a: unknown,
88
+ b: unknown,
89
+ names: [string, string],
90
+ min = Number.NEGATIVE_INFINITY,
91
+ ): { pair: [number, number] | null } | ToolFailure {
92
+ const first = readNumber(a);
93
+ const second = readNumber(b);
94
+ if (first === null && second === null) return { pair: null };
95
+ if (first === null || second === null) {
96
+ return toolFailure("invalid", `${names[0]} and ${names[1]} must be given together`);
97
+ }
98
+ if (first < min || second < min) {
99
+ return toolFailure("invalid", `${names[0]} and ${names[1]} must be at least ${min}`);
100
+ }
101
+ return { pair: [first, second] };
102
+ }
103
+
104
+ function isFailure(value: object): value is ToolFailure {
105
+ return "ok" in value;
106
+ }
107
+
108
+ function parseRequest(input: StudioTransformInput): TransformRequest | ToolFailure {
109
+ const move = parsePair(input.x, input.y, ["x", "y"]);
110
+ if (isFailure(move)) return move;
111
+ const size = parsePair(input.width, input.height, ["width", "height"], 0);
112
+ if (isFailure(size)) return size;
113
+ const rotate = readNumber(input.rotate);
114
+
115
+ if (!move.pair && !size.pair && rotate === null) {
116
+ return toolFailure(
117
+ "invalid",
118
+ "give at least one of x, y, width, height, rotate as a finite number",
119
+ );
120
+ }
121
+
122
+ return {
123
+ move: move.pair ? { x: move.pair[0], y: move.pair[1] } : null,
124
+ size: size.pair ? { width: size.pair[0], height: size.pair[1] } : null,
125
+ rotate,
126
+ };
127
+ }
128
+
129
+ export async function studioTransform(
130
+ deps: TransformToolDeps,
131
+ input: StudioTransformInput,
132
+ ): Promise<ToolResult<StudioTransformResult>> {
133
+ const request = parseRequest(input);
134
+ if (isFailure(request)) return request;
135
+
136
+ const blocked = guard(deps);
137
+ if (blocked) return blocked;
138
+
139
+ const selection = deps.getCurrentSelection();
140
+ if (!selection) return toolFailure("invalid", "nothing is selected");
141
+
142
+ const applied: string[] = [];
143
+ const unchanged: Record<string, string> = {};
144
+
145
+ // Sequential, and each one re-reads first, so a move is judged against the box
146
+ // AFTER a resize in the same call rather than against the original.
147
+ if (request.size) {
148
+ const before = deps.readBox(selection);
149
+ await deps.resizeTo(selection, request.size);
150
+ const after = deps.readBox(selection);
151
+ if (after.width !== before.width || after.height !== before.height) applied.push("resize");
152
+ else unchanged.resize = "the element's size did not change";
153
+ }
154
+
155
+ if (request.move) {
156
+ const before = deps.readBox(selection);
157
+ await deps.moveTo(selection, request.move);
158
+ const after = deps.readBox(selection);
159
+ if (after.x !== before.x || after.y !== before.y) applied.push("move");
160
+ else unchanged.move = `the element did not move. ${NO_OP_HINT}`;
161
+ }
162
+
163
+ if (request.rotate !== null) {
164
+ // Rotation is written as the CSS `rotate` property, an individual transform
165
+ // property that does NOT appear in getComputedStyle().transform. There is no
166
+ // reliable box-derived signal, so this is reported as dispatched rather than
167
+ // verified, and the description says so.
168
+ await deps.rotateTo(selection, { angle: request.rotate });
169
+ applied.push("rotate");
170
+ }
171
+
172
+ if (applied.length === 0) {
173
+ return toolFailure(
174
+ "blocked",
175
+ `nothing changed: ${Object.values(unchanged).join("; ")}`,
176
+ NO_OP_HINT,
177
+ );
178
+ }
179
+
180
+ return toolOk<StudioTransformResult>({ box: deps.readBox(selection), applied, unchanged });
181
+ }
182
+
183
+ export const STUDIO_TRANSFORM_INPUT_SCHEMA = {
184
+ type: "object",
185
+ properties: {
186
+ x: { type: "number", description: "New x offset in pixels. Must be paired with y." },
187
+ y: { type: "number", description: "New y offset in pixels. Must be paired with x." },
188
+ width: { type: "number", minimum: 0, description: "New width. Must be paired with height." },
189
+ height: { type: "number", minimum: 0, description: "New height. Must be paired with width." },
190
+ rotate: { type: "number", description: "Rotation in degrees." },
191
+ },
192
+ additionalProperties: false,
193
+ } as const;
194
+
195
+ export const STUDIO_TRANSFORM_DESCRIPTION = [
196
+ "Move, resize or rotate the CURRENTLY SELECTED element, the way a drag would.",
197
+ "Call studio_select first. Give x with y, and width with height.",
198
+ "The result's `box` is READ BACK after the write, not echoed from your request, and",
199
+ "`applied` lists what actually took effect. Check it.",
200
+ "Move and rotate are written as GSAP code, so in a composition with no GSAP timeline they",
201
+ "do nothing; that shows up in `unchanged` rather than as a false success.",
202
+ "Rotation is reported as dispatched rather than verified, because the CSS `rotate` property",
203
+ "does not appear in the element's computed transform.",
204
+ "Returns `ok: true`, or `ok: false` with `kind`, `reason` and a `hint`.",
205
+ ].join(" ");