@iwsdk/cli 1.1.0-rc.1 → 1.1.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/dist/cli.js CHANGED
@@ -2384,7 +2384,7 @@ function getUnsupportedNodeMessage(version, requiredRange) {
2384
2384
  }
2385
2385
 
2386
2386
  const NODE_ENGINE = ">=20.19.0 <21.0.0-0 || >=22.12.0 <23.0.0-0 || >=24.0.0";
2387
- const CLI_VERSION = "1.1.0-rc.1";
2387
+ const CLI_VERSION = "1.1.0";
2388
2388
 
2389
2389
  /**
2390
2390
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -2521,21 +2521,48 @@ const DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS = 30_000;
2521
2521
  const UI_RENDER_PREVIEW_TIMEOUT_MS = 60_000;
2522
2522
  const ASSET_RENDER_PREVIEW_TIMEOUT_MS = 120_000;
2523
2523
  const BROWSER_RUNTIME_COMMAND_TIMEOUT_MS = 60_000;
2524
+ /**
2525
+ * IWER resolves a running hand sequence at most 28 s after dispatch, with a
2526
+ * partial result when it runs out of time. The default budget, less the
2527
+ * relay's margin, would give up first.
2528
+ */
2529
+ const HAND_SEQUENCE_COMMAND_TIMEOUT_MS = 40_000;
2530
+ /** The longest `duration` (seconds) that extends a default command timeout. */
2531
+ const MAX_TIMED_COMMAND_DURATION_S = 3_600;
2532
+ /** IWER replies to these only once their `duration` (seconds) has elapsed. */
2533
+ const TIMED_RUNTIME_METHODS = new Set([
2534
+ 'animate_to',
2535
+ 'select',
2536
+ 'set_hand_pose',
2537
+ 'set_select_value',
2538
+ ]);
2524
2539
  const BROWSER_RUNTIME_METHODS = new Set([
2525
2540
  'browser_interact',
2526
2541
  'browser_profile',
2542
+ 'browser_set_muted',
2527
2543
  'browser_snapshot',
2528
2544
  'get_console_logs',
2529
2545
  'reload_page',
2530
2546
  'screenshot',
2531
2547
  ]);
