@vestra-player/sdk 1.7.14 → 1.7.16

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.16
4
+
5
+ **Who must change: nobody.** One optional field on an existing call (Ask Vestra UX, step 3: one approval for the whole request); `apiVersion` stays `vestra/1`, no new capability or message; the API surface snapshot gains the field. The field is an option of `commands.run`, not a separate `commands.plan`: the plan only matters for the run that starts it, a separate call would be a second request whose ordering against the first the player would have to tie together, and an option keeps an older player's behaviour (it ignores the field and asks per command) without a version check.
6
+
7
+ - **`CommandRunOptions.then`** (`commands.run`'s `then`): the global ids of the commands the same ticket runs next, 0–7 of them (a plan has at most 8 commands; an id may repeat). The player judges the plan whole, this command first: if any of it asks first (a `destructive` command, the player's Close and Quit, the Settings and Reset menus, a command of a plugin that is not built in), it asks once, before this command runs, listing the whole plan. Run runs this command and remembers the rest of the plan for the ticket: each later run of a planned command uses up one entry and does not ask; a command outside the plan asks on its own. A run without `then` (absent or `null`) starts no plan; a later run with `then` starts a new plan, and `then: []` is a plan of that command alone, which replaces the rest of the earlier one. Don't Run runs nothing and remembers nothing (`{ ran: false, declined: true }`). When nothing in the plan asks, nothing is asked or remembered. Refusals, in the player's order after `step`/`of`: not an array, more than 7 ids or an id that is not a non-empty string is `invalid`; after the command's own checks, an id that is not listed now is `missing` and `host/palette` `invalid`; enabled and busy are checked when each command runs. `then` counts no run. The SDK sends it only when given and checks its shape first. Players before the approval sheet ignore it. Docs: [Reference: commands](docs/reference/commands.md#running-commands-for-the-user).
8
+ - **`TestHost`** models it: one `dialogAnswers` answer covers the plan, an approved plan is remembered per ticket and used up per run, a new plan replaces the old, Don't Run remembers nothing. `{ confirmed: true, checked: true }` is Run with "Don't ask again" (the player's answer `always`); every command a test host lists is built in, so it runs like Run. `TestHost` checks `then` like the player for a client that bypasses the SDK. `COMMAND_RUN_LIMITS` (the plan's 8 and the existing rates and ticket idle time) is exported from `./runtime` for the player's agreement test. Test: `test/run-plan.test.ts`.
9
+ - **`TestHost` follows the player** (review follow-ups of 1.7.15): `palette.lead.set`'s texts are counted as shown (translated with the plugin's catalog, a text value with its arguments), as the player counts them, not by their source text, and refused on more than one line (`… must be 1–N characters on one line`); a `status` without `text` is `invalid`. `commands.list`'s `dangerous` covers the built-in Settings and Reset menus by key (`@settings`, `@reset`, and the old Chinese title 设置 of Settings, the whole path normalized), as the player's; it named a `Plugins` path and missed `@settings`. The docs of `Commands.run` and the reference say Settings and Reset.
10
+
11
+ ## 1.7.15
12
+
13
+ **Who must change: nobody.** One optional field on an existing call (Ask Vestra UX, step 2: the status strip); `apiVersion` stays `vestra/1`, no new capability or message; the API surface snapshot gains the field.
14
+
15
+ - **`PaletteLeadOptions.status.state`** (`palette.lead.set`'s `status.state`): `"working"` (the default) or an end state, `"done"`, `"failed"` or `"note"`. While the palette is closed the player shows the status in a strip at the top of the main window: `working` with a moving line and a Stop button, until the status changes; an end state with a check, in the danger colour or plain, removed by the player after a few seconds and never shown again (not kept while the plugin is stopped), so the plugin needs no timer. Once `commands.run` has shown a step of the ticket in the strip, a `working` text changes only the palette's status row. The SDK sends `state` only when set; any other value is `invalid` (through `ready`, or `update` rejects). Players before the strip refuse the field with `invalid`; a built-in plugin ships with its player. Docs: [Reference: commands](docs/reference/commands.md#running-commands-for-the-user).
16
+ - **`TestHost`** checks `status.state` like the player (absent or `null` is `working`, any other value than the four is `invalid`) and keeps it in `host.paletteLead`; the end state's timing is the player's and is not modelled. Test: `test/builtin-only.test.ts`.
17
+ - **Docs, Windows confirmations** (player main 7cc5d648): `Dialogs.confirm` and [Platforms](docs/reference/platforms.md) say what the player now shows: `message` is the main instruction with `detail` below it, the `checkbox` is the dialog's own verification box (no second dialog), `checked` is reported on cancel too, and no system sound plays.
18
+
3
19
  ## 1.7.14
4
20
 
5
21
  **Who must change: nobody.** A product-data refresh and a `TestHost` follow-up to player 0.8.0: no API change, `apiVersion` stays `vestra/1`, the API surface snapshot is unchanged.
@@ -177,6 +177,33 @@ export declare const BAR_BUTTON_LIMITS: {
177
177
  /** The highest `order` (999; the lowest is 0). */
178
178
  readonly maxOrder: 999;
179
179
  };
180
+ /**
181
+ * The player's limits on `commands.run` (built-in plugins only), the same
182
+ * values as the player's (its agreement test checks that they agree).
183
+ * Internal: exported from `@vestra-player/sdk/runtime` only.
184
+ *
185
+ * @internal
186
+ */
187
+ export declare const COMMAND_RUN_LIMITS: {
188
+ /** Commands of one plan: the run and the ids of its `then` (8). */
189
+ readonly plan: 8;
190
+ /** Runs of one ticket (30). */
191
+ readonly perTicket: 30;
192
+ /** Runs a second, per ticket (4). */
193
+ readonly perSecond: 4;
194
+ /** Runs a minute, per plugin (120). */
195
+ readonly perMinute: 120;
196
+ /** A ticket ends this long after it was given or last ran a command (ms). */
197
+ readonly ticketIdleMs: 120000;
198
+ };
199
+ /**
200
+ * What is wrong with `commands.run`'s `then` (given, not `null`), as
201
+ * the player words it; `null` when nothing is. The SDK and `TestHost`
202
+ * check it the same way.
203
+ *
204
+ * @internal
205
+ */
206
+ export declare function thenProblem(then: unknown): string | null;
180
207
  /**
181
208
  * A submenu that one of the player's built-in plugins declares: an entry of
182
209
  * {@link BUILTIN_SUBMENUS}.
@@ -393,5 +420,6 @@ export declare function commandClient(transport: Transport): {
393
420
  ticket: string;
394
421
  step?: number;
395
422
  of?: number;
423
+ then?: string[];
396
424
  }) => Promise<CommandRunResult>;
397
425
  };
package/dist/commands.js CHANGED
@@ -223,6 +223,41 @@ export const BAR_BUTTON_LIMITS = {
223
223
  /** The highest `order` (999; the lowest is 0). */
224
224
  maxOrder: 999,
225
225
  };
226
+ /**
227
+ * The player's limits on `commands.run` (built-in plugins only), the same
228
+ * values as the player's (its agreement test checks that they agree).
229
+ * Internal: exported from `@vestra-player/sdk/runtime` only.
230
+ *
231
+ * @internal
232
+ */
233
+ export const COMMAND_RUN_LIMITS = {
234
+ /** Commands of one plan: the run and the ids of its `then` (8). */
235
+ plan: 8,
236
+ /** Runs of one ticket (30). */
237
+ perTicket: 30,
238
+ /** Runs a second, per ticket (4). */
239
+ perSecond: 4,
240
+ /** Runs a minute, per plugin (120). */
241
+ perMinute: 120,
242
+ /** A ticket ends this long after it was given or last ran a command (ms). */
243
+ ticketIdleMs: 120_000,
244
+ };
245
+ /**
246
+ * What is wrong with `commands.run`'s `then` (given, not `null`), as
247
+ * the player words it; `null` when nothing is. The SDK and `TestHost`
248
+ * check it the same way.
249
+ *
250
+ * @internal
251
+ */
252
+ export function thenProblem(then) {
253
+ if (!Array.isArray(then))
254
+ return "then is an array of command ids";
255
+ if (then.length > COMMAND_RUN_LIMITS.plan - 1)
256
+ return `then has at most ${COMMAND_RUN_LIMITS.plan - 1} command ids`;
257
+ if (then.some((id) => typeof id !== "string" || id === ""))
258
+ return "then has command ids: non-empty strings";
259
+ return null;
260
+ }
226
261
  /**
227
262
  * The submenus the player's built-in plugins declare, by key path, in menu
228
263
  * order (built-in menus as in {@link MENU_IDS}, then top-level submenus).
Binary file
@@ -17,6 +17,7 @@ export { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, BUILTIN_SUBMENUS
17
17
  export { BINDING_INPUTS } from "./plugin/bindings.ts";
18
18
  export { MEDIA_SOURCE_LIMITS } from "./plugin/media.ts";
19
19
  export { REQUEST_LIMITS, UNQUEUED_METHODS } from "./request-queue.ts";
20
+ export { COMMAND_RUN_LIMITS } from "./commands.ts";
20
21
  export { OSD_LIMITS } from "./plugin/osd.ts";
21
22
  export { TIMELINE_LIMITS } from "./plugin/timeline.ts";
22
23
  export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.ts";
@@ -15,6 +15,7 @@ export { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, BUILTIN_SUBMENUS
15
15
  export { BINDING_INPUTS } from "./plugin/bindings.js";
16
16
  export { MEDIA_SOURCE_LIMITS } from "./plugin/media.js";
17
17
  export { REQUEST_LIMITS, UNQUEUED_METHODS } from "./request-queue.js";
18
+ export { COMMAND_RUN_LIMITS } from "./commands.js";
18
19
  export { OSD_LIMITS } from "./plugin/osd.js";
19
20
  export { TIMELINE_LIMITS } from "./plugin/timeline.js";
20
21
  export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.js";
@@ -2,7 +2,7 @@
2
2
  import { Latest } from "./latest.js";
3
3
  import { failure, quiet, uncertain } from "./errors.js";
4
4
  import { checkBindings } from "./bindings.js";
5
- import { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, MENU_IDS } from "../commands.js";
5
+ import { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, MENU_IDS, thenProblem, } from "../commands.js";
6
6
  import { ImageHandle } from "./view/image.js";
7
7
  import { isTextValue, textProblem } from "../i18n.js";
8
8
  import { conditionJson, isCondition } from "./when.js";
@@ -366,7 +366,7 @@ export const commands = (scope) => ({
366
366
  needs(scope, "commands.run");
367
367
  if (typeof id !== "string" || id === "")
368
368
  throw failure("invalid", "run takes a command id: <plugin>/<id>");
369
- const { ticket, step, of } = (options ?? {});
369
+ const { ticket, step, of, then } = (options ?? {});
370
370
  if (typeof ticket !== "string" || ticket === "")
371
371
  throw failure("ticket", "run needs the ticket of a user action");
372
372
  // As the player: both or neither, 1 <= step <= of <= 99.
@@ -376,11 +376,21 @@ export const commands = (scope) => ({
376
376
  if ((step === undefined) !== (of === undefined) ||
377
377
  (step !== undefined && (!whole(step) || !whole(of) || step > of)))
378
378
  throw failure("invalid", "step and of go together, 1 <= step <= of <= 99");
379
+ // As the player: the rest of the plan, 0–7 non-empty ids.
380
+ const planned = then ?? undefined;
381
+ if (planned !== undefined) {
382
+ const problem = thenProblem(planned);
383
+ if (problem)
384
+ throw failure("invalid", problem);
385
+ }
379
386
  return scope.runtime.host.commands.run({
380
387
  id,
381
388
  ticket,
382
389
  ...(step === undefined ? {} : { step }),
383
390
  ...(of === undefined ? {} : { of }),
391
+ // An array, never called: not a thenable.
392
+ // oxlint-disable-next-line unicorn/no-thenable
393
+ ...(planned === undefined ? {} : { then: [...planned] }),
384
394
  });
385
395
  },
386
396
  });
@@ -407,12 +417,15 @@ function leadJson(options) {
407
417
  out.status = null;
408
418
  else if (status !== undefined) {
409
419
  if (typeof status !== "object")
410
- throw failure("invalid", "status is { text, note? } or null");
420
+ throw failure("invalid", "status is { text, note?, state? } or null");
411
421
  out.status = {
412
422
  text: text(status.text, "status.text"),
413
423
  ...(status.note === undefined
414
424
  ? {}
415
425
  : { note: text(status.note, "status.note") }),
426
+ // Sent only when set (players before it refuse the field); the
427
+ // player checks the value.
428
+ ...(status.state === undefined ? {} : { state: status.state }),
416
429
  };
417
430
  }
418
431
  return out;
@@ -7,7 +7,7 @@
7
7
  * Internal to the SDK; not exported from `@vestra-player/sdk/testing`.
8
8
  */
9
9
  import { HostError } from "../../wire.js";
10
- import { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, COMMAND_LIMITS, MENU_IDS, } from "../../commands.js";
10
+ import { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, COMMAND_LIMITS, MENU_IDS, thenProblem, } from "../../commands.js";
11
11
  import { canonical, keyLabel } from "../bindings.js";
12
12
  import { evaluate } from "../when.js";
13
13
  import { menuKeys, textKey } from "../../i18n.js";
@@ -484,7 +484,9 @@ function listed(host, inner, row) {
484
484
  : declared === null || !parent.length
485
485
  ? "Menu"
486
486
  : `${parent.join(" ▸ ")} ▸`;
487
- const root = keys[0] === undefined ? undefined : menuTextKey(keys[0]);
487
+ // The built-in menu's key, as the player's `path_keys`: the whole path
488
+ // normalized (`@settings` and the old title `设置` are `Settings`).
489
+ const root = menuKeys(keys.map(menuTextKey))[0];
488
490
  return {
489
491
  id: row.global,
490
492
  label: `${category}: ${display.title}`,
@@ -502,13 +504,14 @@ function listed(host, inner, row) {
502
504
  group: declaration.group,
503
505
  busy: state.busy,
504
506
  // Asks first: not built in, destructive, the player's Close and Quit,
505
- // the Settings and Plugins menus.
507
+ // the built-in Settings and Reset menus (capabilities/commands_run.rs
508
+ // `dangerous`).
506
509
  dangerous: !builtin ||
507
510
  declaration.destructive === true ||
508
511
  row.global === "host/stop" ||
509
512
  row.global === "host/quit" ||
510
513
  root === "Settings" ||
511
- root === "Plugins",
514
+ root === "Reset",
512
515
  ...(state.checked === null ? {} : { checked: state.checked }),
513
516
  ...(!state.enabled && display.reason ? { reason: display.reason } : {}),
514
517
  };
@@ -522,6 +525,8 @@ const LEAD_TEXTS = {
522
525
  "status.text": 80,
523
526
  "status.note": 40,
524
527
  };
528
+ /** `palette.lead.set`'s `status.state` (absent or null: `working`). */
529
+ const LEAD_STATES = ["working", "done", "failed", "note"];
525
530
  /** The default handlers of `commands.run` and `palette.lead`. */
526
531
  export function builtinHandlers(host, inner) {
527
532
  return {
@@ -545,17 +550,32 @@ export function builtinHandlers(host, inner) {
545
550
  (p.step !== undefined &&
546
551
  (!whole(p.step) || !whole(p.of) || Number(p.step) > Number(p.of))))
547
552
  throw new HostError("invalid", "step and of go together, step ≤ of");
553
+ // The rest of the plan: its shape, then (after the command) each id.
554
+ const then = p.then === undefined || p.then === null ? null : p.then;
555
+ if (then !== null) {
556
+ const problem = thenProblem(then);
557
+ if (problem)
558
+ throw new HostError("invalid", problem);
559
+ }
560
+ const table = rows(host);
561
+ const find = (id) => {
562
+ // The player lists its palette command (a test host does not).
563
+ if (id === "host/palette")
564
+ throw new HostError("invalid", "the command palette is not run this way");
565
+ const row = table.find((each) => each.global === id);
566
+ if (!row)
567
+ throw new HostError("missing", `no command ${id}`);
568
+ return row;
569
+ };
548
570
  const id = String(p.id);
549
- const row = rows(host).find((each) => each.global === id);
550
- if (!row)
551
- throw new HostError("missing", `no command ${id}`);
552
- if (id === "host/palette")
553
- throw new HostError("invalid", "the command palette is not run this way");
571
+ const row = find(id);
554
572
  const item = listed(host, inner, row);
555
573
  if (!item.enabled)
556
574
  throw new HostError("disabled", item.reason ?? `${item.label} is disabled`);
557
575
  if (item.busy)
558
576
  throw new HostError("busy", `${item.label} is busy`);
577
+ // Listed now; enabled and busy are checked when each runs.
578
+ const planned = (then ?? []).map((each) => listed(host, inner, find(each)));
559
579
  const now = Date.now();
560
580
  const ticket = inner.tickets.get(String(p.ticket));
561
581
  if (!ticket || now - ticket.last > 120_000) {
@@ -574,13 +594,32 @@ export function builtinHandlers(host, inner) {
574
594
  ticket.runs.push(now);
575
595
  ticket.last = now;
576
596
  inner.runs.push(now);
577
- // The player's own alert, answered like the plugin's alerts.
578
- if (item.dangerous) {
597
+ // Whether to ask: a new plan (`then`) is judged whole and replaces the
598
+ // rest of an earlier one; a run left in the approved plan uses up one
599
+ // entry and does not ask; anything else is judged on its own.
600
+ let asks;
601
+ if (then !== null) {
602
+ ticket.plan = null;
603
+ asks = [item, ...planned].some((each) => each.dangerous);
604
+ }
605
+ else {
606
+ const at = ticket.plan?.indexOf(id) ?? -1;
607
+ if (at >= 0)
608
+ ticket.plan.splice(at, 1);
609
+ asks = at < 0 && item.dangerous;
610
+ }
611
+ // The player's own question, answered like the plugin's alerts: Run
612
+ // (`confirmed`), Run with "Don't ask again" (`confirmed` and
613
+ // `checked`: every command a test host lists is built in, so there
614
+ // is nothing to remember), or Don't Run.
615
+ if (asks) {
579
616
  const answer = host.dialogAnswers.shift();
580
617
  if (answer === undefined || answer === null || Array.isArray(answer))
581
618
  throw new Error("test host: no confirm answer queued for commands.run");
582
619
  if (!answer.confirmed)
583
620
  return { ran: false, declined: true };
621
+ if (then !== null)
622
+ ticket.plan = [...then];
584
623
  }
585
624
  // The OSD line naming the caller and the command.
586
625
  const step = p.step === undefined ? "" : ` · ${p.step}/${p.of}`;
@@ -602,16 +641,25 @@ export function builtinHandlers(host, inner) {
602
641
  ? p[first]?.[second]
603
642
  : p[first];
604
643
  if (value === undefined || value === null) {
605
- if (name === "title")
606
- throw new HostError("invalid", "title is required");
644
+ if (name === "title" || (name === "status.text" && p.status))
645
+ throw new HostError("invalid", `${name} is required`);
607
646
  continue;
608
647
  }
609
- const length = [...menuTextKey(value)].length;
610
- if (length < 1 || length > max)
611
- throw new HostError("invalid", `${name} has 1–${max} characters`);
648
+ // Counted as shown, as the player counts it: translated with the
649
+ // plugin's catalog, a text value rendered with its arguments.
650
+ const shown = declaredText(host, inner, value, name);
651
+ const length = [...shown].length;
652
+ if (length < 1 || length > max || /[\0\n\r]/.test(shown))
653
+ throw new HostError("invalid", `${name} must be 1–${max} characters on one line`);
612
654
  }
613
655
  if (typeof p.icon !== "string" && host.imagePath(p.icon) === null)
614
656
  throw new HostError("invalid", "icon is an icon name or an image");
657
+ const state = p.status
658
+ ?.state;
659
+ if (state !== undefined &&
660
+ state !== null &&
661
+ !LEAD_STATES.includes(state))
662
+ throw new HostError("invalid", `status.state is one of ${LEAD_STATES.join(", ")}`);
615
663
  host.paletteLead = { ...p };
616
664
  },
617
665
  "palette.lead.clear": () => {
@@ -631,7 +679,12 @@ export async function runPaletteLead(host, inner, query, options) {
631
679
  // One request at a time: the plugin's earlier tickets end.
632
680
  inner.tickets.clear();
633
681
  const ticket = `ticket-${++inner.next.ticket}`;
634
- inner.tickets.set(ticket, { count: 0, runs: [], last: Date.now() });
682
+ inner.tickets.set(ticket, {
683
+ count: 0,
684
+ runs: [],
685
+ last: Date.now(),
686
+ plan: null,
687
+ });
635
688
  host.emit("palette.lead", {
636
689
  query,
637
690
  keep: options.keep ?? false,
@@ -2350,10 +2350,15 @@ export declare class TestHost implements Transport {
2350
2350
  * Like the player, `commands.run` takes the ticket until
2351
2351
  * `PaletteLead.done` or 120 s after its last run, at most 30 runs, 4 a
2352
2352
  * second, and 120 runs a minute per plugin (`limit`). A command declared
2353
- * `destructive` (and the player's `host/stop`) is confirmed first: the
2354
- * answer comes from {@link TestHost.dialogAnswers}
2355
- * (`{ confirmed: false, checked: false }` is Don't Run); each run adds
2356
- * the command's title (and ` · step/of`) to {@link TestHost.osd}.
2353
+ * `destructive` (and the player's `host/stop` and `host/quit`, and the
2354
+ * Settings and Reset menus) is confirmed first: the answer comes from
2355
+ * {@link TestHost.dialogAnswers} (`{ confirmed: false, checked: false }`
2356
+ * is Don't Run, `confirmed: true` Run, with `checked: true` Run and
2357
+ * "Don't ask again", which runs like Run since every command a test host
2358
+ * lists is built in). A run with `then` (since 1.7.16) takes one answer
2359
+ * for its whole plan and remembers an approved plan for the ticket, as
2360
+ * the player does ({@link "@vestra-player/sdk"!CommandRunOptions.then}). Each run adds the
2361
+ * command's title (and ` · step/of`) to {@link TestHost.osd}.
2357
2362
  *
2358
2363
  * @param query - What the user typed.
2359
2364
  * @param options - `keep`: Shift+Enter; `status`: the status row.
@@ -2363,7 +2368,8 @@ export declare class TestHost implements Transport {
2363
2368
  * The user asks the plugin to stop playback and declines the
2364
2369
  * confirmation. `builtin` lets the plugin hold the lead; the ticket
2365
2370
  * minted here is what its listener passes to `commands.run`, and the
2366
- * queued answer declines the player's alert for `host/stop`.
2371
+ * queued answer declines the player's alert for `host/stop`. One answer
2372
+ * covers a request whose first run names the rest of its plan in `then`.
2367
2373
  * ```ts
2368
2374
  * import assert from "node:assert/strict";
2369
2375
  * import { startPlugin } from "@vestra-player/sdk/testing";
@@ -1854,10 +1854,15 @@ export class TestHost {
1854
1854
  * Like the player, `commands.run` takes the ticket until
1855
1855
  * `PaletteLead.done` or 120 s after its last run, at most 30 runs, 4 a
1856
1856
  * second, and 120 runs a minute per plugin (`limit`). A command declared
1857
- * `destructive` (and the player's `host/stop`) is confirmed first: the
1858
- * answer comes from {@link TestHost.dialogAnswers}
1859
- * (`{ confirmed: false, checked: false }` is Don't Run); each run adds
1860
- * the command's title (and ` · step/of`) to {@link TestHost.osd}.
1857
+ * `destructive` (and the player's `host/stop` and `host/quit`, and the
1858
+ * Settings and Reset menus) is confirmed first: the answer comes from
1859
+ * {@link TestHost.dialogAnswers} (`{ confirmed: false, checked: false }`
1860
+ * is Don't Run, `confirmed: true` Run, with `checked: true` Run and
1861
+ * "Don't ask again", which runs like Run since every command a test host
1862
+ * lists is built in). A run with `then` (since 1.7.16) takes one answer
1863
+ * for its whole plan and remembers an approved plan for the ticket, as
1864
+ * the player does ({@link "@vestra-player/sdk"!CommandRunOptions.then}). Each run adds the
1865
+ * command's title (and ` · step/of`) to {@link TestHost.osd}.
1861
1866
  *
1862
1867
  * @param query - What the user typed.
1863
1868
  * @param options - `keep`: Shift+Enter; `status`: the status row.
@@ -1867,7 +1872,8 @@ export class TestHost {
1867
1872
  * The user asks the plugin to stop playback and declines the
1868
1873
  * confirmation. `builtin` lets the plugin hold the lead; the ticket
1869
1874
  * minted here is what its listener passes to `commands.run`, and the
1870
- * queued answer declines the player's alert for `host/stop`.
1875
+ * queued answer declines the player's alert for `host/stop`. One answer
1876
+ * covers a request whose first run names the rest of its plan in `then`.
1871
1877
  * ```ts
1872
1878
  * import assert from "node:assert/strict";
1873
1879
  * import { startPlugin } from "@vestra-player/sdk/testing";
@@ -72,11 +72,15 @@ export declare class Internals {
72
72
  resolution: number;
73
73
  ticket: number;
74
74
  };
75
- /** `commands.run` tickets: runs, run times in the last second, last use (ms). */
75
+ /**
76
+ * `commands.run` tickets: runs, run times in the last second, last use
77
+ * (ms), and the rest of an approved plan (`then`), `null` without one.
78
+ */
76
79
  readonly tickets: Map<string, {
77
80
  count: number;
78
81
  runs: number[];
79
82
  last: number;
83
+ plan: string[] | null;
80
84
  }>;
81
85
  /** The last `commands.list` table (JSON) and its revision. */
82
86
  listed: {
@@ -55,7 +55,10 @@ export class Internals {
55
55
  resolution: 0,
56
56
  ticket: 0,
57
57
  };
58
- /** `commands.run` tickets: runs, run times in the last second, last use (ms). */
58
+ /**
59
+ * `commands.run` tickets: runs, run times in the last second, last use
60
+ * (ms), and the rest of an approved plan (`then`), `null` without one.
61
+ */
59
62
  tickets = new Map();
60
63
  /** The last `commands.list` table (JSON) and its revision. */
61
64
  listed = { text: "", revision: 0 };
@@ -894,33 +894,49 @@ export interface Commands {
894
894
  * line naming the plugin and the command (`Vestra Player AI · 1/2 ·
895
895
  * Playback: Mute`), and asks the user first (Run / Don't Run) before a
896
896
  * command declared {@link CommandOptions.destructive}, the player's Close
897
- * and Quit, anything in the Settings and Plugins menus, and every command
897
+ * and Quit, anything in the Settings and Reset menus, and every command
898
898
  * of a plugin that is not built in. Runs are limited to 4 a second and 30
899
899
  * per ticket, and 120 a minute per plugin. The run is not added to the
900
900
  * palette's recent list.
901
901
  *
902
+ * A request of several commands names the rest of its plan in `then` on
903
+ * its first run (since 1.7.16): if any command of the plan asks first,
904
+ * the player asks once, before the first command runs, listing the whole
905
+ * plan, and the later runs of the planned commands with the same ticket
906
+ * do not ask again. Don't Run runs none of them. See
907
+ * {@link CommandRunOptions.then}.
908
+ *
902
909
  * @param id - The command's global id, as {@link CommandInfo.id}:
903
910
  * `<manifest id>/<local id>`, `host/<id>` for the player's own.
904
911
  * @param options - `ticket`: from the user action this run is for.
905
912
  * `step` and `of`: this is step `step` of `of` (1-based), shown in the
906
- * on-screen line.
913
+ * on-screen line. `then`: the commands the ticket runs next, asked for
914
+ * together with this one.
907
915
  * @returns `{ ran: true }` once the command was started, or
908
916
  * `{ ran: false, declined: true }` when the user chose Don't Run.
909
917
  *
910
918
  * @example Run the commands of one request
911
- * The user typed "fullscreen and mute" into the palette's lead row; the
912
- * plugin runs the two commands it chose for it. The ticket comes with the
913
- * lead's run event and covers every run of this request; `done` ends it.
914
- * A declined confirmation or a failure stops the request.
919
+ * The user typed "reset the picture and mute" into the palette's lead
920
+ * row; the plugin runs the two commands it chose for it. The ticket comes
921
+ * with the lead's run event and covers every run of this request; `done`
922
+ * ends it. The first run names the rest of the plan in `then`, so the
923
+ * player asks once for both (Reset: Picture asks first) before anything
924
+ * runs. A declined confirmation or a failure stops the request.
915
925
  * ```ts
916
926
  * declare const lead: PaletteLead;
917
927
  * // ---cut---
918
928
  * lead.onRun(async ({ ticket }) => {
919
- * const ids = ["host/fullscreen", "host/mute"]; // chosen for the request
929
+ * const ids = ["vestra.video/video.reset", "host/mute"]; // chosen for the request
920
930
  * try {
921
931
  * for (const [index, id] of ids.entries()) {
922
- * const result = await plugin.commands.run(id, { ticket, step: index + 1, of: ids.length });
923
- * if (!result.ran) break; // the user chose Don't Run
932
+ * const result = await plugin.commands.run(id, {
933
+ * ticket,
934
+ * step: index + 1,
935
+ * of: ids.length,
936
+ * // The first run names the rest of the plan.
937
+ * ...(index === 0 ? { then: ids.slice(1) } : {}),
938
+ * });
939
+ * if (!result.ran) break; // the user chose Don't Run: nothing ran
924
940
  * }
925
941
  * } catch (error) {
926
942
  * // `disabled`, `busy`, `missing`, `ticket` (expired), `limit` (rate).
@@ -935,15 +951,17 @@ export interface Commands {
935
951
  * @throws `capability` (rejects) The manifest does not declare
936
952
  * `commands.run`, or the plugin is not built into the player.
937
953
  * @throws `ticket` (rejects) No ticket, or it ended or expired.
938
- * @throws `missing` (rejects) No command has this id.
954
+ * @throws `missing` (rejects) No listed command has this id, or one of
955
+ * the ids of `then`.
939
956
  * @throws `disabled` (rejects) The command is disabled now; `message` has
940
957
  * its reason.
941
958
  * @throws `busy` (rejects) The command is busy, or its confirmation
942
959
  * cannot be shown while another alert is open.
943
960
  * @throws `limit` (rejects) Over the rate limits above.
944
961
  * @throws `invalid` (rejects) Only one of `step` and `of`, or not
945
- * whole numbers with 1 ≤ `step` ≤ `of` ≤ 99; or `id` is the command
946
- * palette itself (`host/palette`).
962
+ * whole numbers with 1 ≤ `step` ≤ `of` ≤ 99; `then` is not an array
963
+ * of at most 7 non-empty strings; or `id` or an id of `then` is the
964
+ * command palette itself (`host/palette`).
947
965
  * @player 0.7.6
948
966
  * @since 1.7.9
949
967
  */
@@ -962,6 +980,43 @@ export interface CommandRunOptions {
962
980
  step?: number;
963
981
  /** The request's number of steps (`step`–99); with `step`. */
964
982
  of?: number;
983
+ /**
984
+ * The rest of the request's plan: the global ids of the commands this
985
+ * ticket runs next, in order. At most 7, so a plan has at most 8
986
+ * commands; the same id may appear more than once. Absent or `null`: no
987
+ * new plan; the run is judged as a later run below (one left in an
988
+ * approved plan uses up an entry and does not ask). An empty array: a
989
+ * new plan of this command alone, which replaces the rest of an earlier
990
+ * one.
991
+ *
992
+ * The player looks at the whole plan, this command first. When none of
993
+ * it asks first (see {@link Commands.run}), nothing is asked and nothing
994
+ * is remembered. When any of it does, the player asks once, before this
995
+ * command runs, listing every command of the plan:
996
+ *
997
+ * - **Run** runs this command and remembers the rest of the plan for the
998
+ * ticket. Each later run of a planned command with the same ticket,
999
+ * in any order, uses up one of its entries and does not ask. A command
1000
+ * not left in the plan (never in it, or its entries used up) is judged
1001
+ * on its own and asks first as usual.
1002
+ * - **Don't Run** runs nothing and remembers nothing: the result is
1003
+ * `{ ran: false, declined: true }`.
1004
+ *
1005
+ * A later run that gives `then` again (`[]` included) starts a new plan:
1006
+ * the rest of the earlier one is forgotten and the new plan is judged as
1007
+ * above. The plan
1008
+ * ends with its ticket. The ids of `then` must be listed commands now
1009
+ * (`missing` otherwise; `host/palette` is `invalid`); whether each is
1010
+ * enabled and not busy is checked when it runs, as for any run. `then`
1011
+ * itself is no run: only runs count against the rate limits.
1012
+ *
1013
+ * Players before the approval sheet (Ask Vestra UX, step 3) ignore the
1014
+ * field and ask before each command that asks first; a built-in plugin
1015
+ * ships with its player.
1016
+ *
1017
+ * @since 1.7.16
1018
+ */
1019
+ then?: string[] | null;
965
1020
  }
966
1021
  /**
967
1022
  * The outcome of {@link Commands.run}: the command started, or the user
@@ -1116,12 +1171,41 @@ export interface PaletteLeadOptions {
1116
1171
  /**
1117
1172
  * Replaces the row while nothing is typed (a running request; the cursor
1118
1173
  * starts on it); `null` or absent: none. Its run event has `status: true`.
1174
+ * While the palette is closed the player shows it in a status strip at
1175
+ * the top of the main window, as its `state` says.
1119
1176
  */
1120
1177
  status?: {
1121
1178
  /** The status text (up to 80 characters). */
1122
1179
  text: string | Text;
1123
1180
  /** On the right of the row (up to 40 characters). */
1124
1181
  note?: string | Text;
1182
+ /**
1183
+ * Still working or ended. Absent: `"working"`.
1184
+ *
1185
+ * - `"working"`: the work goes on. The strip shows the text with a
1186
+ * moving line and a Stop button (Stop is Enter on the status row)
1187
+ * and stays until the status changes or is removed.
1188
+ * - `"done"`, `"failed"`, `"note"`: an end state (finished; failed; a
1189
+ * sentence for the user, such as an answer). The player shows it
1190
+ * with a check, in the danger colour, or plain, then removes it by
1191
+ * itself after a few seconds (about 2 s, 6 s, and 4–10 s by length;
1192
+ * longer while the pointer is on it). It is shown once: not kept,
1193
+ * not shown again later (when the plugin is stopped or woken), and
1194
+ * the row goes back to its usual form. The plugin needs no timer of
1195
+ * its own and may call {@link PaletteLead.done} right after setting
1196
+ * it.
1197
+ *
1198
+ * Once {@link Commands.run} has shown a step of the ticket in the
1199
+ * strip, a `"working"` text changes only the palette's status row,
1200
+ * until an end state, `status: null` or the end of the ticket.
1201
+ *
1202
+ * Players before the status strip refuse the field (`invalid`); a
1203
+ * built-in plugin ships with its player. Any other value: `invalid`
1204
+ * (through `ready`, or `update` rejects).
1205
+ *
1206
+ * @since 1.7.15
1207
+ */
1208
+ state?: "working" | "done" | "failed" | "note";
1125
1209
  } | null;
1126
1210
  }
1127
1211
  /**
@@ -613,9 +613,10 @@ export interface Dialogs {
613
613
  * tool window the user just clicked in), else on the main window.
614
614
  *
615
615
  * **Windows:** a task dialog owned by the active player window, titled
616
- * "Vestra Player"; `detail` follows `message` after a blank line. A
617
- * `checkbox` is asked as a second yes/no dialog after the user confirms
618
- * (on cancel it is not asked and `checked` is `false`).
616
+ * "Vestra Player" and centred on it: `message` is the main instruction
617
+ * and `detail` the text below it. A `checkbox` is the dialog's own
618
+ * verification box (no second dialog); `checked` is its state on cancel
619
+ * too. No system sound plays; `destructive` shows a warning icon.
619
620
  *
620
621
  * Remembering "Don't ask again" is up to the plugin (see
621
622
  * {@link Scope.storage}).
package/dist/wire.d.ts CHANGED
@@ -696,7 +696,8 @@ export declare function createWire(transport: Transport): {
696
696
  id: string;
697
697
  ticket: string;
698
698
  step?: number;
699
- of?: number;
699
+ of? /** What listens (the player logs it). */: number;
700
+ then?: string[];
700
701
  }) => Promise<import("./index.ts").CommandRunResult>;
701
702
  };
702
703
  /** The command palette's lead row (`palette.lead`). */
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # Vestra Player SDK
2
2
 
3
- > @vestra-player/sdk 1.7.14: write plugins for Vestra Player in TypeScript (plugin API `vestra/1`). A plugin is a folder with `manifest.json` and an entry module whose default export `activate(plugin)` the player calls. The documentation is a tree of short pages read by path, like `go doc`: the same pages and API as https://vestrasys.github.io/vestra-player-sdk/.
3
+ > @vestra-player/sdk 1.7.16: write plugins for Vestra Player in TypeScript (plugin API `vestra/1`). A plugin is a folder with `manifest.json` and an entry module whose default export `activate(plugin)` the player calls. The documentation is a tree of short pages read by path, like `go doc`: the same pages and API as https://vestrasys.github.io/vestra-player-sdk/.
4
4
 
5
5
  ## Read the documentation
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vestra-player/sdk",
3
- "version": "1.7.14",
3
+ "version": "1.7.16",
4
4
  "description": "Plugin API types, test host and plugin CLI for Vestra Player (apiVersion vestra/1)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {