diff --git a/tauri/src/runtime/app-management/app-registry.test.ts b/tauri/src/runtime/app-management/app-registry.test.ts new file mode 100644 index 0000000..2ab58e0 --- /dev/null +++ b/tauri/src/runtime/app-management/app-registry.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from "vitest"; +import { CoreAppRegistry } from "@/runtime/app-management/app-registry"; + +describe("CoreAppRegistry SDK v1 kind policy", () => { + it("keeps Interact as the only system MiniApp", () => { + const registry = new CoreAppRegistry(); + expect(registry.get("chat")?.kind).toBe("system"); + expect(() => registry.install({ + app_scope: "other-system", kind: "system", enabled: true, default_eligible: false, recovery: false, + manifest: { app_scope: "other-system", version: "1.0.0", permissions: [], tools: [] }, + })).toThrow("Only the Interact system MiniApp"); + }); +}); diff --git a/tauri/src/runtime/app-management/app-registry.ts b/tauri/src/runtime/app-management/app-registry.ts index 12a4985..bd55550 100644 --- a/tauri/src/runtime/app-management/app-registry.ts +++ b/tauri/src/runtime/app-management/app-registry.ts @@ -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));