Skip to content

@codesoul-co/hypha-tools / index

模块用法

聚合 @codesoul-co/hypha-tools 的公共入口导出;应用应从包入口导入这些 Symbol,不应依赖内部文件路径。

从包入口导入

ts
import {
  AllowAllToolAuthorizer,
  GovernedToolRunner,
  HttpToolAdapter,
  InMemoryToolApprovalStore,
  InMemoryToolInvocationStore,
  InMemoryToolResultCache,
  LocalFunctionToolAdapter,
  MCPToolAdapter,
} from '@codesoul-co/hypha-tools';

import type {
  AdapterCancellationRequest,
  AdapterExecutionRequest,
  HttpToolAdapterOptions,
  InMemoryToolResultCacheOptions,
  MCPToolInvocationPort,
  RedisLikeToolResultCacheClient,
  RedisToolResultCacheOptions,
  ToolAdapter,
} from '@codesoul-co/hypha-tools';

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

使用要点

  • 51 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 17 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。
  • 5 个函数是该模块的直接操作入口;每个 overload 的必需/可选参数与返回类型均在下方列出。
  • 12 个常量/枚举提供稳定值、Schema、Definition 或默认配置;应复用这些导出,避免在应用中复制内部值。

运行时校验示例

ts
import { toolCacheValidityRecordSchema } from '@codesoul-co/hypha-tools';

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

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

公共导出

