Skip to content

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

模块用法

用于声明并运行时校验契约。Artifact events 模块公开 2 接口、5 类型。

从包入口导入

ts
import type {
  ArtifactEventPayload,
  ArtifactEventPublisher,
  ArtifactEventCreateInput,
  ArtifactEventPayloadMap,
  ArtifactEventPublication,
  ArtifactFrameworkEvent,
  ArtifactFrameworkEventType,
} from '@codesoul-co/hypha-core';

使用要点

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

公共导出

Symbol种类签名说明
ArtifactEventPayload接口interface ArtifactEventPayloadArtifact Event Payload 接口,共包含 19 个公开字段或方法。
ArtifactEventPublisher接口interface ArtifactEventPublisherRuntime-owned adapters must durably and idempotently publish by publication ID.
ArtifactEventCreateInput类型type ArtifactEventCreateInput = Omit<EventCreateInput<ArtifactEventPayloadMap[TType]>, 'type'> & { type: TType; }Artifact Event Create Input 公共类型别名;完整类型表达式见声明。
ArtifactEventPayloadMap类型type ArtifactEventPayloadMap = { 'artifact.create.requested': ArtifactEventPayloadWithRequired<'operationId' | 'workspaceId' | 'profileRef'>; 'artifact.created': ArtifactStatusEventPayload<'draft'> & ArtifactEventPayloadWithRequired<'logicalArtifactId' | 'contentHash'>; 'artifact.deduplicated': ArtifactEventPayloadWithRequired<'operationId' | 'artifactId' | 'versionId' | 'contentHash' | 'deduplicated'> & { dedupli...Artifact Event Payload Map 公共类型别名;完整类型表达式见声明。
ArtifactEventPublication类型type ArtifactEventPublication = { id: string; type: TType; timestamp: string; payload: ArtifactEventPayloadMap[TType]; workspaceId?: string; sessionId?: string; runId?: string; agentId?: string; }Artifact Event Publication 公共类型别名;完整类型表达式见声明。
ArtifactFrameworkEvent类型type ArtifactFrameworkEvent = Omit<FrameworkEvent<ArtifactEventPayloadMap[TType]>, 'type'> & { type: TType; }Artifact Framework Event 公共类型别名;完整类型表达式见声明。
ArtifactFrameworkEventType类型type ArtifactFrameworkEventType = 'artifact.create.requested' | 'artifact.created' | 'artifact.deduplicated' | 'artifact.create.failed' | 'artifact.read.requested' | 'artifact.read.completed' | 'artifact.version.created' | 'artifact.finalized' | 'artifact.archived' | 'artifact.invalidated' | 'artifact.delete.requested' | 'artifact.delete.blocked' | 'artifact.deleted' | 'artifact.delete.failed' | 'artifact.lineage....Artifact Framework Event Type 公共类型别名;完整类型表达式见声明。

ArtifactEventPayload

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

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

声明

text
export interface ArtifactEventPayload {
    operationId?: string;
    artifactId?: string;
    versionId?: string;
    logicalArtifactId?: string;
    profileRef?: SpecRef;
    workspaceId?: string;
    executionId?: string;
    artifactRefs?: string[];
    contentHash?: string;
    sizeBytes?: number;
    status?: ArtifactStatus;
    deduplicated?: boolean;
    candidateObjects?: number;
    deletedObjects?: number;
    missingObjects?: number;
    reclaimedBytes?: number;
    reason?: string;
    error?: NormalizedArtifactError;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
artifactId属性artifactId?: string公开属性;类型、只读和可选状态以签名列为准。
artifactRefs属性artifactRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
candidateObjects属性candidateObjects?: number公开属性;类型、只读和可选状态以签名列为准。
contentHash属性contentHash?: string公开属性;类型、只读和可选状态以签名列为准。
deduplicated属性deduplicated?: boolean公开属性;类型、只读和可选状态以签名列为准。
deletedObjects属性deletedObjects?: number公开属性;类型、只读和可选状态以签名列为准。
error属性error?: NormalizedArtifactError公开属性;类型、只读和可选状态以签名列为准。
executionId属性executionId?: string公开属性;类型、只读和可选状态以签名列为准。
logicalArtifactId属性logicalArtifactId?: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
missingObjects属性missingObjects?: number公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId?: string公开属性;类型、只读和可选状态以签名列为准。
profileRef属性profileRef?: SpecRef公开属性;类型、只读和可选状态以签名列为准。
reason属性reason?: string公开属性;类型、只读和可选状态以签名列为准。
reclaimedBytes属性reclaimedBytes?: number公开属性;类型、只读和可选状态以签名列为准。
sizeBytes属性sizeBytes?: number公开属性;类型、只读和可选状态以签名列为准。
status属性status?: ArtifactStatus公开属性;类型、只读和可选状态以签名列为准。
versionId属性versionId?: string公开属性;类型、只读和可选状态以签名列为准。
workspaceId属性workspaceId?: string公开属性;类型、只读和可选状态以签名列为准。

ArtifactEventPublisher

Runtime-owned adapters must durably and idempotently publish by publication ID.

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

声明

text
export interface ArtifactEventPublisher {
    publish(publication: ArtifactEventPublication): Promise<void>;
}

契约成员

成员种类签名说明
publish方法publish(publication: ArtifactEventPublication): Promise<void>公开方法;参数与返回类型以签名列为准。

ArtifactEventCreateInput

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

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

声明

text
export type ArtifactEventCreateInput<TType extends ArtifactFrameworkEventType = ArtifactFrameworkEventType> = Omit<EventCreateInput<ArtifactEventPayloadMap[TType]>, 'type'> & {
    type: TType;
};

ArtifactEventPayloadMap

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

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

声明

text
export type ArtifactEventPayloadMap = {
    'artifact.create.requested': ArtifactEventPayloadWithRequired<'operationId' | 'workspaceId' | 'profileRef'>;
    'artifact.created': ArtifactStatusEventPayload<'draft'> & ArtifactEventPayloadWithRequired<'logicalArtifactId' | 'contentHash'>;
    'artifact.deduplicated': ArtifactEventPayloadWithRequired<'operationId' | 'artifactId' | 'versionId' | 'contentHash' | 'deduplicated'> & {
        deduplicated: true;
    };
    'artifact.create.failed': ArtifactEventPayloadWithRequired<'operationId' | 'error'>;
    'artifact.read.requested': ArtifactEventPayloadWithRequired<'artifactId'>;
    'artifact.read.completed': ArtifactEventPayloadWithRequired<'artifactId' | 'versionId' | 'contentHash' | 'sizeBytes'>;
    'artifact.version.created': ArtifactEventPayloadWithRequired<'operationId' | 'artifactId' | 'versionId' | 'logicalArtifactId' | 'contentHash' | 'status'>;
    'artifact.finalized': ArtifactStatusEventPayload<'final'>;
    'artifact.archived': ArtifactStatusEventPayload<'archived'>;
    'artifact.invalidated': ArtifactStatusEventPayload<'invalidated'>;
    'artifact.delete.requested': ArtifactEventPayloadWithRequired<'operationId' | 'artifactId'>;
    'artifact.delete.blocked': ArtifactEventPayloadWithRequired<'operationId' | 'artifactId' | 'error'>;
    'artifact.deleted': ArtifactEventPayloadWithRequired<'operationId' | 'artifactId' | 'status'> & {
        status: 'deleted';
    };
    'artifact.delete.failed': ArtifactEventPayloadWithRequired<'operationId' | 'artifactId' | 'error'>;
    'artifact.lineage.recorded': ArtifactEventPayloadWithRequired<'artifactId' | 'artifactRefs'>;
    'artifact.retention.expired': ArtifactEventPayloadWithRequired<'artifactId' | 'versionId'>;
    'artifact.gc.completed': ArtifactEventPayloadWithRequired<'operationId' | 'candidateObjects' | 'deletedObjects' | 'missingObjects' | 'reclaimedBytes'>;
    'artifact.gc.failed': ArtifactEventPayloadWithRequired<'operationId' | 'error'>;
};

ArtifactEventPublication

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

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

声明

text
export type ArtifactEventPublication<TType extends ArtifactFrameworkEventType = ArtifactFrameworkEventType> = {
    id: string;
    type: TType;
    timestamp: string;
    payload: ArtifactEventPayloadMap[TType];
    workspaceId?: string;
    sessionId?: string;
    runId?: string;
    agentId?: string;
};

ArtifactFrameworkEvent

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

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

声明

text
export type ArtifactFrameworkEvent<TType extends ArtifactFrameworkEventType = ArtifactFrameworkEventType> = Omit<FrameworkEvent<ArtifactEventPayloadMap[TType]>, 'type'> & {
    type: TType;
};

ArtifactFrameworkEventType

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

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

声明

text
export type ArtifactFrameworkEventType = 'artifact.create.requested' | 'artifact.created' | 'artifact.deduplicated' | 'artifact.create.failed' | 'artifact.read.requested' | 'artifact.read.completed' | 'artifact.version.created' | 'artifact.finalized' | 'artifact.archived' | 'artifact.invalidated' | 'artifact.delete.requested' | 'artifact.delete.blocked' | 'artifact.deleted' | 'artifact.delete.failed' | 'artifact.lineage.recorded' | 'artifact.retention.expired' | 'artifact.gc.completed' | 'artifact.gc.failed';