Skip to content

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

模块用法

用于声明并运行时校验契约。Execution events 模块公开 4 接口、7 类型。

从包入口导入

ts
import type {
  CommandExecutionEventPayload,
  ExecutionEventPayloadBase,
  NetworkAuthorizationEventPayload,
  SandboxLifecycleEventPayload,
  CommandExecutionFrameworkEventType,
  ExecutionEventCreateInput,
  ExecutionEventPayloadMap,
  ExecutionFrameworkEvent,
} from '@codesoul-co/hypha-core';

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

使用要点

  • 11 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。

公共导出

Symbol种类签名说明
CommandExecutionEventPayload接口interface CommandExecutionEventPayload extends ExecutionEventPayloadBaseCommand Execution Event Payload 接口,共包含 22 个公开字段或方法。
ExecutionEventPayloadBase接口interface ExecutionEventPayloadBaseExecution Event Payload Base 接口,共包含 14 个公开字段或方法。
NetworkAuthorizationEventPayload接口interface NetworkAuthorizationEventPayload extends ExecutionEventPayloadBaseNetwork Authorization Event Payload 接口,共包含 19 个公开字段或方法。
SandboxLifecycleEventPayload接口interface SandboxLifecycleEventPayload extends ExecutionEventPayloadBaseSandbox Lifecycle Event Payload 接口,共包含 17 个公开字段或方法。
CommandExecutionFrameworkEventType类型type CommandExecutionFrameworkEventType = 'command.execution.requested' | 'command.execution.validated' | 'command.execution.approval.required' | 'command.execution.queued' | 'command.execution.started' | 'command.execution.output.truncated' | 'command.execution.resource.exceeded' | 'command.execution.oom_killed' | 'command.execution.timeout' | 'command.execution.cancellation.requested' | 'command.execution.cancel...Command Execution Framework Event Type 公共类型别名;完整类型表达式见声明。
ExecutionEventCreateInput类型type ExecutionEventCreateInput = Omit<EventCreateInput<ExecutionEventPayloadMap[TType]>, 'type'> & { type: TType; }Execution Event Create Input 公共类型别名;完整类型表达式见声明。
ExecutionEventPayloadMap类型type ExecutionEventPayloadMap = { [K in SandboxFrameworkEventType]: SandboxLifecycleEventPayload; } & { [K in CommandExecutionFrameworkEventType]: CommandExecutionEventPayload; } & { [K in NetworkAuthorizationFrameworkEventType]: NetworkAuthorizationEventPayload; }Execution Event Payload Map 公共类型别名;完整类型表达式见声明。
ExecutionFrameworkEvent类型type ExecutionFrameworkEvent = Omit<FrameworkEvent<ExecutionEventPayloadMap[TType]>, 'type'> & { type: TType; }Execution Framework Event 公共类型别名;完整类型表达式见声明。
ExecutionFrameworkEventType类型type ExecutionFrameworkEventType = SandboxFrameworkEventType | CommandExecutionFrameworkEventType | NetworkAuthorizationFrameworkEventTypeExecution Framework Event Type 公共类型别名;完整类型表达式见声明。
NetworkAuthorizationFrameworkEventType类型type NetworkAuthorizationFrameworkEventType = 'network.authorization.requested' | 'network.authorization.granted' | 'network.authorization.denied' | 'network.authorization.revoked'Network Authorization Framework Event Type 公共类型别名;完整类型表达式见声明。
SandboxFrameworkEventType类型type SandboxFrameworkEventType = 'sandbox.create.requested' | 'sandbox.created' | 'sandbox.started' | 'sandbox.ready' | 'sandbox.degraded' | 'sandbox.terminate.requested' | 'sandbox.terminated' | 'sandbox.cleanup.completed' | 'sandbox.cleanup.failed'Sandbox Framework Event Type 公共类型别名;完整类型表达式见声明。

CommandExecutionEventPayload

Command Execution Event Payload 接口,共包含 22 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { CommandExecutionEventPayload } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/execution-events

声明

text
export interface CommandExecutionEventPayload extends ExecutionEventPayloadBase {
    executionId: string;
    revision?: number;
    providerId?: string;
    status?: CommandExecutionStatus;
    exitCode?: number | null;
    signal?: string;
    outputStream?: 'stdout' | 'stderr';
    outputTruncated?: boolean;
    approvalRef?: string;
    recoveryDisposition?: ExecutionRecoveryDisposition;
}

契约成员

