Skip to content

@codesoul-co/hypha-core / contracts/runtime-capacity-schemas

模块用法

用于声明并运行时校验契约。Runtime capacity schemas 模块公开 22 常量。

从包入口导入

ts
import {
  runtimeCapacityAcquireRequestSchema,
  runtimeCapacityAssertionRequestSchema,
  runtimeCapacityContractDefinitions,
  runtimeCapacityContractJsonSchemas,
  runtimeCapacityLeaseDefinition,
  runtimeCapacityLeaseGuardSchema,
  runtimeCapacityLeaseSchema,
  runtimeCapacityPolicyDefinition,
} from '@codesoul-co/hypha-core';

// 完整导出列表见下方。

使用要点

  • 22 个常量/枚举提供稳定值、Schema、Definition 或默认配置;应复用这些导出,避免在应用中复制内部值。

运行时校验示例

ts
import { runtimeCapacityAcquireRequestSchema } from '@codesoul-co/hypha-core';

declare function loadExternalInput(): unknown;
const input: unknown = loadExternalInput();
const parsed = runtimeCapacityAcquireRequestSchema.parse(input);

配置、网络请求或持久化数据等不可信输入应先通过 Runtime Schema,再传给只接受已校验契约的函数或类。

公共导出

Symbol种类签名说明
runtimeCapacityAcquireRequestSchema常量const runtimeCapacityAcquireRequestSchema: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; runId: z.ZodString; } & { kind: z.ZodEnum<["model", "tool", "execution"]>; operationId: z.ZodString; requestedLeaseId: z.ZodString; ownerId: z.ZodString; acquiredAt: z.ZodString; ttlMs: z.ZodNumber; idempotencyKey: z.ZodString; }, "strict", z.ZodTypeAny, { userId: string; runId: string; kind: "tool" ...Runtime Capacity Acquire Request 的运行时 Schema。
runtimeCapacityAssertionRequestSchema常量const runtimeCapacityAssertionRequestSchema: z.ZodObject<{ scope: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; runId: z.ZodString; }, "strict", z.ZodTypeAny, { userId: string; runId: string; tenantId?: string | undefined; }, { userId: string; runId: string; tenantId?: string | undefined; }>; kind: z.ZodEnum<["model", "tool", "execution"]>; guard: z.ZodObject<{ leaseId: z.ZodString; owne...Runtime Capacity Assertion Request 的运行时 Schema。
runtimeCapacityContractDefinitions常量const runtimeCapacityContractDefinitions: readonly [SpecSchemaDefinition<RuntimeCapacityPolicy>, SpecSchemaDefinition<RuntimeCapacityLease>]contracts/runtime-capacity-schemas 模块导出的 Runtime Capacity Contract Definitions 常量。
runtimeCapacityContractJsonSchemas常量const runtimeCapacityContractJsonSchemas: Record<string, JsonSchema>contracts/runtime-capacity-schemas 模块导出的 Runtime Capacity Contract JSON Schemas 常量。
runtimeCapacityLeaseDefinition常量const runtimeCapacityLeaseDefinition: SpecSchemaDefinition<RuntimeCapacityLease>contracts/runtime-capacity-schemas 模块导出的 Runtime Capacity Lease Definition 常量。
runtimeCapacityLeaseGuardSchema常量const runtimeCapacityLeaseGuardSchema: z.ZodObject<{ leaseId: z.ZodString; ownerId: z.ZodString; fencingToken: z.ZodNumber; }, "strict", z.ZodTypeAny, { fencingToken: number; ownerId: string; leaseId: string; }, { fencingToken: number; ownerId: string; leaseId: string; }>Runtime Capacity Lease Guard 的运行时 Schema。
runtimeCapacityLeaseSchema常量const runtimeCapacityLeaseSchema: z.ZodEffects<z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; runId: z.ZodString; } & { id: z.ZodString; kind: z.ZodEnum<["model", "tool", "execution"]>; operationId: z.ZodString; ownerId: z.ZodString; fencingToken: z.ZodNumber; policyRevision: z.ZodString; acquiredAt: z.ZodString; heartbeatAt: z.ZodString; expiresAt: z.ZodString; }, "strict", z.ZodTypeAny,...Runtime Capacity Lease 的运行时 Schema。
runtimeCapacityPolicyDefinition常量const runtimeCapacityPolicyDefinition: SpecSchemaDefinition<RuntimeCapacityPolicy>contracts/runtime-capacity-schemas 模块导出的 Runtime Capacity Policy Definition 常量。
runtimeCapacityPolicySchema常量const runtimeCapacityPolicySchema: z.ZodObject<{ version: z.ZodLiteral<"1.0.0">; revision: z.ZodString; limits: z.ZodObject<{ model: z.ZodEffects<z.ZodObject<{ global: z.ZodNumber; perUser: z.ZodNumber; }, "strict", z.ZodTypeAny, { global: number; perUser: number; }, { global: number; perUser: number; }>, { global: number; perUser: number; }, { global: number; perUser: number; }>; tool: z.ZodEffects<z.ZodObject<{ ...Runtime Capacity Policy 的运行时 Schema。
runtimeCapacityReleaseRequestSchema常量const runtimeCapacityReleaseRequestSchema: z.ZodObject<{ scope: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; runId: z.ZodString; }, "strict", z.ZodTypeAny, { userId: string; runId: string; tenantId?: string | undefined; }, { userId: string; runId: string; tenantId?: string | undefined; }>; kind: z.ZodEnum<["model", "tool", "execution"]>; guard: z.ZodObject<{ leaseId: z.ZodString; ownerI...Runtime Capacity Release Request 的运行时 Schema。
runtimeCapacityRenewRequestSchema常量const runtimeCapacityRenewRequestSchema: z.ZodObject<{ scope: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; runId: z.ZodString; }, "strict", z.ZodTypeAny, { userId: string; runId: string; tenantId?: string | undefined; }, { userId: string; runId: string; tenantId?: string | undefined; }>; kind: z.ZodEnum<["model", "tool", "execution"]>; guard: z.ZodObject<{ leaseId: z.ZodString; ownerId:...Runtime Capacity Renew Request 的运行时 Schema。
runtimeCapacityScopeSchema常量const runtimeCapacityScopeSchema: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; runId: z.ZodString; }, "strict", z.ZodTypeAny, { userId: string; runId: string; tenantId?: string | undefined; }, { userId: string; runId: string; tenantId?: string | undefined; }>Runtime Capacity Scope 的运行时 Schema。
runtimeCapacityUsageRequestSchema常量const runtimeCapacityUsageRequestSchema: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; kind: z.ZodEnum<["model", "tool", "execution"]>; checkedAt: z.ZodString; }, "strict", z.ZodTypeAny, { userId: string; kind: "tool" | "model" | "execution"; checkedAt: string; tenantId?: string | undefined; }, { userId: string; kind: "tool" | "model" | "execution"; checkedAt: string; tenantId?: string |...Runtime Capacity Usage Request 的运行时 Schema。
runtimeCapacityUsageSchema常量const runtimeCapacityUsageSchema: z.ZodObject<{ kind: z.ZodEnum<["model", "tool", "execution"]>; policyRevision: z.ZodString; globalActive: z.ZodNumber; userActive: z.ZodNumber; globalLimit: z.ZodNumber; userLimit: z.ZodNumber; checkedAt: z.ZodString; }, "strict", z.ZodTypeAny, { kind: "tool" | "model" | "execution"; checkedAt: string; policyRevision: string; globalActive: number; userActive: number; globalLimit: ...Runtime Capacity Usage 的运行时 Schema。
validateRuntimeCapacityAcquireRequest常量const validateRuntimeCapacityAcquireRequest: (input: unknown) => RuntimeCapacityAcquireRequestcontracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Acquire Request 常量。
validateRuntimeCapacityAssertionRequest常量const validateRuntimeCapacityAssertionRequest: (input: unknown) => RuntimeCapacityAssertionRequestcontracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Assertion Request 常量。
validateRuntimeCapacityLease常量const validateRuntimeCapacityLease: (input: unknown) => RuntimeCapacityLeasecontracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Lease 常量。
validateRuntimeCapacityPolicy常量const validateRuntimeCapacityPolicy: (input: unknown) => RuntimeCapacityPolicycontracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Policy 常量。
validateRuntimeCapacityReleaseRequest常量const validateRuntimeCapacityReleaseRequest: (input: unknown) => RuntimeCapacityReleaseRequestcontracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Release Request 常量。
validateRuntimeCapacityRenewRequest常量const validateRuntimeCapacityRenewRequest: (input: unknown) => RuntimeCapacityRenewRequestcontracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Renew Request 常量。
validateRuntimeCapacityUsage常量const validateRuntimeCapacityUsage: (input: unknown) => RuntimeCapacityUsagecontracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Usage 常量。
validateRuntimeCapacityUsageRequest常量const validateRuntimeCapacityUsageRequest: (input: unknown) => RuntimeCapacityUsageRequestcontracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Usage Request 常量。

runtimeCapacityAcquireRequestSchema

Runtime Capacity Acquire Request 的运行时 Schema。

声明

text
export declare const runtimeCapacityAcquireRequestSchema: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; runId: z.ZodString; } & { kind: z.ZodEnum<["model", "tool", "execution"]>; operationId: z.ZodString; requestedLeaseId: z.ZodString; ownerId: z.ZodString; acquiredAt: z.ZodString; ttlMs: z.ZodNumber; idempotencyKey: z.ZodString; }, "strict", z.ZodTypeAny, { userId: string; runId: string; kind: "tool" | "model" | "execution"; operationId: string; idempotencyKey: string; ownerId: string; acquiredAt: string; requestedLeaseId: string; ttlMs: number; tenantId?: string | undefined; }, { userId: string; runId: string; kind: "tool" | "model" | "execution"; operationId: string; idempotencyKey: string; ownerId: string; acquiredAt: string; requestedLeaseId: string; ttlMs: number; tenantId?: string | undefined; }>;

runtimeCapacityAssertionRequestSchema

Runtime Capacity Assertion Request 的运行时 Schema。

声明

text
export declare const runtimeCapacityAssertionRequestSchema: z.ZodObject<{ scope: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; runId: z.ZodString; }, "strict", z.ZodTypeAny, { userId: string; runId: string; tenantId?: string | undefined; }, { userId: string; runId: string; tenantId?: string | undefined; }>; kind: z.ZodEnum<["model", "tool", "execution"]>; guard: z.ZodObject<{ leaseId: z.ZodString; ownerId: z.ZodString; fencingToken: z.ZodNumber; }, "strict", z.ZodTypeAny, { fencingToken: number; ownerId: string; leaseId: string; }, { fencingToken: number; ownerId: string; leaseId: string; }>; checkedAt: z.ZodString; }, "strict", z.ZodTypeAny, { kind: "tool" | "model" | "execution"; scope: { userId: string; runId: string; tenantId?: string | undefined; }; checkedAt: string; guard: { fencingToken: number; ownerId: string; leaseId: string; }; }, { kind: "tool" | "model" | "execution"; scope: { userId: string; runId: string; tenantId?: string | undefined; }; checkedAt: string; guard: { fencingToken: number; ownerId: string; leaseId: string; }; }>;

runtimeCapacityContractDefinitions

contracts/runtime-capacity-schemas 模块导出的 Runtime Capacity Contract Definitions 常量。

声明

text
export declare const runtimeCapacityContractDefinitions: readonly [SpecSchemaDefinition<RuntimeCapacityPolicy>, SpecSchemaDefinition<RuntimeCapacityLease>];

runtimeCapacityContractJsonSchemas

contracts/runtime-capacity-schemas 模块导出的 Runtime Capacity Contract JSON Schemas 常量。

声明

text
export declare const runtimeCapacityContractJsonSchemas: Record<string, JsonSchema>;

runtimeCapacityLeaseDefinition

contracts/runtime-capacity-schemas 模块导出的 Runtime Capacity Lease Definition 常量。

声明

text
export declare const runtimeCapacityLeaseDefinition: SpecSchemaDefinition<RuntimeCapacityLease>;

runtimeCapacityLeaseGuardSchema

Runtime Capacity Lease Guard 的运行时 Schema。

声明

text
export declare const runtimeCapacityLeaseGuardSchema: z.ZodObject<{ leaseId: z.ZodString; ownerId: z.ZodString; fencingToken: z.ZodNumber; }, "strict", z.ZodTypeAny, { fencingToken: number; ownerId: string; leaseId: string; }, { fencingToken: number; ownerId: string; leaseId: string; }>;

runtimeCapacityLeaseSchema

Runtime Capacity Lease 的运行时 Schema。

声明

text
export declare const runtimeCapacityLeaseSchema: z.ZodEffects<z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; runId: z.ZodString; } & { id: z.ZodString; kind: z.ZodEnum<["model", "tool", "execution"]>; operationId: z.ZodString; ownerId: z.ZodString; fencingToken: z.ZodNumber; policyRevision: z.ZodString; acquiredAt: z.ZodString; heartbeatAt: z.ZodString; expiresAt: z.ZodString; }, "strict", z.ZodTypeAny, { id: string; userId: string; runId: string; kind: "tool" | "model" | "execution"; expiresAt: string; operationId: string; fencingToken: number; ownerId: string; acquiredAt: string; heartbeatAt: string; policyRevision: string; tenantId?: string | undefined; }, { id: string; userId: string; runId: string; kind: "tool" | "model" | "execution"; expiresAt: string; operationId: string; fencingToken: number; ownerId: string; acquiredAt: string; heartbeatAt: string; policyRevision: string; tenantId?: string | undefined; }>, { id: string; userId: string; runId: string; kind: "tool" | "model" | "execution"; expiresAt: string; operationId: string; fencingToken: number; ownerId: string; acquiredAt: string; heartbeatAt: string; policyRevision: string; tenantId?: string | undefined; }, { id: string; userId: string; runId: string; kind: "tool" | "model" | "execution"; expiresAt: string; operationId: string; fencingToken: number; ownerId: string; acquiredAt: string; heartbeatAt: string; policyRevision: string; tenantId?: string | undefined; }>;

runtimeCapacityPolicyDefinition

contracts/runtime-capacity-schemas 模块导出的 Runtime Capacity Policy Definition 常量。

声明

text
export declare const runtimeCapacityPolicyDefinition: SpecSchemaDefinition<RuntimeCapacityPolicy>;

runtimeCapacityPolicySchema

Runtime Capacity Policy 的运行时 Schema。

声明

text
export declare const runtimeCapacityPolicySchema: z.ZodObject<{ version: z.ZodLiteral<"1.0.0">; revision: z.ZodString; limits: z.ZodObject<{ model: z.ZodEffects<z.ZodObject<{ global: z.ZodNumber; perUser: z.ZodNumber; }, "strict", z.ZodTypeAny, { global: number; perUser: number; }, { global: number; perUser: number; }>, { global: number; perUser: number; }, { global: number; perUser: number; }>; tool: z.ZodEffects<z.ZodObject<{ global: z.ZodNumber; perUser: z.ZodNumber; }, "strict", z.ZodTypeAny, { global: number; perUser: number; }, { global: number; perUser: number; }>, { global: number; perUser: number; }, { global: number; perUser: number; }>; execution: z.ZodEffects<z.ZodObject<{ global: z.ZodNumber; perUser: z.ZodNumber; }, "strict", z.ZodTypeAny, { global: number; perUser: number; }, { global: number; perUser: number; }>, { global: number; perUser: number; }, { global: number; perUser: number; }>; }, "strict", z.ZodTypeAny, { tool: { global: number; perUser: number; }; model: { global: number; perUser: number; }; execution: { global: number; perUser: number; }; }, { tool: { global: number; perUser: number; }; model: { global: number; perUser: number; }; execution: { global: number; perUser: number; }; }>; }, "strict", z.ZodTypeAny, { revision: string; version: "1.0.0"; limits: { tool: { global: number; perUser: number; }; model: { global: number; perUser: number; }; execution: { global: number; perUser: number; }; }; }, { revision: string; version: "1.0.0"; limits: { tool: { global: number; perUser: number; }; model: { global: number; perUser: number; }; execution: { global: number; perUser: number; }; }; }>;

runtimeCapacityReleaseRequestSchema

Runtime Capacity Release Request 的运行时 Schema。

声明

text
export declare const runtimeCapacityReleaseRequestSchema: z.ZodObject<{ scope: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; runId: z.ZodString; }, "strict", z.ZodTypeAny, { userId: string; runId: string; tenantId?: string | undefined; }, { userId: string; runId: string; tenantId?: string | undefined; }>; kind: z.ZodEnum<["model", "tool", "execution"]>; guard: z.ZodObject<{ leaseId: z.ZodString; ownerId: z.ZodString; fencingToken: z.ZodNumber; }, "strict", z.ZodTypeAny, { fencingToken: number; ownerId: string; leaseId: string; }, { fencingToken: number; ownerId: string; leaseId: string; }>; releasedAt: z.ZodString; }, "strict", z.ZodTypeAny, { kind: "tool" | "model" | "execution"; scope: { userId: string; runId: string; tenantId?: string | undefined; }; guard: { fencingToken: number; ownerId: string; leaseId: string; }; releasedAt: string; }, { kind: "tool" | "model" | "execution"; scope: { userId: string; runId: string; tenantId?: string | undefined; }; guard: { fencingToken: number; ownerId: string; leaseId: string; }; releasedAt: string; }>;

runtimeCapacityRenewRequestSchema

Runtime Capacity Renew Request 的运行时 Schema。

声明

text
export declare const runtimeCapacityRenewRequestSchema: z.ZodObject<{ scope: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; runId: z.ZodString; }, "strict", z.ZodTypeAny, { userId: string; runId: string; tenantId?: string | undefined; }, { userId: string; runId: string; tenantId?: string | undefined; }>; kind: z.ZodEnum<["model", "tool", "execution"]>; guard: z.ZodObject<{ leaseId: z.ZodString; ownerId: z.ZodString; fencingToken: z.ZodNumber; }, "strict", z.ZodTypeAny, { fencingToken: number; ownerId: string; leaseId: string; }, { fencingToken: number; ownerId: string; leaseId: string; }>; renewedAt: z.ZodString; ttlMs: z.ZodNumber; }, "strict", z.ZodTypeAny, { kind: "tool" | "model" | "execution"; scope: { userId: string; runId: string; tenantId?: string | undefined; }; guard: { fencingToken: number; ownerId: string; leaseId: string; }; ttlMs: number; renewedAt: string; }, { kind: "tool" | "model" | "execution"; scope: { userId: string; runId: string; tenantId?: string | undefined; }; guard: { fencingToken: number; ownerId: string; leaseId: string; }; ttlMs: number; renewedAt: string; }>;

runtimeCapacityScopeSchema

Runtime Capacity Scope 的运行时 Schema。

声明

text
export declare const runtimeCapacityScopeSchema: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; runId: z.ZodString; }, "strict", z.ZodTypeAny, { userId: string; runId: string; tenantId?: string | undefined; }, { userId: string; runId: string; tenantId?: string | undefined; }>;

