@anna-ai/cli 0.1.21 → 0.1.22
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/cli.js +12 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -160,14 +160,22 @@ function checkHostApiAllowance(usages, manifest, bundleMethods) {
|
|
|
160
160
|
//#endregion
|
|
161
161
|
//#region src/validate/ui-section.ts
|
|
162
162
|
/**
|
|
163
|
-
* Static validation of `manifest.ui` —
|
|
163
|
+
* Static validation of `manifest.ui` — port of
|
|
164
164
|
* `src/services/anna_app_validator.py::validate_ui_section_static` from
|
|
165
165
|
* matrix-nexus. Keep these algorithms byte-equivalent: any divergence here
|
|
166
166
|
* means `anna-app validate` will lie about what production accepts.
|
|
167
|
+
*
|
|
168
|
+
* One intentional divergence: this CLI validates the **source** manifest
|
|
169
|
+
* *before* publish, so it must additionally tolerate the `bundled:<handle>`
|
|
170
|
+
* placeholder form in `host_api.tools` / `required_executas[].tool_id`.
|
|
171
|
+
* Those placeholders are resolved to real tool_ids at publish time by
|
|
172
|
+
* `substituteBundledRefs` (src/publish/bundled-executas.ts); production
|
|
173
|
+
* (the Python validator) only ever sees the substituted manifest, where
|
|
174
|
+
* the `bundled:` prefix is gone.
|
|
167
175
|
*/
|
|
168
176
|
const VIEW_NAME_PATTERN = /^[a-z0-9_-]{1,40}$/;
|
|
169
177
|
const BUNDLE_PATH_PATTERN = /^[A-Za-z0-9_./\-]+$/;
|
|
170
|
-
const HOST_API_TOOL_REF_PATTERN = /^(?:required:\*|optional:\*|required:[A-Za-z0-9_.\-]+|optional:[A-Za-z0-9_.\-]+|[A-Za-z0-9_.\-]+)$/;
|
|
178
|
+
const HOST_API_TOOL_REF_PATTERN = /^(?:required:\*|optional:\*|(?:required:|optional:)?bundled:[A-Za-z0-9_.\-]+|required:[A-Za-z0-9_.\-]+|optional:[A-Za-z0-9_.\-]+|[A-Za-z0-9_.\-]+)$/;
|
|
171
179
|
const CSP_OVERRIDABLE_DIRECTIVES = new Set([
|
|
172
180
|
"connect-src",
|
|
173
181
|
"img-src",
|
|
@@ -211,7 +219,8 @@ function validateUiSectionStatic(manifest) {
|
|
|
211
219
|
continue;
|
|
212
220
|
}
|
|
213
221
|
if (ref === "required:*" || ref === "optional:*") continue;
|
|
214
|
-
const
|
|
222
|
+
const colon = ref.indexOf(":");
|
|
223
|
+
const bare = ref.startsWith("required:") || ref.startsWith("optional:") ? ref.slice(colon + 1) : ref;
|
|
215
224
|
if (!requiredIds.has(bare) && !optionalIds.has(bare)) errors.push(`host_api.tools 引用未在 manifest 中声明的 tool_id: ${ref}`);
|
|
216
225
|
}
|
|
217
226
|
const cspOverrides = ui.csp_overrides ?? {};
|