refactor(runtime): remove legacy extension sdk bypass

This commit is contained in:
2026-08-06 00:55:17 +08:00
parent 75529cdd49
commit 20e63dc0dd
4 changed files with 4 additions and 47 deletions
@@ -115,21 +115,6 @@ export interface InteractRuntimeSDK {
/** @deprecated Use InteractRuntimeSDK; kept for the compatibility app_scope=chat name. */
export type ChatRuntimeSDK = InteractRuntimeSDK;
/**
* The intentionally smaller SDK granted to an installed Extension App. It
* does not reveal another App's inbox, the focus stack, Transport, DOM root,
* storage, credentials, or Host capabilities.
*/
export interface ExtensionRuntimeSDK {
readonly app_scope: AppScope;
readonly instance_id: string;
readonly conversation_id: string;
listMessages(afterMessageID?: string): readonly ScopedConversationItem[];
acknowledgeMessage(messageID: string): boolean;
reportResult(result: JsonObject): Promise<CommandReceipt>;
reportFailure(message: string): void;
}
export type RuntimeAppEvent =
| { type: "agent-message"; message: ScopedConversationItem }
| { type: "local-item"; item: ConversationItem; local_id: string }
@@ -84,11 +84,6 @@ describe("LineUpRuntime", () => {
const interaction = runtime.lifecycle.instances.activeFor("chat", conversationID);
expect(interaction).toMatchObject({ state: "background" });
expect(runtime.snapshot()?.app_inbox).toEqual([expect.objectContaining({ app_scope: "draw-and-guess", message_id: "launch-game" })]);
const game = runtime.openExtensionApp("draw-and-guess", "draw-and-guess:game-001");
expect(game.listMessages()).toEqual([expect.objectContaining({ scope: { app_scope: "draw-and-guess", conversation_id: conversationID } })]);
expect(await game.reportResult({ winner: "user_1" })).toMatchObject({ disposition: "accepted" });
expect(transport.sent.at(-1)?.payload).toContain("lineup.v1.app.result");
runtime.closeAppInstance("draw-and-guess:game-001");
expect(runtime.lifecycle.focus.foreground()).toBe(interaction?.instance_id);
expect(runtime.lifecycle.instances.get(interaction!.instance_id)).toMatchObject({ state: "foreground" });
@@ -21,7 +21,6 @@ import {
type ChatRuntimeSDK,
type ChatViewModel,
type CommandReceipt,
type ExtensionRuntimeSDK,
type RuntimeAppEvent,
type Unsubscribe,
} from "@/runtime/app-management/app-sdk";
@@ -295,23 +294,6 @@ export class LineUpRuntime {
};
}
/** Opens a per-instance Extension projection after Runtime has started it. */
public openExtensionApp(appScope: AppScope, instanceID: string): ExtensionRuntimeSDK {
const app = this.apps.get(appScope);
const instance = this.lifecycle.instances.get(instanceID);
const conversationID = this.requireConversationID();
if (!app || app.kind !== "bundled" || !app.enabled || !instance || instance.app_scope !== appScope || instance.conversation_id !== conversationID) {
throw new Error("Bundled MiniApp SDK is unavailable for this instance.");
}
return {
app_scope: appScope, instance_id: instanceID, conversation_id: conversationID,
listMessages: afterMessageID => this.listAppMessages(appScope, afterMessageID),
acknowledgeMessage: messageID => this.store.acknowledgeAppInbox(appScope, messageID),
reportResult: result => this.queueProtocolAction("app-result", "lineup.v1.app.result", { instance_id: instanceID, app_scope: appScope, result }),
reportFailure: message => this.closeAppInstance(instanceID, boundedFailure(message)),
};
}
/** The restricted SDK injected into a bundled MiniApp instance. */
public openBundledMiniApp(appScope: AppScope, instanceID: string): LineUpMiniAppSDK {
const app = this.apps.get(appScope);
@@ -1295,11 +1277,6 @@ export class LineUpRuntime {
}
}
function boundedFailure(value: string): string {
const message = value.trim();
return message ? message.slice(0, 500) : "Extension App failed.";
}
function appSessionHistory(records: readonly StandardInteractionRecord[]): readonly { id: string; role: "agent" | "user"; text: string }[] {
const history: Array<{ id: string; role: "agent" | "user"; text: string }> = [];
for (const record of records) {