import z from "zod"; import * as _$node_stream0 from "node:stream"; //#region src/manifest.type.d.ts declare const UserToolManifestSchema: z.ZodObject<{ toolDescription: z.ZodOptional; icon: z.ZodOptional; name: z.ZodObject<{ en: z.ZodString; "zh-CN": z.ZodString; "zh-Hant": z.ZodOptional; }, z.core.$strip>; description: z.ZodObject<{ en: z.ZodString; "zh-CN": z.ZodString; "zh-Hant": z.ZodOptional; }, z.core.$strip>; pluginId: z.ZodString; version: z.ZodString; author: z.ZodOptional; repoUrl: z.ZodOptional; tutorialUrl: z.ZodOptional; tags: z.ZodOptional>>; versionDescription: z.ZodOptional; }, z.core.$strip>>; permission: z.ZodOptional>>; }, z.core.$strip>; type UserToolManifestType = z.infer; //#endregion //#region ../../packages/domain/src/value-objects/i18n-string.vo.d.ts declare const I18nStringSchema: z.ZodObject<{ en: z.ZodString; "zh-CN": z.ZodString; "zh-Hant": z.ZodOptional; }, z.core.$strip>; type I18nStringType = z.infer; //#endregion //#region ../../packages/domain/src/value-objects/result.vo.d.ts /** usecase, interface-adapter 都要使用这个类型, 手动处理错误,并且能从内到外把错误透出来*/ type ResultFailure = { reason: I18nStringType; error: E; code?: string; message?: string; data?: unknown; }; type Result = [T, null] | [null, ResultFailure]; //#endregion //#region ../../packages/domain/src/ports/invoke.port.d.ts declare const InvokeUploadFileInputSchema: z.ZodObject<{ file: z.ZodUnion, z.ZodPipe, Buffer>, z.ZodCustom, Uint8Array>]>, z.ZodTransform, Uint8Array | Buffer>>]>; fileName: z.ZodOptional; contentType: z.ZodOptional, z.ZodString>>; }, z.core.$strip>; declare const InvokeUploadFileOutputSchema: z.ZodObject<{ accessURL: z.ZodString; etag: z.ZodOptional; fileName: z.ZodOptional; contentType: z.ZodOptional, z.ZodString>>; size: z.ZodOptional; createTime: z.ZodOptional; }, z.core.$strip>; type InvokeUploadFileInputType = z.infer; type InvokeUploadFileOutputType = z.infer; declare const InvokeUserInfoOutputSchema: z.ZodObject<{ username: z.ZodString; contact: z.ZodOptional>; memberName: z.ZodOptional>; orgs: z.ZodArray>; groups: z.ZodArray>; }, z.core.$strip>; type InvokeUserInfoOutputType = z.infer; type InvokeWecomCorpTokenOutputType = { access_token: string; expires_in: number; }; /** * 反向调用 FastGPT 的能力 */ interface InvokePort { /** 上传文件 */ uploadFile(input: InvokeUploadFileInputType): Promise>; userInfo(): Promise>; getWecomCorpToken(): Promise>; } //#endregion //#region ../../packages/domain/src/value-objects/system-var.vo.d.ts declare const SystemVarSchema: z.ZodObject<{ app: z.ZodObject<{ id: z.ZodString; name: z.ZodString; }, z.core.$strip>; chat: z.ZodObject<{ chatId: z.ZodString; uid: z.ZodOptional; }, z.core.$strip>; invokeToken: z.ZodString; time: z.ZodString; }, z.core.$strip>; type SystemVarType = z.infer; //#endregion //#region ../../packages/domain/src/value-objects/tool.vo.d.ts declare const ToolAnswerSchema: z.ZodObject<{ type: z.ZodEnum<{ answer: "answer"; fastAnswer: "fastAnswer"; }>; content: z.ZodString; }, z.core.$strip>; type ToolAnswerType = z.infer; //#endregion //#region src/tool-factory.d.ts type ToolChildManifestDefinition = { id: string; description: UserToolManifestType['description']; name: UserToolManifestType['name']; icon?: string; toolDescription?: string; }; type ToolInputSchema = z.ZodObject; type ToolOutputSchema = z.ZodObject; type ToolSecretSchema = z.ZodTypeAny | undefined; type ToolSecretValue = TSecret extends z.ZodTypeAny ? z.output> : undefined; type ToolHandlerContext = { systemVar: SystemVarType; secrets?: ToolSecretValue; invoke: InvokePort; streamResponse: (msg: ToolAnswerType) => void; }; type ToolHandlerFn = (input: z.output>, ctx: ToolHandlerContext) => Promise>>; type ToolHandlerDefinition = { inputSchema: TInput; outputSchema: TOutput; secretSchema?: TSecret; handler: ToolHandlerFn; }; declare function createToolHandler(def: ToolHandlerDefinition): ToolHandlerDefinition; //#endregion //#region src/index.d.ts type InputSchemaMetaType = z.GlobalMeta & { /** 面向模型的参数说明 */toolDescription?: string; /** 标注该字段是否推荐由 AI 托管补充 */ isToolParam?: boolean; }; type OutputSchemaMetaType = z.GlobalMeta; type SecretSchemaMetaType = z.GlobalMeta & { /** 标注该字段是否需要加密存储 */isSecret: boolean; }; interface DefinedToolFactory { setSecretSchema>(schema: z.ZodType): void; registerTool(definition: ToolHandlerDefinition, id?: string, childManifest?: ToolChildManifestDefinition): void; getSecretSchema(): z.ZodType; getToolHandler(): ToolHandlerDefinition; getToolHandler(childId: string): ToolHandlerDefinition | undefined; getUserToolManifest(): UserToolManifestType; getChildManifests(): ToolChildManifestDefinition[]; } declare const defineTool: ({ manifest, handler }: { manifest: UserToolManifestType; handler: ToolHandlerDefinition; }) => DefinedToolFactory; declare const defineToolSet: ({ manifest, children, secretSchema }: { manifest: UserToolManifestType; secretSchema?: z.ZodObject; children: (ToolChildManifestDefinition & { handler: ToolHandlerDefinition; })[]; }) => DefinedToolFactory; //#endregion export { DefinedToolFactory, InputSchemaMetaType, OutputSchemaMetaType, SecretSchemaMetaType, type ToolHandlerContext, createToolHandler, defineTool, defineToolSet };