@synopackageland/cli 0.10.5 → 0.10.6

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,52 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.6 (2026-10-15)
4
+
5
+ Builds with SDK 0.10.6 and templates 0.10.7: `init` writes SDK v0.10.6 (Go
6
+ module, Rust crate tag and `backend.sdk`), `@synopackageland/sdk` 0.10.6 and
7
+ `@synopackageland/ui` 0.9.8, whose `CellText` takes `wrap`. Templates 0.10.6
8
+ was tagged but not published (a failing delegate frontend test); 0.10.7 is the
9
+ same templates with that test fixed. The executor digest table adds SDK 0.10.6,
10
+ whose executor and lifecycle digests equal 0.10.5, so an App rebuilt on it keeps
11
+ its approval unless its own root programs change. The CLI still needs SDK 0.10.5
12
+ or later: SDK 0.10.5's panels already read `executor_starting` as a starting
13
+ package and check again, and nothing in the CLI depends on SDK 0.10.6.
14
+
15
+ 繁中摘要:搭配 SDK 0.10.6、templates 0.10.7(UI 0.9.8);templates 0.10.6 有 tag 但未發佈;
16
+ digest 與 0.10.5 相同;SDK 下限維持 0.10.5。e2e 新增 `openPath`、`handleDialogs`、80/443 通道。
17
+
18
+ - `signIn`, `openDesktop` and `openPortal` open their page once more when
19
+ the first navigation fails with `net::ERR_ABORTED`, which about one run in
20
+ ten met as DSM's desktop navigated on its own (t-0499, t-0500); any other
21
+ failure, or a second abort, still fails. The helper is exported as
22
+ `openPath(app, path)`.
23
+ - The DSM window's `status()` answers a pinned executor that reports
24
+ `state: "starting"` (its `root.start` step) at once, blocked with code
25
+ `executor_starting` and no approval offered, instead of waiting up to 75 s
26
+ for the step. The SDK's panels read that code as a starting package and
27
+ check again on their own, as they do `APP_STARTING` since CLI 0.10.5.
28
+ Approving and `control("start")` still wait for the step.
29
+ - `openApp(app, appId, timeout, browser)` and `openPortal(app, path, browser)`
30
+ take the test's `browser` fixture and accept native alert and confirm dialogs
31
+ through its `onDialog`, recording their text (`handleDialogs(browser)` returns
32
+ the list). DSM's `alert("You are not authorized to use this service.")` no
33
+ longer fails the test as an unhandled dialog. Without `browser` nothing
34
+ changes.
35
+ - `openPortal` registers the session's cookies as e2e secrets too (a portal
36
+ page may have no SynoToken, which is no failure); only `signIn` and
37
+ `openDesktop` did.
38
+ - `signIn` accepts a restored profile only when the desktop holds a SynoToken
39
+ and DSM's `/webman/login.cgi` still accepts the session (`dsmSessionLive`).
40
+ A profile with only the `stay_login` cookie, or an expired session (DSM error
41
+ 119), now clears the cookies and signs in again with the account file's
42
+ password; the desktop alone used to be enough, and the app's CGIs then
43
+ answered "authorization unavailable".
44
+ - `runWithTunnel` also forwards the NAS's port 80 and 443 when
45
+ `DSM_E2E_TUNNEL_HTTP_PORT` and `DSM_E2E_TUNNEL_HTTPS_PORT` name local ports
46
+ (portal alias tests), and hands both to the command; the targets default to
47
+ 80 and 443 (`DSM_E2E_REMOTE_HTTP_PORT`, `DSM_E2E_REMOTE_HTTPS_PORT`). Without
48
+ them the tunnel is unchanged.
49
+
3
50
  ## 0.10.5 (2026-10-15)
4
51
 
