Skip to content

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

Using this module

Use the Runtime capacity module for declaring and runtime-validating contracts. It exports 1 constant, 12 interfaces, 1 type.

Import from the package entrypoint

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

import type {
  RuntimeCapacityAcquireRequest,
  RuntimeCapacityAssertionRequest,
  RuntimeCapacityLease,
  RuntimeCapacityLeaseGuard,
  RuntimeCapacityLimit,
  RuntimeCapacityPolicy,
  RuntimeCapacityReleaseRequest,
  RuntimeCapacityRenewRequest,
} from '@codesoul-co/hypha-core';

// The complete export list is documented below.

Usage patterns

  • Use the 13 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The 1 constant/enum export provides stable values, schemas, definitions, or defaults. Reuse these exports instead of copying internal values into an application.

Public exports

SymbolKindSignatureDescription
RUNTIME_CAPACITY_KINDSconstantconst RUNTIME_CAPACITY_KINDS: readonly ["model", "tool", "execution"]RUNTIME CAPACITY KINDS constant exported by the contracts/runtime-capacity module.
RuntimeCapacityAcquireRequestinterfaceinterface RuntimeCapacityAcquireRequest extends RuntimeCapacityScopeRuntime Capacity Acquire Request interface with 10 public fields or methods.
RuntimeCapacityAssertionRequestinterfaceinterface RuntimeCapacityAssertionRequestRuntime Capacity Assertion Request interface with 4 public fields or methods.
RuntimeCapacityLeaseinterfaceinterface RuntimeCapacityLease extends RuntimeCapacityScopeRuntime Capacity Lease interface with 12 public fields or methods.
RuntimeCapacityLeaseGuardinterfaceinterface RuntimeCapacityLeaseGuardRuntime Capacity Lease Guard interface with 3 public fields or methods.
RuntimeCapacityLimitinterfaceinterface RuntimeCapacityLimitRuntime Capacity Limit interface with 2 public fields or methods.
RuntimeCapacityPolicyinterfaceinterface RuntimeCapacityPolicyRuntime Capacity Policy interface with 3 public fields or methods.
RuntimeCapacityReleaseRequestinterfaceinterface RuntimeCapacityReleaseRequestRuntime Capacity Release Request interface with 4 public fields or methods.
RuntimeCapacityRenewRequestinterfaceinterface RuntimeCapacityRenewRequestRuntime Capacity Renew Request interface with 5 public fields or methods.
RuntimeCapacityScopeinterfaceinterface RuntimeCapacityScopeRuntime Capacity Scope interface with 3 public fields or methods.
RuntimeCapacitySemaphoreinterfaceinterface RuntimeCapacitySemaphoreRuntime Capacity Semaphore interface with 5 public fields or methods.
RuntimeCapacityUsageinterfaceinterface RuntimeCapacityUsageRuntime Capacity Usage interface with 7 public fields or methods.
RuntimeCapacityUsageRequestinterfaceinterface RuntimeCapacityUsageRequestRuntime Capacity Usage Request interface with 4 public fields or methods.
RuntimeCapacityKindtypetype RuntimeCapacityKind = (typeof RUNTIME_CAPACITY_KINDS)[number]Public type alias for Runtime Capacity Kind; the declaration contains its complete type expression.

RUNTIME_CAPACITY_KINDS

RUNTIME CAPACITY KINDS constant exported by the contracts/runtime-capacity module.

Declaration

text
export declare const RUNTIME_CAPACITY_KINDS: readonly ["model", "tool", "execution"];

RuntimeCapacityAcquireRequest

Runtime Capacity Acquire Request interface with 10 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeCapacityAcquireRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-capacity

Declaration

text
export interface RuntimeCapacityAcquireRequest extends RuntimeCapacityScope {
    kind: RuntimeCapacityKind;
    operationId: string;
    requestedLeaseId: string;
    ownerId: string;
    acquiredAt: string;
    ttlMs: number;
    idempotencyKey: string;
}

Contract members

