@codesoul-co/hypha-tools / index
- 包索引:
@codesoul-co/hypha-tools - 源码:
packages/tools/src/index.ts - 导出数: 85
模块用法
聚合 @codesoul-co/hypha-tools 的公共入口导出;应用应从包入口导入这些 Symbol,不应依赖内部文件路径。
从包入口导入
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 或默认配置;应复用这些导出,避免在应用中复制内部值。
运行时校验示例
import { toolCacheValidityRecordSchema } from '@codesoul-co/hypha-tools';
declare function loadExternalInput(): unknown;
const input: unknown = loadExternalInput();
const parsed = toolCacheValidityRecordSchema.parse(input);配置、网络请求或持久化数据等不可信输入应先通过 Runtime Schema,再传给只接受已校验契约的函数或类。
公共导出
| Symbol | 种类 | 签名 | 说明 |
|---|---|---|---|
AllowAllToolAuthorizer | 类 | new AllowAllToolAuthorizer(): AllowAllToolAuthorizer | Allow All Tool Authorizer 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。 |
GovernedToolRunner | 类 | new 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 个构造函数或成员;精确签名见本条目的声明与成员表。 |
HttpToolAdapter | 类 | new HttpToolAdapter(id: string, options: HttpToolAdapterOptions): HttpToolAdapter | Http Tool Adapter 类,共公开 7 个构造函数或成员;精确签名见本条目的声明与成员表。 |
InMemoryToolApprovalStore | 类 | new InMemoryToolApprovalStore(): InMemoryToolApprovalStore | In Memory Tool Approval Store 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。 |
InMemoryToolInvocationStore | 类 | new InMemoryToolInvocationStore(): InMemoryToolInvocationStore | In Memory Tool Invocation Store 类,共公开 8 个构造函数或成员;精确签名见本条目的声明与成员表。 |
InMemoryToolResultCache | 类 | new InMemoryToolResultCache(options?: InMemoryToolResultCacheOptions): InMemoryToolResultCache | In Memory Tool Result Cache 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。 |
LocalFunctionToolAdapter | 类 | new LocalFunctionToolAdapter<TInput = unknown, TOutput = unknown>(id: string, handler: ToolHandler<TInput, TOutput>): LocalFunctionToolAdapter<TInput, TOutput> | Local Function Tool Adapter 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。 |
MCPToolAdapter | 类 | new MCPToolAdapter(id: string, serverId: string, capabilityId: string, gateway: MCPToolInvocationPort): MCPToolAdapter | MCP Tool Adapter 类,共公开 7 个构造函数或成员;精确签名见本条目的声明与成员表。 |
MockToolAdapter | 类 | new MockToolAdapter<TInput = unknown, TOutput = unknown>(id: string, handler: ToolHandler<TInput, TOutput>): MockToolAdapter<TInput, TOutput> | Mock Tool Adapter 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。 |
MockToolRunner | 类 | new MockToolRunner(defaultOutput?: unknown): MockToolRunner | Mock Tool Runner 类,共公开 4 个构造函数或成员;精确签名见本条目的声明与成员表。 |
PermissionScopeToolAuthorizer | 类 | new PermissionScopeToolAuthorizer(): PermissionScopeToolAuthorizer | Permission Scope Tool Authorizer 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。 |
PluginToolAdapter | 类 | new PluginToolAdapter<TInput = unknown, TOutput = unknown>(id: string, handler: ToolHandler<TInput, TOutput>): PluginToolAdapter<TInput, TOutput> | Plugin Tool Adapter 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。 |
RedisToolResultCache | 类 | new RedisToolResultCache(options: RedisToolResultCacheOptions): RedisToolResultCache | Shared Redis-compatible Store for local, self-hosted, and managed Redis deployments. |
ToolRegistry | 类 | new ToolRegistry(): ToolRegistry | Tool Registry 类,共公开 9 个构造函数或成员;精确签名见本条目的声明与成员表。 |
ToolResultCacheEntryTooLargeError | 类 | new ToolResultCacheEntryTooLargeError(actualBytes: number, maxEntryBytes: number): ToolResultCacheEntryTooLargeError | Tool Result Cache Entry Too Large Error 类,共公开 11 个构造函数或成员;精确签名见本条目的声明与成员表。 |
ToolResultCacheOperationTimeoutError | 类 | new ToolResultCacheOperationTimeoutError(operation: "get" | "set" | "delete" | "verify", timeoutMs: number): ToolResultCacheOperationTimeoutError | Tool Result Cache Operation Timeout Error 类,共公开 11 个构造函数或成员;精确签名见本条目的声明与成员表。 |
ToolResultCacheValidationError | 类 | new ToolResultCacheValidationError(message: string): ToolResultCacheValidationError | Tool 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: JsonSchema | Tool 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: ToolSpec | Tool Spec 的有效示例值。 |
toolSpecJsonSchema | 常量 | const toolSpecJsonSchema: JsonSchema | Tool 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): ResolvedToolSpec | Normalize Tool Spec 函数,提供 1 个公开调用签名;参数与返回类型见下表。 |
validateEffectiveCapabilityAccess | 函数 | validateEffectiveCapabilityAccess(input: { snapshot: ToolContractSnapshot | null; context: ToolCallContext; spec: ToolSpec; }): string | null | Validate Effective Capability Access 函数,提供 1 个公开调用签名;参数与返回类型见下表。 |
validateToolInput | 函数 | validateToolInput(schema: JsonSchema, input: unknown): ToolSchemaValidationResult | Validate Tool Input 函数,提供 1 个公开调用签名;参数与返回类型见下表。 |
validateToolResultCacheEntry | 函数 | validateToolResultCacheEntry(value: unknown, maxEntryBytes?: number): ToolResultCacheEntry | Validate Tool Result Cache Entry 函数,提供 1 个公开调用签名;参数与返回类型见下表。 |
validateToolSpec | 函数 | validateToolSpec(input: unknown): ToolSpec | Validate Tool Spec 函数,提供 1 个公开调用签名;参数与返回类型见下表。 |
AdapterCancellationRequest | 接口 | interface AdapterCancellationRequest | Adapter Cancellation Request 接口,共包含 3 个公开字段或方法。 |
AdapterExecutionRequest | 接口 | interface AdapterExecutionRequest | Adapter Execution Request 接口,共包含 3 个公开字段或方法。 |
HttpToolAdapterOptions | 接口 | interface HttpToolAdapterOptions | Http Tool Adapter Options 接口,共包含 4 个公开字段或方法。 |
InMemoryToolResultCacheOptions | 接口 | interface InMemoryToolResultCacheOptions | In Memory Tool Result Cache Options 接口,共包含 2 个公开字段或方法。 |
MCPToolInvocationPort | 接口 | interface MCPToolInvocationPort | MCP Tool Invocation Port 接口,共包含 3 个公开字段或方法。 |
RedisLikeToolResultCacheClient | 接口 | interface RedisLikeToolResultCacheClient | Redis Like Tool Result Cache Client 接口,共包含 3 个公开字段或方法。 |
RedisToolResultCacheOptions | 接口 | interface RedisToolResultCacheOptions | Redis Tool Result Cache Options 接口,共包含 5 个公开字段或方法。 |
ToolAdapter | 接口 | interface ToolAdapter | Tool Adapter 接口,共包含 7 个公开字段或方法。 |
ToolAdapterCapabilities | 接口 | interface ToolAdapterCapabilities | Tool Adapter Capabilities 接口,共包含 5 个公开字段或方法。 |
ToolApprovalGrant | 接口 | interface ToolApprovalGrant | Tool Approval Grant 接口,共包含 11 个公开字段或方法。 |
ToolApprovalRequest | 接口 | interface ToolApprovalRequest | Tool Approval Request 接口,共包含 15 个公开字段或方法。 |
ToolApprovalStore | 接口 | interface ToolApprovalStore | Tool Approval Store 接口,共包含 5 个公开字段或方法。 |
ToolArtifactPort | 接口 | interface ToolArtifactPort | Tool Artifact Port 接口,共包含 1 个公开字段或方法。 |
ToolAuthorizationDecision | 接口 | interface ToolAuthorizationDecision | Tool Authorization Decision 接口,共包含 3 个公开字段或方法。 |
ToolAuthorizationInput | 接口 | interface ToolAuthorizationInput | Tool Authorization Input 接口,共包含 4 个公开字段或方法。 |
ToolAuthorizer | 接口 | interface ToolAuthorizer | Tool Authorizer 接口,共包含 1 个公开字段或方法。 |
ToolCachedResultProjection | 接口 | interface ToolCachedResultProjection | Only stable, replay-safe output fields may cross invocation boundaries. |
ToolCallContext | 接口 | interface ToolCallContext | Tool Call Context 接口,共包含 24 个公开字段或方法。 |
ToolCallError | 接口 | interface ToolCallError | Tool Call Error 接口,共包含 5 个公开字段或方法。 |
ToolCallRequest | 接口 | interface ToolCallRequest | Tool Call Request 接口,共包含 3 个公开字段或方法。 |
ToolCallResult | 接口 | interface ToolCallResult | Tool Call Result 接口,共包含 12 个公开字段或方法。 |
ToolExecutionEnvelope | 接口 | interface ToolExecutionEnvelope | Tool Execution Envelope 接口,共包含 7 个公开字段或方法。 |
ToolExecutionScope | 接口 | interface ToolExecutionScope | Tool Execution Scope 接口,共包含 3 个公开字段或方法。 |
ToolIdempotencyLookup | 接口 | interface ToolIdempotencyLookup | Tool Idempotency Lookup 接口,共包含 3 个公开字段或方法。 |
ToolInvocationListRequest | 接口 | interface ToolInvocationListRequest | Tool Invocation List Request 接口,共包含 4 个公开字段或方法。 |
ToolInvocationRecord | 接口 | interface ToolInvocationRecord | Tool Invocation Record 接口,共包含 37 个公开字段或方法。 |
ToolInvocationStore | 接口 | interface ToolInvocationStore | Tool Invocation Store 接口,共包含 7 个公开字段或方法。 |
ToolMiddleware | 接口 | interface ToolMiddleware | Tool Middleware 接口,共包含 5 个公开字段或方法。 |
ToolMiddlewareContext | 接口 | interface ToolMiddlewareContext | Tool Middleware Context 接口,共包含 5 个公开字段或方法。 |
ToolObservationPort | 接口 | interface ToolObservationPort | Tool Observation Port 接口,共包含 1 个公开字段或方法。 |
ToolPrincipal | 接口 | interface ToolPrincipal | Tool Principal 接口,共包含 13 个公开字段或方法。 |
ToolProfileSpec | 接口 | interface ToolProfileSpec extends VersionedSpec | Tool Profile Spec 接口,共包含 11 个公开字段或方法。 |
ToolProgressUpdate | 接口 | interface ToolProgressUpdate | Tool Progress Update 接口,共包含 6 个公开字段或方法。 |
ToolReceiptReconciler | 接口 | interface ToolReceiptReconciler | Tool Receipt Reconciler 接口,共包含 1 个公开字段或方法。 |
ToolReceiptReconciliation | 接口 | interface ToolReceiptReconciliation | Tool Receipt Reconciliation 接口,共包含 3 个公开字段或方法。 |
ToolResultCache | 接口 | interface ToolResultCache | Tool Result Cache 接口,共包含 3 个公开字段或方法。 |
ToolResultCacheArtifactVerifier | 接口 | interface ToolResultCacheArtifactVerifier | Tool Result Cache Artifact Verifier 接口,共包含 1 个公开字段或方法。 |
ToolResultCacheEntry | 接口 | interface ToolResultCacheEntry | Tool Result Cache Entry 接口,共包含 5 个公开字段或方法。 |
ToolRunner | 接口 | interface ToolRunner | Tool Runner 接口,共包含 2 个公开字段或方法。 |
ToolSchemaValidationIssue | 接口 | interface ToolSchemaValidationIssue | Tool Schema Validation Issue 接口,共包含 2 个公开字段或方法。 |
ToolSchemaValidationResult | 接口 | interface ToolSchemaValidationResult | Tool Schema Validation Result 接口,共包含 3 个公开字段或方法。 |
ToolSpec | 接口 | interface ToolSpec | Tool Spec 接口,共包含 33 个公开字段或方法。 |
ToolTargetResolution | 接口 | interface ToolTargetResolution | Tool Target Resolution 接口,共包含 3 个公开字段或方法。 |
ToolTargetResolver | 接口 | interface ToolTargetResolver | Tool Target Resolver 接口,共包含 1 个公开字段或方法。 |
MockToolHandler | 类型 | type MockToolHandler = (request: ToolCallRequest) => Promise<ToolCallResult> | ToolCallResult | Mock Tool Handler 公共类型别名;完整类型表达式见声明。 |
ResolvedToolSpec | 类型 | type ResolvedToolSpec = ToolSpec & GovernedToolContractSpec | Resolved 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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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): void | Creates 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: number | The 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
声明
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): void | Creates 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: number | The 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
声明
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): void | Creates 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: number | The 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
声明
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
声明
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
声明
export declare const toolProfileSpecDefinition: SpecSchemaDefinition<ToolProfileSpec>;toolProfileSpecSchema
Tool Profile Spec 的运行时 Schema。
- 种类: 常量
- 导入:
import { toolProfileSpecSchema } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
// 精确类型由包入口解析;完整编译器展开定义见源码链接。
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
声明
export declare const toolResultCacheEntryJsonSchema: JsonSchema;toolResultCacheEntrySchema
Tool Result Cache Entry 的运行时 Schema。
- 种类: 常量
- 导入:
import { toolResultCacheEntrySchema } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
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
声明
export declare const toolSpecDefinition: SpecSchemaDefinition<ToolSpec>;toolSpecDefinitions
由 index 模块导出的 Tool Spec Definitions 常量。
- 种类: 常量
- 导入:
import { toolSpecDefinitions } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
export declare const toolSpecDefinitions: readonly [SpecSchemaDefinition<ToolSpec>, SpecSchemaDefinition<ToolProfileSpec>];toolSpecExample
Tool Spec 的有效示例值。
- 种类: 常量
- 导入:
import { toolSpecExample } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
export declare const toolSpecExample: ToolSpec;toolSpecJsonSchema
Tool Spec 的 JSON Schema。
- 种类: 常量
- 导入:
import { toolSpecJsonSchema } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
export declare const toolSpecJsonSchema: JsonSchema;toolSpecJsonSchemas
由 index 模块导出的 Tool Spec JSON Schemas 常量。
- 种类: 常量
- 导入:
import { toolSpecJsonSchemas } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
export declare const toolSpecJsonSchemas: Record<string, JsonSchema>;toolSpecSchema
Tool Spec 的运行时 Schema。
- 种类: 常量
- 导入:
import { toolSpecSchema } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
// 精确类型由包入口解析;完整编译器展开定义见源码链接。
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
声明
export declare function normalizeToolSpec(spec: ToolSpec): ResolvedToolSpec;调用签名
normalizeToolSpec(spec: ToolSpec): ResolvedToolSpec参数
| 参数 | 类型 | 必需 | 说明 |
|---|---|---|---|
spec | ToolSpec | 是 | 必需参数;接受的值由类型列定义。 |
返回值
- 类型:
ResolvedToolSpec - 说明: 返回值契约由上述类型定义。
validateEffectiveCapabilityAccess
Validate Effective Capability Access 函数,提供 1 个公开调用签名;参数与返回类型见下表。
- 种类: 函数
- 导入:
import { validateEffectiveCapabilityAccess } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
export declare function validateEffectiveCapabilityAccess(input: {
snapshot: ToolContractSnapshot | null;
context: ToolCallContext;
spec: ToolSpec;
}): string | null;调用签名
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
声明
export declare function validateToolInput(schema: JsonSchema, input: unknown): ToolSchemaValidationResult;调用签名
validateToolInput(schema: JsonSchema, input: unknown): ToolSchemaValidationResult参数
| 参数 | 类型 | 必需 | 说明 |
|---|---|---|---|
schema | JsonSchema | 是 | 必需参数;接受的值由类型列定义。 |
input | unknown | 是 | 必需参数;接受的值由类型列定义。 |
返回值
- 类型:
ToolSchemaValidationResult - 说明: 返回值契约由上述类型定义。
validateToolResultCacheEntry
Validate Tool Result Cache Entry 函数,提供 1 个公开调用签名;参数与返回类型见下表。
- 种类: 函数
- 导入:
import { validateToolResultCacheEntry } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
export declare function validateToolResultCacheEntry(value: unknown, maxEntryBytes?: number): ToolResultCacheEntry;调用签名
validateToolResultCacheEntry(value: unknown, maxEntryBytes?: number): ToolResultCacheEntry参数
| 参数 | 类型 | 必需 | 说明 |
|---|---|---|---|
value | unknown | 是 | 必需参数;接受的值由类型列定义。 |
maxEntryBytes | number | 否 | 可选参数;接受的值由类型列定义。 |
返回值
- 类型:
ToolResultCacheEntry - 说明: 返回值契约由上述类型定义。
validateToolSpec
Validate Tool Spec 函数,提供 1 个公开调用签名;参数与返回类型见下表。
- 种类: 函数
- 导入:
import { validateToolSpec } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
export declare function validateToolSpec(input: unknown): ToolSpec;调用签名
validateToolSpec(input: unknown): ToolSpec参数
| 参数 | 类型 | 必需 | 说明 |
|---|---|---|---|
input | unknown | 是 | 必需参数;接受的值由类型列定义。 |
返回值
- 类型:
ToolSpec - 说明: 返回值契约由上述类型定义。
AdapterCancellationRequest
Adapter Cancellation Request 接口,共包含 3 个公开字段或方法。
- 种类: 接口
- 导入:
import type { AdapterCancellationRequest } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
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
声明
export type MockToolHandler = (request: ToolCallRequest) => Promise<ToolCallResult> | ToolCallResult;ResolvedToolSpec
Resolved Tool Spec 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { ResolvedToolSpec } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
export type ResolvedToolSpec = ToolSpec & GovernedToolContractSpec;ToolExecutionPhase
Tool Execution Phase 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { ToolExecutionPhase } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
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
声明
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
声明
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
声明
export type ToolInvocationStatus = (typeof TOOL_INVOCATION_STATUSES)[number];ToolResultContent
Tool Result Content 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { ToolResultContent } from '@codesoul-co/hypha-tools'; - 源码模块:
index
声明
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;
};