@fastgpt-plugin/sdk-client 0.0.1-alpha.5 → 0.0.1-alpha.6
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 +10 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -424,12 +424,12 @@ declare const PluginBaseDTOSchema: z$2.ZodObject<{
|
|
|
424
424
|
}, z$2.core.$strip>>;
|
|
425
425
|
}, z$2.core.$strip>;
|
|
426
426
|
declare const PluginListItemDTOSchema: z$2.ZodObject<{
|
|
427
|
-
type: z$2.ZodString;
|
|
428
427
|
name: z$2.ZodObject<{
|
|
429
428
|
en: z$2.ZodString;
|
|
430
429
|
"zh-CN": z$2.ZodOptional<z$2.ZodString>;
|
|
431
430
|
"zh-Hant": z$2.ZodOptional<z$2.ZodString>;
|
|
432
431
|
}, z$2.core.$strip>;
|
|
432
|
+
type: z$2.ZodString;
|
|
433
433
|
description: z$2.ZodOptional<z$2.ZodObject<{
|
|
434
434
|
en: z$2.ZodString;
|
|
435
435
|
"zh-CN": z$2.ZodOptional<z$2.ZodString>;
|
|
@@ -447,12 +447,12 @@ declare const PluginListItemDTOSchema: z$2.ZodObject<{
|
|
|
447
447
|
source: z$2.ZodString;
|
|
448
448
|
}, z$2.core.$strip>;
|
|
449
449
|
declare const PluginListDTOSchema: z$2.ZodArray<z$2.ZodObject<{
|
|
450
|
-
type: z$2.ZodString;
|
|
451
450
|
name: z$2.ZodObject<{
|
|
452
451
|
en: z$2.ZodString;
|
|
453
452
|
"zh-CN": z$2.ZodOptional<z$2.ZodString>;
|
|
454
453
|
"zh-Hant": z$2.ZodOptional<z$2.ZodString>;
|
|
455
454
|
}, z$2.core.$strip>;
|
|
455
|
+
type: z$2.ZodString;
|
|
456
456
|
description: z$2.ZodOptional<z$2.ZodObject<{
|
|
457
457
|
en: z$2.ZodString;
|
|
458
458
|
"zh-CN": z$2.ZodOptional<z$2.ZodString>;
|
|
@@ -590,7 +590,12 @@ declare const PluginVersionListParamsSchema: z$2.ZodObject<{
|
|
|
590
590
|
pluginId: z$2.ZodString;
|
|
591
591
|
source: z$2.ZodString;
|
|
592
592
|
}, z$2.core.$strip>;
|
|
593
|
-
declare const PluginRuntimeConfigSchema: z$2.ZodObject<{
|
|
593
|
+
declare const PluginRuntimeConfigSchema: z$2.ZodObject<{
|
|
594
|
+
minPods: z$2.ZodNumber;
|
|
595
|
+
maxPods: z$2.ZodNumber;
|
|
596
|
+
podTimeout: z$2.ZodNumber;
|
|
597
|
+
maxConcurrentRequestsPerPod: z$2.ZodNumber;
|
|
598
|
+
}, z$2.core.$strict>;
|
|
594
599
|
type PluginDTOType = z$2.infer<typeof PluginBaseDTOSchema>;
|
|
595
600
|
type PluginUploadFailureDTOType = z$2.infer<typeof PluginUploadFailureDTOSchema>;
|
|
596
601
|
type PluginUploadResponseDTOType = z$2.infer<typeof PluginUploadResponseDTOSchema>;
|
|
@@ -644,12 +649,12 @@ declare const ToolListItemDTOSchema: z$2.ZodObject<{
|
|
|
644
649
|
}, z$2.core.$strip>>>;
|
|
645
650
|
source: z$2.ZodUnion<[z$2.ZodLiteral<"system">, z$2.ZodString]>;
|
|
646
651
|
isToolset: z$2.ZodBoolean;
|
|
647
|
-
type: z$2.ZodLiteral<"tool">;
|
|
648
652
|
name: z$2.ZodObject<{
|
|
649
653
|
en: z$2.ZodString;
|
|
650
654
|
"zh-CN": z$2.ZodOptional<z$2.ZodString>;
|
|
651
655
|
"zh-Hant": z$2.ZodOptional<z$2.ZodString>;
|
|
652
656
|
}, z$2.core.$strip>;
|
|
657
|
+
type: z$2.ZodLiteral<"tool">;
|
|
653
658
|
description: z$2.ZodObject<{
|
|
654
659
|
en: z$2.ZodString;
|
|
655
660
|
"zh-CN": z$2.ZodOptional<z$2.ZodString>;
|
|
@@ -697,12 +702,12 @@ declare const ToolListDTOSchema: z$2.ZodArray<z$2.ZodObject<{
|
|
|
697
702
|
}, z$2.core.$strip>>>;
|
|
698
703
|
source: z$2.ZodUnion<[z$2.ZodLiteral<"system">, z$2.ZodString]>;
|
|
699
704
|
isToolset: z$2.ZodBoolean;
|
|
700
|
-
type: z$2.ZodLiteral<"tool">;
|
|
701
705
|
name: z$2.ZodObject<{
|
|
702
706
|
en: z$2.ZodString;
|
|
703
707
|
"zh-CN": z$2.ZodOptional<z$2.ZodString>;
|
|
704
708
|
"zh-Hant": z$2.ZodOptional<z$2.ZodString>;
|
|
705
709
|
}, z$2.core.$strip>;
|
|
710
|
+
type: z$2.ZodLiteral<"tool">;
|
|
706
711
|
description: z$2.ZodObject<{
|
|
707
712
|
en: z$2.ZodString;
|
|
708
713
|
"zh-CN": z$2.ZodOptional<z$2.ZodString>;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e,{z as t,z as n}from"zod";import{createHash as r}from"node:crypto";import i from"node:path";import{Readable as a}from"node:stream";var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e},m=(e,t,n)=>(n=e==null?{}:o(u(e)),p(t||!e||!e.__esModule?s(n,`default`,{value:e,enumerable:!0}):n,e));(0,f((e=>{function t(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}let n={ZodAny:`any`,ZodArray:`array`,ZodBigInt:`bigint`,ZodBoolean:`boolean`,ZodDefault:`default`,ZodPrefault:`prefault`,ZodTransform:`transform`,ZodEnum:`enum`,ZodIntersection:`intersection`,ZodLazy:`lazy`,ZodLiteral:`literal`,ZodNever:`never`,ZodNull:`null`,ZodNullable:`nullable`,ZodNumber:`number`,ZodNonOptional:`nonoptional`,ZodObject:`object`,ZodOptional:`optional`,ZodPipe:`pipe`,ZodReadonly:`readonly`,ZodRecord:`record`,ZodString:`string`,ZodTuple:`tuple`,ZodType:`type`,ZodUnion:`union`,ZodDiscriminatedUnion:`union`,ZodUnknown:`unknown`,ZodVoid:`void`,ZodDate:`date`,ZodTemplateLiteral:`template_literal`};function r(e,t){return(Array.isArray(t)?t:[t]).some(t=>{let r=e?.def?.type===n[t];return t===`ZodDiscriminatedUnion`?r&&`discriminator`in e.def:r})}function i(e){return e&&`def`in e}var a=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function o(){return new a}function s(e){return e===void 0}function c(e,t){let n={};return Object.entries(e).forEach(([e,r])=>{t.some(t=>t===e)||(n[e]=r)}),n}function l(e,t){let n={};return Object.entries(e).forEach(([e,r])=>{t(r,e)||(n[e]=r)}),n}let u=o();var d=class{static collectMetadata(e,t){let n=this.getMetadataFromRegistry(e),a=Object.assign(Object.assign({},n?._internal),t?._internal),o=Object.assign(Object.assign({},n?.param),t?.param),s=Object.assign(Object.assign(Object.assign(Object.assign({},Object.keys(a).length>0?{_internal:a}:{}),n),t),Object.keys(o).length>0?{param:o}:{});if(r(e,[`ZodOptional`,`ZodNullable`,`ZodDefault`,`ZodPrefault`,`ZodReadonly`,`ZodNonOptional`])&&i(e._zod.def.innerType))return this.collectMetadata(e._zod.def.innerType,s);if(r(e,`ZodPipe`)){let t=e._zod.def.in,n=e._zod.def.out;if(r(t,`ZodTransform`)&&i(n))return this.collectMetadata(n,s);if(i(t))return this.collectMetadata(t,s)}return s}static getMetadata(e){return this.collectMetadata(e)}static getOpenApiMetadata(e){let n=this.collectMetadata(e)??{},{_internal:r}=n;return t(n,[`_internal`])}static getInternalMetadata(e){return this.collectMetadata(e)?._internal}static getParamMetadata(e){let t=this.collectMetadata(e);return Object.assign(Object.assign({},t),{param:Object.assign(Object.assign({},t?.description?{description:t.description}:{}),t?.param)})}static buildSchemaMetadata(e){return l(c(e,[`param`,`_internal`]),s)}static buildParameterMetadata(e){return l(e,s)}static applySchemaMetadata(e,t){return l(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),s)}static getRefId(e){return this.getInternalMetadata(e)?.refId}static unwrapChained(e){return this.unwrapUntil(e)}static getDefaultValue(e){return(this.unwrapUntil(e,`ZodDefault`)??this.unwrapUntil(e,`ZodPrefault`))?._zod.def.defaultValue}static unwrapUntil(e,t){if(t&&r(e,t))return e;if(r(e,[`ZodOptional`,`ZodNullable`,`ZodDefault`,`ZodPrefault`,`ZodReadonly`,`ZodNonOptional`])&&i(e._zod.def.innerType))return this.unwrapUntil(e._zod.def.innerType,t);if(r(e,`ZodPipe`)){let n=e._zod.def.in,a=e._zod.def.out;if(r(n,`ZodTransform`)&&i(a))return this.unwrapUntil(a,t);if(i(n))return this.unwrapUntil(n,t)}return t?void 0:e}static getMetadataFromInternalRegistry(e){return u.get(e)}static getMetadataFromRegistry(e){let n=this.getMetadataFromInternalRegistry(e),r=e.meta();if(!n)return r;let{_internal:i}=n,a=t(n,[`_internal`]),o=r??{},{id:s,title:c}=o,l=t(o,[`id`,`title`]);return Object.assign(Object.assign(Object.assign({_internal:Object.assign(Object.assign({},s?{refId:s}:{}),i)},a),c?{description:c}:{}),l)}static setMetadataInRegistry(e,t){u.add(e,t)}};function f(e,t){let n=e[t];typeof n==`function`&&(e[t]=function(...e){let t=n.apply(this,e),r=d.getMetadataFromRegistry(this);return r&&d.setMetadataInRegistry(t,r),t})}function p(e){e.ZodType.prototype.openapi===void 0&&(e.ZodType.prototype.openapi=function(...e){let{refId:n,metadata:i,options:a}=m(...e),o=i??{},{param:s}=o,c=t(o,[`param`]),l=d.getMetadataFromRegistry(this)??{},{_internal:u}=l,p=t(l,[`_internal`]),h=Object.assign(Object.assign(Object.assign({},u),a),n?{refId:n}:void 0),g=Object.assign(Object.assign(Object.assign({},p),c),p?.param||s?{param:Object.assign(Object.assign({},p?.param),s)}:void 0),_=new this.constructor(this._def);function v(e){d.setMetadataInRegistry(e,Object.assign(Object.assign({},Object.keys(h).length>0?{_internal:h}:void 0),g))}if(v(_),r(_,`ZodLazy`)&&v(this),r(_,`ZodObject`)){let e=d.getMetadataFromRegistry(_),n=_.extend;_.extend=function(...r){let i=n.apply(_,r),a=e??{},{_internal:o}=a,s=t(a,[`_internal`]);return d.setMetadataInRegistry(i,{_internal:{extendedFrom:o?.refId?{refId:o.refId,schema:_}:o?.extendedFrom}}),i.openapi(s)},f(_,`catchall`)}f(_,`optional`),f(_,`nullable`),f(_,`default`),f(_,`transform`),f(_,`refine`),f(_,`length`),f(_,`min`),f(_,`max`);let y=_.meta;return _.meta=function(...e){let t=y.apply(this,e);if(e[0]){let n=d.getMetadataFromInternalRegistry(this);n&&d.setMetadataInRegistry(t,Object.assign(Object.assign({},n),e[0]))}return t},_})}function m(e,t,n){return typeof e==`string`?{refId:e,metadata:t,options:n}:{refId:void 0,metadata:e,options:t}}e.extendZodWithOpenApi=p}))().extendZodWithOpenApi)(n);const h=e.enum([`en`,`zh-CN`,`zh-Hant`]).enum,g=e.object({[h.en]:e.string(),[h[`zh-CN`]]:e.string().optional(),[h[`zh-Hant`]]:e.string().optional()}),_=e.object({[h.en]:e.string(),[h[`zh-CN`]]:e.string(),[h[`zh-Hant`]]:e.string()}),v=e.enum([`userInfo:read`,`teamInfo:read`,`model:read`,`dataset:read`,`file-upload:allow`]),y=v.enum;e.object({pluginId:e.string(),version:e.string(),etag:e.string()});const b=e.literal(`system`).or(e.string()),x=e.object({id:e.string(),name:_});e.array(x),e.enum([`localPool`,`serverless`]).enum;const S=e.object({pluginId:e.string(),version:e.string().optional(),source:b.optional()}),C=e.enum([`tools`,`search`,`multimodal`,`communication`,`finance`,`design`,`productivity`,`news`,`entertainment`,`social`,`scientific`,`other`]),w=C.enum,ee=e.enum([`tool`]),T=ee.enum;e.enum([`active`,`pending`,`disabled`]).enum;const E=e.object({pluginId:e.string(),version:e.string(),etag:e.string(),type:ee,author:e.string().optional(),repoUrl:e.string().optional(),name:g,icon:e.string(),tutorialUrl:e.url().optional(),readmeUrl:e.url().optional(),description:g,tags:e.array(C).optional(),versionDescription:g.optional(),permission:e.array(v).optional()}),D=e.object({id:e.string(),name:g,description:g.optional(),icon:e.string(),toolDescription:e.string(),inputSchema:e.any(),outputSchema:e.any()}),O=e.object({...E.shape,type:e.literal(T.tool),toolDescription:e.string(),inputSchema:e.any().optional(),outputSchema:e.any().optional(),secretSchema:e.any().optional(),children:e.array(D).optional()});e.object({...E.shape,type:e.literal(T.tool),meta:e.object({secretSchema:e.any().optional(),toolDescription:e.string()})});const k=e.object(g.shape),A=e.object(_.shape),te=e=>n.preprocess(e=>{if(e!=null)return Array.isArray(e)?e:[e]},n.array(e).optional()),j=n.object({pluginId:n.string().openapi({description:`Plugin ID`,example:`getTime`}),version:n.string().openapi({description:`Plugin version`,example:`1.0.0`}),etag:n.string().openapi({description:`Plugin etag`,example:`a1d809f6`}),type:n.string().openapi({description:`Plugin type`,example:`tool`}),author:n.string().optional().openapi({description:`Plugin author`,example:``}),name:k.openapi({description:`Plugin name`,example:{en:`Get Time`,"zh-CN":`获取时间`}}),icon:n.string().openapi({description:`Plugin icon`,example:`https://oss.example.com/getTime/icon.svg`}),tutorialUrl:n.url().optional().openapi({description:`Plugin tutorial URL`,example:`https://oss.example.com/getTime/tutorial`}),readmeUrl:n.url().optional().openapi({description:`Plugin readme URL`,example:`https://oss.example.com/getTime/README.md`}),repoUrl:n.url().optional().openapi({description:`Plugin repository URL`,example:`https://git.example.com/example/getTime`}),permission:n.array(n.string()).optional().openapi({description:`Plugin permissions`,example:[`userInfo:read`]}),description:k.optional().openapi({description:`Plugin description`,example:{en:`Plugin description`,"zh-CN":`插件描述`}}),tags:n.array(n.string()).optional().openapi({description:`Plugin tags`,example:[`tool`]}),versionDescription:g.optional().describe(`Plugin version description`)}),M=j.omit({versionDescription:!0,permission:!0}).extend({source:n.string().openapi({description:`Plugin source`,example:`system`})}).openapi({description:`Plugin list item`}),N=n.array(M).openapi({description:`Plugin List`}),ne=n.object({fileName:n.string().optional().openapi({description:`Failed upload file name`,example:`bad.pkg`}),reason:g.openapi({description:`Upload failure reason`})}).openapi({description:`Plugin upload failure`}),re=n.object({plugins:n.array(j).openapi({description:`Parsed uploaded plugin list`}),failed:n.array(ne).optional().openapi({description:`Failed uploaded plugin files`})}).openapi({description:`Plugin upload response`}),ie=n.object({files:n.array(n.file()).min(1).openapi({description:`Plugin .pkg files or .zip package collection files`,example:[`example.pkg`]})}).openapi({description:`Plugin upload parameters`,example:{files:[`example.pkg`]}}),ae=n.object({pluginId:n.string().openapi({description:`Plugin unique id`,example:`getTime`}),version:n.string().openapi({description:`Plugin version id`,example:`1.0.0`}),etag:n.string().openapi({description:`Plugin etag`,example:`12345678`})}),oe=n.object({uniqueIds:n.array(ae).min(1).openapi({description:`Plugin unique id list`,example:[{pluginId:`getTime`,version:`1.0.0`,etag:`12345678`}]})}),se=n.object({count:n.number().int().nonnegative().openapi({description:`Number of disabled plugins removed`,example:2}),plugins:n.array(ae).openapi({description:`Removed disabled plugin unique ids`})}),P=n.object({url:n.string(),reason:g}),F={request:n.object({urls:n.array(n.string()).openapi({description:`Plugin install urls`,example:[`https://oss.example.com/plugin/getTime.pkg`,`https://oss.example.com/plugin/delay.pkg`]})}),response:n.object({failed:n.array(P).optional()}).openapi({description:`Plugin install response`,examples:[{},{failed:[{url:`https://oss.example.com/plugin/getTime.pkg`,reason:{en:`Failed to install plugin`,"zh-CN":`安装插件失败`}}]}]})},ce=n.object({types:te(ee).openapi({description:`Filter by plugin types`,example:[`tool`]}),tags:te(C).openapi({description:`Filter by plugin tags`,example:[`tools`,`productivity`]}),op:n.enum([`or`,`and`]).optional().openapi({description:`Filter operator for tags and types`,example:`or`}),sources:te(b).openapi({description:`Filter by plugin sources`,example:[`system`,`market`]})}),le=n.object({version:n.string().openapi({description:`Plugin version`,example:`1.0.0`}),versionDescription:k.optional().openapi({description:`Plugin version description`,example:{en:`Initial stable release`,"zh-CN":`首个稳定版本`}})}),ue=n.array(le).openapi({description:`Plugin version list`}),de=n.object({pluginId:n.string().openapi({description:`Plugin ID`,example:`getTime`}),source:n.string().openapi({description:`Plugin source`,example:`system`})}),fe=n.array(n.object({id:n.string().openapi({description:`Plugin tag ID`,example:`tools`}),name:k.openapi({description:`Plugin tag name`,example:{en:`Tools`,"zh-CN":`工具`}})})).openapi({description:`Plugin tag list`}),pe=n.object({}).catchall(n.unknown()).openapi({description:`Plugin runtime config`}),me=n.object({pluginId:n.string().openapi({description:`Plugin ID`,example:`getTime`})}),he=n.object({pluginId:n.string().openapi({description:`Plugin ID`,example:`getTime`}),config:pe}),ge=n.object({pluginId:n.string().openapi({description:`Plugin ID`,example:`getTime`})}),_e=e.object({id:D.shape.id,name:D.shape.name,description:D.shape.description,toolDescription:D.shape.toolDescription}),ve=e.object({...O.omit({inputSchema:!0,outputSchema:!0,secretSchema:!0,children:!0,versionDescription:!0,permission:!0}).shape,source:b,isToolset:e.boolean(),children:e.array(_e).optional()}),ye=e.object({...O.shape,source:b,isLatestVersion:e.boolean(),isToolset:e.boolean()}),be=S.extend({fallbackLatestVersion:e.boolean().optional()}),xe=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()}),Se=e=>n.preprocess(e=>{if(e!=null)return Array.isArray(e)?e:[e]},n.array(e).optional()),Ce=e=>n.preprocess(e=>typeof e==`boolean`||typeof e!=`string`?e:e===`true`?!0:e===`false`?!1:e,e),we=n.object({...xe.shape}).openapi({description:`System variables provided to the tool when it is run`,example:{time:`example-time`,app:{id:`example-id`,name:`example-name`},chat:{chatId:`example-chat-id`,uId:`example-u-id`},invokeToken:`example-invoke-token`}}).openapi(`SystemVar`),Te=n.object({pluginId:n.string().openapi({description:`Plugin ID`,example:`getTime`}),version:n.string().optional().openapi({description:`Plugin version, optional. Empty or missing means latest version`,example:`1.0.0`}),source:n.string().optional().openapi({description:`Plugin source, optional, default is "system"`,example:`system`}),secrets:n.record(n.string(),n.any()).optional().openapi({description:`Tool secrets, key-value pairs`,example:{secretKey1:`secretValue1`,secretKey2:`secretValue2`}}),systemVar:we,input:n.record(n.string(),n.unknown()).openapi({description:`Tool input parameters, key-value pairs`,example:{param1:`value1`,param2:123,param3:{subParam1:`subValue1`}}}),childId:n.string().optional().openapi({description:`Child tool ID, only exists when the tool is part of a toolset`,example:`example-child-tool-id`})}),Ee=n.object({..._e.shape}),De=n.object({...ve.shape,children:n.array(Ee).optional()}),Oe=n.array(De),ke=n.object({...ye.shape}),Ae=n.object({pluginId:n.string().openapi({description:`Tool plugin ID`,example:`getTime`}),version:n.string().optional().openapi({description:`Tool version`,example:`1.0.0`}),source:b.optional().default(`system`).openapi({description:`Tool source`,example:`system`}),fallbackLatestVersion:Ce(be.shape.fallbackLatestVersion).openapi({description:`Fallback to latest version when the requested version is missing`,example:!0})}),je=n.object({tags:Se(C).openapi({description:`Filter by tool tags`,example:[`tools`]}),op:n.enum([`or`,`and`]).optional().openapi({description:`Filter operator for tags`,example:`or`}),sources:Se(b).openapi({description:`Filter by tool sources`,example:[`system`]})}),I=e=>e,Me=()=>void 0,Ne=({data:t,error:n})=>e.object({...t&&{data:t},...n&&{error:n}}),L=({data:e,error:t}={})=>Ne({data:e,error:t}),Pe=e.enum([`llm`,`embedding`,`rerank`,`tts`,`stt`]).enum,Fe=e.object({charsPointsPrice:e.number().optional(),inputPrice:e.number().optional(),outputPrice:e.number().optional()}),Ie=e.object({provider:e.string(),model:e.string(),name:e.string()}),Le=e.object({...Fe.shape,...Ie.shape,type:e.literal(Pe.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()}),Re=e.object({...Fe.shape,...Ie.shape,type:e.literal(Pe.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()}),ze=e.object({...Fe.shape,...Ie.shape,type:e.literal(Pe.rerank)}),Be=e.object({...Fe.shape,...Ie.shape,type:e.literal(Pe.tts),voices:e.array(e.object({label:e.string(),value:e.string()}))}),Ve=e.object({...Fe.shape,...Ie.shape,type:e.literal(Pe.stt)}),He=e.discriminatedUnion(`type`,[Le,Re,ze,Be,Ve]);e.object({id:e.string(),name:_,avatar:e.string()});const Ue=n.array(He).openapi({description:`Available model list`}),We=n.object({provider:n.string().openapi({description:`Model provider id`,example:`OpenAI`}),value:A.openapi({description:`Model provider display name`}),avatar:n.string().openapi({description:`Model provider logo url`,example:`https://example.com/models/OpenAI/logo`})}),Ge=n.object({channelId:n.number().openapi({description:`AIProxy channel id`,example:1}),name:A.openapi({description:`AIProxy provider display name`}),avatar:n.string().openapi({description:`Custom avatar url`})}),Ke=n.object({modelProviders:n.array(We).openapi({description:`Model provider list`}),aiproxyChannels:n.array(Ge).openapi({description:`AIProxy channel list`})}),R=[{bearerAuth:[]}],qe={List:I({meta:{method:`get`,path:`/models`,operationId:`model.list`,description:`Get a list of all available AI models`,summary:`List models`,tags:[`model`],security:R},response:{200:L({data:Ue}),500:L({error:g})}}),GetProviders:I({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:R},response:{200:L({data:Ke}),500:L({error:g})}})},Je={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:R},Ye={200:L({data:re}),400:L({error:g})},z={Upload:I({meta:Je,request:ie,response:Ye,openapi:{...Je,request:{body:{content:{"multipart/form-data":{schema:n.object({files:n.any()})}}}},responses:{200:{description:`HTTP 200 response`,content:{"application/json":{schema:Ye[200]}}},400:{description:`HTTP 400 response`,content:{"application/json":{schema:Ye[400]}}}}}}),Confirm:I({meta:{method:`post`,path:`/plugin/confirm`,operationId:`plugin.confirm`,description:`Confirm the uploaded plugin`,summary:`Confirm a plugin`,tags:[`plugin`],security:R},request:oe,response:{200:Me(),500:L({error:g})}}),PruneDisabled:I({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:R},response:{200:L({data:se}),500:L({error:g})}}),Install:I({meta:{method:`post`,path:`/plugin/install`,operationId:`plugin.install`,description:`Install a plugin`,summary:`Install a plugin`,tags:[`plugin`],security:R},request:F.request,response:{200:L({data:F.response}),500:L({error:g})}}),List:I({meta:{method:`get`,path:`/plugins`,operationId:`plugin.list`,description:`List plugins with optional filters`,summary:`List plugins`,tags:[`plugin`],security:R},request:ce,response:{200:L({data:N}),500:L({error:g})}}),Versions:I({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:R},request:de,response:{200:L({data:ue}),500:L({error:g})}}),TagList:I({meta:{method:`get`,path:`/plugin/tags`,operationId:`plugin.tags`,description:`List plugin tags`,summary:`List plugin tags`,tags:[`plugin`],security:R},response:{200:L({data:fe}),500:L({error:g})}}),RuntimeConfigGet:I({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:R},request:me,response:{200:L({data:pe}),500:L({error:g})}}),RuntimeConfigSet:I({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:R},request:he,response:{200:Me(),500:L({error:g})}}),RuntimeConfigReset:I({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:R},request:ge,response:{200:Me(),500:L({error:g})}})},Xe={Get:I({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:R},request:Ae,response:{200:L({data:ke}),404:L({error:g})}}),List:I({meta:{method:`get`,path:`/tools`,operationId:`tool.list`,description:`List tools with optional filters`,summary:`List tools`,tags:[`plugin`,`tool`],security:R},request:je,response:{200:L({data:Oe}),500:L({error:g})}}),RunStream:I({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:R},request:Te,response:{200:e.object({type:e.string()}),400:L({error:g})}})};Xe.RunStream;const Ze=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.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(Ze);const Qe=n.object(Ze.shape).openapi({description:`Workflow template`}),$e=n.array(Qe).openapi({description:`Workflow template list`}),et={List:I({meta:{method:`get`,path:`/list`,operationId:`workflow.list`,description:`Get a list of all available workflow templates`,summary:`List workflow templates`,tags:[`workflow`],security:R},response:{200:L({data:$e}),500:L({error:g})}})},tt=e.record(e.string(),e.unknown()),nt=e.enum([`response`,`error`,`stream`]).enum,rt=e.enum([`answer`,`fastAnswer`]);rt.enum;const it=e.object({type:rt,content:e.string()}),at=e.discriminatedUnion(`type`,[e.object({type:e.literal(nt.response),data:tt}),e.object({type:e.literal(nt.stream),data:it}),e.object({type:e.literal(nt.error),data:e.string()})]);e.object({pluginId:e.string(),version:e.preprocess(e=>{if(e!==``)return e},e.string().optional()),source:b.optional(),childId:e.string().optional(),input:e.record(e.string(),e.unknown()),secrets:e.record(e.string(),e.unknown()).optional(),systemVar:xe});var ot=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}}},st=class{transport;constructor(e){this.transport=new ot(e)}async run(e,t){try{let n=Te.parse(e),r=await this.transport.requestResponse({path:`/api${Xe.RunStream.meta.path}`,method:Xe.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,z as n}from"zod";import{createHash as r}from"node:crypto";import i from"node:path";import{Readable as a}from"node:stream";var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e},m=(e,t,n)=>(n=e==null?{}:o(u(e)),p(t||!e||!e.__esModule?s(n,`default`,{value:e,enumerable:!0}):n,e));(0,f((e=>{function t(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}let n={ZodAny:`any`,ZodArray:`array`,ZodBigInt:`bigint`,ZodBoolean:`boolean`,ZodDefault:`default`,ZodPrefault:`prefault`,ZodTransform:`transform`,ZodEnum:`enum`,ZodIntersection:`intersection`,ZodLazy:`lazy`,ZodLiteral:`literal`,ZodNever:`never`,ZodNull:`null`,ZodNullable:`nullable`,ZodNumber:`number`,ZodNonOptional:`nonoptional`,ZodObject:`object`,ZodOptional:`optional`,ZodPipe:`pipe`,ZodReadonly:`readonly`,ZodRecord:`record`,ZodString:`string`,ZodTuple:`tuple`,ZodType:`type`,ZodUnion:`union`,ZodDiscriminatedUnion:`union`,ZodUnknown:`unknown`,ZodVoid:`void`,ZodDate:`date`,ZodTemplateLiteral:`template_literal`};function r(e,t){return(Array.isArray(t)?t:[t]).some(t=>{let r=e?.def?.type===n[t];return t===`ZodDiscriminatedUnion`?r&&`discriminator`in e.def:r})}function i(e){return e&&`def`in e}var a=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function o(){return new a}function s(e){return e===void 0}function c(e,t){let n={};return Object.entries(e).forEach(([e,r])=>{t.some(t=>t===e)||(n[e]=r)}),n}function l(e,t){let n={};return Object.entries(e).forEach(([e,r])=>{t(r,e)||(n[e]=r)}),n}let u=o();var d=class{static collectMetadata(e,t){let n=this.getMetadataFromRegistry(e),a=Object.assign(Object.assign({},n?._internal),t?._internal),o=Object.assign(Object.assign({},n?.param),t?.param),s=Object.assign(Object.assign(Object.assign(Object.assign({},Object.keys(a).length>0?{_internal:a}:{}),n),t),Object.keys(o).length>0?{param:o}:{});if(r(e,[`ZodOptional`,`ZodNullable`,`ZodDefault`,`ZodPrefault`,`ZodReadonly`,`ZodNonOptional`])&&i(e._zod.def.innerType))return this.collectMetadata(e._zod.def.innerType,s);if(r(e,`ZodPipe`)){let t=e._zod.def.in,n=e._zod.def.out;if(r(t,`ZodTransform`)&&i(n))return this.collectMetadata(n,s);if(i(t))return this.collectMetadata(t,s)}return s}static getMetadata(e){return this.collectMetadata(e)}static getOpenApiMetadata(e){let n=this.collectMetadata(e)??{},{_internal:r}=n;return t(n,[`_internal`])}static getInternalMetadata(e){return this.collectMetadata(e)?._internal}static getParamMetadata(e){let t=this.collectMetadata(e);return Object.assign(Object.assign({},t),{param:Object.assign(Object.assign({},t?.description?{description:t.description}:{}),t?.param)})}static buildSchemaMetadata(e){return l(c(e,[`param`,`_internal`]),s)}static buildParameterMetadata(e){return l(e,s)}static applySchemaMetadata(e,t){return l(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),s)}static getRefId(e){return this.getInternalMetadata(e)?.refId}static unwrapChained(e){return this.unwrapUntil(e)}static getDefaultValue(e){return(this.unwrapUntil(e,`ZodDefault`)??this.unwrapUntil(e,`ZodPrefault`))?._zod.def.defaultValue}static unwrapUntil(e,t){if(t&&r(e,t))return e;if(r(e,[`ZodOptional`,`ZodNullable`,`ZodDefault`,`ZodPrefault`,`ZodReadonly`,`ZodNonOptional`])&&i(e._zod.def.innerType))return this.unwrapUntil(e._zod.def.innerType,t);if(r(e,`ZodPipe`)){let n=e._zod.def.in,a=e._zod.def.out;if(r(n,`ZodTransform`)&&i(a))return this.unwrapUntil(a,t);if(i(n))return this.unwrapUntil(n,t)}return t?void 0:e}static getMetadataFromInternalRegistry(e){return u.get(e)}static getMetadataFromRegistry(e){let n=this.getMetadataFromInternalRegistry(e),r=e.meta();if(!n)return r;let{_internal:i}=n,a=t(n,[`_internal`]),o=r??{},{id:s,title:c}=o,l=t(o,[`id`,`title`]);return Object.assign(Object.assign(Object.assign({_internal:Object.assign(Object.assign({},s?{refId:s}:{}),i)},a),c?{description:c}:{}),l)}static setMetadataInRegistry(e,t){u.add(e,t)}};function f(e,t){let n=e[t];typeof n==`function`&&(e[t]=function(...e){let t=n.apply(this,e),r=d.getMetadataFromRegistry(this);return r&&d.setMetadataInRegistry(t,r),t})}function p(e){e.ZodType.prototype.openapi===void 0&&(e.ZodType.prototype.openapi=function(...e){let{refId:n,metadata:i,options:a}=m(...e),o=i??{},{param:s}=o,c=t(o,[`param`]),l=d.getMetadataFromRegistry(this)??{},{_internal:u}=l,p=t(l,[`_internal`]),h=Object.assign(Object.assign(Object.assign({},u),a),n?{refId:n}:void 0),g=Object.assign(Object.assign(Object.assign({},p),c),p?.param||s?{param:Object.assign(Object.assign({},p?.param),s)}:void 0),_=new this.constructor(this._def);function v(e){d.setMetadataInRegistry(e,Object.assign(Object.assign({},Object.keys(h).length>0?{_internal:h}:void 0),g))}if(v(_),r(_,`ZodLazy`)&&v(this),r(_,`ZodObject`)){let e=d.getMetadataFromRegistry(_),n=_.extend;_.extend=function(...r){let i=n.apply(_,r),a=e??{},{_internal:o}=a,s=t(a,[`_internal`]);return d.setMetadataInRegistry(i,{_internal:{extendedFrom:o?.refId?{refId:o.refId,schema:_}:o?.extendedFrom}}),i.openapi(s)},f(_,`catchall`)}f(_,`optional`),f(_,`nullable`),f(_,`default`),f(_,`transform`),f(_,`refine`),f(_,`length`),f(_,`min`),f(_,`max`);let y=_.meta;return _.meta=function(...e){let t=y.apply(this,e);if(e[0]){let n=d.getMetadataFromInternalRegistry(this);n&&d.setMetadataInRegistry(t,Object.assign(Object.assign({},n),e[0]))}return t},_})}function m(e,t,n){return typeof e==`string`?{refId:e,metadata:t,options:n}:{refId:void 0,metadata:e,options:t}}e.extendZodWithOpenApi=p}))().extendZodWithOpenApi)(n);const h=e.enum([`en`,`zh-CN`,`zh-Hant`]).enum,g=e.object({[h.en]:e.string(),[h[`zh-CN`]]:e.string().optional(),[h[`zh-Hant`]]:e.string().optional()}),_=e.object({[h.en]:e.string(),[h[`zh-CN`]]:e.string(),[h[`zh-Hant`]]:e.string()}),v=e.enum([`userInfo:read`,`teamInfo:read`,`model:read`,`dataset:read`,`file-upload:allow`]),y=v.enum;e.object({pluginId:e.string(),version:e.string(),etag:e.string()});const b=e.literal(`system`).or(e.string()),x=e.object({id:e.string(),name:_});e.array(x),e.enum([`localPool`,`serverless`]).enum;const S=e.object({pluginId:e.string(),version:e.string().optional(),source:b.optional()}),C=e.enum([`tools`,`search`,`multimodal`,`communication`,`finance`,`design`,`productivity`,`news`,`entertainment`,`social`,`scientific`,`other`]),w=C.enum,ee=e.enum([`tool`]),T=ee.enum;e.enum([`active`,`pending`,`disabled`]).enum;const E=e.object({pluginId:e.string(),version:e.string(),etag:e.string(),type:ee,author:e.string().optional(),repoUrl:e.string().optional(),name:g,icon:e.string(),tutorialUrl:e.url().optional(),readmeUrl:e.url().optional(),description:g,tags:e.array(C).optional(),versionDescription:g.optional(),permission:e.array(v).optional()}),D=e.object({id:e.string(),name:g,description:g.optional(),icon:e.string(),toolDescription:e.string(),inputSchema:e.any(),outputSchema:e.any()}),O=e.object({...E.shape,type:e.literal(T.tool),toolDescription:e.string(),inputSchema:e.any().optional(),outputSchema:e.any().optional(),secretSchema:e.any().optional(),children:e.array(D).optional()});e.object({...E.shape,type:e.literal(T.tool),meta:e.object({secretSchema:e.any().optional(),toolDescription:e.string()})});const k=e.object(g.shape),A=e.object(_.shape),te=e=>n.preprocess(e=>{if(e!=null)return Array.isArray(e)?e:[e]},n.array(e).optional()),j=n.object({pluginId:n.string().openapi({description:`Plugin ID`,example:`getTime`}),version:n.string().openapi({description:`Plugin version`,example:`1.0.0`}),etag:n.string().openapi({description:`Plugin etag`,example:`a1d809f6`}),type:n.string().openapi({description:`Plugin type`,example:`tool`}),author:n.string().optional().openapi({description:`Plugin author`,example:``}),name:k.openapi({description:`Plugin name`,example:{en:`Get Time`,"zh-CN":`获取时间`}}),icon:n.string().openapi({description:`Plugin icon`,example:`https://oss.example.com/getTime/icon.svg`}),tutorialUrl:n.url().optional().openapi({description:`Plugin tutorial URL`,example:`https://oss.example.com/getTime/tutorial`}),readmeUrl:n.url().optional().openapi({description:`Plugin readme URL`,example:`https://oss.example.com/getTime/README.md`}),repoUrl:n.url().optional().openapi({description:`Plugin repository URL`,example:`https://git.example.com/example/getTime`}),permission:n.array(n.string()).optional().openapi({description:`Plugin permissions`,example:[`userInfo:read`]}),description:k.optional().openapi({description:`Plugin description`,example:{en:`Plugin description`,"zh-CN":`插件描述`}}),tags:n.array(n.string()).optional().openapi({description:`Plugin tags`,example:[`tool`]}),versionDescription:g.optional().describe(`Plugin version description`)}),M=j.omit({versionDescription:!0,permission:!0}).extend({source:n.string().openapi({description:`Plugin source`,example:`system`})}).openapi({description:`Plugin list item`}),N=n.array(M).openapi({description:`Plugin List`}),ne=n.object({fileName:n.string().optional().openapi({description:`Failed upload file name`,example:`bad.pkg`}),reason:k.openapi({description:`Upload failure reason`})}).openapi({description:`Plugin upload failure`}),re=n.object({plugins:n.array(j).openapi({description:`Parsed uploaded plugin list`}),failed:n.array(ne).optional().openapi({description:`Failed uploaded plugin files`})}).openapi({description:`Plugin upload response`}),ie=n.object({files:n.array(n.file()).min(1).openapi({description:`Plugin .pkg files or .zip package collection files`,example:[`example.pkg`]})}).openapi({description:`Plugin upload parameters`,example:{files:[`example.pkg`]}}),ae=n.object({pluginId:n.string().openapi({description:`Plugin unique id`,example:`getTime`}),version:n.string().openapi({description:`Plugin version id`,example:`1.0.0`}),etag:n.string().openapi({description:`Plugin etag`,example:`12345678`})}),oe=n.object({uniqueIds:n.array(ae).min(1).openapi({description:`Plugin unique id list`,example:[{pluginId:`getTime`,version:`1.0.0`,etag:`12345678`}]})}),se=n.object({count:n.number().int().nonnegative().openapi({description:`Number of disabled plugins removed`,example:2}),plugins:n.array(ae).openapi({description:`Removed disabled plugin unique ids`})}),P=n.object({url:n.string(),reason:g}),F={request:n.object({urls:n.array(n.string()).openapi({description:`Plugin install urls`,example:[`https://oss.example.com/plugin/getTime.pkg`,`https://oss.example.com/plugin/delay.pkg`]})}),response:n.object({failed:n.array(P).optional()}).openapi({description:`Plugin install response`,examples:[{},{failed:[{url:`https://oss.example.com/plugin/getTime.pkg`,reason:{en:`Failed to install plugin`,"zh-CN":`安装插件失败`}}]}]})},ce=n.object({types:te(ee).openapi({description:`Filter by plugin types`,example:[`tool`]}),tags:te(C).openapi({description:`Filter by plugin tags`,example:[`tools`,`productivity`]}),op:n.enum([`or`,`and`]).optional().openapi({description:`Filter operator for tags and types`,example:`or`}),sources:te(b).openapi({description:`Filter by plugin sources`,example:[`system`,`market`]})}),le=n.object({version:n.string().openapi({description:`Plugin version`,example:`1.0.0`}),versionDescription:k.optional().openapi({description:`Plugin version description`,example:{en:`Initial stable release`,"zh-CN":`首个稳定版本`}})}),ue=n.array(le).openapi({description:`Plugin version list`}),de=n.object({pluginId:n.string().openapi({description:`Plugin ID`,example:`getTime`}),source:n.string().openapi({description:`Plugin source`,example:`system`})}),fe=n.array(n.object({id:n.string().openapi({description:`Plugin tag ID`,example:`tools`}),name:k.openapi({description:`Plugin tag name`,example:{en:`Tools`,"zh-CN":`工具`}})})).openapi({description:`Plugin tag list`}),pe=n.object({minPods:n.number().int().nonnegative().openapi({description:`Minimum pods kept warm for one plugin`,example:0}),maxPods:n.number().int().positive().openapi({description:`Maximum pods allowed for one plugin`,example:5}),podTimeout:n.number().int().positive().openapi({description:`Plugin pod request timeout in milliseconds`,example:12e4}),maxConcurrentRequestsPerPod:n.number().int().positive().openapi({description:`Maximum concurrent requests per pod`,example:10})}).strict().refine(e=>e.minPods<=e.maxPods,{message:`minPods cannot be greater than maxPods`,path:[`minPods`]}).openapi({description:`Plugin runtime config. Global local-pool settings are configured by env only.`,example:{minPods:0,maxPods:5,podTimeout:12e4,maxConcurrentRequestsPerPod:10}}),me=n.object({pluginId:n.string().openapi({description:`Plugin ID`,example:`getTime`})}),he=n.object({pluginId:n.string().openapi({description:`Plugin ID`,example:`getTime`}),config:pe}),ge=n.object({pluginId:n.string().openapi({description:`Plugin ID`,example:`getTime`})}),_e=e.object({id:D.shape.id,name:D.shape.name,description:D.shape.description,toolDescription:D.shape.toolDescription}),ve=e.object({...O.omit({inputSchema:!0,outputSchema:!0,secretSchema:!0,children:!0,versionDescription:!0,permission:!0}).shape,source:b,isToolset:e.boolean(),children:e.array(_e).optional()}),ye=e.object({...O.shape,source:b,isLatestVersion:e.boolean(),isToolset:e.boolean()}),be=S.extend({fallbackLatestVersion:e.boolean().optional()}),xe=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()}),Se=e=>n.preprocess(e=>{if(e!=null)return Array.isArray(e)?e:[e]},n.array(e).optional()),Ce=e=>n.preprocess(e=>typeof e==`boolean`||typeof e!=`string`?e:e===`true`?!0:e===`false`?!1:e,e),we=n.object({...xe.shape}).openapi({description:`System variables provided to the tool when it is run`,example:{time:`example-time`,app:{id:`example-id`,name:`example-name`},chat:{chatId:`example-chat-id`,uId:`example-u-id`},invokeToken:`example-invoke-token`}}).openapi(`SystemVar`),Te=n.object({pluginId:n.string().openapi({description:`Plugin ID`,example:`getTime`}),version:n.string().optional().openapi({description:`Plugin version, optional. Empty or missing means latest version`,example:`1.0.0`}),source:n.string().optional().openapi({description:`Plugin source, optional, default is "system"`,example:`system`}),secrets:n.record(n.string(),n.any()).optional().openapi({description:`Tool secrets, key-value pairs`,example:{secretKey1:`secretValue1`,secretKey2:`secretValue2`}}),systemVar:we,input:n.record(n.string(),n.unknown()).openapi({description:`Tool input parameters, key-value pairs`,example:{param1:`value1`,param2:123,param3:{subParam1:`subValue1`}}}),childId:n.string().optional().openapi({description:`Child tool ID, only exists when the tool is part of a toolset`,example:`example-child-tool-id`})}),Ee=n.object({..._e.shape}),De=n.object({...ve.shape,children:n.array(Ee).optional()}),Oe=n.array(De),ke=n.object({...ye.shape}),Ae=n.object({pluginId:n.string().openapi({description:`Tool plugin ID`,example:`getTime`}),version:n.string().optional().openapi({description:`Tool version`,example:`1.0.0`}),source:b.optional().default(`system`).openapi({description:`Tool source`,example:`system`}),fallbackLatestVersion:Ce(be.shape.fallbackLatestVersion).openapi({description:`Fallback to latest version when the requested version is missing`,example:!0})}),je=n.object({tags:Se(C).openapi({description:`Filter by tool tags`,example:[`tools`]}),op:n.enum([`or`,`and`]).optional().openapi({description:`Filter operator for tags`,example:`or`}),sources:Se(b).openapi({description:`Filter by tool sources`,example:[`system`]})}),I=e=>e,Me=()=>void 0,Ne=({data:t,error:n})=>e.object({...t&&{data:t},...n&&{error:n}}),L=({data:e,error:t}={})=>Ne({data:e,error:t}),Pe=e.enum([`llm`,`embedding`,`rerank`,`tts`,`stt`]).enum,Fe=e.object({charsPointsPrice:e.number().optional(),inputPrice:e.number().optional(),outputPrice:e.number().optional()}),Ie=e.object({provider:e.string(),model:e.string(),name:e.string()}),Le=e.object({...Fe.shape,...Ie.shape,type:e.literal(Pe.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()}),Re=e.object({...Fe.shape,...Ie.shape,type:e.literal(Pe.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()}),ze=e.object({...Fe.shape,...Ie.shape,type:e.literal(Pe.rerank)}),Be=e.object({...Fe.shape,...Ie.shape,type:e.literal(Pe.tts),voices:e.array(e.object({label:e.string(),value:e.string()}))}),Ve=e.object({...Fe.shape,...Ie.shape,type:e.literal(Pe.stt)}),He=e.discriminatedUnion(`type`,[Le,Re,ze,Be,Ve]);e.object({id:e.string(),name:_,avatar:e.string()});const Ue=n.array(He).openapi({description:`Available model list`}),We=n.object({provider:n.string().openapi({description:`Model provider id`,example:`OpenAI`}),value:A.openapi({description:`Model provider display name`}),avatar:n.string().openapi({description:`Model provider logo url`,example:`https://example.com/models/OpenAI/logo`})}),Ge=n.object({channelId:n.number().openapi({description:`AIProxy channel id`,example:1}),name:A.openapi({description:`AIProxy provider display name`}),avatar:n.string().openapi({description:`Custom avatar url`})}),Ke=n.object({modelProviders:n.array(We).openapi({description:`Model provider list`}),aiproxyChannels:n.array(Ge).openapi({description:`AIProxy channel list`})}),R=[{bearerAuth:[]}],qe={List:I({meta:{method:`get`,path:`/models`,operationId:`model.list`,description:`Get a list of all available AI models`,summary:`List models`,tags:[`model`],security:R},response:{200:L({data:Ue}),500:L({error:g})}}),GetProviders:I({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:R},response:{200:L({data:Ke}),500:L({error:g})}})},Je={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:R},Ye={200:L({data:re}),400:L({error:g})},z={Upload:I({meta:Je,request:ie,response:Ye,openapi:{...Je,request:{body:{content:{"multipart/form-data":{schema:n.object({files:n.any()})}}}},responses:{200:{description:`HTTP 200 response`,content:{"application/json":{schema:Ye[200]}}},400:{description:`HTTP 400 response`,content:{"application/json":{schema:Ye[400]}}}}}}),Confirm:I({meta:{method:`post`,path:`/plugin/confirm`,operationId:`plugin.confirm`,description:`Confirm the uploaded plugin`,summary:`Confirm a plugin`,tags:[`plugin`],security:R},request:oe,response:{200:Me(),500:L({error:g})}}),PruneDisabled:I({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:R},response:{200:L({data:se}),500:L({error:g})}}),Install:I({meta:{method:`post`,path:`/plugin/install`,operationId:`plugin.install`,description:`Install a plugin`,summary:`Install a plugin`,tags:[`plugin`],security:R},request:F.request,response:{200:L({data:F.response}),500:L({error:g})}}),List:I({meta:{method:`get`,path:`/plugins`,operationId:`plugin.list`,description:`List plugins with optional filters`,summary:`List plugins`,tags:[`plugin`],security:R},request:ce,response:{200:L({data:N}),500:L({error:g})}}),Versions:I({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:R},request:de,response:{200:L({data:ue}),500:L({error:g})}}),TagList:I({meta:{method:`get`,path:`/plugin/tags`,operationId:`plugin.tags`,description:`List plugin tags`,summary:`List plugin tags`,tags:[`plugin`],security:R},response:{200:L({data:fe}),500:L({error:g})}}),RuntimeConfigGet:I({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:R},request:me,response:{200:L({data:pe}),500:L({error:g})}}),RuntimeConfigSet:I({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:R},request:he,response:{200:Me(),500:L({error:g})}}),RuntimeConfigReset:I({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:R},request:ge,response:{200:Me(),500:L({error:g})}})},Xe={Get:I({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:R},request:Ae,response:{200:L({data:ke}),404:L({error:g})}}),List:I({meta:{method:`get`,path:`/tools`,operationId:`tool.list`,description:`List tools with optional filters`,summary:`List tools`,tags:[`plugin`,`tool`],security:R},request:je,response:{200:L({data:Oe}),500:L({error:g})}}),RunStream:I({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:R},request:Te,response:{200:e.object({type:e.string()}),400:L({error:g})}})};Xe.RunStream;const Ze=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.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(Ze);const Qe=n.object(Ze.shape).openapi({description:`Workflow template`}),$e=n.array(Qe).openapi({description:`Workflow template list`}),et={List:I({meta:{method:`get`,path:`/list`,operationId:`workflow.list`,description:`Get a list of all available workflow templates`,summary:`List workflow templates`,tags:[`workflow`],security:R},response:{200:L({data:$e}),500:L({error:g})}})},tt=e.record(e.string(),e.unknown()),nt=e.enum([`response`,`error`,`stream`]).enum,rt=e.enum([`answer`,`fastAnswer`]);rt.enum;const it=e.object({type:rt,content:e.string()}),at=e.discriminatedUnion(`type`,[e.object({type:e.literal(nt.response),data:tt}),e.object({type:e.literal(nt.stream),data:it}),e.object({type:e.literal(nt.error),data:e.string()})]);e.object({pluginId:e.string(),version:e.preprocess(e=>{if(e!==``)return e},e.string().optional()),source:b.optional(),childId:e.string().optional(),input:e.record(e.string(),e.unknown()),secrets:e.record(e.string(),e.unknown()).optional(),systemVar:xe});var ot=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}}},st=class{transport;constructor(e){this.transport=new ot(e)}async run(e,t){try{let n=Te.parse(e),r=await this.transport.requestResponse({path:`/api${Xe.RunStream.meta.path}`,method:Xe.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(`
|