@codesoul-co/hypha-core / contracts/runtime-messages
模块用法
用于声明并运行时校验契约。Runtime messages 模块公开 3 常量、4 接口、3 类型。
从包入口导入
ts
import {
RUNTIME_INBOX_STATUSES,
RUNTIME_MESSAGE_TYPES,
RUNTIME_OUTBOX_STATES,
} from '@codesoul-co/hypha-core';
import type {
RuntimeMessageEnvelope,
RuntimeMessageEnvelopeInput,
RuntimeMessageInboxRecord,
RuntimeMessageOutboxRecord,
RuntimeMessageInboxStatus,
RuntimeMessageOutboxState,
RuntimeMessageType,
} from '@codesoul-co/hypha-core';使用要点
- 7 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用
import type,运行时不应依赖它们。 - 3 个常量/枚举提供稳定值、Schema、Definition 或默认配置;应复用这些导出,避免在应用中复制内部值。
公共导出
| Symbol | 种类 | 签名 | 说明 |
|---|---|---|---|
RUNTIME_INBOX_STATUSES | 常量 | const RUNTIME_INBOX_STATUSES: readonly ["processing", "applied", "ignored", "failed"] | 由 contracts/runtime-messages 模块导出的 RUNTIME INBOX STATUSES 常量。 |
RUNTIME_MESSAGE_TYPES | 常量 | const RUNTIME_MESSAGE_TYPES: readonly ["runtime.command.start", "runtime.command.resume", "runtime.command.cancel", "runtime.signal", "runtime.timer.fire", "runtime.activity.requested", "runtime.activity.completed", "runtime.activity.failed", "runtime.agent.message", "runtime.child.completed", "runtime.projection.rebuild", "runtime.recovery.requested", "runtime.custom"] | 由 contracts/runtime-messages 模块导出的 RUNTIME MESSAGE TYPES 常量。 |
RUNTIME_OUTBOX_STATES | 常量 | const RUNTIME_OUTBOX_STATES: readonly ["pending", "publishing", "published", "failed", "dead_letter"] | 由 contracts/runtime-messages 模块导出的 RUNTIME OUTBOX STATES 常量。 |
RuntimeMessageEnvelope | 接口 | interface RuntimeMessageEnvelope | Runtime Message Envelope 接口,共包含 28 个公开字段或方法。 |
RuntimeMessageEnvelopeInput | 接口 | interface RuntimeMessageEnvelopeInput extends Omit<RuntimeMessageEnvelope<TPayload>, 'payloadHash' | 'sequence'> | Runtime Message Envelope Input 接口,共包含 28 个公开字段或方法。 |
RuntimeMessageInboxRecord | 接口 | interface RuntimeMessageInboxRecord | Runtime Message Inbox Record 接口,共包含 12 个公开字段或方法。 |
RuntimeMessageOutboxRecord | 接口 | interface RuntimeMessageOutboxRecord | Runtime Message Outbox Record 接口,共包含 14 个公开字段或方法。 |
RuntimeMessageInboxStatus | 类型 | type RuntimeMessageInboxStatus = (typeof RUNTIME_INBOX_STATUSES)[number] | Runtime Message Inbox Status 公共类型别名;完整类型表达式见声明。 |
RuntimeMessageOutboxState | 类型 | type RuntimeMessageOutboxState = (typeof RUNTIME_OUTBOX_STATES)[number] | Runtime Message Outbox State 公共类型别名;完整类型表达式见声明。 |
RuntimeMessageType | 类型 | type RuntimeMessageType = (typeof RUNTIME_MESSAGE_TYPES)[number] | Runtime Message Type 公共类型别名;完整类型表达式见声明。 |
RUNTIME_INBOX_STATUSES
由 contracts/runtime-messages 模块导出的 RUNTIME INBOX STATUSES 常量。
- 种类: 常量
- 导入:
import { RUNTIME_INBOX_STATUSES } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/runtime-messages
声明
text
export declare const RUNTIME_INBOX_STATUSES: readonly ["processing", "applied", "ignored", "failed"];RUNTIME_MESSAGE_TYPES
由 contracts/runtime-messages 模块导出的 RUNTIME MESSAGE TYPES 常量。
- 种类: 常量
- 导入:
import { RUNTIME_MESSAGE_TYPES } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/runtime-messages
声明
text
export declare const RUNTIME_MESSAGE_TYPES: readonly ["runtime.command.start", "runtime.command.resume", "runtime.command.cancel", "runtime.signal", "runtime.timer.fire", "runtime.activity.requested", "runtime.activity.completed", "runtime.activity.failed", "runtime.agent.message", "runtime.child.completed", "runtime.projection.rebuild", "runtime.recovery.requested", "runtime.custom"];RUNTIME_OUTBOX_STATES
由 contracts/runtime-messages 模块导出的 RUNTIME OUTBOX STATES 常量。
- 种类: 常量
- 导入:
import { RUNTIME_OUTBOX_STATES } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/runtime-messages
声明
text
export declare const RUNTIME_OUTBOX_STATES: readonly ["pending", "publishing", "published", "failed", "dead_letter"];RuntimeMessageEnvelope
Runtime Message Envelope 接口,共包含 28 个公开字段或方法。
- 种类: 接口
- 导入:
import type { RuntimeMessageEnvelope } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/runtime-messages
声明
text
export interface RuntimeMessageEnvelope<TPayload = unknown> {
messageId: string;
messageType: RuntimeMessageType;
schemaVersion: string;
topic: string;
partitionKey: string;
orderingKey?: string;
sequence?: number;
tenantId?: string;
workspaceId?: string;
userId?: string;
sessionId?: string;
runId?: string;
stepId?: string;
activityId?: string;
agentId?: string;
correlationId?: string;
causationId?: string;
traceId?: string;
principal?: RuntimePrincipal;
payload: TPayload;
payloadHash: string;
priority?: number;
availableAt?: string;
expiresAt?: string;
publishedAt: string;
producerId: string;
producerRevision?: string;
metadata?: Record<string, unknown>;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
activityId | 属性 | activityId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
agentId | 属性 | agentId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
availableAt | 属性 | availableAt?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
causationId | 属性 | causationId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
correlationId | 属性 | correlationId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
expiresAt | 属性 | expiresAt?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
messageId | 属性 | messageId: string | 公开属性;类型、只读和可选状态以签名列为准。 |
messageType | 属性 | messageType: "runtime.activity.requested" | "runtime.activity.completed" | "runtime.activity.failed" | "runtime.command.start" | "runtime.command.resume" | "runtime.command.cancel" | "runtime.signal" | "runtime.timer.fire" | "runtime.agent.message" | "runtime.child.completed" | "runtime.projection.rebuild" | "runtime.recovery.requested" | "runtime.custom" | 公开属性;类型、只读和可选状态以签名列为准。 |
metadata | 属性 | metadata?: Record<string, unknown> | 公开属性;类型、只读和可选状态以签名列为准。 |
orderingKey | 属性 | orderingKey?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
partitionKey | 属性 | partitionKey: string | 公开属性;类型、只读和可选状态以签名列为准。 |
payload | 属性 | payload: TPayload | 公开属性;类型、只读和可选状态以签名列为准。 |
payloadHash | 属性 | payloadHash: string | 公开属性;类型、只读和可选状态以签名列为准。 |
principal | 属性 | principal?: RuntimePrincipal | 公开属性;类型、只读和可选状态以签名列为准。 |
priority | 属性 | priority?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
producerId | 属性 | producerId: string | 公开属性;类型、只读和可选状态以签名列为准。 |
producerRevision | 属性 | producerRevision?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
publishedAt | 属性 | publishedAt: string | 公开属性;类型、只读和可选状态以签名列为准。 |
runId | 属性 | runId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
schemaVersion | 属性 | schemaVersion: string | 公开属性;类型、只读和可选状态以签名列为准。 |
sequence | 属性 | sequence?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
sessionId | 属性 | sessionId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
stepId | 属性 | stepId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
tenantId | 属性 | tenantId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
topic | 属性 | topic: string | 公开属性;类型、只读和可选状态以签名列为准。 |
traceId | 属性 | traceId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
userId | 属性 | userId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
workspaceId | 属性 | workspaceId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
RuntimeMessageEnvelopeInput
Runtime Message Envelope Input 接口,共包含 28 个公开字段或方法。
- 种类: 接口
- 导入:
import type { RuntimeMessageEnvelopeInput } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/runtime-messages
声明
text
export interface RuntimeMessageEnvelopeInput<TPayload = unknown> extends Omit<RuntimeMessageEnvelope<TPayload>, 'payloadHash' | 'sequence'> {
payloadHash?: string;
sequence?: number;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
activityId | 属性 | activityId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
agentId | 属性 | agentId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
availableAt | 属性 | availableAt?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
causationId | 属性 | causationId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
correlationId | 属性 | correlationId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
expiresAt | 属性 | expiresAt?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
messageId | 属性 | messageId: string | 公开属性;类型、只读和可选状态以签名列为准。 |
messageType | 属性 | messageType: "runtime.activity.requested" | "runtime.activity.completed" | "runtime.activity.failed" | "runtime.command.start" | "runtime.command.resume" | "runtime.command.cancel" | "runtime.signal" | "runtime.timer.fire" | "runtime.agent.message" | "runtime.child.completed" | "runtime.projection.rebuild" | "runtime.recovery.requested" | "runtime.custom" | 公开属性;类型、只读和可选状态以签名列为准。 |
metadata | 属性 | metadata?: Record<string, unknown> | 公开属性;类型、只读和可选状态以签名列为准。 |
orderingKey | 属性 | orderingKey?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
partitionKey | 属性 | partitionKey: string | 公开属性;类型、只读和可选状态以签名列为准。 |
payload | 属性 | payload: TPayload | 公开属性;类型、只读和可选状态以签名列为准。 |
payloadHash | 属性 | payloadHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
principal | 属性 | principal?: RuntimePrincipal | 公开属性;类型、只读和可选状态以签名列为准。 |
priority | 属性 | priority?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
producerId | 属性 | producerId: string | 公开属性;类型、只读和可选状态以签名列为准。 |
producerRevision | 属性 | producerRevision?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
publishedAt | 属性 | publishedAt: string | 公开属性;类型、只读和可选状态以签名列为准。 |
runId | 属性 | runId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
schemaVersion | 属性 | schemaVersion: string | 公开属性;类型、只读和可选状态以签名列为准。 |
sequence | 属性 | sequence?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
sessionId | 属性 | sessionId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
stepId | 属性 | stepId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
tenantId | 属性 | tenantId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
topic | 属性 | topic: string | 公开属性;类型、只读和可选状态以签名列为准。 |
traceId | 属性 | traceId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
userId | 属性 | userId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
workspaceId | 属性 | workspaceId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
RuntimeMessageInboxRecord
Runtime Message Inbox Record 接口,共包含 12 个公开字段或方法。
- 种类: 接口
- 导入:
import type { RuntimeMessageInboxRecord } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/runtime-messages
声明
text
export interface RuntimeMessageInboxRecord {
consumerId: string;
messageId: string;
payloadHash: string;
status: RuntimeMessageInboxStatus;
appliedEventIds?: string[];
firstReceivedAt: string;
lastReceivedAt: string;
attempts: number;
expiresAt?: string;
processingOwner?: string;
processingExpiresAt?: string;
lastError?: NormalizedRuntimeError;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
appliedEventIds | 属性 | appliedEventIds?: string[] | 公开属性;类型、只读和可选状态以签名列为准。 |
attempts | 属性 | attempts: number | 公开属性;类型、只读和可选状态以签名列为准。 |
consumerId | 属性 | consumerId: string | 公开属性;类型、只读和可选状态以签名列为准。 |
expiresAt | 属性 | expiresAt?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
firstReceivedAt | 属性 | firstReceivedAt: string | 公开属性;类型、只读和可选状态以签名列为准。 |
lastError | 属性 | lastError?: NormalizedRuntimeError | 公开属性;类型、只读和可选状态以签名列为准。 |
lastReceivedAt | 属性 | lastReceivedAt: string | 公开属性;类型、只读和可选状态以签名列为准。 |
messageId | 属性 | messageId: string | 公开属性;类型、只读和可选状态以签名列为准。 |
payloadHash | 属性 | payloadHash: string | 公开属性;类型、只读和可选状态以签名列为准。 |
processingExpiresAt | 属性 | processingExpiresAt?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
processingOwner | 属性 | processingOwner?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
status | 属性 | status: "failed" | "processing" | "applied" | "ignored" | 公开属性;类型、只读和可选状态以签名列为准。 |
RuntimeMessageOutboxRecord
Runtime Message Outbox Record 接口,共包含 14 个公开字段或方法。
- 种类: 接口
- 导入:
import type { RuntimeMessageOutboxRecord } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/runtime-messages
声明
text
export interface RuntimeMessageOutboxRecord {
id: string;
eventId?: string;
messageId: string;
topic: string;
partitionKey: string;
envelope: RuntimeMessageEnvelope;
state: RuntimeMessageOutboxState;
attempts: number;
availableAt: string;
leaseOwner?: string;
leaseExpiresAt?: string;
lastError?: NormalizedRuntimeError;
createdAt: string;
updatedAt: string;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
attempts | 属性 | attempts: number | 公开属性;类型、只读和可选状态以签名列为准。 |
availableAt | 属性 | availableAt: string | 公开属性;类型、只读和可选状态以签名列为准。 |
createdAt | 属性 | createdAt: string | 公开属性;类型、只读和可选状态以签名列为准。 |
envelope | 属性 | envelope: RuntimeMessageEnvelope<unknown> | 公开属性;类型、只读和可选状态以签名列为准。 |
eventId | 属性 | eventId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
id | 属性 | id: string | 公开属性;类型、只读和可选状态以签名列为准。 |
lastError | 属性 | lastError?: NormalizedRuntimeError | 公开属性;类型、只读和可选状态以签名列为准。 |
leaseExpiresAt | 属性 | leaseExpiresAt?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
leaseOwner | 属性 | leaseOwner?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
messageId | 属性 | messageId: string | 公开属性;类型、只读和可选状态以签名列为准。 |
partitionKey | 属性 | partitionKey: string | 公开属性;类型、只读和可选状态以签名列为准。 |
state | 属性 | state: "failed" | "pending" | "publishing" | "published" | "dead_letter" | 公开属性;类型、只读和可选状态以签名列为准。 |
topic | 属性 | topic: string | 公开属性;类型、只读和可选状态以签名列为准。 |
updatedAt | 属性 | updatedAt: string | 公开属性;类型、只读和可选状态以签名列为准。 |
RuntimeMessageInboxStatus
Runtime Message Inbox Status 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { RuntimeMessageInboxStatus } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/runtime-messages
声明
text
export type RuntimeMessageInboxStatus = (typeof RUNTIME_INBOX_STATUSES)[number];RuntimeMessageOutboxState
Runtime Message Outbox State 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { RuntimeMessageOutboxState } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/runtime-messages
声明
text
export type RuntimeMessageOutboxState = (typeof RUNTIME_OUTBOX_STATES)[number];RuntimeMessageType
Runtime Message Type 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { RuntimeMessageType } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/runtime-messages
声明
text
export type RuntimeMessageType = (typeof RUNTIME_MESSAGE_TYPES)[number];