@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 ExecutionEventPayloadBase | Command Execution Event Payload 接口,共包含 22 个公开字段或方法。 |
ExecutionEventPayloadBase | 接口 | interface ExecutionEventPayloadBase | Execution Event Payload Base 接口,共包含 14 个公开字段或方法。 |
NetworkAuthorizationEventPayload | 接口 | interface NetworkAuthorizationEventPayload extends ExecutionEventPayloadBase | Network Authorization Event Payload 接口,共包含 19 个公开字段或方法。 |
SandboxLifecycleEventPayload | 接口 | interface SandboxLifecycleEventPayload extends ExecutionEventPayloadBase | Sandbox 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 | NetworkAuthorizationFrameworkEventType | Execution 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';