2532
- function getDefaultRuntimeCommandTimeoutMs(method) {
2548
+ function getDefaultRuntimeCommandTimeoutMs(method, params) {
2533
2549
  if (method === 'asset_render_preview') {
2534
2550
  return ASSET_RENDER_PREVIEW_TIMEOUT_MS;
2535
2551
  }
2536
2552
  if (method === 'ui_render_preview') {
2537
2553
  return UI_RENDER_PREVIEW_TIMEOUT_MS;
2538
2554
  }
2555
+ if (method === 'run_sequence') {
2556
+ return HAND_SEQUENCE_COMMAND_TIMEOUT_MS;
2557
+ }
2558
+ if (TIMED_RUNTIME_METHODS.has(method)) {
2559
+ // A long fade or ramp gets the default budget on top of its duration.
2560
+ const duration = params?.duration;
2561
+ return typeof duration === 'number' && duration > 0
2562
+ ? DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS +
2563
+ Math.ceil(Math.min(duration, MAX_TIMED_COMMAND_DURATION_S) * 1000)
2564
+ : DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS;
2565
+ }
2539
2566
  return BROWSER_RUNTIME_METHODS.has(method)
2540
2567
  ? BROWSER_RUNTIME_COMMAND_TIMEOUT_MS
2541
2568
  : DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS;
@@ -2549,6 +2576,41 @@ function describeValue(value) {
2549
2576
  }
2550
2577
  return typeof value;
2551
2578
  }
2579
+ /**
2580
+ * The error of the union member a value was evidently meant for: the only one
2581
+ * of its type, or the object shape sharing the most of its keys. A misspelt
2582
+ * key in a hand direction then reports that key, not "a supported shape".
2583
+ */
2584
+ function closestShapeError(value, candidates, errors) {
2585
+ const kind = describeValue(value);
2586
+ const sameKind = candidates
2587
+ .map((candidate, index) => ({ candidate, error: errors[index] }))
2588
+ .filter(({ candidate }) => candidate.type == null ||
2589
+ candidate.type === kind ||
2590
+ (candidate.type === 'integer' && kind === 'number'));
2591
+ if (sameKind.length === 1) {
2592
+ return sameKind[0].error;
2593
+ }
2594
+ if (!isRecord$6(value)) {
2595
+ return null;
2596
+ }
2597
+ const keys = Object.keys(value);
2598
+ let best = null;
2599
+ let bestScore = 0;
2600
+ let tied = false;
2601
+ for (const entry of sameKind) {
2602
+ const score = keys.filter((key) => entry.candidate.properties?.[key] != null).length;
2603
+ if (score > bestScore) {
2604
+ best = entry;
2605
+ bestScore = score;
2606
+ tied = false;
2607
+ }
2608
+ else if (score === bestScore) {
2609
+ tied = true;
2610
+ }
2611
+ }
2612
+ return best && !tied ? best.error : null;
2613
+ }
2552
2614
  function assertSchemaValue(value, schema, path) {
2553
2615
  if (schema.oneOf?.length) {
2554
2616
  const matches = schema.oneOf.filter((candidate) => {
@@ -2565,17 +2627,20 @@ function assertSchemaValue(value, schema, path) {
2565
2627
  }
2566
2628
  }
2567
2629
  if (schema.anyOf?.length) {
2630
+ const errors = [];
2568
2631
  const matches = schema.anyOf.some((candidate) => {
2569
2632
  try {
2570
2633
  assertSchemaValue(value, candidate, path);
2571
2634
  return true;
2572
2635
  }
2573
- catch {
2636
+ catch (error) {
2637
+ errors.push(error);
2574
2638
  return false;
2575
2639
  }
2576
2640
  });
2577
2641
  if (!matches) {
2578
- throw new Error(`${path} must match a supported shape`);
2642
+ throw (closestShapeError(value, schema.anyOf, errors) ??
2643
+ new Error(`${path} must match a supported shape`));
2579
2644
  }
2580
2645
  }
2581
2646
  if (schema.not) {
@@ -2664,6 +2729,7 @@ function assertSchemaValue(value, schema, path) {
2664
2729
  const IWSDK_RUNTIME_LOGS_DIR = '.iwsdk/runtime/logs';
2665
2730
  const IWSDK_RUNTIME_SESSION_PATH = '.iwsdk/runtime/session.json';
2666
2731
  const IWSDK_RUNTIME_LAUNCH_PATH = '.iwsdk/runtime/launch.json';
2732
+ const IWSDK_RUNTIME_COMMAND_CREDENTIAL_PATH = '.iwsdk/runtime/command-credential.json';
2667
2733
  const IWSDK_RUNTIME_STATE_SCHEMA_VERSION = 2;
2668
2734
  const IWSDK_RUNTIME_BROWSER_READY_SCHEMA_VERSION = 2;
2669
2735
  const INTERNAL_BROWSER_PROBE_METHOD = '__iwsdk_browser_probe';
@@ -3006,6 +3072,364 @@ const SCENE_OBJECT_INSPECTION_ASSESSMENT_SCHEMA = {
3006
3072
  },
3007
3073
  required: ['id', 'status', 'evidenceRefs', 'observation'],
3008
3074
  };
3075
+ // =============================================================================
3076
+ // Emulated device shapes
3077
+ // =============================================================================
3078
+ // The xr_* schemas mirror IWER's extension-bridge contract and its JSON Schema
3079
+ // catalog (`iwer/lib/remote/catalog.js`): the same parameters, unions and
3080
+ // descriptions. vite-plugin-dev's tests compare them with the catalog of the
3081
+ // IWER it installs.
3082
+ const XR_POSITION_SCHEMA = {
3083
+ type: 'object',
3084
+ description: 'A 3D position in metres, XR-origin relative.',
3085
+ properties: {
3086
+ x: { type: 'number' },
3087
+ y: { type: 'number' },
3088
+ z: { type: 'number' },
3089
+ },
3090
+ required: ['x', 'y', 'z'],
3091
+ };
3092
+ const XR_STRICT_POSITION_SCHEMA = {
3093
+ ...XR_POSITION_SCHEMA,
3094
+ additionalProperties: false,
3095
+ };
3096
+ const XR_TUPLE3_SCHEMA = {
3097
+ type: 'array',
3098
+ items: { type: 'number' },
3099
+ minItems: 3,
3100
+ maxItems: 3,
3101
+ };
3102
+ const XR_QUATERNION_SCHEMA = {
3103
+ type: 'object',
3104
+ additionalProperties: false,
3105
+ properties: {
3106
+ x: { type: 'number', description: 'Quaternion X component' },
3107
+ y: { type: 'number', description: 'Quaternion Y component' },
3108
+ z: { type: 'number', description: 'Quaternion Z component' },
3109
+ w: { type: 'number', description: 'Quaternion W component' },
3110
+ },
3111
+ required: ['x', 'y', 'z', 'w'],
3112
+ };
3113
+ const XR_EULER_SCHEMA = {
3114
+ type: 'object',
3115
+ additionalProperties: false,
3116
+ properties: {
3117
+ pitch: { type: 'number', description: 'Pitch in degrees (X rotation)' },
3118
+ yaw: { type: 'number', description: 'Yaw in degrees (Y rotation)' },
3119
+ roll: { type: 'number', description: 'Roll in degrees (Z rotation)' },
3120
+ },
3121
+ };
3122
+ const XR_ORIENTATION_SCHEMA = {
3123
+ anyOf: [XR_QUATERNION_SCHEMA, XR_EULER_SCHEMA],
3124
+ description: 'Orientation as a quaternion {x,y,z,w} or euler degrees {pitch,yaw,roll}.',
3125
+ };
3126
+ const XR_DIRECTION_SCHEMA = {
3127
+ anyOf: [
3128
+ {
3129
+ type: 'string',
3130
+ enum: [
3131
+ 'up',
3132
+ 'down',
3133
+ 'forward',
3134
+ 'back',
3135
+ 'left',
3136
+ 'right',
3137
+ 'toward-head',
3138
+ 'away-from-head',
3139
+ ],
3140
+ },
3141
+ XR_STRICT_POSITION_SCHEMA,
3142
+ XR_TUPLE3_SCHEMA,
3143
+ ],
3144
+ 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).',
3145
+ };
3146
+ // Hand directions come before quaternion/euler and every orientation object
3147
+ // is strict, so a misspelt hand direction is an error, not an empty euler.
3148
+ const XR_HAND_DIRECTIONS_SCHEMA = {
3149
+ type: 'object',
3150
+ additionalProperties: false,
3151
+ 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"}.',
3152
+ properties: {
3153
+ fingers: XR_DIRECTION_SCHEMA,
3154
+ palm: XR_DIRECTION_SCHEMA,
3155
+ thumb: XR_DIRECTION_SCHEMA,
3156
+ },
3157
+ required: ['fingers'],
3158
+ };
3159
+ const XR_PLACEMENT_ORIENTATION_SCHEMA = {
3160
+ anyOf: [
3161
+ { type: 'string', enum: ['auto'] },
3162
+ XR_HAND_DIRECTIONS_SCHEMA,
3163
+ XR_QUATERNION_SCHEMA,
3164
+ XR_EULER_SCHEMA,
3165
+ ],
3166
+ 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.',
3167
+ };
3168
+ const XR_HAND_ANCHOR_SCHEMA = {
3169
+ type: 'string',
3170
+ 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.',
3171
+ };
3172
+ const XR_EASING_SCHEMA = {
3173
+ type: 'string',
3174
+ enum: ['linear', 'minimum-jerk'],
3175
+ description: 'Time curve; minimum-jerk starts and stops like a human reach.',
3176
+ };
3177
+ const XR_HAND_DEVICE_SCHEMA = {
3178
+ type: 'string',
3179
+ enum: ['hand-left', 'hand-right'],
3180
+ description: 'A hand-tracking device.',
3181
+ };
3182
+ // One short gloss per built-in IWER hand pose, for xr_set_hand_pose. Keep in
3183
+ // sync with IWER's BUILTIN_HAND_POSE_IDS (checked by vite-plugin-dev's tests).
3184
+ const XR_HAND_POSE_GLOSS = {
3185
+ default: 'relaxed',
3186
+ pinch: 'thumb and index touching',
3187
+ point: 'index extended',
3188
+ open: 'high five',
3189
+ flat: 'fingers together, blade',
3190
+ fist: 'closed fist',
3191
+ 'thumbs-up': 'fist with thumb up',
3192
+ 'finger-gun': 'index and thumb out',
3193
+ peace: 'V sign',
3194
+ three: 'index, middle, ring up',
3195
+ four: 'four fingers up, thumb folded',
3196
+ ok: 'thumb-index circle',
3197
+ rock: 'index and pinky out',
3198
+ call: 'thumb and pinky out',
3199
+ 'pinch-middle': 'thumb to middle tip',
3200
+ 'pinch-ring': 'thumb to ring tip',
3201
+ 'pinch-pinky': 'thumb to pinky tip',
3202
+ tripod: 'thumb, index, middle tips together',
3203
+ 'key-pinch': 'thumb against side of index',
3204
+ microgesture: 'loose curl, thumb by the side of the index',
3205
+ grip: 'wrapped around a handle',
3206
+ claw: 'holding a ball',
3207
+ hook: 'carrying a bag handle',
3208
+ cup: 'scooping water',
3209
+ };
3210
+ const XR_HAND_POSE_GLOSSES = Object.entries(XR_HAND_POSE_GLOSS)
3211
+ .map(([id, gloss]) => `${id} (${gloss})`)
3212
+ .join(', ');
3213
+ const XR_FINGER_POSE_SCHEMA = {
3214
+ anyOf: [
3215
+ { type: 'string' },
3216
+ {
3217
+ type: 'object',
3218
+ additionalProperties: false,
3219
+ properties: {
3220
+ poseId: { type: 'string' },
3221
+ weight: { type: 'number', minimum: 0, maximum: 1 },
3222
+ },
3223
+ required: ['poseId'],
3224
+ },
3225
+ ],
3226
+ description: 'A pose id, or {poseId, weight} where weight 0-1 blends from the base pose toward it.',
3227
+ };
3228
+ const XR_FINGER_POSES_SCHEMA = {
3229
+ type: 'object',
3230
+ additionalProperties: false,
3231
+ description: 'Fingers to take from other poses, on top of poseId.',
3232
+ properties: {
3233
+ thumb: XR_FINGER_POSE_SCHEMA,
3234
+ index: XR_FINGER_POSE_SCHEMA,
3235
+ middle: XR_FINGER_POSE_SCHEMA,
3236
+ ring: XR_FINGER_POSE_SCHEMA,
3237
+ pinky: XR_FINGER_POSE_SCHEMA,
3238
+ },
3239
+ };
3240
+ const XR_INPUT_STATE_SCHEMA = {
3241
+ type: 'object',
3242
+ additionalProperties: false,
3243
+ properties: {
3244
+ connected: { type: 'boolean' },
3245
+ position: XR_POSITION_SCHEMA,
3246
+ orientation: XR_ORIENTATION_SCHEMA,
3247
+ },
3248
+ };
3249
+ const XR_HAND_STATE_SCHEMA = {
3250
+ ...XR_INPUT_STATE_SCHEMA,
3251
+ properties: {
3252
+ ...XR_INPUT_STATE_SCHEMA.properties,
3253
+ poseId: { type: 'string' },
3254
+ pinchValue: { type: 'number', minimum: 0, maximum: 1 },
3255
+ },
3256
+ };
3257
+ const XR_MICROGESTURE_SCHEMA = {
3258
+ type: 'string',
3259
+ enum: ['swipe-left', 'swipe-right', 'swipe-forward', 'swipe-backward', 'tap'],
3260
+ 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.",
3261
+ };
3262
+ // --- run_sequence ------------------------------------------------------------
3263
+ const XR_FRACTION_SCHEMA = {
3264
+ type: 'number',
3265
+ minimum: 0,
3266
+ maximum: 1,
3267
+ };
3268
+ const XR_TIMED_WINDOW_PROPERTIES = {
3269
+ start: XR_FRACTION_SCHEMA,
3270
+ end: XR_FRACTION_SCHEMA,
3271
+ easing: XR_EASING_SCHEMA,
3272
+ };
3273
+ const XR_SEQUENCE_TARGET_SCHEMA = {
3274
+ anyOf: [
3275
+ { type: 'string' },
3276
+ {
3277
+ type: 'object',
3278
+ additionalProperties: false,
3279
+ properties: {
3280
+ name: { type: 'string' },
3281
+ face: {
3282
+ type: 'string',
3283
+ enum: ['front', 'back', 'top', 'bottom', 'left', 'right'],
3284
+ },
3285
+ },
3286
+ required: ['name'],
3287
+ },
3288
+ ],
3289
+ description: 'A target name from xr_list_targets, or {name, face}; resolved again when the step starts.',
3290
+ };
3291
+ const XR_SEQUENCE_POSITION_SCHEMA = {
3292
+ anyOf: [
3293
+ XR_TUPLE3_SCHEMA,
3294
+ {
3295
+ type: 'object',
3296
+ additionalProperties: false,
3297
+ properties: {
3298
+ x: { type: 'number' },
3299
+ y: { type: 'number' },
3300
+ z: { type: 'number' },
3301
+ normal: XR_DIRECTION_SCHEMA,
3302
+ },
3303
+ required: ['x', 'y', 'z'],
3304
+ },
3305
+ {
3306
+ type: 'object',
3307
+ additionalProperties: false,
3308
+ properties: {
3309
+ relativeTo: { type: 'string', enum: ['head', 'body'] },
3310
+ x: { type: 'number' },
3311
+ y: { type: 'number' },
3312
+ z: { type: 'number' },
3313
+ },
3314
+ required: ['relativeTo', 'x', 'y', 'z'],
3315
+ },
3316
+ ],
3317
+ 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.',
3318
+ };
3319
+ const XR_STAND_OFF_SCHEMA = {
3320
+ type: 'object',
3321
+ additionalProperties: false,
3322
+ properties: {
3323
+ distance: { type: 'number', minimum: 0 },
3324
+ normal: XR_DIRECTION_SCHEMA,
3325
+ },
3326
+ required: ['distance'],
3327
+ };
3328
+ const XR_SEQUENCE_STEP_SCHEMA = {
3329
+ type: 'object',
3330
+ additionalProperties: false,
3331
+ properties: {
3332
+ label: { type: 'string' },
3333
+ duration: {
3334
+ anyOf: [
3335
+ { type: 'number', minimum: 0 },
3336
+ { type: 'string', enum: ['auto'] },
3337
+ ],
3338
+ description: 'Seconds for the reach, or "auto" (the default for moves): scaled to distance, turn and pose change.',
3339
+ },
3340
+ target: XR_SEQUENCE_TARGET_SCHEMA,
3341
+ position: XR_SEQUENCE_POSITION_SCHEMA,
3342
+ offset: {
3343
+ anyOf: [
3344
+ XR_STRICT_POSITION_SCHEMA,
3345
+ {
3346
+ type: 'object',
3347
+ additionalProperties: false,
3348
+ properties: { normal: { type: 'number' } },
3349
+ required: ['normal'],
3350
+ },
3351
+ ],
3352
+ 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.',
3353
+ },
3354
+ approach: {
3355
+ ...XR_STAND_OFF_SCHEMA,
3356
+ description: 'Come straight in along the surface normal (straight down while holding) for the last `distance` metres.',
3357
+ },
3358
+ depart: {
3359
+ ...XR_STAND_OFF_SCHEMA,
3360
+ description: 'Lift straight off first, along the last surface normal (straight up while holding).',
3361
+ },
3362
+ press: {
3363
+ type: 'object',
3364
+ additionalProperties: false,
3365
+ properties: {
3366
+ depth: { type: 'number', minimum: 0, maximum: 0.015 },
3367
+ hold: { type: 'number', minimum: 0, maximum: 0.2 },
3368
+ retract: { type: 'number', minimum: 0.05 },
3369
+ },
3370
+ 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.',
3371
+ },
3372
+ anchor: XR_HAND_ANCHOR_SCHEMA,
3373
+ orientation: XR_PLACEMENT_ORIENTATION_SCHEMA,
3374
+ poseId: {
3375
+ anyOf: [
3376
+ { type: 'string' },
3377
+ {
3378
+ type: 'object',
3379
+ additionalProperties: false,
3380
+ properties: {
3381
+ value: { type: 'string' },
3382
+ ...XR_TIMED_WINDOW_PROPERTIES,
3383
+ },
3384
+ required: ['value'],
3385
+ },
3386
+ ],
3387
+ description: 'Pose to fade to during the step; {value, start, end} as fractions of the reach. Never "pinch": poses do not select.',
3388
+ },
3389
+ fingers: XR_FINGER_POSES_SCHEMA,
3390
+ pinch: {
3391
+ anyOf: [
3392
+ XR_FRACTION_SCHEMA,
3393
+ {
3394
+ type: 'object',
3395
+ additionalProperties: false,
3396
+ properties: {
3397
+ value: XR_FRACTION_SCHEMA,
3398
+ ...XR_TIMED_WINDOW_PROPERTIES,
3399
+ },
3400
+ required: ['value'],
3401
+ },
3402
+ {
3403
+ type: 'object',
3404
+ additionalProperties: false,
3405
+ properties: {
3406
+ value: XR_FRACTION_SCHEMA,
3407
+ at: { type: 'string', enum: ['arrival'] },
3408
+ },
3409
+ required: ['value', 'at'],
3410
+ },
3411
+ ],
3412
+ 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.',
3413
+ },
3414
+ body: {
3415
+ type: 'object',
3416
+ additionalProperties: false,
3417
+ properties: {
3418
+ position: XR_SEQUENCE_POSITION_SCHEMA,
3419
+ stepTo: XR_SEQUENCE_TARGET_SCHEMA,
3420
+ facing: XR_DIRECTION_SCHEMA,
3421
+ },
3422
+ description: 'Move the body first: to position, or a step closer to stepTo; facing turns it. The hand goes along.',
3423
+ },
3424
+ microgesture: {
3425
+ ...XR_MICROGESTURE_SCHEMA,
3426
+ description: 'Make a microgesture where the hand is, as a step of its own (only label alongside); events report it by name.',
3427
+ },
3428
+ },
3429
+ };
3430
+ 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. " +
3431
+ '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. ' +
3432
+ '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}]}';
3009
3433
  const ALL_RUNTIME_MCP_TOOLS = [
3010
3434
  // =============================================================================
3011
3435
  // Session Management
@@ -3064,9 +3488,10 @@ const ALL_RUNTIME_MCP_TOOLS = [
3064
3488
  },
3065
3489
  {
3066
3490
  name: 'xr_set_transform',
3067
- 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.',
3491
+ 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.',
3068
3492
  inputSchema: {
3069
3493
  type: 'object',
3494
+ additionalProperties: false,
3070
3495
  properties: {
3071
3496
  device: {
3072
3497
  type: 'string',
@@ -3081,8 +3506,7 @@ const ALL_RUNTIME_MCP_TOOLS = [
3081
3506
  description: 'The device to move',
3082
3507
  },
3083
3508
  position: {
3084
- type: 'object',
3085
- description: 'World position in meters',
3509
+ ...XR_POSITION_SCHEMA,
3086
3510
  properties: {
3087
3511
  x: { type: 'number', description: 'X position (left/right)' },
3088
3512
  y: {
@@ -3095,25 +3519,8 @@ const ALL_RUNTIME_MCP_TOOLS = [
3095
3519
  },
3096
3520
  },
3097
3521
  },
3098
- orientation: {
3099
- type: 'object',
3100
- description: 'Rotation as quaternion {x,y,z,w} or euler angles {pitch,yaw,roll} in degrees',
3101
- properties: {
3102
- x: { type: 'number', description: 'Quaternion X component' },
3103
- y: { type: 'number', description: 'Quaternion Y component' },
3104
- z: { type: 'number', description: 'Quaternion Z component' },
3105
- w: { type: 'number', description: 'Quaternion W component' },
3106
- pitch: {
3107
- type: 'number',
3108
- description: 'Pitch in degrees (X rotation)',
3109
- },
3110
- yaw: { type: 'number', description: 'Yaw in degrees (Y rotation)' },
3111
- roll: {
3112
- type: 'number',
3113
- description: 'Roll in degrees (Z rotation)',
3114
- },
3115
- },
3116
- },
3522
+ orientation: XR_PLACEMENT_ORIENTATION_SCHEMA,
3523
+ anchor: XR_HAND_ANCHOR_SCHEMA,
3117
3524
  },
3118
3525
  required: ['device'],
3119
3526
  },
@@ -3156,9 +3563,10 @@ const ALL_RUNTIME_MCP_TOOLS = [
3156
3563
  },
3157
3564
  {
3158
3565
  name: 'xr_animate_to',
3159
- description: 'Smoothly animate a device to a new position/orientation over time. Gaze accepts orientation only.',
3566
+ 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.',
3160
3567
  inputSchema: {
3161
3568
  type: 'object',
3569
+ additionalProperties: false,
3162
3570
  properties: {
3163
3571
  device: {
3164
3572
  type: 'string',
@@ -3172,38 +3580,15 @@ const ALL_RUNTIME_MCP_TOOLS = [
3172
3580
  ],
3173
3581
  description: 'The device to animate',
3174
3582
  },
3175
- position: {
3176
- type: 'object',
3177
- description: 'Target world position in meters',
3178
- properties: {
3179
- x: { type: 'number' },
3180
- y: { type: 'number' },
3181
- z: { type: 'number' },
3182
- },
3183
- },
3184
- orientation: {
3185
- type: 'object',
3186
- description: 'Target rotation as quaternion {x,y,z,w} or euler angles {pitch,yaw,roll} in degrees',
3187
- properties: {
3188
- x: { type: 'number', description: 'Quaternion X component' },
3189
- y: { type: 'number', description: 'Quaternion Y component' },
3190
- z: { type: 'number', description: 'Quaternion Z component' },
3191
- w: { type: 'number', description: 'Quaternion W component' },
3192
- pitch: {
3193
- type: 'number',
3194
- description: 'Pitch in degrees (X rotation)',
3195
- },
3196
- yaw: { type: 'number', description: 'Yaw in degrees (Y rotation)' },
3197
- roll: {
3198
- type: 'number',
3199
- description: 'Roll in degrees (Z rotation)',
3200
- },
3201
- },
3202
- },
3583
+ position: XR_POSITION_SCHEMA,
3584
+ orientation: XR_PLACEMENT_ORIENTATION_SCHEMA,
3203
3585
  duration: {
3204
3586
  type: 'number',
3587
+ exclusiveMinimum: 0,
3205
3588
  description: 'Animation duration in seconds (default: 0.5)',
3206
3589
  },
3590
+ easing: XR_EASING_SCHEMA,
3591
+ anchor: XR_HAND_ANCHOR_SCHEMA,
3207
3592
  },
3208
3593
  required: ['device'],
3209
3594
  },
@@ -3276,9 +3661,10 @@ const ALL_RUNTIME_MCP_TOOLS = [
3276
3661
  },
3277
3662
  {
3278
3663
  name: 'xr_set_select_value',
3279
- description: 'Set the select (trigger/pinch) value for an input device. Use for grab-move-release patterns.',
3664
+ 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.',
3280
3665
  inputSchema: {
3281
3666
  type: 'object',
3667
+ additionalProperties: false,
3282
3668
  properties: {
3283
3669
  device: {
3284
3670
  type: 'string',
@@ -3296,13 +3682,19 @@ const ALL_RUNTIME_MCP_TOOLS = [
3296
3682
  maximum: 1,
3297
3683
  description: 'Select value (0=released, 1=fully pressed/pinched)',
3298
3684
  },
3685
+ duration: {
3686
+ type: 'number',
3687
+ minimum: 0,
3688
+ description: 'Seconds to ramp from the current value (default: 0)',
3689
+ },
3690
+ easing: XR_EASING_SCHEMA,
3299
3691
  },
3300
3692
  required: ['device', 'value'],
3301
3693
  },
3302
3694
  },
3303
3695
  {
3304
3696
  name: 'xr_select',
3305
- description: 'Perform a complete select action (press and release). Dispatches selectstart, select, selectend events.',
3697
+ 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.',
3306
3698
  inputSchema: {
3307
3699
  type: 'object',
3308
3700
  properties: {
@@ -3318,6 +3710,7 @@ const ALL_RUNTIME_MCP_TOOLS = [
3318
3710
  },
3319
3711
  duration: {
3320
3712
  type: 'number',
3713
+ exclusiveMinimum: 0,
3321
3714
  description: 'How long to hold in seconds (default: 0.15)',
3322
3715
  },
3323
3716
  },
@@ -3629,7 +4022,7 @@ const ALL_RUNTIME_MCP_TOOLS = [
3629
4022
  // =============================================================================
3630
4023
  {
3631
4024
  name: 'xr_get_device_state',
3632
- description: 'Get comprehensive state of the XR device including headset, controllers, hands, and gaze',
4025
+ description: 'Get a full snapshot: headset pose, input mode, controllers, hands (with poseId and pinchValue), gaze, stereo, and FOV. Positions are XR-origin relative.',
3633
4026
  inputSchema: {
3634
4027
  type: 'object',
3635
4028
  properties: {},
@@ -3638,35 +4031,23 @@ const ALL_RUNTIME_MCP_TOOLS = [
3638
4031
  },
3639
4032
  {
3640
4033
  name: 'xr_set_device_state',
3641
- description: 'Set device state. When called with no state, resets everything to defaults.',
4034
+ description: 'Apply a partial device state (positions XR-origin; hands also take poseId and pinchValue). Call with no `state` to reset everything to defaults.',
3642
4035
  inputSchema: {
3643
4036
  type: 'object',
4037
+ additionalProperties: false,
3644
4038
  properties: {
3645
4039
  state: {
3646
4040
  type: 'object',
4041
+ additionalProperties: false,
3647
4042
  description: 'Partial device state to apply. Omit to reset to defaults.',
3648
4043
  properties: {
3649
4044
  headset: {
3650
4045
  type: 'object',
4046
+ additionalProperties: false,
3651
4047
  description: 'Headset transform',
3652
4048
  properties: {
3653
- position: {
3654
- type: 'object',
3655
- properties: {
3656
- x: { type: 'number' },
3657
- y: { type: 'number' },
3658
- z: { type: 'number' },
3659
- },
3660
- },
3661
- orientation: {
3662
- type: 'object',
3663
- properties: {
3664
- x: { type: 'number' },
3665
- y: { type: 'number' },
3666
- z: { type: 'number' },
3667
- w: { type: 'number' },
3668
- },
3669
- },
4049
+ position: XR_POSITION_SCHEMA,
4050
+ orientation: XR_ORIENTATION_SCHEMA,
3670
4051
  },
3671
4052
  },
3672
4053
  inputMode: {
@@ -3684,46 +4065,20 @@ const ALL_RUNTIME_MCP_TOOLS = [
3684
4065
  },
3685
4066
  controllers: {
3686
4067
  type: 'object',
4068
+ additionalProperties: false,
3687
4069
  description: 'Controller states',
3688
4070
  properties: {
3689
- left: {
3690
- type: 'object',
3691
- properties: {
3692
- position: { type: 'object' },
3693
- orientation: { type: 'object' },
3694
- connected: { type: 'boolean' },
3695
- },
3696
- },
3697
- right: {
3698
- type: 'object',
3699
- properties: {
3700
- position: { type: 'object' },
3701
- orientation: { type: 'object' },
3702
- connected: { type: 'boolean' },
3703
- },
3704
- },
4071
+ left: XR_INPUT_STATE_SCHEMA,
4072
+ right: XR_INPUT_STATE_SCHEMA,
3705
4073
  },
3706
4074
  },
3707
4075
  hands: {
3708
4076
  type: 'object',
3709
- description: 'Hand states',
4077
+ additionalProperties: false,
4078
+ description: 'Hand states, including poseId and pinchValue',
3710
4079
  properties: {
3711
- left: {
3712
- type: 'object',
3713
- properties: {
3714
- position: { type: 'object' },
3715
- orientation: { type: 'object' },
3716
- connected: { type: 'boolean' },
3717
- },
3718
- },
3719
- right: {
3720
- type: 'object',
3721
- properties: {
3722
- position: { type: 'object' },
3723
- orientation: { type: 'object' },
3724
- connected: { type: 'boolean' },
3725
- },
3726
- },
4080
+ left: XR_HAND_STATE_SCHEMA,
4081
+ right: XR_HAND_STATE_SCHEMA,
3727
4082
  },
3728
4083
  },
3729
4084
  gaze: {
@@ -3731,16 +4086,8 @@ const ALL_RUNTIME_MCP_TOOLS = [
3731
4086
  additionalProperties: false,
3732
4087
  description: 'Gaze state. Its origin is derived from the headset and cannot be set independently.',
3733
4088
  properties: {
3734
- orientation: {
3735
- type: 'object',
3736
- properties: {
3737
- x: { type: 'number' },
3738
- y: { type: 'number' },
3739
- z: { type: 'number' },
3740
- w: { type: 'number' },
3741
- },
3742
- },
3743
4089
  connected: { type: 'boolean' },
4090
+ orientation: XR_ORIENTATION_SCHEMA,
3744
4091
  },
3745
4092
  },
3746
4093
  },
@@ -3749,6 +4096,108 @@ const ALL_RUNTIME_MCP_TOOLS = [
3749
4096
  },
3750
4097
  },
3751
4098
  // =============================================================================
4099
+ // Hands
4100
+ // =============================================================================
4101
+ {
4102
+ name: 'xr_set_hand_pose',
4103
+ 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}. ` +
4104
+ '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.',
4105
+ inputSchema: {
4106
+ type: 'object',
4107
+ additionalProperties: false,
4108
+ properties: {
4109
+ device: XR_HAND_DEVICE_SCHEMA,
4110
+ poseId: { type: 'string' },
4111
+ fingers: XR_FINGER_POSES_SCHEMA,
4112
+ duration: { type: 'number', minimum: 0 },
4113
+ easing: XR_EASING_SCHEMA,
4114
+ },
4115
+ required: ['device', 'poseId'],
4116
+ },
4117
+ },
4118
+ {
4119
+ name: 'xr_microgesture',
4120
+ 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.',
4121
+ inputSchema: {
4122
+ type: 'object',
4123
+ additionalProperties: false,
4124
+ properties: {
4125
+ device: XR_HAND_DEVICE_SCHEMA,
4126
+ gesture: XR_MICROGESTURE_SCHEMA,
4127
+ },
4128
+ required: ['device', 'gesture'],
4129
+ },
4130
+ },
4131
+ {
4132
+ name: 'xr_get_hand_state',
4133
+ 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).',
4134
+ inputSchema: {
4135
+ type: 'object',
4136
+ additionalProperties: false,
4137
+ properties: {
4138
+ device: XR_HAND_DEVICE_SCHEMA,
4139
+ joints: { type: 'string', enum: ['key', 'all'] },
4140
+ },
4141
+ required: ['device'],
4142
+ },
4143
+ },
4144
+ {
4145
+ name: 'xr_run_sequence',
4146
+ description: XR_RUN_SEQUENCE_DESCRIPTION,
4147
+ inputSchema: {
4148
+ type: 'object',
4149
+ additionalProperties: false,
4150
+ properties: {
4151
+ device: XR_HAND_DEVICE_SCHEMA,
4152
+ steps: {
4153
+ type: 'array',
4154
+ items: XR_SEQUENCE_STEP_SCHEMA,
4155
+ minItems: 1,
4156
+ },
4157
+ idleHand: {
4158
+ type: 'string',
4159
+ enum: ['keep', 'rest'],
4160
+ description: 'The other hand: rest it by the hip (the default unless it is pinching) or keep it where it is.',
4161
+ },
4162
+ body: {
4163
+ type: 'string',
4164
+ enum: ['auto', 'fixed'],
4165
+ description: 'auto (default): lean for low targets and step closer to ones out of reach. fixed: out of reach is an error.',
4166
+ },
4167
+ gaze: {
4168
+ type: 'string',
4169
+ enum: ['follow', 'fixed'],
4170
+ description: 'follow (default): the head turns to each target before the hand gets there.',
4171
+ },
4172
+ dryRun: {
4173
+ type: 'boolean',
4174
+ description: 'Validate and return the planned steps, walks, durations and warnings without moving anything.',
4175
+ },
4176
+ },
4177
+ required: ['device', 'steps'],
4178
+ },
4179
+ },
4180
+ {
4181
+ name: 'xr_cancel_sequence',
4182
+ 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).',
4183
+ inputSchema: {
4184
+ type: 'object',
4185
+ additionalProperties: false,
4186
+ properties: {},
4187
+ required: [],
4188
+ },
4189
+ },
4190
+ {
4191
+ name: 'xr_list_targets',
4192
+ 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.",
4193
+ inputSchema: {
4194
+ type: 'object',
4195
+ additionalProperties: false,
4196
+ properties: {},
4197
+ required: [],
4198
+ },
4199
+ },
4200
+ // =============================================================================
3752
4201
  // Console Logs (Plugin-specific, not in IWER)
3753
4202
  // =============================================================================
3754
4203
  {
@@ -3798,6 +4247,21 @@ const ALL_RUNTIME_MCP_TOOLS = [
3798
4247
  properties: {},
3799
4248
  },
3800
4249
  },
4250
+ {
4251
+ name: 'browser_set_muted',
4252
+ 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.',
4253
+ inputSchema: {
4254
+ type: 'object',
4255
+ additionalProperties: false,
4256
+ properties: {
4257
+ muted: {
4258
+ type: 'boolean',
4259
+ description: 'true mutes the tab; false unmutes it',
4260
+ },
4261
+ },
4262
+ required: ['muted'],
4263
+ },
4264
+ },
3801
4265
  // =============================================================================
3802
4266
  // Managed Workspace Tools
3803
4267
  // =============================================================================
@@ -5370,6 +5834,12 @@ const RUNTIME_TOOL_TO_METHOD = {
5370
5834
  xr_set_gamepad_state: 'set_gamepad_state',
5371
5835
  xr_get_device_state: 'get_device_state',
5372
5836
  xr_set_device_state: 'set_device_state',
5837
+ xr_set_hand_pose: 'set_hand_pose',
5838
+ xr_microgesture: 'microgesture',
5839
+ xr_get_hand_state: 'get_hand_state',
5840
+ xr_run_sequence: 'run_sequence',
5841
+ xr_cancel_sequence: 'cancel_sequence',
5842
+ xr_list_targets: 'list_targets',
5373
5843
  browser_screenshot: 'screenshot',
5374
5844
  browser_snapshot: 'browser_snapshot',
5375
5845
  browser_interact: 'browser_interact',
@@ -5401,8 +5871,15 @@ const ALL_RUNTIME_CLI_PATHS = {
5401
5871
  browser_profile: ['browser', 'profile'],
5402
5872
  xr_get_device_state: ['xr', 'get-device-state'],
5403
5873
  xr_set_device_state: ['xr', 'set-device-state'],
5874
+ xr_set_hand_pose: ['xr', 'set-hand-pose'],
5875
+ xr_microgesture: ['xr', 'microgesture'],
5876
+ xr_get_hand_state: ['xr', 'get-hand-state'],
5877
+ xr_run_sequence: ['xr', 'run-sequence'],
5878
+ xr_cancel_sequence: ['xr', 'cancel-sequence'],
5879
+ xr_list_targets: ['xr', 'list-targets'],
5404
5880
  browser_get_console_logs: ['browser', 'logs'],
5405
5881
  browser_reload_page: ['browser', 'reload'],
5882
+ browser_set_muted: ['browser', 'set-muted'],
5406
5883
  workspace_get_state: ['workspace', 'state'],
5407
5884
  workspace_set_view: ['workspace', 'set-view'],
5408
5885
  workspace_open_scene: ['workspace', 'open-scene'],
@@ -5507,6 +5984,7 @@ const HOST_BROWSER_MCP_TOOL_NAME_SET = new Set([
5507
5984
  'browser_profile',
5508
5985
  'browser_get_console_logs',
5509
5986
  'browser_reload_page',
5987
+ 'browser_set_muted',
5510
5988
  ]);
5511
5989
  const APP_TARGET_MCP_TOOL_NAME_SET = new Set([
5512
5990
  ...HOST_BROWSER_MCP_TOOL_NAME_SET,
@@ -6076,6 +6554,29 @@ function getRuntimeSessionFilePath(workspaceRoot) {
6076
6554
  function getRuntimeLaunchFilePath(workspaceRoot) {
6077
6555
  return getRuntimeFilePath(workspaceRoot, IWSDK_RUNTIME_LAUNCH_PATH);
6078
6556
  }
6557
+ function getRuntimeCommandCredentialFilePath(workspaceRoot) {
6558
+ return getRuntimeFilePath(workspaceRoot, IWSDK_RUNTIME_COMMAND_CREDENTIAL_PATH);
6559
+ }
6560
+ /**
6561
+ * Reads the command credential the dev server wrote for this session. A
6562
+ * credential left by another session is never sent. Without one (an older dev
6563
+ * server writes none), commands go out without a credential. The read is
6564
+ * synchronous so a command starts connecting without an extra turn.
6565
+ */
6566
+ function getRuntimeCommandToken(session) {
6567
+ let credential;
6568
+ try {
6569
+ credential = JSON.parse(readFileSync(getRuntimeCommandCredentialFilePath(session.workspaceRoot), 'utf8'));
6570
+ }
6571
+ catch {
6572
+ return undefined;
6573
+ }
6574
+ return credential?.sessionId === session.sessionId &&
6575
+ typeof credential.commandToken === 'string' &&
6576
+ credential.commandToken.length > 0
6577
+ ? credential.commandToken
6578
+ : undefined;
6579
+ }
6079
6580
  function getRuntimeLogsDir(workspaceRoot) {
6080
6581
  return path.join(normalizeWorkspaceRoot(workspaceRoot), IWSDK_RUNTIME_LOGS_DIR);
6081
6582
  }
@@ -11439,6 +11940,7 @@ const { CLOSE_TIMEOUT, GUID, kWebSocket } = constants;
11439
11940
  /** Keep a command connection open for the complete secondary-CDP operation. */
11440
11941
  async function acquireBrowserLease(session, timeoutMs) {
11441
11942
  const id = randomUUID();
11943
+ const commandToken = getRuntimeCommandToken(session);
11442
11944
  const protocol = session.localUrl.startsWith('https:') ? 'wss' : 'ws';
11443
11945
  const ws = new WebSocket$1(`${protocol}://127.0.0.1:${session.port}/__iwer_mcp`, { rejectUnauthorized: false });
11444
11946
  let granted = false;
@@ -11457,7 +11959,11 @@ async function acquireBrowserLease(session, timeoutMs) {
11457
11959
  closed = true;
11458
11960
  released = true;
11459
11961
  if (granted && ws.readyState === WebSocket$1.OPEN) {
11460
- ws.send(JSON.stringify({ id, method: '__iwsdk_browser_lease_release' }));
11962
+ ws.send(JSON.stringify({
11963
+ id,
11964
+ method: '__iwsdk_browser_lease_release',
11965
+ commandToken,
11966
+ }));
11461
11967
  }
11462
11968
  ws.close();
11463
11969
  };
@@ -11498,6 +12004,7 @@ async function acquireBrowserLease(session, timeoutMs) {
11498
12004
  targetId: session.browserAutomation?.targetId,
11499
12005
  timeoutMs,
11500
12006
  },
12007
+ commandToken,
11501
12008
  })));
11502
12009
  ws.on('message', (raw) => {
11503
12010
  try {
@@ -11642,7 +12149,7 @@ function inferRuntimeIssueCause(message, browser, explicitCause) {
11642
12149
  }
11643
12150
  return undefined;
11644
12151
  }
11645
- async function trySendRuntimeCommand(protocol, port, method, params, target, deadline, connectDeadline, browser, expectedSessionId) {
12152
+ async function trySendRuntimeCommand(protocol, port, method, params, target, deadline, connectDeadline, browser, expectedSessionId, commandToken) {
11646
12153
  const inferCause = (message, explicitCause) => target?.deviceClass === 'physical'
11647
12154
  ? inferPhysicalIssueCause(message, explicitCause)
11648
12155
  : inferRuntimeIssueCause(message, browser, explicitCause);
@@ -11722,6 +12229,7 @@ async function trySendRuntimeCommand(protocol, port, method, params, target, dea
11722
12229
  method,
11723
12230
  params: params ?? {},
11724
12231
  ...(target ? { target } : {}),
12232
+ commandToken,
11725
12233
  });
11726
12234
  traceTransport('open', {
11727
12235
  method,
@@ -11863,7 +12371,7 @@ async function trySendRuntimeCommand(protocol, port, method, params, target, dea
11863
12371
  });
11864
12372
  }
11865
12373
  async function sendRuntimeCommandBeforeDeadline(options, deadline) {
11866
- const { method, params, port, runtimeSession, target } = options;
12374
+ const { commandToken, method, params, port, runtimeSession, target } = options;
11867
12375
  // Managed browser state describes the host browser only, never a headset.
11868
12376
  const browser = target?.deviceClass === 'physical' ? undefined : runtimeSession?.browser;
11869
12377
  const protocolOrder = getProtocolOrder(runtimeSession);
@@ -11875,7 +12383,7 @@ async function sendRuntimeCommandBeforeDeadline(options, deadline) {
11875
12383
  ? Date.now() + FAST_WSS_FALLBACK_TIMEOUT_MS
11876
12384
  : deadline;
11877
12385
  try {
11878
- return await trySendRuntimeCommand(firstProtocol, port, method, params, target, deadline, connectDeadline, browser, runtimeSession?.sessionId);
12386
+ return await trySendRuntimeCommand(firstProtocol, port, method, params, target, deadline, connectDeadline, browser, runtimeSession?.sessionId, commandToken);
11879
12387
  }
11880
12388
  catch (error) {
11881
12389
  if (!(error instanceof RuntimeCommandTransportError)) {
@@ -11902,7 +12410,7 @@ async function sendRuntimeCommandBeforeDeadline(options, deadline) {
11902
12410
  })
11903
12411
  : false,
11904
12412
  });
11905
- return trySendRuntimeCommand(fallbackProtocol, port, method, params, target, deadline, deadline, browser, runtimeSession?.sessionId);
12413
+ return trySendRuntimeCommand(fallbackProtocol, port, method, params, target, deadline, deadline, browser, runtimeSession?.sessionId, commandToken);
11906
12414
  }
11907
12415
  }
11908
12416
  function sceneOpenReadinessRequest(method, params, response, previousSceneSessionId) {
@@ -11938,6 +12446,7 @@ async function captureSceneOpenSessionBaseline(options, deadline) {
11938
12446
  while (Date.now() < deadline) {
11939
12447
  try {
11940
12448
  const stateResponse = await sendRuntimeCommandBeforeDeadline({
12449
+ commandToken: options.commandToken,
11941
12450
  method: 'scene_get_state',
11942
12451
  params: {},
11943
12452
  port: options.port,
@@ -11995,6 +12504,7 @@ async function confirmOpenedSceneReady(options, response, deadline, previousScen
11995
12504
  while (Date.now() < deadline) {
11996
12505
  try {
11997
12506
  const stateResponse = await sendRuntimeCommandBeforeDeadline({
12507
+ commandToken: options.commandToken,
11998
12508
  method: 'scene_get_state',
11999
12509
  params: {},
12000
12510
  port: options.port,
@@ -12051,9 +12561,17 @@ async function confirmOpenedSceneReady(options, response, deadline, previousScen
12051
12561
  : 'browser_not_ready',
12052
12562
  });
12053
12563
  }
12054
- async function sendRuntimeCommand({ port, method, params, target, timeoutMs = getDefaultRuntimeCommandTimeoutMs(method), runtimeSession, }) {
12564
+ async function sendRuntimeCommand({ port, method, params, target, timeoutMs = getDefaultRuntimeCommandTimeoutMs(method, params), runtimeSession, }) {
12055
12565
  const deadline = Date.now() + Math.max(timeoutMs, 1);
12056
- const options = { method, params, port, runtimeSession, target };
12566
+ const commandToken = runtimeSession == null ? undefined : getRuntimeCommandToken(runtimeSession);
12567
+ const options = {
12568
+ commandToken,
12569
+ method,
12570
+ params,
12571
+ port,
12572
+ runtimeSession,
12573
+ target,
12574
+ };
12057
12575
  const previousSceneSessionId = await captureSceneOpenSessionBaseline(options, deadline);
12058
12576
  const response = await sendRuntimeCommandBeforeDeadline(options, deadline);
12059
12577
  return confirmOpenedSceneReady(options, response, deadline, previousSceneSessionId);
@@ -31158,6 +31676,9 @@ const DIRECT_OPTION_ALIASES = {
31158
31676
  pattern: { parameter: 'pattern', type: 'string' },
31159
31677
  since: { parameter: 'since', type: 'number' },
31160
31678
  },
31679
+ browser_set_muted: {
31680
+ muted: { parameter: 'muted', type: 'boolean' },
31681
+ },
31161
31682
  ecs_step: {
31162
31683
  count: { parameter: 'count', type: 'number' },
31163
31684
  frames: { parameter: 'count', type: 'number' },
@@ -31165,6 +31686,15 @@ const DIRECT_OPTION_ALIASES = {
31165
31686
  },
31166
31687
  };
31167
31688
  function parseDirectValue(value, option, type) {
31689
+ if (type === 'boolean') {
31690
+ if (value === true || value === 'true') {
31691
+ return true;
31692
+ }
31693
+ if (value === 'false') {
31694
+ return false;
31695
+ }
31696
+ throw new Error(`--${option} must be true or false`);
31697
+ }
31168
31698
  if (typeof value !== 'string') {
31169
31699
  throw new Error(`--${option} requires a value`);
31170
31700
  }
@@ -31274,7 +31804,7 @@ async function runRuntimeOperation(operation, options, io, telemetry) {
31274
31804
  try {
31275
31805
  const parsedParams = resolveRuntimeParams(operation.mcpName, options);
31276
31806
  command = resolveRuntimeOperationRequest(operation, parsedParams);
31277
- timeoutMs = parseIntegerOption(options.timeout, '--timeout', getDefaultRuntimeCommandTimeoutMs(operation.wsMethod));
31807
+ timeoutMs = parseIntegerOption(options.timeout, '--timeout', getDefaultRuntimeCommandTimeoutMs(operation.wsMethod, command.params));
31278
31808
  }
31279
31809
  catch (error) {
31280
31810
  telemetry.fail('invalid_input');
@@ -31396,6 +31926,14 @@ function formatSchemaPropertyLines(propertyPath, schema, required, indent = 2) {
31396
31926
  }
31397
31927
  return lines;
31398
31928
  }
31929
+ // Where the schema alone would make an empty or placeholder example.
31930
+ const RUNTIME_HELP_EXAMPLES = {
31931
+ xr_run_sequence: {
31932
+ device: 'hand-right',
31933
+ steps: [{ label: 'press', target: 'counter-button', press: {} }],
31934
+ },
31935
+ xr_set_hand_pose: { device: 'hand-right', poseId: 'point' },
31936
+ };
31399
31937
  function schemaExample(schema) {
31400
31938
  if (schema.enum?.length) {
31401
31939
  return schema.enum[0];
@@ -31453,13 +31991,17 @@ function buildRuntimeCommandHelp(domain, action) {
31453
31991
  lines.push(...formatSchemaPropertyLines(name, schema, required.has(name)));
31454
31992
  }
31455
31993
  }
31456
- lines.push('', 'Example:', ` iwsdk ${domain} ${action} --input-json '${JSON.stringify(schemaExample(operation.inputSchema))}'`, '', 'Options:', ' --input-json <json>', ' --timeout <ms>', ' --raw');
31994
+ lines.push('', 'Example:', ` iwsdk ${domain} ${action} --input-json '${JSON.stringify(RUNTIME_HELP_EXAMPLES[operation.mcpName] ??
31995
+ schemaExample(operation.inputSchema))}'`, '', 'Options:', ' --input-json <json>', ' --timeout <ms>', ' --raw');
31457
31996
  if (writesScreenshot) {
31458
31997
  lines.push(' --output-file <path> Write the PNG to this path and return screenshotPath; takes precedence over --raw');
31459
31998
  }
31460
31999
  if (operation.mcpName === 'ecs_step') {
31461
32000
  lines.push(' --frames <count> Alias for input count', ' --count <count> Alias for input count', ' --delta <seconds> Alias for input delta');
31462
32001
  }
32002
+ if (operation.mcpName === 'browser_set_muted') {
32003
+ lines.push(' --muted <true|false> Alias for input muted');
32004
+ }
31463
32005
  if (operation.mcpName === 'browser_get_console_logs') {
31464
32006
  lines.push(' --level <levels> Comma-separated log-level alias', ' --count <count> Maximum log-count alias', ' --pattern <regex> Message-pattern alias', ' --since <timestamp> Timestamp alias');
31465
32007
  }