Symbol种类签名说明
AllowAllToolAuthorizernew AllowAllToolAuthorizer(): AllowAllToolAuthorizerAllow All Tool Authorizer 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。
GovernedToolRunnernew GovernedToolRunner(registry: ToolRegistry, trace: TraceRecorder, policy?: PolicyEngine, options?: { approvalStore?: ToolApprovalStore; invocationStore?: ToolInvocationStore; authorizer?: ToolAuthorizer; middleware?: ToolMiddleware[]; artifactPort?: ToolArtifactPort; snapshotStore?: ToolContractSnapshotStore; receiptReconciler?: ToolReceiptReconciler; resultCache?: ToolResultCache; resultCacheFailureMode?: "byp...Governed Tool Runner 类,共公开 8 个构造函数或成员;精确签名见本条目的声明与成员表。
HttpToolAdapternew HttpToolAdapter(id: string, options: HttpToolAdapterOptions): HttpToolAdapterHttp Tool Adapter 类,共公开 7 个构造函数或成员;精确签名见本条目的声明与成员表。
InMemoryToolApprovalStorenew InMemoryToolApprovalStore(): InMemoryToolApprovalStoreIn Memory Tool Approval Store 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。
InMemoryToolInvocationStorenew InMemoryToolInvocationStore(): InMemoryToolInvocationStoreIn Memory Tool Invocation Store 类,共公开 8 个构造函数或成员;精确签名见本条目的声明与成员表。
InMemoryToolResultCachenew InMemoryToolResultCache(options?: InMemoryToolResultCacheOptions): InMemoryToolResultCacheIn Memory Tool Result Cache 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。
LocalFunctionToolAdapternew LocalFunctionToolAdapter<TInput = unknown, TOutput = unknown>(id: string, handler: ToolHandler<TInput, TOutput>): LocalFunctionToolAdapter<TInput, TOutput>Local Function Tool Adapter 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。
MCPToolAdapternew MCPToolAdapter(id: string, serverId: string, capabilityId: string, gateway: MCPToolInvocationPort): MCPToolAdapterMCP Tool Adapter 类,共公开 7 个构造函数或成员;精确签名见本条目的声明与成员表。
MockToolAdapternew MockToolAdapter<TInput = unknown, TOutput = unknown>(id: string, handler: ToolHandler<TInput, TOutput>): MockToolAdapter<TInput, TOutput>Mock Tool Adapter 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。
MockToolRunnernew MockToolRunner(defaultOutput?: unknown): MockToolRunnerMock Tool Runner 类,共公开 4 个构造函数或成员;精确签名见本条目的声明与成员表。
PermissionScopeToolAuthorizernew PermissionScopeToolAuthorizer(): PermissionScopeToolAuthorizerPermission Scope Tool Authorizer 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。
PluginToolAdapternew PluginToolAdapter<TInput = unknown, TOutput = unknown>(id: string, handler: ToolHandler<TInput, TOutput>): PluginToolAdapter<TInput, TOutput>Plugin Tool Adapter 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。
RedisToolResultCachenew RedisToolResultCache(options: RedisToolResultCacheOptions): RedisToolResultCacheShared Redis-compatible Store for local, self-hosted, and managed Redis deployments.
ToolRegistrynew ToolRegistry(): ToolRegistryTool Registry 类,共公开 9 个构造函数或成员;精确签名见本条目的声明与成员表。
ToolResultCacheEntryTooLargeErrornew ToolResultCacheEntryTooLargeError(actualBytes: number, maxEntryBytes: number): ToolResultCacheEntryTooLargeErrorTool Result Cache Entry Too Large Error 类,共公开 11 个构造函数或成员;精确签名见本条目的声明与成员表。
ToolResultCacheOperationTimeoutErrornew ToolResultCacheOperationTimeoutError(operation: "get" | "set" | "delete" | "verify", timeoutMs: number): ToolResultCacheOperationTimeoutErrorTool Result Cache Operation Timeout Error 类,共公开 11 个构造函数或成员;精确签名见本条目的声明与成员表。
ToolResultCacheValidationErrornew ToolResultCacheValidationError(message: string): ToolResultCacheValidationErrorTool Result Cache Validation Error 类,共公开 9 个构造函数或成员;精确签名见本条目的声明与成员表。
TOOL_INVOCATION_STATUSES常量const TOOL_INVOCATION_STATUSES: readonly ["created", "validating", "validated", "policy_checked", "waiting_approval", "approved", "rejected", "queued", "running", "cancelling", "completed", "failed", "timed_out", "expired", "conflict", "denied", "cancelled"]index 模块导出的 TOOL INVOCATION STATUSES 常量。
toolCacheValidityRecordSchema常量const toolCacheValidityRecordSchema: z.ZodObject<{ toolId: z.ZodString; toolRevision: z.ZodString; inputHash: z.ZodString; scopeHash: z.ZodString; policyRevision: z.ZodString; contractSnapshotHash: z.ZodOptional<z.ZodString>; capabilityHash: z.ZodOptional<z.ZodString>; externalStateVersion: z.ZodOptional<z.ZodString>; key: z.ZodString; validUntil: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { toolId: st...Tool Cache Validity Record 的运行时 Schema。
toolProfileSpecDefinition常量const toolProfileSpecDefinition: SpecSchemaDefinition<ToolProfileSpec>Tool Profile Spec 的运行时校验入口,组合 Parser、Example 与 JSON Schema。
toolProfileSpecSchema常量const toolProfileSpecSchema: z.ZodObject<{ id: z.ZodString; version: z.ZodString; revision: z.ZodOptional<z.ZodString>; toolRefs: z.ZodArray<z.ZodObject<{ id: z.ZodString; version: z.ZodOptional<z.ZodString>; revision: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { id: string; revision?: string | undefined; version?: string | undefined; }, { id: string; revision?: string | undefined; version?: string | un...Tool Profile Spec 的运行时 Schema。
toolResultCacheEntryJsonSchema常量const toolResultCacheEntryJsonSchema: JsonSchemaTool Result Cache Entry 的 JSON Schema。
toolResultCacheEntrySchema常量const toolResultCacheEntrySchema: z.ZodObject<{ schemaVersion: z.ZodLiteral<"1.0">; keyVersion: z.ZodLiteral<"1">; validity: z.ZodObject<{ toolId: z.ZodString; toolRevision: z.ZodString; inputHash: z.ZodString; scopeHash: z.ZodString; policyRevision: z.ZodString; contractSnapshotHash: z.ZodOptional<z.ZodString>; capabilityHash: z.ZodOptional<z.ZodString>; externalStateVersion: z.ZodOptional<z.ZodString>; key: z.Zo...Tool Result Cache Entry 的运行时 Schema。
toolSpecDefinition常量const toolSpecDefinition: SpecSchemaDefinition<ToolSpec>Tool Spec 的运行时校验入口,组合 Parser、Example 与 JSON Schema。
toolSpecDefinitions常量const toolSpecDefinitions: readonly [SpecSchemaDefinition<ToolSpec>, SpecSchemaDefinition<ToolProfileSpec>]index 模块导出的 Tool Spec Definitions 常量。
toolSpecExample常量const toolSpecExample: ToolSpecTool Spec 的有效示例值。
toolSpecJsonSchema常量const toolSpecJsonSchema: JsonSchemaTool Spec 的 JSON Schema。
toolSpecJsonSchemas常量const toolSpecJsonSchemas: Record<string, JsonSchema>index 模块导出的 Tool Spec JSON Schemas 常量。
toolSpecSchema常量const toolSpecSchema: z.ZodObject<{ id: z.ZodString; version: z.ZodString; revision: z.ZodOptional<z.ZodString>; name: z.ZodOptional<z.ZodString>; displayName: z.ZodOptional<z.ZodString>; description: z.ZodString; instructions: z.ZodOptional<z.ZodString>; tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; inputSchema: z.ZodType<JsonSchema, z.ZodTypeDef, JsonSchema>; outputSchema: z.ZodOptional<z.ZodType<JsonSch...Tool Spec 的运行时 Schema。
normalizeToolSpec函数normalizeToolSpec(spec: ToolSpec): ResolvedToolSpecNormalize Tool Spec 函数,提供 1 个公开调用签名;参数与返回类型见下表。
validateEffectiveCapabilityAccess函数validateEffectiveCapabilityAccess(input: { snapshot: ToolContractSnapshot | null; context: ToolCallContext; spec: ToolSpec; }): string | nullValidate Effective Capability Access 函数,提供 1 个公开调用签名;参数与返回类型见下表。
validateToolInput函数validateToolInput(schema: JsonSchema, input: unknown): ToolSchemaValidationResultValidate Tool Input 函数,提供 1 个公开调用签名;参数与返回类型见下表。
validateToolResultCacheEntry函数validateToolResultCacheEntry(value: unknown, maxEntryBytes?: number): ToolResultCacheEntryValidate Tool Result Cache Entry 函数,提供 1 个公开调用签名;参数与返回类型见下表。
validateToolSpec函数validateToolSpec(input: unknown): ToolSpecValidate Tool Spec 函数,提供 1 个公开调用签名;参数与返回类型见下表。
AdapterCancellationRequest接口interface AdapterCancellationRequestAdapter Cancellation Request 接口,共包含 3 个公开字段或方法。
AdapterExecutionRequest接口interface AdapterExecutionRequestAdapter Execution Request 接口,共包含 3 个公开字段或方法。
HttpToolAdapterOptions接口interface HttpToolAdapterOptionsHttp Tool Adapter Options 接口,共包含 4 个公开字段或方法。
InMemoryToolResultCacheOptions接口interface InMemoryToolResultCacheOptionsIn Memory Tool Result Cache Options 接口,共包含 2 个公开字段或方法。
MCPToolInvocationPort接口interface MCPToolInvocationPortMCP Tool Invocation Port 接口,共包含 3 个公开字段或方法。
RedisLikeToolResultCacheClient接口interface RedisLikeToolResultCacheClientRedis Like Tool Result Cache Client 接口,共包含 3 个公开字段或方法。
RedisToolResultCacheOptions接口interface RedisToolResultCacheOptionsRedis Tool Result Cache Options 接口,共包含 5 个公开字段或方法。
ToolAdapter接口interface ToolAdapterTool Adapter 接口,共包含 7 个公开字段或方法。
ToolAdapterCapabilities接口interface ToolAdapterCapabilitiesTool Adapter Capabilities 接口,共包含 5 个公开字段或方法。
ToolApprovalGrant接口interface ToolApprovalGrantTool Approval Grant 接口,共包含 11 个公开字段或方法。
ToolApprovalRequest接口interface ToolApprovalRequestTool Approval Request 接口,共包含 15 个公开字段或方法。
ToolApprovalStore接口interface ToolApprovalStoreTool Approval Store 接口,共包含 5 个公开字段或方法。
ToolArtifactPort接口interface ToolArtifactPortTool Artifact Port 接口,共包含 1 个公开字段或方法。
ToolAuthorizationDecision接口interface ToolAuthorizationDecisionTool Authorization Decision 接口,共包含 3 个公开字段或方法。
ToolAuthorizationInput接口interface ToolAuthorizationInputTool Authorization Input 接口,共包含 4 个公开字段或方法。
ToolAuthorizer接口interface ToolAuthorizerTool Authorizer 接口,共包含 1 个公开字段或方法。
ToolCachedResultProjection接口interface ToolCachedResultProjectionOnly stable, replay-safe output fields may cross invocation boundaries.
ToolCallContext接口interface ToolCallContextTool Call Context 接口,共包含 24 个公开字段或方法。
ToolCallError接口interface ToolCallErrorTool Call Error 接口,共包含 5 个公开字段或方法。
ToolCallRequest接口interface ToolCallRequestTool Call Request 接口,共包含 3 个公开字段或方法。
ToolCallResult接口interface ToolCallResultTool Call Result 接口,共包含 12 个公开字段或方法。
ToolExecutionEnvelope接口interface ToolExecutionEnvelopeTool Execution Envelope 接口,共包含 7 个公开字段或方法。
ToolExecutionScope接口interface ToolExecutionScopeTool Execution Scope 接口,共包含 3 个公开字段或方法。
ToolIdempotencyLookup接口interface ToolIdempotencyLookupTool Idempotency Lookup 接口,共包含 3 个公开字段或方法。
ToolInvocationListRequest接口interface ToolInvocationListRequestTool Invocation List Request 接口,共包含 4 个公开字段或方法。
ToolInvocationRecord接口interface ToolInvocationRecordTool Invocation Record 接口,共包含 37 个公开字段或方法。
ToolInvocationStore接口interface ToolInvocationStoreTool Invocation Store 接口,共包含 7 个公开字段或方法。
ToolMiddleware接口interface ToolMiddlewareTool Middleware 接口,共包含 5 个公开字段或方法。
ToolMiddlewareContext接口interface ToolMiddlewareContextTool Middleware Context 接口,共包含 5 个公开字段或方法。
ToolObservationPort接口interface ToolObservationPortTool Observation Port 接口,共包含 1 个公开字段或方法。
ToolPrincipal接口interface ToolPrincipalTool Principal 接口,共包含 13 个公开字段或方法。
ToolProfileSpec接口interface ToolProfileSpec extends VersionedSpecTool Profile Spec 接口,共包含 11 个公开字段或方法。
ToolProgressUpdate接口interface ToolProgressUpdateTool Progress Update 接口,共包含 6 个公开字段或方法。
ToolReceiptReconciler接口interface ToolReceiptReconcilerTool Receipt Reconciler 接口,共包含 1 个公开字段或方法。
ToolReceiptReconciliation接口interface ToolReceiptReconciliationTool Receipt Reconciliation 接口,共包含 3 个公开字段或方法。
ToolResultCache接口interface ToolResultCacheTool Result Cache 接口,共包含 3 个公开字段或方法。
ToolResultCacheArtifactVerifier接口interface ToolResultCacheArtifactVerifierTool Result Cache Artifact Verifier 接口,共包含 1 个公开字段或方法。
ToolResultCacheEntry接口interface ToolResultCacheEntryTool Result Cache Entry 接口,共包含 5 个公开字段或方法。
ToolRunner接口interface ToolRunnerTool Runner 接口,共包含 2 个公开字段或方法。
ToolSchemaValidationIssue接口interface ToolSchemaValidationIssueTool Schema Validation Issue 接口,共包含 2 个公开字段或方法。
ToolSchemaValidationResult接口interface ToolSchemaValidationResultTool Schema Validation Result 接口,共包含 3 个公开字段或方法。
ToolSpec接口interface ToolSpecTool Spec 接口,共包含 33 个公开字段或方法。
ToolTargetResolution接口interface ToolTargetResolutionTool Target Resolution 接口,共包含 3 个公开字段或方法。
ToolTargetResolver接口interface ToolTargetResolverTool Target Resolver 接口,共包含 1 个公开字段或方法。
MockToolHandler类型type MockToolHandler = (request: ToolCallRequest) => Promise<ToolCallResult> | ToolCallResultMock Tool Handler 公共类型别名;完整类型表达式见声明。
ResolvedToolSpec类型type ResolvedToolSpec = ToolSpec & GovernedToolContractSpecResolved Tool Spec 公共类型别名;完整类型表达式见声明。
ToolExecutionPhase类型type ToolExecutionPhase = 'resolution' | 'authorization' | 'input_validation' | 'policy' | 'approval' | 'execution' | 'timeout' | 'output_validation'Tool Execution Phase 公共类型别名;完整类型表达式见声明。
ToolHandler类型type ToolHandler = (input: TInput, context: ToolCallContext) => Promise<TOutput>Tool Handler 公共类型别名;完整类型表达式见声明。
ToolInvocationPatch类型type ToolInvocationPatch = Partial<Pick<ToolInvocationRecord, 'status' | 'executionCycle' | 'attemptCount' | 'result' | 'approvalRequest' | 'updatedAt' | 'startedAt' | 'completedAt' | 'lateResultState' | 'outputHash' | 'artifactRefs' | 'observationRefs' | 'externalReceipt'>>Tool Invocation Patch 公共类型别名;完整类型表达式见声明。
ToolInvocationStatus类型type ToolInvocationStatus = (typeof TOOL_INVOCATION_STATUSES)[number]Tool Invocation Status 公共类型别名;完整类型表达式见声明。
ToolResultContent类型type ToolResultContent = { type: 'text'; text: string; } | { type: 'json'; value: unknown; } | { type: 'image'; artifactRef?: string; url?: string; mimeType?: string; alt?: string; } | { type: 'resource'; uri: string; mimeType?: string; title?: string; } | { type: 'artifact'; artifactRef: string; title?: string; mimeType?: string; }Tool Result Content 公共类型别名;完整类型表达式见声明。

AllowAllToolAuthorizer

Allow All Tool Authorizer 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { AllowAllToolAuthorizer } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class AllowAllToolAuthorizer implements ToolAuthorizer {
    authorize(): Promise<ToolAuthorizationDecision>;
}

公开成员

成员种类签名说明
authorize方法authorize(): Promise<ToolAuthorizationDecision>公开方法;参数与返回类型以签名列为准。
constructor构造函数(): AllowAllToolAuthorizer创建该类的实例。

GovernedToolRunner

Governed Tool Runner 类,共公开 8 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { GovernedToolRunner } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class GovernedToolRunner implements ToolRunner {
    constructor(registry: ToolRegistry, trace: TraceRecorder, policy?: PolicyEngine, options?: {
            approvalStore?: ToolApprovalStore;
            invocationStore?: ToolInvocationStore;
            authorizer?: ToolAuthorizer;
            middleware?: ToolMiddleware[];
            artifactPort?: ToolArtifactPort;
            snapshotStore?: ToolContractSnapshotStore;
            receiptReconciler?: ToolReceiptReconciler;
            resultCache?: ToolResultCache;
            resultCacheFailureMode?: 'bypass' | 'strict';
            resultCacheTimeoutMs?: number;
            resultCacheMaxEntryBytes?: number;
            resultCacheArtifactVerifier?: ToolResultCacheArtifactVerifier;
            observationPort?: ToolObservationPort;
            telemetry?: TelemetryRecorder;
            now?: () => string;
        });
    getInvocation(invocationId: string): Promise<ToolInvocationRecord | null>;
    listInvocations(request?: ToolInvocationListRequest): Promise<ToolInvocationRecord[]>;
    recoverPendingInvocations(): Promise<ToolCallResult[]>;
    run(request: ToolCallRequest): Promise<ToolCallResult>;
    approveAndResume(invocationId: string, approvedBy: string, options?: {
            approvedAt?: string;
            expiresAt?: string;
        }): Promise<ToolCallResult>;
    rejectInvocation(invocationId: string): Promise<ToolCallResult>;
    cancelInvocation(invocationId: string, reason?: string): Promise<ToolCallResult>;
}

公开成员

成员种类签名说明
approveAndResume方法approveAndResume(invocationId: string, approvedBy: string, options?: { approvedAt?: string; expiresAt?: string; }): Promise<ToolCallResult>公开方法;参数与返回类型以签名列为准。
cancelInvocation方法cancelInvocation(invocationId: string, reason?: string): Promise<ToolCallResult>公开方法;参数与返回类型以签名列为准。
constructor构造函数(registry: ToolRegistry, trace: TraceRecorder, policy?: PolicyEngine, options?: { approvalStore?: ToolApprovalStore; invocationStore?: ToolInvocationStore; authorizer?: ToolAuthorizer; middleware?: ToolMiddleware[]; artifactPort?: ToolArtifactPort; snapshotStore?: ToolContractSnapshotStore; receiptReconciler?: ToolReceiptReconciler; resultCache?: ToolResultCache; resultCacheFailureMode?: "bypass" | "strict"; resul...创建该类的实例。
getInvocation方法getInvocation(invocationId: string): Promise<ToolInvocationRecord | null>公开方法;参数与返回类型以签名列为准。
listInvocations方法listInvocations(request?: ToolInvocationListRequest): Promise<ToolInvocationRecord[]>公开方法;参数与返回类型以签名列为准。
recoverPendingInvocations方法recoverPendingInvocations(): Promise<ToolCallResult[]>公开方法;参数与返回类型以签名列为准。
rejectInvocation方法rejectInvocation(invocationId: string): Promise<ToolCallResult>公开方法;参数与返回类型以签名列为准。
run方法run(request: ToolCallRequest): Promise<ToolCallResult>公开方法;参数与返回类型以签名列为准。

HttpToolAdapter

Http Tool Adapter 类,共公开 7 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { HttpToolAdapter } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class HttpToolAdapter implements ToolAdapter {
    readonly id: string;
    readonly source: ToolSource;
    constructor(id: string, options: HttpToolAdapterOptions);
    capabilities(): Promise<ToolAdapterCapabilities>;
    execute(request: AdapterExecutionRequest): Promise<ToolExecutionEnvelope>;
    cancel(): Promise<void>;
    health(): Promise<ProviderHealth>;
}

公开成员

成员种类签名说明
cancel方法cancel(): Promise<void>公开方法;参数与返回类型以签名列为准。
capabilities方法capabilities(): Promise<ToolAdapterCapabilities>公开方法;参数与返回类型以签名列为准。
constructor构造函数(id: string, options: HttpToolAdapterOptions): HttpToolAdapter创建该类的实例。
execute方法execute(request: AdapterExecutionRequest): Promise<ToolExecutionEnvelope>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
id属性readonly id: string公开属性;类型、只读和可选状态以签名列为准。
source属性readonly source: ToolSource公开属性;类型、只读和可选状态以签名列为准。

InMemoryToolApprovalStore

In Memory Tool Approval Store 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { InMemoryToolApprovalStore } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class InMemoryToolApprovalStore implements ToolApprovalStore {
    getRequest(invocationId: string): Promise<ToolApprovalRequest | null>;
    requestApproval(request: ToolApprovalRequest): Promise<ToolApprovalRequest>;
    getGrant(invocationId: string): Promise<ToolApprovalGrant | null>;
    approve(invocationId: string, approvedBy: string, options?: {
            approvedAt?: string;
            expiresAt?: string;
        }): Promise<ToolApprovalGrant>;
    reject(invocationId: string): Promise<ToolApprovalRequest>;
}

公开成员

成员种类签名说明
approve方法approve(invocationId: string, approvedBy: string, options?: { approvedAt?: string; expiresAt?: string; }): Promise<ToolApprovalGrant>公开方法;参数与返回类型以签名列为准。
constructor构造函数(): InMemoryToolApprovalStore创建该类的实例。
getGrant方法getGrant(invocationId: string): Promise<ToolApprovalGrant | null>公开方法;参数与返回类型以签名列为准。
getRequest方法getRequest(invocationId: string): Promise<ToolApprovalRequest | null>公开方法;参数与返回类型以签名列为准。
reject方法reject(invocationId: string): Promise<ToolApprovalRequest>公开方法;参数与返回类型以签名列为准。
requestApproval方法requestApproval(request: ToolApprovalRequest): Promise<ToolApprovalRequest>公开方法;参数与返回类型以签名列为准。

InMemoryToolInvocationStore

In Memory Tool Invocation Store 类,共公开 8 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { InMemoryToolInvocationStore } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class InMemoryToolInvocationStore implements ToolInvocationStore {
    get(invocationId: string): Promise<ToolInvocationRecord | null>;
    findByIdempotency(request: ToolIdempotencyLookup): Promise<ToolInvocationRecord | null>;
    list(request?: ToolInvocationListRequest): Promise<ToolInvocationRecord[]>;
    create(record: ToolInvocationRecord): Promise<ToolInvocationRecord>;
    update(invocationId: string, patch: ToolInvocationPatch, options?: {
            expectedStatuses?: readonly ToolInvocationStatus[];
            expectedRevision?: number;
        }): Promise<ToolInvocationRecord>;
    getCompleted(invocationId: string): Promise<ToolCallResult | null>;
    saveCompleted(invocationId: string, result: ToolCallResult): Promise<void>;
}

公开成员

成员种类签名说明
constructor构造函数(): InMemoryToolInvocationStore创建该类的实例。
create方法create(record: ToolInvocationRecord): Promise<ToolInvocationRecord>公开方法;参数与返回类型以签名列为准。
findByIdempotency方法findByIdempotency(request: ToolIdempotencyLookup): Promise<ToolInvocationRecord | null>公开方法;参数与返回类型以签名列为准。
get方法get(invocationId: string): Promise<ToolInvocationRecord | null>公开方法;参数与返回类型以签名列为准。
getCompleted方法getCompleted(invocationId: string): Promise<ToolCallResult | null>公开方法;参数与返回类型以签名列为准。
list方法list(request?: ToolInvocationListRequest): Promise<ToolInvocationRecord[]>公开方法;参数与返回类型以签名列为准。
saveCompleted方法saveCompleted(invocationId: string, result: ToolCallResult): Promise<void>公开方法;参数与返回类型以签名列为准。
update方法update(invocationId: string, patch: ToolInvocationPatch, options?: { expectedStatuses?: readonly ToolInvocationStatus[]; expectedRevision?: number; }): Promise<ToolInvocationRecord>公开方法;参数与返回类型以签名列为准。

InMemoryToolResultCache

In Memory Tool Result Cache 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { InMemoryToolResultCache } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class InMemoryToolResultCache implements ToolResultCache {
    constructor(options?: InMemoryToolResultCacheOptions);
    get(key: string): Promise<ToolResultCacheEntry | null>;
    set(entry: ToolResultCacheEntry): Promise<void>;
    delete(key: string): Promise<void>;
    size(): number;
}

公开成员

成员种类签名说明
constructor构造函数(options?: InMemoryToolResultCacheOptions): InMemoryToolResultCache创建该类的实例。
delete方法delete(key: string): Promise<void>公开方法;参数与返回类型以签名列为准。
get方法get(key: string): Promise<ToolResultCacheEntry | null>公开方法;参数与返回类型以签名列为准。
set方法set(entry: ToolResultCacheEntry): Promise<void>公开方法;参数与返回类型以签名列为准。
size方法size(): number公开方法;参数与返回类型以签名列为准。

LocalFunctionToolAdapter

Local Function Tool Adapter 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { LocalFunctionToolAdapter } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class LocalFunctionToolAdapter<TInput = unknown, TOutput = unknown> implements ToolAdapter<TInput, TOutput> {
    readonly id: string;
    readonly source: ToolSource;
    constructor(id: string, handler: ToolHandler<TInput, TOutput>);
    capabilities(): Promise<ToolAdapterCapabilities>;
    execute(request: AdapterExecutionRequest<TInput>): Promise<ToolExecutionEnvelope<TOutput>>;
    health(): Promise<ProviderHealth>;
}

公开成员

成员种类签名说明
capabilities方法capabilities(): Promise<ToolAdapterCapabilities>公开方法;参数与返回类型以签名列为准。
constructor构造函数<TInput = unknown, TOutput = unknown>(id: string, handler: ToolHandler<TInput, TOutput>): LocalFunctionToolAdapter<TInput, TOutput>创建该类的实例。
execute方法execute(request: AdapterExecutionRequest<TInput>): Promise<ToolExecutionEnvelope<TOutput>>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
id属性readonly id: string公开属性;类型、只读和可选状态以签名列为准。
source属性readonly source: ToolSource公开属性;类型、只读和可选状态以签名列为准。

MCPToolAdapter

MCP Tool Adapter 类,共公开 7 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { MCPToolAdapter } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class MCPToolAdapter implements ToolAdapter {
    readonly id: string;
    readonly source: ToolSource;
    constructor(id: string, serverId: string, capabilityId: string, gateway: MCPToolInvocationPort);
    capabilities(): Promise<ToolAdapterCapabilities>;
    execute(request: AdapterExecutionRequest): Promise<ToolExecutionEnvelope>;
    cancel(request: AdapterCancellationRequest): Promise<void>;
    health(): Promise<ProviderHealth>;
}

公开成员

成员种类签名说明
cancel方法cancel(request: AdapterCancellationRequest): Promise<void>公开方法;参数与返回类型以签名列为准。
capabilities方法capabilities(): Promise<ToolAdapterCapabilities>公开方法;参数与返回类型以签名列为准。
constructor构造函数(id: string, serverId: string, capabilityId: string, gateway: MCPToolInvocationPort): MCPToolAdapter创建该类的实例。
execute方法execute(request: AdapterExecutionRequest): Promise<ToolExecutionEnvelope>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
id属性readonly id: string公开属性;类型、只读和可选状态以签名列为准。
source属性readonly source: ToolSource公开属性;类型、只读和可选状态以签名列为准。

MockToolAdapter

Mock Tool Adapter 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { MockToolAdapter } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class MockToolAdapter<TInput = unknown, TOutput = unknown> extends LocalFunctionToolAdapter<TInput, TOutput> {
    readonly source: ToolSource;
}

公开成员

成员种类签名说明
capabilities方法capabilities(): Promise<ToolAdapterCapabilities>公开方法;参数与返回类型以签名列为准。
constructor构造函数<TInput = unknown, TOutput = unknown>(id: string, handler: ToolHandler<TInput, TOutput>): MockToolAdapter<TInput, TOutput>创建该类的实例。
execute方法execute(request: AdapterExecutionRequest<TInput>): Promise<ToolExecutionEnvelope<TOutput>>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
id属性readonly id: string公开属性;类型、只读和可选状态以签名列为准。
source属性readonly source: ToolSource公开属性;类型、只读和可选状态以签名列为准。

MockToolRunner

Mock Tool Runner 类,共公开 4 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { MockToolRunner } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class MockToolRunner implements ToolRunner {
    constructor(defaultOutput?: unknown);
    registerHandler(toolId: string, handler: MockToolHandler): void;
    registerResult(toolId: string, result: ToolCallResult): void;
    run(request: ToolCallRequest): Promise<ToolCallResult>;
}

公开成员

成员种类签名说明
constructor构造函数(defaultOutput?: unknown): MockToolRunner创建该类的实例。
registerHandler方法registerHandler(toolId: string, handler: MockToolHandler): void公开方法;参数与返回类型以签名列为准。
registerResult方法registerResult(toolId: string, result: ToolCallResult): void公开方法;参数与返回类型以签名列为准。
run方法run(request: ToolCallRequest): Promise<ToolCallResult>公开方法;参数与返回类型以签名列为准。

PermissionScopeToolAuthorizer

Permission Scope Tool Authorizer 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { PermissionScopeToolAuthorizer } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class PermissionScopeToolAuthorizer implements ToolAuthorizer {
    authorize(input: ToolAuthorizationInput): Promise<ToolAuthorizationDecision>;
}

公开成员

成员种类签名说明
authorize方法authorize(input: ToolAuthorizationInput): Promise<ToolAuthorizationDecision>公开方法;参数与返回类型以签名列为准。
constructor构造函数(): PermissionScopeToolAuthorizer创建该类的实例。

PluginToolAdapter

Plugin Tool Adapter 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { PluginToolAdapter } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class PluginToolAdapter<TInput = unknown, TOutput = unknown> extends LocalFunctionToolAdapter<TInput, TOutput> {
    readonly source: ToolSource;
}

公开成员

成员种类签名说明
capabilities方法capabilities(): Promise<ToolAdapterCapabilities>公开方法;参数与返回类型以签名列为准。
constructor构造函数<TInput = unknown, TOutput = unknown>(id: string, handler: ToolHandler<TInput, TOutput>): PluginToolAdapter<TInput, TOutput>创建该类的实例。
execute方法execute(request: AdapterExecutionRequest<TInput>): Promise<ToolExecutionEnvelope<TOutput>>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
id属性readonly id: string公开属性;类型、只读和可选状态以签名列为准。
source属性readonly source: ToolSource公开属性;类型、只读和可选状态以签名列为准。

RedisToolResultCache

Shared Redis-compatible Store for local, self-hosted, and managed Redis deployments.

  • 种类: 类
  • 导入: import { RedisToolResultCache } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class RedisToolResultCache implements ToolResultCache {
    constructor(options: RedisToolResultCacheOptions);
    get(key: string): Promise<ToolResultCacheEntry | null>;
    set(entry: ToolResultCacheEntry): Promise<void>;
    delete(key: string): Promise<void>;
}

公开成员

成员种类签名说明
constructor构造函数(options: RedisToolResultCacheOptions): RedisToolResultCache创建该类的实例。
delete方法delete(key: string): Promise<void>公开方法;参数与返回类型以签名列为准。
get方法get(key: string): Promise<ToolResultCacheEntry | null>公开方法;参数与返回类型以签名列为准。
set方法set(entry: ToolResultCacheEntry): Promise<void>公开方法;参数与返回类型以签名列为准。

ToolRegistry

Tool Registry 类,共公开 9 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { ToolRegistry } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class ToolRegistry {
    register(spec: ToolSpec, handler: ToolHandler, options?: {
            replace?: boolean;
            targetResolver?: ToolTargetResolver;
        }): void;
    registerAdapter(spec: ToolSpec, adapter: ToolAdapter, options?: {
            replace?: boolean;
            targetResolver?: ToolTargetResolver;
        }): void;
    unregister(toolId: string): boolean;
    getSpec(toolId: string): ResolvedToolSpec | null;
    getAdapter(toolId: string): ToolAdapter | null;
    getTargetResolver(toolId: string): ToolTargetResolver | null;
    resolve(ref: {
            id: string;
            version?: string;
            revision?: string;
        }): {
            spec: ResolvedToolSpec;
            adapter: ToolAdapter;
        } | null;
    list(): ResolvedToolSpec[];
}

公开成员

成员种类签名说明
constructor构造函数(): ToolRegistry创建该类的实例。
getAdapter方法getAdapter(toolId: string): ToolAdapter | null公开方法;参数与返回类型以签名列为准。
getSpec方法getSpec(toolId: string): ResolvedToolSpec | null公开方法;参数与返回类型以签名列为准。
getTargetResolver方法getTargetResolver(toolId: string): ToolTargetResolver | null公开方法;参数与返回类型以签名列为准。
list方法list(): ResolvedToolSpec[]公开方法;参数与返回类型以签名列为准。
register方法register(spec: ToolSpec, handler: ToolHandler, options?: { replace?: boolean; targetResolver?: ToolTargetResolver; }): void公开方法;参数与返回类型以签名列为准。
registerAdapter方法registerAdapter(spec: ToolSpec, adapter: ToolAdapter, options?: { replace?: boolean; targetResolver?: ToolTargetResolver; }): void公开方法;参数与返回类型以签名列为准。
resolve方法resolve(ref: { id: string; version?: string; revision?: string; }): { spec: ResolvedToolSpec; adapter: ToolAdapter; } | null公开方法;参数与返回类型以签名列为准。
unregister方法unregister(toolId: string): boolean公开方法;参数与返回类型以签名列为准。

ToolResultCacheEntryTooLargeError

Tool Result Cache Entry Too Large Error 类,共公开 11 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { ToolResultCacheEntryTooLargeError } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class ToolResultCacheEntryTooLargeError extends Error {
    readonly actualBytes: number;
    readonly maxEntryBytes: number;
    readonly code = "TOOL_RESULT_CACHE_ENTRY_TOO_LARGE";
    constructor(actualBytes: number, maxEntryBytes: number);
}

公开成员

成员种类签名说明
actualBytes属性readonly actualBytes: number公开属性;类型、只读和可选状态以签名列为准。
cause属性cause?: unknown公开属性;类型、只读和可选状态以签名列为准。
code属性readonly code: "TOOL_RESULT_CACHE_ENTRY_TOO_LARGE"公开属性;类型、只读和可选状态以签名列为准。
constructor构造函数(actualBytes: number, maxEntryBytes: number): ToolResultCacheEntryTooLargeError创建该类的实例。
maxEntryBytes属性readonly maxEntryBytes: number公开属性;类型、只读和可选状态以签名列为准。
message属性message: string公开属性;类型、只读和可选状态以签名列为准。
name属性name: string公开属性;类型、只读和可选状态以签名列为准。
stack属性stack?: string公开属性;类型、只读和可选状态以签名列为准。
static captureStackTrace方法static captureStackTrace(targetObject: object, constructorOpt?: Function): voidCreates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called. js const myObject = {}; Error.captureStackTrace(myObject); myObject.stack; // Similar to `new Error().stack` The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}. The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance: js function a() { b(); } function b() { c(); } function c() { // Create an error without stack trace to avoid calculating the stack trace twice. const { stackTraceLimit } = Error; Error.stackTraceLimit = 0; const error = new Error(); Error.stackTraceLimit = stackTraceLimit; // Capture the stack trace above function b Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace throw error; } a();
static prepareStackTrace方法static prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any公开方法;参数与返回类型以签名列为准。
static stackTraceLimit属性static stackTraceLimit: numberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

ToolResultCacheOperationTimeoutError

Tool Result Cache Operation Timeout Error 类,共公开 11 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { ToolResultCacheOperationTimeoutError } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class ToolResultCacheOperationTimeoutError extends Error {
    readonly operation: 'get' | 'set' | 'delete' | 'verify';
    readonly timeoutMs: number;
    readonly code = "TOOL_RESULT_CACHE_TIMEOUT";
    constructor(operation: 'get' | 'set' | 'delete' | 'verify', timeoutMs: number);
}

公开成员

成员种类签名说明
cause属性cause?: unknown公开属性;类型、只读和可选状态以签名列为准。
code属性readonly code: "TOOL_RESULT_CACHE_TIMEOUT"公开属性;类型、只读和可选状态以签名列为准。
constructor构造函数(operation: "get" | "set" | "delete" | "verify", timeoutMs: number): ToolResultCacheOperationTimeoutError创建该类的实例。
message属性message: string公开属性;类型、只读和可选状态以签名列为准。
name属性name: string公开属性;类型、只读和可选状态以签名列为准。
operation属性readonly operation: "delete" | "verify" | "get" | "set"公开属性;类型、只读和可选状态以签名列为准。
stack属性stack?: string公开属性;类型、只读和可选状态以签名列为准。
static captureStackTrace方法static captureStackTrace(targetObject: object, constructorOpt?: Function): voidCreates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called. js const myObject = {}; Error.captureStackTrace(myObject); myObject.stack; // Similar to `new Error().stack` The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}. The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance: js function a() { b(); } function b() { c(); } function c() { // Create an error without stack trace to avoid calculating the stack trace twice. const { stackTraceLimit } = Error; Error.stackTraceLimit = 0; const error = new Error(); Error.stackTraceLimit = stackTraceLimit; // Capture the stack trace above function b Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace throw error; } a();
static prepareStackTrace方法static prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any公开方法;参数与返回类型以签名列为准。
static stackTraceLimit属性static stackTraceLimit: numberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
timeoutMs属性readonly timeoutMs: number公开属性;类型、只读和可选状态以签名列为准。

ToolResultCacheValidationError

Tool Result Cache Validation Error 类,共公开 9 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { ToolResultCacheValidationError } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare class ToolResultCacheValidationError extends Error {
    readonly code = "TOOL_RESULT_CACHE_CORRUPT";
    constructor(message: string);
}

公开成员

成员种类签名说明
cause属性cause?: unknown公开属性;类型、只读和可选状态以签名列为准。
code属性readonly code: "TOOL_RESULT_CACHE_CORRUPT"公开属性;类型、只读和可选状态以签名列为准。
constructor构造函数(message: string): ToolResultCacheValidationError创建该类的实例。
message属性message: string公开属性;类型、只读和可选状态以签名列为准。
name属性name: string公开属性;类型、只读和可选状态以签名列为准。
stack属性stack?: string公开属性;类型、只读和可选状态以签名列为准。
static captureStackTrace方法static captureStackTrace(targetObject: object, constructorOpt?: Function): voidCreates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called. js const myObject = {}; Error.captureStackTrace(myObject); myObject.stack; // Similar to `new Error().stack` The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}. The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance: js function a() { b(); } function b() { c(); } function c() { // Create an error without stack trace to avoid calculating the stack trace twice. const { stackTraceLimit } = Error; Error.stackTraceLimit = 0; const error = new Error(); Error.stackTraceLimit = stackTraceLimit; // Capture the stack trace above function b Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace throw error; } a();
static prepareStackTrace方法static prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any公开方法;参数与返回类型以签名列为准。
static stackTraceLimit属性static stackTraceLimit: numberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

TOOL_INVOCATION_STATUSES

index 模块导出的 TOOL INVOCATION STATUSES 常量。

  • 种类: 常量
  • 导入: import { TOOL_INVOCATION_STATUSES } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare const TOOL_INVOCATION_STATUSES: readonly ["created", "validating", "validated", "policy_checked", "waiting_approval", "approved", "rejected", "queued", "running", "cancelling", "completed", "failed", "timed_out", "expired", "conflict", "denied", "cancelled"];

toolCacheValidityRecordSchema

Tool Cache Validity Record 的运行时 Schema。

  • 种类: 常量
  • 导入: import { toolCacheValidityRecordSchema } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare const toolCacheValidityRecordSchema: z.ZodObject<{ toolId: z.ZodString; toolRevision: z.ZodString; inputHash: z.ZodString; scopeHash: z.ZodString; policyRevision: z.ZodString; contractSnapshotHash: z.ZodOptional<z.ZodString>; capabilityHash: z.ZodOptional<z.ZodString>; externalStateVersion: z.ZodOptional<z.ZodString>; key: z.ZodString; validUntil: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { toolId: string; toolRevision: string; policyRevision: string; scopeHash: string; inputHash: string; key: string; contractSnapshotHash?: string | undefined; capabilityHash?: string | undefined; externalStateVersion?: string | undefined; validUntil?: string | undefined; }, { toolId: string; toolRevision: string; policyRevision: string; scopeHash: string; inputHash: string; key: string; contractSnapshotHash?: string | undefined; capabilityHash?: string | undefined; externalStateVersion?: string | undefined; validUntil?: string | undefined; }>;

toolProfileSpecDefinition

Tool Profile Spec 的运行时校验入口,组合 Parser、Example 与 JSON Schema。

  • 种类: 常量
  • 导入: import { toolProfileSpecDefinition } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare const toolProfileSpecDefinition: SpecSchemaDefinition<ToolProfileSpec>;

toolProfileSpecSchema

Tool Profile Spec 的运行时 Schema。

  • 种类: 常量
  • 导入: import { toolProfileSpecSchema } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

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

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

toolResultCacheEntryJsonSchema

Tool Result Cache Entry 的 JSON Schema。

  • 种类: 常量
  • 导入: import { toolResultCacheEntryJsonSchema } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare const toolResultCacheEntryJsonSchema: JsonSchema;

toolResultCacheEntrySchema

Tool Result Cache Entry 的运行时 Schema。

  • 种类: 常量
  • 导入: import { toolResultCacheEntrySchema } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare const toolResultCacheEntrySchema: z.ZodObject<{ schemaVersion: z.ZodLiteral<"1.0">; keyVersion: z.ZodLiteral<"1">; validity: z.ZodObject<{ toolId: z.ZodString; toolRevision: z.ZodString; inputHash: z.ZodString; scopeHash: z.ZodString; policyRevision: z.ZodString; contractSnapshotHash: z.ZodOptional<z.ZodString>; capabilityHash: z.ZodOptional<z.ZodString>; externalStateVersion: z.ZodOptional<z.ZodString>; key: z.ZodString; validUntil: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { toolId: string; toolRevision: string; policyRevision: string; scopeHash: string; inputHash: string; key: string; contractSnapshotHash?: string | undefined; capabilityHash?: string | undefined; externalStateVersion?: string | undefined; validUntil?: string | undefined; }, { toolId: string; toolRevision: string; policyRevision: string; scopeHash: string; inputHash: string; key: string; contractSnapshotHash?: string | undefined; capabilityHash?: string | undefined; externalStateVersion?: string | undefined; validUntil?: string | undefined; }>; result: z.ZodObject<{ output: z.ZodOptional<z.ZodUnknown>; content: z.ZodOptional<z.ZodArray<z.ZodType<ToolResultContent, z.ZodTypeDef, ToolResultContent>, "many">>; artifactRefs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; }, "strict", z.ZodTypeAny, { output?: unknown; artifactRefs?: string[] | undefined; content?: ToolResultContent[] | undefined; }, { output?: unknown; artifactRefs?: string[] | undefined; content?: ToolResultContent[] | undefined; }>; createdAt: z.ZodString; }, "strict", z.ZodTypeAny, { schemaVersion: "1.0"; result: { output?: unknown; artifactRefs?: string[] | undefined; content?: ToolResultContent[] | undefined; }; createdAt: string; keyVersion: "1"; validity: { toolId: string; toolRevision: string; policyRevision: string; scopeHash: string; inputHash: string; key: string; contractSnapshotHash?: string | undefined; capabilityHash?: string | undefined; externalStateVersion?: string | undefined; validUntil?: string | undefined; }; }, { schemaVersion: "1.0"; result: { output?: unknown; artifactRefs?: string[] | undefined; content?: ToolResultContent[] | undefined; }; createdAt: string; keyVersion: "1"; validity: { toolId: string; toolRevision: string; policyRevision: string; scopeHash: string; inputHash: string; key: string; contractSnapshotHash?: string | undefined; capabilityHash?: string | undefined; externalStateVersion?: string | undefined; validUntil?: string | undefined; }; }>;

toolSpecDefinition

Tool Spec 的运行时校验入口,组合 Parser、Example 与 JSON Schema。

  • 种类: 常量
  • 导入: import { toolSpecDefinition } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare const toolSpecDefinition: SpecSchemaDefinition<ToolSpec>;

toolSpecDefinitions

index 模块导出的 Tool Spec Definitions 常量。

  • 种类: 常量
  • 导入: import { toolSpecDefinitions } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare const toolSpecDefinitions: readonly [SpecSchemaDefinition<ToolSpec>, SpecSchemaDefinition<ToolProfileSpec>];

toolSpecExample

Tool Spec 的有效示例值。

  • 种类: 常量
  • 导入: import { toolSpecExample } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare const toolSpecExample: ToolSpec;

toolSpecJsonSchema

Tool Spec 的 JSON Schema。

  • 种类: 常量
  • 导入: import { toolSpecJsonSchema } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare const toolSpecJsonSchema: JsonSchema;

toolSpecJsonSchemas

index 模块导出的 Tool Spec JSON Schemas 常量。

  • 种类: 常量
  • 导入: import { toolSpecJsonSchemas } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

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

toolSpecSchema

Tool Spec 的运行时 Schema。

  • 种类: 常量
  • 导入: import { toolSpecSchema } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

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

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

normalizeToolSpec

Normalize Tool Spec 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { normalizeToolSpec } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare function normalizeToolSpec(spec: ToolSpec): ResolvedToolSpec;

调用签名

text
normalizeToolSpec(spec: ToolSpec): ResolvedToolSpec

参数

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

返回值

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

validateEffectiveCapabilityAccess

Validate Effective Capability Access 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { validateEffectiveCapabilityAccess } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare function validateEffectiveCapabilityAccess(input: {
    snapshot: ToolContractSnapshot | null;
    context: ToolCallContext;
    spec: ToolSpec;
}): string | null;

调用签名

text
validateEffectiveCapabilityAccess(input: { snapshot: ToolContractSnapshot | null; context: ToolCallContext; spec: ToolSpec; }): string | null

参数

参数类型必需说明
input{ snapshot: ToolContractSnapshot | null; context: ToolCallContext; spec: ToolSpec; }必需参数;接受的值由类型列定义。

返回值

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

validateToolInput

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

  • 种类: 函数
  • 导入: import { validateToolInput } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare function validateToolInput(schema: JsonSchema, input: unknown): ToolSchemaValidationResult;

调用签名

text
validateToolInput(schema: JsonSchema, input: unknown): ToolSchemaValidationResult

参数

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

返回值

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

validateToolResultCacheEntry

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

  • 种类: 函数
  • 导入: import { validateToolResultCacheEntry } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare function validateToolResultCacheEntry(value: unknown, maxEntryBytes?: number): ToolResultCacheEntry;

调用签名

text
validateToolResultCacheEntry(value: unknown, maxEntryBytes?: number): ToolResultCacheEntry

参数

参数类型必需说明
valueunknown必需参数;接受的值由类型列定义。
maxEntryBytesnumber可选参数;接受的值由类型列定义。

返回值

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

validateToolSpec

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

  • 种类: 函数
  • 导入: import { validateToolSpec } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export declare function validateToolSpec(input: unknown): ToolSpec;

调用签名

text
validateToolSpec(input: unknown): ToolSpec

参数

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

返回值

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

AdapterCancellationRequest

Adapter Cancellation Request 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { AdapterCancellationRequest } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface AdapterCancellationRequest {
    toolId: string;
    invocationId: string;
    reason?: string;
}

契约成员

成员种类签名说明
invocationId属性invocationId: string公开属性;类型、只读和可选状态以签名列为准。
reason属性reason?: string公开属性;类型、只读和可选状态以签名列为准。
toolId属性toolId: string公开属性;类型、只读和可选状态以签名列为准。

AdapterExecutionRequest

Adapter Execution Request 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { AdapterExecutionRequest } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface AdapterExecutionRequest<TInput = unknown> {
    toolId: string;
    input: TInput;
    context: ToolCallContext;
}

契约成员

成员种类签名说明
context属性context: ToolCallContext公开属性;类型、只读和可选状态以签名列为准。
input属性input: TInput公开属性;类型、只读和可选状态以签名列为准。
toolId属性toolId: string公开属性;类型、只读和可选状态以签名列为准。

HttpToolAdapterOptions

Http Tool Adapter Options 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { HttpToolAdapterOptions } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface HttpToolAdapterOptions {
    endpoint: string;
    headers?: Record<string, string>;
    resolveHeaders?: () => Promise<Record<string, string>>;
    fetch?: typeof fetch;
}

契约成员

成员种类签名说明
endpoint属性endpoint: string公开属性;类型、只读和可选状态以签名列为准。
fetch方法fetch?(input: RequestInfo | URL, init?: RequestInit): Promise<Response> | fetch?(input: string | URL | Request, init?: RequestInit): Promise<Response>公开方法;参数与返回类型以签名列为准。
headers属性headers?: Record<string, string>公开属性;类型、只读和可选状态以签名列为准。
resolveHeaders方法resolveHeaders?(): Promise<Record<string, string>>公开方法;参数与返回类型以签名列为准。

InMemoryToolResultCacheOptions

In Memory Tool Result Cache Options 接口,共包含 2 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InMemoryToolResultCacheOptions } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface InMemoryToolResultCacheOptions {
    maxEntries?: number;
    maxEntryBytes?: number;
}

契约成员

成员种类签名说明
maxEntries属性maxEntries?: number公开属性;类型、只读和可选状态以签名列为准。
maxEntryBytes属性maxEntryBytes?: number公开属性;类型、只读和可选状态以签名列为准。

MCPToolInvocationPort

MCP Tool Invocation Port 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MCPToolInvocationPort } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface MCPToolInvocationPort {
    invoke(request: {
        serverId: string;
        capabilityId: string;
        input: unknown;
        context: ToolCallContext;
    }): Promise<unknown>;
    health(serverId: string): Promise<ProviderHealth>;
    cancel?(requestId: string): Promise<void>;
}

契约成员

成员种类签名说明
cancel方法cancel?(requestId: string): Promise<void>公开方法;参数与返回类型以签名列为准。
health方法health(serverId: string): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
invoke方法invoke(request: { serverId: string; capabilityId: string; input: unknown; context: ToolCallContext; }): Promise<unknown>公开方法;参数与返回类型以签名列为准。

RedisLikeToolResultCacheClient

Redis Like Tool Result Cache Client 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RedisLikeToolResultCacheClient } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface RedisLikeToolResultCacheClient {
    get(key: string): Promise<string | null>;
    set(key: string, value: string, mode?: 'PX', durationMilliseconds?: number): Promise<unknown>;
    del(...keys: string[]): Promise<number>;
}

契约成员

成员种类签名说明
del方法del(...keys: string[]): Promise<number>公开方法;参数与返回类型以签名列为准。
get方法get(key: string): Promise<string | null>公开方法;参数与返回类型以签名列为准。
set方法set(key: string, value: string, mode?: "PX", durationMilliseconds?: number): Promise<unknown>公开方法;参数与返回类型以签名列为准。

RedisToolResultCacheOptions

Redis Tool Result Cache Options 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RedisToolResultCacheOptions } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface RedisToolResultCacheOptions {
    client: RedisLikeToolResultCacheClient;
    namespace?: string;
    maxEntryBytes?: number;
    defaultTtlMs?: number;
    now?: () => string;
}

契约成员

成员种类签名说明
client属性client: RedisLikeToolResultCacheClient公开属性;类型、只读和可选状态以签名列为准。
defaultTtlMs属性defaultTtlMs?: number公开属性;类型、只读和可选状态以签名列为准。
maxEntryBytes属性maxEntryBytes?: number公开属性;类型、只读和可选状态以签名列为准。
namespace属性namespace?: string公开属性;类型、只读和可选状态以签名列为准。
now方法now?(): string公开方法;参数与返回类型以签名列为准。

ToolAdapter

Tool Adapter 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolAdapter } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolAdapter<TInput = unknown, TOutput = unknown> {
    readonly id: string;
    readonly source: ToolSource;
    capabilities(): Promise<ToolAdapterCapabilities>;
    execute(request: AdapterExecutionRequest<TInput>): Promise<ToolExecutionEnvelope<TOutput>>;
    cancel?(request: AdapterCancellationRequest): Promise<void>;
    health(): Promise<ProviderHealth>;
    close?(): Promise<void>;
}

契约成员

成员种类签名说明
cancel方法cancel?(request: AdapterCancellationRequest): Promise<void>公开方法;参数与返回类型以签名列为准。
capabilities方法capabilities(): Promise<ToolAdapterCapabilities>公开方法;参数与返回类型以签名列为准。
close方法close?(): Promise<void>公开方法;参数与返回类型以签名列为准。
execute方法execute(request: AdapterExecutionRequest<TInput>): Promise<ToolExecutionEnvelope<TOutput>>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
id属性readonly id: string公开属性;类型、只读和可选状态以签名列为准。
source属性readonly source: ToolSource公开属性;类型、只读和可选状态以签名列为准。

ToolAdapterCapabilities

Tool Adapter Capabilities 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolAdapterCapabilities } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolAdapterCapabilities {
    execute: boolean;
    cancel: boolean;
    health: boolean;
    close: boolean;
    streaming?: boolean;
}

契约成员

成员种类签名说明
cancel属性cancel: boolean公开属性;类型、只读和可选状态以签名列为准。
close属性close: boolean公开属性;类型、只读和可选状态以签名列为准。
execute属性execute: boolean公开属性;类型、只读和可选状态以签名列为准。
health属性health: boolean公开属性;类型、只读和可选状态以签名列为准。
streaming属性streaming?: boolean公开属性;类型、只读和可选状态以签名列为准。

ToolApprovalGrant

Tool Approval Grant 接口,共包含 11 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolApprovalGrant } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolApprovalGrant {
    requestId: string;
    invocationId: string;
    toolId: string;
    inputHash: string;
    toolRevision?: string;
    contractSnapshotRef?: string;
    principalId?: string;
    policyDecisionRef?: string;
    approvedBy: string;
    approvedAt: string;
    expiresAt?: string;
}

契约成员

成员种类签名说明
approvedAt属性approvedAt: string公开属性;类型、只读和可选状态以签名列为准。
approvedBy属性approvedBy: string公开属性;类型、只读和可选状态以签名列为准。
contractSnapshotRef属性contractSnapshotRef?: string公开属性;类型、只读和可选状态以签名列为准。
expiresAt属性expiresAt?: string公开属性;类型、只读和可选状态以签名列为准。
inputHash属性inputHash: string公开属性;类型、只读和可选状态以签名列为准。
invocationId属性invocationId: string公开属性;类型、只读和可选状态以签名列为准。
policyDecisionRef属性policyDecisionRef?: string公开属性;类型、只读和可选状态以签名列为准。
principalId属性principalId?: string公开属性;类型、只读和可选状态以签名列为准。
requestId属性requestId: string公开属性;类型、只读和可选状态以签名列为准。
toolId属性toolId: string公开属性;类型、只读和可选状态以签名列为准。
toolRevision属性toolRevision?: string公开属性;类型、只读和可选状态以签名列为准。

ToolApprovalRequest

Tool Approval Request 接口,共包含 15 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolApprovalRequest } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolApprovalRequest {
    id: string;
    invocationId: string;
    toolId: string;
    toolRevision?: string;
    contractSnapshotRef?: string;
    principalId?: string;
    policyDecisionRef?: string;
    inputHash: string;
    runId: string;
    stepId: string;
    userId?: string;
    reason?: string;
    requestedAt: string;
    expiresAt?: string;
    status: 'pending' | 'approved' | 'rejected' | 'expired' | 'cancelled';
}

契约成员

成员种类签名说明
contractSnapshotRef属性contractSnapshotRef?: string公开属性;类型、只读和可选状态以签名列为准。
expiresAt属性expiresAt?: string公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
inputHash属性inputHash: string公开属性;类型、只读和可选状态以签名列为准。
invocationId属性invocationId: string公开属性;类型、只读和可选状态以签名列为准。
policyDecisionRef属性policyDecisionRef?: string公开属性;类型、只读和可选状态以签名列为准。
principalId属性principalId?: string公开属性;类型、只读和可选状态以签名列为准。
reason属性reason?: string公开属性;类型、只读和可选状态以签名列为准。
requestedAt属性requestedAt: string公开属性;类型、只读和可选状态以签名列为准。
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
status属性status: "rejected" | "cancelled" | "expired" | "pending" | "approved"公开属性;类型、只读和可选状态以签名列为准。
stepId属性stepId: string公开属性;类型、只读和可选状态以签名列为准。
toolId属性toolId: string公开属性;类型、只读和可选状态以签名列为准。
toolRevision属性toolRevision?: string公开属性;类型、只读和可选状态以签名列为准。
userId属性userId?: string公开属性;类型、只读和可选状态以签名列为准。

ToolApprovalStore

Tool Approval Store 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolApprovalStore } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolApprovalStore {
    getRequest(invocationId: string): Promise<ToolApprovalRequest | null>;
    requestApproval(request: ToolApprovalRequest): Promise<ToolApprovalRequest>;
    getGrant(invocationId: string): Promise<ToolApprovalGrant | null>;
    approve(invocationId: string, approvedBy: string, options?: {
        approvedAt?: string;
        expiresAt?: string;
    }): Promise<ToolApprovalGrant>;
    reject(invocationId: string): Promise<ToolApprovalRequest>;
}

契约成员

成员种类签名说明
approve方法approve(invocationId: string, approvedBy: string, options?: { approvedAt?: string; expiresAt?: string; }): Promise<ToolApprovalGrant>公开方法;参数与返回类型以签名列为准。
getGrant方法getGrant(invocationId: string): Promise<ToolApprovalGrant | null>公开方法;参数与返回类型以签名列为准。
getRequest方法getRequest(invocationId: string): Promise<ToolApprovalRequest | null>公开方法;参数与返回类型以签名列为准。
reject方法reject(invocationId: string): Promise<ToolApprovalRequest>公开方法;参数与返回类型以签名列为准。
requestApproval方法requestApproval(request: ToolApprovalRequest): Promise<ToolApprovalRequest>公开方法;参数与返回类型以签名列为准。

ToolArtifactPort

Tool Artifact Port 接口,共包含 1 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolArtifactPort } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolArtifactPort {
    store(request: {
        invocationId: string;
        toolId: string;
        value: unknown;
        mimeType?: string;
        metadata?: Record<string, unknown>;
    }): Promise<string>;
}

契约成员

成员种类签名说明
store方法store(request: { invocationId: string; toolId: string; value: unknown; mimeType?: string; metadata?: Record<string, unknown>; }): Promise<string>公开方法;参数与返回类型以签名列为准。

ToolAuthorizationDecision

Tool Authorization Decision 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolAuthorizationDecision } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolAuthorizationDecision {
    allowed: boolean;
    reason?: string;
    missingPermissionScopes?: string[];
}

契约成员

成员种类签名说明
allowed属性allowed: boolean公开属性;类型、只读和可选状态以签名列为准。
missingPermissionScopes属性missingPermissionScopes?: string[]公开属性;类型、只读和可选状态以签名列为准。
reason属性reason?: string公开属性;类型、只读和可选状态以签名列为准。

ToolAuthorizationInput

Tool Authorization Input 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolAuthorizationInput } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolAuthorizationInput {
    tool: ToolSpec;
    request: ToolCallRequest;
    principal?: ToolPrincipal;
    executionScope?: ToolExecutionScope;
}

契约成员

成员种类签名说明
executionScope属性executionScope?: ToolExecutionScope公开属性;类型、只读和可选状态以签名列为准。
principal属性principal?: ToolPrincipal公开属性;类型、只读和可选状态以签名列为准。
request属性request: ToolCallRequest<unknown>公开属性;类型、只读和可选状态以签名列为准。
tool属性tool: ToolSpec公开属性;类型、只读和可选状态以签名列为准。

ToolAuthorizer

Tool Authorizer 接口,共包含 1 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolAuthorizer } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolAuthorizer {
    authorize(input: ToolAuthorizationInput): Promise<ToolAuthorizationDecision>;
}

契约成员

成员种类签名说明
authorize方法authorize(input: ToolAuthorizationInput): Promise<ToolAuthorizationDecision>公开方法;参数与返回类型以签名列为准。

ToolCachedResultProjection

Only stable, replay-safe output fields may cross invocation boundaries.

  • 种类: 接口
  • 导入: import type { ToolCachedResultProjection } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolCachedResultProjection {
    output?: unknown;
    content?: ToolResultContent[];
    artifactRefs?: string[];
}

契约成员

成员种类签名说明
artifactRefs属性artifactRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
content属性content?: ToolResultContent[]公开属性;类型、只读和可选状态以签名列为准。
output属性output?: unknown公开属性;类型、只读和可选状态以签名列为准。

ToolCallContext

Tool Call Context 接口,共包含 24 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolCallContext } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolCallContext {
    runId: string;
    stepId: string;
    invocationId?: string;
    userId?: string;
    tenantId?: string;
    workspaceId?: string;
    sessionId?: string;
    agentId?: string;
    fsmState?: string;
    idempotencyKey?: string;
    operationId?: string;
    correlationId?: string;
    causationId?: string;
    parentEventId?: string;
    contractSnapshotRef?: string;
    capabilitySnapshotRef?: string;
    capabilityApprovals?: EffectiveCapabilityApproval[];
    deadlineAt?: string;
    signal?: AbortSignal;
    abortSignal?: AbortSignal;
    reportProgress?: (update: ToolProgressUpdate) => void | Promise<void>;
    executionScope?: ToolExecutionScope;
    principal?: ToolPrincipal;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
abortSignal属性abortSignal?: AbortSignal公开属性;类型、只读和可选状态以签名列为准。
agentId属性agentId?: string公开属性;类型、只读和可选状态以签名列为准。
capabilityApprovals属性capabilityApprovals?: EffectiveCapabilityApproval[]公开属性;类型、只读和可选状态以签名列为准。
capabilitySnapshotRef属性capabilitySnapshotRef?: string公开属性;类型、只读和可选状态以签名列为准。
causationId属性causationId?: string公开属性;类型、只读和可选状态以签名列为准。
contractSnapshotRef属性contractSnapshotRef?: string公开属性;类型、只读和可选状态以签名列为准。
correlationId属性correlationId?: string公开属性;类型、只读和可选状态以签名列为准。
deadlineAt属性deadlineAt?: string公开属性;类型、只读和可选状态以签名列为准。
executionScope属性executionScope?: ToolExecutionScope公开属性;类型、只读和可选状态以签名列为准。
fsmState属性fsmState?: string公开属性;类型、只读和可选状态以签名列为准。
idempotencyKey属性idempotencyKey?: string公开属性;类型、只读和可选状态以签名列为准。
invocationId属性invocationId?: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId?: string公开属性;类型、只读和可选状态以签名列为准。
parentEventId属性parentEventId?: string公开属性;类型、只读和可选状态以签名列为准。
principal属性principal?: ToolPrincipal公开属性;类型、只读和可选状态以签名列为准。
reportProgress方法reportProgress?(update: ToolProgressUpdate): void | Promise<void>公开方法;参数与返回类型以签名列为准。
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
sessionId属性sessionId?: string公开属性;类型、只读和可选状态以签名列为准。
signal属性signal?: AbortSignal公开属性;类型、只读和可选状态以签名列为准。
stepId属性stepId: string公开属性;类型、只读和可选状态以签名列为准。
tenantId属性tenantId?: string公开属性;类型、只读和可选状态以签名列为准。
userId属性userId?: string公开属性;类型、只读和可选状态以签名列为准。
workspaceId属性workspaceId?: string公开属性;类型、只读和可选状态以签名列为准。

ToolCallError

Tool Call Error 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolCallError } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolCallError {
    code: string;
    message: string;
    phase: ToolExecutionPhase;
    retryable?: boolean;
    details?: Record<string, unknown>;
}

