@synopackageland/cli 0.48.9 → 0.48.11

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/dist/ctl/cli.d.ts CHANGED
@@ -19,6 +19,7 @@ export declare function listView(host: string, apps: Descriptor[]): {
19
19
  }[];
20
20
  examples: string[];
21
21
  summary: string;
22
+ kind?: "rpc" | "ai" | "stream";
22
23
  ai?: import("./registry.js").AIClass;
23
24
  preview?: string;
24
25
  longRunning?: boolean;
@@ -3,6 +3,7 @@ export declare const DESCRIPTION_METHOD = "synopkgland.describe";
3
3
  export declare const DESCRIPTION_FILE = "synopkgland-api.json";
4
4
  export type Operation = {
5
5
  summary: string;
6
+ kind?: 'rpc' | 'ai' | 'stream';
6
7
  ai?: import('./registry.js').AIClass;
7
8
  preview?: string;
8
9
  longRunning?: boolean;
@@ -44,4 +44,18 @@ export declare function registryTools(registry: OperationRegistry): {
44
44
  }[];
45
45
  export declare function registryReference(registry: OperationRegistry): string;
46
46
  export declare function writeGenerated(path: string, contents: string, check: boolean): void;
47
- export declare function registryArtifacts(root: string, registry: OperationRegistry, check: boolean): void;
47
+ /** Execution kind comes from trusted metadata, never a method name. AI exposure
48
+ * classes describe tool visibility, not model execution. Unknown stays closed. */
49
+ export declare function registrySessionRetry(registry: OperationRegistry, routes: readonly {
50
+ method: string;
51
+ kind?: string;
52
+ }[]): {
53
+ [k: string]: {
54
+ effect: "read" | "write" | "destructive";
55
+ kind: "rpc" | "ai" | "stream" | "unknown";
56
+ };
57
+ };
58
+ export declare function registryArtifacts(root: string, registry: OperationRegistry, check: boolean, routes?: readonly {
59
+ method: string;
60
+ kind?: string;
61
+ }[]): void;
@@ -28,6 +28,8 @@ export function validateRegistry(value) {
28
28
  fail(`${name}: explicit ai class and English summary are required.`);
29
29
  if (!['read', 'write', 'destructive'].includes(op.effect) || !['public', 'authenticated', 'administrators', 'integration'].includes(op.permission))
30
30
  fail(`${name}: effect and permission are required.`);
31
+ if (op.kind !== undefined && !['rpc', 'ai', 'stream'].includes(op.kind))
32
+ fail(`${name}: invalid kind.`);
31
33
  if (!Array.isArray(op.cli) || !op.cli.length || op.cli.length > 8 || op.cli.some(p => typeof p !== 'string' || !/^[a-z][a-z0-9-]{0,63}$/.test(p)))
32
34
  fail(`${name}: invalid cli path.`);
33
35
  if (op.ai !== 'hidden') {
@@ -112,8 +114,25 @@ export function writeGenerated(path, contents, check) {
112
114
  writeFileSync(path, contents);
113
115
  }
114
116
  }
115
- export function registryArtifacts(root, registry, check) {
117
+ /** Execution kind comes from trusted metadata, never a method name. AI exposure
118
+ * classes describe tool visibility, not model execution. Unknown stays closed. */
119
+ export function registrySessionRetry(registry, routes) {
120
+ const kinds = new Map(routes.map(route => [route.method, route.kind]));
121
+ return Object.fromEntries(Object.entries(registry.operations).sort(([a], [b]) => a.localeCompare(b)).map(([name, op]) => {
122
+ const routeKind = kinds.get(name);
123
+ let kind = 'unknown';
124
+ if (op.kind === 'ai' || routeKind === 'ai')
125
+ kind = 'ai';
126
+ else if (op.kind === 'stream' || ['ndjson', 'upload'].includes(op.flow.type) || ['transfer', 'stream', 'download', 'export'].includes(routeKind ?? ''))
127
+ kind = 'stream';
128
+ else if (routeKind === 'json' || routeKind === 'rpc' || routeKind === undefined && op.kind === 'rpc')
129
+ kind = 'rpc';
130
+ return [name, { effect: op.effect, kind }];
131
+ }));
132
+ }
133
+ export function registryArtifacts(root, registry, check, routes = []) {
116
134
  writeGenerated(join(root, 'generated', 'tools.json'), JSON.stringify({ tools: registryTools(registry) }, null, 2) + '\n', check);
117
135
  writeGenerated(join(root, 'generated', 'operations.md'), registryReference(registry), check);
118
136
  writeGenerated(join(root, 'generated', 'routes.json'), JSON.stringify(Object.fromEntries(Object.entries(registry.operations).sort(([a], [b]) => a.localeCompare(b)).map(([name, op]) => [name, { permission: op.permission, effect: op.effect }])), null, 2) + '\n', check);
137
+ writeGenerated(join(root, 'generated', 'session-retry.ts'), '// Generated by synopkgland ctl generate; edit the operation registry.\nexport const sessionRetryOperations = ' + JSON.stringify(registrySessionRetry(registry, routes), null, 2) + ' as const;\n', check);
119
138
  }
@@ -46,7 +46,7 @@ import { renderNativePrivilege } from "../build-spk/native-lifecycle.js";
46
46
  import { renderUiConfig } from "./dsm-window.js";
47
47
  import { identityGatewayConfig, gatewayCgiPaths, GATEWAY_SETTINGS_CGI_PATH, gatewayAdmissionReport, gatewayAdmissionPolicy, readIdentityGateway, } from "./identity-gateway.js";
48
48
  import { checkCgiBinary } from "./binary.js";
49
- import { matchesStandaloneScript, renderStandaloneScript, matchesStandaloneScriptPrefix } from "./lifecycle.js";
49
+ import { matchesStandaloneScript, matchesStandaloneScriptPrefix } from "./lifecycle.js";
50
50
  import { listPortExposures, loadCompose } from "../compose/analyze.js";
51
51
  import { uninstallCleanup, } from "../runtime/uninstall-cleanup.js";
52
52
  import { PORTAL_JSON_RELPATH, PORTAL_MUSTACHE_RELPATH, renderPortalJson, renderPortalLifecycle, renderPortalMustache, renderPortalWizardStep, } from "../portal/package.js";
@@ -310,8 +310,7 @@ export async function inspectSpk(spkPath, expectedKind) {
310
310
  ...(uninstallHook ? { uninstall: uninstallHook.uninstall } : {}),
311
311
  };
312
312
  for (const hook of ["preuninst", "preupgrade", "start-stop-status"]) {
313
- if (readOptional(join(dir, "scripts", hook)) !==
314
- renderStandaloneScript(hook, lifecycleManifest))
313
+ if (!matchesStandaloneScript(hook, lifecycleManifest, readOptional(join(dir, "scripts", hook))))
315
314
  findings.push(`Executor scripts/${hook} differs from fixed lifecycle.`);
316
315
  }
317
316
  }
@@ -45,6 +45,13 @@ function standaloneScriptVariants(name, manifest, expected) {
45
45
  const wait = renderNativeGatewayPortWait(manifest, name);
46
46
  const diagnosticOnly = wait ? expected.replace(wait, '') : expected;
47
47
  const variants = [expected, ...(wait ? [diagnosticOnly] : []), ...(diagnostic ? [diagnosticOnly.replace(diagnostic, '')] : [])];
48
+ // One released renderer added daemon bookkeeping even without a daemon.
49
+ // Replay that exact variant, retaining the complete lifecycle comparison.
50
+ if (name === 'start-stop-status' && !manifest.daemon &&
51
+ (manifest.capabilities?.rootOps || manifest.capabilities?.delegate || manifest.capabilities?.webapi)) {
52
+ const stop = `"\${SYNOPKG_PKGDEST:-/var/packages/${manifest.package}/target}/executor/lifecycle" stop --package ${manifest.package} || exit $?\n`;
53
+ variants.push(...variants.map(v => v.replace('if [ "$1" = stop ]; then\n', 'if [ "$1" = stop ]; then\ndaemon_result=0\n').replace(stop, stop + '[ "$daemon_result" = 0 ] || exit "$daemon_result"\n')));
54
+ }
48
55
  // Released packages stop the daemon in preupgrade without the first-daemon guard.
49
56
  const unguarded = (v) => v.replace(daemonGuard(manifest.package), '').replace(delegatedDaemonGuard(manifest.package), '');
50
57
  return name === 'preupgrade' ? [...new Set([...variants, ...variants.map(unguarded)])] : variants;
@@ -162,7 +169,7 @@ function renderStandaloneScriptBody(name, manifest) {
162
169
  const stopDaemon = manifest.daemon
163
170
  ? `"/var/packages/${manifest.package}/target/daemon/control" stop "\${SYNOPKG_PKGDEST:-/var/packages/${manifest.package}/target}" "\${SYNOPKG_PKGVAR:-/var/packages/${manifest.package}/var}" || daemon_result=$?\n`
164
171
  : "";
165
- return normal.replace("#!/bin/sh\n", `#!/bin/sh\n${workerStop}if [ "$1" = start ]; then\n${request("start")}fi\nif [ "$1" = stop ]; then\n${stopWorker}daemon_result=0\n${stopDaemon}${request("stop")}[ "$daemon_result" = 0 ] || exit "$daemon_result"\n${workerResult}fi\n`);
172
+ return normal.replace("#!/bin/sh\n", `#!/bin/sh\n${workerStop}if [ "$1" = start ]; then\n${request("start")}fi\nif [ "$1" = stop ]; then\n${stopWorker}${manifest.daemon ? 'daemon_result=0\n' : ''}${stopDaemon}${request("stop")}${manifest.daemon ? '[ "$daemon_result" = 0 ] || exit "$daemon_result"\n' : ''}${workerResult}fi\n`);
166
173
  }
167
174
  if (name === "preuninst")
168
175
  return renderExecutorPreuninst(manifest, workerStop, stopWorker, workerResult, request);
@@ -76,7 +76,7 @@ export async function generateOperations(m, run, check = false, bridgeMethods) {
76
76
  if (m.entry === 'admin-only' && Object.values(registry.operations).some(op => op.permission !== 'administrators' && op.permission !== 'integration'))
77
77
  throw Error('CTL_ROUTE_MISMATCH: administrator entry requires administrator operation permissions.');
78
78
  const description = registryDescriptor(m, registry);
79
- registryArtifacts(m.root, registry, check);
79
+ registryArtifacts(m.root, registry, check, routes);
80
80
  writeGenerated(join(m.root, 'generated', 'synopkgland-api.json'), JSON.stringify(description, null, 2) + '\n', check);
81
81
  writeGenerated(join(m.root, 'generated', 'ctl.json'), JSON.stringify({ commands: description.payload.commands }, null, 2) + '\n', check);
82
82
  return { description, registry: { ...Object.fromEntries(routes.map(r => [r.method, r.permission])), ...(m.capabilities.identity ? { 'identity.session': 'public', 'identity.logout': 'public' } : {}) } };
@@ -13,7 +13,9 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
13
13
  if (e && e.passwordConfirm) return code + (code === "dsm_3121" ? ": DSM rejected the administrator password." : ": administrator password confirmation failed.") + " Nothing was created.";
14
14
  if (e && e.detail) return code + ": " + e.detail;
15
15
  if (["dsm_106","dsm_107","dsm_119"].indexOf(code) >= 0) return code + ": the DSM session ended. Sign in to DSM again, then approve again.";
16
- return code + (code === "105" || code === "dsm_105" ? ": DSM denied administrator scheduler access. Check the DSM session and scheduler; a NAS restart resolved this on the measured DSM. No automatic retry was made." : ": scheduler readback or operation failed.");
16
+ var step = e && e.operation;
17
+ var at = step ? " [" + step.api + "/" + step.method + " v" + step.version + "]" : "";
18
+ return code + (code === "105" || code === "dsm_105" ? ": DSM denied administrator scheduler access. Sign out of DSM, sign in again from the DSM desktop, then check status before approving again. If access is still denied, contact your administrator. No automatic retry was made." : ": scheduler readback or operation failed.") + at;
17
19
  }
18
20
  // What a result's code says, for the window panel and the SDK to translate;
19
21
  // reason keeps the English detail. fallback names a step's own failure.
@@ -27,17 +29,31 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
27
29
  if (code === "executor_starting") return code;
28
30
  if (e && e.detail) return /other digests/.test(e.detail) ? "executor_mismatch" : "executor_unreachable";
29
31
  if (code.indexOf("executor_selection") === 0) return "selection_failed";
30
- if (fallback) return fallback;
31
32
  if (code === "105" || code === "dsm_105") return "scheduler_denied";
33
+ if (fallback) return fallback;
32
34
  if (["102","103","104","dsm_102","dsm_103","dsm_104"].indexOf(code) >= 0) return "scheduler_unsupported";
33
35
  return "scheduler_failed";
34
36
  }
35
- function block(result, e, fallback) { result.state = "blocked"; result.reason = reason(e); result.code = codeOf(e, fallback); return result; }
37
+ function block(result, e, fallback) {
38
+ result.state = "blocked"; result.reason = reason(e); result.code = codeOf(e, fallback);
39
+ if (e && e.diagnostic) result.diagnostic = e.diagnostic;
40
+ return result;
41
+ }
36
42
  // A find result that stops an approval, with its code.
37
- function refused(current) { var e = fail(current.reason); e.task = current.code; return e; }
43
+ function refused(current) { var e = fail(current.reason); e.task = current.code; e.diagnostic = current.diagnostic; return e; }
38
44
  // AppWindow.sendWebAPI encodes JSON parameters. Preserve their native types;
39
45
  // pre-encoding turns objects/booleans into strings and DSM rejects create.
40
- function send(api, method, version, params) { return options.send(api, method, version, params || {}); }
46
+ function send(api, method, version, params) {
47
+ return options.send(api, method, version, params || {}).catch(function (error) {
48
+ // Identify the refused native operation without carrying request parameters,
49
+ // credentials, a password token or a raw DSM response into diagnostics.
50
+ var e = fail(error && error.code || "executor_bad_response");
51
+ e.operation = {api: api, method: method, version: version};
52
+ var match = /^(?:dsm_)?([0-9]+)$/.exec(String(e.code));
53
+ if (match) e.diagnostic = {api: api, method: method, version: version, dsm_code: Number(match[1])};
54
+ throw e;
55
+ });
56
+ }
41
57
  // DSM 7.1 has no Root APIs: TaskScheduler stops at list v2 (offset) and get v3.
42
58
  // Only an unsupported method version on a read selects that profile, which
43
59
  // then creates through the plain scheduler APIs. Writes never fall back.
@@ -105,7 +121,11 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
105
121
  delete listed[task.name];
106
122
  return find(task, false);
107
123
  });
