syno-pkg-land-sdk

module
v0.53.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT

README

Synology Package Land SDK

SDK for DSM packages built with synopkgland.

Path Contents
/ Go module github.com/synopackageland/syno-pkg-land-sdk: api, appbackup, background, datamigrate, delegate, dsm, filestation, identity, ipc, jsonlimits, portal, sharedfolder
executor/ Go module github.com/synopackageland/syno-pkg-land-sdk/executor: the delegated executor; pins the root Go SDK for the shared DSM role provider
ts/ npm package @synopackageland/sdk (. headless, ./vue components, ./native, ./entry, ./mobile, ./mobile/shell)
spec/protocol/v1/ Executor protocol: rules (RFC 2119), op schemas, errors.json, vectors
spec/delegate/v1/ App backend delegate DTOs: single schema generating Go and TypeScript wire types
bridge/, spec/bridge/v1/ bridge/cmd/runtime, the package CGI that hands verified calls to a Python, Node or Rust App, one process per request; the channel and the App manifest (bridge.json) are frozen (spec/bridge/v1, docs/multilang/design.md). Each request starts the App: Node adds about 0.5 s on an ARM NAS, so latency-sensitive Apps should use Python or Rust
rust/app/ Crate syno-pkg-land-app: thin SDK for Rust Apps behind the bridge runtime (rust/app/README.md)
node/ npm package @synopackageland/app: the Node App SDK for the bridge, TypeScript with ESM and .d.ts, Node 22 or later, no runtime dependencies (node/README.md)
python/ Package synopkgland_app: the Python App SDK for the bridge, standard library only, Python 3.8 or later (python/README.md)
testdata/golden/ api.Server replies every bridge App must reproduce byte for byte (repository check, not published)
supervision/ Shared bounded restart policy, dependency waits and Linux process-group ownership
conformance/ Runs the vectors against the executor over a Unix socket (repository check, not published)
scripts/ gate.sh (local gate), executor-digests.sh (reproducible SDK payload inventory)

<sdk-version> is a placeholder, not manifest syntax. synopkgland init copies compatible SDK pins from the locally installed templates. For a manual configuration, query npm view @synopackageland/sdk version, replace the placeholder with that exact release, and keep all App SDK declarations (including Go, Rust and frontend dependencies) aligned. Run synopkgland check with an up-to-date CLI before building.

An app depends on the SDK through backend/go.mod:

require github.com/synopackageland/syno-pkg-land-sdk v<sdk-version>

A Rust App depends on syno-pkg-land-app (rust/app/) and runs behind the Go runtime:

syno-pkg-land-app = { git = "https://github.com/synopackageland/syno-pkg-land-sdk", tag = "v<sdk-version>" }

The go.mod line is the only source of the SDK version. The CLI builds the executor from github.com/synopackageland/syno-pkg-land-sdk/executor at the immutable release declared by the SDK executor manifest and verifies its six payload digests. The manifest ships in both the Go module and npm package. Use a CLI that supports executor manifest format 1 and templates that produce the owner-and-grant staging/job namespaces required by delegate.OwnerStagingPrefix and delegate.OwnerJobSuffix. The CLI builds the Hyper Backup control from appbackup.

Apps build their API server with api.NewServerWithPermissions(auth, permissionsJSON, routes...); it refuses an SDK policy that differs from the digest the CLI binds with -X github.com/synopackageland/syno-pkg-land-sdk/api.expectedSDKPermissionsDigest=….

For bounded public HTTP(S) subprocess probes, see Outbound probe proxy.

For optional HTTPS requirements, administrator-only HTTPS links and opt-in read RPC recovery after a stale DSM token, see HTTPS and session recovery. Ordinary HTTP Apps remain supported; writes, AI and streams never auto-replay.

For owner-bound asynchronous Go work, structured results and ctl integration, see Structured background jobs.

Native Apps appear in Hyper Backup as applications by default; see Hyper Backup application backup for what is archived, offline and online modes, the data version check, and the fixed root script Hyper Backup runs.

Testing an App with the executor

An App behind the bridge runtime reaches its executor at /run/synopkgland/<package>/executor.sock, which only root can create. A Go end-to-end test serves a fake executor instead, without root and on macOS too:

e := delegatetest.NewExecutor(t, func(q delegate.Request) string {
	if q.Op == "root.run" {
		return delegatetest.OK(`{"request_id":"r1","exit_code":0,"stderr":"","output":"{}"}`)
	}
	return delegatetest.Refused("EXECUTOR_PAUSED")
})
h, err := bridge.NewRuntime(bridge.Config{PackageID: "MyApp", AppDir: appDir,
	DataDir: t.TempDir(), Auth: auth, ExecutorSocket: e.Socket})