契约成员

成员种类签名说明
code属性code: string公开属性;类型、只读和可选状态以签名列为准。
details属性details?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
message属性message: string公开属性;类型、只读和可选状态以签名列为准。
phase属性phase: ToolExecutionPhase公开属性;类型、只读和可选状态以签名列为准。
retryable属性retryable?: boolean公开属性;类型、只读和可选状态以签名列为准。

ToolCallRequest

Tool Call Request 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolCallRequest } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolCallRequest<TInput = unknown> {
    toolId: string;
    input: TInput;
    context: ToolCallContext;
}

契约成员

成员种类签名说明
context属性context: ToolCallContext公开属性;类型、只读和可选状态以签名列为准。
input属性input: TInput公开属性;类型、只读和可选状态以签名列为准。
toolId属性toolId: string公开属性;类型、只读和可选状态以签名列为准。

ToolCallResult

Tool Call Result 接口,共包含 12 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolCallResult } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolCallResult<TOutput = unknown> {
    toolId: string;
    invocationId?: string;
    output?: TOutput;
    error?: ToolCallError | string;
    approvalRequest?: ToolApprovalRequest;
    attempts?: number;
    durationMs?: number;
    content?: ToolResultContent[];
    artifactRefs?: string[];
    observationRefs?: string[];
    externalReceipt?: ToolExternalReceipt;
    status: 'completed' | 'failed' | 'denied' | 'human_review_required' | 'cancelled' | 'conflict';
}

