Skip to content

@codesoul-co/hypha-core / contracts/runtime-control-schemas

模块用法

用于声明并运行时校验契约。Runtime control schemas 模块公开 13 常量、2 函数。

从包入口导入

ts
import {
  runtimeControlContractDefinitions,
  runtimeControlContractJsonSchemas,
  runtimePauseCommandSchema,
  runtimeResumeCommandSchema,
  runtimeRunControlCommandDefinition,
  runtimeRunControlCommandExample,
  runtimeRunControlCommandJsonSchema,
  runtimeRunControlCommandSchema,
} from '@codesoul-co/hypha-core';

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

使用要点

  • 2 个函数是该模块的直接操作入口;每个 overload 的必需/可选参数与返回类型均在下方列出。
  • 13 个常量/枚举提供稳定值、Schema、Definition 或默认配置;应复用这些导出,避免在应用中复制内部值。

运行时校验示例

ts
import { runtimePauseCommandSchema } from '@codesoul-co/hypha-core';

declare function loadExternalInput(): unknown;
const input: unknown = loadExternalInput();
const parsed = runtimePauseCommandSchema.parse(input);

配置、网络请求或持久化数据等不可信输入应先通过 Runtime Schema,再传给只接受已校验契约的函数或类。

公共导出

Symbol种类签名说明
runtimeControlContractDefinitions常量const runtimeControlContractDefinitions: readonly [SpecSchemaDefinition<RuntimeRunControlCommand>, SpecSchemaDefinition<RuntimeRunControlResult>]contracts/runtime-control-schemas 模块导出的 Runtime Control Contract Definitions 常量。
runtimeControlContractJsonSchemas常量const runtimeControlContractJsonSchemas: Record<string, JsonSchema>contracts/runtime-control-schemas 模块导出的 Runtime Control Contract JSON Schemas 常量。
runtimePauseCommandSchema常量const runtimePauseCommandSchema: z.ZodObject<{ kind: z.ZodLiteral<"pause">; reason: z.ZodString; resumeKey: z.ZodOptional<z.ZodString>; requestedAt: z.ZodString; commandId: z.ZodString; scope: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; workspaceId: z.ZodOptional<z.ZodString>; sessionId: z.ZodString; runId: z.ZodString; agentId: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { ...Runtime Pause Command 的运行时 Schema。
runtimeResumeCommandSchema常量const runtimeResumeCommandSchema: z.ZodObject<{ kind: z.ZodLiteral<"resume">; key: z.ZodOptional<z.ZodString>; payload: z.ZodOptional<z.ZodType<RuntimeJsonValue, z.ZodTypeDef, RuntimeJsonValue>>; requestedAt: z.ZodString; commandId: z.ZodString; scope: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; workspaceId: z.ZodOptional<z.ZodString>; sessionId: z.ZodString; runId: z.ZodString; agentI...Runtime Resume Command 的运行时 Schema。
runtimeRunControlCommandDefinition常量const runtimeRunControlCommandDefinition: SpecSchemaDefinition<RuntimeRunControlCommand>contracts/runtime-control-schemas 模块导出的 Runtime Run Control Command Definition 常量。
runtimeRunControlCommandExample常量const runtimeRunControlCommandExample: RuntimeRunControlCommandRuntime Run Control Command 的有效示例值。
runtimeRunControlCommandJsonSchema常量const runtimeRunControlCommandJsonSchema: JsonSchemaRuntime Run Control Command 的 JSON Schema。
runtimeRunControlCommandSchema常量const runtimeRunControlCommandSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"pause">; reason: z.ZodString; resumeKey: z.ZodOptional<z.ZodString>; requestedAt: z.ZodString; commandId: z.ZodString; scope: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; workspaceId: z.ZodOptional<z.ZodString>; sessionId: z.ZodString; runId: z.ZodString; agentId: z.ZodOptional<z.Zod...Runtime Run Control Command 的运行时 Schema。
runtimeRunControlResultDefinition常量const runtimeRunControlResultDefinition: SpecSchemaDefinition<RuntimeRunControlResult>contracts/runtime-control-schemas 模块导出的 Runtime Run Control Result Definition 常量。
runtimeRunControlResultExample常量const runtimeRunControlResultExample: RuntimeRunControlResultRuntime Run Control Result 的有效示例值。
runtimeRunControlResultJsonSchema常量const runtimeRunControlResultJsonSchema: JsonSchemaRuntime Run Control Result 的 JSON Schema。
runtimeRunControlResultSchema常量const runtimeRunControlResultSchema: z.ZodObject<{ commandId: z.ZodString; kind: z.ZodEnum<["pause", "resume", "signal"]>; disposition: z.ZodEnum<["applied", "reused", "lease_unavailable"]>; eventIds: z.ZodArray<z.ZodString, "many">; runRevision: z.ZodNumber; projection: z.ZodEffects<z.ZodObject<{ runId: z.ZodString; runStatus: z.ZodEnum<[import("./runtime-projection").RuntimeOrchestrationRunStatus, ...import("./r...Runtime Run Control Result 的运行时 Schema。
runtimeSignalCommandSchema常量const runtimeSignalCommandSchema: z.ZodObject<{ kind: z.ZodLiteral<"signal">; key: z.ZodString; payload: z.ZodType<RuntimeJsonValue, z.ZodTypeDef, RuntimeJsonValue>; sentAt: z.ZodString; commandId: z.ZodString; scope: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; workspaceId: z.ZodOptional<z.ZodString>; sessionId: z.ZodString; runId: z.ZodString; agentId: z.ZodOptional<z.ZodString>; }, "...Runtime Signal Command 的运行时 Schema。
validateRuntimeRunControlCommand函数validateRuntimeRunControlCommand(input: unknown): RuntimeRunControlCommandValidate Runtime Run Control Command 函数,提供 1 个公开调用签名;参数与返回类型见下表。
validateRuntimeRunControlResult函数validateRuntimeRunControlResult(input: unknown): RuntimeRunControlResultValidate Runtime Run Control Result 函数,提供 1 个公开调用签名;参数与返回类型见下表。

runtimeControlContractDefinitions

contracts/runtime-control-schemas 模块导出的 Runtime Control Contract Definitions 常量。

声明

text
export declare const runtimeControlContractDefinitions: readonly [SpecSchemaDefinition<RuntimeRunControlCommand>, SpecSchemaDefinition<RuntimeRunControlResult>];

runtimeControlContractJsonSchemas

contracts/runtime-control-schemas 模块导出的 Runtime Control Contract JSON Schemas 常量。

声明

text
export declare const runtimeControlContractJsonSchemas: Record<string, JsonSchema>;

runtimePauseCommandSchema

Runtime Pause Command 的运行时 Schema。

声明

text
// 精确类型由包入口解析;完整编译器展开定义见源码链接。
export declare const runtimePauseCommandSchema: (typeof import('@codesoul-co/hypha-core'))['runtimePauseCommandSchema'];

该常量的编译器展开类型已压缩;它的公共名称、顶层类型与源码位置仍保留在本条目中。相关输入/输出字段请使用同模块导出的接口、类型或 Runtime Schema。

runtimeResumeCommandSchema

Runtime Resume Command 的运行时 Schema。

声明

text
// 精确类型由包入口解析;完整编译器展开定义见源码链接。
export declare const runtimeResumeCommandSchema: (typeof import('@codesoul-co/hypha-core'))['runtimeResumeCommandSchema'];

该常量的编译器展开类型已压缩;它的公共名称、顶层类型与源码位置仍保留在本条目中。相关输入/输出字段请使用同模块导出的接口、类型或 Runtime Schema。

runtimeRunControlCommandDefinition

contracts/runtime-control-schemas 模块导出的 Runtime Run Control Command Definition 常量。

声明

text
export declare const runtimeRunControlCommandDefinition: SpecSchemaDefinition<RuntimeRunControlCommand>;

runtimeRunControlCommandExample

Runtime Run Control Command 的有效示例值。

声明

text
export declare const runtimeRunControlCommandExample: RuntimeRunControlCommand;

runtimeRunControlCommandJsonSchema

Runtime Run Control Command 的 JSON Schema。

声明

text
export declare const runtimeRunControlCommandJsonSchema: JsonSchema;

runtimeRunControlCommandSchema

Runtime Run Control Command 的运行时 Schema。

声明

text
// 精确类型由包入口解析;完整编译器展开定义见源码链接。
export declare const runtimeRunControlCommandSchema: (typeof import('@codesoul-co/hypha-core'))['runtimeRunControlCommandSchema'];

该常量的编译器展开类型已压缩;它的公共名称、顶层类型与源码位置仍保留在本条目中。相关输入/输出字段请使用同模块导出的接口、类型或 Runtime Schema。

runtimeRunControlResultDefinition

contracts/runtime-control-schemas 模块导出的 Runtime Run Control Result Definition 常量。

声明

text
export declare const runtimeRunControlResultDefinition: SpecSchemaDefinition<RuntimeRunControlResult>;

runtimeRunControlResultExample

Runtime Run Control Result 的有效示例值。

声明

text
export declare const runtimeRunControlResultExample: RuntimeRunControlResult;

runtimeRunControlResultJsonSchema

Runtime Run Control Result 的 JSON Schema。

声明

text
export declare const runtimeRunControlResultJsonSchema: JsonSchema;

runtimeRunControlResultSchema

Runtime Run Control Result 的运行时 Schema。

声明

text
// 精确类型由包入口解析;完整编译器展开定义见源码链接。
export declare const runtimeRunControlResultSchema: (typeof import('@codesoul-co/hypha-core'))['runtimeRunControlResultSchema'];

该常量的编译器展开类型已压缩;它的公共名称、顶层类型与源码位置仍保留在本条目中。相关输入/输出字段请使用同模块导出的接口、类型或 Runtime Schema。

runtimeSignalCommandSchema

Runtime Signal Command 的运行时 Schema。

声明

text
// 精确类型由包入口解析;完整编译器展开定义见源码链接。
export declare const runtimeSignalCommandSchema: (typeof import('@codesoul-co/hypha-core'))['runtimeSignalCommandSchema'];

该常量的编译器展开类型已压缩;它的公共名称、顶层类型与源码位置仍保留在本条目中。相关输入/输出字段请使用同模块导出的接口、类型或 Runtime Schema。

validateRuntimeRunControlCommand

Validate Runtime Run Control Command 函数,提供 1 个公开调用签名;参数与返回类型见下表。

声明

text
export declare function validateRuntimeRunControlCommand(input: unknown): RuntimeRunControlCommand;

调用签名

text
validateRuntimeRunControlCommand(input: unknown): RuntimeRunControlCommand

参数

参数类型必需说明
inputunknown必需参数;接受的值由类型列定义。

返回值

  • 类型: RuntimeRunControlCommand
  • 说明: 返回值契约由上述类型定义。

validateRuntimeRunControlResult

Validate Runtime Run Control Result 函数,提供 1 个公开调用签名;参数与返回类型见下表。

声明

text
export declare function validateRuntimeRunControlResult(input: unknown): RuntimeRunControlResult;

调用签名

text
validateRuntimeRunControlResult(input: unknown): RuntimeRunControlResult

参数

参数类型必需说明
inputunknown必需参数;接受的值由类型列定义。

返回值

  • 类型: RuntimeRunControlResult
  • 说明: 返回值契约由上述类型定义。