MemberKindSignatureDescription
acquiredAtpropertyacquiredAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
idempotencyKeypropertyidempotencyKey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
kindpropertykind: "tool" | "model" | "execution"Public property; its type, readonly modifier and optionality are shown in the signature.
operationIdpropertyoperationId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
ownerIdpropertyownerId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
requestedLeaseIdpropertyrequestedLeaseId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
tenantIdpropertytenantId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
ttlMspropertyttlMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCapacityAssertionRequest

Runtime Capacity Assertion Request interface with 4 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeCapacityAssertionRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-capacity

Declaration

text
export interface RuntimeCapacityAssertionRequest {
    scope: RuntimeCapacityScope;
    kind: RuntimeCapacityKind;
    guard: RuntimeCapacityLeaseGuard;
    checkedAt: string;
}

Contract members

MemberKindSignatureDescription
checkedAtpropertycheckedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
guardpropertyguard: RuntimeCapacityLeaseGuardPublic property; its type, readonly modifier and optionality are shown in the signature.
kindpropertykind: "tool" | "model" | "execution"Public property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope: RuntimeCapacityScopePublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCapacityLease

Runtime Capacity Lease interface with 12 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeCapacityLease } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-capacity

Declaration

text
export interface RuntimeCapacityLease extends RuntimeCapacityScope {
    id: string;
    kind: RuntimeCapacityKind;
    operationId: string;
    ownerId: string;
    fencingToken: number;
    policyRevision: string;
    acquiredAt: string;
    heartbeatAt: string;
    expiresAt: string;
}

Contract members

MemberKindSignatureDescription
acquiredAtpropertyacquiredAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expiresAtpropertyexpiresAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
fencingTokenpropertyfencingToken: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
heartbeatAtpropertyheartbeatAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
kindpropertykind: "tool" | "model" | "execution"Public property; its type, readonly modifier and optionality are shown in the signature.
operationIdpropertyoperationId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
ownerIdpropertyownerId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
policyRevisionpropertypolicyRevision: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
tenantIdpropertytenantId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCapacityLeaseGuard

Runtime Capacity Lease Guard interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeCapacityLeaseGuard } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-capacity

Declaration

text
export interface RuntimeCapacityLeaseGuard {
    leaseId: string;
    ownerId: string;
    fencingToken: number;
}

Contract members

MemberKindSignatureDescription
fencingTokenpropertyfencingToken: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
leaseIdpropertyleaseId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
ownerIdpropertyownerId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCapacityLimit

Runtime Capacity Limit interface with 2 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeCapacityLimit } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-capacity

Declaration

text
export interface RuntimeCapacityLimit {
    global: number;
    perUser: number;
}

Contract members

MemberKindSignatureDescription
globalpropertyglobal: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
perUserpropertyperUser: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCapacityPolicy

Runtime Capacity Policy interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeCapacityPolicy } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-capacity

Declaration

text
export interface RuntimeCapacityPolicy {
    version: '1.0.0';
    revision: string;
    limits: Record<RuntimeCapacityKind, RuntimeCapacityLimit>;
}

Contract members

MemberKindSignatureDescription
limitspropertylimits: Record<"tool" | "model" | "execution", RuntimeCapacityLimit>Public property; its type, readonly modifier and optionality are shown in the signature.
revisionpropertyrevision: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
versionpropertyversion: "1.0.0"Public property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCapacityReleaseRequest

Runtime Capacity Release Request interface with 4 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeCapacityReleaseRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-capacity

Declaration

text
export interface RuntimeCapacityReleaseRequest {
    scope: RuntimeCapacityScope;
    kind: RuntimeCapacityKind;
    guard: RuntimeCapacityLeaseGuard;
    releasedAt: string;
}

Contract members

MemberKindSignatureDescription
guardpropertyguard: RuntimeCapacityLeaseGuardPublic property; its type, readonly modifier and optionality are shown in the signature.
kindpropertykind: "tool" | "model" | "execution"Public property; its type, readonly modifier and optionality are shown in the signature.
releasedAtpropertyreleasedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope: RuntimeCapacityScopePublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCapacityRenewRequest

Runtime Capacity Renew Request interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeCapacityRenewRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-capacity

