fix(runtime): restrict system miniapp registration

This commit is contained in:
2026-08-06 01:37:07 +08:00
parent e91d07b389
commit fec04a90d7
2 changed files with 15 additions and 0 deletions
@@ -16,6 +16,7 @@ import type { JsonObject } from "@/runtime/protocol/lineup-v1";
export type AppScope = "chat" | "app-registry" | "settings" | "runtime" | (string & {});
export type MiniAppKind = "system" | "bundled";
const SYSTEM_APP_SCOPE: AppScope = "chat";
export type AppToolDefinition = {
name: string;
@@ -134,6 +135,7 @@ export class CoreAppRegistry {
private register(record: CoreAppRecordInput): void {
if (!isAppScope(record.app_scope) || record.manifest.app_scope !== record.app_scope) throw new Error("Core App Registry received an invalid app_scope.");
if (record.kind === "system" && record.app_scope !== SYSTEM_APP_SCOPE) throw new Error("Only the Interact system MiniApp may use kind=system in SDK v1.");
if (this.apps.has(record.app_scope)) throw new Error(`Core App Registry has duplicate app_scope: ${record.app_scope}`);
if (!isManifest(record.manifest)) throw new Error(`Core App Registry has an invalid manifest: ${record.app_scope}`);
this.apps.set(record.app_scope, copyRecord(record));