Skip to content

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

Using this module

Use the Runtime capacity schemas module for declaring and runtime-validating contracts. It exports 22 constants.

Import from the package entrypoint

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

// The complete export list is documented below.

Usage patterns

  • The 22 constant/enum exports provide stable values, schemas, definitions, or defaults. Reuse these exports instead of copying internal values into an application.

Runtime validation example

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

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

Parse untrusted configuration, network, or persisted input with the runtime schema before passing it to functions or classes that expect a validated contract.

Public exports

SymbolKindSignatureDescription
runtimeCapacityAcquireRequestSchemaconstantconst 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 schema for Runtime Capacity Acquire Request.
runtimeCapacityAssertionRequestSchemaconstantconst 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 schema for Runtime Capacity Assertion Request.
runtimeCapacityContractDefinitionsconstantconst runtimeCapacityContractDefinitions: readonly [SpecSchemaDefinition<RuntimeCapacityPolicy>, SpecSchemaDefinition<RuntimeCapacityLease>]Runtime Capacity Contract Definitions constant exported by the contracts/runtime-capacity-schemas module.
runtimeCapacityContractJsonSchemasconstantconst runtimeCapacityContractJsonSchemas: Record<string, JsonSchema>Runtime Capacity Contract JSON Schemas constant exported by the contracts/runtime-capacity-schemas module.
runtimeCapacityLeaseDefinitionconstantconst runtimeCapacityLeaseDefinition: SpecSchemaDefinition<RuntimeCapacityLease>Runtime Capacity Lease Definition constant exported by the contracts/runtime-capacity-schemas module.
runtimeCapacityLeaseGuardSchemaconstantconst 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 schema for Runtime Capacity Lease Guard.
runtimeCapacityLeaseSchemaconstantconst 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 schema for Runtime Capacity Lease.
runtimeCapacityPolicyDefinitionconstantconst runtimeCapacityPolicyDefinition: SpecSchemaDefinition<RuntimeCapacityPolicy>Runtime Capacity Policy Definition constant exported by the contracts/runtime-capacity-schemas module.
runtimeCapacityPolicySchemaconstantconst 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 schema for Runtime Capacity Policy.
runtimeCapacityReleaseRequestSchemaconstantconst 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 schema for Runtime Capacity Release Request.
runtimeCapacityRenewRequestSchemaconstantconst 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 schema for Runtime Capacity Renew Request.
runtimeCapacityScopeSchemaconstantconst 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 schema for Runtime Capacity Scope.
runtimeCapacityUsageRequestSchemaconstantconst 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 schema for Runtime Capacity Usage Request.
runtimeCapacityUsageSchemaconstantconst 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 schema for Runtime Capacity Usage.
validateRuntimeCapacityAcquireRequestconstantconst validateRuntimeCapacityAcquireRequest: (input: unknown) => RuntimeCapacityAcquireRequestValidate Runtime Capacity Acquire Request constant exported by the contracts/runtime-capacity-schemas module.
validateRuntimeCapacityAssertionRequestconstantconst validateRuntimeCapacityAssertionRequest: (input: unknown) => RuntimeCapacityAssertionRequestValidate Runtime Capacity Assertion Request constant exported by the contracts/runtime-capacity-schemas module.
validateRuntimeCapacityLeaseconstantconst validateRuntimeCapacityLease: (input: unknown) => RuntimeCapacityLeaseValidate Runtime Capacity Lease constant exported by the contracts/runtime-capacity-schemas module.
validateRuntimeCapacityPolicyconstantconst validateRuntimeCapacityPolicy: (input: unknown) => RuntimeCapacityPolicyValidate Runtime Capacity Policy constant exported by the contracts/runtime-capacity-schemas module.
validateRuntimeCapacityReleaseRequestconstantconst validateRuntimeCapacityReleaseRequest: (input: unknown) => RuntimeCapacityReleaseRequestValidate Runtime Capacity Release Request constant exported by the contracts/runtime-capacity-schemas module.
validateRuntimeCapacityRenewRequestconstantconst validateRuntimeCapacityRenewRequest: (input: unknown) => RuntimeCapacityRenewRequestValidate Runtime Capacity Renew Request constant exported by the contracts/runtime-capacity-schemas module.
validateRuntimeCapacityUsageconstantconst validateRuntimeCapacityUsage: (input: unknown) => RuntimeCapacityUsageValidate Runtime Capacity Usage constant exported by the contracts/runtime-capacity-schemas module.
validateRuntimeCapacityUsageRequestconstantconst validateRuntimeCapacityUsageRequest: (input: unknown) => RuntimeCapacityUsageRequestValidate Runtime Capacity Usage Request constant exported by the contracts/runtime-capacity-schemas module.

runtimeCapacityAcquireRequestSchema

Runtime schema for Runtime Capacity Acquire Request.

Declaration

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 schema for Runtime Capacity Assertion Request.

Declaration

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

Runtime Capacity Contract Definitions constant exported by the contracts/runtime-capacity-schemas module.

Declaration

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

runtimeCapacityContractJsonSchemas

Runtime Capacity Contract JSON Schemas constant exported by the contracts/runtime-capacity-schemas module.

Declaration

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

runtimeCapacityLeaseDefinition

Runtime Capacity Lease Definition constant exported by the contracts/runtime-capacity-schemas module.

Declaration

text
export declare const runtimeCapacityLeaseDefinition: SpecSchemaDefinition<RuntimeCapacityLease>;

runtimeCapacityLeaseGuardSchema

Runtime schema for Runtime Capacity Lease Guard.

Declaration

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 schema for Runtime Capacity Lease.

Declaration

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

Runtime Capacity Policy Definition constant exported by the contracts/runtime-capacity-schemas module.

Declaration

text
export declare const runtimeCapacityPolicyDefinition: SpecSchemaDefinition<RuntimeCapacityPolicy>;

runtimeCapacityPolicySchema

Runtime schema for Runtime Capacity Policy.

Declaration

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 schema for Runtime Capacity Release Request.

Declaration

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 schema for Runtime Capacity Renew Request.

Declaration

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 schema for Runtime Capacity Scope.

Declaration

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 schema for Runtime Capacity Usage Request.

Declaration

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 schema for Runtime Capacity Usage.

Declaration

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

Validate Runtime Capacity Acquire Request constant exported by the contracts/runtime-capacity-schemas module.

Declaration

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

validateRuntimeCapacityAssertionRequest

Validate Runtime Capacity Assertion Request constant exported by the contracts/runtime-capacity-schemas module.

Declaration

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

validateRuntimeCapacityLease

Validate Runtime Capacity Lease constant exported by the contracts/runtime-capacity-schemas module.

Declaration

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

validateRuntimeCapacityPolicy

Validate Runtime Capacity Policy constant exported by the contracts/runtime-capacity-schemas module.

Declaration

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

validateRuntimeCapacityReleaseRequest

Validate Runtime Capacity Release Request constant exported by the contracts/runtime-capacity-schemas module.

Declaration

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

validateRuntimeCapacityRenewRequest

Validate Runtime Capacity Renew Request constant exported by the contracts/runtime-capacity-schemas module.

Declaration

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

validateRuntimeCapacityUsage

Validate Runtime Capacity Usage constant exported by the contracts/runtime-capacity-schemas module.

Declaration

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

validateRuntimeCapacityUsageRequest

Validate Runtime Capacity Usage Request constant exported by the contracts/runtime-capacity-schemas module.

Declaration

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