runtimeCapacityUsageRequestSchema

Runtime Capacity Usage Request 的运行时 Schema。

声明

text
export declare const runtimeCapacityUsageRequestSchema: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; kind: z.ZodEnum<["model", "tool", "execution"]>; checkedAt: z.ZodString; }, "strict", z.ZodTypeAny, { userId: string; kind: "tool" | "model" | "execution"; checkedAt: string; tenantId?: string | undefined; }, { userId: string; kind: "tool" | "model" | "execution"; checkedAt: string; tenantId?: string | undefined; }>;

runtimeCapacityUsageSchema

Runtime Capacity Usage 的运行时 Schema。

声明

text
export declare const runtimeCapacityUsageSchema: z.ZodObject<{ kind: z.ZodEnum<["model", "tool", "execution"]>; policyRevision: z.ZodString; globalActive: z.ZodNumber; userActive: z.ZodNumber; globalLimit: z.ZodNumber; userLimit: z.ZodNumber; checkedAt: z.ZodString; }, "strict", z.ZodTypeAny, { kind: "tool" | "model" | "execution"; checkedAt: string; policyRevision: string; globalActive: number; userActive: number; globalLimit: number; userLimit: number; }, { kind: "tool" | "model" | "execution"; checkedAt: string; policyRevision: string; globalActive: number; userActive: number; globalLimit: number; userLimit: number; }>;

