@synopackageland/cli 0.53.8 → 0.53.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/CHANGELOG.md +13 -0
- package/dist/ctl/ai-tools.d.ts +2 -0
- package/dist/ctl/ai-tools.js +3 -1
- package/dist/ctl/descriptor.d.ts +1 -0
- package/dist/ctl/descriptor.js +3 -3
- package/dist/ctl/operation-semantics.d.ts +7 -1
- package/dist/ctl/operation-semantics.js +28 -3
- package/dist/ctl/registry.d.ts +13 -2
- package/dist/ctl/registry.js +50 -6
- package/dist/ctl/shared-defs.d.ts +30 -0
- package/dist/ctl/shared-defs.js +92 -0
- package/dist/standalone/api-description.js +2 -1
- package/dist/standalone/operation-registry.js +14 -8
- package/package.json +1 -1
- package/schema/synopkgland-api-v2.schema.json +21 -0
- package/skills/reference/ctl.md +24 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.53.10 (2026-11-11)
|
|
4
|
+
|
|
5
|
+
- `entry: admin-only` no longer turns `integration` routes (`api.HandleIntegration` callbacks, which have no DSM session) into `administrators`. Every admin-only App with an integration callback in its v2 `ctl.registry` failed `ctl generate`, `check` and `build` with `CTL_ROUTE_MISMATCH: missing spec or permission mismatch` for the callback. The registry keeps `integration` for these operations, and the generated permissions keep `integration`. Other App routes are still raised to `administrators`, so a registry that declares them below `administrators` is still refused. The v1 description path is unchanged.
|
|
6
|
+
|
|
7
|
+
## 0.53.9 (2026-11-11)
|
|
8
|
+
|
|
9
|
+
- The v2 operation registry accepts the SDK 0.53.34 fields `ctl` and `gateway`. `ctl: hidden` keeps an operation off ctl (it can only narrow, like `mcp`). `gateway: "<method>"` routes an operation's ctl command through a dedicated hidden `invoke` operation, for Apps that run ctl through an audited engine. The gateway needs the same permission and audit class, at least the same effect, a JSON RPC route, and serves one operation. `ctl generate`, `check` and description validation refuse invalid values with the same messages as the SDK.
|
|
10
|
+
- A gatewayed ctl command keeps its name, CLI path and semantics but calls the gateway with the gateway's params and checks the gateway's result. `ctl tool` runs it the same way; `ctl tool` on a `ctl: hidden` tool returns `CTL_AI_NOT_EXPOSED`. `ctl tools --mcp` shows the gateway's params, result and flow; `generated/tools.json` keeps the business schema and adds `gateway` and `ctl` only when declared. `generated/operations.md` writes `ctl: … via …` and `No ctl exposure.`.
|
|
11
|
+
- `CTL_FLOW_UNSUPPORTED` checks only operations that are ctl commands, so `ctl: hidden` stream and HTTP routes are accepted.
|
|
12
|
+
- `audit: sensitive-read` is accepted on write and destructive operations; `read` and `none` stay refused for changes.
|
|
13
|
+
- A registry may declare shared top-level `$defs` that operation schemas reference. Generation moves identical per-operation definitions into the shared set in the descriptor and runtime registry, while ctl commands and tools stay self-contained. Without top-level `$defs` nothing is rewritten.
|
|
14
|
+
- Registries without the new fields generate byte-identical artifacts. Apps that declare them need CLI 0.53.9 or later to read their descriptions with ctl.
|
|
15
|
+
|
|
3
16
|
## 0.53.8 (2026-11-11)
|
|
4
17
|
|
|
5
18
|
- The ready-to-paste `ui_secret_ignores` entry printed by `build` and project `check` now lists every flagged text. Texts longer than 200 characters were left out, which in minified output (non-ASCII escaped as `\uXXXX`) dropped long translated strings; now every text up to the 4096-character `match` limit is listed untruncated, exactly as `match` needs it. Error lines stay truncated, and known token signatures are still never printed.
|
package/dist/ctl/ai-tools.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ export declare function listAiTools(client: CtlClient, appName: string, options?
|
|
|
28
28
|
mcp?: "exposed" | "hidden" | "human-only" | undefined;
|
|
29
29
|
labels?: Record<string, string> | undefined;
|
|
30
30
|
dynamicProvider?: boolean | undefined;
|
|
31
|
+
ctl?: "exposed" | "hidden" | undefined;
|
|
32
|
+
gateway?: string | undefined;
|
|
31
33
|
execution: string;
|
|
32
34
|
preview?: string | undefined;
|
|
33
35
|
name: string;
|
package/dist/ctl/ai-tools.js
CHANGED
|
@@ -5,7 +5,7 @@ export async function listAiTools(client, appName, options = {}) {
|
|
|
5
5
|
const app = client.selectApp(await client.discover(options), appName);
|
|
6
6
|
if (app.version === 1 || app.version === 2 && !app.payload.operations)
|
|
7
7
|
throw new CtlError('CTL_AI_REGISTRY_REQUIRED', 'AI tools require an operation registry.', 'Migrate the App operation registry.', 5);
|
|
8
|
-
return { package: app.payload.package, sha256: app.sha256, tools: registryTools({ operations: app.version === 3 ? app.payload.commands : app.payload.operations }, { mcp: options.mcp }), ...(app.payload.execution ? { auth: await client.nativeState(app), credentialGuidance: 'Ask the user to run ctl auth in their own terminal. Never request credentials in chat.' } : {}) };
|
|
8
|
+
return { package: app.payload.package, sha256: app.sha256, tools: registryTools({ operations: app.version === 3 ? app.payload.commands : app.payload.operations, ...(app.version === 2 && app.payload.$defs ? { $defs: app.payload.$defs } : {}) }, { mcp: options.mcp }), ...(app.payload.execution ? { auth: await client.nativeState(app), credentialGuidance: 'Ask the user to run ctl auth in their own terminal. Never request credentials in chat.' } : {}) };
|
|
9
9
|
}
|
|
10
10
|
/** A draft is always a preview and plan. This API has no write-confirmation input.
|
|
11
11
|
* Humans can execute the reviewed ctl plan separately with the normal --yes guard.
|
|
@@ -16,6 +16,8 @@ export async function listAiTools(client, appName, options = {}) {
|
|
|
16
16
|
export async function runAiTool(client, appName, method, params, options = {}) {
|
|
17
17
|
const app = client.selectApp(await client.discover(options), appName);
|
|
18
18
|
const op = app.version !== 1 ? app.payload.commands[method] : undefined;
|
|
19
|
+
if (!op && app.version === 2 && isToolClass(app.payload.operations?.[method]?.ai))
|
|
20
|
+
throw new CtlError('CTL_AI_NOT_EXPOSED', 'AI tool is not exposed to ctl.', 'Use the App\'s own chat for this tool.', 4);
|
|
19
21
|
if (!op || !isToolClass(op.ai))
|
|
20
22
|
throw new CtlError('CTL_AI_NOT_EXPOSED', 'Operation is not an AI tool.', 'Use the generated tool list.', 4);
|
|
21
23
|
const args = ['--input', '-'], stdin = JSON.stringify(params);
|
package/dist/ctl/descriptor.d.ts
CHANGED
package/dist/ctl/descriptor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validateRegistry, INFRASTRUCTURE_METHODS } from './registry.js';
|
|
1
|
+
import { validateRegistry, ctlCommands, INFRASTRUCTURE_METHODS } from './registry.js';
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { createHash } from 'node:crypto';
|
|
4
4
|
import { canonicalize } from 'json-canonicalize';
|
|
@@ -36,12 +36,12 @@ export function validateDescriptor(value, id, version) {
|
|
|
36
36
|
if (value.version === 2) {
|
|
37
37
|
try {
|
|
38
38
|
if (value.version === 2)
|
|
39
|
-
validateRegistry({ format: 'synopkgland.api', version: 2, operations: p.operations });
|
|
39
|
+
validateRegistry({ format: 'synopkgland.api', version: 2, ...(p.$defs !== undefined ? { $defs: p.$defs } : {}), operations: p.operations });
|
|
40
40
|
}
|
|
41
41
|
catch {
|
|
42
42
|
return fail('Invalid operation registry.');
|
|
43
43
|
}
|
|
44
|
-
const expected =
|
|
44
|
+
const expected = ctlCommands({ operations: p.operations, $defs: p.$defs });
|
|
45
45
|
if (canonicalize(expected) !== canonicalize(p.commands))
|
|
46
46
|
return fail('Commands differ from the operation registry.');
|
|
47
47
|
for (const [name, op] of Object.entries(p.operations)) {
|
|
@@ -24,14 +24,20 @@ export interface OperationSemantics {
|
|
|
24
24
|
mcp?: 'exposed' | 'hidden' | 'human-only';
|
|
25
25
|
labels?: Record<string, string>;
|
|
26
26
|
dynamicProvider?: boolean;
|
|
27
|
+
ctl?: 'exposed' | 'hidden';
|
|
28
|
+
gateway?: string;
|
|
27
29
|
}
|
|
28
|
-
export declare const SEMANTIC_FIELDS: readonly ["consent", "targets", "risk", "tier", "undo", "audit", "mcp", "labels", "dynamicProvider"];
|
|
30
|
+
export declare const SEMANTIC_FIELDS: readonly ["consent", "targets", "risk", "tier", "undo", "audit", "mcp", "labels", "dynamicProvider", "ctl", "gateway"];
|
|
29
31
|
export declare const isToolClass: (ai: unknown) => boolean;
|
|
30
32
|
/** Effective defaults follow from ai and effect alone. */
|
|
31
33
|
export declare function auditClass(op: {
|
|
32
34
|
audit?: string;
|
|
33
35
|
effect: string;
|
|
34
36
|
}): string;
|
|
37
|
+
export declare function ctlExposure(op: {
|
|
38
|
+
ctl?: string;
|
|
39
|
+
ai?: string;
|
|
40
|
+
}): string;
|
|
35
41
|
export declare function mcpExposure(op: {
|
|
36
42
|
mcp?: string;
|
|
37
43
|
ai?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Optional v2 AI semantics. Every field is metadata for the App/SDK runtime;
|
|
2
2
|
* none grants authority. Omitted fields keep earlier v2 output unchanged. */
|
|
3
3
|
export const TOOL_CLASSES = ['read', 'preview', 'draft', 'propose', 'local', 'one-click'];
|
|
4
|
-
export const SEMANTIC_FIELDS = ['consent', 'targets', 'risk', 'tier', 'undo', 'audit', 'mcp', 'labels', 'dynamicProvider'];
|
|
4
|
+
export const SEMANTIC_FIELDS = ['consent', 'targets', 'risk', 'tier', 'undo', 'audit', 'mcp', 'labels', 'dynamicProvider', 'ctl', 'gateway'];
|
|
5
5
|
const TOKEN = /^[a-z][a-z0-9-]{0,31}$/, TIER = /^[A-Za-z0-9][A-Za-z0-9_-]{0,15}$/, PARAM = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
6
6
|
export const isToolClass = (ai) => TOOL_CLASSES.includes(ai);
|
|
7
7
|
const record = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
@@ -11,6 +11,8 @@ const head = (p) => p.slice(1).split('/')[0].replaceAll('~1', '/').replaceAll('~
|
|
|
11
11
|
const hasParam = (schema, name) => !record(schema?.properties) || Object.hasOwn(schema.properties, name);
|
|
12
12
|
/** Effective defaults follow from ai and effect alone. */
|
|
13
13
|
export function auditClass(op) { return op.audit ?? (op.effect === 'read' ? 'read' : 'change'); }
|
|
14
|
+
export function ctlExposure(op) { return op.ctl ?? (op.ai === 'hidden' ? 'hidden' : 'exposed'); }
|
|
15
|
+
const EFFECT_RANK = { read: 0, write: 1, destructive: 2 };
|
|
14
16
|
export function mcpExposure(op) { return op.mcp ?? (isToolClass(op.ai) ? 'exposed' : op.ai === 'human-only' ? 'human-only' : 'hidden'); }
|
|
15
17
|
/** Returns the first problem as `field: reason`, or undefined. Mirrors the SDK's Go validation. */
|
|
16
18
|
export function semanticsProblem(name, op, ops) {
|
|
@@ -53,8 +55,8 @@ export function semanticsProblem(name, op, ops) {
|
|
|
53
55
|
if (op.audit !== undefined) {
|
|
54
56
|
if (!['change', 'sensitive-read', 'read', 'none'].includes(op.audit))
|
|
55
57
|
return 'audit must be change, sensitive-read, read or none';
|
|
56
|
-
if (op.audit
|
|
57
|
-
return 'audit of a change must be change';
|
|
58
|
+
if (['read', 'none'].includes(op.audit) && op.effect !== 'read')
|
|
59
|
+
return 'audit of a change must be change or sensitive-read';
|
|
58
60
|
}
|
|
59
61
|
if (op.mcp !== undefined) {
|
|
60
62
|
if (!['exposed', 'hidden', 'human-only'].includes(op.mcp))
|
|
@@ -64,6 +66,29 @@ export function semanticsProblem(name, op, ops) {
|
|
|
64
66
|
if (op.mcp === 'human-only' && op.ai === 'hidden')
|
|
65
67
|
return 'mcp cannot expose a hidden operation';
|
|
66
68
|
}
|
|
69
|
+
if (op.ctl !== undefined) {
|
|
70
|
+
if (!['exposed', 'hidden'].includes(op.ctl))
|
|
71
|
+
return 'ctl must be exposed or hidden';
|
|
72
|
+
if (op.ctl === 'exposed' && op.ai === 'hidden')
|
|
73
|
+
return 'ctl cannot expose a hidden operation';
|
|
74
|
+
}
|
|
75
|
+
if (op.gateway !== undefined) {
|
|
76
|
+
const g = typeof op.gateway === 'string' && Object.hasOwn(ops, op.gateway) ? ops[op.gateway] : undefined;
|
|
77
|
+
if (ctlExposure(op) !== 'exposed')
|
|
78
|
+
return 'gateway applies only to an operation exposed to ctl';
|
|
79
|
+
if (op.gateway === name || !g)
|
|
80
|
+
return 'gateway must name another registered operation';
|
|
81
|
+
if (g.ai !== 'hidden' || g.flow?.type !== 'invoke' || g.gateway !== undefined)
|
|
82
|
+
return 'gateway must name a hidden invoke operation without its own gateway';
|
|
83
|
+
if (g.permission !== op.permission)
|
|
84
|
+
return 'gateway must name an operation with the same permission';
|
|
85
|
+
if (EFFECT_RANK[g.effect] < EFFECT_RANK[op.effect])
|
|
86
|
+
return "gateway effect must be at least the operation's effect";
|
|
87
|
+
if (auditClass(g) !== auditClass(op))
|
|
88
|
+
return "gateway audit must equal the operation's audit class";
|
|
89
|
+
if (Object.entries(ops).some(([other, spec]) => other < name && spec?.gateway === op.gateway))
|
|
90
|
+
return 'gateway serves only one operation';
|
|
91
|
+
}
|
|
67
92
|
if (op.dynamicProvider !== undefined && (typeof op.dynamicProvider !== 'boolean' || op.dynamicProvider && !isToolClass(op.ai)))
|
|
68
93
|
return 'dynamicProvider requires an AI tool class';
|
|
69
94
|
const l = op.labels;
|
package/dist/ctl/registry.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Operation } from './descriptor.js';
|
|
2
2
|
import { type OperationSemantics } from './operation-semantics.js';
|
|
3
|
+
import { type SharedDefs } from './shared-defs.js';
|
|
3
4
|
export declare const AI_CLASSES: readonly ["read", "preview", "draft", "propose", "local", "one-click", "human-only", "hidden"];
|
|
4
5
|
export type AIClass = typeof AI_CLASSES[number];
|
|
5
6
|
export type RegisteredOperation = Operation & OperationSemantics & {
|
|
@@ -18,6 +19,7 @@ export interface OperationRegistry {
|
|
|
18
19
|
format: 'synopkgland.api';
|
|
19
20
|
version: 2 | 3;
|
|
20
21
|
nativeHttp?: import('./native-types.js').NativeHttp;
|
|
22
|
+
$defs?: SharedDefs;
|
|
21
23
|
operations: Record<string, RegisteredOperation>;
|
|
22
24
|
}
|
|
23
25
|
export declare const INFRASTRUCTURE_METHODS: Set<string>;
|
|
@@ -29,10 +31,17 @@ export declare function checkRouteEquality(registry: OperationRegistry, routes:
|
|
|
29
31
|
permission: string;
|
|
30
32
|
}[]): void;
|
|
31
33
|
export declare function registryPermissions(registry: OperationRegistry): string;
|
|
34
|
+
/** ctl commands: every operation except hidden and `ctl: hidden` ones. A
|
|
35
|
+
* gatewayed operation keeps its name, cli and semantics; ctl calls its gateway
|
|
36
|
+
* with the gateway's params and checks the gateway's result. Command schemas
|
|
37
|
+
* are self-contained even when the registry shares `$defs`. */
|
|
38
|
+
export declare function ctlCommands(registry: Pick<OperationRegistry, 'operations' | '$defs'>): Record<string, RegisteredOperation>;
|
|
32
39
|
/** Model-facing tools. Semantic fields appear only when declared, so earlier
|
|
33
40
|
* registries generate byte-identical tools.json. With mcp, only tools an
|
|
34
|
-
* external MCP client may list (exposed, or human-only as a card) remain
|
|
35
|
-
|
|
41
|
+
* external MCP client may list (exposed, or human-only as a card) remain, and
|
|
42
|
+
* a gatewayed tool shows the call an external client makes: the gateway's
|
|
43
|
+
* params, result and flow. The chat view keeps the business shape. */
|
|
44
|
+
export declare function registryTools(registry: Pick<OperationRegistry, 'operations' | '$defs'>, options?: {
|
|
36
45
|
mcp?: boolean;
|
|
37
46
|
}): {
|
|
38
47
|
consent?: import("./operation-semantics.js").OperationConsent | undefined;
|
|
@@ -44,6 +53,8 @@ export declare function registryTools(registry: Pick<OperationRegistry, 'operati
|
|
|
44
53
|
mcp?: "exposed" | "hidden" | "human-only" | undefined;
|
|
45
54
|
labels?: Record<string, string> | undefined;
|
|
46
55
|
dynamicProvider?: boolean | undefined;
|
|
56
|
+
ctl?: "exposed" | "hidden" | undefined;
|
|
57
|
+
gateway?: string | undefined;
|
|
47
58
|
execution: string;
|
|
48
59
|
preview?: string | undefined;
|
|
49
60
|
name: string;
|
package/dist/ctl/registry.js
CHANGED
|
@@ -3,7 +3,8 @@ import { dirname, join, resolve, relative, isAbsolute } from 'node:path';
|
|
|
3
3
|
import { strictJson } from './json.js';
|
|
4
4
|
import { ajv, safeSchema, validateFlow } from './descriptor.js';
|
|
5
5
|
import { validateNativeRegistry } from './native-registry.js';
|
|
6
|
-
import { semanticsProblem, declaredSemantics, isToolClass, mcpExposure, TOOL_EXECUTION } from './operation-semantics.js';
|
|
6
|
+
import { semanticsProblem, declaredSemantics, isToolClass, mcpExposure, ctlExposure, TOOL_EXECUTION } from './operation-semantics.js';
|
|
7
|
+
import { expandOperations, sharedClosure } from './shared-defs.js';
|
|
7
8
|
export const AI_CLASSES = ['read', 'preview', 'draft', 'propose', 'local', 'one-click', 'human-only', 'hidden'];
|
|
8
9
|
export const INFRASTRUCTURE_METHODS = new Set(['synopkgland.describe', 'identity.status', 'identity.login', 'identity.session', 'identity.logout']);
|
|
9
10
|
const METHOD = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/;
|
|
@@ -25,8 +26,23 @@ export function validateRegistry(value) {
|
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
28
|
const fail = (why) => { throw Error('CTL_REGISTRY_INVALID: ' + why); };
|
|
28
|
-
if (!value || value.format !== 'synopkgland.api' || value.version !== 2 || !value.operations || Array.isArray(value.operations) || typeof value.operations !== 'object' || Object.keys(value.operations).length > 1024 || Object.keys(value).some(k => !['format', 'version', 'operations'].includes(k)))
|
|
29
|
+
if (!value || value.format !== 'synopkgland.api' || value.version !== 2 || !value.operations || Array.isArray(value.operations) || typeof value.operations !== 'object' || Object.keys(value.operations).length > 1024 || Object.keys(value).some(k => !['format', 'version', 'operations', '$defs'].includes(k)))
|
|
29
30
|
fail('expected synopkgland.api v2 operations.');
|
|
31
|
+
const shared = value.$defs;
|
|
32
|
+
if (shared !== undefined) {
|
|
33
|
+
if (!shared || typeof shared !== 'object' || Array.isArray(shared) || Object.keys(shared).length > 4096)
|
|
34
|
+
fail('$defs must be an object of JSON schemas.');
|
|
35
|
+
for (const [def, schema] of Object.entries(shared)) {
|
|
36
|
+
if (!def || typeof schema !== 'boolean' && (!schema || typeof schema !== 'object' || Array.isArray(schema)))
|
|
37
|
+
fail(`$defs entries must be JSON schemas: ${def}.`);
|
|
38
|
+
try {
|
|
39
|
+
safeSchema(schema);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
fail(`$defs entries must be JSON schemas: ${def}.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
30
46
|
const bindings = {};
|
|
31
47
|
const paths = new Set();
|
|
32
48
|
for (const [name, op] of Object.entries(value.operations)) {
|
|
@@ -47,8 +63,17 @@ export function validateRegistry(value) {
|
|
|
47
63
|
for (const schema of [op.paramsSchema, op.resultSchema]) {
|
|
48
64
|
if (!schema || typeof schema !== 'object' || Array.isArray(schema))
|
|
49
65
|
fail(`${name}: params/result schemas are required.`);
|
|
66
|
+
if (!shared) {
|
|
67
|
+
safeSchema(schema);
|
|
68
|
+
ajv.compile(schema);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const { defs, missing } = sharedClosure(schema, shared);
|
|
72
|
+
if (missing !== undefined)
|
|
73
|
+
fail(`${name}: schema reference #/$defs/${missing} is not defined.`);
|
|
74
|
+
const names = Object.keys(defs);
|
|
50
75
|
safeSchema(schema);
|
|
51
|
-
ajv.compile(schema);
|
|
76
|
+
ajv.compile(names.length ? { ...schema, $defs: { ...(schema.$defs ?? {}), ...defs } } : schema);
|
|
52
77
|
}
|
|
53
78
|
if (['read', 'preview'].includes(op.ai) && op.effect !== 'read')
|
|
54
79
|
fail(`${name}: read/preview tools must be non-mutating.`);
|
|
@@ -107,6 +132,17 @@ export function checkRouteEquality(registry, routes) {
|
|
|
107
132
|
export function registryPermissions(registry) {
|
|
108
133
|
return JSON.stringify({ schema: 1, default: 'administrators', methods: Object.fromEntries(Object.entries(registry.operations).sort(([a], [b]) => a.localeCompare(b)).map(([name, op]) => [name, op.permission])) }, null, 2) + '\n';
|
|
109
134
|
}
|
|
135
|
+
/** ctl commands: every operation except hidden and `ctl: hidden` ones. A
|
|
136
|
+
* gatewayed operation keeps its name, cli and semantics; ctl calls its gateway
|
|
137
|
+
* with the gateway's params and checks the gateway's result. Command schemas
|
|
138
|
+
* are self-contained even when the registry shares `$defs`. */
|
|
139
|
+
export function ctlCommands(registry) {
|
|
140
|
+
const ops = expandOperations(registry);
|
|
141
|
+
return Object.fromEntries(Object.entries(ops).filter(([, op]) => op.ai !== 'hidden' && ctlExposure(op) !== 'hidden').map(([name, op]) => {
|
|
142
|
+
const gateway = op.gateway ? ops[op.gateway] : undefined;
|
|
143
|
+
return [name, gateway ? { ...op, effect: gateway.effect, paramsSchema: gateway.paramsSchema, resultSchema: gateway.resultSchema, flow: { type: 'invoke', method: op.gateway } } : op];
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
110
146
|
function toolResultSchema(op) {
|
|
111
147
|
if (!op.http || !['paginate-http', 'ndjson'].includes(op.flow.type))
|
|
112
148
|
return op.resultSchema;
|
|
@@ -115,9 +151,15 @@ function toolResultSchema(op) {
|
|
|
115
151
|
}
|
|
116
152
|
/** Model-facing tools. Semantic fields appear only when declared, so earlier
|
|
117
153
|
* registries generate byte-identical tools.json. With mcp, only tools an
|
|
118
|
-
* external MCP client may list (exposed, or human-only as a card) remain
|
|
154
|
+
* external MCP client may list (exposed, or human-only as a card) remain, and
|
|
155
|
+
* a gatewayed tool shows the call an external client makes: the gateway's
|
|
156
|
+
* params, result and flow. The chat view keeps the business shape. */
|
|
119
157
|
export function registryTools(registry, options = {}) {
|
|
120
|
-
|
|
158
|
+
const ops = expandOperations(registry);
|
|
159
|
+
return Object.entries(ops).sort(([a], [b]) => a.localeCompare(b)).filter(([, op]) => isToolClass(op.ai) && (!options.mcp || mcpExposure(op) !== 'hidden')).map(([name, op]) => {
|
|
160
|
+
const call = options.mcp && op.gateway ? { ...ops[op.gateway], flow: { type: 'invoke', method: op.gateway } } : op;
|
|
161
|
+
return { name, description: op.summary, inputSchema: call.paramsSchema, outputSchema: toolResultSchema(call), annotations: { readOnlyHint: call.effect === 'read', destructiveHint: call.effect === 'destructive', openWorldHint: false }, ai: op.ai, flow: call.flow, ...(op.preview ? { preview: op.preview } : {}), execution: TOOL_EXECUTION[op.ai], ...declaredSemantics(op) };
|
|
162
|
+
});
|
|
121
163
|
}
|
|
122
164
|
function semanticsLine(op) {
|
|
123
165
|
const parts = [];
|
|
@@ -135,6 +177,8 @@ function semanticsLine(op) {
|
|
|
135
177
|
parts.push(`audit: ${op.audit}`);
|
|
136
178
|
if (op.mcp)
|
|
137
179
|
parts.push(`MCP: ${op.mcp}`);
|
|
180
|
+
if (op.ctl)
|
|
181
|
+
parts.push(`ctl: ${op.ctl}`);
|
|
138
182
|
if (op.dynamicProvider)
|
|
139
183
|
parts.push('runtime tools: the App adds tools that call this operation at runtime');
|
|
140
184
|
if (op.labels)
|
|
@@ -142,7 +186,7 @@ function semanticsLine(op) {
|
|
|
142
186
|
return parts.length ? `${parts.join('; ').replaceAll('<', '<')}\n\n` : '';
|
|
143
187
|
}
|
|
144
188
|
export function registryReference(registry) {
|
|
145
|
-
return '<!-- Generated by synopkgland ctl generate; edit the operation registry. -->\n# App operations\n\n' + Object.entries(registry.operations).sort(([a], [b]) => a.localeCompare(b)).map(([name, op]) => `## ${name}\n\n${op.summary.replaceAll('<', '<')}\n\nAI: ${op.ai}; effect: ${op.effect}; permission: ${op.permission}; flow: ${op.flow.type}\n\n${semanticsLine(op)}${op.ai === 'hidden' ? 'No ctl or AI exposure.' : `ctl: \`${op.cli.join(' ')}\``}\n${op.preview ? `\nPreview: \`${op.preview}\`; obtain human confirmation before execution.\n` : ''}`).join('\n');
|
|
189
|
+
return '<!-- Generated by synopkgland ctl generate; edit the operation registry. -->\n# App operations\n\n' + Object.entries(registry.operations).sort(([a], [b]) => a.localeCompare(b)).map(([name, op]) => `## ${name}\n\n${op.summary.replaceAll('<', '<')}\n\nAI: ${op.ai}; effect: ${op.effect}; permission: ${op.permission}; flow: ${op.flow.type}\n\n${semanticsLine(op)}${op.ai === 'hidden' ? 'No ctl or AI exposure.' : ctlExposure(op) === 'hidden' ? 'No ctl exposure.' : `ctl: \`${op.cli.join(' ')}\`${op.gateway ? ` via \`${op.gateway}\`` : ''}`}\n${op.preview ? `\nPreview: \`${op.preview}\`; obtain human confirmation before execution.\n` : ''}`).join('\n');
|
|
146
190
|
}
|
|
147
191
|
export function writeGenerated(path, contents, check) {
|
|
148
192
|
if (check) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Optional registry-level `$defs`. An operation schema's `#/$defs/<name>`
|
|
2
|
+
* reference resolves to its own `$defs` first, then to the shared ones.
|
|
3
|
+
* Generators inline what a schema uses, so every emitted tool and ctl
|
|
4
|
+
* command schema stays self-contained. Registries without `$defs` are
|
|
5
|
+
* never rewritten. */
|
|
6
|
+
export type SharedDefs = Record<string, unknown>;
|
|
7
|
+
type Schemas = {
|
|
8
|
+
paramsSchema: Record<string, any>;
|
|
9
|
+
resultSchema: Record<string, any>;
|
|
10
|
+
};
|
|
11
|
+
/** Shared definitions a schema needs, followed transitively; a name the schema defines locally always resolves locally. */
|
|
12
|
+
export declare function sharedClosure(schema: Record<string, any>, shared: SharedDefs): {
|
|
13
|
+
defs: SharedDefs;
|
|
14
|
+
missing?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function expandSchema<T extends Record<string, any>>(schema: T, shared: SharedDefs): T;
|
|
17
|
+
/** Operations with self-contained schemas. Without shared `$defs` the operations are returned unchanged. */
|
|
18
|
+
export declare function expandOperations<O extends Schemas>(registry: {
|
|
19
|
+
operations: Record<string, O>;
|
|
20
|
+
$defs?: SharedDefs;
|
|
21
|
+
}): Record<string, O>;
|
|
22
|
+
/** Dedupes definitions for generated artifacts: a name defined identically by
|
|
23
|
+
* several operation schemas moves to the shared `$defs` (the most frequent
|
|
24
|
+
* variant when variants differ), and every local copy equal to its shared
|
|
25
|
+
* definition is dropped. Only for registries that declare `$defs`. */
|
|
26
|
+
export declare function compactRegistry<R extends {
|
|
27
|
+
operations: Record<string, O>;
|
|
28
|
+
$defs?: SharedDefs;
|
|
29
|
+
}, O extends Schemas>(registry: R): R;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { canonicalize } from 'json-canonicalize';
|
|
2
|
+
const PREFIX = '#/$defs/';
|
|
3
|
+
const record = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
4
|
+
function refs(value, into) {
|
|
5
|
+
if (Array.isArray(value)) {
|
|
6
|
+
for (const item of value)
|
|
7
|
+
refs(item, into);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (!record(value))
|
|
11
|
+
return;
|
|
12
|
+
for (const [key, item] of Object.entries(value)) {
|
|
13
|
+
if (key === '$ref' && typeof item === 'string' && item.startsWith(PREFIX))
|
|
14
|
+
into.add(item.slice(PREFIX.length).split('/')[0].replaceAll('~1', '/').replaceAll('~0', '~'));
|
|
15
|
+
else
|
|
16
|
+
refs(item, into);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Shared definitions a schema needs, followed transitively; a name the schema defines locally always resolves locally. */
|
|
20
|
+
export function sharedClosure(schema, shared) {
|
|
21
|
+
const local = record(schema.$defs) ? schema.$defs : {};
|
|
22
|
+
let pending = new Set();
|
|
23
|
+
refs(schema, pending);
|
|
24
|
+
const defs = {};
|
|
25
|
+
while (pending.size) {
|
|
26
|
+
const next = new Set();
|
|
27
|
+
for (const name of [...pending].sort()) {
|
|
28
|
+
if (Object.hasOwn(local, name) || Object.hasOwn(defs, name))
|
|
29
|
+
continue;
|
|
30
|
+
if (!Object.hasOwn(shared, name))
|
|
31
|
+
return { defs, missing: name };
|
|
32
|
+
defs[name] = shared[name];
|
|
33
|
+
refs(shared[name], next);
|
|
34
|
+
}
|
|
35
|
+
pending = next;
|
|
36
|
+
}
|
|
37
|
+
return { defs };
|
|
38
|
+
}
|
|
39
|
+
export function expandSchema(schema, shared) {
|
|
40
|
+
const { defs } = sharedClosure(schema, shared);
|
|
41
|
+
const names = Object.keys(defs).sort();
|
|
42
|
+
if (!names.length)
|
|
43
|
+
return schema;
|
|
44
|
+
return { ...schema, $defs: { ...(record(schema.$defs) ? schema.$defs : {}), ...Object.fromEntries(names.map(name => [name, defs[name]])) } };
|
|
45
|
+
}
|
|
46
|
+
/** Operations with self-contained schemas. Without shared `$defs` the operations are returned unchanged. */
|
|
47
|
+
export function expandOperations(registry) {
|
|
48
|
+
const shared = registry.$defs;
|
|
49
|
+
if (!shared)
|
|
50
|
+
return registry.operations;
|
|
51
|
+
return Object.fromEntries(Object.entries(registry.operations).map(([name, op]) => [name, { ...op, paramsSchema: expandSchema(op.paramsSchema, shared), resultSchema: expandSchema(op.resultSchema, shared) }]));
|
|
52
|
+
}
|
|
53
|
+
/** Dedupes definitions for generated artifacts: a name defined identically by
|
|
54
|
+
* several operation schemas moves to the shared `$defs` (the most frequent
|
|
55
|
+
* variant when variants differ), and every local copy equal to its shared
|
|
56
|
+
* definition is dropped. Only for registries that declare `$defs`. */
|
|
57
|
+
export function compactRegistry(registry) {
|
|
58
|
+
if (!registry.$defs)
|
|
59
|
+
return registry;
|
|
60
|
+
const shared = { ...registry.$defs };
|
|
61
|
+
const variants = new Map();
|
|
62
|
+
for (const op of Object.values(registry.operations))
|
|
63
|
+
for (const schema of [op.paramsSchema, op.resultSchema]) {
|
|
64
|
+
if (!record(schema?.$defs))
|
|
65
|
+
continue;
|
|
66
|
+
for (const [name, value] of Object.entries(schema.$defs)) {
|
|
67
|
+
if (Object.hasOwn(shared, name))
|
|
68
|
+
continue;
|
|
69
|
+
const byText = variants.get(name) ?? new Map(), text = canonicalize(value), seen = byText.get(text);
|
|
70
|
+
byText.set(text, { count: (seen?.count ?? 0) + 1, value });
|
|
71
|
+
variants.set(name, byText);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
for (const [name, byText] of variants) {
|
|
75
|
+
const [text, best] = [...byText].sort(([a, x], [b, y]) => y.count - x.count || (a < b ? -1 : a > b ? 1 : 0))[0];
|
|
76
|
+
if (best.count > 1 && text)
|
|
77
|
+
shared[name] = best.value;
|
|
78
|
+
}
|
|
79
|
+
const texts = new Map(Object.entries(shared).map(([name, value]) => [name, canonicalize(value)]));
|
|
80
|
+
const compact = (schema) => {
|
|
81
|
+
if (!record(schema?.$defs))
|
|
82
|
+
return schema;
|
|
83
|
+
const kept = Object.entries(schema.$defs).filter(([name, value]) => texts.get(name) !== canonicalize(value));
|
|
84
|
+
if (kept.length === Object.keys(schema.$defs).length)
|
|
85
|
+
return schema;
|
|
86
|
+
const { $defs: _, ...rest } = schema;
|
|
87
|
+
return kept.length ? { ...schema, $defs: Object.fromEntries(kept) } : rest;
|
|
88
|
+
};
|
|
89
|
+
const names = Object.keys(shared).sort();
|
|
90
|
+
return { ...registry, $defs: Object.fromEntries(names.map(name => [name, shared[name]])),
|
|
91
|
+
operations: Object.fromEntries(Object.entries(registry.operations).map(([name, op]) => [name, { ...op, paramsSchema: compact(op.paramsSchema), resultSchema: compact(op.resultSchema) }])) };
|
|
92
|
+
}
|
|
@@ -63,7 +63,8 @@ export async function describeApiRoutes(m, bridgeMethods, run) {
|
|
|
63
63
|
}
|
|
64
64
|
if (!Array.isArray(methods) || methods.some(item => typeof item.method !== 'string' || typeof item.permission !== 'string'))
|
|
65
65
|
throw new StandaloneBuildError('CTL_DESCRIBE_FAILED', 'Invalid registry snapshot.');
|
|
66
|
-
|
|
66
|
+
// Integration callbacks carry no DSM session, so admin-only keeps them as integration.
|
|
67
|
+
return methods.map(route => m.entry === 'admin-only' && route.permission !== 'integration' && !['identity.status', 'identity.login', 'identity.session', 'identity.logout'].includes(route.method) ? { ...route, permission: 'administrators' } : route);
|
|
67
68
|
}
|
|
68
69
|
/** Retain the v1 protocol for existing Apps; new registries use the v2 path above. */
|
|
69
70
|
function buildLegacyApiDescription(m, methods) {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { appSdkVersion, sdkSource } from '../runtime/sdk-source.js';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { readRegistry, registryFile, registryArtifacts, registryPermissions, writeGenerated, checkRouteEquality } from '../ctl/registry.js';
|
|
4
|
+
import { readRegistry, registryFile, registryArtifacts, registryPermissions, writeGenerated, checkRouteEquality, ctlCommands } from '../ctl/registry.js';
|
|
5
|
+
import { compactRegistry } from '../ctl/shared-defs.js';
|
|
5
6
|
import { makeDescriptor, validateDescriptor, flowMethods } from '../ctl/descriptor.js';
|
|
6
7
|
import { readApiPermissions, API_PERMISSIONS_FILE } from './api-permissions.js';
|
|
7
8
|
import { sdkBackend } from './manifest.js';
|
|
8
9
|
import { describeApiRoutes } from './api-description.js';
|
|
9
10
|
import { generateNativeOperations } from './native-http.js';
|
|
10
|
-
import { descriptionFindings } from '../ctl/operation-semantics.js';
|
|
11
|
+
import { descriptionFindings, ctlExposure } from '../ctl/operation-semantics.js';
|
|
11
12
|
/** Tool summary lint. Warnings by default; ctl.descriptions: error refuses generation. */
|
|
12
13
|
export function descriptionWarnings(m, operations) {
|
|
13
14
|
const findings = descriptionFindings(operations).map(f => f.message);
|
|
@@ -21,12 +22,14 @@ export function operationRegistry(m) {
|
|
|
21
22
|
return readRegistry(registryFile(m.root, m.ctl.registry));
|
|
22
23
|
}
|
|
23
24
|
export function registryDescriptor(m, registry = operationRegistry(m)) {
|
|
24
|
-
|
|
25
|
+
// Shared $defs: operations carry deduplicated schemas, commands stay self-contained.
|
|
26
|
+
const shared = registry.$defs ? compactRegistry(registry) : undefined;
|
|
27
|
+
const operations = shared ? shared.operations : registry.operations;
|
|
25
28
|
const bindings = Object.fromEntries(Object.entries(operations).map(([name, op]) => [name, { effect: op.effect, permission: op.permission }]));
|
|
26
29
|
if (m.capabilities.identity)
|
|
27
30
|
for (const name of ['identity.session', 'identity.logout'])
|
|
28
31
|
bindings[name] = { effect: 'write', permission: 'public' };
|
|
29
|
-
const commands =
|
|
32
|
+
const commands = ctlCommands(shared ?? registry);
|
|
30
33
|
const external = m.ctl?.external;
|
|
31
34
|
if (external)
|
|
32
35
|
for (const entry of Object.values(external)) {
|
|
@@ -34,7 +37,7 @@ export function registryDescriptor(m, registry = operationRegistry(m)) {
|
|
|
34
37
|
if (!op || op.ai !== 'hidden' || op.permission !== 'administrators' || op.effect !== 'destructive')
|
|
35
38
|
throw Error('CTL_EXTERNAL_ENTRY: external entry must be a hidden destructive administrator operation.');
|
|
36
39
|
}
|
|
37
|
-
const description = makeDescriptor({ package: { id: m.package, version: m.spkVersion, displayName: m.displayname }, aliases: m.ctl?.aliases ?? [m.package.toLowerCase()], provenance: { developedBy: m.ctl?.developedBy ?? 'unknown', generator: 'synopkgland-cli' }, entry: m.entry ?? 'policy', transport: { path: `/webman/3rdparty/${m.package}/cgi/api.cgi`, auth: m.capabilities.identity ? 'dsm-app-session' : 'dsm-session' }, operations, commands, bindings, ...(external ? { external } : {}) });
|
|
40
|
+
const description = makeDescriptor({ package: { id: m.package, version: m.spkVersion, displayName: m.displayname }, aliases: m.ctl?.aliases ?? [m.package.toLowerCase()], provenance: { developedBy: m.ctl?.developedBy ?? 'unknown', generator: 'synopkgland-cli' }, entry: m.entry ?? 'policy', transport: { path: `/webman/3rdparty/${m.package}/cgi/api.cgi`, auth: m.capabilities.identity ? 'dsm-app-session' : 'dsm-session' }, operations, commands, bindings, ...(external ? { external } : {}), ...(shared ? { $defs: shared.$defs } : {}) });
|
|
38
41
|
return validateDescriptor(description, m.package, m.spkVersion);
|
|
39
42
|
}
|
|
40
43
|
/** Generation writes metadata only. The exporter constructs routes without running handlers. */
|
|
@@ -69,7 +72,7 @@ export async function generateOperations(m, run, check = false, bridgeMethods) {
|
|
|
69
72
|
registry.operations[route.method] = { ...structuredClone(spec), permission: route.permission };
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
|
-
writeGenerated(runtimeFile, JSON.stringify(registry, null, 2) + '\n', check);
|
|
75
|
+
writeGenerated(runtimeFile, JSON.stringify(compactRegistry(registry), null, 2) + '\n', check);
|
|
73
76
|
checkRouteEquality(registry, routes);
|
|
74
77
|
const kinds = new Map(routes.map(route => [route.method, route.kind ?? 'json']));
|
|
75
78
|
if (m.ctl?.external) {
|
|
@@ -79,9 +82,12 @@ export async function generateOperations(m, run, check = false, bridgeMethods) {
|
|
|
79
82
|
if (kinds.get(entry.method) !== 'json')
|
|
80
83
|
throw Error('CTL_EXTERNAL_ENTRY: external entries require JSON RPC handlers.');
|
|
81
84
|
}
|
|
85
|
+
// Only ctl commands need a ctl transport; a gatewayed command runs its gateway, a JSON RPC route.
|
|
82
86
|
for (const [name, op] of Object.entries(registry.operations))
|
|
83
|
-
if (op.ai !== 'hidden') {
|
|
84
|
-
|
|
87
|
+
if (op.ai !== 'hidden' && ctlExposure(op) !== 'hidden') {
|
|
88
|
+
if (op.gateway && kinds.get(op.gateway) !== 'json')
|
|
89
|
+
throw Error('CTL_FLOW_UNSUPPORTED: gateway must be a JSON RPC route: ' + name);
|
|
90
|
+
for (const method of flowMethods(op.gateway ? { type: 'invoke', method: op.gateway } : op.flow))
|
|
85
91
|
if (['http', 'integration'].includes(kinds.get(method) ?? ''))
|
|
86
92
|
throw Error('CTL_FLOW_UNSUPPORTED: exposed flows require RPC or SDK transfer handlers: ' + name);
|
|
87
93
|
}
|
package/package.json
CHANGED
|
@@ -174,6 +174,16 @@
|
|
|
174
174
|
"additionalProperties": {
|
|
175
175
|
"$ref": "#/$defs/operation"
|
|
176
176
|
}
|
|
177
|
+
},
|
|
178
|
+
"$defs": {
|
|
179
|
+
"type": "object",
|
|
180
|
+
"maxProperties": 4096,
|
|
181
|
+
"additionalProperties": {
|
|
182
|
+
"type": [
|
|
183
|
+
"object",
|
|
184
|
+
"boolean"
|
|
185
|
+
]
|
|
186
|
+
}
|
|
177
187
|
}
|
|
178
188
|
},
|
|
179
189
|
"required": [
|
|
@@ -593,6 +603,17 @@
|
|
|
593
603
|
},
|
|
594
604
|
"dynamicProvider": {
|
|
595
605
|
"type": "boolean"
|
|
606
|
+
},
|
|
607
|
+
"ctl": {
|
|
608
|
+
"enum": [
|
|
609
|
+
"exposed",
|
|
610
|
+
"hidden"
|
|
611
|
+
]
|
|
612
|
+
},
|
|
613
|
+
"gateway": {
|
|
614
|
+
"type": "string",
|
|
615
|
+
"maxLength": 128,
|
|
616
|
+
"pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"
|
|
596
617
|
}
|
|
597
618
|
},
|
|
598
619
|
"required": [
|
package/skills/reference/ctl.md
CHANGED
|
@@ -275,7 +275,7 @@ Each real method has one English `summary`, `paramsSchema`, `resultSchema`,
|
|
|
275
275
|
| `propose` | Write that stores a proposal when the turn allows changes; a human reviews and applies it |
|
|
276
276
|
| `local` | Reversible App-local write; runs only with the turn's Allow changes, otherwise a card the person presses |
|
|
277
277
|
| `one-click` | Never runs on a model call; returns a card the person presses |
|
|
278
|
-
| `human-only` | ctl with normal confirmation
|
|
278
|
+
| `human-only` | ctl with normal confirmation unless `ctl: hidden`; absent from AI tools |
|
|
279
279
|
| `hidden` | Runtime spec only; absent from ctl and AI tools |
|
|
280
280
|
|
|
281
281
|
A draft names its non-mutating `preview` method; both handlers must accept the
|
|
@@ -287,10 +287,29 @@ operations fail.
|
|
|
287
287
|
Optional AI semantics, all omitted by default: `consent` (`{category}` or
|
|
288
288
|
`{param: "/json/pointer"}`), `targets` (`{max: 0..1000, traceable}`), `risk`
|
|
289
289
|
(`low|medium|high`), `tier` (App token), `undo` (`{method, from, param}` receipt
|
|
290
|
-
contract), `audit` (`change|sensitive-read|read|none`;
|
|
291
|
-
`mcp` (`exposed|hidden|human-only`, narrowing only), `
|
|
292
|
-
|
|
293
|
-
|
|
290
|
+
contract), `audit` (`change|sensitive-read|read|none`; a write is `change` or
|
|
291
|
+
`sensitive-read`), `mcp` (`exposed|hidden|human-only`, narrowing only), `ctl`
|
|
292
|
+
(`exposed|hidden`, narrowing only: `hidden` keeps an operation off ctl),
|
|
293
|
+
`gateway` (see below), `dynamicProvider: true` for an operation that runtime
|
|
294
|
+
tools bind to, and `labels` (App strings, never for authorization). Generated
|
|
295
|
+
`tools.json` adds a field only when it is declared.
|
|
296
|
+
|
|
297
|
+
An App that runs ctl through an audited engine declares `gateway: "<method>"`
|
|
298
|
+
on each served operation. The gateway is its own registered hidden `invoke`
|
|
299
|
+
operation with the same permission and audit class and at least the same
|
|
300
|
+
effect, serving exactly one operation, on a JSON RPC route. The ctl command keeps
|
|
301
|
+
the served operation's name, CLI path and semantics but calls the gateway with
|
|
302
|
+
the gateway's params and checks the gateway's result; `--yes` follows the
|
|
303
|
+
gateway's effect. `ctl tools --mcp` shows the gateway's schemas; `tools.json`
|
|
304
|
+
keeps the business schema for the App's own chat. `operations.md` writes
|
|
305
|
+
``ctl: `path` via `gateway` `` and `No ctl exposure.` for `ctl: hidden`.
|
|
306
|
+
|
|
307
|
+
A large registry may declare shared `$defs` at the top level. An operation
|
|
308
|
+
schema's `#/$defs/<name>` resolves to its own `$defs` first, then the shared
|
|
309
|
+
ones. Generation moves identical per-operation definitions into the shared set
|
|
310
|
+
for the descriptor and runtime registry; ctl commands and tools stay
|
|
311
|
+
self-contained. Without top-level `$defs` nothing is rewritten.
|
|
312
|
+
|
|
294
313
|
The SDK's AI operation semantics guide has the full rules and the runtime
|
|
295
314
|
namespace API. Apps using them need an SDK and CLI release that lists these
|
|
296
315
|
fields in its changelog; older ctl clients refuse such descriptions.
|