契约成员

成员种类签名说明
approvalRequest属性approvalRequest?: ToolApprovalRequest公开属性;类型、只读和可选状态以签名列为准。
artifactRefs属性artifactRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
attempts属性attempts?: number公开属性;类型、只读和可选状态以签名列为准。
content属性content?: ToolResultContent[]公开属性;类型、只读和可选状态以签名列为准。
durationMs属性durationMs?: number公开属性;类型、只读和可选状态以签名列为准。
error属性error?: string | ToolCallError公开属性;类型、只读和可选状态以签名列为准。
externalReceipt属性externalReceipt?: ToolExternalReceipt公开属性;类型、只读和可选状态以签名列为准。
invocationId属性invocationId?: string公开属性;类型、只读和可选状态以签名列为准。
observationRefs属性observationRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
output属性output?: TOutput公开属性;类型、只读和可选状态以签名列为准。
status属性status: "completed" | "cancelled" | "failed" | "denied" | "conflict" | "human_review_required"公开属性;类型、只读和可选状态以签名列为准。
toolId属性toolId: string公开属性;类型、只读和可选状态以签名列为准。

ToolExecutionEnvelope

Tool Execution Envelope 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolExecutionEnvelope } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolExecutionEnvelope<TOutput = unknown> {
    kind: 'tool_execution_envelope';
    output?: TOutput;
    content?: ToolResultContent[];
    artifactRefs?: string[];
    observationRefs?: string[];
    externalReceipt?: ToolExternalReceipt;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
artifactRefs属性artifactRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
content属性content?: ToolResultContent[]公开属性;类型、只读和可选状态以签名列为准。
externalReceipt属性externalReceipt?: ToolExternalReceipt公开属性;类型、只读和可选状态以签名列为准。
kind属性kind: "tool_execution_envelope"公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
observationRefs属性observationRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
output属性output?: TOutput公开属性;类型、只读和可选状态以签名列为准。

ToolExecutionScope

Tool Execution Scope 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolExecutionScope } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolExecutionScope {
    allowedToolIds?: readonly string[];
    policyRefs?: readonly string[];
    fsmState?: string;
}

