@iwsdk/cli 1.1.0-rc.1 → 1.1.0-rc.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.
package/dist/contract.js CHANGED
@@ -8,21 +8,48 @@ const DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS = 30_000;
8
8
  const UI_RENDER_PREVIEW_TIMEOUT_MS = 60_000;
9
9
  const ASSET_RENDER_PREVIEW_TIMEOUT_MS = 120_000;
10
10
  const BROWSER_RUNTIME_COMMAND_TIMEOUT_MS = 60_000;
11
+ /**
12
+ * IWER resolves a running hand sequence at most 28 s after dispatch, with a
13
+ * partial result when it runs out of time. The default budget, less the
14
+ * relay's margin, would give up first.
15
+ */
16
+ const HAND_SEQUENCE_COMMAND_TIMEOUT_MS = 40_000;
17
+ /** The longest `duration` (seconds) that extends a default command timeout. */
18
+ const MAX_TIMED_COMMAND_DURATION_S = 3_600;
19
+ /** IWER replies to these only once their `duration` (seconds) has elapsed. */
20
+ const TIMED_RUNTIME_METHODS = new Set([
21
+ 'animate_to',
22
+ 'select',
23
+ 'set_hand_pose',
24
+ 'set_select_value',
25
+ ]);
11
26
  const BROWSER_RUNTIME_METHODS = new Set([
12
27
  'browser_interact',
13
28
  'browser_profile',
29
+ 'browser_set_muted',
14
30
  'browser_snapshot',
15
31
  'get_console_logs',
16
32
  'reload_page',
17
33
  'screenshot',
18
34
  ]);