成员种类签名说明
approvalRef属性approvalRef?: string公开属性;类型、只读和可选状态以签名列为准。
artifactRefs属性artifactRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
commandHash属性commandHash?: string公开属性;类型、只读和可选状态以签名列为准。
environmentId属性environmentId?: string公开属性;类型、只读和可选状态以签名列为准。
environmentRevision属性environmentRevision?: string公开属性;类型、只读和可选状态以签名列为准。
error属性error?: NormalizedExecutionError公开属性;类型、只读和可选状态以签名列为准。
executionId属性executionId: string公开属性;类型、只读和可选状态以签名列为准。
exitCode属性exitCode?: number公开属性;类型、只读和可选状态以签名列为准。
latencyMs属性latencyMs?: number公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId?: string公开属性;类型、只读和可选状态以签名列为准。
outputStream属性outputStream?: "stdout" | "stderr"公开属性;类型、只读和可选状态以签名列为准。
outputTruncated属性outputTruncated?: boolean公开属性;类型、只读和可选状态以签名列为准。
providerId属性providerId?: string公开属性;类型、只读和可选状态以签名列为准。
recoveryDisposition属性recoveryDisposition?: ExecutionRecoveryDisposition公开属性;类型、只读和可选状态以签名列为准。
resourceUsage属性resourceUsage?: ExecutionResourceUsage公开属性;类型、只读和可选状态以签名列为准。
revision属性revision?: number公开属性;类型、只读和可选状态以签名列为准。
sandboxId属性sandboxId?: string公开属性;类型、只读和可选状态以签名列为准。
signal属性signal?: string公开属性;类型、只读和可选状态以签名列为准。
sourceTreeHash属性sourceTreeHash?: string公开属性;类型、只读和可选状态以签名列为准。
status属性status?: CommandExecutionStatus公开属性;类型、只读和可选状态以签名列为准。
workspaceId属性workspaceId?: string公开属性;类型、只读和可选状态以签名列为准。

ExecutionEventPayloadBase

Execution Event Payload Base 接口,共包含 14 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ExecutionEventPayloadBase } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/execution-events

声明