108
- }).catch(function (e) { return {state: ["102","103","104","dsm_102","dsm_103","dsm_104"].indexOf(String(e && e.code)) >= 0 ? "unsupported" : "blocked", reason: reason(e), code: codeOf(e)}; });
124
+ }).catch(function (e) {
125
+ var result = block({}, e);
126
+ if (["102","103","104","dsm_102","dsm_103","dsm_104"].indexOf(String(e && e.code)) >= 0) result.state = "unsupported";
127
+ return result;
128
+ });
109
129
  }
110
130
  function read(cached) {
111
131
  try { admin(); } catch (e) { return Promise.resolve(block({tasks: {}}, e)); }
@@ -113,7 +133,7 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
113
133
  var result = {state: "ready", tasks: {}};
114
134
  options.tasks.forEach(function (t, i) {
115
135
  result.tasks[t.kind] = found[i];
116
- if (found[i].state === "blocked" || (found[i].state !== "ready" && result.state === "ready")) { result.state = found[i].state; result.reason = found[i].reason; result.code = found[i].code; }
136
+ if (found[i].state === "blocked" || (found[i].state !== "ready" && result.state === "ready")) { result.state = found[i].state; result.reason = found[i].reason; result.code = found[i].code; result.diagnostic = found[i].diagnostic; }
117
137
  });
118
138
  return result;
119
139
  });
