@synopackageland/cli 0.53.4 → 0.53.5
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 +6 -0
- package/dist/ctl/external.d.ts +2 -0
- package/dist/ctl/external.js +29 -12
- package/docs/ctl-external.md +59 -19
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.53.5 (2026-11-11)
|
|
4
|
+
|
|
5
|
+
- Page `ctl external` describe so an App's MCP Catalog can grow far past 1 MiB while every message stays within it. Describe returns one page with the Catalog `revision` and, until the last page, a `nextCursor`; request the next page with `{"protocol","action":"describe","revision","cursor"}`. These map directly onto MCP `tools/list` `cursor`/`nextCursor`. A page from a changed revision refuses with `CTL_EXTERNAL_REVISION`; list again from the first page. A page holds at most 1024 tools, and a page with `nextCursor` holds at least one.
|
|
6
|
+
- Calls no longer fetch the whole Catalog: the CLI sends the App one tool lookup (`describe` with `revision` and `method`) and validates arguments against that tool. Revision, method and argument refusals before dispatch are unchanged, and there is still exactly one call attempt.
|
|
7
|
+
- Apps answer describe with their current revision, page so each reply stays within 1 MiB, and answer tool lookups; a reply over 1 MiB refuses with `CTL_RESPONSE_TOO_LARGE`. Apps that change their request shape should declare a new protocol ID and be reapproved. See [the external contract](docs/ctl-external.md).
|
|
8
|
+
|
|
3
9
|
## 0.53.4 (2026-11-10)
|
|
4
10
|
|
|
5
11
|
- Recognize ELF, Mach-O and PE content in public UI scans, so compiled CGI string pools do not trigger source-syntax `credential-literal` false positives. Text-file rules stay unchanged; executable content still fails private-key, known token, environment-file and source-map checks. Known token signatures in executables no longer require word boundaries between pooled constants.
|
package/dist/ctl/external.d.ts
CHANGED
package/dist/ctl/external.js
CHANGED
|
@@ -8,6 +8,8 @@ import { nasOptions } from '../nas/options.js';
|
|
|
8
8
|
const LIMIT = 1048576;
|
|
9
9
|
const PROTOCOL = /^[a-z][a-z0-9-]{0,63}$/;
|
|
10
10
|
const METHOD = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/;
|
|
11
|
+
const CURSOR = /^[A-Za-z0-9_.:~-]{1,256}$/;
|
|
12
|
+
const PAGE_TOOLS = 1024;
|
|
11
13
|
const AUTHORITY_KEYS = ['actor', 'via', 'allowMutation', 'allow_mutation', 'host'];
|
|
12
14
|
const USAGE = 'synopkgland ctl external --protocol <declared-protocol> --host <profile> --input - --json';
|
|
13
15
|
const HINT = 'Check local login, administrator access, App approval and tool revision. Query original state before repeating a mutation.';
|
|
@@ -21,11 +23,15 @@ export function parseExternalRequest(raw, protocol) {
|
|
|
21
23
|
const value = strictJson(raw);
|
|
22
24
|
if (!object(value) || value.protocol !== protocol)
|
|
23
25
|
throw Error();
|
|
24
|
-
const keys = value.action
|
|
26
|
+
const keys = value.action !== 'describe' ? ['protocol', 'action', 'revision', 'method', 'arguments'] :
|
|
27
|
+
Object.hasOwn(value, 'cursor') ? ['protocol', 'action', 'revision', 'cursor'] : ['protocol', 'action'];
|
|
25
28
|
if (Object.keys(value).length !== keys.length || keys.some(key => !Object.hasOwn(value, key)))
|
|
26
29
|
throw Error();
|
|
27
|
-
if (value.action === 'describe')
|
|
30
|
+
if (value.action === 'describe') {
|
|
31
|
+
if (keys.length === 4 && (!revision(value.revision) || typeof value.cursor !== 'string' || !CURSOR.test(value.cursor)))
|
|
32
|
+
throw Error();
|
|
28
33
|
return value;
|
|
34
|
+
}
|
|
29
35
|
if (value.action !== 'call' || !revision(value.revision) || typeof value.method !== 'string' || value.method.length > 128 || !METHOD.test(value.method) || !object(value.arguments) || AUTHORITY_KEYS.some(key => Object.hasOwn(value.arguments, key)))
|
|
30
36
|
throw Error();
|
|
31
37
|
return value;
|
|
@@ -34,9 +40,10 @@ export function parseExternalRequest(raw, protocol) {
|
|
|
34
40
|
return fail('CTL_EXTERNAL_INPUT', 'Invalid external request.', 3);
|
|
35
41
|
}
|
|
36
42
|
}
|
|
37
|
-
function
|
|
38
|
-
if (!object(value) || !revision(value.revision) || !Array.isArray(value.tools) || value.tools.length >
|
|
39
|
-
|
|
43
|
+
function validatePage(value) {
|
|
44
|
+
if (!object(value) || !revision(value.revision) || !Array.isArray(value.tools) || value.tools.length > PAGE_TOOLS ||
|
|
45
|
+
Object.hasOwn(value, 'nextCursor') && (typeof value.nextCursor !== 'string' || !CURSOR.test(value.nextCursor) || !value.tools.length))
|
|
46
|
+
return fail('CTL_EXTERNAL_CATALOG', 'Invalid external tool catalog page.', 5);
|
|
40
47
|
const methods = new Set(), names = new Set();
|
|
41
48
|
for (const tool of value.tools) {
|
|
42
49
|
if (!object(tool) || typeof tool.name !== 'string' || !/^[A-Za-z0-9_-]{1,128}$/.test(tool.name) ||
|
|
@@ -124,13 +131,23 @@ export class ExternalClient {
|
|
|
124
131
|
fail('CTL_EXTERNAL_VERIFICATION', 'External verification did not match the pinned request.', 5);
|
|
125
132
|
return reply.data.data;
|
|
126
133
|
};
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
+
// A page answers with the App's current revision. A cursor continues only the
|
|
135
|
+
// listing of the revision it came from; any change restarts at the first page.
|
|
136
|
+
const changed = () => fail('CTL_EXTERNAL_REVISION', 'External tool revision changed; list tools again from the first page.');
|
|
137
|
+
if (input.action === 'describe') {
|
|
138
|
+
const page = validatePage(await invoke(input));
|
|
139
|
+
if (input.revision !== undefined && page.revision !== input.revision)
|
|
140
|
+
changed();
|
|
141
|
+
return page;
|
|
142
|
+
}
|
|
143
|
+
// The call preflight reads only the named tool of the requested revision.
|
|
144
|
+
const found = validatePage(await invoke({ protocol, action: 'describe', revision: input.revision, method: input.method }));
|
|
145
|
+
if (found.revision !== input.revision)
|
|
146
|
+
changed();
|
|
147
|
+
if (found.tools.length > 1 || Object.hasOwn(found, 'nextCursor'))
|
|
148
|
+
fail('CTL_EXTERNAL_CATALOG', 'Invalid external tool lookup.', 5);
|
|
149
|
+
const tool = found.tools[0];
|
|
150
|
+
if (!tool || tool._meta.method !== input.method)
|
|
134
151
|
fail('CTL_EXTERNAL_METHOD', 'Method is not an external tool.');
|
|
135
152
|
if (!ajv.validate(tool.inputSchema, input.arguments))
|
|
136
153
|
fail('CTL_EXTERNAL_INPUT', 'Arguments do not match the current tool schema.', 3);
|
package/docs/ctl-external.md
CHANGED
|
@@ -97,23 +97,41 @@ automatic login is available. Reapprove intentional changes outside the bridge.
|
|
|
97
97
|
|
|
98
98
|
## Local stdin/stdout contract
|
|
99
99
|
|
|
100
|
-
Describe
|
|
100
|
+
Describe lists the App's Catalog one page at a time, so a Catalog can grow
|
|
101
|
+
far past 1 MiB while every message stays within it. The first page's input has
|
|
102
|
+
exactly these fields:
|
|
101
103
|
|
|
102
104
|
```json
|
|
103
105
|
{"protocol":"example-external-v1","action":"describe"}
|
|
104
106
|
```
|
|
105
107
|
|
|
106
|
-
Success data is the App's current Catalog
|
|
107
|
-
tool set:
|
|
108
|
+
Success data is one page of the App's current Catalog. Its revision binds the
|
|
109
|
+
entire tool set, not only this page:
|
|
108
110
|
|
|
109
111
|
```json
|
|
110
|
-
{"ok":true,"data":{"revision":"r1","tools":[{"name":"notes__list","description":"notes.list","inputSchema":{"type":"object","additionalProperties":false},"outputSchema":{"type":"object"},"_meta":{"method":"notes.list"}}]}}
|
|
112
|
+
{"ok":true,"data":{"revision":"r1","tools":[{"name":"notes__list","description":"notes.list","inputSchema":{"type":"object","additionalProperties":false},"outputSchema":{"type":"object"},"_meta":{"method":"notes.list"}}],"nextCursor":"50"}}
|
|
111
113
|
```
|
|
112
114
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
When `nextCursor` is present, request the next page with exactly the page's
|
|
116
|
+
revision and that cursor:
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{"protocol":"example-external-v1","action":"describe","revision":"r1","cursor":"50"}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The last page has no `nextCursor`; an empty Catalog is one page with no tools.
|
|
123
|
+
The fields map directly onto MCP `tools/list` (`cursor`/`nextCursor`); a bridge
|
|
124
|
+
can keep the revision inside its own MCP cursor. Every page of one listing has
|
|
125
|
+
the same revision. If the App's revision changed, the next page refuses with
|
|
126
|
+
`CTL_EXTERNAL_REVISION`, and no tools of another revision are returned: list
|
|
127
|
+
again from the first page. Never merge pages of different revisions.
|
|
128
|
+
|
|
129
|
+
Catalog revisions contain 1–128 letters/digits/underscores/dashes, and cursors
|
|
130
|
+
1–256 letters/digits and `_ . : ~ -`. A cursor is opaque to callers. A page holds
|
|
131
|
+
at most 1024 tools; a page with `nextCursor` holds at least one. Each tool has a
|
|
132
|
+
unique MCP-compatible `name` (1–128 letters/digits/underscores/dashes), unique
|
|
133
|
+
original dotted method in `_meta.method`, and self-contained JSON Schema 2020-12
|
|
134
|
+
input/output objects; names and methods are unique across the whole Catalog.
|
|
117
135
|
Other App metadata is preserved. Schema references must be local. The App owns
|
|
118
136
|
tool eligibility, effect, schema hashes and revision construction; the bridge
|
|
119
137
|
may additionally compare these against its matching built-in OpSpecs.
|
|
@@ -124,9 +142,10 @@ Call input has exactly these fields:
|
|
|
124
142
|
{"protocol":"example-external-v1","action":"call","revision":"r1","method":"notes.list","arguments":{}}
|
|
125
143
|
```
|
|
126
144
|
|
|
127
|
-
The CLI
|
|
128
|
-
|
|
129
|
-
|
|
145
|
+
The CLI reads only the named tool of the requested revision through the trusted
|
|
146
|
+
entry (see the tool lookup below), refuses stale revisions
|
|
147
|
+
(`CTL_EXTERNAL_REVISION`) and unknown methods (`CTL_EXTERNAL_METHOD`), and
|
|
148
|
+
validates arguments against that tool's current input schema. Success data is the App's tool Result, validated against the
|
|
130
149
|
tool's output schema. The CLI never starts an ordinary ctl flow for this call.
|
|
131
150
|
`actor`, `via`, `allowMutation`, `allow_mutation` and `host` are forbidden as
|
|
132
151
|
request fields and root argument fields. They cannot establish authority through
|
|
@@ -146,7 +165,25 @@ The CLI adds installed-package and approved-description pins to RPC `params`:
|
|
|
146
165
|
{"method":"bridge.external","params":{"protocol":"example-external-v1","action":"call","revision":"r1","method":"notes.list","arguments":{},"package":{"id":"Example","version":"1"},"descriptionSha256":"<approved 64-hex hash>"}}
|
|
147
166
|
```
|
|
148
167
|
|
|
149
|
-
Describe has the same pins plus `protocol` and `action`,
|
|
168
|
+
Describe has the same pins plus `protocol` and `action`, and for a later page
|
|
169
|
+
`revision` and `cursor`, without call fields. Before a call, the CLI sends one
|
|
170
|
+
tool lookup, a describe with `revision` and `method` instead of a cursor:
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{"method":"bridge.external","params":{"protocol":"example-external-v1","action":"describe","revision":"r1","method":"notes.list","package":{"id":"Example","version":"1"},"descriptionSha256":"<approved 64-hex hash>"}}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Describe always answers with the App's **current** revision. When a requested
|
|
177
|
+
revision differs, return no tools (`{"revision":"<current>","tools":[]}`) or
|
|
178
|
+
refuse; never return tools of a revision other than the one in the data. A
|
|
179
|
+
lookup returns only the eligible tool with that method, or no tools, and never
|
|
180
|
+
`nextCursor`. A page returns a contiguous part of the Catalog: the App chooses
|
|
181
|
+
page sizes so each reply, including the RPC and evidence envelope, stays within
|
|
182
|
+
1 MiB. The CLI refuses a larger reply with `CTL_RESPONSE_TOO_LARGE`; a single
|
|
183
|
+
tool that cannot fit in one reply is an App defect, and the App should refuse it
|
|
184
|
+
by name rather than truncate it. Bind cursors to their revision and refuse
|
|
185
|
+
cursors that are not page boundaries of it.
|
|
186
|
+
|
|
150
187
|
The App must strictly decode this envelope and, for **both** actions:
|
|
151
188
|
|
|
152
189
|
1. Authenticate the current DSM session and SynoToken, require a current
|
|
@@ -175,12 +212,13 @@ Use the ordinary SDK `{success,data|error}` RPC envelope. On success, `data` is:
|
|
|
175
212
|
"administrator": true,
|
|
176
213
|
"revision": "r1"
|
|
177
214
|
},
|
|
178
|
-
"data": {"revision":"r1","tools":[]}
|
|
215
|
+
"data": {"revision":"r1","tools":[],"nextCursor":"50"}
|
|
179
216
|
}
|
|
180
217
|
```
|
|
181
218
|
|
|
182
|
-
For
|
|
183
|
-
|
|
219
|
+
For describe the verified revision must equal the inner page's revision. For
|
|
220
|
+
calls the inner `data` is the tool Result and the verified revision must equal
|
|
221
|
+
the requested revision. The CLI verifies all evidence against its pins,
|
|
184
222
|
stored username and Catalog revision, then unwraps only the inner data for the
|
|
185
223
|
local bridge. Evidence is an assertion by the approved authenticated App, not
|
|
186
224
|
a signed delegation token. The server must perform these checks before dispatch;
|
|
@@ -205,14 +243,16 @@ rotation. They do not establish any App's installed or deployed readiness.
|
|
|
205
243
|
|
|
206
244
|
## Syngle I-B / K9 integration checklist
|
|
207
245
|
|
|
208
|
-
- Keep the existing bridge argv and
|
|
209
|
-
`syngle-external-
|
|
210
|
-
|
|
246
|
+
- Keep the existing bridge argv and call shapes. Paged describe changes the
|
|
247
|
+
request shape, so declare `syngle-external-v2` under `ctl.external` and
|
|
248
|
+
reapprove the App. Select a fixed administrator RPC method such as
|
|
249
|
+
`mcp.external`.
|
|
211
250
|
- Register that exact RPC in CGI and worker route composition and digest-bound
|
|
212
251
|
administrator permissions. Align generated/static and runtime descriptors,
|
|
213
252
|
their canonical hashes and package version. Keep it out of ordinary ctl flows.
|
|
214
253
|
- Strictly decode the trusted RPC params and implement the evidence envelope
|
|
215
|
-
above.
|
|
254
|
+
above. Page Describe data from the current exact `mcpbridge.NewCatalog` and
|
|
255
|
+
answer tool lookups from the same snapshot.
|
|
216
256
|
Compare revision/pins at the shared Engine dispatch boundary, not after effects.
|
|
217
257
|
- Construct `aitools.NewExternal(Config)` per verified Caller, preserving the
|
|
218
258
|
scope resolver, mutation-intent gate, selection/DraftGate and read-NAS budgets.
|