feat(plugins): move game resources behind marketplace

This commit is contained in:
2026-08-31 10:45:20 +08:00
parent 62304dc85b
commit fe656dd865
33 changed files with 1413 additions and 1018 deletions

View File

@@ -31,6 +31,8 @@ export interface SkillEntry {
/** A policy row copied from the last verified server catalog. */
export interface RuntimePolicy {
readonly pluginId: string;
readonly pluginVersion: string;
readonly releaseId: string | null;
readonly contractVersion: number;
readonly capabilityId: string;
readonly operation: string;
@@ -90,6 +92,7 @@ export interface EffectivePluginResolverOptions {
readonly packageStore?: {
readInstalledIndex(): Promise<readonly { pluginId: string }[]>;
getInstalled(pluginId: string): Promise<InstalledRelease | null>;
getInstalledRelease(pluginId: string, releaseId: string): Promise<InstalledRelease | null>;
};
readonly getLibrary?: (binding: AccountBinding) => Promise<MarketplaceLibrarySnapshot | null> | MarketplaceLibrarySnapshot | null;
readonly marketplace?: {
@@ -393,6 +396,8 @@ export class EffectivePluginResolver {
if (!policy) continue;
runtimePolicies.push({
pluginId: definition.id,
pluginVersion: definition.version,
releaseId: definition.releaseId,
contractVersion: definition.contractVersion,
capabilityId: operation.capabilityId,
operation: operation.operation,
@@ -455,6 +460,18 @@ export class EffectivePluginResolver {
return this.options.policyClient?.getState() ?? EMPTY_POLICY_STATE;
}
async getInstalledDefinition(
pluginId: string,
releaseId?: string | null,
): Promise<CodingPluginDefinition | null> {
if (releaseId && this.options.packageStore) {
const installed = await this.options.packageStore.getInstalledRelease(pluginId, releaseId);
return installed && !installed.unavailableReason ? installed.definition : null;
}
const record = (await this.definitionRecords()).find(({ definition }) => definition.id === pluginId);
return record?.installed && !record.unavailableReason ? record.definition : null;
}
private async definitionRecords(): Promise<DefinitionRecord[]> {
const base = [
...(this.options.definitions ?? []),