@@ -124,7 +144,10 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
124
144
  var failed;
125
145
  return created.reduceRight(function (withdrawn, task) {
126
146
  return withdrawn.then(function () { return find(task); }).then(function (current) {
127
- if (current.state === "ready") return remove(task, current.ref);
147
+ if (current.state === "ready") return remove(task, current.ref).then(function () { return find(task); }).then(function (after) {
148
+ if (after.state !== "needs-admin-approval" || after.ref) throw refused(after);
149
+ });
150
+ if (current.state !== "needs-admin-approval" || current.ref) throw refused(current);
128
151
  }).catch(function (e) { failed = reason(e); });
129
152
  }, Promise.resolve()).then(function () { return failed; });
130
153
  }
@@ -135,7 +158,11 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
135
158
  return removed.reduceRight(function (restored, earlier) {
136
159
  return restored.then(function () { return find(earlier); }).then(function (current) {
137
160
  if (current.state === "blocked") throw refused(current);
138
- if (!current.ref) return create(earlier.kind === "boot", definition(earlier), confirmation);
161
+ if (current.state === "ready") return;
162
+ if (current.ref) throw refused(current);
163
+ return create(earlier.kind === "boot", definition(earlier), confirmation).then(function () { return find(earlier); }).then(function (restored) {
164
+ if (restored.state !== "ready") throw refused(restored);
165
+ });
139
166
  }).catch(function (e) { failed = reason(e); });
140
167
  }, Promise.resolve()).then(function () { return failed; });
141
168
  });
@@ -407,7 +434,7 @@ export const ROOT_PANEL_MESSAGES = {
407
434
  "reason.password_confirm_failed": { en: "DSM could not confirm the administrator password. Nothing was changed.", "zh-TW": "DSM 無法確認管理員密碼,沒有做任何變更。", "zh-CN": "DSM 无法确认管理员密码,没有做任何更改。", ja: "DSM で管理者パスワードを確認できませんでした。何も変更されていません。", ko: "DSM에서 관리자 비밀번호를 확인할 수 없습니다. 변경된 내용은 없습니다.", de: "DSM konnte das Administratorkennwort nicht bestätigen. Es wurde nichts geändert.", fr: "DSM n'a pas pu confirmer le mot de passe administrateur. Rien n'a été modifié.", es: "DSM no pudo confirmar la contraseña de administrador. No se ha cambiado nada.", it: "DSM non ha potuto confermare la password amministratore. Non è stato modificato nulla." },
408
435
  "reason.session_ended": { en: "The DSM session ended. Sign in to DSM again, then approve again.", "zh-TW": "DSM 工作階段已結束。請重新登入 DSM 後再核准一次。", "zh-CN": "DSM 会话已结束。请重新登录 DSM 后再批准一次。", ja: "DSM セッションが終了しました。DSM に再度サインインしてから、もう一度承認してください。", ko: "DSM 세션이 종료되었습니다. DSM에 다시 로그인한 후 다시 승인하십시오.", de: "Die DSM-Sitzung ist abgelaufen. Melden Sie sich erneut bei DSM an und genehmigen Sie dann erneut.", fr: "La session DSM a expiré. Reconnectez-vous à DSM, puis approuvez de nouveau.", es: "La sesión de DSM ha finalizado. Vuelva a iniciar sesión en DSM y apruebe de nuevo.", it: "La sessione DSM è terminata. Accedere di nuovo a DSM, quindi approvare di nuovo." },
409
436
  "reason.admin_required": { en: "Only a DSM administrator can approve.", "zh-TW": "只有 DSM 管理員可以核准。", "zh-CN": "只有 DSM 管理员可以批准。", ja: "承認できるのは DSM 管理者のみです。", ko: "DSM 관리자만 승인할 수 있습니다.", de: "Nur ein DSM-Administrator kann genehmigen.", fr: "Seul un administrateur DSM peut approuver.", es: "Solo un administrador de DSM puede aprobar.", it: "Solo un amministratore DSM può approvare." },
410
- "reason.scheduler_denied": { en: "DSM denied the administrator access to Task Scheduler. Check the DSM session; restarting the NAS resolved this before.", "zh-TW": "DSM 拒絕了管理員對任務排程表的存取。請檢查 DSM 工作階段;先前重新啟動 NAS 可解決此問題。", "zh-CN": "DSM 拒绝了管理员对任务计划的访问。请检查 DSM 会话;之前重新启动 NAS 可解决此问题。", ja: "DSM が管理者のタスクスケジューラへのアクセスを拒否しました。DSM セッションを確認してください。以前は NAS の再起動で解決しました。", ko: "DSM에서 관리자의 작업 스케줄러 액세스를 거부했습니다. DSM 세션을 확인하십시오. 이전에는 NAS를 다시 시작하여 해결되었습니다.", de: "DSM hat dem Administrator den Zugriff auf den Aufgabenplaner verweigert. Prüfen Sie die DSM-Sitzung; ein Neustart des NAS hat dies bisher behoben.", fr: "DSM a refusé à l'administrateur l'accès au Planificateur de tâches. Vérifiez la session DSM ; un redémarrage du NAS a déjà résolu ce problème.", es: "DSM denegó al administrador el acceso al Programador de tareas. Compruebe la sesión de DSM; reiniciar el NAS lo resolvió anteriormente.", it: "DSM ha negato all'amministratore l'accesso a Utilità di pianificazione. Controllare la sessione DSM; in passato il riavvio del NAS ha risolto il problema." },
437
+ "reason.scheduler_denied": { "en": "DSM denied Task Scheduler access. Sign out of DSM, sign in again from the DSM desktop, then select Check status. If access is still denied, contact your administrator", "zh-TW": "DSM 拒絕了管理員對任務排程表的存取。請登出 DSM,重新登入 DSM 桌面後按「檢查狀態」。若仍被拒絕,請聯絡管理員", "zh-CN": "DSM 拒绝访问任务计划。请退出 DSM,重新登录 DSM 桌面后点击“检查状态”。若仍被拒绝,请联系管理员", "ja": "DSM がタスクスケジューラへのアクセスを拒否しました。DSM からサインアウトし、DSM デスクトップに再度サインインしてから「状態を確認」を選択してください。拒否が続く場合は管理者にお問い合わせください", "ko": "DSM에서 작업 스케줄러 액세스를 거부했습니다. DSM에서 로그아웃하고 DSM 데스크톱에 다시 로그인한 후 상태 확인을 선택하십시오. 계속 거부되면 관리자에게 문의하십시오", "de": "DSM hat den Zugriff auf den Aufgabenplaner verweigert. Melden Sie sich von DSM ab und am DSM-Desktop erneut an. Wählen Sie dann „Status prüfen“. Wird der Zugriff weiterhin verweigert, wenden Sie sich an Ihren Administrator", "fr": "DSM a refusé l’accès au Planificateur de tâches. Déconnectez-vous de DSM, reconnectez-vous au bureau DSM, puis sélectionnez Vérifier l’état. Si l’accès est toujours refusé, contactez votre administrateur", "es": "DSM denegó el acceso al Programador de tareas. Cierre sesión en DSM, vuelva a entrar desde el escritorio de DSM y seleccione Comprobar estado. Si se sigue denegando el acceso, contacte con su administrador", "it": "DSM ha negato l’accesso a Utilità di pianificazione. Esci da DSM, accedi nuovamente dal desktop DSM e seleziona Verifica stato. Se l’accesso viene ancora negato, contatta l’amministratore" },
411
438
  "reason.scheduler_failed": { en: "Reading or changing the scheduled tasks failed.", "zh-TW": "讀取或變更排程任務失敗。", "zh-CN": "读取或更改计划任务失败。", ja: "スケジュール済みタスクの読み取りまたは変更に失敗しました。", ko: "예약된 작업을 읽거나 변경하지 못했습니다.", de: "Die geplanten Aufgaben konnten nicht gelesen oder geändert werden.", fr: "La lecture ou la modification des tâches planifiées a échoué.", es: "No se pudieron leer ni cambiar las tareas programadas.", it: "Impossibile leggere o modificare le attività pianificate." },
412
439
  "reason.scheduler_unsupported": { en: "This DSM's Task Scheduler does not offer what background access needs.", "zh-TW": "這台 DSM 的任務排程表不提供背景存取所需的功能。", "zh-CN": "此 DSM 的任务计划不提供后台访问所需的功能。", ja: "この DSM のタスクスケジューラには、バックグラウンドアクセスに必要な機能がありません。", ko: "이 DSM의 작업 스케줄러는 백그라운드 액세스에 필요한 기능을 제공하지 않습니다.", de: "Der Aufgabenplaner dieses DSM bietet nicht, was der Hintergrundzugriff benötigt.", fr: "Le Planificateur de tâches de ce DSM n'offre pas ce dont l'accès en arrière-plan a besoin.", es: "El Programador de tareas de este DSM no ofrece lo que necesita el acceso en segundo plano.", it: "L'Utilità di pianificazione di questo DSM non offre quanto necessario all'accesso in background." },
413
440
  "reason.task_missing": { en: "The approved tasks are not in Task Scheduler.", "zh-TW": "任務排程表中沒有已核准的任務。", "zh-CN": "任务计划中没有已批准的任务。", ja: "承認済みのタスクがタスクスケジューラにありません。", ko: "승인된 작업이 작업 스케줄러에 없습니다.", de: "Die genehmigten Aufgaben fehlen im Aufgabenplaner.", fr: "Les tâches approuvées ne figurent pas dans le Planificateur de tâches.", es: "Las tareas aprobadas no están en el Programador de tareas.", it: "Le attività approvate non sono presenti in Utilità di pianificazione." },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.48.9",
3
+ "version": "0.48.11",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -208,6 +208,9 @@
208
208
  "minLength": 1,
209
209
  "maxLength": 1024
210
210
  },
