aicommunicator-plugin-check 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +10 -3
- package/dist/bundle.js +26 -4
- package/dist/manifest.d.ts +20 -0
- package/dist/manifest.js +80 -1
- package/package.json +1 -1
package/dist/bundle.d.ts
CHANGED
|
@@ -21,11 +21,18 @@ export declare class BundleError extends Error {
|
|
|
21
21
|
/** 묶음 파일의 이름. 예: rawdev.novel-0.3.0.tgz */
|
|
22
22
|
export declare function bundleFileName(id: string, version: string): string;
|
|
23
23
|
export declare function sha256Hex(data: Uint8Array | string): string;
|
|
24
|
+
/** manifest 의 requires.external[].connect.messages 가 가리키는 메시지 표 파일들(032 44.2절). */
|
|
25
|
+
export declare function connectMessageFiles(manifest: Pick<Manifest, 'requires'>): string[];
|
|
24
26
|
/**
|
|
25
27
|
* 이 경로의 파일이 묶음에 들어갈 수 있는가(036 3절). manifest, 논리 파일, ui/ 의 파일, LICENSE, README.md, 그리고 manifest 가 가리키는
|
|
26
|
-
* 설명서와 예제 파일(037 5.1절)뿐이다.
|
|
28
|
+
* 설명서와 예제 파일(037 5.1절), 외부 연결의 메시지 표(032 44.2절)뿐이다.
|
|
27
29
|
*/
|
|
28
|
-
export declare function bundlePathAllowed(p: string, manifest: Pick<Manifest, 'logic' | 'manual' | 'samples'>): boolean;
|
|
30
|
+
export declare function bundlePathAllowed(p: string, manifest: Pick<Manifest, 'logic' | 'manual' | 'samples' | 'requires'>): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 외부 연결의 메시지 표 파일 검사(032 44.2절). connect.messages 가 가리키는 파일이 묶음에 있어야 하고 메시지 표의 검사(032 31.3절)를 지나야
|
|
33
|
+
* 한다. 코어도 연결을 쓴 뒤 읽을 때 다시 검사한다. 틀리면 까닭이고 없으면 null 이다.
|
|
34
|
+
*/
|
|
35
|
+
export declare function connectFilesProblem(manifest: Pick<Manifest, 'requires'>, files: ReadonlyMap<string, Uint8Array>): string | null;
|
|
29
36
|
/**
|
|
30
37
|
* 설명서와 예제 파일의 검사(037 5절, 7절 4번). manifest 가 가리키는 파일이 묶음에 있어야 하고, 설명서는 50,000자, 예제는 하나에
|
|
31
38
|
* 200,000자까지다. 예제는 aic-sample/1 모양이어야 하고 쓴 플러그인에 이 플러그인이 있어야 한다. 틀리면 까닭이고 없으면 null 이다.
|
|
@@ -46,7 +53,7 @@ export declare function packBundle(files: Map<string, Uint8Array | string> | Rec
|
|
|
46
53
|
/**
|
|
47
54
|
* `.tgz` 를 풀어 036 3절의 규칙을 확인한다. 묶음 크기, 풀린 크기, 파일 수, 묶음 밖 경로, 보통 파일이 아닌 항목(링크 같은 것),
|
|
48
55
|
* 같은 경로 둘, 들어갈 수 없는 파일, manifest 검사, 논리 파일과 화면 파일이 있는지, 설명서와 예제 파일(docsProblem), 아이콘 파일
|
|
49
|
-
* (iconFileProblem)
|
|
56
|
+
* (iconFileProblem), 외부 연결의 메시지 표(connectFilesProblem)를 본다. 틀리면
|
|
50
57
|
* 까닭이 든 BundleError 를 던진다.
|
|
51
58
|
* 풀린 크기는 gzip 을 풀면서 한도로 막으므로 아주 크게 부풀리는 묶음도 메모리에 다 풀지 않는다.
|
|
52
59
|
*/
|
package/dist/bundle.js
CHANGED
|
@@ -4,6 +4,7 @@ import { createHash } from 'node:crypto';
|
|
|
4
4
|
import zlib from 'node:zlib';
|
|
5
5
|
import { checkForRegistry, checkManifest, isFileName, isPluginPath } from "./manifest.js";
|
|
6
6
|
import { iconProblem } from "./icon.js";
|
|
7
|
+
import { checkMessageTable } from "./messages.js";
|
|
7
8
|
import { parseManual, parseSample } from "./sample.js";
|
|
8
9
|
/** 묶음 파일의 크기 한도와 풀린 파일 크기 합의 한도(036 12절 3번). */
|
|
9
10
|
export const BUNDLE_MAX_BYTES = 5 * 1024 * 1024;
|
|
@@ -25,17 +26,38 @@ export function bundleFileName(id, version) {
|
|
|
25
26
|
export function sha256Hex(data) {
|
|
26
27
|
return createHash('sha256').update(data).digest('hex');
|
|
27
28
|
}
|
|
29
|
+
/** manifest 의 requires.external[].connect.messages 가 가리키는 메시지 표 파일들(032 44.2절). */
|
|
30
|
+
export function connectMessageFiles(manifest) {
|
|
31
|
+
return (manifest.requires?.external ?? []).map((t) => t.connect?.messages).filter((p) => typeof p === 'string');
|
|
32
|
+
}
|
|
28
33
|
/**
|
|
29
34
|
* 이 경로의 파일이 묶음에 들어갈 수 있는가(036 3절). manifest, 논리 파일, ui/ 의 파일, LICENSE, README.md, 그리고 manifest 가 가리키는
|
|
30
|
-
* 설명서와 예제 파일(037 5.1절)뿐이다.
|
|
35
|
+
* 설명서와 예제 파일(037 5.1절), 외부 연결의 메시지 표(032 44.2절)뿐이다.
|
|
31
36
|
*/
|
|
32
37
|
export function bundlePathAllowed(p, manifest) {
|
|
33
38
|
if (p === 'manifest.json' || p === 'LICENSE' || p === 'README.md' || p === manifest.logic)
|
|
34
39
|
return true;
|
|
35
40
|
if (p === manifest.manual || (manifest.samples ?? []).some((s) => s.file === p))
|
|
36
41
|
return true;
|
|
42
|
+
if (connectMessageFiles(manifest).includes(p))
|
|
43
|
+
return true;
|
|
37
44
|
return p.startsWith('ui/') && isFileName(p.slice(3));
|
|
38
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* 외부 연결의 메시지 표 파일 검사(032 44.2절). connect.messages 가 가리키는 파일이 묶음에 있어야 하고 메시지 표의 검사(032 31.3절)를 지나야
|
|
48
|
+
* 한다. 코어도 연결을 쓴 뒤 읽을 때 다시 검사한다. 틀리면 까닭이고 없으면 null 이다.
|
|
49
|
+
*/
|
|
50
|
+
export function connectFilesProblem(manifest, files) {
|
|
51
|
+
for (const p of connectMessageFiles(manifest)) {
|
|
52
|
+
const data = files.get(p);
|
|
53
|
+
if (!data)
|
|
54
|
+
return `The message table file ${p} is missing`;
|
|
55
|
+
const checked = checkMessageTable(data);
|
|
56
|
+
if (!checked.ok)
|
|
57
|
+
return `${p}: ${checked.problems.join('. ')}`;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
39
61
|
/**
|
|
40
62
|
* 설명서와 예제 파일의 검사(037 5절, 7절 4번). manifest 가 가리키는 파일이 묶음에 있어야 하고, 설명서는 50,000자, 예제는 하나에
|
|
41
63
|
* 200,000자까지다. 예제는 aic-sample/1 모양이어야 하고 쓴 플러그인에 이 플러그인이 있어야 한다. 틀리면 까닭이고 없으면 null 이다.
|
|
@@ -204,7 +226,7 @@ function cleanPath(raw, dir) {
|
|
|
204
226
|
/**
|
|
205
227
|
* `.tgz` 를 풀어 036 3절의 규칙을 확인한다. 묶음 크기, 풀린 크기, 파일 수, 묶음 밖 경로, 보통 파일이 아닌 항목(링크 같은 것),
|
|
206
228
|
* 같은 경로 둘, 들어갈 수 없는 파일, manifest 검사, 논리 파일과 화면 파일이 있는지, 설명서와 예제 파일(docsProblem), 아이콘 파일
|
|
207
|
-
* (iconFileProblem)
|
|
229
|
+
* (iconFileProblem), 외부 연결의 메시지 표(connectFilesProblem)를 본다. 틀리면
|
|
208
230
|
* 까닭이 든 BundleError 를 던진다.
|
|
209
231
|
* 풀린 크기는 gzip 을 풀면서 한도로 막으므로 아주 크게 부풀리는 묶음도 메모리에 다 풀지 않는다.
|
|
210
232
|
*/
|
|
@@ -299,9 +321,9 @@ export function readBundle(buffer) {
|
|
|
299
321
|
throw new BundleError('bad_bundle', `The package has no screen file ${m.ui}`);
|
|
300
322
|
const extra = [...files.keys()].filter((p) => !bundlePathAllowed(p, m));
|
|
301
323
|
if (extra.length > 0) {
|
|
302
|
-
throw new BundleError('bad_bundle', `The package has files that cannot go into it: ${extra.join(', ')}. Only include manifest.json, the logic file, files in ui/, LICENSE, README.md, and the files that manual and
|
|
324
|
+
throw new BundleError('bad_bundle', `The package has files that cannot go into it: ${extra.join(', ')}. Only include manifest.json, the logic file, files in ui/, LICENSE, README.md, and the files that manual, samples and connect.messages in the manifest point to`);
|
|
303
325
|
}
|
|
304
|
-
const docs = docsProblem(m, files) ?? iconFileProblem(m, files);
|
|
326
|
+
const docs = docsProblem(m, files) ?? iconFileProblem(m, files) ?? connectFilesProblem(m, files);
|
|
305
327
|
if (docs)
|
|
306
328
|
throw new BundleError('bad_bundle', docs);
|
|
307
329
|
return { manifest: m, files, sha256: sha256Hex(buf), size: buf.length };
|
package/dist/manifest.d.ts
CHANGED
|
@@ -43,6 +43,18 @@ export interface ExternalTool {
|
|
|
43
43
|
account: 'none' | 'free' | 'paid';
|
|
44
44
|
install: boolean;
|
|
45
45
|
note?: string;
|
|
46
|
+
/** 플러그인 화면에서 사람이 만들 수 있는 HTTP 연결(032 44.2절). kind 가 mcp 인 항목에만 있다. */
|
|
47
|
+
connect?: ExternalConnect;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 플러그인 화면에서 사람이 [연결] 을 눌러 만드는 HTTP 연결(032 44.2절). 코어는 이 manifest 의 주소만 쓰고 화면 코드가 주소를 넘기지 못한다.
|
|
51
|
+
* messages 는 플러그인 폴더 안의 메시지 표이고, 연결을 만들 때 코어가 연결 정의 파일의 폴더로 복사한다.
|
|
52
|
+
*/
|
|
53
|
+
export interface ExternalConnect {
|
|
54
|
+
connection: string;
|
|
55
|
+
url: string;
|
|
56
|
+
title?: string;
|
|
57
|
+
messages?: string;
|
|
46
58
|
}
|
|
47
59
|
export interface PluginRequires {
|
|
48
60
|
os: 'any' | OsName[];
|
|
@@ -54,6 +66,14 @@ export declare const RESERVED_IDS: readonly string[];
|
|
|
54
66
|
export declare const MAX_DEPENDENCIES = 20;
|
|
55
67
|
/** samples 의 항목 수 한도(037 7절 4번). */
|
|
56
68
|
export declare const MAX_SAMPLES = 5;
|
|
69
|
+
/** connect.url 의 길이 한도(032 44.2절). */
|
|
70
|
+
export declare const CONNECT_URL_MAX = 500;
|
|
71
|
+
/**
|
|
72
|
+
* connect.url 의 모양(032 44.2절). https 이고, 시험을 위해 http://127.0.0.1 과 http://localhost 는 받는다(032 31.6절과 같다). 사용자 정보(user@)와
|
|
73
|
+
* # 뒤는 받지 않는다. 물음표 뒤는 공개 manifest 에 있으니 비밀이 아니라 받는다. 빈칸, 제어 글자, 역빗금은 URL 이 조용히 고쳐 읽으므로 받지
|
|
74
|
+
* 않는다. 문제가 있으면 "<칸> <까닭>" 의 까닭이고 없으면 null 이다. 코어도 연결을 쓰기 전에 이것으로 다시 본다.
|
|
75
|
+
*/
|
|
76
|
+
export declare function connectUrlProblem(value: unknown): string | null;
|
|
57
77
|
/** `계정이름.플러그인이름` 모양인가. 각 부분은 영어 소문자, 숫자, `-` 이고 2자에서 40자다(036 4절). */
|
|
58
78
|
export declare function isPluginId(id: unknown): id is string;
|
|
59
79
|
/** id 의 앞부분(계정 이름). */
|
package/dist/manifest.js
CHANGED
|
@@ -14,6 +14,68 @@ const FILE_NAME = /^[\w.-]+$/;
|
|
|
14
14
|
const OS_NAMES = ['windows', 'macos', 'linux'];
|
|
15
15
|
const TOOL_KINDS = ['program', 'web', 'mcp'];
|
|
16
16
|
const ACCOUNTS = ['none', 'free', 'paid'];
|
|
17
|
+
/** 연결 이름. 코어의 link/connections.ts 의 CONNECTION_NAME 과 같은 모양이다(이 패키지는 코어를 불러오지 않는다). */
|
|
18
|
+
const CONNECTION_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
19
|
+
/**
|
|
20
|
+
* Windows 가 장치로 읽는 이름. 코어가 메시지 표를 messages/<연결 이름>.json 으로 복사하는데, 첫 점 앞이 이 이름이면 Windows 가 파일이 아니라
|
|
21
|
+
* 장치로 열기 때문이다.
|
|
22
|
+
*/
|
|
23
|
+
const WINDOWS_DEVICE = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\.|$)/i;
|
|
24
|
+
/** connect.url 의 길이 한도(032 44.2절). */
|
|
25
|
+
export const CONNECT_URL_MAX = 500;
|
|
26
|
+
/**
|
|
27
|
+
* connect.url 의 모양(032 44.2절). https 이고, 시험을 위해 http://127.0.0.1 과 http://localhost 는 받는다(032 31.6절과 같다). 사용자 정보(user@)와
|
|
28
|
+
* # 뒤는 받지 않는다. 물음표 뒤는 공개 manifest 에 있으니 비밀이 아니라 받는다. 빈칸, 제어 글자, 역빗금은 URL 이 조용히 고쳐 읽으므로 받지
|
|
29
|
+
* 않는다. 문제가 있으면 "<칸> <까닭>" 의 까닭이고 없으면 null 이다. 코어도 연결을 쓰기 전에 이것으로 다시 본다.
|
|
30
|
+
*/
|
|
31
|
+
export function connectUrlProblem(value) {
|
|
32
|
+
if (typeof value !== 'string' || value === '')
|
|
33
|
+
return 'must be an https address';
|
|
34
|
+
if (chars(value) > CONNECT_URL_MAX)
|
|
35
|
+
return `is over ${CONNECT_URL_MAX} characters (${chars(value)} characters)`;
|
|
36
|
+
if (/[\s\x00-\x1f\x7f\\]/.test(value))
|
|
37
|
+
return 'must not have spaces, control characters or backslashes';
|
|
38
|
+
if (value.includes('#'))
|
|
39
|
+
return 'must not have # (the part after # is not sent to the server)';
|
|
40
|
+
let u;
|
|
41
|
+
try {
|
|
42
|
+
u = new URL(value);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return 'is not an address';
|
|
46
|
+
}
|
|
47
|
+
if (u.username !== '' || u.password !== '' || /^[^:/?]+:\/\/[^/?]*@/.test(value))
|
|
48
|
+
return 'must not have user information (user@)';
|
|
49
|
+
if (u.protocol === 'https:')
|
|
50
|
+
return null;
|
|
51
|
+
if (u.protocol === 'http:' && (u.hostname === '127.0.0.1' || u.hostname === 'localhost'))
|
|
52
|
+
return null;
|
|
53
|
+
return 'must be https (http is accepted only for 127.0.0.1 and localhost, for tests)';
|
|
54
|
+
}
|
|
55
|
+
/** requires.external[].connect 의 모양(032 44.2절). */
|
|
56
|
+
function connectProblem(where, value) {
|
|
57
|
+
const shape = objectProblem(where, value, ['connection', 'url', 'title', 'messages']);
|
|
58
|
+
if (shape)
|
|
59
|
+
return shape;
|
|
60
|
+
const c = value;
|
|
61
|
+
if (typeof c.connection !== 'string' || !CONNECTION_NAME.test(c.connection)) {
|
|
62
|
+
return `${where}.connection must be up to 64 characters of English letters, digits, ., _ and -, starting with a letter or digit`;
|
|
63
|
+
}
|
|
64
|
+
if (WINDOWS_DEVICE.test(c.connection))
|
|
65
|
+
return `${where}.connection ${c.connection} is a name Windows keeps for a device, so it cannot be used`;
|
|
66
|
+
const url = connectUrlProblem(c.url);
|
|
67
|
+
if (url)
|
|
68
|
+
return `${where}.url ${url}`;
|
|
69
|
+
if (c.title !== undefined) {
|
|
70
|
+
const title = textProblem(`${where}.title`, c.title, 100);
|
|
71
|
+
if (title)
|
|
72
|
+
return title;
|
|
73
|
+
}
|
|
74
|
+
if (c.messages !== undefined && (!isPluginPath(c.messages) || !c.messages.endsWith('.json'))) {
|
|
75
|
+
return `${where}.messages ${JSON.stringify(c.messages)} must be a relative path to a message table file (.json) inside the plugin folder (for example link/messages.json)`;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
17
79
|
/** `계정이름.플러그인이름` 모양인가. 각 부분은 영어 소문자, 숫자, `-` 이고 2자에서 40자다(036 4절). */
|
|
18
80
|
export function isPluginId(id) {
|
|
19
81
|
if (typeof id !== 'string')
|
|
@@ -77,9 +139,12 @@ function requiresProblem(value) {
|
|
|
77
139
|
return 'requires.external must be a list of external tools';
|
|
78
140
|
if (r.external.length > 10)
|
|
79
141
|
return `requires.external can have up to 10 entries (${r.external.length} given)`;
|
|
142
|
+
// 화면은 connectExternal 에 name 을 주고 코어는 connect.connection 으로 연결을 만든다. 둘 다 겹치면 어느 것인지 모른다(032 44.3절)
|
|
143
|
+
const connectNames = new Set();
|
|
144
|
+
const connections = new Set();
|
|
80
145
|
for (const [i, t] of r.external.entries()) {
|
|
81
146
|
const where = `requires.external[${i}]`;
|
|
82
|
-
const shape = objectProblem(where, t, ['name', 'kind', 'account', 'install', 'note']);
|
|
147
|
+
const shape = objectProblem(where, t, ['name', 'kind', 'account', 'install', 'note', 'connect']);
|
|
83
148
|
if (shape)
|
|
84
149
|
return shape;
|
|
85
150
|
const tool = t;
|
|
@@ -97,6 +162,20 @@ function requiresProblem(value) {
|
|
|
97
162
|
if (note)
|
|
98
163
|
return note;
|
|
99
164
|
}
|
|
165
|
+
if (tool.connect !== undefined) {
|
|
166
|
+
if (tool.kind !== 'mcp')
|
|
167
|
+
return `${where}.connect is only for kind "mcp" (an MCP server the core connects to)`;
|
|
168
|
+
const connect = connectProblem(`${where}.connect`, tool.connect);
|
|
169
|
+
if (connect)
|
|
170
|
+
return connect;
|
|
171
|
+
const c = tool.connect;
|
|
172
|
+
if (connectNames.has(tool.name))
|
|
173
|
+
return `requires.external has two entries with connect named ${tool.name}`;
|
|
174
|
+
if (connections.has(c.connection))
|
|
175
|
+
return `requires.external has two entries that make the connection ${c.connection}`;
|
|
176
|
+
connectNames.add(tool.name);
|
|
177
|
+
connections.add(c.connection);
|
|
178
|
+
}
|
|
100
179
|
}
|
|
101
180
|
}
|
|
102
181
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aicommunicator-plugin-check",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Checks the rules for the manifest and package file (.tgz) of AIC (aicommunicator) plugins. Shared by the AIC core, the aic command, and the plugin registry site",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|