Declaration

text
export interface RuntimeCapacityRenewRequest {
    scope: RuntimeCapacityScope;
    kind: RuntimeCapacityKind;
    guard: RuntimeCapacityLeaseGuard;
    renewedAt: string;
    ttlMs: number;
}

Contract members

MemberKindSignatureDescription
guardpropertyguard: RuntimeCapacityLeaseGuardPublic property; its type, readonly modifier and optionality are shown in the signature.
kindpropertykind: "tool" | "model" | "execution"Public property; its type, readonly modifier and optionality are shown in the signature.
renewedAtpropertyrenewedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope: RuntimeCapacityScopePublic property; its type, readonly modifier and optionality are shown in the signature.
ttlMspropertyttlMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCapacityScope

Runtime Capacity Scope interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeCapacityScope } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-capacity

Declaration

text
export interface RuntimeCapacityScope {
    tenantId?: string;
    userId: string;
    runId: string;
}

Contract members

MemberKindSignatureDescription
runIdpropertyrunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
tenantIdpropertytenantId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCapacitySemaphore

Runtime Capacity Semaphore interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeCapacitySemaphore } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-capacity

Declaration

text
export interface RuntimeCapacitySemaphore {
    acquire(request: RuntimeCapacityAcquireRequest): Promise<RuntimeCapacityLease | null>;
    renew(request: RuntimeCapacityRenewRequest): Promise<RuntimeCapacityLease>;
    release(request: RuntimeCapacityReleaseRequest): Promise<void>;
    assertCurrent(request: RuntimeCapacityAssertionRequest): Promise<RuntimeCapacityLease>;
    usage(request: RuntimeCapacityUsageRequest): Promise<RuntimeCapacityUsage>;
}

Contract members

MemberKindSignatureDescription
acquiremethodacquire(request: RuntimeCapacityAcquireRequest): Promise<RuntimeCapacityLease | null>Public method; parameters and return type are shown in the signature.
assertCurrentmethodassertCurrent(request: RuntimeCapacityAssertionRequest): Promise<RuntimeCapacityLease>Public method; parameters and return type are shown in the signature.
releasemethodrelease(request: RuntimeCapacityReleaseRequest): Promise<void>Public method; parameters and return type are shown in the signature.
renewmethodrenew(request: RuntimeCapacityRenewRequest): Promise<RuntimeCapacityLease>Public method; parameters and return type are shown in the signature.
usagemethodusage(request: RuntimeCapacityUsageRequest): Promise<RuntimeCapacityUsage>Public method; parameters and return type are shown in the signature.

RuntimeCapacityUsage

Runtime Capacity Usage interface with 7 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeCapacityUsage } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-capacity

Declaration

text
export interface RuntimeCapacityUsage {
    kind: RuntimeCapacityKind;
    policyRevision: string;
    globalActive: number;
    userActive: number;
    globalLimit: number;
    userLimit: number;
    checkedAt: string;
}

Contract members

MemberKindSignatureDescription
checkedAtpropertycheckedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
globalActivepropertyglobalActive: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
globalLimitpropertyglobalLimit: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
kindpropertykind: "tool" | "model" | "execution"Public property; its type, readonly modifier and optionality are shown in the signature.
policyRevisionpropertypolicyRevision: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
userActivepropertyuserActive: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
userLimitpropertyuserLimit: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCapacityUsageRequest

Runtime Capacity Usage Request interface with 4 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeCapacityUsageRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-capacity

Declaration

text
export interface RuntimeCapacityUsageRequest {
    tenantId?: string;
    userId: string;
    kind: RuntimeCapacityKind;
    checkedAt: string;
}

Contract members

MemberKindSignatureDescription
checkedAtpropertycheckedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
kindpropertykind: "tool" | "model" | "execution"Public property; its type, readonly modifier and optionality are shown in the signature.
tenantIdpropertytenantId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCapacityKind

Public type alias for Runtime Capacity Kind; the declaration contains its complete type expression.

Declaration

text
export type RuntimeCapacityKind = (typeof RUNTIME_CAPACITY_KINDS)[number];