@synopackageland/cli 0.48.0 → 0.48.2
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 +13 -0
- package/README.md +14 -11
- package/dist/ctl/descriptor.d.ts +1 -1
- package/dist/ctl/descriptor.js +1 -1
- package/dist/ctl/flows.d.ts +2 -1
- package/dist/ctl/flows.js +19 -5
- package/dist/ctl/service.d.ts +2 -0
- package/dist/ctl/service.js +9 -5
- package/dist/error-registry.js +2 -2
- package/dist/nas/transport.d.ts +2 -2
- package/dist/nas/transport.js +4 -3
- package/dist/runtime/operation-budget.d.ts +2 -0
- package/dist/runtime/operation-budget.js +5 -0
- package/dist/runtime/sdk-source.d.ts +1 -1
- package/dist/runtime/sdk-source.js +1 -1
- package/dist/runtime/sdk-timeouts.js +2 -1
- package/dist/standalone/build.js +1 -1
- package/dist/standalone/manifest.js +3 -1
- package/package.json +2 -2
- package/schema/bridge-manifest.v1.schema.json +1 -1
- package/schema/sdk-timeouts.json +24 -0
- package/schema/synopkgland-api-v1.schema.json +1 -2
- package/skills/SKILL.md +3 -3
- package/skills/reference/compose.md +3 -3
- package/skills/reference/create.md +3 -3
- package/skills/reference/ctl.md +8 -7
- package/skills/reference/identity-gateway.md +5 -5
- package/skills/reference/install.md +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.48.2
|
|
4
|
+
|
|
5
|
+
- Pin SDK 0.49.5 for CLI-owned controllers and planning so they inherit the shared operation policy
|
|
6
|
+
- Make job flow timeoutMs optional; use the SDK operation allowance for each query and keep live jobs polling until completion or cancellation
|
|
7
|
+
- Preserve job IDs and dispatch start once; abort pending JSON reads when local waiting is canceled
|
|
8
|
+
- Use the SDK timeout contract for ctl defaults and allow unconfigured root programs to share the parent request budget
|
|
9
|
+
- Build CLI-owned controllers against the published SDK 0.49.5 and its protected executor inventory; retain explicit App SDK pins and templates ~0.39.2
|
|
10
|
+
|
|
11
|
+
## 0.48.1
|
|
12
|
+
|
|
13
|
+
- Align Go requirement messages, native build guidance and fixtures with Go 1.26.10 (#130)
|
|
14
|
+
- Pin the runtime SDK default to 0.47.1 and require templates ~0.39.2 with UI 0.19.5
|
|
15
|
+
|
|
3
16
|
## 0.48.0
|
|
4
17
|
|
|
5
18
|
- Generate permissions, runtime bindings, ctl commands, AI/MCP tools and App references from one synopkgland.api v2 operation registry
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Full documentation: <https://www.varvis.me/docs/> ([繁體中文](https://www.va
|
|
|
11
11
|
npm install -g @synopackageland/cli --registry=https://registry.npmjs.org
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Native Go apps need Go 1.
|
|
14
|
+
Native Go apps need Go 1.26.10 and npm. The CLI is tested on Node.js 22.19.
|
|
15
15
|
|
|
16
16
|
## Quick start
|
|
17
17
|
|
|
@@ -89,8 +89,8 @@ alongside npm lockfiles. Do not disable checksum verification for public SDK
|
|
|
89
89
|
packages. Private mirrors can use explicitly configured Go authentication and
|
|
90
90
|
checksum settings; a failed fetch reports `SDK_DOWNLOAD_FAILED`.
|
|
91
91
|
|
|
92
|
-
The CLI pins SDK 0.
|
|
93
|
-
context. Explicit App SDK declarations take precedence. Templates use ~0.39.
|
|
92
|
+
The CLI pins SDK 0.49.5 for its daemon controllers, Compose planning and installer
|
|
93
|
+
context. Explicit App SDK declarations take precedence. Templates use ~0.39.2
|
|
94
94
|
and retain their own scaffold SDK pins; none declare daemon ingress.
|
|
95
95
|
Every App method is declared once in operations.json; ctl generate writes the
|
|
96
96
|
permissions table and runtime bindings. Dynamic names and custom HTTP dispatchers
|
|
@@ -102,7 +102,7 @@ unimported development commands are excluded. Use
|
|
|
102
102
|
authentication. See [App entry and registration](docs/app-entry.md).
|
|
103
103
|
|
|
104
104
|
`init` and `add` read their templates from the locally installed
|
|
105
|
-
`@synopackageland/templates`. CLI 0.48.
|
|
105
|
+
`@synopackageland/templates`. CLI 0.48.1 depends on `~0.39.2`: npm installation or
|
|
106
106
|
update can select the latest templates patch in the 0.39 minor line. Templates
|
|
107
107
|
patches need only a templates release; update the npm installation to receive them.
|
|
108
108
|
The CLI never fetches templates at runtime, so offline use works after installation;
|
|
@@ -364,7 +364,7 @@ contract for the complete transport and CGI validation rules.
|
|
|
364
364
|
|
|
365
365
|
`webapi.call` request parameters are JSON-only; it has no request upload field.
|
|
366
366
|
Use streaming `files.write` for uploads, up to 100 MiB per file. Reads and URL
|
|
367
|
-
downloads retain their separate 64 MiB limit. Rebuild with SDK 0.
|
|
367
|
+
downloads retain their separate 64 MiB limit. Rebuild with SDK 0.49.5 and approve
|
|
368
368
|
the refreshed executor payload.
|
|
369
369
|
|
|
370
370
|
## App launch mode
|
|
@@ -570,11 +570,14 @@ such as `CTL_DESCRIPTOR_INVALID`, remain specific errors (exit 5).
|
|
|
570
570
|
`host list/show` can also succeed while reporting `authenticated:false` and
|
|
571
571
|
exit 0. Check discovery `apps`/`diagnostics` and session fields as well as the exit
|
|
572
572
|
code when deciding whether an App is ready.
|
|
573
|
-
`ctl --timeout <seconds>` applies to discovery, JSON calls
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
573
|
+
`ctl --timeout <seconds>` applies to discovery, JSON calls and transfer inactivity.
|
|
574
|
+
The default is the SDK's shared five-minute work allowance plus its two-second
|
|
575
|
+
response reserve. Synchronous flows consume one remaining allowance. Job flows
|
|
576
|
+
refresh that allowance for each status/result request and keep polling a live job
|
|
577
|
+
until a terminal state or cancellation. `flow.timeoutMs` is optional; an explicit
|
|
578
|
+
value changes per-request waiting, never the elapsed job lifetime. A failed status
|
|
579
|
+
read does not fail or restart the remote job: query its original ID before retrying.
|
|
580
|
+
|
|
578
581
|
|
|
579
582
|
Read `synopkgland skill show ctl` for the AI workflow, batch discovery approval,
|
|
580
583
|
cache refresh, host removal/revocation and `ctl.registry` authoring with `synopkgland.api` v2. Run `ctl generate`,
|
|
@@ -626,7 +629,7 @@ package start activates nginx.
|
|
|
626
629
|
|
|
627
630
|
Older SDK/DSM targets retain the direct listener and explain its certificate or
|
|
628
631
|
unencrypted-HTTP limitations before opening it. Native resource/startup failures
|
|
629
|
-
fail closed; they do not silently expose a direct listener. The native runtime uses the resolved SDK release; new scaffolds pin SDK 0.47.
|
|
632
|
+
fail closed; they do not silently expose a direct listener. The native runtime uses the resolved SDK release; new scaffolds pin SDK 0.47.1.
|
|
630
633
|
|
|
631
634
|
Compose Apps may opt in to Intel render devices with
|
|
632
635
|
`compose.devices.gpu.services: [media]`. The matching SDK discovers exact devices
|
package/dist/ctl/descriptor.d.ts
CHANGED
package/dist/ctl/descriptor.js
CHANGED
|
@@ -113,7 +113,7 @@ export function validateFlow(op, bindings) {
|
|
|
113
113
|
throw Error('binding/effect');
|
|
114
114
|
}
|
|
115
115
|
if (flow.type === 'job') {
|
|
116
|
-
if (!flow.jobId || !flow.idParam || !flow.state || !Array.isArray(flow.done) || !flow.done.length || !Array.isArray(flow.failed) || !Number.isInteger(flow.intervalMs) || flow.intervalMs < 10 || flow.intervalMs > 60000 || !Number.isInteger(flow.timeoutMs) || flow.timeoutMs < flow.intervalMs || flow.timeoutMs > 3600000 || bindings[flow.poll].effect !== 'read' || flow.result && bindings[flow.result].effect !== 'read')
|
|
116
|
+
if (!flow.jobId || !flow.idParam || !flow.state || !Array.isArray(flow.done) || !flow.done.length || !Array.isArray(flow.failed) || !Number.isInteger(flow.intervalMs) || flow.intervalMs < 10 || flow.intervalMs > 60000 || flow.timeoutMs !== undefined && (!Number.isInteger(flow.timeoutMs) || flow.timeoutMs < flow.intervalMs || flow.timeoutMs > 3600000) || bindings[flow.poll].effect !== 'read' || flow.result && bindings[flow.result].effect !== 'read')
|
|
117
117
|
throw Error('job contract');
|
|
118
118
|
}
|
|
119
119
|
if (flow.type === 'paginate' && (!flow.items || !flow.offsetParam || !flow.limitParam || !Number.isInteger(flow.pageSize) || flow.pageSize < 1 || flow.pageSize > 1000 || !Number.isInteger(flow.maxPages) || flow.maxPages < 1 || flow.maxPages > 1000 || op.effect !== 'read'))
|
package/dist/ctl/flows.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ export type Invoke = (method: string, params: Record<string, unknown>) => Promis
|
|
|
3
3
|
export interface FlowOptions {
|
|
4
4
|
wait?: boolean;
|
|
5
5
|
timeoutMs?: number;
|
|
6
|
+
signal?: AbortSignal;
|
|
6
7
|
upload?: (method: string, params: Record<string, unknown>, flow: Extract<Flow, {
|
|
7
8
|
type: 'upload';
|
|
8
9
|
}>) => Promise<unknown>;
|
|
9
10
|
ndjson?: (method: string, params: Record<string, unknown>) => Promise<unknown>;
|
|
10
11
|
}
|
|
11
|
-
export declare function runFlow(flow: Flow, params: Record<string, unknown>,
|
|
12
|
+
export declare function runFlow(flow: Flow, params: Record<string, unknown>, send: Invoke, options: FlowOptions): Promise<any>;
|
package/dist/ctl/flows.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
1
2
|
import { CtlError } from './errors.js';
|
|
3
|
+
function canceled() { return new CtlError('CTL_CANCELED', 'Stopped waiting for the job.', 'Query the original job; start was not repeated.', 130); }
|
|
4
|
+
function cancelable(work, signal) {
|
|
5
|
+
if (signal?.aborted)
|
|
6
|
+
return Promise.reject(canceled());
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const abort = () => { signal?.removeEventListener('abort', abort); reject(canceled()); };
|
|
9
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
10
|
+
const finish = () => signal?.removeEventListener('abort', abort);
|
|
11
|
+
Promise.resolve().then(() => { if (signal?.aborted)
|
|
12
|
+
throw canceled(); return work(); }).then(value => { finish(); resolve(value); }, error => { finish(); reject(error); });
|
|
13
|
+
});
|
|
14
|
+
}
|
|
2
15
|
function field(value, path) { for (const key of path.split('.')) {
|
|
3
16
|
if (!value || typeof value !== 'object' || !Object.hasOwn(value, key))
|
|
4
17
|
return undefined;
|
|
5
18
|
value = value[key];
|
|
6
19
|
} return value; }
|
|
7
|
-
export async function runFlow(flow, params,
|
|
20
|
+
export async function runFlow(flow, params, send, options) {
|
|
21
|
+
const invoke = (method, input) => cancelable(() => send(method, input), options.signal);
|
|
8
22
|
if (flow.type === 'invoke')
|
|
9
23
|
return invoke(flow.method, params);
|
|
10
24
|
if (flow.type === 'upload') {
|
|
@@ -32,21 +46,21 @@ export async function runFlow(flow, params, invoke, options) {
|
|
|
32
46
|
}
|
|
33
47
|
throw new CtlError('CTL_FLOW_LIMIT', 'Pagination page limit reached; result is incomplete.', 'Narrow the query.', 5);
|
|
34
48
|
}
|
|
35
|
-
const until = performance.now() + Math.min(options.timeoutMs ?? flow.timeoutMs, 3600000);
|
|
36
49
|
const accepted = await invoke(flow.start, params);
|
|
37
50
|
if (options.wait === false)
|
|
38
51
|
return { accepted: true, job: accepted };
|
|
39
52
|
const id = field(accepted, flow.jobId);
|
|
40
53
|
if (!['string', 'number'].includes(typeof id))
|
|
41
54
|
throw new CtlError('CTL_FLOW_RESPONSE', 'Start response has no job ID.', 'Check command metadata; start is not retried.', 5);
|
|
42
|
-
while (
|
|
55
|
+
while (true) {
|
|
43
56
|
const poll = await invoke(flow.poll, { [flow.idParam]: id });
|
|
44
57
|
const state = field(poll, flow.state);
|
|
58
|
+
if (typeof state !== 'string')
|
|
59
|
+
throw new CtlError('CTL_FLOW_RESPONSE', 'Job status has no state.', 'Query the original job; start was not repeated.', 5);
|
|
45
60
|
if (flow.failed.includes(state))
|
|
46
61
|
throw new CtlError('CTL_JOB_FAILED', `Job ${id} failed (${state}).`, 'Inspect the job in the App; start was not retried.', 5);
|
|
47
62
|
if (flow.done.includes(state))
|
|
48
63
|
return flow.result ? invoke(flow.result, { [flow.idParam]: id }) : poll;
|
|
49
|
-
await
|
|
64
|
+
await delay(flow.intervalMs, undefined, { signal: options.signal }).catch(() => { throw canceled(); });
|
|
50
65
|
}
|
|
51
|
-
throw new CtlError('CTL_JOB_TIMEOUT', `Wait timed out; job ${id} may still be running.`, 'Query the job status; do not repeat the start blindly.', 6);
|
|
52
66
|
}
|
package/dist/ctl/service.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare class CtlClient {
|
|
|
30
30
|
request: JsonRequest;
|
|
31
31
|
constructor(store: CtlStore, host: Host, request?: JsonRequest, timeoutMs?: number);
|
|
32
32
|
private until?;
|
|
33
|
+
private jobRequestBudget?;
|
|
33
34
|
private remaining;
|
|
34
35
|
valid(): Promise<boolean>;
|
|
35
36
|
inventory(session: DsmSession): Promise<{
|
|
@@ -46,6 +47,7 @@ export declare class CtlClient {
|
|
|
46
47
|
stdin?: string;
|
|
47
48
|
wait?: boolean;
|
|
48
49
|
timeoutMs?: number;
|
|
50
|
+
signal?: AbortSignal;
|
|
49
51
|
}): Promise<any>;
|
|
50
52
|
private executeWithin;
|
|
51
53
|
private appCookieSession;
|
package/dist/ctl/service.js
CHANGED
|
@@ -19,7 +19,8 @@ export class CtlClient {
|
|
|
19
19
|
this.request = request ?? createRequest(host.origin, () => this.remaining(timeoutMs), undefined, store.trust(host));
|
|
20
20
|
}
|
|
21
21
|
until;
|
|
22
|
-
|
|
22
|
+
jobRequestBudget;
|
|
23
|
+
remaining(fallback) { return this.jobRequestBudget ?? (this.until === undefined ? fallback : Math.max(0, this.until - performance.now())); }
|
|
23
24
|
async valid() { try {
|
|
24
25
|
await this.inventory(await this.store.session(this.host));
|
|
25
26
|
return true;
|
|
@@ -121,6 +122,7 @@ export class CtlClient {
|
|
|
121
122
|
}
|
|
122
123
|
finally {
|
|
123
124
|
this.until = undefined;
|
|
125
|
+
this.jobRequestBudget = undefined;
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
128
|
async executeWithin(name, path, args, options = {}) {
|
|
@@ -131,8 +133,10 @@ export class CtlClient {
|
|
|
131
133
|
const { id, operation } = selectOperation(app, path);
|
|
132
134
|
const params = operationInput(operation, args, options.stdin, `run: synopkgland ctl ${name} ${operation.cli.join(' ')} --host ${this.host.name} --help`);
|
|
133
135
|
const output = new SensitiveOutput(params, operation.paramsSchema);
|
|
134
|
-
if (
|
|
135
|
-
this.until =
|
|
136
|
+
if (operation.flow.type === 'job') {
|
|
137
|
+
this.until = undefined;
|
|
138
|
+
this.jobRequestBudget = options.timeoutMs ?? operation.flow.timeoutMs ?? CTL_TIMEOUT_MS;
|
|
139
|
+
}
|
|
136
140
|
try {
|
|
137
141
|
const plan = requestPlan(app, id, params);
|
|
138
142
|
if (operation.flow.type === 'upload')
|
|
@@ -153,14 +157,14 @@ export class CtlClient {
|
|
|
153
157
|
const invoke = async (method, input) => {
|
|
154
158
|
if (!app.payload.bindings[method])
|
|
155
159
|
throw new CtlError('CTL_METHOD_NOT_ALLOWED', 'Flow method is not allowlisted.', 'Refresh the API description.', 4);
|
|
156
|
-
const response = await this.request(app.payload.transport.path, { method, params: input }, appSession);
|
|
160
|
+
const response = await this.request(app.payload.transport.path, { method, params: input }, appSession, options.signal);
|
|
157
161
|
if (response?.success !== true) {
|
|
158
162
|
const code = String(response?.error?.code ?? 'invalid_response');
|
|
159
163
|
throw new CtlError(['admin_required', 'app_privilege_denied'].includes(code) ? 'CTL_PERMISSION_DENIED' : 'CTL_APP_ERROR', `App rejected operation (${code}).`, 'Check command permissions and App state.', ['admin_required', 'app_privilege_denied'].includes(code) ? 4 : 5);
|
|
160
164
|
}
|
|
161
165
|
return response.data;
|
|
162
166
|
};
|
|
163
|
-
const result = await runFlow(operation.flow, params, invoke, { wait: options.wait, timeoutMs: this.remaining(options.timeoutMs ?? CTL_TIMEOUT_MS),
|
|
167
|
+
const result = await runFlow(operation.flow, params, invoke, { wait: options.wait, signal: options.signal, timeoutMs: this.remaining(options.timeoutMs ?? CTL_TIMEOUT_MS),
|
|
164
168
|
ndjson: (method, input) => transferRequest(appSession, app.payload.transport.path, method, input, { trust: this.store.trust(this.host), timeoutMs: this.remaining(options.timeoutMs ?? CTL_TIMEOUT_MS) }),
|
|
165
169
|
upload: (method, input, flow) => transferRequest(appSession, app.payload.transport.path, method, {}, { trust: this.store.trust(this.host), timeoutMs: this.remaining(options.timeoutMs ?? CTL_TIMEOUT_MS), file: { path: String(input[flow.fileParam]), parent: String(input[flow.parentParam]), name: String(input[flow.nameParam]) } }) });
|
|
166
170
|
if (operation.resultSchema && !ajv.validate(operation.resultSchema, result))
|
package/dist/error-registry.js
CHANGED
|
@@ -444,7 +444,7 @@ export const ERROR_REGISTRY = {
|
|
|
444
444
|
STANDALONE_BACKGROUND_BUILD_FAILED: {
|
|
445
445
|
code: "STANDALONE_BACKGROUND_BUILD_FAILED",
|
|
446
446
|
description: "The package background worker could not be built.",
|
|
447
|
-
suggestion: "Install Go 1.
|
|
447
|
+
suggestion: "Install Go 1.26.10, confirm the backend has cmd/background-worker (create it with synopkgland init -t native-go --with jobs), and check the compiler stderr.",
|
|
448
448
|
},
|
|
449
449
|
STANDALONE_BACKGROUND_ARTIFACT_REQUIRED: {
|
|
450
450
|
code: "STANDALONE_BACKGROUND_ARTIFACT_REQUIRED",
|
|
@@ -614,7 +614,7 @@ export const ERROR_REGISTRY = {
|
|
|
614
614
|
STANDALONE_GO_MISSING: {
|
|
615
615
|
code: "STANDALONE_GO_MISSING",
|
|
616
616
|
description: "The go command was not found.",
|
|
617
|
-
suggestion: "Install Go 1.
|
|
617
|
+
suggestion: "Install Go 1.26.10 (https://go.dev/dl/), or package an existing executable with backend.files.",
|
|
618
618
|
},
|
|
619
619
|
STANDALONE_GO_BUILD_FAILED: {
|
|
620
620
|
code: "STANDALONE_GO_BUILD_FAILED",
|
package/dist/nas/transport.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HostTls } from './tls.js';
|
|
2
2
|
import http from 'node:http';
|
|
3
|
-
export declare const CTL_TIMEOUT_MS
|
|
3
|
+
export declare const CTL_TIMEOUT_MS: number;
|
|
4
4
|
export declare const APP_COOKIE: unique symbol;
|
|
5
5
|
export interface DsmSession {
|
|
6
6
|
origin: string;
|
|
@@ -9,7 +9,7 @@ export interface DsmSession {
|
|
|
9
9
|
token: string;
|
|
10
10
|
deviceId?: string;
|
|
11
11
|
}
|
|
12
|
-
export type JsonRequest = (path: string, body: URLSearchParams | Record<string, unknown>, session?: DsmSession) => Promise<any>;
|
|
12
|
+
export type JsonRequest = (path: string, body: URLSearchParams | Record<string, unknown>, session?: DsmSession, signal?: AbortSignal) => Promise<any>;
|
|
13
13
|
export declare function canonicalOrigin(input: string, tunnel?: boolean): string;
|
|
14
14
|
export declare function createRequest(origin: string, timeoutMs?: number | (() => number) | undefined, ca?: string, trust?: HostTls): JsonRequest;
|
|
15
15
|
export declare function sessionFetch(url: string, init: RequestInit, session: DsmSession | undefined, ca?: string, trust?: HostTls, timeoutMs?: number): Promise<Response>;
|
package/dist/nas/transport.js
CHANGED
|
@@ -7,7 +7,8 @@ import { nasOptions } from './options.js';
|
|
|
7
7
|
import { readFileSync } from 'node:fs';
|
|
8
8
|
import { CtlError } from '../ctl/errors.js';
|
|
9
9
|
import { dsmRequestTimeoutMs, dsmApiTimeoutMs } from './timeouts.js';
|
|
10
|
-
|
|
10
|
+
import { DEFAULT_OPERATION_TIMEOUT_MS, RESPONSE_RESERVE_MS } from '../runtime/operation-budget.js';
|
|
11
|
+
export const CTL_TIMEOUT_MS = DEFAULT_OPERATION_TIMEOUT_MS + RESPONSE_RESERVE_MS;
|
|
11
12
|
export const APP_COOKIE = Symbol("ctlAppCookie");
|
|
12
13
|
export function canonicalOrigin(input, tunnel = false) {
|
|
13
14
|
let url;
|
|
@@ -22,7 +23,7 @@ export function canonicalOrigin(input, tunnel = false) {
|
|
|
22
23
|
return url.origin;
|
|
23
24
|
}
|
|
24
25
|
export function createRequest(origin, timeoutMs = undefined, ca, trust) {
|
|
25
|
-
return async (path, body, session) => {
|
|
26
|
+
return async (path, body, session, signal) => {
|
|
26
27
|
if (!path.startsWith('/') || path.startsWith('//') || path.includes('?') || path.includes('#') || path.includes('\\') || path.includes('%') || path.split('/').some(p => p === '.' || p === '..'))
|
|
27
28
|
throw new CtlError('CTL_PATH_INVALID', 'Unsafe request path.', 'run: synopkgland ctl list --refresh');
|
|
28
29
|
const params = body instanceof URLSearchParams ? body : undefined;
|
|
@@ -42,7 +43,7 @@ export function createRequest(origin, timeoutMs = undefined, ca, trust) {
|
|
|
42
43
|
headers.cookie = session.cookie;
|
|
43
44
|
headers['X-SYNO-TOKEN'] = session.token;
|
|
44
45
|
}
|
|
45
|
-
const req = nasHttpRequest(url, { method: 'POST', headers }, remaining, trustWithCa(trust, ca), res => {
|
|
46
|
+
const req = nasHttpRequest(url, { method: 'POST', headers, signal }, remaining, trustWithCa(trust, ca), res => {
|
|
46
47
|
if (!res.statusCode || res.statusCode < 200 || res.statusCode >= 300) {
|
|
47
48
|
res.resume();
|
|
48
49
|
reject(new CtlError('CTL_HTTP_ERROR', `HTTP ${res.statusCode}; redirects are never followed.`, 'Check the NAS URL and connection.', 6));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
// Build-time snapshot of the SDK timeout contract, shipped in schema/.
|
|
3
|
+
const budget = JSON.parse(readFileSync(new URL('../../schema/sdk-timeouts.json', import.meta.url), 'utf8'));
|
|
4
|
+
export const DEFAULT_OPERATION_TIMEOUT_MS = budget.request.default_s * 1000;
|
|
5
|
+
export const RESPONSE_RESERVE_MS = budget.browser.margin_ms;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { goPrivateCovers } from './go-env.js';
|
|
2
2
|
import { type ExecutorManifest } from './sdk-executor-manifest.js';
|
|
3
3
|
/** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
|
|
4
|
-
export declare const DEFAULT_SDK_VERSION = "0.
|
|
4
|
+
export declare const DEFAULT_SDK_VERSION = "0.49.5";
|
|
5
5
|
export declare const SDK_PACKAGE = "@synopackageland/sdk";
|
|
6
6
|
export declare const SDK_MODULE = "github.com/synopackageland/syno-pkg-land-sdk";
|
|
7
7
|
export declare const EXECUTOR_MODULE = "github.com/synopackageland/syno-pkg-land-sdk/executor";
|
|
@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os';
|
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { readExecutorManifest, predatesExecutorManifest } from './sdk-executor-manifest.js';
|
|
7
7
|
/** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
|
|
8
|
-
export const DEFAULT_SDK_VERSION = '0.
|
|
8
|
+
export const DEFAULT_SDK_VERSION = '0.49.5';
|
|
9
9
|
export const SDK_PACKAGE = '@synopackageland/sdk';
|
|
10
10
|
export const SDK_MODULE = 'github.com/synopackageland/syno-pkg-land-sdk';
|
|
11
11
|
export const EXECUTOR_MODULE = `${SDK_MODULE}/executor`;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { DEFAULT_OPERATION_TIMEOUT_MS } from './operation-budget.js';
|
|
1
2
|
import { readFileSync } from 'node:fs';
|
|
2
3
|
import { join } from 'node:path';
|
|
3
4
|
import { appSdkVersion, sdkBelowFloor, sdkSource } from './sdk-source.js';
|
|
4
5
|
/** The SDK's timeouts on the call chain to the executor (spec/protocol/v1, Timeouts). */
|
|
5
6
|
export const SDK_TIMEOUTS_FILE = join('spec', 'protocol', 'v1', 'timeouts.json');
|
|
6
7
|
/** What an App without the SDK waits. */
|
|
7
|
-
export const NO_SDK_TIMEOUTS = { requestDefaultSeconds:
|
|
8
|
+
export const NO_SDK_TIMEOUTS = { requestDefaultSeconds: DEFAULT_OPERATION_TIMEOUT_MS / 1000, browserMarginMs: 2000, rootRunDefaultSeconds: DEFAULT_OPERATION_TIMEOUT_MS / 1000, rootRunRequestMarginSeconds: 20 };
|
|
8
9
|
const read = new Map();
|
|
9
10
|
/** The timeouts of the SDK checkout or module at goDir. */
|
|
10
11
|
export function sdkTimeouts(goDir) {
|
package/dist/standalone/build.js
CHANGED
|
@@ -295,7 +295,7 @@ async function buildGoCgi(manifest, backend, arch, work, run) {
|
|
|
295
295
|
env: goChildEnv({ ...process.env, ...goBuildEnv(arch) }),
|
|
296
296
|
});
|
|
297
297
|
if (result.missing) {
|
|
298
|
-
throw new StandaloneBuildError("STANDALONE_GO_MISSING", "The go command was not found. Install Go 1.
|
|
298
|
+
throw new StandaloneBuildError("STANDALONE_GO_MISSING", "The go command was not found. Install Go 1.26.10 (https://go.dev/dl/), or package an existing executable with backend.binary.");
|
|
299
299
|
}
|
|
300
300
|
if (result.status !== 0) {
|
|
301
301
|
const fetchingSdk = result.stderr.includes(`${SDK_MODULE}@`)
|
|
@@ -226,7 +226,9 @@ function readManifest(raw, c) {
|
|
|
226
226
|
.filter(({ setting }) => !setting || setting.run)
|
|
227
227
|
.map(({ op, setting }) => ({
|
|
228
228
|
name: op.name,
|
|
229
|
-
timeoutSeconds: setting?.run?.timeout_s ?? timeouts.rootRunDefaultSeconds
|
|
229
|
+
timeoutSeconds: setting?.run?.timeout_s ?? (timeouts.rootRunDefaultSeconds === timeouts.requestDefaultSeconds
|
|
230
|
+
? Math.min(timeouts.rootRunDefaultSeconds, Math.max(1, requestTimeoutSeconds(backend) - timeouts.rootRunRequestMarginSeconds))
|
|
231
|
+
: timeouts.rootRunDefaultSeconds),
|
|
230
232
|
}));
|
|
231
233
|
const problem = rootRunDeadlineProblem(runnable, requestTimeoutSeconds(backend), timeouts.rootRunRequestMarginSeconds);
|
|
232
234
|
if (problem)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synopackageland/cli",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.2",
|
|
4
4
|
"description": "Syno Package Land Developer Kit CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@napi-rs/keyring": "^2.1.1",
|
|
32
|
-
"@synopackageland/templates": "~0.39.
|
|
32
|
+
"@synopackageland/templates": "~0.39.2",
|
|
33
33
|
"ajv": "^8.17.1",
|
|
34
34
|
"commander": "^13.1.0",
|
|
35
35
|
"json-canonicalize": "^3.0.1",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"$comment": "The App's methods. The App's hello MUST list exactly these. They MUST NOT be SDK methods (api/sdk-permissions.json)."
|
|
26
26
|
},
|
|
27
27
|
"access": { "enum": ["admin-only", "app-privilege"], "$comment": "Entry restriction (dsm.NewEntryGate). Absent: permissions.json alone decides." },
|
|
28
|
-
"timeout_seconds": { "type": "integer", "minimum": 1, "maximum": 3600, "$comment": "Request deadline. Absent: api.DefaultRequestTimeout (
|
|
28
|
+
"timeout_seconds": { "type": "integer", "minimum": 1, "maximum": 3600, "$comment": "Request deadline. Absent: api.DefaultRequestTimeout (300 s). The browser client must wait longer." },
|
|
29
29
|
"max_request_bytes": { "type": "integer", "minimum": 1, "maximum": 16777216, "$comment": "JSON request body limit. Absent: api.MaxRequestBytes." },
|
|
30
30
|
"env": {
|
|
31
31
|
"type": "object",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Timeouts on the call chain to the executor, in seconds unless the name says ms. Each layer waits margin_s longer than the layer it calls, so the inner answer arrives first; README.md, Timeouts.",
|
|
3
|
+
"margin_s": 10,
|
|
4
|
+
"executor": {
|
|
5
|
+
"op_s": 300,
|
|
6
|
+
"webapi_raw_execution_s": 300,
|
|
7
|
+
"webapi_raw_answer_s": 310,
|
|
8
|
+
"root_run_program_default_s": 300,
|
|
9
|
+
"root_run_program_max_s": 3600,
|
|
10
|
+
"root_run_answer_s": 3610,
|
|
11
|
+
"start_step_s": 300
|
|
12
|
+
},
|
|
13
|
+
"client": {
|
|
14
|
+
"op_s": 310,
|
|
15
|
+
"webapi_raw_s": 320,
|
|
16
|
+
"root_run_s": 3620
|
|
17
|
+
},
|
|
18
|
+
"request": {
|
|
19
|
+
"default_s": 300
|
|
20
|
+
},
|
|
21
|
+
"browser": {
|
|
22
|
+
"margin_ms": 2000
|
|
23
|
+
}
|
|
24
|
+
}
|
package/skills/SKILL.md
CHANGED
|
@@ -5,7 +5,7 @@ description: Initialize, extend, check, build, inspect, and deploy Synology appl
|
|
|
5
5
|
|
|
6
6
|
# Independent Synology SPKs
|
|
7
7
|
|
|
8
|
-
The CLI installs templates through `~0.39.
|
|
8
|
+
The CLI installs templates through `~0.39.2`. A templates patch needs only a
|
|
9
9
|
templates release; npm install/update selects a patch in that minor line. The CLI
|
|
10
10
|
uses the locally installed templates and reads their SDK pin for defaults; it
|
|
11
11
|
never downloads templates at runtime. Preserve the lockfile and use `npm ci` for
|
|
@@ -14,7 +14,7 @@ the CLI: executor manifest format 1 in the resolved SDK pins the executor releas
|
|
|
14
14
|
Go toolchain and six payload digests. Preserve npm integrity and Go module sums.
|
|
15
15
|
The CLI verifies bytes before packaging and never fetches a manifest at NAS runtime.
|
|
16
16
|
Unsupported formats require a CLI update; invalid manifests fail closed.
|
|
17
|
-
Current scaffolds pin SDK/App 0.47.
|
|
17
|
+
Current scaffolds pin SDK/App 0.47.1 and declare operations in one v2 registry.
|
|
18
18
|
|
|
19
19
|
For Apps with data folders or gateway listeners, read [reference/install.md](reference/install.md). Default to an App-named dedicated DSM data share and installer-selected ports. Existing-folder access, port number format/range and required HTTPS origins use localized wizard validation before Next; detected port conflicts are nonblocking inline warnings, and an unavailable DSM port inventory does not block installation; upgrades retain port selections.
|
|
20
20
|
|
|
@@ -53,7 +53,7 @@ progress and authorized status/result polling by the original ID. A timed-out
|
|
|
53
53
|
status read does not fail a queued/running job; reuse the same key/input after
|
|
54
54
|
a lost admission reply. Read [reference/create.md](reference/create.md) for
|
|
55
55
|
the deadline and background-job contract. The independent ctl transport keeps
|
|
56
|
-
|
|
56
|
+
the shared SDK operation default; use existing jobs for long work and poll until terminal state or cancellation.
|
|
57
57
|
|
|
58
58
|
Use `ipc.StartUnix(ctx, path, handler)` for multiple private data-plane sockets.
|
|
59
59
|
Each direct `.sock` child of the package `var/run` gets an independent handle
|
|
@@ -26,7 +26,7 @@ compose:
|
|
|
26
26
|
network: {egress: isolated}
|
|
27
27
|
# Private package binds are rejected by DSM build; keep compatible upstream named volumes.
|
|
28
28
|
identity_gateway:
|
|
29
|
-
sdk: 0.47.
|
|
29
|
+
sdk: 0.47.1
|
|
30
30
|
mode: none
|
|
31
31
|
access: dsm-users
|
|
32
32
|
listen: {http: 28000}
|
|
@@ -39,7 +39,7 @@ architecture-specific native payloads for token/account adapters. All lifecycle
|
|
|
39
39
|
scripts run as the package account; containers are managed by Container Manager.
|
|
40
40
|
|
|
41
41
|
For external access, pin both `compose.sdk` and `identity_gateway.sdk` to
|
|
42
|
-
0.47.
|
|
42
|
+
0.47.1 and use the gateway's
|
|
43
43
|
[`external_access` policy and DSM settings entry](identity-gateway.md#external-access).
|
|
44
44
|
Declare required HTTPS origins through `install.settings`; wizard validation checks the selected HTTPS port before Next. See [install.md](install.md).
|
|
45
45
|
Manual URL configuration does not require Connect. The SDK resolves the public
|
|
@@ -260,7 +260,7 @@ declared availability readiness, LAN isolation/egress, protected grant lifecycle
|
|
|
260
260
|
ACLs, two-user visibility and clean install/upgrade/reboot/stop/uninstall before
|
|
261
261
|
calling the package supported on a NAS. No NAS is accessed by the build gate.
|
|
262
262
|
|
|
263
|
-
The unified Compose contract uses SDK defaults from locally installed templates `~0.39.
|
|
263
|
+
The unified Compose contract uses SDK defaults from locally installed templates `~0.39.2` with CLI 0.48.1. Templates patches can ship independently; npm install/update resolves them, and SDK defaults come from the installed templates. SDK minor upgrades do not require a CLI release when they declare supported executor manifest format 1; the resolved SDK owns the release mapping and verified payload digests. The CLI does not fetch templates at runtime. The legacy packaging route and bridge publish mode are removed.
|
|
264
264
|
|
|
265
265
|
Primary override files, and each included override set, must share a directory. Cross-directory override bases are rejected before loader I/O. Included implicit .env files are confined, inventoried and preserved; symlinks are rejected.
|
|
266
266
|
|
|
@@ -46,8 +46,8 @@ rootOps 與 delegate 已共用管理員 PasswordConfirm 核准的 protected exec
|
|
|
46
46
|
backend 寫 `runtime: python|node|rust`(`runtime: go` 等同 `kind: go`)。CGI 是 SDK 的 Go runtime(`bridge/cmd/runtime`),它驗證 DSM session、entry 與 `permissions.json` 後,以套件帳號(不是 root)每個請求啟動一次 App。App 放在 ui 以外的目錄,打包成 `target/app/`,build 寫入 `bridge.json`(spec/bridge/v1)並把它與 `permissions.json` 的 sha256 編進 runtime。
|
|
47
47
|
|
|
48
48
|
```yaml
|
|
49
|
-
backend: {runtime: python, dir: app, entry: main.py, sdk: 0.47.
|
|
50
|
-
backend: {runtime: node, dir: app, entry: main.mjs, sdk: 0.47.
|
|
49
|
+
backend: {runtime: python, dir: app, entry: main.py, sdk: 0.47.1}
|
|
50
|
+
backend: {runtime: node, dir: app, entry: main.mjs, sdk: 0.47.1, node: {package: Node.js_v22}}
|
|
51
51
|
backend: {runtime: rust, dir: app, entry: hello, methods: [hello.greet]}
|
|
52
52
|
```
|
|
53
53
|
|
|
@@ -93,7 +93,7 @@ func deadline() api.DeadlineOption {
|
|
|
93
93
|
|
|
94
94
|
直接 File Station 瀏覽器讀取預設也為 302 秒;identity gateway 等候 upstream headers 預設 310 秒,自訂期限需對齊 gateway 與外部 proxy。這些預設不保證所有 DSM/proxy 都能完成五分鐘請求。executor batch 的 60 秒上限、已核准 root policy/program budget 與 credential lifetime 維持原契約;長 root 工作使用既有 `root.start` / `root.jobs.*`。
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
`ctl` transport 採 SDK 共用的五分鐘操作預算與回覆保留時間;job flow 不以累計時間中止存活工作。長工作必須映射既有 job flow,不以延長同步等待取代非同步 API;參考 [ctl](ctl.md)。完整契約見 SDK 的 [request deadlines](https://github.com/synopackageland/syno-pkg-land-sdk/blob/v0.47.1/docs/request-deadlines.md)。
|
|
97
97
|
|
|
98
98
|
DSM 視窗預設 960×640、最小 700×420;`ui.window` 只寫要改的欄位:
|
|
99
99
|
|
package/skills/reference/ctl.md
CHANGED
|
@@ -152,7 +152,7 @@ direction, including hidden routes. The only infrastructure exceptions are the
|
|
|
152
152
|
fixed describe and identity ceremony methods. SDK capability metadata comes from
|
|
153
153
|
the SDK's own hidden catalog and can be explicitly overridden in the App spec.
|
|
154
154
|
Never hand-edit generated operation descriptions or add them to a skill manually.
|
|
155
|
-
Current scaffolds use SDK 0.47.
|
|
155
|
+
Current scaffolds use SDK 0.47.1, templates 0.39.2 and CLI 0.48.1.
|
|
156
156
|
|
|
157
157
|
For installed Apps, use `ctl tools <app> --host <profile>` and
|
|
158
158
|
`ctl tool <app> <method> --input <file|-> --host <profile>`. These require the
|
|
@@ -208,16 +208,17 @@ list, get, result, cancel, pause and resume capabilities. Only declare capabilit
|
|
|
208
208
|
that the selected SDK and enabled backend actually provide. Never fabricate ETA,
|
|
209
209
|
cancellation, deduplication or "return existing ID" behavior.
|
|
210
210
|
|
|
211
|
-
The
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
211
|
+
The ctl transport uses the shared five-minute SDK operation default plus response
|
|
212
|
+
reserve. Job flow `timeoutMs` is optional and sets a per-request allowance. Keep
|
|
213
|
+
polling while the App reports a live job; elapsed time never fails it. Cancellation
|
|
214
|
+
ends the local wait. Preserve the original ID after a failed status read or lost
|
|
215
|
+
admission reply, and never repeat a dispatched mutation merely because it was slow.
|
|
216
|
+
|
|
216
217
|
|
|
217
218
|
For AI tools, a draft always returns a non-mutating preview and plan. Obtain
|
|
218
219
|
human authorization before the normal ctl command executes with --yes. Report
|
|
219
220
|
acceptance separately from completion; preparation is not download or save
|
|
220
|
-
completion. If
|
|
221
|
+
completion. If a status request times out, return the original ID and the exact
|
|
221
222
|
existing status command. A timeout does not prove failure or cancellation.
|
|
222
223
|
Cancellation also requires its declared preview/confirmation policy and readback
|
|
223
224
|
until the existing API proves that work stopped.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Upstream-authenticated paths
|
|
4
4
|
|
|
5
|
-
Build with SDK 0.47.
|
|
5
|
+
Build with SDK 0.47.1 and CLI 0.48.1. Use `upstream_auth_paths` for client API
|
|
6
6
|
paths that use upstream authentication.
|
|
7
7
|
|
|
8
8
|
Keep browser routes behind `entry: admin-only` or `entry: app-privilege`; list
|
|
@@ -22,12 +22,12 @@ See `docs/app-entry.md` for the complete contract.
|
|
|
22
22
|
|
|
23
23
|
## External access
|
|
24
24
|
|
|
25
|
-
Use SDK 0.47.
|
|
25
|
+
Use SDK 0.47.1 with matching gateway sources. Add this to the existing
|
|
26
26
|
complete gateway declaration; keep the App's upstream, listener and auth policy:
|
|
27
27
|
|
|
28
28
|
```yaml
|
|
29
29
|
identity_gateway:
|
|
30
|
-
sdk: 0.47.
|
|
30
|
+
sdk: 0.47.1
|
|
31
31
|
external_access:
|
|
32
32
|
connect: optional # optional | none
|
|
33
33
|
origin_change: none # none | confirm
|
|
@@ -191,7 +191,7 @@ For user-controlled mobile API or WebDAV access, declare fixed prefixes:
|
|
|
191
191
|
```yaml
|
|
192
192
|
identity_gateway:
|
|
193
193
|
# Add to the existing complete identity_gateway declaration.
|
|
194
|
-
sdk: 0.47.
|
|
194
|
+
sdk: 0.47.1
|
|
195
195
|
optional_passthrough:
|
|
196
196
|
mobile:
|
|
197
197
|
prefixes: [/dav, /api/mobile]
|
|
@@ -231,7 +231,7 @@ An upstream with its own OIDC login can opt into a generic browser bridge:
|
|
|
231
231
|
install:
|
|
232
232
|
ports: true
|
|
233
233
|
identity_gateway:
|
|
234
|
-
sdk: 0.47.
|
|
234
|
+
sdk: 0.47.1
|
|
235
235
|
mode: oidc
|
|
236
236
|
access: dsm-admins
|
|
237
237
|
upstream: 8000
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Native installation settings
|
|
2
2
|
|
|
3
|
-
Use CLI 0.48.
|
|
3
|
+
Use CLI 0.48.1 with SDK/App 0.47.1 and templates ~0.39.2. Configure installation through the manifest and generated wizard; do not add App ACL writers, root hooks or independent port state.
|
|
4
4
|
|
|
5
5
|
```yaml
|
|
6
6
|
install:
|
|
@@ -11,7 +11,7 @@ install:
|
|
|
11
11
|
name: MyApp
|
|
12
12
|
permission: rw
|
|
13
13
|
identity_gateway:
|
|
14
|
-
sdk: 0.47.
|
|
14
|
+
sdk: 0.47.1
|
|
15
15
|
listen: {https: 28443}
|
|
16
16
|
```
|
|
17
17
|
|