契约成员

成员种类签名说明
allowedToolIds属性allowedToolIds?: readonly string[]公开属性;类型、只读和可选状态以签名列为准。
fsmState属性fsmState?: string公开属性;类型、只读和可选状态以签名列为准。
policyRefs属性policyRefs?: readonly string[]公开属性;类型、只读和可选状态以签名列为准。

ToolIdempotencyLookup

Tool Idempotency Lookup 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolIdempotencyLookup } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolIdempotencyLookup {
    toolId: string;
    idempotencyKey: string;
    scopeHash: string;
}

契约成员

成员种类签名说明
idempotencyKey属性idempotencyKey: string公开属性;类型、只读和可选状态以签名列为准。
scopeHash属性scopeHash: string公开属性;类型、只读和可选状态以签名列为准。
toolId属性toolId: string公开属性;类型、只读和可选状态以签名列为准。

ToolInvocationListRequest

Tool Invocation List Request 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolInvocationListRequest } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolInvocationListRequest {
    statuses?: readonly ToolInvocationStatus[];
    toolId?: string;
    runId?: string;
    limit?: number;
}

契约成员

成员种类签名说明
limit属性limit?: number公开属性;类型、只读和可选状态以签名列为准。
runId属性runId?: string公开属性;类型、只读和可选状态以签名列为准。
statuses属性statuses?: readonly ("completed" | "rejected" | "queued" | "running" | "cancelling" | "cancelled" | "failed" | "timed_out" | "created" | "denied" | "expired" | "approved" | "conflict" | "policy_checked" | "waiting_approval" | "validating" | "validated")[]公开属性;类型、只读和可选状态以签名列为准。
toolId属性toolId?: string公开属性;类型、只读和可选状态以签名列为准。