validateRuntimeCapacityAcquireRequest

contracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Acquire Request 常量。

声明

text
export declare const validateRuntimeCapacityAcquireRequest: (input: unknown) => RuntimeCapacityAcquireRequest;

validateRuntimeCapacityAssertionRequest

contracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Assertion Request 常量。

声明

text
export declare const validateRuntimeCapacityAssertionRequest: (input: unknown) => RuntimeCapacityAssertionRequest;

validateRuntimeCapacityLease

contracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Lease 常量。

声明

text
export declare const validateRuntimeCapacityLease: (input: unknown) => RuntimeCapacityLease;

validateRuntimeCapacityPolicy

contracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Policy 常量。

声明

text
export declare const validateRuntimeCapacityPolicy: (input: unknown) => RuntimeCapacityPolicy;

validateRuntimeCapacityReleaseRequest

contracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Release Request 常量。

声明

text
export declare const validateRuntimeCapacityReleaseRequest: (input: unknown) => RuntimeCapacityReleaseRequest;

validateRuntimeCapacityRenewRequest

contracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Renew Request 常量。

声明

text
export declare const validateRuntimeCapacityRenewRequest: (input: unknown) => RuntimeCapacityRenewRequest;

validateRuntimeCapacityUsage

contracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Usage 常量。

声明

text
export declare const validateRuntimeCapacityUsage: (input: unknown) => RuntimeCapacityUsage;

validateRuntimeCapacityUsageRequest

contracts/runtime-capacity-schemas 模块导出的 Validate Runtime Capacity Usage Request 常量。

声明

text
export declare const validateRuntimeCapacityUsageRequest: (input: unknown) => RuntimeCapacityUsageRequest;