5
52
  Builds with SDK 0.10.5 and templates 0.10.5: `init` writes SDK v0.10.5 (Go
package/README.md CHANGED
@@ -98,7 +98,8 @@ it as root once at the first start of each new version, while the administrator'
98
98
  live, for at most 60 seconds; a failure is logged and does not block the start, and the executor
99
99
  `status` reports the result as `start_step`. While it runs, the executor answers only `status`
100
100
  (`state: "starting"`) and refuses other requests with the retryable `EXECUTOR_STARTING`; the DSM
101
- window's approval waits for it. The program cannot declare `run` or `job`, and
101
+ window's approval waits for it, while a status read answers `executor_starting` at once and the
102
+ SDK's panels check again on their own. The program cannot declare `run` or `job`, and
102
103
  declaring it changes the policy digest, so an administrator approves the App again.
103
104
 
104
105
  ## Commands
package/dist/e2e/dsm.d.ts CHANGED
@@ -3,6 +3,12 @@ type Env = Readonly<Record<string, string | undefined>>;
3
3
  type App = {
4
4
  open(path?: string): Promise<unknown>;
5
5
  };
6
+ type DialogBrowser = {
7
+ onDialog(handler: (dialog: {
8
+ message: string;
9
+ accept(): Promise<void>;
10
+ }) => Promise<void>): Promise<unknown>;
11
+ };
6
12
  type StorageState = {
7
13
  cookies: unknown[];
8
14
  origins: unknown[];
@@ -11,13 +17,15 @@ type Page = ReturnType<NonNullable<ReturnType<typeof surfaceOf>>["page"]>;
11
17
  type Locator = ReturnType<Page["locator"]>;
12
18
  /** The DSM URL the browser opens: DSM_E2E_URL, else the local end of the SSH tunnel. */
13
19
  export declare function dsmUrl(env?: Env): string;
14
- /** ssh arguments forwarding the loopback port DSM_E2E_TUNNEL_PORT (default 15000) to DSM's HTTP port on the NAS. */
20
+ /** ssh arguments forwarding the loopback ports of `forwards` to the NAS. */
15
21
  export declare function tunnelArgs(env?: Env): string[];
16
22
  /** A loopback port nothing listens on now, for a tunnel that names none. */
17
23
  export declare function freePort(): Promise<number>;
18
24
  /**
19
25
  * Opens the SSH tunnel on DSM_E2E_TUNNEL_PORT, else on a free port, runs
20
26
  * `command` with DSM_E2E_URL pointing at it, and closes the tunnel afterwards.
27
+ * DSM_E2E_TUNNEL_HTTP_PORT and DSM_E2E_TUNNEL_HTTPS_PORT, when set, also
28
+ * forward the NAS's port 80 and 443 (see forwards) and reach the command's env.
21
29
  * The command's output reaches this process's stdout and stderr with DSM's
22
30
  * secrets masked, and its e2e output directory, DSM_E2E_OUTPUT_DIR (default
23
31
  * .e2e), is protected afterwards (see protectE2eOutput). Resolves to the
@@ -100,6 +108,15 @@ type SessionPage = {
100
108
  * Playwright call log carries them (t-0498). Returns how many were registered.
101
109
  */
102
110
  export declare function registerDsmSecrets(page?: SessionPage, ledger?: SecretLedger): Promise<number>;
111
+ /**
112
+ * Has the attempt's native alert and confirm dialogs accepted and returns the
113
+ * live list of their texts, so a DSM `alert("You are not authorized to use this
114
+ * service.")` does not fail the test and a test can still assert on it. e2e 0.19
115
+ * routes dialogs through the `browser` fixture's onDialog (Playwright's
116
+ * page.on('dialog') does not reach them), so a helper needs that fixture:
117
+ * openApp and openPortal take it and call this. Registers once per browser.
118
+ */
119
+ export declare function handleDialogs(browser: DialogBrowser): Promise<string[]>;
103
120
  /** Waits until the DSM desktop and its signed-in taskbar are shown. */
104
121
  export declare function waitForDesktop(page?: Page): Promise<void>;
105
122
  /**
@@ -109,9 +126,24 @@ export declare function waitForDesktop(page?: Page): Promise<void>;
109
126
  * DSM_E2E_NOTIFICATION_WAIT_MS (default 5000) for one.
110
127
  */
111
128
  export declare function dismissNotifications(page?: Page, env?: Env): Promise<number>;
129
+ /**
130
+ * Whether the signed-in desktop's session is usable: it holds a SynoToken
131
+ * (a restored `stay_login` cookie alone yields none, and the app's CGIs then
132
+ * answer 119) and DSM's login.cgi, asked from the page, still accepts the
133
+ * session. Any failure to ask counts as not live.
134
+ */
135
+ export declare function dsmSessionLive(page: Pick<SessionPage, "evaluate">): Promise<boolean>;
136
+ /**
137
+ * `app.open(path)`, once more after net::ERR_ABORTED: about one first
138
+ * navigation in ten was aborted as DSM's desktop navigated on its own, and the
139
+ * next one loaded (t-0499, t-0500). Any other failure, or a second abort, is
140
+ * thrown.
141
+ */
142
+ export declare function openPath(app: Pick<App, "open">, path: string): Promise<void>;
112
143
  /**
113
144
  * Restores the saved profile of `user`; signs in with the account file only
114
- * when that profile is missing or no longer reaches the desktop. Saves the
145
+ * when that profile is missing, no longer reaches the desktop, or gives a
146
+ * session without a SynoToken or that DSM refuses (dsmSessionLive). Saves the
115
147
  * resulting state and returns which path it took.
116
148
  */
117
149
  export declare function signIn(app: App, user?: string, env?: Env): Promise<"restored" | "signed-in">;
@@ -129,9 +161,18 @@ export declare function openDesktop(app: App): Promise<Page>;
129
161
  /**
130
162
  * Opens the DSM app `appId` (for example SYNO.SDS.SynoPkgConnect.Instance) in
131
163
  * its desktop window, or brings its open window to the front, and returns it
132
- * once the app has rendered text into the window.
164
+ * once the app has rendered text into the window. With the `browser` fixture,
165
+ * native dialogs are accepted and recorded (see handleDialogs).
166
+ */
167
+ export declare function openApp(app: App, appId: string, timeout?: number, browser?: DialogBrowser): Promise<Locator>;
168
+ /**
169
+ * Waits until an Application Portal page has loaded and registers the session's
170
+ * cookies as e2e secrets. A portal page has no SynoToken, which is no failure.
171
+ */
172
+ export declare function waitForPortal(page?: Page): Promise<void>;
173
+ /**
174
+ * Opens an Application Portal page (for example /download-hub/) as the whole
175
+ * tab. With the `browser` fixture, native dialogs are accepted and recorded (see handleDialogs).
133
176
  */
134
- export declare function openApp(app: App, appId: string, timeout?: number): Promise<Locator>;
135
- /** Opens an Application Portal page (for example /download-hub/) as the whole tab. */
136
- export declare function openPortal(app: App, path: string): Promise<Page>;
177
+ export declare function openPortal(app: App, path: string, browser?: DialogBrowser): Promise<Page>;
137
178
  export {};
package/dist/e2e/dsm.js CHANGED
@@ -1,7 +1,8 @@
1
1
  // DSM helpers for package e2e suites on upstream `e2e` + `@e2e-dev/web`.
2
2
  // One self-contained file: a package may copy it verbatim to tests/e2e/support/dsm.ts.
3
3
  // It signs in once per run (a saved, private profile is restored when still valid),
4
- // opens DSM app windows and Application Portal pages, dismisses DSM notifications,
4
+ // opens DSM app windows and Application Portal pages (accepting their native
5
+ // dialogs when given the `browser` fixture), dismisses DSM notifications,
5
6
  // configures the magpie LLM, and runs a command through an SSH tunnel to the NAS
6
7
  // (on a free loopback port unless DSM_E2E_TUNNEL_PORT names one). DSM's session
7
8
  // cookies and tokens are masked in what that command prints and leaves in its
@@ -26,12 +27,25 @@ const loginSelector = 'input[name="username"]';
26
27
  export function dsmUrl(env = process.env) {
27
28
  return env.DSM_E2E_URL || `http://127.0.0.1:${env.DSM_E2E_TUNNEL_PORT || "15000"}/`;
28
29
  }
29
- /** ssh arguments forwarding the loopback port DSM_E2E_TUNNEL_PORT (default 15000) to DSM's HTTP port on the NAS. */
30
+ /**
31
+ * The loopback ports to forward as [local, remote]: DSM_E2E_TUNNEL_PORT (default 15000)
32
+ * to DSM's web port, and, only when named, DSM_E2E_TUNNEL_HTTP_PORT and
33
+ * DSM_E2E_TUNNEL_HTTPS_PORT to the NAS's port 80 and 443 (DSM_E2E_REMOTE_HTTP_PORT
34
+ * and DSM_E2E_REMOTE_HTTPS_PORT override them), for Application Portal alias pages.
35
+ */
36
+ function forwards(env) {
37
+ const extra = (local, remote, fallback) => local ? [[local, remote || fallback]] : [];
38
+ return [
39
+ [env.DSM_E2E_TUNNEL_PORT || "15000", env.DSM_E2E_REMOTE_PORT || "5000"],
40
+ ...extra(env.DSM_E2E_TUNNEL_HTTP_PORT, env.DSM_E2E_REMOTE_HTTP_PORT, "80"),
41
+ ...extra(env.DSM_E2E_TUNNEL_HTTPS_PORT, env.DSM_E2E_REMOTE_HTTPS_PORT, "443"),
42
+ ];
43
+ }
44
+ /** ssh arguments forwarding the loopback ports of `forwards` to the NAS. */
30
45
  export function tunnelArgs(env = process.env) {
31
- const local = env.DSM_E2E_TUNNEL_PORT || "15000";
32
- const remote = env.DSM_E2E_REMOTE_PORT || "5000";
33
46
  return ["-N", "-o", "BatchMode=yes", "-o", "ExitOnForwardFailure=yes",
34
- "-L", `127.0.0.1:${local}:127.0.0.1:${remote}`, env.DSM_E2E_SSH || "root@vt-nas.syno"];
47
+ ...forwards(env).flatMap(([local, remote]) => ["-L", `127.0.0.1:${local}:127.0.0.1:${remote}`]),
48
+ env.DSM_E2E_SSH || "root@vt-nas.syno"];
35
49
  }
36
50
  /** A loopback port nothing listens on now, for a tunnel that names none. */
37
51
  export function freePort() {
@@ -54,6 +68,8 @@ function portOpen(port) {
54
68
  /**
55
69
  * Opens the SSH tunnel on DSM_E2E_TUNNEL_PORT, else on a free port, runs
56
70
  * `command` with DSM_E2E_URL pointing at it, and closes the tunnel afterwards.
71
+ * DSM_E2E_TUNNEL_HTTP_PORT and DSM_E2E_TUNNEL_HTTPS_PORT, when set, also
72
+ * forward the NAS's port 80 and 443 (see forwards) and reach the command's env.
57
73
  * The command's output reaches this process's stdout and stderr with DSM's
58
74
  * secrets masked, and its e2e output directory, DSM_E2E_OUTPUT_DIR (default
59
75
  * .e2e), is protected afterwards (see protectE2eOutput). Resolves to the
@@ -64,17 +80,22 @@ export async function runWithTunnel(command, outer = process.env) {
64
80
  throw new Error("runWithTunnel needs a command to run.");
65
81
  const port = Number(outer.DSM_E2E_TUNNEL_PORT || await freePort());
66
82
  const env = { ...outer, DSM_E2E_TUNNEL_PORT: String(port) };
67
- if (await portOpen(port))
68
- throw new Error(`Port ${port} is already in use; set DSM_E2E_TUNNEL_PORT or close it before opening the tunnel.`);
83
+ const ports = forwards(env).map(([local]) => Number(local));
84
+ for (const used of ports) {
85
+ if (await portOpen(used))
86
+ throw new Error(`Port ${used} is already in use; name another DSM_E2E_TUNNEL_* port or close it before opening the tunnel.`);
87
+ }
69
88
  const ssh = spawn(env.DSM_E2E_SSH_BIN || "ssh", tunnelArgs(env), { stdio: ["ignore", "ignore", "inherit"] });
70
89
  let sshExited = false;
71
90
  ssh.once("exit", () => { sshExited = true; });
72
91
  try {
73
92
  const deadline = Date.now() + Number(env.DSM_E2E_TUNNEL_TIMEOUT_MS || "15000");
74
- while (!(await portOpen(port))) {
75
- if (sshExited || Date.now() > deadline)
76
- throw new Error(`The SSH tunnel to ${tunnelArgs(env).at(-1)} did not open on port ${port}.`);
77
- await new Promise(accept => setTimeout(accept, 100));
93
+ for (const waiting of ports) {
94
+ while (!(await portOpen(waiting))) {
95
+ if (sshExited || Date.now() > deadline)
96
+ throw new Error(`The SSH tunnel to ${tunnelArgs(env).at(-1)} did not open on port ${waiting}.`);
97
+ await new Promise(accept => setTimeout(accept, 100));
98
+ }
78
99
  }
79
100
  // Piped output loses the terminal, not its colours.
80
101
  const color = process.stdout.isTTY && env.FORCE_COLOR === undefined ? { FORCE_COLOR: "1" } : {};
@@ -314,6 +335,25 @@ export async function registerDsmSecrets(page = dsmPage(), ledger) {
314
335
  target.register(name, value);
315
336
  return values.length;
316
337
  }
338
+ const dialogLogs = new WeakMap();
339
+ /**
340
+ * Has the attempt's native alert and confirm dialogs accepted and returns the
341
+ * live list of their texts, so a DSM `alert("You are not authorized to use this
342
+ * service.")` does not fail the test and a test can still assert on it. e2e 0.19
343
+ * routes dialogs through the `browser` fixture's onDialog (Playwright's
344
+ * page.on('dialog') does not reach them), so a helper needs that fixture:
345
+ * openApp and openPortal take it and call this. Registers once per browser.
346
+ */
347
+ export async function handleDialogs(browser) {
348
+ let messages = dialogLogs.get(browser);
349
+ if (!messages) {
350
+ const seen = [];
351
+ messages = seen;
352
+ dialogLogs.set(browser, seen);
353
+ await browser.onDialog(async (dialog) => { seen.push(dialog.message); await dialog.accept(); });
354
+ }
355
+ return messages;
356
+ }
317
357
  /** Waits until the DSM desktop and its signed-in taskbar are shown. */
318
358
  export async function waitForDesktop(page = dsmPage()) {
319
359
  await page.locator(desktopSelector).waitFor({ state: "visible", timeout: 60_000 });
@@ -342,6 +382,20 @@ export async function dismissNotifications(page = dsmPage(), env = process.env)
342
382
  }
343
383
  return closed;
344
384
  }
385
+ /**
386
+ * Whether the signed-in desktop's session is usable: it holds a SynoToken
387
+ * (a restored `stay_login` cookie alone yields none, and the app's CGIs then
388
+ * answer 119) and DSM's login.cgi, asked from the page, still accepts the
389
+ * session. Any failure to ask counts as not live.
390
+ */
391
+ export async function dsmSessionLive(page) {
392
+ const state = await page.evaluate(async () => {
393
+ const token = window.SYNO?.SDS?.Session?.SynoToken;
394
+ const reply = await fetch("/webman/login.cgi", { credentials: "same-origin" }).then(response => response.json());
395
+ return { token: typeof token === "string" && token !== "", success: reply?.success === true };
396
+ }).catch(() => undefined);
397
+ return !!state?.token && state.success;
398
+ }
345
399
  function accountFile(user, env) {
346
400
  const key = `DSM_E2E_ACCOUNT_${user.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`;
347
401
  const file = env[key];
@@ -349,9 +403,29 @@ function accountFile(user, env) {
349
403
  throw new Error(`Set ${key} to the account file for ${user} (mode 600).`);
350
404
  return resolve(file);
351
405
  }
406
+ /**
407
+ * `app.open(path)`, once more after net::ERR_ABORTED: about one first
408
+ * navigation in ten was aborted as DSM's desktop navigated on its own, and the
409
+ * next one loaded (t-0499, t-0500). Any other failure, or a second abort, is
410
+ * thrown.
411
+ */
412
+ export async function openPath(app, path) {
413
+ try {
414
+ await app.open(path);
415
+ }
416
+ catch (error) {
417
+ if (!/net::ERR_ABORTED/.test(String(error?.message ?? error)))
418
+ throw error;
419
+ await app.open(path);
420
+ }
421
+ }
422
+ async function restoredSessionLive(page) {
423
+ return await desktopOrLogin(page) === "desktop" && await dsmSessionLive(page);
424
+ }
352
425
  /**
353
426
  * Restores the saved profile of `user`; signs in with the account file only
354
- * when that profile is missing or no longer reaches the desktop. Saves the
427
+ * when that profile is missing, no longer reaches the desktop, or gives a
428
+ * session without a SynoToken or that DSM refuses (dsmSessionLive). Saves the
355
429
  * resulting state and returns which path it took.
356
430
  */
357
431
  export async function signIn(app, user = "admin", env = process.env) {
@@ -361,12 +435,15 @@ export async function signIn(app, user = "admin", env = process.env) {
361
435
  const profile = loadProfile(file, url);
362
436
  if (profile)
363
437
  await context.setStorageState(profile);
364
- await app.open("/");
438
+ await openPath(app, "/");
365
439
  const page = dsmPage();
366
440
  let outcome = "restored";
367
- if (!profile || await desktopOrLogin(page) === "login") {
368
- if (profile)
369
- await app.open("/");
441
+ if (!profile || !await restoredSessionLive(page)) {
442
+ // A refused session still shows the desktop; dropping its cookies shows the login form.
443
+ if (profile) {
444
+ await context.clearCookies();
445
+ await openPath(app, "/");
446
+ }
370
447
  const account = readAccount(accountFile(user, env), user);
371
448
  await page.locator(loginSelector).fill(account.username);
372
449
  await page.keyboard.press("Enter");
@@ -403,7 +480,7 @@ export async function openDesktop(app) {
403
480
  } })();
404
481
  if (current && await current.locator(desktopSelector).isVisible().catch(() => false))
405
482
  return current;
406
- await app.open("/");
483
+ await openPath(app, "/");
407
484
  const page = dsmPage();
408
485
  if (await desktopOrLogin(page) === "login")
409
486
  throw new Error("The DSM session is signed out; declare the session that dsmLoginSetup saves.");
@@ -415,9 +492,12 @@ export async function openDesktop(app) {
415
492
  /**
416
493
  * Opens the DSM app `appId` (for example SYNO.SDS.SynoPkgConnect.Instance) in
417
494
  * its desktop window, or brings its open window to the front, and returns it
418
- * once the app has rendered text into the window.
495
+ * once the app has rendered text into the window. With the `browser` fixture,
496
+ * native dialogs are accepted and recorded (see handleDialogs).
419
497
  */
420
- export async function openApp(app, appId, timeout = 30_000) {
498
+ export async function openApp(app, appId, timeout = 30_000, browser) {
499
+ if (browser)
500
+ await handleDialogs(browser);
421
501
  const page = await openDesktop(app);
422
502
  await page.evaluate(id => window.SYNO.SDS.AppLaunch(id), appId);
423
503
  const handle = await page.waitForFunction(id => {
@@ -430,13 +510,26 @@ export async function openApp(app, appId, timeout = 30_000) {
430
510
  await page.waitForFunction(windowId => document.getElementById(windowId)?.querySelector(".x-window-body")?.innerText.trim(), id, { timeout });
431
511
  return page.locator(`#${id}`);
432
512
  }
433
- /** Opens an Application Portal page (for example /download-hub/) as the whole tab. */
434
- export async function openPortal(app, path) {
513
+ /**
514
+ * Waits until an Application Portal page has loaded and registers the session's
515
+ * cookies as e2e secrets. A portal page has no SynoToken, which is no failure.
516
+ */
517
+ export async function waitForPortal(page = dsmPage()) {
518
+ await page.waitForLoadState("load");
519
+ await registerDsmSecrets(page);
520
+ }
521
+ /**
522
+ * Opens an Application Portal page (for example /download-hub/) as the whole
523
+ * tab. With the `browser` fixture, native dialogs are accepted and recorded (see handleDialogs).
524
+ */
525
+ export async function openPortal(app, path, browser) {
435
526
  if (!path.startsWith("/") || path.startsWith("//"))
436
527
  throw new Error("openPortal takes a same-origin path such as /download-hub/.");
437
- await app.open(path);
528
+ if (browser)
529
+ await handleDialogs(browser);
530
+ await openPath(app, path);
438
531
  const page = dsmPage();
439
- await page.waitForLoadState("load");
532
+ await waitForPortal(page);
440
533
  return page;
441
534
  }
442
535
  // ---- Command line ---------------------------------------------------------
@@ -64,5 +64,16 @@
64
64
  "armv7": "cafc97c89f5645c14a8cf31d6d9f258394ed6f2d086478a7aebd04d57c274b4e"
65
65
  },
66
66
  "goToolchain": "go1.26.9"
67
+ },
68
+ "0.10.6": {
69
+ "x86_64": "4ba7040761a719e74d6b047ef68b9415e658ebb8b373b69555b8c307524e26ba",
70
+ "aarch64": "ba80b389e3291419389b66be7b0a0e1085d3dfec55c9c651fecae427279bb3d5",
71
+ "armv7": "49474467b9c9a7f31b30b5053b70eb4f71a95f2c06fbf3566e8de8f16972a299",
72
+ "lifecycle": {
73
+ "x86_64": "d65500c4f04713a32b45d360059281391acfa5e00ee24895fdd2de7b82735372",
74
+ "aarch64": "94f6cd119186ff482b8aea56541dd1f9d53c147566bc1efdca6f5a1c86198331",
75
+ "armv7": "cafc97c89f5645c14a8cf31d6d9f258394ed6f2d086478a7aebd04d57c274b4e"
76
+ },
77
+ "goToolchain": "go1.26.9"
67
78
  }
68
79
  }
@@ -236,7 +236,7 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
236
236
  function readSelection(budget, delay) {
237
237
  delay = Math.min(delay || 500, 1000);
238
238
  verified.state = "ready";
239
- return health(verified, 0).then(function (current) {
239
+ return health(verified).then(function (current) {
240
240
  if (current.state === "ready" && current.executor.selection && current.executor.selection.scope === selectedScope && Number.isSafeInteger(current.executor.selection.generation) && current.executor.selection.generation > 0) return current;
241
241
  if (budget >= delay && options.wait) return options.wait(delay).then(function () { return readSelection(budget - delay, delay * 2); });
242
242
  throw fail("executor_selection_unconfirmed");
@@ -304,9 +304,15 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
304
304
  throw e;
305
305
  });
306
306
  }
307
- function health(verified, budget) {
307
+ // step: how long to wait for a start step (ms). A status read waits none:
308
+ // executor_starting says the package is starting, which the SDK checks
309
+ // again on its own.
310
+ function health(verified, step) {
308
311
  if (verified.state !== "ready") return Promise.resolve(verified);
309
- return settle(verified, alive(budget));
312
+ return settle(verified, alive(0, undefined, step)).then(function (result) {
313
+ if (result.code === "executor_starting") delete result.retry;
314
+ return result;
315
+ });
310
316
  }
311
317
  function settle(verified, status) {
312
318
  return status.then(function (current) { verified.executor = current; return verified; }, function (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.10.5",
3
+ "version": "0.10.6",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,7 +25,7 @@
25
25
  "prepublishOnly": "npm run build"
26
26
  },
27
27
  "dependencies": {
28
- "@synopackageland/templates": "0.10.5",
28
+ "@synopackageland/templates": "0.10.7",
29
29
  "ajv": "^8.17.1",
30
30
  "commander": "^13.1.0",
31
31
  "tar": "^7.4.3",
@@ -112,7 +112,7 @@ root:
112
112
  migrate: {} # 沒有 run、job:只作為 start 步驟
113
113
  ```
114
114
 
115
- start、stop 步驟與 `uninstall.purge.root` 都以 root、無 session 執行,只在管理員核准有效時跑;這些程式不能宣告 run 或 job(session 要用時以另一個名稱設定,可指向同一份內容)。start 步驟在新版本第一次啟動、executor 開 socket 並回讀核准任務之後執行,最多 60 秒;執行期間 executor 只回應 `status`(`state: "starting"`),其他請求回可重試的 `EXECUTOR_STARTING`,DSM 視窗的核准會等它結束,失敗只寫進 executor log,不擋啟動;同一版本不重跑,程式要能重複執行。結果由 executor `status` 的 `start_step` 讀取(`pending`、`ok`、`failed`,含 exit 與 output)。DSM 的 start 只寫入要求就返回,所以 `dsm-scripts/postinst`、`postupgrade`、`start` 看不到它的結果;root 的清理或遷移放 `root.start`,非特權的收尾放 `dsm-scripts/`。宣告 `root.start` 會改變 policy digest,需要管理員重新核准;沒有宣告的 App policy 不變。需要 SDK 0.10.3 以上。
115
+ start、stop 步驟與 `uninstall.purge.root` 都以 root、無 session 執行,只在管理員核准有效時跑;這些程式不能宣告 run 或 job(session 要用時以另一個名稱設定,可指向同一份內容)。start 步驟在新版本第一次啟動、executor 開 socket 並回讀核准任務之後執行,最多 60 秒;執行期間 executor 只回應 `status`(`state: "starting"`),其他請求回可重試的 `EXECUTOR_STARTING`,DSM 視窗的核准會等它結束,狀態讀取則立即回 `executor_starting`、由 SDK 面板自行重試,失敗只寫進 executor log,不擋啟動;同一版本不重跑,程式要能重複執行。結果由 executor `status` 的 `start_step` 讀取(`pending`、`ok`、`failed`,含 exit 與 output)。DSM 的 start 只寫入要求就返回,所以 `dsm-scripts/postinst`、`postupgrade`、`start` 看不到它的結果;root 的清理或遷移放 `root.start`,非特權的收尾放 `dsm-scripts/`。宣告 `root.start` 會改變 policy digest,需要管理員重新核准;沒有宣告的 App policy 不變。需要 SDK 0.10.3 以上。
116
116
 
117
117
  schema 是 executor 的封閉子集(每個 object 都要 `additionalProperties: false`,key `[a-z0-9_]`,pattern 為 RE2)。這些設定需要支援它們的 SDK executor(`EXECUTOR_ROOT_PROGRAMS_UNSUPPORTED`)。preupgrade 呼叫 `executor/lifecycle stop --upgrade`;舊 SDK 的 helper 不認得此旗標時改用一般 stop。
118
118