// serve requests with h, then check e.Requests()

The fake speaks protocol v1's framing only: it checks no session and no policy. ExecutorSocket is for tests: the package CGI and worker (bridge/cmd/runtime) never set it, so no request can choose the socket.

Read DSM service and port definitions without root with dsmservices.

Development

For ES module frontends and lazy routes in DSM windows, see frontend bundles.

Native foreground daemons can opt into bounded crash recovery in their generated runtime config; see native daemon restart policy for defaults, status diagnostics and the required CLI/templates integration.

npm run gates                  # basic checks for development and release
npm run gates:full             # extended checks, only when explicitly requested
bash scripts/gate.sh --plan    # print the default workloads without running them
go generate ./...              # after editing protocol or delegate specs

Basic checks cover core unit tests, native builds, static policy and manifest validation, npm packing and tarball content scans. Full adds target matrices, runtime containers, daemon/gateway integration, Rust target checks, cold executor reproducibility and registry integration. Full is optional for releases. See release checks for all entry points. A configured SYNOPKGLAND_DOCKER_SSH supplies build isolation for frontend checks; it does not enable extended integrations. Rust runs only in Linux containers.

Contributor checks

Local release checks and private CI share the basic gate. From a clone with dependencies accessible, install Git, Bash and the Go toolchain declared in go.mod, then run:

git fetch origin
npm run gates

Basic checks need Node.js/npm, Go and Python. Extended checks additionally use uv, Rust/rustup and Docker for supported runtime and target checks. Rust runs inside a Linux container. A release uses basic checks; extended checks require npm run gates:full. Neither gate requires a NAS or DSM login. The root module's Compose prepare tests read Linux kernel routes from /proc; run those checks on Linux or in a Linux container. Docker SSH redirects the Rust/TS segments; root Go checks still run on the machine invoking the gate.

Docker SSH is optional. Contributors can use their own local tools and Docker engine with SYNOPKGLAND_DOCKER_SSH unset, or an SSH-accessible Docker host:

SYNOPKGLAND_DOCKER_SSH=builder.example npm run gates

builder.example is a placeholder; supply your own host. Set SYNOPKGLAND_GATE_BASE to another fetched ref when comparing a different base. On a shared host, keep the synopkgland- gate images and cache volumes; remove only containers and temporary files created by your run.

Executor source or build-input changes require a matching immutable inventory. Build it only as executor-digests.sh specifies; other build inputs can change the resulting digests. Unrelated patches reuse the committed inventory.

License: MIT for SDK code; retained upstream Compose fixtures have separate licenses and notices.

Notifications and App entry

Use notify for stable notification delivery identities, event/key throttling and App-owned webhook/SMTP attempts. The App retains its durable outbox and retry policy.

App entry policy covers the centralized CGI admin gate and the non-blocking frontend EntryGuard.

Use dsm.LookupAccount for a complete single-account snapshot, provider source, numeric groups and distinct lookup errors.

Identity gateway

See gateway access failures for admission errors and localization, and DSM-managed HTTPS ingress for the native transport, certificate trust requirements and direct fallback.

Upstream Compose

See Compose packages for schema-2 planning, identity gateway transport, immutable artifacts and explicit DSM acceptance blockers.

Described commands

Syno Package Land API 描述 v1 defines authenticated discovery, explicit task-level commands, fixed workflow adapters, and the public JSON Schema. api.WithDescription serves the private build artifact using DSM authentication; api.DescribeRoutes exports the actual registry to the build tool.

See runtime storage and NAS idle periods for volatile worker liveness and durable job/approval state.

For public-network URL downloads and registry access, see outbound HTTP policy.

For credential-authorized IPC between package accounts, use ipc.StartPackagePeerUnix.

Single operation registry

Native RPC Apps declare operation metadata in a synopkgland.api v2 JSON registry. The CLI generates permissions, runtime bindings, the private API descriptor, ctl commands, AI/MCP tools and the App reference from that one source. English summaries are not maintained in a second skill or document. Each operation needs an explicit ai class: read, preview, draft, human-only or hidden. Reads and previews cannot mutate; drafts require a non-mutating preview and human confirmation. Long operations use a fixed job flow.

Go Apps embed the generated full registry and construct the server with api.NewServerWithOperations; ValidateOperationRegistry checks exact handler, spec and permission equality before handlers or migrations run. Only the fixed describe and identity ceremony routes are infrastructure exceptions. SDK-owned capability metadata lives in api/operations.json and defaults to hidden.