19
- function getDefaultRuntimeCommandTimeoutMs(method) {
35
+ function getDefaultRuntimeCommandTimeoutMs(method, params) {
20
36
  if (method === 'asset_render_preview') {
21
37
  return ASSET_RENDER_PREVIEW_TIMEOUT_MS;
22
38
  }
23
39
  if (method === 'ui_render_preview') {
24
40
  return UI_RENDER_PREVIEW_TIMEOUT_MS;
25
41
  }
42
+ if (method === 'run_sequence') {
43
+ return HAND_SEQUENCE_COMMAND_TIMEOUT_MS;
44
+ }
45
+ if (TIMED_RUNTIME_METHODS.has(method)) {
46
+ // A long fade or ramp gets the default budget on top of its duration.
47
+ const duration = params?.duration;
48
+ return typeof duration === 'number' && duration > 0
49
+ ? DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS +
50
+ Math.ceil(Math.min(duration, MAX_TIMED_COMMAND_DURATION_S) * 1000)
51
+ : DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS;
52
+ }
26
53
  return BROWSER_RUNTIME_METHODS.has(method)
27
54
  ? BROWSER_RUNTIME_COMMAND_TIMEOUT_MS
28
55
  : DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS;
@@ -36,6 +63,41 @@ function describeValue(value) {
36
63
  }
37
64
  return typeof value;
38
65
  }
66
+ /**
67
+ * The error of the union member a value was evidently meant for: the only one
68
+ * of its type, or the object shape sharing the most of its keys. A misspelt
69
+ * key in a hand direction then reports that key, not "a supported shape".
70
+ */
71
+ function closestShapeError(value, candidates, errors) {
72
+ const kind = describeValue(value);
73
+ const sameKind = candidates
74
+ .map((candidate, index) => ({ candidate, error: errors[index] }))
75
+ .filter(({ candidate }) => candidate.type == null ||
76
+ candidate.type === kind ||
77
+ (candidate.type === 'integer' && kind === 'number'));
78
+ if (sameKind.length === 1) {
79
+ return sameKind[0].error;
80
+ }
81
+ if (!isRecord(value)) {
82
+ return null;
83
+ }
84
+ const keys = Object.keys(value);
85
+ let best = null;
86
+ let bestScore = 0;
87
+ let tied = false;
88
+ for (const entry of sameKind) {
89
+ const score = keys.filter((key) => entry.candidate.properties?.[key] != null).length;
90
+ if (score > bestScore) {
91
+ best = entry;
92
+ bestScore = score;
93
+ tied = false;
94
+ }
95
+ else if (score === bestScore) {
96
+ tied = true;
97
+ }
98
+ }
99
+ return best && !tied ? best.error : null;
100
+ }
39
101
  function assertSchemaValue(value, schema, path) {
40
102
  if (schema.oneOf?.length) {
41
103
  const matches = schema.oneOf.filter((candidate) => {
@@ -52,17 +114,20 @@ function assertSchemaValue(value, schema, path) {
52
114
  }
53
115
  }
54
116
  if (schema.anyOf?.length) {
117
+ const errors = [];
55
118
  const matches = schema.anyOf.some((candidate) => {
56
119
  try {
57
120
  assertSchemaValue(value, candidate, path);
58
121
  return true;
59
122
  }
60
- catch {
123
+ catch (error) {
124
+ errors.push(error);
61
125
  return false;
62
126
  }
63
127
  });
64
128
  if (!matches) {
65
- throw new Error(`${path} must match a supported shape`);
129
+ throw (closestShapeError(value, schema.anyOf, errors) ??
130
+ new Error(`${path} must match a supported shape`));
66
131
  }
67
132
  }
68
133
  if (schema.not) {
@@ -153,6 +218,7 @@ const IWSDK_RUNTIME_STATE_DIR = '.iwsdk/runtime';
153
218
  const IWSDK_RUNTIME_LOGS_DIR = '.iwsdk/runtime/logs';
154
219
  const IWSDK_RUNTIME_SESSION_PATH = '.iwsdk/runtime/session.json';
155
220
  const IWSDK_RUNTIME_LAUNCH_PATH = '.iwsdk/runtime/launch.json';
221
+ const IWSDK_RUNTIME_COMMAND_CREDENTIAL_PATH = '.iwsdk/runtime/command-credential.json';
156
222
  const IWSDK_RUNTIME_STATE_SCHEMA_VERSION = 2;
157
223
  const IWSDK_RUNTIME_BROWSER_READY_SCHEMA_VERSION = 2;
158
224
  const INTERNAL_BROWSER_PROBE_METHOD = '__iwsdk_browser_probe';
@@ -495,6 +561,364 @@ const SCENE_OBJECT_INSPECTION_ASSESSMENT_SCHEMA = {
495
561
  },
496
562
  required: ['id', 'status', 'evidenceRefs', 'observation'],
497
563
  };
564
+ // =============================================================================
565
+ // Emulated device shapes
566
+ // =============================================================================
567
+ // The xr_* schemas mirror IWER's extension-bridge contract and its JSON Schema
568
+ // catalog (`iwer/lib/remote/catalog.js`): the same parameters, unions and
569
+ // descriptions. vite-plugin-dev's tests compare them with the catalog of the
570
+ // IWER it installs.
571
+ const XR_POSITION_SCHEMA = {
572
+ type: 'object',
573
+ description: 'A 3D position in metres, XR-origin relative.',
574
+ properties: {
575
+ x: { type: 'number' },
576
+ y: { type: 'number' },
577
+ z: { type: 'number' },
578
+ },
579
+ required: ['x', 'y', 'z'],
580
+ };
581
+ const XR_STRICT_POSITION_SCHEMA = {
582
+ ...XR_POSITION_SCHEMA,
583
+ additionalProperties: false,
584
+ };
585
+ const XR_TUPLE3_SCHEMA = {
586
+ type: 'array',
587
+ items: { type: 'number' },
588
+ minItems: 3,
589
+ maxItems: 3,
590
+ };
591
+ const XR_QUATERNION_SCHEMA = {
592
+ type: 'object',
593
+ additionalProperties: false,
594
+ properties: {
595
+ x: { type: 'number', description: 'Quaternion X component' },
596
+ y: { type: 'number', description: 'Quaternion Y component' },
597
+ z: { type: 'number', description: 'Quaternion Z component' },
598
+ w: { type: 'number', description: 'Quaternion W component' },
599
+ },
600
+ required: ['x', 'y', 'z', 'w'],
601
+ };
602
+ const XR_EULER_SCHEMA = {
603
+ type: 'object',
604
+ additionalProperties: false,
605
+ properties: {
606
+ pitch: { type: 'number', description: 'Pitch in degrees (X rotation)' },
607
+ yaw: { type: 'number', description: 'Yaw in degrees (Y rotation)' },
608
+ roll: { type: 'number', description: 'Roll in degrees (Z rotation)' },
609
+ },
610
+ };
611
+ const XR_ORIENTATION_SCHEMA = {
612
+ anyOf: [XR_QUATERNION_SCHEMA, XR_EULER_SCHEMA],
613
+ description: 'Orientation as a quaternion {x,y,z,w} or euler degrees {pitch,yaw,roll}.',
614
+ };
615
+ const XR_DIRECTION_SCHEMA = {
616
+ anyOf: [
617
+ {
618
+ type: 'string',
619
+ enum: [
620
+ 'up',
621
+ 'down',
622
+ 'forward',
623
+ 'back',
624
+ 'left',
625
+ 'right',
626
+ 'toward-head',
627
+ 'away-from-head',
628
+ ],
629
+ },
630
+ XR_STRICT_POSITION_SCHEMA,
631
+ XR_TUPLE3_SCHEMA,
632
+ ],
633
+ description: 'A direction: a name (up, down, forward, back, left, right, toward-head, away-from-head; forward/left/right follow where the headset faces) or an XR-origin vector (approximate is fine).',
634
+ };
635
+ // Hand directions come before quaternion/euler and every orientation object
636
+ // is strict, so a misspelt hand direction is an error, not an empty euler.
637
+ const XR_HAND_DIRECTIONS_SCHEMA = {
638
+ type: 'object',
639
+ additionalProperties: false,
640
+ description: 'Hand orientation by direction: where the fingers point plus where the palm faces OR where the thumb side points. A thumbs up is {fingers:"forward", thumb:"up"}.',
641
+ properties: {
642
+ fingers: XR_DIRECTION_SCHEMA,
643
+ palm: XR_DIRECTION_SCHEMA,
644
+ thumb: XR_DIRECTION_SCHEMA,
645
+ },
646
+ required: ['fingers'],
647
+ };
648
+ const XR_PLACEMENT_ORIENTATION_SCHEMA = {
649
+ anyOf: [
650
+ { type: 'string', enum: ['auto'] },
651
+ XR_HAND_DIRECTIONS_SCHEMA,
652
+ XR_QUATERNION_SCHEMA,
653
+ XR_EULER_SCHEMA,
654
+ ],
655
+ description: 'For hands: {fingers, palm|thumb} directions, or "auto" (a natural reach from the shoulder toward the position). A quaternion {x,y,z,w} or euler degrees {pitch,yaw,roll} sets the device (for hands, the target ray) as before.',
656
+ };
657
+ const XR_HAND_ANCHOR_SCHEMA = {
658
+ type: 'string',
659
+ description: 'Hands: the point of the hand `position` places and keeps there while the hand changes shape: index-tip (press), grasp (where thumb and index tips meet in a full pinch), wrist (gestures), grip, thumb-tip, target-ray (default), or a WebXR joint name.',
660
+ };
661
+ const XR_EASING_SCHEMA = {
662
+ type: 'string',
663
+ enum: ['linear', 'minimum-jerk'],
664
+ description: 'Time curve; minimum-jerk starts and stops like a human reach.',
665
+ };
666
+ const XR_HAND_DEVICE_SCHEMA = {
667
+ type: 'string',
668
+ enum: ['hand-left', 'hand-right'],
669
+ description: 'A hand-tracking device.',
670
+ };
671
+ // One short gloss per built-in IWER hand pose, for xr_set_hand_pose. Keep in
672
+ // sync with IWER's BUILTIN_HAND_POSE_IDS (checked by vite-plugin-dev's tests).
673
+ const XR_HAND_POSE_GLOSS = {
674
+ default: 'relaxed',
675
+ pinch: 'thumb and index touching',
676
+ point: 'index extended',
677
+ open: 'high five',
678
+ flat: 'fingers together, blade',
679
+ fist: 'closed fist',
680
+ 'thumbs-up': 'fist with thumb up',
681
+ 'finger-gun': 'index and thumb out',
682
+ peace: 'V sign',
683
+ three: 'index, middle, ring up',
684
+ four: 'four fingers up, thumb folded',
685
+ ok: 'thumb-index circle',
686
+ rock: 'index and pinky out',
687
+ call: 'thumb and pinky out',
688
+ 'pinch-middle': 'thumb to middle tip',
689
+ 'pinch-ring': 'thumb to ring tip',
690
+ 'pinch-pinky': 'thumb to pinky tip',
691
+ tripod: 'thumb, index, middle tips together',
692
+ 'key-pinch': 'thumb against side of index',
693
+ microgesture: 'loose curl, thumb by the side of the index',
694
+ grip: 'wrapped around a handle',
695
+ claw: 'holding a ball',
696
+ hook: 'carrying a bag handle',
697
+ cup: 'scooping water',
698
+ };
699
+ const XR_HAND_POSE_GLOSSES = Object.entries(XR_HAND_POSE_GLOSS)
700
+ .map(([id, gloss]) => `${id} (${gloss})`)
701
+ .join(', ');
702
+ const XR_FINGER_POSE_SCHEMA = {
703
+ anyOf: [
704
+ { type: 'string' },
705
+ {
706
+ type: 'object',
707
+ additionalProperties: false,
708
+ properties: {
709
+ poseId: { type: 'string' },
710
+ weight: { type: 'number', minimum: 0, maximum: 1 },
711
+ },
712
+ required: ['poseId'],
713
+ },
714
+ ],
715
+ description: 'A pose id, or {poseId, weight} where weight 0-1 blends from the base pose toward it.',
716
+ };
717
+ const XR_FINGER_POSES_SCHEMA = {
718
+ type: 'object',
719
+ additionalProperties: false,
720
+ description: 'Fingers to take from other poses, on top of poseId.',
721
+ properties: {
722
+ thumb: XR_FINGER_POSE_SCHEMA,
723
+ index: XR_FINGER_POSE_SCHEMA,
724
+ middle: XR_FINGER_POSE_SCHEMA,
725
+ ring: XR_FINGER_POSE_SCHEMA,
726
+ pinky: XR_FINGER_POSE_SCHEMA,
727
+ },
728
+ };
729
+ const XR_INPUT_STATE_SCHEMA = {
730
+ type: 'object',
731
+ additionalProperties: false,
732
+ properties: {
733
+ connected: { type: 'boolean' },
734
+ position: XR_POSITION_SCHEMA,
735
+ orientation: XR_ORIENTATION_SCHEMA,
736
+ },
737
+ };
738
+ const XR_HAND_STATE_SCHEMA = {
739
+ ...XR_INPUT_STATE_SCHEMA,
740
+ properties: {
741
+ ...XR_INPUT_STATE_SCHEMA.properties,
742
+ poseId: { type: 'string' },
743
+ pinchValue: { type: 'number', minimum: 0, maximum: 1 },
744
+ },
745
+ };
746
+ const XR_MICROGESTURE_SCHEMA = {
747
+ type: 'string',
748
+ enum: ['swipe-left', 'swipe-right', 'swipe-forward', 'swipe-backward', 'tap'],
749
+ description: "A thumb microgesture on the side of the curled index finger: swipe left / right (the user's), forward (over the finger), backward (toward the palm), or tap.",
750
+ };
751
+ // --- run_sequence ------------------------------------------------------------
752
+ const XR_FRACTION_SCHEMA = {
753
+ type: 'number',
754
+ minimum: 0,
755
+ maximum: 1,
756
+ };
757
+ const XR_TIMED_WINDOW_PROPERTIES = {
758
+ start: XR_FRACTION_SCHEMA,
759
+ end: XR_FRACTION_SCHEMA,
760
+ easing: XR_EASING_SCHEMA,
761
+ };
762
+ const XR_SEQUENCE_TARGET_SCHEMA = {
763
+ anyOf: [
764
+ { type: 'string' },
765
+ {
766
+ type: 'object',
767
+ additionalProperties: false,
768
+ properties: {
769
+ name: { type: 'string' },
770
+ face: {
771
+ type: 'string',
772
+ enum: ['front', 'back', 'top', 'bottom', 'left', 'right'],
773
+ },
774
+ },
775
+ required: ['name'],
776
+ },
777
+ ],
778
+ description: 'A target name from xr_list_targets, or {name, face}; resolved again when the step starts.',
779
+ };
780
+ const XR_SEQUENCE_POSITION_SCHEMA = {
781
+ anyOf: [
782
+ XR_TUPLE3_SCHEMA,
783
+ {
784
+ type: 'object',
785
+ additionalProperties: false,
786
+ properties: {
787
+ x: { type: 'number' },
788
+ y: { type: 'number' },
789
+ z: { type: 'number' },
790
+ normal: XR_DIRECTION_SCHEMA,
791
+ },
792
+ required: ['x', 'y', 'z'],
793
+ },
794
+ {
795
+ type: 'object',
796
+ additionalProperties: false,
797
+ properties: {
798
+ relativeTo: { type: 'string', enum: ['head', 'body'] },
799
+ x: { type: 'number' },
800
+ y: { type: 'number' },
801
+ z: { type: 'number' },
802
+ },
803
+ required: ['relativeTo', 'x', 'y', 'z'],
804
+ },
805
+ ],
806
+ description: 'XR-origin metres (optionally with the surface normal), or {relativeTo:"head"|"body", x right, y up, z back} turning with the body, never with head pitch; "body" measures y from the floor.',
807
+ };
808
+ const XR_STAND_OFF_SCHEMA = {
809
+ type: 'object',
810
+ additionalProperties: false,
811
+ properties: {
812
+ distance: { type: 'number', minimum: 0 },
813
+ normal: XR_DIRECTION_SCHEMA,
814
+ },
815
+ required: ['distance'],
816
+ };
817
+ const XR_SEQUENCE_STEP_SCHEMA = {
818
+ type: 'object',
819
+ additionalProperties: false,
820
+ properties: {
821
+ label: { type: 'string' },
822
+ duration: {
823
+ anyOf: [
824
+ { type: 'number', minimum: 0 },
825
+ { type: 'string', enum: ['auto'] },
826
+ ],
827
+ description: 'Seconds for the reach, or "auto" (the default for moves): scaled to distance, turn and pose change.',
828
+ },
829
+ target: XR_SEQUENCE_TARGET_SCHEMA,
830
+ position: XR_SEQUENCE_POSITION_SCHEMA,
831
+ offset: {
832
+ anyOf: [
833
+ XR_STRICT_POSITION_SCHEMA,
834
+ {
835
+ type: 'object',
836
+ additionalProperties: false,
837
+ properties: { normal: { type: 'number' } },
838
+ required: ['normal'],
839
+ },
840
+ ],
841
+ description: 'Added to the target or position; {normal:d} moves d metres along the surface normal. Setting a held object down: its clearance above the surface.',
842
+ },
843
+ approach: {
844
+ ...XR_STAND_OFF_SCHEMA,
845
+ description: 'Come straight in along the surface normal (straight down while holding) for the last `distance` metres.',
846
+ },
847
+ depart: {
848
+ ...XR_STAND_OFF_SCHEMA,
849
+ description: 'Lift straight off first, along the last surface normal (straight up while holding).',
850
+ },
851
+ press: {
852
+ type: 'object',
853
+ additionalProperties: false,
854
+ properties: {
855
+ depth: { type: 'number', minimum: 0, maximum: 0.015 },
856
+ hold: { type: 'number', minimum: 0, maximum: 0.2 },
857
+ retract: { type: 'number', minimum: 0.05 },
858
+ },
859
+ description: 'Press the target with the index fingertip: reach, go `depth` m (default 0.008) past the surface, hold `hold` s, pull back `retract` m. Implies anchor index-tip and pose point. Use this for buttons, not a pinch.',
860
+ },
861
+ anchor: XR_HAND_ANCHOR_SCHEMA,
862
+ orientation: XR_PLACEMENT_ORIENTATION_SCHEMA,
863
+ poseId: {
864
+ anyOf: [
865
+ { type: 'string' },
866
+ {
867
+ type: 'object',
868
+ additionalProperties: false,
869
+ properties: {
870
+ value: { type: 'string' },
871
+ ...XR_TIMED_WINDOW_PROPERTIES,
872
+ },
873
+ required: ['value'],
874
+ },
875
+ ],
876
+ description: 'Pose to fade to during the step; {value, start, end} as fractions of the reach. Never "pinch": poses do not select.',
877
+ },
878
+ fingers: XR_FINGER_POSES_SCHEMA,
879
+ pinch: {
880
+ anyOf: [
881
+ XR_FRACTION_SCHEMA,
882
+ {
883
+ type: 'object',
884
+ additionalProperties: false,
885
+ properties: {
886
+ value: XR_FRACTION_SCHEMA,
887
+ ...XR_TIMED_WINDOW_PROPERTIES,
888
+ },
889
+ required: ['value'],
890
+ },
891
+ {
892
+ type: 'object',
893
+ additionalProperties: false,
894
+ properties: {
895
+ value: XR_FRACTION_SCHEMA,
896
+ at: { type: 'string', enum: ['arrival'] },
897
+ },
898
+ required: ['value', 'at'],
899
+ },
900
+ ],
901
+ description: 'Pinch 0..1 (selects at 0.9, lets go at 0.7). {value:1, at:"arrival"} opens to a grip and closes as the hand arrives; on a target it implies anchor grasp.',
902
+ },
903
+ body: {
904
+ type: 'object',
905
+ additionalProperties: false,
906
+ properties: {
907
+ position: XR_SEQUENCE_POSITION_SCHEMA,
908
+ stepTo: XR_SEQUENCE_TARGET_SCHEMA,
909
+ facing: XR_DIRECTION_SCHEMA,
910
+ },
911
+ description: 'Move the body first: to position, or a step closer to stepTo; facing turns it. The hand goes along.',
912
+ },
913
+ microgesture: {
914
+ ...XR_MICROGESTURE_SCHEMA,
915
+ description: 'Make a microgesture where the hand is, as a step of its own (only label alongside); events report it by name.',
916
+ },
917
+ },
918
+ };
919
+ const XR_RUN_SEQUENCE_DESCRIPTION = "Run a whole hand interaction in one call with natural motion: one smooth arc per move, the head turning to each target first, the body leaning or stepping closer when needed, the other hand resting by the hip. Steps run in order and each step's properties animate together. Positions are XR-origin metres; -Z is forward, +Y up. Resolves when done with the select events the app saw, step times, press contact times, warnings and the final hand state. " +
920
+ 'Rules: press buttons with `press`, not a pinch. To pick something up, target it with `pinch:{value:1,at:"arrival"}` (the grasp point, between thumb and index, goes on the target). While holding, targeting a surface sets the object down on it; let go with pinch 0. The anchor carries over to later steps. A thumbs up is poseId "thumbs-up" with orientation {fingers:"forward",thumb:"up"} at a head-relative position. A microgesture is a step of its own, {"microgesture":"swipe-left"}, with the hand raised in view and the pinch open (see xr_microgesture). Get names from xr_list_targets and check a plan with dryRun:true first. ' +
921
+ 'Example: {"device":"hand-right","steps":[{"label":"reach","target":"button","press":{}},{"label":"grab","target":"piece","approach":{"distance":0.06},"pinch":{"value":1,"at":"arrival"}},{"label":"carry","target":"tray","depart":{"distance":0.08},"approach":{"distance":0.06}},{"label":"release","pinch":0,"duration":0.15},{"label":"thumbs up","position":{"relativeTo":"head","x":0.12,"y":-0.35,"z":-0.35},"anchor":"wrist","orientation":{"fingers":"forward","thumb":"up"},"poseId":"thumbs-up"},{"label":"hold","duration":1}]}';
498
922
  const ALL_RUNTIME_MCP_TOOLS = [
499
923
  // =============================================================================
500
924
  // Session Management
@@ -553,9 +977,10 @@ const ALL_RUNTIME_MCP_TOOLS = [
553
977
  },
554
978
  {
555
979
  name: 'xr_set_transform',
556
- description: 'Set position and/or orientation of a tracked device. Position is in meters, orientation can be quaternion or euler angles (degrees). Gaze accepts orientation only; move its origin with the headset.',
980
+ description: 'Set a device position and/or orientation immediately (XR-origin). Gaze accepts orientation only; move its origin with the headset. Hands: `anchor` puts that point of the hand at `position` and keeps it there while the hand changes shape (e.g. anchor "index-tip" on a button, "grasp" on an object before pinching); orientation may be hand directions or "auto". Requires an active session.',
557
981
  inputSchema: {
558
982
  type: 'object',
983
+ additionalProperties: false,
559
984
  properties: {
560
985
  device: {
561
986
  type: 'string',
@@ -570,8 +995,7 @@ const ALL_RUNTIME_MCP_TOOLS = [
570
995
  description: 'The device to move',
571
996
  },
572
997
  position: {
573
- type: 'object',
574
- description: 'World position in meters',
998
+ ...XR_POSITION_SCHEMA,
575
999
  properties: {
576
1000
  x: { type: 'number', description: 'X position (left/right)' },
577
1001
  y: {
@@ -584,25 +1008,8 @@ const ALL_RUNTIME_MCP_TOOLS = [
584
1008
  },
585
1009
  },
586
1010
  },
587
- orientation: {
588
- type: 'object',
589
- description: 'Rotation as quaternion {x,y,z,w} or euler angles {pitch,yaw,roll} in degrees',
590
- properties: {
591
- x: { type: 'number', description: 'Quaternion X component' },
592
- y: { type: 'number', description: 'Quaternion Y component' },
593
- z: { type: 'number', description: 'Quaternion Z component' },
594
- w: { type: 'number', description: 'Quaternion W component' },
595
- pitch: {
596
- type: 'number',
597
- description: 'Pitch in degrees (X rotation)',
598
- },
599
- yaw: { type: 'number', description: 'Yaw in degrees (Y rotation)' },
600
- roll: {
601
- type: 'number',
602
- description: 'Roll in degrees (Z rotation)',
603
- },
604
- },
605
- },
1011
+ orientation: XR_PLACEMENT_ORIENTATION_SCHEMA,
1012
+ anchor: XR_HAND_ANCHOR_SCHEMA,
606
1013
  },
607
1014
  required: ['device'],
608
1015
  },
@@ -645,9 +1052,10 @@ const ALL_RUNTIME_MCP_TOOLS = [
645
1052
  },
646
1053
  {
647
1054
  name: 'xr_animate_to',
648
- description: 'Smoothly animate a device to a new position/orientation over time. Gaze accepts orientation only.',
1055
+ description: 'Animate a device to a target position and/or orientation (XR-origin) over `duration` seconds (default 0.5), from where it is when the animation starts. Gaze accepts orientation only. Hands take `anchor` and hand directions as in xr_set_transform. easing "minimum-jerk" moves like a person (default "linear"). For multi-step hand interactions (press, grab, carry, gestures) prefer xr_run_sequence. Requires an active, rendering session.',
649
1056
  inputSchema: {
650
1057
  type: 'object',
1058
+ additionalProperties: false,
651
1059
  properties: {
652
1060
  device: {
653
1061
  type: 'string',
@@ -661,38 +1069,15 @@ const ALL_RUNTIME_MCP_TOOLS = [
661
1069
  ],
662
1070
  description: 'The device to animate',
663
1071
  },
664
- position: {
665
- type: 'object',
666
- description: 'Target world position in meters',
667
- properties: {
668
- x: { type: 'number' },
669
- y: { type: 'number' },
670
- z: { type: 'number' },
671
- },
672
- },
673
- orientation: {
674
- type: 'object',
675
- description: 'Target rotation as quaternion {x,y,z,w} or euler angles {pitch,yaw,roll} in degrees',
676
- properties: {
677
- x: { type: 'number', description: 'Quaternion X component' },
678
- y: { type: 'number', description: 'Quaternion Y component' },
679
- z: { type: 'number', description: 'Quaternion Z component' },
680
- w: { type: 'number', description: 'Quaternion W component' },
681
- pitch: {
682
- type: 'number',
683
- description: 'Pitch in degrees (X rotation)',
684
- },
685
- yaw: { type: 'number', description: 'Yaw in degrees (Y rotation)' },
686
- roll: {
687
- type: 'number',
688
- description: 'Roll in degrees (Z rotation)',
689
- },
690
- },
691
- },
1072
+ position: XR_POSITION_SCHEMA,
1073
+ orientation: XR_PLACEMENT_ORIENTATION_SCHEMA,
692
1074
  duration: {
693
1075
  type: 'number',
1076
+ exclusiveMinimum: 0,
694
1077
  description: 'Animation duration in seconds (default: 0.5)',
695
1078
  },
1079
+ easing: XR_EASING_SCHEMA,
1080
+ anchor: XR_HAND_ANCHOR_SCHEMA,
696
1081
  },
697
1082
  required: ['device'],
698
1083
  },
@@ -765,9 +1150,10 @@ const ALL_RUNTIME_MCP_TOOLS = [
765
1150
  },
766
1151
  {
767
1152
  name: 'xr_set_select_value',
768
- description: 'Set the select (trigger/pinch) value for an input device. Use for grab-move-release patterns.',
1153
+ description: 'Set the select value (trigger/pinch), 0..1, optionally ramping from the current value over `duration` seconds (easing default minimum-jerk). A hand pinch selects at 0.9 and lets go at 0.7; a trigger selects above 0. Use xr_select for a full press+release.',
769
1154
  inputSchema: {
770
1155
  type: 'object',
1156
+ additionalProperties: false,
771
1157
  properties: {
772
1158
  device: {
773
1159
  type: 'string',
@@ -785,13 +1171,19 @@ const ALL_RUNTIME_MCP_TOOLS = [
785
1171
  maximum: 1,
786
1172
  description: 'Select value (0=released, 1=fully pressed/pinched)',
787
1173
  },
1174
+ duration: {
1175
+ type: 'number',
1176
+ minimum: 0,
1177
+ description: 'Seconds to ramp from the current value (default: 0)',
1178
+ },
1179
+ easing: XR_EASING_SCHEMA,
788
1180
  },
789
1181
  required: ['device', 'value'],
790
1182
  },
791
1183
  },
792
1184
  {
793
1185
  name: 'xr_select',
794
- description: 'Perform a complete select action (press and release). Dispatches selectstart, select, selectend events.',
1186
+ description: 'Perform a full select gesture: selectstart on press, then select and selectend on release, holding `duration` seconds (default 0.15). A hand closes its pinch over 0.1 s before the hold and opens it over 0.1 s after. Requires an active session.',
795
1187
  inputSchema: {
796
1188
  type: 'object',
797
1189
  properties: {
@@ -807,6 +1199,7 @@ const ALL_RUNTIME_MCP_TOOLS = [
807
1199
  },
808
1200
  duration: {
809
1201
  type: 'number',
1202
+ exclusiveMinimum: 0,
810
1203
  description: 'How long to hold in seconds (default: 0.15)',
811
1204
  },
812
1205
  },
@@ -1118,7 +1511,7 @@ const ALL_RUNTIME_MCP_TOOLS = [
1118
1511
  // =============================================================================
1119
1512
  {
1120
1513
  name: 'xr_get_device_state',
1121
- description: 'Get comprehensive state of the XR device including headset, controllers, hands, and gaze',
1514
+ description: 'Get a full snapshot: headset pose, input mode, controllers, hands (with poseId and pinchValue), gaze, stereo, and FOV. Positions are XR-origin relative.',
1122
1515
  inputSchema: {
1123
1516
  type: 'object',
1124
1517
  properties: {},
@@ -1127,35 +1520,23 @@ const ALL_RUNTIME_MCP_TOOLS = [
1127
1520
  },
1128
1521
  {
1129
1522
  name: 'xr_set_device_state',
1130
- description: 'Set device state. When called with no state, resets everything to defaults.',
1523
+ description: 'Apply a partial device state (positions XR-origin; hands also take poseId and pinchValue). Call with no `state` to reset everything to defaults.',
1131
1524
  inputSchema: {
1132
1525
  type: 'object',
1526
+ additionalProperties: false,
1133
1527
  properties: {
1134
1528
  state: {
1135
1529
  type: 'object',
1530
+ additionalProperties: false,
1136
1531
  description: 'Partial device state to apply. Omit to reset to defaults.',
1137
1532
  properties: {
1138
1533
  headset: {
1139
1534
  type: 'object',
1535
+ additionalProperties: false,
1140
1536
  description: 'Headset transform',
1141
1537
  properties: {
1142
- position: {
1143
- type: 'object',
1144
- properties: {
1145
- x: { type: 'number' },
1146
- y: { type: 'number' },
1147
- z: { type: 'number' },
1148
- },
1149
- },
1150
- orientation: {
1151
- type: 'object',
1152
- properties: {
1153
- x: { type: 'number' },
1154
- y: { type: 'number' },
1155
- z: { type: 'number' },
1156
- w: { type: 'number' },
1157
- },
1158
- },
1538
+ position: XR_POSITION_SCHEMA,
1539
+ orientation: XR_ORIENTATION_SCHEMA,
1159
1540
  },
1160
1541
  },
1161
1542
  inputMode: {
@@ -1173,46 +1554,20 @@ const ALL_RUNTIME_MCP_TOOLS = [
1173
1554
  },
1174
1555
  controllers: {
1175
1556
  type: 'object',
1557
+ additionalProperties: false,
1176
1558
  description: 'Controller states',
1177
1559
  properties: {
1178
- left: {
1179
- type: 'object',
1180
- properties: {
1181
- position: { type: 'object' },
1182
- orientation: { type: 'object' },
1183
- connected: { type: 'boolean' },
1184
- },
1185
- },
1186
- right: {
1187
- type: 'object',
1188
- properties: {
1189
- position: { type: 'object' },
1190
- orientation: { type: 'object' },
1191
- connected: { type: 'boolean' },
1192
- },
1193
- },
1560
+ left: XR_INPUT_STATE_SCHEMA,
1561
+ right: XR_INPUT_STATE_SCHEMA,
1194
1562
  },
1195
1563
  },
1196
1564
  hands: {
1197
1565
  type: 'object',
1198
- description: 'Hand states',
1566
+ additionalProperties: false,
1567
+ description: 'Hand states, including poseId and pinchValue',
1199
1568
  properties: {
1200
- left: {
1201
- type: 'object',
1202
- properties: {
1203
- position: { type: 'object' },
1204
- orientation: { type: 'object' },
1205
- connected: { type: 'boolean' },
1206
- },
1207
- },
1208
- right: {
1209
- type: 'object',
1210
- properties: {
1211
- position: { type: 'object' },
1212
- orientation: { type: 'object' },
1213
- connected: { type: 'boolean' },
1214
- },
1215
- },
1569
+ left: XR_HAND_STATE_SCHEMA,
1570
+ right: XR_HAND_STATE_SCHEMA,
1216
1571
  },
1217
1572
  },
1218
1573
  gaze: {
@@ -1220,16 +1575,8 @@ const ALL_RUNTIME_MCP_TOOLS = [
1220
1575
  additionalProperties: false,
1221
1576
  description: 'Gaze state. Its origin is derived from the headset and cannot be set independently.',
1222
1577
  properties: {
1223
- orientation: {
1224
- type: 'object',
1225
- properties: {
1226
- x: { type: 'number' },
1227
- y: { type: 'number' },
1228
- z: { type: 'number' },
1229
- w: { type: 'number' },
1230
- },
1231
- },
1232
1578
  connected: { type: 'boolean' },
1579
+ orientation: XR_ORIENTATION_SCHEMA,
1233
1580
  },
1234
1581
  },
1235
1582
  },
@@ -1238,6 +1585,108 @@ const ALL_RUNTIME_MCP_TOOLS = [
1238
1585
  },
1239
1586
  },
1240
1587
  // =============================================================================
1588
+ // Hands
1589
+ // =============================================================================
1590
+ {
1591
+ name: 'xr_set_hand_pose',
1592
+ description: `Set a named hand pose on a hand device. Poses only shape the hand; to pinch (select), use the pinch value (xr_set_select_value). Poses: ${XR_HAND_POSE_GLOSSES}. ` +
1593
+ 'Optionally take individual fingers from other poses, e.g. poseId "open" with fingers {"middle":"fist","ring":"fist","pinky":"fist"}, or blend partway with {"poseId":"fist","weight":0.5}. Setting a pose clears earlier finger overrides. `duration` fades from the hand as shown (easing default minimum-jerk); a hand placed by an anchor keeps the anchor in place.',
1594
+ inputSchema: {
1595
+ type: 'object',
1596
+ additionalProperties: false,
1597
+ properties: {
1598
+ device: XR_HAND_DEVICE_SCHEMA,
1599
+ poseId: { type: 'string' },
1600
+ fingers: XR_FINGER_POSES_SCHEMA,
1601
+ duration: { type: 'number', minimum: 0 },
1602
+ easing: XR_EASING_SCHEMA,
1603
+ },
1604
+ required: ['device', 'poseId'],
1605
+ },
1606
+ },
1607
+ {
1608
+ name: 'xr_microgesture',
1609
+ description: 'Swipe or tap the thumb on the side of the curled index finger, as on Quest. The app sees the hand gamepad (xr-standard) button pressed for 35 ms when the gesture completes: 5 swipe-left, 6 swipe-right, 7 swipe-forward, 8 swipe-backward, 9 tap; no select events. A hand not in the "microgesture" pose takes it first (0.25 s); a hand that is selecting must let go first. Raise the hand side-on in view first, e.g. xr_set_transform with anchor "wrist" and orientation {fingers:[0,-0.6,-0.8],palm:"left"} (right hand; "right" for the left). Requires an active session and hand input.',
1610
+ inputSchema: {
1611
+ type: 'object',
1612
+ additionalProperties: false,
1613
+ properties: {
1614
+ device: XR_HAND_DEVICE_SCHEMA,
1615
+ gesture: XR_MICROGESTURE_SCHEMA,
1616
+ },
1617
+ required: ['device', 'gesture'],
1618
+ },
1619
+ },
1620
+ {
1621
+ name: 'xr_get_hand_state',
1622
+ description: 'Read a hand: pose, finger blends, a pose fade in progress, pinch value, whether select is pressed, its anchor pin, and XR-origin positions of the wrist, grip, grasp point, index tip and thumb tip, plus its finger/palm/thumb directions (joints:"all" adds every joint).',
1623
+ inputSchema: {
1624
+ type: 'object',
1625
+ additionalProperties: false,
1626
+ properties: {
1627
+ device: XR_HAND_DEVICE_SCHEMA,
1628
+ joints: { type: 'string', enum: ['key', 'all'] },
1629
+ },
1630
+ required: ['device'],
1631
+ },
1632
+ },
1633
+ {
1634
+ name: 'xr_run_sequence',
1635
+ description: XR_RUN_SEQUENCE_DESCRIPTION,
1636
+ inputSchema: {
1637
+ type: 'object',
1638
+ additionalProperties: false,
1639
+ properties: {
1640
+ device: XR_HAND_DEVICE_SCHEMA,
1641
+ steps: {
1642
+ type: 'array',
1643
+ items: XR_SEQUENCE_STEP_SCHEMA,
1644
+ minItems: 1,
1645
+ },
1646
+ idleHand: {
1647
+ type: 'string',
1648
+ enum: ['keep', 'rest'],
1649
+ description: 'The other hand: rest it by the hip (the default unless it is pinching) or keep it where it is.',
1650
+ },
1651
+ body: {
1652
+ type: 'string',
1653
+ enum: ['auto', 'fixed'],
1654
+ description: 'auto (default): lean for low targets and step closer to ones out of reach. fixed: out of reach is an error.',
1655
+ },
1656
+ gaze: {
1657
+ type: 'string',
1658
+ enum: ['follow', 'fixed'],
1659
+ description: 'follow (default): the head turns to each target before the hand gets there.',
1660
+ },
1661
+ dryRun: {
1662
+ type: 'boolean',
1663
+ description: 'Validate and return the planned steps, walks, durations and warnings without moving anything.',
1664
+ },
1665
+ },
1666
+ required: ['device', 'steps'],
1667
+ },
1668
+ },
1669
+ {
1670
+ name: 'xr_cancel_sequence',
1671
+ description: 'Stop the running xr_run_sequence where it is; that call returns with cancelled: true and the steps done. The pinch is left as it is (no select events).',
1672
+ inputSchema: {
1673
+ type: 'object',
1674
+ additionalProperties: false,
1675
+ properties: {},
1676
+ required: [],
1677
+ },
1678
+ },
1679
+ {
1680
+ name: 'xr_list_targets',
1681
+ description: "List the named targets xr_run_sequence steps can use, from the page's target resolver: name, box centre and size (XR-origin). resolver:false means the page has none; use positions.",
1682
+ inputSchema: {
1683
+ type: 'object',
1684
+ additionalProperties: false,
1685
+ properties: {},
1686
+ required: [],
1687
+ },
1688
+ },
1689
+ // =============================================================================
1241
1690
  // Console Logs (Plugin-specific, not in IWER)
1242
1691
  // =============================================================================
1243
1692
  {
@@ -1287,6 +1736,21 @@ const ALL_RUNTIME_MCP_TOOLS = [
1287
1736
  properties: {},
1288
1737
  },
1289
1738
  },
1739
+ {
1740
+ name: 'browser_set_muted',
1741
+ description: 'Mute or unmute all audio in the managed browser tab, whose app-mode window hides the browser mute control. The state is shared with the workspace mute button and persists across reloads and browser relaunches for the dev session.',
1742
+ inputSchema: {
1743
+ type: 'object',
1744
+ additionalProperties: false,
1745
+ properties: {
1746
+ muted: {
1747
+ type: 'boolean',
1748
+ description: 'true mutes the tab; false unmutes it',
1749
+ },
1750
+ },
1751
+ required: ['muted'],
1752
+ },
1753
+ },
1290
1754
  // =============================================================================
1291
1755
  // Managed Workspace Tools
1292
1756
  // =============================================================================
@@ -2859,6 +3323,12 @@ const RUNTIME_TOOL_TO_METHOD = {
2859
3323
  xr_set_gamepad_state: 'set_gamepad_state',
2860
3324
  xr_get_device_state: 'get_device_state',
2861
3325
  xr_set_device_state: 'set_device_state',
3326
+ xr_set_hand_pose: 'set_hand_pose',
3327
+ xr_microgesture: 'microgesture',
3328
+ xr_get_hand_state: 'get_hand_state',
3329
+ xr_run_sequence: 'run_sequence',
3330
+ xr_cancel_sequence: 'cancel_sequence',
3331
+ xr_list_targets: 'list_targets',
2862
3332
  browser_screenshot: 'screenshot',
2863
3333
  browser_snapshot: 'browser_snapshot',
2864
3334
  browser_interact: 'browser_interact',
@@ -2890,8 +3360,15 @@ const ALL_RUNTIME_CLI_PATHS = {
2890
3360
  browser_profile: ['browser', 'profile'],
2891
3361
  xr_get_device_state: ['xr', 'get-device-state'],
2892
3362
  xr_set_device_state: ['xr', 'set-device-state'],
3363
+ xr_set_hand_pose: ['xr', 'set-hand-pose'],
3364
+ xr_microgesture: ['xr', 'microgesture'],
3365
+ xr_get_hand_state: ['xr', 'get-hand-state'],
3366
+ xr_run_sequence: ['xr', 'run-sequence'],
3367
+ xr_cancel_sequence: ['xr', 'cancel-sequence'],
3368
+ xr_list_targets: ['xr', 'list-targets'],
2893
3369
  browser_get_console_logs: ['browser', 'logs'],
2894
3370
  browser_reload_page: ['browser', 'reload'],
3371
+ browser_set_muted: ['browser', 'set-muted'],
2895
3372
  workspace_get_state: ['workspace', 'state'],
2896
3373
  workspace_set_view: ['workspace', 'set-view'],
2897
3374
  workspace_open_scene: ['workspace', 'open-scene'],
@@ -2996,6 +3473,7 @@ const HOST_BROWSER_MCP_TOOL_NAME_SET = new Set([
2996
3473
  'browser_profile',
2997
3474
  'browser_get_console_logs',
2998
3475
  'browser_reload_page',
3476
+ 'browser_set_muted',
2999
3477
  ]);
3000
3478
  const APP_TARGET_MCP_TOOL_NAME_SET = new Set([
3001
3479
  ...HOST_BROWSER_MCP_TOOL_NAME_SET,
@@ -3097,5 +3575,5 @@ function isRecord(value) {
3097
3575
  return typeof value === 'object' && value !== null && !Array.isArray(value);
3098
3576
  }
3099
3577
 
3100
- export { APP_RUNTIME_SCENE_MCP_TOOL_NAMES, ASSET_RENDER_PREVIEW_TIMEOUT_MS, BROWSER_RUNTIME_COMMAND_TIMEOUT_MS, DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS, INTERNAL_BROWSER_PROBE_METHOD, INTERNAL_RUNTIME_LAUNCH_CLAIM_ENV, INTERNAL_RUNTIME_SHUTDOWN_METHOD, IWSDK_PROJECT_STATE_DIR, IWSDK_RUNTIME_BROWSER_READY_SCHEMA_VERSION, IWSDK_RUNTIME_LAUNCH_PATH, IWSDK_RUNTIME_LOGS_DIR, IWSDK_RUNTIME_SESSION_PATH, IWSDK_RUNTIME_STATE_DIR, IWSDK_RUNTIME_STATE_SCHEMA_VERSION, MCP_CONFIG_TARGETS, PROJECT_ASSET_MCP_TOOL_NAMES, REVIEW_EVIDENCE_MCP_TOOL_NAMES, RUNTIME_CLI_PATHS, RUNTIME_MCP_TOOLS, RUNTIME_OPERATIONS, RUNTIME_TOOL_TO_METHOD, SCENE_EDITOR_MCP_TOOL_NAMES, SCENE_FILE_MCP_TOOL_NAMES, SCENE_MCP_TOOL_NAMES, SUPPORTED_AI_TOOLS, UI_RENDER_PREVIEW_TIMEOUT_MS, WORKSPACE_MCP_TOOL_NAMES, getDefaultRuntimeCommandTimeoutMs, getRuntimeOperationByCliPath, getRuntimeOperationByToolName, hasRuntimeBrowserCommandReadyContract, isRuntimeBrowserCommandReady, resolveRuntimeOperationRequest };
3578
+ export { APP_RUNTIME_SCENE_MCP_TOOL_NAMES, ASSET_RENDER_PREVIEW_TIMEOUT_MS, BROWSER_RUNTIME_COMMAND_TIMEOUT_MS, DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS, HAND_SEQUENCE_COMMAND_TIMEOUT_MS, INTERNAL_BROWSER_PROBE_METHOD, INTERNAL_RUNTIME_LAUNCH_CLAIM_ENV, INTERNAL_RUNTIME_SHUTDOWN_METHOD, IWSDK_PROJECT_STATE_DIR, IWSDK_RUNTIME_BROWSER_READY_SCHEMA_VERSION, IWSDK_RUNTIME_COMMAND_CREDENTIAL_PATH, IWSDK_RUNTIME_LAUNCH_PATH, IWSDK_RUNTIME_LOGS_DIR, IWSDK_RUNTIME_SESSION_PATH, IWSDK_RUNTIME_STATE_DIR, IWSDK_RUNTIME_STATE_SCHEMA_VERSION, MAX_TIMED_COMMAND_DURATION_S, MCP_CONFIG_TARGETS, PROJECT_ASSET_MCP_TOOL_NAMES, REVIEW_EVIDENCE_MCP_TOOL_NAMES, RUNTIME_CLI_PATHS, RUNTIME_MCP_TOOLS, RUNTIME_OPERATIONS, RUNTIME_TOOL_TO_METHOD, SCENE_EDITOR_MCP_TOOL_NAMES, SCENE_FILE_MCP_TOOL_NAMES, SCENE_MCP_TOOL_NAMES, SUPPORTED_AI_TOOLS, UI_RENDER_PREVIEW_TIMEOUT_MS, WORKSPACE_MCP_TOOL_NAMES, XR_HAND_POSE_GLOSS, getDefaultRuntimeCommandTimeoutMs, getRuntimeOperationByCliPath, getRuntimeOperationByToolName, hasRuntimeBrowserCommandReadyContract, isRuntimeBrowserCommandReady, resolveRuntimeOperationRequest };
3101
3579
  //# sourceMappingURL=contract.js.map