@fastgpt-plugin/sdk-client 0.1.0-alpha.1 → 0.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +18 -12
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ declare const ModelListDTOSchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObjec
|
|
|
12
12
|
showStopSign: z.ZodOptional<z.ZodBoolean>;
|
|
13
13
|
censor: z.ZodOptional<z.ZodBoolean>;
|
|
14
14
|
vision: z.ZodBoolean;
|
|
15
|
+
audio: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
video: z.ZodOptional<z.ZodBoolean>;
|
|
15
17
|
reasoning: z.ZodBoolean;
|
|
16
18
|
reasoningEffort: z.ZodBoolean;
|
|
17
19
|
toolChoice: z.ZodBoolean;
|
|
@@ -148,12 +150,12 @@ declare const PluginBaseDTOSchema: z.ZodObject<{
|
|
|
148
150
|
}, z.core.$strip>>;
|
|
149
151
|
}, z.core.$strip>;
|
|
150
152
|
declare const PluginListItemDTOSchema: z.ZodObject<{
|
|
151
|
-
type: z.ZodString;
|
|
152
153
|
name: z.ZodObject<{
|
|
153
154
|
en: z.ZodString;
|
|
154
155
|
"zh-CN": z.ZodOptional<z.ZodString>;
|
|
155
156
|
"zh-Hant": z.ZodOptional<z.ZodString>;
|
|
156
157
|
}, z.core.$strip>;
|
|
158
|
+
type: z.ZodString;
|
|
157
159
|
description: z.ZodOptional<z.ZodObject<{
|
|
158
160
|
en: z.ZodString;
|
|
159
161
|
"zh-CN": z.ZodOptional<z.ZodString>;
|
|
@@ -171,12 +173,12 @@ declare const PluginListItemDTOSchema: z.ZodObject<{
|
|
|
171
173
|
source: z.ZodString;
|
|
172
174
|
}, z.core.$strip>;
|
|
173
175
|
declare const PluginListDTOSchema: z.ZodArray<z.ZodObject<{
|
|
174
|
-
type: z.ZodString;
|
|
175
176
|
name: z.ZodObject<{
|
|
176
177
|
en: z.ZodString;
|
|
177
178
|
"zh-CN": z.ZodOptional<z.ZodString>;
|
|
178
179
|
"zh-Hant": z.ZodOptional<z.ZodString>;
|
|
179
180
|
}, z.core.$strip>;
|
|
181
|
+
type: z.ZodString;
|
|
180
182
|
description: z.ZodOptional<z.ZodObject<{
|
|
181
183
|
en: z.ZodString;
|
|
182
184
|
"zh-CN": z.ZodOptional<z.ZodString>;
|
|
@@ -275,8 +277,8 @@ declare const PluginListParamsSchema: z.ZodObject<{
|
|
|
275
277
|
tool: "tool";
|
|
276
278
|
}>>>>;
|
|
277
279
|
tags: z.ZodPipe<z.ZodTransform<any[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
278
|
-
search: "search";
|
|
279
280
|
tools: "tools";
|
|
281
|
+
search: "search";
|
|
280
282
|
multimodal: "multimodal";
|
|
281
283
|
communication: "communication";
|
|
282
284
|
finance: "finance";
|
|
@@ -386,12 +388,12 @@ declare const PluginDebugSessionStatusResponseDTOSchema: z$1.ZodObject<{
|
|
|
386
388
|
enabled: z$1.ZodBoolean;
|
|
387
389
|
keyId: z$1.ZodOptional<z$1.ZodString>;
|
|
388
390
|
plugins: z$1.ZodArray<z$1.ZodObject<{
|
|
389
|
-
type: z$1.ZodString;
|
|
390
391
|
name: z$1.ZodObject<{
|
|
391
392
|
en: z$1.ZodString;
|
|
392
393
|
"zh-CN": z$1.ZodOptional<z$1.ZodString>;
|
|
393
394
|
"zh-Hant": z$1.ZodOptional<z$1.ZodString>;
|
|
394
395
|
}, z$1.core.$strip>;
|
|
396
|
+
type: z$1.ZodString;
|
|
395
397
|
description: z$1.ZodOptional<z$1.ZodObject<{
|
|
396
398
|
en: z$1.ZodString;
|
|
397
399
|
"zh-CN": z$1.ZodOptional<z$1.ZodString>;
|
|
@@ -480,12 +482,12 @@ declare const ToolListItemDTOSchema: z.ZodObject<{
|
|
|
480
482
|
source: z.ZodUnion<[z.ZodLiteral<"system">, z.ZodString]>;
|
|
481
483
|
isToolset: z.ZodBoolean;
|
|
482
484
|
hasSecret: z.ZodBoolean;
|
|
483
|
-
type: z.ZodLiteral<"tool">;
|
|
484
485
|
name: z.ZodObject<{
|
|
485
486
|
en: z.ZodString;
|
|
486
487
|
"zh-CN": z.ZodOptional<z.ZodString>;
|
|
487
488
|
"zh-Hant": z.ZodOptional<z.ZodString>;
|
|
488
489
|
}, z.core.$strip>;
|
|
490
|
+
type: z.ZodLiteral<"tool">;
|
|
489
491
|
description: z.ZodObject<{
|
|
490
492
|
en: z.ZodString;
|
|
491
493
|
"zh-CN": z.ZodOptional<z.ZodString>;
|
|
@@ -500,8 +502,8 @@ declare const ToolListItemDTOSchema: z.ZodObject<{
|
|
|
500
502
|
tutorialUrl: z.ZodOptional<z.ZodURL>;
|
|
501
503
|
readmeUrl: z.ZodOptional<z.ZodURL>;
|
|
502
504
|
tags: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
503
|
-
search: "search";
|
|
504
505
|
tools: "tools";
|
|
506
|
+
search: "search";
|
|
505
507
|
multimodal: "multimodal";
|
|
506
508
|
communication: "communication";
|
|
507
509
|
finance: "finance";
|
|
@@ -534,12 +536,12 @@ declare const ToolListDTOSchema: z.ZodArray<z.ZodObject<{
|
|
|
534
536
|
source: z.ZodUnion<[z.ZodLiteral<"system">, z.ZodString]>;
|
|
535
537
|
isToolset: z.ZodBoolean;
|
|
536
538
|
hasSecret: z.ZodBoolean;
|
|
537
|
-
type: z.ZodLiteral<"tool">;
|
|
538
539
|
name: z.ZodObject<{
|
|
539
540
|
en: z.ZodString;
|
|
540
541
|
"zh-CN": z.ZodOptional<z.ZodString>;
|
|
541
542
|
"zh-Hant": z.ZodOptional<z.ZodString>;
|
|
542
543
|
}, z.core.$strip>;
|
|
544
|
+
type: z.ZodLiteral<"tool">;
|
|
543
545
|
description: z.ZodObject<{
|
|
544
546
|
en: z.ZodString;
|
|
545
547
|
"zh-CN": z.ZodOptional<z.ZodString>;
|
|
@@ -554,8 +556,8 @@ declare const ToolListDTOSchema: z.ZodArray<z.ZodObject<{
|
|
|
554
556
|
tutorialUrl: z.ZodOptional<z.ZodURL>;
|
|
555
557
|
readmeUrl: z.ZodOptional<z.ZodURL>;
|
|
556
558
|
tags: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
557
|
-
search: "search";
|
|
558
559
|
tools: "tools";
|
|
560
|
+
search: "search";
|
|
559
561
|
multimodal: "multimodal";
|
|
560
562
|
communication: "communication";
|
|
561
563
|
finance: "finance";
|
|
@@ -615,8 +617,8 @@ declare const ToolDetailDTOSchema: z.ZodObject<{
|
|
|
615
617
|
"zh-Hant": z.ZodOptional<z.ZodString>;
|
|
616
618
|
}, z.core.$strip>;
|
|
617
619
|
tags: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
618
|
-
search: "search";
|
|
619
620
|
tools: "tools";
|
|
621
|
+
search: "search";
|
|
620
622
|
multimodal: "multimodal";
|
|
621
623
|
communication: "communication";
|
|
622
624
|
finance: "finance";
|
|
@@ -651,8 +653,8 @@ declare const ToolGetParamsDTOSchema: z.ZodObject<{
|
|
|
651
653
|
type ToolGetParamsDTOType = z.infer<typeof ToolGetParamsDTOSchema>;
|
|
652
654
|
declare const ToolListParamsDTOSchema: z.ZodObject<{
|
|
653
655
|
tags: z.ZodPipe<z.ZodTransform<any[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
654
|
-
search: "search";
|
|
655
656
|
tools: "tools";
|
|
657
|
+
search: "search";
|
|
656
658
|
multimodal: "multimodal";
|
|
657
659
|
communication: "communication";
|
|
658
660
|
finance: "finance";
|
|
@@ -732,6 +734,8 @@ declare const LLMModelItemSchema: z$1.ZodObject<{
|
|
|
732
734
|
showStopSign: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
733
735
|
censor: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
734
736
|
vision: z$1.ZodBoolean;
|
|
737
|
+
audio: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
738
|
+
video: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
735
739
|
reasoning: z$1.ZodBoolean;
|
|
736
740
|
reasoningEffort: z$1.ZodBoolean;
|
|
737
741
|
toolChoice: z$1.ZodBoolean;
|
|
@@ -815,6 +819,8 @@ declare const ModelItemSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
|
|
|
815
819
|
showStopSign: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
816
820
|
censor: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
817
821
|
vision: z$1.ZodBoolean;
|
|
822
|
+
audio: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
823
|
+
video: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
818
824
|
reasoning: z$1.ZodBoolean;
|
|
819
825
|
reasoningEffort: z$1.ZodBoolean;
|
|
820
826
|
toolChoice: z$1.ZodBoolean;
|
|
@@ -923,8 +929,8 @@ declare const ToolSchema: z$1.ZodObject<{
|
|
|
923
929
|
"zh-Hant": z$1.ZodOptional<z$1.ZodString>;
|
|
924
930
|
}, z$1.core.$strip>;
|
|
925
931
|
tags: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
|
|
926
|
-
search: "search";
|
|
927
932
|
tools: "tools";
|
|
933
|
+
search: "search";
|
|
928
934
|
multimodal: "multimodal";
|
|
929
935
|
communication: "communication";
|
|
930
936
|
finance: "finance";
|
|
@@ -953,8 +959,8 @@ type ToolType = z$1.output<typeof ToolSchema>;
|
|
|
953
959
|
//#endregion
|
|
954
960
|
//#region ../../packages/domain/src/entities/plugin-base.entity.d.ts
|
|
955
961
|
declare const PluginTagSchema: z$1.ZodEnum<{
|
|
956
|
-
search: "search";
|
|
957
962
|
tools: "tools";
|
|
963
|
+
search: "search";
|
|
958
964
|
multimodal: "multimodal";
|
|
959
965
|
communication: "communication";
|
|
960
966
|
finance: "finance";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e,{z as t}from"zod";import{createHash as n}from"node:crypto";import r from"node:path";import{Readable as i}from"node:stream";var a=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,d=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),f=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=c(t),a=0,l=i.length,d;a<l;a++)d=i[a],!u.call(e,d)&&d!==n&&o(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=s(t,d))||r.enumerable});return e},p=(e,t,n)=>(n=e==null?{}:a(l(e)),f(t||!e||!e.__esModule?o(n,`default`,{value:e,enumerable:!0}):n,e));const m=e.enum([`en`,`zh-CN`,`zh-Hant`]).enum,h=e.object({[m.en]:e.string(),[m[`zh-CN`]]:e.string().optional(),[m[`zh-Hant`]]:e.string().optional()}),g=e.object({[m.en]:e.string(),[m[`zh-CN`]]:e.string(),[m[`zh-Hant`]]:e.string()}),_=t.object(h.shape),v=t.object(g.shape),y=t.object({code:t.string(),message:t.string(),reason:_,data:t.unknown().optional(),cause:t.unknown().optional()}),b=t.string(),x=t.enum([`tools`,`search`,`multimodal`,`communication`,`finance`,`design`,`productivity`,`news`,`entertainment`,`social`,`scientific`,`other`]),S=t.enum([`tool`]),C=e=>t.preprocess(e=>{if(e!=null)return Array.isArray(e)?e:[e]},t.array(e).optional()),w=t.object({pluginId:t.string(),version:t.string(),etag:t.string(),type:t.string(),author:t.string().optional(),name:_,icon:t.string(),tutorialUrl:t.url().optional(),readmeUrl:t.url().optional(),repoUrl:t.url().optional(),permission:t.array(t.string()).optional(),description:_.optional(),tags:t.array(t.string()).optional(),versionDescription:_.describe(`Plugin version description`).optional()}),ee=w.omit({versionDescription:!0,permission:!0}).extend({source:t.string()}),te=t.array(ee),ne=t.object({fileName:t.string().optional(),reason:_}),T=t.object({plugins:t.array(w),failed:t.array(ne).optional()}),E=t.object({files:t.array(t.file()).min(1)}),D=t.object({pluginId:t.string(),version:t.string(),etag:t.string()}),O=t.object({uniqueIds:t.array(D).min(1)}),re=t.object({count:t.number().int().nonnegative(),plugins:t.array(D)}),k=t.object({pluginId:t.string(),source:t.string(),version:t.string()}),A=t.object({url:t.string(),reason:_}),j={request:t.object({urls:t.array(t.string())}),response:t.object({failed:t.array(A).optional()})},M=t.object({types:C(S),tags:C(x),op:t.enum([`or`,`and`]).optional(),sources:C(b)}),ie=t.object({version:t.string(),versionDescription:_.optional()}),ae=t.array(ie),oe=t.object({pluginId:t.string(),source:t.string()}),se=t.array(t.object({id:t.string(),name:_})),ce=t.object({minPods:t.number().int().nonnegative(),maxPods:t.number().int().positive(),podTimeout:t.number().int().positive(),maxConcurrentRequestsPerPod:t.number().int().positive()}).strict().refine(e=>e.minPods<=e.maxPods,{message:`minPods cannot be greater than maxPods`,path:[`minPods`]}),N=t.object({pluginId:t.string()}),le=t.object({pluginId:t.string(),config:ce}),ue=t.object({pluginId:t.string()}),de=e.enum([`enabled`,`connected`,`disconnected`,`revoked`]),fe=e.object({tmbId:e.string().min(1)}),pe=e.object({tmbId:e.string().min(1),source:e.string().min(1),status:de,enabled:e.boolean(),keyId:e.string().min(1),connectionKey:e.string().min(1).optional(),createdAt:e.number().int().positive(),updatedAt:e.number().int().positive()}),me=e.object({connectionKey:e.string().min(1)}),he=e.object({gatewayUrl:e.string().min(1),transport:e.literal(`websocket`),source:e.string().min(1),connectToken:e.string().min(1),fastgptBaseUrl:e.string().min(1),expiresAt:e.number().int().positive()}),ge=e.object({tmbId:e.string().min(1)}),_e=e.object({tmbId:e.string().min(1),source:e.string().min(1),status:de,enabled:e.boolean(),keyId:e.string().min(1).optional(),plugins:e.array(ee),gateway:e.object({sessionId:e.string().min(1).optional(),ownerAlive:e.boolean(),mailboxLag:e.number().int().nonnegative()}).optional(),createdAt:e.number().int().positive().optional(),updatedAt:e.number().int().positive().optional(),refreshedAt:e.number().int().positive().optional(),revokedAt:e.number().int().positive().optional()}),ve=e.object({tmbId:e.string().min(1),reason:e.string().optional()}),ye=e.object({revoked:e.boolean()}),be=e.enum([`userInfo:read`,`teamInfo:read`,`model:read`,`dataset:read`,`file-upload:allow`]),xe=be.enum,Se=e.enum([`tools`,`search`,`multimodal`,`communication`,`finance`,`design`,`productivity`,`news`,`entertainment`,`social`,`scientific`,`other`]),P=Se.enum,Ce=e.enum([`tool`]),we=Ce.enum;e.enum([`active`,`pending`,`disabled`]).enum;const Te=e.object({pluginId:e.string(),version:e.string(),etag:e.string(),type:Ce,author:e.string().optional(),repoUrl:e.string().optional(),name:h,icon:e.string(),tutorialUrl:e.url().optional(),readmeUrl:e.url().optional(),description:h,tags:e.array(Se).optional(),versionDescription:h.optional(),permission:e.array(be).optional()}),Ee=e.object({id:e.string(),name:h,description:h.optional(),icon:e.string(),toolDescription:e.string(),inputSchema:e.any(),outputSchema:e.any()}),De=e.object({...Te.shape,type:e.literal(we.tool),toolDescription:e.string(),inputSchema:e.any().optional(),outputSchema:e.any().optional(),secretSchema:e.any().optional(),children:e.array(Ee).optional()});e.object({...Te.shape,type:e.literal(we.tool),meta:e.object({secretSchema:e.any().optional(),toolDescription:e.string()})}),e.object({pluginId:e.string(),version:e.string(),etag:e.string()});const Oe=e.literal(`system`).or(e.string()),ke=e.object({id:e.string(),name:g});e.array(ke),e.enum([`localPool`,`serverless`]).enum;const Ae=e.object({pluginId:e.string(),version:e.string().optional(),source:Oe.optional()}),je=e.object({id:Ee.shape.id,name:Ee.shape.name,description:Ee.shape.description,toolDescription:Ee.shape.toolDescription}),Me=e.object({...De.omit({inputSchema:!0,outputSchema:!0,secretSchema:!0,children:!0,versionDescription:!0,permission:!0}).shape,source:Oe,isToolset:e.boolean(),hasSecret:e.boolean(),children:e.array(je).optional()}),Ne=e.object({...De.shape,source:Oe,isLatestVersion:e.boolean(),isToolset:e.boolean()});Ae.extend({fallbackLatestVersion:e.boolean().optional()});const Pe=e.object({app:e.object({id:e.string(),name:e.string()}),chat:e.object({chatId:e.string(),uid:e.string().optional()}),invokeToken:e.string(),time:e.string()}),Fe=t.string(),Ie=t.enum([`tools`,`search`,`multimodal`,`communication`,`finance`,`design`,`productivity`,`news`,`entertainment`,`social`,`scientific`,`other`]),Le=e=>t.preprocess(e=>{if(e!=null)return Array.isArray(e)?e:[e]},t.array(e).optional()),Re=e=>t.preprocess(e=>typeof e==`boolean`||typeof e!=`string`?e:e===`true`?!0:e===`false`?!1:e,e),ze=t.object({...Pe.shape}),Be=t.object({pluginId:t.string(),version:t.string().optional(),source:t.string().optional(),secrets:t.record(t.string(),t.any()).optional(),systemVar:ze,input:t.record(t.string(),t.unknown()),childId:t.string().optional()}),Ve=t.object({...je.shape}),He=t.object({...Me.shape,children:t.array(Ve).optional()}),Ue=t.array(He),We=t.object({...Ne.shape}),Ge=t.object({pluginId:t.string(),version:t.string().optional(),source:Fe.optional().default(`system`),fallbackLatestVersion:Re(t.boolean().optional())}),Ke=t.object({tags:Le(Ie),op:t.enum([`or`,`and`]).optional(),sources:Le(Fe)}),F=e=>e,qe=()=>void 0,Je=({data:t,error:n})=>e.object({...t&&{data:t},...n&&{error:n}}),I=({data:e,error:t}={})=>Je({data:e,error:t}),Ye=e.enum([`llm`,`embedding`,`rerank`,`tts`,`stt`]).enum,Xe=e.object({charsPointsPrice:e.number().optional(),inputPrice:e.number().optional(),outputPrice:e.number().optional()}),Ze=e.object({provider:e.string(),model:e.string(),name:e.string()}),Qe=e.object({...Xe.shape,...Ze.shape,type:e.literal(Ye.llm),maxContext:e.number(),maxTokens:e.number(),quoteMaxToken:e.number(),maxTemperature:e.union([e.number(),e.null()]),showTopP:e.boolean().optional(),responseFormatList:e.array(e.string()).optional(),showStopSign:e.boolean().optional(),censor:e.boolean().optional(),vision:e.boolean(),reasoning:e.boolean(),reasoningEffort:e.boolean(),toolChoice:e.boolean(),datasetProcess:e.boolean().optional(),usedInClassify:e.boolean().optional(),usedInExtractFields:e.boolean().optional(),usedInToolCall:e.boolean().optional(),useInEvaluation:e.boolean().optional(),defaultSystemChatPrompt:e.string().optional(),defaultConfig:e.record(e.string(),e.any()).optional(),fieldMap:e.record(e.string(),e.string()).optional()}),$e=e.object({...Xe.shape,...Ze.shape,type:e.literal(Ye.embedding),defaultToken:e.number(),maxToken:e.number(),weight:e.number().optional(),hidden:e.boolean().optional(),normalization:e.boolean().optional(),defaultConfig:e.record(e.string(),e.any()).optional(),dbConfig:e.record(e.string(),e.any()).optional(),queryConfig:e.record(e.string(),e.any()).optional()}),et=e.object({...Xe.shape,...Ze.shape,type:e.literal(Ye.rerank),maxToken:e.number()}),tt=e.object({...Xe.shape,...Ze.shape,type:e.literal(Ye.tts),voices:e.array(e.object({label:e.string(),value:e.string()}))}),nt=e.object({...Xe.shape,...Ze.shape,type:e.literal(Ye.stt)}),rt=e.discriminatedUnion(`type`,[Qe,$e,et,tt,nt]);e.object({id:e.string(),name:g,avatar:e.string()});const it=t.array(rt),at=t.object({provider:t.string(),value:v,avatar:t.string()}),ot=t.object({channelId:t.number(),name:v,avatar:t.string()}),st=t.object({modelProviders:t.array(at),aiproxyChannels:t.array(ot)}),L=[{bearerAuth:[]}],ct={List:F({meta:{method:`get`,path:`/models`,operationId:`model.list`,description:`Get a list of all available AI models`,summary:`List models`,tags:[`model`],security:L},response:{200:I({data:it}),500:I({error:y})}}),GetProviders:F({meta:{method:`get`,path:`/models/get-providers`,operationId:`model.getProviders`,description:`Get all available model providers with their avatars`,summary:`Get model providers`,tags:[`model`],security:L},response:{200:I({data:st}),500:I({error:y})}})},lt={method:`post`,path:`/plugin/upload`,operationId:`plugin.upload`,description:`Upload plugin .pkg files or .zip package collection files and get parsed plugin info`,summary:`Upload plugin packages`,tags:[`plugin`],security:L},ut={200:I({data:T}),400:I({error:y})},R={Upload:F({meta:lt,request:E,response:ut,openapi:{...lt,request:{body:{content:{"multipart/form-data":{schema:t.object({files:t.any()})}}}},responses:{200:{description:`HTTP 200 response`,content:{"application/json":{schema:ut[200]}}},400:{description:`HTTP 400 response`,content:{"application/json":{schema:ut[400]}}}}}}),Confirm:F({meta:{method:`post`,path:`/plugin/confirm`,operationId:`plugin.confirm`,description:`Confirm the uploaded plugin`,summary:`Confirm a plugin`,tags:[`plugin`],security:L},request:O,response:{200:qe(),500:I({error:y})}}),PruneDisabled:F({meta:{method:`post`,path:`/plugin/prune-disabled`,operationId:`plugin.pruneDisabled`,description:`Delete all disabled plugin data from Mongo and storage`,summary:`Prune disabled plugins`,tags:[`plugin`],security:L},response:{200:I({data:re}),500:I({error:y})}}),Delete:F({meta:{method:`post`,path:`/plugin/delete`,operationId:`plugin.delete`,description:`Disable an installed plugin by source, plugin id, and version`,summary:`Delete a plugin`,tags:[`plugin`],security:L},request:k,response:{200:qe(),500:I({error:y})}}),Install:F({meta:{method:`post`,path:`/plugin/install`,operationId:`plugin.install`,description:`Install a plugin`,summary:`Install a plugin`,tags:[`plugin`],security:L},request:j.request,response:{200:I({data:j.response}),500:I({error:y})}}),List:F({meta:{method:`get`,path:`/plugins`,operationId:`plugin.list`,description:`List plugins with optional filters`,summary:`List plugins`,tags:[`plugin`],security:L},request:M,response:{200:I({data:te}),500:I({error:y})}}),Versions:F({meta:{method:`get`,path:`/plugin/versions`,operationId:`plugin.versions`,description:`List all versions of a plugin under the given source`,summary:`List plugin versions`,tags:[`plugin`],security:L},request:oe,response:{200:I({data:ae}),500:I({error:y})}}),TagList:F({meta:{method:`get`,path:`/plugin/tags`,operationId:`plugin.tags`,description:`List plugin tags`,summary:`List plugin tags`,tags:[`plugin`],security:L},response:{200:I({data:se}),500:I({error:y})}}),RuntimeConfigGet:F({meta:{method:`post`,path:`/plugin/runtime-config/get`,operationId:`plugin.runtimeConfig.get`,description:`Get plugin runtime config`,summary:`Get plugin runtime config`,tags:[`plugin`],security:L},request:N,response:{200:I({data:ce}),500:I({error:y})}}),RuntimeConfigSet:F({meta:{method:`post`,path:`/plugin/runtime-config/set`,operationId:`plugin.runtimeConfig.set`,description:`Set plugin runtime config`,summary:`Set plugin runtime config`,tags:[`plugin`],security:L},request:le,response:{200:qe(),500:I({error:y})}}),RuntimeConfigReset:F({meta:{method:`post`,path:`/plugin/runtime-config/reset`,operationId:`plugin.runtimeConfig.reset`,description:`Reset plugin runtime config`,summary:`Reset plugin runtime config`,tags:[`plugin`],security:L},request:ue,response:{200:qe(),500:I({error:y})}})},dt=[`plugin`],z={Create:F({meta:{method:`post`,path:`/plugin/debug-sessions`,operationId:`pluginDebugSession.create`,description:`Enable a tmbId-scoped plugin debug channel`,summary:`Enable debug channel`,tags:dt,security:L},request:fe,response:{200:I({data:pe}),400:I({error:y})}}),RefreshKey:F({meta:{method:`post`,path:`/plugin/debug-sessions/key:refresh`,operationId:`pluginDebugSession.refreshKey`,description:`Refresh a tmbId-scoped plugin debug channel connection key`,summary:`Refresh debug connection key`,tags:dt,security:L},request:fe,response:{200:I({data:pe}),400:I({error:y})}}),ExchangeConnectionKey:F({meta:{method:`post`,path:`/plugin/debug-sessions/connection-key:exchange`,operationId:`pluginDebugSession.exchangeConnectionKey`,description:`Exchange a reusable debug connection key for scoped gateway connection info`,summary:`Exchange debug connection key`,tags:dt,security:L},request:me,response:{200:I({data:he}),400:I({error:y}),404:I({error:y})}}),Status:F({meta:{method:`get`,path:`/plugin/debug-sessions/:tmbId`,operationId:`pluginDebugSession.status`,description:`Get a plugin debug channel status and mounted debug plugins`,summary:`Get debug channel status`,tags:dt,security:L},response:{200:I({data:_e}),400:I({error:y}),404:I({error:y})}}),Revoke:F({meta:{method:`post`,path:`/plugin/debug-sessions/:tmbId/revoke`,operationId:`pluginDebugSession.revoke`,description:`Close the current plugin debug session without rotating its connection key`,summary:`Close debug session`,tags:dt,security:L},request:ve,response:{200:I({data:ye}),400:I({error:y}),404:I({error:y})}})},ft=e.object({remoteDebug:e.boolean()}),pt={Get:F({meta:{method:`get`,path:`/plugin/features`,operationId:`plugin.features`,description:`Get enabled Plugin service features`,summary:`Get Plugin service features`,tags:[`plugin`],security:L},response:{200:I({data:ft}),500:I({error:y})}})},mt={Get:F({meta:{method:`get`,path:`/tool`,operationId:`tool.get`,description:`Get a tool by pluginId, version and source`,summary:`Get tool detail`,tags:[`plugin`,`tool`],security:L},request:Ge,response:{200:I({data:We}),404:I({error:y})}}),List:F({meta:{method:`get`,path:`/tools`,operationId:`tool.list`,description:`List tools with optional filters`,summary:`List tools`,tags:[`plugin`,`tool`],security:L},request:Ke,response:{200:I({data:Ue}),500:I({error:y})}}),RunStream:F({meta:{method:`post`,path:`/tool/runStream`,operationId:`tool.runStream`,description:`Run a tool and return stream messages`,summary:`Run tool stream`,tags:[`plugin`,`tool`],security:L},request:Be,response:{200:e.object({type:e.string()}),400:I({error:y})}})};mt.RunStream;const ht=t.object({templateId:t.string().describe(`The unique id of the template`),name:t.string().describe(`The name of the template`),intro:t.string().describe(`The introduction of the template`),avatar:t.string().describe(`The icon of the template`),tags:t.array(t.string()).describe(`The tags of the template`),type:t.string().describe(`The type of the template`),author:t.string().optional().describe(`The author of the template`),isActive:t.boolean().optional().describe(`Whether it is active`),userGuide:t.union([t.string(),t.object({type:t.string(),content:t.string()})]).optional().describe(`The user guide of the template`),isQuickTemplate:t.boolean().optional().describe(`Whether it is a quick template`),order:t.number().optional().describe(`The order of the template`),weight:t.number().optional().describe(`The weight of the template`),workflow:t.object({nodes:t.array(t.any()).describe(`The nodes of the template`),edges:t.array(t.any()).describe(`The edges of the template`),chatConfig:t.any().optional().describe(`The chat config of the template`)})});t.array(ht);const gt=t.object(ht.shape),_t=t.array(gt),vt={List:F({meta:{method:`get`,path:`/list`,operationId:`workflow.list`,description:`Get a list of all available workflow templates`,summary:`List workflow templates`,tags:[`workflow`],security:L},response:{200:I({data:_t}),500:I({error:y})}})},yt=e.record(e.string(),e.unknown()),bt=e.enum([`response`,`error`,`stream`]).enum,xt=e.enum([`answer`,`fastAnswer`]);xt.enum;const St=e.object({type:xt,content:e.string()}),Ct=e.discriminatedUnion(`type`,[e.object({type:e.literal(bt.response),data:yt}),e.object({type:e.literal(bt.stream),data:St}),e.object({type:e.literal(bt.error),data:e.string()})]);e.object({pluginId:e.string(),version:e.preprocess(e=>{if(e!==``)return e},e.string().optional()),source:Oe.optional(),childId:e.string().optional(),input:e.record(e.string(),e.unknown()),secrets:e.record(e.string(),e.unknown()).optional(),systemVar:Pe});var wt=class{baseUrl;token;fetchImpl;constructor({baseUrl:e,token:t,fetch:n}){this.baseUrl=e.endsWith(`/`)?e.slice(0,-1):e,this.token=t;let r=n??globalThis.fetch;if(!r)throw Error(`Global fetch is not available. Please provide fetch in client options.`);this.fetchImpl=r.bind(globalThis)}async requestData({path:e,...t}){let n=await this.requestResponse({path:e,...t}),r=await this.readBody(n);return r&&typeof r==`object`&&`data`in r?r.data:r}async requestEmpty({path:e,...t}){await(await this.requestResponse({path:e,...t})).text().catch(()=>void 0)}async requestResponse({path:e,method:t=`GET`,headers:n,query:r,body:i,signal:a}){let o=this.buildUrl(e,r),s=new Headers(n);this.token&&s.set(`Authorization`,`Bearer ${this.token}`);let c=this.normalizeBody(i,s),l=await this.fetchImpl(o,{method:t.toUpperCase(),headers:s,body:c,signal:a});if(!l.ok)throw await this.buildError(l);return l}buildUrl(e,t){let n=new URL(e,`${this.baseUrl}/`);if(t){for(let[e,r]of Object.entries(t))if(r!=null){if(Array.isArray(r)){for(let t of r)n.searchParams.append(e,String(t));continue}n.searchParams.append(e,String(r))}}return n.toString()}normalizeBody(e,t){if(e!=null)return this.isNativeBodyInit(e)?e:(t.has(`Content-Type`)||t.set(`Content-Type`,`application/json`),JSON.stringify(e))}isNativeBodyInit(e){return typeof e==`string`||typeof Blob<`u`&&e instanceof Blob||typeof FormData<`u`&&e instanceof FormData||typeof URLSearchParams<`u`&&e instanceof URLSearchParams||typeof ReadableStream<`u`&&e instanceof ReadableStream||e instanceof ArrayBuffer||ArrayBuffer.isView(e)}async readBody(e){let t=await e.text();if(t)try{return JSON.parse(t)}catch{return t}}async buildError(e){let t=await this.readBody(e).catch(()=>void 0),n=this.extractErrorMessage(t)??`${e.status} ${e.statusText||`Request failed`}`;return Error(n)}extractErrorMessage(e){if(!e)return;if(typeof e==`string`)return e;if(typeof e!=`object`)return String(e);if(`error`in e)return this.extractErrorMessage(e.error);if(`msg`in e)return this.extractErrorMessage(e.msg);if(`message`in e)return this.extractErrorMessage(e.message);let t=e;if(typeof t[`zh-CN`]==`string`)return t[`zh-CN`];if(typeof t.en==`string`)return t.en;if(typeof t[`zh-Hant`]==`string`)return t[`zh-Hant`];try{return JSON.stringify(e)}catch{return}}},Tt=class{transport;constructor(e){this.transport=new wt(e)}async run(e,t){try{let n=Be.parse(e),r=await this.transport.requestResponse({path:`/api${mt.RunStream.meta.path}`,method:mt.RunStream.meta.method,body:n,headers:{Accept:`text/event-stream`},signal:t?.signal});if(!r.body)throw Error(`Tool stream response body is empty`);let i=r.body.getReader(),a=new TextDecoder,o=``,s,c;for(;;){let{value:t,done:n}=await i.read();o+=a.decode(t,{stream:!n});let r=o.split(`
|
|
1
|
+
import e,{z as t}from"zod";import{createHash as n}from"node:crypto";import r from"node:path";import{Readable as i}from"node:stream";var a=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,d=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),f=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=c(t),a=0,l=i.length,d;a<l;a++)d=i[a],!u.call(e,d)&&d!==n&&o(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=s(t,d))||r.enumerable});return e},p=(e,t,n)=>(n=e==null?{}:a(l(e)),f(t||!e||!e.__esModule?o(n,`default`,{value:e,enumerable:!0}):n,e));const m=e.enum([`en`,`zh-CN`,`zh-Hant`]).enum,h=e.object({[m.en]:e.string(),[m[`zh-CN`]]:e.string().optional(),[m[`zh-Hant`]]:e.string().optional()}),g=e.object({[m.en]:e.string(),[m[`zh-CN`]]:e.string(),[m[`zh-Hant`]]:e.string()}),_=t.object(h.shape),v=t.object(g.shape),y=t.object({code:t.string(),message:t.string(),reason:_,data:t.unknown().optional(),cause:t.unknown().optional()}),b=t.string(),x=t.enum([`tools`,`search`,`multimodal`,`communication`,`finance`,`design`,`productivity`,`news`,`entertainment`,`social`,`scientific`,`other`]),S=t.enum([`tool`]),C=e=>t.preprocess(e=>{if(e!=null)return Array.isArray(e)?e:[e]},t.array(e).optional()),w=t.object({pluginId:t.string(),version:t.string(),etag:t.string(),type:t.string(),author:t.string().optional(),name:_,icon:t.string(),tutorialUrl:t.url().optional(),readmeUrl:t.url().optional(),repoUrl:t.url().optional(),permission:t.array(t.string()).optional(),description:_.optional(),tags:t.array(t.string()).optional(),versionDescription:_.describe(`Plugin version description`).optional()}),ee=w.omit({versionDescription:!0,permission:!0}).extend({source:t.string()}),te=t.array(ee),ne=t.object({fileName:t.string().optional(),reason:_}),T=t.object({plugins:t.array(w),failed:t.array(ne).optional()}),E=t.object({files:t.array(t.file()).min(1)}),D=t.object({pluginId:t.string(),version:t.string(),etag:t.string()}),O=t.object({uniqueIds:t.array(D).min(1)}),re=t.object({count:t.number().int().nonnegative(),plugins:t.array(D)}),k=t.object({pluginId:t.string(),source:t.string(),version:t.string()}),A=t.object({url:t.string(),reason:_}),j={request:t.object({urls:t.array(t.string())}),response:t.object({failed:t.array(A).optional()})},M=t.object({types:C(S),tags:C(x),op:t.enum([`or`,`and`]).optional(),sources:C(b)}),ie=t.object({version:t.string(),versionDescription:_.optional()}),ae=t.array(ie),oe=t.object({pluginId:t.string(),source:t.string()}),se=t.array(t.object({id:t.string(),name:_})),ce=t.object({minPods:t.number().int().nonnegative(),maxPods:t.number().int().positive(),podTimeout:t.number().int().positive(),maxConcurrentRequestsPerPod:t.number().int().positive()}).strict().refine(e=>e.minPods<=e.maxPods,{message:`minPods cannot be greater than maxPods`,path:[`minPods`]}),N=t.object({pluginId:t.string()}),le=t.object({pluginId:t.string(),config:ce}),ue=t.object({pluginId:t.string()}),de=e.enum([`enabled`,`connected`,`disconnected`,`revoked`]),fe=e.object({tmbId:e.string().min(1)}),pe=e.object({tmbId:e.string().min(1),source:e.string().min(1),status:de,enabled:e.boolean(),keyId:e.string().min(1),connectionKey:e.string().min(1).optional(),createdAt:e.number().int().positive(),updatedAt:e.number().int().positive()}),me=e.object({connectionKey:e.string().min(1)}),he=e.object({gatewayUrl:e.string().min(1),transport:e.literal(`websocket`),source:e.string().min(1),connectToken:e.string().min(1),fastgptBaseUrl:e.string().min(1),expiresAt:e.number().int().positive()}),ge=e.object({tmbId:e.string().min(1)}),_e=e.object({tmbId:e.string().min(1),source:e.string().min(1),status:de,enabled:e.boolean(),keyId:e.string().min(1).optional(),plugins:e.array(ee),gateway:e.object({sessionId:e.string().min(1).optional(),ownerAlive:e.boolean(),mailboxLag:e.number().int().nonnegative()}).optional(),createdAt:e.number().int().positive().optional(),updatedAt:e.number().int().positive().optional(),refreshedAt:e.number().int().positive().optional(),revokedAt:e.number().int().positive().optional()}),ve=e.object({tmbId:e.string().min(1),reason:e.string().optional()}),ye=e.object({revoked:e.boolean()}),be=e.enum([`userInfo:read`,`teamInfo:read`,`model:read`,`dataset:read`,`file-upload:allow`]),xe=be.enum,Se=e.enum([`tools`,`search`,`multimodal`,`communication`,`finance`,`design`,`productivity`,`news`,`entertainment`,`social`,`scientific`,`other`]),P=Se.enum,Ce=e.enum([`tool`]),we=Ce.enum;e.enum([`active`,`pending`,`disabled`]).enum;const Te=e.object({pluginId:e.string(),version:e.string(),etag:e.string(),type:Ce,author:e.string().optional(),repoUrl:e.string().optional(),name:h,icon:e.string(),tutorialUrl:e.url().optional(),readmeUrl:e.url().optional(),description:h,tags:e.array(Se).optional(),versionDescription:h.optional(),permission:e.array(be).optional()}),Ee=e.object({id:e.string(),name:h,description:h.optional(),icon:e.string(),toolDescription:e.string(),inputSchema:e.any(),outputSchema:e.any()}),De=e.object({...Te.shape,type:e.literal(we.tool),toolDescription:e.string(),inputSchema:e.any().optional(),outputSchema:e.any().optional(),secretSchema:e.any().optional(),children:e.array(Ee).optional()});e.object({...Te.shape,type:e.literal(we.tool),meta:e.object({secretSchema:e.any().optional(),toolDescription:e.string()})}),e.object({pluginId:e.string(),version:e.string(),etag:e.string()});const Oe=e.literal(`system`).or(e.string()),ke=e.object({id:e.string(),name:g});e.array(ke),e.enum([`localPool`,`serverless`]).enum;const Ae=e.object({pluginId:e.string(),version:e.string().optional(),source:Oe.optional()}),je=e.object({id:Ee.shape.id,name:Ee.shape.name,description:Ee.shape.description,toolDescription:Ee.shape.toolDescription}),Me=e.object({...De.omit({inputSchema:!0,outputSchema:!0,secretSchema:!0,children:!0,versionDescription:!0,permission:!0}).shape,source:Oe,isToolset:e.boolean(),hasSecret:e.boolean(),children:e.array(je).optional()}),Ne=e.object({...De.shape,source:Oe,isLatestVersion:e.boolean(),isToolset:e.boolean()});Ae.extend({fallbackLatestVersion:e.boolean().optional()});const Pe=e.object({app:e.object({id:e.string(),name:e.string()}),chat:e.object({chatId:e.string(),uid:e.string().optional()}),invokeToken:e.string(),time:e.string()}),Fe=t.string(),Ie=t.enum([`tools`,`search`,`multimodal`,`communication`,`finance`,`design`,`productivity`,`news`,`entertainment`,`social`,`scientific`,`other`]),Le=e=>t.preprocess(e=>{if(e!=null)return Array.isArray(e)?e:[e]},t.array(e).optional()),Re=e=>t.preprocess(e=>typeof e==`boolean`||typeof e!=`string`?e:e===`true`?!0:e===`false`?!1:e,e),ze=t.object({...Pe.shape}),Be=t.object({pluginId:t.string(),version:t.string().optional(),source:t.string().optional(),secrets:t.record(t.string(),t.any()).optional(),systemVar:ze,input:t.record(t.string(),t.unknown()),childId:t.string().optional()}),Ve=t.object({...je.shape}),He=t.object({...Me.shape,children:t.array(Ve).optional()}),Ue=t.array(He),We=t.object({...Ne.shape}),Ge=t.object({pluginId:t.string(),version:t.string().optional(),source:Fe.optional().default(`system`),fallbackLatestVersion:Re(t.boolean().optional())}),Ke=t.object({tags:Le(Ie),op:t.enum([`or`,`and`]).optional(),sources:Le(Fe)}),F=e=>e,qe=()=>void 0,Je=({data:t,error:n})=>e.object({...t&&{data:t},...n&&{error:n}}),I=({data:e,error:t}={})=>Je({data:e,error:t}),Ye=e.enum([`llm`,`embedding`,`rerank`,`tts`,`stt`]).enum,Xe=e.object({charsPointsPrice:e.number().optional(),inputPrice:e.number().optional(),outputPrice:e.number().optional()}),Ze=e.object({provider:e.string(),model:e.string(),name:e.string()}),Qe=e.object({...Xe.shape,...Ze.shape,type:e.literal(Ye.llm),maxContext:e.number(),maxTokens:e.number(),quoteMaxToken:e.number(),maxTemperature:e.union([e.number(),e.null()]),showTopP:e.boolean().optional(),responseFormatList:e.array(e.string()).optional(),showStopSign:e.boolean().optional(),censor:e.boolean().optional(),vision:e.boolean(),audio:e.boolean().optional(),video:e.boolean().optional(),reasoning:e.boolean(),reasoningEffort:e.boolean(),toolChoice:e.boolean(),datasetProcess:e.boolean().optional(),usedInClassify:e.boolean().optional(),usedInExtractFields:e.boolean().optional(),usedInToolCall:e.boolean().optional(),useInEvaluation:e.boolean().optional(),defaultSystemChatPrompt:e.string().optional(),defaultConfig:e.record(e.string(),e.any()).optional(),fieldMap:e.record(e.string(),e.string()).optional()}),$e=e.object({...Xe.shape,...Ze.shape,type:e.literal(Ye.embedding),defaultToken:e.number(),maxToken:e.number(),weight:e.number().optional(),hidden:e.boolean().optional(),normalization:e.boolean().optional(),defaultConfig:e.record(e.string(),e.any()).optional(),dbConfig:e.record(e.string(),e.any()).optional(),queryConfig:e.record(e.string(),e.any()).optional()}),et=e.object({...Xe.shape,...Ze.shape,type:e.literal(Ye.rerank),maxToken:e.number()}),tt=e.object({...Xe.shape,...Ze.shape,type:e.literal(Ye.tts),voices:e.array(e.object({label:e.string(),value:e.string()}))}),nt=e.object({...Xe.shape,...Ze.shape,type:e.literal(Ye.stt)}),rt=e.discriminatedUnion(`type`,[Qe,$e,et,tt,nt]);e.object({id:e.string(),name:g,avatar:e.string()});const it=t.array(rt),at=t.object({provider:t.string(),value:v,avatar:t.string()}),ot=t.object({channelId:t.number(),name:v,avatar:t.string()}),st=t.object({modelProviders:t.array(at),aiproxyChannels:t.array(ot)}),L=[{bearerAuth:[]}],ct={List:F({meta:{method:`get`,path:`/models`,operationId:`model.list`,description:`Get a list of all available AI models`,summary:`List models`,tags:[`model`],security:L},response:{200:I({data:it}),500:I({error:y})}}),GetProviders:F({meta:{method:`get`,path:`/models/get-providers`,operationId:`model.getProviders`,description:`Get all available model providers with their avatars`,summary:`Get model providers`,tags:[`model`],security:L},response:{200:I({data:st}),500:I({error:y})}})},lt={method:`post`,path:`/plugin/upload`,operationId:`plugin.upload`,description:`Upload plugin .pkg files or .zip package collection files and get parsed plugin info`,summary:`Upload plugin packages`,tags:[`plugin`],security:L},ut={200:I({data:T}),400:I({error:y})},R={Upload:F({meta:lt,request:E,response:ut,openapi:{...lt,request:{body:{content:{"multipart/form-data":{schema:t.object({files:t.any()})}}}},responses:{200:{description:`HTTP 200 response`,content:{"application/json":{schema:ut[200]}}},400:{description:`HTTP 400 response`,content:{"application/json":{schema:ut[400]}}}}}}),Confirm:F({meta:{method:`post`,path:`/plugin/confirm`,operationId:`plugin.confirm`,description:`Confirm the uploaded plugin`,summary:`Confirm a plugin`,tags:[`plugin`],security:L},request:O,response:{200:qe(),500:I({error:y})}}),PruneDisabled:F({meta:{method:`post`,path:`/plugin/prune-disabled`,operationId:`plugin.pruneDisabled`,description:`Delete all disabled plugin data from Mongo and storage`,summary:`Prune disabled plugins`,tags:[`plugin`],security:L},response:{200:I({data:re}),500:I({error:y})}}),Delete:F({meta:{method:`post`,path:`/plugin/delete`,operationId:`plugin.delete`,description:`Disable an installed plugin by source, plugin id, and version`,summary:`Delete a plugin`,tags:[`plugin`],security:L},request:k,response:{200:qe(),500:I({error:y})}}),Install:F({meta:{method:`post`,path:`/plugin/install`,operationId:`plugin.install`,description:`Install a plugin`,summary:`Install a plugin`,tags:[`plugin`],security:L},request:j.request,response:{200:I({data:j.response}),500:I({error:y})}}),List:F({meta:{method:`get`,path:`/plugins`,operationId:`plugin.list`,description:`List plugins with optional filters`,summary:`List plugins`,tags:[`plugin`],security:L},request:M,response:{200:I({data:te}),500:I({error:y})}}),Versions:F({meta:{method:`get`,path:`/plugin/versions`,operationId:`plugin.versions`,description:`List all versions of a plugin under the given source`,summary:`List plugin versions`,tags:[`plugin`],security:L},request:oe,response:{200:I({data:ae}),500:I({error:y})}}),TagList:F({meta:{method:`get`,path:`/plugin/tags`,operationId:`plugin.tags`,description:`List plugin tags`,summary:`List plugin tags`,tags:[`plugin`],security:L},response:{200:I({data:se}),500:I({error:y})}}),RuntimeConfigGet:F({meta:{method:`post`,path:`/plugin/runtime-config/get`,operationId:`plugin.runtimeConfig.get`,description:`Get plugin runtime config`,summary:`Get plugin runtime config`,tags:[`plugin`],security:L},request:N,response:{200:I({data:ce}),500:I({error:y})}}),RuntimeConfigSet:F({meta:{method:`post`,path:`/plugin/runtime-config/set`,operationId:`plugin.runtimeConfig.set`,description:`Set plugin runtime config`,summary:`Set plugin runtime config`,tags:[`plugin`],security:L},request:le,response:{200:qe(),500:I({error:y})}}),RuntimeConfigReset:F({meta:{method:`post`,path:`/plugin/runtime-config/reset`,operationId:`plugin.runtimeConfig.reset`,description:`Reset plugin runtime config`,summary:`Reset plugin runtime config`,tags:[`plugin`],security:L},request:ue,response:{200:qe(),500:I({error:y})}})},dt=[`plugin`],z={Create:F({meta:{method:`post`,path:`/plugin/debug-sessions`,operationId:`pluginDebugSession.create`,description:`Enable a tmbId-scoped plugin debug channel`,summary:`Enable debug channel`,tags:dt,security:L},request:fe,response:{200:I({data:pe}),400:I({error:y})}}),RefreshKey:F({meta:{method:`post`,path:`/plugin/debug-sessions/key:refresh`,operationId:`pluginDebugSession.refreshKey`,description:`Refresh a tmbId-scoped plugin debug channel connection key`,summary:`Refresh debug connection key`,tags:dt,security:L},request:fe,response:{200:I({data:pe}),400:I({error:y})}}),ExchangeConnectionKey:F({meta:{method:`post`,path:`/plugin/debug-sessions/connection-key:exchange`,operationId:`pluginDebugSession.exchangeConnectionKey`,description:`Exchange a reusable debug connection key for scoped gateway connection info`,summary:`Exchange debug connection key`,tags:dt,security:L},request:me,response:{200:I({data:he}),400:I({error:y}),404:I({error:y})}}),Status:F({meta:{method:`get`,path:`/plugin/debug-sessions/:tmbId`,operationId:`pluginDebugSession.status`,description:`Get a plugin debug channel status and mounted debug plugins`,summary:`Get debug channel status`,tags:dt,security:L},response:{200:I({data:_e}),400:I({error:y}),404:I({error:y})}}),Revoke:F({meta:{method:`post`,path:`/plugin/debug-sessions/:tmbId/revoke`,operationId:`pluginDebugSession.revoke`,description:`Close the current plugin debug session without rotating its connection key`,summary:`Close debug session`,tags:dt,security:L},request:ve,response:{200:I({data:ye}),400:I({error:y}),404:I({error:y})}})},ft=e.object({remoteDebug:e.boolean()}),pt={Get:F({meta:{method:`get`,path:`/plugin/features`,operationId:`plugin.features`,description:`Get enabled Plugin service features`,summary:`Get Plugin service features`,tags:[`plugin`],security:L},response:{200:I({data:ft}),500:I({error:y})}})},mt={Get:F({meta:{method:`get`,path:`/tool`,operationId:`tool.get`,description:`Get a tool by pluginId, version and source`,summary:`Get tool detail`,tags:[`plugin`,`tool`],security:L},request:Ge,response:{200:I({data:We}),404:I({error:y})}}),List:F({meta:{method:`get`,path:`/tools`,operationId:`tool.list`,description:`List tools with optional filters`,summary:`List tools`,tags:[`plugin`,`tool`],security:L},request:Ke,response:{200:I({data:Ue}),500:I({error:y})}}),RunStream:F({meta:{method:`post`,path:`/tool/runStream`,operationId:`tool.runStream`,description:`Run a tool and return stream messages`,summary:`Run tool stream`,tags:[`plugin`,`tool`],security:L},request:Be,response:{200:e.object({type:e.string()}),400:I({error:y})}})};mt.RunStream;const ht=t.object({templateId:t.string().describe(`The unique id of the template`),name:t.string().describe(`The name of the template`),intro:t.string().describe(`The introduction of the template`),avatar:t.string().describe(`The icon of the template`),tags:t.array(t.string()).describe(`The tags of the template`),type:t.string().describe(`The type of the template`),author:t.string().optional().describe(`The author of the template`),isActive:t.boolean().optional().describe(`Whether it is active`),userGuide:t.union([t.string(),t.object({type:t.string(),content:t.string()})]).optional().describe(`The user guide of the template`),isQuickTemplate:t.boolean().optional().describe(`Whether it is a quick template`),order:t.number().optional().describe(`The order of the template`),weight:t.number().optional().describe(`The weight of the template`),workflow:t.object({nodes:t.array(t.any()).describe(`The nodes of the template`),edges:t.array(t.any()).describe(`The edges of the template`),chatConfig:t.any().optional().describe(`The chat config of the template`)})});t.array(ht);const gt=t.object(ht.shape),_t=t.array(gt),vt={List:F({meta:{method:`get`,path:`/list`,operationId:`workflow.list`,description:`Get a list of all available workflow templates`,summary:`List workflow templates`,tags:[`workflow`],security:L},response:{200:I({data:_t}),500:I({error:y})}})},yt=e.record(e.string(),e.unknown()),bt=e.enum([`response`,`error`,`stream`]).enum,xt=e.enum([`answer`,`fastAnswer`]);xt.enum;const St=e.object({type:xt,content:e.string()}),Ct=e.discriminatedUnion(`type`,[e.object({type:e.literal(bt.response),data:yt}),e.object({type:e.literal(bt.stream),data:St}),e.object({type:e.literal(bt.error),data:e.string()})]);e.object({pluginId:e.string(),version:e.preprocess(e=>{if(e!==``)return e},e.string().optional()),source:Oe.optional(),childId:e.string().optional(),input:e.record(e.string(),e.unknown()),secrets:e.record(e.string(),e.unknown()).optional(),systemVar:Pe});var wt=class{baseUrl;token;fetchImpl;constructor({baseUrl:e,token:t,fetch:n}){this.baseUrl=e.endsWith(`/`)?e.slice(0,-1):e,this.token=t;let r=n??globalThis.fetch;if(!r)throw Error(`Global fetch is not available. Please provide fetch in client options.`);this.fetchImpl=r.bind(globalThis)}async requestData({path:e,...t}){let n=await this.requestResponse({path:e,...t}),r=await this.readBody(n);return r&&typeof r==`object`&&`data`in r?r.data:r}async requestEmpty({path:e,...t}){await(await this.requestResponse({path:e,...t})).text().catch(()=>void 0)}async requestResponse({path:e,method:t=`GET`,headers:n,query:r,body:i,signal:a}){let o=this.buildUrl(e,r),s=new Headers(n);this.token&&s.set(`Authorization`,`Bearer ${this.token}`);let c=this.normalizeBody(i,s),l=await this.fetchImpl(o,{method:t.toUpperCase(),headers:s,body:c,signal:a});if(!l.ok)throw await this.buildError(l);return l}buildUrl(e,t){let n=new URL(e,`${this.baseUrl}/`);if(t){for(let[e,r]of Object.entries(t))if(r!=null){if(Array.isArray(r)){for(let t of r)n.searchParams.append(e,String(t));continue}n.searchParams.append(e,String(r))}}return n.toString()}normalizeBody(e,t){if(e!=null)return this.isNativeBodyInit(e)?e:(t.has(`Content-Type`)||t.set(`Content-Type`,`application/json`),JSON.stringify(e))}isNativeBodyInit(e){return typeof e==`string`||typeof Blob<`u`&&e instanceof Blob||typeof FormData<`u`&&e instanceof FormData||typeof URLSearchParams<`u`&&e instanceof URLSearchParams||typeof ReadableStream<`u`&&e instanceof ReadableStream||e instanceof ArrayBuffer||ArrayBuffer.isView(e)}async readBody(e){let t=await e.text();if(t)try{return JSON.parse(t)}catch{return t}}async buildError(e){let t=await this.readBody(e).catch(()=>void 0),n=this.extractErrorMessage(t)??`${e.status} ${e.statusText||`Request failed`}`;return Error(n)}extractErrorMessage(e){if(!e)return;if(typeof e==`string`)return e;if(typeof e!=`object`)return String(e);if(`error`in e)return this.extractErrorMessage(e.error);if(`msg`in e)return this.extractErrorMessage(e.msg);if(`message`in e)return this.extractErrorMessage(e.message);let t=e;if(typeof t[`zh-CN`]==`string`)return t[`zh-CN`];if(typeof t.en==`string`)return t.en;if(typeof t[`zh-Hant`]==`string`)return t[`zh-Hant`];try{return JSON.stringify(e)}catch{return}}},Tt=class{transport;constructor(e){this.transport=new wt(e)}async run(e,t){try{let n=Be.parse(e),r=await this.transport.requestResponse({path:`/api${mt.RunStream.meta.path}`,method:mt.RunStream.meta.method,body:n,headers:{Accept:`text/event-stream`},signal:t?.signal});if(!r.body)throw Error(`Tool stream response body is empty`);let i=r.body.getReader(),a=new TextDecoder,o=``,s,c;for(;;){let{value:t,done:n}=await i.read();o+=a.decode(t,{stream:!n});let r=o.split(`
|
|
2
2
|
|
|
3
3
|
`);o=r.pop()??``;for(let t of r){let n=this.parseStreamMessage(t);if(n){if(n.type===`stream`){e.onMessage?.(n.data);continue}if(n.type===`response`){s=n.data,await i.cancel();break}c=Error(n.data),await i.cancel();break}}if(n||s||c)break}if(!s&&!c){let t=this.parseStreamMessage(o);t?.type===`response`?s=t.data:t?.type===`error`?c=Error(t.data):t?.type===`stream`&&e.onMessage?.(t.data)}if(c)return{error:c};if(s)return{output:s};throw Error(`Tool stream closed without terminal event`)}catch(e){return{error:e instanceof Error?e:Error(String(e))}}}parseStreamMessage(e){let t=e.split(`
|
|
4
4
|
`).map(e=>e.startsWith(`data:`)?e.slice(5).trimStart():e).join(`
|