@verentis/cli 0.2.27 → 0.2.29

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 CHANGED
@@ -1077,6 +1077,14 @@ async function loadManifest(path) {
1077
1077
  if (collaborationErrors.length > 0) {
1078
1078
  throw new Error(`Invalid manifest at ${path}: ${collaborationErrors.join(" ")}`);
1079
1079
  }
1080
+ const messageErrors = validateMessageChannelsSection(kind, manifest.spec);
1081
+ if (messageErrors.length > 0) {
1082
+ throw new Error(`Invalid manifest at ${path}: ${messageErrors.join(" ")}`);
1083
+ }
1084
+ const actorErrors = validateActorSection(kind, manifest.spec);
1085
+ if (actorErrors.length > 0) {
1086
+ throw new Error(`Invalid manifest at ${path}: ${actorErrors.join(" ")}`);
1087
+ }
1080
1088
  const operationErrors = validateWopiOperationsSection(manifest.spec);
1081
1089
  if (operationErrors.length > 0) {
1082
1090
  throw new Error(`Invalid manifest at ${path}: ${operationErrors.join(" ")}`);
@@ -1143,6 +1151,135 @@ function validateHostedBackendDeclaration(kind, spec) {
1143
1151
  }
1144
1152
  return [];
1145
1153
  }
1154
+ var MESSAGE_CHANNEL_PATTERN = /^[a-z0-9][a-z0-9._-]{0,63}$/;
1155
+ var MAX_MESSAGE_CHANNELS = 32;
1156
+ function validateMessageChannelsSection(kind, spec) {
1157
+ if (!spec || typeof spec !== "object" || Array.isArray(spec) || !Object.prototype.hasOwnProperty.call(spec, "messages")) return [];
1158
+ if (kind !== "Application") return ["spec.messages is only supported for Application manifests."];
1159
+ const messages = spec.messages;
1160
+ if (!Array.isArray(messages)) return ["spec.messages must be a list of { channel, description, schema? }."];
1161
+ if (messages.length > MAX_MESSAGE_CHANNELS) return [`spec.messages declares more than ${MAX_MESSAGE_CHANNELS} channels.`];
1162
+ const errors = [];
1163
+ const seen = /* @__PURE__ */ new Set();
1164
+ messages.forEach((value, index) => {
1165
+ const path = `spec.messages[${index}]`;
1166
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
1167
+ errors.push(`${path} must be an object with channel and description.`);
1168
+ return;
1169
+ }
1170
+ const { channel, description, schema } = value;
1171
+ if (typeof channel !== "string" || !MESSAGE_CHANNEL_PATTERN.test(channel)) {
1172
+ errors.push(`${path}.channel must match ${MESSAGE_CHANNEL_PATTERN.source}.`);
1173
+ } else if (seen.has(channel)) {
1174
+ errors.push(`${path}.channel '${channel}' is declared more than once.`);
1175
+ } else {
1176
+ seen.add(channel);
1177
+ }
1178
+ if (typeof description !== "string" || description.trim().length === 0) {
1179
+ errors.push(`${path}.description is required so agents know when to use the channel.`);
1180
+ }
1181
+ if (schema !== void 0 && (!schema || typeof schema !== "object" || Array.isArray(schema))) {
1182
+ errors.push(`${path}.schema must be a JSON Schema object.`);
1183
+ }
1184
+ });
1185
+ return errors;
1186
+ }
1187
+ var ACTOR_SURFACE_KINDS = ["app-backend", "mcp", "native-collaboration", "document", "raw-file"];
1188
+ var ACTOR_FILE_KINDS = /* @__PURE__ */ new Set(["native-collaboration", "document", "raw-file"]);
1189
+ var MAX_ACTOR_SURFACES = 16;
1190
+ function validateActorSection(kind, spec) {
1191
+ if (!spec || typeof spec !== "object" || Array.isArray(spec) || !Object.prototype.hasOwnProperty.call(spec, "actor")) return [];
1192
+ if (kind !== "Application") return ["spec.actor is only supported for Application manifests."];
1193
+ const applicationSpec = spec;
1194
+ const actor = applicationSpec.actor;
1195
+ if (!actor || typeof actor !== "object" || Array.isArray(actor)) {
1196
+ return ["spec.actor must be an object with live-channel and/or surfaces."];
1197
+ }
1198
+ const { "live-channel": liveChannel, surfaces } = actor;
1199
+ const errors = [];
1200
+ if (liveChannel !== void 0) {
1201
+ const declared = Array.isArray(applicationSpec.messages) && applicationSpec.messages.some((m) => m && typeof m === "object" && m.channel === liveChannel);
1202
+ if (typeof liveChannel !== "string" || !declared) {
1203
+ errors.push("spec.actor.live-channel must name a channel declared in spec.messages.");
1204
+ }
1205
+ }
1206
+ if (surfaces === void 0) {
1207
+ if (liveChannel === void 0) errors.push("spec.actor must declare live-channel and/or surfaces.");
1208
+ return errors;
1209
+ }
1210
+ if (!Array.isArray(surfaces) || surfaces.length === 0) {
1211
+ errors.push("spec.actor.surfaces must be a non-empty list of { kind, ... }.");
1212
+ return errors;
1213
+ }
1214
+ if (surfaces.length > MAX_ACTOR_SURFACES) {
1215
+ errors.push(`spec.actor.surfaces declares more than ${MAX_ACTOR_SURFACES} surfaces.`);
1216
+ return errors;
1217
+ }
1218
+ const appTools = declaredTools(applicationSpec);
1219
+ surfaces.forEach((value, index) => {
1220
+ const path = `spec.actor.surfaces[${index}]`;
1221
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
1222
+ errors.push(`${path} must be an object with a kind.`);
1223
+ return;
1224
+ }
1225
+ const surface = value;
1226
+ const surfaceKind = surface.kind;
1227
+ if (typeof surfaceKind !== "string" || !ACTOR_SURFACE_KINDS.includes(surfaceKind)) {
1228
+ errors.push(`${path}.kind must be one of ${ACTOR_SURFACE_KINDS.join(", ")}.`);
1229
+ return;
1230
+ }
1231
+ const mimeTypes = surface["mime-types"];
1232
+ const extensions = surface.extensions;
1233
+ for (const [name, list] of [["mime-types", mimeTypes], ["extensions", extensions]]) {
1234
+ if (list !== void 0 && (!Array.isArray(list) || list.some((item) => typeof item !== "string" || item.trim().length === 0))) {
1235
+ errors.push(`${path}.${name} must be a list of non-empty strings.`);
1236
+ }
1237
+ }
1238
+ const filters = (Array.isArray(mimeTypes) ? mimeTypes.length : 0) + (Array.isArray(extensions) ? extensions.length : 0);
1239
+ if (ACTOR_FILE_KINDS.has(surfaceKind)) {
1240
+ if (filters === 0) errors.push(`${path} (${surfaceKind}) must list mime-types and/or extensions.`);
1241
+ } else if (mimeTypes !== void 0 || extensions !== void 0) {
1242
+ errors.push(`${path} (${surfaceKind}) is not a file surface and cannot list mime-types or extensions.`);
1243
+ }
1244
+ if (surface.format !== void 0 && (surfaceKind !== "raw-file" || surface.format !== "text" && surface.format !== "json")) {
1245
+ errors.push(`${path}.format is only for raw-file surfaces and must be text or json.`);
1246
+ }
1247
+ if (surface.description !== void 0 && typeof surface.description !== "string") {
1248
+ errors.push(`${path}.description must be a string.`);
1249
+ }
1250
+ if (surfaceKind === "native-collaboration" && applicationSpec.collaboration?.mode !== "native-scene-v1") {
1251
+ errors.push(`${path} (native-collaboration) requires spec.collaboration.mode native-scene-v1.`);
1252
+ }
1253
+ for (const name of ["read-tool", "apply-tool"]) {
1254
+ const key = surface[name];
1255
+ if (key === void 0) continue;
1256
+ if (!ACTOR_FILE_KINDS.has(surfaceKind)) {
1257
+ errors.push(`${path}.${name} is only for file surfaces (${[...ACTOR_FILE_KINDS].join(", ")}).`);
1258
+ continue;
1259
+ }
1260
+ const tool = typeof key === "string" ? appTools.get(key) : void 0;
1261
+ if (!tool) {
1262
+ errors.push(`${path}.${name} must name a tool declared in spec.tools.`);
1263
+ } else if (name === "read-tool" && (tool.effect !== "read" || tool.approval === "always")) {
1264
+ errors.push(`${path}.read-tool '${key}' must be a read tool (effect: read) without approval: always.`);
1265
+ }
1266
+ }
1267
+ if (surfaceKind === "document" && surface["read-tool"] === void 0 && !Object.prototype.hasOwnProperty.call(applicationSpec, "wopi")) {
1268
+ errors.push(`${path} (document) requires spec.wopi or a read-tool.`);
1269
+ }
1270
+ });
1271
+ return errors;
1272
+ }
1273
+ function declaredTools(spec) {
1274
+ const tools = /* @__PURE__ */ new Map();
1275
+ if (!Array.isArray(spec.tools)) return tools;
1276
+ for (const tool of spec.tools) {
1277
+ if (tool && typeof tool === "object" && typeof tool.key === "string") {
1278
+ tools.set(tool.key, tool);
1279
+ }
1280
+ }
1281
+ return tools;
1282
+ }
1146
1283
  function validateNativeCollaborationSection(kind, spec) {
1147
1284
  if (!spec || typeof spec !== "object" || Array.isArray(spec) || !Object.prototype.hasOwnProperty.call(spec, "collaboration")) return [];
1148
1285
  if (kind !== "Application") return ["spec.collaboration is only supported for Application manifests."];
@@ -1355,6 +1492,8 @@ function validateManifest(manifest) {
1355
1492
  for (const message of validateHostedBackendDeclaration(kind, spec)) error(message);
1356
1493
  for (const message of validateDependencies(spec)) error(message);
1357
1494
  for (const message of validateNativeCollaborationSection(kind, spec)) error(message);
1495
+ for (const message of validateMessageChannelsSection(kind, spec)) error(message);
1496
+ for (const message of validateActorSection(kind, spec)) error(message);
1358
1497
  if (kind === "ExecutionEngine") {
1359
1498
  const runtimes = spec.runtimes ?? {};
1360
1499
  if (Object.keys(runtimes).length === 0) {