feat(plugins): move game resources behind marketplace
This commit is contained in:
@@ -41,6 +41,7 @@ export interface TrustedCodingCapabilityContext {
|
||||
durableProjectId: string;
|
||||
workerRole: 'parent' | 'child';
|
||||
effectiveSkillIds: readonly string[];
|
||||
pluginReleaseId?: string;
|
||||
}
|
||||
|
||||
export type PluginBackendProjection =
|
||||
@@ -527,19 +528,50 @@ export class CodingCapabilityRegistryImpl implements CodingCapabilityRegistryPor
|
||||
effectiveSkillIds: readonly string[];
|
||||
value: unknown;
|
||||
}): Promise<PiProductToolResult> {
|
||||
const indexed = this.toolsByName.get(input.toolName);
|
||||
let indexed = this.toolsByName.get(input.toolName);
|
||||
const validId = requestId(input.context) !== 'invalid-request-id';
|
||||
if (!indexed && this.options.effectiveResolver && input.context.effectiveSnapshot) {
|
||||
const snapshotTool = input.context.effectiveSnapshot.toolDefinitions
|
||||
.find(({ name }) => name === input.toolName);
|
||||
const policy = snapshotTool
|
||||
? input.context.effectiveSnapshot.runtimePolicies.find((candidate) => (
|
||||
candidate.capabilityId === snapshotTool.capabilityId
|
||||
&& candidate.operation === snapshotTool.operation
|
||||
))
|
||||
: undefined;
|
||||
const definition = policy
|
||||
? await this.options.effectiveResolver.getInstalledDefinition(policy.pluginId, policy.releaseId)
|
||||
: null;
|
||||
const tool = definition?.tools.find((candidate) => (
|
||||
candidate.name === input.toolName
|
||||
&& candidate.capabilityId === snapshotTool?.capabilityId
|
||||
&& candidate.operation === snapshotTool.operation
|
||||
));
|
||||
if (definition && tool) indexed = { definition, tool };
|
||||
}
|
||||
if (!indexed) return this.unknownResult(input.context, 'plugin_backend_unavailable', 'Plugin capability is unavailable');
|
||||
const { definition, tool } = indexed;
|
||||
if (this.options.effectiveResolver && input.context.effectiveSnapshot) {
|
||||
const frozenPolicy = input.context.effectiveSnapshot.runtimePolicies.find((candidate) => (
|
||||
candidate.pluginId === definition.id
|
||||
&& candidate.capabilityId === tool.capabilityId
|
||||
&& candidate.operation === tool.operation
|
||||
));
|
||||
const currentSnapshot = await this.options.effectiveResolver.resolve({
|
||||
projectId: input.context.projectId,
|
||||
projectPath: input.context.projectPath,
|
||||
assignedSkillIds: input.context.effectiveSnapshot.effectiveSkillIds,
|
||||
role: input.workerRole,
|
||||
});
|
||||
const currentPolicy = currentSnapshot.runtimePolicies.find((candidate) => (
|
||||
candidate.pluginId === definition.id
|
||||
&& candidate.capabilityId === tool.capabilityId
|
||||
&& candidate.operation === tool.operation
|
||||
));
|
||||
if (currentSnapshot.accountSessionId !== input.context.effectiveSnapshot.accountSessionId
|
||||
|| !currentSnapshot.toolDefinitions.some(({ name }) => name === input.toolName)) {
|
||||
|| !currentSnapshot.toolDefinitions.some(({ name }) => name === input.toolName)
|
||||
|| frozenPolicy?.releaseId !== currentPolicy?.releaseId
|
||||
|| frozenPolicy?.pluginVersion !== currentPolicy?.pluginVersion) {
|
||||
const disabled = currentSnapshot.unavailableReasons.some((reason) => (
|
||||
reason.pluginId === definition.id && reason.code === 'project_disabled'
|
||||
));
|
||||
@@ -599,6 +631,7 @@ export class CodingCapabilityRegistryImpl implements CodingCapabilityRegistryPor
|
||||
durableProjectId,
|
||||
workerRole: input.workerRole,
|
||||
effectiveSkillIds: [...input.effectiveSkillIds],
|
||||
...(definition.releaseId ? { pluginReleaseId: definition.releaseId } : {}),
|
||||
};
|
||||
let result: AdapterInvocationResult;
|
||||
try {
|
||||
@@ -640,7 +673,7 @@ export class CodingCapabilityRegistryImpl implements CodingCapabilityRegistryPor
|
||||
code,
|
||||
error,
|
||||
retryable,
|
||||
payload_schema: 'data-service.v1',
|
||||
payload_schema: 'unknown',
|
||||
data: null,
|
||||
}, billing);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user