ToolInvocationRecord

Tool Invocation Record 接口,共包含 37 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolInvocationRecord } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolInvocationRecord {
    id: string;
    operationId?: string;
    toolId: string;
    toolVersion?: string;
    toolRevision?: string;
    contractSnapshotRef?: string;
    principal?: ToolPrincipal;
    scope?: {
        tenantId?: string;
        userId?: string;
        workspaceId?: string;
        sessionId?: string;
        runId: string;
        stepId?: string;
        agentId?: string;
        fsmState?: string;
    };
    status: ToolInvocationStatus;
    inputHash: string;
    redactedInput?: unknown;
    sideEffectLevel?: SideEffectLevel;
    idempotencyKey?: string;
    idempotencyFingerprint?: string;
    reusedFromInvocationId?: string;
    request: ToolCallRequest;
    executionCycle: number;
    attemptCount: number;
    revision: number;
    result?: ToolCallResult;
    approvalRequest?: ToolApprovalRequest;
    approvalRequestId?: string;
    maxAttempts?: number;
    queuedAt?: string;
    deadlineAt?: string;
    outputHash?: string;
    artifactRefs?: string[];
    observationRefs?: string[];
    externalReceipt?: {
        provider?: string;
        receiptId: string;
        status?: string;
        metadata?: Record<string, unknown>;
    };
    lateResultState?: 'none' | 'pending' | 'accepted' | 'discarded' | 'quarantined';
    correlationId?: string;
    causationId?: string;
    metadata?: Record<string, unknown>;
    createdAt: string;
    updatedAt: string;
    startedAt?: string;
    completedAt?: string;
}

