feat: integrate automatic game resource delivery
This commit is contained in:
@@ -89,6 +89,7 @@ export interface CodingPluginAdapter {
|
||||
context: TrustedCodingCapabilityContext,
|
||||
tool: CodingPluginToolDefinition,
|
||||
input: unknown,
|
||||
onProgress?: (result: AdapterInvocationResult) => void,
|
||||
): Promise<AdapterInvocationResult>;
|
||||
deactivate?(projectPath: string): Promise<void>;
|
||||
}
|
||||
@@ -124,6 +125,7 @@ export interface CodingCapabilityRegistryPort {
|
||||
workerRole: 'parent' | 'child';
|
||||
effectiveSkillIds: readonly string[];
|
||||
value: unknown;
|
||||
onUpdate?: (result: PiProductToolResult) => void;
|
||||
}): Promise<PiProductToolResult>;
|
||||
}
|
||||
|
||||
@@ -530,6 +532,7 @@ export class CodingCapabilityRegistryImpl implements CodingCapabilityRegistryPor
|
||||
workerRole: 'parent' | 'child';
|
||||
effectiveSkillIds: readonly string[];
|
||||
value: unknown;
|
||||
onUpdate?: (result: PiProductToolResult) => void;
|
||||
}): Promise<PiProductToolResult> {
|
||||
let indexed = this.toolsByName.get(input.toolName);
|
||||
const validId = requestId(input.context) !== 'invalid-request-id';
|
||||
@@ -638,7 +641,30 @@ export class CodingCapabilityRegistryImpl implements CodingCapabilityRegistryPor
|
||||
};
|
||||
let result: AdapterInvocationResult;
|
||||
try {
|
||||
result = await adapter.invoke(trustedContext, tool, input.value);
|
||||
const reportProgress = input.onUpdate ? (progress: AdapterInvocationResult) => {
|
||||
let progressBilling: CapabilityBillingReceiptV1;
|
||||
if (catalogPolicy.billing.mode === 'platform_metered') {
|
||||
if (!progress.billing || !validBillingReceipt(progress.billing)
|
||||
|| progress.billing.mode !== 'platform_metered') return;
|
||||
progressBilling = progress.billing;
|
||||
} else {
|
||||
progressBilling = policyEntered(catalogPolicy.billing.mode);
|
||||
}
|
||||
try {
|
||||
input.onUpdate?.(buildCapabilityToolResult(
|
||||
definition,
|
||||
tool,
|
||||
input.context,
|
||||
progress,
|
||||
progressBilling,
|
||||
));
|
||||
} catch {
|
||||
// Progress is observational and must not change the capability outcome.
|
||||
}
|
||||
} : undefined;
|
||||
result = reportProgress
|
||||
? await adapter.invoke(trustedContext, tool, input.value, reportProgress)
|
||||
: await adapter.invoke(trustedContext, tool, input.value);
|
||||
} catch {
|
||||
return this.resultFailure(definition, tool, input.context, 'plugin_backend_unavailable', 'Plugin adapter is temporarily unavailable', 503, true, baseBilling);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user