@synopackageland/cli 0.48.3 → 0.48.4

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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.48.4
4
+
5
+ - Derive executor policy and runtime operation defaults from the SDK shared operation contract; preserve explicit App overrides without inheriting shorter implicit daemon lifecycle defaults
6
+
7
+ - Restore check and build support for legacy v1 ctl.commands Apps, with one nonblocking deprecation warning during check
8
+ - Remove byte-size caps from App-authored operation registry files and authenticated description reads; retain validation, route equality and ordinary request limits
9
+
3
10
  ## 0.48.3
4
11
 
5
12
  - Make v2 job flow timeoutMs optional in commands and operations, matching v1: shared per-request budgets and no total polling deadline; retain explicit bounds and preserve omission through generation
package/README.md CHANGED
@@ -649,3 +649,9 @@ not a GPU blocker. Plan metadata describes SDK policy, not an attestation of the
649
649
  provider's final container configuration; see the SDK Compose security boundary.
650
650
 
651
651
  For same-origin App URLs, see [DSM path ingress](docs/path-ingress.md).
652
+
653
+ ### CLI release checks
654
+
655
+ `npm run gates` runs basic checks and is the default for release packaging and CI.
656
+ Use `npm run gates:full` only when explicitly requested. See
657
+ [release entry points and checks](docs/release-checks.md) for the complete inventory.
package/dist/cli.js CHANGED
@@ -391,7 +391,7 @@ async function runCliWithin(argv) {
391
391
  : loadStandaloneManifest(standalone);
392
392
  if (!loaded.ok)
393
393
  throw failure(loaded.errors[0].code, loaded.errors.map((e) => `[${e.code}] ${e.message}`).join("\n"), "Update dsm-package.yaml to schema: 2, fix the declaration and retry.");
394
- if ('ctl' in loaded.manifest && (loaded.manifest.ctl?.enabled || loaded.manifest.ctl?.registry)) {
394
+ if ('ctl' in loaded.manifest && loaded.manifest.ctl?.registry) {
395
395
  const { generateOperations } = await import('./standalone/operation-registry.js');
396
396
  const { spawnSync } = await import('node:child_process');
397
397
  await generateOperations(loaded.manifest, (command, args, options) => {
@@ -1,6 +1,6 @@
1
1
  import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
2
2
  import { dirname, join, resolve, relative, isAbsolute } from 'node:path';
3
- import { readBounded, strictJson } from './json.js';
3
+ import { strictJson } from './json.js';
4
4
  import { ajv, safeSchema, validateFlow } from './descriptor.js';
5
5
  export const AI_CLASSES = ['read', 'preview', 'draft', 'human-only', 'hidden'];
6
6
  export const INFRASTRUCTURE_METHODS = new Set(['synopkgland.describe', 'identity.status', 'identity.login', 'identity.session', 'identity.logout']);
@@ -12,7 +12,7 @@ export function registryFile(root, file) {
12
12
  return path;
13
13
  }
14
14
  export function readRegistry(path) {
15
- const raw = readBounded(path);
15
+ const raw = readFileSync(path);
16
16
  const value = strictJson(raw);
17
17
  validateRegistry(value);
18
18
  return value;
@@ -35,6 +35,7 @@ export const ERROR_REGISTRY = {
35
35
  INIT_UPSTREAM_IMAGE_INVALID: { code: "INIT_UPSTREAM_IMAGE_INVALID", description: "The upstream image repository is invalid.", suggestion: "Supply the official repository without a tag or digest; upgrade.sh selects the matching release and resolves its digest." },
36
36
  CTL_APP_NEEDS_APPROVAL: { "code": "CTL_APP_NEEDS_APPROVAL", "description": "The installed App needs approval or re-approval.", "suggestion": "Run synopkgland ctl list --app <package-id> --approve-installed --host <host>." },
37
37
  COMPOSE_HEALTH_REQUIRED: { code: "COMPOSE_HEALTH_REQUIRED", description: "Compose web readiness was not selected.", suggestion: "Set compose.web.health.path and expected 2xx status for the actual App; redirects are not followed." },
38
+ CTL_LEGACY_COMMANDS_DEPRECATED: { code: 'CTL_LEGACY_COMMANDS_DEPRECATED', description: 'The App uses the supported legacy ctl.commands declaration.', suggestion: 'Plan migration to ctl.registry when ready; check and build continue to support v1.' },
38
39
  CTL_REGISTRY_REQUIRED: { code: 'CTL_REGISTRY_REQUIRED', description: 'The App needs a single operation registry.', suggestion: 'Replace ctl.commands with ctl.registry and run synopkgland ctl generate.' },
39
40
  CTL_REGISTRY_INVALID: { code: 'CTL_REGISTRY_INVALID', description: 'The operation registry is invalid.', suggestion: 'Declare every method with its required ai class, schemas, effect, permission and fixed flow.' },
40
41
  CTL_ROUTE_MISMATCH: { code: 'CTL_ROUTE_MISMATCH', description: 'Operation specs and registered handlers differ.', suggestion: 'Match all method names and permissions in both directions, including hidden methods.' },
@@ -34,6 +34,8 @@ export function createRequest(origin, timeoutMs = undefined, ca, trust) {
34
34
  if (url.origin !== origin || (session && session.origin !== origin))
35
35
  throw new CtlError('CTL_ORIGIN_MISMATCH', 'Credentials cannot cross NAS origins.', 'run: synopkgland host list', 4);
36
36
  const form = body instanceof URLSearchParams;
37
+ // Discovery returns the trusted App-authored registry, rather than operation input.
38
+ const description = !(body instanceof URLSearchParams) && body.method === 'synopkgland.describe' && path.startsWith('/webman/3rdparty/') && path.endsWith('/cgi/api.cgi');
37
39
  const payload = Buffer.from(form ? body.toString() : JSON.stringify(body));
38
40
  if (payload.length > 1048576)
39
41
  throw new CtlError('CTL_INPUT_TOO_LARGE', 'Request exceeds 1 MiB.', 'Reduce the input.');
@@ -56,7 +58,7 @@ export function createRequest(origin, timeoutMs = undefined, ca, trust) {
56
58
  }
57
59
  const chunks = [];
58
60
  let length = 0;
59
- res.on('data', (c) => { length += c.length; if (length > 1048576) {
61
+ res.on('data', (c) => { length += c.length; if (!description && length > 1048576) {
60
62
  res.destroy();
61
63
  reject(new CtlError('CTL_RESPONSE_TOO_LARGE', 'Response exceeds 1 MiB.', 'Use a smaller operation.', 5));
62
64
  }
@@ -76,6 +76,12 @@ export declare function executorPolicy(m: {
76
76
  status: number;
77
77
  uninstall: number;
78
78
  };
79
+ declaredLifecycleTimeouts?: Partial<{
80
+ start: number;
81
+ stop: number;
82
+ status: number;
83
+ uninstall: number;
84
+ }>;
79
85
  backend?: {
80
86
  kind: string;
81
87
  timeoutSeconds?: number;
@@ -1,3 +1,4 @@
1
+ import { DEFAULT_OPERATION_TIMEOUT_SECONDS } from './operation-budget.js';
1
2
  import { operationBudgetSeconds } from "./runtime-budgets.js";
2
3
  import { validWebAPIProfiles, sortedWebAPIProfiles } from './webapi-profile.js';
3
4
  import { createHash } from 'node:crypto';
@@ -51,6 +52,9 @@ export function executorPolicy(m, arch) {
51
52
  root[op.name] = rootEntry(op, settings?.programs?.[op.name], arch);
52
53
  operations.push(...rootOperations(root));
53
54
  }
55
+ // Loaded manifests retain only author-declared lifecycle overrides here.
56
+ // Direct callers can still supply normalized settings explicitly.
57
+ const lifecycle = m.declaredLifecycleTimeouts ?? m.lifecycleTimeouts ?? m.daemon?.timeouts;
54
58
  const d = m.capabilities.delegate;
55
59
  const purge = m.capabilities.rootOps ? m.uninstall?.purge.root : undefined;
56
60
  return { v: 1, package: m.package, app: `SYNO.SDS.${m.package}.Instance`, ...(m.entry ? { entry: m.entry } : {}), ...(d ? { scope: d.scope } : {}),
@@ -58,12 +62,12 @@ export function executorPolicy(m, arch) {
58
62
  operations: [...new Set(operations)].sort(), ...(portal ? { portal } : {}), ...(purge ? { purge } : {}), ...(settings?.stop ? { stop: settings.stop } : {}),
59
63
  ...(settings?.start ? { start: settings.start } : {}),
60
64
  ...(m.capabilities.webapi ? { webapi: sortedWebAPIProfiles(m.capabilities.webapi) } : {}),
61
- ...((m.lifecycleTimeouts || m.daemon || m.backend?.timeoutSeconds || (m.uninstall?.purge.root && m.uninstall.purge.timeout)) ? { timeouts: {
62
- start: m.lifecycleTimeouts?.start ?? m.daemon?.timeouts.start ?? 60,
63
- stop: m.lifecycleTimeouts?.stop ?? m.daemon?.timeouts.stop ?? 60,
64
- purge: m.lifecycleTimeouts?.uninstall ?? m.daemon?.timeouts.uninstall ?? Math.min(3600, Math.max(300, m.uninstall?.purge.timeout ?? 0)),
65
- operation: operationBudgetSeconds(m),
66
- } } : {}),
65
+ timeouts: {
66
+ start: lifecycle?.start ?? DEFAULT_OPERATION_TIMEOUT_SECONDS,
67
+ stop: lifecycle?.stop ?? DEFAULT_OPERATION_TIMEOUT_SECONDS,
68
+ purge: lifecycle?.uninstall ?? Math.min(3600, Math.max(DEFAULT_OPERATION_TIMEOUT_SECONDS, m.uninstall?.purge.timeout ?? 0)),
69
+ operation: operationBudgetSeconds(m),
70
+ },
67
71
  root, ...(settings?.state ? { root_state: true } : {}) };
68
72
  }
69
73
  /** A script without settings keeps the bare digest; a binary pins the bytes built for this architecture. */
@@ -1,2 +1,3 @@
1
+ export declare const DEFAULT_OPERATION_TIMEOUT_SECONDS: number;
1
2
  export declare const DEFAULT_OPERATION_TIMEOUT_MS: number;
2
3
  export declare const RESPONSE_RESERVE_MS: number;
@@ -1,5 +1,6 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  // Build-time snapshot of the SDK timeout contract, shipped in schema/.
3
3
  const budget = JSON.parse(readFileSync(new URL('../../schema/sdk-timeouts.json', import.meta.url), 'utf8'));
4
+ export const DEFAULT_OPERATION_TIMEOUT_SECONDS = budget.executor.op_s;
4
5
  export const DEFAULT_OPERATION_TIMEOUT_MS = budget.request.default_s * 1000;
5
6
  export const RESPONSE_RESERVE_MS = budget.browser.margin_ms;
@@ -16,7 +16,7 @@ interface OperationBudgetSource {
16
16
  /**
17
17
  * A CGI's declared request budget owns operation work. Binary and Compose Apps
18
18
  * have no compiled CGI deadline to configure, so their existing status allowance
19
- * can enlarge the shared operation budget above its 60-second default.
19
+ * can enlarge the shared operation budget above the SDK shared default.
20
20
  */
21
21
  export declare function operationBudgetSeconds(source: OperationBudgetSource): number;
22
22
  /** First released SDK that decodes operation/lifecycle budget config fields. */
@@ -1,10 +1,11 @@
1
+ import { DEFAULT_OPERATION_TIMEOUT_SECONDS } from './operation-budget.js';
1
2
  /**
2
3
  * A CGI's declared request budget owns operation work. Binary and Compose Apps
3
4
  * have no compiled CGI deadline to configure, so their existing status allowance
4
- * can enlarge the shared operation budget above its 60-second default.
5
+ * can enlarge the shared operation budget above the SDK shared default.
5
6
  */
6
7
  export function operationBudgetSeconds(source) {
7
- return source.backend?.timeoutSeconds ?? Math.max(60, source.lifecycleTimeouts?.status ?? source.daemon?.timeouts?.status ?? 5);
8
+ return source.backend?.timeoutSeconds ?? Math.max(DEFAULT_OPERATION_TIMEOUT_SECONDS, source.lifecycleTimeouts?.status ?? source.daemon?.timeouts?.status ?? 5);
8
9
  }
9
10
  /** First released SDK that decodes operation/lifecycle budget config fields. */
10
11
  export function runtimeBudgetSdkSupported(sdk) {
@@ -1,6 +1,7 @@
1
1
  import { portalByExecutor } from '../build-spk/dsm-version.js';
2
2
  import { generateOperations } from './operation-registry.js';
3
3
  import { readFileSync, mkdtempSync, writeFileSync, rmSync } from 'node:fs';
4
+ import { makeDescriptor, validateDescriptor, flowMethods } from '../ctl/descriptor.js';
4
5
  import { tmpdir } from 'node:os';
5
6
  import { requiredSdk } from '../runtime/sdk-source.js';
6
7
  import { renderBridgeJson } from './bridge-json.js';
@@ -21,7 +22,7 @@ export async function buildApiDescription(m, bridgeMethods, run) {
21
22
  return undefined;
22
23
  if (m.backend.kind === 'binary' || m.compose)
23
24
  throw new StandaloneBuildError('CTL_UNSUPPORTED_BACKEND', 'Automatic API descriptions require a standard SDK native App.');
24
- throw new StandaloneBuildError('CTL_REGISTRY_REQUIRED', 'Replace ctl.commands with ctl.registry and run synopkgland ctl generate.');
25
+ return buildLegacyApiDescription(m, await describeApiRoutes(m, bridgeMethods, run));
25
26
  }
26
27
  export async function describeApiRoutes(m, bridgeMethods, run) {
27
28
  if (m.backend.kind === 'binary')
@@ -63,3 +64,59 @@ export async function describeApiRoutes(m, bridgeMethods, run) {
63
64
  throw new StandaloneBuildError('CTL_DESCRIBE_FAILED', 'Invalid registry snapshot.');
64
65
  return methods.map(route => m.entry === 'admin-only' && !['identity.status', 'identity.login', 'identity.session', 'identity.logout'].includes(route.method) ? { ...route, permission: 'administrators' } : route);
65
66
  }
67
+ /** Retain the v1 protocol for existing Apps; new registries use the v2 path above. */
68
+ function buildLegacyApiDescription(m, methods) {
69
+ const ctl = m.ctl;
70
+ const registry = new Map(methods.map(item => [item.method, item.permission]));
71
+ const rawHTTP = new Set(methods.filter(item => item.kind === 'http').map(item => item.method));
72
+ const nonRPC = new Set(methods.filter(item => item.kind && item.kind !== 'json').map(item => item.method));
73
+ // Identity transport routes are outside the business registry but have immutable SDK ownership.
74
+ if (m.capabilities.identity) {
75
+ registry.set('identity.session', 'public');
76
+ registry.set('identity.logout', 'public');
77
+ }
78
+ const bindings = {};
79
+ const commands = {};
80
+ if (ctl.external) {
81
+ if (m.capabilities.identity)
82
+ throw new StandaloneBuildError('CTL_EXTERNAL_TRANSPORT', 'External entries require the DSM session transport.');
83
+ for (const entry of Object.values(ctl.external)) {
84
+ if (!entry || typeof entry.method !== 'string' || !registry.has(entry.method) || nonRPC.has(entry.method) || m.entry !== 'admin-only' && registry.get(entry.method) !== 'administrators')
85
+ throw new StandaloneBuildError('CTL_EXTERNAL_ENTRY', 'External entries require registered administrator RPC methods.');
86
+ registry.set(entry.method, 'administrators');
87
+ bindings[entry.method] = { permission: 'administrators', effect: 'destructive' };
88
+ }
89
+ }
90
+ const weights = { read: 0, write: 1, destructive: 2 };
91
+ for (const [id, declared] of Object.entries(ctl.commands)) {
92
+ const command = structuredClone(declared);
93
+ const names = flowMethods(command.flow);
94
+ let permission = 'public';
95
+ for (const name of names) {
96
+ if (rawHTTP.has(name))
97
+ throw new StandaloneBuildError('CTL_COMMAND_UNREGISTERED', `Command ${id} references raw HTTP route ${name}; ctl commands require RPC methods.`);
98
+ if (!registry.has(name))
99
+ throw new StandaloneBuildError('CTL_COMMAND_UNREGISTERED', `Command ${id} references unregistered method ${name}.`);
100
+ const effective = m.entry === 'admin-only' ? 'administrators' : registry.get(name);
101
+ registry.set(name, effective);
102
+ const effect = command.flow.type === 'job' && name !== command.flow.start ? 'read' : command.effect;
103
+ const previous = bindings[name];
104
+ if (!previous || weights[effect] > weights[previous.effect])
105
+ bindings[name] = { permission: effective, effect };
106
+ if (effective === 'administrators' || effective === 'authenticated' && permission === 'public')
107
+ permission = effective;
108
+ }
109
+ commands[id] = { ...command, permission };
110
+ }
111
+ if (m.capabilities.identity) {
112
+ for (const method of ['identity.session', 'identity.logout'])
113
+ bindings[method] = { permission: 'public', effect: 'write' };
114
+ }
115
+ const description = makeDescriptor({ package: { id: m.package, version: m.spkVersion, displayName: m.displayname }, aliases: ctl.aliases ?? [m.package.toLowerCase()], provenance: { developedBy: ctl.developedBy ?? 'unknown', generator: 'synopkgland-cli' }, entry: m.entry ?? 'policy', transport: { path: `/webman/3rdparty/${m.package}/cgi/api.cgi`, auth: m.capabilities.identity ? 'dsm-app-session' : 'dsm-session' }, commands, bindings, ...(ctl.external ? { external: ctl.external } : {}) });
116
+ try {
117
+ return { description: validateDescriptor(description, m.package, m.spkVersion), registry: Object.fromEntries(registry) };
118
+ }
119
+ catch (error) {
120
+ throw new StandaloneBuildError('CTL_DESCRIPTOR_INVALID', error.message);
121
+ }
122
+ }
@@ -95,6 +95,8 @@ export interface StandaloneManifest {
95
95
  };
96
96
  daemon?: Daemon;
97
97
  lifecycleTimeouts?: Daemon["timeouts"];
98
+ /** Author-supplied overrides, before daemon supervision defaults are filled. */
99
+ declaredLifecycleTimeouts?: Partial<Daemon["timeouts"]>;
98
100
  /** `identity_gateway`: signs DSM users in to the daemon's own web UI. */
99
101
  identityGateway?: IdentityGateway;
100
102
  compose?: ComposeApp;
@@ -607,6 +607,8 @@ function readManifest(raw, c) {
607
607
  ...(daemon ? { daemon } : {}),
608
608
  ...(dependencies ? { dependencies } : {}),
609
609
  ...(lifecycleTimeouts ? { lifecycleTimeouts } : {}),
610
+ declaredLifecycleTimeouts: isRecord(raw.daemon) && isRecord(raw.daemon.timeouts)
611
+ ? { ...raw.daemon.timeouts } : {},
610
612
  ...(identityGateway ? { identityGateway } : {}),
611
613
  ...(compose ? { compose } : {}),
612
614
  ...(uninstall ? { uninstall } : {}),
package/dist/validate.js CHANGED
@@ -37,6 +37,12 @@ export function validateProject(project, _options = {}) {
37
37
  "Correct the schema-2 declaration; see the SDK Compose support matrix.",
38
38
  })),
39
39
  }
40
- : { ok: true, errors: [], warnings: upstreamAttributionWarnings(project.root) };
40
+ : { ok: true, errors: [], warnings: [...upstreamAttributionWarnings(project.root),
41
+ ...(loaded.ok && 'ctl' in loaded.manifest && loaded.manifest.ctl?.enabled && !loaded.manifest.ctl.registry ? [{
42
+ code: 'CTL_LEGACY_COMMANDS_DEPRECATED', severity: 'warning',
43
+ span: { file, line: 1, column: 1 },
44
+ message: 'Legacy ctl.commands is deprecated and remains supported for check and build.',
45
+ suggestion: 'Plan migration to ctl.registry when ready; this warning does not block existing Apps.',
46
+ }] : [])] };
41
47
  }
42
48
  export { findProjectRoot } from "./discovery.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.48.3",
3
+ "version": "0.48.4",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -24,8 +24,10 @@
24
24
  "test:glossary": "node --test scripts/test/glossary-drift.test.mjs",
25
25
  "test:scripts": "node --test scripts/test/gate.test.mjs scripts/test/release.test.mjs scripts/test/pack-docker.test.mjs scripts/test/npm-pack.test.mjs scripts/test/executor-bump.test.mjs scripts/test/smoke-exports.test.mjs scripts/test/parallel.test.mjs scripts/test/scaffold-matrix.test.mjs scripts/test/frontend-deps.test.mjs scripts/test/docker-gate.test.mjs scripts/test/gate-plan.test.mjs scripts/test/gates.test.mjs && python3 scripts/test/npm-publish.py",
26
26
  "gates": "bash scripts/ci/gates.sh",
27
- "gates:fast": "bash scripts/ci/gates.sh --fast",
28
- "prepublishOnly": "npm run build"
27
+ "gates:fast": "bash scripts/ci/gates.sh",
28
+ "prepublishOnly": "npm run build",
29
+ "gates:full": "bash scripts/ci/gates.sh --full",
30
+ "test:basic": "node --import tsx --test test/schema.test.ts test/standalone-manifest.test.ts test/native-arch.test.ts test/archive-inventory.test.ts"
29
31
  },
30
32
  "dependencies": {
31
33
  "@napi-rs/keyring": "^2.1.1",
package/skills/SKILL.md CHANGED
@@ -356,3 +356,11 @@ Use opt-in `identity_gateway.ingress: {path: /my-app/}` for
356
356
  upstreams with a hardcoded base path. Read [reference/identity-gateway.md](reference/identity-gateway.md)
357
357
  for reserved paths, install-time ownership checks and unchanged auth policy.
358
358
  Apps requiring `/` cannot use ingress.
359
+
360
+ ## Maintaining this CLI
361
+
362
+ For CLI releases, `npm run gates` runs basic build/typecheck, core unit checks,
363
+ npm pack and tarball content checks. Run `npm run gates:full` only when the user
364
+ explicitly requests extended matrices and integration checks. Publishing does
365
+ not require a full-gate result. Application fixture acceptance remains scoped
366
+ to the application task's authorization.
@@ -121,10 +121,15 @@ actual upstream token/header/API-password mapping and shared-account semantics.
121
121
 
122
122
  ## Designing commands for AI
123
123
 
124
- Each App has one `synopkgland.api` v2 operation spec (`operations.json`; OSS
124
+ New Apps have one `synopkgland.api` v2 operation spec (`operations.json`; OSS
125
125
  wrappers keep it under `synology/`). Set `ctl: {enabled: true, registry:
126
126
  operations.json}` relative to the packaging manifest. Do not maintain a second
127
- list of summaries or command schemas.
127
+ list of summaries or command schemas. Existing v1 `ctl.commands` Apps continue
128
+ passing check and build; check emits one nonblocking deprecation warning.
129
+ Migrate them deliberately, keeping their registered methods and permissions.
130
+ App-authored registry files and authenticated discovery responses have no byte-size
131
+ cap. Runtime description/registry loading also needs the matching SDK metadata fix;
132
+ ordinary operation input limits continue to apply.
128
133
  Each real method has one English `summary`, `paramsSchema`, `resultSchema`,
129
134
  `effect`, `permission`, fixed `flow`, `cli` path and required `ai` class:
130
135
 
@@ -121,7 +121,7 @@ allowance with `KillMode=control-group`.
121
121
 
122
122
  `backend.timeout_seconds` owns request/operation work. Binary and Compose Apps
123
123
  without a CGI request setting can enlarge the shared operation allowance through
124
- `daemon.timeouts.status` above its 60-second default. Generated gateway and
124
+ `daemon.timeouts.status` above the SDK shared operation default. Generated gateway and
125
125
  approved executor configurations inherit it; nested calls use remaining time and
126
126
  leave response reserve. Budget changes in the protected policy require renewed
127
127
  approval and do not change token/session/grant lifetimes.