契约成员

成员种类签名说明
approvalRequest属性approvalRequest?: ToolApprovalRequest公开属性;类型、只读和可选状态以签名列为准。
approvalRequestId属性approvalRequestId?: string公开属性;类型、只读和可选状态以签名列为准。
artifactRefs属性artifactRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
attemptCount属性attemptCount: number公开属性;类型、只读和可选状态以签名列为准。
causationId属性causationId?: string公开属性;类型、只读和可选状态以签名列为准。
completedAt属性completedAt?: string公开属性;类型、只读和可选状态以签名列为准。
contractSnapshotRef属性contractSnapshotRef?: string公开属性;类型、只读和可选状态以签名列为准。
correlationId属性correlationId?: string公开属性;类型、只读和可选状态以签名列为准。
createdAt属性createdAt: string公开属性;类型、只读和可选状态以签名列为准。
deadlineAt属性deadlineAt?: string公开属性;类型、只读和可选状态以签名列为准。
executionCycle属性executionCycle: number公开属性;类型、只读和可选状态以签名列为准。
externalReceipt属性externalReceipt?: { provider?: string; receiptId: string; status?: string; metadata?: Record<string, unknown>; }公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
idempotencyFingerprint属性idempotencyFingerprint?: string公开属性;类型、只读和可选状态以签名列为准。
idempotencyKey属性idempotencyKey?: string公开属性;类型、只读和可选状态以签名列为准。
inputHash属性inputHash: string公开属性;类型、只读和可选状态以签名列为准。
lateResultState属性lateResultState?: "none" | "accepted" | "quarantined" | "pending" | "discarded"公开属性;类型、只读和可选状态以签名列为准。
maxAttempts属性maxAttempts?: number公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
observationRefs属性observationRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId?: string公开属性;类型、只读和可选状态以签名列为准。
outputHash属性outputHash?: string公开属性;类型、只读和可选状态以签名列为准。
principal属性principal?: ToolPrincipal公开属性;类型、只读和可选状态以签名列为准。
queuedAt属性queuedAt?: string公开属性;类型、只读和可选状态以签名列为准。
redactedInput属性redactedInput?: unknown公开属性;类型、只读和可选状态以签名列为准。
request属性request: ToolCallRequest<unknown>公开属性;类型、只读和可选状态以签名列为准。
result属性result?: ToolCallResult<unknown>公开属性;类型、只读和可选状态以签名列为准。
reusedFromInvocationId属性reusedFromInvocationId?: string公开属性;类型、只读和可选状态以签名列为准。
revision属性revision: number公开属性;类型、只读和可选状态以签名列为准。
scope属性scope?: { tenantId?: string; userId?: string; workspaceId?: string; sessionId?: string; runId: string; stepId?: string; agentId?: string; fsmState?: string; }公开属性;类型、只读和可选状态以签名列为准。
sideEffectLevel属性sideEffectLevel?: SideEffectLevel公开属性;类型、只读和可选状态以签名列为准。
startedAt属性startedAt?: string公开属性;类型、只读和可选状态以签名列为准。
status属性status: "completed" | "rejected" | "queued" | "running" | "cancelling" | "cancelled" | "failed" | "timed_out" | "created" | "denied" | "expired" | "approved" | "conflict" | "policy_checked" | "waiting_approval" | "validating" | "validated"公开属性;类型、只读和可选状态以签名列为准。
toolId属性toolId: string公开属性;类型、只读和可选状态以签名列为准。
toolRevision属性toolRevision?: string公开属性;类型、只读和可选状态以签名列为准。
toolVersion属性toolVersion?: string公开属性;类型、只读和可选状态以签名列为准。
updatedAt属性updatedAt: string公开属性;类型、只读和可选状态以签名列为准。

ToolInvocationStore

Tool Invocation Store 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolInvocationStore } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolInvocationStore {
    get(invocationId: string): Promise<ToolInvocationRecord | null>;
    findByIdempotency(request: ToolIdempotencyLookup): Promise<ToolInvocationRecord | null>;
    list(request?: ToolInvocationListRequest): Promise<ToolInvocationRecord[]>;
    create(record: ToolInvocationRecord): Promise<ToolInvocationRecord>;
    update(invocationId: string, patch: ToolInvocationPatch, options?: {
        expectedStatuses?: readonly ToolInvocationStatus[];
        expectedRevision?: number;
    }): Promise<ToolInvocationRecord>;
    getCompleted(invocationId: string): Promise<ToolCallResult | null>;
    saveCompleted(invocationId: string, result: ToolCallResult): Promise<void>;
}

契约成员

成员种类签名说明
create方法create(record: ToolInvocationRecord): Promise<ToolInvocationRecord>公开方法;参数与返回类型以签名列为准。
findByIdempotency方法findByIdempotency(request: ToolIdempotencyLookup): Promise<ToolInvocationRecord | null>公开方法;参数与返回类型以签名列为准。
get方法get(invocationId: string): Promise<ToolInvocationRecord | null>公开方法;参数与返回类型以签名列为准。
getCompleted方法getCompleted(invocationId: string): Promise<ToolCallResult | null>公开方法;参数与返回类型以签名列为准。
list方法list(request?: ToolInvocationListRequest): Promise<ToolInvocationRecord[]>公开方法;参数与返回类型以签名列为准。
saveCompleted方法saveCompleted(invocationId: string, result: ToolCallResult): Promise<void>公开方法;参数与返回类型以签名列为准。
update方法update(invocationId: string, patch: ToolInvocationPatch, options?: { expectedStatuses?: readonly ToolInvocationStatus[]; expectedRevision?: number; }): Promise<ToolInvocationRecord>公开方法;参数与返回类型以签名列为准。

ToolMiddleware

Tool Middleware 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolMiddleware } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolMiddleware {
    id: string;
    beforeAuthorization?(context: ToolMiddlewareContext): Promise<void> | void;
    beforeExecution?(context: ToolMiddlewareContext): Promise<void> | void;
    afterExecution?(context: ToolMiddlewareContext, result: ToolExecutionEnvelope): Promise<ToolExecutionEnvelope | void> | ToolExecutionEnvelope | void;
    onError?(context: ToolMiddlewareContext, error: unknown): Promise<void> | void;
}

契约成员

成员种类签名说明
afterExecution方法afterExecution?(context: ToolMiddlewareContext, result: ToolExecutionEnvelope): Promise<ToolExecutionEnvelope | void> | ToolExecutionEnvelope | void公开方法;参数与返回类型以签名列为准。
beforeAuthorization方法beforeAuthorization?(context: ToolMiddlewareContext): Promise<void> | void公开方法;参数与返回类型以签名列为准。
beforeExecution方法beforeExecution?(context: ToolMiddlewareContext): Promise<void> | void公开方法;参数与返回类型以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
onError方法onError?(context: ToolMiddlewareContext, error: unknown): Promise<void> | void公开方法;参数与返回类型以签名列为准。

ToolMiddlewareContext

Tool Middleware Context 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolMiddlewareContext } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolMiddlewareContext {
    invocationId: string;
    request: ToolCallRequest;
    originalRequest: ToolCallRequest;
    spec: ResolvedToolSpec;
    attempt?: number;
}

契约成员

成员种类签名说明
attempt属性attempt?: number公开属性;类型、只读和可选状态以签名列为准。
invocationId属性invocationId: string公开属性;类型、只读和可选状态以签名列为准。
originalRequest属性originalRequest: ToolCallRequest<unknown>公开属性;类型、只读和可选状态以签名列为准。
request属性request: ToolCallRequest<unknown>公开属性;类型、只读和可选状态以签名列为准。
spec属性spec: ResolvedToolSpec公开属性;类型、只读和可选状态以签名列为准。

ToolObservationPort

Tool Observation Port 接口,共包含 1 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolObservationPort } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolObservationPort {
    record(request: {
        invocationId: string;
        toolId: string;
        toolRevision: string;
        runId: string;
        stepId: string;
        inputHash: string;
        outputHash: string;
        value: unknown;
        artifactRefs?: string[];
        provenance: Record<string, unknown>;
    }): Promise<string>;
}

契约成员

成员种类签名说明
record方法record(request: { invocationId: string; toolId: string; toolRevision: string; runId: string; stepId: string; inputHash: string; outputHash: string; value: unknown; artifactRefs?: string[]; provenance: Record<string, unknown>; }): Promise<string>公开方法;参数与返回类型以签名列为准。

ToolPrincipal

Tool Principal 接口,共包含 13 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolPrincipal } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolPrincipal {
    id: string;
    principalId?: string;
    type: 'user' | 'agent' | 'service' | 'system';
    permissionScopes: readonly string[];
    tenantId?: string;
    userId?: string;
    workspaceId?: string;
    agentId?: string;
    roles?: readonly string[];
    delegatedBy?: string;
    delegationDepth?: number;
    authenticationContext?: Record<string, unknown>;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
agentId属性agentId?: string公开属性;类型、只读和可选状态以签名列为准。
authenticationContext属性authenticationContext?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
delegatedBy属性delegatedBy?: string公开属性;类型、只读和可选状态以签名列为准。
delegationDepth属性delegationDepth?: number公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
permissionScopes属性permissionScopes: readonly string[]公开属性;类型、只读和可选状态以签名列为准。
principalId属性principalId?: string公开属性;类型、只读和可选状态以签名列为准。
roles属性roles?: readonly string[]公开属性;类型、只读和可选状态以签名列为准。
tenantId属性tenantId?: string公开属性;类型、只读和可选状态以签名列为准。
type属性type: "system" | "agent" | "user" | "service"公开属性;类型、只读和可选状态以签名列为准。
userId属性userId?: string公开属性;类型、只读和可选状态以签名列为准。
workspaceId属性workspaceId?: string公开属性;类型、只读和可选状态以签名列为准。

ToolProfileSpec

Tool Profile Spec 接口,共包含 11 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolProfileSpec } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolProfileSpec extends VersionedSpec {
    toolRefs: SpecRef[];
    mcpProfileRefs?: SpecRef[];
    policyRefs?: SpecRef[];
    defaultPermissionScopes?: string[];
    contractSnapshotMode?: 'run' | 'state';
    lazyLoad?: boolean;
    maxLoadedTools?: number;
    metadata?: Record<string, unknown>;
    /** @deprecated Register Tool contracts separately and use toolRefs. */
    tools?: ToolSpec[];
}

契约成员

成员种类签名说明
contractSnapshotMode属性contractSnapshotMode?: "run" | "state"公开属性;类型、只读和可选状态以签名列为准。
defaultPermissionScopes属性defaultPermissionScopes?: string[]公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
lazyLoad属性lazyLoad?: boolean公开属性;类型、只读和可选状态以签名列为准。
maxLoadedTools属性maxLoadedTools?: number公开属性;类型、只读和可选状态以签名列为准。
mcpProfileRefs属性mcpProfileRefs?: SpecRef[]公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
policyRefs属性policyRefs?: SpecRef[]公开属性;类型、只读和可选状态以签名列为准。
toolRefs属性toolRefs: SpecRef[]公开属性;类型、只读和可选状态以签名列为准。
tools属性tools?: ToolSpec[]公开属性;类型、只读和可选状态以签名列为准。
version属性version: string公开属性;类型、只读和可选状态以签名列为准。

ToolProgressUpdate

Tool Progress Update 接口,共包含 6 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolProgressUpdate } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolProgressUpdate {
    message?: string;
    current?: number;
    total?: number;
    percentage?: number;
    stage?: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
current属性current?: number公开属性;类型、只读和可选状态以签名列为准。
message属性message?: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
percentage属性percentage?: number公开属性;类型、只读和可选状态以签名列为准。
stage属性stage?: string公开属性;类型、只读和可选状态以签名列为准。
total属性total?: number公开属性;类型、只读和可选状态以签名列为准。

ToolReceiptReconciler

Tool Receipt Reconciler 接口,共包含 1 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolReceiptReconciler } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolReceiptReconciler {
    reconcile(request: {
        invocationId: string;
        tool: ResolvedToolSpec;
        call: ToolCallRequest;
        attempt: number;
    }): Promise<ToolReceiptReconciliation>;
}

