feat(coding): add plugin capability policy registry

This commit is contained in:
2026-08-27 16:29:02 +08:00
parent d9c9a2b0dd
commit a0361a3cda
14 changed files with 2169 additions and 245 deletions

View File

@@ -62,6 +62,65 @@ export type DataServiceDocumentList = {
export type DataServiceErrorContext = Record<string, string | number>;
export type PluginBillingMode =
| 'included'
| 'platform_metered'
| 'external_account';
/**
* A closed billing projection. Token Point amounts stay decimal strings all
* the way through the client boundary; no UI or adapter is allowed to invent
* an amount or a terminal receipt.
*/
export type CapabilityBillingReceiptV1 =
| {
mode: 'unknown' | PluginBillingMode;
status: 'not_started';
}
| {
mode: 'included';
status: 'included';
}
| {
mode: 'external_account';
status: 'external';
}
| {
mode: 'platform_metered';
status: 'reserved' | 'dispatched' | 'released' | 'pending_review' | 'expired';
reserved_points: string;
actual_points?: string;
usage_amount?: number;
unit?: string;
}
| {
mode: 'platform_metered';
status: 'settled' | 'refunded';
reserved_points: string;
actual_points: string;
usage_amount?: number;
unit?: string;
};
export interface CapabilityResultV1<T = unknown> {
schema: 'makelore-capability.v1';
plugin_id: string;
plugin_version: string;
capability_id: string;
operation: string;
request_id: string;
success: boolean;
status: number;
code: string | null;
error: string | null;
retryable: boolean;
retry_after_seconds?: number;
context?: Readonly<Record<string, string | number>>;
billing: CapabilityBillingReceiptV1;
payload_schema: string;
data: T | null;
}
export const DATA_SERVICE_PI_TOOL_NAMES = [
'data_service_configure',
'data_service_inspect',
@@ -96,9 +155,9 @@ export type DataServiceToolData =
| DataServiceCollectionRemoval
| DataServiceInstanceRemoval;
export type DataServiceToolDetailsV1 = DataServiceHostResult<DataServiceToolData> & {
schema: 'data-service.v1';
operation: DataServicePiToolName;
/** @deprecated Use the registry-owned capability envelope with this payload schema. */
export type DataServiceToolDetailsV1 = CapabilityResultV1<DataServiceToolData> & {
payload_schema: 'data-service.v1';
};
export type DataServicePutDocumentInput = {