@verentis/cli 1.0.1 → 1.0.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/index.js +80 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2013,6 +2013,7 @@ function validatePackageManifestRules(kind, manifest) {
|
|
|
2013
2013
|
...launchKindError ? [`${launchKindError}.`] : [],
|
|
2014
2014
|
...validateNativeCollaborationSection(kind, manifest.spec),
|
|
2015
2015
|
...validateMessageChannelsSection(kind, manifest.spec),
|
|
2016
|
+
...validateChatSection(kind, manifest.spec),
|
|
2016
2017
|
...validateActorSection(kind, manifest.spec),
|
|
2017
2018
|
...validateWopiOperationsSection(manifest.spec),
|
|
2018
2019
|
...validateApplicationSplashSection(kind, manifest.spec),
|
|
@@ -2051,6 +2052,10 @@ async function loadManifest(path) {
|
|
|
2051
2052
|
if (messageErrors.length > 0) {
|
|
2052
2053
|
throw new Error(`Invalid manifest at ${path}: ${messageErrors.join(" ")}`);
|
|
2053
2054
|
}
|
|
2055
|
+
const chatErrors = validateChatSection(kind, manifest.spec);
|
|
2056
|
+
if (chatErrors.length > 0) {
|
|
2057
|
+
throw new Error(`Invalid manifest at ${path}: ${chatErrors.join(" ")}`);
|
|
2058
|
+
}
|
|
2054
2059
|
const actorErrors = validateActorSection(kind, manifest.spec);
|
|
2055
2060
|
if (actorErrors.length > 0) {
|
|
2056
2061
|
throw new Error(`Invalid manifest at ${path}: ${actorErrors.join(" ")}`);
|
|
@@ -2165,6 +2170,80 @@ function validateMessageChannelsSection(kind, spec) {
|
|
|
2165
2170
|
});
|
|
2166
2171
|
return errors;
|
|
2167
2172
|
}
|
|
2173
|
+
var CHAT_KEY_PATTERN = /^[a-z][a-z0-9-]{1,31}$/;
|
|
2174
|
+
var CHAT_ARGUMENT_PATTERN = /^[a-z][a-z0-9_]{0,31}$/;
|
|
2175
|
+
var CHAT_RESERVED_ARGUMENT_PREFIX = "chat_";
|
|
2176
|
+
var MAX_CHAT_BOTS = 5;
|
|
2177
|
+
var MAX_CHAT_COMMANDS = 25;
|
|
2178
|
+
var MAX_CHAT_ARGUMENTS = 10;
|
|
2179
|
+
function validateChatSection(kind, spec) {
|
|
2180
|
+
if (!spec || typeof spec !== "object" || Array.isArray(spec) || !Object.prototype.hasOwnProperty.call(spec, "chat")) return [];
|
|
2181
|
+
if (!isApplicationProfile(kind)) return ["spec.chat is only supported for Application manifests."];
|
|
2182
|
+
const record = spec;
|
|
2183
|
+
const chat = record.chat;
|
|
2184
|
+
if (!chat || typeof chat !== "object" || Array.isArray(chat)) return ["spec.chat must be an object with bots and/or commands."];
|
|
2185
|
+
const { bots = [], commands = [] } = chat;
|
|
2186
|
+
const errors = [];
|
|
2187
|
+
const botKeys = /* @__PURE__ */ new Set();
|
|
2188
|
+
if (!Array.isArray(bots)) errors.push("spec.chat.bots must be a list.");
|
|
2189
|
+
else {
|
|
2190
|
+
if (bots.length > MAX_CHAT_BOTS) errors.push(`spec.chat.bots declares more than ${MAX_CHAT_BOTS} bots.`);
|
|
2191
|
+
bots.forEach((value, index) => {
|
|
2192
|
+
const path = `spec.chat.bots[${index}]`;
|
|
2193
|
+
const bot = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2194
|
+
if (typeof bot.key !== "string" || !CHAT_KEY_PATTERN.test(bot.key)) errors.push(`${path}.key must match ${CHAT_KEY_PATTERN.source}.`);
|
|
2195
|
+
else if (botKeys.has(bot.key)) errors.push(`${path}.key '${bot.key}' is declared more than once.`);
|
|
2196
|
+
else botKeys.add(bot.key);
|
|
2197
|
+
if (typeof bot["display-name"] !== "string" || !bot["display-name"].trim()) errors.push(`${path}.display-name is required.`);
|
|
2198
|
+
});
|
|
2199
|
+
const permissions = Array.isArray(record.permissions) ? record.permissions : [];
|
|
2200
|
+
if (bots.length > 0 && !permissions.includes("chat.write")) {
|
|
2201
|
+
errors.push("spec.permissions must include chat.write for the app to post as its bots.");
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
const scripts = (Array.isArray(record.scripts) ? record.scripts : []).filter((script) => typeof script === "string").map((script) => script.trim().replace(/^\.\//, "").replace(/\/+$/, ""));
|
|
2205
|
+
const names = /* @__PURE__ */ new Set();
|
|
2206
|
+
if (!Array.isArray(commands)) errors.push("spec.chat.commands must be a list.");
|
|
2207
|
+
else {
|
|
2208
|
+
if (commands.length > MAX_CHAT_COMMANDS) errors.push(`spec.chat.commands declares more than ${MAX_CHAT_COMMANDS} commands.`);
|
|
2209
|
+
commands.forEach((value, index) => {
|
|
2210
|
+
const path = `spec.chat.commands[${index}]`;
|
|
2211
|
+
const command = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2212
|
+
if (typeof command.name !== "string" || !CHAT_KEY_PATTERN.test(command.name)) errors.push(`${path}.name must match ${CHAT_KEY_PATTERN.source}.`);
|
|
2213
|
+
else if (names.has(command.name)) errors.push(`${path}.name '${command.name}' is declared more than once.`);
|
|
2214
|
+
else names.add(command.name);
|
|
2215
|
+
const script = typeof command.script === "string" ? command.script.trim().replace(/^\.\//, "") : "";
|
|
2216
|
+
if (!script || script.split("/").some((segment) => segment === "" || segment === "." || segment === "..") || !scripts.some((program2) => script.startsWith(`${program2}/`))) {
|
|
2217
|
+
errors.push(`${path}.script must be the entry file of a program listed in spec.scripts (e.g. scripts/approve/main.mjs).`);
|
|
2218
|
+
}
|
|
2219
|
+
if (command.bot !== void 0 && (typeof command.bot !== "string" || !botKeys.has(command.bot))) {
|
|
2220
|
+
errors.push(`${path}.bot must name a bot declared in spec.chat.bots.`);
|
|
2221
|
+
}
|
|
2222
|
+
const args = command.arguments ?? [];
|
|
2223
|
+
if (!Array.isArray(args) || args.length > MAX_CHAT_ARGUMENTS) {
|
|
2224
|
+
errors.push(`${path}.arguments must be a list of at most ${MAX_CHAT_ARGUMENTS} arguments.`);
|
|
2225
|
+
return;
|
|
2226
|
+
}
|
|
2227
|
+
const argumentNames = /* @__PURE__ */ new Set();
|
|
2228
|
+
args.forEach((argumentValue, argumentIndex) => {
|
|
2229
|
+
const argumentPath = `${path}.arguments[${argumentIndex}]`;
|
|
2230
|
+
const argument = argumentValue && typeof argumentValue === "object" && !Array.isArray(argumentValue) ? argumentValue : {};
|
|
2231
|
+
if (typeof argument.name !== "string" || !CHAT_ARGUMENT_PATTERN.test(argument.name) || argumentNames.has(argument.name)) {
|
|
2232
|
+
errors.push(`${argumentPath}.name must be a unique name matching ${CHAT_ARGUMENT_PATTERN.source}.`);
|
|
2233
|
+
} else if (argument.name.startsWith(CHAT_RESERVED_ARGUMENT_PREFIX)) {
|
|
2234
|
+
errors.push(`${argumentPath}.name must not start with '${CHAT_RESERVED_ARGUMENT_PREFIX}': Chat reserves it for the context it passes to command scripts.`);
|
|
2235
|
+
} else argumentNames.add(argument.name);
|
|
2236
|
+
if (argument.type !== void 0 && !["string", "number", "boolean"].includes(argument.type)) {
|
|
2237
|
+
errors.push(`${argumentPath}.type must be string, number or boolean.`);
|
|
2238
|
+
}
|
|
2239
|
+
if (argument.required !== void 0 && typeof argument.required !== "boolean") {
|
|
2240
|
+
errors.push(`${argumentPath}.required must be true or false.`);
|
|
2241
|
+
}
|
|
2242
|
+
});
|
|
2243
|
+
});
|
|
2244
|
+
}
|
|
2245
|
+
return errors;
|
|
2246
|
+
}
|
|
2168
2247
|
var ACTOR_SURFACE_KINDS = ["app-backend", "mcp", "native-collaboration", "document", "raw-file"];
|
|
2169
2248
|
var ACTOR_FILE_KINDS = /* @__PURE__ */ new Set(["native-collaboration", "document", "raw-file"]);
|
|
2170
2249
|
var MAX_ACTOR_SURFACES = 16;
|
|
@@ -2519,6 +2598,7 @@ function validateManifest(manifest) {
|
|
|
2519
2598
|
for (const message of validateDependencies(spec)) error(message);
|
|
2520
2599
|
for (const message of validateNativeCollaborationSection(kind, spec)) error(message);
|
|
2521
2600
|
for (const message of validateMessageChannelsSection(kind, spec)) error(message);
|
|
2601
|
+
for (const message of validateChatSection(kind, spec)) error(message);
|
|
2522
2602
|
for (const message of validateActorSection(kind, spec)) error(message);
|
|
2523
2603
|
for (const message of validateApplicationSplashSection(kind, spec)) error(message);
|
|
2524
2604
|
for (const message of validateTypeSpecFields(kind, spec)) error(message);
|