契约成员

成员种类签名说明
reconcile方法reconcile(request: { invocationId: string; tool: ResolvedToolSpec; call: ToolCallRequest; attempt: number; }): Promise<ToolReceiptReconciliation>公开方法;参数与返回类型以签名列为准。

ToolReceiptReconciliation

Tool Receipt Reconciliation 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolReceiptReconciliation } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolReceiptReconciliation {
    state: 'committed' | 'not_committed' | 'unknown';
    receipt?: ToolExternalReceipt;
    details?: Record<string, unknown>;
}

契约成员

成员种类签名说明
details属性details?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
receipt属性receipt?: ToolExternalReceipt公开属性;类型、只读和可选状态以签名列为准。
state属性state: "unknown" | "committed" | "not_committed"公开属性;类型、只读和可选状态以签名列为准。

ToolResultCache

Tool Result Cache 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolResultCache } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolResultCache {
    get(key: string): Promise<ToolResultCacheEntry | null>;
    set(entry: ToolResultCacheEntry): Promise<void>;
    delete?(key: string): Promise<void>;
}

契约成员

成员种类签名说明
delete方法delete?(key: string): Promise<void>公开方法;参数与返回类型以签名列为准。
get方法get(key: string): Promise<ToolResultCacheEntry | null>公开方法;参数与返回类型以签名列为准。
set方法set(entry: ToolResultCacheEntry): Promise<void>公开方法;参数与返回类型以签名列为准。

ToolResultCacheArtifactVerifier

Tool Result Cache Artifact Verifier 接口,共包含 1 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolResultCacheArtifactVerifier } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolResultCacheArtifactVerifier {
    verify(request: {
        toolId: string;
        artifactRefs: readonly string[];
        tenantId?: string;
        userId?: string;
        workspaceId?: string;
    }): Promise<boolean>;
}

契约成员

成员种类签名说明
verify方法verify(request: { toolId: string; artifactRefs: readonly string[]; tenantId?: string; userId?: string; workspaceId?: string; }): Promise<boolean>公开方法;参数与返回类型以签名列为准。

ToolResultCacheEntry

Tool Result Cache Entry 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolResultCacheEntry } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolResultCacheEntry {
    schemaVersion: '1.0';
    keyVersion: '1';
    validity: ToolCacheValidityRecord;
    result: ToolCachedResultProjection;
    createdAt: string;
}

契约成员

成员种类签名说明
createdAt属性createdAt: string公开属性;类型、只读和可选状态以签名列为准。
keyVersion属性keyVersion: "1"公开属性;类型、只读和可选状态以签名列为准。
result属性result: ToolCachedResultProjection公开属性;类型、只读和可选状态以签名列为准。
schemaVersion属性schemaVersion: "1.0"公开属性;类型、只读和可选状态以签名列为准。
validity属性validity: ToolCacheValidityRecord公开属性;类型、只读和可选状态以签名列为准。

ToolRunner

Tool Runner 接口,共包含 2 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolRunner } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolRunner {
    run(request: ToolCallRequest): Promise<ToolCallResult>;
    cancelInvocation?(invocationId: string, reason?: string): Promise<ToolCallResult | null>;
}

契约成员

成员种类签名说明
cancelInvocation方法cancelInvocation?(invocationId: string, reason?: string): Promise<ToolCallResult | null>公开方法;参数与返回类型以签名列为准。
run方法run(request: ToolCallRequest): Promise<ToolCallResult>公开方法;参数与返回类型以签名列为准。

ToolSchemaValidationIssue

Tool Schema Validation Issue 接口,共包含 2 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolSchemaValidationIssue } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolSchemaValidationIssue {
    path: string;
    message: string;
}

契约成员

成员种类签名说明
message属性message: string公开属性;类型、只读和可选状态以签名列为准。
path属性path: string公开属性;类型、只读和可选状态以签名列为准。

ToolSchemaValidationResult

Tool Schema Validation Result 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolSchemaValidationResult } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolSchemaValidationResult {
    valid: boolean;
    error?: string;
    issues: ToolSchemaValidationIssue[];
}

契约成员

成员种类签名说明
error属性error?: string公开属性;类型、只读和可选状态以签名列为准。
issues属性issues: ToolSchemaValidationIssue[]公开属性;类型、只读和可选状态以签名列为准。
valid属性valid: boolean公开属性;类型、只读和可选状态以签名列为准。

ToolSpec

Tool Spec 接口,共包含 33 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolSpec } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolSpec {
    id: string;
    version: string;
    revision?: string;
    name?: string;
    displayName?: string;
    description: string;
    instructions?: string;
    tags?: string[];
    inputSchema: JsonSchema;
    outputSchema?: JsonSchema;
    input?: ToolSchemaSpec;
    output?: ToolSchemaSpec;
    sideEffectLevel: SideEffectLevel;
    permissionScope?: string[];
    preconditions?: string[];
    postconditions?: string[];
    timeoutPolicy?: TimeoutPolicySpec;
    retryPolicy?: RetryPolicySpec;
    auditPolicy?: AuditPolicySpec;
    humanApprovalPolicy?: HumanReviewPolicySpec;
    idempotencyPolicy?: {
        mode: 'none' | 'optional' | 'required';
    };
    source?: ToolSource;
    sourceRef?: {
        serverId?: string;
        capabilityId?: string;
        capabilityHash?: string;
        trustLevel?: 'trusted' | 'reviewed' | 'untrusted';
        declarationSource?: 'framework' | 'user' | 'server' | 'unknown';
    } & ToolSourceRef;
    semantics?: ToolSemanticSpec;
    execution?: ToolExecutionPolicySpec;
    governance?: ToolGovernanceSpec;
    observability?: ToolObservabilitySpec;
    cache?: ToolCachePolicySpec;
    streaming?: ToolStreamingSpec;
    enabled?: boolean;
    deprecated?: boolean;
    replacedBy?: {
        id: string;
        version?: string;
        revision?: string;
    };
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
auditPolicy属性auditPolicy?: AuditPolicySpec公开属性;类型、只读和可选状态以签名列为准。
cache属性cache?: ToolCachePolicySpec公开属性;类型、只读和可选状态以签名列为准。
deprecated属性deprecated?: boolean公开属性;类型、只读和可选状态以签名列为准。
description属性description: string公开属性;类型、只读和可选状态以签名列为准。
displayName属性displayName?: string公开属性;类型、只读和可选状态以签名列为准。
enabled属性enabled?: boolean公开属性;类型、只读和可选状态以签名列为准。
execution属性execution?: ToolExecutionPolicySpec公开属性;类型、只读和可选状态以签名列为准。
governance属性governance?: ToolGovernanceSpec公开属性;类型、只读和可选状态以签名列为准。
humanApprovalPolicy属性humanApprovalPolicy?: HumanReviewPolicySpec公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
idempotencyPolicy属性idempotencyPolicy?: { mode: "none" | "optional" | "required"; }公开属性;类型、只读和可选状态以签名列为准。
input属性input?: ToolSchemaSpec公开属性;类型、只读和可选状态以签名列为准。
inputSchema属性inputSchema: JsonSchema公开属性;类型、只读和可选状态以签名列为准。
instructions属性instructions?: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
name属性name?: string公开属性;类型、只读和可选状态以签名列为准。
observability属性observability?: ToolObservabilitySpec公开属性;类型、只读和可选状态以签名列为准。
output属性output?: ToolSchemaSpec公开属性;类型、只读和可选状态以签名列为准。
outputSchema属性outputSchema?: JsonSchema公开属性;类型、只读和可选状态以签名列为准。
permissionScope属性permissionScope?: string[]公开属性;类型、只读和可选状态以签名列为准。
postconditions属性postconditions?: string[]公开属性;类型、只读和可选状态以签名列为准。
preconditions属性preconditions?: string[]公开属性;类型、只读和可选状态以签名列为准。
replacedBy属性replacedBy?: { id: string; version?: string; revision?: string; }公开属性;类型、只读和可选状态以签名列为准。
retryPolicy属性retryPolicy?: RetryPolicySpec公开属性;类型、只读和可选状态以签名列为准。
revision属性revision?: string公开属性;类型、只读和可选状态以签名列为准。
semantics属性semantics?: ToolSemanticSpec公开属性;类型、只读和可选状态以签名列为准。
sideEffectLevel属性sideEffectLevel: SideEffectLevel公开属性;类型、只读和可选状态以签名列为准。
source属性source?: ToolSource公开属性;类型、只读和可选状态以签名列为准。
sourceRef属性sourceRef?: { serverId?: string; capabilityId?: string; capabilityHash?: string; trustLevel?: "trusted" | "reviewed" | "untrusted"; declarationSource?: "framework" | "user" | "server" | "unknown"; } & ToolSourceRef公开属性;类型、只读和可选状态以签名列为准。
streaming属性streaming?: ToolStreamingSpec公开属性;类型、只读和可选状态以签名列为准。
tags属性tags?: string[]公开属性;类型、只读和可选状态以签名列为准。
timeoutPolicy属性timeoutPolicy?: TimeoutPolicySpec公开属性;类型、只读和可选状态以签名列为准。
version属性version: string公开属性;类型、只读和可选状态以签名列为准。

ToolTargetResolution

Tool Target Resolution 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolTargetResolution } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolTargetResolution {
    toolId: string;
    input: unknown;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
input属性input: unknown公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
toolId属性toolId: string公开属性;类型、只读和可选状态以签名列为准。

ToolTargetResolver

Tool Target Resolver 接口,共包含 1 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ToolTargetResolver } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export interface ToolTargetResolver {
    resolve(request: ToolCallRequest, registry: ToolRegistry): Promise<ToolTargetResolution>;
}

契约成员

成员种类签名说明
resolve方法resolve(request: ToolCallRequest, registry: ToolRegistry): Promise<ToolTargetResolution>公开方法;参数与返回类型以签名列为准。

MockToolHandler

Mock Tool Handler 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { MockToolHandler } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export type MockToolHandler = (request: ToolCallRequest) => Promise<ToolCallResult> | ToolCallResult;

ResolvedToolSpec

Resolved Tool Spec 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { ResolvedToolSpec } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export type ResolvedToolSpec = ToolSpec & GovernedToolContractSpec;

ToolExecutionPhase

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

  • 种类: 类型
  • 导入: import type { ToolExecutionPhase } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export type ToolExecutionPhase = 'resolution' | 'authorization' | 'input_validation' | 'policy' | 'approval' | 'execution' | 'timeout' | 'output_validation';

ToolHandler

Tool Handler 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { ToolHandler } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export type ToolHandler<TInput = unknown, TOutput = unknown> = (input: TInput, context: ToolCallContext) => Promise<TOutput>;

ToolInvocationPatch

Tool Invocation Patch 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { ToolInvocationPatch } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export type ToolInvocationPatch = Partial<Pick<ToolInvocationRecord, 'status' | 'executionCycle' | 'attemptCount' | 'result' | 'approvalRequest' | 'updatedAt' | 'startedAt' | 'completedAt' | 'lateResultState' | 'outputHash' | 'artifactRefs' | 'observationRefs' | 'externalReceipt'>>;

ToolInvocationStatus

Tool Invocation Status 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { ToolInvocationStatus } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export type ToolInvocationStatus = (typeof TOOL_INVOCATION_STATUSES)[number];

ToolResultContent

Tool Result Content 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { ToolResultContent } from '@codesoul-co/hypha-tools';
  • 源码模块: index

声明

text
export type ToolResultContent = {
    type: 'text';
    text: string;
} | {
    type: 'json';
    value: unknown;
} | {
    type: 'image';
    artifactRef?: string;
    url?: string;
    mimeType?: string;
    alt?: string;
} | {
    type: 'resource';
    uri: string;
    mimeType?: string;
    title?: string;
} | {
    type: 'artifact';
    artifactRef: string;
    title?: string;
    mimeType?: string;
};