The bridge exporter bridge/cmd/describe constructs its actual route set without starting an App. Python, Node and Rust share the existing bridge runtime: the CLI binds the digest of generated synopkgland-operations.json, and startup refuses altered metadata or route/spec inequality before dispatch. No new transport, proxy or service is introduced.

Run synopkgland ctl generate, synopkgland ctl generate --check and synopkgland check before building with matching SDK/CLI/templates releases. OpenAPI imports use the same v2 format; every imported operation is hidden until reviewed per API. Wrapper-owned specs and adapters stay under synology/.

External-service passwords and tokens should use the request-only Secret contract, including its persistence and diagnostic boundaries.

Private native audio/video playback is available through the Go media service and TypeScript mediaUrl helper; see media grants for owner hooks, session binding, renewal, and Range handling.

Full-page Apps use @synopackageland/sdk/entry for boot, shared context and sign-in display caches; Go Apps can expose language fields with api.AppStatusHandler. Native mobile Apps use @synopackageland/sdk/mobile for actions and browser fallbacks; shell implementations use the DOM-free ./mobile/shell contract. SynoPkgNative protocol 1 and the mobile: manifest are stable, with optional additions and capability-based degradation under the documented compatibility policy.

Native HTTP Apps declare a synopkgland.api v3 registry with ctl.transport: native-http. The SDK exports validated descriptors and HTTP inventories, shared Go/TypeScript types and JSON schemas, and serves authenticated metadata through the existing DSM CGI entry. The CLI handles upstream credentials, HTTP execution and bounded file transfers. See the native HTTP contract.

Offering another package

An App can offer another Package Land package: detect it, open it, or send an administrator to Package Center with packageCenterUrl(). See offering another package.

Raw TCP protocols

Use manifest-declared ipc.ListenTCP for raw TCP services; bind scope and allowed ports are compiled by the CLI. Omitted or loopback scope binds 127.0.0.1; explicit scope: all binds 0.0.0.0 on every IPv4 interface. Use the DSM firewall to restrict access to an all-interface port. See declared TCP listeners for policy, lifetime, audit and authentication boundaries.

Directories

