Skip to content

@codesoul-co/hypha-core / contracts/command-execution

Using this module

Use the Command execution module for declaring and runtime-validating contracts. It exports 6 interfaces, 1 type.

Import from the package entrypoint

ts
import type {
  CommandExecutionRequest,
  CommandExecutionResult,
  CommandOutputChunk,
  ExecutionCancelRequest,
  ExecutionReceipt,
  ExecutionResourceUsage,
  CommandExecutionStatus,
} from '@codesoul-co/hypha-core';

Usage patterns

  • Use the 7 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.

Public exports

SymbolKindSignatureDescription
CommandExecutionRequestinterfaceinterface CommandExecutionRequestCommand Execution Request interface with 35 public fields or methods.
CommandExecutionResultinterfaceinterface CommandExecutionResultCommand Execution Result interface with 25 public fields or methods.
CommandOutputChunkinterfaceinterface CommandOutputChunkCommand Output Chunk interface with 9 public fields or methods.
ExecutionCancelRequestinterfaceinterface ExecutionCancelRequestExecution Cancel Request interface with 9 public fields or methods.
ExecutionReceiptinterfaceinterface ExecutionReceiptExecution Receipt interface with 8 public fields or methods.
ExecutionResourceUsageinterfaceinterface ExecutionResourceUsageExecution Resource Usage interface with 8 public fields or methods.
CommandExecutionStatustypetype CommandExecutionStatus = 'queued' | 'starting' | 'running' | 'cancelling' | 'cancelled' | 'completed' | 'failed' | 'timed_out' | 'oom_killed' | 'resource_exceeded' | 'quarantined'Public type alias for Command Execution Status; the declaration contains its complete type expression.

CommandExecutionRequest

Command Execution Request interface with 35 public fields or methods.

  • Kind: interface
  • Import: import type { CommandExecutionRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/command-execution

Declaration

text
export interface CommandExecutionRequest {
    executionId?: string;
    operationId: string;
    principal: ExecutionPrincipal;
    tenantId?: string;
    userId: string;
    workspaceId: string;
    sessionId?: string;
    runId: string;
    stepId?: string;
    agentId?: string;
    fsmState?: string;
    sandboxId?: string;
    environmentRef: SpecRef;
    executable: string;
    args?: string[];
    cwd?: string;
    env?: Record<string, string>;
    secretRefs?: string[];
    shell?: boolean;
    stdin?: string | Uint8Array;
    timeoutMs?: number;
    idleTimeoutMs?: number;
    maxStdoutBytes?: number;
    maxStderrBytes?: number;
    captureArtifacts?: boolean;
    captureFileMutations?: boolean;
    snapshotBefore?: boolean;
    snapshotAfter?: boolean;
    snapshotOnFailure?: boolean;
    networkAuthorizationRef?: string;
    idempotencyKey?: string;
    expectedWorkspaceSnapshotHash?: string;
    correlationId?: string;
    causationId?: string;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
agentIdpropertyagentId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
argspropertyargs?: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
captureArtifactspropertycaptureArtifacts?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
captureFileMutationspropertycaptureFileMutations?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
causationIdpropertycausationId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
correlationIdpropertycorrelationId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
cwdpropertycwd?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
envpropertyenv?: Record<string, string>Public property; its type, readonly modifier and optionality are shown in the signature.
environmentRefpropertyenvironmentRef: SpecRefPublic property; its type, readonly modifier and optionality are shown in the signature.
executablepropertyexecutable: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
executionIdpropertyexecutionId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expectedWorkspaceSnapshotHashpropertyexpectedWorkspaceSnapshotHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
fsmStatepropertyfsmState?: 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.
idleTimeoutMspropertyidleTimeoutMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxStderrBytespropertymaxStderrBytes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxStdoutBytespropertymaxStdoutBytes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
networkAuthorizationRefpropertynetworkAuthorizationRef?: stringPublic 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.
principalpropertyprincipal: ExecutionPrincipalPublic 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.
sandboxIdpropertysandboxId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
secretRefspropertysecretRefs?: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
sessionIdpropertysessionId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
shellpropertyshell?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
snapshotAfterpropertysnapshotAfter?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
snapshotBeforepropertysnapshotBefore?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
snapshotOnFailurepropertysnapshotOnFailure?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
stdinpropertystdin?: string | Uint8Array<ArrayBufferLike>Public property; its type, readonly modifier and optionality are shown in the signature.
stepIdpropertystepId?: 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.
timeoutMspropertytimeoutMs?: 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.
workspaceIdpropertyworkspaceId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

CommandExecutionResult

Command Execution Result interface with 25 public fields or methods.

  • Kind: interface
  • Import: import type { CommandExecutionResult } from '@codesoul-co/hypha-core';
  • Source module: contracts/command-execution

Declaration

text
export interface CommandExecutionResult {
    executionId: string;
    revision: number;
    sandboxId: string;
    status: CommandExecutionStatus;
    exitCode: number | null;
    signal?: string;
    stdout?: string;
    stderr?: string;
    /** SHA-256 content hash of the bounded inline stdout value. */
    stdoutContentHash?: string;
    /** SHA-256 content hash of the bounded inline stderr value. */
    stderrContentHash?: string;
    stdoutTruncated?: boolean;
    stderrTruncated?: boolean;
    stdoutArtifactRef?: string;
    stderrArtifactRef?: string;
    changedFiles: FileMutation[];
    generatedArtifactRefs: string[];
    snapshotBeforeRef?: string;
    snapshotAfterRef?: string;
    resourceUsage?: ExecutionResourceUsage;
    externalReceipt?: ExecutionReceipt;
    startedAt: string;
    completedAt?: string;
    latencyMs?: number;
    error?: NormalizedExecutionError;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
changedFilespropertychangedFiles: FileMutation[]Public property; its type, readonly modifier and optionality are shown in the signature.
completedAtpropertycompletedAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
errorpropertyerror?: NormalizedExecutionErrorPublic property; its type, readonly modifier and optionality are shown in the signature.
executionIdpropertyexecutionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
exitCodepropertyexitCode: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
externalReceiptpropertyexternalReceipt?: ExecutionReceiptPublic property; its type, readonly modifier and optionality are shown in the signature.
generatedArtifactRefspropertygeneratedArtifactRefs: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
latencyMspropertylatencyMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
resourceUsagepropertyresourceUsage?: ExecutionResourceUsagePublic property; its type, readonly modifier and optionality are shown in the signature.
revisionpropertyrevision: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
sandboxIdpropertysandboxId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
signalpropertysignal?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
snapshotAfterRefpropertysnapshotAfterRef?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
snapshotBeforeRefpropertysnapshotBeforeRef?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
startedAtpropertystartedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus: CommandExecutionStatusPublic property; its type, readonly modifier and optionality are shown in the signature.
stderrpropertystderr?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
stderrArtifactRefpropertystderrArtifactRef?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
stderrContentHashpropertystderrContentHash?: stringSHA-256 content hash of the bounded inline stderr value.
stderrTruncatedpropertystderrTruncated?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
stdoutpropertystdout?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
stdoutArtifactRefpropertystdoutArtifactRef?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
stdoutContentHashpropertystdoutContentHash?: stringSHA-256 content hash of the bounded inline stdout value.
stdoutTruncatedpropertystdoutTruncated?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.

CommandOutputChunk

Command Output Chunk interface with 9 public fields or methods.

Declaration

text
export interface CommandOutputChunk {
    executionId: string;
    sequence: number;
    stream: 'stdout' | 'stderr';
    encoding: 'utf8' | 'base64';
    content: string;
    byteLength: number;
    contentHash: string;
    emittedAt: string;
    truncated?: boolean;
}

Contract members

MemberKindSignatureDescription
byteLengthpropertybyteLength: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
contentpropertycontent: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
contentHashpropertycontentHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
emittedAtpropertyemittedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
encodingpropertyencoding: "utf8" | "base64"Public property; its type, readonly modifier and optionality are shown in the signature.
executionIdpropertyexecutionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sequencepropertysequence: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
streampropertystream: "stdout" | "stderr"Public property; its type, readonly modifier and optionality are shown in the signature.
truncatedpropertytruncated?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.

ExecutionCancelRequest

Execution Cancel Request interface with 9 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionCancelRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/command-execution

Declaration

text
export interface ExecutionCancelRequest {
    operationId: string;
    executionId: string;
    principal: ExecutionPrincipal;
    expectedRevision: number;
    reason?: string;
    gracePeriodMs?: number;
    idempotencyKey?: string;
    correlationId?: string;
    causationId?: string;
}

Contract members

MemberKindSignatureDescription
causationIdpropertycausationId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
correlationIdpropertycorrelationId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
executionIdpropertyexecutionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expectedRevisionpropertyexpectedRevision: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
gracePeriodMspropertygracePeriodMs?: numberPublic 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.
operationIdpropertyoperationId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
principalpropertyprincipal: ExecutionPrincipalPublic property; its type, readonly modifier and optionality are shown in the signature.
reasonpropertyreason?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ExecutionReceipt

Execution Receipt interface with 8 public fields or methods.

Declaration

text
export interface ExecutionReceipt {
    id: string;
    providerId: string;
    executionId: string;
    providerExecutionRef?: string;
    status: 'accepted' | 'completed' | 'rejected' | 'unknown';
    issuedAt: string;
    receiptHash: string;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
executionIdpropertyexecutionId: 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.
issuedAtpropertyissuedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
providerExecutionRefpropertyproviderExecutionRef?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
providerIdpropertyproviderId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
receiptHashpropertyreceiptHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus: "unknown" | "accepted" | "completed" | "rejected"Public property; its type, readonly modifier and optionality are shown in the signature.

ExecutionResourceUsage

Execution Resource Usage interface with 8 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionResourceUsage } from '@codesoul-co/hypha-core';
  • Source module: contracts/command-execution

Declaration

text
export interface ExecutionResourceUsage {
    cpuTimeMs?: number;
    peakMemoryBytes?: number;
    readBytes?: number;
    writtenBytes?: number;
    networkBytesSent?: number;
    networkBytesReceived?: number;
    processCountPeak?: number;
    outputBytes?: number;
}

Contract members

MemberKindSignatureDescription
cpuTimeMspropertycpuTimeMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
networkBytesReceivedpropertynetworkBytesReceived?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
networkBytesSentpropertynetworkBytesSent?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
outputBytespropertyoutputBytes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
peakMemoryBytespropertypeakMemoryBytes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
processCountPeakpropertyprocessCountPeak?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
readBytespropertyreadBytes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
writtenBytespropertywrittenBytes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

CommandExecutionStatus

Public type alias for Command Execution Status; the declaration contains its complete type expression.

Declaration

text
export type CommandExecutionStatus = 'queued' | 'starting' | 'running' | 'cancelling' | 'cancelled' | 'completed' | 'failed' | 'timed_out' | 'oom_killed' | 'resource_exceeded' | 'quarantined';