text
export interface ExecutionEventPayloadBase {
    operationId?: string;
    executionId?: string;
    sandboxId?: string;
    workspaceId?: string;
    environmentId?: string;
    environmentRevision?: string;
    commandHash?: string;
    sourceTreeHash?: string;
    artifactRefs?: string[];
    status?: string;
    latencyMs?: number;
    resourceUsage?: ExecutionResourceUsage;
    error?: NormalizedExecutionError;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
artifactRefs属性artifactRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
commandHash属性commandHash?: string公开属性;类型、只读和可选状态以签名列为准。
environmentId属性environmentId?: string公开属性;类型、只读和可选状态以签名列为准。
environmentRevision属性environmentRevision?: string公开属性;类型、只读和可选状态以签名列为准。
error属性error?: NormalizedExecutionError公开属性;类型、只读和可选状态以签名列为准。
executionId属性executionId?: string公开属性;类型、只读和可选状态以签名列为准。
latencyMs属性latencyMs?: number公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId?: string公开属性;类型、只读和可选状态以签名列为准。
resourceUsage属性resourceUsage?: ExecutionResourceUsage公开属性;类型、只读和可选状态以签名列为准。
sandboxId属性sandboxId?: string公开属性;类型、只读和可选状态以签名列为准。
sourceTreeHash属性sourceTreeHash?: string公开属性;类型、只读和可选状态以签名列为准。
status属性status?: string公开属性;类型、只读和可选状态以签名列为准。
workspaceId属性workspaceId?: string公开属性;类型、只读和可选状态以签名列为准。

NetworkAuthorizationEventPayload

Network Authorization Event Payload 接口,共包含 19 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { NetworkAuthorizationEventPayload } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/execution-events

声明

text
export interface NetworkAuthorizationEventPayload extends ExecutionEventPayloadBase {
    authorizationId: string;
    networkPolicyHash: string;
    decision: 'requested' | 'granted' | 'denied' | 'revoked';
    expiresAt?: string;
    reason?: string;
}

契约成员

成员种类签名说明
artifactRefs属性artifactRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
authorizationId属性authorizationId: string公开属性;类型、只读和可选状态以签名列为准。
commandHash属性commandHash?: string公开属性;类型、只读和可选状态以签名列为准。
decision属性decision: "requested" | "granted" | "denied" | "revoked"公开属性;类型、只读和可选状态以签名列为准。
environmentId属性environmentId?: string公开属性;类型、只读和可选状态以签名列为准。
environmentRevision属性environmentRevision?: string公开属性;类型、只读和可选状态以签名列为准。
error属性error?: NormalizedExecutionError公开属性;类型、只读和可选状态以签名列为准。
executionId属性executionId?: string公开属性;类型、只读和可选状态以签名列为准。
expiresAt属性expiresAt?: string公开属性;类型、只读和可选状态以签名列为准。
latencyMs属性latencyMs?: number公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
networkPolicyHash属性networkPolicyHash: string公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId?: string公开属性;类型、只读和可选状态以签名列为准。
reason属性reason?: string公开属性;类型、只读和可选状态以签名列为准。
resourceUsage属性resourceUsage?: ExecutionResourceUsage公开属性;类型、只读和可选状态以签名列为准。
sandboxId属性sandboxId?: string公开属性;类型、只读和可选状态以签名列为准。
sourceTreeHash属性sourceTreeHash?: string公开属性;类型、只读和可选状态以签名列为准。
status属性status?: string公开属性;类型、只读和可选状态以签名列为准。
workspaceId属性workspaceId?: string公开属性;类型、只读和可选状态以签名列为准。

SandboxLifecycleEventPayload

Sandbox Lifecycle Event Payload 接口,共包含 17 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { SandboxLifecycleEventPayload } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/execution-events

声明

text
export interface SandboxLifecycleEventPayload extends ExecutionEventPayloadBase {
    sandboxId?: string;
    providerId?: string;
    providerSandboxRef?: string;
    status?: SandboxStatus | 'degraded';
    missingCapabilities?: SandboxCapabilityName[];
}

契约成员

成员种类签名说明
artifactRefs属性artifactRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
commandHash属性commandHash?: string公开属性;类型、只读和可选状态以签名列为准。
environmentId属性environmentId?: string公开属性;类型、只读和可选状态以签名列为准。
environmentRevision属性environmentRevision?: string公开属性;类型、只读和可选状态以签名列为准。
error属性error?: NormalizedExecutionError公开属性;类型、只读和可选状态以签名列为准。
executionId属性executionId?: string公开属性;类型、只读和可选状态以签名列为准。
latencyMs属性latencyMs?: number公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
missingCapabilities属性missingCapabilities?: (keyof import("/Users/erwin/Downloads/codespace/Hypha/packages/core/dist/contracts/sandbox").SandboxProviderCapabilities)[]公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId?: string公开属性;类型、只读和可选状态以签名列为准。
providerId属性providerId?: string公开属性;类型、只读和可选状态以签名列为准。
providerSandboxRef属性providerSandboxRef?: string公开属性;类型、只读和可选状态以签名列为准。
resourceUsage属性resourceUsage?: ExecutionResourceUsage公开属性;类型、只读和可选状态以签名列为准。
sandboxId属性sandboxId?: string公开属性;类型、只读和可选状态以签名列为准。
sourceTreeHash属性sourceTreeHash?: string公开属性;类型、只读和可选状态以签名列为准。
status属性status?: "degraded" | SandboxStatus公开属性;类型、只读和可选状态以签名列为准。
workspaceId属性workspaceId?: string公开属性;类型、只读和可选状态以签名列为准。

CommandExecutionFrameworkEventType

Command Execution Framework Event Type 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { CommandExecutionFrameworkEventType } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/execution-events

声明

text
export type CommandExecutionFrameworkEventType = 'command.execution.requested' | 'command.execution.validated' | 'command.execution.approval.required' | 'command.execution.queued' | 'command.execution.started' | 'command.execution.output.truncated' | 'command.execution.resource.exceeded' | 'command.execution.oom_killed' | 'command.execution.timeout' | 'command.execution.cancellation.requested' | 'command.execution.cancelled' | 'command.execution.completed' | 'command.execution.failed' | 'command.execution.result.unknown' | 'command.execution.recovered';

ExecutionEventCreateInput

Execution Event Create Input 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { ExecutionEventCreateInput } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/execution-events

声明

text
export type ExecutionEventCreateInput<TType extends ExecutionFrameworkEventType = ExecutionFrameworkEventType> = Omit<EventCreateInput<ExecutionEventPayloadMap[TType]>, 'type'> & {
    type: TType;
};

ExecutionEventPayloadMap

Execution Event Payload Map 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { ExecutionEventPayloadMap } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/execution-events

声明

text
export type ExecutionEventPayloadMap = {
    [K in SandboxFrameworkEventType]: SandboxLifecycleEventPayload;
} & {
    [K in CommandExecutionFrameworkEventType]: CommandExecutionEventPayload;
} & {
    [K in NetworkAuthorizationFrameworkEventType]: NetworkAuthorizationEventPayload;
};

ExecutionFrameworkEvent

Execution Framework Event 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { ExecutionFrameworkEvent } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/execution-events

声明

text
export type ExecutionFrameworkEvent<TType extends ExecutionFrameworkEventType = ExecutionFrameworkEventType> = Omit<FrameworkEvent<ExecutionEventPayloadMap[TType]>, 'type'> & {
    type: TType;
};

ExecutionFrameworkEventType

Execution Framework Event Type 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { ExecutionFrameworkEventType } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/execution-events

声明

text
export type ExecutionFrameworkEventType = SandboxFrameworkEventType | CommandExecutionFrameworkEventType | NetworkAuthorizationFrameworkEventType;

NetworkAuthorizationFrameworkEventType

Network Authorization Framework Event Type 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { NetworkAuthorizationFrameworkEventType } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/execution-events

声明

text
export type NetworkAuthorizationFrameworkEventType = 'network.authorization.requested' | 'network.authorization.granted' | 'network.authorization.denied' | 'network.authorization.revoked';

SandboxFrameworkEventType

Sandbox Framework Event Type 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { SandboxFrameworkEventType } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/execution-events

声明

text
export type SandboxFrameworkEventType = 'sandbox.create.requested' | 'sandbox.created' | 'sandbox.started' | 'sandbox.ready' | 'sandbox.degraded' | 'sandbox.terminate.requested' | 'sandbox.terminated' | 'sandbox.cleanup.completed' | 'sandbox.cleanup.failed';