Path Synopsis
api
Package api is the package's one HTTP entry point.
Package api is the package's one HTTP entry point.
nativehttp
Package nativehttp validates and exports native HTTP metadata.
Package nativehttp validates and exports native HTTP metadata.
nativehttp/cmd/export command
Command export emits metadata only; it never initializes an App or gateway.
Command export emits metadata only; it never initializes an App or gateway.
Package appbackup exports and imports a package's data directory for Hyper Backup application backup.
Package appbackup exports and imports a package's data directory for Hyper Backup application backup.
cmd/control command
Command control is the package-account half of Hyper Backup application backup.
Command control is the package-account half of Hyper Backup application backup.
Package background is the package-private spool, journal and fixed worker behind opt-in background jobs.
Package background is the package-private spool, journal and fixed worker behind opt-in background jobs.
Package bridge hands a request the api package already verified to an App written in another language, over the channel in spec/bridge/v1.
Package bridge hands a request the api package already verified to an App written in another language, over the channel in spec/bridge/v1.
cmd/describe command
Command describe is the build-only bridge registry exporter.
Command describe is the build-only bridge registry exporter.
cmd/runtime command
Command runtime is the package CGI (ui/cgi/api.cgi) for an App written in Python, Node or Rust; spec/bridge/v1 describes the App directory it reads.
Command runtime is the package CGI (ui/cgi/api.cgi) for an App written in Python, Node or Rust; spec/bridge/v1 describes the App directory it reads.
internal/bench command
Command bench times one hello.greet request through api.Server, natively in Go and through the bridge to the hello Apps in exec mode.
Command bench times one hello.greet request through api.Server, natively in Go and through the bridge to the hello Apps in exec mode.
Package compose plans unmodified upstream Compose for DSM's official worker.
Package compose plans unmodified upstream Compose for DSM's official worker.
cmd/plan command
Command plan is the SDK's build-time Compose tool.
Command plan is the SDK's build-time Compose tool.
cmd/storage-init command
storage-init ships in the SPK and mounts read-only into the official image.
storage-init ships in the SPK and mounts read-only into the official image.
Package-account supervisor for one fixed foreground executable.
Package-account supervisor for one fixed foreground executable.
Package datamigrate applies ordered, idempotent schema migrations to a package's data directory and records how far they have run.
Package datamigrate applies ordered, idempotent schema migrations to a package's data directory and records how far they have run.
Package delegate provides the fixed v1 executor protocol.
Package delegate provides the fixed v1 executor protocol.
delegatetest
Package delegatetest serves a fake package executor on a Unix socket, for an App's end-to-end tests: pass Executor.Socket as bridge.Config's ExecutorSocket (or a delegate.Client's Socket) and the runtime's root.* and delegate.* calls reach reply instead of the executor at /run/synopkgland/<package>/executor.sock, without root and on macOS.
Package delegatetest serves a fake package executor on a Unix socket, for an App's end-to-end tests: pass Executor.Socket as bridge.Config's ExecutorSocket (or a delegate.Client's Socket) and the runtime's root.* and delegate.* calls reach reply instead of the executor at /run/synopkgland/<package>/executor.sock, without root and on macOS.
Package dsm verifies the DSM login behind a package CGI request.
Package dsm verifies the DSM login behind a package CGI request.
Package dsmservices reads the service definitions DSM's firewall and port forwarding use: INI files with one section per service, written by DSM itself (/usr/syno/etc/services.d, rewritten when the administrator changes a DSM port), by packages and by Container Manager (/usr/local/etc/services.d).
Package dsmservices reads the service definitions DSM's firewall and port forwarding use: INI files with one section per service, written by DSM itself (/usr/syno/etc/services.d, rewritten when the administrator changes a DSM port), by packages and by Container Manager (/usr/local/etc/services.d).
executor module
Package filestation retains typed file contracts and custom authorized adapters.
Package filestation retains typed file contracts and custom authorized adapters.
Package identity implements standalone identity only.
Package identity implements standalone identity only.
Package idgateway signs DSM users in to a packaged web app without a separate sign-in.
Package idgateway signs DSM users in to a packaged web app without a separate sign-in.
cmd/gateway command
Command gateway is the DSM identity gateway of a package.
Command gateway is the DSM identity gateway of a package.
Package installsettings owns package-account installation configuration.
Package installsettings owns package-account installation configuration.
cmd/control command
internal
composeimages
Package composeimages records which locked container images this package has already run.
Package composeimages records which locked container images this package has already run.
composeingress
Package composeingress defines the fixed, package-scoped no-publish endpoint.
Package composeingress defines the fixed, package-scoped no-publish endpoint.
containerpreflight
Package containerpreflight checks read-only DSM container availability as the package account.
Package containerpreflight checks read-only DSM container availability as the package account.
delegategen command
Command delegategen generates the App-facing Go and TypeScript delegate DTOs.
Command delegategen generates the App-facing Go and TypeScript delegate DTOs.
externalorigin
Package externalorigin validates literal public origins without DNS or HTTP.
Package externalorigin validates literal public origins without DNS or HTTP.
hostudp
Package hostudp validates explicit package-UID host UDP listener exceptions.
Package hostudp validates explicit package-UID host UDP listener exceptions.
identityroute
Package identityroute restricts public ceremony markers to SDK assembly.
Package identityroute restricts public ceremony markers to SDK assembly.
runtimebudget
Package runtimebudget derives work deadlines without changing authority lifetimes.
Package runtimebudget derives work deadlines without changing authority lifetimes.
specgen command
Command specgen copies spec/protocol/v1 into package delegate: the error catalog becomes Go constants and the vectors become test data.
Command specgen copies spec/protocol/v1 into package delegate: the error catalog becomes Go constants and the vectors become test data.
startupbudget
Package startupbudget holds the shared container startup contract.
Package startupbudget holds the shared container startup contract.
Package ipc serves private HTTP IPC for the non-root package account and reserves loopback ports for supervised children.
Package ipc serves private HTTP IPC for the non-root package account and reserves loopback ports for supervised children.
Package jsonlimits bounds JSON complexity before a decoder allocates values.
Package jsonlimits bounds JSON complexity before a decoder allocates values.
Package media serves private assets to native audio/video elements without placing DSM credentials in URLs.
Package media serves private assets to native audio/video elements without placing DSM credentials in URLs.
Package notify sends App-owned notifications as the package account.
Package notify sends App-owned notifications as the package account.
Package outbound restricts untrusted HTTP destinations to public networks.
Package outbound restricts untrusted HTTP destinations to public networks.
Package portal reads the DSM Application Portal alias an administrator set for this package.
Package portal reads the DSM Application Portal alias an administrator set for this package.
Package secret provides request-only credentials and safe diagnostic values.
Package secret provides request-only credentials and safe diagnostic values.
Package sharedfolder tells an App which Shared Folders the install wizard stored and what the package account may do in each.
Package sharedfolder tells an App which Shared Folders the install wizard stored and what the package account may do in each.
Package supervision supplies the restart decision shared by package daemons and their provider children.
Package supervision supplies the restart decision shared by package daemons and their provider children.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL