@synopackageland/cli 0.48.9 → 0.48.10
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 +1 -0
- package/dist/ctl/descriptor.d.ts +1 -0
- package/dist/ctl/registry.d.ts +15 -1
- package/dist/ctl/registry.js +20 -1
- package/dist/standalone/operation-registry.js +1 -1
- package/package.json +1 -1
- package/schema/synopkgland-api-v2.schema.json +3 -0
- package/skills/SKILL.md +11 -3
- package/skills/reference/ctl.md +24 -1
package/dist/ctl/cli.d.ts
CHANGED
package/dist/ctl/descriptor.d.ts
CHANGED
|
@@ -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;
|
package/dist/ctl/registry.d.ts
CHANGED
|
@@ -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
|
-
|
|
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;
|
package/dist/ctl/registry.js
CHANGED
|
@@ -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
|
-
|
|
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
|
}
|
|
@@ -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' } : {}) } };
|
package/package.json
CHANGED
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
|
-
|
|
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
|
-
`
|
|
384
|
-
|
|
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)。
|
package/skills/reference/ctl.md
CHANGED
|
@@ -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
|
|
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
|