211
+ "kind": {
212
+ "enum": ["rpc", "ai", "stream"]
213
+ },
211
214
  "cli": {
212
215
  "type": "array",
213
216
  "minItems": 1,
package/skills/SKILL.md CHANGED
@@ -374,14 +374,22 @@ App 不要預設強制 HTTPS。只有使用 secure context 能力(`getUserMedi
374
374
  「需要 HTTPS/請改用 HTTPS」頁,提供重新開啟 App 的說明。
375
375
  只有 `ctx.user?.isAdmin === true` 才呼叫 `readDsmPorts(ctx)`,從 `dms_https`
376
376
  取得實際 HTTPS 埠並提供 DSM 連結;也可用 SDK `readDsmHttpsURL(ctx, location.href)`
377
- 處理此限制。PortInfo 限管理員,一般使用者呼叫可能被拒或關閉 DSM 視窗;
377
+ 處理此限制。若目前 URL 帶有 `launchApp`,可 opt-in
378
+ `readDsmHttpsURL(ctx, location.href, {keepLaunchApp: true, signal})`,保留
379
+ `launchApp` 與 `launchParam` 以回到目前 App;預設仍開啟 DSM,其他 query 與
380
+ fragment 不保留。PortInfo 限管理員,一般使用者呼叫可能被拒或關閉 DSM 視窗;
378
381
  一般使用者只顯示說明文字。查不到埠時不猜測、不阻擋說明頁。
379
382
 
380
383
  舊 DSM 分頁可能在其他分頁重新登入後繼續帶舊 `X-SYNO-TOKEN`。對明確宣告
381
384
  `effect: read` 的一般 JSON RPC,可用 `createClient({sessionRetry: ...})`
382
385
  搭配 `createDsmSession` 的 `refresh(rejectedToken)` 更新 token 後重試一次。
383
- `sessionRetry.operations` 必須來自 App 可信的 effect 資料並明確標示 `kind`;
384
- 只有 `kind: rpc` 可重試。寫入、AI、串流、batch 和不明方法均不自動重試,
386
+ 先跑 `synopkgland ctl generate`,匯入 `generated/session-retry.ts` 的
387
+ `sessionRetryOperations`,直接傳給 `sessionRetry.operations`;不要再手抄 policy。
388
+ registry 可宣告 `kind: rpc | ai | stream`;模型執行應明標 `kind: ai`,它與
389
+ AI tool exposure 的 `ai` class 不同。缺 kind 時由實際 route/transfer/NDJSON
390
+ 宣告推導;無法判定為 `unknown`,不會重試。只有 `effect: read` 且 `kind: rpc`
391
+ 可重試。refresh 失敗或回傳同 token 時保留目前 carrier,後續 write/ingress
392
+ 仍可帶 token,但該次 read 不重送。寫入、AI、串流、batch 和不明方法均不自動重試,
385
393
  失敗後保留原錯誤。既有 `ctx.call` 不會因 SDK 更新而自動啟用此功能。
386
394
  完整 API 與 opt-in 理由見 SDK 的
387
395
  [HTTPS 與 session 恢復指南](https://github.com/synopackageland/syno-pkg-land-sdk/blob/main/docs/https-and-session-recovery.md)。
@@ -151,7 +151,8 @@ pagination, rather than making the model drive individual steps.
151
151
  Register the real handler, then run `synopkgland ctl generate`,
152
152
  `synopkgland ctl generate --check`, and `synopkgland check`. Generation writes the
153
153
  runtime permissions/route binding, `generated/synopkgland-api.json`,
154
- `generated/ctl.json`, `generated/tools.json` and `generated/operations.md`. Commit
154
+ `generated/ctl.json`, `generated/tools.json`, `generated/operations.md` and
155
+ `generated/session-retry.ts`. Commit
155
156
  the generated files. Check/build refuse drift and route/spec inequality in either
156
157
  direction, including hidden routes. The only infrastructure exceptions are the
157
158
  fixed describe and identity ceremony methods. SDK capability metadata comes from
@@ -159,6 +160,28 @@ the SDK's own hidden catalog and can be explicitly overridden in the App spec.
159
160
  Never hand-edit generated operation descriptions or add them to a skill manually.
160
161
  Use the SDK pins in the project generated by `synopkgland init`; query published releases with `npm view @synopackageland/sdk version`, `npm view @synopackageland/templates version` and `npm view @synopackageland/cli version`.
161
162
 
163
+ ### Browser session retry policy
164
+
165
+ Import the generated literal map directly; it has no runtime SDK dependency:
166
+
167
+ ```ts
168
+ import {createClient} from '@synopackageland/sdk'
169
+ import {sessionRetryOperations} from './generated/session-retry'
170
+
171
+ const client = createClient({endpoint, sessionRetry: {session, operations: sessionRetryOperations}})
172
+ ```
173
+
174
+ Each v2 operation may declare `kind: rpc | ai | stream`. Set model calls to
175
+ `kind: ai`; `ai: read` describes tool exposure, not model execution. Without an
176
+ explicit kind, generation uses the exported route kind: JSON/RPC maps to `rpc`,
177
+ transfer/stream/download/export maps to `stream`, and an NDJSON/upload flow also
178
+ maps to `stream`. Known non-RPC declarations cannot become retryable through
179
+ `kind: rpc`. Missing or unrecognized route metadata maps to `unknown`, which
180
+ the SDK refuses to retry. Names such as `get` or `export` are not evidence.
181
+ Only read RPCs can refresh and replay once. Writes, AI, streams, unknown kinds
182
+ and batches never replay. Existing `ctx.call` remains opt-in. Commit the generated
183
+ file and use `ctl generate --check` to verify it with the other artifacts.
184
+
162
185
  For installed Apps, use `ctl tools <app> --host <profile>` and
163
186
  `ctl tool <app> <method> --input <file|-> --host <profile>`. These require the
164
187
  normal approved package/descriptor pin. A draft tool returns a non-mutating