From 44b6a83a300d298c8afd179d8de502a7449ec06c Mon Sep 17 00:00:00 2001 From: kyugao Date: Thu, 6 Aug 2026 01:31:38 +0800 Subject: [PATCH] fix(runtime): freeze miniapp kind vocabulary --- tauri/src/runtime/app-management/app-registry.ts | 11 +++++++---- tauri/src/runtime/coordination/lineup-runtime.test.ts | 2 +- tauri/src/runtime/coordination/tool-router.test.ts | 2 +- tauri/src/runtime/inventory/client-inventory.test.ts | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tauri/src/runtime/app-management/app-registry.ts b/tauri/src/runtime/app-management/app-registry.ts index 0741aa7..806d041 100644 --- a/tauri/src/runtime/app-management/app-registry.ts +++ b/tauri/src/runtime/app-management/app-registry.ts @@ -52,8 +52,12 @@ export type CoreAppRecord = { manifest: AppManifest; }; -/** Transitional input accepted while older host adapters are upgraded. */ -export type CoreAppRecordInput = Omit & { kind: MiniAppKind | "core" | "extension" }; +/** + * The Runtime installation boundary uses the frozen SDK v1 vocabulary. + * Legacy host labels (`core` / `extension`) are intentionally not accepted + * here; callers must migrate before they can register an App. + */ +export type CoreAppRecordInput = Omit & { kind: MiniAppKind }; const INITIAL_CORE_APPS: readonly CoreAppRecord[] = [ { @@ -132,8 +136,7 @@ export class CoreAppRegistry { if (!isAppScope(record.app_scope) || record.manifest.app_scope !== record.app_scope) throw new Error("Core App Registry received an invalid app_scope."); 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}`); - const kind: MiniAppKind = record.kind === "core" ? "system" : record.kind === "extension" ? "bundled" : record.kind; - this.apps.set(record.app_scope, copyRecord({ ...record, kind })); + this.apps.set(record.app_scope, copyRecord(record)); } } diff --git a/tauri/src/runtime/coordination/lineup-runtime.test.ts b/tauri/src/runtime/coordination/lineup-runtime.test.ts index c9a8878..f1eb1f1 100644 --- a/tauri/src/runtime/coordination/lineup-runtime.test.ts +++ b/tauri/src/runtime/coordination/lineup-runtime.test.ts @@ -69,7 +69,7 @@ describe("LineUpRuntime", () => { const transport = new FakeTransport([[{ message_seq: 30, from_uid: "agent_1", payload: launch }], []]); const runtime = new LineUpRuntime({ storage, createTransport: () => transport, now: () => "2026-08-04T00:00:00.000Z" }); runtime.apps.install({ - app_scope: "draw-and-guess", kind: "extension", enabled: true, default_eligible: false, recovery: false, + app_scope: "draw-and-guess", kind: "bundled", enabled: true, default_eligible: false, recovery: false, manifest: { app_scope: "draw-and-guess", version: "1.0.0", permissions: [], tools: [{ name: "app.launch", handling: "launch", parameters: ["app_scope", "instance_id"] }] }, }); await runtime.login(login); diff --git a/tauri/src/runtime/coordination/tool-router.test.ts b/tauri/src/runtime/coordination/tool-router.test.ts index b9158db..8364083 100644 --- a/tauri/src/runtime/coordination/tool-router.test.ts +++ b/tauri/src/runtime/coordination/tool-router.test.ts @@ -4,7 +4,7 @@ import { ToolRouter } from "@/runtime/coordination/tool-router"; function extension(enabled = true) { return { - app_scope: "draw-and-guess", kind: "extension" as const, enabled, default_eligible: false, recovery: false, + app_scope: "draw-and-guess", kind: "bundled" as const, enabled, default_eligible: false, recovery: false, manifest: { app_scope: "draw-and-guess", version: "1.0.0", permissions: [], tools: [{ name: "app.launch", handling: "launch" as const, parameters: ["app_scope"] }] }, }; } diff --git a/tauri/src/runtime/inventory/client-inventory.test.ts b/tauri/src/runtime/inventory/client-inventory.test.ts index 703c990..7b5cb2f 100644 --- a/tauri/src/runtime/inventory/client-inventory.test.ts +++ b/tauri/src/runtime/inventory/client-inventory.test.ts @@ -36,7 +36,7 @@ describe("ClientInventoryPublisher", () => { it("advertises only enabled Runtime manifests and their declarative tools", () => { const inventory = new ClientInventoryPublisher().sync(new SurfaceRegistry().snapshot(), new CapabilityRegistry().inventory(), [{ - app_scope: "draw-and-guess", kind: "extension", enabled: true, default_eligible: false, recovery: false, + app_scope: "draw-and-guess", kind: "bundled", enabled: true, default_eligible: false, recovery: false, manifest: { app_scope: "draw-and-guess", version: "1.0.0", permissions: [], tools: [{ name: "app.launch", handling: "launch", parameters: ["app_scope"] }] }, }]).inventory; expect(inventory.applications).toContainEqual(expect.objectContaining({ id: "draw-and-guess", tools: [{ name: "app.launch", handling: "launch" }] }));