@coze/cli 0.1.4 → 0.1.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/lib/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";const e=require("./index-Bn9CretQ.js"),t=require("chalk"),i=require("node:child_process"),o=require("node:fs/promises"),n=require("node:os"),s=require("node:path"),r=require("node:http"),a=require("node:https"),c=require("undici"),d=require("node:fs"),p=require("path"),l=require("fs/promises"),u=require("fs"),_=require("form-data"),m=require("omelette"),g=require("lodash"),h=require("child_process"),f=require("commander");function y(e){const t=Object.create(null);if(e)for(const i in e)if("default"!==i){const o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}return t.default=e,Object.freeze(t)}require("mitt"),require("crypto"),require("url"),require("http"),require("https"),require("http2"),require("util"),require("stream"),require("assert"),require("tty"),require("os"),require("zlib"),require("events");const v=y(o),b=y(n),P=y(s);function S(e,t){return null!=e?e:t()}class T{format(e){const t=JSON.stringify(e,null,2);return t.endsWith("\n")?t:`${t}\n`}formatError(e){const t={code:e.code,errorName:S(e.errorName,(()=>"UNKNOWN_ERROR")),desc:S(e.desc,(()=>e.message)),trigger:S(e.trigger,(()=>null)),fix:S(e.fix,(()=>null)),example:S(e.example,(()=>null))},i=JSON.stringify(t,null,2);return i.endsWith("\n")?i:`${i}\n`}}function C(e,t){return null!=e?e:t()}function k(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function A(e){return e.replace(/\u001B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,"")}function E(e){return e>=4352&&e<=4447||(9001===e||9002===e||(e>=11904&&e<=12350||(e>=12352&&e<=42191||(e>=44032&&e<=55203||(e>=63744&&e<=64255||(e>=65040&&e<=65049||(e>=65072&&e<=65135||(e>=65280&&e<=65376||(e>=65504&&e<=65510||(e>=127744&&e<=129695||e>=131072&&e<=262141))))))))))}function R(e){const t=A(e);if(!t)return 0;const i=/[\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/u;let o=0;const n=Array.from(t);for(let e=0;e<n.length;e+=1){const t=C(n[e],(()=>""));if(i.test(t))continue;const s=t.codePointAt(0);void 0!==s&&(o+=E(s)?2:1)}return o}function j(e,t){const i=R(e);return i>=t?e:`${e}${" ".repeat(t-i)}`}function z(e,t){if(t<=0)return"";if(R(e)<=t)return e;if(1===t)return"…";const i=A(e),o=Array.from(i),n=Math.max(0,t-R("…"));let s="",r=0;for(let e=0;e<o.length;e+=1){const t=C(o[e],(()=>"")),i=R(t);if(r+i>n)break;s+=t,r+=i}return`${s}…`}function w(e,t={}){if(0===e.length)return"";const i=function(e,t){if(0===e.length)return[];const i=new Set,o=[],n=C(e[0],(()=>({})));for(const e of Object.keys(n))i.has(e)||(i.add(e),o.push(e));for(const t of e)for(const e of Object.keys(t))i.has(e)||(i.add(e),o.push(e));const s=[];for(const t of o){let i=R(t);for(const o of e){const e=o[t],n=void 0===e?"":String(e);i=Math.max(i,R(n))}s.push({key:t,width:i})}const r=C(t.columnGap,(()=>2)),a=C(C(t.maxWidth,(()=>process.stdout.columns)),(()=>120)),c=Math.max(1,Math.floor((a+r)/(6+r))),d=Math.min(C(t.maxColumns,(()=>c)),c);s.length>d&&s.splice(d);const p=Math.max(0,a-r*Math.max(0,s.length-1));for(;s.reduce(((e,t)=>e+t.width),0)>p;){let e=-1,t=-1;for(let i=0;i<s.length;i+=1){const o=C(k([s,"access",e=>e[i],"optionalAccess",e=>e.width]),(()=>0));o>t&&(t=o,e=i)}if(-1===e)break;const i=C(k([s,"access",t=>t[e],"optionalAccess",e=>e.width]),(()=>0));if(i<=6)break;s[e]={...s[e],width:i-1}}for(let e=0;e<s.length;e+=1){const t=s[e];t&&(s[e]={...t,width:Math.max(6,t.width)})}return s}(e,t);if(0===i.length)return"";const o=C(t.columnGap,(()=>2)),n=" ".repeat(o),s=i.map((e=>j(z(e.key,e.width),e.width))).join(n),r=i.map((e=>"-".repeat(e.width))).join(n),a=[];for(const t of e){const e=i.map((e=>{const i=t[e.key];return j(z(void 0===i?"":String(i),e.width),e.width)}));a.push(e.join(n))}return`${[s,r,...a].join("\n")}\n`}function U(e,t={}){const i=Object.entries(e);if(0===i.length)return"";let o=0;for(const[e]of i)o=Math.max(o,R(e));const n=C(C(t.maxWidth,(()=>process.stdout.columns)),(()=>120)),s=C(t.columnGap,(()=>2)),r=C(t.minValueWidth,(()=>12));let a=Math.min(o,C(t.keyMaxWidth,(()=>32)));const c=Math.max(6,n-s-r);a=Math.min(a,c);const d=Math.max(0,n-a-s),p=" ".repeat(s);return`${i.map((([e,t])=>{const i=j(z(e,a),a),o=(void 0===t?"undefined":null===t?"null":String(t)).replace(/\s*\n\s*/g," "),n=d>0?z(o,d):"";return`${i}${p}${n}`})).join("\n")}\n`}function L(e,t="",i=0){const o={};if(null==e)return o;if("object"!=typeof(n=e)||null===n||Array.isArray(n))return o;var n;for(const[n,s]of Object.entries(e)){const e=t?`${t}.${n}`:n;if(null!=s)if(Array.isArray(s))i>=5?o[e]="[Array]":0===s.length?o[e]="[]":s.every((e=>"object"!=typeof e||null===e))?o[e]=s.map((e=>{return String((i=()=>"null",null!=(t=e)?t:i()));var t,i})).join(", "):o[e]="[Array]";else if("object"!=typeof s)o[e]=s;else if(i>=5)o[e]="[Object]";else{const t=L(s,e,i+1);Object.assign(o,t)}else o[e]=s}return o}function O(e,t){return null!=e?e:t()}function I(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}class B{format(e){if(null===e)return"null\n";if(void 0===e)return"undefined\n";if(Array.isArray(e)){if(0===e.length)return"\n";if(t=e,Array.isArray(t)&&t.length>0&&t.every(I)){return w(e.map((e=>L(e))))}return function(e){return Array.isArray(e)&&e.length>0&&e.every((e=>null==e||"object"!=typeof e))}(e)?`${e.map((e=>String(O(e,(()=>"null"))))).join("\n")}\n`:"[Array]\n"}var t;if(I(e)){const t=L(e);return 0===Object.keys(t).length?"{}\n":U(t)}return`${String(e)}\n`}formatError(e){const t=[],i=O(e.errorName,(()=>"UNKNOWN_ERROR")),o=O(e.desc,(()=>e.message));return t.push(`ERROR [${e.code}] ${i}: ${o}`),e.trigger&&t.push(` Trigger: ${e.trigger}`),e.fix&&t.push(` Fix: ${e.fix}`),e.example&&t.push(` Example: ${e.example}`),e.details&&(t.push(" Error Details:"),t.push(`${function(e,t){if(null==e)return"";if("string"==typeof e)return`${t}${e}\n`;if(Array.isArray(e))return 0===e.length?"":`${e.map((e=>"object"==typeof e&&null!==e?U(L(e)):String(e))).map((e=>`${t}- ${e.trim()}`)).join("\n")}\n`;if(I(e)){const i=L(e);return 0===Object.keys(i).length?"":`${U(i).split("\n").filter((e=>e.trim())).map((e=>`${t}${e}`)).join("\n")}\n`}return`${t}${String(e)}\n`}(e.details," ")}`)),`${t.join("\n")}\n`}}function q(e,t){return null!=e?e:t()}function x(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function D(e,t){if(null==e)return;const i=String(e).replace(/\s*\n\s*/g," ").replace(/\s+/g," ").trim();return i?i.length<=t?i:`${i.slice(0,Math.max(0,t-3))}...`:void 0}function M(e){const t=x([e,"optionalAccess",e=>e.help,"optionalAccess",e=>e.errors]);if(t&&t.length>0)return t;const i=x([e,"optionalAccess",e=>e.errors]);return Array.isArray(i)?i:void 0}function G(t,i){const o=q(t.trigger,(()=>function(e){if(!e||0===e.length)return;return D(("coze"===e[0]?e:["coze",...e]).join(" "),150)}(x([i,"optionalAccess",e=>e.argv])))),n=x([M,"call",e=>e(x([i,"optionalAccess",e=>e.commandConfig])),"optionalAccess",e=>e.find,"call",e=>e((e=>e.code===t.code))]),s=q(x([n,"optionalAccess",e=>e.name]),(()=>e.ErrorNameByCode[t.code])),r=q(D(s,80),(()=>"UNKNOWN_ERROR"));let a=s;t.isMessageExplicit&&t.message.trim()?a=t.message:x([n,"optionalAccess",e=>e.desc])&&(a=n.desc);const c=q(D(a,200),(()=>"An unexpected error occurred")),d=q(D(t.fix,150),(()=>D(x([n,"optionalAccess",e=>e.fix]),150))),p=q(D(t.example,150),(()=>D(x([n,"optionalAccess",e=>e.example]),150)));return{code:t.code,errorName:r,desc:c,trigger:o,fix:d,example:p}}function N(e,t){const i=G(e,t);return e.errorName=i.errorName,e.desc=i.desc,e.message=i.desc,e.trigger=i.trigger,e.fix=i.fix,e.example=i.example,e}function F(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}var $;!function(e){e[e.NOT_LOGIN=700012006]="NOT_LOGIN"}($||($={}));const V=(t,i)=>{const o=N(function(t){if(t instanceof e.CozeError)return t;if(t instanceof e.ChatCoreError){const{ext:i}=t;let o=e.ErrorCode.E5000;"number"==typeof i.code&&(i.code===$.NOT_LOGIN?o=e.ErrorCode.E2001:i.code>=500&&(o=e.ErrorCode.E5002));const{message:n}=t;return new e.CozeError(o,n,i)}if(e.isHttpError(t)){const i=t.toJSON();let o=e.ErrorCode.E5000;const n=F([t,"access",e=>e.response,"optionalAccess",e=>e.status]);t.code===$.NOT_LOGIN||401===n?o=e.ErrorCode.E2001:"ECONNREFUSED"===t.code||"ETIMEDOUT"===t.code?o=e.ErrorCode.E5001:403===n?o=e.ErrorCode.E2003:404===n?o=e.ErrorCode.E3000:429===n?o=e.ErrorCode.E4001:n&&n>=500&&(o=e.ErrorCode.E5002);const s=F([t,"access",e=>e.response,"optionalAccess",e=>e.headers,"optionalAccess",e=>e["x-tt-logid"]]),{message:r}=t;return new e.CozeError(o,r,{logId:s,...i})}return t instanceof Error?new e.CozeError(e.ErrorCode.E5000,t.message,t.stack):"string"==typeof t?new e.CozeError(e.ErrorCode.E5000,t):new e.CozeError(e.ErrorCode.E5000,"An unexpected error occurred")}(t),i?{argv:i.argv,commandConfig:i.commandConfig}:void 0);var n,s;if(o.code===e.ErrorCode.E2001&&process.stdout.write(`${n=o.desc,s=()=>o.message,null!=n?n:s()}\n`),i)i.response.eprint(o);else{const e=new B;process.stderr.write(e.formatError(o))}process.exit(e.exitCodeForError(o.code))};const W=P.join(b.homedir(),".coze"),H=P.join(W,"config.json"),K=P.join(process.cwd(),".cozerc.json"),J={apiBaseUrl:"https://code.coze.cn/",openApiBaseUrl:"https://api.coze.cn",integrationApiBaseUrl:"https://integration.coze.cn",clientId:"95438868623436343239609434490626.app.coze",defaultOutputFormat:"json"};async function Q(e){try{const t=await v.readFile(e,"utf8");return JSON.parse(t)}catch(e){return}}function Z(){const e={};return process.env.COZE_API_TOKEN&&(e.accessToken=process.env.COZE_API_TOKEN),process.env.COZE_ORG_ID&&(e.organizationId=process.env.COZE_ORG_ID),process.env.COZE_ENTERPRISE_ID&&(e.enterpriseId=process.env.COZE_ENTERPRISE_ID),process.env.COZE_SPACE_ID&&(e.spaceId=process.env.COZE_SPACE_ID),"global"!==process.env.COZE_CONFIG_SCOPE&&"local"!==process.env.COZE_CONFIG_SCOPE||(e.configScope=process.env.COZE_CONFIG_SCOPE),process.env.COZE_AUTO_CHECK_UPDATE&&(e.autoCheckUpdate="true"===process.env.COZE_AUTO_CHECK_UPDATE),process.env.COZE_DISABLE_TELEMETRY&&(e.disableTelemetry="true"===process.env.COZE_DISABLE_TELEMETRY),e}async function Y(e){const t=process.env.COZE_CONFIG_FILE,[i,o,n,s]=await Promise.all([Q(H),Q(K),t?Q(t):void 0,e?Q(e):void 0]),r=Z();return{...J,...i,...o,...n,...s,...r}}async function X(e,t=function(e,t){return null!=e?e:t()}(Z().configScope,(()=>"global"))){const i=process.env.COZE_CONFIG_FILE,o=i||("global"===t?H:K),n=P.dirname(o);try{await v.mkdir(n,{recursive:!0});const t={...await Q(o)||{},...e};await v.writeFile(o,JSON.stringify(t,null,2),"utf8")}catch(e){throw new Error(`Failed to save config to ${o}: ${e}`)}}async function ee(e){const t=process.env.COZE_CONFIG_FILE;if(t){const i=await Q(t);if(i&&e in i){try{delete i[e],await v.writeFile(t,JSON.stringify(i,null,2),"utf8")}catch(e){throw new Error(`Failed to delete config from ${t}: ${e}`)}return}}let i=K,o=await Q(i);if(o&&e in o||(i=H,o=await Q(i)),o&&e in o)try{delete o[e],await v.writeFile(i,JSON.stringify(o,null,2),"utf8")}catch(e){throw new Error(`Failed to delete config from ${i}: ${e}`)}}async function te(){const e=process.env.COZE_CONFIG_FILE,[t,i,o]=await Promise.all([Q(H),Q(K),e?Q(e):void 0]),n=Z(),s=new Set([...Object.keys(J),...Object.keys(t||{}),...Object.keys(i||{}),...Object.keys(o||{}),...Object.keys(n)]),r=[];for(const e of Array.from(s)){const s=e;let a,c="default";s in n&&void 0!==n[s]?(a=n[s],c="env"):o&&s in o&&void 0!==o[s]?(a=String(o[s]),c="env-file"):i&&s in i&&void 0!==i[s]?(a=String(i[s]),c="local"):t&&s in t&&void 0!==t[s]?(a=String(t[s]),c="global"):s in J&&(a=String(J[s]),c="default"),r.push({key:e,value:a,source:c})}return r}const ie="0.1.4",oe="@coze/cli";function ne(){return ie}function se(e,t){const i=e=>{const t=e.replace(/^v/,"").split(".");return{major:parseInt(t[0]||"0",10),minor:parseInt(t[1]||"0",10),patch:parseInt(t[2]||"0",10)}},o=i(e),n=i(t);return n.major!==o.major?n.major>o.major:n.minor!==o.minor?n.minor>o.minor:n.patch>o.patch}async function re(t,o=!1,n="latest"){const s=ne(),{config:r}=t;if(!o&&r.latestVersion&&r.lastCheckTime&&Date.now()-r.lastCheckTime<864e5)return{currentVersion:s,latestVersion:r.latestVersion,hasUpdate:se(s,r.latestVersion)};const a=function(){try{return i.execSync("npm config get registry",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim().replace(/\/+$/,"")}catch(e){return"https://registry.npmjs.org"}}(),c=await async function(t,i="latest"){const o=`${t}/${oe}/${i}`,n=await e.customFetch.fetch(o,{headers:{accept:"application/json"}});if(!n.ok)throw new Error(`Failed to fetch latest version: ${n.status} ${n.statusText}`);return(await n.json()).version}(a,n);return await X({latestVersion:c,lastCheckTime:Date.now()},r.configScope),{currentVersion:s,latestVersion:c,hasUpdate:se(s,c)}}async function ae(e,i){if(await i(),!0===e.config.autoCheckUpdate)try{const i=await re(e);if(i.hasUpdate){const o=`\nUpdate available: ${t.gray(i.currentVersion)} → ${t.green(i.latestVersion)}\nRun ${t.cyan("coze upgrade")} to update\n`;e.ui.info(o)}}catch(e){}}var ce=e.requireSrc();const de=e.getDefaultExportFromCjs(ce);function pe(e){var t,i,o=e.transport,n=e.endpoint,s=e.size,r=void 0===s?10:s,a=e.wait,c=void 0===a?1e3:a,d=[],p=0;function l(){if(d.length){var e=this.getBatchData();o.post({url:n,data:e,fail:function(i){t&&t(i,e)},success:function(){i&&i(e)}}),d=[]}}return{getSize:function(){return r},getWait:function(){return c},setSize:function(e){r=e},setWait:function(e){c=e},getEndpoint:function(){return n},setEndpoint:function(e){n=e},send:function(e){d.push(e),d.length>=r&&l.call(this),clearTimeout(p),p=setTimeout(l.bind(this),c)},flush:function(){clearTimeout(p),l.call(this)},getBatchData:function(){return d.length?(e=d,JSON.stringify({ev_type:"batch",list:e})):"";var e},clear:function(){clearTimeout(p),d=[]},fail:function(e){t=e},success:function(e){i=e}}}
2
+ "use strict";const e=require("./fetch-client-DwHNkYBR.js"),t=require("./index-BVFZAFCX.js"),i=require("chalk"),s=require("node:child_process"),o=require("./task-worker-CSKiBcYu.js"),n=require("node:http"),r=require("node:https"),a=require("node:buffer"),c=require("node:path"),l=require("node:os"),d=require("node:fs"),p=require("undici"),u=require("node:fs/promises"),_=require("path"),m=require("fs/promises"),g=require("fs"),h=require("form-data"),f=require("omelette"),y=require("lodash"),v=require("child_process"),b=require("ws"),w=require("@byted/frontier-web-sdk"),P=require("commander");function S(e,t){return null!=e?e:t()}require("crypto"),require("url"),require("http"),require("https"),require("http2"),require("util"),require("stream"),require("assert"),require("tty"),require("os"),require("zlib"),require("events"),require("mitt"),require("process");class T{format(e){const t=JSON.stringify(e,null,2);return t.endsWith("\n")?t:`${t}\n`}formatError(e){const t={code:e.code,errorName:S(e.errorName,(()=>"UNKNOWN_ERROR")),desc:S(e.desc,(()=>e.message)),trigger:S(e.trigger,(()=>null)),fix:S(e.fix,(()=>null)),example:S(e.example,(()=>null))},i=JSON.stringify(t,null,2);return i.endsWith("\n")?i:`${i}\n`}}function C(e,t){return null!=e?e:t()}function k(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function A(e){return e.replace(/\u001B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,"")}function E(e){return e>=4352&&e<=4447||(9001===e||9002===e||(e>=11904&&e<=12350||(e>=12352&&e<=42191||(e>=44032&&e<=55203||(e>=63744&&e<=64255||(e>=65040&&e<=65049||(e>=65072&&e<=65135||(e>=65280&&e<=65376||(e>=65504&&e<=65510||(e>=127744&&e<=129695||e>=131072&&e<=262141))))))))))}function I(e){const t=A(e);if(!t)return 0;const i=/[\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/u;let s=0;const o=Array.from(t);for(let e=0;e<o.length;e+=1){const t=C(o[e],(()=>""));if(i.test(t))continue;const n=t.codePointAt(0);void 0!==n&&(s+=E(n)?2:1)}return s}function R(e,t){const i=I(e);return i>=t?e:`${e}${" ".repeat(t-i)}`}function z(e,t){if(t<=0)return"";if(I(e)<=t)return e;if(1===t)return"…";const i=A(e),s=Array.from(i),o=Math.max(0,t-I("…"));let n="",r=0;for(let e=0;e<s.length;e+=1){const t=C(s[e],(()=>"")),i=I(t);if(r+i>o)break;n+=t,r+=i}return`${n}…`}function U(e,t={}){if(0===e.length)return"";const i=function(e,t){if(0===e.length)return[];const i=new Set,s=[],o=C(e[0],(()=>({})));for(const e of Object.keys(o))i.has(e)||(i.add(e),s.push(e));for(const t of e)for(const e of Object.keys(t))i.has(e)||(i.add(e),s.push(e));const n=[];for(const t of s){let i=I(t);for(const s of e){const e=s[t],o=void 0===e?"":String(e);i=Math.max(i,I(o))}n.push({key:t,width:i})}const r=C(t.columnGap,(()=>2)),a=C(C(t.maxWidth,(()=>process.stdout.columns)),(()=>120)),c=Math.max(1,Math.floor((a+r)/(6+r))),l=Math.min(C(t.maxColumns,(()=>c)),c);n.length>l&&n.splice(l);const d=Math.max(0,a-r*Math.max(0,n.length-1));for(;n.reduce(((e,t)=>e+t.width),0)>d;){let e=-1,t=-1;for(let i=0;i<n.length;i+=1){const s=C(k([n,"access",e=>e[i],"optionalAccess",e=>e.width]),(()=>0));s>t&&(t=s,e=i)}if(-1===e)break;const i=C(k([n,"access",t=>t[e],"optionalAccess",e=>e.width]),(()=>0));if(i<=6)break;n[e]={...n[e],width:i-1}}for(let e=0;e<n.length;e+=1){const t=n[e];t&&(n[e]={...t,width:Math.max(6,t.width)})}return n}(e,t);if(0===i.length)return"";const s=C(t.columnGap,(()=>2)),o=" ".repeat(s),n=i.map((e=>R(z(e.key,e.width),e.width))).join(o),r=i.map((e=>"-".repeat(e.width))).join(o),a=[];for(const t of e){const e=i.map((e=>{const i=t[e.key];return R(z(void 0===i?"":String(i),e.width),e.width)}));a.push(e.join(o))}return`${[n,r,...a].join("\n")}\n`}function j(e,t={}){const i=Object.entries(e);if(0===i.length)return"";let s=0;for(const[e]of i)s=Math.max(s,I(e));const o=C(C(t.maxWidth,(()=>process.stdout.columns)),(()=>120)),n=C(t.columnGap,(()=>2)),r=C(t.minValueWidth,(()=>12));let a=Math.min(s,C(t.keyMaxWidth,(()=>32)));const c=Math.max(6,o-n-r);a=Math.min(a,c);const l=Math.max(0,o-a-n),d=" ".repeat(n);return`${i.map((([e,t])=>{const i=R(z(e,a),a),s=(void 0===t?"undefined":null===t?"null":String(t)).replace(/\s*\n\s*/g," "),o=l>0?z(s,l):"";return`${i}${d}${o}`})).join("\n")}\n`}function L(e,t="",i=0){const s={};if(null==e)return s;if("object"!=typeof(o=e)||null===o||Array.isArray(o))return s;var o;for(const[o,n]of Object.entries(e)){const e=t?`${t}.${o}`:o;if(null!=n)if(Array.isArray(n))i>=5?s[e]="[Array]":0===n.length?s[e]="[]":n.every((e=>"object"!=typeof e||null===e))?s[e]=n.map((e=>{return String((i=()=>"null",null!=(t=e)?t:i()));var t,i})).join(", "):s[e]="[Array]";else if("object"!=typeof n)s[e]=n;else if(i>=5)s[e]="[Object]";else{const t=L(n,e,i+1);Object.assign(s,t)}else s[e]=n}return s}function O(e,t){return null!=e?e:t()}function B(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}class x{format(e){if(null===e)return"null\n";if(void 0===e)return"undefined\n";if(Array.isArray(e)){if(0===e.length)return"\n";if(t=e,Array.isArray(t)&&t.length>0&&t.every(B)){return U(e.map((e=>L(e))))}return function(e){return Array.isArray(e)&&e.length>0&&e.every((e=>null==e||"object"!=typeof e))}(e)?`${e.map((e=>String(O(e,(()=>"null"))))).join("\n")}\n`:"[Array]\n"}var t;if(B(e)){const t=L(e);return 0===Object.keys(t).length?"{}\n":j(t)}return`${String(e)}\n`}formatError(e){const t=[],i=O(e.errorName,(()=>"UNKNOWN_ERROR")),s=O(e.desc,(()=>e.message));return t.push(`ERROR [${e.code}] ${i}: ${s}`),e.trigger&&t.push(` Trigger: ${e.trigger}`),e.fix&&t.push(` Fix: ${e.fix}`),e.example&&t.push(` Example: ${e.example}`),e.details&&(t.push(" Error Details:"),t.push(`${function(e,t){if(null==e)return"";if("string"==typeof e)return`${t}${e}\n`;if(Array.isArray(e))return 0===e.length?"":`${e.map((e=>"object"==typeof e&&null!==e?j(L(e)):String(e))).map((e=>`${t}- ${e.trim()}`)).join("\n")}\n`;if(B(e)){const i=L(e);return 0===Object.keys(i).length?"":`${j(i).split("\n").filter((e=>e.trim())).map((e=>`${t}${e}`)).join("\n")}\n`}return`${t}${String(e)}\n`}(e.details," ")}`)),`${t.join("\n")}\n`}}function q(e,t){return null!=e?e:t()}function D(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function M(e,t){if(null==e)return;const i=String(e).replace(/\s*\n\s*/g," ").replace(/\s+/g," ").trim();return i?i.length<=t?i:`${i.slice(0,Math.max(0,t-3))}...`:void 0}function G(e){const t=D([e,"optionalAccess",e=>e.help,"optionalAccess",e=>e.errors]);if(t&&t.length>0)return t;const i=D([e,"optionalAccess",e=>e.errors]);return Array.isArray(i)?i:void 0}function $(t,i){const s=q(t.trigger,(()=>function(e){if(!e||0===e.length)return;return M(("coze"===e[0]?e:["coze",...e]).join(" "),150)}(D([i,"optionalAccess",e=>e.argv])))),o=D([G,"call",e=>e(D([i,"optionalAccess",e=>e.commandConfig])),"optionalAccess",e=>e.find,"call",e=>e((e=>e.code===t.code))]),n=q(D([o,"optionalAccess",e=>e.name]),(()=>e.ErrorNameByCode[t.code])),r=q(M(n,80),(()=>"UNKNOWN_ERROR"));let a=n;t.isMessageExplicit&&t.message.trim()?a=t.message:D([o,"optionalAccess",e=>e.desc])&&(a=o.desc);const c=q(M(a,200),(()=>"An unexpected error occurred")),l=q(M(t.fix,150),(()=>M(D([o,"optionalAccess",e=>e.fix]),150))),d=q(M(t.example,150),(()=>M(D([o,"optionalAccess",e=>e.example]),150)));return{code:t.code,errorName:r,desc:c,trigger:s,fix:l,example:d}}function N(e,t){const i=$(e,t);return e.errorName=i.errorName,e.desc=i.desc,e.message=i.desc,e.trigger=i.trigger,e.fix=i.fix,e.example=i.example,e}function F(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}var V;!function(e){e[e.NOT_LOGIN=700012006]="NOT_LOGIN"}(V||(V={}));const W=(i,s)=>{const o=N(function(i){if(i instanceof e.CozeError)return i;if(i instanceof t.ChatCoreError){const{ext:t}=i;let s=e.ErrorCode.E5000;"number"==typeof t.code&&(t.code===V.NOT_LOGIN?s=e.ErrorCode.E2001:t.code>=500&&(s=e.ErrorCode.E5002));const{message:o}=i;return new e.CozeError(s,o,t)}if(e.isHttpError(i)){const t=i.toJSON();let s=e.ErrorCode.E5000;const o=F([i,"access",e=>e.response,"optionalAccess",e=>e.status]);i.code===V.NOT_LOGIN||401===o?s=e.ErrorCode.E2001:"ECONNREFUSED"===i.code||"ETIMEDOUT"===i.code?s=e.ErrorCode.E5001:403===o?s=e.ErrorCode.E2003:404===o?s=e.ErrorCode.E3000:429===o?s=e.ErrorCode.E4001:o&&o>=500&&(s=e.ErrorCode.E5002);const n=F([i,"access",e=>e.response,"optionalAccess",e=>e.headers,"optionalAccess",e=>e["x-tt-logid"]]),{message:r}=i;return new e.CozeError(s,r,{logId:n,...t})}return i instanceof Error?new e.CozeError(e.ErrorCode.E5000,i.message,i.stack):"string"==typeof i?new e.CozeError(e.ErrorCode.E5000,i):new e.CozeError(e.ErrorCode.E5000,"An unexpected error occurred")}(i),s?{argv:s.argv,commandConfig:s.commandConfig}:void 0);var n,r;if(o.code===e.ErrorCode.E2001&&process.stdout.write(`${n=o.desc,r=()=>o.message,null!=n?n:r()}\n`),s)s.response.eprint(o);else{const e=new x;process.stderr.write(e.formatError(o))}process.exit(e.exitCodeForError(o.code))};const H="0.1.6",K="@coze/cli";function J(){return H}function Q(e,t){const i=e=>{const t=e.replace(/^v/,"").split(".");return{major:parseInt(t[0]||"0",10),minor:parseInt(t[1]||"0",10),patch:parseInt(t[2]||"0",10)}},s=i(e),o=i(t);return o.major!==s.major?o.major>s.major:o.minor!==s.minor?o.minor>s.minor:o.patch>s.patch}async function Y(t,i=!1,n="latest"){const r=J(),{config:a}=t;if(!i&&a.latestVersion&&a.lastCheckTime&&Date.now()-a.lastCheckTime<864e5)return{currentVersion:r,latestVersion:a.latestVersion,hasUpdate:Q(r,a.latestVersion)};const c=function(){try{return s.execSync("npm config get registry",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim().replace(/\/+$/,"")}catch(e){return"https://registry.npmjs.org"}}(),l=await async function(t,i="latest"){const s=`${t}/${K}/${i}`,o=await e.customFetch.fetch(s,{headers:{accept:"application/json"}});if(!o.ok)throw new Error(`Failed to fetch latest version: ${o.status} ${o.statusText}`);return(await o.json()).version}(c,n);return await o.saveConfig({latestVersion:l,lastCheckTime:Date.now()},a.configScope),{currentVersion:r,latestVersion:l,hasUpdate:Q(r,l)}}async function Z(e,t){if(await t(),!0===e.config.autoCheckUpdate)try{const t=await Y(e);if(t.hasUpdate){const s=`\nUpdate available: ${i.gray(t.currentVersion)} → ${i.green(t.latestVersion)}\nRun ${i.cyan("coze upgrade")} to update\n`;e.ui.info(s)}}catch(e){}}var X=e.requireSrc();const ee=e.getDefaultExportFromCjs(X);function te(e){var t,i,s=e.transport,o=e.endpoint,n=e.size,r=void 0===n?10:n,a=e.wait,c=void 0===a?1e3:a,l=[],d=0;function p(){if(l.length){var e=this.getBatchData();s.post({url:o,data:e,fail:function(i){t&&t(i,e)},success:function(){i&&i(e)}}),l=[]}}return{getSize:function(){return r},getWait:function(){return c},setSize:function(e){r=e},setWait:function(e){c=e},getEndpoint:function(){return o},setEndpoint:function(e){o=e},send:function(e){l.push(e),l.length>=r&&p.call(this),clearTimeout(d),d=setTimeout(p.bind(this),c)},flush:function(){clearTimeout(d),p.call(this)},getBatchData:function(){return l.length?(e=l,JSON.stringify({ev_type:"batch",list:e})):"";var e},clear:function(){clearTimeout(d),l=[]},fail:function(e){t=e},success:function(e){i=e}}}
3
3
  /*! *****************************************************************************
4
4
  Copyright (c) Microsoft Corporation.
5
5
 
@@ -13,4 +13,4 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
13
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
14
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
15
  PERFORMANCE OF THIS SOFTWARE.
16
- ***************************************************************************** */var le=function(){return le=Object.assign||function(e){for(var t,i=1,o=arguments.length;i<o;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},le.apply(this,arguments)};function ue(e,t){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var o,n,s=i.call(e),r=[];try{for(;(void 0===t||t-- >0)&&!(o=s.next()).done;)r.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}return r}function _e(e,t,i){if(2===arguments.length)for(var o,n=0,s=t.length;n<s;n++)!o&&n in t||(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}var me=function(){return{}};function ge(e){return e}function he(e){return"object"==typeof e&&null!==e}var fe=Object.prototype;function ye(e){return"[object Array]"===fe.toString.call(e)}function ve(e){return"number"==typeof e}function be(e){return"string"==typeof e}function Pe(e,t){if(!ye(e))return!1;if(0===e.length)return!1;for(var i=0;i<e.length;){if(e[i]===t)return!0;i++}return!1}var Se=function(e,t){if(!ye(e))return e;var i=e.indexOf(t);if(i>=0){var o=e.slice();return o.splice(i,1),o}return e};function Te(e){try{return be(e)?e:JSON.stringify(e)}catch(e){return"[FAILED_TO_STRINGIFY]:"+String(e)}}var Ce="".padStart?function(e,t){return void 0===t&&(t=8),e.padStart(t," ")}:function(e){return e},ke=0,Ae=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,_e(["[SDK]",Date.now(),Ce(""+ke++)],ue(e),!1))},Ee=0,Re=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn.apply(console,_e(["[SDK]",Date.now(),Ce(""+Ee++)],ue(e),!1))},je=function(e){return Math.random()<Number(e)},ze=function(e,t){return e<Number(t)},we=function(e){return function(t){for(var i=t,o=0;o<e.length&&i;o++)try{i=e[o](i)}catch(e){Ae(e)}return i}};function Ue(){var e=function(){for(var e=new Array(16),t=0,i=0;i<16;i++)3&i||(t=4294967296*Math.random()),e[i]=t>>>((3&i)<<3)&255;return e}();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e){for(var t=[],i=0;i<256;++i)t[i]=(i+256).toString(16).substr(1);var o=0,n=t;return[n[e[o++]],n[e[o++]],n[e[o++]],n[e[o++]],"-",n[e[o++]],n[e[o++]],"-",n[e[o++]],n[e[o++]],"-",n[e[o++]],n[e[o++]],"-",n[e[o++]],n[e[o++]],n[e[o++]],n[e[o++]],n[e[o++]],n[e[o++]]].join("")}(e)}var Le=["init","start","config","beforeDestroy","provide","beforeReport","report","beforeBuild","build","beforeSend","send","beforeConfig"];function Oe(e){var t,i,o=e.builder,n=e.createSender,s=e.createDefaultConfig,r=e.createConfigManager,a=e.userConfigNormalizer,c=e.initConfigNormalizer,d=e.validateInitConfig,p={};Le.forEach((function(e){return p[e]=[]}));var l=!1,u=!1,_=!1,m=[],g=[],h=function(){var e=!1,t={},i=function(e){e.length&&e.forEach((function(e){try{e()}catch(e){}})),e.length=0},o=function(e){t[e]&&t[e].forEach((function(e){i(e[1])})),t[e]=void 0};return{set:function(o,n,s){t[o]?t[o].push([n,s]):t[o]=[[n,s]],e&&i(s)},has:function(e){return!!t[e]},remove:o,removeByEvType:function(e){Object.keys(t).forEach((function(o){t[o]&&t[o].forEach((function(t){t[0]===e&&i(t[1])}))}))},clear:function(){e=!0,Object.keys(t).forEach((function(e){o(e)}))}}}(),f={getBuilder:function(){return o},getSender:function(){return t},getPreStartQueue:function(){return m},init:function(e){if(l)Re("already inited");else{if(!(e&&he(e)&&d(e)))throw new Error("invalid InitConfig, init failed");var o=s(e);if(!o)throw new Error("defaultConfig missing");var a=c(e);if((i=r(o)).setConfig(a),i.onChange((function(){y("config")})),!(t=n(i.getConfig())))throw new Error("sender missing");l=!0,y("init",!0)}},set:function(e){l&&e&&he(e)&&(y("beforeConfig",!1,e),null==i||i.setConfig(e))},config:function(e){if(l)return e&&he(e)&&(y("beforeConfig",!1,e),null==i||i.setConfig(a(e))),null==i?void 0:i.getConfig()},provide:function(e,t){Pe(g,e)?Re("cannot provide "+e+", reserved"):(f[e]=t,y("provide",!1,e))},start:function(){l&&(u||null==i||i.onReady((function(){u=!0,y("start",!0),function(e){var t=e.getPreStartQueue();t.forEach((function(t){return e.build(t)})),t.length=0}(f)})))},report:function(e){if(e){var t=we(p.beforeReport)(e);if(t){var i=we(p.report)(t);i&&(u?this.build(i):function(e,t,i){if(t.push(i),!(t.length<500)){var o=t.splice(0,50);e.savePreStartDataToDb&&e.savePreStartDataToDb(o)}}(f,m,i))}}},build:function(e){if(u){var t=we(p.beforeBuild)(e);if(t){var i=o.build(t);if(i){var n=we(p.build)(i);n&&this.send(n)}}}},send:function(e){if(u){var i=we(p.beforeSend)(e);i&&(t.send(i),y("send",!1,i))}},destroy:function(){h.clear(),_=!0,m.length=0,y("beforeDestroy",!0)},on:function(e,t){if("init"===e&&l||"start"===e&&u||"beforeDestroy"===e&&_)try{t()}catch(e){}else p[e]&&p[e].push(t)},off:function(e,t){p[e]&&(p[e]=Se(p[e],t))},destroyAgent:h};return g=Object.keys(f),f;function y(e,t){void 0===t&&(t=!1);for(var i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];p[e].forEach((function(e){try{e.apply(void 0,_e([],ue(i),!1))}catch(e){}})),t&&(p[e].length=0)}}var Ie=function(e){var t=function(){var e={},t={},i={set:function(o,n){return e[o]=n,t[o]=Te(n),i},merge:function(o){return e=le(le({},e),o),Object.keys(o).forEach((function(e){t[e]=Te(o[e])})),i},delete:function(o){return delete e[o],delete t[o],i},clear:function(){return e={},t={},i},get:function(e){return t[e]},toString:function(){return le({},t)}};return i}();e.provide("context",t),e.on("report",(function(e){return e.extra||(e.extra={}),e.extra.context=t.toString(),e}))};var Be=function(){return Date.now()};var qe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=function(e){if(e)return e.__SLARDAR_REGISTRY__||(e.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[],subject:{}}}),e.__SLARDAR_REGISTRY__.Slardar}(function(){if("object"==typeof window&&he(window))return window}());i&&(i.errors||(i.errors=[]),i.errors.push(e))},xe="custom",De=function(e){var t=function(i){var o=function(e){if(e&&he(e)&&e.name&&be(e.name)){var t={name:e.name,type:"event"};if("metrics"in e&&he(e.metrics)){var i=e.metrics,o={};for(var n in i)ve(i[n])&&(o[n]=i[n]);t.metrics=o}if("categories"in e&&he(e.categories)){var s=e.categories,r={};for(var n in s)r[n]=Te(s[n]);t.categories=r}return"attached_log"in e&&be(e.attached_log)&&(t.attached_log=e.attached_log),t}}(i);if(o){var n=function(e){var t;if("object"==typeof window&&window.__perfsee__){var i={};return null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,i,e),i.stack}}(t);n&&(o.stacks=n),e.report({ev_type:xe,payload:o,extra:{timestamp:Be()}})}};e.provide("sendEvent",t),e.provide("sendLog",(function(t){var i=function(e){if(e&&he(e)&&e.content&&be(e.content)){var t={content:Te(e.content),type:"log",level:"info"};if("level"in e&&(t.level=e.level),"extra"in e&&he(e.extra)){var i=e.extra,o={},n={};for(var s in i)ve(i[s])?o[s]=i[s]:n[s]=Te(i[s]);t.metrics=o,t.categories=n}return"attached_log"in e&&be(e.attached_log)&&(t.attached_log=e.attached_log),t}}(t);i&&e.report({ev_type:xe,payload:i,extra:{timestamp:Be()}})}))},Me=function(e,t){var i=e.common||{};return i.sample_rate=t,e.common=i,e},Ge=function(e,t,i,o,n){return e?(s=n(o,t),function(){return s}):function(){return i(t)};var s},Ne=function(e,t,i,o){var n=function(e,t,i){for(var o,n=ue(t.split(".")),s=n[0],r=n.slice(1);e&&r.length>0;)e=e[s],s=(o=ue(r))[0],r=o.slice(1);if(e)return i(e,s)}(e,t,(function(e,t){return e[t]}));return void 0!==n&&function(e,t,i){switch(i){case"eq":return Pe(t,e);case"neq":return!Pe(t,e);case"gt":return e>t[0];case"gte":return e>=t[0];case"lt":return e<t[0];case"lte":return e<=t[0];case"regex":return Boolean(e.match(new RegExp(t.join("|"))));case"not_regex":return!e.match(new RegExp(t.join("|")));default:return!1}}(n,function(e,t){return e.map((function(e){switch(t){case"number":return Number(e);case"boolean":return"1"===e;default:return String(e)}}))}(o,"boolean"==typeof n?"bool":ve(n)?"number":"string"),i)},Fe=function(e,t){try{return"rule"===t.type?Ne(e,t.field,t.op,t.values):"and"===t.type?t.children.every((function(t){return Fe(e,t)})):t.children.some((function(t){return Fe(e,t)}))}catch(e){return qe(e),!1}},$e=function(e,t,i,o,n){if(!t)return ge;var s=t.sample_rate,r=t.include_users,a=t.sample_granularity,c=t.rules,d=t.r,p=void 0===d?Math.random():d;if(Pe(r,e))return function(e){return Me(e,1)};var l="session"===a,u=Ge(l,s,i,p,o),_=function(e,t,i,o,n,s){var r={};return Object.keys(e).forEach((function(a){var c=e[a],d=c.enable,p=c.sample_rate,l=c.conditional_sample_rules;d?(r[a]={enable:d,sample_rate:p,effectiveSampleRate:p*i,hit:Ge(t,p,o,n,s)},l&&(r[a].conditional_hit_rules=l.map((function(e){var r=e.sample_rate,a=e.filter;return{sample_rate:r,hit:Ge(t,r,o,n,s),effectiveSampleRate:r*i,filter:a}})))):r[a]={enable:d,hit:function(){return!1},sample_rate:0,effectiveSampleRate:0}})),r}(c,l,s,i,p,o);return function(e){var t;if(!u())return l&&n[0](),!1;if(!(e.ev_type in _))return Me(e,s);if(!_[e.ev_type].enable)return l&&n[1](e.ev_type),!1;if(null===(t=e.common)||void 0===t?void 0:t.sample_rate)return e;var i=_[e.ev_type],o=i.conditional_hit_rules;if(o)for(var r=0;r<o.length;r++)if(Fe(e,o[r].filter))return!!o[r].hit()&&Me(e,o[r].effectiveSampleRate);return i.hit()?Me(e,i.effectiveSampleRate):((!o||!o.length)&&l&&n[1](e.ev_type),!1)}},Ve={build:function(e){return{ev_type:e.ev_type,payload:e.payload,common:le(le({},e.extra||{}),e.overrides||{})}}},We={sample_rate:1,include_users:[],sample_granularity:"session",rules:{}};function He(e){var t,i;try{for(var o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,i=t&&e[t],o=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(["userId","deviceId","sessionId","env"]),n=o.next();!n.done;n=o.next()){var s=n.value;e[s]||delete e[s]}}catch(e){t={error:e}}finally{try{n&&!n.done&&(i=o.return)&&i.call(o)}finally{if(t)throw t.error}}return e}function Ke(e){return He(le({},e))}function Je(e){return he(e)&&"bid"in e&&"transport"in e}function Qe(e){return He(le({},e))}var Ze=function(e,t){return void 0===t&&(t="/monitor_browser/collect/batch/"),(e&&e.indexOf("//")>=0?"":"https://")+e+t},Ye=function(e,t){return void 0===t&&(t="/monitor_web/settings/browser-settings"),(e&&e.indexOf("//")>=0?"":"https://")+e+t},Xe=function(e){var t,i,o=e,n={},s=me,r=me;return{getConfig:function(){return o},setConfig:function(e){return n=le(le({},n),e||{}),a(),t||(t=e,o.useLocalConfig||!o.bid?(i={},s()):function(e,t,i,o){if(!e.get)return o({});e.get({withCredentials:!0,url:Ye(t)+"?bid="+i+"&store=1",success:function(e){o(e.data||{})},fail:function(){o({sample:{sample_rate:.001}})}})}(o.transport,o.domain,o.bid,(function(e){i=function(e){if(!e)return{};var t=e.sample,i=e.timestamp,o=e.quota_rate,n=void 0===o?1:o;if(!t)return{};var s=t.sample_rate,r=t.sample_granularity,a=void 0===r?"session":r,c=t.include_users,d=t.rules;return{sample:{include_users:c,sample_rate:s*n,sample_granularity:a,rules:(void 0===d?[]:d).reduce((function(e,t){var i=t.name,o=t.enable,n=t.sample_rate,s=t.conditional_sample_rules;return e[i]={enable:o,sample_rate:n,conditional_sample_rules:s},e}),{})},serverTimestamp:i}}(e),a(),s()}))),o},onChange:function(e){r=e},onReady:function(e){s=e,i&&s()}};function a(){var t=le(le(le({},e),i||{}),n);t.sample=et(et(e.sample,null==i?void 0:i.sample),n.sample),o=t,r()}};function et(e,t){if(!e||!t)return e||t;var i=le(le({},e),t);return i.include_users=_e(_e([],ue(e.include_users||[]),!1),ue(t.include_users||[]),!1),i.rules=_e(_e([],ue(Object.keys(e.rules||{})),!1),ue(Object.keys(t.rules||{})),!1).reduce((function(i,o){var n,s;return o in i||(o in(e.rules||{})&&o in(t.rules||{})?(i[o]=le(le({},e.rules[o]),t.rules[o]),i[o].conditional_sample_rules=_e(_e([],ue(e.rules[o].conditional_sample_rules||[]),!1),ue(t.rules[o].conditional_sample_rules||[]),!1)):i[o]=(null===(n=e.rules)||void 0===n?void 0:n[o])||(null===(s=t.rules)||void 0===s?void 0:s[o])),i}),{}),i}var tt=function(e){e.on("report",(function(t){return function(e,t){var i=t||{},o=i.version,n=i.name,s={url:"",protocol:"",domain:"",path:"",query:"",timestamp:Date.now(),sdk_version:o||"2.1.8",sdk_name:n||"SDK_BASE"};return le(le({},e),{extra:le(le({},s),e.extra||{})})}(t,e.config())}))},it=function(e){e.on("beforeBuild",(function(t){return function(e,t){var i={};return i.bid=t.bid,i.pid=t.pid,i.view_id=t.viewId,i.user_id=t.userId,i.device_id=t.deviceId,i.session_id=t.sessionId,i.release=t.release,i.env=t.env,le(le({},e),{extra:le(le({},i),e.extra||{})})}(t,e.config())}))};var ot=function(e){return{bid:"",pid:"",viewId:(t="_",t+"_"+Date.now()),userId:Ue(),deviceId:Ue(),sessionId:Ue(),domain:"mon.zijieapi.com",release:"",env:"production",sample:We,plugins:{},transport:{get:me,post:me},useLocalConfig:!1};var t},nt=function(e){var t=void 0===e?{}:e,i=t.createSender,o=void 0===i?function(e){return function(e){return pe(e)}({size:20,endpoint:Ze(e.domain),transport:e.transport})}:i,n=t.builder,s=void 0===n?Ve:n,r=t.createDefaultConfig,a=Oe({validateInitConfig:Je,initConfigNormalizer:Ke,userConfigNormalizer:Qe,createSender:o,builder:s,createDefaultConfig:void 0===r?ot:r,createConfigManager:Xe});return Ie(a),it(a),tt(a),function(e){e.on("init",(function(){var t=[],i=function(i){i.forEach((function(i){var o=i.name;Pe(t,o)||(t.push(o),i.setup(e),e.destroyAgent.set(o,o,[function(){t=Se(t,o),i.tearDown&&i.tearDown()}]))}))};e.provide("applyIntegrations",i);var o=e.config();o&&o.integrations&&i(o.integrations)}))}(a),function(e){try{"object"==typeof window&&he(window)&&window.__SLARDAR_DEVTOOLS_GLOBAL_HOOK__&&window.__SLARDAR_DEVTOOLS_GLOBAL_HOOK__.push(e)}catch(e){}}(a),a},st=function(e){void 0===e&&(e={});var t=nt(e);return function(e){e.on("start",(function(){var t=e.config(),i=t.userId,o=t.sample,n=$e(i,o,je,ze,[function(){e.destroy()},function(t){e.destroyAgent.removeByEvType(t)}]);e.on("build",n)}))}(t),De(t),t}();const rt=de("slardar:transport"),at=()=>{};function ct(e){const{url:t,method:i,data:o,success:n=at,fail:s=at,getResponseText:c=at}=e;if(rt("Making %s request to %s",i,t),o&&rt("Request data: %s",o.slice(0,200)),!t||"string"!=typeof t){const e=new Error(`Invalid URL: ${t}`);return rt("Invalid URL provided: %o",t),void s(e)}try{const e=new URL(t);rt("Parsed URL - protocol: %s, hostname: %s, port: %s, path: %s",e.protocol,e.hostname,e.port,e.pathname);const d="https:"===e.protocol,p=(d?a.request:r.request)({hostname:e.hostname,port:e.port,path:e.pathname+e.search,method:i,headers:{"Content-Type":"application/json",...o&&{"Content-Length":Buffer.byteLength(o)}}},(e=>{rt("Response callback triggered: status=%s",e.statusCode);let t="";e.on("data",(e=>{rt("Response data chunk received: %s bytes",e.length),t+=e.toString()})),e.on("end",(()=>{rt("Response end event fired"),rt("Response received: status=%s, body=%s",e.statusCode,t.slice(0,200)),c(t);try{if(e.statusCode&&e.statusCode>=400)rt("Request failed with status %s: %s",e.statusCode,t),s(new Error(t||e.statusMessage||"Request failed"));else if(t){const e=JSON.parse(t);rt("Request succeeded"),n(e)}else rt("Request succeeded with empty response"),n({})}catch(e){rt("Failed to parse response: %s",e.message),s(e)}}))}));p.on("error",(e=>{rt("Request error: %s",e.message),s(e)})),p.on("timeout",(()=>{rt("Request timeout"),p.destroy(),s(new Error("Request timeout"))})),o&&p.write(o),p.end()}catch(e){rt("Exception during request: %s",e.message),s(e)}}function dt(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const pt=de("slardar:reporter");class lt{constructor(){lt.prototype.__init.call(this),lt.prototype.__init2.call(this)}__init(){this.initialized=!1}__init2(){this.client=st}setup(e){var t,i;if(this.initialized)pt("Already initialized, skipping setup");else try{pt("Initializing Slardar with config:",{bid:e.bid,release:e.release,env:e.env,userId:e.userId,projectId:e.projectId});const o={get(e){rt("Transport GET called: %s",e.url),ct({method:"GET",...e})},post({url:e,data:t}){rt("Transport POST called: %s",e),ct({method:"POST",url:e,data:t?"string"==typeof t?t:JSON.stringify(t):void 0})}};this.client.init({bid:e.bid,transport:o,userId:e.userId,pid:e.projectId,deviceId:e.deviceId,sessionId:e.sessionId,release:e.release,env:e.env,name:e.name,useLocalConfig:(t=e.useLocalConfig,i=()=>!1,null!=t?t:i()),domain:e.domain,sample:{sample_rate:1,include_users:[],sample_granularity:"session",rules:{}}}),this.client.on("send",(e=>{pt("send hook called for event: %s",dt([e,"optionalAccess",e=>e.ev_type])||"unknown")})),this.client.start(),this.initialized=!0,pt("Slardar initialized successfully")}catch(e){pt("Failed to initialize:",e)}}ensureInitialized(){return!!this.initialized||(pt("Not initialized, call setup() first"),!1)}sendEvent(e,t,i){if(this.ensureInitialized())try{pt("Sending event:",{name:e,metrics:t,categories:i});const o=t?Object.fromEntries(Object.entries(t).filter((([,e])=>void 0!==e))):void 0,n=i?Object.fromEntries(Object.entries(i).filter((([,e])=>void 0!==e))):void 0;dt([this,"access",e=>e.client,"access",e=>e.sendEvent,"optionalCall",t=>t({name:e,metrics:o,categories:n})])}catch(e){pt("Failed to send event:",e)}}sendLog(e,t,i){if(this.ensureInitialized())try{pt("Sending log:",{level:e,message:t,extra:i}),this.sendEvent("cli_log",void 0,{level:e,message:t,...i})}catch(e){pt("Failed to send log:",e)}}reportError(e,t,i){if(this.ensureInitialized())try{const o={ev_type:"js_error",payload:{error:{name:e.name,message:e.message,stack:e.stack},breadcrumbs:[],extra:t,source:i||{type:"manual"}}};pt("Reporting JS error:",{name:e.name,message:e.message.slice(0,100),stack:dt([e,"access",e=>e.stack,"optionalAccess",e=>e.slice,"call",e=>e(0,200)]),extra:t,source:i}),this.client.report(o),pt("JS error reported successfully")}catch(e){pt("Failed to report error:",e)}}setContext(e,t){this.ensureInitialized()&&dt([this,"access",e=>e.client,"access",e=>e.context,"optionalAccess",e=>e.set,"call",i=>i(e,t)])}mergeContext(e){this.ensureInitialized()&&(pt("Merging context:",e),dt([this,"access",e=>e.client,"access",e=>e.context,"optionalAccess",e=>e.merge,"call",t=>t(e)]))}deleteContext(e){this.ensureInitialized()&&dt([this,"access",e=>e.client,"access",e=>e.context,"optionalAccess",e=>e.delete,"call",t=>t(e)])}clearContext(){this.ensureInitialized()&&dt([this,"access",e=>e.client,"access",e=>e.context,"optionalAccess",e=>e.clear,"call",e=>e()])}updateConfig(e){if(this.ensureInitialized())try{pt("Updating config:",e),this.client.config({userId:e.userId,release:e.release,sessionId:e.sessionId,env:e.env})}catch(e){pt("Failed to update config:",e)}}async flush(e=1500){this.ensureInitialized()&&(pt("Flushing Slardar data..."),dt([this,"access",e=>e.client,"access",e=>e.getSender,"optionalCall",e=>e(),"optionalAccess",e=>e.flush,"call",e=>e()]),pt("Waiting %dms for events to be sent...",e),await new Promise((t=>setTimeout(t,e))),pt("Slardar data flushed"))}getRawClient(){return this.client}}const ut=new lt;function _t(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const mt="cli_start",gt="cli_command",ht="cli_command_complete",ft="cli_error",yt="network_request",vt="file_operation",bt={cliStart:e=>({name:mt,metrics:{duration:0,...e}}),cliCommand:(e,t)=>({name:gt,categories:{command:e,args:_t([t,"optionalAccess",e=>e.args]),status:"running",..._t([t,"optionalAccess",e=>e.categories])},metrics:_t([t,"optionalAccess",e=>e.metrics])}),cliCommandComplete:(e,t,i,o)=>({name:ht,categories:{command:e,args:_t([o,"optionalAccess",e=>e.args]),status:t?"success":"fail",..._t([o,"optionalAccess",e=>e.categories])},metrics:{duration:i,..._t([o,"optionalAccess",e=>e.errorCode])&&{errorCode:o.errorCode}}}),networkRequest:(e,t)=>({name:yt,categories:{url:e,method:_t([t,"optionalAccess",e=>e.method])||"GET",statusCode:_t([t,"optionalAccess",e=>e.statusCode,"optionalAccess",e=>e.toString,"call",e=>e()]),status:_t([t,"optionalAccess",e=>e.success])?"success":"fail"},metrics:{duration:_t([t,"optionalAccess",e=>e.duration])}}),fileOperation:(e,t,i)=>({name:vt,categories:{operation:e,filePath:t,status:_t([i,"optionalAccess",e=>e.success])?"success":"fail"},metrics:{duration:_t([i,"optionalAccess",e=>e.duration]),fileSize:_t([i,"optionalAccess",e=>e.fileSize])}}),cliError:(e,t)=>({name:ft,categories:{errorName:e.name,errorMessage:e.message,stack:e.stack||"",...t},metrics:{errorCode:1}})};function Pt(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function St(e){return(...t)=>{try{const i=e(...t);return i instanceof Promise?i.catch((()=>{})):i}catch(e){}}}const Tt=St((()=>{var e,t;ut.setup({bid:"coze_cli",release:ie,env:"production",userId:process.env.USER||"",useLocalConfig:!1,domain:"mon.zijieapi.com"}),ut.mergeContext({platform:process.platform,callerPlatform:(e=process.env.COZE_CLI_PLATFORM,t=()=>"unknown",null!=e?e:t()),nodeVersion:process.version,cliVersion:ie})})),Ct=St((e=>{const t=bt.cliCommand(e);ut.sendEvent(t.name,t.metrics,t.categories)})),kt=St(((e,t,i,o)=>{const n=bt.cliCommandComplete(e,t,i,{errorCode:Pt([o,"optionalAccess",e=>e.errorCode])});ut.sendEvent(n.name,n.metrics,n.categories)})),At=St(((e,t)=>{ut.reportError(e,t,{type:"cli",data:t})})),Et=St((async()=>{await ut.flush()}));async function Rt(e,t){if(e.config.disableTelemetry)return void await t();Tt();const i=function(e){if(e.commandName)return e.commandName;const t=[];for(const i of e.argv){if(i.startsWith("-"))break;t.push(i)}return t.join(" ")||"unknown"}(e);Ct(i);const o=Date.now();let n,s=!0;try{await t()}catch(e){throw s=!1,n=e instanceof Error?e:new Error(String(e)),e}finally{const e=Date.now()-o;try{s?kt(i,!0,e):(n&&At(n,{command:i}),kt(i,!1,e)),await Et()}catch(e){}}}async function jt(t,i){const o=await t.auth.getValidAccessToken();e.axiosInstance.defaults.baseURL=t.config.apiBaseUrl;const n=`Bearer ${o}`;e.axiosInstance.defaults.headers.Authorization=n,e.axiosInstance.defaults.headers["x-request-from-coze-cli"]="1",e.customFetch.setHeaders({Authorization:n,"x-request-from-coze-cli":"1"}),t.config.xTTEnv&&(e.axiosInstance.defaults.headers["x-use-ppe"]="1",e.axiosInstance.defaults.headers["x-tt-env"]=t.config.xTTEnv,e.customFetch.setHeaders({"x-use-ppe":"1","x-tt-env":t.config.xTTEnv})),await i()}function zt(e,t){return null!=e?e:t()}function wt(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}var Ut;!function(e){e.AUTHORIZATION_PENDING="authorization_pending";e.SLOW_DOWN="slow_down";e.ACCESS_DENIED="access_denied";e.EXPIRED_TOKEN="expired_token"}(Ut||(Ut={}));const Lt=e=>new Promise((t=>setTimeout(t,e))),Ot=e.createRequestClient({baseURL:"https://api.coze.com",useDefaultPlugins:!0,plugins:[{name:"oauth-error-handler",onError:t=>{if(e.isHttpError(t))throw t;const i=t,o=zt(wt([i,"access",e=>e.response,"optionalAccess",e=>e.data]),(()=>({}))),n=o.error_description||o.error||i.message,s={status:wt([i,"access",e=>e.response,"optionalAccess",e=>e.status]),code:o.error,config:i.config,response:i.response,data:o};throw new e.HttpError(zt(n,(()=>"OAuth request failed")),s)}}]});async function It(e){return(await Ot.post("/api/permission/oauth2/token",{grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:e.clientId,device_code:e.deviceCode},{baseURL:e.baseURL})).data}const Bt=async(t,i)=>{const o=process.env.HTTP_PROXY||process.env.http_proxy,n=process.env.HTTPS_PROXY||process.env.https_proxy;if(n||o){const i=new c.EnvHttpProxyAgent;e.customFetch.setDispatcher(i);const[{HttpProxyAgent:s},{HttpsProxyAgent:r}]=await Promise.all([import("http-proxy-agent"),import("https-proxy-agent")]);e.axiosInstance.defaults.proxy=!1,Ot.defaults.proxy=!1,n&&(e.axiosInstance.defaults.httpsAgent=new r(n),Ot.defaults.httpsAgent=new r(n),t.ui.debug(`HTTPS proxy enabled: ${n}`)),o&&(e.axiosInstance.defaults.httpAgent=new s(o),Ot.defaults.httpAgent=new s(o),t.ui.debug(`HTTP proxy enabled: ${o}`))}await i()};function qt(e){if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");for(const t of e)if("function"!=typeof t)throw new TypeError("Middleware must be composed of functions!");return function(t,i){let o=-1;return function n(s){if(s<=o)return Promise.reject(new Error("next() called multiple times"));o=s;let r=e[s];s===e.length&&(r=i);if(!r)return Promise.resolve();try{return Promise.resolve(r(t,n.bind(null,s+1)))}catch(e){return Promise.reject(e)}}(0)}}var xt,Dt,Mt,Gt,Nt,Ft,$t,Vt,Wt,Ht,Kt,Jt,Qt,Zt,Yt,Xt,ei,ti,ii,oi,ni,si,ri,ai,ci,di,pi,li,ui,_i,mi,gi,hi,fi,yi,vi,bi,Pi,Si,Ti,Ci,ki,Ai,Ei,Ri,ji,zi,wi,Ui,Li,Oi,Ii,Bi;function qi(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}!function(e){e.app="app";e.pat="pat"}(xt||(xt={})),function(e){e.can_apply2="CanApply";e.already_applied2="AlreadyApplied";e.joined4="Joined";e.deny3="Deny"}(Dt||(Dt={})),function(e){e.processing="Processing";e.approved="Approved";e.rejected="Rejected";e.auto_approved="AutoApproved"}(Mt||(Mt={})),function(e){e.normal="Normal";e.connector="Connector";e.privilege="Privilege"}(Gt||(Gt={})),function(e){e.auth_app="AuthApp";e.on_behalf_of_user="OnBehalfOfUser"}(Nt||(Nt={})),function(e){e.password="Password";e.sms="Sms";e.email="Email";e.unknown3="Unknown"}(Ft||(Ft={})),function(e){e.authorized="authorized";e.unauthorized="unauthorized";e.expired4="expired"}($t||($t={})),function(e){e.api_key="api_key";e.wechat_official="wechat_official";e.oauth_2="oauth2"}(Vt||(Vt={})),function(e){e.noncertificated="Noncertificated";e.certificated="Certificated"}(Wt||(Wt={})),function(e){e.uncertified="Uncertified";e.personal_certification="PersonalCertification";e.enterprise_certification="EnterpriseCertification"}(Ht||(Ht={})),function(e){e.obo="Obo";e.app_auth="AppAuth";e.personal_access_token="PersonalAccessToken"}(Kt||(Kt={})),function(e){e.legacy="Legacy";e.web_backend="WebBackend";e.single_page_or_native="SinglePageOrNative";e.terminal="Terminal";e.service="Service"}(Jt||(Jt={})),function(e){e.bot_editor="BotEditor";e.bot_developer="BotDeveloper";e.bot_operator="BotOperator"}(Qt||(Qt={})),function(e){e.workspace="Workspace";e.o_auth_app="OAuthApp";e.authorized_o_auth_app="AuthorizedOAuthApp";e.service_access_token="ServiceAccessToken";e.personal_access_token2="PersonalAccessToken";e.connector2="Connector";e.normal_api_app="NormalApiApp";e.connector_api_app="ConnectorApiApp"}(Zt||(Zt={})),function(e){e.visitors_prohibited="VisitorsProhibited";e.guest_prohibited_by_invited_user_enterprise2="GuestProhibitedByInvitedUserEnterprise";e.prohibited_by_custom_people_management="ProhibitedByCustomPeopleManagement"}(Yt||(Yt={})),function(e){e.dev2="DEV";e.prod2="PROD"}(Xt||(Xt={})),function(e){e._1="1";e._30="30";e._90="90";e._180="180";e._365="365";e.customize="customize";e.permanent="permanent"}(ei||(ei={})),function(e){e._12="1";e._302="30";e._902="90";e._1802="180";e._3652="365";e.customize2="customize";e.permanent2="permanent"}(ti||(ti={})),function(e){e.aes_256_gcm="AES-256-GCM"}(ii||(ii={})),function(e){e.conversation="Conversation";e.unknown="Unknown"}(oi||(oi={})),function(e){e.active3="Active";e.inactive="Inactive"}(ni||(ni={})),function(e){e.cloud_kms="CloudKMS",e.default="Default";e.unknown2="Unknown"}(si||(si={})),function(e){e.user_custom2="user_custom";e.consumer3="consumer"}(ri||(ri={})),function(e){e.super_admin="SuperAdmin";e.admin="Admin";e.member="Member";e.guest="Guest"}(ai||(ai={})),function(e){e.join_enterprise_share_link_expiration_time="JoinEnterpriseShareLinkExpirationTime";e.sso="SSO";e.forbid_guest_join_enterprise="ForbidGuestJoinEnterprise";e.forbid_member_join_other_enterprise="ForbidMemberJoinOtherEnterprise";e.replace_enterprise_logo="ReplaceEnterpriseLogo";e.forbid_custom_people_management="ForbidCustomPeopleManagement";e.forbid_coze_store_plugin_access="ForbidCozeStorePluginAccess";e.enterprise_member_listing_skill_coze_store="EnterpriseMemberListingSkillCozeStore";e.listing_skill_enterprise_store_audit="ListingSkillEnterpriseStoreAudit"}(ci||(ci={})),function(e){e.string="String";e.boolean="Boolean";e.integer="Integer";e.string_list="StringList"}(di||(di={})),function(e){e.must_handle="MustHandle";e.no_need_handle="NoNeedHandle"}(pi||(pi={})),function(e){e.pending_review_app_auth="pending_review_app_auth";e.pending_review_app_obo="pending_review_app_obo";e.approved_app_auth="approved_app_auth";e.approved_app_obo="approved_app_obo"}(li||(li={})),function(e){e.no_permission="NoPermission";e.guest_prohibited_by_enterprise2="GuestProhibitedByEnterprise";e.guest_prohibited_by_invited_user_enterprise3="GuestProhibitedByInvitedUserEnterprise";e.guest_prohibited_by_custom_people_management="GuestProhibitedByCustomPeopleManagement"}(ui||(ui={})),function(e){e.confirming2="Confirming";e.joined3="Joined";e.rejected3="Rejected";e.revoked2="Revoked";e.expired3="Expired";e.deny2="Deny"}(_i||(_i={})),function(e){e.confirming="Confirming";e.joined2="Joined";e.rejected2="Rejected";e.revoked="Revoked";e.expired2="Expired"}(mi||(mi={})),function(e){e.can_join="CanJoin";e.guest_prohibited_by_enterprise="GuestProhibitedByEnterprise";e.guest_prohibited_by_invited_user_enterprise="GuestProhibitedByInvitedUserEnterprise"}(gi||(gi={})),function(e){e.can_apply="CanApply";e.already_applied="AlreadyApplied";e.joined="Joined";e.expired="Expired";e.deny="Deny"}(hi||(hi={})),function(e){e.free="Free";e.premium_lite="PremiumLite";e.premium="Premium";e.premium_plus="PremiumPlus";e.v_1_pro_instance="V1ProInstance";e.pro_personal="ProPersonal";e.coze_personal_plus="CozePersonalPlus";e.coze_personal_advanced="CozePersonalAdvanced";e.coze_personal_pro="CozePersonalPro";e.team="Team";e.enterprise_basic="EnterpriseBasic";e.enterprise="Enterprise";e.enterprise_pro="EnterprisePro"}(fi||(fi={})),function(e){e.user_custom_only="user_custom_only";e.all2="all"}(yi||(yi={})),function(e){e.system="system";e.custom="custom"}(vi||(vi={})),function(e){e.not_in_enterprise="NotInEnterprise";e.prohibited_by_custom_people_management2="ProhibitedByCustomPeopleManagement"}(bi||(bi={})),function(e){e.can_apply3="CanApply";e.already_applied3="AlreadyApplied";e.joined5="Joined";e.deny4="Deny"}(Pi||(Pi={})),function(e){e.super_admin2="SuperAdmin";e.admin2="Admin";e.member2="Member";e.guest2="Guest"}(Si||(Si={})),function(e){e.member_joining_auto_approved="MemberJoiningAutoApproved"}(Ti||(Ti={})),function(e){e.string2="String";e.boolean2="Boolean";e.integer2="Integer";e.string_list2="StringList"}(Ci||(Ci={})),function(e){e.developer="developer";e.consumer2="consumer"}(ki||(ki={})),function(e){e.all="all";e.owned="owned";e.others="others"}(Ai||(Ai={})),function(e){e.enterprise_member="EnterpriseMember";e.enterprise_guest="EnterpriseGuest"}(Ei||(Ei={})),function(e){e.not_created="NotCreated";e.enabled="Enabled";e.disabled="Disabled"}(Ri||(Ri={})),function(e){e.production="Production";e.development="Development"}(ji||(ji={})),(zi||(zi={})).skill="skill",function(e){e.dev="dev";e.prod="prod"}(wi||(wi={})),function(e){e.user_custom="user_custom";e.coze_default="coze_default";e.consumer="consumer"}(Ui||(Ui={})),function(e){e.active2="Active";e.deactive="Deactive"}(Li||(Li={})),function(e){e.active="active";e.deactivated="deactivated";e.offboarded="offboarded"}(Oi||(Oi={})),function(e){e.studio_space_selector="studio_space_selector";e.studio_create_project_btn="studio_create_project_btn";e.studio_home_page="studio_home_page";e.studio_develop="studio_develop";e.studio_library="studio_library";e.studio_tasks="studio_tasks";e.studio_evaluate="studio_evaluate";e.studio_space_manage="studio_space_manage";e.studio_templates_store="studio_templates_store";e.studio_plugins_store="studio_plugins_store";e.studio_agents_store="studio_agents_store";e.studio_playground="studio_playground";e.studio_docs="studio_docs";e.studio_enterprise_agents_store="studio_enterprise_agents_store";e.studio_enterprise_plugins_store="studio_enterprise_plugins_store";e.studio_organization_manage="studio_organization_manage";e.studio_enterprise_card="studio_enterprise_card";e.studio_subscription_card="studio_subscription_card";e.studio_personal_menu="studio_personal_menu";e.studio_more_products="studio_more_products";e.studio_notice="studio_notice";e.studio_migration_banner="studio_migration_banner";e.coding_space_selector="coding_space_selector";e.coding_create_project="coding_create_project";e.coding_project_manage="coding_project_manage";e.coding_integrations="coding_integrations";e.coding_library="coding_library";e.coding_tasks="coding_tasks";e.coding_playground="coding_playground";e.coding_evaluate="coding_evaluate";e.coding_coze_redirect="coding_coze_redirect";e.coding_docs="coding_docs";e.coding_community="coding_community";e.coding_enterprise_card="coding_enterprise_card";e.coding_subscription_card="coding_subscription_card";e.coding_personal_menu="coding_personal_menu";e.coding_notice="coding_notice";e.admin_organization_manage="admin_organization_manage";e.admin_member_manage="admin_member_manage";e.admin_enterprise_config="admin_enterprise_config"}(Ii||(Ii={})),function(e){e.root_user="RootUser";e.basic_user="BasicUser"}(Bi||(Bi={}));class xi{__init(){this.request=e.request}__init2(){this.baseURL=""}constructor(e){xi.prototype.__init.call(this),xi.prototype.__init2.call(this),this.request=qi([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=qi([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}CreatePersonalAccessTokenAndPermission(e,t){const i=e,o=this.genBaseURL("/api/permission_api/pat/create_personal_access_token_and_permission"),n={name:i.name,expire_at:i.expire_at,duration_day:i.duration_day,organization_id:i.organization_id,workspace_permission:i.workspace_permission,account_permission:i.account_permission,workspace_permission_v2:i.workspace_permission_v2,enterprise_permission:i.enterprise_permission},s={"x-tt-env":i["x-tt-env"]};return this.request({url:o,method:"POST",data:n,headers:s},t)}UpdatePersonalAccessTokenAndPermission(e,t){const i=e,o=this.genBaseURL("/api/permission_api/pat/update_personal_access_token_and_permission"),n={workspace_permission:i.workspace_permission,account_permission:i.account_permission,workspace_permission_v2:i.workspace_permission_v2,enterprise_permission:i.enterprise_permission,id:i.id,name:i.name},s={"x-tt-env":i["x-tt-env"]};return this.request({url:o,method:"POST",data:n,headers:s},t)}DeletePersonalAccessTokenAndPermission(e,t){const i=e,o=this.genBaseURL("/api/permission_api/pat/delete_personal_access_token_and_permission"),n={id:i.id};return this.request({url:o,method:"POST",data:n},t)}ListPersonalAccessTokens(e,t){const i=e||{},o=this.genBaseURL("/api/permission_api/pat/list_personal_access_tokens"),n={organization_id:i.organization_id,page:i.page,size:i.size,search_option:i.search_option};return this.request({url:o,method:"GET",params:n},t)}GetPersonalAccessTokenAndPermission(e,t){const i=e,o=this.genBaseURL("/api/permission_api/pat/get_personal_access_token_and_permission"),n={id:i.id};return this.request({url:o,method:"GET",params:n},t)}ListPersonalAccessTokenSupportPermissions(e,t){const i=this.genBaseURL("/api/permission_api/pat/list_personal_access_token_support_permissions");return this.request({url:i,method:"GET"},t)}CheckPersonalAccessTokenInWorkspace(e,t){const i=e,o=this.genBaseURL("/api/permission_api/pat/check_personal_access_token_in_workspace"),n={workspace_id:i.workspace_id};return this.request({url:o,method:"GET",params:n},t)}AddCollaborator(e,t){const i=e,o=this.genBaseURL("/api/permission/authz/add_collaborator"),n={collaborator_types:i.collaborator_types,principal:i.principal,resource:i.resource};return this.request({url:o,method:"POST",data:n},t)}RemoveCollaborator(e,t){const i=e,o=this.genBaseURL("/api/permission/authz/remove_collaborator"),n={principal:i.principal,resource:i.resource};return this.request({url:o,method:"POST",data:n},t)}CreateAppMeta(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/create_app_meta"),n={app_type:i.app_type,client_type:i.client_type,name:i.name,description:i.description,organization_id:i.organization_id};return this.request({url:o,method:"POST",data:n},t)}ListAppMeta(e,t){const i=e||{},o=this.genBaseURL("/api/permission_api/app/list_app_meta"),n={organization_id:i.organization_id};return this.request({url:o,method:"GET",params:n},t)}GetAppMeta(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/get_app_meta"),n={appid:i.appid},s={"x-tt-env":i["x-tt-env"]};return this.request({url:o,method:"GET",params:n,headers:s},t)}UpdateAppMeta(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/update_app_meta"),n={status:i.status,oauth2_configuration:i.oauth2_configuration,appid:i.appid,name:i.name,description:i.description,declared_permission:i.declared_permission,declared_permission_v2:i.declared_permission_v2},s={"x-tt-env":i["x-tt-env"]};return this.request({url:o,method:"POST",data:n,headers:s},t)}UploadPublicKey(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/upload_public_key"),n={appid:i.appid,public_key_pem:i.public_key_pem};return this.request({url:o,method:"POST",data:n},t)}DeletePublicKey(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/delete_public_key"),n={fingerprint:i.fingerprint};return this.request({url:o,method:"POST",data:n},t)}CreateClientSecret(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/create_client_secret"),n={appid:i.appid};return this.request({url:o,method:"POST",data:n},t)}DeleteClientSecret(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/delete_client_secret"),n={appid:i.appid,client_secret_id:i.client_secret_id};return this.request({url:o,method:"POST",data:n},t)}PutOAuth2Configuration(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/put_oauth2_configuration"),n={oauth2_configuration:i.oauth2_configuration,appid:i.appid};return this.request({url:o,method:"POST",data:n},t)}AuthorizeAppWithDeclaredPermission(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/authorize_app_with_declared_permission"),n={appid:i.appid,organization_id:i.organization_id};return this.request({url:o,method:"POST",data:n},t)}ListAuthorizedApps(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/list_authorized_apps"),n={page:i.page,size:i.size},s={"x-tt-env":i["x-tt-env"]};return this.request({url:o,method:"GET",params:n,headers:s},t)}GetAppAuthorizationRequestInfo(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/get_app_authorization_request_info"),n={authorize_key:i.authorize_key},s={"x-tt-env":i["x-tt-env"]};return this.request({url:o,method:"GET",params:n,headers:s},t)}RevokeAppAuthorizedPermission(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/revoke_app_authorized_permission"),n={authorization_type:i.authorization_type,appid:i.appid,organization_id:i.organization_id};return this.request({url:o,method:"POST",data:n},t)}DeleteApp(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/delete_app"),n={appid:i.appid};return this.request({url:o,method:"POST",data:n},t)}ModifyCollaborator(e,t){const i=e,o=this.genBaseURL("/api/permission/authz/modify_collaborator"),n={principal:i.principal,resource:i.resource,collaborator_types:i.collaborator_types};return this.request({url:o,method:"POST",data:n},t)}BatchAddCollaborator(e,t){const i=e,o=this.genBaseURL("/api/permission/authz/batch_add_collaborator"),n={principal_type:i.principal_type,resource:i.resource,principal_ids:i.principal_ids,collaborator_types:i.collaborator_types};return this.request({url:o,method:"POST",data:n},t)}GetAppInstallationRequestInfo(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/get_app_installation_request_info"),n={appid:i.appid},s={"x-tt-env":i["x-tt-env"]};return this.request({url:o,method:"GET",params:n,headers:s},t)}AppInstallationConsent(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/app_installation_consent"),n={appid:i.appid,installation_account_hint:i.installation_account_hint};return this.request({url:o,method:"POST",data:n},t)}ImpersonateCozeUser(e,t){const i=e||{},o=this.genBaseURL("/api/permission_api/coze_web_app/impersonate_coze_user"),n={duration_seconds:i.duration_seconds,scope:i.scope,connector_info:i.connector_info};return this.request({url:o,method:"POST",data:n},t)}GetVolcanoConnectInfoWithInsName(e,t){const i=this.genBaseURL("/api/permission_api/volcano/get_volcano_connect_info_with_ins_name");return this.request({url:i,method:"GET"},t)}GetVolcanoMaskedMobile(e,t){const i=this.genBaseURL("/api/permission_api/volcano/get_volcano_masked_mobile");return this.request({url:i,method:"GET"},t)}BindVolcano(e,t){const i=this.genBaseURL("/api/permission_api/volcano/bind_volcano");return this.request({url:i,method:"POST"},t)}AuthorizeAppWithSpecifiedWorkspace(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/authorize_app_with_specified_permission"),n={appid:i.appid,workspace_list:i.workspace_list,organization_id:i.organization_id};return this.request({url:o,method:"POST",data:n},t)}GetUserProfile(e,t){const i=this.genBaseURL("/v1/users/me");return this.request({url:i,method:"GET"},t)}ListAppAuthorizations(e,t){const i=e,o=this.genBaseURL(`/v1/oauth-apps/${i.appid}/authorizations`),n={page_num:i.page_num,page_size:i.page_size},s={authorization:i.authorization};return this.request({url:o,method:"GET",params:n,headers:s},t)}GetCertificationInfo(e,t){const i=this.genBaseURL("/api/permission_api/enterprise/get_certification_info");return this.request({url:i,method:"GET"},t)}NeedCreateEnterprise(e,t){const i=this.genBaseURL("/api/permission_api/enterprise/need_create_enterprise");return this.request({url:i,method:"GET"},t)}CreateEnterprise(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/create_enterprise"),n={name:i.name,icon_uri:i.icon_uri};return this.request({url:o,method:"POST",data:n},t)}ListEnterprise(e,t){const i=e||{},o=this.genBaseURL("/api/permission_api/enterprise/list_enterprises"),n={contain_enterprise_of_user:i.contain_enterprise_of_user,contain_organization_of_user:i.contain_organization_of_user,contain_guest_enterprise_of_user:i.contain_guest_enterprise_of_user,is_space:i.is_space};return this.request({url:o,method:"GET",params:n},t)}GetEnterprise(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/get_enterprise"),n={enterprise_id:i.enterprise_id};return this.request({url:o,method:"GET",params:n},t)}UpdateEnterprise(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/update_enterprise"),n={enterprise_id:i.enterprise_id,name:i.name,icon_uri:i.icon_uri,replace_logo:i.replace_logo};return this.request({url:o,method:"POST",data:n},t)}UpdateEnterpriseSettings(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/update_enterprise_settings"),n={enterprise_id:i.enterprise_id,enterprise_settings:i.enterprise_settings};return this.request({url:o,method:"POST",data:n},t)}BatchAddEnterprisePeople(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/batch_add_enterprise_people"),n={enterprise_id:i.enterprise_id,enterprise_people:i.enterprise_people,need_check_people_valid:i.need_check_people_valid};return this.request({url:o,method:"POST",data:n},t)}RemoveEnterprisePeople(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/remove_enterprise_people"),n={enterprise_id:i.enterprise_id,user_id:i.user_id,receiver:i.receiver,sync_default_organization:i.sync_default_organization};return this.request({url:o,method:"POST",data:n},t)}UpdateEnterprisePeople(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/update_enterprise_people"),n={enterprise_id:i.enterprise_id,user_id:i.user_id,enterprise_role_type_list:i.enterprise_role_type_list,sync_default_organization:i.sync_default_organization};return this.request({url:o,method:"POST",data:n},t)}CreateEnterpriseInviteLink(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/create_enterprise_invite_link"),n={enterprise_id:i.enterprise_id};return this.request({url:o,method:"POST",data:n},t)}CreateJoinApplication(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/create_join_application"),n={key:i.key,remark:i.remark};return this.request({url:o,method:"POST",data:n},t)}GetInviteInfo(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/get_invite_info"),n={invite_key:i.invite_key};return this.request({url:o,method:"GET",params:n},t)}UpdateJoinApplication(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/update_join_application"),n={application_status:i.application_status,enterprise_id:i.enterprise_id,join_application_id_list:i.join_application_id_list};return this.request({url:o,method:"POST",data:n},t)}ListPersonalAccessTokensByCreator(e,t){const i=e,o=this.genBaseURL("/api/permission_api/permission/list_personal_access_tokens_by_creator"),n={organization_id:i.organization_id};return this.request({url:o,method:"GET",params:n},t)}ListAppInstallations(e,t){const i=e||{},o=this.genBaseURL("/api/permission_api/app/list_app_installations"),n={enterprise_id:i.enterprise_id,organization_id:i.organization_id},s={"x-tt-env":i["x-tt-env"]};return this.request({url:o,method:"GET",params:n,headers:s},t)}GetEnterpriseSettings(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/get_enterprise_settings"),n={enterprise_id:i.enterprise_id,enterprise_setting_key_list:i.enterprise_setting_key_list};return this.request({url:o,method:"POST",data:n},t)}SearchCanAddEnterprisePeople(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/search_can_add_enterprise_people"),n={people_type:i.people_type,enterprise_id:i.enterprise_id,search_key:i.search_key};return this.request({url:o,method:"POST",data:n},t)}SearchEnterprisePeople(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/search_enterprise_people"),n={people_type:i.people_type,enterprise_id:i.enterprise_id,search_key:i.search_key,enterprise_role_type_list:i.enterprise_role_type_list,need_volcano_user_info:i.need_volcano_user_info,need_people_number:i.need_people_number,page:i.page,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}ListJoinApplication(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/list_join_application"),n={application_status:i.application_status,enterprise_id:i.enterprise_id,search_key:i.search_key,page:i.page,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}PostAdapterMpV1Code2Session(e,t){const i=e||{},o=this.genBaseURL("/adapter/mp/v1/code2session"),n={bot_id:i.bot_id,app_id:i.app_id,connector_id:i.connector_id,code:i.code,with_userinfo:i.with_userinfo,execute_mode:i.execute_mode,agent_type:i.agent_type,agent_version:i.agent_version};return this.request({url:o,method:"POST",data:n},t)}SubmitAppOboInstallationReview(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/submit_app_obo_installation_review"),n={appid:i.appid,enterprise_id:i.enterprise_id};return this.request({url:o,method:"POST",data:n},t)}InstallAppObo(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/install_app_obo"),n={appid:i.appid,enterprise_id:i.enterprise_id};return this.request({url:o,method:"POST",data:n},t)}UninstallAppObo(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/uninstall_app_obo"),n={appid:i.appid,enterprise_id:i.enterprise_id};return this.request({url:o,method:"POST",data:n},t)}GetChecklistForWorkspaceMigration(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/get_checklist_for_workspace_migration"),n={workspace_id_list:i.workspace_id_list};return this.request({url:o,method:"POST",data:n},t)}CheckEnterpriseExist(e,t){const i=this.genBaseURL("/api/permission_api/enterprise/check_enterprise_exist");return this.request({url:i,method:"GET"},t)}GetSSOSetting(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/get_sso_setting"),n={enterprise_id:i.enterprise_id};return this.request({url:o,method:"POST",data:n},t)}BatchMigrateAuthorization(e,t){const i=e,o=this.genBaseURL("/api/permission_api/app/batch_migrate_authorization"),n={authorization_list:i.authorization_list,organization_id:i.organization_id};return this.request({url:o,method:"POST",data:n},t)}ListJoinInvitation(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/list_join_invitation"),n={invitation_status:i.invitation_status,enterprise_id:i.enterprise_id,search_key:i.search_key,page:i.page,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}RevokeJoinInvitation(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/revoke_join_invitation"),n={enterprise_id:i.enterprise_id,join_invitation_id:i.join_invitation_id};return this.request({url:o,method:"POST",data:n},t)}UpdateJoinInvitation(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/update_join_invitation"),n={enterprise_id:i.enterprise_id,join_invitation_id:i.join_invitation_id,joined:i.joined};return this.request({url:o,method:"POST",data:n},t)}GetJoinInvitation(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/get_join_invitation"),n={join_invitation_id:i.join_invitation_id};return this.request({url:o,method:"POST",data:n},t)}SearchPeopleInOtherEnterprise(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/search_people_in_other_enterprise"),n={enterprise_id:i.enterprise_id,search_key:i.search_key,page:i.page,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}CreateApplicationForEnterpriseMember(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/create_application_for_enterprise_member"),n={enterprise_id:i.enterprise_id,remark:i.remark};return this.request({url:o,method:"POST",data:n},t)}GetApplicationForEnterpriseMember(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/get_application_for_enterprise_member"),n={enterprise_id:i.enterprise_id};return this.request({url:o,method:"POST",data:n},t)}AuthorizeAppsAndPersonalaccesstokenListWithPersonalAccountPermission(e,t){const i=e||{},o=this.genBaseURL("/api/permission_api/app/authorize_apps_and_patlist_with_personalaccountpermission"),n={crossaccount_authinfo_list:i.crossaccount_authinfo_list};return this.request({url:o,method:"POST",data:n},t)}RevokeAppAndPersonalaccesstokenPersonalAccountPermission(e,t){const i=e||{},o=this.genBaseURL("/api/permission_api/app/revoke_app_and_pat_personalaccountpermission"),n={crossaccount_authinfo:i.crossaccount_authinfo};return this.request({url:o,method:"POST",data:n},t)}GetAppsAndPersonalAccessTokenListForPersonalAccountPermissionAuthorization(e,t){const i=e||{},o=this.genBaseURL("/api/permission_api/app/get_apps_and_patlist_for_personalaccountpermission_authorization"),n={page:i.page,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}create_service_identity(e,t){const i=e,o=this.genBaseURL("/api/permission_api/service/create_service_identity"),n={name:i.name,organization_id:i.organization_id,expire_at:i.expire_at,duration_day:i.duration_day,permission:i.permission},s={"x-tt-env":i["x-tt-env"]};return this.request({url:o,method:"POST",data:n,headers:s},t)}get_service_identity(e,t){const i=e,o=this.genBaseURL("/api/permission_api/service/get_service_identity"),n={id:i.id};return this.request({url:o,method:"GET",params:n},t)}update_service_identity(e,t){const i=e,o=this.genBaseURL("/api/permission_api/service/update_service_identity"),n={permission:i.permission,id:i.id,name:i.name,expire_at:i.expire_at,duration_day:i.duration_day},s={"x-tt-env":i["x-tt-env"]};return this.request({url:o,method:"POST",data:n,headers:s},t)}delete_service_identity(e,t){const i=e,o=this.genBaseURL("/api/permission_api/service/delete_service_identity"),n={id:i.id};return this.request({url:o,method:"POST",params:n},t)}list_service_identities(e,t){const i=e||{},o=this.genBaseURL("/api/permission_api/service/list_service_identities"),n={organization_id:i.organization_id};return this.request({url:o,method:"GET",params:n},t)}ListEncryptionConfiguration(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterpise/list_encryption_configuration"),n={organization_id:i.organization_id};return this.request({url:o,method:"GET",params:n},t)}UpdateEncryptionConfiguration(e,t){const i=e||{},o=this.genBaseURL("/api/permission_api/enterpise/update_encryption_configuration"),n={encryption_configuration:i.encryption_configuration};return this.request({url:o,method:"POST",data:n},t)}SearchOrganization(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/search_organization"),n={enterprise_id:i.enterprise_id,search_key:i.search_key,joined:i.joined,need_people_number:i.need_people_number,need_workspace_number:i.need_workspace_number,page:i.page,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}CreateOrganization(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/create_organization"),n={enterprise_id:i.enterprise_id,name:i.name,icon_uri:i.icon_uri,description:i.description};return this.request({url:o,method:"POST",data:n},t)}GetOrganization(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/get_organization"),n={organization_id:i.organization_id};return this.request({url:o,method:"POST",data:n},t)}UpdateOrganization(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/update_organization"),n={organization_id:i.organization_id,name:i.name,icon_uri:i.icon_uri,description:i.description};return this.request({url:o,method:"POST",data:n},t)}SearchCanAddOrganizationPeople(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/search_can_add_organization_people"),n={organization_id:i.organization_id,search_key:i.search_key,page:i.page,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}SearchOrganizationPeople(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/search_organization_people"),n={organization_role_type:i.organization_role_type,people_type:i.people_type,organization_id:i.organization_id,search_key:i.search_key,page:i.page,page_size:i.page_size,organization_role_type_list:i.organization_role_type_list};return this.request({url:o,method:"POST",data:n},t)}CreateJoinOrganizationApplication(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/create_join_organization_application"),n={organization_id:i.organization_id,remark:i.remark};return this.request({url:o,method:"POST",data:n},t)}ListJoinOrganizationApplication(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/list_join_organization_application"),n={application_status:i.application_status,organization_id:i.organization_id,search_key:i.search_key,page:i.page,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}UpdateJoinOrganizationApplication(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/update_join_organization_application"),n={application_status:i.application_status,organization_id:i.organization_id,join_application_id_list:i.join_application_id_list};return this.request({url:o,method:"POST",data:n},t)}GetOrganizationApplicationForEnterpriseMember(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/get_organization_application_for_enterprise_member"),n={organization_id:i.organization_id};return this.request({url:o,method:"POST",data:n},t)}CanCustomEncryptionConfiguration(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterpise/can_custom_encryption_configuration"),n={enterprise_id:i.enterprise_id};return this.request({url:o,method:"GET",params:n},t)}BatchAddOrganizationPeople(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/batch_add_organization_people"),n={organization_id:i.organization_id,organization_people:i.organization_people};return this.request({url:o,method:"POST",data:n},t)}RemoveOrganizationPeople(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/remove_organization_people"),n={organization_id:i.organization_id,user_id:i.user_id,receiver:i.receiver};return this.request({url:o,method:"POST",data:n},t)}UpdateOrganizationPeople(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/update_organization_people"),n={organization_role_type:i.organization_role_type,organization_id:i.organization_id,user_id:i.user_id};return this.request({url:o,method:"POST",data:n},t)}DownloadRemoteAttestationEvidence(e,t){const i=e,o=this.genBaseURL("/api/permission_api/aicc/download_remote_attestation_evidence"),n={component_name:i.component_name};return this.request({url:o,method:"GET",params:n},t)}GetAgentAiccInfo(e,t){const i=e,o=this.genBaseURL("/api/permission_api/aicc/get_agent_aicc_info"),n={agent_id:i.agent_id};return this.request({url:o,method:"GET",params:n},t)}CheckDeleteOrganization(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/check_delete_organization"),n={organization_id:i.organization_id};return this.request({url:o,method:"POST",data:n},t)}DeleteOrganization(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/delete_organization"),n={organization_id:i.organization_id};return this.request({url:o,method:"POST",data:n},t)}ListProjectUsers(e,t){const i=e,o=this.genBaseURL("/api/permission_api/auth_integration/list_project_users"),n={project_id:i.project_id,page_size:i.page_size,page_number:i.page_number,environment:i.environment,filter:i.filter};return this.request({url:o,method:"POST",data:n},t)}DeleteProjectUser(e,t){const i=e,o=this.genBaseURL("/api/permission_api/auth_integration/delete_project_user"),n={environment:i.environment,project_id:i.project_id,user_id:i.user_id};return this.request({url:o,method:"POST",data:n},t)}GetProjectAuthConfig(e,t){const i=e,o=this.genBaseURL("/api/permission_api/auth_integration/get_project_auth_config"),n={project_id:i.project_id};return this.request({url:o,method:"GET",params:n},t)}UpdateProjectAuthConfig(e,t){const i=e,o=this.genBaseURL("/api/permission_api/auth_integration/update_project_auth_config"),n={project_id:i.project_id,configuration:i.configuration};return this.request({url:o,method:"POST",data:n},t)}ListProjectSecret(e,t){const i=e,o=this.genBaseURL("/api/permission_api/project_secret/list_project_secret"),n={env:i.env,project_id:i.project_id,with_providers:i.with_providers,deploy_id:i.deploy_id,option:i.option};return this.request({url:o,method:"POST",data:n},t)}UpdateProjectSecret(e,t){const i=e,o=this.genBaseURL("/api/permission_api/project_secret/update_project_secret"),n={project_id:i.project_id,update_secrets:i.update_secrets,update_cred_provider:i.update_cred_provider};return this.request({url:o,method:"POST",data:n},t)}DeleteProjectSecret(e,t){const i=e,o=this.genBaseURL("/api/permission_api/project_secret/delete_project_secret"),n={project_id:i.project_id,keys:i.keys,cred_provider_ids:i.cred_provider_ids};return this.request({url:o,method:"POST",data:n},t)}EncryptProjectSecret(e,t){const i=e,o=this.genBaseURL("/api/permission_api/project_secret/encrypt_project_secret"),n={project_id:i.project_id,project_type:i.project_type,encrypt_secrets:i.encrypt_secrets};return this.request({url:o,method:"POST",data:n},t)}InsertProjectSecret(e,t){const i=e,o=this.genBaseURL("/api/permission_api/project_secret/insert_project_secret"),n={project_id:i.project_id,insert_secrets:i.insert_secrets};return this.request({url:o,method:"POST",data:n},t)}OutboundAuthCallback(e,t){const i=e||{},o=this.genBaseURL("/api/permission_api/outbound_auth/callback"),n={session_id:i.session_id,error:i.error};return this.request({url:o,method:"GET",params:n},t)}CreateAgentAccessToken(e,t){const i=e,o=this.genBaseURL("/api/permission_api/inbound_auth/agent_access_token"),n={project_id:i.project_id,deployment_env:i.deployment_env};return this.request({url:o,method:"POST",data:n},t)}ListAgentAccessTokens(e,t){const i=e,o=this.genBaseURL("/api/permission_api/inbound_auth/agent_access_token"),n={project_id:i.project_id};return this.request({url:o,method:"GET",params:n},t)}DeleteAgentAccessToken(e,t){const i=e,o=this.genBaseURL("/api/permission_api/inbound_auth/agent_access_token"),n={token_id:i.token_id,project_id:i.project_id};return this.request({url:o,method:"DELETE",data:n},t)}GenerateInviteCode(e,t){const i=this.genBaseURL("/api/permission_api/coze_user/generate_invite_code");return this.request({url:i,method:"POST"},t)}GetInviteCodeInfo(e,t){const i=e,o=this.genBaseURL("/api/permission_api/coze_user/get_invite_code_info"),n={invite_code:i.invite_code};return this.request({url:o,method:"GET",params:n},t)}AuthorizeCredProvider(e,t){const i=e,o=this.genBaseURL("/api/permission_api/project_secret/authorize"),n={provider_id:i.provider_id};return this.request({url:o,method:"GET",params:n},t)}ProjectSecretAuthCallback(e,t){const i=e||{},o=this.genBaseURL("/api/permission_api/project_secret/callback"),n={code:i.code,state:i.state,error:i.error};return this.request({url:o,method:"GET",params:n},t)}ListAuthInfo(e,t){const i=e,o=this.genBaseURL("/api/permission_api/project_secret/list_auth_info"),n={credential_ids:i.credential_ids};return this.request({url:o,method:"POST",data:n},t)}RevokeAuthorization(e,t){const i=e,o=this.genBaseURL("/api/permission_api/project_secret/revoke"),n={credential_id:i.credential_id};return this.request({url:o,method:"POST",data:n},t)}VisibilityConfig(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/visibility_config"),n={enterprise_id:i.enterprise_id};return this.request({url:o,method:"POST",data:n},t)}GetVolcanoLoginMaskedMobile(e,t){const i=this.genBaseURL("/api/permission_api/volcano/get_volcano_login_masked_mobile");return this.request({url:i,method:"GET"},t)}BatchGetPeopleJoinedOrganization(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/batch_get_people_joined_organization"),n={enterprise_id:i.enterprise_id,user_ids:i.user_ids};return this.request({url:o,method:"POST",data:n},t)}BatchRemoveOrganizationPeople(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/batch_remove_organization_people"),n={enterprise_id:i.enterprise_id,remove_user_list:i.remove_user_list};return this.request({url:o,method:"POST",data:n},t)}BatchRemoveEnterprisePeople(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/batch_remove_enterprise_people"),n={enterprise_id:i.enterprise_id,remove_user_list:i.remove_user_list};return this.request({url:o,method:"POST",data:n},t)}GetOrganizationSettings(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/get_organization_settings"),n={organization_id:i.organization_id,organization_setting_key_list:i.organization_setting_key_list};return this.request({url:o,method:"POST",data:n},t)}UpdateOrganizationSettings(e,t){const i=e,o=this.genBaseURL("/api/permission_api/enterprise/update_organization_settings"),n={organization_id:i.organization_id,organization_settings:i.organization_settings};return this.request({url:o,method:"POST",data:n},t)}GithubAuthCallback(e,t){const i=e||{},o=this.genBaseURL("/api/permission_api/github_auth/callback"),n={code:i.code,state:i.state,error:i.error};return this.request({url:o,method:"GET",params:n},t)}}const Di=new xi({});function Mi(e,t){return null!=e?e:t()}class Gi{constructor(e){this.ctx=e,this.config=e.config}getOAuthConfig(){return{baseURL:Mi(this.config.openApiBaseUrl,(()=>J.openApiBaseUrl)),clientId:Mi(this.config.clientId,(()=>J.clientId))}}async clearUserContext(){this.config.organizationId=void 0,this.config.enterpriseId=void 0,this.config.spaceId=void 0,await X({organizationId:void 0,enterpriseId:void 0,spaceId:void 0})}openInBrowser(e){const t="darwin"===process.platform?"open":"win32"===process.platform?"cmd":"xdg-open",o="win32"===process.platform?["/c","start",'""',e]:[e],n="Failed to open browser automatically. Please open the URL manually.";try{const e=i.spawn(t,o,{detached:!0,stdio:"ignore"});e.on("error",(()=>{this.ctx.ui.verbose(n)})),e.unref()}catch(e){this.ctx.ui.verbose(`${n} ${e instanceof Error?e.message:String(e)}`)}}async clearAuthData(){this.config.accessToken=void 0,this.config.refreshToken=void 0,this.config.tokenExpiresAt=void 0,await X({accessToken:void 0,refreshToken:void 0,tokenExpiresAt:void 0})}async login(i){if(this.ctx.ui.verbose("Initiating login process..."),i.token)return this.ctx.ui.info("Using Personal Access Token (PAT)..."),this.config.accessToken=i.token,await X({accessToken:i.token,refreshToken:void 0,tokenExpiresAt:void 0}),await this.clearUserContext(),this.ctx.ui.info("Authentication successful. Credentials saved."),void("json"===this.ctx.format&&this.ctx.response.print({success:!0,method:"PAT"}));try{this.ctx.ui.info("Starting OAuth flow...");const{baseURL:i,clientId:o}=this.getOAuthConfig();this.ctx.ui.verbose("Starting OAuth device flow...");const n=await async function(e){const t=e.workspaceId?`/api/permission/oauth2/workspace_id/${e.workspaceId}/device/code`:"/api/permission/oauth2/device/code";return(await Ot.post(t,{client_id:e.clientId},{baseURL:e.baseURL})).data}({baseURL:i,clientId:o}),s=`${n.verification_uri}?user_code=${n.user_code}`;this.ctx.ui.info(`Please visit ${t.underline(s)} and authorize the application.\n\nPrivacy Policy: ${t.underline("https://docs.coze.cn/guides/privacy")}\nTerms of Service: ${t.underline("https://docs.coze.cn/guides/terms-of-service")}\n\nIf you are an agent using Coze CLI, please share the authorization link, Privacy Policy, and Terms of Service with your users.\n `),this.openInBrowser(s);const r=await async function(t,i){if(!t.poll)return It(t);let o=5e3;for(i.ui.debug("Start Polling for device token..."),i.ui.debug(`Polling interval: ${o}ms`),i.ui.debug("Polling timeout: 30000ms");;)try{i.ui.debug(`Polling for device token..., ${JSON.stringify(t)}`);const e=await It(t);return i.ui.debug(`Polling for device token success: ${JSON.stringify(e)}`),e}catch(t){if(e.isHttpError(t)){const e=t;i.ui.debug(`Polling for device token error, the error is a HttpError.\n logid: ${wt([e,"access",e=>e.response,"optionalAccess",e=>e.headers,"access",e=>e["x-tt-logid"]])}`),i.ui.debug(`Polling for device token error: ${JSON.stringify(zt(wt([e,"access",e=>e.toJSON,"optionalCall",e=>e()]),(()=>e)))}`);const n=e.data;if(wt([n,"optionalAccess",e=>e.error])===Ut.AUTHORIZATION_PENDING){i.ui.debug("Polling for device token: user has not completed authorization yet."),await Lt(o);continue}if(wt([n,"optionalAccess",e=>e.error])===Ut.SLOW_DOWN){o<3e4&&(o+=5e3),i.ui.debug(`Polling for device token: client is polling too frequently. Increasing interval to ${o}ms`),await Lt(o);continue}}const n=t;throw i.ui.debug(`Polling for device token error, the error is: ${n.message}\n ${n.stack}\n `),t}}({baseURL:i,clientId:o,deviceCode:n.device_code,poll:!0},this.ctx);this.ctx.ui.debug(`Polling for device token success: ${JSON.stringify(r)}`),await this.saveOAuthToken(r),this.ctx.ui.debug("Saving OAuth token successfully."),await this.clearUserContext(),this.ctx.ui.info("Authentication successful. Credentials saved."),"json"===this.ctx.format&&this.ctx.response.print({success:!0,method:"OAuth"})}catch(e){const t=e instanceof Error?e.message:String(e);throw this.ctx.ui.error(`OAuth login failed: ${t}`),e}}async logout(){await this.clearAuthData(),await this.clearUserContext(),this.ctx.ui.info("You have been logged out. Credentials cleared."),"json"===this.ctx.format&&this.ctx.response.print({success:!0,logged_out:!0})}async whoami(){if(!await this.getValidAccessToken())return void this.ctx.response.print({logged_in:!1});this.ctx.ui.info("Fetching user information...");this.ctx.response.print({logged_in:!0,user:"mock-user@coze.io",org:"mock-org",profile:"default"})}async status(){const e=await this.getValidAccessToken();if(this.ctx.ui.info("Checking authentication status..."),!e)return void this.ctx.response.print({logged_in:!1});const t=this.config.tokenExpiresAt,i=!!this.config.refreshToken,{data:o}=await Di.GetUserProfile({},{baseURL:this.config.openApiBaseUrl}),n={logged_in:!0,user:o,token_expires_at:t?new Date(t).toISOString():i?void 0:"Never (PAT)"};this.ctx.response.print(n)}async getValidAccessToken(){const{accessToken:e,refreshToken:t,tokenExpiresAt:i}=this.config;if(!e)return;if(!t)return e;if(i&&Date.now()<i-3e5)return e;this.ctx.ui.verbose("Access token is expired or expiring soon, refreshing...");try{const{baseURL:e,clientId:i}=this.getOAuthConfig(),o=await async function(e){const t={};return e.clientSecret&&(t.Authorization=`Bearer ${e.clientSecret}`),(await Ot.post("/api/permission/oauth2/token",{grant_type:"refresh_token",client_id:e.clientId,refresh_token:e.refreshToken},{baseURL:e.baseURL,headers:t})).data}({baseURL:e,clientId:i,refreshToken:t});return await this.saveOAuthToken(o),this.ctx.ui.verbose("Token refreshed successfully."),o.access_token}catch(e){const t=e instanceof Error?e.message:String(e);return this.ctx.ui.error(`Failed to refresh token: ${t}`),void await this.clearAuthData()}}async saveOAuthToken(e){const t=1e3*e.expires_in;this.config.accessToken=e.access_token,this.config.refreshToken=e.refresh_token,this.config.tokenExpiresAt=t,await X({accessToken:e.access_token,refreshToken:e.refresh_token,tokenExpiresAt:t})}}const Ni="",Fi="",$i="",Vi="",Wi="",Hi="",Ki="",Ji="",Qi="[PROC]",Zi="[INFO]",Yi="[WARN]",Xi="[ERR]",eo="[DONE]",to="[DBG]",io={debug:0,verbose:1,info:2,success:3,warn:4,error:5};function oo(e){return`${$i}${Fi}${e}${Ni}`}class no{constructor(e,t,i="info"){var o,n;this.log=e,this.silent="json"===t,this.useColor=this.detectColorSupport(),this.level=i,this.levelPriority=(n=()=>2,null!=(o=io[i])?o:n())}detectColorSupport(){return!0===function(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}([process,"access",e=>e.stderr,"optionalAccess",e=>e.isTTY])&&void 0===process.env.NO_COLOR}paint(e,t){return this.useColor?`${e}${t}${Ni}`:t}shouldOutput(e){return!this.silent&&io[e]>=this.levelPriority}verbose(e,...t){this.log.verbose(e,...t),this.shouldOutput("verbose")&&process.stderr.write(`${oo(Qi)} ${this.paint(Ki,e)}\n`)}info(e,...t){this.log.info(e,...t),this.shouldOutput("info")&&process.stderr.write(`${oo(Zi)} ${this.paint(Ni,e)}\n`)}warn(e,...t){this.log.warn(e,...t),this.shouldOutput("warn")&&process.stderr.write(`${oo(Yi)} ${this.paint(Hi,e)}\n`)}error(e,...t){this.log.error(e,...t),this.shouldOutput("error")&&process.stderr.write(`${oo(Xi)} ${this.paint(Vi,e)}\n`)}success(e,...t){this.log.success(e,...t),this.shouldOutput("success")&&process.stderr.write(`${oo(eo)} ${this.paint(Wi,e)}\n`)}debug(e,...t){this.log.debug(e,...t),this.shouldOutput("debug")&&process.stderr.write(`${oo(to)} ${this.paint(Ji,e)}\n`)}}class so{constructor(e){const{format:t}=e;this.formatter=function(e){return"text"===e?new B:new T}(t)}print(e){const t=this.formatter.format(e);process.stdout.write(t)}eprint(e){const t=this.formatter.formatError(e);process.stderr.write(t)}}function ro(e,t){return null!=e?e:t()}const ao=s.join(n.homedir(),".coze","logs");class co{__init(){this.fileStream=null}__init2(){this.writeError=!1}constructor(e={}){co.prototype.__init.call(this),co.prototype.__init2.call(this),this.format=ro(e.format,(()=>"text")),this.printToStderr=ro(e.printToStderr,(()=>!1)),this.tags=ro(e.tags,(()=>({}))),this.startTime=Date.now();const t=ro(e.logFile,(()=>this.getDefaultLogPath()));this.logFile=t;try{this.ensureLogDir(),this.rotateLogFiles(),this.fileStream=d.createWriteStream(t,{flags:"a"}),this.fileStream.on("error",(()=>{this.fileStream=null}))}catch(e){this.logFile=null,this.fileStream=null}}getDefaultLogPath(){const e=(new Date).toISOString().replace(/[:.]/g,"-"),{pid:t}=process;return s.join(ao,`${e}-${t}.log`)}ensureLogDir(){d.existsSync(ao)||d.mkdirSync(ao,{recursive:!0})}rotateLogFiles(){try{const e=d.readdirSync(ao).filter((e=>e.endsWith(".log"))).map((e=>({name:e,path:s.join(ao,e),mtime:d.statSync(s.join(ao,e)).mtime.getTime()}))).sort(((e,t)=>t.mtime-e.mtime));e.length>=10&&e.slice(9).forEach((e=>{try{d.unlinkSync(e.path)}catch(e){}}))}catch(e){}}verbose(e,...t){this.log("verbose",e,t)}info(e,...t){this.log("info",e,t)}warn(e,...t){this.log("warn",e,t)}error(e,...t){this.log("error",e,t)}success(e,...t){this.log("success",e,t)}debug(e,...t){this.log("debug",e,t)}log(e,t,i){const o=this.formatEntry(e,t,i);if(this.fileStream)try{this.fileStream.write(`${o}\n`)}catch(e){!this.writeError&&this.printToStderr&&(process.stderr.write("Warning: Log write failed\n"),this.writeError=!0)}this.printToStderr&&process.stderr.write(`${o}\n`)}formatEntry(e,t,i){const o=(new Date).toISOString(),n=Date.now()-this.startTime;if("json"===this.format){const s={level:e,timestamp:o,delta:n,...this.tags,message:t};return i.length>0&&(s.args=i),JSON.stringify(s)}const s=Object.entries(this.tags).map((([e,t])=>`${e}=${t}`)).join(" "),r=i.length>0?` ${i.map(String).join(" ")}`:"";return`${e.toUpperCase().padEnd(7)} [${o}] +${n}ms ${s} ${t}${r}`}close(){if(this.fileStream)try{this.fileStream.end()}catch(e){}}}function po(e,t){return null!=e?e:t()}async function lo(e,t){const i=Date.now();e.ui.verbose(`[Logger] CLI start: ${e.argv.join(" ")}`);try{await t()}finally{const t=Date.now()-i;e.ui.verbose(`[Logger] CLI end (took ${t}ms)`)}}var uo,_o,mo,go,ho,fo,yo,vo,bo,Po,So,To,Co,ko,Ao,Eo,Ro,jo,zo,wo,Uo,Lo,Oo,Io,Bo,qo,xo,Do,Mo,Go,No,Fo,$o,Vo,Wo,Ho,Ko,Jo,Qo,Zo,Yo,Xo,en,tn,on,nn,sn,rn,an,cn,dn,pn,ln,un,_n,mn,gn,hn,fn,yn,vn,bn,Pn,Sn,Tn,Cn,kn,An,En,Rn,jn,zn,wn,Un,Ln,On,In,Bn,qn,xn,Dn,Mn,Gn,Nn,Fn,$n,Vn,Wn,Hn,Kn,Jn,Qn,Zn,Yn,Xn,es,ts,is,os,ns,ss,rs,as,cs,ds,ps,ls,us,_s,ms,gs,hs,fs,ys,vs,bs,Ps,Ss,Ts,Cs,ks,As,Es,Rs,js,zs,ws,Us,Ls,Os,Is;function Bs(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}!function(e){e[e.Start_Agent=0]="Start_Agent";e[e.LLM_Agent=1]="LLM_Agent";e[e.Task_Agent=2]="Task_Agent";e[e.Global_Agent=3]="Global_Agent";e[e.Bot_Agent=4]="Bot_Agent"}(uo||(uo={})),function(e){e[e.OldVersion=0]="OldVersion";e[e.MiddleVersion=1]="MiddleVersion";e[e.NewVersion=2]="NewVersion";e[e.MiddleVersionNotPrompt=3]="MiddleVersionNotPrompt"}(_o||(_o={})),function(e){e[e.Default=1]="Default";e[e.Customize=2]="Customize"}(mo||(mo={})),function(e){e[e.Direct=1]="Direct";e[e.WebView=2]="WebView";e[e.SendMessage=3]="SendMessage"}(go||(go={})),function(e){e[e.ChatApi=0]="ChatApi";e[e.ResponsesApi=1]="ResponsesApi"}(ho||(ho={})),function(e){e[e.Current=1]="Current";e[e.Previous=2]="Previous";e[e.Start=3]="Start";e[e.MostSuitable=4]="MostSuitable"}(fo||(fo={})),function(e){e[e.SingleMode=0]="SingleMode";e[e.MultiMode=1]="MultiMode";e[e.WorkflowMode=2]="WorkflowMode"}(yo||(yo={})),function(e){e[e.Default=0]="Default";e[e.Function=1]="Function"}(vo||(vo={})),function(e){e[e.Deleted=0]="Deleted";e[e.Using=1]="Using";e[e.Banned=2]="Banned"}(bo||(bo={})),function(e){e[e.LimitedReadWrite=1]="LimitedReadWrite";e[e.ReadOnly=2]="ReadOnly";e[e.UnlimitedReadWrite=3]="UnlimitedReadWrite";e[e.RWModeMax=4]="RWModeMax"}(Po||(Po={})),function(e){e[e.Default=0]="Default";e[e.DouyinAvatar=1]="DouyinAvatar"}(So||(So={})),function(e){e[e.CacheClosed=0]="CacheClosed";e[e.PrefixCache=1]="PrefixCache"}(To||(To={})),function(e){e[e.Chat=0]="Chat";e[e.FunctionCall_1=1]="FunctionCall_1";e[e.FunctionCall_2=2]="FunctionCall_2";e[e.FunctionCall_3=3]="FunctionCall_3"}(Co||(Co={})),function(e){e[e.NotSet=0]="NotSet";e[e.Text=1]="Text";e[e.Voice=2]="Voice";e[e.Call=3]="Call";e[e.VideoCall=4]="VideoCall"}(ko||(ko={})),function(e){e[e.Off=0]="Off";e[e.On=1]="On"}(Ao||(Ao={})),function(e){e[e.Text=1]="Text";e[e.Number=2]="Number";e[e.Date=3]="Date";e[e.Float=4]="Float";e[e.Boolean=5]="Boolean"}(Eo||(Eo={})),function(e){e[e.Off=0]="Off";e[e.On=1]="On"}(Ro||(Ro={})),function(e){e[e.SLM=0]="SLM";e[e.LLM=1]="LLM"}(jo||(jo={})),function(e){e[e.Pre=1]="Pre";e[e.Post=2]="Post";e[e.PreAndPost=3]="PreAndPost"}(zo||(zo={})),function(e){e[e.Default=0]="Default";e[e.CustomizePrompt=1]="CustomizePrompt"}(wo||(wo={})),function(e){e[e.ReplyBottom=0]="ReplyBottom";e[e.CardList=1]="CardList"}(Uo||(Uo={})),function(e){e[e.Coze=0]="Coze";e[e.Volcano=1]="Volcano";e[e.ThirdParty=2]="ThirdParty"}(Lo||(Lo={})),function(e){e[e.Coze=0]="Coze";e[e.Volcano=1]="Volcano";e[e.ThirdParty=2]="ThirdParty"}(Oo||(Oo={})),function(e){e[e.FullSupport=0]="FullSupport";e[e.PoorSupport=1]="PoorSupport";e[e.NotSupport=2]="NotSupport"}(Io||(Io={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.ImageFlow=3]="ImageFlow";e[e.Trigger=4]="Trigger";e[e.KnowledgeText=5]="KnowledgeText";e[e.KnowledgeTable=6]="KnowledgeTable";e[e.KnowledgeAutoCall=7]="KnowledgeAutoCall";e[e.KnowledgeOnDemandCall=8]="KnowledgeOnDemandCall";e[e.Variable=9]="Variable";e[e.Database=10]="Database";e[e.LongTermMemory=11]="LongTermMemory";e[e.FileBox=12]="FileBox";e[e.Onboarding=13]="Onboarding";e[e.Suggestion=14]="Suggestion";e[e.ShortcutCommand=15]="ShortcutCommand";e[e.BackGroundImage=16]="BackGroundImage";e[e.TTS=17]="TTS";e[e.MultiAgentRecognize=18]="MultiAgentRecognize";e[e.KnowledgePhoto=19]="KnowledgePhoto";e[e.HookInfo=20]="HookInfo";e[e.KnowledgeValcanoUnstructured=21]="KnowledgeValcanoUnstructured";e[e.KnowledgeValcanoStructured=22]="KnowledgeValcanoStructured";e[e.Model=23]="Model";e[e.KnowledgeThirdPartyUnstructured=24]="KnowledgeThirdPartyUnstructured";e[e.KnowledgeThirdPartyStructured=25]="KnowledgeThirdPartyStructured"}(Bo||(Bo={})),function(e){e[e.Text=0]="Text";e[e.Markdown=1]="Markdown";e[e.JSON=2]="JSON"}(qo||(qo={})),function(e){e[e.Custom=0]="Custom";e[e.Creative=1]="Creative";e[e.Balance=2]="Balance";e[e.Precise=3]="Precise"}(xo||(xo={})),function(e){e[e.Curve=0]="Curve";e[e.Straight=1]="Straight"}(Do||(Do={})),function(e){e[e.Flow=1]="Flow";e[e.Host=2]="Host"}(Mo||(Mo={})),function(e){e[e.NO_NEED=1]="NO_NEED";e[e.USE_MANUAL=2]="USE_MANUAL";e[e.USE_LLM=3]="USE_LLM"}(Go||(Go={})),function(e){e[e.EQUAL=1]="EQUAL";e[e.NOT_EQUAL=2]="NOT_EQUAL";e[e.GREATER_THAN=3]="GREATER_THAN";e[e.LESS_THAN=4]="LESS_THAN";e[e.GREATER_EQUAL=5]="GREATER_EQUAL";e[e.LESS_EQUAL=6]="LESS_EQUAL";e[e.IN=7]="IN";e[e.NOT_IN=8]="NOT_IN";e[e.IS_NULL=9]="IS_NULL";e[e.IS_NOT_NULL=10]="IS_NOT_NULL";e[e.LIKE=11]="LIKE";e[e.NOT_LIKE=12]="NOT_LIKE"}(No||(No={})),function(e){e[e.Input=0]="Input";e[e.Variable=1]="Variable"}(Fo||(Fo={})),function(e){e[e.Default=0]="Default";e[e.FromSaas=1]="FromSaas"}($o||($o={})),function(e){e[e.Standard=0]="Standard";e[e.PrefixPrompt=1]="PrefixPrompt"}(Vo||(Vo={})),function(e){e[e.FunctionCall=1]="FunctionCall";e[e.Independent=2]="Independent"}(Wo||(Wo={})),function(e){e[e.HasUpdates=1]="HasUpdates";e[e.IsDelete=2]="IsDelete"}(Ho||(Ho={})),function(e){e[e.ManualUpdate=1]="ManualUpdate";e[e.AutoUpdate=2]="AutoUpdate"}(Ko||(Ko={})),function(e){e[e.SemanticSearch=0]="SemanticSearch";e[e.HybirdSearch=1]="HybirdSearch";e[e.FullTextSearch=20]="FullTextSearch"}(Jo||(Jo={})),function(e){e[e.Public=1]="Public";e[e.Anonymous=2]="Anonymous";e[e.Custom=3]="Custom"}(Qo||(Qo={})),function(e){e[e.Random=0]="Random";e[e.All=1]="All"}(Zo||(Zo={})),function(e){e[e.System=0]="System";e[e.Custom=1]="Custom";e[e.Disable=2]="Disable";e[e.OriBot=3]="OriBot"}(Yo||(Yo={})),function(e){e[e.ListString=1]="ListString";e[e.String=2]="String";e[e.Integer=3]="Integer";e[e.Float=4]="Float";e[e.Boolean=5]="Boolean"}(Xo||(Xo={})),function(e){e[e.Off=0]="Off";e[e.On=1]="On"}(en||(en={})),function(e){e[e.CozeOldTimeCapsule=0]="CozeOldTimeCapsule";e[e.VolcanoTimeCapsule=1]="VolcanoTimeCapsule"}(tn||(tn={})),function(e){e[e.Workflow=0]="Workflow";e[e.Imageflow=1]="Imageflow";e[e.SceneFlow=2]="SceneFlow";e[e.ChatFlow=3]="ChatFlow";e[e.All=100]="All"}(on||(on={})),function(e){e[e.BotQuery=1]="BotQuery";e[e.Plugin=2]="Plugin";e[e.Workflow=3]="Workflow"}(nn||(nn={})),function(e){e[e.Unknown=0]="Unknown";e[e.Webhook=1]="Webhook"}(sn||(sn={})),function(e){e[e.Unknown=0]="Unknown";e[e.Time=1]="Time";e[e.Event=2]="Event"}(rn||(rn={})),function(e){e[e.NoHistory=0]="NoHistory";e[e.NeedHistory=1]="NeedHistory"}(an||(an={})),function(e){e[e.NoTriggered=0]="NoTriggered";e[e.Triggered=1]="Triggered";e[e.DoAction=2]="DoAction";e[e.WaitToPush=3]="WaitToPush";e[e.PushSuccess=4]="PushSuccess";e[e.PushFail=5]="PushFail"}(cn||(cn={})),function(e){e[e.Init=0]="Init";e[e.Activated=1]="Activated";e[e.Deactivated=2]="Deactivated";e[e.Suspended=3]="Suspended"}(dn||(dn={})),function(e){e[e.Preset=1]="Preset";e[e.UserTask=2]="UserTask";e[e.PluginRunTask=3]="PluginRunTask"}(pn||(pn={})),function(e){e[e.Deploying=0]="Deploying";e[e.Successful=1]="Successful";e[e.Failed=2]="Failed"}(ln||(ln={})),function(e){e[e.All=0]="All";e[e.Bind=1]="Bind";e[e.UnBind=2]="UnBind"}(un||(un={})),function(e){e[e.CreateTime=0]="CreateTime";e[e.UpdateTime=1]="UpdateTime"}(_n||(_n={})),function(e){e[e.EventMeta=1]="EventMeta";e[e.ProfileMeta=2]="ProfileMeta"}(mn||(mn={})),function(e){e[e.ChatApi=0]="ChatApi";e[e.ResponsesApi=1]="ResponsesApi"}(gn||(gn={})),function(e){e[e.GPT=1]="GPT";e[e.SEED=2]="SEED";e[e.Claude=3]="Claude";e[e.MiniMax=4]="MiniMax";e[e.Plugin=5]="Plugin";e[e.StableDiffusion=6]="StableDiffusion";e[e.ByteArtist=7]="ByteArtist";e[e.Maas=9]="Maas";e[e.QianFan=10]="QianFan";e[e.Gemini=11]="Gemini";e[e.Moonshot=12]="Moonshot";e[e.GLM=13]="GLM";e[e.MaaSAutoSync=14]="MaaSAutoSync";e[e.QWen=15]="QWen";e[e.Cohere=16]="Cohere";e[e.Baichuan=17]="Baichuan";e[e.Ernie=18]="Ernie";e[e.DeekSeek=19]="DeekSeek";e[e.Llama=20]="Llama";e[e.StepFun=23]="StepFun";e[e.Custom=24]="Custom";e[e.Other=999]="Other"}(hn||(hn={})),function(e){e[e.Float=1]="Float";e[e.Int=2]="Int";e[e.Boolean=3]="Boolean";e[e.String=4]="String"}(fn||(fn={})),function(e){e[e.ModelType=1]="ModelType";e[e.ModelUserRight=2]="ModelUserRight";e[e.ModelFeature=3]="ModelFeature";e[e.ModelFunction=4]="ModelFunction";e[e.ModelPaid=15]="ModelPaid";e[e.ModelAbility=16]="ModelAbility";e[e.ModelStatus=17]="ModelStatus";e[e.Custom=20]="Custom";e[e.Others=100]="Others"}(yn||(yn={})),function(e){e[e.Flagship=1]="Flagship";e[e.HighSpeed=2]="HighSpeed";e[e.ToolInvocation=3]="ToolInvocation";e[e.RolePlaying=4]="RolePlaying";e[e.LongText=5]="LongText";e[e.ImageUnderstanding=6]="ImageUnderstanding";e[e.Reasoning=7]="Reasoning";e[e.VideoUnderstanding=8]="VideoUnderstanding";e[e.CostPerformance=9]="CostPerformance";e[e.CodeSpecialization=10]="CodeSpecialization";e[e.AudioUnderstanding=11]="AudioUnderstanding"}(vn||(vn={})),function(e){e[e.Text=1]="Text";e[e.ImageFirstFrame=2]="ImageFirstFrame";e[e.ImageFirstLastFrame=3]="ImageFirstLastFrame";e[e.ReferencePicture=4]="ReferencePicture"}(bn||(bn={})),function(e){e[e.Start_Agent=0]="Start_Agent";e[e.LLM_Agent=1]="LLM_Agent";e[e.Task_Agent=2]="Task_Agent";e[e.Global_Agent=3]="Global_Agent";e[e.Bot_Agent=4]="Bot_Agent"}(Pn||(Pn={})),function(e){e[e.Upgrade=1]="Upgrade";e[e.BrowseOldNoPrompt=2]="BrowseOldNoPrompt"}(Sn||(Sn={})),function(e){e[e.Default=1]="Default";e[e.Customize=2]="Customize"}(Tn||(Tn={})),function(e){e[e.Direct=1]="Direct";e[e.WebView=2]="WebView";e[e.SendMessage=3]="SendMessage"}(Cn||(Cn={})),function(e){e[e.Auditing=0]="Auditing";e[e.Success=1]="Success";e[e.Failed=2]="Failed"}(kn||(kn={})),function(e){e[e.Visit=1]="Visit";e[e.Edit=2]="Edit"}(An||(An={})),function(e){e[e.Online=1]="Online";e[e.Offline=2]="Offline"}(En||(En={})),function(e){e[e.Offline=0]="Offline";e[e.Online=1]="Online"}(Rn||(Rn={})),function(e){e[e.SingleMode=0]="SingleMode";e[e.MultiMode=1]="MultiMode";e[e.WorkflowMode=2]="WorkflowMode"}(jn||(jn={})),function(e){e[e.AutoGenBeforePublish=1]="AutoGenBeforePublish"}(zn||(zn={})),function(e){e[e.CozeHome=1]="CozeHome";e[e.Space=2]="Space"}(wn||(wn={})),function(e){e[e.Undefined=0]="Undefined";e[e.PersonalDraft=1]="PersonalDraft";e[e.Base=2]="Base";e[e.Publish=3]="Publish"}(Un||(Un={})),function(e){e[e.Undefined=0]="Undefined";e[e.Committed=1]="Committed";e[e.Behind=2]="Behind";e[e.NoDraftReplica=3]="NoDraftReplica"}(Ln||(Ln={})),function(e){e[e.Normal=0]="Normal";e[e.Offline=1]="Offline";e[e.TokenDisconnect=2]="TokenDisconnect"}(On||(On={})),function(e){e[e.USER_RES=0]="USER_RES";e[e.USER_LLM_RES=1]="USER_LLM_RES";e[e.USER_LLM_APILEN_RES=2]="USER_LLM_APILEN_RES";e[e.USER_LLM_API_RES=3]="USER_LLM_API_RES"}(In||(In={})),function(e){e[e.Personal=1]="Personal";e[e.Organization=2]="Organization"}(Bn||(Bn={})),function(e){e[e.Agent=1]="Agent";e[e.Project=2]="Project";e[e.Knowledge=3]="Knowledge";e[e.Dataset=4]="Dataset";e[e.Plugin=5]="Plugin";e[e.Memorybase=6]="Memorybase"}(qn||(qn={})),function(e){e[e.Text=0]="Text";e[e.Table=1]="Table";e[e.Image=2]="Image";e[e.VolcanoStructured=4]="VolcanoStructured";e[e.VolcanoUnstructured=5]="VolcanoUnstructured";e[e.ThirdPartyStructured=7]="ThirdPartyStructured";e[e.ThirdPartyUnstructured=8]="ThirdPartyUnstructured"}(xn||(xn={})),function(e){e[e.Deleted=0]="Deleted";e[e.Using=1]="Using";e[e.Banned=2]="Banned";e[e.MoveFail=3]="MoveFail"}(Dn||(Dn={})),function(e){e[e.ByteTree=1]="ByteTree";e[e.GPTAK=2]="GPTAK";e[e.MaasAK=3]="MaasAK"}(Mn||(Mn={})),function(e){e[e.Init=0]="Init";e[e.Generating=1]="Generating";e[e.Success=2]="Success";e[e.Fail=3]="Fail";e[e.Cancel=4]="Cancel"}(Gn||(Gn={})),function(e){e[e.BotStore=1]="BotStore"}(Nn||(Nn={})),function(e){e[e.shorcutIcon=1]="shorcutIcon"}(Fn||(Fn={})),function(e){e[e.Onboarding=0]="Onboarding";e[e.BackgroundImage=1]="BackgroundImage"}($n||($n={})),function(e){e[e.BasicUser=1]="BasicUser";e[e.ExternalUser=2]="ExternalUser";e[e.RootUser=3]="RootUser"}(Vn||(Vn={})),function(e){e[e.GetInfo=1]="GetInfo"}(Wn||(Wn={})),function(e){e[e.Normal=1]="Normal";e[e.Invalid=2]="Invalid";e[e.Expired=3]="Expired";e[e.Rejected=4]="Rejected";e[e.Applying=5]="Applying"}(Hn||(Hn={})),function(e){e[e.Apply=1]="Apply";e[e.Invite=2]="Invite";e[e.EnterpriseApply=3]="EnterpriseApply"}(Kn||(Kn={})),function(e){e[e.GPT=1]="GPT";e[e.Claude=3]="Claude";e[e.Gemini=11]="Gemini";e[e.Moonshot=12]="Moonshot";e[e.GLM=13]="GLM";e[e.QWen=15]="QWen";e[e.DeekSeek=19]="DeekSeek";e[e.StepFun=23]="StepFun"}(Jn||(Jn={})),function(e){e[e.Douyin=1]="Douyin"}(Qn||(Qn={})),function(e){e[e.GPTOpenAPI=1]="GPTOpenAPI";e[e.Maas=2]="Maas";e[e.LLMFlow=3]="LLMFlow";e[e.Merlin=4]="Merlin"}(Zn||(Zn={})),function(e){e[e.Move=0]="Move";e[e.ForcedMove=1]="ForcedMove";e[e.RetryMove=2]="RetryMove";e[e.Preview=3]="Preview";e[e.ViewTask=4]="ViewTask";e[e.CancelTask=5]="CancelTask"}(Yn||(Yn={})),function(e){e[e.All=0]="All";e[e.Unread=1]="Unread"}(Xn||(Xn={})),function(e){e[e.Bot=1]="Bot"}(es||(es={})),function(e){e[e.CharactersAnime=1]="CharactersAnime";e[e.CharactersRealistic=2]="CharactersRealistic";e[e.CharactersCGThickPainting=3]="CharactersCGThickPainting";e[e.CharactersJapaneseShowa=4]="CharactersJapaneseShowa";e[e.CharactersAmericanComics=5]="CharactersAmericanComics";e[e.CharactersChineseWatercolor=6]="CharactersChineseWatercolor";e[e.ScenesScienceFiction=7]="ScenesScienceFiction";e[e.ScenesRealistic=8]="ScenesRealistic";e[e.ScenesChinesePainting=9]="ScenesChinesePainting";e[e.ScenesCartoonIllustrations=10]="ScenesCartoonIllustrations";e[e.ScenesCartoon3D=11]="ScenesCartoon3D"}(ts||(ts={})),function(e){e[e.IconStatic=1]="IconStatic";e[e.IconGif=2]="IconGif";e[e.BackgroundStatic=3]="BackgroundStatic";e[e.BackgroundGif=4]="BackgroundGif";e[e.PicPrompt=5]="PicPrompt"}(is||(is={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.ShortcutCommand=3]="ShortcutCommand";e[e.Task=4]="Task"}(os||(os={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.ImageFlow=3]="ImageFlow";e[e.Knowledge=4]="Knowledge"}(ns||(ns={})),function(e){e[e.NoPublish=0]="NoPublish";e[e.HadPublished=1]="HadPublished"}(ss||(ss={})),function(e){e[e.Success=1]="Success";e[e.Failed=2]="Failed";e[e.InReview=3]="InReview"}(rs||(rs={})),function(e){e[e.Unread=1]="Unread";e[e.Read=2]="Read"}(as||(as={})),function(e){e[e.HasUpdates=1]="HasUpdates";e[e.IsDelete=2]="IsDelete"}(cs||(cs={})),function(e){e[e.UnLimit=1]="UnLimit";e[e.Forbidden=2]="Forbidden"}(ds||(ds={})),function(e){e[e.Plugin=1]="Plugin";e[e.NewBotIDEGuide=2]="NewBotIDEGuide";e[e.NewBeginnerGuide=3]="NewBeginnerGuide"}(ps||(ps={})),function(e){e[e.Default=0]="Default";e[e.Explore=1]="Explore";e[e.BotStore=2]="BotStore";e[e.CozeHome=3]="CozeHome";e[e.Playground=4]="Playground";e[e.Evaluation=5]="Evaluation";e[e.AgentApp=6]="AgentApp";e[e.GenerateAgentInfo=8]="GenerateAgentInfo";e[e.Template=9]="Template";e[e.EnterpriseStore=10]="EnterpriseStore"}(ls||(ls={})),function(e){e[e.All=0]="All";e[e.Self=1]="Self"}(us||(us={})),function(e){e[e.All=0]="All";e[e.Joined=1]="Joined";e[e.Confirming=2]="Confirming";e[e.Rejected=3]="Rejected";e[e.AutoApproved=4]="AutoApproved"}(_s||(_s={})),function(e){e[e.All=0]="All";e[e.Joined=1]="Joined";e[e.Confirming=2]="Confirming";e[e.Rejected=3]="Rejected";e[e.Revoked=4]="Revoked";e[e.Expired=5]="Expired"}(ms||(ms={})),function(e){e[e.EnterpriseUser=1]="EnterpriseUser";e[e.ExternalUser=2]="ExternalUser"}(gs||(gs={})),function(e){e[e.Normal=0]="Normal";e[e.DevMode=1]="DevMode"}(hs||(hs={})),function(e){e[e.DraftBot=1]="DraftBot";e[e.Project=2]="Project";e[e.Space=3]="Space";e[e.DouyinAvatarBot=4]="DouyinAvatarBot"}(fs||(fs={})),function(e){e[e.Default=0]="Default";e[e.Owner=1]="Owner";e[e.Admin=2]="Admin";e[e.Member=3]="Member"}(ys||(ys={})),function(e){e[e.Professional=1]="Professional"}(vs||(vs={})),function(e){e[e.Personal=1]="Personal";e[e.Team=2]="Team"}(bs||(bs={})),function(e){e[e.Dark=1]="Dark";e[e.Light=2]="Light"}(Ps||(Ps={})),function(e){e[e.AlwaysOn=0]="AlwaysOn";e[e.AlwaysOff=1]="AlwaysOff"}(Ss||(Ss={})),function(e){e[e.CozeAssistantGuide=1]="CozeAssistantGuide"}(Ts||(Ts={})),function(e){e[e.Normal=1]="Normal";e[e.Banned=2]="Banned";e[e.Canceled=3]="Canceled"}(Cs||(Cs={})),function(e){e[e.External=0]="External";e[e.Internal=1]="Internal"}(ks||(ks={})),function(e){e[e.Invisible=0]="Invisible";e[e.Visible=1]="Visible";e[e.SocietyInvisible=2]="SocietyInvisible"}(As||(As={})),function(e){e[e.SingleAgent=1]="SingleAgent";e[e.MultiAgent=2]="MultiAgent";e[e.WorkflowAsAgent=3]="WorkflowAsAgent"}(Es||(Es={})),function(e){e[e.Preset=1]="Preset";e[e.Library=2]="Library"}(Rs||(Rs={})),function(e){e[e.DatasetServiceValid=0]="DatasetServiceValid";e[e.DatasetServiceInvalid=1]="DatasetServiceInvalid"}(js||(js={})),function(e){e[e.DatasetValid=0]="DatasetValid";e[e.DatasetInvalid=1]="DatasetInvalid"}(zs||(zs={})),function(e){e[e.RootUser=1]="RootUser";e[e.BasicUser=2]="BasicUser"}(ws||(ws={})),function(e){e[e.Workflow=0]="Workflow";e[e.Imageflow=1]="Imageflow";e[e.SceneFlow=2]="SceneFlow";e[e.ChatFlow=3]="ChatFlow";e[e.All=100]="All"}(Us||(Us={})),function(e){e[e.TextInput=0]="TextInput";e[e.Select=1]="Select";e[e.UploadImage=2]="UploadImage";e[e.UploadDoc=3]="UploadDoc";e[e.UploadTable=4]="UploadTable";e[e.UploadAudio=5]="UploadAudio";e[e.MixUpload=6]="MixUpload";e[e.VIDEO=7]="VIDEO";e[e.ARCHIVE=8]="ARCHIVE";e[e.CODE=9]="CODE";e[e.TXT=10]="TXT";e[e.PPT=11]="PPT"}(Ls||(Ls={})),function(e){e[e.SendTypeQuery=0]="SendTypeQuery";e[e.SendTypePanel=1]="SendTypePanel"}(Os||(Os={})),function(e){e[e.ToolTypeWorkFlow=1]="ToolTypeWorkFlow";e[e.ToolTypePlugin=2]="ToolTypePlugin"}(Is||(Is={}));class qs{__init(){this.request=e.request}__init2(){this.baseURL=""}constructor(e){qs.prototype.__init.call(this),qs.prototype.__init2.call(this),this.request=Bs([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=Bs([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}GetSpaceInfoV2(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/info"),n={space_id:i.space_id,join_space_type:i.join_space_type};return this.request({url:o,method:"POST",data:n},t)}DeleteSpaceV2(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/delete"),n={space_id:i.space_id};return this.request({url:o,method:"POST",data:n},t)}SaveSpaceV2(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/save"),n={space_id:i.space_id,name:i.name,description:i.description,icon_uri:i.icon_uri,space_type:i.space_type,space_mode:i.space_mode,space_config:i.space_config,enterprise_id:i.enterprise_id,organization_id:i.organization_id};return this.request({url:o,method:"POST",data:n},t)}GetSpaceListV2(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/space/list"),n={search_word:i.search_word,enterprise_id:i.enterprise_id,organization_id:i.organization_id,scope_type:i.scope_type,page:i.page,size:i.size};return this.request({url:o,method:"POST",data:n},t)}UpdateAgent(e,t){const i=e,o=this.genBaseURL("/api/playground_api/update_agent"),n={id:i.id,reference_id:i.reference_id,current_version:i.current_version,space_id:i.space_id,bot_id:i.bot_id,base_commit_version:i.base_commit_version,name:i.name,description:i.description,position:i.position,icon_uri:i.icon_uri,intents:i.intents,work_info:i.work_info,is_delete:i.is_delete};return this.request({url:o,method:"POST",data:n},t)}BatchCreateAgent(e,t){const i=e,o=this.genBaseURL("/api/playground_api/batch_create_agent"),n={space_id:i.space_id,bot_id:i.bot_id,agent_type:i.agent_type,position:i.position,references:i.references,agent_cnt:i.agent_cnt,base_commit_version:i.base_commit_version,version_compat:i.version_compat};return this.request({url:o,method:"POST",data:n},t)}GetPublishBotList(e,t){const i=e,o=this.genBaseURL("/api/playground_api/get_publish_bot_list"),n={space_id:i.space_id,bot_mode:i.bot_mode,page_num:i.page_num,page_size:i.page_size,name:i.name,login_user_create:i.login_user_create,bot_id:i.bot_id};return this.request({url:o,method:"GET",params:n},t)}MGetBotByVersion(e,t){const i=e,o=this.genBaseURL("/api/playground_api/mget_bot_by_version"),n={bot_versions:i.bot_versions,space_id:i.space_id};return this.request({url:o,method:"POST",data:n},t)}BotLastPublishInfo(e,t){const i=e,o=this.genBaseURL("/api/playground_api/bot_last_publish_info"),n={space_id:i.space_id,bot_id:i.bot_id,bot_mode:i.bot_mode};return this.request({url:o,method:"GET",params:n},t)}ProduceBot(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/produce/create_bot"),n={space_id:i.space_id,name:i.name,description:i.description,icon_url:i.icon_url,icon_uri:i.icon_uri,prompt:i.prompt,plugin_apis:i.plugin_apis,prologue:i.prologue,suggested_questions:i.suggested_questions,bot_source:i.bot_source};return this.request({url:o,method:"POST",data:n},t)}UpdateProducedBot(e,t){const i=e,o=this.genBaseURL("/api/playground_api/produce/update_bot"),n={bot_id:i.bot_id,name:i.name,description:i.description,icon_url:i.icon_url,icon_uri:i.icon_uri};return this.request({url:o,method:"POST",data:n},t)}GetPublishedBotList(e,t){const i=e,o=this.genBaseURL("/api/playground_api/bot_version/get_published_bot_list"),n={space_id_list:i.space_id_list,page:i.page,size:i.size};return this.request({url:o,method:"POST",data:n},t)}GetBotVersionInfo(e,t){const i=e,o=this.genBaseURL("/api/playground_api/bot_version/get_bot_version_info"),n={bot_id:i.bot_id,version:i.version,scene:i.scene};return this.request({url:o,method:"POST",data:n},t)}DuplicateBotVersionToSpace(e,t){const i=e,o=this.genBaseURL("/api/playground_api/dup_bot_version"),n={target_space_id:i.target_space_id,bot_id:i.bot_id,version:i.version,name:i.name,dup_society_host:i.dup_society_host};return this.request({url:o,method:"POST",data:n},t)}UpdateUserRiskAlertInfo(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/update_user_risk_alert_info"),n={risk_alert_type:i.risk_alert_type,switch_info:i.switch_info};return this.request({url:o,method:"POST",data:n},t)}GetUserRiskAlertInfo(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/get_user_risk_alert_info"),n={risk_alert_type_list:i.risk_alert_type_list,switch_type_list:i.switch_type_list},s={Cookie:i.Cookie};return this.request({url:o,method:"POST",data:n,headers:s},t)}DraftBotCollaboration(e,t){const i=e,o=this.genBaseURL("/api/playground_api/draftbot/collaboration"),n={space_id:i.space_id,bot_id:i.bot_id};return this.request({url:o,method:"POST",data:n},t)}BotInfoAudit(e,t){const i=e,o=this.genBaseURL("/api/playground_api/audit/bot_info"),n={bot_id:i.bot_id,bot_audit_info:i.bot_audit_info,space_id:i.space_id,bot_mode:i.bot_mode};return this.request({url:o,method:"POST",data:n},t)}TimeCapsuleInvokeEvent(e,t){const i=e,o=this.genBaseURL("/api/playground_api/timecapsule_invoke_event"),n={bot_id:i.bot_id};return this.request({url:o,method:"POST",data:n},t)}InviteMemberLinkV2(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/invite"),n={space_id:i.space_id,team_invite_link_status:i.team_invite_link_status,func:i.func};return this.request({url:o,method:"POST",data:n},t)}SpaceMemberDetailV2(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/space/member/detail"),n={space_id:i.space_id,search_word:i.search_word,space_role_type:i.space_role_type,page:i.page,size:i.size};return this.request({url:o,method:"POST",data:n},t)}JoinSpaceV2(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/join"),n={space_id:i.space_id,join_space_type:i.join_space_type,is_reject:i.is_reject};return this.request({url:o,method:"POST",data:n},t)}UpdateSpaceMemberV2(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/space/member/update"),n={space_id:i.space_id,user_id:i.user_id,space_role_type:i.space_role_type};return this.request({url:o,method:"POST",data:n},t)}TransferSpaceV2(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/space/member/transfer"),n={space_id:i.space_id,transfer_user_id:i.transfer_user_id};return this.request({url:o,method:"POST",data:n},t)}RemoveSpaceMemberV2(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/space/member/remove"),n={space_id:i.space_id,remove_user_id:i.remove_user_id,transfer_user_id:i.transfer_user_id};return this.request({url:o,method:"POST",data:n},t)}SearchMemberV2(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/member/search"),n={search_list:i.search_list,space_id:i.space_id,search_volcano_account_list:i.search_volcano_account_list,page:i.page,size:i.size};return this.request({url:o,method:"POST",data:n},t)}AddBotSpaceMemberV2(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/member/add"),n={member_info_list:i.member_info_list,space_id:i.space_id};return this.request({url:o,method:"POST",data:n},t)}ExitSpaceV2(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/space/member/exit"),n={space_id:i.space_id,transfer_user_id:i.transfer_user_id};return this.request({url:o,method:"POST",data:n},t)}GetBotPopupInfo(e,t){const i=e,o=this.genBaseURL("/api/playground_api/operate/get_bot_popup_info"),n={bot_popup_types:i.bot_popup_types,bot_id:i.bot_id};return this.request({url:o,method:"POST",data:n},t)}UpdateBotPopupInfo(e,t){const i=e,o=this.genBaseURL("/api/playground_api/operate/update_bot_popup_info"),n={bot_popup_type:i.bot_popup_type,bot_id:i.bot_id};return this.request({url:o,method:"POST",data:n},t)}GenerateDescription(e,t){const i=e,o=this.genBaseURL("/api/playground_api/draftbot/generate_description"),n={bot_name:i.bot_name,prompt:i.prompt};return this.request({url:o,method:"POST",data:n},t)}DraftBotPublishHistoryDetail(e,t){const i=e,o=this.genBaseURL("/api/playground_api/draftbot/publish_history_detail"),n={bot_id:i.bot_id,space_id:i.space_id,publish_id:i.publish_id,version:i.version};return this.request({url:o,method:"POST",data:n},t)}GenerateStoreCategory(e,t){const i=e,o=this.genBaseURL("/api/playground_api/draftbot/generate_store_category"),n={bot_name:i.bot_name,bot_description:i.bot_description,prompt:i.prompt};return this.request({url:o,method:"POST",data:n},t)}UpdateMultiAgent(e,t){const i=e,o=this.genBaseURL("/api/playground_api/update_multi_agent"),n={space_id:i.space_id,bot_id:i.bot_id,session_type:i.session_type,base_commit_version:i.base_commit_version,connector_type:i.connector_type};return this.request({url:o,method:"POST",data:n},t)}SwitchAgentVersion(e,t){const i=e,o=this.genBaseURL("/api/playground_api/switch_agent_version"),n={bot_id:i.bot_id,space_id:i.space_id,operate_type:i.operate_type};return this.request({url:o,method:"POST",data:n},t)}LangDetect(e,t){const i=e,o=this.genBaseURL("/api/playground_api/audio/lang/detect"),n={detect_text_list:i.detect_text_list};return this.request({url:o,method:"POST",data:n},t)}GetImagexShortUrl(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/get_imagex_url"),n={uris:i.uris,scene:i.scene};return this.request({url:o,method:"POST",data:n},t)}GetPlatformCommonConfig(e,t){const i=this.genBaseURL("/api/playground_api/get_platform_common_config");return this.request({url:i,method:"GET"},t)}CreateShortcutCommand(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/create_shortcut_command"),n={object_id:i.object_id,shortcuts:i.shortcuts};return this.request({url:o,method:"POST",data:n},t)}MGetUserBasicInfo(e,t){const i=e,o=this.genBaseURL("/api/playground_api/mget_user_info"),n={user_ids:i.user_ids,need_user_status:i.need_user_status,need_enterprise_identity:i.need_enterprise_identity,need_volcano_user_name:i.need_volcano_user_name};return this.request({url:o,method:"POST",data:n},t)}BindVolcanoTrn(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/bind_volcano_trn"),n={space_id:i.space_id,trn:i.trn,account_name:i.account_name};return this.request({url:o,method:"POST",data:n},t)}UnbindVolcanoTrn(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/unbind_volcano_trn"),n={space_id:i.space_id};return this.request({url:o,method:"POST",data:n},t)}RetrieveFileOpen(e,t){const i=e,o=this.genBaseURL("/v1/files/retrieve"),n={file_id:i.file_id};return this.request({url:o,method:"GET",params:n},t)}RetrieveFileContentOpen(e,t){const i=e,o=this.genBaseURL("/v1/files/content/retrieve"),n={file_id:i.file_id};return this.request({url:o,method:"GET",params:n},t)}UploadFileOpen(e,t){const i=e,o=this.genBaseURL("/v1/files/upload"),n={Data:i.Data},s={"Content-Type":i["Content-Type"]};return this.request({url:o,method:"POST",data:n,headers:s},t)}BotInfoCheck(e,t){const i=e,o=this.genBaseURL("/api/playground_api/check/bot_info_check"),n={bot_id:i.bot_id,space_id:i.space_id,bot_audit_info:i.bot_audit_info};return this.request({url:o,method:"POST",data:n},t)}SupportVoiceCall(e,t){const i=e,o=this.genBaseURL("/api/playground_api/support_voice_call"),n={voice_id_list:i.voice_id_list};return this.request({url:o,method:"POST",data:n},t)}CreateUpdateShortcutCommand(e,t){const i=e,o=this.genBaseURL("/api/playground_api/create_update_shortcut_command"),n={object_id:i.object_id,space_id:i.space_id,shortcuts:i.shortcuts};return this.request({url:o,method:"POST",data:n},t)}MoveDraftBot(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/move_draft_bot"),n={bot_id:i.bot_id,target_spaceId:i.target_spaceId,from_spaceId:i.from_spaceId,move_action:i.move_action};return this.request({url:o,method:"POST",data:n},t)}GetShortcutAvailNodes(e,t){const i=e,o=this.genBaseURL("/api/playground_api/get_shortcut_avail_nodes"),n={bot_id:i.bot_id,space_id:i.space_id,page_num:i.page_num,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}MarkReadNotice(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/gen_img/mark_read_notice"),n={bot_id:i.bot_id,pic_type:i.pic_type};return this.request({url:o,method:"POST",data:n},t)}CancelGenerateGif(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/gen_img/cancel_generate_gif"),n={task_id:i.task_id};return this.request({url:o,method:"POST",data:n},t)}GetPicTask(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/gen_img/get_pic_task"),n={bot_id:i.bot_id,pic_type:i.pic_type};return this.request({url:o,method:"POST",data:n},t)}GeneratePic(e,t){const i=e,o=this.genBaseURL("/api/playground_api/gen_img/generate_pic"),n={gen_prompt:i.gen_prompt,image_url:i.image_url,image_uri:i.image_uri,bot_id:i.bot_id,pic_type:i.pic_type,device_id:i.device_id,bot_name:i.bot_name,bot_desc:i.bot_desc};return this.request({url:o,method:"POST",data:n},t)}GetGenPicTimes(e,t){const i=this.genBaseURL("/api/playground_api/gen_img/get_gen_pic_times");return this.request({url:i,method:"POST"},t)}ListStyle(e,t){const i=this.genBaseURL("/api/playground_api/gen_img/list_style");return this.request({url:i,method:"POST"},t)}GetFileUrls(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/get_file_list"),n={scene:i.scene};return this.request({url:o,method:"POST",data:n},t)}GetDraftBotInfoAgw(e,t){const i=e,o=this.genBaseURL("/api/playground_api/draftbot/get_draft_bot_info"),n={bot_id:i.bot_id,version:i.version,commit_version:i.commit_version};return this.request({url:o,method:"POST",data:n},t)}CommitDraftBotInfoAgw(e,t){const i=e,o=this.genBaseURL("/api/playground_api/draftbot/commit_draft_bot_info"),n={bot_id:i.bot_id,remark:i.remark};return this.request({url:o,method:"POST",data:n},t)}UpdateDraftBotInfoAgw(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/draftbot/update_draft_bot_info"),n={bot_info:i.bot_info,base_commit_version:i.base_commit_version};return this.request({url:o,method:"POST",data:n},t)}GetUserQueryCollectOption(e,t){const i=this.genBaseURL("/api/playground_api/draftbot/get_user_query_collect_option");return this.request({url:i,method:"GET"},t)}GenerateUserQueryCollectPolicy(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/draftbot/generate_user_query_collect_policy"),n={bot_id:i.bot_id,developer_name:i.developer_name,contact_information:i.contact_information};return this.request({url:o,method:"POST",data:n},t)}GetCozeProRights(e,t){const i=this.genBaseURL("/api/playground_api/get_coze_pro_rights");return this.request({url:i,method:"POST"},t)}GetPolicyContent(e,t){const i=e,o=this.genBaseURL(`/api/playground_api/private_policy/${i.secret}`);return this.request({url:o,method:"GET"},t)}UpdateAgentV2(e,t){const i=e,o=this.genBaseURL("/api/playground_api/update_agent_v2"),n={id:i.id,reference_id:i.reference_id,current_version:i.current_version,space_id:i.space_id,bot_id:i.bot_id,base_commit_version:i.base_commit_version,name:i.name,description:i.description,position:i.position,icon_uri:i.icon_uri,intents:i.intents,is_delete:i.is_delete,prompt_info:i.prompt_info,model_info:i.model_info,plugin_info_list:i.plugin_info_list,knowledge:i.knowledge,workflow_info_list:i.workflow_info_list,jump_config:i.jump_config,suggest_reply_info:i.suggest_reply_info,hook_info:i.hook_info};return this.request({url:o,method:"POST",data:n},t)}CopyAgentV2(e,t){const i=e,o=this.genBaseURL("/api/playground_api/copy_agent_v2"),n={bot_id:i.bot_id,agent_id:i.agent_id,base_commit_version:i.base_commit_version};return this.request({url:o,method:"POST",data:n},t)}CreateAgentV2(e,t){const i=e,o=this.genBaseURL("/api/playground_api/create_agent_v2"),n={bot_id:i.bot_id,agent_type:i.agent_type,position:i.position,references:i.references,base_commit_version:i.base_commit_version};return this.request({url:o,method:"POST",data:n},t)}BatchCreateAgentV2(e,t){const i=e,o=this.genBaseURL("/api/playground_api/batch_create_agent_v2"),n={bot_id:i.bot_id,agent_type:i.agent_type,position:i.position,references:i.references,agent_cnt:i.agent_cnt,base_commit_version:i.base_commit_version};return this.request({url:o,method:"POST",data:n},t)}CozeProCopyGetLinkMetaInfo(e,t){const i=e,o=this.genBaseURL("/api/playground_api/coze_pro/get_link_meta_info"),n={auth_code:i.auth_code};return this.request({url:o,method:"POST",data:n},t)}CozeProCopyTaskConfirm(e,t){const i=e,o=this.genBaseURL("/api/playground_api/coze_pro/copy_task_confirm"),n={auth_code:i.auth_code};return this.request({url:o,method:"POST",data:n},t)}CozeProCopyGenerateAuthLink(e,t){const i=e,o=this.genBaseURL("/api/playground_api/coze_pro/generate_auth_link"),n={copy_user_id:i.copy_user_id,target_space_id:i.target_space_id};return this.request({url:o,method:"POST",data:n},t)}GetOpVoiceList(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/get_op_voice_list"),n={voice_ids:i.voice_ids,name:i.name,style_id:i.style_id,language_code:i.language_code,status:i.status,page_index:i.page_index,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}GetSupportLanguage(e,t){const i=this.genBaseURL("/api/playground_api/get_support_language");return this.request({url:i,method:"GET"},t)}SynchronizeVoiceList(e,t){const i=this.genBaseURL("/api/playground_api/synchronize_voice_list");return this.request({url:i,method:"GET"},t)}CheckBotAllModelPluginIds(e,t){const i=e,o=this.genBaseURL("/api/playground_api/draftbot/check_bot_all_model_plugin_ids"),n={bot_id:i.bot_id,commit_version:i.commit_version};return this.request({url:o,method:"POST",data:n},t)}GetBotCollaborationQuota(e,t){const i=e,o=this.genBaseURL("/api/playground_api/draftbot/collaboration_quota"),n={bot_id:i.bot_id,only_config_item:i.only_config_item,account_type:i.account_type};return this.request({url:o,method:"POST",data:n},t)}OpenCreateSpace(e,t){const i=e||{},o=this.genBaseURL("/v1/workspaces"),n={name:i.name,description:i.description,icon_file_id:i.icon_file_id,coze_account_id:i.coze_account_id,owner_uid:i.owner_uid};return this.request({url:o,method:"POST",data:n},t)}NoticeMarkRead(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/notice/mark_read"),n={notice_ids:i.notice_ids,mark_all:i.mark_all};return this.request({url:o,method:"POST",data:n},t)}GetNoticeList(e,t){const i=e,o=this.genBaseURL("/api/playground_api/notice/get_list"),n={cursor:i.cursor,count:i.count,notice_rank_type:i.notice_rank_type};return this.request({url:o,method:"POST",data:n},t)}GetNoticeUnreadCount(e,t){const i=this.genBaseURL("/api/playground_api/notice/get_unread_count");return this.request({url:i,method:"POST"},t)}OpenSpaceList(e,t){const i=e||{},o=this.genBaseURL("/v1/workspaces"),n={page_num:i.page_num,page_size:i.page_size,enterprise_id:i.enterprise_id,user_id:i.user_id,coze_account_id:i.coze_account_id,scope:i.scope};return this.request({url:o,method:"GET",params:n},t)}ReportUserBehavior(e,t){const i=e,o=this.genBaseURL("/api/playground_api/report_user_behavior"),n={resource_id:i.resource_id,resource_type:i.resource_type,behavior_type:i.behavior_type,space_id:i.space_id};return this.request({url:o,method:"POST",data:n},t)}GetUserConfig(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/get_user_config"),n={risk_alert_type_list:i.risk_alert_type_list,switch_type_list:i.switch_type_list},s={Cookie:i.Cookie};return this.request({url:o,method:"POST",data:n,headers:s},t)}UpdateUserConfig(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/update_user_config"),n={risk_alert_type:i.risk_alert_type,switch_info:i.switch_info};return this.request({url:o,method:"POST",data:n},t)}GetRecentDraftBotList(e,t){const i=e,o=this.genBaseURL("/api/playground_api/draftbot/get_recent_draft_bot"),n={behavior_type:i.behavior_type,limit:i.limit};return this.request({url:o,method:"POST",data:n},t)}GetPromptResourceInfo(e,t){const i=e,o=this.genBaseURL("/api/playground_api/get_prompt_resource_info"),n={prompt_resource_id:i.prompt_resource_id};return this.request({url:o,method:"GET",params:n},t)}UpsertPromptResource(e,t){const i=e,o=this.genBaseURL("/api/playground_api/upsert_prompt_resource"),n={prompt:i.prompt};return this.request({url:o,method:"POST",data:n},t)}DeletePromptResource(e,t){const i=e,o=this.genBaseURL("/api/playground_api/delete_prompt_resource"),n={prompt_resource_id:i.prompt_resource_id};return this.request({url:o,method:"POST",data:n},t)}GetPromptReferenceInfo(e,t){const i=e,o=this.genBaseURL("/api/playground_api/get_prompt_reference_info"),n={space_id:i.space_id,reference_id:i.reference_id,reference_type:i.reference_type,api_id:i.api_id,project_id:i.project_id,avatar_bot_id:i.avatar_bot_id};return this.request({url:o,method:"POST",data:n},t)}GetOfficialPromptResourceList(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/get_official_prompt_list"),n={keyword:i.keyword};return this.request({url:o,method:"POST",data:n},t)}GetByteTreeByName(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/bpm/search_byte_tree"),n={name:i.name},s={"x-jwt-token":i["x-jwt-token"]};return this.request({url:o,method:"GET",params:n,headers:s},t)}CreatePrivateModel(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/bpm/create_private_model"),n={space_id:i.space_id,model_vendor:i.model_vendor,model_show_name:i.model_show_name,model_arch:i.model_arch,ak:i.ak,token_limit:i.token_limit,upper_limit_of_max_token:i.upper_limit_of_max_token,function_call:i.function_call,multimodal:i.multimodal,multimodal_types:i.multimodal_types,form_detail:i.form_detail,record_id:i.record_id,maas_model_name:i.maas_model_name,maas_model_version:i.maas_model_version,maas_model_customer_id:i.maas_model_customer_id,model_family:i.model_family,space_id_i18n:i.space_id_i18n,operator:i.operator,email:i.email,employee_id:i.employee_id,presence_penalty_config:i.presence_penalty_config,frequency_penalty_config:i.frequency_penalty_config,temperature_config:i.temperature_config,top_p_config:i.top_p_config},s={"x-inner-auth":i["x-inner-auth"],"x-jwt-token":i["x-jwt-token"]};return this.request({url:o,method:"POST",data:n,headers:s},t)}CheckExemptFormInfo(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/bpm/check_exempt_form_info"),n={exempt_form_type:i.exempt_form_type,space_id:i.space_id},s={"x-jwt-token":i["x-jwt-token"]};return this.request({url:o,method:"POST",data:n,headers:s},t)}SetByteTreeForSpace(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/bpm/set_byte_tree_for_space"),n={space_id:i.space_id,byte_tree_node_id:i.byte_tree_node_id,byte_tree_node_name:i.byte_tree_node_name,form_detail:i.form_detail,record_id:i.record_id},s={"x-jwt-token":i["x-jwt-token"]};return this.request({url:o,method:"POST",data:n,headers:s},t)}GetModelCapability(e,t){const i=e,o=this.genBaseURL("/api/playground_api/bpm/get_model_capability"),n={vendor:i.vendor,model_arch:i.model_arch,maas_model_name:i.maas_model_name,maas_model_version:i.maas_model_version,maas_customer_id:i.maas_customer_id},s={"x-jwt-token":i["x-jwt-token"]};return this.request({url:o,method:"POST",data:n,headers:s},t)}GetSpaceDetail(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/detail"),n={space_id:i.space_id};return this.request({url:o,method:"POST",data:n},t)}RevocateSpaceInvite(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/space/revocate_invite"),n={space_id:i.space_id,invite_user_id:i.invite_user_id};return this.request({url:o,method:"GET",params:n},t)}SaveVolcanoUserManageInfo(e,t){const i=e,o=this.genBaseURL("/api/playground_api/coze_pro/save_volcano_user_manage_info"),n={volcano_basic_user_config:i.volcano_basic_user_config};return this.request({url:o,method:"POST",data:n},t)}GetVolcanoUserManageInfo(e,t){const i=this.genBaseURL("/api/playground_api/coze_pro/get_volcano_user_manage_info");return this.request({url:i,method:"POST"},t)}GetSpaceInviteManageList(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/space/invite_manage_list"),n={space_id:i.space_id,space_invite_status:i.space_invite_status,search_word:i.search_word,page:i.page,size:i.size};return this.request({url:o,method:"GET",params:n},t)}DebugDouYin(e,t){const i=e,o=this.genBaseURL("/api/playground_api/douyin/debug"),n={bot_id:i.bot_id};return this.request({url:o,method:"POST",data:n},t)}GetDouYinAuthCode(e,t){const i=this.genBaseURL("/api/playground_api/douyin/get_auth_qr_code");return this.request({url:i,method:"GET"},t)}GetDouyinAvatarInfo(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/douyin/v1/get_avatar_info"),n={is_draft:i.is_draft,body:i.body},s={"Open-Platform-App-ID":i["Open-Platform-App-ID"],"Byte-Signature":i["Byte-Signature"],"Byte-Timestamp":i["Byte-Timestamp"],"Byte-Nonce-Str":i["Byte-Nonce-Str"]};return this.request({url:o,method:"POST",data:n,headers:s},t)}DouYinAuthUserList(e,t){const i=e,o=this.genBaseURL("/api/playground_api/douyin/auth_user_list"),n={page_index:i.page_index,page_size:i.page_size,bind_status:i.bind_status,order_by:i.order_by};return this.request({url:o,method:"POST",data:n},t)}GetDebugDouYinStatus(e,t){const i=e,o=this.genBaseURL("/api/playground_api/douyin/get_debug_status"),n={bot_id:i.bot_id};return this.request({url:o,method:"POST",data:n},t)}CanUserApplyClose(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/coze_pro/can_user_apply_close"),n={AccountId:i.AccountId,EventName:i.EventName,Action:i.Action,Version:i.Version},s={"X-Tt-Logid":i["X-Tt-Logid"],"X-Top-Service":i["X-Top-Service"],"X-Top-Region":i["X-Top-Region"]};return this.request({url:o,method:"GET",params:n,headers:s},t)}CreateRoom(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/create_room"),n={bot_id:i.bot_id,conversation_id:i.conversation_id,scene:i.scene,voice_id:i.voice_id,video_config:i.video_config};return this.request({url:o,method:"POST",data:n},t)}GetVoiceList(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/get_voice_list"),n={page_index:i.page_index,page_size:i.page_size,language_code:i.language_code};return this.request({url:o,method:"POST",data:n},t)}GetVoiceByIds(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/get_voice_by_ids"),n={voice_id_map:i.voice_id_map,voice_type:i.voice_type,space_id:i.space_id,emotion_config:i.emotion_config,voice_biz_scene:i.voice_biz_scene};return this.request({url:o,method:"POST",data:n},t)}GrayVoice(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/gray_voice"),n={bot_id:i.bot_id,language_to_voice_id:i.language_to_voice_id};return this.request({url:o,method:"POST",data:n},t)}GetSpaceApplyManageList(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/space/apply_manage_list"),n={space_id:i.space_id,space_apply_status:i.space_apply_status,search_word:i.search_word,page:i.page,size:i.size};return this.request({url:o,method:"GET",params:n},t)}DraftBotCrossSpaceCopy(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/draftbot/crossspace_copy"),n={bot_id:i.bot_id,to_space_id:i.to_space_id};return this.request({url:o,method:"POST",data:n},t)}RemovePublishMember(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/remove_publish_member"),n={space_id:i.space_id,member_list:i.member_list};return this.request({url:o,method:"POST",data:n},t)}AddPublishMember(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/add_publish_member"),n={space_id:i.space_id,member_list:i.member_list};return this.request({url:o,method:"POST",data:n},t)}SearchAddablePublishMember(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/search_addable_publish_member"),n={space_id:i.space_id,search_word:i.search_word,cursor_id:i.cursor_id,limit:i.limit};return this.request({url:o,method:"POST",data:n},t)}PublishMemberList(e,t){const i=e,o=this.genBaseURL("/api/playground_api/space/publish_member_list"),n={space_id:i.space_id,search_word:i.search_word,cursor_id:i.cursor_id,limit:i.limit};return this.request({url:o,method:"POST",data:n},t)}OperateSpaceApply(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/space/operate_apply"),n={space_id:i.space_id,enterprise_id:i.enterprise_id,organization_id:i.organization_id,apply_id_list:i.apply_id_list,space_apply_status:i.space_apply_status};return this.request({url:o,method:"POST",data:n},t)}ImportSpaceConfirm(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/space/import/confirm"),n={space_id_list:i.space_id_list,enterprise_id:i.enterprise_id,organization_id:i.organization_id,personal_space_new_name:i.personal_space_new_name,user_id_list:i.user_id_list};return this.request({url:o,method:"POST",data:n},t)}ImportSpaceList(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/space/import/list"),n={enterprise_id:i.enterprise_id,organization_id:i.organization_id,search_word:i.search_word};return this.request({url:o,method:"GET",params:n},t)}ImportSpaceUserList(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/space/import/user_list"),n={space_id_list:i.space_id_list,enterprise_id:i.enterprise_id,organization_id:i.organization_id};return this.request({url:o,method:"POST",data:n},t)}GetDouYinInfo(e,t){const i=this.genBaseURL("/api/playground_api/douyin/get_douyin_info");return this.request({url:i,method:"POST"},t)}LongTermMemoryList(e,t){const i=e,o=this.genBaseURL("/api/playground_api/long_term_memory/list"),n={bot_id:i.bot_id,connector_id:i.connector_id,offset:i.offset,limit:i.limit,time_capsule_item_type:i.time_capsule_item_type};return this.request({url:o,method:"GET",params:n},t)}LongTermMemoryUpdate(e,t){const i=e,o=this.genBaseURL("/api/playground_api/long_term_memory/update"),n={bot_id:i.bot_id,connector_id:i.connector_id,biz_id:i.biz_id,new_content:i.new_content,event_ms:i.event_ms,ext:i.ext,tags:i.tags,time_capsule_item_type:i.time_capsule_item_type,iid:i.iid,meta_type:i.meta_type,memory_type:i.memory_type};return this.request({url:o,method:"POST",data:n},t)}LongTermMemoryClearAll(e,t){const i=e,o=this.genBaseURL("/api/playground_api/long_term_memory/clear_all"),n={bot_id:i.bot_id,connector_id:i.connector_id,time_capsule_item_type:i.time_capsule_item_type};return this.request({url:o,method:"POST",data:n},t)}LongTermMemoryDelete(e,t){const i=e,o=this.genBaseURL("/api/playground_api/long_term_memory/delete"),n={bot_id:i.bot_id,connector_id:i.connector_id,biz_ids:i.biz_ids,time_capsule_item_type:i.time_capsule_item_type,iids:i.iids,memory_meta_type_map:i.memory_meta_type_map};return this.request({url:o,method:"POST",data:n},t)}LongTermMemoryVersion(e,t){const i=e,o=this.genBaseURL("/api/playground_api/long_term_memory/version"),n={bot_id:i.bot_id};return this.request({url:o,method:"GET",params:n},t)}GetVoiceListV2(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/get_voice_list_v2"),n={language_code:i.language_code,space_id:i.space_id,voice_type:i.voice_type,page_size:i.page_size,next_cursor:i.next_cursor};return this.request({url:o,method:"POST",data:n},t)}GetUserUpdateProfileTag(e,t){const i=this.genBaseURL("/api/playground_api/get_user_update_profile_tag");return this.request({url:i,method:"GET"},t)}OpenRemoveSpaceMember(e,t){const i=e||{},o=this.genBaseURL(`/v1/workspaces/${i.workspace_id}/members`),n={user_ids:i.user_ids};return this.request({url:o,method:"DELETE",data:n},t)}OpenSpaceMemberList(e,t){const i=e||{},o=this.genBaseURL(`/v1/workspaces/${i.workspace_id}/members`),n={page_num:i.page_num,page_size:i.page_size};return this.request({url:o,method:"GET",params:n},t)}OpenAddSpaceMember(e,t){const i=e||{},o=this.genBaseURL(`/v1/workspaces/${i.workspace_id}/members`),n={users:i.users};return this.request({url:o,method:"POST",data:n},t)}OpenGetBotInfo(e,t){const i=e||{},o=this.genBaseURL(`/v1/bots/${i.bot_id}`),n={is_published:i.is_published,connector_id:i.connector_id};return this.request({url:o,method:"GET",params:n},t)}OpenApplyJoinSpace(e,t){const i=e||{},o=this.genBaseURL(`/v1/workspaces/${i.workspace_id}/members/apply`),n={user_ids:i.user_ids};return this.request({url:o,method:"POST",data:n},t)}OpenRemoveSpace(e,t){const i=e||{},o=this.genBaseURL(`/v1/workspaces/${i.workspace_id}`);return this.request({url:o,method:"DELETE"},t)}GetTypeList(e,t){const i=e||{},o=this.genBaseURL("/api/playground_api/get_type_list"),n={model:i.model,voice:i.voice,raw_model:i.raw_model,space_id:i.space_id,cur_model_id:i.cur_model_id,cur_model_ids:i.cur_model_ids,model_scene:i.model_scene,tag_filters:i.tag_filters};return this.request({url:o,method:"POST",data:n},t)}GetCozeLaneInfo(e,t){const i=this.genBaseURL("/api/playground_api/get_coze_lane_info");return this.request({url:i,method:"POST"},t)}OpenUpdateSpaceMember(e,t){const i=e||{},o=this.genBaseURL(`/v1/workspaces/${i.workspace_id}/members/${i.user_id}`),n={role_type:i.role_type};return this.request({url:o,method:"PUT",data:n},t)}OpenListBotVersions(e,t){const i=e||{},o=this.genBaseURL(`/v1/bots/${i.bot_id}/versions`),n={page_num:i.page_num,page_size:i.page_size,publish_status:i.publish_status,connector_id:i.connector_id};return this.request({url:o,method:"GET",params:n},t)}OpenSwitchBotDevelopMode(e,t){const i=e||{},o=this.genBaseURL(`/v1/bots/${i.bot_id}/collaboration_mode`),n={collaboration_mode:i.collaboration_mode};return this.request({url:o,method:"POST",data:n},t)}OpenUpdateSpace(e,t){const i=e||{},o=this.genBaseURL(`/v1/workspaces/${i.workspace_id}`),n={name:i.name,description:i.description};return this.request({url:o,method:"PUT",data:n},t)}}const xs=new qs({});function Ds(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}async function Ms(i,o){if(Ds([i,"access",e=>e.commandConfig,"optionalAccess",e=>e.skipAuth]))return void await o();if(!i.config.accessToken)throw new e.CozeError(e.ErrorCode.E2001,"No API token found. Please authenticate first.",void 0,{fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable",example:"coze auth login --oauth"});if(Ds([i,"access",e=>e.commandConfig,"optionalAccess",e=>e.skipOrgCheck]))return void await o();const n=await async function(i){let o=i.config.organizationId,{enterpriseId:n}=i.config,s=!1;const{data:r}=await Di.ListEnterprise({contain_enterprise_of_user:!0,contain_organization_of_user:!0}),a=r.enterprise_info_list||[],c=r.personal_account_info;if(o){if(!a.some((e=>Ds([e,"access",e=>e.organization_info_list,"optionalAccess",e=>e.some,"call",e=>e((e=>e.organization_id===o))]))))throw new e.CozeError(e.ErrorCode.E1000,`Organization ID ${o} is invalid or not found`,void 0,{fix:"Run `coze organization list` and select a valid organization",example:"coze organization use <organization_id>"})}else{if(c.available)return!1;let r;i.ui.info(t.gray("[Context] Organization ID not found. Attempting to auto-initialize..."));for(const e of a)if(e.organization_info_list&&e.organization_info_list.length>0){const t=e.organization_info_list[0];r={id:t.organization_id,name:t.organization_name,entId:e.enterprise_id};break}if(!r)throw new e.CozeError(e.ErrorCode.E3000,"No organizations found",void 0,{fix:"Create an organization or join an existing one",example:"coze organization list"});o=r.id,n=r.entId,i.config.organizationId=o,i.config.enterpriseId=n,s=!0,i.ui.info(`[Context] Auto-selected Organization: ${r.name} (${r.id})`)}return s}(i);if(Ds([i,"access",e=>e.commandConfig,"optionalAccess",e=>e.skipSpaceCheck]))return n&&await Gs(i,{organizationId:i.config.organizationId,enterpriseId:i.config.enterpriseId}),void await o();const s=await async function(t){const i=t.config.organizationId,{enterpriseId:o}=t.config;let{spaceId:n}=t.config,s=!1;try{if(n){const{data:t}=await xs.GetSpaceListV2({organization_id:i,enterprise_id:o}),s=Ds([t,"optionalAccess",e=>e.bot_space_list])||[];if(!s.some((e=>e.id===n))){const t=i?`[Context] Space ID ${n} is invalid or not found in organization ${i}.`:`[Context] Space ID ${n} is invalid or not found.`;throw new e.CozeError(e.ErrorCode.E1000,t,void 0,{fix:"Run `coze space list` and select a valid space",example:"coze space use <space_id>"})}}else{t.ui.info("[Context] Space ID not found. Attempting to auto-initialize...");const{data:r}=await xs.GetSpaceListV2({organization_id:i,enterprise_id:o,page:1,size:1}),a=Ds([r,"optionalAccess",e=>e.bot_space_list,"optionalAccess",e=>e[0]]);if(!a){const t=i?`[Context] No spaces found in organization ${i}. Please create one.`:"[Context] No spaces found. Please create one.";throw new e.CozeError(e.ErrorCode.E3000,t,void 0,{fix:"Create a space in the current organization",example:"coze space list"})}n=a.id,t.config.spaceId=n,s=!0,t.ui.success(`[Context] Auto-selected Space: ${a.name} (${a.id})`)}}catch(t){const i=t instanceof e.CozeError?t:new e.CozeError(e.ErrorCode.E5000,t.message,t instanceof Error?t.stack:t);throw i.fix??="Switch organization or space using `coze organization use <organization_id>` or `coze space use <space_id>`",i.example??="coze organization list",i}return s}(i);await Ns(i),(n||s)&&await Gs(i,{organizationId:i.config.organizationId,enterpriseId:i.config.enterpriseId,spaceId:i.config.spaceId,billingProjectId:i.config.billingProjectId}),await o()}async function Gs(e,t){try{await X(t)}catch(t){e.ui.warn(`Failed to save auto-initialized context: ${t}`)}}const Ns=async t=>{const{spaceId:i}=t.config;try{const{data:o}=await e.IdeApi.GetOrCreateBillingProject({space_id:i});if(!Ds([o,"optionalAccess",e=>e.project_id]))throw new e.CozeError(e.ErrorCode.E5002,"[Context] Failed to get billing project ID from response.",o);t.config.billingProjectId=o.project_id,t.ui.success(`[Context] Billing Project: ${o.project_id} (space: ${i})`)}catch(e){const t=[`Failed to get billing project, ${e.message}. please check your space context:`," coze space list"," coze space use <space_id>"];throw e.message=`${t.join("\n")}`,e}};function Fs(e,t){return null!=e?e:t()}function $s(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const Vs=t=>{const i=t.command("space").config({skipSpaceCheck:!0,help:{brief:"Workspace (Space) context management commands",description:"Provides workspace viewing and switching functionality, used to set the default Space ID for subsequent commands",examples:[{desc:"List all available workspaces",cmd:"coze space list"},{desc:"Set default space",cmd:"coze space use 123456789"}],seeAlso:["coze organization"]}}).description("Manage workspace (Space) context");i.command("list").description("List all spaces").config({help:{brief:"List all workspaces under the current organization",description:"Retrieve and display a list of all available Spaces under the currently configured Organization or Enterprise. Defaults to fetching up to the first 100.",examples:[{desc:"List space list",cmd:"coze space list",tags:["[RECOMMENDED]"]},{desc:"List in JSON format",cmd:"coze space list --format json"}],schema:{output:{type:"array",items:{type:"object",properties:{id:{type:"string",description:"Space ID"},name:{type:"string",description:"Space name"},org_id:{type:"string",description:"Belonging Organization ID"}}}}}}}).action((async(e,t)=>{const i=t.getContext(),o=e.orgId||$s([i,"optionalAccess",e=>e.config,"access",e=>e.organizationId]),n=$s([i,"optionalAccess",e=>e.config,"access",e=>e.enterpriseId]);$s([i,"optionalAccess",e=>e.ui,"access",e=>e.verbose,"call",e=>e(`Fetching spaces for organization '${o}'...`)]);const s=await async function(e){const{data:t}=await xs.GetSpaceListV2({organization_id:e.orgId,enterprise_id:e.enterpriseId,page:1,size:100});return Fs(function(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}([t,"optionalAccess",e=>e.bot_space_list]),(()=>[])).map((t=>({id:Fs(t.id,(()=>"")),name:Fs(t.name,(()=>"")),org_id:Fs(e.orgId,(()=>""))})))}({orgId:o,enterpriseId:n});$s([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Available Spaces:")]),$s([i,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(s)]);const r=["Please use the following command to switch space:"," coze space use <space_id>"];$s([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(r.join("\n"))])})),i.command("use").description("Set the default workspace context").argument("<space_id>","Space ID to set as default context").config({help:{brief:"Switch current default Space",description:"Save the specified space_id to the local configuration as the default workspace for subsequent commands.",examples:[{desc:"Switch space",cmd:"coze space use 7349123847123",tags:["[RECOMMENDED]"]}],schema:{input:{space_id:{type:"string",required:!0,description:"Space ID to switch to"}},output:{status:{type:"string"},message:{type:"string"}}}}}).action((async(t,i,o)=>{const n=o.getContext();$s([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Switching to space '${t}'...`)]),await async function(t){try{await X({spaceId:t})}catch(i){throw new e.CozeError(e.ErrorCode.E5000,`Failed to set default space to '${t}': ${i.message}`,i.stack)}}(t),$s([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Default space set to '${t}' successfully.`)]),"json"===$s([n,"optionalAccess",e=>e.format])&&$s([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({status:"success",message:`Default space set to '${t}'.`})])}))};function Ws(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const Hs=async t=>{Ws([t,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Switching to personal account...")]);const{available:i}=await async function(){const[e,{data:t}]=await Promise.all([Y(),Di.ListEnterprise({contain_enterprise_of_user:!0,contain_organization_of_user:!0})]);if(!function(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}([t.personal_account_info,"optionalAccess",e=>e.available]))return{available:!1};const i=!!e.organizationId;return await X({organizationId:void 0,enterpriseId:void 0,...i?{spaceId:void 0}:{}}),{available:!0}}();if(!i)throw new e.CozeError(e.ErrorCode.E1000,"Personal account is not available for the current user.");Ws([t,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Switched to personal account successfully.")]),"json"===Ws([t,"optionalAccess",e=>e.format])&&Ws([t,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({status:"success",message:"Switched to personal account."})])},Ks=t=>{const i=t.command("organization").config({skipOrgCheck:!0,help:{brief:"Manage organization context",description:"Provides viewing and switching functions for organizations, used to set the default Organization ID for subsequent commands. Supports switching to personal account by omitting the org_id.",examples:[{desc:"List all accessible organizations",cmd:"coze organization list"},{desc:"Set default organization",cmd:"coze organization use 123456"},{desc:"Switch to personal account",cmd:"coze organization use"},{desc:"List organizations (alias)",cmd:"coze org list"},{desc:"Set default organization (alias)",cmd:"coze org use 123456"}],seeAlso:["coze space"]}}).alias("org").description("Manage organization context");i.command("list").description("List all accessible organizations").config({help:{brief:"List all accessible organizations",description:"Retrieve and display all organizations (Teams) and their corresponding enterprises accessible to the current logged-in user.",examples:[{desc:"List organizations",cmd:"coze organization list",tags:["[RECOMMENDED]"]},{desc:"Output in JSON format",cmd:"coze organization list --format json"}],schema:{output:{type:"array",items:{type:"object",properties:{id:{type:"string",description:"Organization ID"},name:{type:"string",description:"Organization name"},enterprise_id:{type:"string",description:"Belonging Enterprise ID"},enterprise_name:{type:"string",description:"Belonging Enterprise name"}}}}}}}).action((async(e,t)=>{const i=t.getContext();Ws([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Fetching organizations...")]);const o=await async function(){const{data:e}=await Di.ListEnterprise({contain_enterprise_of_user:!0,contain_organization_of_user:!0});return e.enterprise_info_list.flatMap((e=>(e.organization_info_list||[]).map((t=>({id:t.organization_id,name:t.organization_name,enterprise_id:e.enterprise_id,enterprise_name:e.name})))))}();Ws([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Available Organizations (Teams):")]),Ws([i,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(o)]);const n=["Please use the following command to switch organization:"," coze organization use <organization_id>","Please use the following command to switch space:"," coze space list"," coze space use <space_id>"];Ws([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(n.join("\n"))])})),i.command("use").description("Set the default organization context").argument("[org_id]","Organization ID to set as default context (empty to switch to personal account)").config({help:{brief:"Set default organization or switch to personal account",description:"Save the specified org_id to the local configuration as the default organization for subsequent commands. The command will automatically retrieve and save the corresponding Enterprise ID. If the org_id is not found in the user's enterprise list, the command will fail without modifying the configuration. When switching to a different organization, the saved spaceId will be cleared. Omit org_id to switch to personal account mode (requires personal account to be available).",examples:[{desc:"Switch organization",cmd:"coze organization use 12345678",tags:["[RECOMMENDED]"]},{desc:"Switch to personal account",cmd:"coze organization use"},{desc:"Switch to personal account (explicit empty string)",cmd:'coze organization use ""'}],errors:[{code:e.ErrorCode.E3001,name:"RESOURCE_NOT_FOUND",desc:"Organization not found",fix:"Run `coze organization list` to see available organizations."},{code:e.ErrorCode.E1000,name:"INVALID_ARGUMENT",desc:"Personal account not available",fix:"Your account does not have personal account access. Use `coze organization use <org_id>` to switch to an organization instead."}],schema:{input:{org_id:{type:"string",required:!1,description:"Organization ID to switch to. Empty or omitted to switch to personal account."}},output:{status:{type:"string",description:"Operation result status"},message:{type:"string",description:"Human-readable result message"},enterprise_id:{type:"string",description:"Enterprise ID of the selected organization (empty for personal account)"},organization_id:{type:"string",description:"Organization ID that was set (empty for personal account)"}}}}}).action((async(t,i,o)=>{const n=o.getContext();if(!t)return void await Hs(n);Ws([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Switching to organization '${t}'...`)]);const{enterpriseId:s}=await async function(t){const[i,{data:o}]=await Promise.all([Y(),Di.ListEnterprise({contain_enterprise_of_user:!0,contain_organization_of_user:!0})]);let n="",s=!1;for(const e of o.enterprise_info_list)if((e.organization_info_list||[]).find((e=>e.organization_id===t))){n=e.enterprise_id,s=!0;break}if(!s)throw new e.CozeError(e.ErrorCode.E3000,`Organization '${t}' not found in current user's enterprises.`);const r=i.organizationId!==t;return await X({organizationId:t,enterpriseId:n,...r?{spaceId:void 0}:{}}),{enterpriseId:n}}(t);Ws([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Organization '${t}' found in enterprise '${s}'. Config saved.`)]),Ws([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Default organization set to '${t}' successfully.`)]),"json"===Ws([n,"optionalAccess",e=>e.format])&&Ws([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({status:"success",message:`Default organization set to '${t}'.`,enterprise_id:s,organization_id:t})])}))};function Js(e,t){return null!=e?e:t()}const Qs=async(e={})=>{const t=Js(e.stdin,(()=>process.stdin));return!0===Js(e.isTTY,(()=>t.isTTY))?null:await(async e=>{let t="";e.setEncoding("utf-8");for await(const i of e)t+=i;return t})(t)},Zs=e=>{process.stdout.write(e.endsWith("\n")?e:`${e}\n`)},Ys=e=>{Zs(JSON.stringify(e))},Xs=async(e,t)=>{const i=s.resolve(e),n=s.dirname(i);if(await o.mkdir(n,{recursive:!0}),t instanceof Blob){const e=Buffer.from(await t.arrayBuffer());await o.writeFile(i,e)}else Buffer.isBuffer(t)?await o.writeFile(i,t):t instanceof ArrayBuffer?await o.writeFile(i,Buffer.from(t)):await o.writeFile(i,String(t));return i};const er=e=>"object"==typeof e&&null!==e,tr=e=>{if(null==e)return null;const t=e.trim();return 0===t.length?null:t},ir=e=>er(e)&&"data"in e&&void 0!==e.data?e.data:e,or=(e,t)=>{try{const{pathname:i}=new URL(e);return s.extname(i)||t}catch(e){return t}},nr=()=>{const e=new Date;return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}_${String(e.getHours()).padStart(2,"0")}${String(e.getMinutes()).padStart(2,"0")}${String(e.getSeconds()).padStart(2,"0")}`},sr=e=>{const{outputPath:t,type:i,index:o,ext:n,timestamp:r}=e,a=`${i}_${r}_${o}${n}`;return s.join(t,a)},rr=async(t,i={})=>{let o=null;i.stdin&&(o=await Qs());const n=tr(t),s=tr(o),r=(c=()=>s,null!=(a=n)?a:c());var a,c;if(!r)throw new e.CozeError(e.ErrorCode.E1000,"Missing prompt: provide PROMPT argument or use --stdin with piped content");return r},ar="720p",cr="16:9",dr=!1,pr=!1;function lr(e,t){return null!=e?e:t()}function ur(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const _r=(e,t)=>{if(null==e)return 5;const i=Number(e);if(!Number.isFinite(i))return ur([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`Invalid --duration '${String(e)}', falling back to 5`)]),5;const o=Math.floor(i);return o<4||o>12?(ur([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`--duration '${String(e)}' out of bounds (4..12), falling back to -1 as per documentation (letting the model decide)`)]),-1):o},mr=(e,t)=>{if(null==e)return;const i=Number(e);if(Number.isSafeInteger(i)&&i>=0)return i;ur([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`Invalid --seed '${String(e)}', this parameter will be ignored`)])},gr=e=>{const{content:t,options:i,ctx:o}=e,n=(e=>{if("string"!=typeof e)return null;const t=e.trim(),i=/^([0-9]{1,5})x([0-9]{1,5})$/i.exec(t);if(!i)return null;const o=Number(i[1]),n=Number(i[2]);if(!Number.isFinite(o)||!Number.isFinite(n)||o<=0)return null;const s=((e,t)=>{let i=Math.abs(e),o=Math.abs(t);for(;0!==o;){const e=i%o;i=o,o=e}return i})(o,n)||1,r=`${Math.round(o/s)}:${Math.round(n/s)}`,a=Math.max(o,n);return{ratio:r,resolution:a<=854?"480p":a<=1280?"720p":"1080p"}})(i.size),s=((e,t)=>"480p"===e||"720p"===e||"1080p"===e?e:(void 0!==e&&ur([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`Invalid --resolution '${String(e)}', falling back to '${ar}'`)]),ar))(lr(i.resolution,(()=>ur([n,"optionalAccess",e=>e.resolution]))),o),r=((e,t)=>{if("string"==typeof e){const t=e.trim();if(t.length>0)return t}return void 0!==e&&ur([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`Invalid --ratio '${String(e)}', falling back to '${cr}'`)]),cr})(lr(i.ratio,(()=>ur([n,"optionalAccess",e=>e.ratio]))),o);return{model:"doubao-seedance-1-5-pro-251215",content:t,callback_url:lr(tr(i.callbackUrl),(()=>{})),return_last_frame:"boolean"==typeof i.returnLastFrame?i.returnLastFrame:pr,resolution:s,ratio:r,duration:_r(i.duration,o),watermark:"boolean"!=typeof i.watermark||i.watermark,seed:mr(i.seed,o),camerafixed:"boolean"==typeof i.camerafixed?i.camerafixed:dr,generate_audio:"boolean"!=typeof i.generateAudio||i.generateAudio}},hr=async t=>{const i=await e.customFetch.fetch(t);if(!i.ok)throw new e.CozeError(e.ErrorCode.E5001,`Failed to download generated resource: ${i.status} ${i.statusText}`,{url:t});return Buffer.from(await i.arrayBuffer())},fr=async e=>{const{outputPath:t,videoUrl:i,lastFrameUrl:o,shouldSaveLastFrame:n}=e,r=or(i,".mp4"),a=nr(),c=sr({outputPath:t,type:"video",index:0,ext:r,timestamp:a}),d=await hr(i),p=[await Xs(c,d)];if(n&&"string"==typeof o&&o.length>0){const e=(e=>{const{outputPath:t,ext:i,timestamp:o}=e,n=`last_frame_${o}_0${i}`;return s.join(t,n)})({outputPath:t,ext:or(o,".png"),timestamp:a}),i=await hr(o),n=await Xs(e,i);p.push(n)}return p};var yr,vr,br,Pr,Sr,Tr,Cr,kr,Ar,Er,Rr,jr,zr,wr,Ur,Lr,Or,Ir,Br;function qr(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}!function(e){e[e.TotalTokens=1]="TotalTokens";e[e.TotalInputTokens=2]="TotalInputTokens";e[e.TotalOutputTokens=3]="TotalOutputTokens"}(yr||(yr={})),function(e){e[e.ASC=1]="ASC";e[e.DESC=2]="DESC"}(vr||(vr={})),function(e){e[e.None=0]="None";e[e.APIKey=1]="APIKey";e[e.Oauth3LO=2]="Oauth3LO";e[e.Oauth2LO=3]="Oauth2LO";e[e.SAT=4]="SAT"}(br||(br={})),function(e){e[e.Free=1]="Free";e[e.Trial=2]="Trial";e[e.Paid=3]="Paid"}(Pr||(Pr={})),function(e){e[e.Inactive=1]="Inactive";e[e.Active=2]="Active"}(Sr||(Sr={})),function(e){e[e.CNY=1]="CNY";e[e.ResourcePoint=2]="ResourcePoint"}(Tr||(Tr={})),function(e){e[e.Cancellable=0]="Cancellable";e[e.NoCancellable=1]="NoCancellable";e[e.AlwaysDefault=2]="AlwaysDefault"}(Cr||(Cr={})),function(e){e[e.LLMModel=1]="LLMModel";e[e.ImageModel=2]="ImageModel";e[e.VideoModel=3]="VideoModel";e[e.AudioModel=4]="AudioModel";e[e.Database=5]="Database";e[e.Storage=6]="Storage";e[e.WebSearch=7]="WebSearch";e[e.EmbeddingModel=8]="EmbeddingModel";e[e.ContentProcessing=9]="ContentProcessing"}(kr||(kr={})),function(e){e[e.Internal=1]="Internal";e[e.External=2]="External";e[e.Infra=3]="Infra"}(Ar||(Ar={})),function(e){e[e.Text=1]="Text";e[e.Image=2]="Image";e[e.Video=3]="Video";e[e.Audio=4]="Audio"}(Er||(Er={})),function(e){e[e.Float=1]="Float";e[e.Int=2]="Int";e[e.Boolean=3]="Boolean";e[e.String=4]="String";e[e.JsonInput=5]="JsonInput"}(Rr||(Rr={})),function(e){e[e.Seed=1]="Seed";e[e.DeepSeek=2]="DeepSeek";e[e.Kimi=3]="Kimi";e[e.GLM=4]="GLM";e[e.MiniMax=5]="MiniMax";e[e.Qwen=6]="Qwen";e[e.StepFun=7]="StepFun";e[e.GPT=8]="GPT";e[e.Others=100]="Others"}(jr||(jr={})),function(e){e[e.Offline=0]="Offline";e[e.Online=1]="Online";e[e.GradualRollout=2]="GradualRollout";e[e.ReadyToOffline=3]="ReadyToOffline"}(zr||(zr={})),function(e){e[e.None=0]="None";e[e.InProgress=1]="InProgress";e[e.Success=2]="Success";e[e.Fail=3]="Fail";e[e.RollingBack=4]="RollingBack"}(wr||(wr={})),function(e){e[e.Install=1]="Install";e[e.Uninstall=2]="Uninstall"}(Ur||(Ur={})),function(e){e[e.Default=0]="Default";e[e.Agent=1]="Agent";e[e.Workflow=2]="Workflow";e[e.App=4]="App";e[e.Skill=5]="Skill";e[e.Web=6]="Web";e[e.WechatMiniProgram=7]="WechatMiniProgram";e[e.AssistantAgent=8]="AssistantAgent";e[e.General=9]="General";e[e.Design=100]="Design";e[e.Integration=101]="Integration";e[e.Dev=102]="Dev"}(Lr||(Lr={})),function(e){e[e.Scene=1]="Scene";e[e.Type=2]="Type"}(Or||(Or={})),function(e){e[e.Official=1]="Official";e[e.Community=2]="Community"}(Ir||(Ir={})),function(e){e[e.Agent=1]="Agent";e[e.Automation=2]="Automation";e[e.WebApp=3]="WebApp";e[e.App=4]="App";e[e.Skill=5]="Skill";e[e.GeneralWeb=6]="GeneralWeb";e[e.WechatMiniProgram=7]="WechatMiniProgram";e[e.AssistantAgent=8]="AssistantAgent";e[e.General=9]="General";e[e.CLIBilling=101]="CLIBilling"}(Br||(Br={}));class xr{__init(){this.request=e.request}__init2(){this.baseURL=""}constructor(e){xr.prototype.__init.call(this),xr.prototype.__init2.call(this),this.request=qr([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=qr([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}ListIntegration(e,t){const i=e||{},o=this.genBaseURL("/v1/integration/list"),n={space_id:i.space_id,project_id:i.project_id,integration_type:i.integration_type,integration_id:i.integration_id,filter_installed:i.filter_installed,org_id:i.org_id,search_words:i.search_words,page_num:i.page_num,page_size:i.page_size,project_type:i.project_type};return this.request({url:o,method:"POST",data:n},t)}SetIntegration(e,t){const i=e||{},o=this.genBaseURL("/v1/integration/update"),n={integration_id:i.integration_id,space_id:i.space_id,auth_schema_value:i.auth_schema_value};return this.request({url:o,method:"POST",data:n},t)}DeleteIntegration(e,t){const i=e||{},o=this.genBaseURL("/v1/integration/delete"),n={integration_id:i.integration_id,space_id:i.space_id,project_id:i.project_id};return this.request({url:o,method:"POST",data:n},t)}AuthIntegrationStatus(e,t){const i=e||{},o=this.genBaseURL("/v1/integration/auth/status"),n={integration_id:i.integration_id,space_id:i.space_id};return this.request({url:o,method:"POST",data:n},t)}ManageSpaceIntegration(e,t){const i=e||{},o=this.genBaseURL("/v1/integration/space/manage"),n={space_ids:i.space_ids,integration_ids:i.integration_ids,op_type:i.op_type};return this.request({url:o,method:"POST",data:n},t)}SubmitVideoGenerationsTasks(e,t){const i=e||{},o=this.genBaseURL("/api/v3/contents/generations/tasks"),n={Body:i.Body},s={project_id:i.project_id};return this.request({url:o,method:"POST",data:n,params:s},t)}FlashASR(e,t){const i=e||{},o=this.genBaseURL("/api/v3/auc/bigmodel/recognize/flash"),n={Body:i.Body};return this.request({url:o,method:"POST",data:n},t)}ListModel(e,t){const i=e||{},o=this.genBaseURL("/v1/model/list"),n={model_type:i.model_type,current_model_ids:i.current_model_ids,integration_ids:i.integration_ids,need_model_config_param:i.need_model_config_param,page_size:i.page_size,offset:i.offset};return this.request({url:o,method:"POST",data:n},t)}ChatCompletions(e,t){const i=e||{},o=this.genBaseURL("/api/v3/chat/completions"),n={Body:i.Body};return this.request({url:o,method:"POST",data:n},t)}CreateResponses(e,t){const i=e||{},o=this.genBaseURL("/api/v3/responses"),n={Body:i.Body};return this.request({url:o,method:"POST",data:n},t)}GenerateImages(e,t){const i=e||{},o=this.genBaseURL("/api/v3/images/generations"),n={Body:i.Body},s={project_id:i.project_id};return this.request({url:o,method:"POST",data:n,params:s},t)}UnidirectionalTTS(e,t){const i=e||{},o=this.genBaseURL("/api/v3/tts/unidirectional"),n={Body:i.Body},s={project_id:i.project_id};return this.request({url:o,method:"POST",data:n,params:s},t)}GetIntegrationOauthConfig(e,t){const i=e||{},o=this.genBaseURL("/v1/integration/auth/oauth_config"),n={integration_id:i.integration_id,space_id:i.space_id,project_id:i.project_id,session_id:i.session_id};return this.request({url:o,method:"POST",data:n},t)}GetVideoGenerationsTasks(e,t){const i=e||{},o=this.genBaseURL("/api/v3/contents/generations/tasks/:id"),n={Body:i.Body},s={project_id:i.project_id};return this.request({url:o,method:"GET",data:n,params:s},t)}WebSearch(e,t){const i=e||{},o=this.genBaseURL("/api/search_api/web_search"),n={Body:i.Body};return this.request({url:o,method:"POST",data:n},t)}WebSearch(e,t){const i=e||{},o=this.genBaseURL("/coze-coding/api/search_api/web_search"),n={Body:i.Body};return this.request({url:o,method:"POST",data:n},t)}CreateResponses(e,t){const i=e||{},o=this.genBaseURL("/coze-coding/api/v3/responses"),n={Body:i.Body};return this.request({url:o,method:"POST",data:n},t)}GetVideoGenerationsTasks(e,t){const i=e||{},o=this.genBaseURL("/coze-coding/api/v3/contents/generations/tasks/:id"),n={Body:i.Body},s={project_id:i.project_id};return this.request({url:o,method:"GET",data:n,params:s},t)}FlashASR(e,t){const i=e||{},o=this.genBaseURL("/coze-coding/api/v3/auc/bigmodel/recognize/flash"),n={Body:i.Body};return this.request({url:o,method:"POST",data:n},t)}SubmitVideoGenerationsTasks(e,t){const i=e||{},o=this.genBaseURL("/coze-coding/api/v3/contents/generations/tasks"),n={Body:i.Body},s={project_id:i.project_id};return this.request({url:o,method:"POST",data:n,params:s},t)}GenerateImages(e,t){const i=e||{},o=this.genBaseURL("/coze-coding/api/v3/images/generations"),n={Body:i.Body},s={project_id:i.project_id};return this.request({url:o,method:"POST",data:n,params:s},t)}UnidirectionalTTS(e,t){const i=e||{},o=this.genBaseURL("/coze-coding/api/v3/tts/unidirectional"),n={Body:i.Body},s={project_id:i.project_id};return this.request({url:o,method:"POST",data:n,params:s},t)}ChatCompletions(e,t){const i=e||{},o=this.genBaseURL("/coze-coding/api/v3/chat/completions"),n={Body:i.Body};return this.request({url:o,method:"POST",data:n},t)}CancelIntegration(e,t){const i=e||{},o=this.genBaseURL("/v1/integration/cancel"),n={integration_id:i.integration_id,space_id:i.space_id};return this.request({url:o,method:"POST",data:n},t)}Embeddings(e,t){const i=e||{},o=this.genBaseURL("/api/v3/embeddings/multimodal"),n={Body:i.Body};return this.request({url:o,method:"POST",data:n},t)}Embeddings(e,t){const i=e||{},o=this.genBaseURL("/coze-coding/api/v3/embeddings/multimodal"),n={Body:i.Body};return this.request({url:o,method:"POST",data:n},t)}VideoEditingUtils(e,t){const i=e||{},o=this.genBaseURL("/api/v1/integration/video_editing_utils"),n={Body:i.Body},s={tool_name:i.tool_name};return this.request({url:o,method:"POST",data:n,params:s},t)}GetProjectDefaultSkill(e,t){const i=e||{},o=this.genBaseURL("/v1/skill/default"),n={project_type:i.project_type,space_id:i.space_id};return this.request({url:o,method:"POST",data:n},t)}GetSkillByIDs(e,t){const i=e||{},o=this.genBaseURL("/v1/skill/by_ids"),n={project_type:i.project_type,skill_ids:i.skill_ids,space_id:i.space_id};return this.request({url:o,method:"POST",data:n},t)}GetSkillCategoryList(e,t){const i=e||{},o=this.genBaseURL("/v1/skill/category/list"),n={project_type:i.project_type};return this.request({url:o,method:"POST",data:n},t)}UploadSkill(e,t){const i=e||{},o=this.genBaseURL("/v1/skill/upload"),n={data:i.data},s={"Content-Type":i["Content-Type"]};return this.request({url:o,method:"POST",data:n,headers:s},t)}GetUserSkillList(e,t){const i=e||{},o=this.genBaseURL("/v1/skill/user/list"),n={page:i.page,size:i.size};return this.request({url:o,method:"POST",data:n},t)}DeleteSkill(e,t){const i=e||{},o=this.genBaseURL("/v1/skill/delete"),n={skill_id:i.skill_id};return this.request({url:o,method:"POST",data:n},t)}GetSkillList(e,t){const i=e||{},o=this.genBaseURL("/v1/skill/list"),n={project_type:i.project_type,category_type_list:i.category_type_list,space_id:i.space_id,source_list:i.source_list};return this.request({url:o,method:"POST",data:n},t)}UploadSkillConfirm(e,t){const i=e||{},o=this.genBaseURL("/v1/skill/upload/confirm"),n={preview_skill_key:i.preview_skill_key};return this.request({url:o,method:"POST",data:n},t)}FetchTool(e,t){const i=e||{},o=this.genBaseURL("/api/v1/integration/fetch_tool"),n={url:i.url};return this.request({url:o,method:"POST",data:n},t)}GetModelSwitchStatus(e,t){const i=e||{},o=this.genBaseURL("/v1/model/switch/status"),n={model_id:i.model_id,project_ids:i.project_ids,space_id:i.space_id};return this.request({url:o,method:"POST",data:n},t)}StartSwitchModel(e,t){const i=e||{},o=this.genBaseURL("/v1/model/switch/start"),n={space_id:i.space_id,project_ids:i.project_ids,current_model:i.current_model,target_model:i.target_model};return this.request({url:o,method:"POST",data:n},t)}GetModelUsageList(e,t){const i=e||{},o=this.genBaseURL("/v1/model/usage/list"),n={space_id:i.space_id,model_id:i.model_id,start_timestamp:i.start_timestamp,end_timestamp:i.end_timestamp,order_by_field:i.order_by_field,order_by_type:i.order_by_type,page:i.page,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}GetModelDetails(e,t){const i=e||{},o=this.genBaseURL("/v1/model/details"),n={model_id:i.model_id};return this.request({url:o,method:"POST",data:n},t)}GetModelUsageDetail(e,t){const i=e||{},o=this.genBaseURL("/v1/model/usage/details"),n={space_id:i.space_id,model_id:i.model_id,project_id:i.project_id,start_timestamp:i.start_timestamp,end_timestamp:i.end_timestamp};return this.request({url:o,method:"POST",data:n},t)}RollbackSwitchModel(e,t){const i=e||{},o=this.genBaseURL("/v1/model/switch/rollback"),n={space_id:i.space_id,project_ids:i.project_ids,current_model:i.current_model};return this.request({url:o,method:"POST",data:n},t)}TextEmbeddings(e,t){const i=e||{},o=this.genBaseURL("/api/v3/embeddings"),n={Body:i.Body};return this.request({url:o,method:"POST",data:n},t)}TextEmbeddings(e,t){const i=e||{},o=this.genBaseURL("/coze-coding/api/v3/embeddings"),n={Body:i.Body};return this.request({url:o,method:"POST",data:n},t)}CheckModelReadyToOffline(e,t){const i=e||{},o=this.genBaseURL("/v1/model/ready_to_offline/check"),n={model_type:i.model_type};return this.request({url:o,method:"POST",data:n},t)}Audit(e,t){const i=e||{},o=this.genBaseURL("/api/v1/integration/audit"),n={content:i.content};return this.request({url:o,method:"POST",data:n},t)}}xr.prototype.UploadSkill=function(e,t){const i=e||{},o=this.genBaseURL("/v1/skill/upload"),n=i.body;return this.request({url:o,method:"POST",data:n},t)},xr.prototype.GenerateImages=function(e,t){const i=e||{},o=this.genBaseURL("/api/v3/images/generations"),n=i.Body;return this.request({url:o,method:"POST",data:n},t)},xr.prototype.SubmitVideoGenerationsTasks=function(e,t){const i=e||{},o=this.genBaseURL("/api/v3/contents/generations/tasks"),n=i;return this.request({url:o,method:"POST",data:n},t)},xr.prototype.GetVideoGenerationsTasks=function(e,t){const i=e||{},o=this.genBaseURL(`/api/v3/contents/generations/tasks/${i.id}`);return this.request({url:o,method:"GET"},t)};const Dr=new xr({});const Mr=async e=>await new Promise((t=>setTimeout(t,e))),Gr=async e=>{const{taskId:t,baseURL:i,accessToken:o,projectId:n}=e,s=await Dr.GetVideoGenerationsTasks({id:t},{baseURL:i,headers:{Authorization:`Bearer ${o}`},params:{project_id:n}});return ir(s)};function Nr(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const Fr=e=>`coze generate video status ${e}`,$r=e=>{const{ctx:t,response:i}=e;"json"!==Nr([t,"optionalAccess",e=>e.format])?Zs((e=>{const t=[e.status],i=Nr([e,"access",e=>e.content,"optionalAccess",e=>e.video_url]),o=Nr([e,"access",e=>e.content,"optionalAccess",e=>e.last_frame_url]);return"succeeded"===e.status?("string"==typeof i&&i.length>0&&t.push(i),"string"==typeof o&&o.length>0&&t.push(o),t.join("\n")):("string"==typeof e.error_message&&e.error_message&&t.push(e.error_message),t.join("\n"))})(i)):Ys(i)},Vr=t=>{const i=t.getContext(),{outputPath:o}=t.optsWithGlobals(),n=(s=Nr([i,"optionalAccess",e=>e.config,"optionalAccess",e=>e.integrationApiBaseUrl]),r=()=>J.integrationApiBaseUrl,null!=s?s:r());var s,r;const a=Nr([i,"optionalAccess",e=>e.config,"optionalAccess",e=>e.accessToken]);if(!a)throw new e.CozeError(e.ErrorCode.E2001,"Missing access_token: Please run `coze auth login --oauth` or `coze auth login --token <token>` first");return{accessToken:a,ctx:i,integrationApiBaseUrl:n,outputPath:o}},Wr=async(t,i,o)=>{const{accessToken:n,ctx:s,integrationApiBaseUrl:r,outputPath:a}=Vr(o);let c=null;i.stdin&&(c=await Qs());const{content:d}=(t=>{const{prompt:i,stdinPrompt:o,options:n}=t,s=lr(tr(i),(()=>tr(o))),r=tr(n.firstFrame),a=tr(n.lastFrame),c=Boolean(r)||Boolean(a);if(!s&&!c)throw new e.CozeError(e.ErrorCode.E1000,"Missing input: Please provide PROMPT/stdin text, or provide images (--first-frame/--last-frame/--reference-image)");const d=[];return s&&d.push({type:"text",text:s}),r&&d.push({type:"image_url",image_url:{url:r},role:"first_frame"}),a&&d.push({type:"image_url",image_url:{url:a},role:"last_frame"}),{content:d}})({prompt:t,stdinPrompt:c,options:i}),p=gr({content:d,options:i,ctx:s}),l=s.format,u=Nr([s,"optionalAccess",e=>e.config,"access",e=>e.billingProjectId]);if(!u)throw new e.CozeError(e.ErrorCode.E1000,"Missing billing project ID");const{createResp:_,taskId:m}=await(async t=>{const{requestBody:i,baseURL:o,accessToken:n,projectId:s}=t,r=await Dr.SubmitVideoGenerationsTasks(i,{baseURL:o,headers:{Authorization:`Bearer ${n}`},params:{project_id:s}}),a=ir(r),c=function(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}([a,"optionalAccess",e=>e.id]);if(!c||"string"!=typeof c)throw new e.CozeError(e.ErrorCode.E5002,"Video generation task created successfully but no valid task_id was returned",a);return{taskId:c,createResp:a}})({requestBody:p,baseURL:r,accessToken:n,projectId:u});if(!i.wait)return"json"===l?void Ys({query_command:Fr(m),response:_,task_id:m}):void Zs((e=>["Video generation task created successfully.",`taskId: ${e}`,`Use \`${Fr(e)}\` to query status.`].join("\n"))(m));const g=await(async t=>{const{taskId:i,baseURL:o,accessToken:n,pollIntervalMs:s,pollTimeoutMs:r,projectId:a}=t,c=Date.now();for(;;){const t=await Gr({taskId:i,baseURL:o,accessToken:n,projectId:a});if("succeeded"===t.status)return t;if("failed"===t.status||"cancelled"===t.status)throw new e.CozeError(e.ErrorCode.E5002,`Video generation failed (status=${t.status}): ${d=t.error_message,p=()=>"unknown",null!=d?d:p()}`,t);if(Date.now()-c>r)throw new e.CozeError(e.ErrorCode.E5003,[`Video generation timed out after ${r}ms.`,`taskId: ${i}`,`Use \`coze generate video status ${i}\` to query status.`].join("\n"),{task_id:i,last_status:t.status});await Mr(s)}var d,p})({taskId:m,baseURL:r,accessToken:n,pollIntervalMs:2e3,pollTimeoutMs:3e5,projectId:u}),h=Nr([g,"access",e=>e.content,"optionalAccess",e=>e.video_url]),f=Nr([g,"access",e=>e.content,"optionalAccess",e=>e.last_frame_url]);if(!h||"string"!=typeof h)throw new e.CozeError(e.ErrorCode.E5002,"Video generated successfully but video_url was not returned");if(a){const e=await fr({outputPath:a,videoUrl:h,lastFrameUrl:f,shouldSaveLastFrame:!0===i.returnLastFrame});return"json"===l?void Ys({task_id:m,request:p,response:g,saved_paths:e}):void Zs(e.join("\n"))}if("json"===l)return void Ys({task_id:m,request:p,response:g});const y=[h];!0===i.returnLastFrame&&"string"==typeof f&&f.length>0&&y.push(f),Zs(y.join("\n"))},Hr=(e,t)=>{const i=t.getContext();V(e,i)},Kr=t=>{var i;i=t.command("create [prompt]").description("Create a video generation task").config({help:{brief:"Create video generation task",description:"Create a video generation task from text prompts or images. By default the command returns taskId immediately; use `--wait` to poll until completion.",examples:[{desc:"Create video from text",cmd:'coze generate video create "A dancing kitten"'},{desc:"Create task and wait for completion",cmd:'coze generate video create "A dancing kitten" --wait'},{desc:"Save result to file",cmd:'coze generate video create "A dancing kitten" --wait --output-path ./video.mp4'}],errors:[{code:e.ErrorCode.E1000,name:"INVALID_ARGUMENT",desc:"Invalid request parameters or missing prompt",fix:"Provide PROMPT argument or use --stdin with piped content. Check other options (e.g. --first-frame/--last-frame) with -h."},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid access token",fix:"Run `coze auth login --oauth` or set COZE_API_TOKEN/related credentials first"},{code:e.ErrorCode.E5001,name:"NETWORK_ERROR",desc:"Network request failed",fix:"Please check your network connectivity and try again"},{code:e.ErrorCode.E5002,name:"SERVER_ERROR",desc:"Server returned an error or response parsing failed",fix:"Please retry later. Use --debug for more details"},{code:e.ErrorCode.E5003,name:"TIMEOUT",desc:"Video generation request timed out",fix:"Please retry later or use `coze generate video status <taskId>` to query task status"}],schema:{input:{prompt:{type:"string",required:!1,description:"Text prompt (can also be passed via stdin)"}},output:{type:"object",properties:{query_command:{type:"string"},task_id:{type:"string"},request:{type:"object"},response:{type:"object"},saved_paths:{type:"array",items:{type:"string"}}}}}}}).action((async(e,t,i)=>{try{await Wr(e,t,i)}catch(e){Hr(e,i)}})),i.option("--callback-url <url>","Callback URL for task status changes").option("--return-last-frame","Return last frame URL (default: disabled)",pr).option("--resolution <res>","Resolution: 480p|720p|1080p",ar).option("--ratio <ratio>",`Aspect ratio (default: ${cr})`,cr).option("--size <size>","Derive ratio/resolution from WIDTHxHEIGHT (lower priority than explicit parameters)").option("--duration <seconds>","Duration (seconds, 4..12; out-of-bounds fallback -1), default: 5",String(5)).option("--no-watermark","Disable watermark (default: enabled)").option("--seed <seed>","Random seed (safe integer)").option("--camerafixed","Fixed camera position (default: disabled)",dr).option("--no-generate-audio","Do not generate accompanying audio (default: generate)").option("--first-frame <url>","First frame image URL").option("--last-frame <url>","Last frame image URL").option("--stdin","Read prompt from stdin (pipe input)").option("--wait","Wait for task completion by polling; by default the command returns taskId immediately")},Jr=t=>{t.command("status <taskId>").description("Query video generation task status by task ID").option("--output <format>","Output format: text|json").config({help:{brief:"Query video task status",description:"Query the latest status of a video generation task by task ID. This command does not create a new task.",examples:[{desc:"Query task status",cmd:"coze generate video status task_123"},{desc:"Output full response as JSON",cmd:"coze generate video status task_123 --output json"}],errors:[{code:e.ErrorCode.E1000,name:"INVALID_ARGUMENT",desc:"Invalid task ID or request parameters",fix:"Please confirm <taskId> is correct and try again",example:"coze generate video status task_123"},{code:e.ErrorCode.E5001,name:"NETWORK_ERROR",desc:"Network request failed",fix:"Please check your network connectivity and try again"},{code:e.ErrorCode.E5002,name:"SERVER_ERROR",desc:"Server returned an error or response parsing failed",fix:"Please retry later. Use --debug for more details"},{code:e.ErrorCode.E5003,name:"TIMEOUT",desc:"Request timed out",fix:"Please retry later"}],schema:{input:{taskId:{type:"string",required:!0,description:"Video generation task ID"}},output:{type:"object",properties:{id:{type:"string"},status:{type:"string"},model:{type:"string"},content:{type:"object"},error_message:{type:"string"}}}}}}).action((async(t,i,o)=>{try{await(async(t,i,o)=>{const{accessToken:n,ctx:s,integrationApiBaseUrl:r}=Vr(o),a=Nr([s,"optionalAccess",e=>e.config,"access",e=>e.billingProjectId]);if(!a)throw new e.CozeError(e.ErrorCode.E1000,"Missing billing project ID");const c=await Gr({taskId:t,baseURL:r,accessToken:n,projectId:a});$r({ctx:s,response:c})})(t,0,o)}catch(e){Hr(e,o)}}))};function Qr(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const Zr="2K",Yr="url",Xr="standard",ea="disabled",ta=3686400,ia=16777216,oa=e=>"object"==typeof e&&null!==e,na=e=>{if("string"==typeof e){const t=e.trim();return t.length?t:Xr}return Xr},sa=e=>{if(null==e)return;const t=(Array.isArray(e)?e:[e]).filter((e=>"string"==typeof e)).map((e=>e.trim())).filter(Boolean);return 0!==t.length?1===t.length?t[0]:t:void 0},ra=t=>{t.command("image [prompt]").description("Generate images from text prompts").config({help:{brief:"Generate images from text",description:"Generate images based on text prompts. Supports setting size, watermark, and multiple images.",examples:[{desc:"Generate image",cmd:'coze generate image "A futuristic city"'},{desc:"Save to file",cmd:'coze generate image "A cat" --output-path ./cat.png'},{desc:"Specify size",cmd:'coze generate image "A dog" --size 1024x1024'}],errors:[{code:e.ErrorCode.E1000,name:"INVALID_ARGUMENT",desc:"Invalid request parameters or missing prompt",fix:"Provide PROMPT argument or use --stdin with piped content. Check other options (e.g. --size/--max-images) with -h."},{code:e.ErrorCode.E1001,name:"MISSING_PROJECT_ID",desc:"Missing billing project ID",fix:"Please configure billing project ID and retry"},{code:e.ErrorCode.E5001,name:"NETWORK_ERROR",desc:"Network request failed",fix:"Please check your network connectivity and try again"},{code:e.ErrorCode.E5002,name:"SERVER_ERROR",desc:"API response parsing failed or server returned an error",fix:"Please retry later. Use --debug for more details"}],schema:{input:{prompt:{type:"string",required:!1,description:"Text prompt (can also be passed via stdin)"}},output:{type:"object",properties:{model:{type:"string"},created:{type:"number"},image_0:{type:"object"},saved_paths:{type:"array",items:{type:"string"}}}}}}}).option("--size <size>","Image size: 2K|4K or WIDTHxHEIGHT (local validation)",Zr).option("--no-watermark","Disable watermark (default: enabled)").option("--image <url>","Reference image URL (can be used multiple times)",((e,t)=>[...t,e]),[]).option("--response-format <format>","Response format: url|b64_json",Yr).option("--optimize-prompt-mode <mode>",`Prompt optimization mode (default: ${Xr})`,Xr).option("--sequential <mode>","Group image generation mode: auto|disabled",ea).option("--max-images <n>","Maximum number of group images (1-15)",String(15)).option("--stdin","Read prompt from stdin (pipe input)").action((async(t,i,o)=>{const n=o.getContext(),{outputPath:s}=o.optsWithGlobals(),r=await rr(t,{stdin:i.stdin}),a=Qr([n,"optionalAccess",e=>e.config,"access",e=>e.billingProjectId]);if(!a)throw new e.CozeError(e.ErrorCode.E1001,"Missing billing project ID");const c=((e,t)=>{if(null==e)return{value:Zr};if("string"!=typeof e)return Qr([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`Invalid --size '${String(e)}', falling back to '${Zr}'`)]),{value:Zr};const i=e.trim();if("2K"===i||"4K"===i)return{value:i};const o=/^([0-9]{1,5})x([0-9]{1,5})$/i.exec(i);if(!o)return{value:Zr,warning:`Invalid --size '${i}', falling back to '${Zr}'. Expected 2K/4K or WIDTHxHEIGHT`};const n=Number(o[1]),s=Number(o[2]),r=n*s,a=n/s;return Number.isFinite(n)&&Number.isFinite(s)&&n>0&&s>0&&r>=ta&&r<=ia&&a>=.0625&&a<=16?{value:`${n}x${s}`}:{value:Zr,warning:`Invalid --size '${i}', falling back to '${Zr}'. Total pixels must be in [3686400, 16777216], aspect ratio must be in [1:16, 16:1].`}})(i.size,n),d="url"===(p=i.responseFormat)||"b64_json"===p?{value:p}:void 0!==p?{value:Yr,warning:`Invalid --response-format '${String(p)}', falling back to '${Yr}'`}:{value:Yr};var p;const l=(e=>"auto"===e||"disabled"===e?{value:e}:void 0!==e?{value:ea,warning:`Invalid --sequential '${String(e)}', falling back to '${ea}'`}:{value:ea})(i.sequential),u=(e=>{if(null==e)return{value:15};const t=Number(e);if(Number.isFinite(t)){const e=Math.floor(t);if(e>=1&&e<=15)return{value:e}}return{value:15,warning:`Invalid --max-images '${String(e)}', falling back to '15'`}})(i.maxImages);c.warning&&Qr([n,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",e=>e(c.warning)]),d.warning&&Qr([n,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",e=>e(d.warning)]),l.warning&&Qr([n,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",e=>e(l.warning)]),u.warning&&Qr([n,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",e=>e(u.warning)]);const _={model:"doubao-seedream-4-5-251128",prompt:r,size:c.value,watermark:"boolean"!=typeof i.watermark||i.watermark,image:sa(i.image),response_format:d.value,optimize_prompt_options:{mode:na(i.optimizePromptMode)},sequential_image_generation:l.value,sequential_image_generation_options:{max_images:u.value}},m=(t=>{const i=oa(t)&&"data"in t?t.data:t;if(oa(o=i)&&"string"==typeof o.model&&"number"==typeof o.created&&Array.isArray(o.data))return i;var o;throw new e.CozeError(e.ErrorCode.E5002,"Image generation API returned an unexpected response format",t)})(await Dr.GenerateImages({Body:_},{baseURL:J.integrationApiBaseUrl,params:{project_id:a}}));if(m.error)throw new e.CozeError(e.ErrorCode.E5002,"Image generation failed (top-level error)",m.error);const g=(f=()=>Yr,null!=(h=_.response_format)?h:f());var h,f;const y=m.data.filter((e=>!e.error&&("url"===g?"string"==typeof e.url&&e.url.length>0:"string"==typeof e.b64_json&&e.b64_json.length>0)));if(0===y.length)throw new e.CozeError(e.ErrorCode.E5002,"Image generation succeeded but no valid image data was returned",m);if(s){const t=[],i=nr();for(const[o,n]of y.entries()){const r="url"===g&&n.url?or(n.url,".png"):".png",a=sr({outputPath:s,type:"image",index:o,ext:r,timestamp:i});let c;if("url"===g){const t=await e.customFetch.fetch(n.url);if(!t.ok)throw new e.CozeError(e.ErrorCode.E5001,`Failed to download generated image: ${t.status} ${t.statusText}`);c=Buffer.from(await t.arrayBuffer())}else c=Buffer.from(n.b64_json,"base64");const d=await Xs(a,c);t.push(d)}const{model:o,usage:r,HttpHeader:a,...c}=(e=>{const{data:t,...i}=e,o=Object.fromEntries(t.map(((e,t)=>[`image_${t}`,e])));return{...i,...o}})(m);Qr([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({...c,saved_paths:t})])}else Qr([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(m.data)])}))};function aa(e,t){return null!=e?e:t()}function ca(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const da="cli_user",pa="zh_female_xiaohe_uranus_bigtts",la="mp3",ua=24e3,_a=(e,t)=>"pcm"===e||"mp3"===e||"ogg_opus"===e?e:(void 0!==e&&ca([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`Invalid --audio-format '${String(e)}', falling back to '${la}'`)]),la),ma=(e,t,i,o)=>{if(null==e)return t;const n=Number(e);return Number.isFinite(n)?Math.floor(n):(ca([o,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",o=>o(`Invalid --${i} '${String(e)}', falling back to ${t}`)]),t)},ga=t=>{const i=t.trim();if(0===i.length)return null;const o=i.startsWith("data:")?i.slice(5).trim():i;if(0===o.length)return null;const n=o[0];if("{"!==n&&"["!==n)return null;const s=e.safeJsonParse(o,void 0,{onError:t=>{const o=t instanceof Error?t.message:String(t);throw new e.CozeError(e.ErrorCode.E5002,`Failed to parse response: ${o}`,{line:i})}});return void 0===s?null:er(s)&&"number"==typeof s.code?s:null},ha=t=>{const i=t.command("generate").description("Media generation commands (API TBD)").config({help:{brief:"Media generation commands",description:"Generate media such as audio, image, and video using Coze APIs.",examples:[{desc:"Generate image",cmd:'coze generate image "A cat"'},{desc:"Generate audio",cmd:'coze generate audio "Hello world"'},{desc:"Generate video",cmd:'coze generate video create "A dancing dog"'}],seeAlso:["coze auth"]}}).option("--output-path <path>","Directory path to save the generated media files");ra(i),(t=>{t.command("audio [prompt]").description("Synthesize speech from text or SSML (streaming)").config({help:{brief:"Generate audio from text",description:"Synthesize speech from text or SSML. Supports streaming output and configurable audio encodings.",examples:[{desc:"Basic text to speech",cmd:'coze generate audio "Hello world"'},{desc:"Save to file",cmd:'coze generate audio "Hello" --output-path ./audio.mp3'},{desc:"Use SSML",cmd:'echo "<speak>Hello</speak>" | coze generate audio --ssml'},{desc:"Specify audio encoding",cmd:'coze generate audio "Hello" --audio-format ogg_opus'}],errors:[{code:e.ErrorCode.E1000,name:"INVALID_ARGUMENT",desc:"Invalid request parameters or missing prompt",fix:"Provide PROMPT argument or use --stdin with piped content. Check other options (e.g. --speaker/--audio-format) with -h."},{code:e.ErrorCode.E1001,name:"MISSING_PROJECT_ID",desc:"Missing billing project ID",fix:"Configure billing project ID and retry",example:'coze generate audio "Hello"'},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid access token",fix:"Run `coze auth login --oauth` or `coze auth login --token <token>` first"},{code:e.ErrorCode.E5001,name:"NETWORK_ERROR",desc:"Network request failed",fix:"Please check your network connectivity and try again"},{code:e.ErrorCode.E5002,name:"SERVER_ERROR",desc:"API response parsing failed or server returned an error",fix:"Please retry later. Use --debug for more details"}],schema:{input:{prompt:{type:"string",required:!1,description:"Text or SSML prompt (can also be passed via stdin)"}},output:{type:"object",properties:{request:{type:"object"},url:{type:"string",description:"Audio download URL"},saved_path:{type:"string",description:"Local path if saved"}}}}}}).option("--output <format>","Output format: text|json").option("--uid <uid>",`User UID (default: ${da})`,da).option("--speaker <speaker>",`Speaker (default: ${pa})`,pa).option("--audio-format <format>","Audio encoding: pcm|mp3|ogg_opus",la).option("--sample-rate <n>","Sample rate (default: 24000)",String(ua)).option("--speech-rate <n>","Speech rate (-50..100, default: 0)",String(0)).option("--loudness-rate <n>","Loudness (-50..100, default: 0)",String(0)).option("--ssml","Treat input as SSML (defaults to plain text)",!1).option("--stdin","Read prompt from stdin (pipe input)").action((async(t,i,o)=>{const n=o.getContext();try{const{outputPath:s}=o.optsWithGlobals(),r=ca([n,"optionalAccess",e=>e.config,"access",e=>e.integrationApiBaseUrl]);if(!ca([n,"optionalAccess",e=>e.config,"optionalAccess",e=>e.accessToken]))throw new e.CozeError(e.ErrorCode.E2001,"Missing access_token: Please run `coze auth login --oauth` or `coze auth login --token <token>` first");const a=await rr(t,{stdin:i.stdin}),c=ca([n,"optionalAccess",e=>e.config,"access",e=>e.billingProjectId]);if(!c)throw new e.CozeError(e.ErrorCode.E1001,"Missing billing project ID");const d={user:{uid:aa(tr(i.uid),(()=>da))},req_params:{speaker:aa(tr(i.speaker),(()=>pa)),audio_params:{format:_a(i.audioFormat,n),sample_rate:ma(i.sampleRate,ua,"sample-rate",n),speech_rate:ma(i.speechRate,0,"speech-rate",n),loudness_rate:ma(i.loudnessRate,0,"loudness-rate",n)}}};i.ssml?d.req_params={...d.req_params,ssml:a}:d.req_params={...d.req_params,text:a};const p=new URL("/api/v3/tts/unidirectional",r);p.searchParams.append("project_id",c);const l=await e.customFetch.fetch(p.toString(),{method:"POST",body:JSON.stringify(d)});if(!l.ok)throw new e.CozeError(e.ErrorCode.E5002,`Speech synthesis request failed: ${l.status} ${l.statusText}`,{status:l.status,statusText:l.statusText});if(!l.body)throw new e.CozeError(e.ErrorCode.E5002,"Speech synthesis response is empty (no streaming body returned)");const u=new TextDecoder("utf-8"),_=l.body.getReader(),m=[];let g;const h=t=>{if(0===t.code)return s&&"string"==typeof t.data&&m.push(Buffer.from(t.data,"base64")),!1;if(2e7===t.code)return"string"==typeof t.url&&t.url.length>0&&(g=t.url),!0;throw new e.CozeError(e.ErrorCode.E5002,`Speech synthesis failed (code=${t.code}): ${aa(t.message,(()=>"unknown"))}`,t)};let f="";for(;;){const{done:e,value:t}=await _.read();if(e)break;f+=u.decode(t,{stream:!0});const i=f.split(/\r?\n/);f=aa(i.pop(),(()=>""));for(const e of i){const t=ga(e);if(t&&h(t)){await _.cancel();break}}if(g)break}if(!g){f+=u.decode();const e=f.split(/\r?\n/);f="";for(const t of e){const e=ga(t);if(e&&h(e))break}}if(s){const t=aa(ca([d,"access",e=>e.req_params,"optionalAccess",e=>e.audio_params,"optionalAccess",e=>e.format]),(()=>la)),i="pcm"===t?".pcm":"ogg_opus"===t?".ogg":".mp3",o=nr(),r=sr({outputPath:s,type:"audio",index:0,ext:i,timestamp:o});let a=null;if(m.length>0)a=await Xs(r,Buffer.concat(m));else if(g){const t=await e.customFetch.fetch(g);if(!t.ok)throw new e.CozeError(e.ErrorCode.E5001,`Failed to download synthesized speech: ${t.status} ${t.statusText}`,{status:t.status,statusText:t.statusText});const n=Buffer.from(await t.arrayBuffer()),r=or(g,i),c=sr({outputPath:s,type:"audio",index:0,ext:r,timestamp:o});a=await Xs(c,n)}if(!a)throw new e.CozeError(e.ErrorCode.E5002,"Speech synthesis completed but no savable audio data was obtained (neither chunks nor download URL)",{url:g});return"json"===ca([n,"optionalAccess",e=>e.format])?void Ys({request:d,url:g,saved_path:a}):void Zs(a)}if("json"===ca([n,"optionalAccess",e=>e.format]))return void Ys({request:d,url:g});if(g)return void Zs(g);Zs("Speech synthesis completed, but no audio download URL was returned; you can use --output json to view details.")}catch(e){V(e,n)}}))})(i),(e=>{const t=(e=>e.command("video").description("Create videos or query video generation task status").config({help:{brief:"Generate videos",description:"Use explicit subcommands to create video generation tasks or query task status by task ID.",examples:[{desc:"Create video from text",cmd:'coze generate video create "A dancing kitten"'},{desc:"Query task status",cmd:"coze generate video status task_123"}],seeAlso:["coze generate image","coze generate audio"]}}))(e);Kr(t),Jr(t)})(i)};function fa(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const ya=t=>{(t=>{t.command("upload <path>").description("Upload a local file").config({help:{brief:"Upload a local file",description:"Upload a local file to Coze. The file can be used as an attachment or context in projects.",examples:[{desc:"Upload a file",cmd:"coze file upload ./document.pdf",tags:["[RECOMMENDED]"]}],errors:[{code:e.ErrorCode.E3000,name:"RESOURCE_NOT_FOUND",desc:"Local file not found or not readable",fix:"Please confirm the file path exists and you have read permission"}],schema:{input:{path:{type:"string",required:!0,description:"Local file path to upload"}},output:{type:"string",description:"Uploaded file URL"}}}}).action((async(t,i,o)=>{let n;try{n=o.getContext();try{await l.access(t)}catch(i){throw new e.CozeError(e.ErrorCode.E3000,`File not found or not readable: ${t}`,{filePath:t})}const i=p.basename(t),s=p.extname(t),r=s?i.slice(0,-s.length):i,a=s.slice(1),c=new _;c.append("file_name",r),c.append("file_extension",a),c.append("file_content",u.createReadStream(t)),c.append("biz_type","cli_attachment");const d=await e.IdeApi.UploadFile({data:c},{headers:{...c.getHeaders()}});"json"===fa([n,"optionalAccess",e=>e.format])?fa([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(d.data)]):fa([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(fa([d,"access",e=>e.data,"optionalAccess",e=>e.file_url]))])}catch(e){V(e,n)}}))})(t.command("file").description("General file operations").config({help:{brief:"File upload and management",description:"Manage file operations for Coze projects. Currently supports uploading local files to Coze for use as attachments or context.",examples:[{desc:"Upload a file",cmd:"coze file upload ./document.pdf"}],seeAlso:["coze code message send"]}}))};function va(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function ba(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function Pa(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function Sa(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const Ta=t=>{const i=t.command("config").description("Manage Coze CLI configuration").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Manage local configuration",description:"Provides read, set, list, and delete operations for the CLI local configuration file (`~/.cozerc.json`).",examples:[{desc:"List all configurations",cmd:"coze config list"},{desc:"Set configuration value",cmd:"coze config set base_url https://api.coze.cn"}]}});(e=>{e.command("get <keys...>").description("Get configuration values and their sources").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Get configuration values",description:"Read and output the value of the specified configuration keys from `~/.cozerc.json`. If a key does not exist, prompts that it was not found.",examples:[{desc:"Get BaseURL configuration",cmd:"coze config get baseUrl"},{desc:"Get default Space ID",cmd:"coze config get spaceId"},{desc:"Get multiple configurations",cmd:"coze config get baseUrl spaceId"}],schema:{input:{keys:{type:"array",required:!0,description:"Configuration key names"}},output:{value:{type:"any",description:"Configuration value"}}}}}).action((async(e,t,i)=>{const o=i.getContext(),n=await te();for(const t of e){const e=n.find((e=>e.key===t));va(e?[o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",t=>t(e)]:[o,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",e=>e(`Configuration '${t}' not found.`)])}}))})(i),(t=>{t.command("set <key> <value>").description("Set a configuration value").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Set a single configuration value",description:"Update or add the specified local configuration key-value pair. The configuration will be persistently saved in `~/.cozerc.json`.",examples:[{desc:"Modify default workspace",cmd:"coze config set spaceId 123456789"},{desc:"Modify BaseURL",cmd:"coze config set baseUrl https://api.coze.cn"}],errors:[{code:e.ErrorCode.E5000,name:"UNEXPECTED_ERROR",desc:"Failed to set configuration value",fix:"Please check the key/value and retry. Use --debug for more details."}],schema:{input:{key:{type:"string",required:!0,description:"Configuration key name"},value:{type:"string",required:!0,description:"New configuration value"}}}}}).action((async(t,i,o,n)=>{const s=n.getContext();try{const e={};e[t]=i;const o="global";await X(e,o);const n={key:t,value:i,scope:o,status:"updated",message:`Configuration '${t}' updated successfully in ${o} scope.`};if(ba([s,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(n.message)]),"json"===ba([s,"optionalAccess",e=>e.format]))return void ba([s,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(n)])}catch(o){throw new e.CozeError(e.ErrorCode.E5000,`Failed to set '${t}' to '${i}': ${o.message}`,o.stack)}}))})(i),(t=>{t.command("delete <keys...>").description("Delete a configuration value").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Delete configuration values",description:"Remove the specified configuration values from the local configuration file `~/.cozerc.json`.",examples:[{desc:"Delete a specific configuration key",cmd:"coze config delete spaceId"},{desc:"Delete multiple configuration keys",cmd:"coze config delete spaceId baseUrl"}],errors:[{code:e.ErrorCode.E5000,name:"UNEXPECTED_ERROR",desc:"Failed to delete configuration value",fix:"Please check the configuration key and retry. Use --debug for more details."}],schema:{input:{keys:{type:"array",required:!0,description:"Configuration key names"}}}}}).action((async(t,i,o)=>{const n=o.getContext();for(const i of t)try{await ee(i);const e={key:i,status:"deleted",message:`Configuration '${i}' has been removed.`};Pa([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Deleted ${i} from configuration file successfully.`)]),"json"===Pa([n,"optionalAccess",e=>e.format])&&Pa([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",t=>t(e)])}catch(t){const o=t;throw new e.CozeError(e.ErrorCode.E5000,`Failed to delete config '${i}': ${o.message}`,o.stack)}}))})(i),(e=>{e.command("list").description("List all configuration values and their sources").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"List all local configuration values",description:"Print all configuration content stored in `~/.cozerc.json` in JSON format.",examples:[{desc:"List configurations",cmd:"coze config list"}],schema:{output:{type:"object",additionalProperties:!0,description:"Configuration key-value pairs"}}}}).action((async(e,t)=>{const i=t.getContext(),o=(await te()).map((({key:e,value:t,source:i})=>({key:e,value:t,source:i})));Sa([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Configurations found:")]),Sa([i,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(o)])}))})(i)},Ca="__COZE_FILE_COMP__";function ka(){const e=process.env.SHELL;if(e){if(e.includes("bash"))return"bash";if(e.includes("zsh"))return"zsh";if(e.includes("fish"))return"fish"}if(process.env.PSModulePath)return"powershell"}function Aa(e){const t=n.homedir();switch(e){case"bash":return s.join(t,"darwin"===process.platform?".bash_profile":".bashrc");case"zsh":return s.join(t,".zshrc");case"fish":return s.join(t,".config/fish/config.fish");case"powershell":return function(){const e=["pwsh","powershell"];for(const t of e)try{const e=i.execSync(`${t} -NoProfile -NoLogo -Command "echo $PROFILE"`,{encoding:"utf8",timeout:5e3,stdio:["pipe","pipe","pipe"]}).trim();if(e)return e}catch(e){continue}return}();default:return}}function Ea(){return["### coze completion - begin. generated by coze cli ###","if type compdef &>/dev/null; then"," _coze_completion() {"," local completions",' completions=("${(@f)$(coze --compzsh --compgen "${CURRENT}" "${words[CURRENT-1]}" "${BUFFER}")}")',` if [[ "\${completions[1]}" == "${Ca}" ]]; then`," _files"," else"," compadd -- $completions"," fi"," }"," compdef _coze_completion coze","elif type complete &>/dev/null; then"," _coze_completion() {"," local cur prev nb_colon"," _get_comp_words_by_ref -n : cur prev",' nb_colon=$(grep -o ":" <<< "$COMP_LINE" | wc -l)'," local completions",' completions=$(coze --compbash --compgen "$((COMP_CWORD - (nb_colon * 2)))" "$prev" "${COMP_LINE}")',` if [[ "$completions" == "${Ca}" ]]; then`," COMPREPLY=()"," return"," fi",' COMPREPLY=( $(compgen -W "$completions" -- "$cur") )',' __ltrim_colon_completions "$cur"'," }"," complete -o default -o bashdefault -F _coze_completion coze","elif type compctl &>/dev/null; then"," _coze_completion() {"," local cword line point si"," read -Ac words"," read -cn cword"," read -l line",' si="$IFS"',' if ! IFS=$\'\\n\' reply=($(coze --compzsh --compgen "${cword}" "${words[cword-1]}" "${line}")); then'," local ret=$?",' IFS="$si"'," return $ret"," fi",' IFS="$si"'," }"," compctl -K _coze_completion coze","fi","### coze completion - end ###"].join(n.EOL)}function Ra(e){switch(e){case"bash":return`\n# begin coze completion\nsource ${s.join(n.homedir(),".coze","completion.sh")}\n# end coze completion\n`;case"zsh":return"\n# begin coze completion\n. <(coze --completion)\n# end coze completion\n";case"fish":return"\n# begin coze completion\ncoze --completion-fish | source\n# end coze completion\n";case"powershell":return`\n# begin coze completion\nRegister-ArgumentCompleter -Native -CommandName coze -ScriptBlock {\n param($wordToComplete, $commandAst, $cursorPosition)\n $tokens = $commandAst.ToString().Split(" ", [StringSplitOptions]::RemoveEmptyEntries)\n $allArgs = @("--comppwsh")\n if ($tokens.Count -gt 1) {\n $allArgs += $tokens[1..($tokens.Count - 1)]\n }\n $result = & coze $allArgs 2>$null\n if ($result -and $result[0] -ne '${Ca}') {\n $result -split '\\n' | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {\n [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\n }\n } else {\n Get-ChildItem -Path "$wordToComplete*" -ErrorAction SilentlyContinue | ForEach-Object {\n [System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, 'ProviderItem', $_.FullName)\n }\n }\n}\n# end coze completion\n`;default:return}}function ja(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}let za,wa,Ua=!1,La=!1;function Oa(e){const t=(i=e._args,o=()=>[],null!=i?i:o());var i,o;if(0===t.length)return!1;const n=/path|file|dir|folder/i;return t.some((e=>n.test(e._name)))}function Ia(e){wa=e,function(){const e=process.argv.indexOf("--completion");e>-1&&(Ua=!0,process.argv.splice(e,1));const t=process.argv.indexOf("--completion-fish");t>-1&&(La=!0,process.argv.splice(t,1))}(),za=m("coze"),za.on("complete",((t,i)=>{const o=i.line.trimStart().split(/\s+/);o.length>0&&(o[0].endsWith("coze")||o[0].endsWith("bin/main"))&&o.shift();let n="";i.line.endsWith(" ")?(n="",""===o[o.length-1]&&o.pop()):n=o.pop()||"";const s=function(e,t,i){let o=e;for(const e of t){const t=o.commands.find((t=>t.name()===e||t.alias()===e));if(t)o=t;else if(!e.startsWith("-"))return Oa(o)?[Ca]:[]}const n=[];o.commands.length>0&&o.commands.forEach((e=>{n.push(e.name())})),o.options.forEach((e=>{e.flags.split(/[ ,|]+/).forEach((e=>{e.startsWith("<")||e.startsWith("[")||n.push(e)}))})),o!==e&&e.options.forEach((e=>{e.flags.split(/[ ,|]+/).forEach((e=>{e.startsWith("<")||e.startsWith("[")||n.push(e)}))}));const s=Array.from(new Set(n)).filter((e=>e.startsWith(i)));return 0===s.length&&Oa(o)?[Ca]:s}(e,o,n);i.reply(s)})),e.command("completion").description("Setup shell auto-completion").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Configure terminal auto-completion",description:"Install or remove the auto-completion script for the current terminal environment (supports bash/zsh/fish/powershell).",examples:[{desc:"Install completion script",cmd:"coze completion --setup"},{desc:"Remove completion script",cmd:"coze completion --cleanup"}]}}).option("--setup","Install shell completion into your startup script (.zshrc / .bashrc / $PROFILE)").option("--cleanup","Remove shell completion from your startup script").action((async e=>{if(e.cleanup)!function(){const e=ka();if(!e)return;const t=Aa(e);if(!t||!d.existsSync(t))return;const i=Ra(e);if(i){const e=d.readFileSync(t,"utf8").replace(new RegExp(i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),"");d.writeFileSync(t,e)}if("bash"===e){const e=s.join(n.homedir(),".coze"),t=s.join(e,"completion.sh");d.existsSync(t)&&d.unlinkSync(t),d.existsSync(e)&&0===d.readdirSync(e).length&&d.rmdirSync(e)}}(),await X({completionInstalled:!1}),console.log("Shell completion removed! Please restart your terminal.");else{const e=ka();if(!e)return console.error("Could not detect your shell type. Supported shells: bash, zsh, fish, powershell."),void(process.exitCode=1);const t=function(){const e=ka();if(!e)return!1;const t=Aa(e);if(!t)return!1;if("bash"===e){const e=s.join(n.homedir(),".coze"),t=s.join(e,"completion.sh");d.existsSync(e)||d.mkdirSync(e,{recursive:!0}),d.writeFileSync(t,Ea())}const i=s.dirname(t);d.existsSync(i)||d.mkdirSync(i,{recursive:!0});const o=Ra(e);return!!o&&(d.appendFileSync(t,o),!0)}();t?(await X({completionInstalled:!0}),console.log(`Shell completion (${e}) setup successful! Please restart your terminal or source your config file.`)):(console.error(`Failed to setup shell completion for ${e}.`),process.exitCode=1)}}))}function Ba(){return Ua?(console.log(Ea()),void process.exit()):La?(console.log(["### coze completion - begin. generated by coze cli ###","function _coze_completion"," set -l completions (coze --compfish --compgen (count (commandline -poc)) (commandline -pt) (commandline -pb))",` if test (count $completions) -eq 1 -a "$completions[1]" = "${Ca}"`," return"," end"," for c in $completions"," echo $c"," end","end","complete -c coze -a '(_coze_completion)' -n '_coze_completion'","### coze completion - end ###"].join(n.EOL)),void process.exit()):void(process.argv.includes("--comppwsh")?function(){if(!wa)return void process.exit();const e=process.argv.indexOf("--comppwsh"),t=process.argv.slice(e+1);let i=wa;const o=[];for(const e of t){const t=ja([i,"access",e=>e.commands,"optionalAccess",e=>e.find,"call",t=>t((t=>t.name()===e||t.alias()===e))]);t?i=t:o.push(e)}const n=[];ja([i,"access",e=>e.commands,"optionalAccess",e=>e.forEach,"call",e=>e((e=>{n.push(e.name())}))]),ja([i,"access",e=>e.options,"optionalAccess",e=>e.forEach,"call",e=>e((e=>{e.flags.split(/[ ,|]+/).forEach((e=>{e.startsWith("<")||e.startsWith("[")||n.push(e)}))}))]),i!==wa&&ja([wa,"access",e=>e.options,"optionalAccess",e=>e.forEach,"call",e=>e((e=>{e.flags.split(/[ ,|]+/).forEach((e=>{e.startsWith("<")||e.startsWith("[")||n.push(e)}))}))]);const s=o[o.length-1]||"",r=Array.from(new Set(n)).filter((e=>e.startsWith(s)));0===r.length&&Oa(i)?console.log(Ca):r.length>0&&console.log(r.join("\n")),process.exit()}():za&&za.init())}function qa(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function xa(t){t.command("remove <skillId>").description("Remove skills from the project").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"Remove skill from project",description:"Remove a configured skill from the specified project.",examples:[{desc:"Remove skill",cmd:"coze code skill remove <skillId> -p <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},skillId:{type:"string",required:!0,description:"Skill ID to remove"}},output:{command:{type:"string",description:"Command name"},status:{type:"string",description:"Execution status"},data:{type:"object",properties:{project_id:{type:"string",description:"Project ID"},removed_skill_ids:{type:"array",items:{type:"string"},description:"Removed skill IDs"},message:{type:"string",description:"Result message"}}}}},errors:[{code:e.ErrorCode.E3004,name:"SKILL_NOT_INSTALLED",desc:"The specified skill is not installed in the project",fix:"Please use `skill list` to confirm installed skills"}]}}).action((async function(t,i,o){const n=o.getContext(),{projectId:s}=i,r=new Set([t]),a=qa([(await e.IdeApi.GetVibeProject({project_id:s})).data||{},"access",e=>e.project_info,"optionalAccess",e=>e.project_settings,"optionalAccess",e=>e.skill_setting]);var c;const d=(c=qa([a,"optionalAccess",e=>e.skills]),Array.isArray(c)?c.map((e=>{return{skill_id:String((t=qa([e,"optionalAccess",e=>e.skill_id]),i=()=>"",null!=t?t:i())),is_preload:qa([e,"optionalAccess",e=>e.is_preload])};var t,i})).filter((e=>Boolean(e.skill_id))):[]).filter((e=>!r.has(e.skill_id))),p={filter_types:qa([a,"optionalAccess",e=>e.filter_types]),skills:d};await e.IdeApi.UpdateVibeProject({project_id:s,project_settings:{skill_setting:p}}),qa([n,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e("Skill removed.")]),qa([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({project_id:s,removed_skill_ids:Array.from(r),message:"removed Skills successfully."})])}))}function Da(e,t){return null!=e?e:t()}function Ma(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function Ga(t){t.command("list").description("List available skills for the project").requiredOption("-p, --project-id <projectId>","Project ID").option("--space-id <spaceId>","Space ID (optional, reads from config)").config({help:{brief:"List available skills for the project",description:"Retrieve a list of all available skills for the specified project type, with installation status indicating which skills are already added.",examples:[{desc:"List project skills",cmd:"coze code skill list --project-id <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},spaceId:{type:"string",required:!1,description:"Space ID (optional, reads from context)"}},output:{type:"array",items:{type:"object",properties:{description:{type:"string",description:"Skill description"},skill_id:{type:"string",description:"Skill ID"},name:{type:"string",description:"Skill name"},icon:{type:"string",description:"Skill icon URL"},is_installed:{type:"boolean",description:"Whether the skill is installed"}}}}},errors:[{code:e.ErrorCode.E1003,name:"MISSING_SPACE_ID",desc:"Space ID is required",fix:"Please use --space-id <spaceId> or run `coze space use <spaceId>` first"}]}}).action((async function(t,i){const o=i.getContext(),{projectId:n}=t,s=Da(Da(t.spaceId,(()=>Ma([o,"optionalAccess",e=>e.config,"access",e=>e.spaceId]))),(()=>""));if(!s)throw new e.CozeError(e.ErrorCode.E1003,"Missing spaceId: pass --space-id <spaceId> or set config.spaceId");const r=await e.IdeApi.GetVibeProject({project_id:n}),a=function(e){const t=[],i=Ma([e,"optionalAccess",e=>e.project_info,"optionalAccess",e=>e.project_settings]);Ma([i,"optionalAccess",e=>e.skill_setting,"optionalAccess",e=>e.skills])&&t.push(...i.skill_setting.skills);const o=t.map((e=>Ma([e,"optionalAccess",e=>e.skill_id]))).filter(Boolean);return new Set(o)}(r.data||{}),c=Ma([r,"access",e=>e.data,"optionalAccess",e=>e.project_info,"optionalAccess",e=>e.project_type]),d=await Dr.GetSkillList({project_type:c,space_id:s,category_type_list:[c]});Ma([o,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e(`Fetched ${Ma([d,"access",e=>e.data,"optionalAccess",e=>e.skill_meta_list,"optionalAccess",e=>e.length])||0} skills.`)]),Ma([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(Ma([d,"access",e=>e.data,"optionalAccess",e=>e.skill_meta_list,"optionalAccess",e=>e.map,"call",e=>e((e=>({description:Ma([e,"optionalAccess",e=>e.description]),skill_id:Ma([e,"optionalAccess",e=>e.skill_id]),name:Ma([e,"optionalAccess",e=>e.name]),icon:Ma([e,"optionalAccess",e=>e.icon]),is_installed:a.has(e.skill_id||"")})))]))])}))}function Na(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function Fa(t){t.command("add <skillId>").description("Add skills to the project").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"Add skill to project",description:"Add a specified skill to the project. Skills can extend project capabilities, such as adding search, code execution, etc.",examples:[{desc:"Add skill",cmd:"coze code skill add <skillId> -p <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},skillId:{type:"string",required:!0,description:"Skill ID"}},output:{command:{type:"string",description:"Command name"},status:{type:"string",description:"Execution status"},data:{type:"object",properties:{project_id:{type:"string",description:"Project ID"},added_skill_ids:{type:"array",items:{type:"string"},description:"Added skill IDs"},message:{type:"string",description:"Result message"}}}}},errors:[{code:e.ErrorCode.E3002,name:"SKILL_NOT_FOUND",desc:"The specified skill does not exist",fix:"Please use `skill list` to confirm available skills"}]}}).action((async function(t,i,o){const n=o.getContext(),{projectId:s}=i,r=[t],a=(await e.IdeApi.GetVibeProject({project_id:s})).data||{},c=Na([a,"access",e=>e.project_info,"optionalAccess",e=>e.project_type]),d=Na([a,"access",e=>e.project_info,"optionalAccess",e=>e.project_settings,"optionalAccess",e=>e.skill_setting]),p=function(e){const t=new Map;for(const i of e){const e=Na([i,"optionalAccess",e=>e.skill_id])?String(i.skill_id):"";e&&(t.has(e)||t.set(e,{skill_id:e,is_preload:i.is_preload}))}return Array.from(t.values())}([...Array.isArray(Na([d,"optionalAccess",e=>e.skills]))?d.skills:[],...r.map((e=>({skill_id:String(e),is_preload:!0})))]),l={filter_types:Na([d,"optionalAccess",e=>e.filter_types])&&d.filter_types.length>0?d.filter_types:[c],skills:p};await e.IdeApi.UpdateVibeProject({project_id:s,project_settings:{skill_setting:l}}),Na([n,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e("Skills added successfully.")]),Na([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({project_id:s,added_skill_ids:r,message:"added Skills successfully."})])}))}var $a,Va,Wa,Ha,Ka,Ja,Qa,Za,Ya,Xa,ec,tc,ic,oc,nc,sc,rc,ac,cc,dc,pc,lc,uc,_c,mc,gc,hc,fc,yc,vc,bc,Pc,Sc,Tc,Cc,kc,Ac,Ec,Rc,jc,zc,wc,Uc,Lc,Oc,Ic,Bc,qc,xc,Dc,Mc,Gc,Nc,Fc,$c,Vc,Wc,Hc,Kc,Jc,Qc,Zc,Yc,Xc,ed,td,id,od,nd,sd,rd,ad;function cd(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}!function(e){e[e.ChatApi=0]="ChatApi";e[e.ResponsesApi=1]="ResponsesApi"}($a||($a={})),function(e){e[e.CacheClosed=0]="CacheClosed";e[e.PrefixCache=1]="PrefixCache"}(Va||(Va={})),function(e){e[e.Chat=0]="Chat";e[e.FunctionCall_1=1]="FunctionCall_1";e[e.FunctionCall_2=2]="FunctionCall_2";e[e.FunctionCall_3=3]="FunctionCall_3"}(Wa||(Wa={})),function(e){e[e.FullSupport=0]="FullSupport";e[e.PoorSupport=1]="PoorSupport";e[e.NotSupport=2]="NotSupport"}(Ha||(Ha={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.ImageFlow=3]="ImageFlow";e[e.Trigger=4]="Trigger";e[e.KnowledgeText=5]="KnowledgeText";e[e.KnowledgeTable=6]="KnowledgeTable";e[e.KnowledgeAutoCall=7]="KnowledgeAutoCall";e[e.KnowledgeOnDemandCall=8]="KnowledgeOnDemandCall";e[e.Variable=9]="Variable";e[e.Database=10]="Database";e[e.LongTermMemory=11]="LongTermMemory";e[e.FileBox=12]="FileBox";e[e.Onboarding=13]="Onboarding";e[e.Suggestion=14]="Suggestion";e[e.ShortcutCommand=15]="ShortcutCommand";e[e.BackGroundImage=16]="BackGroundImage";e[e.TTS=17]="TTS";e[e.MultiAgentRecognize=18]="MultiAgentRecognize";e[e.KnowledgePhoto=19]="KnowledgePhoto";e[e.HookInfo=20]="HookInfo";e[e.KnowledgeValcanoUnstructured=21]="KnowledgeValcanoUnstructured";e[e.KnowledgeValcanoStructured=22]="KnowledgeValcanoStructured";e[e.Model=23]="Model";e[e.KnowledgeThirdPartyUnstructured=24]="KnowledgeThirdPartyUnstructured";e[e.KnowledgeThirdPartyStructured=25]="KnowledgeThirdPartyStructured"}(Ka||(Ka={})),function(e){e[e.Text=0]="Text";e[e.Markdown=1]="Markdown";e[e.JSON=2]="JSON"}(Ja||(Ja={})),function(e){e[e.Custom=0]="Custom";e[e.Creative=1]="Creative";e[e.Balance=2]="Balance";e[e.Precise=3]="Precise"}(Qa||(Qa={})),function(e){e[e.Auditing=0]="Auditing";e[e.Success=1]="Success";e[e.Failed=2]="Failed"}(Za||(Za={})),function(e){e[e.Official=1]="Official";e[e.Public=2]="Public";e[e.Custom=3]="Custom";e[e.Others=101]="Others"}(Ya||(Ya={})),function(e){e[e.Normal=0]="Normal";e[e.Offline=1]="Offline";e[e.TokenDisconnect=2]="TokenDisconnect"}(Xa||(Xa={})),function(e){e[e.App=1]="App";e[e.Resource=2]="Resource"}(ec||(ec={})),function(e){e[e.CozeModel=1]="CozeModel";e[e.VolcAccount=2]="VolcAccount";e[e.SelfAccount=3]="SelfAccount";e[e.SelfModel=4]="SelfModel"}(tc||(tc={})),function(e){e[e.Asc=1]="Asc";e[e.Desc=2]="Desc"}(ic||(ic={})),function(e){e[e.NoDetail=1]="NoDetail";e[e.Detail=2]="Detail";e[e.Operate=3]="Operate"}(oc||(oc={})),function(e){e[e.Published=1]="Published";e[e.Unpublished=2]="Unpublished"}(nc||(nc={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.Imageflow=3]="Imageflow";e[e.Knowledge=4]="Knowledge";e[e.UI=5]="UI";e[e.Prompt=6]="Prompt";e[e.Database=7]="Database";e[e.Variable=8]="Variable"}(sc||(sc={})),function(e){e[e.Intelligence=1]="Intelligence";e[e.App=2]="App";e[e.Plugin=3]="Plugin";e[e.Workflow=4]="Workflow";e[e.Knowledge=5]="Knowledge";e[e.Card=6]="Card";e[e.Prompt=7]="Prompt";e[e.Database=8]="Database";e[e.Voice=9]="Voice";e[e.VibeProjectAgent=11]="VibeProjectAgent";e[e.VibeProjectAutomation=12]="VibeProjectAutomation";e[e.VibeProjectWebApp=13]="VibeProjectWebApp";e[e.VibeProjectApp=14]="VibeProjectApp";e[e.VibeProjectSkill=15]="VibeProjectSkill";e[e.VibeProjectGeneralWeb=16]="VibeProjectGeneralWeb";e[e.VibeProjectWechatMiniProgram=17]="VibeProjectWechatMiniProgram";e[e.VibeProjectAssistantAgent=18]="VibeProjectAssistantAgent";e[e.VibeProjectGeneral=19]="VibeProjectGeneral"}(rc||(rc={})),function(e){e[e.Mobile=1]="Mobile";e[e.Web=2]="Web"}(ac||(ac={})),function(e){e[e.CacheClosed=0]="CacheClosed";e[e.PrefixCache=1]="PrefixCache"}(cc||(cc={})),function(e){e[e.Using=1]="Using";e[e.Deleted=2]="Deleted";e[e.Banned=3]="Banned";e[e.MoveFailed=4]="MoveFailed";e[e.Copying=5]="Copying";e[e.CopyFailed=6]="CopyFailed"}(dc||(dc={})),function(e){e[e.Bot=1]="Bot";e[e.Project=2]="Project";e[e.DouyinAvatarBot=3]="DouyinAvatarBot";e[e.VibeProjectAgent=11]="VibeProjectAgent";e[e.VibeProjectAutomation=12]="VibeProjectAutomation";e[e.VibeProjectWebApp=13]="VibeProjectWebApp";e[e.VibeProjectApp=14]="VibeProjectApp";e[e.VibeProjectSkill=15]="VibeProjectSkill";e[e.VibeProjectGeneralWeb=16]="VibeProjectGeneralWeb";e[e.VibeProjectWechatMiniProgram=17]="VibeProjectWechatMiniProgram";e[e.VibeProjectAssistantAgent=18]="VibeProjectAssistantAgent";e[e.VibeProjectGeneral=19]="VibeProjectGeneral"}(pc||(pc={})),function(e){e[e.DEFAULT=0]="DEFAULT";e[e.Chux=1]="Chux"}(lc||(lc={})),function(e){e[e.ProjectOwner=1]="ProjectOwner";e[e.ProjectEditor=2]="ProjectEditor";e[e.BotEditor=3]="BotEditor";e[e.BotDeveloper=4]="BotDeveloper";e[e.BotOperator=5]="BotOperator";e[e.BotOwner=6]="BotOwner"}(uc||(uc={})),function(e){e[e.PromptDiff=1]="PromptDiff";e[e.ModelDiff=2]="ModelDiff"}(_c||(_c={})),function(e){e[e.DraftBot=1]="DraftBot"}(mc||(mc={})),function(e){e[e.Success=1]="Success";e[e.Processing=2]="Processing";e[e.Failed=3]="Failed";e[e.Canceled=4]="Canceled"}(gc||(gc={})),function(e){e[e.Archive=1]="Archive";e[e.Rollback=2]="Rollback"}(hc||(hc={})),function(e){e[e.ProjectCopyCancel=1]="ProjectCopyCancel";e[e.ProjectCopyRetry=2]="ProjectCopyRetry"}(fc||(fc={})),function(e){e[e.ProjectCopy=1]="ProjectCopy";e[e.BotCopy=2]="BotCopy";e[e.VibeProjectCopy=3]="VibeProjectCopy"}(yc||(yc={})),function(e){e[e.ChatApi=0]="ChatApi";e[e.ResponsesApi=1]="ResponsesApi"}(vc||(vc={})),function(e){e[e.Bot=1]="Bot";e[e.Workflow=2]="Workflow";e[e.Application=3]="Application"}(bc||(bc={})),function(e){e[e.DefaultHeader=1]="DefaultHeader";e[e.SpecifiedHeader=2]="SpecifiedHeader"}(Pc||(Pc={})),function(e){e[e.VolcKms=1]="VolcKms";e[e.PlainText=2]="PlainText"}(Sc||(Sc={})),function(e){e[e.BatchSize=1]="BatchSize";e[e.LearningRate=2]="LearningRate";e[e.Epochs=3]="Epochs"}(Tc||(Tc={})),function(e){e[e.GPT=1]="GPT";e[e.SEED=2]="SEED";e[e.Claude=3]="Claude";e[e.MiniMax=4]="MiniMax";e[e.Plugin=5]="Plugin";e[e.StableDiffusion=6]="StableDiffusion";e[e.ByteArtist=7]="ByteArtist";e[e.Maas=9]="Maas";e[e.QianFan=10]="QianFan";e[e.Gemini=11]="Gemini";e[e.Moonshot=12]="Moonshot";e[e.GLM=13]="GLM";e[e.MaaSAutoSync=14]="MaaSAutoSync";e[e.QWen=15]="QWen";e[e.Cohere=16]="Cohere";e[e.Baichuan=17]="Baichuan";e[e.Ernie=18]="Ernie";e[e.DeekSeek=19]="DeekSeek";e[e.Llama=20]="Llama";e[e.StepFun=23]="StepFun";e[e.Custom=24]="Custom";e[e.Other=999]="Other"}(Cc||(Cc={})),function(e){e[e.Float=1]="Float";e[e.Int=2]="Int";e[e.Boolean=3]="Boolean";e[e.String=4]="String"}(kc||(kc={})),function(e){e[e.Douyin=1]="Douyin"}(Ac||(Ac={})),function(e){e[e.Terminating=1]="Terminating";e[e.Terminated=2]="Terminated"}(Ec||(Ec={})),function(e){e[e.Online=1]="Online";e[e.Offline=2]="Offline";e[e.Deleted=3]="Deleted";e[e.FineTuneInQueue=4]="FineTuneInQueue";e[e.FineTuneRunning=5]="FineTuneRunning";e[e.FineTuneFailed=6]="FineTuneFailed";e[e.FineTuneTeminated=7]="FineTuneTeminated"}(Rc||(Rc={})),function(e){e[e.ModelType=1]="ModelType";e[e.ModelUserRight=2]="ModelUserRight";e[e.ModelFeature=3]="ModelFeature";e[e.ModelFunction=4]="ModelFunction";e[e.ModelScenario=5]="ModelScenario";e[e.ModelPayment=15]="ModelPayment";e[e.ModelAbility=16]="ModelAbility";e[e.ModelStatus=17]="ModelStatus";e[e.Custom=20]="Custom";e[e.Others=100]="Others"}(jc||(jc={})),function(e){e[e.Flagship=1]="Flagship";e[e.HighSpeed=2]="HighSpeed";e[e.ToolInvocation=3]="ToolInvocation";e[e.RolePlaying=4]="RolePlaying";e[e.LongText=5]="LongText";e[e.ImageUnderstanding=6]="ImageUnderstanding";e[e.Reasoning=7]="Reasoning";e[e.VideoUnderstanding=8]="VideoUnderstanding";e[e.CostPerformance=9]="CostPerformance";e[e.CodeSpecialization=10]="CodeSpecialization";e[e.AudioUnderstanding=11]="AudioUnderstanding"}(zc||(zc={})),function(e){e[e.TotalTokens=1]="TotalTokens";e[e.TotalInput=2]="TotalInput";e[e.TotalOutput=3]="TotalOutput"}(wc||(wc={})),function(e){e[e.stop=1]="stop";e[e.resume=2]="resume",e[e.delete=3]="delete"}(Uc||(Uc={})),function(e){e[e.Recommend=1]="Recommend"}(Lc||(Lc={})),function(e){e[e.Default=0]="Default";e[e.Terminate=1]="Terminate"}(Oc||(Oc={})),function(e){e[e.All=0]="All";e[e.WithBenefit=1]="WithBenefit"}(Ic||(Ic={})),function(e){e[e.upload=1]="upload";e[e.TrainingSetSplit=2]="TrainingSetSplit"}(Bc||(Bc={})),function(e){e[e.Text=1]="Text";e[e.ImageFirstFrame=2]="ImageFirstFrame";e[e.ImageFirstLastFrame=3]="ImageFirstLastFrame";e[e.ReferencePicture=4]="ReferencePicture"}(qc||(qc={})),function(e){e[e.Using=1]="Using";e[e.Deleted=2]="Deleted"}(xc||(xc={})),function(e){e[e.Publish=0]="Publish";e[e.Archive=1]="Archive"}(Dc||(Dc={})),function(e){e[e.User=0]="User";e[e.NL2App=1]="NL2App"}(Mc||(Mc={})),function(e){e[e.NoBindRequired=1]="NoBindRequired";e[e.AuthBind=2]="AuthBind";e[e.KvBind=3]="KvBind";e[e.KvAuthBind=4]="KvAuthBind";e[e.ApiBind=5]="ApiBind";e[e.WebSDKBind=6]="WebSDKBind";e[e.StoreBind=7]="StoreBind";e[e.AuthAndConfig=8]="AuthAndConfig";e[e.ConnectorCustom=9]="ConnectorCustom"}(Gc||(Gc={})),function(e){e[e.APIOrSDK=1]="APIOrSDK";e[e.SocialPlatform=2]="SocialPlatform";e[e.Coze=3]="Coze";e[e.MiniProgram=4]="MiniProgram";e[e.CozeSpaceExtensionLibrary=5]="CozeSpaceExtensionLibrary"}(Nc||(Nc={})),function(e){e[e.Configured=1]="Configured";e[e.NotConfigured=2]="NotConfigured";e[e.Disconnected=3]="Disconnected";e[e.Configuring=4]="Configuring";e[e.NeedReconfiguring=5]="NeedReconfiguring"}(Fc||(Fc={})),function(e){e[e.Default=0]="Default";e[e.Auditing=1]="Auditing";e[e.Success=2]="Success";e[e.Failed=3]="Failed";e[e.Disable=4]="Disable"}($c||($c={})),function(e){e[e.Normal=0]="Normal";e[e.InReview=1]="InReview";e[e.Offline=2]="Offline"}(Vc||(Vc={})),function(e){e[e.Packing=0]="Packing";e[e.PackFailed=1]="PackFailed";e[e.Auditing=2]="Auditing";e[e.AuditNotPass=3]="AuditNotPass";e[e.ConnectorPublishing=4]="ConnectorPublishing";e[e.PublishDone=5]="PublishDone"}(Wc||(Wc={})),function(e){e[e.Authorized=1]="Authorized";e[e.UnAuthorized=2]="UnAuthorized";e[e.Authorizing=3]="Authorizing"}(Hc||(Hc={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.Imageflow=3]="Imageflow";e[e.Knowledge=4]="Knowledge";e[e.UI=5]="UI";e[e.Prompt=6]="Prompt";e[e.Database=7]="Database";e[e.Variable=8]="Variable";e[e.Voice=9]="Voice";e[e.Memorybase=10]="Memorybase";e[e.MCP=11]="MCP"}(Kc||(Kc={})),function(e){e[e.SingleMode=0]="SingleMode";e[e.MultiMode=1]="MultiMode";e[e.WorkflowMode=2]="WorkflowMode"}(Jc||(Jc={})),function(e){e[e.UpdateTime=0]="UpdateTime";e[e.CreateTime=1]="CreateTime";e[e.Name=2]="Name"}(Qc||(Qc={})),function(e){e[e.UpdateTime=0]="UpdateTime";e[e.CreateTime=1]="CreateTime"}(Zc||(Zc={})),function(e){e[e.UpdateTime=0]="UpdateTime";e[e.CreateTime=1]="CreateTime";e[e.PublishTime=2]="PublishTime";e[e.OpenTime=3]="OpenTime"}(Yc||(Yc={})),function(e){e[e.Standard=0]="Standard";e[e.PrefixPrompt=1]="PrefixPrompt"}(Xc||(Xc={})),function(e){e[e.All=0]="All";e[e.CreateByMe=1]="CreateByMe";e[e.AllWithCollaborator=2]="AllWithCollaborator";e[e.CanImportToSpace=3]="CanImportToSpace"}(ed||(ed={})),function(e){e[e.Desc=0]="Desc";e[e.Asc=1]="Asc"}(td||(td={})),function(e){e[e.Copy=1]="Copy";e[e.Move=2]="Move";e[e.Publish=3]="Publish";e[e.ImportExport=4]="ImportExport"}(id||(id={})),function(e){e[e.Project=1]="Project";e[e.Space=2]="Space";e[e.Online=3]="Online";e[e.Template=4]="Template";e[e.Agent=5]="Agent"}(od||(od={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.Imageflow=3]="Imageflow";e[e.Knowledge=4]="Knowledge";e[e.UI=5]="UI";e[e.Project=6]="Project";e[e.Database=7]="Database";e[e.Variable=8]="Variable";e[e.Trigger=9]="Trigger";e[e.Agent=10]="Agent";e[e.Prompt=11]="Prompt";e[e.Shortcut=12]="Shortcut";e[e.Chux=13]="Chux";e[e.Memorybase=14]="Memorybase";e[e.VibeProjectAgent=15]="VibeProjectAgent";e[e.VibeProjectAutomation=16]="VibeProjectAutomation";e[e.VibeProjectWebApp=17]="VibeProjectWebApp";e[e.VibeProjectApp=18]="VibeProjectApp";e[e.VibeProjectSkill=19]="VibeProjectSkill";e[e.VibeProjectGeneralWeb=20]="VibeProjectGeneralWeb";e[e.VibeProjectWechatMiniProgram=21]="VibeProjectWechatMiniProgram";e[e.VibeProjectAssistantAgent=22]="VibeProjectAssistantAgent";e[e.VibeProjectGeneral=23]="VibeProjectGeneral"}(nd||(nd={})),function(e){e[e.Success=1]="Success";e[e.Processing=2]="Processing";e[e.Failed=3]="Failed";e[e.Canceled=4]="Canceled"}(sd||(sd={})),function(e){e[e.CopyResourceInProject=1]="CopyResourceInProject";e[e.CopyProjectResourceToLibrary=2]="CopyProjectResourceToLibrary";e[e.MoveProjectResourceToLibrary=3]="MoveProjectResourceToLibrary";e[e.CopyLibraryResourceToProject=4]="CopyLibraryResourceToProject";e[e.CopyProject=5]="CopyProject";e[e.PublishProject=6]="PublishProject";e[e.CopyTemplateToProject=7]="CopyTemplateToProject";e[e.PublishProjectTemplate=8]="PublishProjectTemplate";e[e.LaunchProjectTemplate=9]="LaunchProjectTemplate";e[e.ArchiveProject=10]="ArchiveProject";e[e.RollbackProject=11]="RollbackProject";e[e.CrossSpaceCopy=12]="CrossSpaceCopy";e[e.CrossSpaceCopyProject=13]="CrossSpaceCopyProject";e[e.Export=14]="Export";e[e.Import=15]="Import";e[e.PublishChuxProject=16]="PublishChuxProject";e[e.CopyResource=17]="CopyResource";e[e.CopyVibeProject=18]="CopyVibeProject"}(rd||(rd={})),function(e){e[e.Packing=0]="Packing";e[e.PackSuccess=1]="PackSuccess";e[e.PackFail=2]="PackFail"}(ad||(ad={}));class dd{__init(){this.request=e.request}__init2(){this.baseURL=""}constructor(e){dd.prototype.__init.call(this),dd.prototype.__init2.call(this),this.request=cd([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=cd([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}Ping(e,t){const i=this.genBaseURL("/api/intelligence_api/ping");return this.request({url:i,method:"POST"},t)}DraftProjectCreate(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/draft_project/create"),n={space_id:i.space_id,name:i.name,description:i.description,icon_uri:i.icon_uri,monetization_conf:i.monetization_conf,create_from:i.create_from,folder_id:i.folder_id,type:i.type};return this.request({url:o,method:"POST",data:n},t)}GetDraftIntelligenceList(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/search/get_draft_intelligence_list"),n={space_id:i.space_id,name:i.name,has_published:i.has_published,status:i.status,types:i.types,search_scope:i.search_scope,folder_id:i.folder_id,folder_include_children:i.folder_include_children,order_type:i.order_type,project_type:i.project_type,is_fav_filter:i.is_fav_filter,is_fav:i.is_fav,recently_open:i.recently_open,option:i.option,order_by:i.order_by,cursor_id:i.cursor_id,size:i.size};return this.request({url:o,method:"POST",data:n},t)}DraftProjectUpdate(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/draft_project/update"),n={project_id:i.project_id,name:i.name,description:i.description,icon_uri:i.icon_uri};return this.request({url:o,method:"POST",data:n},t)}GetDraftIntelligenceInfo(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/search/get_draft_intelligence_info"),n={intelligence_id:i.intelligence_id,intelligence_type:i.intelligence_type,version:i.version};return this.request({url:o,method:"POST",data:n},t)}GetUserRecentlyEditIntelligence(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/search/get_recently_edit_intelligence"),n={size:i.size,types:i.types,enterprise_id:i.enterprise_id,organization_id:i.organization_id};return this.request({url:o,method:"POST",data:n},t)}DraftProjectCopy(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/draft_project/copy"),n={project_id:i.project_id,to_space_id:i.to_space_id,name:i.name,description:i.description,icon_uri:i.icon_uri};return this.request({url:o,method:"POST",data:n},t)}ProcessEntityTask(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/entity_task/process"),n={entity_id:i.entity_id,action:i.action,task_id_list:i.task_id_list};return this.request({url:o,method:"POST",data:n},t)}DraftProjectDelete(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/draft_project/delete"),n={project_id:i.project_id};return this.request({url:o,method:"POST",data:n},t)}EntityTaskSearch(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/entity_task/search"),n={task_list:i.task_list};return this.request({url:o,method:"POST",data:n},t)}ListIntelligenceCollaboration(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/collaboration/list"),n={intelligence_id:i.intelligence_id,intelligence_type:i.intelligence_type};return this.request({url:o,method:"POST",data:n},t)}OceanProjectCreate(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/ocean_project/create"),n={space_id:i.space_id,name:i.name,description:i.description,icon_uri:i.icon_uri};return this.request({url:o,method:"POST",data:n},t)}OceanProjectUpdate(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/ocean_project/update"),n={project_id:i.project_id,name:i.name,description:i.description,icon_uri:i.icon_uri};return this.request({url:o,method:"POST",data:n},t)}GetOceanProjectList(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/search/get_ocean_project_list"),n={space_id:i.space_id,status:i.status,search_scope:i.search_scope,order_by:i.order_by,page_index:i.page_index,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}PublishProject(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/publish/publish_project"),n={project_id:i.project_id,version_number:i.version_number,description:i.description,connectors:i.connectors,connector_publish_config:i.connector_publish_config};return this.request({url:o,method:"POST",data:n},t)}GetPublishRecordDetail(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/publish/publish_record_detail"),n={project_id:i.project_id,publish_record_id:i.publish_record_id};return this.request({url:o,method:"POST",data:n},t)}GetPublishRecordList(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/publish/publish_record_list"),n={project_id:i.project_id};return this.request({url:o,method:"POST",data:n},t)}PublishConnectorList(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/publish/connector_list"),n={project_id:i.project_id};return this.request({url:o,method:"POST",data:n},t)}CheckProjectVersionNumber(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/publish/check_version_number"),n={project_id:i.project_id,version_number:i.version_number};return this.request({url:o,method:"POST",data:n},t)}DraftProjectInnerTaskList(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/draft_project/inner_task_list"),n={project_id:i.project_id};return this.request({url:o,method:"POST",data:n},t)}GetOceanProjectInfo(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/search/get_ocean_project_info"),n={project_id:i.project_id};return this.request({url:o,method:"POST",data:n},t)}GetModelListFilterParams(e,t){const i=this.genBaseURL("/api/intelligence_api/model/get_model_list_filter_params");return this.request({url:i,method:"POST"},t)}StartEstimatedTrainingCost(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/start_estimated_training_cost"),n={base_model_id:i.base_model_id,space_id:i.space_id,training_dataset_id:i.training_dataset_id,epochs:i.epochs};return this.request({url:o,method:"POST",data:n},t)}GetModelList(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/get_model_list"),n={space_id:i.space_id,name:i.name,tag_filters:i.tag_filters,context_len_min:i.context_len_min,context_len_max:i.context_len_max,model_cost_min:i.model_cost_min,model_cost_max:i.model_cost_max,model_vendor:i.model_vendor,statusList:i.statusList,model_show_family_id:i.model_show_family_id,model_source:i.model_source,order_by:i.order_by,cursor_id:i.cursor_id,limit:i.limit};return this.request({url:o,method:"POST",data:n},t)}GetFinetuneTemplateDataset(e,t){const i=this.genBaseURL("/api/intelligence_api/model/get_finetune_template_dataset");return this.request({url:i,method:"POST"},t)}GetModelUsageData(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/get_model_usage_data"),n={space_id:i.space_id,model_id:i.model_id};return this.request({url:o,method:"POST",data:n},t)}GetEstimatedTrainingCost(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/get_estimated_training_cost"),n={task_id:i.task_id,space_id:i.space_id,base_model_id:i.base_model_id,epochs:i.epochs};return this.request({url:o,method:"POST",data:n},t)}CreateFinetuneTask(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/create_finetune_task"),n={space_id:i.space_id,base_model_id:i.base_model_id,training_dataset_id:i.training_dataset_id,validating_dataset:i.validating_dataset,finetune_configuration:i.finetune_configuration,description:i.description,name:i.name};return this.request({url:o,method:"POST",data:n},t)}UploadFinetuneDataset(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/upload_finetune_dataset"),n={space_id:i.space_id,fileType:i.fileType,fileName:i.fileName,data:i.data,testing_data:i.testing_data};return this.request({url:o,method:"POST",data:n},t)}GetModelInfo(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/get_model_info"),n={space_id:i.space_id,model_id:i.model_id,is_finetuning:i.is_finetuning};return this.request({url:o,method:"POST",data:n},t)}GetFinetuneTrainingInfo(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/get_finetune_training_info"),n={space_id:i.space_id,model_id:i.model_id};return this.request({url:o,method:"POST",data:n},t)}GetModelPerformanceData(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/get_model_performance_data"),n={space_id:i.space_id,model_id:i.model_id,get_pct:i.get_pct};return this.request({url:o,method:"POST",data:n},t)}OperateFinetuneTask(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/operate_finetune_task"),n={id:i.id,action:i.action};return this.request({url:o,method:"POST",data:n},t)}DeleteFinetuneModel(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/delete_finetune_model"),n={model_id:i.model_id,space_id:i.space_id};return this.request({url:o,method:"POST",data:n},t)}GetUserCompleteProfileRecord(e,t){const i=this.genBaseURL("/api/intelligence_api/user_profile/get_user_complete_profile_record");return this.request({url:i,method:"POST"},t)}DownloadUserProfile(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/user_profile/download_user_profile"),n={Cookie:i.Cookie};return this.request({url:o,method:"POST",headers:n},t)}GetProjectPublishedConnector(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/publish/get_published_connector"),n={project_id:i.project_id};return this.request({url:o,method:"POST",data:n},t)}PublishIntelligenceUnList(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/publish/publish_intelligence_unlist"),n={intelligence_id:i.intelligence_id,connector_ids:i.connector_ids,intelligence_type:i.intelligence_type};return this.request({url:o,method:"POST",data:n},t)}PublishIntelligenceList(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/search/get_publish_intelligence_list"),n={intelligence_type:i.intelligence_type,space_id:i.space_id,owner_id:i.owner_id,name:i.name,order_last_publish_time:i.order_last_publish_time,order_total_token:i.order_total_token,size:i.size,cursor_id:i.cursor_id,intelligence_ids:i.intelligence_ids};return this.request({url:o,method:"POST",data:n},t)}UpdateDiffModeInfo(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/diff_mode/update_diff_mode_info"),n={target_type:i.target_type,target_id:i.target_id,diff_mode_info:i.diff_mode_info,exit_and_save:i.exit_and_save,exit_and_discard:i.exit_and_discard};return this.request({url:o,method:"POST",data:n},t)}GetDiffModeInfo(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/diff_mode/get_diff_mode_info"),n={target_type:i.target_type,target_id:i.target_id};return this.request({url:o,method:"POST",data:n},t)}GetProjectPublishSummary(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/search/get_project_publish_summary"),n={project_id:i.project_id};return this.request({url:o,method:"POST",data:n},t)}DraftProjectCrossSpaceCopy(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/draft_project/crossspace_copy"),n={project_id:i.project_id,to_space_id:i.to_space_id};return this.request({url:o,method:"POST",data:n},t)}EntityTaskList(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/entity_task/list"),n={space_id:i.space_id,task_id_list:i.task_id_list};return this.request({url:o,method:"POST",data:n},t)}ExpansionTpm(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/expansion_tpm"),n={model_id:i.model_id,enterprise_id:i.enterprise_id,organization_id:i.organization_id,tpm_input_expansion:i.tpm_input_expansion,tpm_output_expansion:i.tpm_output_expansion,start_time:i.start_time,end_time:i.end_time};return this.request({url:o,method:"POST",data:n},t)}GetEstimatedTpmExpansionCost(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/get_estimated_tpm_expansion_cost"),n={model_id:i.model_id,enterprise_id:i.enterprise_id,input_tpm:i.input_tpm,output_tpm:i.output_tpm};return this.request({url:o,method:"POST",data:n},t)}GetEstimatedTpmExpansion(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/get_estimated_tpm_expansion"),n={model_id:i.model_id,enterprise_id:i.enterprise_id,estimated_rpm:i.estimated_rpm,StartTime:i.StartTime,EndTime:i.EndTime};return this.request({url:o,method:"POST",data:n},t)}FolderUpdate(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/folder/update"),n={folder_id:i.folder_id,name:i.name,description:i.description};return this.request({url:o,method:"POST",data:n},t)}GetFolderList(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/search/get_folder_list"),n={space_id:i.space_id,type:i.type,name:i.name,search_scope:i.search_scope,parent_folder_id:i.parent_folder_id,parent_include_children:i.parent_include_children,order_by:i.order_by,order_type:i.order_type,size:i.size,page_num:i.page_num};return this.request({url:o,method:"POST",data:n},t)}FolderMove(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/folder/move"),n={folder_id:i.folder_id,parent_folder_id:i.parent_folder_id};return this.request({url:o,method:"POST",data:n},t)}FolderDelete(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/folder/delete"),n={folder_id:i.folder_id};return this.request({url:o,method:"POST",data:n},t)}FolderCreate(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/folder/create"),n={space_id:i.space_id,type:i.type,name:i.name,description:i.description,parent_folder_id:i.parent_folder_id};return this.request({url:o,method:"POST",data:n},t)}ArchiveProject(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/draft_project/archive"),n={project_id:i.project_id,description:i.description,scene:i.scene};return this.request({url:o,method:"POST",data:n},t)}GetIntelligenceTaskInfo(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/entity_task/task_info"),n={task_id:i.task_id};return this.request({url:o,method:"GET",params:n},t)}ProjectHistoryList(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/draft_project/history_list"),n={project_id:i.project_id,history_type:i.history_type,cursor:i.cursor,size:i.size};return this.request({url:o,method:"POST",data:n},t)}RollbackProject(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/draft_project/rollback"),n={project_id:i.project_id,rollback_version:i.rollback_version,scene:i.scene};return this.request({url:o,method:"POST",data:n},t)}GetModelConcurrencyPerformanceData(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/get_model_concurrency_performance_data"),n={space_id:i.space_id,model_id:i.model_id};return this.request({url:o,method:"POST",data:n},t)}UpdateModelConfigType(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/update_model_config_type"),n={space_id:i.space_id,model_id:i.model_id,config_type:i.config_type};return this.request({url:o,method:"POST",data:n},t)}GetSpaceModelUserConfig(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/get_space_model_user_config"),n={space_id:i.space_id};return this.request({url:o,method:"POST",data:n},t)}OpenGetProjectList(e,t){const i=e||{},o=this.genBaseURL("/v1/apps"),n={workspace_id:i.workspace_id,publish_status:i.publish_status,connector_id:i.connector_id,page_num:i.page_num,page_size:i.page_size};return this.request({url:o,method:"GET",params:n},t)}OpenGetBotList(e,t){const i=e||{},o=this.genBaseURL("/v1/bots"),n={workspace_id:i.workspace_id,publish_status:i.publish_status,connector_id:i.connector_id,page_num:i.page_num,page_size:i.page_size};return this.request({url:o,method:"GET",params:n},t)}GetFolderTree(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/folder/tree"),n={space_id:i.space_id,type:i.type};return this.request({url:o,method:"POST",data:n},t)}OpenGetSpaceFolder(e,t){const i=e||{},o=this.genBaseURL("/v1/folders"),n={workspace_id:i.workspace_id,folder_type:i.folder_type,parent_folder_id:i.parent_folder_id,page_num:i.page_num,page_size:i.page_size};return this.request({url:o,method:"GET",params:n},t)}MoveObjectToFolder(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/folder/move_object"),n={dest_folder_id:i.dest_folder_id,folder_space_id:i.folder_space_id,move_objects:i.move_objects};return this.request({url:o,method:"POST",data:n},t)}GetFolderInfoByIds(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/folder/get_by_ids"),n={space_id:i.space_id,folder_ids:i.folder_ids,get_path_info:i.get_path_info};return this.request({url:o,method:"POST",data:n},t)}OpenGetFolderInfo(e,t){const i=e||{},o=this.genBaseURL(`/v1/folders/${i.folder_id}`);return this.request({url:o,method:"GET"},t)}ExportPreCheck(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/export_pre_check"),n={res_type:i.res_type,id:i.id,commit_id:i.commit_id};return this.request({url:o,method:"POST",data:n},t)}ImportPreCheck(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/import_pre_check"),n={package_uri:i.package_uri};return this.request({url:o,method:"POST",data:n},t)}GetUploadAuthToken(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/upload/auth_token"),n={scene:i.scene};return this.request({url:o,method:"POST",data:n},t)}MarkProjectHistory(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/draft_project/history_list/read"),n={project_id:i.project_id,version:i.version};return this.request({url:o,method:"POST",data:n},t)}GetCustomModelDetail(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/model/get_custom_model_detail"),n={model_id:i.model_id,org_id:i.org_id};return this.request({url:o,method:"POST",data:n},t)}GetCustomModelList(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/model/get_custom_model_list"),n={search_key:i.search_key,sort_field:i.sort_field,org_id:i.org_id,page:i.page,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}GetProjectHistoryNotice(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/draft_project/history_list/notice"),n={project_id:i.project_id};return this.request({url:o,method:"POST",data:n},t)}BindCustomModelSpace(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/model/bind_custom_model_space"),n={model_id:i.model_id,space_id_list:i.space_id_list,status:i.status,org_id:i.org_id};return this.request({url:o,method:"POST",data:n},t)}GetCustomModelSpaceList(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/model/get_custom_model_space_list"),n={model_id:i.model_id,search_key:i.search_key,org_id:i.org_id,cursor_id:i.cursor_id,limit:i.limit,enterprise_id:i.enterprise_id};return this.request({url:o,method:"POST",data:n},t)}GetCustomModelParameterTemplate(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/model/get_custom_model_parameter_template"),n={org_id:i.org_id};return this.request({url:o,method:"POST",data:n},t)}OpenCopyTaskInfo(e,t){const i=e||{},o=this.genBaseURL(`/v1/entities/copy_tasks/${i.task_id}`);return this.request({url:o,method:"GET"},t)}OpenDuplicateDraftEntity(e,t){const i=e||{},o=this.genBaseURL("/v1/entities/copy_tasks"),n={entity_id:i.entity_id,entity_type:i.entity_type,to_workspace_id:i.to_workspace_id};return this.request({url:o,method:"POST",data:n},t)}ConvertCustomModelParameter(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/model/convert_custom_model_parameter"),n={parameters:i.parameters,org_id:i.org_id};return this.request({url:o,method:"POST",data:n},t)}CreateCustomModel(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/model/create_custom_model"),n={model_name:i.model_name,model_icon_uri:i.model_icon_uri,model_arch:i.model_arch,model_desc:i.model_desc,base_url:i.base_url,secret_name:i.secret_name,model_runtime_tag:i.model_runtime_tag,inputLength:i.inputLength,parameters:i.parameters,api_agreement:i.api_agreement,safety_guardrails:i.safety_guardrails,auth:i.auth,api_mode:i.api_mode,org_id:i.org_id};return this.request({url:o,method:"POST",data:n},t)}TerminateCustomModel(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/model/terminate_custom_model"),n={model_id:i.model_id,terminate_time:i.terminate_time,org_id:i.org_id};return this.request({url:o,method:"POST",data:n},t)}UpdateCustomModel(e,t){const i=e,o=this.genBaseURL("/api/intelligence_api/model/update_custom_model"),n={model_name:i.model_name,model_icon_uri:i.model_icon_uri,model_arch:i.model_arch,model_desc:i.model_desc,base_url:i.base_url,secret_name:i.secret_name,model_runtime_tag:i.model_runtime_tag,inputLength:i.inputLength,parameters:i.parameters,model_id:i.model_id,api_agreement:i.api_agreement,safety_guardrails:i.safety_guardrails,auth:i.auth,api_mode:i.api_mode,org_id:i.org_id};return this.request({url:o,method:"POST",data:n},t)}GetModelUsageRecord(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/get_model_usage_record"),n={space_id:i.space_id,model_id:i.model_id,start_timestamp:i.start_timestamp,end_timestamp:i.end_timestamp,order_by_type:i.order_by_type,order_by_field:i.order_by_field,page:i.page,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}GetEntityModelUsage(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/get_entity_model_usage"),n={space_id:i.space_id,model_id:i.model_id,entity_id:i.entity_id,entity_type:i.entity_type,start_timestamp:i.start_timestamp,end_timestamp:i.end_timestamp};return this.request({url:o,method:"POST",data:n},t)}GetTypeList(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/get_type_list"),n={model:i.model,voice:i.voice,raw_model:i.raw_model,space_id:i.space_id,cur_model_id:i.cur_model_id,cur_model_ids:i.cur_model_ids,model_scene:i.model_scene,tag_filters:i.tag_filters,user_benefit_filter:i.user_benefit_filter};return this.request({url:o,method:"POST",data:n},t)}SaveModelReplacement(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/save_replacement"),n={space_id:i.space_id,old_model_id:i.old_model_id,new_model_id:i.new_model_id,start_timestamp:i.start_timestamp,end_timestamp:i.end_timestamp};return this.request({url:o,method:"POST",data:n},t)}GetModelReplacement(e,t){const i=e||{},o=this.genBaseURL("/api/intelligence_api/model/get_replacement"),n={space_id:i.space_id,entity_type:i.entity_type,entity_id:i.entity_id};return this.request({url:o,method:"POST",data:n},t)}}const pd=new dd({}),ld={agent:pc.VibeProjectAgent,workflow:pc.VibeProjectAutomation,webapp:pc.VibeProjectWebApp,app:pc.VibeProjectApp,skill:pc.VibeProjectSkill,web:pc.VibeProjectGeneralWeb,miniprogram:pc.VibeProjectWechatMiniProgram,assistant:pc.VibeProjectAssistantAgent},ud={[pc.VibeProjectAgent]:"agent",[pc.VibeProjectAutomation]:"workflow",[pc.VibeProjectWebApp]:"webapp",[pc.VibeProjectApp]:"app",[pc.VibeProjectSkill]:"skill",[pc.VibeProjectGeneralWeb]:"web",[pc.VibeProjectWechatMiniProgram]:"miniprogram",[pc.VibeProjectAssistantAgent]:"assistant"};function _d(e){if(!e)return;const t=String(e).trim();if(!t)return;const i=t.toLowerCase();return ld[i]}const md=e=>ud[e],gd=[pc.VibeProjectAgent,pc.VibeProjectAutomation,pc.VibeProjectWebApp,pc.VibeProjectApp,pc.VibeProjectSkill,pc.VibeProjectGeneralWeb,pc.VibeProjectWechatMiniProgram,pc.VibeProjectAssistantAgent].map(md).filter(Boolean);function hd(e,t){return null!=e?e:t()}function fd(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const yd={agent:e.VibeProjectType.Agent,workflow:e.VibeProjectType.Automation,webapp:e.VibeProjectType.WebApp,app:e.VibeProjectType.App,skill:e.VibeProjectType.Skill,web:e.VibeProjectType.GeneralWeb,miniprogram:e.VibeProjectType.WechatMiniProgram,assistant:e.VibeProjectType.AssistantAgent},vd={[e.VibeProjectType.Agent]:"agent",[e.VibeProjectType.Automation]:"workflow",[e.VibeProjectType.WebApp]:"webapp",[e.VibeProjectType.App]:"app",[e.VibeProjectType.Skill]:"skill",[e.VibeProjectType.GeneralWeb]:"web",[e.VibeProjectType.WechatMiniProgram]:"miniprogram",[e.VibeProjectType.AssistantAgent]:"assistant"};const bd=e=>vd[e],Pd=[e.VibeProjectType.GeneralWeb,e.VibeProjectType.App],Sd=Pd.map(bd);function Td(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function Cd(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}class kd{static getInstance(){return kd.INSTANCE||(kd.INSTANCE=new kd),kd.INSTANCE}sendMessageRunTask(e){const t=[p.resolve(__dirname,"./send-message.worker.js")],i=process.execPath;h.spawn(i,[...t,JSON.stringify(e)],{detached:!0,stdio:"ignore"}).unref()}async sendMessage(t){return await e.sendProjectChatMessage(t)}isValidType(e){return Pd.includes(e)}}const Ad=kd.getInstance();function Ed(e,t){return null!=e?e:t()}function Rd(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function jd(t){t.command("create").description("Create a new project").requiredOption("--message <message>","Description/requirements for creating the project").requiredOption("--type <type>","Project type: agent | workflow | app | skill | web | miniprogram | assistant").option("--org-id <orgId>","Organization ID (optional, will read from context automatically)").option("--space-id <spaceId>","Space ID (optional, will read from context automatically)").option("--wait","Wait for project creation to complete").config({help:{brief:"Create a new Coze Coding project",description:"Create a new Coze Coding project via natural language description. The system will automatically generate project structure and configuration based on the description, supporting multiple project types.",examples:[{desc:"Create an Agent project",cmd:'coze code project create --message "Create an intelligent customer service robot" --type agent',tags:["[RECOMMENDED]"]},{desc:"Create a Workflow project",cmd:'coze code project create --message "Create a data processing workflow" --type workflow'}],schema:{input:{message:{type:"string",required:!0,description:"Project description/requirements (natural language)"},type:{type:"string",required:!0,enum:Sd,description:"Project type"},spaceId:{type:"string",required:!1,description:"Space ID (optional, reads from context)"}},output:{project_id:{type:"string",description:"Created project ID"},type:{type:"string",description:"Project type"}}},enums:{type:Sd.reduce(((e,t)=>(e[t]=`${t.toUpperCase()} project`,e)),{})},errors:[{code:e.ErrorCode.E1005,name:"INVALID_PROJECT_TYPE",desc:"Invalid project type",fix:"Please use a valid project type: agent | workflow | app | skill | web | miniprogram | assistant"},{code:e.ErrorCode.E1003,name:"MISSING_SPACE_ID",desc:"Missing Space ID",fix:"Please use the --space-id parameter or run `coze space use <spaceId>` first"},{code:e.ErrorCode.E1006,name:"UNSUPPORTED_PROJECT_TYPE",desc:"Project type is not supported for creation",fix:"Please choose a supported project type and try again"},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid API token",fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable",example:"coze auth login --oauth"},{code:e.ErrorCode.E5000,name:"UNEXPECTED_ERROR",desc:"CLI context is not initialized or project tool config is missing",fix:"Please retry and run with --debug if the issue persists"}]}}).action((async(t,i)=>{const o=i.getContext();if(!o)throw new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized");const n=Ed(Ed(t.spaceId,(()=>Rd([o,"optionalAccess",e=>e.config,"access",e=>e.spaceId]))),(()=>"")),{message:s,type:r,wait:a}=t;Rd([o,"optionalAccess",e=>e.log,"access",e=>e.debug,"call",e=>e(`Resolving project type '${r}'...`)]);const c=function(e){if(!e)return;const t=String(e).trim();if(!t)return;const i=t.toLowerCase();return yd[i]}(r);if(!n)throw new e.CozeError(e.ErrorCode.E1003,"Missing space_id: pass --space-id or coze space use <spaceId>");if(!c)throw new e.CozeError(e.ErrorCode.E1005,`Unknown project type: ${r}`,{type:r});if(!Ad.isValidType(c))throw new e.CozeError(e.ErrorCode.E1006,`Project type ${r} is not supported for creation`,{type:r,projectType:c});Rd([o,"optionalAccess",e=>e.log,"access",e=>e.debug,"call",e=>e("Fetching agent tools configuration...")]);const d=Rd([await e.BuildAgentApi.GetTools(),"access",e=>e.project_types,"optionalAccess",e=>e.find,"call",e=>e((e=>e.project_type===c)),"optionalAccess",e=>e.tools]);if(!d||0===d.length)throw new e.CozeError(e.ErrorCode.E5000,`No tools config for projectType: ${String(r)}`,{type:r,projectType:c});const p={};d.forEach((e=>{Rd([e,"optionalAccess",e=>e.name])&&(p[e.name]=Boolean(e.enabled))})),Rd([o,"optionalAccess",e=>e.log,"access",e=>e.debug,"call",e=>e("Fetching project default skills...")]);const l={skills:Ed(Rd([await Dr.GetProjectDefaultSkill({project_type:c,space_id:String(n)}),"access",e=>e.data,"optionalAccess",e=>e.skill_list]),(()=>[])).map((e=>({skill_id:e.skill_id,is_preload:e.is_preload}))),filter_types:[c]},u={space_id:String(n),user_query:s,project_type:c,agent_tools:p,project_settings:{model_setting:{model_name:""},skill_setting:l}};Rd([o,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Creating project...")]);const _=Ed((await e.IdeApi.ChatCreateVibeProject(u)).data,(()=>({}))).project_id,m=await Rd([o,"optionalAccess",e=>e.auth,"optionalAccess",e=>e.getValidAccessToken,"call",e=>e()]);if(!m)throw new e.CozeError(e.ErrorCode.E2001,"Missing API token: set env COZE_API_TOKEN or run `coze auth login` first");if(o.ui.success('Project created successfully, please use "coze code message status" to check the status.'),Rd([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({project_id:_,type:r})]),a){const e=await Ad.sendMessage({projectId:Ed(_,(()=>"")),prompt:s,apiBaseUrl:o.config.apiBaseUrl,accessToken:m,xTTEnv:o.config.xTTEnv,key:`coze-coding-cli:message:${_}`});o.response.print(e.lastAnswerMessage)}else Ad.sendMessageRunTask({projectId:Ed(_,(()=>"")),prompt:s,apiBaseUrl:o.config.apiBaseUrl,accessToken:m,xTTEnv:o.config.xTTEnv,key:`coze-coding-cli:message:${_}`})}))}const zd=t=>{const i=t.command("project").alias("proj").config({help:{brief:"Manage Coze Coding projects",description:"Manage Coze Coding projects (Vibe Project). Supports creating, viewing, listing, and deleting projects, covering various project types like Agent, Workflow, Skill, Web apps, Mini-programs, etc.",examples:[{desc:"Create project",cmd:'coze code project create --message "Create a chatbot" --type web'},{desc:"List projects",cmd:"coze code project list"},{desc:"View project details",cmd:"coze code project get <projectId>"},{desc:"Delete project",cmd:"coze code project delete <projectId>"}],seeAlso:["coze code deploy","coze code skill"],schema:{input:{},output:{}},errors:[{code:e.ErrorCode.E3001,name:"PROJECT_NOT_FOUND",desc:"Project not found",fix:"Please confirm if the project ID is correct"}]}}).description("Manage Coze Coding projects");jd(i),function(t){t.command("list").description("List all projects").config({help:{brief:"List all projects in the current space",description:"Get the list of projects in the current space. Supports filtering by type, name, publish status, and supports pagination.",examples:[{desc:"List projects",cmd:"coze code project list",tags:["[RECOMMENDED]"]},{desc:"Filter by type",cmd:"coze code project list --type agent --type workflow"},{desc:"Search by name",cmd:'coze code project list --name "customer service"'}],schema:{input:{size:{type:"number",required:!1,description:"Number of projects to return (default: 10)"},cursorId:{type:"string",required:!1,description:"Cursor for pagination"},type:{type:"array",required:!1,description:"Project type filter (can be passed multiple times)"},name:{type:"string",required:!1,description:"Filter by project name"},hasPublished:{type:"boolean",required:!1,description:"Filter by publish status"},searchScope:{type:"number",required:!1,description:"Created by (All = 0, CreateByMe = 1)"},folderId:{type:"string",required:!1,description:"Folder ID"},orderType:{type:"number",required:!1,description:"Sort type (0 for descending, 1 for ascending)"},isFavFilter:{type:"boolean",required:!1,description:"Filter by favorite status"}},output:{type:"array",items:{type:"object",properties:{id:{type:"string",description:"Project ID"},name:{type:"string",description:"Project name"},type:{type:"string",description:"Project type"},description:{type:"string",description:"Project description"}}}}},errors:[{code:e.ErrorCode.E1003,name:"MISSING_SPACE_ID",desc:"Space ID is required",fix:"Please use --space-id <spaceId> or run `coze space use <spaceId>` first"}],enums:{type:gd.reduce(((e,t)=>(e[t]=`${t.toUpperCase()} project`,e)),{}),"search-scope":{0:"All",1:"CreateByMe"},"order-type":{0:"Descending",1:"Ascending"},"order-by":{0:"updated_at",1:"created_at"}}}}).option("--size <size>","Number of projects to return",parseInt).option("--cursor-id <cursorId>","Cursor for pagination").option("--type <type>","Project type filter (can be passed multiple times): agent | workflow | webapp | app | web | miniprogram | assistant",((e,t=[])=>[...t,e]),[]).option("--name <name>","Filter by project name").option("--has-published","Filter by publish status").option("--search-scope <searchScope>","Created by (All = 0, CreateByMe = 1, AllWithCollaborator = 2)").option("--folder-id <folderId>","Folder ID").option("--order-type <orderType>","Sort type (0 for descending, 1 for ascending)").option("--order-by <orderBy>","Order by (0 for updated_at, 1 for created_at)").option("--is-fav-filter","Filter by favorite status (true | false)").action((async function(e,t){const i=t.getContext(),o=hd(fd([e,"optionalAccess",e=>e.size]),(()=>10)),n=hd(fd([e,"optionalAccess",e=>e.cursorId]),(()=>{})),s=fd([e,"optionalAccess",e=>e.type,"optionalAccess",e=>e.map,"call",e=>e(_d),"access",e=>e.filter,"call",e=>e(Boolean)]),r=fd([e,"optionalAccess",e=>e.name]),a=fd([e,"optionalAccess",e=>e.hasPublished])?Boolean(fd([e,"optionalAccess",e=>e.hasPublished])):void 0,c=Number(hd(fd([e,"optionalAccess",e=>e.searchScope]),(()=>ed.All))),d=hd(fd([e,"optionalAccess",e=>e.folderId]),(()=>"0")),p=Number(hd(fd([e,"optionalAccess",e=>e.orderType]),(()=>td.Desc))),l=Boolean(fd([e,"optionalAccess",e=>e.isFavFilter])),u=Number(hd(fd([e,"optionalAccess",e=>e.orderBy]),(()=>Yc.UpdateTime)));let _=[];fd([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Fetching project list...")]);const m=await pd.GetDraftIntelligenceList({space_id:hd(fd([i,"optionalAccess",e=>e.config,"access",e=>e.spaceId]),(()=>"")),size:o,cursor_id:n,types:s,name:r,has_published:a,search_scope:c,folder_id:d,order_type:p,order_by:u,is_fav_filter:l,status:[dc.Using,dc.Banned,dc.MoveFailed]});_=fd([m,"access",e=>e.data,"optionalAccess",e=>e.intelligences])||[],fd([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Fetched ${_.length} projects.`)]),fd([i,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(_.map((e=>({id:fd([e,"access",e=>e.basic_info,"optionalAccess",e=>e.id]),name:fd([e,"access",e=>e.basic_info,"optionalAccess",e=>e.name]),type:md(e.type),description:fd([e,"access",e=>e.basic_info,"optionalAccess",e=>e.description])}))))])}))}(i),function(t){t.command("get <projectId>").description("View project details").config({help:{brief:"Get project details",description:"Get the detailed configuration of the specified project, including project type, settings, skill configurations, etc.",examples:[{desc:"View project details",cmd:"coze code project get <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"}},output:{project_id:{type:"string",description:"Project ID"},project_name:{type:"string",description:"Project name"},project_type:{type:"string",description:"Project type"},skills:{type:"object",description:"Project skill configurations",properties:{skills:{type:"array",items:{type:"object",properties:{skill_id:{type:"string",description:"Skill ID"},is_preload:{type:"boolean",description:"Is preloaded"}}}}}}}},errors:[{code:e.ErrorCode.E3001,name:"PROJECT_NOT_FOUND",desc:"Project does not exist",fix:"Please confirm if the project ID is correct, use `project list` to view available projects"}]}}).action((async function(t,i,o){const n=o.getContext();Td([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Fetching project details for '${t}'...`)]);const s=Td([await e.IdeApi.GetVibeProject({project_id:t}),"access",e=>e.data,"optionalAccess",e=>e.project_info]);if(!s)throw new e.CozeError(e.ErrorCode.E3001,`Project ${t} not found`,{projectId:t});Td([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Project details for '${t}':`)]),Td([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({...g.omit(s,["project_settings"]),skills:g.pick(Td([s,"optionalAccess",e=>e.project_settings,"optionalAccess",e=>e.skill_setting]),["skills"]),project_type:bd(Td([s,"optionalAccess",e=>e.project_type]))})])}))}(i),function(t){t.command("delete <projectId>").description("Delete a project").config({help:{brief:"Delete project",description:"Delete the specified Coze Coding project. This operation cannot be undone, please use with caution.",examples:[{desc:"Delete project",cmd:"coze code project delete <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID to delete"}},output:{project_id:{type:"string",description:"Deleted project ID"},message:{type:"string",description:"Result message"}}},errors:[{code:e.ErrorCode.E3005,name:"DELETE_FAILED",desc:"Failed to delete project",fix:"Please confirm if the project ID is correct and check if you have sufficient permissions"}]}}).action((async function(t,i,o){const n=o.getContext();Cd([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Deleting project '${t}'...`)]),await e.IdeApi.DeleteVibeProject({project_id:t}),Cd([n,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e(`Project '${t}' deleted successfully.`)]),Cd([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({project_id:t,message:`Project '${t}' deleted successfully.`})])}))}(i)};var wd,Ud,Ld,Od,Id,Bd,qd,xd,Dd,Md,Gd,Nd,Fd,$d,Vd,Wd,Hd,Kd,Jd,Qd,Zd,Yd,Xd,ep,tp,ip,op,np,sp,rp,ap,cp,dp,pp,lp,up,_p,mp,gp,hp,fp,yp,vp,bp,Pp,Sp,Tp,Cp,kp,Ap,Ep,Rp,jp,zp,wp,Up,Lp,Op,Ip,Bp,qp,xp,Dp,Mp,Gp,Np;function Fp(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}!function(e){e[e.Example=0]="Example";e[e.Template=1]="Template"}(wd||(wd={})),function(e){e[e.SpaceEvent=1]="SpaceEvent"}(Ud||(Ud={})),function(e){e[e.Interest=1]="Interest"}(Ld||(Ld={})),function(e){e[e.General=0]="General";e[e.PPT=1]="PPT";e[e.Podcast=2]="Podcast";e[e.WEB=3]="WEB";e[e.ImageDoc=4]="ImageDoc";e[e.Poster=5]="Poster";e[e.Excel=6]="Excel";e[e.DesignTemplate=7]="DesignTemplate";e[e.PPTTemplate=8]="PPTTemplate";e[e.Chart=9]="Chart";e[e.Video=10]="Video";e[e.ImagePPTTemplate=11]="ImagePPTTemplate";e[e.VideoTemplate=12]="VideoTemplate"}(Od||(Od={})),function(e){e[e.Chat=1]="Chat";e[e.Fill=2]="Fill"}(Id||(Id={})),function(e){e[e.Delete=0]="Delete";e[e.Running=1]="Running";e[e.Pause=2]="Pause";e[e.TaskFinish=3]="TaskFinish";e[e.Init=4]="Init";e[e.Stop=5]="Stop";e[e.Interrupt=6]="Interrupt";e[e.IllegalContent=7]="IllegalContent";e[e.AbnormalInterrupt=8]="AbnormalInterrupt";e[e.Sleep=9]="Sleep"}(Bd||(Bd={})),function(e){e[e.Favorite=1]="Favorite";e[e.Template=2]="Template";e[e.TemplateCover=3]="TemplateCover";e[e.PlanTemplate=4]="PlanTemplate";e[e.Article=5]="Article"}(qd||(qd={})),function(e){e[e.General=0]="General";e[e.Product=1]="Product"}(xd||(xd={})),function(e){e[e.Unknown=0]="Unknown";e[e.Pending=1]="Pending";e[e.Running=2]="Running";e[e.Completed=3]="Completed";e[e.Failed=4]="Failed";e[e.Cancelled=5]="Cancelled"}(Dd||(Dd={})),function(e){e[e.HandsOff=0]="HandsOff";e[e.Cooperative=1]="Cooperative";e[e.Auto=2]="Auto"}(Md||(Md={})),function(e){e[e.Modify=1]="Modify";e[e.Clear=2]="Clear";e[e.RemoveBackground=3]="RemoveBackground";e[e.Inpainting=4]="Inpainting";e[e.TextReplacement=5]="TextReplacement"}(Gd||(Gd={})),function(e){e[e.Unactivated=1]="Unactivated";e[e.Activated=2]="Activated"}(Nd||(Nd={})),function(e){e[e.hot_city=1]="hot_city";e[e.city=2]="city"}(Fd||(Fd={})),function(e){e[e.PDF=1]="PDF";e[e.PPT=2]="PPT";e[e.ImageEditablePpt=3]="ImageEditablePpt"}($d||($d={})),function(e){e[e.Chinese=0]="Chinese";e[e.English=1]="English"}(Vd||(Vd={})),function(e){e[e.Review=1]="Review";e[e.Draft=2]="Draft";e[e.LawQA=3]="LawQA"}(Wd||(Wd={})),function(e){e[e.Pin=1]="Pin";e[e.UnPin=2]="UnPin";e[e.Use=3]="Use"}(Hd||(Hd={})),function(e){e[e.Init=1]="Init";e[e.Stock=2]="Stock";e[e.Sector=3]="Sector"}(Kd||(Kd={})),function(e){e[e.GeneralChat=1]="GeneralChat";e[e.Scheduled=2]="Scheduled"}(Jd||(Jd={})),function(e){e[e.FieldAnalysis=1]="FieldAnalysis";e[e.Upload=2]="Upload"}(Qd||(Qd={})),function(e){e[e.Running=1]="Running";e[e.Pause=2]="Pause";e[e.TaskFinish=3]="TaskFinish";e[e.Init=4]="Init";e[e.Stop=5]="Stop";e[e.Interrupt=6]="Interrupt";e[e.IllegalContent=7]="IllegalContent";e[e.AbnormalInterrupt=8]="AbnormalInterrupt";e[e.Sleep=9]="Sleep"}(Zd||(Zd={})),function(e){e[e.UNKNOWN=0]="UNKNOWN";e[e.HTML=1]="HTML";e[e.WORD=2]="WORD";e[e.PPT=3]="PPT";e[e.EXCEL=4]="EXCEL";e[e.PDF=5]="PDF";e[e.NOTE=6]="NOTE";e[e.IMAGE=7]="IMAGE";e[e.PODCAST=8]="PODCAST"}(Yd||(Yd={})),function(e){e[e.FavoritePage=1]="FavoritePage";e[e.TASK=2]="TASK"}(Xd||(Xd={})),function(e){e[e.UserUpload=1]="UserUpload";e[e.Explore=2]="Explore";e[e.TASK=3]="TASK"}(ep||(ep={})),function(e){e[e.PPT=1]="PPT"}(tp||(tp={})),function(e){e[e.Favorite=1]="Favorite";e[e.MultiDocImage=2]="MultiDocImage"}(ip||(ip={})),function(e){e[e.Upload=1]="Upload";e[e.Search=2]="Search";e[e.Generate=3]="Generate"}(op||(op={})),function(e){e[e.PNG=1]="PNG";e[e.JPG=2]="JPG";e[e.MP4=3]="MP4"}(np||(np={})),function(e){e[e.Modify=1]="Modify";e[e.Clear=2]="Clear";e[e.RemoveBackground=3]="RemoveBackground";e[e.Generate=4]="Generate";e[e.Search=5]="Search";e[e.Blur=6]="Blur"}(sp||(sp={})),function(e){e[e.Image=1]="Image";e[e.Html=2]="Html";e[e.Livephoto=3]="Livephoto"}(rp||(rp={})),function(e){e[e.Chat=1]="Chat";e[e.ApiTemplate=2]="ApiTemplate"}(ap||(ap={})),function(e){e[e.Suggest=1]="Suggest"}(cp||(cp={})),function(e){e[e.Unknown=0]="Unknown";e[e.Clarifying=1]="Clarifying";e[e.PendingActivation=2]="PendingActivation";e[e.Running=3]="Running";e[e.PendingConfirm=4]="PendingConfirm";e[e.Terminated=5]="Terminated"}(dp||(dp={})),function(e){e[e.Unknown=0]="Unknown";e[e.SystemError=1]="SystemError";e[e.InsufficientBalance=2]="InsufficientBalance";e[e.UserManual=3]="UserManual";e[e.Timeout=4]="Timeout"}(pp||(pp={})),function(e){e[e.DiggTypeDigg=1]="DiggTypeDigg";e[e.DiggTypeBury=2]="DiggTypeBury"}(lp||(lp={})),function(e){e[e.Query=1]="Query";e[e.Answer=2]="Answer";e[e.Resume=3]="Resume"}(up||(up={})),function(e){e[e.Unknown=0]="Unknown";e[e.ActivatePlan=1]="ActivatePlan";e[e.ResumePlan=2]="ResumePlan"}(_p||(_p={})),function(e){e[e.DocMultiImage=1]="DocMultiImage"}(mp||(mp={})),function(e){e[e.PDF=1]="PDF";e[e.DOCX=2]="DOCX"}(gp||(gp={})),function(e){e[e.DeleteCookie=1]="DeleteCookie"}(hp||(hp={})),function(e){e[e.POSITION=0]="POSITION";e[e.ELEMENT=1]="ELEMENT"}(fp||(fp={})),function(e){e[e.DiamondMatrix=1]="DiamondMatrix";e[e.BulletPoints=2]="BulletPoints";e[e.StaggeredProcessDiagram=3]="StaggeredProcessDiagram";e[e.ArrowRingDiagram=4]="ArrowRingDiagram";e[e.VerticalTimeline=5]="VerticalTimeline"}(yp||(yp={})),function(e){e[e.Init=1]="Init";e[e.Enabled=2]="Enabled";e[e.Disabled=3]="Disabled"}(vp||(vp={})),function(e){e[e.Pending=1]="Pending";e[e.Success=2]="Success";e[e.Avoid=3]="Avoid";e[e.Failed=4]="Failed"}(bp||(bp={})),function(e){e[e.Authorized=1]="Authorized";e[e.UnAuthorized=2]="UnAuthorized";e[e.Expired=3]="Expired"}(Pp||(Pp={})),function(e){e[e.Query=1]="Query";e[e.Template=2]="Template"}(Sp||(Sp={})),function(e){e[e.Pause=1]="Pause";e[e.Resume=2]="Resume";e[e.Pin=3]="Pin";e[e.Unpin=4]="Unpin";e[e.DoNotDisturb=5]="DoNotDisturb";e[e.CancelDoNotDisturb=6]="CancelDoNotDisturb";e[e.Stop=7]="Stop";e[e.Read=8]="Read"}(Tp||(Tp={})),function(e){e[e.Init=0]="Init";e[e.Enable=1]="Enable";e[e.Disable=2]="Disable"}(Cp||(Cp={})),function(e){e[e.Open=1]="Open";e[e.Close=2]="Close"}(kp||(kp={})),function(e){e[e.Open=1]="Open";e[e.Close=2]="Close"}(Ap||(Ap={})),function(e){e[e.Online=1]="Online";e[e.Debug=2]="Debug"}(Ep||(Ep={})),function(e){e[e.UserCreate=0]="UserCreate";e[e.Example=1]="Example"}(Rp||(Rp={})),function(e){e[e.Init=0]="Init";e[e.List=1]="List";e[e.Unlist=2]="Unlist"}(jp||(jp={})),function(e){e[e.Good=1]="Good";e[e.Bad=2]="Bad"}(zp||(zp={})),function(e){e[e.RootUser=1]="RootUser";e[e.BasicUser=2]="BasicUser"}(wp||(wp={})),function(e){e[e.Pending=1]="Pending";e[e.Running=2]="Running";e[e.Success=3]="Success";e[e.Failed=4]="Failed";e[e.Cancel=5]="Cancel"}(Up||(Up={})),function(e){e[e.Video=1]="Video";e[e.Voice=2]="Voice";e[e.Music=3]="Music"}(Lp||(Lp={})),function(e){e[e.Update=1]="Update";e[e.UpdateAndAdd=2]="UpdateAndAdd";e[e.UpdateAndSync=3]="UpdateAndSync"}(Op||(Op={})),function(e){e[e.ChatQuery=1]="ChatQuery";e[e.VideoEdit=2]="VideoEdit"}(Ip||(Ip={})),function(e){e[e.Pin=1]="Pin";e[e.Unpin=2]="Unpin"}(Bp||(Bp={})),function(e){e[e.Valid=1]="Valid";e[e.Deleted=2]="Deleted"}(qp||(qp={})),function(e){e[e.Narration=1]="Narration";e[e.Music=2]="Music";e[e.Other=3]="Other"}(xp||(xp={})),function(e){e[e.Video=1]="Video";e[e.Image=2]="Image";e[e.Audio=3]="Audio";e[e.Combination=4]="Combination"}(Dp||(Dp={})),function(e){e[e.Local=1]="Local";e[e.AiGenerated=2]="AiGenerated";e[e.Asset=3]="Asset";e[e.Search=4]="Search"}(Mp||(Mp={})),function(e){e[e.Role=1]="Role";e[e.Item=2]="Item";e[e.Scene=3]="Scene";e[e.Other=4]="Other"}(Gp||(Gp={})),function(e){e[e.VoiceSelection=1]="VoiceSelection";e[e.VoiceDescription=2]="VoiceDescription";e[e.None=3]="None"}(Np||(Np={}));class $p{__init(){this.request=e.request}__init2(){this.baseURL=""}constructor(e){$p.prototype.__init.call(this),$p.prototype.__init2.call(this),this.request=Fp([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=Fp([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}CreateTaskReplay(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/create_task_replay"),n={task_id:i.task_id,need_qr_code:i.need_qr_code,file_list:i.file_list,doc_multi_img_zip_uri:i.doc_multi_img_zip_uri};return this.request({url:o,method:"POST",data:n},t)}GetTaskReplay(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_task_replay"),n={task_id:i.task_id};return this.request({url:o,method:"POST",data:n},t)}DeleteCozeSpaceTask(e,t){const i=e,o=this.genBaseURL("/api/coze_space/delete_task"),n={task_id:i.task_id};return this.request({url:o,method:"POST",data:n},t)}UpdateCozeSpaceTask(e,t){const i=e,o=this.genBaseURL("/api/coze_space/update_task"),n={task_id:i.task_id,task_name:i.task_name,mcp_tool_list:i.mcp_tool_list,expert_agent_config:i.expert_agent_config,scheduled_task_setting:i.scheduled_task_setting};return this.request({url:o,method:"POST",data:n},t)}CreateCozeSpaceTask(e,t){const i=e,o=this.genBaseURL("/api/coze_space/create_task"),n={task_name:i.task_name,task_type:i.task_type,file_uri_list:i.file_uri_list,mcp_tool_list:i.mcp_tool_list,agent_ids:i.agent_ids,scheduled_task_setting:i.scheduled_task_setting,source_from:i.source_from,is_debug:i.is_debug,expert_agent_config:i.expert_agent_config};return this.request({url:o,method:"POST",data:n},t)}CozeSpaceChat(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/chat"),n={task_id:i.task_id,query:i.query,files:i.files,mcp_list:i.mcp_list,chat_type:i.chat_type,pause_reason:i.pause_reason,task_run_mode:i.task_run_mode,expert_agent_run_config:i.expert_agent_run_config,scheduled_task_config:i.scheduled_task_config,disable_team_mode:i.disable_team_mode,resume_data:i.resume_data,ability_type:i.ability_type,all_authorized_mcp:i.all_authorized_mcp,reference_template_list:i.reference_template_list,agent_ids:i.agent_ids,router_control:i.router_control,favorites:i.favorites,extra_info:i.extra_info,reference_content:i.reference_content,guiding_id:i.guiding_id,skill_id_list:i.skill_id_list,is_skill_debug:i.is_skill_debug,thinking:i.thinking,reference_items:i.reference_items,plan_template_id:i.plan_template_id,action:i.action,assets:i.assets};return this.request({url:o,method:"POST",data:n},t)}PollStepList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/poll_step_list"),n={task_id:i.task_id,answer_id:i.answer_id,next_key:i.next_key};return this.request({url:o,method:"POST",data:n},t)}OperateTask(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/operate_task"),n={task_id:i.task_id,operate_type:i.operate_type,pause_reason:i.pause_reason,browser:i.browser,read_progress:i.read_progress,has_unread:i.has_unread};return this.request({url:o,method:"POST",data:n},t)}GetCozeSpaceTaskList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_task_list"),n={cursor:i.cursor,size:i.size,long_term:i.long_term};return this.request({url:o,method:"POST",data:n},t)}GetMessageList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_message_list"),n={task_id:i.task_id,cursor:i.cursor,size:i.size,asc_mode:i.asc_mode};return this.request({url:o,method:"POST",data:n},t)}UpdateTaskPlan(e,t){const i=e,o=this.genBaseURL("/api/coze_space/update_task_plan"),n={task_id:i.task_id,action_id:i.action_id,task_plan:i.task_plan};return this.request({url:o,method:"POST",data:n},t)}GetTaskReplayById(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_task_replay_by_id"),n={task_share_id:i.task_share_id,secret:i.secret};return this.request({url:o,method:"POST",data:n},t)}OperateTaskReplay(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/operate_task_replay"),n={task_id:i.task_id,task_share_id:i.task_share_id,operate_type:i.operate_type};return this.request({url:o,method:"POST",data:n},t)}UploadTaskFile(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/upload_task_file"),n={task_id:i.task_id,file_name:i.file_name,file_content:i.file_content};return this.request({url:o,method:"POST",data:n},t)}UploadUserResearchFile(e,t){const i=e,o=this.genBaseURL("/api/coze_space/upload_user_research_file"),n={task_id:i.task_id,action:i.action,file_type:i.file_type,file_name:i.file_name,file_content:i.file_content,desc:i.desc,fields:i.fields};return this.request({url:o,method:"POST",data:n},t)}LandingPageEmailSubscribe(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/landing_page/email_subscribe"),n={email:i.email};return this.request({url:o,method:"POST",data:n},t)}GetUrl(e,t){const i=e,o=this.genBaseURL("/api/coze_space/get_url"),n={uri:i.uri,expire_seconds:i.expire_seconds,is_short_url:i.is_short_url,uri_list:i.uri_list};return this.request({url:o,method:"POST",data:n},t)}LandingPage(e,t){const i=this.genBaseURL("/api/coze_space/landing_page");return this.request({url:i,method:"POST"},t)}ExpertProductDetails(e,t){const i=e,o=this.genBaseURL("/api/coze_space/expert_product_details"),n={agent_id:i.agent_id};return this.request({url:o,method:"POST",data:n},t)}Digg(e,t){const i=e,o=this.genBaseURL("/api/coze_space/digg"),n={agent_id:i.agent_id,action_type:i.action_type,is_cancel:i.is_cancel};return this.request({url:o,method:"POST",data:n},t)}SearchStock(e,t){const i=e,o=this.genBaseURL("/api/coze_space/search_stock"),n={search_type:i.search_type,stock_search_word:i.stock_search_word,sector_search_word:i.sector_search_word};return this.request({url:o,method:"POST",data:n},t)}Text2Image(e,t){const i=e,o=this.genBaseURL("/api/coze_space/text2image"),n={prompt:i.prompt,width:i.width,height:i.height};return this.request({url:o,method:"GET",params:n},t)}GetInviteInfo(e,t){const i=this.genBaseURL("/api/coze_space/get_invite_info");return this.request({url:i,method:"POST"},t)}CheckInviteCode(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/check_invite_code"),n={code:i.code};return this.request({url:o,method:"POST",data:n},t)}ExpertProductList(e,t){const i=this.genBaseURL("/api/coze_space/expert_product_list");return this.request({url:i,method:"POST"},t)}CheckInWaitList(e,t){const i=this.genBaseURL("/api/coze_space/check_in_wait_list");return this.request({url:i,method:"POST"},t)}JoinWaitList(e,t){const i=this.genBaseURL("/api/coze_space/join_wait_list");return this.request({url:i,method:"POST"},t)}GetSandboxToken(e,t){const i=e,o=this.genBaseURL("/api/coze_space/get_sandbox_token"),n={task_id:i.task_id,action_url_code:i.action_url_code};return this.request({url:o,method:"POST",data:n},t)}GetUserScheduledTasks(e,t){const i=this.genBaseURL("/api/coze_space/get_user_scheduled_tasks");return this.request({url:i,method:"POST"},t)}GenerateRelatedWords(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/generate_related_words"),n={original_word:i.original_word,describe:i.describe};return this.request({url:o,method:"POST",data:n},t)}CodeRepair(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/code_repair"),n={uri:i.uri,error_msg:i.error_msg};return this.request({url:o,method:"POST",data:n},t)}AuthorizedChannelMatch(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/authorized_channel_match"),n={web_rul:i.web_rul};return this.request({url:o,method:"POST",data:n},t)}UpdateTaskStatus(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/update_task_status"),n={agent_id:i.agent_id,sk:i.sk,task_id:i.task_id,task_status:i.task_status,result:i.result};return this.request({url:o,method:"POST",data:n},t)}GetWebUrl(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_web_url"),n={original_url:i.original_url,exchange_for_short_url:i.exchange_for_short_url,exchange_for_qr_code:i.exchange_for_qr_code,exchange_for_long_url:i.exchange_for_long_url};return this.request({url:o,method:"POST",data:n},t)}OperateSandbox(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/operate_sandbox"),n={task_id:i.task_id,action:i.action,delete_cookie_info:i.delete_cookie_info};return this.request({url:o,method:"POST",data:n},t)}UpdateTaskName(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/update_task_name"),n={agent_id:i.agent_id,sk:i.sk,task_id:i.task_id,task_name:i.task_name};return this.request({url:o,method:"POST",data:n},t)}GenDoc(e,t){const i=e,o=this.genBaseURL("/api/coze_space/gen_doc"),n={task_id:i.task_id,target_file_type:i.target_file_type,original_file_uri:i.original_file_uri,original_file_name:i.original_file_name,file_content:i.file_content};return this.request({url:o,method:"POST",data:n},t)}PreGetContractInfo(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/pre_get_contract_info"),n={file_content:i.file_content,task_id:i.task_id,file_name:i.file_name};return this.request({url:o,method:"POST",data:n},t)}GetContractCaseInfo(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_contract_case_info"),n={case_no:i.case_no};return this.request({url:o,method:"POST",data:n},t)}GetContractLawInfo(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_contract_law_info"),n={law:i.law,num:i.num};return this.request({url:o,method:"POST",data:n},t)}GetCozeSpaceUserInfo(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_user_info"),n={need_volcano_info:i.need_volcano_info,need_user_job_info:i.need_user_job_info,need_turn_off_user_data_management:i.need_turn_off_user_data_management,need_user_scenes:i.need_user_scenes,need_user_active_time:i.need_user_active_time,need_turn_off_ai_watermark:i.need_turn_off_ai_watermark,need_dnu_user:i.need_dnu_user};return this.request({url:o,method:"POST",data:n},t)}SearchCityInfo(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/search_city_info"),n={search_type:i.search_type,keyword:i.keyword};return this.request({url:o,method:"POST",data:n},t)}UpdateScheduledTask(e,t){const i=e,o=this.genBaseURL("/api/coze_space/update_scheduled_task"),n={scheduled_task_id:i.scheduled_task_id,task_type:i.task_type,status:i.status,scheduled_task_name:i.scheduled_task_name,trigger:i.trigger,mcp_tool_list:i.mcp_tool_list,expert_agent_config:i.expert_agent_config,task_plan:i.task_plan,is_need_try_run:i.is_need_try_run,description:i.description,task_id:i.task_id,daily_executed_at:i.daily_executed_at,task_plan_v2:i.task_plan_v2};return this.request({url:o,method:"POST",data:n},t)}GetScheduledTasks(e,t){const i=this.genBaseURL("/api/coze_space/get_scheduled_tasks");return this.request({url:i,method:"POST"},t)}TryRunScheduledTask(e,t){const i=e,o=this.genBaseURL("/api/coze_space/try_run_scheduled_task"),n={scheduled_task_id:i.scheduled_task_id};return this.request({url:o,method:"POST",data:n},t)}DeleteScheduledTask(e,t){const i=e,o=this.genBaseURL("/api/coze_space/delete_scheduled_task"),n={scheduled_task_id:i.scheduled_task_id};return this.request({url:o,method:"POST",data:n},t)}CreateScheduledTask(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/create_scheduled_task"),n={is_need_try_run:i.is_need_try_run,scheduled_task_name:i.scheduled_task_name,trigger:i.trigger,source_task_id:i.source_task_id,task_plan:i.task_plan,description:i.description,daily_executed_at:i.daily_executed_at,task_plan_v2:i.task_plan_v2};return this.request({url:o,method:"POST",data:n},t)}UpdateTeamInfo(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/update_team_info"),n={switch:i.switch};return this.request({url:o,method:"POST",data:n},t)}GetTeamInfo(e,t){const i=this.genBaseURL("/api/coze_space/get_team_info");return this.request({url:i,method:"POST"},t)}GetTaskInfo(e,t){const i=e,o=this.genBaseURL("/api/coze_space/get_task_info"),n={task_id:i.task_id};return this.request({url:o,method:"POST",data:n},t)}FeelGood(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/feel_good"),n={task_id:i.task_id,answer_id:i.answer_id,feel:i.feel,content:i.content};return this.request({url:o,method:"POST",data:n},t)}GetUserScheduledTaskQuota(e,t){const i=this.genBaseURL("/api/coze_space/get_scheduled_task_quota");return this.request({url:i,method:"POST"},t)}GetSingleScheduledTask(e,t){const i=e,o=this.genBaseURL("/api/coze_space/get_single_scheduled_task"),n={scheduled_task_id:i.scheduled_task_id};return this.request({url:o,method:"POST",data:n},t)}DeleteUserAuthorization(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/delete_user_authorization"),n={url:i.url,clear_arg:i.clear_arg};return this.request({url:o,method:"POST",data:n},t)}GetUserAuthorizationList(e,t){const i=this.genBaseURL("/api/coze_space/get_user_authorization_list");return this.request({url:i,method:"POST"},t)}AddUserAuthorization(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/add_user_authorization"),n={task_id:i.task_id,url:i.url,clear_arg:i.clear_arg,add_arg:i.add_arg};return this.request({url:o,method:"POST",data:n},t)}SearchFeelGood(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/search_feel_good"),n={task_id:i.task_id,answer_id:i.answer_id};return this.request({url:o,method:"POST",data:n},t)}GetAuthorizedChannelList(e,t){const i=this.genBaseURL("/api/coze_space/get_authorized_channel_list");return this.request({url:i,method:"GET"},t)}GetTaskExample(e,t){const i=e,o=this.genBaseURL("/api/coze_space/get_task_example"),n={task_example_id:i.task_example_id};return this.request({url:o,method:"POST",data:n},t)}AdminListTaskExample(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/list_task_example"),n={size:i.size,page:i.page,task_ids:i.task_ids,category_id:i.category_id,ability_type:i.ability_type,status:i.status};return this.request({url:o,method:"POST",data:n},t)}AdminDeleteTaskExample(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/delete_task_example"),n={example_id:i.example_id};return this.request({url:o,method:"POST",data:n},t)}UpdateCozeSpaceUserInfo(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/update_user_info"),n={job_id:i.job_id,turn_off_user_data_management:i.turn_off_user_data_management,scene_ids:i.scene_ids,turn_off_ai_watermark:i.turn_off_ai_watermark};return this.request({url:o,method:"POST",data:n},t)}GetTaskExampleList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_task_example_list"),n={category_id:i.category_id,page_size:i.page_size,page:i.page,ability_type:i.ability_type,scene_ids:i.scene_ids};return this.request({url:o,method:"POST",data:n},t)}AdminCreateTaskExample(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/create_task_example"),n={task_id:i.task_id,example_name:i.example_name,example_description:i.example_description,icon_uri:i.icon_uri,index:i.index,category_id:i.category_id,user_query:i.user_query,share_id:i.share_id,ability_type:i.ability_type,open_app_use:i.open_app_use,app_title:i.app_title,official_recommend:i.official_recommend,file_type:i.file_type,type:i.type,close_make_same:i.close_make_same,product_info:i.product_info,api_template_type:i.api_template_type,attachment_files:i.attachment_files};return this.request({url:o,method:"POST",data:n},t)}AdminUpdateTaskExample(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/update_task_example"),n={example_id:i.example_id,example_name:i.example_name,example_description:i.example_description,icon_uri:i.icon_uri,index:i.index,category_id:i.category_id,user_query:i.user_query,status:i.status,ability_type:i.ability_type,open_app_use:i.open_app_use,app_title:i.app_title,official_recommend:i.official_recommend,type:i.type,close_make_same:i.close_make_same,product_info:i.product_info,file_type:i.file_type,api_template_type:i.api_template_type,attachment_files:i.attachment_files};return this.request({url:o,method:"POST",data:n},t)}GetTaskExampleCategory(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_task_example_category"),n={ability_type:i.ability_type};return this.request({url:o,method:"GET",params:n},t)}GetUserJobList(e,t){const i=this.genBaseURL("/api/coze_space/get_user_job_list");return this.request({url:i,method:"GET"},t)}AdminParseTaskShareURL(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/parse_task_share_url"),n={share_url:i.share_url};return this.request({url:o,method:"POST",data:n},t)}GetAppInfo(e,t){const i=this.genBaseURL("/api/coze_space/get_app_info");return this.request({url:i,method:"GET"},t)}AdminGetTaskExampleCategory(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/get_task_example_category"),n={ability_type:i.ability_type};return this.request({url:o,method:"GET",params:n},t)}AdminUploadFile(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/upload_task_file"),n={file_name:i.file_name,file_content:i.file_content,scene:i.scene};return this.request({url:o,method:"POST",data:n},t)}UpdateFileContent(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/update_file_content"),n={task_id:i.task_id,file_uri:i.file_uri,file_content:i.file_content};return this.request({url:o,method:"POST",data:n},t)}ExportPPTAgentFile(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/export_ppt_agent_file"),n={source_uri:i.source_uri,task_id:i.task_id,export_type:i.export_type};return this.request({url:o,method:"POST",data:n},t)}RestoreExampleFile(e,t){const i=e,o=this.genBaseURL("/api/coze_space/restore_example_file"),n={task_id:i.task_id,example_id:i.example_id,product:i.product};return this.request({url:o,method:"POST",data:n},t)}GetHtmlHeightFix(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_html_height_fix"),n={code:i.code};return this.request({url:o,method:"POST",data:n},t)}PollMessages(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/poll_messages"),n={start_next_key:i.start_next_key};return this.request({url:o,method:"GET",params:n},t)}OperatePausedTask(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/operate_paused_task"),n={task_id:i.task_id,pause_reason:i.pause_reason};return this.request({url:o,method:"POST",data:n},t)}GetFrontierKey(e,t){const i=this.genBaseURL("/api/coze_space/get_frontier_key");return this.request({url:i,method:"GET"},t)}SearchImage(e,t){const i=e,o=this.genBaseURL("/api/coze_space/search_image"),n={query:i.query,count:i.count};return this.request({url:o,method:"POST",data:n},t)}GetUserExpertList(e,t){const i=this.genBaseURL("/api/coze_space/get_user_expert_list");return this.request({url:i,method:"POST"},t)}OperateUserExpert(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/operate_user_expert"),n={agent_id:i.agent_id,operate_type:i.operate_type};return this.request({url:o,method:"POST",data:n},t)}GetHotQuery(e,t){const i=this.genBaseURL("/api/coze_space/get_hot_query");return this.request({url:i,method:"POST"},t)}ImageDownload(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/download_image"),n={image_infos:i.image_infos,download_type:i.download_type};return this.request({url:o,method:"POST",data:n},t)}ImageEdit(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/edit_image"),n={edit_type:i.edit_type,image_url:i.image_url,query:i.query,count:i.count,task_id:i.task_id};return this.request({url:o,method:"POST",data:n},t)}CreateImageCopy(e,t){const i=e,o=this.genBaseURL("/api/coze_space/create_image_copy"),n={task_id:i.task_id,image_path:i.image_path,source_image_url:i.source_image_url};return this.request({url:o,method:"POST",data:n},t)}GetLatestImagesWithID(e,t){const i=e,o=this.genBaseURL("/api/coze_space/get_latest_images_with_id"),n={task_id:i.task_id,image_paths:i.image_paths};return this.request({url:o,method:"POST",data:n},t)}AdminCreateTaskExampleCategory(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/create_task_example_category"),n={name:i.name,ability_type:i.ability_type,index:i.index,job_ids:i.job_ids,scene_ids:i.scene_ids};return this.request({url:o,method:"POST",data:n},t)}AdminDeleteTaskExampleCategory(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/delete_task_example_category"),n={category_id:i.category_id};return this.request({url:o,method:"POST",data:n},t)}AdminUpdateTaskExampleCategory(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/update_task_example_category"),n={category_id:i.category_id,name:i.name,index:i.index,job_ids:i.job_ids,scene_ids:i.scene_ids};return this.request({url:o,method:"POST",data:n},t)}BatchHtmlToImage(e,t){const i=e,o=this.genBaseURL("/api/coze_space/batch_html_to_image"),n={task_id:i.task_id,html_uri:i.html_uri,device_info:i.device_info,screenshot_info:i.screenshot_info};return this.request({url:o,method:"POST",data:n},t)}GetAppTaskExampleList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_app_task_example_list"),n={ability_type:i.ability_type,need_official_recommended:i.need_official_recommended};return this.request({url:o,method:"POST",data:n},t)}GenCover(e,t){const i=e,o=this.genBaseURL("/api/coze_space/gen_cover"),n={task_id:i.task_id,original_file_uri:i.original_file_uri,resolution:i.resolution,mode:i.mode,selector_str:i.selector_str,task_share_url:i.task_share_url};return this.request({url:o,method:"POST",data:n},t)}CopyResource(e,t){const i=e,o=this.genBaseURL("/api/coze_space/copy_resource"),n={new_task_id:i.new_task_id,uri_list:i.uri_list};return this.request({url:o,method:"POST",data:n},t)}BatchUpdateImage(e,t){const i=e,o=this.genBaseURL("/api/coze_space/batch_update_image"),n={task_id:i.task_id,image_info_list:i.image_info_list};return this.request({url:o,method:"POST",data:n},t)}Text2Json(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/text2json"),n={text:i.text,type:i.type};return this.request({url:o,method:"POST",data:n},t)}EditImageWithMsg(e,t){const i=e,o=this.genBaseURL("/api/coze_space/edit_image_with_msg"),n={task_id:i.task_id,source_image_info:i.source_image_info,edit_type:i.edit_type,query:i.query,edit_info:i.edit_info};return this.request({url:o,method:"POST",data:n},t)}GetASRToken(e,t){const i=this.genBaseURL("/api/coze_space/get_asr_token");return this.request({url:i,method:"GET"},t)}QueryRewriting(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/query_rewriting"),n={query:i.query};return this.request({url:o,method:"POST",data:n},t)}GetShortcutCommand(e,t){const i=e,o=this.genBaseURL("/api/coze_space/get_shortcut_command"),n={ability_type:i.ability_type,need_general_data:i.need_general_data};return this.request({url:o,method:"POST",data:n},t)}ClickPopup(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/click_popup"),n={id:i.id};return this.request({url:o,method:"POST",data:n},t)}GetPopupInfo(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_popup_info"),n={ability_type:i.ability_type};return this.request({url:o,method:"POST",data:n},t)}AdminCreateExampleDatabaseData(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/create_example_database_data"),n={data:i.data};return this.request({url:o,method:"POST",data:n},t)}AdminUpdateShortcutCommand(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/update_shortcut_command"),n={id:i.id,title:i.title,app_title:i.app_title,query:i.query,action_type:i.action_type,open_pc:i.open_pc,open_app:i.open_app,job_id:i.job_id,open_time:i.open_time,expire_time:i.expire_time};return this.request({url:o,method:"POST",data:n},t)}AdminCreateShortcutCommand(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/create_shortcut_command"),n={ability_type:i.ability_type,title:i.title,app_title:i.app_title,query:i.query,action_type:i.action_type,open_pc:i.open_pc,open_app:i.open_app,job_id:i.job_id,expire_time:i.expire_time};return this.request({url:o,method:"POST",data:n},t)}AdminGetShortcutCommandList(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/get_shortcut_command_list"),n={size:i.size,ability_type:i.ability_type,page:i.page,open_pc:i.open_pc,open_app:i.open_app,job_id:i.job_id};return this.request({url:o,method:"POST",data:n},t)}AdminDeleteShortcutCommand(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/delete_shortcut_command"),n={id:i.id};return this.request({url:o,method:"POST",data:n},t)}AdminSyncCrawl(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/sync_crawl"),n={req:i.req,upload:i.upload};return this.request({url:o,method:"POST",data:n},t)}AdminGetUserJobList(e,t){const i=this.genBaseURL("/api/coze_space/admin/get_user_job_list");return this.request({url:i,method:"GET"},t)}AdminListTemplate(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/list_template"),n={size:i.size,page:i.page,template_ids:i.template_ids,category_ids:i.category_ids,ability_type:i.ability_type,template_name:i.template_name};return this.request({url:o,method:"POST",data:n},t)}AdminCreateTemplate(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/create_template"),n={ability_type:i.ability_type,category_id:i.category_id,web_template_conf:i.web_template_conf,template_labels:i.template_labels,original_query:i.original_query,query_template:i.query_template,template_words:i.template_words,open_app_use:i.open_app_use,app_template_conf:i.app_template_conf,template_files:i.template_files,reference_info:i.reference_info,api_template_type:i.api_template_type,tags:i.tags};return this.request({url:o,method:"POST",data:n},t)}AdminUpdateTemplate(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/update_template"),n={template_id:i.template_id,ability_type:i.ability_type,category_id:i.category_id,web_template_conf:i.web_template_conf,template_labels:i.template_labels,original_query:i.original_query,query_template:i.query_template,template_words:i.template_words,open_app_use:i.open_app_use,app_template_conf:i.app_template_conf,index:i.index,is_selected:i.is_selected,template_files:i.template_files,reference_info:i.reference_info,api_template_type:i.api_template_type,tags:i.tags};return this.request({url:o,method:"POST",data:n},t)}AdminDeleteTemplate(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/delete_template"),n={template_id:i.template_id};return this.request({url:o,method:"POST",data:n},t)}GetTemplateList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_template_list"),n={category_id:i.category_id,page_size:i.page_size,page:i.page,ability_type:i.ability_type};return this.request({url:o,method:"POST",data:n},t)}GetAppTemplateList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_app_template_list"),n={ability_type:i.ability_type};return this.request({url:o,method:"POST",data:n},t)}GetTemplate(e,t){const i=e,o=this.genBaseURL("/api/coze_space/get_template_info"),n={template_id:i.template_id};return this.request({url:o,method:"POST",data:n},t)}GetActivityInfo(e,t){const i=this.genBaseURL("/api/coze_space/activity/info");return this.request({url:i,method:"GET"},t)}BindRelation(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/activity/bind"),n={code:i.code};return this.request({url:o,method:"POST",data:n},t)}GetInviteCode(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/activity/invite_code"),n={activity_id:i.activity_id};return this.request({url:o,method:"POST",data:n},t)}GetInviteRecords(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/activity/invite_records"),n={activity_id:i.activity_id};return this.request({url:o,method:"POST",data:n},t)}RollbackFileVersion(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/rollback_file_version"),n={task_id:i.task_id,file_name:i.file_name,target_version:i.target_version};return this.request({url:o,method:"POST",data:n},t)}GetFileVersionInfo(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_file_version_info"),n={task_id:i.task_id,file_name:i.file_name,long_term_plan:i.long_term_plan};return this.request({url:o,method:"POST",data:n},t)}AdminMDelUri(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/mdel_uri"),n={uris:i.uris,urls:i.urls};return this.request({url:o,method:"POST",data:n},t)}AdminDeleteSEMUrl(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/delete_sem_url"),n={id:i.id};return this.request({url:o,method:"POST",data:n},t)}AdminCreateSEMUrl(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/create_sem_url"),n={experiment_url:i.experiment_url,compare_url:i.compare_url,description:i.description};return this.request({url:o,method:"POST",data:n},t)}AdminListSEMUrl(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/list_sem_url"),n={size:i.size,page:i.page};return this.request({url:o,method:"POST",data:n},t)}AdminUpdateSEMUrl(e,t){const i=e,o=this.genBaseURL("/api/coze_space/admin/update_sem_url"),n={id:i.id,experiment_url:i.experiment_url,compare_url:i.compare_url,description:i.description};return this.request({url:o,method:"POST",data:n},t)}GetSEMUrl(e,t){const i=e,o=this.genBaseURL("/api/coze_space/get_sem_url"),n={id:i.id};return this.request({url:o,method:"POST",data:n},t)}ClickCompetitionLikes(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/click_competition_likes"),n={competition_task_id:i.competition_task_id,is_like:i.is_like};return this.request({url:o,method:"POST",data:n},t)}SubmitCompetitionTask(e,t){const i=e,o=this.genBaseURL("/api/coze_space/submit_competition_task"),n={task_id:i.task_id,product_url:i.product_url,title:i.title,cover_uri:i.cover_uri,competition_id:i.competition_id};return this.request({url:o,method:"POST",data:n},t)}GetCompetitionInfo(e,t){const i=this.genBaseURL("/api/coze_space/get_competition_info");return this.request({url:i,method:"POST"},t)}GetCompetitionTaskList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_competition_task_list"),n={page_size:i.page_size,cursor:i.cursor,is_create_sorted:i.is_create_sorted,search_title:i.search_title,competition_id:i.competition_id};return this.request({url:o,method:"POST",data:n},t)}FavoriteList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/favorites/list"),n={tag_ids:i.tag_ids,name:i.name,need_untagged:i.need_untagged,size:i.size,cursor:i.cursor,exclude_content_types:i.exclude_content_types};return this.request({url:o,method:"POST",data:n},t)}DeleteTags(e,t){const i=e,o=this.genBaseURL("/api/coze_space/favorites/delete_tags"),n={ids:i.ids};return this.request({url:o,method:"POST",data:n},t)}DeleteFavorites(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/favorites/delete"),n={ids:i.ids,related_uris:i.related_uris};return this.request({url:o,method:"POST",data:n},t)}BatchGetFavoriteInfo(e,t){const i=e,o=this.genBaseURL("/api/coze_space/favorites/batch_get_info"),n={favorite_ids:i.favorite_ids};return this.request({url:o,method:"POST",data:n},t)}UpdateFavoriteInfo(e,t){const i=e,o=this.genBaseURL("/api/coze_space/favorites/update"),n={id:i.id,tag_ids:i.tag_ids};return this.request({url:o,method:"POST",data:n},t)}GetTagList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/favorites/get_tag_list"),n={tag_ids:i.tag_ids,tag_name:i.tag_name};return this.request({url:o,method:"POST",data:n},t)}CreateTags(e,t){const i=e,o=this.genBaseURL("/api/coze_space/favorites/create_tag"),n={tag_name:i.tag_name,tag_desc:i.tag_desc,favorite_info_list:i.favorite_info_list};return this.request({url:o,method:"POST",data:n},t)}AddFavorite(e,t){const i=e,o=this.genBaseURL("/api/coze_space/favorites/add"),n={title:i.title,content_uri:i.content_uri,content_text:i.content_text,tag_ids:i.tag_ids,source:i.source,scene:i.scene,product_type:i.product_type};return this.request({url:o,method:"POST",data:n},t)}UpdateTags(e,t){const i=e,o=this.genBaseURL("/api/coze_space/favorites/update_tag"),n={tag_id:i.tag_id,tag_name:i.tag_name,tag_desc:i.tag_desc};return this.request({url:o,method:"POST",data:n},t)}GetMyCompetitionTaskList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_my_competition_task_list"),n={page_size:i.page_size,cursor:i.cursor,competition_id:i.competition_id};return this.request({url:o,method:"POST",data:n},t)}AdminGetUserScenes(e,t){const i=this.genBaseURL("/api/coze_space/admin/get_user_scenes");return this.request({url:i,method:"GET"},t)}GetUserScenes(e,t){const i=this.genBaseURL("/api/coze_space/get_user_scenes");return this.request({url:i,method:"GET"},t)}GetDeepWritingConf(e,t){const i=this.genBaseURL("/api/coze_space/get_deep_writing_conf");return this.request({url:i,method:"GET"},t)}GetCompetitionTask(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_competition_task"),n={competition_task_id:i.competition_task_id};return this.request({url:o,method:"POST",data:n},t)}GetUnreadCount(e,t){const i=this.genBaseURL("/api/coze_space/get_unread_count");return this.request({url:i,method:"POST"},t)}BatchHtmlCodeToImage(e,t){const i=e,o=this.genBaseURL("/api/coze_space/batch_html_code_to_image"),n={task_id:i.task_id,html_code:i.html_code,device_info:i.device_info,screenshot_info:i.screenshot_info,zip:i.zip};return this.request({url:o,method:"POST",data:n},t)}GenDocMultiImageMaterial(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/gen_doc_multi_image_material"),n={task_id:i.task_id,file_uri:i.file_uri};return this.request({url:o,method:"POST",data:n},t)}GetDerivedProduct(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_derived_product"),n={task_id:i.task_id,derived_product_type:i.derived_product_type};return this.request({url:o,method:"POST",data:n},t)}SaveDerivedProduct(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/save_derived_product"),n={task_id:i.task_id,derived_product:i.derived_product};return this.request({url:o,method:"POST",data:n},t)}TagFavorites(e,t){const i=e,o=this.genBaseURL("/api/coze_space/favorites/tag_favorites"),n={tag_name:i.tag_name,tag_desc:i.tag_desc};return this.request({url:o,method:"POST",data:n},t)}SuggestQuery(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/suggest_query"),n={query:i.query,image_urls:i.image_urls};return this.request({url:o,method:"POST",data:n},t)}BatchGetUrl(e,t){const i=e,o=this.genBaseURL("/api/coze_space/batch_get_url"),n={uri_list:i.uri_list,expire_seconds:i.expire_seconds,is_short_url:i.is_short_url};return this.request({url:o,method:"POST",data:n},t)}UploadFile(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/upload_file"),n={file_name:i.file_name,file_content:i.file_content,scene:i.scene};return this.request({url:o,method:"POST",data:n},t)}BatchGetFavorite(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/favorites/get_count"),n={file_uris:i.file_uris};return this.request({url:o,method:"POST",data:n},t)}GetEarliestQuery(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_earliest_query"),n={task_id:i.task_id};return this.request({url:o,method:"POST",data:n},t)}GetMappingUri(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_mapping_uri"),n={uri:i.uri};return this.request({url:o,method:"POST",data:n},t)}ApiTemplate(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/api_template"),n={prompt:i.prompt,files:i.files,type:i.type,task_id:i.task_id,template_id:i.template_id};return this.request({url:o,method:"POST",data:n},t)}BatchGetMultiMedia(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/batch_get_multimedia"),n={media_uris:i.media_uris};return this.request({url:o,method:"POST",data:n},t)}AdminBatchGetMultiMedia(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/batch_get_multimedia"),n={media_uris:i.media_uris};return this.request({url:o,method:"POST",data:n},t)}AdminCreateMultiMedia(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/create_multimedia"),n={task_id:i.task_id,media_path:i.media_path,media_uri:i.media_uri,media_url:i.media_url,image_type:i.image_type,media_ext:i.media_ext};return this.request({url:o,method:"POST",data:n},t)}GetPodcastConfig(e,t){const i=this.genBaseURL("/api/coze_space/get_podcast_config");return this.request({url:i,method:"POST"},t)}IntentRecognition(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/intent_recognition"),n={task_id:i.task_id,files:i.files,ability_type:i.ability_type,query:i.query};return this.request({url:o,method:"POST",data:n},t)}ListTemplate(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/list_template"),n={size:i.size,cursor:i.cursor,tags:i.tags,ability_type:i.ability_type,api_template_type:i.api_template_type};return this.request({url:o,method:"POST",data:n},t)}AdminGetTagsByImages(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/get_tags_by_images"),n={images:i.images,query:i.query,scene:i.scene};return this.request({url:o,method:"POST",data:n},t)}GetTagsByImages(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_tags_by_images"),n={images:i.images,query:i.query,scene:i.scene};return this.request({url:o,method:"POST",data:n},t)}AdminCreateTemplateImage(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/create_template_image"),n={image:i.image,tags:i.tags};return this.request({url:o,method:"POST",data:n},t)}ReportSubmit(e,t){const i=e,o=this.genBaseURL("/api/coze_space/report_submit"),n={object_type:i.object_type,object_id:i.object_id,report_detail:i.report_detail};return this.request({url:o,method:"POST",data:n},t)}ListBotChatMessages(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/list_bot_chat_message"),n={bot_chat_type:i.bot_chat_type,cursor:i.cursor,size:i.size};return this.request({url:o,method:"POST",data:n},t)}BotChatWithType(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/bot_chat_with_type"),n={bot_chat_type:i.bot_chat_type,query:i.query};return this.request({url:o,method:"POST",data:n},t)}GenImage(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/gen_image"),n={task_id:i.task_id,project_id:i.project_id,prompt:i.prompt,count:i.count,video_project_uri:i.video_project_uri,image_url:i.image_url,base_image_urls:i.base_image_urls,skip_save_material:i.skip_save_material};return this.request({url:o,method:"POST",data:n},t)}UploadVideoResource(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/upload_video_resource"),n={task_id:i.task_id,project_id:i.project_id,file_name:i.file_name,file_content:i.file_content,video_project_uri:i.video_project_uri,skip_save_material:i.skip_save_material};return this.request({url:o,method:"POST",data:n},t)}GetVideoConfig(e,t){const i=this.genBaseURL("/api/coze_space/video/get_video_config");return this.request({url:i,method:"POST"},t)}GetCozeSpaceDeviceInfo(e,t){const i=this.genBaseURL("/api/coze_space/get_device_info");return this.request({url:i,method:"POST"},t)}AdminMDeleteReferenceImage(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/mdelete_reference_image"),n={ids:i.ids};return this.request({url:o,method:"POST",data:n},t)}AdminMDeleteTemplateImage(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/mdelete_template_image"),n={ids:i.ids};return this.request({url:o,method:"POST",data:n},t)}AdminListReferenceImage(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/list_reference_image"),n={size:i.size,cursor:i.cursor,tag:i.tag};return this.request({url:o,method:"POST",data:n},t)}AdminListRewriteImage(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/list_rewrite_image"),n={size:i.size,cursor:i.cursor,tag:i.tag};return this.request({url:o,method:"POST",data:n},t)}AdminCreateReferenceImage(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/create_reference_image"),n={tag:i.tag,image:i.image};return this.request({url:o,method:"POST",data:n},t)}AdminTemplateRewrite(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/template_rewrite"),n={template_image_ids:i.template_image_ids,rewrite_image_id:i.rewrite_image_id};return this.request({url:o,method:"POST",data:n},t)}AdminMDeleteRewriteImage(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/mdelete_rewrite_image"),n={ids:i.ids};return this.request({url:o,method:"POST",data:n},t)}AdminListTemplateImage(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/list_template_image"),n={size:i.size,cursor:i.cursor,tags:i.tags};return this.request({url:o,method:"POST",data:n},t)}AdminUpdateRewriteImage(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/update_rewrite_image"),n={id:i.id,rewrite_result:i.rewrite_result};return this.request({url:o,method:"POST",data:n},t)}GetGuidingMessage(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_guiding_message"),n={guiding_id:i.guiding_id};return this.request({url:o,method:"POST",data:n},t)}AdminListImageTag(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/list_image_tag"),n={size:i.size,cursor:i.cursor};return this.request({url:o,method:"POST",data:n},t)}UpdateProject(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video_volc_proxy/update_project"),n={GroupId:i.GroupId,ProjectId:i.ProjectId,LatestEditParam:i.LatestEditParam,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri};return this.request({url:o,method:"POST",data:n},t)}DescribeProject(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video_volc_proxy/describe_project"),n={GroupId:i.GroupId,ProjectId:i.ProjectId,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri};return this.request({url:o,method:"POST",data:n},t)}SubmitEditTaskAsync(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video_volc_proxy/submit_edit_task_async"),n={GroupId:i.GroupId,ProjectId:i.ProjectId,ProjectType:i.ProjectType,EditParam:i.EditParam,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri};return this.request({url:o,method:"POST",data:n},t)}BatchGetVideoPlayInfo(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video_volc_proxy/batch_get_video_play_info"),n={vids:i.vids,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri};return this.request({url:o,method:"POST",data:n},t)}GetDirectEditProgress(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video_volc_proxy/get_direct_edit_progress"),n={ReqId:i.ReqId,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri};return this.request({url:o,method:"POST",data:n},t)}SearchEditMaterial(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video_volc_proxy/search_edit_material"),n={ProjectId:i.ProjectId,EditMids:i.EditMids,Space:i.Space,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri};return this.request({url:o,method:"POST",data:n},t)}ListSnapshots(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video_volc_proxy/list_snapshots"),n={ProjectId:i.ProjectId,Vid:i.Vid,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri};return this.request({url:o,method:"POST",data:n},t)}AdminUpdateTemplateImage(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/update_reference_image"),n={id:i.id,tags:i.tags};return this.request({url:o,method:"POST",data:n},t)}VolcVodCallback(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/volc_vod_callback"),n={RequestId:i.RequestId,Version:i.Version,EventType:i.EventType,EventTime:i.EventTime};return this.request({url:o,method:"POST",data:n},t)}AdminDeleteVideoTextStyle(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/delete_video_text_style"),n={id:i.id};return this.request({url:o,method:"POST",data:n},t)}AdminListVideoTextStyle(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/list_video_text_style"),n={size:i.size,cursor:i.cursor};return this.request({url:o,method:"POST",data:n},t)}AdminSaveVideoTextStyle(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/save_video_text_style"),n={video_text_style:i.video_text_style};return this.request({url:o,method:"POST",data:n},t)}GetMusicList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/get_music_list"),n={size:i.size,cursor:i.cursor};return this.request({url:o,method:"POST",data:n},t)}ListVideoTextStyle(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/list_video_text_style"),n={size:i.size,cursor:i.cursor};return this.request({url:o,method:"POST",data:n},t)}GetMessageMeta(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_message_meta"),n={task_id:i.task_id};return this.request({url:o,method:"GET",params:n},t)}AdminRunWorkflow(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/run_workflow"),n={id:i.id,input:i.input};return this.request({url:o,method:"POST",data:n},t)}QueryGenResourceStatus(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/query_gen_resource_status"),n={task_id:i.task_id,project_id:i.project_id,video_project_uri:i.video_project_uri,gen_resource_task_id:i.gen_resource_task_id};return this.request({url:o,method:"POST",data:n},t)}GenResourceAsync(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/gen_resource_async"),n={task_id:i.task_id,project_id:i.project_id,video_project_uri:i.video_project_uri,gen_resource_type:i.gen_resource_type,gen_video_req_payload:i.gen_video_req_payload,gen_voice_audio_req_payload:i.gen_voice_audio_req_payload,gen_music_req_payload:i.gen_music_req_payload,skip_save_material:i.skip_save_material};return this.request({url:o,method:"POST",data:n},t)}GetTaskItemList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/get_task_item_list"),n={task_id:i.task_id,item_ids:i.item_ids,start_time:i.start_time,end_time:i.end_time};return this.request({url:o,method:"POST",data:n},t)}CancelGenResourceTask(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/cancel_gen_resource_task"),n={task_id:i.task_id,project_id:i.project_id,video_project_uri:i.video_project_uri,gen_resource_task_id:i.gen_resource_task_id};return this.request({url:o,method:"POST",data:n},t)}AdminUpdateTemplateTagsFromCSV(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/update_template_tags_from_csv"),n={is_run_wf:i.is_run_wf,is_update:i.is_update,tos_path:i.tos_path};return this.request({url:o,method:"POST",data:n},t)}GetPlanTemplates(e,t){const i=this.genBaseURL("/api/coze_space/get_plan_templates");return this.request({url:i,method:"POST"},t)}DeleteTaskFile(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/delete_task_file"),n={id:i.id};return this.request({url:o,method:"POST",data:n},t)}ListTaskFile(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/list_task_file"),n={task_id:i.task_id,size:i.size,cursor:i.cursor,plan_file:i.plan_file};return this.request({url:o,method:"POST",data:n},t)}GenPodcastStream(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/gen_podcast"),n={cache_key:i.cache_key};return this.request({url:o,method:"POST",data:n},t)}AdminTemplateTypeIntentBG(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/admin/template_type_intent_bg"),n={files:i.files};return this.request({url:o,method:"POST",data:n},t)}ExportImagePPT(e,t){const i=e,o=this.genBaseURL("/api/coze_space/export_image_ppt_agent_file"),n={task_id:i.task_id,title:i.title,pages:i.pages,export_type:i.export_type};return this.request({url:o,method:"POST",data:n},t)}ExportProject(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/export_project"),n={task_id:i.task_id,project_id:i.project_id,video_project_uri:i.video_project_uri};return this.request({url:o,method:"POST",data:n},t)}GetModelConfig(e,t){const i=this.genBaseURL("/api/coze_space/get_model_config");return this.request({url:i,method:"POST"},t)}ConfirmPlan(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/confirm_plan"),n={task_id:i.task_id};return this.request({url:o,method:"POST",data:n},t)}GetUserSkillAuthorizationInfo(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/skill/get_user_skill_authorization_info"),n={credential_id:i.credential_id};return this.request({url:o,method:"POST",data:n},t)}UpdateCozeUserNickname(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/update_user_nickname"),n={nickname:i.nickname};return this.request({url:o,method:"POST",data:n},t)}CreateCozeUserJobName(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/create_user_job_name"),n={job_name:i.job_name};return this.request({url:o,method:"POST",data:n},t)}EnterpriseCustomer(e,t){const i=this.genBaseURL("/api/coze_space/enterprise_customer");return this.request({url:i,method:"POST"},t)}CreateVideoAsset(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/asset/create_video_asset"),n={base_info:i.base_info,details:i.details};return this.request({url:o,method:"POST",data:n},t)}UpdateVideoAsset(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/asset/update_video_asset"),n={asset_id:i.asset_id,base_info:i.base_info,details:i.details};return this.request({url:o,method:"POST",data:n},t)}DeleteVideoAsset(e,t){const i=e,o=this.genBaseURL("/api/coze_space/video/asset/delete_video_asset"),n={asset_id:i.asset_id};return this.request({url:o,method:"POST",data:n},t)}UpdateVideoProduction(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/production/update_video_production"),n={video_production:i.video_production};return this.request({url:o,method:"POST",data:n},t)}CreateVideoProduction(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/production/create_video_production"),n={video_production:i.video_production,ratio:i.ratio};return this.request({url:o,method:"POST",data:n},t)}VideoProductionMaterialList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/material/video_material_list"),n={production_id:i.production_id,tag_category:i.tag_category,type_category:i.type_category,page:i.page,size:i.size,need_detail_url:i.need_detail_url};return this.request({url:o,method:"POST",data:n},t)}VideoAssetDetail(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/asset/video_asset_detail"),n={asset_id:i.asset_id};return this.request({url:o,method:"POST",data:n},t)}VideoProductionMaterialDetail(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/material/video_material_detail"),n={material_id:i.material_id};return this.request({url:o,method:"POST",data:n},t)}DeleteVideoProductionMaterial(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/material/delete_video_material"),n={material_id:i.material_id};return this.request({url:o,method:"POST",data:n},t)}CreateVideoProductionMaterial(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/material/create_video_material"),n={production_id:i.production_id,base_info:i.base_info,details:i.details,asset_id:i.asset_id};return this.request({url:o,method:"POST",data:n},t)}UpdateVideoProductionMaterial(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/material/update_video_material"),n={material_id:i.material_id,material_update_type:i.material_update_type,base_info:i.base_info,details:i.details};return this.request({url:o,method:"POST",data:n},t)}DeleteVideoProduction(e,t){const i=e,o=this.genBaseURL("/api/coze_space/video/production/delete_video_production"),n={production_id:i.production_id};return this.request({url:o,method:"POST",data:n},t)}VideoAssetList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/asset/video_asset_list"),n={tag_category:i.tag_category,type_category:i.type_category,page:i.page,size:i.size,search_word:i.search_word,need_detail_url:i.need_detail_url};return this.request({url:o,method:"POST",data:n},t)}VideoProductionList(e,t){const i=e||{},o=this.genBaseURL("/api/coze_space/video/production/video_production_list"),n={page:i.page,size:i.size};return this.request({url:o,method:"POST",data:n},t)}OperateVideoProduction(e,t){const i=e,o=this.genBaseURL("/api/coze_space/video/production/operate_video_production"),n={production_id:i.production_id,operate_type:i.operate_type};return this.request({url:o,method:"POST",data:n},t)}OperateVideoAsset(e,t){const i=e,o=this.genBaseURL("/api/coze_space/video/asset/operate_video_asset"),n={asset_id:i.asset_id,operate_type:i.operate_type};return this.request({url:o,method:"POST",data:n},t)}}const Vp=new $p({});var Wp,Hp,Kp,Jp,Qp,Zp,Yp,Xp,el,tl,il,ol,nl,sl,rl,al,cl,dl,pl,ll,ul,_l,ml,gl,hl,fl,yl,vl,bl,Pl,Sl;function Tl(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}!function(e){e[e.Image=1]="Image";e[e.Android=2]="Android";e[e.IOS=3]="IOS";e[e.GitCode=4]="GitCode";e[e.FaasRuntimePkg=5]="FaasRuntimePkg";e[e.SkillPkg=6]="SkillPkg";e[e.H5=7]="H5"}(Wp||(Wp={})),function(e){e[e.Unknown=0]="Unknown";e[e.FreeCertificate=1]="FreeCertificate"}(Hp||(Hp={})),function(e){e[e.Unknown=0]="Unknown";e[e.Normal=1]="Normal"}(Kp||(Kp={})),function(e){e[e.Unknown=0]="Unknown";e[e.Existing=1]="Existing";e[e.Free=2]="Free"}(Jp||(Jp={})),function(e){e[e.AuditPass=1]="AuditPass";e[e.AuditUnPass=2]="AuditUnPass";e[e.Auditing=3]="Auditing";e[e.Released=11]="Released";e[e.ReleaseFailed=12]="ReleaseFailed";e[e.Running=21]="Running"}(Qp||(Qp={})),function(e){e[e.Passed=1]="Passed";e[e.UnPassed=2]="UnPassed";e[e.Auditing=3]="Auditing"}(Zp||(Zp={})),function(e){e[e.Official=1]="Official"}(Yp||(Yp={})),function(e){e[e.Prepare=1]="Prepare";e[e.Package=2]="Package";e[e.Build=3]="Build";e[e.Deploy=4]="Deploy";e[e.Audit=5]="Audit"}(Xp||(Xp={})),function(e){e[e.Pending=1]="Pending";e[e.Running=2]="Running";e[e.Succeeded=3]="Succeeded";e[e.Failed=4]="Failed";e[e.Canceled=5]="Canceled";e[e.Interrupted=6]="Interrupted"}(el||(el={})),function(e){e[e.Unknown=0]="Unknown";e[e.Success=1]="Success";e[e.Pending=2]="Pending";e[e.Failed=3]="Failed"}(tl||(tl={})),function(e){e[e.Unknown=0]="Unknown";e[e.Default=1]="Default";e[e.Custom=2]="Custom"}(il||(il={})),function(e){e[e.Unknown=0]="Unknown";e[e.Active=1]="Active";e[e.Disabled=2]="Disabled";e[e.Redirected=3]="Redirected";e[e.Primary=4]="Primary"}(ol||(ol={})),function(e){e[e.Published=1]="Published";e[e.Unpublished=2]="Unpublished"}(nl||(nl={})),function(e){e[e.Agent=1]="Agent";e[e.Automation=2]="Automation";e[e.WebApp=3]="WebApp";e[e.App=4]="App";e[e.Skill=5]="Skill";e[e.GeneralWeb=6]="GeneralWeb";e[e.WechatMiniProgram=7]="WechatMiniProgram";e[e.General=9]="General"}(sl||(sl={})),function(e){e[e.Created=1]="Created";e[e.Ready=3]="Ready";e[e.Stopped=4]="Stopped";e[e.Banned=5]="Banned";e[e.Paused=6]="Paused"}(rl||(rl={})),function(e){e[e.Unknown=0]="Unknown";e[e.VefaasFunction=1]="VefaasFunction"}(al||(al={})),function(e){e[e.Unknown=0]="Unknown";e[e.Dev=1]="Dev";e[e.Prod=2]="Prod";e[e.Audit=3]="Audit"}(cl||(cl={})),function(e){e[e.A=1]="A";e[e.CNAME=2]="CNAME"}(dl||(dl={})),function(e){e[e.Unknown=0]="Unknown";e[e.Single=1]="Single";e[e.Wildcard=2]="Wildcard";e[e.Multi=3]="Multi"}(pl||(pl={})),function(e){e[e.Unknown=0]="Unknown";e[e.DV=1]="DV";e[e.OV=2]="OV";e[e.EV=3]="EV"}(ll||(ll={})),function(e){e[e.Unknown=0]="Unknown";e[e.NotSubmitted=1]="NotSubmitted";e[e.Pending=2]="Pending";e[e.Issued=3]="Issued";e[e.Cancelling=4]="Cancelling";e[e.Canceled=5]="Canceled";e[e.Revoking=6]="Revoking";e[e.Revoked=7]="Revoked";e[e.Failed=8]="Failed";e[e.Expired=9]="Expired"}(ul||(ul={})),function(e){e[e.Unknown=0]="Unknown";e[e.Free=1]="Free";e[e.Test=2]="Test";e[e.Paid=3]="Paid";e[e.Imported=4]="Imported"}(_l||(_l={})),function(e){e[e.NeedAuthorize=1]="NeedAuthorize";e[e.BindSuccess=2]="BindSuccess";e[e.BoundToOtherProject=3]="BoundToOtherProject";e[e.BoundToOtherUser=4]="BoundToOtherUser"}(ml||(ml={})),function(e){e[e.BoundToSelf=1]="BoundToSelf";e[e.BoundToOtherUser=2]="BoundToOtherUser";e[e.NotAuthorized=3]="NotAuthorized"}(gl||(gl={})),function(e){e[e.Line=1]="Line"}(hl||(hl={})),function(e){e[e.Default=0]="Default";e[e.WechatMini=1]="WechatMini";e[e.DouyinMini=2]="DouyinMini"}(fl||(fl={})),function(e){e[e.Day=1]="Day";e[e.Week=2]="Week";e[e.Month=3]="Month";e[e.Yesterday=4]="Yesterday";e[e.ThreeDays=5]="ThreeDays"}(yl||(yl={})),function(e){e[e.InvokeQPS=1]="InvokeQPS";e[e.ErrorQPS=2]="ErrorQPS";e[e.Latency=3]="Latency";e[e.DAU=4]="DAU";e[e.DNU=5]="DNU";e[e.ActiveRetention=6]="ActiveRetention";e[e.NewUserRetention=7]="NewUserRetention"}(vl||(vl={})),function(e){e[e.Recorded=1]="Recorded"}(bl||(bl={})),function(e){e[e.Sum=1]="Sum";e[e.Avg=2]="Avg"}(Pl||(Pl={})),function(e){e[e.Next=1]="Next";e[e.Third=3]="Third";e[e.Seventh=7]="Seventh"}(Sl||(Sl={}));class Cl{__init(){this.request=e.request}__init2(){this.baseURL=""}constructor(e){Cl.prototype.__init.call(this),Cl.prototype.__init2.call(this),this.request=Tl([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=Tl([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}PublicCreateDeployHistory(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_history/create"),n={project_id:i.project_id,is_sync_db_to_prod:i.is_sync_db_to_prod,encrypt_env_variable:i.encrypt_env_variable,table_sync_configs:i.table_sync_configs,encrypt_deploy:i.encrypt_deploy,commit_hash:i.commit_hash,connector_configs:i.connector_configs};return this.request({url:o,method:"POST",data:n},t)}PublicRollbackDeployHistory(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_history/rollback"),n={project_id:i.project_id,target_deploy_history_id:i.target_deploy_history_id,rollback_database:i.rollback_database};return this.request({url:o,method:"POST",data:n},t)}PublicCancelDeployHistory(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_history/cancel"),n={project_id:i.project_id,deploy_history_id:i.deploy_history_id};return this.request({url:o,method:"POST",data:n},t)}PublicGetDeployConfig(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_config/get"),n={project_id:i.project_id,commit_hash:i.commit_hash};return this.request({url:o,method:"GET",params:n},t)}PublicListDeployHistory(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_history/list"),n={project_id:i.project_id,page_token:i.page_token,page_size:i.page_size};return this.request({url:o,method:"GET",params:n},t)}PublicSearchRuntimeLog(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/runtime_log/search"),n={project_id:i.project_id,deploy_history_id:i.deploy_history_id,start_time:i.start_time,end_time:i.end_time,limit:i.limit,cursor:i.cursor,query:i.query,level:i.level};return this.request({url:o,method:"GET",params:n},t)}PublicGetDeployHistory(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_history/get"),n={project_id:i.project_id,deploy_history_id:i.deploy_history_id};return this.request({url:o,method:"GET",params:n},t)}PublicBindCertificate(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/certificate/bind"),n={project_id:i.project_id,certificate_id:i.certificate_id,domain:i.domain};return this.request({url:o,method:"POST",data:n},t)}PublicApplyFreeCertificate(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/certificate/apply_free"),n={project_id:i.project_id,domain:i.domain,auto_renew_free_cert:i.auto_renew_free_cert};return this.request({url:o,method:"POST",data:n},t)}PublicListDomainRelated(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/domain_related/list"),n={project_id:i.project_id,unit_type:i.unit_type};return this.request({url:o,method:"GET",params:n},t)}PublicDeleteDomainRelated(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/domain_related/delete"),n={project_id:i.project_id,domain:i.domain};return this.request({url:o,method:"POST",data:n},t)}PublicCreateDomainRelated(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/domain_related/create"),n={project_id:i.project_id,domain:i.domain};return this.request({url:o,method:"POST",data:n},t)}PublicGetDeployUnit(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_unit/get"),n={project_id:i.project_id};return this.request({url:o,method:"GET",params:n},t)}PublicGetCertificateDetail(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/certificate/get"),n={project_id:i.project_id,certificate_id:i.certificate_id};return this.request({url:o,method:"GET",params:n},t)}PublicGetDomainRelated(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/domain_related/get"),n={project_id:i.project_id,domain:i.domain};return this.request({url:o,method:"GET",params:n},t)}PublicListVolcanoDomain(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/volcano_domain/list"),n={project_id:i.project_id};return this.request({url:o,method:"GET",params:n},t)}PublicListVolcanoCertificate(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/certificate/list_volcano"),n={project_id:i.project_id,domain:i.domain};return this.request({url:o,method:"GET",params:n},t)}PublicListProjectTraces(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/traces/list"),n={project_id:i.project_id,start_time:i.start_time,end_time:i.end_time,filter:i.filter,page_token:i.page_token,page_size:i.page_size};return this.request({url:o,method:"POST",data:n},t)}PublicDownloadProjectTraces(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/traces/download"),n={project_id:i.project_id,start_time:i.start_time,end_time:i.end_time,filter:i.filter};return this.request({url:o,method:"POST",data:n},t)}PublicGetProjectMetrics(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/metrics/get"),n={project_id:i.project_id,time_range:i.time_range,retention_days:i.retention_days};return this.request({url:o,method:"GET",params:n},t)}PublicDeleteDeployUnit(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_unit/delete"),n={project_id:i.project_id,deploy_unit_id:i.deploy_unit_id};return this.request({url:o,method:"POST",data:n},t)}PublicGetHelpCenterLink(e,t){const i=this.genBaseURL("/api/coding/deployment/help_center/link");return this.request({url:i,method:"GET"},t)}PublicCheckRollbackDatabase(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_history/check_rollback_database"),n={project_id:i.project_id,deploy_history_id:i.deploy_history_id};return this.request({url:o,method:"GET",params:n},t)}PublicGetMiniProgramPreview(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/mini_program/preview"),n={project_id:i.project_id,app_id:i.app_id,connector_id:i.connector_id};return this.request({url:o,method:"GET",params:n},t)}PublicSubmitAuthCode(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/auth/submit_code"),n={project_id:i.project_id,connector_id:i.connector_id,code:i.code,verify_state:i.verify_state,auth_params:i.auth_params};return this.request({url:o,method:"POST",data:n},t)}PublicGetAuthStatus(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/auth/status"),n={project_id:i.project_id,connector_id:i.connector_id,redirect_url:i.redirect_url};return this.request({url:o,method:"POST",data:n},t)}PublicBindAuth(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/auth/bind"),n={project_id:i.project_id,connector_id:i.connector_id,redirect_url:i.redirect_url,auth_params:i.auth_params,override:i.override};return this.request({url:o,method:"POST",data:n},t)}PublicUnbindAuth(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/auth/unbind"),n={project_id:i.project_id,connector_id:i.connector_id};return this.request({url:o,method:"POST",data:n},t)}PublicGetBoundProject(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/connector/get_bound_project"),n={connector_id:i.connector_id,related_id:i.related_id};return this.request({url:o,method:"GET",params:n},t)}PublicUpdateDomainRelated(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/domain_related/update"),n={project_id:i.project_id,domain:i.domain,auto_renew_free_cert:i.auto_renew_free_cert,visit_status:i.visit_status,next_primary_domain:i.next_primary_domain};return this.request({url:o,method:"POST",data:n},t)}PublicGetCertificateQuota(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/certificate/quota"),n={project_id:i.project_id};return this.request({url:o,method:"GET",params:n},t)}PublicListDomainCertificates(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/certificate/list"),n={project_id:i.project_id,domain:i.domain};return this.request({url:o,method:"GET",params:n},t)}PublicUnpublishConnector(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/connector/unpublish_project"),n={project_id:i.project_id,connector_ids:i.connector_ids};return this.request({url:o,method:"POST",data:n},t)}PublicListConnector(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/connector/list"),n={project_id:i.project_id,project_publish_status:i.project_publish_status};return this.request({url:o,method:"GET",params:n},t)}PublicPublishConnector(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/connector/publish_project"),n={project_id:i.project_id,connector_configs:i.connector_configs};return this.request({url:o,method:"POST",data:n},t)}PublicGetDeployCount(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_history/get_count"),n={project_id:i.project_id};return this.request({url:o,method:"GET",params:n},t)}GetRuntimeLogCount(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/runtime_log/count"),n={project_id:i.project_id};return this.request({url:o,method:"GET",params:n},t)}PublicExchangeFeishuAuthCode(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/feishu/auth/exchange_code"),n={project_id:i.project_id,code:i.code,verify_state:i.verify_state};return this.request({url:o,method:"POST",data:n},t)}PublicRevokeFeishuAuth(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/feishu/auth/revoke"),n={project_id:i.project_id};return this.request({url:o,method:"POST",data:n},t)}PublicUpdateDefaultDomainPrefix(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/domain_related/update_default_prefix"),n={project_id:i.project_id,prefix:i.prefix};return this.request({url:o,method:"POST",data:n},t)}PublicFeishuWebhookEvent(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/feishu/webhook/event"),n={body:i.body};return this.request({url:o,method:"POST",data:n},t)}PublicCheckCreateDomainRelated(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/domain_related/check_create"),n={project_id:i.project_id};return this.request({url:o,method:"GET",params:n},t)}PublicGetHostedUsageMonthly(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/hosted_usage/monthly"),n={project_id:i.project_id,bill_month:i.bill_month};return this.request({url:o,method:"GET",params:n},t)}PublicGetEstimateHostedCost(e,t){const i=this.genBaseURL("/api/coding/deployment/hosted_usage/estimate_cost");return this.request({url:i,method:"GET"},t)}PublicGetDeployHistoryLog(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_history/log"),n={deploy_history_id:i.deploy_history_id,key:i.key};return this.request({url:o,method:"GET",params:n},t)}PublicGetMPICPStatus(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/mini_program/icp_status"),n={project_id:i.project_id,app_id:i.app_id,connector_id:i.connector_id};return this.request({url:o,method:"GET",params:n},t)}PublicGetOnlineDeployHistory(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_history/get_online"),n={project_id:i.project_id};return this.request({url:o,method:"GET",params:n},t)}PublicGetUserAnalyticsMetrics(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/metrics/user_analytics/get"),n={project_id:i.project_id,time_range:i.time_range};return this.request({url:o,method:"GET",params:n},t)}PublicPauseDeployUnit(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_unit/pause"),n={project_id:i.project_id,deploy_history_id:i.deploy_history_id};return this.request({url:o,method:"POST",data:n},t)}PublicStopDeployUnit(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_unit/stop"),n={project_id:i.project_id,deploy_history_id:i.deploy_history_id};return this.request({url:o,method:"POST",data:n},t)}PublicResumeDeployUnit(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/deploy_unit/resume"),n={project_id:i.project_id,deploy_history_id:i.deploy_history_id};return this.request({url:o,method:"POST",data:n},t)}PublicReportUserAnalytics(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/analytics/report"),n={events:i.events},s={project_id:i.project_id,did:i.did};return this.request({url:o,method:"POST",data:n,params:s},t)}PublicCreateDefaultDomainRelated(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/domain_related/create_default"),n={project_id:i.project_id,prefix:i.prefix};return this.request({url:o,method:"POST",data:n},t)}PublicGetProtectionConfig(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/protection_config/get"),n={project_id:i.project_id};return this.request({url:o,method:"GET",params:n},t)}PublicUpdateProtectionConfig(e,t){const i=e||{},o=this.genBaseURL("/api/coding/deployment/protection_config/update"),n={project_id:i.project_id,config:i.config};return this.request({url:o,method:"POST",data:n},t)}}const kl=new Cl({}),Al={[el.Pending]:"Pending",[el.Running]:"Running",[el.Succeeded]:"Succeeded",[el.Failed]:"Failed",[el.Canceled]:"Canceled",[el.Interrupted]:"Interrupted"},El=[el.Succeeded,el.Failed,el.Canceled],Rl=e=>e&&Al[e]||"Unknown";function jl(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}class zl{static __initStatic(){this.INSTANCE=new zl}static getInstance(){return zl.INSTANCE||(zl.INSTANCE=new zl),this.INSTANCE}async pollDeployStatus(t){const{projectId:i,deployHistoryId:o,onBeforePoll:n,onStatusChange:s}=t;let r;for(;;){jl([n,"optionalCall",e=>e()]);const t=jl([await kl.PublicGetDeployHistory({project_id:i,deploy_history_id:o}),"optionalAccess",e=>e.data]);if(!t)throw new e.CozeError(e.ErrorCode.E5000,"Failed to get deploy history data during polling");const a=t.status;if(a!==r&&(r=a,jl([s,"optionalCall",e=>e(t)])),El.includes(a))return t;await new Promise((e=>setTimeout(e,3e3)))}}async getLatestDeployHistoryId(e){const{projectId:t}=e;return jl([await kl.PublicListDeployHistory({page_size:1,project_id:t}),"optionalAccess",e=>e.data,"optionalAccess",e=>e.deploy_history_list,"optionalAccess",e=>e[0],"optionalAccess",e=>e.deploy_history_id])}async getDeployHistory(t){const{projectId:i,deployHistoryId:o}=t,n=await kl.PublicGetDeployHistory({project_id:i,deploy_history_id:o});if(!jl([n,"optionalAccess",e=>e.data]))throw new e.CozeError(e.ErrorCode.E5000,"Failed to get deploy history data");return n.data}canDeploy(t){return[e.VibeProjectType.AssistantAgent,e.VibeProjectType.GeneralWeb,e.VibeProjectType.App,e.VibeProjectType.Skill,e.VibeProjectType.Agent,e.VibeProjectType.Automation].includes(t)}async getCommitList({projectId:t}){const i=await e.IdeApi.ProxySandboxMessage({ProjectID:t,Method:"repo_version.commit.list",Params:JSON.stringify({project_id:t})});return e.safeJsonParse(i.data,{commits:[]}).commits||[]}}zl.__initStatic();const wl=zl.getInstance();function Ul(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function Ll(e,t){return null!=e?e:t()}function Ol(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function Il(e,t){return null!=e?e:t()}function Bl(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const ql=e=>{if(null==e)return null;return 0===e.trim().length?null:e},xl=t=>{t.command("send [message]").description("Send a prompt message to Coze Coding project chat").option("--wait","Wait for the chat response before returning").option("--stdin","Read additional context from stdin (pipe input)").config({help:{brief:"Send a message to project chat",description:"Send a prompt message to the specified Coze Coding project chat. The message can be provided as a positional argument. Use --stdin to pipe additional context. Use @<path> to mention and upload local files as context.",examples:[{desc:"Send a message to project",cmd:'coze code message send "Fix the bug in auth module" -p 123456',tags:["[RECOMMENDED]"]},{desc:"Send and wait for the response",cmd:'coze code message send "Fix the bug in auth module" -p 123456 --wait'},{desc:"Mention a file with @",cmd:'coze code message send "Refactor @src/utils.ts to use async/await" -p 123456'},{desc:"Mention multiple files",cmd:'coze code message send "Compare @src/old.ts and @src/new.ts, list the differences" -p 123456'},{desc:"Send message with stdin context",cmd:'cat error.log | coze code message send "Analyze this error" --stdin -p 123456'},{desc:"Use environment variable for project",cmd:'export COZE_PROJECT_ID=123456 && coze code message send "Hello"'}],errors:[{code:e.ErrorCode.E1000,name:"MISSING_MESSAGE",desc:"No message content provided",fix:"Provide MESSAGE argument or use --stdin with piped content",example:'coze code message send "Your question" -p 123456 # or: echo "context" | coze code message send --stdin "question" -p 123456'},{code:e.ErrorCode.E1001,name:"MISSING_PROJECT_ID",desc:"No project ID provided via -p/--project-id or COZE_PROJECT_ID env",fix:"Provide -p/--project-id option or set COZE_PROJECT_ID environment variable",example:'coze code message send "Hello" -p 123456'},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid API token",fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable",example:"coze auth login --oauth"},{code:e.ErrorCode.E5000,name:"UNEXPECTED_ERROR",desc:"CLI context is not initialized",fix:"Please retry and make sure the CLI is initialized correctly"}],schema:{input:{message:{type:"string",required:!1,description:"The prompt message to send to the project chat"},wait:{type:"boolean",required:!1,description:"Wait for the chat response before returning. Without this flag, the message is sent in the background."},stdin:{type:"boolean",required:!1,description:"Read additional context from stdin (pipe input)."}},output:{type:"object",properties:{content:{type:"string",description:"The chat response content"}}}}}}).action((async(t,i,o)=>{const n=o.getContext();try{if(!n)throw new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized");const s=Bl([o,"access",e=>e.parent,"optionalAccess",e=>e.opts,"call",e=>e()]),r=Il(Bl([s,"optionalAccess",e=>e.projectId]),(()=>process.env.COZE_PROJECT_ID));if(!r)throw new e.CozeError(e.ErrorCode.E1001,"Missing required option: --project-id (or env COZE_PROJECT_ID)");const a=await Bl([n,"optionalAccess",e=>e.auth,"optionalAccess",e=>e.getValidAccessToken,"call",e=>e()]);if(!a)throw new e.CozeError(e.ErrorCode.E2001,"Missing API token: set env COZE_API_TOKEN or run `coze auth login` first");const{wait:c,stdin:d}=i;let p=null;d&&(p=await Qs());const l=ql(t),u=ql(p);if(!l&&!u)throw new e.CozeError(e.ErrorCode.E1000,"Missing prompt: provide PROMPT argument or use --stdin");const _=l&&u?`${l}\n\n${u}`:Il(Il(l,(()=>u)),(()=>"")),m=new Set,g=await e.sendProjectChatMessage({projectId:r,prompt:_,apiBaseUrl:n.config.apiBaseUrl,accessToken:a,xTTEnv:n.config.xTTEnv,key:`coze-coding-cli:message:${r}`,onWarn:e=>n.ui.warn(e),waitForResponse:!!c,onMessageItem:e=>{if(c&&"json"===n.format&&e.finish){const t=(e=>{const t=Il(e.msg_id,(()=>"")),i=Il(e.sequence_id,(()=>""));return`${e.type}:${t}:${String(i)}`})(e);m.has(t)||(m.add(t),n.response.print({content:e.content,role:e.role,finish:e.finish,type:e.type}))}}});if(c)"text"===n.format&&n.response.print(Il(Bl([g,"access",e=>e.lastAnswerMessage,"optionalAccess",e=>e.content,"access",e=>e.answer]),(()=>"")));else{const e=`Message sent. Use \`coze code message status -p ${r}\` to check the result.`;"json"===n.format?n.response.print({status:"sent",project_id:r,message:e}):n.response.print(e),process.exit(0)}}catch(e){V(e,n)}}))};function Dl(e,t){return null!=e?e:t()}function Ml(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function Gl(e,t){return null!=e?e:t()}function Nl(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const Fl=async(t,i)=>{const o=i.getContext();try{if(!o)throw new e.CozeError("E5000","CLI context is not initialized");const n=Nl([i,"access",e=>e.parent,"optionalAccess",e=>e.opts,"call",e=>e()]),s=Gl(Nl([n,"optionalAccess",e=>e.projectId]),(()=>process.env.COZE_PROJECT_ID));if(!s)throw new e.CozeError("E1001","Missing required option: --project-id (or env COZE_PROJECT_ID)");if(!await Nl([o,"optionalAccess",e=>e.auth,"optionalAccess",e=>e.getValidAccessToken,"call",e=>e()]))throw new e.CozeError("E2001","Missing API token: set env COZE_API_TOKEN or run `coze auth login` first");if(t.after&&t.before)throw new e.CozeError("E1000","--after and --before cannot be used together. Use only one cursor at a time.");o.ui.verbose(`Fetching conversation history for project ${s}...`);const r=e.createChatCore({key:`coze-coding-cli:history:${s}`,apiBaseUrl:o.config.apiBaseUrl});try{const e=t.after?"loadNext":"loadPrev",i="loadNext"===e?"11":"10",n=await r.getHistoryMessage({limit:i,project_id:s,after:t.after,before:t.before}),a=[],c=new Map,d=new Map;n.histories.forEach((e=>{if(e.user){const t=e.user.msg_id;c.has(t)||a.push(t);const i=(e=>{const t=Nl([e,"optionalAccess",e=>e.content]);return Gl(Gl(Nl([t,"optionalAccess",e=>e.query,"optionalAccess",e=>e.prompt]),(()=>Nl([t,"optionalAccess",e=>e.retry,"optionalAccess",e=>e.prompt]))),(()=>Nl([t,"optionalAccess",e=>e.edit,"optionalAccess",e=>e.prompt])))})(e.user.message);c.set(t,i?(e=>e.map((e=>"text"===e.type?e.content.text:"file"===e.type?`${Ml([e,"access",e=>e.content,"access",e=>e.file,"optionalAccess",e=>e.path])} ${Dl(Ml([e,"access",e=>e.content,"access",e=>e.file,"optionalAccess",e=>e.from,"optionalAccess",e=>e[0]]),(()=>""))} ${Dl(Ml([e,"access",e=>e.content,"access",e=>e.file,"optionalAccess",e=>e.to,"optionalAccess",e=>e[0]]),(()=>""))} `:"console"===e.type?Ml([e,"access",e=>e.content,"access",e=>e.console,"optionalAccess",e=>e.content]):"node"===e.type?Ml([e,"access",e=>e.content,"access",e=>e.node,"optionalAccess",e=>e.node_title]):"upload_file"===e.type?Ml([e,"access",e=>e.content,"access",e=>e.upload_file,"optionalAccess",e=>e.file_name]):"page"===e.type?Ml([e,"access",e=>e.content,"access",e=>e.page,"optionalAccess",e=>e.page_title]):"page_elements"===e.type?Ml([e,"access",e=>e.content,"access",e=>e.page_elements,"optionalAccess",e=>e[0],"optionalAccess",e=>e.path,"optionalAccess",e=>e[0],"optionalAccess",e=>e.node_name]):"wf_canvas_change"===e.type?Ml([e,"access",e=>e.content,"access",e=>e.wf_canvas_change,"optionalAccess",e=>e.query]):"")).join(" "))(i):"")}if(e.assistant){const t=e.assistant.messages.find((e=>"answer"===e.type&&e.content.answer));if(!t)return;const i=t.query_msg_id,o=t.content.answer;"string"==typeof i&&"string"==typeof o&&d.set(i,o)}}));const p=a[0],l=a[a.length-1],u=a.reverse().filter((e=>d.has(e))).map((e=>({userMessage:Gl(c.get(e),(()=>"")),answer:Gl(d.get(e),(()=>""))}))),_={histories:u,cursor:{after:p,before:l,has_more:n.has_more,loadDirection:e}};if("json"===o.format)o.response.print(_);else{if(0===u.length)return void o.response.print("No conversation history found.");u.forEach(((e,t)=>{o.response.print(`--- #${t+1} ---\nQ: ${e.userMessage}\nA: ${e.answer}\n`)})),o.response.print(`\n[cursor] after=${p}, before=${l}, has_more=${n.has_more}, loadDirection=${e}`)}}finally{r.destroy()}}catch(e){V(e,o)}};function $l(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const Vl=t=>{const i=t.command("message");i.description("Manage project chat messages").config({help:{brief:"Manage project chat messages",description:"Manage Coze Coding project chat messages.\n\nThis command group provides:\n- send: Send a new message to the project chat\n- status: Query the status of current chat message (auto-fetch result when completed)\n- cancel: Cancel an ongoing chat message\n- history: View conversation history",examples:[{desc:"Send a message to project",cmd:'coze code message send "Fix the bug" -p 123456',tags:["[RECOMMENDED]"]},{desc:"Check message status",cmd:"coze code message status -p 123456"},{desc:"Cancel ongoing message",cmd:"coze code message cancel -p 123456"},{desc:"View conversation history",cmd:"coze code message history -p 123456"}],errors:[{code:e.ErrorCode.E1001,name:"MISSING_PROJECT_ID",desc:"No project ID provided via -p/--project-id or COZE_PROJECT_ID env",fix:"Provide -p/--project-id option or set COZE_PROJECT_ID environment variable",example:'coze code message send "Hello" -p 123456'},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid API token",fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable",example:"coze auth login --oauth"}],schema:{input:{projectId:{type:"string",required:!0,description:"Coze project ID (can also be set via COZE_PROJECT_ID env)"}}},seeAlso:["coze code project list","coze code project create"]}}).option("-p, --project-id <id>","Coze project id (or env COZE_PROJECT_ID)"),xl(i),(t=>{t.command("status").description("Query current project chat message status and get result when completed").config({help:{brief:"Query chat message status",description:"Get the current status of the chat message for the specified project. Returns status information such as running, completed, or error. When the chat is completed, automatically fetches and returns the result.",examples:[{desc:"Check message status (auto-fetch result when completed)",cmd:"coze code message status -p 123456",tags:["[RECOMMENDED]"]},{desc:"With environment variable",cmd:"coze code message status"},{desc:"Output as JSON",cmd:"coze code message status -p 123456 --format json"}],errors:[{code:e.ErrorCode.E1001,name:"MISSING_PROJECT_ID",desc:"No project ID provided",fix:"Provide -p/--project-id option or set COZE_PROJECT_ID environment variable"},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid API token",fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable"},{code:e.ErrorCode.E5000,name:"UNEXPECTED_ERROR",desc:"CLI context is not initialized",fix:"Please retry and make sure the CLI is initialized correctly"}],schema:{input:{projectId:{type:"string",required:!0,description:"Coze project ID"}},output:{type:"object",properties:{status:{type:"string",description:"Message status (running/completed/error)"},message:{type:"string",description:"Status message or error details"},answer:{type:"string",description:"The chat answer content (only when completed)"}}}}}}).action((async(t,i)=>{const o=i.getContext();try{if(!o)throw new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized");const t=Ol([i,"access",e=>e.parent,"optionalAccess",e=>e.opts,"call",e=>e()]),n=Ll(Ol([t,"optionalAccess",e=>e.projectId]),(()=>process.env.COZE_PROJECT_ID));if(!n)throw new e.CozeError(e.ErrorCode.E1001,"Missing required option: --project-id (or env COZE_PROJECT_ID)");o.ui.verbose(`Fetching chat status for project ${n}...`);const{code:s,msg:r,reply_id:a,...c}=await e.BuildAgentApi.GetChatCLIMessageStatus({project_id:n});if("done"===c.status){o.ui.verbose(`Chat completed, fetching result for project ${n}...`);const t=await e.BuildAgentApi.GetChatCLIMessageResultContent({project_id:n}),i="data"in t?t.data:t;"json"===o.format?o.response.print({...c,answer:i.answer}):o.response.print(`status: [${c.status}]\nanswer: ${Ll(i.answer,(()=>""))}`)}else"json"===o.format?o.response.print(c):o.response.print(c.status)}catch(e){V(e,o)}}))})(i),function(t){t.command("cancel").description("Cancel current project chat message").config({help:{brief:"Cancel ongoing chat message",description:"Cancel the currently running chat message for the specified project. Useful for stopping long-running or stuck message generation.",examples:[{desc:"Cancel current message",cmd:"coze code message cancel -p 123456",tags:["[RECOMMENDED]"]},{desc:"With environment variable",cmd:"coze code message cancel"}],errors:[{code:e.ErrorCode.E1001,name:"MISSING_PROJECT_ID",desc:"No project ID provided",fix:"Provide -p/--project-id option or set COZE_PROJECT_ID environment variable"},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid API token",fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable"},{code:e.ErrorCode.E5000,name:"UNEXPECTED_ERROR",desc:"CLI context is not initialized",fix:"Please retry and make sure the CLI is initialized correctly"}],schema:{input:{projectId:{type:"string",required:!0,description:"Coze project ID"}},output:{type:"object",properties:{status:{type:"string",description:"Cancel operation status"},message:{type:"string",description:"Result message"}}}}}}).action((async(t,i)=>{const o=i.getContext();try{if(!o)throw new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized");const t=$l([i,"access",e=>e.parent,"optionalAccess",e=>e.opts,"call",e=>e()]),s=null!=(n=$l([t,"optionalAccess",e=>e.projectId]))?n:(()=>process.env.COZE_PROJECT_ID)();if(!s)throw new e.CozeError(e.ErrorCode.E1001,"Missing required option: --project-id (or env COZE_PROJECT_ID)");const{accessToken:r}=o.config;if(!r)throw new e.CozeError(e.ErrorCode.E2001,"Missing API token: set env COZE_API_TOKEN or run `coze auth login` first");o.ui.verbose(`Canceling chat message for project ${s}...`);const{message:a}=await e.BuildAgentApi.CancelChatCLIMessage({project_id:s});"json"===o.format?o.response.print({message:a}):o.response.print(a)}catch(e){V(e,o)}var n}))}(i),(e=>{e.command("history").description("View conversation history of the project chat").option("--after <msg_id>","Cursor for fetching newer messages (smaller index)").option("--before <msg_id>","Cursor for fetching older messages (larger index)").config({help:{brief:"View conversation history",description:"Retrieve and display the conversation history for the specified Coze Coding project. Shows each round of user messages and LLM responses. By default, returns the latest 10 rounds of conversation. Use --after or --before cursors for pagination.",examples:[{desc:"View latest 10 rounds of conversation history",cmd:"coze code message history -p 123456",tags:["[RECOMMENDED]"]},{desc:"With environment variable",cmd:"coze code message history"},{desc:"Output as JSON with cursor info",cmd:"coze code message history -p 123456 --format json"},{desc:"Fetch newer messages after a cursor",cmd:"coze code message history -p 123456 --after msg_xxx"},{desc:"Fetch older messages before a cursor",cmd:"coze code message history -p 123456 --before msg_yyy"}],errors:[{code:"E1000",name:"INVALID_ARGUMENT",desc:"--after and --before cannot be used together",fix:"Use only one cursor option at a time for pagination"},{code:"E1001",name:"MISSING_PROJECT_ID",desc:"No project ID provided",fix:"Provide -p/--project-id option or set COZE_PROJECT_ID environment variable"},{code:"E2001",name:"AUTH_FAILED",desc:"Missing or invalid API token",fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable"}],schema:{input:{projectId:{type:"string",required:!0,description:"Coze project ID"},after:{type:"string",description:'Cursor (message ID) for fetching newer messages. Newer messages have smaller index. Use the "after" value from previous output as this parameter.'},before:{type:"string",description:'Cursor (message ID) for fetching older messages. Older messages have larger index. Use the "before" value from previous output as this parameter.'}},output:{type:"object",properties:{histories:{type:"array",items:{type:"object",properties:{userMessage:{type:"string",description:"User's message in this round"},answer:{type:"string",description:"LLM's last answer with content"}}}},cursor:{type:"object",description:"Pagination cursor info for next/prev page requests",properties:{after:{type:"string",description:"Message ID of the newest result, use as --after to fetch newer messages (loadNext)"},before:{type:"string",description:"Message ID of the oldest result, use as --before to fetch older messages (loadPrev)"},has_more:{type:"boolean",description:"Whether there are more messages available"},loadDirection:{type:"string",enum:["loadNext","loadPrev"],description:"Load direction of current request. Defaults to 'loadPrev' (load older messages). 'loadNext' when --after is used, 'loadPrev' when --before is used or on initial request."}}}}}}}}).action(Fl)})(i)};function Wl(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function Hl(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function Kl(t){t.command("list").description("List project environment variables").option("--env <scope>","Environment scope: dev | prod","dev").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"List project environment variables",description:"Retrieve the list of environment variables for the specified project. Supports filtering by environment (dev/prod) and displays all configured sensitive information key names.",examples:[{desc:"List dev environment variables",cmd:"coze code env list -p <projectId>",tags:["[RECOMMENDED]"]},{desc:"List prod environment variables",cmd:"coze code env list -p <projectId> --env prod"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},env:{type:"string",required:!1,enum:["dev","prod"],description:"Environment scope (default: dev)"}},output:{command:{type:"string",description:"Command name"},status:{type:"string",description:"Execution status"},data:{type:"object",properties:{project_id:{type:"string",description:"Project ID"},project_type:{type:"string",description:"Project type"},env:{type:"string",description:"Environment scope"},secrets:{type:"array",description:"Environment variable list"}}}}},errors:[{code:e.ErrorCode.E3001,name:"PROJECT_NOT_FOUND",desc:"Project not found",fix:"Please confirm if the project ID is correct"}]}}).action((async function(t,i){const o=i.getContext(),{projectId:n}=t,s=Hl([await e.IdeApi.GetVibeProject({project_id:n}),"access",e=>e.data,"optionalAccess",e=>e.project_info,"optionalAccess",e=>e.project_type]),r=(a=t.env,"prod"===String(a||"dev").toLowerCase()?wi.prod:wi.dev);var a;const c=Hl([await Di.ListProjectSecret({env:r,project_id:n,...s===e.VibeProjectType.Skill?{with_providers:!0}:{}}),"optionalAccess",e=>e.data,"optionalAccess",e=>e.project_secrets,"optionalAccess",e=>e.secrets])||[];Hl([o,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e("Env secrets listed successfully.")]),Hl([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(c.map((e=>({secret_key:e.secret_key,secret_id:e.secret_id,secret_val:e.secret_val,secret_type:e.secret_type}))))])}))}function Jl(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const Ql=t=>{const i=t.command("env").config({help:{brief:"Manage project environment variables",description:"Manage project environment variables (Secrets). Supports setting, viewing, and deleting sensitive configuration information such as API keys and database connection strings in development and production environments.",examples:[{desc:"List environment variables",cmd:"coze code env list -p <projectId>"},{desc:"Set environment variable",cmd:"coze code env set KEY VALUE -p <projectId>"},{desc:"Delete environment variable",cmd:"coze code env delete KEY -p <projectId>"}],seeAlso:["coze code deploy","coze code project"]}}).description("Manage project environment variables");Kl(i),i.command("set <key> <value>").description("Set a project environment variable").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"Set project environment variable",description:"Add or update environment variables for the project. Environment variables are securely stored and used for sensitive information like API keys, passwords, etc.",examples:[{desc:"Set environment variable",cmd:"coze code env set <KEY> <VALUE> -p <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{key:{type:"string",required:!0,description:"Environment variable key"},value:{type:"string",required:!0,description:"Environment variable value"},projectId:{type:"string",required:!0,description:"Project ID"}},output:{command:{type:"string",description:"Command name"},status:{type:"string",description:"Execution status"},data:{type:"object",properties:{project_id:{type:"string",description:"Project ID"},key:{type:"string",description:"Set key name"},value:{type:"string",description:"Set value"}}}}},errors:[{code:e.ErrorCode.E3008,name:"SKILL_PROJECT_NOT_SUPPORTED",desc:"Skill project secret_type logic to be supplemented",fix:"This feature is not yet supported for Skill projects"}]}}).action((async function(t,i,o,n){const s=n.getContext(),{projectId:r}=o,a=Wl([await e.IdeApi.GetVibeProject({project_id:r}),"access",e=>e.data,"optionalAccess",e=>e.project_info,"optionalAccess",e=>e.project_type]);if(a===e.VibeProjectType.Skill)throw new e.CozeError(e.ErrorCode.E3008,"Skill project secret_type logic to be supplemented",{projectId:r,projectType:a});await Di.InsertProjectSecret({project_id:r,insert_secrets:{secrets:[{secret_key:t,secret_val:i}]}}),Wl([s,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e("Env secret set successfully")]),Wl([s,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({project_id:r,key:t,value:i})])})),function(t){t.command("delete <key>").description("Delete a project environment variable").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"Delete project environment variable",description:"Delete specified environment variables from the project. Supports deleting multiple variables simultaneously by passing the --key parameter multiple times.",examples:[{desc:"Delete a single environment variable",cmd:"coze code env delete <KEY> -p <projectId>",tags:["[RECOMMENDED]"]},{desc:"Delete multiple environment variables",cmd:"coze code env delete <KEY> -p <projectId>"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},key:{type:"string",required:!0,description:"Environment variable key name to delete"}},output:{message:{type:"string",description:"Result message"},key:{type:"string",description:"Deleted key"}}},errors:[{code:e.ErrorCode.E3003,name:"SECRET_NOT_FOUND",desc:"The specified environment variable does not exist",fix:"Please use `env list` first to confirm if the variable name is correct"}]}}).action((async function(t,i,o){const n=o.getContext(),{projectId:s}=i,r=[t],a=Jl([await Di.ListProjectSecret({env:wi.dev,project_id:s}),"optionalAccess",e=>e.data,"optionalAccess",e=>e.project_secrets,"optionalAccess",e=>e.secrets])||[],c=new Set(r.map((e=>String(e)))),d=a.filter((e=>c.has(String(e.secret_key||"")))).map((e=>e.secret_id)).filter(Boolean);if(0===d.length)throw new e.CozeError(e.ErrorCode.E3003,`No matched secrets by keys: ${r.join(", ")}`,{projectId:s,keys:r});await Di.DeleteProjectSecret({project_id:s,keys:d}),Jl([n,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e("Env has been delete successfully")]),Jl([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({message:"env has been delete successfully",key:t,project_id:s,keys:r,secret_ids:d})])}))}(i)};function Zl(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function Yl(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function Xl(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}const eu=t=>{const i=t.command("domain").config({help:{brief:"Manage custom domains for the project",description:"Manage custom domains for deployed projects. Supports adding, listing, and removing domains associated with a project, used to access deployed applications.",examples:[{desc:"List project domains",cmd:"coze code domain list <projectId>"},{desc:"Add custom domain",cmd:"coze code domain add example.com -p <projectId>"},{desc:"Delete domain",cmd:"coze code domain remove example.com -p <projectId>"}],seeAlso:["coze code deploy"]}}).description("Manage custom domains for the project");i.command("list").description("List custom domains of the project").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"List all domains bound to the project",description:"Retrieve a list of all custom domains bound to the specified project.",examples:[{desc:"List domains",cmd:"coze code domain list -p <projectId>",tags:["[RECOMMENDED]"]},{desc:"Output in JSON format",cmd:"coze code domain list -p <projectId> --format json"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"}},output:{type:"array",items:{type:"object",properties:{id:{type:"string",description:"Domain ID"},domain_host:{type:"string",description:"Domain host"}}}}},errors:[{code:e.ErrorCode.E3001,name:"PROJECT_NOT_FOUND",desc:"Project not found",fix:"Please confirm if the project ID is correct"}]}}).action((async function(e,t){const i=t.getContext(),{projectId:o}=e,n=Yl([await kl.PublicListDomainRelated({project_id:o}),"access",e=>e.data,"optionalAccess",e=>e.items])||[];Yl([i,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e("Fetched domains List successfully")]),Yl([i,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(n.map((e=>({id:e.id,domain_host:e.domain_host}))))])})),function(t){t.command("add <domain>").description("Add a custom domain to the project").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"Add custom domain to project",description:"Bind a custom domain to a specified project. The domain must follow standard format (e.g., example.com). Once bound, the deployed application can be accessed via this domain.",examples:[{desc:"Add domain",cmd:"coze code domain add <domain> -p <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},domain:{type:"string",required:!0,description:"Domain to add (e.g., example.com)"}},output:{command:{type:"string",description:"Command name"},status:{type:"string",description:"Execution status"},data:{type:"object",properties:{project_id:{type:"string",description:"Project ID"},domain:{type:"string",description:"Added domain"}}}}},errors:[{code:e.ErrorCode.E1004,name:"INVALID_DOMAIN",desc:"Incorrect domain format",fix:"Please use a standard domain format, e.g., example.com"}]}}).action((async function(t,i,o){const n=o.getContext(),{projectId:s}=i;if(!/^[a-zA-Z0-9][a-zA-Z0-9-]*\.[a-zA-Z0-9][a-zA-Z0-9-]*$/.test(t))throw new e.CozeError(e.ErrorCode.E1004,"Invalid domain",{domain:t});await kl.PublicCreateDomainRelated({project_id:s,domain:t}),Xl([n,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e(`Domain '${t}' added.`)]),Xl([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({project_id:s,domain:t})])}))}(i),function(t){t.command("remove <domain>").description("Remove a custom domain from the project").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"Delete custom domain of the project",description:"Remove a bound custom domain from the specified project.",examples:[{desc:"Delete domain",cmd:"coze code domain remove example.com -p <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},domain:{type:"string",required:!0,description:"Domain to delete"}},output:{command:{type:"string",description:"Command name"},status:{type:"string",description:"Execution status"},data:{type:"object",properties:{project_id:{type:"string",description:"Project ID"},domain:{type:"string",description:"Deleted domain"}}}}},errors:[{code:e.ErrorCode.E1004,name:"INVALID_DOMAIN",desc:"Incorrect domain format",fix:"Please use a standard domain format, e.g., example.com"},{code:e.ErrorCode.E3005,name:"DELETE_FAILED",desc:"Failed to remove domain",fix:"Please confirm the domain is bound to the project and you have sufficient permissions"}]}}).action((async function(e,t,i){const o=i.getContext(),{projectId:n}=t;await kl.PublicDeleteDomainRelated({project_id:n,domain:e}),Zl([o,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",t=>t(`Domain '${e}' removed.`)]),Zl([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",t=>t({message:`Domain '${e}' removed.`,domain:e})])}))}(i)};function tu(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function iu(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function ou(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function nu(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function su(t){const i=t.command("deploy <projectId>").description("Deploy the project to production environment").option("--commit-id <commitId>","Commit ID (optional, queries latest if omitted)").option("--wait","Wait for deployment to complete").config({help:{brief:"Deploy the project to production environment",description:"Deploy the specified project to the production environment. Supports multiple project types (Agent, Workflow, Skill, Web, Mini-program, etc.), automatically fetches the latest commit, and triggers the deployment process.",examples:[{desc:"Deploy latest project",cmd:"coze code deploy <projectId>",tags:["[RECOMMENDED]"]},{desc:"Deploy and wait for completion",cmd:"coze code deploy <projectId> --wait"},{desc:"Deploy a specific commit",cmd:"coze code deploy <projectId> --commit-id <commitId>"},{desc:"View deployment status",cmd:"coze code deploy status <projectId>"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},wait:{type:"boolean",required:!1,description:"Wait for deployment to complete"}},output:{projectId:{type:"string",description:"Project ID"},status:{type:"string",description:"Deployment status"},domain:{type:"string",description:"Deployed domain"},deployHistoryId:{type:"string",description:"Deployment history ID"},commitHash:{type:"string",description:"Commit hash"}}},errors:[{code:e.ErrorCode.E3007,name:"MISSING_COMMIT_HASH",desc:"No commits found in the project",fix:"Please commit your changes first before deploying"},{code:e.ErrorCode.E2002,name:"MINIPROGRAM_NOT_AUTHORIZED",desc:"Mini-program AppID not configured",fix:"Please complete the Mini-program AppID configuration in the project settings"},{code:e.ErrorCode.E1006,name:"UNSUPPORTED_PROJECT_TYPE",desc:"Project type is not supported for deployment",fix:"Please confirm the project type and try again with a supported project"}]}}).description("Deploy the project to production environment").action((async function(t,i,o){const n=o.getContext(),{wait:s,commitId:r}=i,a=nu([(await e.IdeApi.GetVibeProject({project_id:t})).data||{},"access",e=>e.project_info,"optionalAccess",e=>e.project_type]);if(!wl.canDeploy(a)){const t=`Project type ${bd(a)} is not supported for deployment`;throw new e.CozeError(e.ErrorCode.E1006,t,{projectType:a})}if(a===e.VibeProjectType.AssistantAgent){const i=await e.axiosInstance.post("/api/sandbox/coze_coding/devbox/open_claw/deploy",{project_id:t},{headers:{"content-type":"application/json"}});return nu([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Deploying (AssistantAgent)...")]),void nu([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({command:"deploy",status:"ok",data:{type:a,data:nu([i,"optionalAccess",e=>e.data])}})])}let c=r;if(!c){nu([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Fetching latest commit...")]);const e=await wl.getCommitList({projectId:t});c=nu([e,"optionalAccess",e=>e[0],"optionalAccess",e=>e.id])}if(!c){const i="Missing commitHash: pass --commit-hash <commitHash>";throw new e.CozeError(e.ErrorCode.E3007,i,{projectId:t})}if(a===e.VibeProjectType.WechatMiniProgram){nu([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Checking Mini-program authorization...")]);if(!nu([await kl.PublicGetAuthStatus({project_id:t,connector_id:"10000127"}),"access",e=>e.data,"optionalAccess",e=>e.bound_related_id])){const t="Deployment failed, please complete the Mini-program AppID configuration";throw new e.CozeError(e.ErrorCode.E2002,t)}}nu([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Checking deploy config...")]),await kl.PublicGetDeployConfig({project_id:t,commit_hash:c},{__disableErrorToast:!0});let d="";const p=await Di.ListProjectSecret({env:wi.dev,project_id:t,with_providers:!0}),l=nu([p,"optionalAccess",e=>e.data,"optionalAccess",e=>e.project_secrets,"optionalAccess",e=>e.secrets])||[],u=nu([p,"optionalAccess",e=>e.data,"optionalAccess",e=>e.project_cred_providers])||[];nu([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Encrypting secrets...")]);d=nu([await Di.EncryptProjectSecret({project_id:t,project_type:a===e.VibeProjectType.Skill?zi.skill:void 0,encrypt_secrets:{secrets:l.map((e=>({secret_key:e.secret_key||"",secret_val:e.secret_val||"",secret_id:e.secret_id||"",secret_type:e.secret_type===Ui.consumer?ri.consumer3:ri.user_custom2}))),...a===e.VibeProjectType.Skill?{cred_providers:u}:{}}}),"optionalAccess",e=>e.data,"optionalAccess",e=>e.sealed_secrets])||"",nu([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Deploying...")]);const _=nu([await kl.PublicCreateDeployHistory({project_id:t,encrypt_env_variable:d,commit_hash:c}),"optionalAccess",e=>e.data,"optionalAccess",e=>e.deploy_history_id]);nu([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Deploy started.")]),s&&_?await wl.pollDeployStatus({projectId:t,deployHistoryId:_,onBeforePoll:()=>{nu([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Polling deployment status...")])},onStatusChange:e=>{const i=Rl(e.status);nu([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",o=>o({projectId:t,status:i,domain:nu([e,"access",e=>e.domain_list,"optionalAccess",e=>e[0]]),deployHistoryId:_,commitHash:e.commit_hash})])}}):nu([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({projectId:t,status:Rl(el.Pending),domain:"",deployHistoryId:_,commitHash:c})])}));!function(t){t.command("status <projectId>").description("Check deployment status").option("--deploy-id <deployId>","Deployment history ID (optional, queries latest if omitted)").config({help:{brief:"Query project deployment status",description:"Query the deployment status of a specified project. If no deployment history ID is specified, it automatically queries the latest deployment record. Supports viewing deployment progress, results, and error messages.",examples:[{desc:"Query latest deployment status",cmd:"coze code deploy status <projectId>",tags:["[RECOMMENDED]"]},{desc:"Query specific deployment record",cmd:"coze code deploy status <projectId> --deploy-id <deployHistoryId>"},{desc:"Wait for deployment to complete",cmd:"coze code deploy status <projectId> --wait"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},deployId:{type:"string",required:!1,description:"Deployment history ID (optional, queries latest if omitted)"},wait:{type:"boolean",required:!1,description:"Wait for deployment to complete"}},output:{projectId:{type:"string",description:"Project ID"},status:{type:"string",description:"Deployment status"},domain:{type:"string",description:"Deployed domain"},deployHistoryId:{type:"string",description:"Deployment history ID"},commitHash:{type:"string",description:"Commit hash"}}},errors:[{code:e.ErrorCode.E3006,name:"NO_DEPLOYMENT_HISTORY",desc:"No deployment history found for this project",fix:"Please deploy the project first using `coze code deploy <projectId>`"}]}}).action((async function(t,i,o){const n=o.getContext(),{deployId:s}=i,{wait:r}=tu([o,"access",e=>e.parent,"optionalAccess",e=>e.opts,"call",e=>e()])||{};let a=s;if(!a&&(tu([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("get latest deployment record...")]),a=await wl.getLatestDeployHistoryId({projectId:t}),!a))throw new e.CozeError(e.ErrorCode.E3006,"No deployment history found for this project");if(r)await wl.pollDeployStatus({projectId:t,deployHistoryId:a,onBeforePoll:()=>{tu([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Polling deployment status...")])},onStatusChange:e=>{const i=Rl(e.status);tu([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",o=>o({projectId:t,status:i,domain:tu([e,"access",e=>e.domain_list,"optionalAccess",e=>e[0]]),deployHistoryId:a,commitHash:e.commit_hash})])}});else{tu([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Querying deployment status...")]);const e=await wl.getDeployHistory({projectId:t,deployHistoryId:a}),i=Rl(e.status),o=e.domain_list||[];tu([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",n=>n({projectId:t,status:i,domain:o[0],deployHistoryId:a,commitHash:e.commit_hash})])}}))}(i),function(e){e.command("list <projectId>").description("List deployment history for a project").option("--page-size <pageSize>","Number of records per page","10").option("--page-token <pageToken>","Page token for pagination").config({help:{brief:"List project deployment history",description:"List the deployment history of a specified project. Supports pagination to browse historical deployment records including status, commit hash, domains and timestamps.",examples:[{desc:"List deployment history",cmd:"coze code deploy list <projectId>",tags:["[RECOMMENDED]"]},{desc:"List with custom page size",cmd:"coze code deploy list <projectId> --page-size 20"},{desc:"List next page",cmd:"coze code deploy list <projectId> --page-token <token>"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},pageSize:{type:"number",required:!1,description:"Number of records per page (default: 10)"},pageToken:{type:"string",required:!1,description:"Page token for pagination"}},output:{type:"array",items:{deploy_history_id:{type:"string",description:"Deployment history ID"},status:{type:"string",description:"Deployment status"},commit_hash:{type:"string",description:"Commit hash"},domain_list:{type:"array",description:"Deployed domains"},created_at:{type:"string",description:"Creation timestamp"}}}}}}).action((async function(e,t,i){const o=i.getContext(),n=Number(t.pageSize)||10,s=(iu([await kl.PublicListDeployHistory({project_id:e,page_size:n,page_token:t.pageToken}),"optionalAccess",e=>e.data,"optionalAccess",e=>e.deploy_history_list])||[]).map((e=>({deploy_history_id:e.deploy_history_id,project_id:e.project_id,status:Rl(e.status),commit_hash:e.commit_hash_short||e.commit_hash,domain_list:e.domain_list,created_at:e.created_at,can_rollback:e.can_rollback})));iu([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(s)])}))}(i),function(t){t.command("fix <projectId>").description("Fix a failed deployment by sending deploy logs to AI").option("--deploy-id <deployId>","Deployment history ID (optional, queries latest failed if omitted)").option("--wait","Wait for fix message response").config({help:{brief:"Fix a failed deployment",description:"Diagnose and fix a failed deployment. Retrieves deploy logs and sends them to AI for analysis and automatic fix. Only works when the deployment status is Failed.",examples:[{desc:"Fix latest failed deployment",cmd:"coze code deploy fix -p <projectId>",tags:["[RECOMMENDED]"]},{desc:"Fix a specific deployment",cmd:"coze code deploy fix <projectId> --deploy-id <deployId>"},{desc:"Fix and wait for result",cmd:"coze code deploy fix <projectId> --wait"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},deployId:{type:"string",required:!1,description:"Deployment history ID (queries latest failed if omitted)"},wait:{type:"boolean",required:!1,description:"Wait for fix message response"}},output:{type:"object",properties:{deploy_history_id:{type:"string"},status:{type:"string"},message:{type:"string"}}}}}}).action((async function(t,i,o){const n=o.getContext();if(!n)throw new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized");const{deployId:s}=i,{wait:r}=ou([o,"access",e=>e.parent,"optionalAccess",e=>e.opts,"call",e=>e()])||{};let a=s;if(s||(a=await wl.getLatestDeployHistoryId({projectId:t})),!a)throw new e.CozeError(e.ErrorCode.E5002,`No deploy history found for project ${t}`,{project_id:t});const c=ou([await kl.PublicGetDeployHistory({project_id:t,deploy_history_id:a}),"optionalAccess",e=>e.data]);if(ou([c,"optionalAccess",e=>e.status])!==el.Failed){const t=Rl(ou([c,"optionalAccess",e=>e.status]));throw new e.CozeError(e.ErrorCode.E3009,`Deployment ${a} is not in Failed status (current: ${t}). Only failed deployments can be fixed.`,{deploy_history_id:a,status:ou([c,"optionalAccess",e=>e.status])})}const d=c.deploy_log_url;if(!d)throw new e.CozeError(e.ErrorCode.E5002,`No deploy log URL found for deployment ${a}`,{deploy_history_id:a});const p=await e.customFetch.fetch(d,{method:"GET"}),l=await p.text();if(!l)throw new e.CozeError(e.ErrorCode.E5002,`Deploy log is empty for deployment ${a}`,{deploy_history_id:a,deploy_log_url:d});const u=`修复以下部署错误:\n${l}`,_=await ou([n,"access",e=>e.auth,"optionalAccess",e=>e.getValidAccessToken,"call",e=>e()]);if(!_)throw new e.CozeError(e.ErrorCode.E2001,"Missing API token: set env COZE_API_TOKEN or run `coze auth login` first");if(r){const e=await Ad.sendMessage({projectId:t,prompt:u,apiBaseUrl:n.config.apiBaseUrl,accessToken:_,xTTEnv:n.config.xTTEnv,key:`coze-coding-cli:message:${t}`});ou([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",t=>t({deploy_history_id:a,status:"fix_sent",message:e.lastAnswerMessage})])}else Ad.sendMessageRunTask({projectId:t,prompt:u,apiBaseUrl:n.config.apiBaseUrl,accessToken:_,xTTEnv:n.config.xTTEnv,key:`coze-coding-cli:message:${t}`})}))}(i)}function ru(t){const i=t.command("code").description("Coze Coding CLI utilities").config({help:{brief:"Coze Coding project management",description:"Manage Coze Coding projects, including project creation, messaging, deployment, environment variables, domains, skills, and previews.",examples:[{desc:"Create a new project",cmd:'coze code project create --message "Create a chatbot" --type web'},{desc:"Send a message",cmd:'coze code message send "Fix the bug" -p <projectId>'},{desc:"Deploy project",cmd:"coze code deploy <projectId>"},{desc:"Preview project",cmd:"coze code preview <projectId>"}],seeAlso:["coze auth","coze space","coze organization"]}});Vl(i),su(i),zd(i),Ql(i),eu(i),(e=>{const t=e.command("skill").config({help:{brief:"Manage project skills",description:"Manage skills associated with a project. Skills are important components to extend project capabilities, supporting adding, viewing, and removing project skills.",examples:[{desc:"List project skills",cmd:"coze code skill list -p <projectId>"},{desc:"Add skill",cmd:"coze code skill add <skillId> -p <projectId>"},{desc:"Remove skill",cmd:"coze code skill remove <skillId> -p <projectId>"}],seeAlso:["coze code project"]}}).description("Manage project skills");Ga(t),Fa(t),xa(t)})(i),function(t){t.command("preview <projectId>").description("Get deployment preview info for the project").config({help:{brief:"Get project preview URL",description:"Get the sandbox preview URL for the project. Supports AssistantAgent and GeneralWeb project types, returning an accessible preview URL. Sandbox initialization takes 1-3 minutes.",examples:[{desc:"Get preview URL",cmd:"coze code preview <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"}},output:{type:{type:"string",description:"Project type"},preview_url:{type:"string",description:"Preview URL"}}},errors:[{code:e.ErrorCode.E1006,name:"UNSUPPORTED_PROJECT_TYPE",desc:"Unsupported project type",fix:"Preview feature only supports AssistantAgent and GeneralWeb project types"},{code:e.ErrorCode.E1000,name:"INVALID_ARGUMENT",desc:"Missing required argument: projectId",fix:"Pass <projectId> as the first argument: `coze code preview <projectId>`",example:"coze code preview 123456"}]}}).action((async function(t,i,o){const n=o.getContext();if(!t)throw new e.CozeError(e.ErrorCode.E1000,"Missing projectId: pass <projectId> as argument");const s=await e.IdeApi.GetVibeProject({project_id:t}),r=Ul([s,"access",e=>e.data,"optionalAccess",e=>e.project_info,"optionalAccess",e=>e.project_type]),a=Ul([s,"access",e=>e.data,"optionalAccess",e=>e.project_info,"optionalAccess",e=>e.name]),c={type:bd(r)};if(!Ad.isValidType(r))throw new e.CozeError(e.ErrorCode.E1006,"Unsupported project type",{projectId:t,type:r});if(r===e.VibeProjectType.Skill){const e=await wl.getCommitList({projectId:t});Ul([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Creating preview task...")]);const i=await Vp.CreateCozeSpaceTask({task_name:`${a}-preview-${Ul([e,"access",e=>e[0],"optionalAccess",e=>e.id])}`,task_type:1,is_debug:!0,source_from:Rp.UserCreate,mcp_tool_list:[]});c.preview_url=`https://www.coze.cn/task-m/${i.data.task.task_id}`,Ul([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Preview task created. Please access the preview URL: ${c.preview_url}`)])}else{const i=await e.IdeApi.InitSandbox({project_id:t});c.preview_url=i.token?`https://${i.project_host}?token=${i.token}`:`https://${i.project_host}`,Ul([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Sandbox initialization started. Please access the preview URL in 1-3 minutes,preview_url: ${c.preview_url}`)])}Ul([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(c)])}))}(i)}function au(o){o.command("upgrade").description("Upgrade Coze CLI to the latest version").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Upgrade CLI to latest version",description:"Check for the latest version of Coze CLI and upgrade if a newer version is available. Detects the package manager used for the original installation (npm/pnpm/yarn) and runs the appropriate global install command.",examples:[{desc:"Upgrade to latest version",cmd:"coze upgrade",tags:["[RECOMMENDED]"]},{desc:"Force check and upgrade",cmd:"coze upgrade --force"},{desc:"Upgrade to a specific tag",cmd:"coze upgrade --tag beta"}],seeAlso:["coze --version"]}}).option("--force","Force upgrade even if already on the latest version").option("--tag <tag>","Specify the dist-tag to upgrade to","latest").action((async(o,n)=>{const s=n.getContext();s||process.exit(e.ExitCode.FAILURE),s.ui.info("Checking for updates...");try{const e=await re(s,!0,o.tag);if(!e.hasUpdate&&!o.force)return void s.ui.success(`You are already on the latest version (${e.currentVersion}).`);e.hasUpdate&&s.ui.info(`New version available: ${t.gray(e.currentVersion)} → ${t.green(e.latestVersion)}`),s.ui.info("Upgrading Coze CLI...");const n=function(){const e=[{pm:"npm",cmd:"npm ls -g @coze/cli --json 2>/dev/null"},{pm:"pnpm",cmd:"pnpm ls -g @coze/cli --json 2>/dev/null"},{pm:"yarn",cmd:"yarn global list --json 2>/dev/null"}];for(const{pm:t,cmd:o}of e)try{if(i.execSync(o,{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).includes("@coze/cli"))return t}catch(e){}return"npm"}(),r=function(e,t){switch(e){case"pnpm":return`pnpm add -g @coze/cli@${t}`;case"yarn":return`yarn global add @coze/cli@${t}`;default:return`npm install -g @coze/cli@${t}`}}(n,o.tag);s.ui.verbose(`Using package manager: ${n}`),s.ui.verbose(`Running: ${r}`),i.execSync(r,{stdio:"inherit"});const a=ne();s.ui.success(`Successfully upgraded Coze CLI to ${e.latestVersion}. (was ${e.currentVersion})`),"json"===s.format&&s.response.print({previousVersion:e.currentVersion,currentVersion:a,latestVersion:e.latestVersion,status:"upgraded"})}catch(t){s.ui.error(`Failed to upgrade: ${t.message}`),s.ui.info("You can try upgrading manually with: npm install -g @coze/cli"),process.exit(e.ExitCode.FAILURE)}}))}function cu(t){!function(t){const i=t.command("auth").description("Manage user authentication and credentials").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Manage authentication and credentials",description:"Manage the full authentication lifecycle for Coze CLI. Supports interactive OAuth login via browser. All other commands require valid authentication.",examples:[{desc:"Interactive login via browser",cmd:"coze auth login --oauth",tags:["[RECOMMENDED]"]},{desc:"Check current login status",cmd:"coze auth status"},{desc:"Logout and clear credentials",cmd:"coze auth logout"}],seeAlso:["coze organization","coze space"]}});i.command("login").description("Login to obtain and persist access credentials").config({skipAuth:!0,help:{brief:"Login to Coze services",description:"Login to Coze services via OAuth authorization. Opens browser to complete authorization.",examples:[{desc:"Interactive login using OAuth",cmd:"coze auth login --oauth",tags:["[RECOMMENDED]"]}],errors:[{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Authentication failed",fix:"Please try again with `coze auth login --oauth`."}]}}).option("--token <PAT>","Login using an access token").option("--oauth","Start browser-based OAuth device authorization flow").action((async function(t,i){const o=i.getContext();if(!o)return void V(new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized"));await o.auth.login(t);const n=["Please use the following commands to manage organizations and spaces:"," coze organization list"," coze organization use <organization_id>"," coze space list"," coze space use <space_id>"];!function(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}}([o,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(n.join("\n"))])})),i.command("logout").description("Logout and clear stored credentials").config({skipOrgCheck:!0,skipAuth:!0,skipSpaceCheck:!0,help:{brief:"Logout",description:"Clear locally stored access credentials and log out of the current account.",examples:[{desc:"Execute logout",cmd:"coze auth logout"}]}}).action((async(t,i)=>{const o=i.getContext();o?await o.auth.logout():V(new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized"))})),i.command("status").description("Check current login status and credential validity").config({skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Check login status",description:"Verify if the current locally cached credentials are valid and display current login account information. If the token was obtained via OAuth and is about to expire, it will be refreshed automatically.",examples:[{desc:"Check current authentication status",cmd:"coze auth status",tags:["[RECOMMENDED]"]},{desc:"Check status in JSON format",cmd:"coze auth status --format json"}],schema:{output:{type:"object",properties:{logged_in:{type:"boolean",description:"Whether the user is currently logged in"},user:{type:"object",description:"Current user profile information"},token_expires_at:{type:"string",description:"Token expiration time in ISO 8601 format"}}}},errors:[{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"No valid credentials found or token has expired",fix:"Run `coze auth login --oauth` to authenticate."}],seeAlso:["coze auth login","coze auth logout"]}}).action((async(t,i)=>{const o=i.getContext();o?await o.auth.status():V(new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized"))}))}(t),Ia(t),ru(t),ya(t),Vs(t),Ks(t),ha(t),Ta(t),au(t),Ba()}function du(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function pu(e,t){return null!=e?e:t()}function lu(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function uu(e){const t=[];let i=e;for(;i;)i.name()&&t.unshift(i.name()),i=i.parent;return t.join(" ")}function _u(e){return e._args.map((e=>e.required?`<${e.name()}>`:`[${e.name()}]`)).join(" ")}const mu=new Set(["--version","--format","--no-color","--config","--org-id","--space-id","--verbose","--debug","--log-file","--man","--schema","--commands"]);function gu(e){const t=new Map,i=[];let o=e;for(;o;)i.unshift(o),o=o.parent;for(const e of i)for(const i of e.options){const e=i.flags.split(", ").find((e=>e.startsWith("--")));!e||t.has(e)||mu.has(e)||t.set(e,i)}return Array.from(t.values())}function hu(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}class fu extends f.Command{__init(){this.middlewares=[]}constructor(e){super(e),fu.prototype.__init.call(this),this.helpInformation=()=>{const e=process.argv.slice(2);if(e.includes("--schema"))return`${JSON.stringify(hu([this,"access",e=>e.getConfig,"call",e=>e(),"optionalAccess",e=>e.help,"optionalAccess",e=>e.schema])||{},null,2)}\n`;if(e.includes("--commands")){const e=this.commands.filter((e=>!e._hidden)).map((e=>({name:e.name(),description:e.description()})));return`${JSON.stringify(e,null,2)}\n`}if(e.includes("--man")||e.includes("-m"))return`${function(e){const t=lu([e,"access",e=>e.getConfig,"call",e=>e(),"optionalAccess",e=>e.help]),i=uu(e);let o=`@MAN ${i}\n\n`;o+=`NAME\n ${i} — ${lu([t,"optionalAccess",e=>e.brief])||e.description()}\n\n`,o+=`SYNOPSIS\n ${i} ${_u(e)}\n`,gu(e).forEach((e=>{o+=` [${e.flags}]\n`})),o+="\n",lu([t,"optionalAccess",e=>e.description])&&(o+=`DESCRIPTION\n ${t.description.replace(/\n/g,"\n ")}\n\n`);const n=gu(e);return n.length>0&&(o+="OPTIONS\n",n.forEach((e=>{const t=e.flags.split(", "),i=t.find((e=>e.startsWith("-")&&!e.startsWith("--")))||"",n=t.find((e=>e.startsWith("--")))||"";o+=` ${i?`${n}, ${i}`:n}\n`,o+=` Type: ${e.isBoolean()?"flag":"string"}\n`,o+=` Required: ${e.mandatory?"yes":"no"}\n`,o+=` Default: ${void 0!==e.defaultValue?String(e.defaultValue):"-"}\n`,o+=` Desc: ${e.description}\n\n`}))),lu([t,"optionalAccess",e=>e.schema])&&(o+="SCHEMA\n",t.schema.input&&(o+=` Input:\n ${JSON.stringify(t.schema.input,null,2).replace(/\n/g,"\n ")}\n`),t.schema.output&&(o+=` Output:\n ${JSON.stringify(t.schema.output,null,2).replace(/\n/g,"\n ")}\n`),o+="\n"),lu([t,"optionalAccess",e=>e.errors])&&t.errors.length>0&&(o+="ERRORS\n",o+=" CODE NAME TRIGGER RECOVERY\n",t.errors.forEach((e=>{o+=` ${e.code.padEnd(6)} ${e.name.padEnd(17)} ${e.desc.padEnd(37)} ${e.fix}\n`})),o+="\n"),lu([t,"optionalAccess",e=>e.caveats])&&t.caveats.length>0&&(o+="CAVEATS\n",t.caveats.forEach((e=>{o+=` - ${e}\n`})),o+="\n"),lu([t,"optionalAccess",e=>e.seeAlso])&&t.seeAlso.length>0&&(o+="SEE ALSO\n",t.seeAlso.forEach((e=>{o+=` ${e}\n`})),o+="\n"),o.trimEnd()}(this)}\n`;return e.includes("-h")||e.includes("--help")?`${function(e){const t=lu([e,"access",e=>e.getConfig,"call",e=>e(),"optionalAccess",e=>e.help]),i=uu(e);let o=`@HELP ${i}\n\n`;return lu([t,"optionalAccess",e=>e.brief])?o+=`BRIEF: ${t.brief}\n\n`:o+=`BRIEF: ${e.description()||"No description provided."}\n\n`,e.parent&&"coze"!==e.parent.name()&&(o+=`PARENT: ${uu(e.parent)}\n\n`),o+=`SYNTAX:\n ${i} ${_u(e)} [options]\n\n`,lu([t,"optionalAccess",e=>e.description])&&(o+=`DESCRIPTION:\n ${t.description.replace(/\n/g,"\n ")}\n\n`),o+="OPTIONS:\n",o+=" Name Type Required Default Description\n",o+=" ─────────────────────────────────────────────────────────\n",e._args.forEach((e=>{const t=`<${e.name()}>`,i=e.required?"Yes":"No",n=void 0!==e.defaultValue?String(e.defaultValue):"-",s=e.description||"";o+=` ${t.padEnd(16)} ${"string".padEnd(10)} ${i.padEnd(4)} ${n.padEnd(10)} ${s}\n`})),gu(e).forEach((e=>{const t=e.flags.split(", "),i=t.find((e=>e.startsWith("-")&&!e.startsWith("--")))||"",n=t.find((e=>e.startsWith("--")))||"",s=i?`${n}, ${i}`:n;let r="string";e.isBoolean()&&(r="flag");const a=e.mandatory?"Yes":"No",c=void 0!==e.defaultValue?String(e.defaultValue):"-",d=e.description||"";o+=` ${s.padEnd(16)} ${r.padEnd(10)} ${a.padEnd(4)} ${c.padEnd(10)} ${d}\n`})),o+="\n",lu([t,"optionalAccess",e=>e.enums])&&(o+="ENUMS:\n",Object.keys(t.enums).forEach((e=>{o+=` --${e}:\n`;const i=pu(lu([t,"access",e=>e.enums,"optionalAccess",t=>t[e]]),(()=>({})));Object.keys(i).forEach((e=>{o+=` ${e.padEnd(12)} ${i[e]}\n`}))})),o+="\n"),lu([t,"optionalAccess",e=>e.examples])&&t.examples.length>0&&(o+="COMMON EXAMPLES:\n",t.examples.forEach((e=>{const t=e.tags?` ${e.tags.join(" ")}`:"";o+=` #${t} ${e.desc}\n ${e.cmd}\n\n`}))),lu([t,"optionalAccess",e=>e.errors])&&t.errors.length>0&&(o+="COMMON ERRORS:\n",o+=" CODE NAME DESCRIPTION FIX\n",t.errors.slice(0,5).forEach((e=>{o+=` ${e.code.padEnd(6)} ${e.name.padEnd(17)} ${e.desc.padEnd(30)} ${e.fix}\n`})),o+="\n"),lu([t,"optionalAccess",e=>e.seeAlso])&&t.seeAlso.length>0&&(o+="SEE ALSO:\n",t.seeAlso.forEach((e=>{o+=` ${e}\n`})),o+="\n"),o.trimEnd()}(this)}\n`:`${function(e){const t=lu([e,"access",e=>e.getConfig,"call",e=>e(),"optionalAccess",e=>e.help]),i=uu(e);let o=`@USAGE ${i}\n\n`;lu([t,"optionalAccess",e=>e.brief])?o+=`BRIEF: ${t.brief}\n\n`:o+=`BRIEF: ${e.description()||"No description provided."}\n\n`,o+=`SYNTAX:\n ${i} ${_u(e)} [options]\n\n`,e.commands.length>0&&(o+="ACTIONS:\n",e.commands.forEach((e=>{const t=e;if(!t._hidden){const e=lu([t,"access",e=>e.getConfig,"optionalCall",e=>e(),"optionalAccess",e=>e.help,"optionalAccess",e=>e.brief])||t.description()||"";o+=` ${t.name().padEnd(10)} ${e}\n`}})),o+="\n"),lu([t,"optionalAccess",e=>e.examples])&&t.examples.length>0&&(o+="EXAMPLES:\n",t.examples.slice(0,5).forEach((e=>{o+=` # ${e.desc}\n ${e.cmd}\n\n`})));if(lu([t,"optionalAccess",e=>e.enums])){const e=Object.keys(t.enums).filter((e=>Object.keys(pu(lu([t,"access",e=>e.enums,"optionalAccess",t=>t[e]]),(()=>({})))).length<=7));e.length>0&&(o+="ENUMS:\n",e.forEach((e=>{const i=Object.keys(pu(lu([t,"access",e=>e.enums,"optionalAccess",t=>t[e]]),(()=>({})))).join(" | ");o+=` --${e}: ${i}\n`})),o+="\n")}return o.trimEnd()}(this)}\n`},this.hook("preAction",(e=>{}))}config(e){return this.commandConfig={...this.commandConfig,...e},this}setConfig(e){return this.commandConfig=e,this}getConfig(){return this.commandConfig}setContext(e){return this.context=e,this}getContext(){return this.context}use(e){return this.middlewares.push(e),this}createCommand(e){const t=new fu(e);return this.context&&t.setContext(this.context),t}action(e){return super.action((async(...t)=>{const i=this.getContext();let o={},n=[],s=this;if(t.length>0){const e=t[t.length-1];e instanceof fu&&(s=e),t.length>=2&&(r=t[t.length-2],a=()=>({}),o=null!=r?r:a(),n=t.slice(0,t.length-2))}var r,a;if(i&&(o&&(i.options=o),n&&(i.args=n),s)){i.commandName=s.name();const e=hu([s,"access",e=>e.getConfig,"optionalCall",e=>e()]);e&&(i.commandConfig=e),s.setContext(i)}if(this.middlewares.length>0&&i){const o=qt(this.middlewares);await o(i,(async()=>{await e.apply(this,t)}))}else await e.apply(this,t)}))}}function yu(e){let t,i=e[0],o=1;for(;o<e.length;){const n=e[o],s=e[o+1];if(o+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):"call"!==n&&"optionalCall"!==n||(i=s(((...e)=>i.call(t,...e))),t=void 0)}return i}function vu(e){e.exitOverride(),e.outputError=()=>{},e.commands.forEach((e=>vu(e)))}async function bu(t){const i=new fu;i.name("coze").description("Coze Coding CLI").version(ie,"-v, --version").option("--format <fmt>","Specify output format (json, text). Default: text").option("--no-color","Disable ANSI color output").option("--config <path>","Specify config file path").option("--org-id <id>","Override Organization ID").option("--space-id <id>","Override Space ID").option("--verbose","Enable verbose mode, output more business process information").option("--debug","Enable debug mode, output all log information for diagnosing CLI execution issues").option("--log-file <path>","Output logs to a file").option("--man","Show full manual information").option("--schema","Output the command's JSON Schema").option("--commands","Output the list of subcommands"),i.config({help:{errors:[{code:e.ErrorCode.E1100,name:"UNKNOWN_OPTION",desc:"Unknown option provided",fix:"Check parameter spelling or use -h for help",example:"coze <command> -h"},{code:e.ErrorCode.E1101,name:"UNKNOWN_COMMAND",desc:"Unknown subcommand provided",fix:"Check subcommand spelling or use -h for help",example:"coze -h"},{code:e.ErrorCode.E1102,name:"MISSING_ARGUMENT",desc:"Missing required argument",fix:"Provide missing required parameters",example:"coze <command> -h"},{code:e.ErrorCode.E1103,name:"MISSING_OPTION",desc:"Missing required option value",fix:"Provide missing required options",example:"coze <command> -h"}]}}),cu(i),await async function(e){e.completionInstalled||process.stdout.isTTY}(t.config),function(e,t,i){const o=new Set;e.setContext(i),function e(n){o.has(n)||(o.add(n),n.setContext(i),t.forEach((e=>n.use(e))),n.commands.forEach((t=>{const i=du([n,"access",e=>e.getConfig,"optionalCall",e=>e()]),o=du([t,"access",e=>e.getConfig,"optionalCall",e=>e()]);t.setConfig({...i,...o}),e(t)})))}(e)}(i,[lo,Ms],t),process.on("uncaughtException",(e=>{V(e,t)})),process.on("unhandledRejection",(e=>{V(e,t)})),(t.argv.includes("--schema")||t.argv.includes("--commands")||t.argv.includes("--man")||t.argv.includes("-m"))&&(t.argv.includes("--help")||t.argv.includes("-h")||t.argv.push("--help")),vu(i);try{await i.parseAsync(t.argv,{from:"user"})}catch(s){const r=s,a=function(e,t,i){let o=e;if(t.command)o=t.command;else if(i.commandName){const t=(e,i)=>{if(e.name()===i)return e;for(const o of e.commands){const e=t(o,i);if(e)return e}return null},n=t(e,i.commandName);n&&(o=n)}let n=e;for(const e of i.argv){if(e.startsWith("-"))break;const t=n.commands.find((t=>t.name()===e));t&&(n=t,o=n)}return o}(i,r,t);"commander.helpDisplayed"!==r.code&&"commander.help"!==r.code&&"commander.version"!==r.code||process.exit(e.ExitCode.SUCCESS);const c=yu([a,"access",e=>e.getConfig,"optionalCall",e=>e()]),d=yu([i,"access",e=>e.getConfig,"optionalCall",e=>e()]);if(t.commandConfig=(n=()=>d,null!=(o=c)?o:n()),"commander.unknownOption"===r.code){const i=N(new e.CozeError(e.ErrorCode.E1100,r.message),{argv:t.argv,commandConfig:t.commandConfig});t.response.eprint(i),process.exit(e.exitCodeForError(i.code))}if("commander.unknownCommand"===r.code){const i=N(new e.CozeError(e.ErrorCode.E1101,r.message),{argv:t.argv,commandConfig:t.commandConfig});t.response.eprint(i),process.exit(e.exitCodeForError(i.code))}if("commander.missingArgument"===r.code){const i=N(new e.CozeError(e.ErrorCode.E1102,r.message),{argv:t.argv,commandConfig:t.commandConfig});t.response.eprint(i),"json"!==t.format&&process.stderr.write(`\n${a.helpInformation()}`),process.exit(e.exitCodeForError(i.code))}if("commander.missingMandatoryOptionValue"===r.code||"commander.optionMissingArgument"===r.code){const i=N(new e.CozeError(e.ErrorCode.E1103,r.message),{argv:t.argv,commandConfig:t.commandConfig});t.response.eprint(i),"json"!==t.format&&process.stderr.write(`\n${a.helpInformation()}`),process.exit(e.exitCodeForError(i.code))}V(r,t)}var o,n}(async function(){const e=process.argv.slice(2),{globalOptions:t}=function(e){const t={};let i;const o=[];let n=!1;for(let s=0;s<e.length;s++){const r=e[s];if("--help"!==r&&"-h"!==r)if("--version"!==r&&"-v"!==r)if("--output"!==r)if("--format"!==r)"--no-color"!==r?"--config"!==r?"--org-id"!==r?"--space-id"!==r?"--verbose"!==r?"--debug"!==r?"--log-file"!==r?"--print-logs"!==r?n||r.startsWith("-")?o.push(r):(i=r,n=!0):t.printLogs=!0:t.logFile=e[++s]:t.debug=!0:t.verbose=!0:t.spaceId=e[++s]:t.orgId=e[++s]:t.config=e[++s]:t.noColor=!0;else{const i=e[++s];"json"!==i&&"text"!==i||(t.format=i)}else t.output=e[++s];else t.version=!0;else t.help=!0}return{globalOptions:t,commandName:i,commandArgs:o}}(e),i=function(e){const t=po(e.cwd,(()=>process.cwd())),i=po(e.env,(()=>process.env)),o=e.globalOptions||{};o.noColor&&(process.env.NO_COLOR="1");let n="text";o.format&&(n=o.format);const s={...e.config};o.orgId&&(s.organizationId=o.orgId),o.spaceId&&(s.spaceId=o.spaceId);const r=new co({format:"text",logFile:o.logFile,printToStderr:o.printLogs});let a="info";o.debug?a="debug":o.verbose&&(a="verbose");const c=new no(r,n,a),d=new so({format:n}),p={cwd:t,env:i,argv:e.argv,config:s,format:n,log:r,ui:c,response:d,globalOptions:o,auth:void 0};return p.auth=new Gi(p),p}({argv:e,config:await Y(t.config),globalOptions:t}),o=qt([Rt,Bt,jt,ae]);await o(i,(async()=>{await bu(i)}))})().catch((e=>{V(e,void 0),process.exitCode=1}));
16
+ ***************************************************************************** */var ie=function(){return ie=Object.assign||function(e){for(var t,i=1,s=arguments.length;i<s;i++)for(var o in t=arguments[i])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ie.apply(this,arguments)};function se(e,t){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var s,o,n=i.call(e),r=[];try{for(;(void 0===t||t-- >0)&&!(s=n.next()).done;)r.push(s.value)}catch(e){o={error:e}}finally{try{s&&!s.done&&(i=n.return)&&i.call(n)}finally{if(o)throw o.error}}return r}function oe(e,t,i){if(2===arguments.length)for(var s,o=0,n=t.length;o<n;o++)!s&&o in t||(s||(s=Array.prototype.slice.call(t,0,o)),s[o]=t[o]);return e.concat(s||Array.prototype.slice.call(t))}var ne=function(){return{}};function re(e){return e}function ae(e){return"object"==typeof e&&null!==e}var ce=Object.prototype;function le(e){return"[object Array]"===ce.toString.call(e)}function de(e){return"number"==typeof e}function pe(e){return"string"==typeof e}function ue(e,t){if(!le(e))return!1;if(0===e.length)return!1;for(var i=0;i<e.length;){if(e[i]===t)return!0;i++}return!1}var _e=function(e,t){if(!le(e))return e;var i=e.indexOf(t);if(i>=0){var s=e.slice();return s.splice(i,1),s}return e};function me(e){try{return pe(e)?e:JSON.stringify(e)}catch(e){return"[FAILED_TO_STRINGIFY]:"+String(e)}}var ge="".padStart?function(e,t){return void 0===t&&(t=8),e.padStart(t," ")}:function(e){return e},he=0,fe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,oe(["[SDK]",Date.now(),ge(""+he++)],se(e),!1))},ye=0,ve=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn.apply(console,oe(["[SDK]",Date.now(),ge(""+ye++)],se(e),!1))},be=function(e){return Math.random()<Number(e)},we=function(e,t){return e<Number(t)},Pe=function(e){return function(t){for(var i=t,s=0;s<e.length&&i;s++)try{i=e[s](i)}catch(e){fe(e)}return i}};function Se(){var e=function(){for(var e=new Array(16),t=0,i=0;i<16;i++)3&i||(t=4294967296*Math.random()),e[i]=t>>>((3&i)<<3)&255;return e}();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e){for(var t=[],i=0;i<256;++i)t[i]=(i+256).toString(16).substr(1);var s=0,o=t;return[o[e[s++]],o[e[s++]],o[e[s++]],o[e[s++]],"-",o[e[s++]],o[e[s++]],"-",o[e[s++]],o[e[s++]],"-",o[e[s++]],o[e[s++]],"-",o[e[s++]],o[e[s++]],o[e[s++]],o[e[s++]],o[e[s++]],o[e[s++]]].join("")}(e)}var Te=["init","start","config","beforeDestroy","provide","beforeReport","report","beforeBuild","build","beforeSend","send","beforeConfig"];function Ce(e){var t,i,s=e.builder,o=e.createSender,n=e.createDefaultConfig,r=e.createConfigManager,a=e.userConfigNormalizer,c=e.initConfigNormalizer,l=e.validateInitConfig,d={};Te.forEach((function(e){return d[e]=[]}));var p=!1,u=!1,_=!1,m=[],g=[],h=function(){var e=!1,t={},i=function(e){e.length&&e.forEach((function(e){try{e()}catch(e){}})),e.length=0},s=function(e){t[e]&&t[e].forEach((function(e){i(e[1])})),t[e]=void 0};return{set:function(s,o,n){t[s]?t[s].push([o,n]):t[s]=[[o,n]],e&&i(n)},has:function(e){return!!t[e]},remove:s,removeByEvType:function(e){Object.keys(t).forEach((function(s){t[s]&&t[s].forEach((function(t){t[0]===e&&i(t[1])}))}))},clear:function(){e=!0,Object.keys(t).forEach((function(e){s(e)}))}}}(),f={getBuilder:function(){return s},getSender:function(){return t},getPreStartQueue:function(){return m},init:function(e){if(p)ve("already inited");else{if(!(e&&ae(e)&&l(e)))throw new Error("invalid InitConfig, init failed");var s=n(e);if(!s)throw new Error("defaultConfig missing");var a=c(e);if((i=r(s)).setConfig(a),i.onChange((function(){y("config")})),!(t=o(i.getConfig())))throw new Error("sender missing");p=!0,y("init",!0)}},set:function(e){p&&e&&ae(e)&&(y("beforeConfig",!1,e),null==i||i.setConfig(e))},config:function(e){if(p)return e&&ae(e)&&(y("beforeConfig",!1,e),null==i||i.setConfig(a(e))),null==i?void 0:i.getConfig()},provide:function(e,t){ue(g,e)?ve("cannot provide "+e+", reserved"):(f[e]=t,y("provide",!1,e))},start:function(){p&&(u||null==i||i.onReady((function(){u=!0,y("start",!0),function(e){var t=e.getPreStartQueue();t.forEach((function(t){return e.build(t)})),t.length=0}(f)})))},report:function(e){if(e){var t=Pe(d.beforeReport)(e);if(t){var i=Pe(d.report)(t);i&&(u?this.build(i):function(e,t,i){if(t.push(i),!(t.length<500)){var s=t.splice(0,50);e.savePreStartDataToDb&&e.savePreStartDataToDb(s)}}(f,m,i))}}},build:function(e){if(u){var t=Pe(d.beforeBuild)(e);if(t){var i=s.build(t);if(i){var o=Pe(d.build)(i);o&&this.send(o)}}}},send:function(e){if(u){var i=Pe(d.beforeSend)(e);i&&(t.send(i),y("send",!1,i))}},destroy:function(){h.clear(),_=!0,m.length=0,y("beforeDestroy",!0)},on:function(e,t){if("init"===e&&p||"start"===e&&u||"beforeDestroy"===e&&_)try{t()}catch(e){}else d[e]&&d[e].push(t)},off:function(e,t){d[e]&&(d[e]=_e(d[e],t))},destroyAgent:h};return g=Object.keys(f),f;function y(e,t){void 0===t&&(t=!1);for(var i=[],s=2;s<arguments.length;s++)i[s-2]=arguments[s];d[e].forEach((function(e){try{e.apply(void 0,oe([],se(i),!1))}catch(e){}})),t&&(d[e].length=0)}}var ke=function(e){var t=function(){var e={},t={},i={set:function(s,o){return e[s]=o,t[s]=me(o),i},merge:function(s){return e=ie(ie({},e),s),Object.keys(s).forEach((function(e){t[e]=me(s[e])})),i},delete:function(s){return delete e[s],delete t[s],i},clear:function(){return e={},t={},i},get:function(e){return t[e]},toString:function(){return ie({},t)}};return i}();e.provide("context",t),e.on("report",(function(e){return e.extra||(e.extra={}),e.extra.context=t.toString(),e}))};var Ae=function(){return Date.now()};var Ee=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=function(e){if(e)return e.__SLARDAR_REGISTRY__||(e.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[],subject:{}}}),e.__SLARDAR_REGISTRY__.Slardar}(function(){if("object"==typeof window&&ae(window))return window}());i&&(i.errors||(i.errors=[]),i.errors.push(e))},Ie="custom",Re=function(e){var t=function(i){var s=function(e){if(e&&ae(e)&&e.name&&pe(e.name)){var t={name:e.name,type:"event"};if("metrics"in e&&ae(e.metrics)){var i=e.metrics,s={};for(var o in i)de(i[o])&&(s[o]=i[o]);t.metrics=s}if("categories"in e&&ae(e.categories)){var n=e.categories,r={};for(var o in n)r[o]=me(n[o]);t.categories=r}return"attached_log"in e&&pe(e.attached_log)&&(t.attached_log=e.attached_log),t}}(i);if(s){var o=function(e){var t;if("object"==typeof window&&window.__perfsee__){var i={};return null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,i,e),i.stack}}(t);o&&(s.stacks=o),e.report({ev_type:Ie,payload:s,extra:{timestamp:Ae()}})}};e.provide("sendEvent",t),e.provide("sendLog",(function(t){var i=function(e){if(e&&ae(e)&&e.content&&pe(e.content)){var t={content:me(e.content),type:"log",level:"info"};if("level"in e&&(t.level=e.level),"extra"in e&&ae(e.extra)){var i=e.extra,s={},o={};for(var n in i)de(i[n])?s[n]=i[n]:o[n]=me(i[n]);t.metrics=s,t.categories=o}return"attached_log"in e&&pe(e.attached_log)&&(t.attached_log=e.attached_log),t}}(t);i&&e.report({ev_type:Ie,payload:i,extra:{timestamp:Ae()}})}))},ze=function(e,t){var i=e.common||{};return i.sample_rate=t,e.common=i,e},Ue=function(e,t,i,s,o){return e?(n=o(s,t),function(){return n}):function(){return i(t)};var n},je=function(e,t,i,s){var o=function(e,t,i){for(var s,o=se(t.split(".")),n=o[0],r=o.slice(1);e&&r.length>0;)e=e[n],n=(s=se(r))[0],r=s.slice(1);if(e)return i(e,n)}(e,t,(function(e,t){return e[t]}));return void 0!==o&&function(e,t,i){switch(i){case"eq":return ue(t,e);case"neq":return!ue(t,e);case"gt":return e>t[0];case"gte":return e>=t[0];case"lt":return e<t[0];case"lte":return e<=t[0];case"regex":return Boolean(e.match(new RegExp(t.join("|"))));case"not_regex":return!e.match(new RegExp(t.join("|")));default:return!1}}(o,function(e,t){return e.map((function(e){switch(t){case"number":return Number(e);case"boolean":return"1"===e;default:return String(e)}}))}(s,"boolean"==typeof o?"bool":de(o)?"number":"string"),i)},Le=function(e,t){try{return"rule"===t.type?je(e,t.field,t.op,t.values):"and"===t.type?t.children.every((function(t){return Le(e,t)})):t.children.some((function(t){return Le(e,t)}))}catch(e){return Ee(e),!1}},Oe=function(e,t,i,s,o){if(!t)return re;var n=t.sample_rate,r=t.include_users,a=t.sample_granularity,c=t.rules,l=t.r,d=void 0===l?Math.random():l;if(ue(r,e))return function(e){return ze(e,1)};var p="session"===a,u=Ue(p,n,i,d,s),_=function(e,t,i,s,o,n){var r={};return Object.keys(e).forEach((function(a){var c=e[a],l=c.enable,d=c.sample_rate,p=c.conditional_sample_rules;l?(r[a]={enable:l,sample_rate:d,effectiveSampleRate:d*i,hit:Ue(t,d,s,o,n)},p&&(r[a].conditional_hit_rules=p.map((function(e){var r=e.sample_rate,a=e.filter;return{sample_rate:r,hit:Ue(t,r,s,o,n),effectiveSampleRate:r*i,filter:a}})))):r[a]={enable:l,hit:function(){return!1},sample_rate:0,effectiveSampleRate:0}})),r}(c,p,n,i,d,s);return function(e){var t;if(!u())return p&&o[0](),!1;if(!(e.ev_type in _))return ze(e,n);if(!_[e.ev_type].enable)return p&&o[1](e.ev_type),!1;if(null===(t=e.common)||void 0===t?void 0:t.sample_rate)return e;var i=_[e.ev_type],s=i.conditional_hit_rules;if(s)for(var r=0;r<s.length;r++)if(Le(e,s[r].filter))return!!s[r].hit()&&ze(e,s[r].effectiveSampleRate);return i.hit()?ze(e,i.effectiveSampleRate):((!s||!s.length)&&p&&o[1](e.ev_type),!1)}},Be={build:function(e){return{ev_type:e.ev_type,payload:e.payload,common:ie(ie({},e.extra||{}),e.overrides||{})}}},xe={sample_rate:1,include_users:[],sample_granularity:"session",rules:{}};function qe(e){var t,i;try{for(var s=function(e){var t="function"==typeof Symbol&&Symbol.iterator,i=t&&e[t],s=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(["userId","deviceId","sessionId","env"]),o=s.next();!o.done;o=s.next()){var n=o.value;e[n]||delete e[n]}}catch(e){t={error:e}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}return e}function De(e){return qe(ie({},e))}function Me(e){return ae(e)&&"bid"in e&&"transport"in e}function Ge(e){return qe(ie({},e))}var $e=function(e,t){return void 0===t&&(t="/monitor_browser/collect/batch/"),(e&&e.indexOf("//")>=0?"":"https://")+e+t},Ne=function(e,t){return void 0===t&&(t="/monitor_web/settings/browser-settings"),(e&&e.indexOf("//")>=0?"":"https://")+e+t},Fe=function(e){var t,i,s=e,o={},n=ne,r=ne;return{getConfig:function(){return s},setConfig:function(e){return o=ie(ie({},o),e||{}),a(),t||(t=e,s.useLocalConfig||!s.bid?(i={},n()):function(e,t,i,s){if(!e.get)return s({});e.get({withCredentials:!0,url:Ne(t)+"?bid="+i+"&store=1",success:function(e){s(e.data||{})},fail:function(){s({sample:{sample_rate:.001}})}})}(s.transport,s.domain,s.bid,(function(e){i=function(e){if(!e)return{};var t=e.sample,i=e.timestamp,s=e.quota_rate,o=void 0===s?1:s;if(!t)return{};var n=t.sample_rate,r=t.sample_granularity,a=void 0===r?"session":r,c=t.include_users,l=t.rules;return{sample:{include_users:c,sample_rate:n*o,sample_granularity:a,rules:(void 0===l?[]:l).reduce((function(e,t){var i=t.name,s=t.enable,o=t.sample_rate,n=t.conditional_sample_rules;return e[i]={enable:s,sample_rate:o,conditional_sample_rules:n},e}),{})},serverTimestamp:i}}(e),a(),n()}))),s},onChange:function(e){r=e},onReady:function(e){n=e,i&&n()}};function a(){var t=ie(ie(ie({},e),i||{}),o);t.sample=Ve(Ve(e.sample,null==i?void 0:i.sample),o.sample),s=t,r()}};function Ve(e,t){if(!e||!t)return e||t;var i=ie(ie({},e),t);return i.include_users=oe(oe([],se(e.include_users||[]),!1),se(t.include_users||[]),!1),i.rules=oe(oe([],se(Object.keys(e.rules||{})),!1),se(Object.keys(t.rules||{})),!1).reduce((function(i,s){var o,n;return s in i||(s in(e.rules||{})&&s in(t.rules||{})?(i[s]=ie(ie({},e.rules[s]),t.rules[s]),i[s].conditional_sample_rules=oe(oe([],se(e.rules[s].conditional_sample_rules||[]),!1),se(t.rules[s].conditional_sample_rules||[]),!1)):i[s]=(null===(o=e.rules)||void 0===o?void 0:o[s])||(null===(n=t.rules)||void 0===n?void 0:n[s])),i}),{}),i}var We=function(e){e.on("report",(function(t){return function(e,t){var i=t||{},s=i.version,o=i.name,n={url:"",protocol:"",domain:"",path:"",query:"",timestamp:Date.now(),sdk_version:s||"2.1.8",sdk_name:o||"SDK_BASE"};return ie(ie({},e),{extra:ie(ie({},n),e.extra||{})})}(t,e.config())}))},He=function(e){e.on("beforeBuild",(function(t){return function(e,t){var i={};return i.bid=t.bid,i.pid=t.pid,i.view_id=t.viewId,i.user_id=t.userId,i.device_id=t.deviceId,i.session_id=t.sessionId,i.release=t.release,i.env=t.env,ie(ie({},e),{extra:ie(ie({},i),e.extra||{})})}(t,e.config())}))};var Ke=function(e){return{bid:"",pid:"",viewId:(t="_",t+"_"+Date.now()),userId:Se(),deviceId:Se(),sessionId:Se(),domain:"mon.zijieapi.com",release:"",env:"production",sample:xe,plugins:{},transport:{get:ne,post:ne},useLocalConfig:!1};var t},Je=function(e){var t=void 0===e?{}:e,i=t.createSender,s=void 0===i?function(e){return function(e){return te(e)}({size:20,endpoint:$e(e.domain),transport:e.transport})}:i,o=t.builder,n=void 0===o?Be:o,r=t.createDefaultConfig,a=Ce({validateInitConfig:Me,initConfigNormalizer:De,userConfigNormalizer:Ge,createSender:s,builder:n,createDefaultConfig:void 0===r?Ke:r,createConfigManager:Fe});return ke(a),He(a),We(a),function(e){e.on("init",(function(){var t=[],i=function(i){i.forEach((function(i){var s=i.name;ue(t,s)||(t.push(s),i.setup(e),e.destroyAgent.set(s,s,[function(){t=_e(t,s),i.tearDown&&i.tearDown()}]))}))};e.provide("applyIntegrations",i);var s=e.config();s&&s.integrations&&i(s.integrations)}))}(a),function(e){try{"object"==typeof window&&ae(window)&&window.__SLARDAR_DEVTOOLS_GLOBAL_HOOK__&&window.__SLARDAR_DEVTOOLS_GLOBAL_HOOK__.push(e)}catch(e){}}(a),a},Qe=function(e){void 0===e&&(e={});var t=Je(e);return function(e){e.on("start",(function(){var t=e.config(),i=t.userId,s=t.sample,o=Oe(i,s,be,we,[function(){e.destroy()},function(t){e.destroyAgent.removeByEvType(t)}]);e.on("build",o)}))}(t),Re(t),t}();const Ye=ee("slardar:transport"),Ze=()=>{};function Xe(e){const{url:t,method:i,data:s,success:o=Ze,fail:a=Ze,getResponseText:c=Ze}=e;if(Ye("Making %s request to %s",i,t),s&&Ye("Request data: %s",s.slice(0,200)),!t||"string"!=typeof t){const e=new Error(`Invalid URL: ${t}`);return Ye("Invalid URL provided: %o",t),void a(e)}try{const e=new URL(t);Ye("Parsed URL - protocol: %s, hostname: %s, port: %s, path: %s",e.protocol,e.hostname,e.port,e.pathname);const l="https:"===e.protocol,d=(l?r.request:n.request)({hostname:e.hostname,port:e.port,path:e.pathname+e.search,method:i,headers:{"Content-Type":"application/json",...s&&{"Content-Length":Buffer.byteLength(s)}}},(e=>{Ye("Response callback triggered: status=%s",e.statusCode);let t="";e.on("data",(e=>{Ye("Response data chunk received: %s bytes",e.length),t+=e.toString()})),e.on("end",(()=>{Ye("Response end event fired"),Ye("Response received: status=%s, body=%s",e.statusCode,t.slice(0,200)),c(t);try{if(e.statusCode&&e.statusCode>=400)Ye("Request failed with status %s: %s",e.statusCode,t),a(new Error(t||e.statusMessage||"Request failed"));else if(t){const e=JSON.parse(t);Ye("Request succeeded"),o(e)}else Ye("Request succeeded with empty response"),o({})}catch(e){Ye("Failed to parse response: %s",e.message),a(e)}}))}));d.on("error",(e=>{Ye("Request error: %s",e.message),a(e)})),d.on("timeout",(()=>{Ye("Request timeout"),d.destroy(),a(new Error("Request timeout"))})),s&&d.write(s),d.end()}catch(e){Ye("Exception during request: %s",e.message),a(e)}}function et(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const tt=ee("slardar:reporter");class it{constructor(){it.prototype.__init.call(this),it.prototype.__init2.call(this)}__init(){this.initialized=!1}__init2(){this.client=Qe}setup(e){var t,i;if(this.initialized)tt("Already initialized, skipping setup");else try{tt("Initializing Slardar with config:",{bid:e.bid,release:e.release,env:e.env,userId:e.userId,projectId:e.projectId});const s={get(e){Ye("Transport GET called: %s",e.url),Xe({method:"GET",...e})},post({url:e,data:t}){Ye("Transport POST called: %s",e),Xe({method:"POST",url:e,data:t?"string"==typeof t?t:JSON.stringify(t):void 0})}};this.client.init({bid:e.bid,transport:s,userId:e.userId,pid:e.projectId,deviceId:e.deviceId,sessionId:e.sessionId,release:e.release,env:e.env,name:e.name,useLocalConfig:(t=e.useLocalConfig,i=()=>!1,null!=t?t:i()),domain:e.domain,sample:{sample_rate:1,include_users:[],sample_granularity:"session",rules:{}}}),this.client.on("send",(e=>{tt("send hook called for event: %s",et([e,"optionalAccess",e=>e.ev_type])||"unknown")})),this.client.start(),this.initialized=!0,tt("Slardar initialized successfully")}catch(e){tt("Failed to initialize:",e)}}ensureInitialized(){return!!this.initialized||(tt("Not initialized, call setup() first"),!1)}sendEvent(e,t,i){if(this.ensureInitialized())try{tt("Sending event:",{name:e,metrics:t,categories:i});const s=t?Object.fromEntries(Object.entries(t).filter((([,e])=>void 0!==e))):void 0,o=i?Object.fromEntries(Object.entries(i).filter((([,e])=>void 0!==e))):void 0;et([this,"access",e=>e.client,"access",e=>e.sendEvent,"optionalCall",t=>t({name:e,metrics:s,categories:o})])}catch(e){tt("Failed to send event:",e)}}sendLog(e,t,i){if(this.ensureInitialized())try{tt("Sending log:",{level:e,message:t,extra:i}),this.sendEvent("cli_log",void 0,{level:e,message:t,...i})}catch(e){tt("Failed to send log:",e)}}reportError(e,t,i){if(this.ensureInitialized())try{const s={ev_type:"js_error",payload:{error:{name:e.name,message:e.message,stack:e.stack},breadcrumbs:[],extra:t,source:i||{type:"manual"}}};tt("Reporting JS error:",{name:e.name,message:e.message.slice(0,100),stack:et([e,"access",e=>e.stack,"optionalAccess",e=>e.slice,"call",e=>e(0,200)]),extra:t,source:i}),this.client.report(s),tt("JS error reported successfully")}catch(e){tt("Failed to report error:",e)}}setContext(e,t){this.ensureInitialized()&&et([this,"access",e=>e.client,"access",e=>e.context,"optionalAccess",e=>e.set,"call",i=>i(e,t)])}mergeContext(e){this.ensureInitialized()&&(tt("Merging context:",e),et([this,"access",e=>e.client,"access",e=>e.context,"optionalAccess",e=>e.merge,"call",t=>t(e)]))}deleteContext(e){this.ensureInitialized()&&et([this,"access",e=>e.client,"access",e=>e.context,"optionalAccess",e=>e.delete,"call",t=>t(e)])}clearContext(){this.ensureInitialized()&&et([this,"access",e=>e.client,"access",e=>e.context,"optionalAccess",e=>e.clear,"call",e=>e()])}updateConfig(e){if(this.ensureInitialized())try{tt("Updating config:",e),this.client.config({userId:e.userId,release:e.release,sessionId:e.sessionId,env:e.env})}catch(e){tt("Failed to update config:",e)}}async flush(e=1500){this.ensureInitialized()&&(tt("Flushing Slardar data..."),et([this,"access",e=>e.client,"access",e=>e.getSender,"optionalCall",e=>e(),"optionalAccess",e=>e.flush,"call",e=>e()]),tt("Waiting %dms for events to be sent...",e),await new Promise((t=>setTimeout(t,e))),tt("Slardar data flushed"))}getRawClient(){return this.client}}const st=new it;function ot(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const nt="cli_start",rt="cli_command",at="cli_command_complete",ct="cli_error",lt="network_request",dt="file_operation",pt={cliStart:e=>({name:nt,metrics:{duration:0,...e}}),cliCommand:(e,t)=>({name:rt,categories:{command:e,args:ot([t,"optionalAccess",e=>e.args]),status:"running",...ot([t,"optionalAccess",e=>e.categories])},metrics:ot([t,"optionalAccess",e=>e.metrics])}),cliCommandComplete:(e,t,i,s)=>({name:at,categories:{command:e,args:ot([s,"optionalAccess",e=>e.args]),status:t?"success":"fail",...ot([s,"optionalAccess",e=>e.categories])},metrics:{duration:i,...ot([s,"optionalAccess",e=>e.errorCode])&&{errorCode:s.errorCode}}}),networkRequest:(e,t)=>({name:lt,categories:{url:e,method:ot([t,"optionalAccess",e=>e.method])||"GET",statusCode:ot([t,"optionalAccess",e=>e.statusCode,"optionalAccess",e=>e.toString,"call",e=>e()]),status:ot([t,"optionalAccess",e=>e.success])?"success":"fail"},metrics:{duration:ot([t,"optionalAccess",e=>e.duration])}}),fileOperation:(e,t,i)=>({name:dt,categories:{operation:e,filePath:t,status:ot([i,"optionalAccess",e=>e.success])?"success":"fail"},metrics:{duration:ot([i,"optionalAccess",e=>e.duration]),fileSize:ot([i,"optionalAccess",e=>e.fileSize])}}),cliError:(e,t)=>({name:ct,categories:{errorName:e.name,errorMessage:e.message,stack:e.stack||"",...t},metrics:{errorCode:1}})};function ut(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function _t(e){return(...t)=>{try{const i=e(...t);return i instanceof Promise?i.catch((()=>{})):i}catch(e){}}}const mt=_t((()=>{var e,t;st.setup({bid:"coze_cli",release:H,env:"production",userId:process.env.USER||"",useLocalConfig:!1,domain:"mon.zijieapi.com"}),st.mergeContext({platform:process.platform,callerPlatform:(e=process.env.COZE_CLI_PLATFORM,t=()=>"unknown",null!=e?e:t()),nodeVersion:process.version,cliVersion:H})})),gt=_t((e=>{const t=pt.cliCommand(e);st.sendEvent(t.name,t.metrics,t.categories)})),ht=_t(((e,t,i,s)=>{const o=pt.cliCommandComplete(e,t,i,{errorCode:ut([s,"optionalAccess",e=>e.errorCode])});st.sendEvent(o.name,o.metrics,o.categories)})),ft=_t(((e,t)=>{st.reportError(e,t,{type:"cli",data:t})})),yt=_t((async()=>{await st.flush()}));async function vt(e,t){if(e.config.disableTelemetry)return void await t();mt();const i=function(e){if(e.commandName)return e.commandName;const t=[];for(const i of e.argv){if(i.startsWith("-"))break;t.push(i)}return t.join(" ")||"unknown"}(e);gt(i);const s=Date.now();let o,n=!0;try{await t()}catch(e){throw n=!1,o=e instanceof Error?e:new Error(String(e)),e}finally{const e=Date.now()-s;try{n?ht(i,!0,e):(o&&ft(o,{command:i}),ht(i,!1,e)),await yt()}catch(e){}}}function bt(e,t){return null!=e?e:t()}const wt=c.join(l.homedir(),".coze","logs");class Pt{__init(){this.fileStream=null}__init2(){this.writeError=!1}constructor(e={}){Pt.prototype.__init.call(this),Pt.prototype.__init2.call(this),this.format=bt(e.format,(()=>"text")),this.printToStderr=bt(e.printToStderr,(()=>!1)),this.tags=bt(e.tags,(()=>({}))),this.startTime=Date.now();const t=bt(e.logFile,(()=>this.getDefaultLogPath()));this.logFile=t;try{this.ensureLogDir(),this.rotateLogFiles(),this.fileStream=d.createWriteStream(t,{flags:"a"}),this.fileStream.on("error",(()=>{this.fileStream=null}))}catch(e){this.logFile=null,this.fileStream=null}}getDefaultLogPath(){const e=(new Date).toISOString().replace(/[:.]/g,"-"),{pid:t}=process;return c.join(wt,`${e}-${t}.log`)}ensureLogDir(){d.existsSync(wt)||d.mkdirSync(wt,{recursive:!0})}rotateLogFiles(){try{const e=d.readdirSync(wt).filter((e=>e.endsWith(".log"))).map((e=>({name:e,path:c.join(wt,e),mtime:d.statSync(c.join(wt,e)).mtime.getTime()}))).sort(((e,t)=>t.mtime-e.mtime));e.length>=10&&e.slice(9).forEach((e=>{try{d.unlinkSync(e.path)}catch(e){}}))}catch(e){}}verbose(e,...t){this.log("verbose",e,t)}info(e,...t){this.log("info",e,t)}warn(e,...t){this.log("warn",e,t)}error(e,...t){this.log("error",e,t)}success(e,...t){this.log("success",e,t)}debug(e,...t){this.log("debug",e,t)}debugFileOnly(e,...t){this.log("debug",e,t,!1)}log(e,t,i,s=this.printToStderr){const o=this.formatEntry(e,t,i);if(this.fileStream)try{this.fileStream.write(`${o}\n`)}catch(e){!this.writeError&&s&&(process.stderr.write("Warning: Log write failed\n"),this.writeError=!0)}s&&process.stderr.write(`${o}\n`)}formatEntry(e,t,i){const s=(new Date).toISOString(),o=Date.now()-this.startTime;if("json"===this.format){const n={level:e,timestamp:s,delta:o,...this.tags,message:t};return i.length>0&&(n.args=i),JSON.stringify(n)}const n=Object.entries(this.tags).map((([e,t])=>`${e}=${t}`)).join(" "),r=i.length>0?` ${i.map(String).join(" ")}`:"";return`${e.toUpperCase().padEnd(7)} [${s}] +${o}ms ${n} ${t}${r}`}close(){if(this.fileStream)try{this.fileStream.end()}catch(e){}}}function St(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const Tt=new Set(["authorization","cookie","set-cookie"]),Ct=/(^|_|-)(token|secret|password|authorization|cookie)(_|-|$)/i,kt=Symbol("request-debug-json-parse-fallback");let At=null,Et=!1,It=!1;const Rt=e.customFetch.fetch.bind(e.customFetch),zt=e=>"[object Object]"===Object.prototype.toString.call(e),Ut=e=>{try{return JSON.stringify(e)}catch(t){return JSON.stringify(String(e))}},jt=e=>{if("string"!=typeof e)return"***";const t=e.trim(),i=St([/^bearer\s+/i,"access",e=>e.exec,"call",e=>e(t),"optionalAccess",e=>e[0]]);return i?`${i}***`:"***"},Lt=(e,t)=>t&&Ct.test(t)?jt(e):Array.isArray(e)?e.map((e=>Lt(e))):zt(e)?Object.fromEntries(Object.entries(e).map((([e,t])=>[e,Lt(t,e)]))):e,Ot=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(Array.from(e.entries()).map((([e,t])=>[e.toLowerCase(),t])));if(Array.isArray(e))return Object.fromEntries(e.map((([e,t])=>[e.toLowerCase(),String(t)])));const t=e;return"function"==typeof t.toJSON?Ot(t.toJSON()):"function"==typeof t.entries?Object.fromEntries(Array.from(t.entries()).map((([e,t])=>[e.toLowerCase(),t]))):Object.fromEntries(Object.entries(e).map((([e,t])=>[e.toLowerCase(),Array.isArray(t)?t.map((e=>String(e))).join(", "):String(t)])))},Bt=(e,t)=>e[t.toLowerCase()],xt=(e,t,i="binary")=>{const s=(e=>"string"==typeof e?a.Buffer.byteLength(e):a.Buffer.isBuffer(e)?e.length:e instanceof Uint8Array||e instanceof ArrayBuffer?e.byteLength:"undefined"!=typeof Blob&&e instanceof Blob?e.size:void 0)(e),o=[i];return t&&o.push(t),"number"==typeof s&&o.push(`${s} bytes`),`[${o.join("; ")}]`},qt=(t,i)=>{if(null==t||""===t)return"<empty>";const s=St([Bt,"call",e=>e(i,"content-type"),"optionalAccess",e=>e.toLowerCase,"call",e=>e()]);if(St([s,"optionalAccess",e=>e.includes,"call",e=>e("multipart/form-data")]))return xt(t,s,"multipart");if(t instanceof URLSearchParams)return Ut(Lt(Object.fromEntries(Array.from(t.entries()))));if(a.Buffer.isBuffer(t)||t instanceof Uint8Array||t instanceof ArrayBuffer||"undefined"!=typeof Blob&&t instanceof Blob)return xt(t,s);if("string"==typeof t){const i=(t=>{const i=e.safeJsonParse(t,kt);if(i!==kt)return i})(t);return void 0!==i?Ut(Lt(i)):JSON.stringify(t)}return Array.isArray(t)||zt(t)?Ut(Lt(t)):xt(t,s,typeof t)},Dt=(e,t)=>{try{return new URL(e,t).toString()}catch(i){return t?`${t}${e}`:e}},Mt=e=>{const t=Ot(e);return t["x-tt-logid"]||t["x-tt-log-id"]||t.logid||""},Gt=e=>(e||"GET").toUpperCase(),$t=e=>{Et&&At&&(At instanceof Pt?At.debugFileOnly(e):At.debug(e))},Nt=({method:e,url:t,headers:i,body:s})=>{$t(`[DBG][HTTP][REQ] ${e} ${t}\nheaders: ${Ut((e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[e,Tt.has(e)?jt(t):t]))))(i))}\nbody: ${qt(s,i)}`)},Ft=({method:e,url:t,status:i,logId:s})=>{$t(`[DBG][HTTP][RES] ${e} ${t} status=${i} logid=${s||"-"}`)},Vt=({method:e,url:t,status:i,logId:s,message:o})=>{const n=(a=()=>"ERR",null!=(r=i)?r:a());var r,a;const c=o?` error=${JSON.stringify(o)}`:"";$t(`[DBG][HTTP][ERR] ${e} ${t} status=${n} logid=${s||"-"}${c}`)},Wt=(e,t)=>t&&"body"in t?t.body:"object"==typeof e&&e&&"body"in e&&null!==e.body?"[request body stream]":void 0,Ht=()=>{e.axiosInstance.interceptors.request.use((e=>((e=>{const t=Gt(e.method),i=Dt(e.url||"",e.baseURL),s=Ot(e.headers);Nt({method:t,url:i,headers:s,body:e.data})})(e),e))),e.axiosInstance.interceptors.response.use((e=>((e=>{const t=Gt(e.config.method),i=Dt(e.config.url||"",e.config.baseURL);Ft({method:t,url:i,status:e.status,logId:Mt(e.headers)})})(e),e)),(e=>((e=>{const t=Gt(St([e,"access",e=>e.config,"optionalAccess",e=>e.method])),i=Dt(St([e,"access",e=>e.config,"optionalAccess",e=>e.url])||"",St([e,"access",e=>e.config,"optionalAccess",e=>e.baseURL]));Vt({method:t,url:i,status:St([e,"access",e=>e.response,"optionalAccess",e=>e.status]),logId:Mt(St([e,"access",e=>e.response,"optionalAccess",e=>e.headers])),message:e.message})})(e),Promise.reject(e))))},Kt=()=>{e.customFetch.fetch=async(t,i)=>{const s=((e,t)=>St([t,"optionalAccess",e=>e.method])?Gt(t.method):"object"==typeof e&&e&&"method"in e&&"string"==typeof e.method?Gt(e.method):"GET")(t,i),o=(e=>"string"==typeof e?e:e instanceof URL?e.toString():"object"==typeof e&&e&&"url"in e&&"string"==typeof e.url?e.url:String(e))(t),n=((t,i)=>{const s="object"==typeof t&&t&&"headers"in t?Ot(t.headers):{};return{...Ot(e.customFetch.getHeaders()),...s,...Ot(St([i,"optionalAccess",e=>e.headers]))}})(t,i);Nt({method:s,url:o,headers:n,body:Wt(t,i)});try{const e=await Rt(t,i);return Ft({method:s,url:o,status:e.status,logId:Mt(e.headers)}),e}catch(e){throw Vt({method:s,url:o,message:e instanceof Error?e.message:String(e)}),e}}};function Jt(e,t){return null!=e?e:t()}function Qt(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}var Yt;!function(e){e.AUTHORIZATION_PENDING="authorization_pending";e.SLOW_DOWN="slow_down";e.ACCESS_DENIED="access_denied";e.EXPIRED_TOKEN="expired_token"}(Yt||(Yt={}));const Zt=e=>new Promise((t=>setTimeout(t,e))),Xt=e.createRequestClient({baseURL:"https://api.coze.com",useDefaultPlugins:!0,plugins:[{name:"oauth-error-handler",onError:t=>{if(e.isHttpError(t))throw t;const i=t,s=Jt(Qt([i,"access",e=>e.response,"optionalAccess",e=>e.data]),(()=>({}))),o=s.error_description||s.error||i.message,n={status:Qt([i,"access",e=>e.response,"optionalAccess",e=>e.status]),code:s.error,config:i.config,response:i.response,data:s};throw new e.HttpError(Jt(o,(()=>"OAuth request failed")),n)}}]});async function ei(e){return(await Xt.post("/api/permission/oauth2/token",{grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:e.clientId,device_code:e.deviceCode},{baseURL:e.baseURL})).data}const ti=async(t,i)=>{const s=process.env.HTTP_PROXY||process.env.http_proxy,o=process.env.HTTPS_PROXY||process.env.https_proxy;if(o||s){const i=new p.EnvHttpProxyAgent;e.customFetch.setDispatcher(i);const[{HttpProxyAgent:n},{HttpsProxyAgent:r}]=await Promise.all([import("http-proxy-agent"),import("https-proxy-agent")]);e.axiosInstance$1.defaults.proxy=!1,Xt.defaults.proxy=!1,o&&(e.axiosInstance$1.defaults.httpsAgent=new r(o),Xt.defaults.httpsAgent=new r(o),t.ui.debug(`HTTPS proxy enabled: ${o}`)),s&&(e.axiosInstance$1.defaults.httpAgent=new n(s),Xt.defaults.httpAgent=new n(s),t.ui.debug(`HTTP proxy enabled: ${s}`))}await i()};async function ii(t,i){const s=await t.auth.getValidAccessToken();if(!s)return t.config.accessToken=void 0,delete e.axiosInstance$1.defaults.headers.Authorization,delete e.axiosInstance$1.defaults.headers["x-use-ppe"],delete e.axiosInstance$1.defaults.headers["x-tt-env"],e.customFetch.resetHeaders(),void await i();e.axiosInstance$1.defaults.baseURL=t.config.apiBaseUrl;const o=`Bearer ${s}`;t.config.accessToken=s,e.axiosInstance$1.defaults.headers.Authorization=o,e.axiosInstance$1.defaults.headers["x-request-from-coze-cli"]="1",e.customFetch.setHeaders({Authorization:o,"x-request-from-coze-cli":"1"}),t.config.xTTEnv&&(e.axiosInstance$1.defaults.headers["x-use-ppe"]="1",e.axiosInstance$1.defaults.headers["x-tt-env"]=t.config.xTTEnv,e.customFetch.setHeaders({"x-use-ppe":"1","x-tt-env":t.config.xTTEnv})),await i()}function si(e){if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");for(const t of e)if("function"!=typeof t)throw new TypeError("Middleware must be composed of functions!");return function(t,i){let s=-1;return function o(n){if(n<=s)return Promise.reject(new Error("next() called multiple times"));s=n;let r=e[n];n===e.length&&(r=i);if(!r)return Promise.resolve();try{return Promise.resolve(r(t,o.bind(null,n+1)))}catch(e){return Promise.reject(e)}}(0)}}var oi,ni,ri,ai,ci,li,di,pi,ui,_i,mi,gi,hi,fi,yi,vi,bi,wi,Pi,Si,Ti,Ci,ki,Ai,Ei,Ii,Ri,zi,Ui,ji,Li,Oi,Bi,xi,qi,Di,Mi,Gi,$i,Ni,Fi,Vi,Wi,Hi,Ki,Ji,Qi,Yi,Zi,Xi,es,ts,is;function ss(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}!function(e){e.app="app";e.pat="pat"}(oi||(oi={})),function(e){e.can_apply2="CanApply";e.already_applied2="AlreadyApplied";e.joined4="Joined";e.deny3="Deny"}(ni||(ni={})),function(e){e.processing="Processing";e.approved="Approved";e.rejected="Rejected";e.auto_approved="AutoApproved"}(ri||(ri={})),function(e){e.normal="Normal";e.connector="Connector";e.privilege="Privilege"}(ai||(ai={})),function(e){e.auth_app="AuthApp";e.on_behalf_of_user="OnBehalfOfUser"}(ci||(ci={})),function(e){e.password="Password";e.sms="Sms";e.email="Email";e.unknown3="Unknown"}(li||(li={})),function(e){e.authorized="authorized";e.unauthorized="unauthorized";e.expired4="expired"}(di||(di={})),function(e){e.api_key="api_key";e.wechat_official="wechat_official";e.oauth_2="oauth2"}(pi||(pi={})),function(e){e.noncertificated="Noncertificated";e.certificated="Certificated"}(ui||(ui={})),function(e){e.uncertified="Uncertified";e.personal_certification="PersonalCertification";e.enterprise_certification="EnterpriseCertification"}(_i||(_i={})),function(e){e.obo="Obo";e.app_auth="AppAuth";e.personal_access_token="PersonalAccessToken"}(mi||(mi={})),function(e){e.legacy="Legacy";e.web_backend="WebBackend";e.single_page_or_native="SinglePageOrNative";e.terminal="Terminal";e.service="Service"}(gi||(gi={})),function(e){e.bot_editor="BotEditor";e.bot_developer="BotDeveloper";e.bot_operator="BotOperator"}(hi||(hi={})),function(e){e.workspace="Workspace";e.o_auth_app="OAuthApp";e.authorized_o_auth_app="AuthorizedOAuthApp";e.service_access_token="ServiceAccessToken";e.personal_access_token2="PersonalAccessToken";e.connector2="Connector";e.normal_api_app="NormalApiApp";e.connector_api_app="ConnectorApiApp"}(fi||(fi={})),function(e){e.visitors_prohibited="VisitorsProhibited";e.guest_prohibited_by_invited_user_enterprise2="GuestProhibitedByInvitedUserEnterprise";e.prohibited_by_custom_people_management="ProhibitedByCustomPeopleManagement"}(yi||(yi={})),function(e){e.dev2="DEV";e.prod2="PROD"}(vi||(vi={})),function(e){e._1="1";e._30="30";e._90="90";e._180="180";e._365="365";e.customize="customize";e.permanent="permanent"}(bi||(bi={})),function(e){e._12="1";e._302="30";e._902="90";e._1802="180";e._3652="365";e.customize2="customize";e.permanent2="permanent"}(wi||(wi={})),function(e){e.aes_256_gcm="AES-256-GCM"}(Pi||(Pi={})),function(e){e.conversation="Conversation";e.unknown="Unknown"}(Si||(Si={})),function(e){e.active3="Active";e.inactive="Inactive"}(Ti||(Ti={})),function(e){e.cloud_kms="CloudKMS",e.default="Default";e.unknown2="Unknown"}(Ci||(Ci={})),function(e){e.user_custom2="user_custom";e.consumer3="consumer"}(ki||(ki={})),function(e){e.super_admin="SuperAdmin";e.admin="Admin";e.member="Member";e.guest="Guest"}(Ai||(Ai={})),function(e){e.join_enterprise_share_link_expiration_time="JoinEnterpriseShareLinkExpirationTime";e.sso="SSO";e.forbid_guest_join_enterprise="ForbidGuestJoinEnterprise";e.forbid_member_join_other_enterprise="ForbidMemberJoinOtherEnterprise";e.replace_enterprise_logo="ReplaceEnterpriseLogo";e.forbid_custom_people_management="ForbidCustomPeopleManagement";e.forbid_coze_store_plugin_access="ForbidCozeStorePluginAccess";e.enterprise_member_listing_skill_coze_store="EnterpriseMemberListingSkillCozeStore";e.listing_skill_enterprise_store_audit="ListingSkillEnterpriseStoreAudit"}(Ei||(Ei={})),function(e){e.string="String";e.boolean="Boolean";e.integer="Integer";e.string_list="StringList"}(Ii||(Ii={})),function(e){e.must_handle="MustHandle";e.no_need_handle="NoNeedHandle"}(Ri||(Ri={})),function(e){e.pending_review_app_auth="pending_review_app_auth";e.pending_review_app_obo="pending_review_app_obo";e.approved_app_auth="approved_app_auth";e.approved_app_obo="approved_app_obo"}(zi||(zi={})),function(e){e.no_permission="NoPermission";e.guest_prohibited_by_enterprise2="GuestProhibitedByEnterprise";e.guest_prohibited_by_invited_user_enterprise3="GuestProhibitedByInvitedUserEnterprise";e.guest_prohibited_by_custom_people_management="GuestProhibitedByCustomPeopleManagement"}(Ui||(Ui={})),function(e){e.confirming2="Confirming";e.joined3="Joined";e.rejected3="Rejected";e.revoked2="Revoked";e.expired3="Expired";e.deny2="Deny"}(ji||(ji={})),function(e){e.confirming="Confirming";e.joined2="Joined";e.rejected2="Rejected";e.revoked="Revoked";e.expired2="Expired"}(Li||(Li={})),function(e){e.can_join="CanJoin";e.guest_prohibited_by_enterprise="GuestProhibitedByEnterprise";e.guest_prohibited_by_invited_user_enterprise="GuestProhibitedByInvitedUserEnterprise"}(Oi||(Oi={})),function(e){e.can_apply="CanApply";e.already_applied="AlreadyApplied";e.joined="Joined";e.expired="Expired";e.deny="Deny"}(Bi||(Bi={})),function(e){e.free="Free";e.premium_lite="PremiumLite";e.premium="Premium";e.premium_plus="PremiumPlus";e.v_1_pro_instance="V1ProInstance";e.pro_personal="ProPersonal";e.coze_personal_plus="CozePersonalPlus";e.coze_personal_advanced="CozePersonalAdvanced";e.coze_personal_pro="CozePersonalPro";e.team="Team";e.enterprise_basic="EnterpriseBasic";e.enterprise="Enterprise";e.enterprise_pro="EnterprisePro"}(xi||(xi={})),function(e){e.user_custom_only="user_custom_only";e.all2="all"}(qi||(qi={})),function(e){e.system="system";e.custom="custom"}(Di||(Di={})),function(e){e.not_in_enterprise="NotInEnterprise";e.prohibited_by_custom_people_management2="ProhibitedByCustomPeopleManagement"}(Mi||(Mi={})),function(e){e.can_apply3="CanApply";e.already_applied3="AlreadyApplied";e.joined5="Joined";e.deny4="Deny"}(Gi||(Gi={})),function(e){e.super_admin2="SuperAdmin";e.admin2="Admin";e.member2="Member";e.guest2="Guest"}($i||($i={})),function(e){e.member_joining_auto_approved="MemberJoiningAutoApproved"}(Ni||(Ni={})),function(e){e.string2="String";e.boolean2="Boolean";e.integer2="Integer";e.string_list2="StringList"}(Fi||(Fi={})),function(e){e.developer="developer";e.consumer2="consumer"}(Vi||(Vi={})),function(e){e.all="all";e.owned="owned";e.others="others"}(Wi||(Wi={})),function(e){e.enterprise_member="EnterpriseMember";e.enterprise_guest="EnterpriseGuest"}(Hi||(Hi={})),function(e){e.not_created="NotCreated";e.enabled="Enabled";e.disabled="Disabled"}(Ki||(Ki={})),function(e){e.production="Production";e.development="Development"}(Ji||(Ji={})),(Qi||(Qi={})).skill="skill",function(e){e.dev="dev";e.prod="prod"}(Yi||(Yi={})),function(e){e.user_custom="user_custom";e.coze_default="coze_default";e.consumer="consumer"}(Zi||(Zi={})),function(e){e.active2="Active";e.deactive="Deactive"}(Xi||(Xi={})),function(e){e.active="active";e.deactivated="deactivated";e.offboarded="offboarded"}(es||(es={})),function(e){e.studio_space_selector="studio_space_selector";e.studio_create_project_btn="studio_create_project_btn";e.studio_home_page="studio_home_page";e.studio_develop="studio_develop";e.studio_library="studio_library";e.studio_tasks="studio_tasks";e.studio_evaluate="studio_evaluate";e.studio_space_manage="studio_space_manage";e.studio_templates_store="studio_templates_store";e.studio_plugins_store="studio_plugins_store";e.studio_agents_store="studio_agents_store";e.studio_playground="studio_playground";e.studio_docs="studio_docs";e.studio_enterprise_agents_store="studio_enterprise_agents_store";e.studio_enterprise_plugins_store="studio_enterprise_plugins_store";e.studio_organization_manage="studio_organization_manage";e.studio_enterprise_card="studio_enterprise_card";e.studio_subscription_card="studio_subscription_card";e.studio_personal_menu="studio_personal_menu";e.studio_more_products="studio_more_products";e.studio_notice="studio_notice";e.studio_migration_banner="studio_migration_banner";e.coding_space_selector="coding_space_selector";e.coding_create_project="coding_create_project";e.coding_project_manage="coding_project_manage";e.coding_integrations="coding_integrations";e.coding_library="coding_library";e.coding_tasks="coding_tasks";e.coding_playground="coding_playground";e.coding_evaluate="coding_evaluate";e.coding_coze_redirect="coding_coze_redirect";e.coding_docs="coding_docs";e.coding_community="coding_community";e.coding_enterprise_card="coding_enterprise_card";e.coding_subscription_card="coding_subscription_card";e.coding_personal_menu="coding_personal_menu";e.coding_notice="coding_notice";e.admin_organization_manage="admin_organization_manage";e.admin_member_manage="admin_member_manage";e.admin_enterprise_config="admin_enterprise_config"}(ts||(ts={})),function(e){e.root_user="RootUser";e.basic_user="BasicUser"}(is||(is={}));class os{__init(){this.request=e.request}__init2(){this.baseURL=""}constructor(e){os.prototype.__init.call(this),os.prototype.__init2.call(this),this.request=ss([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=ss([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}CreatePersonalAccessTokenAndPermission(e,t){const i=e,s=this.genBaseURL("/api/permission_api/pat/create_personal_access_token_and_permission"),o={name:i.name,expire_at:i.expire_at,duration_day:i.duration_day,organization_id:i.organization_id,workspace_permission:i.workspace_permission,account_permission:i.account_permission,workspace_permission_v2:i.workspace_permission_v2,enterprise_permission:i.enterprise_permission},n={"x-tt-env":i["x-tt-env"]};return this.request({url:s,method:"POST",data:o,headers:n},t)}UpdatePersonalAccessTokenAndPermission(e,t){const i=e,s=this.genBaseURL("/api/permission_api/pat/update_personal_access_token_and_permission"),o={workspace_permission:i.workspace_permission,account_permission:i.account_permission,workspace_permission_v2:i.workspace_permission_v2,enterprise_permission:i.enterprise_permission,id:i.id,name:i.name},n={"x-tt-env":i["x-tt-env"]};return this.request({url:s,method:"POST",data:o,headers:n},t)}DeletePersonalAccessTokenAndPermission(e,t){const i=e,s=this.genBaseURL("/api/permission_api/pat/delete_personal_access_token_and_permission"),o={id:i.id};return this.request({url:s,method:"POST",data:o},t)}ListPersonalAccessTokens(e,t){const i=e||{},s=this.genBaseURL("/api/permission_api/pat/list_personal_access_tokens"),o={organization_id:i.organization_id,page:i.page,size:i.size,search_option:i.search_option};return this.request({url:s,method:"GET",params:o},t)}GetPersonalAccessTokenAndPermission(e,t){const i=e,s=this.genBaseURL("/api/permission_api/pat/get_personal_access_token_and_permission"),o={id:i.id};return this.request({url:s,method:"GET",params:o},t)}ListPersonalAccessTokenSupportPermissions(e,t){const i=this.genBaseURL("/api/permission_api/pat/list_personal_access_token_support_permissions");return this.request({url:i,method:"GET"},t)}CheckPersonalAccessTokenInWorkspace(e,t){const i=e,s=this.genBaseURL("/api/permission_api/pat/check_personal_access_token_in_workspace"),o={workspace_id:i.workspace_id};return this.request({url:s,method:"GET",params:o},t)}AddCollaborator(e,t){const i=e,s=this.genBaseURL("/api/permission/authz/add_collaborator"),o={collaborator_types:i.collaborator_types,principal:i.principal,resource:i.resource};return this.request({url:s,method:"POST",data:o},t)}RemoveCollaborator(e,t){const i=e,s=this.genBaseURL("/api/permission/authz/remove_collaborator"),o={principal:i.principal,resource:i.resource};return this.request({url:s,method:"POST",data:o},t)}CreateAppMeta(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/create_app_meta"),o={app_type:i.app_type,client_type:i.client_type,name:i.name,description:i.description,organization_id:i.organization_id};return this.request({url:s,method:"POST",data:o},t)}ListAppMeta(e,t){const i=e||{},s=this.genBaseURL("/api/permission_api/app/list_app_meta"),o={organization_id:i.organization_id};return this.request({url:s,method:"GET",params:o},t)}GetAppMeta(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/get_app_meta"),o={appid:i.appid},n={"x-tt-env":i["x-tt-env"]};return this.request({url:s,method:"GET",params:o,headers:n},t)}UpdateAppMeta(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/update_app_meta"),o={status:i.status,oauth2_configuration:i.oauth2_configuration,appid:i.appid,name:i.name,description:i.description,declared_permission:i.declared_permission,declared_permission_v2:i.declared_permission_v2},n={"x-tt-env":i["x-tt-env"]};return this.request({url:s,method:"POST",data:o,headers:n},t)}UploadPublicKey(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/upload_public_key"),o={appid:i.appid,public_key_pem:i.public_key_pem};return this.request({url:s,method:"POST",data:o},t)}DeletePublicKey(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/delete_public_key"),o={fingerprint:i.fingerprint};return this.request({url:s,method:"POST",data:o},t)}CreateClientSecret(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/create_client_secret"),o={appid:i.appid};return this.request({url:s,method:"POST",data:o},t)}DeleteClientSecret(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/delete_client_secret"),o={appid:i.appid,client_secret_id:i.client_secret_id};return this.request({url:s,method:"POST",data:o},t)}PutOAuth2Configuration(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/put_oauth2_configuration"),o={oauth2_configuration:i.oauth2_configuration,appid:i.appid};return this.request({url:s,method:"POST",data:o},t)}AuthorizeAppWithDeclaredPermission(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/authorize_app_with_declared_permission"),o={appid:i.appid,organization_id:i.organization_id};return this.request({url:s,method:"POST",data:o},t)}ListAuthorizedApps(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/list_authorized_apps"),o={page:i.page,size:i.size},n={"x-tt-env":i["x-tt-env"]};return this.request({url:s,method:"GET",params:o,headers:n},t)}GetAppAuthorizationRequestInfo(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/get_app_authorization_request_info"),o={authorize_key:i.authorize_key},n={"x-tt-env":i["x-tt-env"]};return this.request({url:s,method:"GET",params:o,headers:n},t)}RevokeAppAuthorizedPermission(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/revoke_app_authorized_permission"),o={authorization_type:i.authorization_type,appid:i.appid,organization_id:i.organization_id};return this.request({url:s,method:"POST",data:o},t)}DeleteApp(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/delete_app"),o={appid:i.appid};return this.request({url:s,method:"POST",data:o},t)}ModifyCollaborator(e,t){const i=e,s=this.genBaseURL("/api/permission/authz/modify_collaborator"),o={principal:i.principal,resource:i.resource,collaborator_types:i.collaborator_types};return this.request({url:s,method:"POST",data:o},t)}BatchAddCollaborator(e,t){const i=e,s=this.genBaseURL("/api/permission/authz/batch_add_collaborator"),o={principal_type:i.principal_type,resource:i.resource,principal_ids:i.principal_ids,collaborator_types:i.collaborator_types};return this.request({url:s,method:"POST",data:o},t)}GetAppInstallationRequestInfo(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/get_app_installation_request_info"),o={appid:i.appid},n={"x-tt-env":i["x-tt-env"]};return this.request({url:s,method:"GET",params:o,headers:n},t)}AppInstallationConsent(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/app_installation_consent"),o={appid:i.appid,installation_account_hint:i.installation_account_hint};return this.request({url:s,method:"POST",data:o},t)}ImpersonateCozeUser(e,t){const i=e||{},s=this.genBaseURL("/api/permission_api/coze_web_app/impersonate_coze_user"),o={duration_seconds:i.duration_seconds,scope:i.scope,connector_info:i.connector_info};return this.request({url:s,method:"POST",data:o},t)}GetVolcanoConnectInfoWithInsName(e,t){const i=this.genBaseURL("/api/permission_api/volcano/get_volcano_connect_info_with_ins_name");return this.request({url:i,method:"GET"},t)}GetVolcanoMaskedMobile(e,t){const i=this.genBaseURL("/api/permission_api/volcano/get_volcano_masked_mobile");return this.request({url:i,method:"GET"},t)}BindVolcano(e,t){const i=this.genBaseURL("/api/permission_api/volcano/bind_volcano");return this.request({url:i,method:"POST"},t)}AuthorizeAppWithSpecifiedWorkspace(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/authorize_app_with_specified_permission"),o={appid:i.appid,workspace_list:i.workspace_list,organization_id:i.organization_id};return this.request({url:s,method:"POST",data:o},t)}GetUserProfile(e,t){const i=this.genBaseURL("/v1/users/me");return this.request({url:i,method:"GET"},t)}ListAppAuthorizations(e,t){const i=e,s=this.genBaseURL(`/v1/oauth-apps/${i.appid}/authorizations`),o={page_num:i.page_num,page_size:i.page_size},n={authorization:i.authorization};return this.request({url:s,method:"GET",params:o,headers:n},t)}GetCertificationInfo(e,t){const i=this.genBaseURL("/api/permission_api/enterprise/get_certification_info");return this.request({url:i,method:"GET"},t)}NeedCreateEnterprise(e,t){const i=this.genBaseURL("/api/permission_api/enterprise/need_create_enterprise");return this.request({url:i,method:"GET"},t)}CreateEnterprise(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/create_enterprise"),o={name:i.name,icon_uri:i.icon_uri};return this.request({url:s,method:"POST",data:o},t)}ListEnterprise(e,t){const i=e||{},s=this.genBaseURL("/api/permission_api/enterprise/list_enterprises"),o={contain_enterprise_of_user:i.contain_enterprise_of_user,contain_organization_of_user:i.contain_organization_of_user,contain_guest_enterprise_of_user:i.contain_guest_enterprise_of_user,is_space:i.is_space};return this.request({url:s,method:"GET",params:o},t)}GetEnterprise(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/get_enterprise"),o={enterprise_id:i.enterprise_id};return this.request({url:s,method:"GET",params:o},t)}UpdateEnterprise(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/update_enterprise"),o={enterprise_id:i.enterprise_id,name:i.name,icon_uri:i.icon_uri,replace_logo:i.replace_logo};return this.request({url:s,method:"POST",data:o},t)}UpdateEnterpriseSettings(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/update_enterprise_settings"),o={enterprise_id:i.enterprise_id,enterprise_settings:i.enterprise_settings};return this.request({url:s,method:"POST",data:o},t)}BatchAddEnterprisePeople(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/batch_add_enterprise_people"),o={enterprise_id:i.enterprise_id,enterprise_people:i.enterprise_people,need_check_people_valid:i.need_check_people_valid};return this.request({url:s,method:"POST",data:o},t)}RemoveEnterprisePeople(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/remove_enterprise_people"),o={enterprise_id:i.enterprise_id,user_id:i.user_id,receiver:i.receiver,sync_default_organization:i.sync_default_organization};return this.request({url:s,method:"POST",data:o},t)}UpdateEnterprisePeople(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/update_enterprise_people"),o={enterprise_id:i.enterprise_id,user_id:i.user_id,enterprise_role_type_list:i.enterprise_role_type_list,sync_default_organization:i.sync_default_organization};return this.request({url:s,method:"POST",data:o},t)}CreateEnterpriseInviteLink(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/create_enterprise_invite_link"),o={enterprise_id:i.enterprise_id};return this.request({url:s,method:"POST",data:o},t)}CreateJoinApplication(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/create_join_application"),o={key:i.key,remark:i.remark};return this.request({url:s,method:"POST",data:o},t)}GetInviteInfo(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/get_invite_info"),o={invite_key:i.invite_key};return this.request({url:s,method:"GET",params:o},t)}UpdateJoinApplication(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/update_join_application"),o={application_status:i.application_status,enterprise_id:i.enterprise_id,join_application_id_list:i.join_application_id_list};return this.request({url:s,method:"POST",data:o},t)}ListPersonalAccessTokensByCreator(e,t){const i=e,s=this.genBaseURL("/api/permission_api/permission/list_personal_access_tokens_by_creator"),o={organization_id:i.organization_id};return this.request({url:s,method:"GET",params:o},t)}ListAppInstallations(e,t){const i=e||{},s=this.genBaseURL("/api/permission_api/app/list_app_installations"),o={enterprise_id:i.enterprise_id,organization_id:i.organization_id},n={"x-tt-env":i["x-tt-env"]};return this.request({url:s,method:"GET",params:o,headers:n},t)}GetEnterpriseSettings(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/get_enterprise_settings"),o={enterprise_id:i.enterprise_id,enterprise_setting_key_list:i.enterprise_setting_key_list};return this.request({url:s,method:"POST",data:o},t)}SearchCanAddEnterprisePeople(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/search_can_add_enterprise_people"),o={people_type:i.people_type,enterprise_id:i.enterprise_id,search_key:i.search_key};return this.request({url:s,method:"POST",data:o},t)}SearchEnterprisePeople(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/search_enterprise_people"),o={people_type:i.people_type,enterprise_id:i.enterprise_id,search_key:i.search_key,enterprise_role_type_list:i.enterprise_role_type_list,need_volcano_user_info:i.need_volcano_user_info,need_people_number:i.need_people_number,page:i.page,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}ListJoinApplication(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/list_join_application"),o={application_status:i.application_status,enterprise_id:i.enterprise_id,search_key:i.search_key,page:i.page,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}PostAdapterMpV1Code2Session(e,t){const i=e||{},s=this.genBaseURL("/adapter/mp/v1/code2session"),o={bot_id:i.bot_id,app_id:i.app_id,connector_id:i.connector_id,code:i.code,with_userinfo:i.with_userinfo,execute_mode:i.execute_mode,agent_type:i.agent_type,agent_version:i.agent_version};return this.request({url:s,method:"POST",data:o},t)}SubmitAppOboInstallationReview(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/submit_app_obo_installation_review"),o={appid:i.appid,enterprise_id:i.enterprise_id};return this.request({url:s,method:"POST",data:o},t)}InstallAppObo(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/install_app_obo"),o={appid:i.appid,enterprise_id:i.enterprise_id};return this.request({url:s,method:"POST",data:o},t)}UninstallAppObo(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/uninstall_app_obo"),o={appid:i.appid,enterprise_id:i.enterprise_id};return this.request({url:s,method:"POST",data:o},t)}GetChecklistForWorkspaceMigration(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/get_checklist_for_workspace_migration"),o={workspace_id_list:i.workspace_id_list};return this.request({url:s,method:"POST",data:o},t)}CheckEnterpriseExist(e,t){const i=this.genBaseURL("/api/permission_api/enterprise/check_enterprise_exist");return this.request({url:i,method:"GET"},t)}GetSSOSetting(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/get_sso_setting"),o={enterprise_id:i.enterprise_id};return this.request({url:s,method:"POST",data:o},t)}BatchMigrateAuthorization(e,t){const i=e,s=this.genBaseURL("/api/permission_api/app/batch_migrate_authorization"),o={authorization_list:i.authorization_list,organization_id:i.organization_id};return this.request({url:s,method:"POST",data:o},t)}ListJoinInvitation(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/list_join_invitation"),o={invitation_status:i.invitation_status,enterprise_id:i.enterprise_id,search_key:i.search_key,page:i.page,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}RevokeJoinInvitation(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/revoke_join_invitation"),o={enterprise_id:i.enterprise_id,join_invitation_id:i.join_invitation_id};return this.request({url:s,method:"POST",data:o},t)}UpdateJoinInvitation(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/update_join_invitation"),o={enterprise_id:i.enterprise_id,join_invitation_id:i.join_invitation_id,joined:i.joined};return this.request({url:s,method:"POST",data:o},t)}GetJoinInvitation(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/get_join_invitation"),o={join_invitation_id:i.join_invitation_id};return this.request({url:s,method:"POST",data:o},t)}SearchPeopleInOtherEnterprise(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/search_people_in_other_enterprise"),o={enterprise_id:i.enterprise_id,search_key:i.search_key,page:i.page,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}CreateApplicationForEnterpriseMember(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/create_application_for_enterprise_member"),o={enterprise_id:i.enterprise_id,remark:i.remark};return this.request({url:s,method:"POST",data:o},t)}GetApplicationForEnterpriseMember(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/get_application_for_enterprise_member"),o={enterprise_id:i.enterprise_id};return this.request({url:s,method:"POST",data:o},t)}AuthorizeAppsAndPersonalaccesstokenListWithPersonalAccountPermission(e,t){const i=e||{},s=this.genBaseURL("/api/permission_api/app/authorize_apps_and_patlist_with_personalaccountpermission"),o={crossaccount_authinfo_list:i.crossaccount_authinfo_list};return this.request({url:s,method:"POST",data:o},t)}RevokeAppAndPersonalaccesstokenPersonalAccountPermission(e,t){const i=e||{},s=this.genBaseURL("/api/permission_api/app/revoke_app_and_pat_personalaccountpermission"),o={crossaccount_authinfo:i.crossaccount_authinfo};return this.request({url:s,method:"POST",data:o},t)}GetAppsAndPersonalAccessTokenListForPersonalAccountPermissionAuthorization(e,t){const i=e||{},s=this.genBaseURL("/api/permission_api/app/get_apps_and_patlist_for_personalaccountpermission_authorization"),o={page:i.page,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}create_service_identity(e,t){const i=e,s=this.genBaseURL("/api/permission_api/service/create_service_identity"),o={name:i.name,organization_id:i.organization_id,expire_at:i.expire_at,duration_day:i.duration_day,permission:i.permission},n={"x-tt-env":i["x-tt-env"]};return this.request({url:s,method:"POST",data:o,headers:n},t)}get_service_identity(e,t){const i=e,s=this.genBaseURL("/api/permission_api/service/get_service_identity"),o={id:i.id};return this.request({url:s,method:"GET",params:o},t)}update_service_identity(e,t){const i=e,s=this.genBaseURL("/api/permission_api/service/update_service_identity"),o={permission:i.permission,id:i.id,name:i.name,expire_at:i.expire_at,duration_day:i.duration_day},n={"x-tt-env":i["x-tt-env"]};return this.request({url:s,method:"POST",data:o,headers:n},t)}delete_service_identity(e,t){const i=e,s=this.genBaseURL("/api/permission_api/service/delete_service_identity"),o={id:i.id};return this.request({url:s,method:"POST",params:o},t)}list_service_identities(e,t){const i=e||{},s=this.genBaseURL("/api/permission_api/service/list_service_identities"),o={organization_id:i.organization_id};return this.request({url:s,method:"GET",params:o},t)}ListEncryptionConfiguration(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterpise/list_encryption_configuration"),o={organization_id:i.organization_id};return this.request({url:s,method:"GET",params:o},t)}UpdateEncryptionConfiguration(e,t){const i=e||{},s=this.genBaseURL("/api/permission_api/enterpise/update_encryption_configuration"),o={encryption_configuration:i.encryption_configuration};return this.request({url:s,method:"POST",data:o},t)}SearchOrganization(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/search_organization"),o={enterprise_id:i.enterprise_id,search_key:i.search_key,joined:i.joined,need_people_number:i.need_people_number,need_workspace_number:i.need_workspace_number,page:i.page,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}CreateOrganization(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/create_organization"),o={enterprise_id:i.enterprise_id,name:i.name,icon_uri:i.icon_uri,description:i.description};return this.request({url:s,method:"POST",data:o},t)}GetOrganization(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/get_organization"),o={organization_id:i.organization_id};return this.request({url:s,method:"POST",data:o},t)}UpdateOrganization(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/update_organization"),o={organization_id:i.organization_id,name:i.name,icon_uri:i.icon_uri,description:i.description};return this.request({url:s,method:"POST",data:o},t)}SearchCanAddOrganizationPeople(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/search_can_add_organization_people"),o={organization_id:i.organization_id,search_key:i.search_key,page:i.page,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}SearchOrganizationPeople(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/search_organization_people"),o={organization_role_type:i.organization_role_type,people_type:i.people_type,organization_id:i.organization_id,search_key:i.search_key,page:i.page,page_size:i.page_size,organization_role_type_list:i.organization_role_type_list};return this.request({url:s,method:"POST",data:o},t)}CreateJoinOrganizationApplication(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/create_join_organization_application"),o={organization_id:i.organization_id,remark:i.remark};return this.request({url:s,method:"POST",data:o},t)}ListJoinOrganizationApplication(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/list_join_organization_application"),o={application_status:i.application_status,organization_id:i.organization_id,search_key:i.search_key,page:i.page,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}UpdateJoinOrganizationApplication(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/update_join_organization_application"),o={application_status:i.application_status,organization_id:i.organization_id,join_application_id_list:i.join_application_id_list};return this.request({url:s,method:"POST",data:o},t)}GetOrganizationApplicationForEnterpriseMember(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/get_organization_application_for_enterprise_member"),o={organization_id:i.organization_id};return this.request({url:s,method:"POST",data:o},t)}CanCustomEncryptionConfiguration(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterpise/can_custom_encryption_configuration"),o={enterprise_id:i.enterprise_id};return this.request({url:s,method:"GET",params:o},t)}BatchAddOrganizationPeople(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/batch_add_organization_people"),o={organization_id:i.organization_id,organization_people:i.organization_people};return this.request({url:s,method:"POST",data:o},t)}RemoveOrganizationPeople(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/remove_organization_people"),o={organization_id:i.organization_id,user_id:i.user_id,receiver:i.receiver};return this.request({url:s,method:"POST",data:o},t)}UpdateOrganizationPeople(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/update_organization_people"),o={organization_role_type:i.organization_role_type,organization_id:i.organization_id,user_id:i.user_id};return this.request({url:s,method:"POST",data:o},t)}DownloadRemoteAttestationEvidence(e,t){const i=e,s=this.genBaseURL("/api/permission_api/aicc/download_remote_attestation_evidence"),o={component_name:i.component_name};return this.request({url:s,method:"GET",params:o},t)}GetAgentAiccInfo(e,t){const i=e,s=this.genBaseURL("/api/permission_api/aicc/get_agent_aicc_info"),o={agent_id:i.agent_id};return this.request({url:s,method:"GET",params:o},t)}CheckDeleteOrganization(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/check_delete_organization"),o={organization_id:i.organization_id};return this.request({url:s,method:"POST",data:o},t)}DeleteOrganization(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/delete_organization"),o={organization_id:i.organization_id};return this.request({url:s,method:"POST",data:o},t)}ListProjectUsers(e,t){const i=e,s=this.genBaseURL("/api/permission_api/auth_integration/list_project_users"),o={project_id:i.project_id,page_size:i.page_size,page_number:i.page_number,environment:i.environment,filter:i.filter};return this.request({url:s,method:"POST",data:o},t)}DeleteProjectUser(e,t){const i=e,s=this.genBaseURL("/api/permission_api/auth_integration/delete_project_user"),o={environment:i.environment,project_id:i.project_id,user_id:i.user_id};return this.request({url:s,method:"POST",data:o},t)}GetProjectAuthConfig(e,t){const i=e,s=this.genBaseURL("/api/permission_api/auth_integration/get_project_auth_config"),o={project_id:i.project_id};return this.request({url:s,method:"GET",params:o},t)}UpdateProjectAuthConfig(e,t){const i=e,s=this.genBaseURL("/api/permission_api/auth_integration/update_project_auth_config"),o={project_id:i.project_id,configuration:i.configuration};return this.request({url:s,method:"POST",data:o},t)}ListProjectSecret(e,t){const i=e,s=this.genBaseURL("/api/permission_api/project_secret/list_project_secret"),o={env:i.env,project_id:i.project_id,with_providers:i.with_providers,deploy_id:i.deploy_id,option:i.option};return this.request({url:s,method:"POST",data:o},t)}UpdateProjectSecret(e,t){const i=e,s=this.genBaseURL("/api/permission_api/project_secret/update_project_secret"),o={project_id:i.project_id,update_secrets:i.update_secrets,update_cred_provider:i.update_cred_provider};return this.request({url:s,method:"POST",data:o},t)}DeleteProjectSecret(e,t){const i=e,s=this.genBaseURL("/api/permission_api/project_secret/delete_project_secret"),o={project_id:i.project_id,keys:i.keys,cred_provider_ids:i.cred_provider_ids};return this.request({url:s,method:"POST",data:o},t)}EncryptProjectSecret(e,t){const i=e,s=this.genBaseURL("/api/permission_api/project_secret/encrypt_project_secret"),o={project_id:i.project_id,project_type:i.project_type,encrypt_secrets:i.encrypt_secrets};return this.request({url:s,method:"POST",data:o},t)}InsertProjectSecret(e,t){const i=e,s=this.genBaseURL("/api/permission_api/project_secret/insert_project_secret"),o={project_id:i.project_id,insert_secrets:i.insert_secrets};return this.request({url:s,method:"POST",data:o},t)}OutboundAuthCallback(e,t){const i=e||{},s=this.genBaseURL("/api/permission_api/outbound_auth/callback"),o={session_id:i.session_id,error:i.error};return this.request({url:s,method:"GET",params:o},t)}CreateAgentAccessToken(e,t){const i=e,s=this.genBaseURL("/api/permission_api/inbound_auth/agent_access_token"),o={project_id:i.project_id,deployment_env:i.deployment_env};return this.request({url:s,method:"POST",data:o},t)}ListAgentAccessTokens(e,t){const i=e,s=this.genBaseURL("/api/permission_api/inbound_auth/agent_access_token"),o={project_id:i.project_id};return this.request({url:s,method:"GET",params:o},t)}DeleteAgentAccessToken(e,t){const i=e,s=this.genBaseURL("/api/permission_api/inbound_auth/agent_access_token"),o={token_id:i.token_id,project_id:i.project_id};return this.request({url:s,method:"DELETE",data:o},t)}GenerateInviteCode(e,t){const i=this.genBaseURL("/api/permission_api/coze_user/generate_invite_code");return this.request({url:i,method:"POST"},t)}GetInviteCodeInfo(e,t){const i=e,s=this.genBaseURL("/api/permission_api/coze_user/get_invite_code_info"),o={invite_code:i.invite_code};return this.request({url:s,method:"GET",params:o},t)}AuthorizeCredProvider(e,t){const i=e,s=this.genBaseURL("/api/permission_api/project_secret/authorize"),o={provider_id:i.provider_id};return this.request({url:s,method:"GET",params:o},t)}ProjectSecretAuthCallback(e,t){const i=e||{},s=this.genBaseURL("/api/permission_api/project_secret/callback"),o={code:i.code,state:i.state,error:i.error};return this.request({url:s,method:"GET",params:o},t)}ListAuthInfo(e,t){const i=e,s=this.genBaseURL("/api/permission_api/project_secret/list_auth_info"),o={credential_ids:i.credential_ids};return this.request({url:s,method:"POST",data:o},t)}RevokeAuthorization(e,t){const i=e,s=this.genBaseURL("/api/permission_api/project_secret/revoke"),o={credential_id:i.credential_id};return this.request({url:s,method:"POST",data:o},t)}VisibilityConfig(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/visibility_config"),o={enterprise_id:i.enterprise_id};return this.request({url:s,method:"POST",data:o},t)}GetVolcanoLoginMaskedMobile(e,t){const i=this.genBaseURL("/api/permission_api/volcano/get_volcano_login_masked_mobile");return this.request({url:i,method:"GET"},t)}BatchGetPeopleJoinedOrganization(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/batch_get_people_joined_organization"),o={enterprise_id:i.enterprise_id,user_ids:i.user_ids};return this.request({url:s,method:"POST",data:o},t)}BatchRemoveOrganizationPeople(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/batch_remove_organization_people"),o={enterprise_id:i.enterprise_id,remove_user_list:i.remove_user_list};return this.request({url:s,method:"POST",data:o},t)}BatchRemoveEnterprisePeople(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/batch_remove_enterprise_people"),o={enterprise_id:i.enterprise_id,remove_user_list:i.remove_user_list};return this.request({url:s,method:"POST",data:o},t)}GetOrganizationSettings(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/get_organization_settings"),o={organization_id:i.organization_id,organization_setting_key_list:i.organization_setting_key_list};return this.request({url:s,method:"POST",data:o},t)}UpdateOrganizationSettings(e,t){const i=e,s=this.genBaseURL("/api/permission_api/enterprise/update_organization_settings"),o={organization_id:i.organization_id,organization_settings:i.organization_settings};return this.request({url:s,method:"POST",data:o},t)}GithubAuthCallback(e,t){const i=e||{},s=this.genBaseURL("/api/permission_api/github_auth/callback"),o={code:i.code,state:i.state,error:i.error};return this.request({url:s,method:"GET",params:o},t)}}const ns=new os({});function rs(e,t){return null!=e?e:t()}const as=1e3,cs=Math.floor(new Date("2000-01-01T00:00:00.000Z").getTime()/as),ls=e=>e instanceof Error?e.message:String(e);class ds{constructor(e){this.ctx=e,this.config=e.config}getOAuthConfig(){return{baseURL:rs(this.config.openApiBaseUrl,(()=>o.DEFAULT_CONFIG.openApiBaseUrl)),clientId:rs(this.config.clientId,(()=>o.DEFAULT_CONFIG.clientId))}}async clearUserContext(){this.config.organizationId=void 0,this.config.enterpriseId=void 0,this.config.spaceId=void 0,await o.saveConfig({organizationId:void 0,enterpriseId:void 0,spaceId:void 0})}openInBrowser(e){const t="darwin"===process.platform?"open":"win32"===process.platform?"cmd":"xdg-open",i="win32"===process.platform?["/c","start",'""',e]:[e],o="Failed to open browser automatically. Please open the URL manually.";try{const e=s.spawn(t,i,{detached:!0,stdio:"ignore"});e.on("error",(()=>{this.ctx.ui.verbose(o)})),e.unref()}catch(e){this.ctx.ui.verbose(`${o} ${e instanceof Error?e.message:String(e)}`)}}async clearAuthData(){this.config.accessToken=void 0,this.config.refreshToken=void 0,this.config.tokenExpiresAt=void 0,await o.saveConfig({accessToken:void 0,refreshToken:void 0,tokenExpiresAt:void 0})}async login(t){if(this.ctx.ui.verbose("Initiating login process..."),t.token)return this.ctx.ui.info("Using Personal Access Token (PAT)..."),this.config.accessToken=t.token,await o.saveConfig({accessToken:t.token,refreshToken:void 0,tokenExpiresAt:void 0}),await this.clearUserContext(),this.ctx.ui.info("Authentication successful. Credentials saved."),void("json"===this.ctx.format&&this.ctx.response.print({success:!0,method:"PAT"}));try{this.ctx.ui.info("Starting OAuth flow...");const{baseURL:t,clientId:s}=this.getOAuthConfig();this.ctx.ui.verbose("Starting OAuth device flow...");const o=await async function(e){const t=e.workspaceId?`/api/permission/oauth2/workspace_id/${e.workspaceId}/device/code`:"/api/permission/oauth2/device/code";return(await Xt.post(t,{client_id:e.clientId},{baseURL:e.baseURL})).data}({baseURL:t,clientId:s}),n=`${o.verification_uri}?user_code=${o.user_code}`;this.ctx.ui.info(`Please visit ${i.underline(n)} and authorize the application.\n\nPrivacy Policy: ${i.underline("https://docs.coze.cn/guides/privacy")}\nTerms of Service: ${i.underline("https://docs.coze.cn/guides/terms-of-service")}\n\nIf you are an agent using Coze CLI, please share the authorization link,\nPrivacy Policy, and Terms of Service with your users.\n `),this.openInBrowser(n);const r=await async function(t,i){if(!t.poll)return ei(t);let s=5e3;for(i.ui.debug("Start Polling for device token..."),i.ui.debug(`Polling interval: ${s}ms`),i.ui.debug("Polling timeout: 30000ms");;)try{i.ui.debug(`Polling for device token..., ${JSON.stringify(t)}`);const e=await ei(t);return i.ui.debug(`Polling for device token success: ${JSON.stringify(e)}`),e}catch(t){if(e.isHttpError(t)){const e=t;i.ui.debug(`Polling for device token error, the error is a HttpError.\n logid: ${Qt([e,"access",e=>e.response,"optionalAccess",e=>e.headers,"access",e=>e["x-tt-logid"]])}`),i.ui.debug(`Polling for device token error: ${JSON.stringify(Jt(Qt([e,"access",e=>e.toJSON,"optionalCall",e=>e()]),(()=>e)))}`);const o=e.data;if(Qt([o,"optionalAccess",e=>e.error])===Yt.AUTHORIZATION_PENDING){i.ui.debug("Polling for device token: user has not completed authorization yet."),await Zt(s);continue}if(Qt([o,"optionalAccess",e=>e.error])===Yt.SLOW_DOWN){s<3e4&&(s+=5e3),i.ui.debug(`Polling for device token: client is polling too frequently. Increasing interval to ${s}ms`),await Zt(s);continue}}const o=t;throw i.ui.debug(`Polling for device token error, the error is: ${o.message}\n ${o.stack}\n `),t}}({baseURL:t,clientId:s,deviceCode:o.device_code,poll:!0},this.ctx);this.ctx.ui.debug(`Polling for device token success: ${JSON.stringify(r)}`),await this.saveOAuthToken(r),this.ctx.ui.debug("Saving OAuth token successfully."),await this.clearUserContext(),this.ctx.ui.info("Authentication successful. Credentials saved."),"json"===this.ctx.format&&this.ctx.response.print({success:!0,method:"OAuth"})}catch(e){throw this.ctx.ui.error(`OAuth login failed: ${ls(e)}`),e}}async logout(){await this.clearAuthData(),await this.clearUserContext(),this.ctx.ui.info("You have been logged out. Credentials cleared."),"json"===this.ctx.format&&this.ctx.response.print({success:!0,logged_out:!0})}async whoami(){if(!await this.getValidAccessToken())return void this.ctx.response.print({logged_in:!1});this.ctx.ui.info("Fetching user information...");this.ctx.response.print({logged_in:!0,user:"mock-user@coze.io",org:"mock-org",profile:"default"})}async status(){const e=await this.getValidAccessToken();if(this.ctx.ui.info("Checking authentication status..."),!e)return void this.ctx.response.print({logged_in:!1});const t=this.config.tokenExpiresAt,i=!!this.config.refreshToken,{data:s}=await ns.GetUserProfile({},{baseURL:this.config.openApiBaseUrl}),o={logged_in:!0,user:s,token_expires_at:t?new Date(t).toISOString():i?void 0:"Never (PAT)"};this.ctx.response.print(o)}async getValidAccessToken(){const{accessToken:e,refreshToken:t,tokenExpiresAt:i}=this.config;if(e){if(!t)return e;if((e=>{if(!e)return!1;const t=Date.now();return!(e-t>316224e5)&&t<e-3e5})(i))return e;this.ctx.ui.verbose("Access token is expired or expiring soon, refreshing...");try{const{baseURL:e,clientId:i}=this.getOAuthConfig(),s=await async function(e){const t={};return e.clientSecret&&(t.Authorization=`Bearer ${e.clientSecret}`),(await Xt.post("/api/permission/oauth2/token",{grant_type:"refresh_token",client_id:e.clientId,refresh_token:e.refreshToken},{baseURL:e.baseURL,headers:t})).data}({baseURL:e,clientId:i,refreshToken:t});return await this.saveOAuthToken(s),this.ctx.ui.verbose("Token refreshed successfully."),s.access_token}catch(e){return this.ctx.ui.error(`Failed to refresh token: ${ls(e)}`),void await this.clearAuthData()}}}async saveOAuthToken(e){const t=(i=e.expires_in)>=cs?i*as:Date.now()+i*as;var i;this.config.accessToken=e.access_token,this.config.refreshToken=e.refresh_token,this.config.tokenExpiresAt=t,await o.saveConfig({accessToken:e.access_token,refreshToken:e.refresh_token,tokenExpiresAt:t})}}const ps="",us="",_s="",ms="",gs="",hs="",fs="",ys="",vs="[PROC]",bs="[INFO]",ws="[WARN]",Ps="[ERR]",Ss="[DONE]",Ts="[DBG]",Cs={debug:0,verbose:1,info:2,success:3,warn:4,error:5};function ks(e){return`${_s}${us}${e}${ps}`}class As{constructor(e,t,i="info"){var s,o;this.log=e,this.silent="json"===t,this.useColor=this.detectColorSupport(),this.level=i,this.levelPriority=(o=()=>2,null!=(s=Cs[i])?s:o())}detectColorSupport(){return!0===function(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}([process,"access",e=>e.stderr,"optionalAccess",e=>e.isTTY])&&void 0===process.env.NO_COLOR}paint(e,t){return this.useColor?`${e}${t}${ps}`:t}shouldOutput(e){return!this.silent&&Cs[e]>=this.levelPriority}verbose(e,...t){this.log.verbose(e,...t),this.shouldOutput("verbose")&&process.stderr.write(`${ks(vs)} ${this.paint(fs,e)}\n`)}info(e,...t){this.log.info(e,...t),this.shouldOutput("info")&&process.stderr.write(`${ks(bs)} ${this.paint(ps,e)}\n`)}warn(e,...t){this.log.warn(e,...t),this.shouldOutput("warn")&&process.stderr.write(`${ks(ws)} ${this.paint(hs,e)}\n`)}error(e,...t){this.log.error(e,...t),this.shouldOutput("error")&&process.stderr.write(`${ks(Ps)} ${this.paint(ms,e)}\n`)}success(e,...t){this.log.success(e,...t),this.shouldOutput("success")&&process.stderr.write(`${ks(Ss)} ${this.paint(gs,e)}\n`)}debug(e,...t){this.log.debug(e,...t),this.shouldOutput("debug")&&process.stderr.write(`${ks(Ts)} ${this.paint(ys,e)}\n`)}}class Es{constructor(e){const{format:t}=e;this.formatter=function(e){return"text"===e?new x:new T}(t)}print(e){const t=this.formatter.format(e);process.stdout.write(t)}eprint(e){const t=this.formatter.formatError(e);process.stderr.write(t)}}function Is(e,t){return null!=e?e:t()}async function Rs(e,t){const i=Date.now();e.ui.verbose(`[Logger] CLI start: ${e.argv.join(" ")}`);try{await t()}finally{const t=Date.now()-i;e.ui.verbose(`[Logger] CLI end (took ${t}ms)`)}}var zs,Us,js,Ls,Os,Bs,xs,qs,Ds,Ms,Gs,$s,Ns,Fs,Vs,Ws,Hs,Ks,Js,Qs,Ys,Zs,Xs,eo,to,io,so,oo,no,ro,ao,co,lo,po,uo,_o,mo,go,ho,fo,yo,vo,bo,wo,Po,So,To,Co,ko,Ao,Eo,Io,Ro,zo,Uo,jo,Lo,Oo,Bo,xo,qo,Do,Mo,Go,$o,No,Fo,Vo,Wo,Ho,Ko,Jo,Qo,Yo,Zo,Xo,en,tn,sn,on,nn,rn,an,cn,ln,dn,pn,un,_n,mn,gn,hn,fn,yn,vn,bn,wn,Pn,Sn,Tn,Cn,kn,An,En,In,Rn,zn,Un,jn,Ln,On,Bn,xn,qn,Dn,Mn,Gn,$n,Nn,Fn,Vn,Wn,Hn,Kn,Jn,Qn,Yn,Zn,Xn,er,tr;function ir(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}!function(e){e[e.Start_Agent=0]="Start_Agent";e[e.LLM_Agent=1]="LLM_Agent";e[e.Task_Agent=2]="Task_Agent";e[e.Global_Agent=3]="Global_Agent";e[e.Bot_Agent=4]="Bot_Agent"}(zs||(zs={})),function(e){e[e.OldVersion=0]="OldVersion";e[e.MiddleVersion=1]="MiddleVersion";e[e.NewVersion=2]="NewVersion";e[e.MiddleVersionNotPrompt=3]="MiddleVersionNotPrompt"}(Us||(Us={})),function(e){e[e.Default=1]="Default";e[e.Customize=2]="Customize"}(js||(js={})),function(e){e[e.Direct=1]="Direct";e[e.WebView=2]="WebView";e[e.SendMessage=3]="SendMessage"}(Ls||(Ls={})),function(e){e[e.ChatApi=0]="ChatApi";e[e.ResponsesApi=1]="ResponsesApi"}(Os||(Os={})),function(e){e[e.Current=1]="Current";e[e.Previous=2]="Previous";e[e.Start=3]="Start";e[e.MostSuitable=4]="MostSuitable"}(Bs||(Bs={})),function(e){e[e.SingleMode=0]="SingleMode";e[e.MultiMode=1]="MultiMode";e[e.WorkflowMode=2]="WorkflowMode"}(xs||(xs={})),function(e){e[e.Default=0]="Default";e[e.Function=1]="Function"}(qs||(qs={})),function(e){e[e.Deleted=0]="Deleted";e[e.Using=1]="Using";e[e.Banned=2]="Banned"}(Ds||(Ds={})),function(e){e[e.LimitedReadWrite=1]="LimitedReadWrite";e[e.ReadOnly=2]="ReadOnly";e[e.UnlimitedReadWrite=3]="UnlimitedReadWrite";e[e.RWModeMax=4]="RWModeMax"}(Ms||(Ms={})),function(e){e[e.Default=0]="Default";e[e.DouyinAvatar=1]="DouyinAvatar"}(Gs||(Gs={})),function(e){e[e.CacheClosed=0]="CacheClosed";e[e.PrefixCache=1]="PrefixCache"}($s||($s={})),function(e){e[e.Chat=0]="Chat";e[e.FunctionCall_1=1]="FunctionCall_1";e[e.FunctionCall_2=2]="FunctionCall_2";e[e.FunctionCall_3=3]="FunctionCall_3"}(Ns||(Ns={})),function(e){e[e.NotSet=0]="NotSet";e[e.Text=1]="Text";e[e.Voice=2]="Voice";e[e.Call=3]="Call";e[e.VideoCall=4]="VideoCall"}(Fs||(Fs={})),function(e){e[e.Off=0]="Off";e[e.On=1]="On"}(Vs||(Vs={})),function(e){e[e.Text=1]="Text";e[e.Number=2]="Number";e[e.Date=3]="Date";e[e.Float=4]="Float";e[e.Boolean=5]="Boolean"}(Ws||(Ws={})),function(e){e[e.Off=0]="Off";e[e.On=1]="On"}(Hs||(Hs={})),function(e){e[e.SLM=0]="SLM";e[e.LLM=1]="LLM"}(Ks||(Ks={})),function(e){e[e.Pre=1]="Pre";e[e.Post=2]="Post";e[e.PreAndPost=3]="PreAndPost"}(Js||(Js={})),function(e){e[e.Default=0]="Default";e[e.CustomizePrompt=1]="CustomizePrompt"}(Qs||(Qs={})),function(e){e[e.ReplyBottom=0]="ReplyBottom";e[e.CardList=1]="CardList"}(Ys||(Ys={})),function(e){e[e.Coze=0]="Coze";e[e.Volcano=1]="Volcano";e[e.ThirdParty=2]="ThirdParty"}(Zs||(Zs={})),function(e){e[e.Coze=0]="Coze";e[e.Volcano=1]="Volcano";e[e.ThirdParty=2]="ThirdParty"}(Xs||(Xs={})),function(e){e[e.FullSupport=0]="FullSupport";e[e.PoorSupport=1]="PoorSupport";e[e.NotSupport=2]="NotSupport"}(eo||(eo={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.ImageFlow=3]="ImageFlow";e[e.Trigger=4]="Trigger";e[e.KnowledgeText=5]="KnowledgeText";e[e.KnowledgeTable=6]="KnowledgeTable";e[e.KnowledgeAutoCall=7]="KnowledgeAutoCall";e[e.KnowledgeOnDemandCall=8]="KnowledgeOnDemandCall";e[e.Variable=9]="Variable";e[e.Database=10]="Database";e[e.LongTermMemory=11]="LongTermMemory";e[e.FileBox=12]="FileBox";e[e.Onboarding=13]="Onboarding";e[e.Suggestion=14]="Suggestion";e[e.ShortcutCommand=15]="ShortcutCommand";e[e.BackGroundImage=16]="BackGroundImage";e[e.TTS=17]="TTS";e[e.MultiAgentRecognize=18]="MultiAgentRecognize";e[e.KnowledgePhoto=19]="KnowledgePhoto";e[e.HookInfo=20]="HookInfo";e[e.KnowledgeValcanoUnstructured=21]="KnowledgeValcanoUnstructured";e[e.KnowledgeValcanoStructured=22]="KnowledgeValcanoStructured";e[e.Model=23]="Model";e[e.KnowledgeThirdPartyUnstructured=24]="KnowledgeThirdPartyUnstructured";e[e.KnowledgeThirdPartyStructured=25]="KnowledgeThirdPartyStructured"}(to||(to={})),function(e){e[e.Text=0]="Text";e[e.Markdown=1]="Markdown";e[e.JSON=2]="JSON"}(io||(io={})),function(e){e[e.Custom=0]="Custom";e[e.Creative=1]="Creative";e[e.Balance=2]="Balance";e[e.Precise=3]="Precise"}(so||(so={})),function(e){e[e.Curve=0]="Curve";e[e.Straight=1]="Straight"}(oo||(oo={})),function(e){e[e.Flow=1]="Flow";e[e.Host=2]="Host"}(no||(no={})),function(e){e[e.NO_NEED=1]="NO_NEED";e[e.USE_MANUAL=2]="USE_MANUAL";e[e.USE_LLM=3]="USE_LLM"}(ro||(ro={})),function(e){e[e.EQUAL=1]="EQUAL";e[e.NOT_EQUAL=2]="NOT_EQUAL";e[e.GREATER_THAN=3]="GREATER_THAN";e[e.LESS_THAN=4]="LESS_THAN";e[e.GREATER_EQUAL=5]="GREATER_EQUAL";e[e.LESS_EQUAL=6]="LESS_EQUAL";e[e.IN=7]="IN";e[e.NOT_IN=8]="NOT_IN";e[e.IS_NULL=9]="IS_NULL";e[e.IS_NOT_NULL=10]="IS_NOT_NULL";e[e.LIKE=11]="LIKE";e[e.NOT_LIKE=12]="NOT_LIKE"}(ao||(ao={})),function(e){e[e.Input=0]="Input";e[e.Variable=1]="Variable"}(co||(co={})),function(e){e[e.Default=0]="Default";e[e.FromSaas=1]="FromSaas"}(lo||(lo={})),function(e){e[e.Standard=0]="Standard";e[e.PrefixPrompt=1]="PrefixPrompt"}(po||(po={})),function(e){e[e.FunctionCall=1]="FunctionCall";e[e.Independent=2]="Independent"}(uo||(uo={})),function(e){e[e.HasUpdates=1]="HasUpdates";e[e.IsDelete=2]="IsDelete"}(_o||(_o={})),function(e){e[e.ManualUpdate=1]="ManualUpdate";e[e.AutoUpdate=2]="AutoUpdate"}(mo||(mo={})),function(e){e[e.SemanticSearch=0]="SemanticSearch";e[e.HybirdSearch=1]="HybirdSearch";e[e.FullTextSearch=20]="FullTextSearch"}(go||(go={})),function(e){e[e.Public=1]="Public";e[e.Anonymous=2]="Anonymous";e[e.Custom=3]="Custom"}(ho||(ho={})),function(e){e[e.Random=0]="Random";e[e.All=1]="All"}(fo||(fo={})),function(e){e[e.System=0]="System";e[e.Custom=1]="Custom";e[e.Disable=2]="Disable";e[e.OriBot=3]="OriBot"}(yo||(yo={})),function(e){e[e.ListString=1]="ListString";e[e.String=2]="String";e[e.Integer=3]="Integer";e[e.Float=4]="Float";e[e.Boolean=5]="Boolean"}(vo||(vo={})),function(e){e[e.Off=0]="Off";e[e.On=1]="On"}(bo||(bo={})),function(e){e[e.CozeOldTimeCapsule=0]="CozeOldTimeCapsule";e[e.VolcanoTimeCapsule=1]="VolcanoTimeCapsule"}(wo||(wo={})),function(e){e[e.Workflow=0]="Workflow";e[e.Imageflow=1]="Imageflow";e[e.SceneFlow=2]="SceneFlow";e[e.ChatFlow=3]="ChatFlow";e[e.All=100]="All"}(Po||(Po={})),function(e){e[e.BotQuery=1]="BotQuery";e[e.Plugin=2]="Plugin";e[e.Workflow=3]="Workflow"}(So||(So={})),function(e){e[e.Unknown=0]="Unknown";e[e.Webhook=1]="Webhook"}(To||(To={})),function(e){e[e.Unknown=0]="Unknown";e[e.Time=1]="Time";e[e.Event=2]="Event"}(Co||(Co={})),function(e){e[e.NoHistory=0]="NoHistory";e[e.NeedHistory=1]="NeedHistory"}(ko||(ko={})),function(e){e[e.NoTriggered=0]="NoTriggered";e[e.Triggered=1]="Triggered";e[e.DoAction=2]="DoAction";e[e.WaitToPush=3]="WaitToPush";e[e.PushSuccess=4]="PushSuccess";e[e.PushFail=5]="PushFail"}(Ao||(Ao={})),function(e){e[e.Init=0]="Init";e[e.Activated=1]="Activated";e[e.Deactivated=2]="Deactivated";e[e.Suspended=3]="Suspended"}(Eo||(Eo={})),function(e){e[e.Preset=1]="Preset";e[e.UserTask=2]="UserTask";e[e.PluginRunTask=3]="PluginRunTask"}(Io||(Io={})),function(e){e[e.Deploying=0]="Deploying";e[e.Successful=1]="Successful";e[e.Failed=2]="Failed"}(Ro||(Ro={})),function(e){e[e.All=0]="All";e[e.Bind=1]="Bind";e[e.UnBind=2]="UnBind"}(zo||(zo={})),function(e){e[e.CreateTime=0]="CreateTime";e[e.UpdateTime=1]="UpdateTime"}(Uo||(Uo={})),function(e){e[e.EventMeta=1]="EventMeta";e[e.ProfileMeta=2]="ProfileMeta"}(jo||(jo={})),function(e){e[e.ChatApi=0]="ChatApi";e[e.ResponsesApi=1]="ResponsesApi"}(Lo||(Lo={})),function(e){e[e.GPT=1]="GPT";e[e.SEED=2]="SEED";e[e.Claude=3]="Claude";e[e.MiniMax=4]="MiniMax";e[e.Plugin=5]="Plugin";e[e.StableDiffusion=6]="StableDiffusion";e[e.ByteArtist=7]="ByteArtist";e[e.Maas=9]="Maas";e[e.QianFan=10]="QianFan";e[e.Gemini=11]="Gemini";e[e.Moonshot=12]="Moonshot";e[e.GLM=13]="GLM";e[e.MaaSAutoSync=14]="MaaSAutoSync";e[e.QWen=15]="QWen";e[e.Cohere=16]="Cohere";e[e.Baichuan=17]="Baichuan";e[e.Ernie=18]="Ernie";e[e.DeekSeek=19]="DeekSeek";e[e.Llama=20]="Llama";e[e.StepFun=23]="StepFun";e[e.Custom=24]="Custom";e[e.Other=999]="Other"}(Oo||(Oo={})),function(e){e[e.Float=1]="Float";e[e.Int=2]="Int";e[e.Boolean=3]="Boolean";e[e.String=4]="String"}(Bo||(Bo={})),function(e){e[e.ModelType=1]="ModelType";e[e.ModelUserRight=2]="ModelUserRight";e[e.ModelFeature=3]="ModelFeature";e[e.ModelFunction=4]="ModelFunction";e[e.ModelPaid=15]="ModelPaid";e[e.ModelAbility=16]="ModelAbility";e[e.ModelStatus=17]="ModelStatus";e[e.Custom=20]="Custom";e[e.Others=100]="Others"}(xo||(xo={})),function(e){e[e.Flagship=1]="Flagship";e[e.HighSpeed=2]="HighSpeed";e[e.ToolInvocation=3]="ToolInvocation";e[e.RolePlaying=4]="RolePlaying";e[e.LongText=5]="LongText";e[e.ImageUnderstanding=6]="ImageUnderstanding";e[e.Reasoning=7]="Reasoning";e[e.VideoUnderstanding=8]="VideoUnderstanding";e[e.CostPerformance=9]="CostPerformance";e[e.CodeSpecialization=10]="CodeSpecialization";e[e.AudioUnderstanding=11]="AudioUnderstanding"}(qo||(qo={})),function(e){e[e.Text=1]="Text";e[e.ImageFirstFrame=2]="ImageFirstFrame";e[e.ImageFirstLastFrame=3]="ImageFirstLastFrame";e[e.ReferencePicture=4]="ReferencePicture"}(Do||(Do={})),function(e){e[e.Start_Agent=0]="Start_Agent";e[e.LLM_Agent=1]="LLM_Agent";e[e.Task_Agent=2]="Task_Agent";e[e.Global_Agent=3]="Global_Agent";e[e.Bot_Agent=4]="Bot_Agent"}(Mo||(Mo={})),function(e){e[e.Upgrade=1]="Upgrade";e[e.BrowseOldNoPrompt=2]="BrowseOldNoPrompt"}(Go||(Go={})),function(e){e[e.Default=1]="Default";e[e.Customize=2]="Customize"}($o||($o={})),function(e){e[e.Direct=1]="Direct";e[e.WebView=2]="WebView";e[e.SendMessage=3]="SendMessage"}(No||(No={})),function(e){e[e.Auditing=0]="Auditing";e[e.Success=1]="Success";e[e.Failed=2]="Failed"}(Fo||(Fo={})),function(e){e[e.Visit=1]="Visit";e[e.Edit=2]="Edit"}(Vo||(Vo={})),function(e){e[e.Online=1]="Online";e[e.Offline=2]="Offline"}(Wo||(Wo={})),function(e){e[e.Offline=0]="Offline";e[e.Online=1]="Online"}(Ho||(Ho={})),function(e){e[e.SingleMode=0]="SingleMode";e[e.MultiMode=1]="MultiMode";e[e.WorkflowMode=2]="WorkflowMode"}(Ko||(Ko={})),function(e){e[e.AutoGenBeforePublish=1]="AutoGenBeforePublish"}(Jo||(Jo={})),function(e){e[e.CozeHome=1]="CozeHome";e[e.Space=2]="Space"}(Qo||(Qo={})),function(e){e[e.Undefined=0]="Undefined";e[e.PersonalDraft=1]="PersonalDraft";e[e.Base=2]="Base";e[e.Publish=3]="Publish"}(Yo||(Yo={})),function(e){e[e.Undefined=0]="Undefined";e[e.Committed=1]="Committed";e[e.Behind=2]="Behind";e[e.NoDraftReplica=3]="NoDraftReplica"}(Zo||(Zo={})),function(e){e[e.Normal=0]="Normal";e[e.Offline=1]="Offline";e[e.TokenDisconnect=2]="TokenDisconnect"}(Xo||(Xo={})),function(e){e[e.USER_RES=0]="USER_RES";e[e.USER_LLM_RES=1]="USER_LLM_RES";e[e.USER_LLM_APILEN_RES=2]="USER_LLM_APILEN_RES";e[e.USER_LLM_API_RES=3]="USER_LLM_API_RES"}(en||(en={})),function(e){e[e.Personal=1]="Personal";e[e.Organization=2]="Organization"}(tn||(tn={})),function(e){e[e.Agent=1]="Agent";e[e.Project=2]="Project";e[e.Knowledge=3]="Knowledge";e[e.Dataset=4]="Dataset";e[e.Plugin=5]="Plugin";e[e.Memorybase=6]="Memorybase"}(sn||(sn={})),function(e){e[e.Text=0]="Text";e[e.Table=1]="Table";e[e.Image=2]="Image";e[e.VolcanoStructured=4]="VolcanoStructured";e[e.VolcanoUnstructured=5]="VolcanoUnstructured";e[e.ThirdPartyStructured=7]="ThirdPartyStructured";e[e.ThirdPartyUnstructured=8]="ThirdPartyUnstructured"}(on||(on={})),function(e){e[e.Deleted=0]="Deleted";e[e.Using=1]="Using";e[e.Banned=2]="Banned";e[e.MoveFail=3]="MoveFail"}(nn||(nn={})),function(e){e[e.ByteTree=1]="ByteTree";e[e.GPTAK=2]="GPTAK";e[e.MaasAK=3]="MaasAK"}(rn||(rn={})),function(e){e[e.Init=0]="Init";e[e.Generating=1]="Generating";e[e.Success=2]="Success";e[e.Fail=3]="Fail";e[e.Cancel=4]="Cancel"}(an||(an={})),function(e){e[e.BotStore=1]="BotStore"}(cn||(cn={})),function(e){e[e.shorcutIcon=1]="shorcutIcon"}(ln||(ln={})),function(e){e[e.Onboarding=0]="Onboarding";e[e.BackgroundImage=1]="BackgroundImage"}(dn||(dn={})),function(e){e[e.BasicUser=1]="BasicUser";e[e.ExternalUser=2]="ExternalUser";e[e.RootUser=3]="RootUser"}(pn||(pn={})),function(e){e[e.GetInfo=1]="GetInfo"}(un||(un={})),function(e){e[e.Normal=1]="Normal";e[e.Invalid=2]="Invalid";e[e.Expired=3]="Expired";e[e.Rejected=4]="Rejected";e[e.Applying=5]="Applying"}(_n||(_n={})),function(e){e[e.Apply=1]="Apply";e[e.Invite=2]="Invite";e[e.EnterpriseApply=3]="EnterpriseApply"}(mn||(mn={})),function(e){e[e.GPT=1]="GPT";e[e.Claude=3]="Claude";e[e.Gemini=11]="Gemini";e[e.Moonshot=12]="Moonshot";e[e.GLM=13]="GLM";e[e.QWen=15]="QWen";e[e.DeekSeek=19]="DeekSeek";e[e.StepFun=23]="StepFun"}(gn||(gn={})),function(e){e[e.Douyin=1]="Douyin"}(hn||(hn={})),function(e){e[e.GPTOpenAPI=1]="GPTOpenAPI";e[e.Maas=2]="Maas";e[e.LLMFlow=3]="LLMFlow";e[e.Merlin=4]="Merlin"}(fn||(fn={})),function(e){e[e.Move=0]="Move";e[e.ForcedMove=1]="ForcedMove";e[e.RetryMove=2]="RetryMove";e[e.Preview=3]="Preview";e[e.ViewTask=4]="ViewTask";e[e.CancelTask=5]="CancelTask"}(yn||(yn={})),function(e){e[e.All=0]="All";e[e.Unread=1]="Unread"}(vn||(vn={})),function(e){e[e.Bot=1]="Bot"}(bn||(bn={})),function(e){e[e.CharactersAnime=1]="CharactersAnime";e[e.CharactersRealistic=2]="CharactersRealistic";e[e.CharactersCGThickPainting=3]="CharactersCGThickPainting";e[e.CharactersJapaneseShowa=4]="CharactersJapaneseShowa";e[e.CharactersAmericanComics=5]="CharactersAmericanComics";e[e.CharactersChineseWatercolor=6]="CharactersChineseWatercolor";e[e.ScenesScienceFiction=7]="ScenesScienceFiction";e[e.ScenesRealistic=8]="ScenesRealistic";e[e.ScenesChinesePainting=9]="ScenesChinesePainting";e[e.ScenesCartoonIllustrations=10]="ScenesCartoonIllustrations";e[e.ScenesCartoon3D=11]="ScenesCartoon3D"}(wn||(wn={})),function(e){e[e.IconStatic=1]="IconStatic";e[e.IconGif=2]="IconGif";e[e.BackgroundStatic=3]="BackgroundStatic";e[e.BackgroundGif=4]="BackgroundGif";e[e.PicPrompt=5]="PicPrompt"}(Pn||(Pn={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.ShortcutCommand=3]="ShortcutCommand";e[e.Task=4]="Task"}(Sn||(Sn={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.ImageFlow=3]="ImageFlow";e[e.Knowledge=4]="Knowledge"}(Tn||(Tn={})),function(e){e[e.NoPublish=0]="NoPublish";e[e.HadPublished=1]="HadPublished"}(Cn||(Cn={})),function(e){e[e.Success=1]="Success";e[e.Failed=2]="Failed";e[e.InReview=3]="InReview"}(kn||(kn={})),function(e){e[e.Unread=1]="Unread";e[e.Read=2]="Read"}(An||(An={})),function(e){e[e.HasUpdates=1]="HasUpdates";e[e.IsDelete=2]="IsDelete"}(En||(En={})),function(e){e[e.UnLimit=1]="UnLimit";e[e.Forbidden=2]="Forbidden"}(In||(In={})),function(e){e[e.Plugin=1]="Plugin";e[e.NewBotIDEGuide=2]="NewBotIDEGuide";e[e.NewBeginnerGuide=3]="NewBeginnerGuide"}(Rn||(Rn={})),function(e){e[e.Default=0]="Default";e[e.Explore=1]="Explore";e[e.BotStore=2]="BotStore";e[e.CozeHome=3]="CozeHome";e[e.Playground=4]="Playground";e[e.Evaluation=5]="Evaluation";e[e.AgentApp=6]="AgentApp";e[e.GenerateAgentInfo=8]="GenerateAgentInfo";e[e.Template=9]="Template";e[e.EnterpriseStore=10]="EnterpriseStore"}(zn||(zn={})),function(e){e[e.All=0]="All";e[e.Self=1]="Self"}(Un||(Un={})),function(e){e[e.All=0]="All";e[e.Joined=1]="Joined";e[e.Confirming=2]="Confirming";e[e.Rejected=3]="Rejected";e[e.AutoApproved=4]="AutoApproved"}(jn||(jn={})),function(e){e[e.All=0]="All";e[e.Joined=1]="Joined";e[e.Confirming=2]="Confirming";e[e.Rejected=3]="Rejected";e[e.Revoked=4]="Revoked";e[e.Expired=5]="Expired"}(Ln||(Ln={})),function(e){e[e.EnterpriseUser=1]="EnterpriseUser";e[e.ExternalUser=2]="ExternalUser"}(On||(On={})),function(e){e[e.Normal=0]="Normal";e[e.DevMode=1]="DevMode"}(Bn||(Bn={})),function(e){e[e.DraftBot=1]="DraftBot";e[e.Project=2]="Project";e[e.Space=3]="Space";e[e.DouyinAvatarBot=4]="DouyinAvatarBot"}(xn||(xn={})),function(e){e[e.Default=0]="Default";e[e.Owner=1]="Owner";e[e.Admin=2]="Admin";e[e.Member=3]="Member";e[e.Guest=4]="Guest"}(qn||(qn={})),function(e){e[e.Professional=1]="Professional"}(Dn||(Dn={})),function(e){e[e.Personal=1]="Personal";e[e.Team=2]="Team"}(Mn||(Mn={})),function(e){e[e.Dark=1]="Dark";e[e.Light=2]="Light"}(Gn||(Gn={})),function(e){e[e.AlwaysOn=0]="AlwaysOn";e[e.AlwaysOff=1]="AlwaysOff"}($n||($n={})),function(e){e[e.CozeAssistantGuide=1]="CozeAssistantGuide"}(Nn||(Nn={})),function(e){e[e.Normal=1]="Normal";e[e.Banned=2]="Banned";e[e.Canceled=3]="Canceled"}(Fn||(Fn={})),function(e){e[e.External=0]="External";e[e.Internal=1]="Internal"}(Vn||(Vn={})),function(e){e[e.Invisible=0]="Invisible";e[e.Visible=1]="Visible";e[e.SocietyInvisible=2]="SocietyInvisible"}(Wn||(Wn={})),function(e){e[e.SingleAgent=1]="SingleAgent";e[e.MultiAgent=2]="MultiAgent";e[e.WorkflowAsAgent=3]="WorkflowAsAgent"}(Hn||(Hn={})),function(e){e[e.Preset=1]="Preset";e[e.Library=2]="Library"}(Kn||(Kn={})),function(e){e[e.DatasetServiceValid=0]="DatasetServiceValid";e[e.DatasetServiceInvalid=1]="DatasetServiceInvalid"}(Jn||(Jn={})),function(e){e[e.DatasetValid=0]="DatasetValid";e[e.DatasetInvalid=1]="DatasetInvalid"}(Qn||(Qn={})),function(e){e[e.RootUser=1]="RootUser";e[e.BasicUser=2]="BasicUser"}(Yn||(Yn={})),function(e){e[e.Workflow=0]="Workflow";e[e.Imageflow=1]="Imageflow";e[e.SceneFlow=2]="SceneFlow";e[e.ChatFlow=3]="ChatFlow";e[e.All=100]="All"}(Zn||(Zn={})),function(e){e[e.TextInput=0]="TextInput";e[e.Select=1]="Select";e[e.UploadImage=2]="UploadImage";e[e.UploadDoc=3]="UploadDoc";e[e.UploadTable=4]="UploadTable";e[e.UploadAudio=5]="UploadAudio";e[e.MixUpload=6]="MixUpload";e[e.VIDEO=7]="VIDEO";e[e.ARCHIVE=8]="ARCHIVE";e[e.CODE=9]="CODE";e[e.TXT=10]="TXT";e[e.PPT=11]="PPT"}(Xn||(Xn={})),function(e){e[e.SendTypeQuery=0]="SendTypeQuery";e[e.SendTypePanel=1]="SendTypePanel"}(er||(er={})),function(e){e[e.ToolTypeWorkFlow=1]="ToolTypeWorkFlow";e[e.ToolTypePlugin=2]="ToolTypePlugin"}(tr||(tr={}));class sr{__init(){this.request=e.request}__init2(){this.baseURL=""}constructor(e){sr.prototype.__init.call(this),sr.prototype.__init2.call(this),this.request=ir([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=ir([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}GetSpaceInfoV2(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/info"),o={space_id:i.space_id,join_space_type:i.join_space_type};return this.request({url:s,method:"POST",data:o},t)}DeleteSpaceV2(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/delete"),o={space_id:i.space_id};return this.request({url:s,method:"POST",data:o},t)}SaveSpaceV2(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/save"),o={space_id:i.space_id,name:i.name,description:i.description,icon_uri:i.icon_uri,space_type:i.space_type,space_mode:i.space_mode,space_config:i.space_config,enterprise_id:i.enterprise_id,organization_id:i.organization_id};return this.request({url:s,method:"POST",data:o},t)}GetSpaceListV2(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/space/list"),o={search_word:i.search_word,enterprise_id:i.enterprise_id,organization_id:i.organization_id,scope_type:i.scope_type,page:i.page,size:i.size};return this.request({url:s,method:"POST",data:o},t)}UpdateAgent(e,t){const i=e,s=this.genBaseURL("/api/playground_api/update_agent"),o={id:i.id,reference_id:i.reference_id,current_version:i.current_version,space_id:i.space_id,bot_id:i.bot_id,base_commit_version:i.base_commit_version,name:i.name,description:i.description,position:i.position,icon_uri:i.icon_uri,intents:i.intents,work_info:i.work_info,is_delete:i.is_delete};return this.request({url:s,method:"POST",data:o},t)}BatchCreateAgent(e,t){const i=e,s=this.genBaseURL("/api/playground_api/batch_create_agent"),o={space_id:i.space_id,bot_id:i.bot_id,agent_type:i.agent_type,position:i.position,references:i.references,agent_cnt:i.agent_cnt,base_commit_version:i.base_commit_version,version_compat:i.version_compat};return this.request({url:s,method:"POST",data:o},t)}GetPublishBotList(e,t){const i=e,s=this.genBaseURL("/api/playground_api/get_publish_bot_list"),o={space_id:i.space_id,bot_mode:i.bot_mode,page_num:i.page_num,page_size:i.page_size,name:i.name,login_user_create:i.login_user_create,bot_id:i.bot_id};return this.request({url:s,method:"GET",params:o},t)}MGetBotByVersion(e,t){const i=e,s=this.genBaseURL("/api/playground_api/mget_bot_by_version"),o={bot_versions:i.bot_versions,space_id:i.space_id};return this.request({url:s,method:"POST",data:o},t)}BotLastPublishInfo(e,t){const i=e,s=this.genBaseURL("/api/playground_api/bot_last_publish_info"),o={space_id:i.space_id,bot_id:i.bot_id,bot_mode:i.bot_mode};return this.request({url:s,method:"GET",params:o},t)}ProduceBot(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/produce/create_bot"),o={space_id:i.space_id,name:i.name,description:i.description,icon_url:i.icon_url,icon_uri:i.icon_uri,prompt:i.prompt,plugin_apis:i.plugin_apis,prologue:i.prologue,suggested_questions:i.suggested_questions,bot_source:i.bot_source};return this.request({url:s,method:"POST",data:o},t)}UpdateProducedBot(e,t){const i=e,s=this.genBaseURL("/api/playground_api/produce/update_bot"),o={bot_id:i.bot_id,name:i.name,description:i.description,icon_url:i.icon_url,icon_uri:i.icon_uri};return this.request({url:s,method:"POST",data:o},t)}GetPublishedBotList(e,t){const i=e,s=this.genBaseURL("/api/playground_api/bot_version/get_published_bot_list"),o={space_id_list:i.space_id_list,page:i.page,size:i.size};return this.request({url:s,method:"POST",data:o},t)}GetBotVersionInfo(e,t){const i=e,s=this.genBaseURL("/api/playground_api/bot_version/get_bot_version_info"),o={bot_id:i.bot_id,version:i.version,scene:i.scene};return this.request({url:s,method:"POST",data:o},t)}DuplicateBotVersionToSpace(e,t){const i=e,s=this.genBaseURL("/api/playground_api/dup_bot_version"),o={target_space_id:i.target_space_id,bot_id:i.bot_id,version:i.version,name:i.name,dup_society_host:i.dup_society_host};return this.request({url:s,method:"POST",data:o},t)}UpdateUserRiskAlertInfo(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/update_user_risk_alert_info"),o={risk_alert_type:i.risk_alert_type,switch_info:i.switch_info};return this.request({url:s,method:"POST",data:o},t)}GetUserRiskAlertInfo(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/get_user_risk_alert_info"),o={risk_alert_type_list:i.risk_alert_type_list,switch_type_list:i.switch_type_list},n={Cookie:i.Cookie};return this.request({url:s,method:"POST",data:o,headers:n},t)}DraftBotCollaboration(e,t){const i=e,s=this.genBaseURL("/api/playground_api/draftbot/collaboration"),o={space_id:i.space_id,bot_id:i.bot_id};return this.request({url:s,method:"POST",data:o},t)}BotInfoAudit(e,t){const i=e,s=this.genBaseURL("/api/playground_api/audit/bot_info"),o={bot_id:i.bot_id,bot_audit_info:i.bot_audit_info,space_id:i.space_id,bot_mode:i.bot_mode};return this.request({url:s,method:"POST",data:o},t)}TimeCapsuleInvokeEvent(e,t){const i=e,s=this.genBaseURL("/api/playground_api/timecapsule_invoke_event"),o={bot_id:i.bot_id};return this.request({url:s,method:"POST",data:o},t)}InviteMemberLinkV2(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/invite"),o={space_id:i.space_id,team_invite_link_status:i.team_invite_link_status,func:i.func};return this.request({url:s,method:"POST",data:o},t)}SpaceMemberDetailV2(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/space/member/detail"),o={space_id:i.space_id,search_word:i.search_word,space_role_type:i.space_role_type,page:i.page,size:i.size};return this.request({url:s,method:"POST",data:o},t)}JoinSpaceV2(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/join"),o={space_id:i.space_id,join_space_type:i.join_space_type,is_reject:i.is_reject};return this.request({url:s,method:"POST",data:o},t)}UpdateSpaceMemberV2(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/space/member/update"),o={space_id:i.space_id,user_id:i.user_id,space_role_type:i.space_role_type};return this.request({url:s,method:"POST",data:o},t)}TransferSpaceV2(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/space/member/transfer"),o={space_id:i.space_id,transfer_user_id:i.transfer_user_id};return this.request({url:s,method:"POST",data:o},t)}RemoveSpaceMemberV2(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/space/member/remove"),o={space_id:i.space_id,remove_user_id:i.remove_user_id,transfer_user_id:i.transfer_user_id};return this.request({url:s,method:"POST",data:o},t)}SearchMemberV2(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/member/search"),o={search_list:i.search_list,space_id:i.space_id,search_volcano_account_list:i.search_volcano_account_list,page:i.page,size:i.size};return this.request({url:s,method:"POST",data:o},t)}AddBotSpaceMemberV2(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/member/add"),o={member_info_list:i.member_info_list,space_id:i.space_id};return this.request({url:s,method:"POST",data:o},t)}ExitSpaceV2(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/space/member/exit"),o={space_id:i.space_id,transfer_user_id:i.transfer_user_id};return this.request({url:s,method:"POST",data:o},t)}GetBotPopupInfo(e,t){const i=e,s=this.genBaseURL("/api/playground_api/operate/get_bot_popup_info"),o={bot_popup_types:i.bot_popup_types,bot_id:i.bot_id};return this.request({url:s,method:"POST",data:o},t)}UpdateBotPopupInfo(e,t){const i=e,s=this.genBaseURL("/api/playground_api/operate/update_bot_popup_info"),o={bot_popup_type:i.bot_popup_type,bot_id:i.bot_id};return this.request({url:s,method:"POST",data:o},t)}GenerateDescription(e,t){const i=e,s=this.genBaseURL("/api/playground_api/draftbot/generate_description"),o={bot_name:i.bot_name,prompt:i.prompt};return this.request({url:s,method:"POST",data:o},t)}DraftBotPublishHistoryDetail(e,t){const i=e,s=this.genBaseURL("/api/playground_api/draftbot/publish_history_detail"),o={bot_id:i.bot_id,space_id:i.space_id,publish_id:i.publish_id,version:i.version};return this.request({url:s,method:"POST",data:o},t)}GenerateStoreCategory(e,t){const i=e,s=this.genBaseURL("/api/playground_api/draftbot/generate_store_category"),o={bot_name:i.bot_name,bot_description:i.bot_description,prompt:i.prompt};return this.request({url:s,method:"POST",data:o},t)}UpdateMultiAgent(e,t){const i=e,s=this.genBaseURL("/api/playground_api/update_multi_agent"),o={space_id:i.space_id,bot_id:i.bot_id,session_type:i.session_type,base_commit_version:i.base_commit_version,connector_type:i.connector_type};return this.request({url:s,method:"POST",data:o},t)}SwitchAgentVersion(e,t){const i=e,s=this.genBaseURL("/api/playground_api/switch_agent_version"),o={bot_id:i.bot_id,space_id:i.space_id,operate_type:i.operate_type};return this.request({url:s,method:"POST",data:o},t)}LangDetect(e,t){const i=e,s=this.genBaseURL("/api/playground_api/audio/lang/detect"),o={detect_text_list:i.detect_text_list};return this.request({url:s,method:"POST",data:o},t)}GetImagexShortUrl(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/get_imagex_url"),o={uris:i.uris,scene:i.scene};return this.request({url:s,method:"POST",data:o},t)}GetPlatformCommonConfig(e,t){const i=this.genBaseURL("/api/playground_api/get_platform_common_config");return this.request({url:i,method:"GET"},t)}CreateShortcutCommand(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/create_shortcut_command"),o={object_id:i.object_id,shortcuts:i.shortcuts};return this.request({url:s,method:"POST",data:o},t)}MGetUserBasicInfo(e,t){const i=e,s=this.genBaseURL("/api/playground_api/mget_user_info"),o={user_ids:i.user_ids,need_user_status:i.need_user_status,need_enterprise_identity:i.need_enterprise_identity,need_volcano_user_name:i.need_volcano_user_name};return this.request({url:s,method:"POST",data:o},t)}BindVolcanoTrn(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/bind_volcano_trn"),o={space_id:i.space_id,trn:i.trn,account_name:i.account_name};return this.request({url:s,method:"POST",data:o},t)}UnbindVolcanoTrn(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/unbind_volcano_trn"),o={space_id:i.space_id};return this.request({url:s,method:"POST",data:o},t)}RetrieveFileOpen(e,t){const i=e,s=this.genBaseURL("/v1/files/retrieve"),o={file_id:i.file_id};return this.request({url:s,method:"GET",params:o},t)}RetrieveFileContentOpen(e,t){const i=e,s=this.genBaseURL("/v1/files/content/retrieve"),o={file_id:i.file_id};return this.request({url:s,method:"GET",params:o},t)}UploadFileOpen(e,t){const i=e,s=this.genBaseURL("/v1/files/upload"),o={Data:i.Data},n={"Content-Type":i["Content-Type"]};return this.request({url:s,method:"POST",data:o,headers:n},t)}BotInfoCheck(e,t){const i=e,s=this.genBaseURL("/api/playground_api/check/bot_info_check"),o={bot_id:i.bot_id,space_id:i.space_id,bot_audit_info:i.bot_audit_info};return this.request({url:s,method:"POST",data:o},t)}SupportVoiceCall(e,t){const i=e,s=this.genBaseURL("/api/playground_api/support_voice_call"),o={voice_id_list:i.voice_id_list};return this.request({url:s,method:"POST",data:o},t)}CreateUpdateShortcutCommand(e,t){const i=e,s=this.genBaseURL("/api/playground_api/create_update_shortcut_command"),o={object_id:i.object_id,space_id:i.space_id,shortcuts:i.shortcuts};return this.request({url:s,method:"POST",data:o},t)}MoveDraftBot(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/move_draft_bot"),o={bot_id:i.bot_id,target_spaceId:i.target_spaceId,from_spaceId:i.from_spaceId,move_action:i.move_action};return this.request({url:s,method:"POST",data:o},t)}GetShortcutAvailNodes(e,t){const i=e,s=this.genBaseURL("/api/playground_api/get_shortcut_avail_nodes"),o={bot_id:i.bot_id,space_id:i.space_id,page_num:i.page_num,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}MarkReadNotice(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/gen_img/mark_read_notice"),o={bot_id:i.bot_id,pic_type:i.pic_type};return this.request({url:s,method:"POST",data:o},t)}CancelGenerateGif(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/gen_img/cancel_generate_gif"),o={task_id:i.task_id};return this.request({url:s,method:"POST",data:o},t)}GetPicTask(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/gen_img/get_pic_task"),o={bot_id:i.bot_id,pic_type:i.pic_type};return this.request({url:s,method:"POST",data:o},t)}GeneratePic(e,t){const i=e,s=this.genBaseURL("/api/playground_api/gen_img/generate_pic"),o={gen_prompt:i.gen_prompt,image_url:i.image_url,image_uri:i.image_uri,bot_id:i.bot_id,pic_type:i.pic_type,device_id:i.device_id,bot_name:i.bot_name,bot_desc:i.bot_desc};return this.request({url:s,method:"POST",data:o},t)}GetGenPicTimes(e,t){const i=this.genBaseURL("/api/playground_api/gen_img/get_gen_pic_times");return this.request({url:i,method:"POST"},t)}ListStyle(e,t){const i=this.genBaseURL("/api/playground_api/gen_img/list_style");return this.request({url:i,method:"POST"},t)}GetFileUrls(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/get_file_list"),o={scene:i.scene};return this.request({url:s,method:"POST",data:o},t)}GetDraftBotInfoAgw(e,t){const i=e,s=this.genBaseURL("/api/playground_api/draftbot/get_draft_bot_info"),o={bot_id:i.bot_id,version:i.version,commit_version:i.commit_version};return this.request({url:s,method:"POST",data:o},t)}CommitDraftBotInfoAgw(e,t){const i=e,s=this.genBaseURL("/api/playground_api/draftbot/commit_draft_bot_info"),o={bot_id:i.bot_id,remark:i.remark};return this.request({url:s,method:"POST",data:o},t)}UpdateDraftBotInfoAgw(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/draftbot/update_draft_bot_info"),o={bot_info:i.bot_info,base_commit_version:i.base_commit_version};return this.request({url:s,method:"POST",data:o},t)}GetUserQueryCollectOption(e,t){const i=this.genBaseURL("/api/playground_api/draftbot/get_user_query_collect_option");return this.request({url:i,method:"GET"},t)}GenerateUserQueryCollectPolicy(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/draftbot/generate_user_query_collect_policy"),o={bot_id:i.bot_id,developer_name:i.developer_name,contact_information:i.contact_information};return this.request({url:s,method:"POST",data:o},t)}GetCozeProRights(e,t){const i=this.genBaseURL("/api/playground_api/get_coze_pro_rights");return this.request({url:i,method:"POST"},t)}GetPolicyContent(e,t){const i=e,s=this.genBaseURL(`/api/playground_api/private_policy/${i.secret}`);return this.request({url:s,method:"GET"},t)}UpdateAgentV2(e,t){const i=e,s=this.genBaseURL("/api/playground_api/update_agent_v2"),o={id:i.id,reference_id:i.reference_id,current_version:i.current_version,space_id:i.space_id,bot_id:i.bot_id,base_commit_version:i.base_commit_version,name:i.name,description:i.description,position:i.position,icon_uri:i.icon_uri,intents:i.intents,is_delete:i.is_delete,prompt_info:i.prompt_info,model_info:i.model_info,plugin_info_list:i.plugin_info_list,knowledge:i.knowledge,workflow_info_list:i.workflow_info_list,jump_config:i.jump_config,suggest_reply_info:i.suggest_reply_info,hook_info:i.hook_info};return this.request({url:s,method:"POST",data:o},t)}CopyAgentV2(e,t){const i=e,s=this.genBaseURL("/api/playground_api/copy_agent_v2"),o={bot_id:i.bot_id,agent_id:i.agent_id,base_commit_version:i.base_commit_version};return this.request({url:s,method:"POST",data:o},t)}CreateAgentV2(e,t){const i=e,s=this.genBaseURL("/api/playground_api/create_agent_v2"),o={bot_id:i.bot_id,agent_type:i.agent_type,position:i.position,references:i.references,base_commit_version:i.base_commit_version};return this.request({url:s,method:"POST",data:o},t)}BatchCreateAgentV2(e,t){const i=e,s=this.genBaseURL("/api/playground_api/batch_create_agent_v2"),o={bot_id:i.bot_id,agent_type:i.agent_type,position:i.position,references:i.references,agent_cnt:i.agent_cnt,base_commit_version:i.base_commit_version};return this.request({url:s,method:"POST",data:o},t)}CozeProCopyGetLinkMetaInfo(e,t){const i=e,s=this.genBaseURL("/api/playground_api/coze_pro/get_link_meta_info"),o={auth_code:i.auth_code};return this.request({url:s,method:"POST",data:o},t)}CozeProCopyTaskConfirm(e,t){const i=e,s=this.genBaseURL("/api/playground_api/coze_pro/copy_task_confirm"),o={auth_code:i.auth_code};return this.request({url:s,method:"POST",data:o},t)}CozeProCopyGenerateAuthLink(e,t){const i=e,s=this.genBaseURL("/api/playground_api/coze_pro/generate_auth_link"),o={copy_user_id:i.copy_user_id,target_space_id:i.target_space_id};return this.request({url:s,method:"POST",data:o},t)}GetOpVoiceList(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/get_op_voice_list"),o={voice_ids:i.voice_ids,name:i.name,style_id:i.style_id,language_code:i.language_code,status:i.status,page_index:i.page_index,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}GetSupportLanguage(e,t){const i=this.genBaseURL("/api/playground_api/get_support_language");return this.request({url:i,method:"GET"},t)}SynchronizeVoiceList(e,t){const i=this.genBaseURL("/api/playground_api/synchronize_voice_list");return this.request({url:i,method:"GET"},t)}CheckBotAllModelPluginIds(e,t){const i=e,s=this.genBaseURL("/api/playground_api/draftbot/check_bot_all_model_plugin_ids"),o={bot_id:i.bot_id,commit_version:i.commit_version};return this.request({url:s,method:"POST",data:o},t)}GetBotCollaborationQuota(e,t){const i=e,s=this.genBaseURL("/api/playground_api/draftbot/collaboration_quota"),o={bot_id:i.bot_id,only_config_item:i.only_config_item,account_type:i.account_type};return this.request({url:s,method:"POST",data:o},t)}OpenCreateSpace(e,t){const i=e||{},s=this.genBaseURL("/v1/workspaces"),o={name:i.name,description:i.description,icon_file_id:i.icon_file_id,coze_account_id:i.coze_account_id,owner_uid:i.owner_uid};return this.request({url:s,method:"POST",data:o},t)}NoticeMarkRead(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/notice/mark_read"),o={notice_ids:i.notice_ids,mark_all:i.mark_all};return this.request({url:s,method:"POST",data:o},t)}GetNoticeList(e,t){const i=e,s=this.genBaseURL("/api/playground_api/notice/get_list"),o={cursor:i.cursor,count:i.count,notice_rank_type:i.notice_rank_type};return this.request({url:s,method:"POST",data:o},t)}GetNoticeUnreadCount(e,t){const i=this.genBaseURL("/api/playground_api/notice/get_unread_count");return this.request({url:i,method:"POST"},t)}OpenSpaceList(e,t){const i=e||{},s=this.genBaseURL("/v1/workspaces"),o={page_num:i.page_num,page_size:i.page_size,enterprise_id:i.enterprise_id,user_id:i.user_id,coze_account_id:i.coze_account_id,scope:i.scope};return this.request({url:s,method:"GET",params:o},t)}ReportUserBehavior(e,t){const i=e,s=this.genBaseURL("/api/playground_api/report_user_behavior"),o={resource_id:i.resource_id,resource_type:i.resource_type,behavior_type:i.behavior_type,space_id:i.space_id};return this.request({url:s,method:"POST",data:o},t)}GetUserConfig(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/get_user_config"),o={risk_alert_type_list:i.risk_alert_type_list,switch_type_list:i.switch_type_list},n={Cookie:i.Cookie};return this.request({url:s,method:"POST",data:o,headers:n},t)}UpdateUserConfig(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/update_user_config"),o={risk_alert_type:i.risk_alert_type,switch_info:i.switch_info};return this.request({url:s,method:"POST",data:o},t)}GetRecentDraftBotList(e,t){const i=e,s=this.genBaseURL("/api/playground_api/draftbot/get_recent_draft_bot"),o={behavior_type:i.behavior_type,limit:i.limit};return this.request({url:s,method:"POST",data:o},t)}GetPromptResourceInfo(e,t){const i=e,s=this.genBaseURL("/api/playground_api/get_prompt_resource_info"),o={prompt_resource_id:i.prompt_resource_id};return this.request({url:s,method:"GET",params:o},t)}UpsertPromptResource(e,t){const i=e,s=this.genBaseURL("/api/playground_api/upsert_prompt_resource"),o={prompt:i.prompt};return this.request({url:s,method:"POST",data:o},t)}DeletePromptResource(e,t){const i=e,s=this.genBaseURL("/api/playground_api/delete_prompt_resource"),o={prompt_resource_id:i.prompt_resource_id};return this.request({url:s,method:"POST",data:o},t)}GetPromptReferenceInfo(e,t){const i=e,s=this.genBaseURL("/api/playground_api/get_prompt_reference_info"),o={space_id:i.space_id,reference_id:i.reference_id,reference_type:i.reference_type,api_id:i.api_id,project_id:i.project_id,avatar_bot_id:i.avatar_bot_id};return this.request({url:s,method:"POST",data:o},t)}GetOfficialPromptResourceList(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/get_official_prompt_list"),o={keyword:i.keyword};return this.request({url:s,method:"POST",data:o},t)}GetByteTreeByName(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/bpm/search_byte_tree"),o={name:i.name},n={"x-jwt-token":i["x-jwt-token"]};return this.request({url:s,method:"GET",params:o,headers:n},t)}CreatePrivateModel(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/bpm/create_private_model"),o={space_id:i.space_id,model_vendor:i.model_vendor,model_show_name:i.model_show_name,model_arch:i.model_arch,ak:i.ak,token_limit:i.token_limit,upper_limit_of_max_token:i.upper_limit_of_max_token,function_call:i.function_call,multimodal:i.multimodal,multimodal_types:i.multimodal_types,form_detail:i.form_detail,record_id:i.record_id,maas_model_name:i.maas_model_name,maas_model_version:i.maas_model_version,maas_model_customer_id:i.maas_model_customer_id,model_family:i.model_family,space_id_i18n:i.space_id_i18n,operator:i.operator,email:i.email,employee_id:i.employee_id,presence_penalty_config:i.presence_penalty_config,frequency_penalty_config:i.frequency_penalty_config,temperature_config:i.temperature_config,top_p_config:i.top_p_config},n={"x-inner-auth":i["x-inner-auth"],"x-jwt-token":i["x-jwt-token"]};return this.request({url:s,method:"POST",data:o,headers:n},t)}CheckExemptFormInfo(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/bpm/check_exempt_form_info"),o={exempt_form_type:i.exempt_form_type,space_id:i.space_id},n={"x-jwt-token":i["x-jwt-token"]};return this.request({url:s,method:"POST",data:o,headers:n},t)}SetByteTreeForSpace(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/bpm/set_byte_tree_for_space"),o={space_id:i.space_id,byte_tree_node_id:i.byte_tree_node_id,byte_tree_node_name:i.byte_tree_node_name,form_detail:i.form_detail,record_id:i.record_id},n={"x-jwt-token":i["x-jwt-token"]};return this.request({url:s,method:"POST",data:o,headers:n},t)}GetModelCapability(e,t){const i=e,s=this.genBaseURL("/api/playground_api/bpm/get_model_capability"),o={vendor:i.vendor,model_arch:i.model_arch,maas_model_name:i.maas_model_name,maas_model_version:i.maas_model_version,maas_customer_id:i.maas_customer_id},n={"x-jwt-token":i["x-jwt-token"]};return this.request({url:s,method:"POST",data:o,headers:n},t)}GetSpaceDetail(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/detail"),o={space_id:i.space_id};return this.request({url:s,method:"POST",data:o},t)}RevocateSpaceInvite(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/space/revocate_invite"),o={space_id:i.space_id,invite_user_id:i.invite_user_id};return this.request({url:s,method:"GET",params:o},t)}SaveVolcanoUserManageInfo(e,t){const i=e,s=this.genBaseURL("/api/playground_api/coze_pro/save_volcano_user_manage_info"),o={volcano_basic_user_config:i.volcano_basic_user_config};return this.request({url:s,method:"POST",data:o},t)}GetVolcanoUserManageInfo(e,t){const i=this.genBaseURL("/api/playground_api/coze_pro/get_volcano_user_manage_info");return this.request({url:i,method:"POST"},t)}GetSpaceInviteManageList(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/space/invite_manage_list"),o={space_id:i.space_id,space_invite_status:i.space_invite_status,search_word:i.search_word,page:i.page,size:i.size};return this.request({url:s,method:"GET",params:o},t)}DebugDouYin(e,t){const i=e,s=this.genBaseURL("/api/playground_api/douyin/debug"),o={bot_id:i.bot_id};return this.request({url:s,method:"POST",data:o},t)}GetDouYinAuthCode(e,t){const i=this.genBaseURL("/api/playground_api/douyin/get_auth_qr_code");return this.request({url:i,method:"GET"},t)}GetDouyinAvatarInfo(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/douyin/v1/get_avatar_info"),o={is_draft:i.is_draft,body:i.body},n={"Open-Platform-App-ID":i["Open-Platform-App-ID"],"Byte-Signature":i["Byte-Signature"],"Byte-Timestamp":i["Byte-Timestamp"],"Byte-Nonce-Str":i["Byte-Nonce-Str"]};return this.request({url:s,method:"POST",data:o,headers:n},t)}DouYinAuthUserList(e,t){const i=e,s=this.genBaseURL("/api/playground_api/douyin/auth_user_list"),o={page_index:i.page_index,page_size:i.page_size,bind_status:i.bind_status,order_by:i.order_by};return this.request({url:s,method:"POST",data:o},t)}GetDebugDouYinStatus(e,t){const i=e,s=this.genBaseURL("/api/playground_api/douyin/get_debug_status"),o={bot_id:i.bot_id};return this.request({url:s,method:"POST",data:o},t)}CanUserApplyClose(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/coze_pro/can_user_apply_close"),o={AccountId:i.AccountId,EventName:i.EventName,Action:i.Action,Version:i.Version},n={"X-Tt-Logid":i["X-Tt-Logid"],"X-Top-Service":i["X-Top-Service"],"X-Top-Region":i["X-Top-Region"]};return this.request({url:s,method:"GET",params:o,headers:n},t)}CreateRoom(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/create_room"),o={bot_id:i.bot_id,conversation_id:i.conversation_id,scene:i.scene,voice_id:i.voice_id,video_config:i.video_config};return this.request({url:s,method:"POST",data:o},t)}GetVoiceList(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/get_voice_list"),o={page_index:i.page_index,page_size:i.page_size,language_code:i.language_code};return this.request({url:s,method:"POST",data:o},t)}GetVoiceByIds(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/get_voice_by_ids"),o={voice_id_map:i.voice_id_map,voice_type:i.voice_type,space_id:i.space_id,emotion_config:i.emotion_config,voice_biz_scene:i.voice_biz_scene};return this.request({url:s,method:"POST",data:o},t)}GrayVoice(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/gray_voice"),o={bot_id:i.bot_id,language_to_voice_id:i.language_to_voice_id};return this.request({url:s,method:"POST",data:o},t)}GetSpaceApplyManageList(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/space/apply_manage_list"),o={space_id:i.space_id,space_apply_status:i.space_apply_status,search_word:i.search_word,page:i.page,size:i.size};return this.request({url:s,method:"GET",params:o},t)}DraftBotCrossSpaceCopy(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/draftbot/crossspace_copy"),o={bot_id:i.bot_id,to_space_id:i.to_space_id};return this.request({url:s,method:"POST",data:o},t)}RemovePublishMember(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/remove_publish_member"),o={space_id:i.space_id,member_list:i.member_list};return this.request({url:s,method:"POST",data:o},t)}AddPublishMember(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/add_publish_member"),o={space_id:i.space_id,member_list:i.member_list};return this.request({url:s,method:"POST",data:o},t)}SearchAddablePublishMember(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/search_addable_publish_member"),o={space_id:i.space_id,search_word:i.search_word,cursor_id:i.cursor_id,limit:i.limit};return this.request({url:s,method:"POST",data:o},t)}PublishMemberList(e,t){const i=e,s=this.genBaseURL("/api/playground_api/space/publish_member_list"),o={space_id:i.space_id,search_word:i.search_word,cursor_id:i.cursor_id,limit:i.limit};return this.request({url:s,method:"POST",data:o},t)}OperateSpaceApply(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/space/operate_apply"),o={space_id:i.space_id,enterprise_id:i.enterprise_id,organization_id:i.organization_id,apply_id_list:i.apply_id_list,space_apply_status:i.space_apply_status};return this.request({url:s,method:"POST",data:o},t)}ImportSpaceConfirm(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/space/import/confirm"),o={space_id_list:i.space_id_list,enterprise_id:i.enterprise_id,organization_id:i.organization_id,personal_space_new_name:i.personal_space_new_name,user_id_list:i.user_id_list};return this.request({url:s,method:"POST",data:o},t)}ImportSpaceList(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/space/import/list"),o={enterprise_id:i.enterprise_id,organization_id:i.organization_id,search_word:i.search_word};return this.request({url:s,method:"GET",params:o},t)}ImportSpaceUserList(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/space/import/user_list"),o={space_id_list:i.space_id_list,enterprise_id:i.enterprise_id,organization_id:i.organization_id};return this.request({url:s,method:"POST",data:o},t)}GetDouYinInfo(e,t){const i=this.genBaseURL("/api/playground_api/douyin/get_douyin_info");return this.request({url:i,method:"POST"},t)}LongTermMemoryList(e,t){const i=e,s=this.genBaseURL("/api/playground_api/long_term_memory/list"),o={bot_id:i.bot_id,connector_id:i.connector_id,offset:i.offset,limit:i.limit,time_capsule_item_type:i.time_capsule_item_type};return this.request({url:s,method:"GET",params:o},t)}LongTermMemoryUpdate(e,t){const i=e,s=this.genBaseURL("/api/playground_api/long_term_memory/update"),o={bot_id:i.bot_id,connector_id:i.connector_id,biz_id:i.biz_id,new_content:i.new_content,event_ms:i.event_ms,ext:i.ext,tags:i.tags,time_capsule_item_type:i.time_capsule_item_type,iid:i.iid,meta_type:i.meta_type,memory_type:i.memory_type};return this.request({url:s,method:"POST",data:o},t)}LongTermMemoryClearAll(e,t){const i=e,s=this.genBaseURL("/api/playground_api/long_term_memory/clear_all"),o={bot_id:i.bot_id,connector_id:i.connector_id,time_capsule_item_type:i.time_capsule_item_type};return this.request({url:s,method:"POST",data:o},t)}LongTermMemoryDelete(e,t){const i=e,s=this.genBaseURL("/api/playground_api/long_term_memory/delete"),o={bot_id:i.bot_id,connector_id:i.connector_id,biz_ids:i.biz_ids,time_capsule_item_type:i.time_capsule_item_type,iids:i.iids,memory_meta_type_map:i.memory_meta_type_map};return this.request({url:s,method:"POST",data:o},t)}LongTermMemoryVersion(e,t){const i=e,s=this.genBaseURL("/api/playground_api/long_term_memory/version"),o={bot_id:i.bot_id};return this.request({url:s,method:"GET",params:o},t)}GetVoiceListV2(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/get_voice_list_v2"),o={language_code:i.language_code,space_id:i.space_id,voice_type:i.voice_type,page_size:i.page_size,next_cursor:i.next_cursor};return this.request({url:s,method:"POST",data:o},t)}GetUserUpdateProfileTag(e,t){const i=this.genBaseURL("/api/playground_api/get_user_update_profile_tag");return this.request({url:i,method:"GET"},t)}OpenRemoveSpaceMember(e,t){const i=e||{},s=this.genBaseURL(`/v1/workspaces/${i.workspace_id}/members`),o={user_ids:i.user_ids};return this.request({url:s,method:"DELETE",data:o},t)}OpenSpaceMemberList(e,t){const i=e||{},s=this.genBaseURL(`/v1/workspaces/${i.workspace_id}/members`),o={page_num:i.page_num,page_size:i.page_size};return this.request({url:s,method:"GET",params:o},t)}OpenAddSpaceMember(e,t){const i=e||{},s=this.genBaseURL(`/v1/workspaces/${i.workspace_id}/members`),o={users:i.users};return this.request({url:s,method:"POST",data:o},t)}OpenGetBotInfo(e,t){const i=e||{},s=this.genBaseURL(`/v1/bots/${i.bot_id}`),o={is_published:i.is_published,connector_id:i.connector_id};return this.request({url:s,method:"GET",params:o},t)}OpenApplyJoinSpace(e,t){const i=e||{},s=this.genBaseURL(`/v1/workspaces/${i.workspace_id}/members/apply`),o={user_ids:i.user_ids};return this.request({url:s,method:"POST",data:o},t)}OpenRemoveSpace(e,t){const i=e||{},s=this.genBaseURL(`/v1/workspaces/${i.workspace_id}`);return this.request({url:s,method:"DELETE"},t)}GetTypeList(e,t){const i=e||{},s=this.genBaseURL("/api/playground_api/get_type_list"),o={model:i.model,voice:i.voice,raw_model:i.raw_model,space_id:i.space_id,cur_model_id:i.cur_model_id,cur_model_ids:i.cur_model_ids,model_scene:i.model_scene,tag_filters:i.tag_filters};return this.request({url:s,method:"POST",data:o},t)}GetCozeLaneInfo(e,t){const i=this.genBaseURL("/api/playground_api/get_coze_lane_info");return this.request({url:i,method:"POST"},t)}OpenUpdateSpaceMember(e,t){const i=e||{},s=this.genBaseURL(`/v1/workspaces/${i.workspace_id}/members/${i.user_id}`),o={role_type:i.role_type};return this.request({url:s,method:"PUT",data:o},t)}OpenListBotVersions(e,t){const i=e||{},s=this.genBaseURL(`/v1/bots/${i.bot_id}/versions`),o={page_num:i.page_num,page_size:i.page_size,publish_status:i.publish_status,connector_id:i.connector_id};return this.request({url:s,method:"GET",params:o},t)}OpenSwitchBotDevelopMode(e,t){const i=e||{},s=this.genBaseURL(`/v1/bots/${i.bot_id}/collaboration_mode`),o={collaboration_mode:i.collaboration_mode};return this.request({url:s,method:"POST",data:o},t)}OpenUpdateSpace(e,t){const i=e||{},s=this.genBaseURL(`/v1/workspaces/${i.workspace_id}`),o={name:i.name,description:i.description};return this.request({url:s,method:"PUT",data:o},t)}}const or=new sr({});function nr(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}async function rr(t,s){if(nr([t,"access",e=>e.commandConfig,"optionalAccess",e=>e.skipAuth]))return void await s();if(!t.config.accessToken)throw new e.CozeError(e.ErrorCode.E2001,"No API token found. Please authenticate first.",void 0,{fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable",example:"coze auth login --oauth"});if(nr([t,"access",e=>e.commandConfig,"optionalAccess",e=>e.skipOrgCheck]))return void await s();const o=await async function(t){let s=t.config.organizationId,{enterpriseId:o}=t.config,n=!1;const{data:r}=await ns.ListEnterprise({contain_enterprise_of_user:!0,contain_organization_of_user:!0}),a=r.enterprise_info_list||[],c=r.personal_account_info;if(s){if(!a.some((e=>nr([e,"access",e=>e.organization_info_list,"optionalAccess",e=>e.some,"call",e=>e((e=>e.organization_id===s))]))))throw new e.CozeError(e.ErrorCode.E1000,`Organization ID ${s} is invalid or not found`,void 0,{fix:"Run `coze organization list` and select a valid organization",example:"coze organization use <organization_id>"})}else{if(c.available)return!1;let r;t.ui.info(i.gray("[Context] Organization ID not found. Attempting to auto-initialize..."));for(const e of a)if(e.organization_info_list&&e.organization_info_list.length>0){const t=e.organization_info_list[0];r={id:t.organization_id,name:t.organization_name,entId:e.enterprise_id};break}if(!r)throw new e.CozeError(e.ErrorCode.E3000,"No organizations found",void 0,{fix:"Create an organization or join an existing one",example:"coze organization list"});s=r.id,o=r.entId,t.config.organizationId=s,t.config.enterpriseId=o,n=!0,t.ui.info(`[Context] Auto-selected Organization: ${r.name} (${r.id})`)}return n}(t);if(nr([t,"access",e=>e.commandConfig,"optionalAccess",e=>e.skipSpaceCheck]))return o&&await ar(t,{organizationId:t.config.organizationId,enterpriseId:t.config.enterpriseId}),void await s();const n=await async function(t){const i=t.config.organizationId,{enterpriseId:s}=t.config;let{spaceId:o}=t.config,n=!1;try{if(o){const{data:t}=await or.GetSpaceListV2({organization_id:i,enterprise_id:s}),n=nr([t,"optionalAccess",e=>e.bot_space_list])||[];if(!n.some((e=>e.id===o))){const t=i?`[Context] Space ID ${o} is invalid or not found in organization ${i}.`:`[Context] Space ID ${o} is invalid or not found.`;throw new e.CozeError(e.ErrorCode.E1000,t,void 0,{fix:"Run `coze space list` and select a valid space",example:"coze space use <space_id>"})}}else{t.ui.info("[Context] Space ID not found. Attempting to auto-initialize...");const{data:r}=await or.GetSpaceListV2({organization_id:i,enterprise_id:s,page:1,size:1}),a=nr([r,"optionalAccess",e=>e.bot_space_list,"optionalAccess",e=>e[0]]);if(!a){const t=i?`[Context] No spaces found in organization ${i}. Please create one.`:"[Context] No spaces found. Please create one.";throw new e.CozeError(e.ErrorCode.E3000,t,void 0,{fix:"Create a space in the current organization",example:"coze space list"})}o=a.id,t.config.spaceId=o,n=!0,t.ui.success(`[Context] Auto-selected Space: ${a.name} (${a.id})`)}}catch(t){const i=t instanceof e.CozeError?t:new e.CozeError(e.ErrorCode.E5000,t.message,t instanceof Error?t.stack:t);throw i.fix??="Switch organization or space using `coze organization use <organization_id>` or `coze space use <space_id>`",i.example??="coze organization list",i}return n}(t);await cr(t),(o||n)&&await ar(t,{organizationId:t.config.organizationId,enterpriseId:t.config.enterpriseId,spaceId:t.config.spaceId,billingProjectId:t.config.billingProjectId}),await s()}async function ar(e,t){try{await o.saveConfig(t)}catch(t){e.ui.warn(`Failed to save auto-initialized context: ${t}`)}}const cr=async i=>{const{spaceId:s}=i.config;try{const{data:o}=await t.IdeApi.GetOrCreateBillingProject({space_id:s});if(!nr([o,"optionalAccess",e=>e.project_id]))throw new e.CozeError(e.ErrorCode.E5002,"[Context] Failed to get billing project ID from response.",o);i.config.billingProjectId=o.project_id,i.ui.success(`[Context] Billing Project: ${o.project_id} (space: ${s})`)}catch(e){const t=[`Failed to get billing project, ${e.message}. please check your space context:`," coze space list"," coze space use <space_id>"];throw e.message=`${t.join("\n")}`,e}};function lr(e,t){return null!=e?e:t()}function dr(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const pr=t=>{const i=t.command("space").config({skipSpaceCheck:!0,help:{brief:"Workspace (Space) context management commands",description:"Provides workspace viewing and switching functionality, used to set the default Space ID for subsequent commands",examples:[{desc:"List all available workspaces",cmd:"coze space list"},{desc:"Set default space",cmd:"coze space use 123456789"}],seeAlso:["coze organization"]}}).description("Manage workspace (Space) context");i.command("list").description("List all spaces").config({help:{brief:"List all workspaces under the current organization",description:"Retrieve and display a list of all available Spaces under the currently configured Organization or Enterprise. Defaults to fetching up to the first 100.",examples:[{desc:"List space list",cmd:"coze space list",tags:["[RECOMMENDED]"]},{desc:"List in JSON format",cmd:"coze space list --format json"}],schema:{output:{type:"array",items:{type:"object",properties:{id:{type:"string",description:"Space ID"},name:{type:"string",description:"Space name"},org_id:{type:"string",description:"Belonging Organization ID"}}}}}}}).action((async(e,t)=>{const i=t.getContext(),s=e.orgId||dr([i,"optionalAccess",e=>e.config,"access",e=>e.organizationId]),o=dr([i,"optionalAccess",e=>e.config,"access",e=>e.enterpriseId]);dr([i,"optionalAccess",e=>e.ui,"access",e=>e.verbose,"call",e=>e(`Fetching spaces for organization '${s}'...`)]);const n=await async function(e){const{data:t}=await or.GetSpaceListV2({organization_id:e.orgId,enterprise_id:e.enterpriseId,page:1,size:100});return lr(function(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}([t,"optionalAccess",e=>e.bot_space_list]),(()=>[])).map((t=>({id:lr(t.id,(()=>"")),name:lr(t.name,(()=>"")),org_id:lr(e.orgId,(()=>""))})))}({orgId:s,enterpriseId:o});dr([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Available Spaces:")]),dr([i,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(n)]);const r=["Please use the following command to switch space:"," coze space use <space_id>"];dr([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(r.join("\n"))])})),i.command("use").description("Set the default workspace context").argument("<space_id>","Space ID to set as default context").config({help:{brief:"Switch current default Space",description:"Save the specified space_id to the local configuration as the default workspace for subsequent commands.",examples:[{desc:"Switch space",cmd:"coze space use 7349123847123",tags:["[RECOMMENDED]"]}],schema:{input:{space_id:{type:"string",required:!0,description:"Space ID to switch to"}},output:{status:{type:"string"},message:{type:"string"}}}}}).action((async(t,i,s)=>{const n=s.getContext();dr([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Switching to space '${t}'...`)]),await async function(t){try{await o.saveConfig({spaceId:t})}catch(i){throw new e.CozeError(e.ErrorCode.E5000,`Failed to set default space to '${t}': ${i.message}`,i.stack)}}(t),dr([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Default space set to '${t}' successfully.`)]),"json"===dr([n,"optionalAccess",e=>e.format])&&dr([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({status:"success",message:`Default space set to '${t}'.`})])}))};function ur(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const _r=async t=>{ur([t,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Switching to personal account...")]);const{available:i}=await async function(){const[e,{data:t}]=await Promise.all([o.loadConfig(),ns.ListEnterprise({contain_enterprise_of_user:!0,contain_organization_of_user:!0})]);if(!function(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}([t.personal_account_info,"optionalAccess",e=>e.available]))return{available:!1};const i=!!e.organizationId;return await o.saveConfig({organizationId:void 0,enterpriseId:void 0,...i?{spaceId:void 0}:{}}),{available:!0}}();if(!i)throw new e.CozeError(e.ErrorCode.E1000,"Personal account is not available for the current user.");ur([t,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Switched to personal account successfully.")]),"json"===ur([t,"optionalAccess",e=>e.format])&&ur([t,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({status:"success",message:"Switched to personal account."})])},mr=t=>{const i=t.command("organization").config({skipOrgCheck:!0,help:{brief:"Manage organization context",description:"Provides viewing and switching functions for organizations, used to set the default Organization ID for subsequent commands. Supports switching to personal account by omitting the org_id.",examples:[{desc:"List all accessible organizations",cmd:"coze organization list"},{desc:"Set default organization",cmd:"coze organization use 123456"},{desc:"Switch to personal account",cmd:"coze organization use"},{desc:"List organizations (alias)",cmd:"coze org list"},{desc:"Set default organization (alias)",cmd:"coze org use 123456"}],seeAlso:["coze space"]}}).alias("org").description("Manage organization context");i.command("list").description("List all accessible organizations").config({help:{brief:"List all accessible organizations",description:"Retrieve and display all organizations (Teams) and their corresponding enterprises accessible to the current logged-in user.",examples:[{desc:"List organizations",cmd:"coze organization list",tags:["[RECOMMENDED]"]},{desc:"Output in JSON format",cmd:"coze organization list --format json"}],schema:{output:{type:"array",items:{type:"object",properties:{id:{type:"string",description:"Organization ID"},name:{type:"string",description:"Organization name"},enterprise_id:{type:"string",description:"Belonging Enterprise ID"},enterprise_name:{type:"string",description:"Belonging Enterprise name"}}}}}}}).action((async(e,t)=>{const i=t.getContext();ur([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Fetching organizations...")]);const s=await async function(){const{data:e}=await ns.ListEnterprise({contain_enterprise_of_user:!0,contain_organization_of_user:!0});return e.enterprise_info_list.flatMap((e=>(e.organization_info_list||[]).map((t=>({id:t.organization_id,name:t.organization_name,enterprise_id:e.enterprise_id,enterprise_name:e.name})))))}();ur([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Available Organizations (Teams):")]),ur([i,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(s)]);const o=["Please use the following command to switch organization:"," coze organization use <organization_id>","Please use the following command to switch space:"," coze space list"," coze space use <space_id>"];ur([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(o.join("\n"))])})),i.command("use").description("Set the default organization context").argument("[org_id]","Organization ID to set as default context (empty to switch to personal account)").config({help:{brief:"Set default organization or switch to personal account",description:"Save the specified org_id to the local configuration as the default organization for subsequent commands. The command will automatically retrieve and save the corresponding Enterprise ID. If the org_id is not found in the user's enterprise list, the command will fail without modifying the configuration. When switching to a different organization, the saved spaceId will be cleared. Omit org_id to switch to personal account mode (requires personal account to be available).",examples:[{desc:"Switch organization",cmd:"coze organization use 12345678",tags:["[RECOMMENDED]"]},{desc:"Switch to personal account",cmd:"coze organization use"},{desc:"Switch to personal account (explicit empty string)",cmd:'coze organization use ""'}],errors:[{code:e.ErrorCode.E3001,name:"RESOURCE_NOT_FOUND",desc:"Organization not found",fix:"Run `coze organization list` to see available organizations."},{code:e.ErrorCode.E1000,name:"INVALID_ARGUMENT",desc:"Personal account not available",fix:"Your account does not have personal account access. Use `coze organization use <org_id>` to switch to an organization instead."}],schema:{input:{org_id:{type:"string",required:!1,description:"Organization ID to switch to. Empty or omitted to switch to personal account."}},output:{status:{type:"string",description:"Operation result status"},message:{type:"string",description:"Human-readable result message"},enterprise_id:{type:"string",description:"Enterprise ID of the selected organization (empty for personal account)"},organization_id:{type:"string",description:"Organization ID that was set (empty for personal account)"}}}}}).action((async(t,i,s)=>{const n=s.getContext();if(!t)return void await _r(n);ur([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Switching to organization '${t}'...`)]);const{enterpriseId:r}=await async function(t){const[i,{data:s}]=await Promise.all([o.loadConfig(),ns.ListEnterprise({contain_enterprise_of_user:!0,contain_organization_of_user:!0})]);let n="",r=!1;for(const e of s.enterprise_info_list)if((e.organization_info_list||[]).find((e=>e.organization_id===t))){n=e.enterprise_id,r=!0;break}if(!r)throw new e.CozeError(e.ErrorCode.E3000,`Organization '${t}' not found in current user's enterprises.`);const a=i.organizationId!==t;return await o.saveConfig({organizationId:t,enterpriseId:n,...a?{spaceId:void 0}:{}}),{enterpriseId:n}}(t);ur([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Organization '${t}' found in enterprise '${r}'. Config saved.`)]),ur([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Default organization set to '${t}' successfully.`)]),"json"===ur([n,"optionalAccess",e=>e.format])&&ur([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({status:"success",message:`Default organization set to '${t}'.`,enterprise_id:r,organization_id:t})])}))};function gr(e,t){return null!=e?e:t()}const hr=async(e={})=>{const t=gr(e.stdin,(()=>process.stdin));return!0===gr(e.isTTY,(()=>t.isTTY))?null:await(async e=>{let t="";e.setEncoding("utf-8");for await(const i of e)t+=i;return t})(t)},fr=e=>{process.stdout.write(e.endsWith("\n")?e:`${e}\n`)},yr=e=>{fr(JSON.stringify(e))},vr=async(e,t)=>{const i=c.resolve(e),s=c.dirname(i);if(await u.mkdir(s,{recursive:!0}),t instanceof Blob){const e=Buffer.from(await t.arrayBuffer());await u.writeFile(i,e)}else Buffer.isBuffer(t)?await u.writeFile(i,t):t instanceof ArrayBuffer?await u.writeFile(i,Buffer.from(t)):await u.writeFile(i,String(t));return i};const br=e=>"object"==typeof e&&null!==e,wr=e=>{if(null==e)return null;const t=e.trim();return 0===t.length?null:t},Pr=e=>br(e)&&"data"in e&&void 0!==e.data?e.data:e,Sr=(e,t)=>{try{const{pathname:i}=new URL(e);return c.extname(i)||t}catch(e){return t}},Tr=()=>{const e=new Date;return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}_${String(e.getHours()).padStart(2,"0")}${String(e.getMinutes()).padStart(2,"0")}${String(e.getSeconds()).padStart(2,"0")}`},Cr=e=>{const{outputPath:t,type:i,index:s,ext:o,timestamp:n}=e,r=`${i}_${n}_${s}${o}`;return c.join(t,r)},kr=async(t,i={})=>{let s=null;i.stdin&&(s=await hr());const o=wr(t),n=wr(s),r=(c=()=>n,null!=(a=o)?a:c());var a,c;if(!r)throw new e.CozeError(e.ErrorCode.E1000,"Missing prompt: provide PROMPT argument or use --stdin with piped content");return r},Ar="720p",Er="16:9",Ir=!1,Rr=!1;function zr(e,t){return null!=e?e:t()}function Ur(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const jr=(e,t)=>{if(null==e)return 5;const i=Number(e);if(!Number.isFinite(i))return Ur([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`Invalid --duration '${String(e)}', falling back to 5`)]),5;const s=Math.floor(i);return s<4||s>12?(Ur([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`--duration '${String(e)}' out of bounds (4..12), falling back to -1 as per documentation (letting the model decide)`)]),-1):s},Lr=(e,t)=>{if(null==e)return;const i=Number(e);if(Number.isSafeInteger(i)&&i>=0)return i;Ur([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`Invalid --seed '${String(e)}', this parameter will be ignored`)])},Or=e=>{const{content:t,options:i,ctx:s}=e,o=(e=>{if("string"!=typeof e)return null;const t=e.trim(),i=/^([0-9]{1,5})x([0-9]{1,5})$/i.exec(t);if(!i)return null;const s=Number(i[1]),o=Number(i[2]);if(!Number.isFinite(s)||!Number.isFinite(o)||s<=0)return null;const n=((e,t)=>{let i=Math.abs(e),s=Math.abs(t);for(;0!==s;){const e=i%s;i=s,s=e}return i})(s,o)||1,r=`${Math.round(s/n)}:${Math.round(o/n)}`,a=Math.max(s,o);return{ratio:r,resolution:a<=854?"480p":a<=1280?"720p":"1080p"}})(i.size),n=((e,t)=>"480p"===e||"720p"===e||"1080p"===e?e:(void 0!==e&&Ur([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`Invalid --resolution '${String(e)}', falling back to '${Ar}'`)]),Ar))(zr(i.resolution,(()=>Ur([o,"optionalAccess",e=>e.resolution]))),s),r=((e,t)=>{if("string"==typeof e){const t=e.trim();if(t.length>0)return t}return void 0!==e&&Ur([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`Invalid --ratio '${String(e)}', falling back to '${Er}'`)]),Er})(zr(i.ratio,(()=>Ur([o,"optionalAccess",e=>e.ratio]))),s);return{model:"doubao-seedance-1-5-pro-251215",content:t,callback_url:zr(wr(i.callbackUrl),(()=>{})),return_last_frame:"boolean"==typeof i.returnLastFrame?i.returnLastFrame:Rr,resolution:n,ratio:r,duration:jr(i.duration,s),watermark:"boolean"!=typeof i.watermark||i.watermark,seed:Lr(i.seed,s),camerafixed:"boolean"==typeof i.camerafixed?i.camerafixed:Ir,generate_audio:"boolean"!=typeof i.generateAudio||i.generateAudio}},Br=async t=>{const i=await e.customFetch.fetch(t);if(!i.ok)throw new e.CozeError(e.ErrorCode.E5001,`Failed to download generated resource: ${i.status} ${i.statusText}`,{url:t});return Buffer.from(await i.arrayBuffer())},xr=async e=>{const{outputPath:t,videoUrl:i,lastFrameUrl:s,shouldSaveLastFrame:o}=e,n=Sr(i,".mp4"),r=Tr(),a=Cr({outputPath:t,type:"video",index:0,ext:n,timestamp:r}),l=await Br(i),d=[await vr(a,l)];if(o&&"string"==typeof s&&s.length>0){const e=(e=>{const{outputPath:t,ext:i,timestamp:s}=e,o=`last_frame_${s}_0${i}`;return c.join(t,o)})({outputPath:t,ext:Sr(s,".png"),timestamp:r}),i=await Br(s),o=await vr(e,i);d.push(o)}return d};var qr,Dr,Mr,Gr,$r,Nr,Fr,Vr,Wr,Hr,Kr,Jr,Qr,Yr,Zr,Xr,ea,ta,ia;function sa(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}!function(e){e[e.TotalTokens=1]="TotalTokens";e[e.TotalInputTokens=2]="TotalInputTokens";e[e.TotalOutputTokens=3]="TotalOutputTokens"}(qr||(qr={})),function(e){e[e.ASC=1]="ASC";e[e.DESC=2]="DESC"}(Dr||(Dr={})),function(e){e[e.None=0]="None";e[e.APIKey=1]="APIKey";e[e.Oauth3LO=2]="Oauth3LO";e[e.Oauth2LO=3]="Oauth2LO";e[e.SAT=4]="SAT"}(Mr||(Mr={})),function(e){e[e.Free=1]="Free";e[e.Trial=2]="Trial";e[e.Paid=3]="Paid"}(Gr||(Gr={})),function(e){e[e.Inactive=1]="Inactive";e[e.Active=2]="Active"}($r||($r={})),function(e){e[e.CNY=1]="CNY";e[e.ResourcePoint=2]="ResourcePoint"}(Nr||(Nr={})),function(e){e[e.Cancellable=0]="Cancellable";e[e.NoCancellable=1]="NoCancellable";e[e.AlwaysDefault=2]="AlwaysDefault"}(Fr||(Fr={})),function(e){e[e.LLMModel=1]="LLMModel";e[e.ImageModel=2]="ImageModel";e[e.VideoModel=3]="VideoModel";e[e.AudioModel=4]="AudioModel";e[e.Database=5]="Database";e[e.Storage=6]="Storage";e[e.WebSearch=7]="WebSearch";e[e.EmbeddingModel=8]="EmbeddingModel";e[e.ContentProcessing=9]="ContentProcessing"}(Vr||(Vr={})),function(e){e[e.Internal=1]="Internal";e[e.External=2]="External";e[e.Infra=3]="Infra"}(Wr||(Wr={})),function(e){e[e.Text=1]="Text";e[e.Image=2]="Image";e[e.Video=3]="Video";e[e.Audio=4]="Audio"}(Hr||(Hr={})),function(e){e[e.Float=1]="Float";e[e.Int=2]="Int";e[e.Boolean=3]="Boolean";e[e.String=4]="String";e[e.JsonInput=5]="JsonInput"}(Kr||(Kr={})),function(e){e[e.Seed=1]="Seed";e[e.DeepSeek=2]="DeepSeek";e[e.Kimi=3]="Kimi";e[e.GLM=4]="GLM";e[e.MiniMax=5]="MiniMax";e[e.Qwen=6]="Qwen";e[e.StepFun=7]="StepFun";e[e.GPT=8]="GPT";e[e.Others=100]="Others"}(Jr||(Jr={})),function(e){e[e.Offline=0]="Offline";e[e.Online=1]="Online";e[e.GradualRollout=2]="GradualRollout";e[e.ReadyToOffline=3]="ReadyToOffline"}(Qr||(Qr={})),function(e){e[e.None=0]="None";e[e.InProgress=1]="InProgress";e[e.Success=2]="Success";e[e.Fail=3]="Fail";e[e.RollingBack=4]="RollingBack"}(Yr||(Yr={})),function(e){e[e.Install=1]="Install";e[e.Uninstall=2]="Uninstall"}(Zr||(Zr={})),function(e){e[e.Default=0]="Default";e[e.Agent=1]="Agent";e[e.Workflow=2]="Workflow";e[e.App=4]="App";e[e.Skill=5]="Skill";e[e.Web=6]="Web";e[e.WechatMiniProgram=7]="WechatMiniProgram";e[e.AssistantAgent=8]="AssistantAgent";e[e.General=9]="General";e[e.Design=100]="Design";e[e.Integration=101]="Integration";e[e.Dev=102]="Dev"}(Xr||(Xr={})),function(e){e[e.Scene=1]="Scene";e[e.Type=2]="Type"}(ea||(ea={})),function(e){e[e.Official=1]="Official";e[e.Community=2]="Community"}(ta||(ta={})),function(e){e[e.Agent=1]="Agent";e[e.Automation=2]="Automation";e[e.WebApp=3]="WebApp";e[e.App=4]="App";e[e.Skill=5]="Skill";e[e.GeneralWeb=6]="GeneralWeb";e[e.WechatMiniProgram=7]="WechatMiniProgram";e[e.AssistantAgent=8]="AssistantAgent";e[e.General=9]="General";e[e.CLIBilling=101]="CLIBilling"}(ia||(ia={}));class oa{__init(){this.request=e.request}__init2(){this.baseURL=""}constructor(e){oa.prototype.__init.call(this),oa.prototype.__init2.call(this),this.request=sa([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=sa([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}ListIntegration(e,t){const i=e||{},s=this.genBaseURL("/v1/integration/list"),o={space_id:i.space_id,project_id:i.project_id,integration_type:i.integration_type,integration_id:i.integration_id,filter_installed:i.filter_installed,org_id:i.org_id,search_words:i.search_words,page_num:i.page_num,page_size:i.page_size,project_type:i.project_type};return this.request({url:s,method:"POST",data:o},t)}SetIntegration(e,t){const i=e||{},s=this.genBaseURL("/v1/integration/update"),o={integration_id:i.integration_id,space_id:i.space_id,auth_schema_value:i.auth_schema_value};return this.request({url:s,method:"POST",data:o},t)}DeleteIntegration(e,t){const i=e||{},s=this.genBaseURL("/v1/integration/delete"),o={integration_id:i.integration_id,space_id:i.space_id,project_id:i.project_id};return this.request({url:s,method:"POST",data:o},t)}AuthIntegrationStatus(e,t){const i=e||{},s=this.genBaseURL("/v1/integration/auth/status"),o={integration_id:i.integration_id,space_id:i.space_id};return this.request({url:s,method:"POST",data:o},t)}ManageSpaceIntegration(e,t){const i=e||{},s=this.genBaseURL("/v1/integration/space/manage"),o={space_ids:i.space_ids,integration_ids:i.integration_ids,op_type:i.op_type};return this.request({url:s,method:"POST",data:o},t)}SubmitVideoGenerationsTasks(e,t){const i=e||{},s=this.genBaseURL("/api/v3/contents/generations/tasks"),o={Body:i.Body},n={project_id:i.project_id};return this.request({url:s,method:"POST",data:o,params:n},t)}FlashASR(e,t){const i=e||{},s=this.genBaseURL("/api/v3/auc/bigmodel/recognize/flash"),o={Body:i.Body};return this.request({url:s,method:"POST",data:o},t)}ListModel(e,t){const i=e||{},s=this.genBaseURL("/v1/model/list"),o={model_type:i.model_type,current_model_ids:i.current_model_ids,integration_ids:i.integration_ids,need_model_config_param:i.need_model_config_param,page_size:i.page_size,offset:i.offset};return this.request({url:s,method:"POST",data:o},t)}ChatCompletions(e,t){const i=e||{},s=this.genBaseURL("/api/v3/chat/completions"),o={Body:i.Body};return this.request({url:s,method:"POST",data:o},t)}CreateResponses(e,t){const i=e||{},s=this.genBaseURL("/api/v3/responses"),o={Body:i.Body};return this.request({url:s,method:"POST",data:o},t)}GenerateImages(e,t){const i=e||{},s=this.genBaseURL("/api/v3/images/generations"),o={Body:i.Body},n={project_id:i.project_id};return this.request({url:s,method:"POST",data:o,params:n},t)}UnidirectionalTTS(e,t){const i=e||{},s=this.genBaseURL("/api/v3/tts/unidirectional"),o={Body:i.Body},n={project_id:i.project_id};return this.request({url:s,method:"POST",data:o,params:n},t)}GetIntegrationOauthConfig(e,t){const i=e||{},s=this.genBaseURL("/v1/integration/auth/oauth_config"),o={integration_id:i.integration_id,space_id:i.space_id,project_id:i.project_id,session_id:i.session_id};return this.request({url:s,method:"POST",data:o},t)}GetVideoGenerationsTasks(e,t){const i=e||{},s=this.genBaseURL("/api/v3/contents/generations/tasks/:id"),o={Body:i.Body},n={project_id:i.project_id};return this.request({url:s,method:"GET",data:o,params:n},t)}WebSearch(e,t){const i=e||{},s=this.genBaseURL("/api/search_api/web_search"),o={Body:i.Body};return this.request({url:s,method:"POST",data:o},t)}WebSearch(e,t){const i=e||{},s=this.genBaseURL("/coze-coding/api/search_api/web_search"),o={Body:i.Body};return this.request({url:s,method:"POST",data:o},t)}CreateResponses(e,t){const i=e||{},s=this.genBaseURL("/coze-coding/api/v3/responses"),o={Body:i.Body};return this.request({url:s,method:"POST",data:o},t)}GetVideoGenerationsTasks(e,t){const i=e||{},s=this.genBaseURL("/coze-coding/api/v3/contents/generations/tasks/:id"),o={Body:i.Body},n={project_id:i.project_id};return this.request({url:s,method:"GET",data:o,params:n},t)}FlashASR(e,t){const i=e||{},s=this.genBaseURL("/coze-coding/api/v3/auc/bigmodel/recognize/flash"),o={Body:i.Body};return this.request({url:s,method:"POST",data:o},t)}SubmitVideoGenerationsTasks(e,t){const i=e||{},s=this.genBaseURL("/coze-coding/api/v3/contents/generations/tasks"),o={Body:i.Body},n={project_id:i.project_id};return this.request({url:s,method:"POST",data:o,params:n},t)}GenerateImages(e,t){const i=e||{},s=this.genBaseURL("/coze-coding/api/v3/images/generations"),o={Body:i.Body},n={project_id:i.project_id};return this.request({url:s,method:"POST",data:o,params:n},t)}UnidirectionalTTS(e,t){const i=e||{},s=this.genBaseURL("/coze-coding/api/v3/tts/unidirectional"),o={Body:i.Body},n={project_id:i.project_id};return this.request({url:s,method:"POST",data:o,params:n},t)}ChatCompletions(e,t){const i=e||{},s=this.genBaseURL("/coze-coding/api/v3/chat/completions"),o={Body:i.Body};return this.request({url:s,method:"POST",data:o},t)}CancelIntegration(e,t){const i=e||{},s=this.genBaseURL("/v1/integration/cancel"),o={integration_id:i.integration_id,space_id:i.space_id};return this.request({url:s,method:"POST",data:o},t)}Embeddings(e,t){const i=e||{},s=this.genBaseURL("/api/v3/embeddings/multimodal"),o={Body:i.Body};return this.request({url:s,method:"POST",data:o},t)}Embeddings(e,t){const i=e||{},s=this.genBaseURL("/coze-coding/api/v3/embeddings/multimodal"),o={Body:i.Body};return this.request({url:s,method:"POST",data:o},t)}VideoEditingUtils(e,t){const i=e||{},s=this.genBaseURL("/api/v1/integration/video_editing_utils"),o={Body:i.Body},n={tool_name:i.tool_name};return this.request({url:s,method:"POST",data:o,params:n},t)}GetProjectDefaultSkill(e,t){const i=e||{},s=this.genBaseURL("/v1/skill/default"),o={project_type:i.project_type,space_id:i.space_id};return this.request({url:s,method:"POST",data:o},t)}GetSkillByIDs(e,t){const i=e||{},s=this.genBaseURL("/v1/skill/by_ids"),o={project_type:i.project_type,skill_ids:i.skill_ids,space_id:i.space_id};return this.request({url:s,method:"POST",data:o},t)}GetSkillCategoryList(e,t){const i=e||{},s=this.genBaseURL("/v1/skill/category/list"),o={project_type:i.project_type};return this.request({url:s,method:"POST",data:o},t)}UploadSkill(e,t){const i=e||{},s=this.genBaseURL("/v1/skill/upload"),o={data:i.data},n={"Content-Type":i["Content-Type"]};return this.request({url:s,method:"POST",data:o,headers:n},t)}GetUserSkillList(e,t){const i=e||{},s=this.genBaseURL("/v1/skill/user/list"),o={page:i.page,size:i.size};return this.request({url:s,method:"POST",data:o},t)}DeleteSkill(e,t){const i=e||{},s=this.genBaseURL("/v1/skill/delete"),o={skill_id:i.skill_id};return this.request({url:s,method:"POST",data:o},t)}GetSkillList(e,t){const i=e||{},s=this.genBaseURL("/v1/skill/list"),o={project_type:i.project_type,category_type_list:i.category_type_list,space_id:i.space_id,source_list:i.source_list};return this.request({url:s,method:"POST",data:o},t)}UploadSkillConfirm(e,t){const i=e||{},s=this.genBaseURL("/v1/skill/upload/confirm"),o={preview_skill_key:i.preview_skill_key};return this.request({url:s,method:"POST",data:o},t)}FetchTool(e,t){const i=e||{},s=this.genBaseURL("/api/v1/integration/fetch_tool"),o={url:i.url};return this.request({url:s,method:"POST",data:o},t)}GetModelSwitchStatus(e,t){const i=e||{},s=this.genBaseURL("/v1/model/switch/status"),o={model_id:i.model_id,project_ids:i.project_ids,space_id:i.space_id};return this.request({url:s,method:"POST",data:o},t)}StartSwitchModel(e,t){const i=e||{},s=this.genBaseURL("/v1/model/switch/start"),o={space_id:i.space_id,project_ids:i.project_ids,current_model:i.current_model,target_model:i.target_model};return this.request({url:s,method:"POST",data:o},t)}GetModelUsageList(e,t){const i=e||{},s=this.genBaseURL("/v1/model/usage/list"),o={space_id:i.space_id,model_id:i.model_id,start_timestamp:i.start_timestamp,end_timestamp:i.end_timestamp,order_by_field:i.order_by_field,order_by_type:i.order_by_type,page:i.page,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}GetModelDetails(e,t){const i=e||{},s=this.genBaseURL("/v1/model/details"),o={model_id:i.model_id};return this.request({url:s,method:"POST",data:o},t)}GetModelUsageDetail(e,t){const i=e||{},s=this.genBaseURL("/v1/model/usage/details"),o={space_id:i.space_id,model_id:i.model_id,project_id:i.project_id,start_timestamp:i.start_timestamp,end_timestamp:i.end_timestamp};return this.request({url:s,method:"POST",data:o},t)}RollbackSwitchModel(e,t){const i=e||{},s=this.genBaseURL("/v1/model/switch/rollback"),o={space_id:i.space_id,project_ids:i.project_ids,current_model:i.current_model};return this.request({url:s,method:"POST",data:o},t)}TextEmbeddings(e,t){const i=e||{},s=this.genBaseURL("/api/v3/embeddings"),o={Body:i.Body};return this.request({url:s,method:"POST",data:o},t)}TextEmbeddings(e,t){const i=e||{},s=this.genBaseURL("/coze-coding/api/v3/embeddings"),o={Body:i.Body};return this.request({url:s,method:"POST",data:o},t)}CheckModelReadyToOffline(e,t){const i=e||{},s=this.genBaseURL("/v1/model/ready_to_offline/check"),o={model_type:i.model_type};return this.request({url:s,method:"POST",data:o},t)}Audit(e,t){const i=e||{},s=this.genBaseURL("/api/v1/integration/audit"),o={content:i.content};return this.request({url:s,method:"POST",data:o},t)}}oa.prototype.UploadSkill=function(e,t){const i=e||{},s=this.genBaseURL("/v1/skill/upload"),o=i.body;return this.request({url:s,method:"POST",data:o},t)},oa.prototype.GenerateImages=function(e,t){const i=e||{},s=this.genBaseURL("/api/v3/images/generations"),o=i.Body;return this.request({url:s,method:"POST",data:o},t)},oa.prototype.SubmitVideoGenerationsTasks=function(e,t){const i=e||{},s=this.genBaseURL("/api/v3/contents/generations/tasks"),o=i;return this.request({url:s,method:"POST",data:o},t)},oa.prototype.GetVideoGenerationsTasks=function(e,t){const i=e||{},s=this.genBaseURL(`/api/v3/contents/generations/tasks/${i.id}`);return this.request({url:s,method:"GET"},t)};const na=new oa({});const ra=async e=>await new Promise((t=>setTimeout(t,e))),aa=async e=>{const{taskId:t,baseURL:i,accessToken:s,projectId:o}=e,n=await na.GetVideoGenerationsTasks({id:t},{baseURL:i,headers:{Authorization:`Bearer ${s}`},params:{project_id:o}});return Pr(n)};function ca(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const la=e=>`coze generate video status ${e}`,da=e=>{const{ctx:t,response:i}=e;"json"!==ca([t,"optionalAccess",e=>e.format])?fr((e=>{const t=[e.status],i=ca([e,"access",e=>e.content,"optionalAccess",e=>e.video_url]),s=ca([e,"access",e=>e.content,"optionalAccess",e=>e.last_frame_url]);return"succeeded"===e.status?("string"==typeof i&&i.length>0&&t.push(i),"string"==typeof s&&s.length>0&&t.push(s),t.join("\n")):("string"==typeof e.error_message&&e.error_message&&t.push(e.error_message),t.join("\n"))})(i)):yr(i)},pa=t=>{const i=t.getContext(),{outputPath:s}=t.optsWithGlobals(),n=(r=ca([i,"optionalAccess",e=>e.config,"optionalAccess",e=>e.integrationApiBaseUrl]),a=()=>o.DEFAULT_CONFIG.integrationApiBaseUrl,null!=r?r:a());var r,a;const c=ca([i,"optionalAccess",e=>e.config,"optionalAccess",e=>e.accessToken]);if(!c)throw new e.CozeError(e.ErrorCode.E2001,"Missing access_token: Please run `coze auth login --oauth` or `coze auth login --token <token>` first");return{accessToken:c,ctx:i,integrationApiBaseUrl:n,outputPath:s}},ua=async(t,i,s)=>{const{accessToken:o,ctx:n,integrationApiBaseUrl:r,outputPath:a}=pa(s);let c=null;i.stdin&&(c=await hr());const{content:l}=(t=>{const{prompt:i,stdinPrompt:s,options:o}=t,n=zr(wr(i),(()=>wr(s))),r=wr(o.firstFrame),a=wr(o.lastFrame),c=Boolean(r)||Boolean(a);if(!n&&!c)throw new e.CozeError(e.ErrorCode.E1000,"Missing input: Please provide PROMPT/stdin text, or provide images (--first-frame/--last-frame/--reference-image)");const l=[];return n&&l.push({type:"text",text:n}),r&&l.push({type:"image_url",image_url:{url:r},role:"first_frame"}),a&&l.push({type:"image_url",image_url:{url:a},role:"last_frame"}),{content:l}})({prompt:t,stdinPrompt:c,options:i}),d=Or({content:l,options:i,ctx:n}),p=n.format,u=ca([n,"optionalAccess",e=>e.config,"access",e=>e.billingProjectId]);if(!u)throw new e.CozeError(e.ErrorCode.E1000,"Missing billing project ID");const{createResp:_,taskId:m}=await(async t=>{const{requestBody:i,baseURL:s,accessToken:o,projectId:n}=t,r=await na.SubmitVideoGenerationsTasks(i,{baseURL:s,headers:{Authorization:`Bearer ${o}`},params:{project_id:n}}),a=Pr(r),c=function(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}([a,"optionalAccess",e=>e.id]);if(!c||"string"!=typeof c)throw new e.CozeError(e.ErrorCode.E5002,"Video generation task created successfully but no valid task_id was returned",a);return{taskId:c,createResp:a}})({requestBody:d,baseURL:r,accessToken:o,projectId:u});if(!i.wait)return"json"===p?void yr({query_command:la(m),response:_,task_id:m}):void fr((e=>["Video generation task created successfully.",`taskId: ${e}`,`Use \`${la(e)}\` to query status.`].join("\n"))(m));const g=await(async t=>{const{taskId:i,baseURL:s,accessToken:o,pollIntervalMs:n,pollTimeoutMs:r,projectId:a}=t,c=Date.now();for(;;){const t=await aa({taskId:i,baseURL:s,accessToken:o,projectId:a});if("succeeded"===t.status)return t;if("failed"===t.status||"cancelled"===t.status)throw new e.CozeError(e.ErrorCode.E5002,`Video generation failed (status=${t.status}): ${l=t.error_message,d=()=>"unknown",null!=l?l:d()}`,t);if(Date.now()-c>r)throw new e.CozeError(e.ErrorCode.E5003,[`Video generation timed out after ${r}ms.`,`taskId: ${i}`,`Use \`coze generate video status ${i}\` to query status.`].join("\n"),{task_id:i,last_status:t.status});await ra(n)}var l,d})({taskId:m,baseURL:r,accessToken:o,pollIntervalMs:2e3,pollTimeoutMs:3e5,projectId:u}),h=ca([g,"access",e=>e.content,"optionalAccess",e=>e.video_url]),f=ca([g,"access",e=>e.content,"optionalAccess",e=>e.last_frame_url]);if(!h||"string"!=typeof h)throw new e.CozeError(e.ErrorCode.E5002,"Video generated successfully but video_url was not returned");if(a){const e=await xr({outputPath:a,videoUrl:h,lastFrameUrl:f,shouldSaveLastFrame:!0===i.returnLastFrame});return"json"===p?void yr({task_id:m,request:d,response:g,saved_paths:e}):void fr(e.join("\n"))}if("json"===p)return void yr({task_id:m,request:d,response:g});const y=[h];!0===i.returnLastFrame&&"string"==typeof f&&f.length>0&&y.push(f),fr(y.join("\n"))},_a=(e,t)=>{const i=t.getContext();W(e,i)},ma=t=>{var i;i=t.command("create [prompt]").description("Create a video generation task").config({help:{brief:"Create video generation task",description:"Create a video generation task from text prompts or images. By default the command returns taskId immediately; use `--wait` to poll until completion.",examples:[{desc:"Create video from text",cmd:'coze generate video create "A dancing kitten"'},{desc:"Create task and wait for completion",cmd:'coze generate video create "A dancing kitten" --wait'},{desc:"Save result to file",cmd:'coze generate video create "A dancing kitten" --wait --output-path ./video.mp4'}],errors:[{code:e.ErrorCode.E1000,name:"INVALID_ARGUMENT",desc:"Invalid request parameters or missing prompt",fix:"Provide PROMPT argument or use --stdin with piped content. Check other options (e.g. --first-frame/--last-frame) with -h."},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid access token",fix:"Run `coze auth login --oauth` or set COZE_API_TOKEN/related credentials first"},{code:e.ErrorCode.E5001,name:"NETWORK_ERROR",desc:"Network request failed",fix:"Please check your network connectivity and try again"},{code:e.ErrorCode.E5002,name:"SERVER_ERROR",desc:"Server returned an error or response parsing failed",fix:"Please retry later. Use --debug for more details"},{code:e.ErrorCode.E5003,name:"TIMEOUT",desc:"Video generation request timed out",fix:"Please retry later or use `coze generate video status <taskId>` to query task status"}],schema:{input:{prompt:{type:"string",required:!1,description:"Text prompt (can also be passed via stdin)"}},output:{type:"object",properties:{query_command:{type:"string"},task_id:{type:"string"},request:{type:"object"},response:{type:"object"},saved_paths:{type:"array",items:{type:"string"}}}}}}}).action((async(e,t,i)=>{try{await ua(e,t,i)}catch(e){_a(e,i)}})),i.option("--callback-url <url>","Callback URL for task status changes").option("--return-last-frame","Return last frame URL (default: disabled)",Rr).option("--resolution <res>","Resolution: 480p|720p|1080p",Ar).option("--ratio <ratio>",`Aspect ratio (default: ${Er})`,Er).option("--size <size>","Derive ratio/resolution from WIDTHxHEIGHT (lower priority than explicit parameters)").option("--duration <seconds>","Duration (seconds, 4..12; out-of-bounds fallback -1), default: 5",String(5)).option("--no-watermark","Disable watermark (default: enabled)").option("--seed <seed>","Random seed (safe integer)").option("--camerafixed","Fixed camera position (default: disabled)",Ir).option("--no-generate-audio","Do not generate accompanying audio (default: generate)").option("--first-frame <url>","First frame image URL").option("--last-frame <url>","Last frame image URL").option("--stdin","Read prompt from stdin (pipe input)").option("--wait","Wait for task completion by polling; by default the command returns taskId immediately")},ga=t=>{t.command("status <taskId>").description("Query video generation task status by task ID").option("--output <format>","Output format: text|json").config({help:{brief:"Query video task status",description:"Query the latest status of a video generation task by task ID. This command does not create a new task.",examples:[{desc:"Query task status",cmd:"coze generate video status task_123"},{desc:"Output full response as JSON",cmd:"coze generate video status task_123 --output json"}],errors:[{code:e.ErrorCode.E1000,name:"INVALID_ARGUMENT",desc:"Invalid task ID or request parameters",fix:"Please confirm <taskId> is correct and try again",example:"coze generate video status task_123"},{code:e.ErrorCode.E5001,name:"NETWORK_ERROR",desc:"Network request failed",fix:"Please check your network connectivity and try again"},{code:e.ErrorCode.E5002,name:"SERVER_ERROR",desc:"Server returned an error or response parsing failed",fix:"Please retry later. Use --debug for more details"},{code:e.ErrorCode.E5003,name:"TIMEOUT",desc:"Request timed out",fix:"Please retry later"}],schema:{input:{taskId:{type:"string",required:!0,description:"Video generation task ID"}},output:{type:"object",properties:{id:{type:"string"},status:{type:"string"},model:{type:"string"},content:{type:"object"},error_message:{type:"string"}}}}}}).action((async(t,i,s)=>{try{await(async(t,i,s)=>{const{accessToken:o,ctx:n,integrationApiBaseUrl:r}=pa(s),a=ca([n,"optionalAccess",e=>e.config,"access",e=>e.billingProjectId]);if(!a)throw new e.CozeError(e.ErrorCode.E1000,"Missing billing project ID");const c=await aa({taskId:t,baseURL:r,accessToken:o,projectId:a});da({ctx:n,response:c})})(t,0,s)}catch(e){_a(e,s)}}))};function ha(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const fa="2K",ya="url",va="standard",ba="disabled",wa=3686400,Pa=16777216,Sa=e=>"object"==typeof e&&null!==e,Ta=e=>{if("string"==typeof e){const t=e.trim();return t.length?t:va}return va},Ca=e=>{if(null==e)return;const t=(Array.isArray(e)?e:[e]).filter((e=>"string"==typeof e)).map((e=>e.trim())).filter(Boolean);return 0!==t.length?1===t.length?t[0]:t:void 0},ka=t=>{t.command("image [prompt]").description("Generate images from text prompts").config({help:{brief:"Generate images from text",description:"Generate images based on text prompts. Supports setting size, watermark, and multiple images.",examples:[{desc:"Generate image",cmd:'coze generate image "A futuristic city"'},{desc:"Save to file",cmd:'coze generate image "A cat" --output-path ./cat.png'},{desc:"Specify size",cmd:'coze generate image "A dog" --size 1024x1024'}],errors:[{code:e.ErrorCode.E1000,name:"INVALID_ARGUMENT",desc:"Invalid request parameters or missing prompt",fix:"Provide PROMPT argument or use --stdin with piped content. Check other options (e.g. --size/--max-images) with -h."},{code:e.ErrorCode.E1001,name:"MISSING_PROJECT_ID",desc:"Missing billing project ID",fix:"Please configure billing project ID and retry"},{code:e.ErrorCode.E5001,name:"NETWORK_ERROR",desc:"Network request failed",fix:"Please check your network connectivity and try again"},{code:e.ErrorCode.E5002,name:"SERVER_ERROR",desc:"API response parsing failed or server returned an error",fix:"Please retry later. Use --debug for more details"}],schema:{input:{prompt:{type:"string",required:!1,description:"Text prompt (can also be passed via stdin)"}},output:{type:"object",properties:{model:{type:"string"},created:{type:"number"},image_0:{type:"object"},saved_paths:{type:"array",items:{type:"string"}}}}}}}).option("--size <size>","Image size: 2K|4K or WIDTHxHEIGHT (local validation)",fa).option("--no-watermark","Disable watermark (default: enabled)").option("--image <url>","Reference image URL (can be used multiple times)",((e,t)=>[...t,e]),[]).option("--response-format <format>","Response format: url|b64_json",ya).option("--optimize-prompt-mode <mode>",`Prompt optimization mode (default: ${va})`,va).option("--sequential <mode>","Group image generation mode: auto|disabled",ba).option("--max-images <n>","Maximum number of group images (1-15)",String(15)).option("--stdin","Read prompt from stdin (pipe input)").action((async(t,i,s)=>{const n=s.getContext(),{outputPath:r}=s.optsWithGlobals(),a=await kr(t,{stdin:i.stdin}),c=ha([n,"optionalAccess",e=>e.config,"access",e=>e.billingProjectId]);if(!c)throw new e.CozeError(e.ErrorCode.E1001,"Missing billing project ID");const l=((e,t)=>{if(null==e)return{value:fa};if("string"!=typeof e)return ha([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`Invalid --size '${String(e)}', falling back to '${fa}'`)]),{value:fa};const i=e.trim();if("2K"===i||"4K"===i)return{value:i};const s=/^([0-9]{1,5})x([0-9]{1,5})$/i.exec(i);if(!s)return{value:fa,warning:`Invalid --size '${i}', falling back to '${fa}'. Expected 2K/4K or WIDTHxHEIGHT`};const o=Number(s[1]),n=Number(s[2]),r=o*n,a=o/n;return Number.isFinite(o)&&Number.isFinite(n)&&o>0&&n>0&&r>=wa&&r<=Pa&&a>=.0625&&a<=16?{value:`${o}x${n}`}:{value:fa,warning:`Invalid --size '${i}', falling back to '${fa}'. Total pixels must be in [3686400, 16777216], aspect ratio must be in [1:16, 16:1].`}})(i.size,n),d="url"===(p=i.responseFormat)||"b64_json"===p?{value:p}:void 0!==p?{value:ya,warning:`Invalid --response-format '${String(p)}', falling back to '${ya}'`}:{value:ya};var p;const u=(e=>"auto"===e||"disabled"===e?{value:e}:void 0!==e?{value:ba,warning:`Invalid --sequential '${String(e)}', falling back to '${ba}'`}:{value:ba})(i.sequential),_=(e=>{if(null==e)return{value:15};const t=Number(e);if(Number.isFinite(t)){const e=Math.floor(t);if(e>=1&&e<=15)return{value:e}}return{value:15,warning:`Invalid --max-images '${String(e)}', falling back to '15'`}})(i.maxImages);l.warning&&ha([n,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",e=>e(l.warning)]),d.warning&&ha([n,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",e=>e(d.warning)]),u.warning&&ha([n,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",e=>e(u.warning)]),_.warning&&ha([n,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",e=>e(_.warning)]);const m={model:"doubao-seedream-4-5-251128",prompt:a,size:l.value,watermark:"boolean"!=typeof i.watermark||i.watermark,image:Ca(i.image),response_format:d.value,optimize_prompt_options:{mode:Ta(i.optimizePromptMode)},sequential_image_generation:u.value,sequential_image_generation_options:{max_images:_.value}},g=(t=>{const i=Sa(t)&&"data"in t?t.data:t;if(Sa(s=i)&&"string"==typeof s.model&&"number"==typeof s.created&&Array.isArray(s.data))return i;var s;throw new e.CozeError(e.ErrorCode.E5002,"Image generation API returned an unexpected response format",t)})(await na.GenerateImages({Body:m},{baseURL:o.DEFAULT_CONFIG.integrationApiBaseUrl,params:{project_id:c}}));if(g.error)throw new e.CozeError(e.ErrorCode.E5002,"Image generation failed (top-level error)",g.error);const h=(y=()=>ya,null!=(f=m.response_format)?f:y());var f,y;const v=g.data.filter((e=>!e.error&&("url"===h?"string"==typeof e.url&&e.url.length>0:"string"==typeof e.b64_json&&e.b64_json.length>0)));if(0===v.length)throw new e.CozeError(e.ErrorCode.E5002,"Image generation succeeded but no valid image data was returned",g);if(r){const t=[],i=Tr();for(const[s,o]of v.entries()){const n="url"===h&&o.url?Sr(o.url,".png"):".png",a=Cr({outputPath:r,type:"image",index:s,ext:n,timestamp:i});let c;if("url"===h){const t=await e.customFetch.fetch(o.url);if(!t.ok)throw new e.CozeError(e.ErrorCode.E5001,`Failed to download generated image: ${t.status} ${t.statusText}`);c=Buffer.from(await t.arrayBuffer())}else c=Buffer.from(o.b64_json,"base64");const l=await vr(a,c);t.push(l)}const{model:s,usage:o,HttpHeader:a,...c}=(e=>{const{data:t,...i}=e,s=Object.fromEntries(t.map(((e,t)=>[`image_${t}`,e])));return{...i,...s}})(g);ha([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({...c,saved_paths:t})])}else ha([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(g.data)])}))};function Aa(e,t){return null!=e?e:t()}function Ea(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const Ia="cli_user",Ra="zh_female_xiaohe_uranus_bigtts",za="mp3",Ua=24e3,ja=(e,t)=>"pcm"===e||"mp3"===e||"ogg_opus"===e?e:(void 0!==e&&Ea([t,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",t=>t(`Invalid --audio-format '${String(e)}', falling back to '${za}'`)]),za),La=(e,t,i,s)=>{if(null==e)return t;const o=Number(e);return Number.isFinite(o)?Math.floor(o):(Ea([s,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",s=>s(`Invalid --${i} '${String(e)}', falling back to ${t}`)]),t)},Oa=t=>{const i=t.trim();if(0===i.length)return null;const s=i.startsWith("data:")?i.slice(5).trim():i;if(0===s.length)return null;const o=s[0];if("{"!==o&&"["!==o)return null;const n=e.safeJsonParse(s,void 0,{onError:t=>{const s=t instanceof Error?t.message:String(t);throw new e.CozeError(e.ErrorCode.E5002,`Failed to parse response: ${s}`,{line:i})}});return void 0===n?null:br(n)&&"number"==typeof n.code?n:null},Ba=t=>{const i=t.command("generate").description("Media generation commands (API TBD)").config({help:{brief:"Media generation commands",description:"Generate media such as audio, image, and video using Coze APIs.",examples:[{desc:"Generate image",cmd:'coze generate image "A cat"'},{desc:"Generate audio",cmd:'coze generate audio "Hello world"'},{desc:"Generate video",cmd:'coze generate video create "A dancing dog"'}],seeAlso:["coze auth"]}}).option("--output-path <path>","Directory path to save the generated media files");ka(i),(t=>{t.command("audio [prompt]").description("Synthesize speech from text or SSML (streaming)").config({help:{brief:"Generate audio from text",description:"Synthesize speech from text or SSML. Supports streaming output and configurable audio encodings.",examples:[{desc:"Basic text to speech",cmd:'coze generate audio "Hello world"'},{desc:"Save to file",cmd:'coze generate audio "Hello" --output-path ./audio.mp3'},{desc:"Use SSML",cmd:'echo "<speak>Hello</speak>" | coze generate audio --ssml'},{desc:"Specify audio encoding",cmd:'coze generate audio "Hello" --audio-format ogg_opus'}],errors:[{code:e.ErrorCode.E1000,name:"INVALID_ARGUMENT",desc:"Invalid request parameters or missing prompt",fix:"Provide PROMPT argument or use --stdin with piped content. Check other options (e.g. --speaker/--audio-format) with -h."},{code:e.ErrorCode.E1001,name:"MISSING_PROJECT_ID",desc:"Missing billing project ID",fix:"Configure billing project ID and retry",example:'coze generate audio "Hello"'},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid access token",fix:"Run `coze auth login --oauth` or `coze auth login --token <token>` first"},{code:e.ErrorCode.E5001,name:"NETWORK_ERROR",desc:"Network request failed",fix:"Please check your network connectivity and try again"},{code:e.ErrorCode.E5002,name:"SERVER_ERROR",desc:"API response parsing failed or server returned an error",fix:"Please retry later. Use --debug for more details"}],schema:{input:{prompt:{type:"string",required:!1,description:"Text or SSML prompt (can also be passed via stdin)"}},output:{type:"object",properties:{request:{type:"object"},url:{type:"string",description:"Audio download URL"},saved_path:{type:"string",description:"Local path if saved"}}}}}}).option("--output <format>","Output format: text|json").option("--uid <uid>",`User UID (default: ${Ia})`,Ia).option("--speaker <speaker>",`Speaker (default: ${Ra})`,Ra).option("--audio-format <format>","Audio encoding: pcm|mp3|ogg_opus",za).option("--sample-rate <n>","Sample rate (default: 24000)",String(Ua)).option("--speech-rate <n>","Speech rate (-50..100, default: 0)",String(0)).option("--loudness-rate <n>","Loudness (-50..100, default: 0)",String(0)).option("--ssml","Treat input as SSML (defaults to plain text)",!1).option("--stdin","Read prompt from stdin (pipe input)").action((async(t,i,s)=>{const o=s.getContext();try{const{outputPath:n}=s.optsWithGlobals(),r=Ea([o,"optionalAccess",e=>e.config,"access",e=>e.integrationApiBaseUrl]);if(!Ea([o,"optionalAccess",e=>e.config,"optionalAccess",e=>e.accessToken]))throw new e.CozeError(e.ErrorCode.E2001,"Missing access_token: Please run `coze auth login --oauth` or `coze auth login --token <token>` first");const a=await kr(t,{stdin:i.stdin}),c=Ea([o,"optionalAccess",e=>e.config,"access",e=>e.billingProjectId]);if(!c)throw new e.CozeError(e.ErrorCode.E1001,"Missing billing project ID");const l={user:{uid:Aa(wr(i.uid),(()=>Ia))},req_params:{speaker:Aa(wr(i.speaker),(()=>Ra)),audio_params:{format:ja(i.audioFormat,o),sample_rate:La(i.sampleRate,Ua,"sample-rate",o),speech_rate:La(i.speechRate,0,"speech-rate",o),loudness_rate:La(i.loudnessRate,0,"loudness-rate",o)}}};i.ssml?l.req_params={...l.req_params,ssml:a}:l.req_params={...l.req_params,text:a};const d=new URL("/api/v3/tts/unidirectional",r);d.searchParams.append("project_id",c);const p=await e.customFetch.fetch(d.toString(),{method:"POST",body:JSON.stringify(l)});if(!p.ok)throw new e.CozeError(e.ErrorCode.E5002,`Speech synthesis request failed: ${p.status} ${p.statusText}`,{status:p.status,statusText:p.statusText});if(!p.body)throw new e.CozeError(e.ErrorCode.E5002,"Speech synthesis response is empty (no streaming body returned)");const u=new TextDecoder("utf-8"),_=p.body.getReader(),m=[];let g;const h=t=>{if(0===t.code)return n&&"string"==typeof t.data&&m.push(Buffer.from(t.data,"base64")),!1;if(2e7===t.code)return"string"==typeof t.url&&t.url.length>0&&(g=t.url),!0;throw new e.CozeError(e.ErrorCode.E5002,`Speech synthesis failed (code=${t.code}): ${Aa(t.message,(()=>"unknown"))}`,t)};let f="";for(;;){const{done:e,value:t}=await _.read();if(e)break;f+=u.decode(t,{stream:!0});const i=f.split(/\r?\n/);f=Aa(i.pop(),(()=>""));for(const e of i){const t=Oa(e);if(t&&h(t)){await _.cancel();break}}if(g)break}if(!g){f+=u.decode();const e=f.split(/\r?\n/);f="";for(const t of e){const e=Oa(t);if(e&&h(e))break}}if(n){const t=Aa(Ea([l,"access",e=>e.req_params,"optionalAccess",e=>e.audio_params,"optionalAccess",e=>e.format]),(()=>za)),i="pcm"===t?".pcm":"ogg_opus"===t?".ogg":".mp3",s=Tr(),r=Cr({outputPath:n,type:"audio",index:0,ext:i,timestamp:s});let a=null;if(m.length>0)a=await vr(r,Buffer.concat(m));else if(g){const t=await e.customFetch.fetch(g);if(!t.ok)throw new e.CozeError(e.ErrorCode.E5001,`Failed to download synthesized speech: ${t.status} ${t.statusText}`,{status:t.status,statusText:t.statusText});const o=Buffer.from(await t.arrayBuffer()),r=Sr(g,i),c=Cr({outputPath:n,type:"audio",index:0,ext:r,timestamp:s});a=await vr(c,o)}if(!a)throw new e.CozeError(e.ErrorCode.E5002,"Speech synthesis completed but no savable audio data was obtained (neither chunks nor download URL)",{url:g});return"json"===Ea([o,"optionalAccess",e=>e.format])?void yr({request:l,url:g,saved_path:a}):void fr(a)}if("json"===Ea([o,"optionalAccess",e=>e.format]))return void yr({request:l,url:g});if(g)return void fr(g);fr("Speech synthesis completed, but no audio download URL was returned; you can use --output json to view details.")}catch(e){W(e,o)}}))})(i),(e=>{const t=(e=>e.command("video").description("Create videos or query video generation task status").config({help:{brief:"Generate videos",description:"Use explicit subcommands to create video generation tasks or query task status by task ID.",examples:[{desc:"Create video from text",cmd:'coze generate video create "A dancing kitten"'},{desc:"Query task status",cmd:"coze generate video status task_123"}],seeAlso:["coze generate image","coze generate audio"]}}))(e);ma(t),ga(t)})(i)};function xa(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const qa=i=>{(i=>{i.command("upload <path>").description("Upload a local file").config({help:{brief:"Upload a local file",description:"Upload a local file to Coze. The file can be used as an attachment or context in projects.",examples:[{desc:"Upload a file",cmd:"coze file upload ./document.pdf",tags:["[RECOMMENDED]"]}],errors:[{code:e.ErrorCode.E3000,name:"RESOURCE_NOT_FOUND",desc:"Local file not found or not readable",fix:"Please confirm the file path exists and you have read permission"}],schema:{input:{path:{type:"string",required:!0,description:"Local file path to upload"}},output:{type:"string",description:"Uploaded file URL"}}}}).action((async(i,s,o)=>{let n;try{n=o.getContext();try{await m.access(i)}catch(t){throw new e.CozeError(e.ErrorCode.E3000,`File not found or not readable: ${i}`,{filePath:i})}const s=_.basename(i),r=_.extname(i),a=r?s.slice(0,-r.length):s,c=r.slice(1),l=new h;l.append("file_name",a),l.append("file_extension",c),l.append("file_content",g.createReadStream(i)),l.append("biz_type","cli_attachment");const d=await t.IdeApi.UploadFile({data:l},{headers:{...l.getHeaders()}});"json"===xa([n,"optionalAccess",e=>e.format])?xa([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(d.data)]):xa([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(xa([d,"access",e=>e.data,"optionalAccess",e=>e.file_url]))])}catch(e){W(e,n)}}))})(i.command("file").description("General file operations").config({help:{brief:"File upload and management",description:"Manage file operations for Coze projects. Currently supports uploading local files to Coze for use as attachments or context.",examples:[{desc:"Upload a file",cmd:"coze file upload ./document.pdf"}],seeAlso:["coze code message send"]}}))};function Da(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function Ma(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function Ga(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function $a(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const Na=t=>{const i=t.command("config").description("Manage Coze CLI configuration").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Manage local configuration",description:"Provides read, set, list, and delete operations for the CLI local configuration file (`~/.cozerc.json`).",examples:[{desc:"List all configurations",cmd:"coze config list"},{desc:"Set configuration value",cmd:"coze config set base_url https://api.coze.cn"}]}});(e=>{e.command("get <keys...>").description("Get configuration values and their sources").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Get configuration values",description:"Read and output the value of the specified configuration keys from `~/.cozerc.json`. If a key does not exist, prompts that it was not found.",examples:[{desc:"Get BaseURL configuration",cmd:"coze config get baseUrl"},{desc:"Get default Space ID",cmd:"coze config get spaceId"},{desc:"Get multiple configurations",cmd:"coze config get baseUrl spaceId"}],schema:{input:{keys:{type:"array",required:!0,description:"Configuration key names"}},output:{value:{type:"any",description:"Configuration value"}}}}}).action((async(e,t,i)=>{const s=i.getContext(),n=await o.listConfigs();for(const t of e){const e=n.find((e=>e.key===t));Da(e?[s,"optionalAccess",e=>e.response,"access",e=>e.print,"call",t=>t(e)]:[s,"optionalAccess",e=>e.ui,"access",e=>e.warn,"call",e=>e(`Configuration '${t}' not found.`)])}}))})(i),(t=>{t.command("set <key> <value>").description("Set a configuration value").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Set a single configuration value",description:"Update or add the specified local configuration key-value pair. The configuration will be persistently saved in `~/.cozerc.json`.",examples:[{desc:"Modify default workspace",cmd:"coze config set spaceId 123456789"},{desc:"Modify BaseURL",cmd:"coze config set baseUrl https://api.coze.cn"}],errors:[{code:e.ErrorCode.E5000,name:"UNEXPECTED_ERROR",desc:"Failed to set configuration value",fix:"Please check the key/value and retry. Use --debug for more details."}],schema:{input:{key:{type:"string",required:!0,description:"Configuration key name"},value:{type:"string",required:!0,description:"New configuration value"}}}}}).action((async(t,i,s,n)=>{const r=n.getContext();try{const e={};e[t]=i;const s="global";await o.saveConfig(e,s);const n={key:t,value:i,scope:s,status:"updated",message:`Configuration '${t}' updated successfully in ${s} scope.`};if(Ma([r,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(n.message)]),"json"===Ma([r,"optionalAccess",e=>e.format]))return void Ma([r,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(n)])}catch(s){throw new e.CozeError(e.ErrorCode.E5000,`Failed to set '${t}' to '${i}': ${s.message}`,s.stack)}}))})(i),(t=>{t.command("delete <keys...>").description("Delete a configuration value").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Delete configuration values",description:"Remove the specified configuration values from the local configuration file `~/.cozerc.json`.",examples:[{desc:"Delete a specific configuration key",cmd:"coze config delete spaceId"},{desc:"Delete multiple configuration keys",cmd:"coze config delete spaceId baseUrl"}],errors:[{code:e.ErrorCode.E5000,name:"UNEXPECTED_ERROR",desc:"Failed to delete configuration value",fix:"Please check the configuration key and retry. Use --debug for more details."}],schema:{input:{keys:{type:"array",required:!0,description:"Configuration key names"}}}}}).action((async(t,i,s)=>{const n=s.getContext();for(const i of t)try{await o.deleteConfig(i);const e={key:i,status:"deleted",message:`Configuration '${i}' has been removed.`};Ga([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Deleted ${i} from configuration file successfully.`)]),"json"===Ga([n,"optionalAccess",e=>e.format])&&Ga([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",t=>t(e)])}catch(t){const s=t;throw new e.CozeError(e.ErrorCode.E5000,`Failed to delete config '${i}': ${s.message}`,s.stack)}}))})(i),(e=>{e.command("list").description("List all configuration values and their sources").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"List all local configuration values",description:"Print all configuration content stored in `~/.cozerc.json` in JSON format.",examples:[{desc:"List configurations",cmd:"coze config list"}],schema:{output:{type:"object",additionalProperties:!0,description:"Configuration key-value pairs"}}}}).action((async(e,t)=>{const i=t.getContext(),s=(await o.listConfigs()).map((({key:e,value:t,source:i})=>({key:e,value:t,source:i})));$a([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Configurations found:")]),$a([i,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(s)])}))})(i)},Fa="__COZE_FILE_COMP__";function Va(){const e=process.env.SHELL;if(e){if(e.includes("bash"))return"bash";if(e.includes("zsh"))return"zsh";if(e.includes("fish"))return"fish"}if(process.env.PSModulePath)return"powershell"}function Wa(e){const t=l.homedir();switch(e){case"bash":return c.join(t,"darwin"===process.platform?".bash_profile":".bashrc");case"zsh":return c.join(t,".zshrc");case"fish":return c.join(t,".config/fish/config.fish");case"powershell":return function(){const e=["pwsh","powershell"];for(const t of e)try{const e=s.execSync(`${t} -NoProfile -NoLogo -Command "echo $PROFILE"`,{encoding:"utf8",timeout:5e3,stdio:["pipe","pipe","pipe"]}).trim();if(e)return e}catch(e){continue}return}();default:return}}function Ha(){return["### coze completion - begin. generated by coze cli ###","if type compdef &>/dev/null; then"," _coze_completion() {"," local completions",' completions=("${(@f)$(coze --compzsh --compgen "${CURRENT}" "${words[CURRENT-1]}" "${BUFFER}")}")',` if [[ "\${completions[1]}" == "${Fa}" ]]; then`," _files"," else"," compadd -- $completions"," fi"," }"," compdef _coze_completion coze","elif type complete &>/dev/null; then"," _coze_completion() {"," local cur prev nb_colon"," _get_comp_words_by_ref -n : cur prev",' nb_colon=$(grep -o ":" <<< "$COMP_LINE" | wc -l)'," local completions",' completions=$(coze --compbash --compgen "$((COMP_CWORD - (nb_colon * 2)))" "$prev" "${COMP_LINE}")',` if [[ "$completions" == "${Fa}" ]]; then`," COMPREPLY=()"," return"," fi",' COMPREPLY=( $(compgen -W "$completions" -- "$cur") )',' __ltrim_colon_completions "$cur"'," }"," complete -o default -o bashdefault -F _coze_completion coze","elif type compctl &>/dev/null; then"," _coze_completion() {"," local cword line point si"," read -Ac words"," read -cn cword"," read -l line",' si="$IFS"',' if ! IFS=$\'\\n\' reply=($(coze --compzsh --compgen "${cword}" "${words[cword-1]}" "${line}")); then'," local ret=$?",' IFS="$si"'," return $ret"," fi",' IFS="$si"'," }"," compctl -K _coze_completion coze","fi","### coze completion - end ###"].join(l.EOL)}function Ka(e){switch(e){case"bash":return`\n# begin coze completion\nsource ${c.join(l.homedir(),".coze","completion.sh")}\n# end coze completion\n`;case"zsh":return"\n# begin coze completion\n. <(coze --completion)\n# end coze completion\n";case"fish":return"\n# begin coze completion\ncoze --completion-fish | source\n# end coze completion\n";case"powershell":return`\n# begin coze completion\nRegister-ArgumentCompleter -Native -CommandName coze -ScriptBlock {\n param($wordToComplete, $commandAst, $cursorPosition)\n $tokens = $commandAst.ToString().Split(" ", [StringSplitOptions]::RemoveEmptyEntries)\n $allArgs = @("--comppwsh")\n if ($tokens.Count -gt 1) {\n $allArgs += $tokens[1..($tokens.Count - 1)]\n }\n $result = & coze $allArgs 2>$null\n if ($result -and $result[0] -ne '${Fa}') {\n $result -split '\\n' | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {\n [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\n }\n } else {\n Get-ChildItem -Path "$wordToComplete*" -ErrorAction SilentlyContinue | ForEach-Object {\n [System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, 'ProviderItem', $_.FullName)\n }\n }\n}\n# end coze completion\n`;default:return}}function Ja(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}let Qa,Ya,Za=!1,Xa=!1;function ec(e){const t=(i=e._args,s=()=>[],null!=i?i:s());var i,s;if(0===t.length)return!1;const o=/path|file|dir|folder/i;return t.some((e=>o.test(e._name)))}function tc(){const e=Va();if(!e)return!1;const t=Wa(e);if(!t)return!1;if("bash"===e){const e=c.join(l.homedir(),".coze"),t=c.join(e,"completion.sh");d.existsSync(e)||d.mkdirSync(e,{recursive:!0}),d.writeFileSync(t,Ha())}const i=c.dirname(t);d.existsSync(i)||d.mkdirSync(i,{recursive:!0});const s=Ka(e);return!!s&&(d.appendFileSync(t,s),!0)}async function ic(e){if(!e.completionInstalled&&process.stdout.isTTY&&!(process.argv.includes("--compzsh")||process.argv.includes("--compbash")||process.argv.includes("--compfish")||process.argv.includes("--comppwsh")||Za||Xa))if(function(){try{const e=Va();if(!e)return!1;const t=Wa(e);return!(!t||!d.existsSync(t))&&d.readFileSync(t,"utf8").includes("begin coze completion")}catch(e){return!1}}())try{await o.saveConfig({completionInstalled:!0})}catch(e){}else try{tc()&&(await o.saveConfig({completionInstalled:!0}),console.log("Shell auto-completion has been configured. Restart your terminal to activate."))}catch(e){}}function sc(e){Ya=e,function(){const e=process.argv.indexOf("--completion");e>-1&&(Za=!0,process.argv.splice(e,1));const t=process.argv.indexOf("--completion-fish");t>-1&&(Xa=!0,process.argv.splice(t,1))}(),Qa=f("coze"),Qa.on("complete",((t,i)=>{const s=i.line.trimStart().split(/\s+/);s.length>0&&(s[0].endsWith("coze")||s[0].endsWith("bin/main"))&&s.shift();let o="";i.line.endsWith(" ")?(o="",""===s[s.length-1]&&s.pop()):o=s.pop()||"";const n=function(e,t,i){let s=e;for(const e of t){const t=s.commands.find((t=>t.name()===e||t.alias()===e));if(t)s=t;else if(!e.startsWith("-"))return ec(s)?[Fa]:[]}const o=[];s.commands.length>0&&s.commands.forEach((e=>{o.push(e.name())})),s.options.forEach((e=>{e.flags.split(/[ ,|]+/).forEach((e=>{e.startsWith("<")||e.startsWith("[")||o.push(e)}))})),s!==e&&e.options.forEach((e=>{e.flags.split(/[ ,|]+/).forEach((e=>{e.startsWith("<")||e.startsWith("[")||o.push(e)}))}));const n=Array.from(new Set(o)).filter((e=>e.startsWith(i)));return 0===n.length&&ec(s)?[Fa]:n}(e,s,o);i.reply(n)})),e.command("completion").description("Setup shell auto-completion").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Configure terminal auto-completion",description:"Install or remove the auto-completion script for the current terminal environment (supports bash/zsh/fish/powershell).",examples:[{desc:"Install completion script",cmd:"coze completion --setup"},{desc:"Remove completion script",cmd:"coze completion --cleanup"}]}}).option("--setup","Install shell completion into your startup script (.zshrc / .bashrc / $PROFILE)").option("--cleanup","Remove shell completion from your startup script").action((async e=>{if(e.cleanup)!function(){const e=Va();if(!e)return;const t=Wa(e);if(!t||!d.existsSync(t))return;const i=Ka(e);if(i){const e=d.readFileSync(t,"utf8").replace(new RegExp(i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),"");d.writeFileSync(t,e)}if("bash"===e){const e=c.join(l.homedir(),".coze"),t=c.join(e,"completion.sh");d.existsSync(t)&&d.unlinkSync(t),d.existsSync(e)&&0===d.readdirSync(e).length&&d.rmdirSync(e)}}(),await o.saveConfig({completionInstalled:!1}),console.log("Shell completion removed! Please restart your terminal.");else{const e=Va();if(!e)return console.error("Could not detect your shell type. Supported shells: bash, zsh, fish, powershell."),void(process.exitCode=1);tc()?(await o.saveConfig({completionInstalled:!0}),console.log(`Shell completion (${e}) setup successful! Please restart your terminal or source your config file.`)):(console.error(`Failed to setup shell completion for ${e}.`),process.exitCode=1)}}))}function oc(){return Za?(console.log(Ha()),void process.exit()):Xa?(console.log(["### coze completion - begin. generated by coze cli ###","function _coze_completion"," set -l completions (coze --compfish --compgen (count (commandline -poc)) (commandline -pt) (commandline -pb))",` if test (count $completions) -eq 1 -a "$completions[1]" = "${Fa}"`," return"," end"," for c in $completions"," echo $c"," end","end","complete -c coze -a '(_coze_completion)' -n '_coze_completion'","### coze completion - end ###"].join(l.EOL)),void process.exit()):void(process.argv.includes("--comppwsh")?function(){if(!Ya)return void process.exit();const e=process.argv.indexOf("--comppwsh"),t=process.argv.slice(e+1);let i=Ya;const s=[];for(const e of t){const t=Ja([i,"access",e=>e.commands,"optionalAccess",e=>e.find,"call",t=>t((t=>t.name()===e||t.alias()===e))]);t?i=t:s.push(e)}const o=[];Ja([i,"access",e=>e.commands,"optionalAccess",e=>e.forEach,"call",e=>e((e=>{o.push(e.name())}))]),Ja([i,"access",e=>e.options,"optionalAccess",e=>e.forEach,"call",e=>e((e=>{e.flags.split(/[ ,|]+/).forEach((e=>{e.startsWith("<")||e.startsWith("[")||o.push(e)}))}))]),i!==Ya&&Ja([Ya,"access",e=>e.options,"optionalAccess",e=>e.forEach,"call",e=>e((e=>{e.flags.split(/[ ,|]+/).forEach((e=>{e.startsWith("<")||e.startsWith("[")||o.push(e)}))}))]);const n=s[s.length-1]||"",r=Array.from(new Set(o)).filter((e=>e.startsWith(n)));0===r.length&&ec(i)?console.log(Fa):r.length>0&&console.log(r.join("\n")),process.exit()}():Qa&&Qa.init())}function nc(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function rc(i){i.command("remove <skillId>").description("Remove skills from the project").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"Remove skill from project",description:"Remove a configured skill from the specified project.",examples:[{desc:"Remove skill",cmd:"coze code skill remove <skillId> -p <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},skillId:{type:"string",required:!0,description:"Skill ID to remove"}},output:{command:{type:"string",description:"Command name"},status:{type:"string",description:"Execution status"},data:{type:"object",properties:{project_id:{type:"string",description:"Project ID"},removed_skill_ids:{type:"array",items:{type:"string"},description:"Removed skill IDs"},message:{type:"string",description:"Result message"}}}}},errors:[{code:e.ErrorCode.E3004,name:"SKILL_NOT_INSTALLED",desc:"The specified skill is not installed in the project",fix:"Please use `skill list` to confirm installed skills"}]}}).action((async function(e,i,s){const o=s.getContext(),{projectId:n}=i,r=new Set([e]),a=nc([(await t.IdeApi.GetVibeProject({project_id:n})).data||{},"access",e=>e.project_info,"optionalAccess",e=>e.project_settings,"optionalAccess",e=>e.skill_setting]);var c;const l=(c=nc([a,"optionalAccess",e=>e.skills]),Array.isArray(c)?c.map((e=>{return{skill_id:String((t=nc([e,"optionalAccess",e=>e.skill_id]),i=()=>"",null!=t?t:i())),is_preload:nc([e,"optionalAccess",e=>e.is_preload])};var t,i})).filter((e=>Boolean(e.skill_id))):[]).filter((e=>!r.has(e.skill_id))),d={filter_types:nc([a,"optionalAccess",e=>e.filter_types]),skills:l};await t.IdeApi.UpdateVibeProject({project_id:n,project_settings:{skill_setting:d}}),nc([o,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e("Skill removed.")]),nc([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({project_id:n,removed_skill_ids:Array.from(r),message:"removed Skills successfully."})])}))}function ac(e,t){return null!=e?e:t()}function cc(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function lc(i){i.command("list").description("List available skills for the project").requiredOption("-p, --project-id <projectId>","Project ID").option("--space-id <spaceId>","Space ID (optional, reads from config)").config({help:{brief:"List available skills for the project",description:"Retrieve a list of all available skills for the specified project type, with installation status indicating which skills are already added.",examples:[{desc:"List project skills",cmd:"coze code skill list --project-id <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},spaceId:{type:"string",required:!1,description:"Space ID (optional, reads from context)"}},output:{type:"array",items:{type:"object",properties:{description:{type:"string",description:"Skill description"},skill_id:{type:"string",description:"Skill ID"},name:{type:"string",description:"Skill name"},icon:{type:"string",description:"Skill icon URL"},is_installed:{type:"boolean",description:"Whether the skill is installed"}}}}},errors:[{code:e.ErrorCode.E1003,name:"MISSING_SPACE_ID",desc:"Space ID is required",fix:"Please use --space-id <spaceId> or run `coze space use <spaceId>` first"}]}}).action((async function(i,s){const o=s.getContext(),{projectId:n}=i,r=ac(ac(i.spaceId,(()=>cc([o,"optionalAccess",e=>e.config,"access",e=>e.spaceId]))),(()=>""));if(!r)throw new e.CozeError(e.ErrorCode.E1003,"Missing spaceId: pass --space-id <spaceId> or set config.spaceId");const a=await t.IdeApi.GetVibeProject({project_id:n}),c=function(e){const t=[],i=cc([e,"optionalAccess",e=>e.project_info,"optionalAccess",e=>e.project_settings]);cc([i,"optionalAccess",e=>e.skill_setting,"optionalAccess",e=>e.skills])&&t.push(...i.skill_setting.skills);const s=t.map((e=>cc([e,"optionalAccess",e=>e.skill_id]))).filter(Boolean);return new Set(s)}(a.data||{}),l=cc([a,"access",e=>e.data,"optionalAccess",e=>e.project_info,"optionalAccess",e=>e.project_type]),d=await na.GetSkillList({project_type:l,space_id:r,category_type_list:[l]});cc([o,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e(`Fetched ${cc([d,"access",e=>e.data,"optionalAccess",e=>e.skill_meta_list,"optionalAccess",e=>e.length])||0} skills.`)]),cc([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(cc([d,"access",e=>e.data,"optionalAccess",e=>e.skill_meta_list,"optionalAccess",e=>e.map,"call",e=>e((e=>({description:cc([e,"optionalAccess",e=>e.description]),skill_id:cc([e,"optionalAccess",e=>e.skill_id]),name:cc([e,"optionalAccess",e=>e.name]),icon:cc([e,"optionalAccess",e=>e.icon]),is_installed:c.has(e.skill_id||"")})))]))])}))}function dc(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function pc(i){i.command("add <skillId>").description("Add skills to the project").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"Add skill to project",description:"Add a specified skill to the project. Skills can extend project capabilities, such as adding search, code execution, etc.",examples:[{desc:"Add skill",cmd:"coze code skill add <skillId> -p <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},skillId:{type:"string",required:!0,description:"Skill ID"}},output:{command:{type:"string",description:"Command name"},status:{type:"string",description:"Execution status"},data:{type:"object",properties:{project_id:{type:"string",description:"Project ID"},added_skill_ids:{type:"array",items:{type:"string"},description:"Added skill IDs"},message:{type:"string",description:"Result message"}}}}},errors:[{code:e.ErrorCode.E3002,name:"SKILL_NOT_FOUND",desc:"The specified skill does not exist",fix:"Please use `skill list` to confirm available skills"}]}}).action((async function(e,i,s){const o=s.getContext(),{projectId:n}=i,r=[e],a=(await t.IdeApi.GetVibeProject({project_id:n})).data||{},c=dc([a,"access",e=>e.project_info,"optionalAccess",e=>e.project_type]),l=dc([a,"access",e=>e.project_info,"optionalAccess",e=>e.project_settings,"optionalAccess",e=>e.skill_setting]),d=function(e){const t=new Map;for(const i of e){const e=dc([i,"optionalAccess",e=>e.skill_id])?String(i.skill_id):"";e&&(t.has(e)||t.set(e,{skill_id:e,is_preload:i.is_preload}))}return Array.from(t.values())}([...Array.isArray(dc([l,"optionalAccess",e=>e.skills]))?l.skills:[],...r.map((e=>({skill_id:String(e),is_preload:!0})))]),p={filter_types:dc([l,"optionalAccess",e=>e.filter_types])&&l.filter_types.length>0?l.filter_types:[c],skills:d};await t.IdeApi.UpdateVibeProject({project_id:n,project_settings:{skill_setting:p}}),dc([o,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e("Skills added successfully.")]),dc([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({project_id:n,added_skill_ids:r,message:"added Skills successfully."})])}))}var uc,_c,mc,gc,hc,fc,yc,vc,bc,wc,Pc,Sc,Tc,Cc,kc,Ac,Ec,Ic,Rc,zc,Uc,jc,Lc,Oc,Bc,xc,qc,Dc,Mc,Gc,$c,Nc,Fc,Vc,Wc,Hc,Kc,Jc,Qc,Yc,Zc,Xc,el,tl,il,sl,ol,nl,rl,al,cl,ll,dl,pl,ul,_l,ml,gl,hl,fl,yl,vl,bl,wl,Pl,Sl,Tl,Cl,kl,Al,El,Il,Rl,zl,Ul,jl,Ll,Ol;function Bl(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}!function(e){e[e.ChatApi=0]="ChatApi";e[e.ResponsesApi=1]="ResponsesApi"}(uc||(uc={})),function(e){e[e.CacheClosed=0]="CacheClosed";e[e.PrefixCache=1]="PrefixCache"}(_c||(_c={})),function(e){e[e.Chat=0]="Chat";e[e.FunctionCall_1=1]="FunctionCall_1";e[e.FunctionCall_2=2]="FunctionCall_2";e[e.FunctionCall_3=3]="FunctionCall_3"}(mc||(mc={})),function(e){e[e.FullSupport=0]="FullSupport";e[e.PoorSupport=1]="PoorSupport";e[e.NotSupport=2]="NotSupport"}(gc||(gc={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.ImageFlow=3]="ImageFlow";e[e.Trigger=4]="Trigger";e[e.KnowledgeText=5]="KnowledgeText";e[e.KnowledgeTable=6]="KnowledgeTable";e[e.KnowledgeAutoCall=7]="KnowledgeAutoCall";e[e.KnowledgeOnDemandCall=8]="KnowledgeOnDemandCall";e[e.Variable=9]="Variable";e[e.Database=10]="Database";e[e.LongTermMemory=11]="LongTermMemory";e[e.FileBox=12]="FileBox";e[e.Onboarding=13]="Onboarding";e[e.Suggestion=14]="Suggestion";e[e.ShortcutCommand=15]="ShortcutCommand";e[e.BackGroundImage=16]="BackGroundImage";e[e.TTS=17]="TTS";e[e.MultiAgentRecognize=18]="MultiAgentRecognize";e[e.KnowledgePhoto=19]="KnowledgePhoto";e[e.HookInfo=20]="HookInfo";e[e.KnowledgeValcanoUnstructured=21]="KnowledgeValcanoUnstructured";e[e.KnowledgeValcanoStructured=22]="KnowledgeValcanoStructured";e[e.Model=23]="Model";e[e.KnowledgeThirdPartyUnstructured=24]="KnowledgeThirdPartyUnstructured";e[e.KnowledgeThirdPartyStructured=25]="KnowledgeThirdPartyStructured"}(hc||(hc={})),function(e){e[e.Text=0]="Text";e[e.Markdown=1]="Markdown";e[e.JSON=2]="JSON"}(fc||(fc={})),function(e){e[e.Custom=0]="Custom";e[e.Creative=1]="Creative";e[e.Balance=2]="Balance";e[e.Precise=3]="Precise"}(yc||(yc={})),function(e){e[e.Auditing=0]="Auditing";e[e.Success=1]="Success";e[e.Failed=2]="Failed"}(vc||(vc={})),function(e){e[e.Official=1]="Official";e[e.Public=2]="Public";e[e.Custom=3]="Custom";e[e.Others=101]="Others"}(bc||(bc={})),function(e){e[e.Normal=0]="Normal";e[e.Offline=1]="Offline";e[e.TokenDisconnect=2]="TokenDisconnect"}(wc||(wc={})),function(e){e[e.App=1]="App";e[e.Resource=2]="Resource"}(Pc||(Pc={})),function(e){e[e.CozeModel=1]="CozeModel";e[e.VolcAccount=2]="VolcAccount";e[e.SelfAccount=3]="SelfAccount";e[e.SelfModel=4]="SelfModel"}(Sc||(Sc={})),function(e){e[e.Asc=1]="Asc";e[e.Desc=2]="Desc"}(Tc||(Tc={})),function(e){e[e.NoDetail=1]="NoDetail";e[e.Detail=2]="Detail";e[e.Operate=3]="Operate"}(Cc||(Cc={})),function(e){e[e.Published=1]="Published";e[e.Unpublished=2]="Unpublished"}(kc||(kc={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.Imageflow=3]="Imageflow";e[e.Knowledge=4]="Knowledge";e[e.UI=5]="UI";e[e.Prompt=6]="Prompt";e[e.Database=7]="Database";e[e.Variable=8]="Variable"}(Ac||(Ac={})),function(e){e[e.ChatApi=1]="ChatApi";e[e.ResponsesApi=2]="ResponsesApi"}(Ec||(Ec={})),function(e){e[e.Success=1]="Success";e[e.Failed=2]="Failed"}(Ic||(Ic={})),function(e){e[e.DefaultHeader=1]="DefaultHeader";e[e.SpecifiedHeader=2]="SpecifiedHeader"}(Rc||(Rc={})),function(e){e[e.VolcKms=1]="VolcKms";e[e.PlainText=2]="PlainText"}(zc||(zc={})),function(e){e[e.Provider=1]="Provider";e[e.Custom=2]="Custom"}(Uc||(Uc={})),function(e){e[e.CozeAccountTypeUnknown=0]="CozeAccountTypeUnknown";e[e.CozeAccountTypePersonal=1]="CozeAccountTypePersonal";e[e.CozeAccountTypeOrganization=2]="CozeAccountTypeOrganization"}(jc||(jc={})),function(e){e[e.Intelligence=1]="Intelligence";e[e.App=2]="App";e[e.Plugin=3]="Plugin";e[e.Workflow=4]="Workflow";e[e.Knowledge=5]="Knowledge";e[e.Card=6]="Card";e[e.Prompt=7]="Prompt";e[e.Database=8]="Database";e[e.Voice=9]="Voice";e[e.VibeProjectAgent=11]="VibeProjectAgent";e[e.VibeProjectAutomation=12]="VibeProjectAutomation";e[e.VibeProjectWebApp=13]="VibeProjectWebApp";e[e.VibeProjectApp=14]="VibeProjectApp";e[e.VibeProjectSkill=15]="VibeProjectSkill";e[e.VibeProjectGeneralWeb=16]="VibeProjectGeneralWeb";e[e.VibeProjectWechatMiniProgram=17]="VibeProjectWechatMiniProgram";e[e.VibeProjectAssistantAgent=18]="VibeProjectAssistantAgent";e[e.VibeProjectGeneral=19]="VibeProjectGeneral"}(Lc||(Lc={})),function(e){e[e.Mobile=1]="Mobile";e[e.Web=2]="Web"}(Oc||(Oc={})),function(e){e[e.CacheClosed=0]="CacheClosed";e[e.PrefixCache=1]="PrefixCache"}(Bc||(Bc={})),function(e){e[e.Using=1]="Using";e[e.Deleted=2]="Deleted";e[e.Banned=3]="Banned";e[e.MoveFailed=4]="MoveFailed";e[e.Copying=5]="Copying";e[e.CopyFailed=6]="CopyFailed"}(xc||(xc={})),function(e){e[e.Bot=1]="Bot";e[e.Project=2]="Project";e[e.DouyinAvatarBot=3]="DouyinAvatarBot";e[e.VibeProjectAgent=11]="VibeProjectAgent";e[e.VibeProjectAutomation=12]="VibeProjectAutomation";e[e.VibeProjectWebApp=13]="VibeProjectWebApp";e[e.VibeProjectApp=14]="VibeProjectApp";e[e.VibeProjectSkill=15]="VibeProjectSkill";e[e.VibeProjectGeneralWeb=16]="VibeProjectGeneralWeb";e[e.VibeProjectWechatMiniProgram=17]="VibeProjectWechatMiniProgram";e[e.VibeProjectAssistantAgent=18]="VibeProjectAssistantAgent";e[e.VibeProjectGeneral=19]="VibeProjectGeneral"}(qc||(qc={})),function(e){e[e.DEFAULT=0]="DEFAULT";e[e.Chux=1]="Chux"}(Dc||(Dc={})),function(e){e[e.ProjectOwner=1]="ProjectOwner";e[e.ProjectEditor=2]="ProjectEditor";e[e.BotEditor=3]="BotEditor";e[e.BotDeveloper=4]="BotDeveloper";e[e.BotOperator=5]="BotOperator";e[e.BotOwner=6]="BotOwner"}(Mc||(Mc={})),function(e){e[e.PromptDiff=1]="PromptDiff";e[e.ModelDiff=2]="ModelDiff"}(Gc||(Gc={})),function(e){e[e.DraftBot=1]="DraftBot"}($c||($c={})),function(e){e[e.Success=1]="Success";e[e.Processing=2]="Processing";e[e.Failed=3]="Failed";e[e.Canceled=4]="Canceled"}(Nc||(Nc={})),function(e){e[e.Archive=1]="Archive";e[e.Rollback=2]="Rollback"}(Fc||(Fc={})),function(e){e[e.ProjectCopyCancel=1]="ProjectCopyCancel";e[e.ProjectCopyRetry=2]="ProjectCopyRetry"}(Vc||(Vc={})),function(e){e[e.ProjectCopy=1]="ProjectCopy";e[e.BotCopy=2]="BotCopy";e[e.VibeProjectCopy=3]="VibeProjectCopy"}(Wc||(Wc={})),function(e){e[e.ChatApi=0]="ChatApi";e[e.ResponsesApi=1]="ResponsesApi"}(Hc||(Hc={})),function(e){e[e.Bot=1]="Bot";e[e.Workflow=2]="Workflow";e[e.Application=3]="Application"}(Kc||(Kc={})),function(e){e[e.DefaultHeader=1]="DefaultHeader";e[e.SpecifiedHeader=2]="SpecifiedHeader"}(Jc||(Jc={})),function(e){e[e.VolcKms=1]="VolcKms";e[e.PlainText=2]="PlainText"}(Qc||(Qc={})),function(e){e[e.BatchSize=1]="BatchSize";e[e.LearningRate=2]="LearningRate";e[e.Epochs=3]="Epochs"}(Yc||(Yc={})),function(e){e[e.GPT=1]="GPT";e[e.SEED=2]="SEED";e[e.Claude=3]="Claude";e[e.MiniMax=4]="MiniMax";e[e.Plugin=5]="Plugin";e[e.StableDiffusion=6]="StableDiffusion";e[e.ByteArtist=7]="ByteArtist";e[e.Maas=9]="Maas";e[e.QianFan=10]="QianFan";e[e.Gemini=11]="Gemini";e[e.Moonshot=12]="Moonshot";e[e.GLM=13]="GLM";e[e.MaaSAutoSync=14]="MaaSAutoSync";e[e.QWen=15]="QWen";e[e.Cohere=16]="Cohere";e[e.Baichuan=17]="Baichuan";e[e.Ernie=18]="Ernie";e[e.DeekSeek=19]="DeekSeek";e[e.Llama=20]="Llama";e[e.StepFun=23]="StepFun";e[e.Custom=24]="Custom";e[e.Other=999]="Other"}(Zc||(Zc={})),function(e){e[e.Float=1]="Float";e[e.Int=2]="Int";e[e.Boolean=3]="Boolean";e[e.String=4]="String"}(Xc||(Xc={})),function(e){e[e.Douyin=1]="Douyin"}(el||(el={})),function(e){e[e.Terminating=1]="Terminating";e[e.Terminated=2]="Terminated"}(tl||(tl={})),function(e){e[e.Online=1]="Online";e[e.Offline=2]="Offline";e[e.Deleted=3]="Deleted";e[e.FineTuneInQueue=4]="FineTuneInQueue";e[e.FineTuneRunning=5]="FineTuneRunning";e[e.FineTuneFailed=6]="FineTuneFailed";e[e.FineTuneTeminated=7]="FineTuneTeminated"}(il||(il={})),function(e){e[e.ModelType=1]="ModelType";e[e.ModelUserRight=2]="ModelUserRight";e[e.ModelFeature=3]="ModelFeature";e[e.ModelFunction=4]="ModelFunction";e[e.ModelScenario=5]="ModelScenario";e[e.ModelPayment=15]="ModelPayment";e[e.ModelAbility=16]="ModelAbility";e[e.ModelStatus=17]="ModelStatus";e[e.Custom=20]="Custom";e[e.Others=100]="Others"}(sl||(sl={})),function(e){e[e.Flagship=1]="Flagship";e[e.HighSpeed=2]="HighSpeed";e[e.ToolInvocation=3]="ToolInvocation";e[e.RolePlaying=4]="RolePlaying";e[e.LongText=5]="LongText";e[e.ImageUnderstanding=6]="ImageUnderstanding";e[e.Reasoning=7]="Reasoning";e[e.VideoUnderstanding=8]="VideoUnderstanding";e[e.CostPerformance=9]="CostPerformance";e[e.CodeSpecialization=10]="CodeSpecialization";e[e.AudioUnderstanding=11]="AudioUnderstanding"}(ol||(ol={})),function(e){e[e.TotalTokens=1]="TotalTokens";e[e.TotalInput=2]="TotalInput";e[e.TotalOutput=3]="TotalOutput"}(nl||(nl={})),function(e){e[e.stop=1]="stop";e[e.resume=2]="resume",e[e.delete=3]="delete"}(rl||(rl={})),function(e){e[e.Recommend=1]="Recommend"}(al||(al={})),function(e){e[e.Default=0]="Default";e[e.Terminate=1]="Terminate"}(cl||(cl={})),function(e){e[e.All=0]="All";e[e.WithBenefit=1]="WithBenefit"}(ll||(ll={})),function(e){e[e.upload=1]="upload";e[e.TrainingSetSplit=2]="TrainingSetSplit"}(dl||(dl={})),function(e){e[e.Text=1]="Text";e[e.ImageFirstFrame=2]="ImageFirstFrame";e[e.ImageFirstLastFrame=3]="ImageFirstLastFrame";e[e.ReferencePicture=4]="ReferencePicture"}(pl||(pl={})),function(e){e[e.Using=1]="Using";e[e.Deleted=2]="Deleted"}(ul||(ul={})),function(e){e[e.Publish=0]="Publish";e[e.Archive=1]="Archive"}(_l||(_l={})),function(e){e[e.User=0]="User";e[e.NL2App=1]="NL2App"}(ml||(ml={})),function(e){e[e.NoBindRequired=1]="NoBindRequired";e[e.AuthBind=2]="AuthBind";e[e.KvBind=3]="KvBind";e[e.KvAuthBind=4]="KvAuthBind";e[e.ApiBind=5]="ApiBind";e[e.WebSDKBind=6]="WebSDKBind";e[e.StoreBind=7]="StoreBind";e[e.AuthAndConfig=8]="AuthAndConfig";e[e.ConnectorCustom=9]="ConnectorCustom"}(gl||(gl={})),function(e){e[e.APIOrSDK=1]="APIOrSDK";e[e.SocialPlatform=2]="SocialPlatform";e[e.Coze=3]="Coze";e[e.MiniProgram=4]="MiniProgram";e[e.CozeSpaceExtensionLibrary=5]="CozeSpaceExtensionLibrary"}(hl||(hl={})),function(e){e[e.Configured=1]="Configured";e[e.NotConfigured=2]="NotConfigured";e[e.Disconnected=3]="Disconnected";e[e.Configuring=4]="Configuring";e[e.NeedReconfiguring=5]="NeedReconfiguring"}(fl||(fl={})),function(e){e[e.Default=0]="Default";e[e.Auditing=1]="Auditing";e[e.Success=2]="Success";e[e.Failed=3]="Failed";e[e.Disable=4]="Disable"}(yl||(yl={})),function(e){e[e.Normal=0]="Normal";e[e.InReview=1]="InReview";e[e.Offline=2]="Offline"}(vl||(vl={})),function(e){e[e.Packing=0]="Packing";e[e.PackFailed=1]="PackFailed";e[e.Auditing=2]="Auditing";e[e.AuditNotPass=3]="AuditNotPass";e[e.ConnectorPublishing=4]="ConnectorPublishing";e[e.PublishDone=5]="PublishDone"}(bl||(bl={})),function(e){e[e.Authorized=1]="Authorized";e[e.UnAuthorized=2]="UnAuthorized";e[e.Authorizing=3]="Authorizing"}(wl||(wl={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.Imageflow=3]="Imageflow";e[e.Knowledge=4]="Knowledge";e[e.UI=5]="UI";e[e.Prompt=6]="Prompt";e[e.Database=7]="Database";e[e.Variable=8]="Variable";e[e.Voice=9]="Voice";e[e.Memorybase=10]="Memorybase";e[e.MCP=11]="MCP"}(Pl||(Pl={})),function(e){e[e.SingleMode=0]="SingleMode";e[e.MultiMode=1]="MultiMode";e[e.WorkflowMode=2]="WorkflowMode"}(Sl||(Sl={})),function(e){e[e.UpdateTime=0]="UpdateTime";e[e.CreateTime=1]="CreateTime";e[e.Name=2]="Name"}(Tl||(Tl={})),function(e){e[e.UpdateTime=0]="UpdateTime";e[e.CreateTime=1]="CreateTime"}(Cl||(Cl={})),function(e){e[e.UpdateTime=0]="UpdateTime";e[e.CreateTime=1]="CreateTime";e[e.PublishTime=2]="PublishTime";e[e.OpenTime=3]="OpenTime"}(kl||(kl={})),function(e){e[e.Standard=0]="Standard";e[e.PrefixPrompt=1]="PrefixPrompt"}(Al||(Al={})),function(e){e[e.All=0]="All";e[e.CreateByMe=1]="CreateByMe";e[e.AllWithCollaborator=2]="AllWithCollaborator";e[e.CanImportToSpace=3]="CanImportToSpace"}(El||(El={})),function(e){e[e.Desc=0]="Desc";e[e.Asc=1]="Asc"}(Il||(Il={})),function(e){e[e.Copy=1]="Copy";e[e.Move=2]="Move";e[e.Publish=3]="Publish";e[e.ImportExport=4]="ImportExport"}(Rl||(Rl={})),function(e){e[e.Project=1]="Project";e[e.Space=2]="Space";e[e.Online=3]="Online";e[e.Template=4]="Template";e[e.Agent=5]="Agent"}(zl||(zl={})),function(e){e[e.Plugin=1]="Plugin";e[e.Workflow=2]="Workflow";e[e.Imageflow=3]="Imageflow";e[e.Knowledge=4]="Knowledge";e[e.UI=5]="UI";e[e.Project=6]="Project";e[e.Database=7]="Database";e[e.Variable=8]="Variable";e[e.Trigger=9]="Trigger";e[e.Agent=10]="Agent";e[e.Prompt=11]="Prompt";e[e.Shortcut=12]="Shortcut";e[e.Chux=13]="Chux";e[e.Memorybase=14]="Memorybase";e[e.VibeProjectAgent=15]="VibeProjectAgent";e[e.VibeProjectAutomation=16]="VibeProjectAutomation";e[e.VibeProjectWebApp=17]="VibeProjectWebApp";e[e.VibeProjectApp=18]="VibeProjectApp";e[e.VibeProjectSkill=19]="VibeProjectSkill";e[e.VibeProjectGeneralWeb=20]="VibeProjectGeneralWeb";e[e.VibeProjectWechatMiniProgram=21]="VibeProjectWechatMiniProgram";e[e.VibeProjectAssistantAgent=22]="VibeProjectAssistantAgent";e[e.VibeProjectGeneral=23]="VibeProjectGeneral"}(Ul||(Ul={})),function(e){e[e.Success=1]="Success";e[e.Processing=2]="Processing";e[e.Failed=3]="Failed";e[e.Canceled=4]="Canceled"}(jl||(jl={})),function(e){e[e.CopyResourceInProject=1]="CopyResourceInProject";e[e.CopyProjectResourceToLibrary=2]="CopyProjectResourceToLibrary";e[e.MoveProjectResourceToLibrary=3]="MoveProjectResourceToLibrary";e[e.CopyLibraryResourceToProject=4]="CopyLibraryResourceToProject";e[e.CopyProject=5]="CopyProject";e[e.PublishProject=6]="PublishProject";e[e.CopyTemplateToProject=7]="CopyTemplateToProject";e[e.PublishProjectTemplate=8]="PublishProjectTemplate";e[e.LaunchProjectTemplate=9]="LaunchProjectTemplate";e[e.ArchiveProject=10]="ArchiveProject";e[e.RollbackProject=11]="RollbackProject";e[e.CrossSpaceCopy=12]="CrossSpaceCopy";e[e.CrossSpaceCopyProject=13]="CrossSpaceCopyProject";e[e.Export=14]="Export";e[e.Import=15]="Import";e[e.PublishChuxProject=16]="PublishChuxProject";e[e.CopyResource=17]="CopyResource";e[e.CopyVibeProject=18]="CopyVibeProject"}(Ll||(Ll={})),function(e){e[e.Packing=0]="Packing";e[e.PackSuccess=1]="PackSuccess";e[e.PackFail=2]="PackFail"}(Ol||(Ol={}));class xl{__init(){this.request=e.request}__init2(){this.baseURL=""}constructor(e){xl.prototype.__init.call(this),xl.prototype.__init2.call(this),this.request=Bl([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=Bl([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}Ping(e,t){const i=this.genBaseURL("/api/intelligence_api/ping");return this.request({url:i,method:"POST"},t)}DraftProjectCreate(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/draft_project/create"),o={space_id:i.space_id,name:i.name,description:i.description,icon_uri:i.icon_uri,monetization_conf:i.monetization_conf,create_from:i.create_from,folder_id:i.folder_id,type:i.type};return this.request({url:s,method:"POST",data:o},t)}GetDraftIntelligenceList(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/search/get_draft_intelligence_list"),o={space_id:i.space_id,name:i.name,has_published:i.has_published,status:i.status,types:i.types,search_scope:i.search_scope,folder_id:i.folder_id,folder_include_children:i.folder_include_children,order_type:i.order_type,project_type:i.project_type,is_fav_filter:i.is_fav_filter,is_collaborator_filter:i.is_collaborator_filter,organization_id:i.organization_id,is_fav:i.is_fav,recently_open:i.recently_open,option:i.option,order_by:i.order_by,cursor_id:i.cursor_id,size:i.size};return this.request({url:s,method:"POST",data:o},t)}DraftProjectUpdate(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/draft_project/update"),o={project_id:i.project_id,name:i.name,description:i.description,icon_uri:i.icon_uri};return this.request({url:s,method:"POST",data:o},t)}GetDraftIntelligenceInfo(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/search/get_draft_intelligence_info"),o={intelligence_id:i.intelligence_id,intelligence_type:i.intelligence_type,version:i.version};return this.request({url:s,method:"POST",data:o},t)}GetUserRecentlyEditIntelligence(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/search/get_recently_edit_intelligence"),o={size:i.size,types:i.types,enterprise_id:i.enterprise_id,organization_id:i.organization_id};return this.request({url:s,method:"POST",data:o},t)}DraftProjectCopy(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/draft_project/copy"),o={project_id:i.project_id,to_space_id:i.to_space_id,name:i.name,description:i.description,icon_uri:i.icon_uri};return this.request({url:s,method:"POST",data:o},t)}ProcessEntityTask(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/entity_task/process"),o={entity_id:i.entity_id,action:i.action,task_id_list:i.task_id_list};return this.request({url:s,method:"POST",data:o},t)}DraftProjectDelete(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/draft_project/delete"),o={project_id:i.project_id};return this.request({url:s,method:"POST",data:o},t)}EntityTaskSearch(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/entity_task/search"),o={task_list:i.task_list};return this.request({url:s,method:"POST",data:o},t)}ListIntelligenceCollaboration(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/collaboration/list"),o={intelligence_id:i.intelligence_id,intelligence_type:i.intelligence_type};return this.request({url:s,method:"POST",data:o},t)}OceanProjectCreate(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/ocean_project/create"),o={space_id:i.space_id,name:i.name,description:i.description,icon_uri:i.icon_uri};return this.request({url:s,method:"POST",data:o},t)}OceanProjectUpdate(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/ocean_project/update"),o={project_id:i.project_id,name:i.name,description:i.description,icon_uri:i.icon_uri};return this.request({url:s,method:"POST",data:o},t)}GetOceanProjectList(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/search/get_ocean_project_list"),o={space_id:i.space_id,status:i.status,search_scope:i.search_scope,order_by:i.order_by,page_index:i.page_index,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}PublishProject(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/publish/publish_project"),o={project_id:i.project_id,version_number:i.version_number,description:i.description,connectors:i.connectors,connector_publish_config:i.connector_publish_config};return this.request({url:s,method:"POST",data:o},t)}GetPublishRecordDetail(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/publish/publish_record_detail"),o={project_id:i.project_id,publish_record_id:i.publish_record_id};return this.request({url:s,method:"POST",data:o},t)}GetPublishRecordList(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/publish/publish_record_list"),o={project_id:i.project_id};return this.request({url:s,method:"POST",data:o},t)}PublishConnectorList(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/publish/connector_list"),o={project_id:i.project_id};return this.request({url:s,method:"POST",data:o},t)}CheckProjectVersionNumber(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/publish/check_version_number"),o={project_id:i.project_id,version_number:i.version_number};return this.request({url:s,method:"POST",data:o},t)}DraftProjectInnerTaskList(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/draft_project/inner_task_list"),o={project_id:i.project_id};return this.request({url:s,method:"POST",data:o},t)}GetOceanProjectInfo(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/search/get_ocean_project_info"),o={project_id:i.project_id};return this.request({url:s,method:"POST",data:o},t)}GetModelListFilterParams(e,t){const i=this.genBaseURL("/api/intelligence_api/model/get_model_list_filter_params");return this.request({url:i,method:"POST"},t)}StartEstimatedTrainingCost(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/start_estimated_training_cost"),o={base_model_id:i.base_model_id,space_id:i.space_id,training_dataset_id:i.training_dataset_id,epochs:i.epochs};return this.request({url:s,method:"POST",data:o},t)}GetModelList(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/get_model_list"),o={space_id:i.space_id,name:i.name,tag_filters:i.tag_filters,context_len_min:i.context_len_min,context_len_max:i.context_len_max,model_cost_min:i.model_cost_min,model_cost_max:i.model_cost_max,model_vendor:i.model_vendor,statusList:i.statusList,model_show_family_id:i.model_show_family_id,model_source:i.model_source,order_by:i.order_by,cursor_id:i.cursor_id,limit:i.limit};return this.request({url:s,method:"POST",data:o},t)}GetFinetuneTemplateDataset(e,t){const i=this.genBaseURL("/api/intelligence_api/model/get_finetune_template_dataset");return this.request({url:i,method:"POST"},t)}GetModelUsageData(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/get_model_usage_data"),o={space_id:i.space_id,model_id:i.model_id};return this.request({url:s,method:"POST",data:o},t)}GetEstimatedTrainingCost(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/get_estimated_training_cost"),o={task_id:i.task_id,space_id:i.space_id,base_model_id:i.base_model_id,epochs:i.epochs};return this.request({url:s,method:"POST",data:o},t)}CreateFinetuneTask(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/create_finetune_task"),o={space_id:i.space_id,base_model_id:i.base_model_id,training_dataset_id:i.training_dataset_id,validating_dataset:i.validating_dataset,finetune_configuration:i.finetune_configuration,description:i.description,name:i.name};return this.request({url:s,method:"POST",data:o},t)}UploadFinetuneDataset(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/upload_finetune_dataset"),o={space_id:i.space_id,fileType:i.fileType,fileName:i.fileName,data:i.data,testing_data:i.testing_data};return this.request({url:s,method:"POST",data:o},t)}GetModelInfo(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/get_model_info"),o={space_id:i.space_id,model_id:i.model_id,is_finetuning:i.is_finetuning};return this.request({url:s,method:"POST",data:o},t)}GetFinetuneTrainingInfo(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/get_finetune_training_info"),o={space_id:i.space_id,model_id:i.model_id};return this.request({url:s,method:"POST",data:o},t)}GetModelPerformanceData(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/get_model_performance_data"),o={space_id:i.space_id,model_id:i.model_id,get_pct:i.get_pct};return this.request({url:s,method:"POST",data:o},t)}OperateFinetuneTask(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/operate_finetune_task"),o={id:i.id,action:i.action};return this.request({url:s,method:"POST",data:o},t)}DeleteFinetuneModel(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/delete_finetune_model"),o={model_id:i.model_id,space_id:i.space_id};return this.request({url:s,method:"POST",data:o},t)}GetUserCompleteProfileRecord(e,t){const i=this.genBaseURL("/api/intelligence_api/user_profile/get_user_complete_profile_record");return this.request({url:i,method:"POST"},t)}DownloadUserProfile(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/user_profile/download_user_profile"),o={Cookie:i.Cookie};return this.request({url:s,method:"POST",headers:o},t)}GetProjectPublishedConnector(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/publish/get_published_connector"),o={project_id:i.project_id};return this.request({url:s,method:"POST",data:o},t)}PublishIntelligenceUnList(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/publish/publish_intelligence_unlist"),o={intelligence_id:i.intelligence_id,connector_ids:i.connector_ids,intelligence_type:i.intelligence_type};return this.request({url:s,method:"POST",data:o},t)}PublishIntelligenceList(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/search/get_publish_intelligence_list"),o={intelligence_type:i.intelligence_type,space_id:i.space_id,owner_id:i.owner_id,name:i.name,order_last_publish_time:i.order_last_publish_time,order_total_token:i.order_total_token,size:i.size,cursor_id:i.cursor_id,intelligence_ids:i.intelligence_ids};return this.request({url:s,method:"POST",data:o},t)}UpdateDiffModeInfo(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/diff_mode/update_diff_mode_info"),o={target_type:i.target_type,target_id:i.target_id,diff_mode_info:i.diff_mode_info,exit_and_save:i.exit_and_save,exit_and_discard:i.exit_and_discard};return this.request({url:s,method:"POST",data:o},t)}GetDiffModeInfo(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/diff_mode/get_diff_mode_info"),o={target_type:i.target_type,target_id:i.target_id};return this.request({url:s,method:"POST",data:o},t)}GetProjectPublishSummary(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/search/get_project_publish_summary"),o={project_id:i.project_id};return this.request({url:s,method:"POST",data:o},t)}DraftProjectCrossSpaceCopy(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/draft_project/crossspace_copy"),o={project_id:i.project_id,to_space_id:i.to_space_id};return this.request({url:s,method:"POST",data:o},t)}EntityTaskList(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/entity_task/list"),o={space_id:i.space_id,task_id_list:i.task_id_list};return this.request({url:s,method:"POST",data:o},t)}ExpansionTpm(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/expansion_tpm"),o={model_id:i.model_id,enterprise_id:i.enterprise_id,organization_id:i.organization_id,tpm_input_expansion:i.tpm_input_expansion,tpm_output_expansion:i.tpm_output_expansion,start_time:i.start_time,end_time:i.end_time};return this.request({url:s,method:"POST",data:o},t)}GetEstimatedTpmExpansionCost(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/get_estimated_tpm_expansion_cost"),o={model_id:i.model_id,enterprise_id:i.enterprise_id,input_tpm:i.input_tpm,output_tpm:i.output_tpm};return this.request({url:s,method:"POST",data:o},t)}GetEstimatedTpmExpansion(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/get_estimated_tpm_expansion"),o={model_id:i.model_id,enterprise_id:i.enterprise_id,estimated_rpm:i.estimated_rpm,StartTime:i.StartTime,EndTime:i.EndTime};return this.request({url:s,method:"POST",data:o},t)}FolderUpdate(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/folder/update"),o={folder_id:i.folder_id,name:i.name,description:i.description};return this.request({url:s,method:"POST",data:o},t)}GetFolderList(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/search/get_folder_list"),o={space_id:i.space_id,type:i.type,name:i.name,search_scope:i.search_scope,parent_folder_id:i.parent_folder_id,parent_include_children:i.parent_include_children,order_by:i.order_by,order_type:i.order_type,size:i.size,page_num:i.page_num};return this.request({url:s,method:"POST",data:o},t)}FolderMove(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/folder/move"),o={folder_id:i.folder_id,parent_folder_id:i.parent_folder_id};return this.request({url:s,method:"POST",data:o},t)}FolderDelete(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/folder/delete"),o={folder_id:i.folder_id};return this.request({url:s,method:"POST",data:o},t)}FolderCreate(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/folder/create"),o={space_id:i.space_id,type:i.type,name:i.name,description:i.description,parent_folder_id:i.parent_folder_id};return this.request({url:s,method:"POST",data:o},t)}ArchiveProject(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/draft_project/archive"),o={project_id:i.project_id,description:i.description,scene:i.scene};return this.request({url:s,method:"POST",data:o},t)}GetIntelligenceTaskInfo(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/entity_task/task_info"),o={task_id:i.task_id};return this.request({url:s,method:"GET",params:o},t)}ProjectHistoryList(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/draft_project/history_list"),o={project_id:i.project_id,history_type:i.history_type,cursor:i.cursor,size:i.size};return this.request({url:s,method:"POST",data:o},t)}RollbackProject(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/draft_project/rollback"),o={project_id:i.project_id,rollback_version:i.rollback_version,scene:i.scene};return this.request({url:s,method:"POST",data:o},t)}GetModelConcurrencyPerformanceData(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/get_model_concurrency_performance_data"),o={space_id:i.space_id,model_id:i.model_id};return this.request({url:s,method:"POST",data:o},t)}UpdateModelConfigType(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/update_model_config_type"),o={space_id:i.space_id,model_id:i.model_id,config_type:i.config_type};return this.request({url:s,method:"POST",data:o},t)}GetSpaceModelUserConfig(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/get_space_model_user_config"),o={space_id:i.space_id};return this.request({url:s,method:"POST",data:o},t)}OpenGetProjectList(e,t){const i=e||{},s=this.genBaseURL("/v1/apps"),o={workspace_id:i.workspace_id,publish_status:i.publish_status,connector_id:i.connector_id,page_num:i.page_num,page_size:i.page_size};return this.request({url:s,method:"GET",params:o},t)}OpenGetBotList(e,t){const i=e||{},s=this.genBaseURL("/v1/bots"),o={workspace_id:i.workspace_id,publish_status:i.publish_status,connector_id:i.connector_id,page_num:i.page_num,page_size:i.page_size};return this.request({url:s,method:"GET",params:o},t)}GetFolderTree(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/folder/tree"),o={space_id:i.space_id,type:i.type};return this.request({url:s,method:"POST",data:o},t)}OpenGetSpaceFolder(e,t){const i=e||{},s=this.genBaseURL("/v1/folders"),o={workspace_id:i.workspace_id,folder_type:i.folder_type,parent_folder_id:i.parent_folder_id,page_num:i.page_num,page_size:i.page_size};return this.request({url:s,method:"GET",params:o},t)}MoveObjectToFolder(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/folder/move_object"),o={dest_folder_id:i.dest_folder_id,folder_space_id:i.folder_space_id,move_objects:i.move_objects};return this.request({url:s,method:"POST",data:o},t)}GetFolderInfoByIds(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/folder/get_by_ids"),o={space_id:i.space_id,folder_ids:i.folder_ids,get_path_info:i.get_path_info};return this.request({url:s,method:"POST",data:o},t)}OpenGetFolderInfo(e,t){const i=e||{},s=this.genBaseURL(`/v1/folders/${i.folder_id}`);return this.request({url:s,method:"GET"},t)}ExportPreCheck(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/export_pre_check"),o={res_type:i.res_type,id:i.id,commit_id:i.commit_id};return this.request({url:s,method:"POST",data:o},t)}ImportPreCheck(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/import_pre_check"),o={package_uri:i.package_uri};return this.request({url:s,method:"POST",data:o},t)}GetUploadAuthToken(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/upload/auth_token"),o={scene:i.scene};return this.request({url:s,method:"POST",data:o},t)}MarkProjectHistory(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/draft_project/history_list/read"),o={project_id:i.project_id,version:i.version};return this.request({url:s,method:"POST",data:o},t)}GetCustomModelDetail(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/model/get_custom_model_detail"),o={model_id:i.model_id,org_id:i.org_id};return this.request({url:s,method:"POST",data:o},t)}GetCustomModelList(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/model/get_custom_model_list"),o={search_key:i.search_key,sort_field:i.sort_field,org_id:i.org_id,page:i.page,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}GetProjectHistoryNotice(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/draft_project/history_list/notice"),o={project_id:i.project_id};return this.request({url:s,method:"POST",data:o},t)}BindCustomModelSpace(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/model/bind_custom_model_space"),o={model_id:i.model_id,space_id_list:i.space_id_list,status:i.status,org_id:i.org_id};return this.request({url:s,method:"POST",data:o},t)}GetCustomModelSpaceList(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/model/get_custom_model_space_list"),o={model_id:i.model_id,search_key:i.search_key,org_id:i.org_id,cursor_id:i.cursor_id,limit:i.limit,enterprise_id:i.enterprise_id};return this.request({url:s,method:"POST",data:o},t)}GetCustomModelParameterTemplate(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/model/get_custom_model_parameter_template"),o={org_id:i.org_id};return this.request({url:s,method:"POST",data:o},t)}OpenCopyTaskInfo(e,t){const i=e||{},s=this.genBaseURL(`/v1/entities/copy_tasks/${i.task_id}`);return this.request({url:s,method:"GET"},t)}OpenDuplicateDraftEntity(e,t){const i=e||{},s=this.genBaseURL("/v1/entities/copy_tasks"),o={entity_id:i.entity_id,entity_type:i.entity_type,to_workspace_id:i.to_workspace_id};return this.request({url:s,method:"POST",data:o},t)}ConvertCustomModelParameter(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/model/convert_custom_model_parameter"),o={parameters:i.parameters,org_id:i.org_id};return this.request({url:s,method:"POST",data:o},t)}CreateCustomModel(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/model/create_custom_model"),o={model_name:i.model_name,model_icon_uri:i.model_icon_uri,model_arch:i.model_arch,model_desc:i.model_desc,base_url:i.base_url,secret_name:i.secret_name,model_runtime_tag:i.model_runtime_tag,inputLength:i.inputLength,parameters:i.parameters,api_agreement:i.api_agreement,safety_guardrails:i.safety_guardrails,auth:i.auth,api_mode:i.api_mode,org_id:i.org_id};return this.request({url:s,method:"POST",data:o},t)}TerminateCustomModel(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/model/terminate_custom_model"),o={model_id:i.model_id,terminate_time:i.terminate_time,org_id:i.org_id};return this.request({url:s,method:"POST",data:o},t)}UpdateCustomModel(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/model/update_custom_model"),o={model_name:i.model_name,model_icon_uri:i.model_icon_uri,model_arch:i.model_arch,model_desc:i.model_desc,base_url:i.base_url,secret_name:i.secret_name,model_runtime_tag:i.model_runtime_tag,inputLength:i.inputLength,parameters:i.parameters,model_id:i.model_id,api_agreement:i.api_agreement,safety_guardrails:i.safety_guardrails,auth:i.auth,api_mode:i.api_mode,org_id:i.org_id};return this.request({url:s,method:"POST",data:o},t)}GetModelUsageRecord(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/get_model_usage_record"),o={space_id:i.space_id,model_id:i.model_id,start_timestamp:i.start_timestamp,end_timestamp:i.end_timestamp,order_by_type:i.order_by_type,order_by_field:i.order_by_field,page:i.page,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}GetEntityModelUsage(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/get_entity_model_usage"),o={space_id:i.space_id,model_id:i.model_id,entity_id:i.entity_id,entity_type:i.entity_type,start_timestamp:i.start_timestamp,end_timestamp:i.end_timestamp};return this.request({url:s,method:"POST",data:o},t)}GetTypeList(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/get_type_list"),o={model:i.model,voice:i.voice,raw_model:i.raw_model,space_id:i.space_id,cur_model_id:i.cur_model_id,cur_model_ids:i.cur_model_ids,model_scene:i.model_scene,tag_filters:i.tag_filters,user_benefit_filter:i.user_benefit_filter};return this.request({url:s,method:"POST",data:o},t)}SaveModelReplacement(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/save_replacement"),o={space_id:i.space_id,old_model_id:i.old_model_id,new_model_id:i.new_model_id,start_timestamp:i.start_timestamp,end_timestamp:i.end_timestamp};return this.request({url:s,method:"POST",data:o},t)}GetModelReplacement(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/model/get_replacement"),o={space_id:i.space_id,entity_type:i.entity_type,entity_id:i.entity_id};return this.request({url:s,method:"POST",data:o},t)}UpdateCustomModelV2(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/custom_model/update"),o={model_id:i.model_id,display_name:i.display_name,model_name:i.model_name,base_url:i.base_url,api_mode:i.api_mode,auth:i.auth,support_image_understanding:i.support_image_understanding,max_tokens:i.max_tokens};return this.request({url:s,method:"POST",data:o},t)}ListProviderModels(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/custom_model/list_provider_models"),o={provider:i.provider,auth:i.auth,base_url:i.base_url,search_key:i.search_key};return this.request({url:s,method:"POST",data:o},t)}ListCustomModelV2(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/custom_model/list"),o={account_type:i.account_type,coze_account_id:i.coze_account_id,enterprise_id:i.enterprise_id,search_key:i.search_key,provider:i.provider,source_type:i.source_type,sort_field:i.sort_field,sort_order:i.sort_order,page:i.page,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}ToggleCustomModelMemberVisibility(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/custom_model/toggle_member_visibility"),o={model_id:i.model_id,member_visible:i.member_visible};return this.request({url:s,method:"POST",data:o},t)}DeleteCustomModelV2(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/custom_model/delete"),o={model_id:i.model_id};return this.request({url:s,method:"POST",data:o},t)}ListProviders(e,t){const i=e||{},s=this.genBaseURL("/api/intelligence_api/custom_model/list_providers"),o={only_enabled:i.only_enabled};return this.request({url:s,method:"POST",data:o},t)}GetCustomModelDetailV2(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/custom_model/detail"),o={model_id:i.model_id};return this.request({url:s,method:"POST",data:o},t)}TestCustomModelConnection(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/custom_model/test_connection"),o={source_type:i.source_type,provider:i.provider,base_url:i.base_url,api_mode:i.api_mode,model_name:i.model_name,auth:i.auth};return this.request({url:s,method:"POST",data:o},t)}CreateCustomModelV2(e,t){const i=e,s=this.genBaseURL("/api/intelligence_api/custom_model/create"),o={source_type:i.source_type,provider:i.provider,display_name:i.display_name,model_name:i.model_name,base_url:i.base_url,api_mode:i.api_mode,auth:i.auth,support_image_understanding:i.support_image_understanding,max_tokens:i.max_tokens,account_type:i.account_type,coze_account_id:i.coze_account_id,enterprise_id:i.enterprise_id};return this.request({url:s,method:"POST",data:o},t)}}const ql=new xl({}),Dl={agent:qc.VibeProjectAgent,workflow:qc.VibeProjectAutomation,webapp:qc.VibeProjectWebApp,app:qc.VibeProjectApp,skill:qc.VibeProjectSkill,web:qc.VibeProjectGeneralWeb,miniprogram:qc.VibeProjectWechatMiniProgram,assistant:qc.VibeProjectAssistantAgent},Ml={[qc.VibeProjectAgent]:"agent",[qc.VibeProjectAutomation]:"workflow",[qc.VibeProjectWebApp]:"webapp",[qc.VibeProjectApp]:"app",[qc.VibeProjectSkill]:"skill",[qc.VibeProjectGeneralWeb]:"web",[qc.VibeProjectWechatMiniProgram]:"miniprogram",[qc.VibeProjectAssistantAgent]:"assistant"};function Gl(e){if(!e)return;const t=String(e).trim();if(!t)return;const i=t.toLowerCase();return Dl[i]}const $l=e=>Ml[e],Nl=[qc.VibeProjectAgent,qc.VibeProjectAutomation,qc.VibeProjectWebApp,qc.VibeProjectApp,qc.VibeProjectSkill,qc.VibeProjectGeneralWeb,qc.VibeProjectWechatMiniProgram,qc.VibeProjectAssistantAgent].map($l).filter(Boolean);function Fl(e,t){return null!=e?e:t()}function Vl(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const Wl={agent:t.VibeProjectType.Agent,workflow:t.VibeProjectType.Automation,webapp:t.VibeProjectType.WebApp,app:t.VibeProjectType.App,skill:t.VibeProjectType.Skill,web:t.VibeProjectType.GeneralWeb,miniprogram:t.VibeProjectType.WechatMiniProgram,assistant:t.VibeProjectType.AssistantAgent},Hl={[t.VibeProjectType.Agent]:"agent",[t.VibeProjectType.Automation]:"workflow",[t.VibeProjectType.WebApp]:"webapp",[t.VibeProjectType.App]:"app",[t.VibeProjectType.Skill]:"skill",[t.VibeProjectType.GeneralWeb]:"web",[t.VibeProjectType.WechatMiniProgram]:"miniprogram",[t.VibeProjectType.AssistantAgent]:"assistant"};const Kl=e=>Hl[e],Jl=[t.VibeProjectType.GeneralWeb,t.VibeProjectType.App],Ql=Jl.map(Kl);function Yl(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function Zl(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}class Xl{static getInstance(){return Xl.INSTANCE||(Xl.INSTANCE=new Xl),Xl.INSTANCE}sendMessageRunTask(e){const t=[_.resolve(__dirname,"./send-message.worker.js")],i=process.execPath;v.spawn(i,[...t,JSON.stringify(e)],{detached:!0,stdio:"ignore"}).unref()}async sendMessage(e){return await t.sendProjectChatMessage(e)}isValidType(e){return Jl.includes(e)}}const ed=Xl.getInstance();function td(e,t){return null!=e?e:t()}function id(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function sd(i){i.command("create").description("Create a new project").requiredOption("--message <message>","Description/requirements for creating the project").requiredOption("--type <type>","Project type: agent | workflow | app | skill | web | miniprogram | assistant").option("--org-id <orgId>","Organization ID (optional, will read from context automatically)").option("--space-id <spaceId>","Space ID (optional, will read from context automatically)").option("--wait","Wait for project creation to complete").config({help:{brief:"Create a new Coze Coding project",description:"Create a new Coze Coding project via natural language description. The system will automatically generate project structure and configuration based on the description, supporting multiple project types.",examples:[{desc:"Create an Agent project",cmd:'coze code project create --message "Create an intelligent customer service robot" --type agent',tags:["[RECOMMENDED]"]},{desc:"Create a Workflow project",cmd:'coze code project create --message "Create a data processing workflow" --type workflow'}],schema:{input:{message:{type:"string",required:!0,description:"Project description/requirements (natural language)"},type:{type:"string",required:!0,enum:Ql,description:"Project type"},spaceId:{type:"string",required:!1,description:"Space ID (optional, reads from context)"}},output:{project_id:{type:"string",description:"Created project ID"},type:{type:"string",description:"Project type"}}},enums:{type:Ql.reduce(((e,t)=>(e[t]=`${t.toUpperCase()} project`,e)),{})},errors:[{code:e.ErrorCode.E1005,name:"INVALID_PROJECT_TYPE",desc:"Invalid project type",fix:"Please use a valid project type: agent | workflow | app | skill | web | miniprogram | assistant"},{code:e.ErrorCode.E1003,name:"MISSING_SPACE_ID",desc:"Missing Space ID",fix:"Please use the --space-id parameter or run `coze space use <spaceId>` first"},{code:e.ErrorCode.E1006,name:"UNSUPPORTED_PROJECT_TYPE",desc:"Project type is not supported for creation",fix:"Please choose a supported project type and try again"},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid API token",fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable",example:"coze auth login --oauth"},{code:e.ErrorCode.E5000,name:"UNEXPECTED_ERROR",desc:"CLI context is not initialized or project tool config is missing",fix:"Please retry and run with --debug if the issue persists"}]}}).action((async(i,s)=>{const o=s.getContext();if(!o)throw new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized");const n=td(td(i.spaceId,(()=>id([o,"optionalAccess",e=>e.config,"access",e=>e.spaceId]))),(()=>"")),{message:r,type:a,wait:c}=i;id([o,"optionalAccess",e=>e.log,"access",e=>e.debug,"call",e=>e(`Resolving project type '${a}'...`)]);const l=function(e){if(!e)return;const t=String(e).trim();if(!t)return;const i=t.toLowerCase();return Wl[i]}(a);if(!n)throw new e.CozeError(e.ErrorCode.E1003,"Missing space_id: pass --space-id or coze space use <spaceId>");if(!l)throw new e.CozeError(e.ErrorCode.E1005,`Unknown project type: ${a}`,{type:a});if(!ed.isValidType(l))throw new e.CozeError(e.ErrorCode.E1006,`Project type ${a} is not supported for creation`,{type:a,projectType:l});id([o,"optionalAccess",e=>e.log,"access",e=>e.debug,"call",e=>e("Fetching agent tools configuration...")]);const d=id([await t.BuildAgentApi.GetTools(),"access",e=>e.project_types,"optionalAccess",e=>e.find,"call",e=>e((e=>e.project_type===l)),"optionalAccess",e=>e.tools]);if(!d||0===d.length)throw new e.CozeError(e.ErrorCode.E5000,`No tools config for projectType: ${String(a)}`,{type:a,projectType:l});const p={};d.forEach((e=>{id([e,"optionalAccess",e=>e.name])&&(p[e.name]=Boolean(e.enabled))})),id([o,"optionalAccess",e=>e.log,"access",e=>e.debug,"call",e=>e("Fetching project default skills...")]);const u={skills:td(id([await na.GetProjectDefaultSkill({project_type:l,space_id:String(n)}),"access",e=>e.data,"optionalAccess",e=>e.skill_list]),(()=>[])).map((e=>({skill_id:e.skill_id,is_preload:e.is_preload}))),filter_types:[l]},_={space_id:String(n),user_query:r,project_type:l,agent_tools:p,project_settings:{model_setting:{model_name:""},skill_setting:u}};id([o,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Creating project...")]);const m=td((await t.IdeApi.ChatCreateVibeProject(_)).data,(()=>({}))).project_id,g=await id([o,"optionalAccess",e=>e.auth,"optionalAccess",e=>e.getValidAccessToken,"call",e=>e()]);if(!g)throw new e.CozeError(e.ErrorCode.E2001,"Missing API token: set env COZE_API_TOKEN or run `coze auth login` first");if(o.ui.success('Project created successfully, please use "coze code message status" to check the status.'),id([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({project_id:m,type:a})]),c){const e=await ed.sendMessage({projectId:td(m,(()=>"")),prompt:r,apiBaseUrl:o.config.apiBaseUrl,accessToken:g,xTTEnv:o.config.xTTEnv,key:`coze-coding-cli:message:${m}`});o.response.print(e.lastAnswerMessage)}else ed.sendMessageRunTask({projectId:td(m,(()=>"")),prompt:r,apiBaseUrl:o.config.apiBaseUrl,accessToken:g,xTTEnv:o.config.xTTEnv,key:`coze-coding-cli:message:${m}`})}))}const od=i=>{const s=i.command("project").alias("proj").config({help:{brief:"Manage Coze Coding projects",description:"Manage Coze Coding projects (Vibe Project). Supports creating, viewing, listing, and deleting projects, covering various project types like Agent, Workflow, Skill, Web apps, Mini-programs, etc.",examples:[{desc:"Create project",cmd:'coze code project create --message "Create a chatbot" --type web'},{desc:"List projects",cmd:"coze code project list"},{desc:"View project details",cmd:"coze code project get <projectId>"},{desc:"Delete project",cmd:"coze code project delete <projectId>"}],seeAlso:["coze code deploy","coze code skill"],schema:{input:{},output:{}},errors:[{code:e.ErrorCode.E3001,name:"PROJECT_NOT_FOUND",desc:"Project not found",fix:"Please confirm if the project ID is correct"}]}}).description("Manage Coze Coding projects");sd(s),function(t){t.command("list").description("List all projects").config({help:{brief:"List all projects in the current space",description:"Get the list of projects in the current space. Supports filtering by type, name, publish status, and supports pagination.",examples:[{desc:"List projects",cmd:"coze code project list",tags:["[RECOMMENDED]"]},{desc:"Filter by type",cmd:"coze code project list --type agent --type workflow"},{desc:"Search by name",cmd:'coze code project list --name "customer service"'}],schema:{input:{size:{type:"number",required:!1,description:"Number of projects to return (default: 10)"},cursorId:{type:"string",required:!1,description:"Cursor for pagination"},type:{type:"array",required:!1,description:"Project type filter (can be passed multiple times)"},name:{type:"string",required:!1,description:"Filter by project name"},hasPublished:{type:"boolean",required:!1,description:"Filter by publish status"},searchScope:{type:"number",required:!1,description:"Created by (All = 0, CreateByMe = 1)"},folderId:{type:"string",required:!1,description:"Folder ID"},orderType:{type:"number",required:!1,description:"Sort type (0 for descending, 1 for ascending)"},isFavFilter:{type:"boolean",required:!1,description:"Filter by favorite status"}},output:{type:"array",items:{type:"object",properties:{id:{type:"string",description:"Project ID"},name:{type:"string",description:"Project name"},type:{type:"string",description:"Project type"},description:{type:"string",description:"Project description"}}}}},errors:[{code:e.ErrorCode.E1003,name:"MISSING_SPACE_ID",desc:"Space ID is required",fix:"Please use --space-id <spaceId> or run `coze space use <spaceId>` first"}],enums:{type:Nl.reduce(((e,t)=>(e[t]=`${t.toUpperCase()} project`,e)),{}),"search-scope":{0:"All",1:"CreateByMe"},"order-type":{0:"Descending",1:"Ascending"},"order-by":{0:"updated_at",1:"created_at"}}}}).option("--size <size>","Number of projects to return",parseInt).option("--cursor-id <cursorId>","Cursor for pagination").option("--type <type>","Project type filter (can be passed multiple times): agent | workflow | webapp | app | web | miniprogram | assistant",((e,t=[])=>[...t,e]),[]).option("--name <name>","Filter by project name").option("--has-published","Filter by publish status").option("--search-scope <searchScope>","Created by (All = 0, CreateByMe = 1, AllWithCollaborator = 2)").option("--folder-id <folderId>","Folder ID").option("--order-type <orderType>","Sort type (0 for descending, 1 for ascending)").option("--order-by <orderBy>","Order by (0 for updated_at, 1 for created_at)").option("--is-fav-filter","Filter by favorite status (true | false)").action((async function(e,t){const i=t.getContext(),s=Fl(Vl([e,"optionalAccess",e=>e.size]),(()=>10)),o=Fl(Vl([e,"optionalAccess",e=>e.cursorId]),(()=>{})),n=Vl([e,"optionalAccess",e=>e.type,"optionalAccess",e=>e.map,"call",e=>e(Gl),"access",e=>e.filter,"call",e=>e(Boolean)]),r=Vl([e,"optionalAccess",e=>e.name]),a=Vl([e,"optionalAccess",e=>e.hasPublished])?Boolean(Vl([e,"optionalAccess",e=>e.hasPublished])):void 0,c=Number(Fl(Vl([e,"optionalAccess",e=>e.searchScope]),(()=>El.All))),l=Fl(Vl([e,"optionalAccess",e=>e.folderId]),(()=>"0")),d=Number(Fl(Vl([e,"optionalAccess",e=>e.orderType]),(()=>Il.Desc))),p=Boolean(Vl([e,"optionalAccess",e=>e.isFavFilter])),u=Number(Fl(Vl([e,"optionalAccess",e=>e.orderBy]),(()=>kl.UpdateTime)));let _=[];Vl([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Fetching project list...")]);const m=await ql.GetDraftIntelligenceList({space_id:Fl(Vl([i,"optionalAccess",e=>e.config,"access",e=>e.spaceId]),(()=>"")),size:s,cursor_id:o,types:n,name:r,has_published:a,search_scope:c,folder_id:l,order_type:d,order_by:u,is_fav_filter:p,status:[xc.Using,xc.Banned,xc.MoveFailed]});_=Vl([m,"access",e=>e.data,"optionalAccess",e=>e.intelligences])||[],Vl([i,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Fetched ${_.length} projects.`)]),Vl([i,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(_.map((e=>({id:Vl([e,"access",e=>e.basic_info,"optionalAccess",e=>e.id]),name:Vl([e,"access",e=>e.basic_info,"optionalAccess",e=>e.name]),type:$l(e.type),description:Vl([e,"access",e=>e.basic_info,"optionalAccess",e=>e.description])}))))])}))}(s),function(i){i.command("get <projectId>").description("View project details").config({help:{brief:"Get project details",description:"Get the detailed configuration of the specified project, including project type, settings, skill configurations, etc.",examples:[{desc:"View project details",cmd:"coze code project get <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"}},output:{project_id:{type:"string",description:"Project ID"},project_name:{type:"string",description:"Project name"},project_type:{type:"string",description:"Project type"},skills:{type:"object",description:"Project skill configurations",properties:{skills:{type:"array",items:{type:"object",properties:{skill_id:{type:"string",description:"Skill ID"},is_preload:{type:"boolean",description:"Is preloaded"}}}}}}}},errors:[{code:e.ErrorCode.E3001,name:"PROJECT_NOT_FOUND",desc:"Project does not exist",fix:"Please confirm if the project ID is correct, use `project list` to view available projects"}]}}).action((async function(i,s,o){const n=o.getContext();Yl([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Fetching project details for '${i}'...`)]);const r=Yl([await t.IdeApi.GetVibeProject({project_id:i}),"access",e=>e.data,"optionalAccess",e=>e.project_info]);if(!r)throw new e.CozeError(e.ErrorCode.E3001,`Project ${i} not found`,{projectId:i});Yl([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Project details for '${i}':`)]),Yl([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({...y.omit(r,["project_settings"]),skills:y.pick(Yl([r,"optionalAccess",e=>e.project_settings,"optionalAccess",e=>e.skill_setting]),["skills"]),project_type:Kl(Yl([r,"optionalAccess",e=>e.project_type]))})])}))}(s),function(i){i.command("delete <projectId>").description("Delete a project").config({help:{brief:"Delete project",description:"Delete the specified Coze Coding project. This operation cannot be undone, please use with caution.",examples:[{desc:"Delete project",cmd:"coze code project delete <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID to delete"}},output:{project_id:{type:"string",description:"Deleted project ID"},message:{type:"string",description:"Result message"}}},errors:[{code:e.ErrorCode.E3005,name:"DELETE_FAILED",desc:"Failed to delete project",fix:"Please confirm if the project ID is correct and check if you have sufficient permissions"}]}}).action((async function(e,i,s){const o=s.getContext();Zl([o,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",t=>t(`Deleting project '${e}'...`)]),await t.IdeApi.DeleteVibeProject({project_id:e}),Zl([o,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",t=>t(`Project '${e}' deleted successfully.`)]),Zl([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",t=>t({project_id:e,message:`Project '${e}' deleted successfully.`})])}))}(s)};var nd,rd,ad,cd,ld,dd,pd,ud,_d,md,gd,hd,fd,yd,vd,bd,wd,Pd,Sd,Td,Cd,kd,Ad,Ed,Id,Rd,zd,Ud,jd,Ld,Od,Bd,xd,qd,Dd,Md,Gd,$d,Nd,Fd,Vd,Wd,Hd,Kd,Jd,Qd,Yd,Zd,Xd,ep,tp,ip,sp,op,np,rp,ap,cp,lp,dp,pp,up,_p,mp,gp,hp,fp;function yp(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}!function(e){e[e.Example=0]="Example";e[e.Template=1]="Template"}(nd||(nd={})),function(e){e[e.SpaceEvent=1]="SpaceEvent"}(rd||(rd={})),function(e){e[e.Interest=1]="Interest"}(ad||(ad={})),function(e){e[e.General=0]="General";e[e.PPT=1]="PPT";e[e.Podcast=2]="Podcast";e[e.WEB=3]="WEB";e[e.ImageDoc=4]="ImageDoc";e[e.Poster=5]="Poster";e[e.Excel=6]="Excel";e[e.DesignTemplate=7]="DesignTemplate";e[e.PPTTemplate=8]="PPTTemplate";e[e.Chart=9]="Chart";e[e.Video=10]="Video";e[e.ImagePPTTemplate=11]="ImagePPTTemplate";e[e.VideoTemplate=12]="VideoTemplate"}(cd||(cd={})),function(e){e[e.Chat=1]="Chat";e[e.Fill=2]="Fill"}(ld||(ld={})),function(e){e[e.Delete=0]="Delete";e[e.Running=1]="Running";e[e.Pause=2]="Pause";e[e.TaskFinish=3]="TaskFinish";e[e.Init=4]="Init";e[e.Stop=5]="Stop";e[e.Interrupt=6]="Interrupt";e[e.IllegalContent=7]="IllegalContent";e[e.AbnormalInterrupt=8]="AbnormalInterrupt";e[e.Sleep=9]="Sleep"}(dd||(dd={})),function(e){e[e.Favorite=1]="Favorite";e[e.Template=2]="Template";e[e.TemplateCover=3]="TemplateCover";e[e.PlanTemplate=4]="PlanTemplate";e[e.Article=5]="Article"}(pd||(pd={})),function(e){e[e.General=0]="General";e[e.Product=1]="Product"}(ud||(ud={})),function(e){e[e.Unknown=0]="Unknown";e[e.Pending=1]="Pending";e[e.Running=2]="Running";e[e.Completed=3]="Completed";e[e.Failed=4]="Failed";e[e.Cancelled=5]="Cancelled"}(_d||(_d={})),function(e){e[e.HandsOff=0]="HandsOff";e[e.Cooperative=1]="Cooperative";e[e.Auto=2]="Auto"}(md||(md={})),function(e){e[e.Modify=1]="Modify";e[e.Clear=2]="Clear";e[e.RemoveBackground=3]="RemoveBackground";e[e.Inpainting=4]="Inpainting";e[e.TextReplacement=5]="TextReplacement"}(gd||(gd={})),function(e){e[e.Unactivated=1]="Unactivated";e[e.Activated=2]="Activated"}(hd||(hd={})),function(e){e[e.hot_city=1]="hot_city";e[e.city=2]="city"}(fd||(fd={})),function(e){e[e.PDF=1]="PDF";e[e.PPT=2]="PPT";e[e.ImageEditablePpt=3]="ImageEditablePpt"}(yd||(yd={})),function(e){e[e.Chinese=0]="Chinese";e[e.English=1]="English"}(vd||(vd={})),function(e){e[e.Review=1]="Review";e[e.Draft=2]="Draft";e[e.LawQA=3]="LawQA"}(bd||(bd={})),function(e){e[e.Pin=1]="Pin";e[e.UnPin=2]="UnPin";e[e.Use=3]="Use"}(wd||(wd={})),function(e){e[e.Init=1]="Init";e[e.Stock=2]="Stock";e[e.Sector=3]="Sector"}(Pd||(Pd={})),function(e){e[e.GeneralChat=1]="GeneralChat";e[e.Scheduled=2]="Scheduled"}(Sd||(Sd={})),function(e){e[e.FieldAnalysis=1]="FieldAnalysis";e[e.Upload=2]="Upload"}(Td||(Td={})),function(e){e[e.Running=1]="Running";e[e.Pause=2]="Pause";e[e.TaskFinish=3]="TaskFinish";e[e.Init=4]="Init";e[e.Stop=5]="Stop";e[e.Interrupt=6]="Interrupt";e[e.IllegalContent=7]="IllegalContent";e[e.AbnormalInterrupt=8]="AbnormalInterrupt";e[e.Sleep=9]="Sleep"}(Cd||(Cd={})),function(e){e[e.UNKNOWN=0]="UNKNOWN";e[e.HTML=1]="HTML";e[e.WORD=2]="WORD";e[e.PPT=3]="PPT";e[e.EXCEL=4]="EXCEL";e[e.PDF=5]="PDF";e[e.NOTE=6]="NOTE";e[e.IMAGE=7]="IMAGE";e[e.PODCAST=8]="PODCAST"}(kd||(kd={})),function(e){e[e.FavoritePage=1]="FavoritePage";e[e.TASK=2]="TASK"}(Ad||(Ad={})),function(e){e[e.UserUpload=1]="UserUpload";e[e.Explore=2]="Explore";e[e.TASK=3]="TASK"}(Ed||(Ed={})),function(e){e[e.PPT=1]="PPT"}(Id||(Id={})),function(e){e[e.Favorite=1]="Favorite";e[e.MultiDocImage=2]="MultiDocImage"}(Rd||(Rd={})),function(e){e[e.Upload=1]="Upload";e[e.Search=2]="Search";e[e.Generate=3]="Generate"}(zd||(zd={})),function(e){e[e.PNG=1]="PNG";e[e.JPG=2]="JPG";e[e.MP4=3]="MP4"}(Ud||(Ud={})),function(e){e[e.Modify=1]="Modify";e[e.Clear=2]="Clear";e[e.RemoveBackground=3]="RemoveBackground";e[e.Generate=4]="Generate";e[e.Search=5]="Search";e[e.Blur=6]="Blur"}(jd||(jd={})),function(e){e[e.Image=1]="Image";e[e.Html=2]="Html";e[e.Livephoto=3]="Livephoto"}(Ld||(Ld={})),function(e){e[e.Chat=1]="Chat";e[e.ApiTemplate=2]="ApiTemplate"}(Od||(Od={})),function(e){e[e.Suggest=1]="Suggest"}(Bd||(Bd={})),function(e){e[e.Unknown=0]="Unknown";e[e.Clarifying=1]="Clarifying";e[e.PendingActivation=2]="PendingActivation";e[e.Running=3]="Running";e[e.PendingConfirm=4]="PendingConfirm";e[e.Terminated=5]="Terminated"}(xd||(xd={})),function(e){e[e.Unknown=0]="Unknown";e[e.SystemError=1]="SystemError";e[e.InsufficientBalance=2]="InsufficientBalance";e[e.UserManual=3]="UserManual";e[e.Timeout=4]="Timeout"}(qd||(qd={})),function(e){e[e.DiggTypeDigg=1]="DiggTypeDigg";e[e.DiggTypeBury=2]="DiggTypeBury"}(Dd||(Dd={})),function(e){e[e.Query=1]="Query";e[e.Answer=2]="Answer";e[e.Resume=3]="Resume"}(Md||(Md={})),function(e){e[e.Unknown=0]="Unknown";e[e.ActivatePlan=1]="ActivatePlan";e[e.ResumePlan=2]="ResumePlan"}(Gd||(Gd={})),function(e){e[e.DocMultiImage=1]="DocMultiImage"}($d||($d={})),function(e){e[e.PDF=1]="PDF";e[e.DOCX=2]="DOCX"}(Nd||(Nd={})),function(e){e[e.DeleteCookie=1]="DeleteCookie"}(Fd||(Fd={})),function(e){e[e.POSITION=0]="POSITION";e[e.ELEMENT=1]="ELEMENT"}(Vd||(Vd={})),function(e){e[e.DiamondMatrix=1]="DiamondMatrix";e[e.BulletPoints=2]="BulletPoints";e[e.StaggeredProcessDiagram=3]="StaggeredProcessDiagram";e[e.ArrowRingDiagram=4]="ArrowRingDiagram";e[e.VerticalTimeline=5]="VerticalTimeline"}(Wd||(Wd={})),function(e){e[e.Init=1]="Init";e[e.Enabled=2]="Enabled";e[e.Disabled=3]="Disabled"}(Hd||(Hd={})),function(e){e[e.Pending=1]="Pending";e[e.Success=2]="Success";e[e.Avoid=3]="Avoid";e[e.Failed=4]="Failed"}(Kd||(Kd={})),function(e){e[e.Authorized=1]="Authorized";e[e.UnAuthorized=2]="UnAuthorized";e[e.Expired=3]="Expired"}(Jd||(Jd={})),function(e){e[e.Query=1]="Query";e[e.Template=2]="Template"}(Qd||(Qd={})),function(e){e[e.Pause=1]="Pause";e[e.Resume=2]="Resume";e[e.Pin=3]="Pin";e[e.Unpin=4]="Unpin";e[e.DoNotDisturb=5]="DoNotDisturb";e[e.CancelDoNotDisturb=6]="CancelDoNotDisturb";e[e.Stop=7]="Stop";e[e.Read=8]="Read"}(Yd||(Yd={})),function(e){e[e.Init=0]="Init";e[e.Enable=1]="Enable";e[e.Disable=2]="Disable"}(Zd||(Zd={})),function(e){e[e.Open=1]="Open";e[e.Close=2]="Close"}(Xd||(Xd={})),function(e){e[e.Open=1]="Open";e[e.Close=2]="Close"}(ep||(ep={})),function(e){e[e.Online=1]="Online";e[e.Debug=2]="Debug"}(tp||(tp={})),function(e){e[e.UserCreate=0]="UserCreate";e[e.Example=1]="Example"}(ip||(ip={})),function(e){e[e.Init=0]="Init";e[e.List=1]="List";e[e.Unlist=2]="Unlist"}(sp||(sp={})),function(e){e[e.Good=1]="Good";e[e.Bad=2]="Bad"}(op||(op={})),function(e){e[e.RootUser=1]="RootUser";e[e.BasicUser=2]="BasicUser"}(np||(np={})),function(e){e[e.Pending=1]="Pending";e[e.Running=2]="Running";e[e.Success=3]="Success";e[e.Failed=4]="Failed";e[e.Cancel=5]="Cancel"}(rp||(rp={})),function(e){e[e.Video=1]="Video";e[e.Voice=2]="Voice";e[e.Music=3]="Music"}(ap||(ap={})),function(e){e[e.Update=1]="Update";e[e.UpdateAndAdd=2]="UpdateAndAdd";e[e.UpdateAndSync=3]="UpdateAndSync"}(cp||(cp={})),function(e){e[e.ChatQuery=1]="ChatQuery";e[e.VideoEdit=2]="VideoEdit"}(lp||(lp={})),function(e){e[e.Pin=1]="Pin";e[e.Unpin=2]="Unpin"}(dp||(dp={})),function(e){e[e.Valid=1]="Valid";e[e.Deleted=2]="Deleted"}(pp||(pp={})),function(e){e[e.Narration=1]="Narration";e[e.Music=2]="Music";e[e.Other=3]="Other"}(up||(up={})),function(e){e[e.Video=1]="Video";e[e.Image=2]="Image";e[e.Audio=3]="Audio";e[e.Combination=4]="Combination";e[e.Document=5]="Document"}(_p||(_p={})),function(e){e[e.Local=1]="Local";e[e.AiGenerated=2]="AiGenerated";e[e.Asset=3]="Asset";e[e.Search=4]="Search"}(mp||(mp={})),function(e){e[e.Role=1]="Role";e[e.Item=2]="Item";e[e.Scene=3]="Scene";e[e.Other=4]="Other"}(gp||(gp={})),function(e){e[e.VoiceSelection=1]="VoiceSelection";e[e.VoiceDescription=2]="VoiceDescription";e[e.None=3]="None"}(hp||(hp={})),function(e){e[e.NotUploaded=1]="NotUploaded";e[e.Active=2]="Active";e[e.Processing=3]="Processing";e[e.Failed=4]="Failed"}(fp||(fp={}));class vp{__init(){this.request=e.request}__init2(){this.baseURL=""}constructor(e){vp.prototype.__init.call(this),vp.prototype.__init2.call(this),this.request=yp([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=yp([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}CreateTaskReplay(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/create_task_replay"),o={task_id:i.task_id,need_qr_code:i.need_qr_code,file_list:i.file_list,doc_multi_img_zip_uri:i.doc_multi_img_zip_uri};return this.request({url:s,method:"POST",data:o},t)}GetTaskReplay(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_task_replay"),o={task_id:i.task_id};return this.request({url:s,method:"POST",data:o},t)}DeleteCozeSpaceTask(e,t){const i=e,s=this.genBaseURL("/api/coze_space/delete_task"),o={task_id:i.task_id};return this.request({url:s,method:"POST",data:o},t)}UpdateCozeSpaceTask(e,t){const i=e,s=this.genBaseURL("/api/coze_space/update_task"),o={task_id:i.task_id,task_name:i.task_name,mcp_tool_list:i.mcp_tool_list,expert_agent_config:i.expert_agent_config,scheduled_task_setting:i.scheduled_task_setting};return this.request({url:s,method:"POST",data:o},t)}CreateCozeSpaceTask(e,t){const i=e,s=this.genBaseURL("/api/coze_space/create_task"),o={task_name:i.task_name,task_type:i.task_type,file_uri_list:i.file_uri_list,mcp_tool_list:i.mcp_tool_list,agent_ids:i.agent_ids,scheduled_task_setting:i.scheduled_task_setting,source_from:i.source_from,is_debug:i.is_debug,expert_agent_config:i.expert_agent_config};return this.request({url:s,method:"POST",data:o},t)}CozeSpaceChat(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/chat"),o={task_id:i.task_id,query:i.query,files:i.files,mcp_list:i.mcp_list,chat_type:i.chat_type,pause_reason:i.pause_reason,task_run_mode:i.task_run_mode,expert_agent_run_config:i.expert_agent_run_config,scheduled_task_config:i.scheduled_task_config,disable_team_mode:i.disable_team_mode,resume_data:i.resume_data,ability_type:i.ability_type,all_authorized_mcp:i.all_authorized_mcp,reference_template_list:i.reference_template_list,agent_ids:i.agent_ids,router_control:i.router_control,favorites:i.favorites,extra_info:i.extra_info,reference_content:i.reference_content,guiding_id:i.guiding_id,skill_id_list:i.skill_id_list,is_skill_debug:i.is_skill_debug,thinking:i.thinking,reference_items:i.reference_items,plan_template_id:i.plan_template_id,action:i.action,assets:i.assets};return this.request({url:s,method:"POST",data:o},t)}PollStepList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/poll_step_list"),o={task_id:i.task_id,answer_id:i.answer_id,next_key:i.next_key};return this.request({url:s,method:"POST",data:o},t)}OperateTask(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/operate_task"),o={task_id:i.task_id,operate_type:i.operate_type,pause_reason:i.pause_reason,browser:i.browser,read_progress:i.read_progress,has_unread:i.has_unread};return this.request({url:s,method:"POST",data:o},t)}GetCozeSpaceTaskList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_task_list"),o={cursor:i.cursor,size:i.size,long_term:i.long_term};return this.request({url:s,method:"POST",data:o},t)}GetMessageList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_message_list"),o={task_id:i.task_id,cursor:i.cursor,size:i.size,asc_mode:i.asc_mode};return this.request({url:s,method:"POST",data:o},t)}UpdateTaskPlan(e,t){const i=e,s=this.genBaseURL("/api/coze_space/update_task_plan"),o={task_id:i.task_id,action_id:i.action_id,task_plan:i.task_plan};return this.request({url:s,method:"POST",data:o},t)}GetTaskReplayById(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_task_replay_by_id"),o={task_share_id:i.task_share_id,secret:i.secret};return this.request({url:s,method:"POST",data:o},t)}OperateTaskReplay(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/operate_task_replay"),o={task_id:i.task_id,task_share_id:i.task_share_id,operate_type:i.operate_type};return this.request({url:s,method:"POST",data:o},t)}UploadTaskFile(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/upload_task_file"),o={task_id:i.task_id,file_name:i.file_name,file_content:i.file_content};return this.request({url:s,method:"POST",data:o},t)}UploadUserResearchFile(e,t){const i=e,s=this.genBaseURL("/api/coze_space/upload_user_research_file"),o={task_id:i.task_id,action:i.action,file_type:i.file_type,file_name:i.file_name,file_content:i.file_content,desc:i.desc,fields:i.fields};return this.request({url:s,method:"POST",data:o},t)}LandingPageEmailSubscribe(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/landing_page/email_subscribe"),o={email:i.email};return this.request({url:s,method:"POST",data:o},t)}GetUrl(e,t){const i=e,s=this.genBaseURL("/api/coze_space/get_url"),o={uri:i.uri,expire_seconds:i.expire_seconds,is_short_url:i.is_short_url,uri_list:i.uri_list};return this.request({url:s,method:"POST",data:o},t)}LandingPage(e,t){const i=this.genBaseURL("/api/coze_space/landing_page");return this.request({url:i,method:"POST"},t)}ExpertProductDetails(e,t){const i=e,s=this.genBaseURL("/api/coze_space/expert_product_details"),o={agent_id:i.agent_id};return this.request({url:s,method:"POST",data:o},t)}Digg(e,t){const i=e,s=this.genBaseURL("/api/coze_space/digg"),o={agent_id:i.agent_id,action_type:i.action_type,is_cancel:i.is_cancel};return this.request({url:s,method:"POST",data:o},t)}SearchStock(e,t){const i=e,s=this.genBaseURL("/api/coze_space/search_stock"),o={search_type:i.search_type,stock_search_word:i.stock_search_word,sector_search_word:i.sector_search_word};return this.request({url:s,method:"POST",data:o},t)}Text2Image(e,t){const i=e,s=this.genBaseURL("/api/coze_space/text2image"),o={prompt:i.prompt,width:i.width,height:i.height};return this.request({url:s,method:"GET",params:o},t)}GetInviteInfo(e,t){const i=this.genBaseURL("/api/coze_space/get_invite_info");return this.request({url:i,method:"POST"},t)}CheckInviteCode(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/check_invite_code"),o={code:i.code};return this.request({url:s,method:"POST",data:o},t)}ExpertProductList(e,t){const i=this.genBaseURL("/api/coze_space/expert_product_list");return this.request({url:i,method:"POST"},t)}CheckInWaitList(e,t){const i=this.genBaseURL("/api/coze_space/check_in_wait_list");return this.request({url:i,method:"POST"},t)}JoinWaitList(e,t){const i=this.genBaseURL("/api/coze_space/join_wait_list");return this.request({url:i,method:"POST"},t)}GetSandboxToken(e,t){const i=e,s=this.genBaseURL("/api/coze_space/get_sandbox_token"),o={task_id:i.task_id,action_url_code:i.action_url_code};return this.request({url:s,method:"POST",data:o},t)}GetUserScheduledTasks(e,t){const i=this.genBaseURL("/api/coze_space/get_user_scheduled_tasks");return this.request({url:i,method:"POST"},t)}GenerateRelatedWords(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/generate_related_words"),o={original_word:i.original_word,describe:i.describe};return this.request({url:s,method:"POST",data:o},t)}CodeRepair(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/code_repair"),o={uri:i.uri,error_msg:i.error_msg};return this.request({url:s,method:"POST",data:o},t)}AuthorizedChannelMatch(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/authorized_channel_match"),o={web_rul:i.web_rul};return this.request({url:s,method:"POST",data:o},t)}UpdateTaskStatus(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/update_task_status"),o={agent_id:i.agent_id,sk:i.sk,task_id:i.task_id,task_status:i.task_status,result:i.result};return this.request({url:s,method:"POST",data:o},t)}GetWebUrl(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_web_url"),o={original_url:i.original_url,exchange_for_short_url:i.exchange_for_short_url,exchange_for_qr_code:i.exchange_for_qr_code,exchange_for_long_url:i.exchange_for_long_url};return this.request({url:s,method:"POST",data:o},t)}OperateSandbox(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/operate_sandbox"),o={task_id:i.task_id,action:i.action,delete_cookie_info:i.delete_cookie_info};return this.request({url:s,method:"POST",data:o},t)}UpdateTaskName(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/update_task_name"),o={agent_id:i.agent_id,sk:i.sk,task_id:i.task_id,task_name:i.task_name};return this.request({url:s,method:"POST",data:o},t)}GenDoc(e,t){const i=e,s=this.genBaseURL("/api/coze_space/gen_doc"),o={task_id:i.task_id,target_file_type:i.target_file_type,original_file_uri:i.original_file_uri,original_file_name:i.original_file_name,file_content:i.file_content};return this.request({url:s,method:"POST",data:o},t)}PreGetContractInfo(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/pre_get_contract_info"),o={file_content:i.file_content,task_id:i.task_id,file_name:i.file_name};return this.request({url:s,method:"POST",data:o},t)}GetContractCaseInfo(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_contract_case_info"),o={case_no:i.case_no};return this.request({url:s,method:"POST",data:o},t)}GetContractLawInfo(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_contract_law_info"),o={law:i.law,num:i.num};return this.request({url:s,method:"POST",data:o},t)}GetCozeSpaceUserInfo(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_user_info"),o={need_volcano_info:i.need_volcano_info,need_user_job_info:i.need_user_job_info,need_turn_off_user_data_management:i.need_turn_off_user_data_management,need_user_scenes:i.need_user_scenes,need_user_active_time:i.need_user_active_time,need_turn_off_ai_watermark:i.need_turn_off_ai_watermark,need_dnu_user:i.need_dnu_user,need_close_video_demo_project:i.need_close_video_demo_project,need_video_demo_project_account:i.need_video_demo_project_account};return this.request({url:s,method:"POST",data:o},t)}SearchCityInfo(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/search_city_info"),o={search_type:i.search_type,keyword:i.keyword};return this.request({url:s,method:"POST",data:o},t)}UpdateScheduledTask(e,t){const i=e,s=this.genBaseURL("/api/coze_space/update_scheduled_task"),o={scheduled_task_id:i.scheduled_task_id,task_type:i.task_type,status:i.status,scheduled_task_name:i.scheduled_task_name,trigger:i.trigger,mcp_tool_list:i.mcp_tool_list,expert_agent_config:i.expert_agent_config,task_plan:i.task_plan,is_need_try_run:i.is_need_try_run,description:i.description,task_id:i.task_id,daily_executed_at:i.daily_executed_at,task_plan_v2:i.task_plan_v2};return this.request({url:s,method:"POST",data:o},t)}GetScheduledTasks(e,t){const i=this.genBaseURL("/api/coze_space/get_scheduled_tasks");return this.request({url:i,method:"POST"},t)}TryRunScheduledTask(e,t){const i=e,s=this.genBaseURL("/api/coze_space/try_run_scheduled_task"),o={scheduled_task_id:i.scheduled_task_id};return this.request({url:s,method:"POST",data:o},t)}DeleteScheduledTask(e,t){const i=e,s=this.genBaseURL("/api/coze_space/delete_scheduled_task"),o={scheduled_task_id:i.scheduled_task_id};return this.request({url:s,method:"POST",data:o},t)}CreateScheduledTask(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/create_scheduled_task"),o={is_need_try_run:i.is_need_try_run,scheduled_task_name:i.scheduled_task_name,trigger:i.trigger,source_task_id:i.source_task_id,task_plan:i.task_plan,description:i.description,daily_executed_at:i.daily_executed_at,task_plan_v2:i.task_plan_v2};return this.request({url:s,method:"POST",data:o},t)}UpdateTeamInfo(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/update_team_info"),o={switch:i.switch};return this.request({url:s,method:"POST",data:o},t)}GetTeamInfo(e,t){const i=this.genBaseURL("/api/coze_space/get_team_info");return this.request({url:i,method:"POST"},t)}GetTaskInfo(e,t){const i=e,s=this.genBaseURL("/api/coze_space/get_task_info"),o={task_id:i.task_id};return this.request({url:s,method:"POST",data:o},t)}FeelGood(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/feel_good"),o={task_id:i.task_id,answer_id:i.answer_id,feel:i.feel,content:i.content};return this.request({url:s,method:"POST",data:o},t)}GetUserScheduledTaskQuota(e,t){const i=this.genBaseURL("/api/coze_space/get_scheduled_task_quota");return this.request({url:i,method:"POST"},t)}GetSingleScheduledTask(e,t){const i=e,s=this.genBaseURL("/api/coze_space/get_single_scheduled_task"),o={scheduled_task_id:i.scheduled_task_id};return this.request({url:s,method:"POST",data:o},t)}DeleteUserAuthorization(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/delete_user_authorization"),o={url:i.url,clear_arg:i.clear_arg};return this.request({url:s,method:"POST",data:o},t)}GetUserAuthorizationList(e,t){const i=this.genBaseURL("/api/coze_space/get_user_authorization_list");return this.request({url:i,method:"POST"},t)}AddUserAuthorization(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/add_user_authorization"),o={task_id:i.task_id,url:i.url,clear_arg:i.clear_arg,add_arg:i.add_arg};return this.request({url:s,method:"POST",data:o},t)}SearchFeelGood(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/search_feel_good"),o={task_id:i.task_id,answer_id:i.answer_id};return this.request({url:s,method:"POST",data:o},t)}GetAuthorizedChannelList(e,t){const i=this.genBaseURL("/api/coze_space/get_authorized_channel_list");return this.request({url:i,method:"GET"},t)}GetTaskExample(e,t){const i=e,s=this.genBaseURL("/api/coze_space/get_task_example"),o={task_example_id:i.task_example_id};return this.request({url:s,method:"POST",data:o},t)}AdminListTaskExample(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/list_task_example"),o={size:i.size,page:i.page,task_ids:i.task_ids,category_id:i.category_id,ability_type:i.ability_type,status:i.status};return this.request({url:s,method:"POST",data:o},t)}AdminDeleteTaskExample(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/delete_task_example"),o={example_id:i.example_id};return this.request({url:s,method:"POST",data:o},t)}UpdateCozeSpaceUserInfo(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/update_user_info"),o={job_id:i.job_id,turn_off_user_data_management:i.turn_off_user_data_management,scene_ids:i.scene_ids,turn_off_ai_watermark:i.turn_off_ai_watermark,close_video_demo_project:i.close_video_demo_project,video_demo_project_account:i.video_demo_project_account};return this.request({url:s,method:"POST",data:o},t)}GetTaskExampleList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_task_example_list"),o={category_id:i.category_id,page_size:i.page_size,page:i.page,ability_type:i.ability_type,scene_ids:i.scene_ids};return this.request({url:s,method:"POST",data:o},t)}AdminCreateTaskExample(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/create_task_example"),o={task_id:i.task_id,example_name:i.example_name,example_description:i.example_description,icon_uri:i.icon_uri,index:i.index,category_id:i.category_id,user_query:i.user_query,share_id:i.share_id,ability_type:i.ability_type,open_app_use:i.open_app_use,app_title:i.app_title,official_recommend:i.official_recommend,file_type:i.file_type,type:i.type,close_make_same:i.close_make_same,product_info:i.product_info,api_template_type:i.api_template_type,attachment_files:i.attachment_files};return this.request({url:s,method:"POST",data:o},t)}AdminUpdateTaskExample(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/update_task_example"),o={example_id:i.example_id,example_name:i.example_name,example_description:i.example_description,icon_uri:i.icon_uri,index:i.index,category_id:i.category_id,user_query:i.user_query,status:i.status,ability_type:i.ability_type,open_app_use:i.open_app_use,app_title:i.app_title,official_recommend:i.official_recommend,type:i.type,close_make_same:i.close_make_same,product_info:i.product_info,file_type:i.file_type,api_template_type:i.api_template_type,attachment_files:i.attachment_files};return this.request({url:s,method:"POST",data:o},t)}GetTaskExampleCategory(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_task_example_category"),o={ability_type:i.ability_type};return this.request({url:s,method:"GET",params:o},t)}GetUserJobList(e,t){const i=this.genBaseURL("/api/coze_space/get_user_job_list");return this.request({url:i,method:"GET"},t)}AdminParseTaskShareURL(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/parse_task_share_url"),o={share_url:i.share_url};return this.request({url:s,method:"POST",data:o},t)}GetAppInfo(e,t){const i=this.genBaseURL("/api/coze_space/get_app_info");return this.request({url:i,method:"GET"},t)}AdminGetTaskExampleCategory(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/get_task_example_category"),o={ability_type:i.ability_type};return this.request({url:s,method:"GET",params:o},t)}AdminUploadFile(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/upload_task_file"),o={file_name:i.file_name,file_content:i.file_content,scene:i.scene};return this.request({url:s,method:"POST",data:o},t)}UpdateFileContent(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/update_file_content"),o={task_id:i.task_id,file_uri:i.file_uri,file_content:i.file_content};return this.request({url:s,method:"POST",data:o},t)}ExportPPTAgentFile(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/export_ppt_agent_file"),o={source_uri:i.source_uri,task_id:i.task_id,export_type:i.export_type};return this.request({url:s,method:"POST",data:o},t)}RestoreExampleFile(e,t){const i=e,s=this.genBaseURL("/api/coze_space/restore_example_file"),o={task_id:i.task_id,example_id:i.example_id,product:i.product};return this.request({url:s,method:"POST",data:o},t)}GetHtmlHeightFix(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_html_height_fix"),o={code:i.code};return this.request({url:s,method:"POST",data:o},t)}PollMessages(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/poll_messages"),o={start_next_key:i.start_next_key};return this.request({url:s,method:"GET",params:o},t)}OperatePausedTask(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/operate_paused_task"),o={task_id:i.task_id,pause_reason:i.pause_reason};return this.request({url:s,method:"POST",data:o},t)}GetFrontierKey(e,t){const i=this.genBaseURL("/api/coze_space/get_frontier_key");return this.request({url:i,method:"GET"},t)}SearchImage(e,t){const i=e,s=this.genBaseURL("/api/coze_space/search_image"),o={query:i.query,count:i.count};return this.request({url:s,method:"POST",data:o},t)}GetUserExpertList(e,t){const i=this.genBaseURL("/api/coze_space/get_user_expert_list");return this.request({url:i,method:"POST"},t)}OperateUserExpert(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/operate_user_expert"),o={agent_id:i.agent_id,operate_type:i.operate_type};return this.request({url:s,method:"POST",data:o},t)}GetHotQuery(e,t){const i=this.genBaseURL("/api/coze_space/get_hot_query");return this.request({url:i,method:"POST"},t)}ImageDownload(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/download_image"),o={image_infos:i.image_infos,download_type:i.download_type};return this.request({url:s,method:"POST",data:o},t)}ImageEdit(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/edit_image"),o={edit_type:i.edit_type,image_url:i.image_url,query:i.query,count:i.count,task_id:i.task_id};return this.request({url:s,method:"POST",data:o},t)}CreateImageCopy(e,t){const i=e,s=this.genBaseURL("/api/coze_space/create_image_copy"),o={task_id:i.task_id,image_path:i.image_path,source_image_url:i.source_image_url};return this.request({url:s,method:"POST",data:o},t)}GetLatestImagesWithID(e,t){const i=e,s=this.genBaseURL("/api/coze_space/get_latest_images_with_id"),o={task_id:i.task_id,image_paths:i.image_paths};return this.request({url:s,method:"POST",data:o},t)}AdminCreateTaskExampleCategory(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/create_task_example_category"),o={name:i.name,ability_type:i.ability_type,index:i.index,job_ids:i.job_ids,scene_ids:i.scene_ids};return this.request({url:s,method:"POST",data:o},t)}AdminDeleteTaskExampleCategory(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/delete_task_example_category"),o={category_id:i.category_id};return this.request({url:s,method:"POST",data:o},t)}AdminUpdateTaskExampleCategory(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/update_task_example_category"),o={category_id:i.category_id,name:i.name,index:i.index,job_ids:i.job_ids,scene_ids:i.scene_ids};return this.request({url:s,method:"POST",data:o},t)}BatchHtmlToImage(e,t){const i=e,s=this.genBaseURL("/api/coze_space/batch_html_to_image"),o={task_id:i.task_id,html_uri:i.html_uri,device_info:i.device_info,screenshot_info:i.screenshot_info};return this.request({url:s,method:"POST",data:o},t)}GetAppTaskExampleList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_app_task_example_list"),o={ability_type:i.ability_type,need_official_recommended:i.need_official_recommended};return this.request({url:s,method:"POST",data:o},t)}GenCover(e,t){const i=e,s=this.genBaseURL("/api/coze_space/gen_cover"),o={task_id:i.task_id,original_file_uri:i.original_file_uri,resolution:i.resolution,mode:i.mode,selector_str:i.selector_str,task_share_url:i.task_share_url};return this.request({url:s,method:"POST",data:o},t)}CopyResource(e,t){const i=e,s=this.genBaseURL("/api/coze_space/copy_resource"),o={new_task_id:i.new_task_id,uri_list:i.uri_list};return this.request({url:s,method:"POST",data:o},t)}BatchUpdateImage(e,t){const i=e,s=this.genBaseURL("/api/coze_space/batch_update_image"),o={task_id:i.task_id,image_info_list:i.image_info_list};return this.request({url:s,method:"POST",data:o},t)}Text2Json(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/text2json"),o={text:i.text,type:i.type};return this.request({url:s,method:"POST",data:o},t)}EditImageWithMsg(e,t){const i=e,s=this.genBaseURL("/api/coze_space/edit_image_with_msg"),o={task_id:i.task_id,source_image_info:i.source_image_info,edit_type:i.edit_type,query:i.query,edit_info:i.edit_info};return this.request({url:s,method:"POST",data:o},t)}GetASRToken(e,t){const i=this.genBaseURL("/api/coze_space/get_asr_token");return this.request({url:i,method:"GET"},t)}QueryRewriting(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/query_rewriting"),o={query:i.query};return this.request({url:s,method:"POST",data:o},t)}GetShortcutCommand(e,t){const i=e,s=this.genBaseURL("/api/coze_space/get_shortcut_command"),o={ability_type:i.ability_type,need_general_data:i.need_general_data};return this.request({url:s,method:"POST",data:o},t)}ClickPopup(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/click_popup"),o={id:i.id};return this.request({url:s,method:"POST",data:o},t)}GetPopupInfo(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_popup_info"),o={ability_type:i.ability_type};return this.request({url:s,method:"POST",data:o},t)}AdminCreateExampleDatabaseData(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/create_example_database_data"),o={data:i.data};return this.request({url:s,method:"POST",data:o},t)}AdminUpdateShortcutCommand(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/update_shortcut_command"),o={id:i.id,title:i.title,app_title:i.app_title,query:i.query,action_type:i.action_type,open_pc:i.open_pc,open_app:i.open_app,job_id:i.job_id,open_time:i.open_time,expire_time:i.expire_time};return this.request({url:s,method:"POST",data:o},t)}AdminCreateShortcutCommand(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/create_shortcut_command"),o={ability_type:i.ability_type,title:i.title,app_title:i.app_title,query:i.query,action_type:i.action_type,open_pc:i.open_pc,open_app:i.open_app,job_id:i.job_id,expire_time:i.expire_time};return this.request({url:s,method:"POST",data:o},t)}AdminGetShortcutCommandList(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/get_shortcut_command_list"),o={size:i.size,ability_type:i.ability_type,page:i.page,open_pc:i.open_pc,open_app:i.open_app,job_id:i.job_id};return this.request({url:s,method:"POST",data:o},t)}AdminDeleteShortcutCommand(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/delete_shortcut_command"),o={id:i.id};return this.request({url:s,method:"POST",data:o},t)}AdminSyncCrawl(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/sync_crawl"),o={req:i.req,upload:i.upload};return this.request({url:s,method:"POST",data:o},t)}AdminGetUserJobList(e,t){const i=this.genBaseURL("/api/coze_space/admin/get_user_job_list");return this.request({url:i,method:"GET"},t)}AdminListTemplate(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/list_template"),o={size:i.size,page:i.page,template_ids:i.template_ids,category_ids:i.category_ids,ability_type:i.ability_type,template_name:i.template_name};return this.request({url:s,method:"POST",data:o},t)}AdminCreateTemplate(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/create_template"),o={ability_type:i.ability_type,category_id:i.category_id,web_template_conf:i.web_template_conf,template_labels:i.template_labels,original_query:i.original_query,query_template:i.query_template,template_words:i.template_words,open_app_use:i.open_app_use,app_template_conf:i.app_template_conf,template_files:i.template_files,reference_info:i.reference_info,api_template_type:i.api_template_type,tags:i.tags};return this.request({url:s,method:"POST",data:o},t)}AdminUpdateTemplate(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/update_template"),o={template_id:i.template_id,ability_type:i.ability_type,category_id:i.category_id,web_template_conf:i.web_template_conf,template_labels:i.template_labels,original_query:i.original_query,query_template:i.query_template,template_words:i.template_words,open_app_use:i.open_app_use,app_template_conf:i.app_template_conf,index:i.index,is_selected:i.is_selected,template_files:i.template_files,reference_info:i.reference_info,api_template_type:i.api_template_type,tags:i.tags};return this.request({url:s,method:"POST",data:o},t)}AdminDeleteTemplate(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/delete_template"),o={template_id:i.template_id};return this.request({url:s,method:"POST",data:o},t)}GetTemplateList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_template_list"),o={category_id:i.category_id,page_size:i.page_size,page:i.page,ability_type:i.ability_type};return this.request({url:s,method:"POST",data:o},t)}GetAppTemplateList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_app_template_list"),o={ability_type:i.ability_type};return this.request({url:s,method:"POST",data:o},t)}GetTemplate(e,t){const i=e,s=this.genBaseURL("/api/coze_space/get_template_info"),o={template_id:i.template_id};return this.request({url:s,method:"POST",data:o},t)}GetActivityInfo(e,t){const i=this.genBaseURL("/api/coze_space/activity/info");return this.request({url:i,method:"GET"},t)}BindRelation(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/activity/bind"),o={code:i.code};return this.request({url:s,method:"POST",data:o},t)}GetInviteCode(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/activity/invite_code"),o={activity_id:i.activity_id};return this.request({url:s,method:"POST",data:o},t)}GetInviteRecords(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/activity/invite_records"),o={activity_id:i.activity_id};return this.request({url:s,method:"POST",data:o},t)}RollbackFileVersion(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/rollback_file_version"),o={task_id:i.task_id,file_name:i.file_name,target_version:i.target_version};return this.request({url:s,method:"POST",data:o},t)}GetFileVersionInfo(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_file_version_info"),o={task_id:i.task_id,file_name:i.file_name,long_term_plan:i.long_term_plan};return this.request({url:s,method:"POST",data:o},t)}AdminMDelUri(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/mdel_uri"),o={uris:i.uris,urls:i.urls};return this.request({url:s,method:"POST",data:o},t)}AdminDeleteSEMUrl(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/delete_sem_url"),o={id:i.id};return this.request({url:s,method:"POST",data:o},t)}AdminCreateSEMUrl(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/create_sem_url"),o={experiment_url:i.experiment_url,compare_url:i.compare_url,description:i.description};return this.request({url:s,method:"POST",data:o},t)}AdminListSEMUrl(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/list_sem_url"),o={size:i.size,page:i.page};return this.request({url:s,method:"POST",data:o},t)}AdminUpdateSEMUrl(e,t){const i=e,s=this.genBaseURL("/api/coze_space/admin/update_sem_url"),o={id:i.id,experiment_url:i.experiment_url,compare_url:i.compare_url,description:i.description};return this.request({url:s,method:"POST",data:o},t)}GetSEMUrl(e,t){const i=e,s=this.genBaseURL("/api/coze_space/get_sem_url"),o={id:i.id};return this.request({url:s,method:"POST",data:o},t)}ClickCompetitionLikes(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/click_competition_likes"),o={competition_task_id:i.competition_task_id,is_like:i.is_like};return this.request({url:s,method:"POST",data:o},t)}SubmitCompetitionTask(e,t){const i=e,s=this.genBaseURL("/api/coze_space/submit_competition_task"),o={task_id:i.task_id,product_url:i.product_url,title:i.title,cover_uri:i.cover_uri,competition_id:i.competition_id};return this.request({url:s,method:"POST",data:o},t)}GetCompetitionInfo(e,t){const i=this.genBaseURL("/api/coze_space/get_competition_info");return this.request({url:i,method:"POST"},t)}GetCompetitionTaskList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_competition_task_list"),o={page_size:i.page_size,cursor:i.cursor,is_create_sorted:i.is_create_sorted,search_title:i.search_title,competition_id:i.competition_id};return this.request({url:s,method:"POST",data:o},t)}FavoriteList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/favorites/list"),o={tag_ids:i.tag_ids,name:i.name,need_untagged:i.need_untagged,size:i.size,cursor:i.cursor,exclude_content_types:i.exclude_content_types};return this.request({url:s,method:"POST",data:o},t)}DeleteTags(e,t){const i=e,s=this.genBaseURL("/api/coze_space/favorites/delete_tags"),o={ids:i.ids};return this.request({url:s,method:"POST",data:o},t)}DeleteFavorites(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/favorites/delete"),o={ids:i.ids,related_uris:i.related_uris};return this.request({url:s,method:"POST",data:o},t)}BatchGetFavoriteInfo(e,t){const i=e,s=this.genBaseURL("/api/coze_space/favorites/batch_get_info"),o={favorite_ids:i.favorite_ids};return this.request({url:s,method:"POST",data:o},t)}UpdateFavoriteInfo(e,t){const i=e,s=this.genBaseURL("/api/coze_space/favorites/update"),o={id:i.id,tag_ids:i.tag_ids};return this.request({url:s,method:"POST",data:o},t)}GetTagList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/favorites/get_tag_list"),o={tag_ids:i.tag_ids,tag_name:i.tag_name};return this.request({url:s,method:"POST",data:o},t)}CreateTags(e,t){const i=e,s=this.genBaseURL("/api/coze_space/favorites/create_tag"),o={tag_name:i.tag_name,tag_desc:i.tag_desc,favorite_info_list:i.favorite_info_list};return this.request({url:s,method:"POST",data:o},t)}AddFavorite(e,t){const i=e,s=this.genBaseURL("/api/coze_space/favorites/add"),o={title:i.title,content_uri:i.content_uri,content_text:i.content_text,tag_ids:i.tag_ids,source:i.source,scene:i.scene,product_type:i.product_type};return this.request({url:s,method:"POST",data:o},t)}UpdateTags(e,t){const i=e,s=this.genBaseURL("/api/coze_space/favorites/update_tag"),o={tag_id:i.tag_id,tag_name:i.tag_name,tag_desc:i.tag_desc};return this.request({url:s,method:"POST",data:o},t)}GetMyCompetitionTaskList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_my_competition_task_list"),o={page_size:i.page_size,cursor:i.cursor,competition_id:i.competition_id};return this.request({url:s,method:"POST",data:o},t)}AdminGetUserScenes(e,t){const i=this.genBaseURL("/api/coze_space/admin/get_user_scenes");return this.request({url:i,method:"GET"},t)}GetUserScenes(e,t){const i=this.genBaseURL("/api/coze_space/get_user_scenes");return this.request({url:i,method:"GET"},t)}GetDeepWritingConf(e,t){const i=this.genBaseURL("/api/coze_space/get_deep_writing_conf");return this.request({url:i,method:"GET"},t)}GetCompetitionTask(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_competition_task"),o={competition_task_id:i.competition_task_id};return this.request({url:s,method:"POST",data:o},t)}GetUnreadCount(e,t){const i=this.genBaseURL("/api/coze_space/get_unread_count");return this.request({url:i,method:"POST"},t)}BatchHtmlCodeToImage(e,t){const i=e,s=this.genBaseURL("/api/coze_space/batch_html_code_to_image"),o={task_id:i.task_id,html_code:i.html_code,device_info:i.device_info,screenshot_info:i.screenshot_info,zip:i.zip};return this.request({url:s,method:"POST",data:o},t)}GenDocMultiImageMaterial(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/gen_doc_multi_image_material"),o={task_id:i.task_id,file_uri:i.file_uri};return this.request({url:s,method:"POST",data:o},t)}GetDerivedProduct(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_derived_product"),o={task_id:i.task_id,derived_product_type:i.derived_product_type};return this.request({url:s,method:"POST",data:o},t)}SaveDerivedProduct(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/save_derived_product"),o={task_id:i.task_id,derived_product:i.derived_product};return this.request({url:s,method:"POST",data:o},t)}TagFavorites(e,t){const i=e,s=this.genBaseURL("/api/coze_space/favorites/tag_favorites"),o={tag_name:i.tag_name,tag_desc:i.tag_desc};return this.request({url:s,method:"POST",data:o},t)}SuggestQuery(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/suggest_query"),o={query:i.query,image_urls:i.image_urls};return this.request({url:s,method:"POST",data:o},t)}BatchGetUrl(e,t){const i=e,s=this.genBaseURL("/api/coze_space/batch_get_url"),o={uri_list:i.uri_list,expire_seconds:i.expire_seconds,is_short_url:i.is_short_url};return this.request({url:s,method:"POST",data:o},t)}UploadFile(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/upload_file"),o={file_name:i.file_name,file_content:i.file_content,scene:i.scene};return this.request({url:s,method:"POST",data:o},t)}BatchGetFavorite(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/favorites/get_count"),o={file_uris:i.file_uris};return this.request({url:s,method:"POST",data:o},t)}GetEarliestQuery(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_earliest_query"),o={task_id:i.task_id};return this.request({url:s,method:"POST",data:o},t)}GetMappingUri(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_mapping_uri"),o={uri:i.uri};return this.request({url:s,method:"POST",data:o},t)}ApiTemplate(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/api_template"),o={prompt:i.prompt,files:i.files,type:i.type,task_id:i.task_id,template_id:i.template_id};return this.request({url:s,method:"POST",data:o},t)}BatchGetMultiMedia(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/batch_get_multimedia"),o={media_uris:i.media_uris};return this.request({url:s,method:"POST",data:o},t)}AdminBatchGetMultiMedia(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/batch_get_multimedia"),o={media_uris:i.media_uris};return this.request({url:s,method:"POST",data:o},t)}AdminCreateMultiMedia(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/create_multimedia"),o={task_id:i.task_id,media_path:i.media_path,media_uri:i.media_uri,media_url:i.media_url,image_type:i.image_type,media_ext:i.media_ext};return this.request({url:s,method:"POST",data:o},t)}GetPodcastConfig(e,t){const i=this.genBaseURL("/api/coze_space/get_podcast_config");return this.request({url:i,method:"POST"},t)}IntentRecognition(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/intent_recognition"),o={task_id:i.task_id,files:i.files,ability_type:i.ability_type,query:i.query};return this.request({url:s,method:"POST",data:o},t)}ListTemplate(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/list_template"),o={size:i.size,cursor:i.cursor,tags:i.tags,ability_type:i.ability_type,api_template_type:i.api_template_type};return this.request({url:s,method:"POST",data:o},t)}AdminGetTagsByImages(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/get_tags_by_images"),o={images:i.images,query:i.query,scene:i.scene};return this.request({url:s,method:"POST",data:o},t)}GetTagsByImages(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_tags_by_images"),o={images:i.images,query:i.query,scene:i.scene};return this.request({url:s,method:"POST",data:o},t)}AdminCreateTemplateImage(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/create_template_image"),o={image:i.image,tags:i.tags};return this.request({url:s,method:"POST",data:o},t)}ReportSubmit(e,t){const i=e,s=this.genBaseURL("/api/coze_space/report_submit"),o={object_type:i.object_type,object_id:i.object_id,report_detail:i.report_detail};return this.request({url:s,method:"POST",data:o},t)}ListBotChatMessages(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/list_bot_chat_message"),o={bot_chat_type:i.bot_chat_type,cursor:i.cursor,size:i.size};return this.request({url:s,method:"POST",data:o},t)}BotChatWithType(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/bot_chat_with_type"),o={bot_chat_type:i.bot_chat_type,query:i.query};return this.request({url:s,method:"POST",data:o},t)}GenImage(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/gen_image"),o={task_id:i.task_id,project_id:i.project_id,prompt:i.prompt,count:i.count,video_project_uri:i.video_project_uri,image_url:i.image_url,base_image_urls:i.base_image_urls,skip_save_material:i.skip_save_material,coze_claw_session_id:i.coze_claw_session_id,coze_claw_conversion_id:i.coze_claw_conversion_id};return this.request({url:s,method:"POST",data:o},t)}UploadVideoResource(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/upload_video_resource"),o={task_id:i.task_id,project_id:i.project_id,file_name:i.file_name,file_content:i.file_content,video_project_uri:i.video_project_uri,skip_save_material:i.skip_save_material,coze_claw_session_id:i.coze_claw_session_id,coze_claw_conversion_id:i.coze_claw_conversion_id};return this.request({url:s,method:"POST",data:o},t)}GetVideoConfig(e,t){const i=this.genBaseURL("/api/coze_space/video/get_video_config");return this.request({url:i,method:"POST"},t)}GetCozeSpaceDeviceInfo(e,t){const i=this.genBaseURL("/api/coze_space/get_device_info");return this.request({url:i,method:"POST"},t)}AdminMDeleteReferenceImage(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/mdelete_reference_image"),o={ids:i.ids};return this.request({url:s,method:"POST",data:o},t)}AdminMDeleteTemplateImage(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/mdelete_template_image"),o={ids:i.ids};return this.request({url:s,method:"POST",data:o},t)}AdminListReferenceImage(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/list_reference_image"),o={size:i.size,cursor:i.cursor,tag:i.tag};return this.request({url:s,method:"POST",data:o},t)}AdminListRewriteImage(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/list_rewrite_image"),o={size:i.size,cursor:i.cursor,tag:i.tag};return this.request({url:s,method:"POST",data:o},t)}AdminCreateReferenceImage(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/create_reference_image"),o={tag:i.tag,image:i.image};return this.request({url:s,method:"POST",data:o},t)}AdminTemplateRewrite(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/template_rewrite"),o={template_image_ids:i.template_image_ids,rewrite_image_id:i.rewrite_image_id};return this.request({url:s,method:"POST",data:o},t)}AdminMDeleteRewriteImage(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/mdelete_rewrite_image"),o={ids:i.ids};return this.request({url:s,method:"POST",data:o},t)}AdminListTemplateImage(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/list_template_image"),o={size:i.size,cursor:i.cursor,tags:i.tags};return this.request({url:s,method:"POST",data:o},t)}AdminUpdateRewriteImage(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/update_rewrite_image"),o={id:i.id,rewrite_result:i.rewrite_result};return this.request({url:s,method:"POST",data:o},t)}GetGuidingMessage(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_guiding_message"),o={guiding_id:i.guiding_id};return this.request({url:s,method:"POST",data:o},t)}AdminListImageTag(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/list_image_tag"),o={size:i.size,cursor:i.cursor};return this.request({url:s,method:"POST",data:o},t)}UpdateProject(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video_volc_proxy/update_project"),o={GroupId:i.GroupId,ProjectId:i.ProjectId,LatestEditParam:i.LatestEditParam,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri,coze_claw_session_id:i.coze_claw_session_id,coze_claw_conversion_id:i.coze_claw_conversion_id};return this.request({url:s,method:"POST",data:o},t)}DescribeProject(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video_volc_proxy/describe_project"),o={GroupId:i.GroupId,ProjectId:i.ProjectId,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri,coze_claw_session_id:i.coze_claw_session_id,coze_claw_conversion_id:i.coze_claw_conversion_id};return this.request({url:s,method:"POST",data:o},t)}SubmitEditTaskAsync(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video_volc_proxy/submit_edit_task_async"),o={GroupId:i.GroupId,ProjectId:i.ProjectId,ProjectType:i.ProjectType,EditParam:i.EditParam,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri,ignore_edit_param:i.ignore_edit_param,coze_claw_session_id:i.coze_claw_session_id,coze_claw_conversion_id:i.coze_claw_conversion_id};return this.request({url:s,method:"POST",data:o},t)}BatchGetVideoPlayInfo(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video_volc_proxy/batch_get_video_play_info"),o={vids:i.vids,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri};return this.request({url:s,method:"POST",data:o},t)}GetDirectEditProgress(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video_volc_proxy/get_direct_edit_progress"),o={ReqId:i.ReqId,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri,coze_claw_session_id:i.coze_claw_session_id,coze_claw_conversion_id:i.coze_claw_conversion_id};return this.request({url:s,method:"POST",data:o},t)}SearchEditMaterial(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video_volc_proxy/search_edit_material"),o={ProjectId:i.ProjectId,EditMids:i.EditMids,Space:i.Space,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri,coze_claw_session_id:i.coze_claw_session_id,coze_claw_conversion_id:i.coze_claw_conversion_id};return this.request({url:s,method:"POST",data:o},t)}ListSnapshots(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video_volc_proxy/list_snapshots"),o={ProjectId:i.ProjectId,Vid:i.Vid,coze_space_task_id:i.coze_space_task_id,coze_space_video_project_uri:i.coze_space_video_project_uri,coze_claw_session_id:i.coze_claw_session_id,coze_claw_conversion_id:i.coze_claw_conversion_id};return this.request({url:s,method:"POST",data:o},t)}AdminUpdateTemplateImage(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/update_reference_image"),o={id:i.id,tags:i.tags};return this.request({url:s,method:"POST",data:o},t)}VolcVodCallback(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/volc_vod_callback"),o={RequestId:i.RequestId,Version:i.Version,EventType:i.EventType,EventTime:i.EventTime};return this.request({url:s,method:"POST",data:o},t)}AdminDeleteVideoTextStyle(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/delete_video_text_style"),o={id:i.id};return this.request({url:s,method:"POST",data:o},t)}AdminListVideoTextStyle(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/list_video_text_style"),o={size:i.size,cursor:i.cursor};return this.request({url:s,method:"POST",data:o},t)}AdminSaveVideoTextStyle(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/save_video_text_style"),o={video_text_style:i.video_text_style};return this.request({url:s,method:"POST",data:o},t)}GetMusicList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/get_music_list"),o={size:i.size,cursor:i.cursor};return this.request({url:s,method:"POST",data:o},t)}ListVideoTextStyle(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/list_video_text_style"),o={size:i.size,cursor:i.cursor};return this.request({url:s,method:"POST",data:o},t)}GetMessageMeta(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_message_meta"),o={task_id:i.task_id};return this.request({url:s,method:"GET",params:o},t)}AdminRunWorkflow(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/run_workflow"),o={id:i.id,input:i.input};return this.request({url:s,method:"POST",data:o},t)}QueryGenResourceStatus(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/query_gen_resource_status"),o={task_id:i.task_id,project_id:i.project_id,video_project_uri:i.video_project_uri,gen_resource_task_id:i.gen_resource_task_id,coze_claw_session_id:i.coze_claw_session_id,coze_claw_conversion_id:i.coze_claw_conversion_id};return this.request({url:s,method:"POST",data:o},t)}GenResourceAsync(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/gen_resource_async"),o={task_id:i.task_id,project_id:i.project_id,video_project_uri:i.video_project_uri,gen_resource_type:i.gen_resource_type,gen_video_req_payload:i.gen_video_req_payload,gen_voice_audio_req_payload:i.gen_voice_audio_req_payload,gen_music_req_payload:i.gen_music_req_payload,skip_save_material:i.skip_save_material,coze_claw_session_id:i.coze_claw_session_id,coze_claw_conversion_id:i.coze_claw_conversion_id};return this.request({url:s,method:"POST",data:o},t)}GetTaskItemList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/get_task_item_list"),o={task_id:i.task_id,item_ids:i.item_ids,start_time:i.start_time,end_time:i.end_time};return this.request({url:s,method:"POST",data:o},t)}CancelGenResourceTask(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/cancel_gen_resource_task"),o={task_id:i.task_id,project_id:i.project_id,video_project_uri:i.video_project_uri,gen_resource_task_id:i.gen_resource_task_id,coze_claw_session_id:i.coze_claw_session_id,coze_claw_conversion_id:i.coze_claw_conversion_id};return this.request({url:s,method:"POST",data:o},t)}AdminUpdateTemplateTagsFromCSV(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/update_template_tags_from_csv"),o={is_run_wf:i.is_run_wf,is_update:i.is_update,tos_path:i.tos_path};return this.request({url:s,method:"POST",data:o},t)}GetPlanTemplates(e,t){const i=this.genBaseURL("/api/coze_space/get_plan_templates");return this.request({url:i,method:"POST"},t)}DeleteTaskFile(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/delete_task_file"),o={id:i.id};return this.request({url:s,method:"POST",data:o},t)}ListTaskFile(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/list_task_file"),o={task_id:i.task_id,size:i.size,cursor:i.cursor,plan_file:i.plan_file};return this.request({url:s,method:"POST",data:o},t)}GenPodcastStream(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/gen_podcast"),o={cache_key:i.cache_key};return this.request({url:s,method:"POST",data:o},t)}AdminTemplateTypeIntentBG(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/admin/template_type_intent_bg"),o={files:i.files};return this.request({url:s,method:"POST",data:o},t)}ExportImagePPT(e,t){const i=e,s=this.genBaseURL("/api/coze_space/export_image_ppt_agent_file"),o={task_id:i.task_id,title:i.title,pages:i.pages,export_type:i.export_type};return this.request({url:s,method:"POST",data:o},t)}ExportProject(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/export_project"),o={task_id:i.task_id,project_id:i.project_id,video_project_uri:i.video_project_uri,coze_claw_session_id:i.coze_claw_session_id,coze_claw_conversion_id:i.coze_claw_conversion_id};return this.request({url:s,method:"POST",data:o},t)}GetModelConfig(e,t){const i=this.genBaseURL("/api/coze_space/get_model_config");return this.request({url:i,method:"POST"},t)}ConfirmPlan(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/confirm_plan"),o={task_id:i.task_id};return this.request({url:s,method:"POST",data:o},t)}GetUserSkillAuthorizationInfo(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/skill/get_user_skill_authorization_info"),o={credential_id:i.credential_id};return this.request({url:s,method:"POST",data:o},t)}UpdateCozeUserNickname(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/update_user_nickname"),o={nickname:i.nickname};return this.request({url:s,method:"POST",data:o},t)}CreateCozeUserJobName(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/create_user_job_name"),o={job_name:i.job_name};return this.request({url:s,method:"POST",data:o},t)}EnterpriseCustomer(e,t){const i=this.genBaseURL("/api/coze_space/enterprise_customer");return this.request({url:i,method:"POST"},t)}CreateVideoAsset(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/asset/create_video_asset"),o={base_info:i.base_info,details:i.details};return this.request({url:s,method:"POST",data:o},t)}UpdateVideoAsset(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/asset/update_video_asset"),o={asset_id:i.asset_id,base_info:i.base_info,details:i.details};return this.request({url:s,method:"POST",data:o},t)}DeleteVideoAsset(e,t){const i=e,s=this.genBaseURL("/api/coze_space/video/asset/delete_video_asset"),o={asset_id:i.asset_id};return this.request({url:s,method:"POST",data:o},t)}UpdateVideoProduction(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/production/update_video_production"),o={video_production:i.video_production,ratio:i.ratio};return this.request({url:s,method:"POST",data:o},t)}CreateVideoProduction(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/production/create_video_production"),o={video_production:i.video_production,ratio:i.ratio};return this.request({url:s,method:"POST",data:o},t)}VideoProductionMaterialList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/material/video_material_list"),o={production_id:i.production_id,tag_category:i.tag_category,type_category:i.type_category,page:i.page,size:i.size,need_detail_url:i.need_detail_url,session_id:i.session_id,conversation_id:i.conversation_id,search_word:i.search_word,not_need_cvs_or_cvp:i.not_need_cvs_or_cvp};return this.request({url:s,method:"POST",data:o},t)}VideoAssetDetail(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/asset/video_asset_detail"),o={asset_id:i.asset_id};return this.request({url:s,method:"POST",data:o},t)}VideoProductionMaterialDetail(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/material/video_material_detail"),o={material_id:i.material_id};return this.request({url:s,method:"POST",data:o},t)}DeleteVideoProductionMaterial(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/material/delete_video_material"),o={material_id:i.material_id};return this.request({url:s,method:"POST",data:o},t)}CreateVideoProductionMaterial(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/material/create_video_material"),o={production_id:i.production_id,base_info:i.base_info,details:i.details,asset_id:i.asset_id,session_id:i.session_id,conversation_id:i.conversation_id};return this.request({url:s,method:"POST",data:o},t)}UpdateVideoProductionMaterial(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/material/update_video_material"),o={material_id:i.material_id,material_update_type:i.material_update_type,base_info:i.base_info,details:i.details};return this.request({url:s,method:"POST",data:o},t)}DeleteVideoProduction(e,t){const i=e,s=this.genBaseURL("/api/coze_space/video/production/delete_video_production"),o={production_id:i.production_id};return this.request({url:s,method:"POST",data:o},t)}VideoAssetList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/asset/video_asset_list"),o={tag_category:i.tag_category,type_category:i.type_category,page:i.page,size:i.size,search_word:i.search_word,need_detail_url:i.need_detail_url};return this.request({url:s,method:"POST",data:o},t)}VideoProductionList(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/production/video_production_list"),o={page:i.page,size:i.size};return this.request({url:s,method:"POST",data:o},t)}OperateVideoProduction(e,t){const i=e,s=this.genBaseURL("/api/coze_space/video/production/operate_video_production"),o={production_id:i.production_id,operate_type:i.operate_type};return this.request({url:s,method:"POST",data:o},t)}OperateVideoAsset(e,t){const i=e,s=this.genBaseURL("/api/coze_space/video/asset/operate_video_asset"),o={asset_id:i.asset_id,operate_type:i.operate_type};return this.request({url:s,method:"POST",data:o},t)}BatchParseVideoAsset(e,t){const i=e,s=this.genBaseURL("/api/coze_space/video/asset/batch_parse_video_asset"),o={vids:i.vids};return this.request({url:s,method:"POST",data:o},t)}GetFileLock(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/file_lock/get"),o={project_id:i.project_id,file_path:i.file_path};return this.request({url:s,method:"GET",params:o},t)}ReleaseFileLock(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/file_lock/release"),o={project_id:i.project_id,file_path:i.file_path,session_id:i.session_id};return this.request({url:s,method:"POST",data:o},t)}AcquireFileLock(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/file_lock/acquire"),o={project_id:i.project_id,file_path:i.file_path,session_id:i.session_id,file_name:i.file_name};return this.request({url:s,method:"POST",data:o},t)}GetOutputVideo(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/get_output_video"),o={video_project_uri:i.video_project_uri};return this.request({url:s,method:"POST",data:o},t)}CloneToVideoAsset(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/asset/clone_to_video_asset"),o={material_id:i.material_id};return this.request({url:s,method:"POST",data:o},t)}CloneToVideoProductionMaterial(e,t){const i=e||{},s=this.genBaseURL("/api/coze_space/video/material/clone_to_video_material"),o={asset_id:i.asset_id,production_id:i.production_id,session_id:i.session_id,conversation_id:i.conversation_id};return this.request({url:s,method:"POST",data:o},t)}}const bp=new vp({});var wp,Pp,Sp,Tp,Cp,kp,Ap,Ep,Ip,Rp,zp,Up,jp,Lp,Op,Bp,xp,qp,Dp,Mp,Gp,$p,Np,Fp,Vp,Wp,Hp,Kp,Jp,Qp,Yp;function Zp(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}!function(e){e[e.Image=1]="Image";e[e.Android=2]="Android";e[e.IOS=3]="IOS";e[e.GitCode=4]="GitCode";e[e.FaasRuntimePkg=5]="FaasRuntimePkg";e[e.SkillPkg=6]="SkillPkg";e[e.H5=7]="H5"}(wp||(wp={})),function(e){e[e.Unknown=0]="Unknown";e[e.FreeCertificate=1]="FreeCertificate"}(Pp||(Pp={})),function(e){e[e.Unknown=0]="Unknown";e[e.Normal=1]="Normal"}(Sp||(Sp={})),function(e){e[e.Unknown=0]="Unknown";e[e.Existing=1]="Existing";e[e.Free=2]="Free"}(Tp||(Tp={})),function(e){e[e.AuditPass=1]="AuditPass";e[e.AuditUnPass=2]="AuditUnPass";e[e.Auditing=3]="Auditing";e[e.Released=11]="Released";e[e.ReleaseFailed=12]="ReleaseFailed";e[e.Running=21]="Running"}(Cp||(Cp={})),function(e){e[e.Passed=1]="Passed";e[e.UnPassed=2]="UnPassed";e[e.Auditing=3]="Auditing"}(kp||(kp={})),function(e){e[e.Official=1]="Official"}(Ap||(Ap={})),function(e){e[e.Prepare=1]="Prepare";e[e.Package=2]="Package";e[e.Build=3]="Build";e[e.Deploy=4]="Deploy";e[e.Audit=5]="Audit"}(Ep||(Ep={})),function(e){e[e.Pending=1]="Pending";e[e.Running=2]="Running";e[e.Succeeded=3]="Succeeded";e[e.Failed=4]="Failed";e[e.Canceled=5]="Canceled";e[e.Interrupted=6]="Interrupted"}(Ip||(Ip={})),function(e){e[e.Unknown=0]="Unknown";e[e.Success=1]="Success";e[e.Pending=2]="Pending";e[e.Failed=3]="Failed"}(Rp||(Rp={})),function(e){e[e.Unknown=0]="Unknown";e[e.Default=1]="Default";e[e.Custom=2]="Custom"}(zp||(zp={})),function(e){e[e.Unknown=0]="Unknown";e[e.Active=1]="Active";e[e.Disabled=2]="Disabled";e[e.Redirected=3]="Redirected";e[e.Primary=4]="Primary"}(Up||(Up={})),function(e){e[e.Published=1]="Published";e[e.Unpublished=2]="Unpublished"}(jp||(jp={})),function(e){e[e.Agent=1]="Agent";e[e.Automation=2]="Automation";e[e.WebApp=3]="WebApp";e[e.App=4]="App";e[e.Skill=5]="Skill";e[e.GeneralWeb=6]="GeneralWeb";e[e.WechatMiniProgram=7]="WechatMiniProgram";e[e.General=9]="General"}(Lp||(Lp={})),function(e){e[e.Created=1]="Created";e[e.Ready=3]="Ready";e[e.Stopped=4]="Stopped";e[e.Banned=5]="Banned";e[e.Paused=6]="Paused"}(Op||(Op={})),function(e){e[e.Unknown=0]="Unknown";e[e.VefaasFunction=1]="VefaasFunction"}(Bp||(Bp={})),function(e){e[e.Unknown=0]="Unknown";e[e.Dev=1]="Dev";e[e.Prod=2]="Prod";e[e.Audit=3]="Audit"}(xp||(xp={})),function(e){e[e.A=1]="A";e[e.CNAME=2]="CNAME"}(qp||(qp={})),function(e){e[e.Unknown=0]="Unknown";e[e.Single=1]="Single";e[e.Wildcard=2]="Wildcard";e[e.Multi=3]="Multi"}(Dp||(Dp={})),function(e){e[e.Unknown=0]="Unknown";e[e.DV=1]="DV";e[e.OV=2]="OV";e[e.EV=3]="EV"}(Mp||(Mp={})),function(e){e[e.Unknown=0]="Unknown";e[e.NotSubmitted=1]="NotSubmitted";e[e.Pending=2]="Pending";e[e.Issued=3]="Issued";e[e.Cancelling=4]="Cancelling";e[e.Canceled=5]="Canceled";e[e.Revoking=6]="Revoking";e[e.Revoked=7]="Revoked";e[e.Failed=8]="Failed";e[e.Expired=9]="Expired"}(Gp||(Gp={})),function(e){e[e.Unknown=0]="Unknown";e[e.Free=1]="Free";e[e.Test=2]="Test";e[e.Paid=3]="Paid";e[e.Imported=4]="Imported"}($p||($p={})),function(e){e[e.NeedAuthorize=1]="NeedAuthorize";e[e.BindSuccess=2]="BindSuccess";e[e.BoundToOtherProject=3]="BoundToOtherProject";e[e.BoundToOtherUser=4]="BoundToOtherUser"}(Np||(Np={})),function(e){e[e.BoundToSelf=1]="BoundToSelf";e[e.BoundToOtherUser=2]="BoundToOtherUser";e[e.NotAuthorized=3]="NotAuthorized"}(Fp||(Fp={})),function(e){e[e.Line=1]="Line"}(Vp||(Vp={})),function(e){e[e.Default=0]="Default";e[e.WechatMini=1]="WechatMini";e[e.DouyinMini=2]="DouyinMini"}(Wp||(Wp={})),function(e){e[e.Day=1]="Day";e[e.Week=2]="Week";e[e.Month=3]="Month";e[e.Yesterday=4]="Yesterday";e[e.ThreeDays=5]="ThreeDays"}(Hp||(Hp={})),function(e){e[e.InvokeQPS=1]="InvokeQPS";e[e.ErrorQPS=2]="ErrorQPS";e[e.Latency=3]="Latency";e[e.DAU=4]="DAU";e[e.DNU=5]="DNU";e[e.ActiveRetention=6]="ActiveRetention";e[e.NewUserRetention=7]="NewUserRetention"}(Kp||(Kp={})),function(e){e[e.Recorded=1]="Recorded"}(Jp||(Jp={})),function(e){e[e.Sum=1]="Sum";e[e.Avg=2]="Avg"}(Qp||(Qp={})),function(e){e[e.Next=1]="Next";e[e.Third=3]="Third";e[e.Seventh=7]="Seventh"}(Yp||(Yp={}));class Xp{__init(){this.request=e.request}__init2(){this.baseURL=""}constructor(e){Xp.prototype.__init.call(this),Xp.prototype.__init2.call(this),this.request=Zp([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=Zp([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}PublicCreateDeployHistory(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_history/create"),o={project_id:i.project_id,is_sync_db_to_prod:i.is_sync_db_to_prod,encrypt_env_variable:i.encrypt_env_variable,table_sync_configs:i.table_sync_configs,encrypt_deploy:i.encrypt_deploy,commit_hash:i.commit_hash,connector_configs:i.connector_configs};return this.request({url:s,method:"POST",data:o},t)}PublicRollbackDeployHistory(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_history/rollback"),o={project_id:i.project_id,target_deploy_history_id:i.target_deploy_history_id,rollback_database:i.rollback_database};return this.request({url:s,method:"POST",data:o},t)}PublicCancelDeployHistory(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_history/cancel"),o={project_id:i.project_id,deploy_history_id:i.deploy_history_id};return this.request({url:s,method:"POST",data:o},t)}PublicGetDeployConfig(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_config/get"),o={project_id:i.project_id,commit_hash:i.commit_hash};return this.request({url:s,method:"GET",params:o},t)}PublicListDeployHistory(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_history/list"),o={project_id:i.project_id,page_token:i.page_token,page_size:i.page_size};return this.request({url:s,method:"GET",params:o},t)}PublicSearchRuntimeLog(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/runtime_log/search"),o={project_id:i.project_id,deploy_history_id:i.deploy_history_id,start_time:i.start_time,end_time:i.end_time,limit:i.limit,cursor:i.cursor,query:i.query,level:i.level};return this.request({url:s,method:"GET",params:o},t)}PublicGetDeployHistory(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_history/get"),o={project_id:i.project_id,deploy_history_id:i.deploy_history_id};return this.request({url:s,method:"GET",params:o},t)}PublicBindCertificate(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/certificate/bind"),o={project_id:i.project_id,certificate_id:i.certificate_id,domain:i.domain};return this.request({url:s,method:"POST",data:o},t)}PublicApplyFreeCertificate(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/certificate/apply_free"),o={project_id:i.project_id,domain:i.domain,auto_renew_free_cert:i.auto_renew_free_cert};return this.request({url:s,method:"POST",data:o},t)}PublicListDomainRelated(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/domain_related/list"),o={project_id:i.project_id,unit_type:i.unit_type};return this.request({url:s,method:"GET",params:o},t)}PublicDeleteDomainRelated(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/domain_related/delete"),o={project_id:i.project_id,domain:i.domain};return this.request({url:s,method:"POST",data:o},t)}PublicCreateDomainRelated(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/domain_related/create"),o={project_id:i.project_id,domain:i.domain};return this.request({url:s,method:"POST",data:o},t)}PublicGetDeployUnit(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_unit/get"),o={project_id:i.project_id};return this.request({url:s,method:"GET",params:o},t)}PublicGetCertificateDetail(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/certificate/get"),o={project_id:i.project_id,certificate_id:i.certificate_id};return this.request({url:s,method:"GET",params:o},t)}PublicGetDomainRelated(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/domain_related/get"),o={project_id:i.project_id,domain:i.domain};return this.request({url:s,method:"GET",params:o},t)}PublicListVolcanoDomain(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/volcano_domain/list"),o={project_id:i.project_id};return this.request({url:s,method:"GET",params:o},t)}PublicListVolcanoCertificate(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/certificate/list_volcano"),o={project_id:i.project_id,domain:i.domain};return this.request({url:s,method:"GET",params:o},t)}PublicListProjectTraces(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/traces/list"),o={project_id:i.project_id,start_time:i.start_time,end_time:i.end_time,filter:i.filter,page_token:i.page_token,page_size:i.page_size};return this.request({url:s,method:"POST",data:o},t)}PublicDownloadProjectTraces(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/traces/download"),o={project_id:i.project_id,start_time:i.start_time,end_time:i.end_time,filter:i.filter};return this.request({url:s,method:"POST",data:o},t)}PublicGetProjectMetrics(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/metrics/get"),o={project_id:i.project_id,time_range:i.time_range,retention_days:i.retention_days};return this.request({url:s,method:"GET",params:o},t)}PublicDeleteDeployUnit(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_unit/delete"),o={project_id:i.project_id,deploy_unit_id:i.deploy_unit_id};return this.request({url:s,method:"POST",data:o},t)}PublicGetHelpCenterLink(e,t){const i=this.genBaseURL("/api/coding/deployment/help_center/link");return this.request({url:i,method:"GET"},t)}PublicCheckRollbackDatabase(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_history/check_rollback_database"),o={project_id:i.project_id,deploy_history_id:i.deploy_history_id};return this.request({url:s,method:"GET",params:o},t)}PublicGetMiniProgramPreview(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/mini_program/preview"),o={project_id:i.project_id,app_id:i.app_id,connector_id:i.connector_id};return this.request({url:s,method:"GET",params:o},t)}PublicSubmitAuthCode(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/auth/submit_code"),o={project_id:i.project_id,connector_id:i.connector_id,code:i.code,verify_state:i.verify_state,auth_params:i.auth_params};return this.request({url:s,method:"POST",data:o},t)}PublicGetAuthStatus(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/auth/status"),o={project_id:i.project_id,connector_id:i.connector_id,redirect_url:i.redirect_url};return this.request({url:s,method:"POST",data:o},t)}PublicBindAuth(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/auth/bind"),o={project_id:i.project_id,connector_id:i.connector_id,redirect_url:i.redirect_url,auth_params:i.auth_params,override:i.override};return this.request({url:s,method:"POST",data:o},t)}PublicUnbindAuth(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/auth/unbind"),o={project_id:i.project_id,connector_id:i.connector_id};return this.request({url:s,method:"POST",data:o},t)}PublicGetBoundProject(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/connector/get_bound_project"),o={connector_id:i.connector_id,related_id:i.related_id};return this.request({url:s,method:"GET",params:o},t)}PublicUpdateDomainRelated(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/domain_related/update"),o={project_id:i.project_id,domain:i.domain,auto_renew_free_cert:i.auto_renew_free_cert,visit_status:i.visit_status,next_primary_domain:i.next_primary_domain};return this.request({url:s,method:"POST",data:o},t)}PublicGetCertificateQuota(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/certificate/quota"),o={project_id:i.project_id};return this.request({url:s,method:"GET",params:o},t)}PublicListDomainCertificates(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/certificate/list"),o={project_id:i.project_id,domain:i.domain};return this.request({url:s,method:"GET",params:o},t)}PublicUnpublishConnector(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/connector/unpublish_project"),o={project_id:i.project_id,connector_ids:i.connector_ids};return this.request({url:s,method:"POST",data:o},t)}PublicListConnector(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/connector/list"),o={project_id:i.project_id,project_publish_status:i.project_publish_status};return this.request({url:s,method:"GET",params:o},t)}PublicPublishConnector(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/connector/publish_project"),o={project_id:i.project_id,connector_configs:i.connector_configs};return this.request({url:s,method:"POST",data:o},t)}PublicGetDeployCount(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_history/get_count"),o={project_id:i.project_id};return this.request({url:s,method:"GET",params:o},t)}GetRuntimeLogCount(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/runtime_log/count"),o={project_id:i.project_id};return this.request({url:s,method:"GET",params:o},t)}PublicExchangeFeishuAuthCode(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/feishu/auth/exchange_code"),o={project_id:i.project_id,code:i.code,verify_state:i.verify_state};return this.request({url:s,method:"POST",data:o},t)}PublicRevokeFeishuAuth(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/feishu/auth/revoke"),o={project_id:i.project_id};return this.request({url:s,method:"POST",data:o},t)}PublicUpdateDefaultDomainPrefix(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/domain_related/update_default_prefix"),o={project_id:i.project_id,prefix:i.prefix};return this.request({url:s,method:"POST",data:o},t)}PublicFeishuWebhookEvent(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/feishu/webhook/event"),o={body:i.body};return this.request({url:s,method:"POST",data:o},t)}PublicCheckCreateDomainRelated(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/domain_related/check_create"),o={project_id:i.project_id};return this.request({url:s,method:"GET",params:o},t)}PublicGetHostedUsageMonthly(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/hosted_usage/monthly"),o={project_id:i.project_id,bill_month:i.bill_month};return this.request({url:s,method:"GET",params:o},t)}PublicGetEstimateHostedCost(e,t){const i=this.genBaseURL("/api/coding/deployment/hosted_usage/estimate_cost");return this.request({url:i,method:"GET"},t)}PublicGetDeployHistoryLog(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_history/log"),o={deploy_history_id:i.deploy_history_id,key:i.key};return this.request({url:s,method:"GET",params:o},t)}PublicGetMPICPStatus(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/mini_program/icp_status"),o={project_id:i.project_id,app_id:i.app_id,connector_id:i.connector_id};return this.request({url:s,method:"GET",params:o},t)}PublicGetOnlineDeployHistory(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_history/get_online"),o={project_id:i.project_id};return this.request({url:s,method:"GET",params:o},t)}PublicGetUserAnalyticsMetrics(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/metrics/user_analytics/get"),o={project_id:i.project_id,time_range:i.time_range};return this.request({url:s,method:"GET",params:o},t)}PublicPauseDeployUnit(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_unit/pause"),o={project_id:i.project_id,deploy_history_id:i.deploy_history_id};return this.request({url:s,method:"POST",data:o},t)}PublicStopDeployUnit(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_unit/stop"),o={project_id:i.project_id,deploy_history_id:i.deploy_history_id};return this.request({url:s,method:"POST",data:o},t)}PublicResumeDeployUnit(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/deploy_unit/resume"),o={project_id:i.project_id,deploy_history_id:i.deploy_history_id};return this.request({url:s,method:"POST",data:o},t)}PublicReportUserAnalytics(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/analytics/report"),o={events:i.events},n={project_id:i.project_id,did:i.did};return this.request({url:s,method:"POST",data:o,params:n},t)}PublicCreateDefaultDomainRelated(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/domain_related/create_default"),o={project_id:i.project_id,prefix:i.prefix};return this.request({url:s,method:"POST",data:o},t)}PublicGetProtectionConfig(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/protection_config/get"),o={project_id:i.project_id};return this.request({url:s,method:"GET",params:o},t)}PublicUpdateProtectionConfig(e,t){const i=e||{},s=this.genBaseURL("/api/coding/deployment/protection_config/update"),o={project_id:i.project_id,config:i.config};return this.request({url:s,method:"POST",data:o},t)}}const eu=new Xp({}),tu={[Ip.Pending]:"Pending",[Ip.Running]:"Running",[Ip.Succeeded]:"Succeeded",[Ip.Failed]:"Failed",[Ip.Canceled]:"Canceled",[Ip.Interrupted]:"Interrupted"},iu=[Ip.Succeeded,Ip.Failed,Ip.Canceled],su=e=>e&&tu[e]||"Unknown";function ou(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}class nu{static __initStatic(){this.INSTANCE=new nu}static getInstance(){return nu.INSTANCE||(nu.INSTANCE=new nu),this.INSTANCE}async pollDeployStatus(t){const{projectId:i,deployHistoryId:s,onBeforePoll:o,onStatusChange:n}=t;let r;for(;;){ou([o,"optionalCall",e=>e()]);const t=ou([await eu.PublicGetDeployHistory({project_id:i,deploy_history_id:s}),"optionalAccess",e=>e.data]);if(!t)throw new e.CozeError(e.ErrorCode.E5000,"Failed to get deploy history data during polling");const a=t.status;if(a!==r&&(r=a,ou([n,"optionalCall",e=>e(t)])),iu.includes(a))return t;await new Promise((e=>setTimeout(e,3e3)))}}async getLatestDeployHistoryId(e){const{projectId:t}=e;return ou([await eu.PublicListDeployHistory({page_size:1,project_id:t}),"optionalAccess",e=>e.data,"optionalAccess",e=>e.deploy_history_list,"optionalAccess",e=>e[0],"optionalAccess",e=>e.deploy_history_id])}async getDeployHistory(t){const{projectId:i,deployHistoryId:s}=t,o=await eu.PublicGetDeployHistory({project_id:i,deploy_history_id:s});if(!ou([o,"optionalAccess",e=>e.data]))throw new e.CozeError(e.ErrorCode.E5000,"Failed to get deploy history data");return o.data}canDeploy(e){return[t.VibeProjectType.AssistantAgent,t.VibeProjectType.GeneralWeb,t.VibeProjectType.App,t.VibeProjectType.Skill,t.VibeProjectType.Agent,t.VibeProjectType.Automation].includes(e)}async getCommitList({projectId:i}){const s=await t.IdeApi.ProxySandboxMessage({ProjectID:i,Method:"repo_version.commit.list",Params:JSON.stringify({project_id:i})});return e.safeJsonParse(s.data,{commits:[]}).commits||[]}}nu.__initStatic();const ru=nu.getInstance();function au(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function cu(e,t){return null!=e?e:t()}function lu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function du(e,t){return null!=e?e:t()}function pu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const uu=e=>{if(null==e)return null;return 0===e.trim().length?null:e},_u=i=>{i.command("send [message]").description("Send a prompt message to Coze Coding project chat").option("--wait","Wait for the chat response before returning").option("--stdin","Read additional context from stdin (pipe input)").config({help:{brief:"Send a message to project chat",description:"Send a prompt message to the specified Coze Coding project chat. The message can be provided as a positional argument. Use --stdin to pipe additional context. Use @<path> to mention and upload local files as context.",examples:[{desc:"Send a message to project",cmd:'coze code message send "Fix the bug in auth module" -p 123456',tags:["[RECOMMENDED]"]},{desc:"Send and wait for the response",cmd:'coze code message send "Fix the bug in auth module" -p 123456 --wait'},{desc:"Mention a file with @",cmd:'coze code message send "Refactor @src/utils.ts to use async/await" -p 123456'},{desc:"Mention multiple files",cmd:'coze code message send "Compare @src/old.ts and @src/new.ts, list the differences" -p 123456'},{desc:"Send message with stdin context",cmd:'cat error.log | coze code message send "Analyze this error" --stdin -p 123456'},{desc:"Use environment variable for project",cmd:'export COZE_PROJECT_ID=123456 && coze code message send "Hello"'}],errors:[{code:e.ErrorCode.E1000,name:"MISSING_MESSAGE",desc:"No message content provided",fix:"Provide MESSAGE argument or use --stdin with piped content",example:'coze code message send "Your question" -p 123456 # or: echo "context" | coze code message send --stdin "question" -p 123456'},{code:e.ErrorCode.E1001,name:"MISSING_PROJECT_ID",desc:"No project ID provided via -p/--project-id or COZE_PROJECT_ID env",fix:"Provide -p/--project-id option or set COZE_PROJECT_ID environment variable",example:'coze code message send "Hello" -p 123456'},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid API token",fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable",example:"coze auth login --oauth"},{code:e.ErrorCode.E5000,name:"UNEXPECTED_ERROR",desc:"CLI context is not initialized",fix:"Please retry and make sure the CLI is initialized correctly"}],schema:{input:{message:{type:"string",required:!1,description:"The prompt message to send to the project chat"},wait:{type:"boolean",required:!1,description:"Wait for the chat response before returning. Without this flag, the message is sent in the background."},stdin:{type:"boolean",required:!1,description:"Read additional context from stdin (pipe input)."}},output:{type:"object",properties:{content:{type:"string",description:"The chat response content"}}}}}}).action((async(i,s,o)=>{const n=o.getContext();try{if(!n)throw new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized");const r=pu([o,"access",e=>e.parent,"optionalAccess",e=>e.opts,"call",e=>e()]),a=du(pu([r,"optionalAccess",e=>e.projectId]),(()=>process.env.COZE_PROJECT_ID));if(!a)throw new e.CozeError(e.ErrorCode.E1001,"Missing required option: --project-id (or env COZE_PROJECT_ID)");const c=await pu([n,"optionalAccess",e=>e.auth,"optionalAccess",e=>e.getValidAccessToken,"call",e=>e()]);if(!c)throw new e.CozeError(e.ErrorCode.E2001,"Missing API token: set env COZE_API_TOKEN or run `coze auth login` first");const{wait:l,stdin:d}=s;let p=null;d&&(p=await hr());const u=uu(i),_=uu(p);if(!u&&!_)throw new e.CozeError(e.ErrorCode.E1000,"Missing prompt: provide PROMPT argument or use --stdin");const m=u&&_?`${u}\n\n${_}`:du(du(u,(()=>_)),(()=>"")),g=new Set,h=await t.sendProjectChatMessage({projectId:a,prompt:m,apiBaseUrl:n.config.apiBaseUrl,accessToken:c,xTTEnv:n.config.xTTEnv,key:`coze-coding-cli:message:${a}`,onWarn:e=>n.ui.warn(e),waitForResponse:!!l,onMessageItem:e=>{if(l&&"json"===n.format&&e.finish){const t=(e=>{const t=du(e.msg_id,(()=>"")),i=du(e.sequence_id,(()=>""));return`${e.type}:${t}:${String(i)}`})(e);g.has(t)||(g.add(t),n.response.print({content:e.content,role:e.role,finish:e.finish,type:e.type}))}}});if(l)"text"===n.format&&n.response.print(du(pu([h,"access",e=>e.lastAnswerMessage,"optionalAccess",e=>e.content,"access",e=>e.answer]),(()=>"")));else{const e=`Message sent. Use \`coze code message status -p ${a}\` to check the result.`;"json"===n.format?n.response.print({status:"sent",project_id:a,message:e}):n.response.print(e),process.exit(0)}}catch(e){W(e,n)}}))};function mu(e,t){return null!=e?e:t()}function gu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function hu(e,t){return null!=e?e:t()}function fu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const yu=async(i,s)=>{const o=s.getContext();try{if(!o)throw new e.CozeError("E5000","CLI context is not initialized");const n=fu([s,"access",e=>e.parent,"optionalAccess",e=>e.opts,"call",e=>e()]),r=hu(fu([n,"optionalAccess",e=>e.projectId]),(()=>process.env.COZE_PROJECT_ID));if(!r)throw new e.CozeError("E1001","Missing required option: --project-id (or env COZE_PROJECT_ID)");if(!await fu([o,"optionalAccess",e=>e.auth,"optionalAccess",e=>e.getValidAccessToken,"call",e=>e()]))throw new e.CozeError("E2001","Missing API token: set env COZE_API_TOKEN or run `coze auth login` first");if(i.after&&i.before)throw new e.CozeError("E1000","--after and --before cannot be used together. Use only one cursor at a time.");o.ui.verbose(`Fetching conversation history for project ${r}...`);const a=t.createChatCore({key:`coze-coding-cli:history:${r}`,apiBaseUrl:o.config.apiBaseUrl});try{const e=i.after?"loadNext":"loadPrev",t="loadNext"===e?"11":"10",s=await a.getHistoryMessage({limit:t,project_id:r,after:i.after,before:i.before}),n=[],c=new Map,l=new Map;s.histories.forEach((e=>{if(e.user){const t=e.user.msg_id;c.has(t)||n.push(t);const i=(e=>{const t=fu([e,"optionalAccess",e=>e.content]);return hu(hu(fu([t,"optionalAccess",e=>e.query,"optionalAccess",e=>e.prompt]),(()=>fu([t,"optionalAccess",e=>e.retry,"optionalAccess",e=>e.prompt]))),(()=>fu([t,"optionalAccess",e=>e.edit,"optionalAccess",e=>e.prompt])))})(e.user.message);c.set(t,i?(e=>e.map((e=>"text"===e.type?e.content.text:"file"===e.type?`${gu([e,"access",e=>e.content,"access",e=>e.file,"optionalAccess",e=>e.path])} ${mu(gu([e,"access",e=>e.content,"access",e=>e.file,"optionalAccess",e=>e.from,"optionalAccess",e=>e[0]]),(()=>""))} ${mu(gu([e,"access",e=>e.content,"access",e=>e.file,"optionalAccess",e=>e.to,"optionalAccess",e=>e[0]]),(()=>""))} `:"console"===e.type?gu([e,"access",e=>e.content,"access",e=>e.console,"optionalAccess",e=>e.content]):"node"===e.type?gu([e,"access",e=>e.content,"access",e=>e.node,"optionalAccess",e=>e.node_title]):"upload_file"===e.type?gu([e,"access",e=>e.content,"access",e=>e.upload_file,"optionalAccess",e=>e.file_name]):"page"===e.type?gu([e,"access",e=>e.content,"access",e=>e.page,"optionalAccess",e=>e.page_title]):"page_elements"===e.type?gu([e,"access",e=>e.content,"access",e=>e.page_elements,"optionalAccess",e=>e[0],"optionalAccess",e=>e.path,"optionalAccess",e=>e[0],"optionalAccess",e=>e.node_name]):"wf_canvas_change"===e.type?gu([e,"access",e=>e.content,"access",e=>e.wf_canvas_change,"optionalAccess",e=>e.query]):"")).join(" "))(i):"")}if(e.assistant){const t=e.assistant.messages.find((e=>"answer"===e.type&&e.content.answer));if(!t)return;const i=t.query_msg_id,s=t.content.answer;"string"==typeof i&&"string"==typeof s&&l.set(i,s)}}));const d=n[0],p=n[n.length-1],u=n.reverse().filter((e=>l.has(e))).map((e=>({userMessage:hu(c.get(e),(()=>"")),answer:hu(l.get(e),(()=>""))}))),_={histories:u,cursor:{after:d,before:p,has_more:s.has_more,loadDirection:e}};if("json"===o.format)o.response.print(_);else{if(0===u.length)return void o.response.print("No conversation history found.");u.forEach(((e,t)=>{o.response.print(`--- #${t+1} ---\nQ: ${e.userMessage}\nA: ${e.answer}\n`)})),o.response.print(`\n[cursor] after=${d}, before=${p}, has_more=${s.has_more}, loadDirection=${e}`)}}finally{a.destroy()}}catch(e){W(e,o)}};function vu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const bu=i=>{const s=i.command("message");s.description("Manage project chat messages").config({help:{brief:"Manage project chat messages",description:"Manage Coze Coding project chat messages.\n\nThis command group provides:\n- send: Send a new message to the project chat\n- status: Query the status of current chat message (auto-fetch result when completed)\n- cancel: Cancel an ongoing chat message\n- history: View conversation history",examples:[{desc:"Send a message to project",cmd:'coze code message send "Fix the bug" -p 123456',tags:["[RECOMMENDED]"]},{desc:"Check message status",cmd:"coze code message status -p 123456"},{desc:"Cancel ongoing message",cmd:"coze code message cancel -p 123456"},{desc:"View conversation history",cmd:"coze code message history -p 123456"}],errors:[{code:e.ErrorCode.E1001,name:"MISSING_PROJECT_ID",desc:"No project ID provided via -p/--project-id or COZE_PROJECT_ID env",fix:"Provide -p/--project-id option or set COZE_PROJECT_ID environment variable",example:'coze code message send "Hello" -p 123456'},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid API token",fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable",example:"coze auth login --oauth"}],schema:{input:{projectId:{type:"string",required:!0,description:"Coze project ID (can also be set via COZE_PROJECT_ID env)"}}},seeAlso:["coze code project list","coze code project create"]}}).option("-p, --project-id <id>","Coze project id (or env COZE_PROJECT_ID)"),_u(s),(i=>{i.command("status").description("Query current project chat message status and get result when completed").config({help:{brief:"Query chat message status",description:"Get the current status of the chat message for the specified project. Returns status information such as running, completed, or error. When the chat is completed, automatically fetches and returns the result.",examples:[{desc:"Check message status (auto-fetch result when completed)",cmd:"coze code message status -p 123456",tags:["[RECOMMENDED]"]},{desc:"With environment variable",cmd:"coze code message status"},{desc:"Output as JSON",cmd:"coze code message status -p 123456 --format json"}],errors:[{code:e.ErrorCode.E1001,name:"MISSING_PROJECT_ID",desc:"No project ID provided",fix:"Provide -p/--project-id option or set COZE_PROJECT_ID environment variable"},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid API token",fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable"},{code:e.ErrorCode.E5000,name:"UNEXPECTED_ERROR",desc:"CLI context is not initialized",fix:"Please retry and make sure the CLI is initialized correctly"}],schema:{input:{projectId:{type:"string",required:!0,description:"Coze project ID"}},output:{type:"object",properties:{status:{type:"string",description:"Message status (running/completed/error)"},message:{type:"string",description:"Status message or error details"},answer:{type:"string",description:"The chat answer content (only when completed)"}}}}}}).action((async(i,s)=>{const o=s.getContext();try{if(!o)throw new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized");const i=lu([s,"access",e=>e.parent,"optionalAccess",e=>e.opts,"call",e=>e()]),n=cu(lu([i,"optionalAccess",e=>e.projectId]),(()=>process.env.COZE_PROJECT_ID));if(!n)throw new e.CozeError(e.ErrorCode.E1001,"Missing required option: --project-id (or env COZE_PROJECT_ID)");o.ui.verbose(`Fetching chat status for project ${n}...`);const{code:r,msg:a,reply_id:c,...l}=await t.BuildAgentApi.GetChatCLIMessageStatus({project_id:n});if("done"===l.status){o.ui.verbose(`Chat completed, fetching result for project ${n}...`);const e=await t.BuildAgentApi.GetChatCLIMessageResultContent({project_id:n}),i="data"in e?e.data:e;"json"===o.format?o.response.print({...l,answer:i.answer}):o.response.print(`status: [${l.status}]\nanswer: ${cu(i.answer,(()=>""))}`)}else"json"===o.format?o.response.print(l):o.response.print(l.status)}catch(e){W(e,o)}}))})(s),function(i){i.command("cancel").description("Cancel current project chat message").config({help:{brief:"Cancel ongoing chat message",description:"Cancel the currently running chat message for the specified project. Useful for stopping long-running or stuck message generation.",examples:[{desc:"Cancel current message",cmd:"coze code message cancel -p 123456",tags:["[RECOMMENDED]"]},{desc:"With environment variable",cmd:"coze code message cancel"}],errors:[{code:e.ErrorCode.E1001,name:"MISSING_PROJECT_ID",desc:"No project ID provided",fix:"Provide -p/--project-id option or set COZE_PROJECT_ID environment variable"},{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Missing or invalid API token",fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable"},{code:e.ErrorCode.E5000,name:"UNEXPECTED_ERROR",desc:"CLI context is not initialized",fix:"Please retry and make sure the CLI is initialized correctly"}],schema:{input:{projectId:{type:"string",required:!0,description:"Coze project ID"}},output:{type:"object",properties:{status:{type:"string",description:"Cancel operation status"},message:{type:"string",description:"Result message"}}}}}}).action((async(i,s)=>{const o=s.getContext();try{if(!o)throw new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized");const i=vu([s,"access",e=>e.parent,"optionalAccess",e=>e.opts,"call",e=>e()]),r=null!=(n=vu([i,"optionalAccess",e=>e.projectId]))?n:(()=>process.env.COZE_PROJECT_ID)();if(!r)throw new e.CozeError(e.ErrorCode.E1001,"Missing required option: --project-id (or env COZE_PROJECT_ID)");const{accessToken:a}=o.config;if(!a)throw new e.CozeError(e.ErrorCode.E2001,"Missing API token: set env COZE_API_TOKEN or run `coze auth login` first");o.ui.verbose(`Canceling chat message for project ${r}...`);const{message:c}=await t.BuildAgentApi.CancelChatCLIMessage({project_id:r});"json"===o.format?o.response.print({message:c}):o.response.print(c)}catch(e){W(e,o)}var n}))}(s),(e=>{e.command("history").description("View conversation history of the project chat").option("--after <msg_id>","Cursor for fetching newer messages (smaller index)").option("--before <msg_id>","Cursor for fetching older messages (larger index)").config({help:{brief:"View conversation history",description:"Retrieve and display the conversation history for the specified Coze Coding project. Shows each round of user messages and LLM responses. By default, returns the latest 10 rounds of conversation. Use --after or --before cursors for pagination.",examples:[{desc:"View latest 10 rounds of conversation history",cmd:"coze code message history -p 123456",tags:["[RECOMMENDED]"]},{desc:"With environment variable",cmd:"coze code message history"},{desc:"Output as JSON with cursor info",cmd:"coze code message history -p 123456 --format json"},{desc:"Fetch newer messages after a cursor",cmd:"coze code message history -p 123456 --after msg_xxx"},{desc:"Fetch older messages before a cursor",cmd:"coze code message history -p 123456 --before msg_yyy"}],errors:[{code:"E1000",name:"INVALID_ARGUMENT",desc:"--after and --before cannot be used together",fix:"Use only one cursor option at a time for pagination"},{code:"E1001",name:"MISSING_PROJECT_ID",desc:"No project ID provided",fix:"Provide -p/--project-id option or set COZE_PROJECT_ID environment variable"},{code:"E2001",name:"AUTH_FAILED",desc:"Missing or invalid API token",fix:"Run `coze auth login` or set COZE_API_TOKEN environment variable"}],schema:{input:{projectId:{type:"string",required:!0,description:"Coze project ID"},after:{type:"string",description:'Cursor (message ID) for fetching newer messages. Newer messages have smaller index. Use the "after" value from previous output as this parameter.'},before:{type:"string",description:'Cursor (message ID) for fetching older messages. Older messages have larger index. Use the "before" value from previous output as this parameter.'}},output:{type:"object",properties:{histories:{type:"array",items:{type:"object",properties:{userMessage:{type:"string",description:"User's message in this round"},answer:{type:"string",description:"LLM's last answer with content"}}}},cursor:{type:"object",description:"Pagination cursor info for next/prev page requests",properties:{after:{type:"string",description:"Message ID of the newest result, use as --after to fetch newer messages (loadNext)"},before:{type:"string",description:"Message ID of the oldest result, use as --before to fetch older messages (loadPrev)"},has_more:{type:"boolean",description:"Whether there are more messages available"},loadDirection:{type:"string",enum:["loadNext","loadPrev"],description:"Load direction of current request. Defaults to 'loadPrev' (load older messages). 'loadNext' when --after is used, 'loadPrev' when --before is used or on initial request."}}}}}}}}).action(yu)})(s)};function wu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function Pu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function Su(i){i.command("list").description("List project environment variables").option("--env <scope>","Environment scope: dev | prod","dev").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"List project environment variables",description:"Retrieve the list of environment variables for the specified project. Supports filtering by environment (dev/prod) and displays all configured sensitive information key names.",examples:[{desc:"List dev environment variables",cmd:"coze code env list -p <projectId>",tags:["[RECOMMENDED]"]},{desc:"List prod environment variables",cmd:"coze code env list -p <projectId> --env prod"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},env:{type:"string",required:!1,enum:["dev","prod"],description:"Environment scope (default: dev)"}},output:{command:{type:"string",description:"Command name"},status:{type:"string",description:"Execution status"},data:{type:"object",properties:{project_id:{type:"string",description:"Project ID"},project_type:{type:"string",description:"Project type"},env:{type:"string",description:"Environment scope"},secrets:{type:"array",description:"Environment variable list"}}}}},errors:[{code:e.ErrorCode.E3001,name:"PROJECT_NOT_FOUND",desc:"Project not found",fix:"Please confirm if the project ID is correct"}]}}).action((async function(e,i){const s=i.getContext(),{projectId:o}=e,n=Pu([await t.IdeApi.GetVibeProject({project_id:o}),"access",e=>e.data,"optionalAccess",e=>e.project_info,"optionalAccess",e=>e.project_type]),r=(a=e.env,"prod"===String(a||"dev").toLowerCase()?Yi.prod:Yi.dev);var a;const c=Pu([await ns.ListProjectSecret({env:r,project_id:o,...n===t.VibeProjectType.Skill?{with_providers:!0}:{}}),"optionalAccess",e=>e.data,"optionalAccess",e=>e.project_secrets,"optionalAccess",e=>e.secrets])||[];Pu([s,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e("Env secrets listed successfully.")]),Pu([s,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(c.map((e=>({secret_key:e.secret_key,secret_id:e.secret_id,secret_val:e.secret_val,secret_type:e.secret_type}))))])}))}function Tu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const Cu=i=>{const s=i.command("env").config({help:{brief:"Manage project environment variables",description:"Manage project environment variables (Secrets). Supports setting, viewing, and deleting sensitive configuration information such as API keys and database connection strings in development and production environments.",examples:[{desc:"List environment variables",cmd:"coze code env list -p <projectId>"},{desc:"Set environment variable",cmd:"coze code env set KEY VALUE -p <projectId>"},{desc:"Delete environment variable",cmd:"coze code env delete KEY -p <projectId>"}],seeAlso:["coze code deploy","coze code project"]}}).description("Manage project environment variables");Su(s),s.command("set <key> <value>").description("Set a project environment variable").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"Set project environment variable",description:"Add or update environment variables for the project. Environment variables are securely stored and used for sensitive information like API keys, passwords, etc.",examples:[{desc:"Set environment variable",cmd:"coze code env set <KEY> <VALUE> -p <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{key:{type:"string",required:!0,description:"Environment variable key"},value:{type:"string",required:!0,description:"Environment variable value"},projectId:{type:"string",required:!0,description:"Project ID"}},output:{command:{type:"string",description:"Command name"},status:{type:"string",description:"Execution status"},data:{type:"object",properties:{project_id:{type:"string",description:"Project ID"},key:{type:"string",description:"Set key name"},value:{type:"string",description:"Set value"}}}}},errors:[{code:e.ErrorCode.E3008,name:"SKILL_PROJECT_NOT_SUPPORTED",desc:"Skill project secret_type logic to be supplemented",fix:"This feature is not yet supported for Skill projects"}]}}).action((async function(i,s,o,n){const r=n.getContext(),{projectId:a}=o,c=wu([await t.IdeApi.GetVibeProject({project_id:a}),"access",e=>e.data,"optionalAccess",e=>e.project_info,"optionalAccess",e=>e.project_type]);if(c===t.VibeProjectType.Skill)throw new e.CozeError(e.ErrorCode.E3008,"Skill project secret_type logic to be supplemented",{projectId:a,projectType:c});await ns.InsertProjectSecret({project_id:a,insert_secrets:{secrets:[{secret_key:i,secret_val:s}]}}),wu([r,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e("Env secret set successfully")]),wu([r,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({project_id:a,key:i,value:s})])})),function(t){t.command("delete <key>").description("Delete a project environment variable").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"Delete project environment variable",description:"Delete specified environment variables from the project. Supports deleting multiple variables simultaneously by passing the --key parameter multiple times.",examples:[{desc:"Delete a single environment variable",cmd:"coze code env delete <KEY> -p <projectId>",tags:["[RECOMMENDED]"]},{desc:"Delete multiple environment variables",cmd:"coze code env delete <KEY> -p <projectId>"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},key:{type:"string",required:!0,description:"Environment variable key name to delete"}},output:{message:{type:"string",description:"Result message"},key:{type:"string",description:"Deleted key"}}},errors:[{code:e.ErrorCode.E3003,name:"SECRET_NOT_FOUND",desc:"The specified environment variable does not exist",fix:"Please use `env list` first to confirm if the variable name is correct"}]}}).action((async function(t,i,s){const o=s.getContext(),{projectId:n}=i,r=[t],a=Tu([await ns.ListProjectSecret({env:Yi.dev,project_id:n}),"optionalAccess",e=>e.data,"optionalAccess",e=>e.project_secrets,"optionalAccess",e=>e.secrets])||[],c=new Set(r.map((e=>String(e)))),l=a.filter((e=>c.has(String(e.secret_key||"")))).map((e=>e.secret_id)).filter(Boolean);if(0===l.length)throw new e.CozeError(e.ErrorCode.E3003,`No matched secrets by keys: ${r.join(", ")}`,{projectId:n,keys:r});await ns.DeleteProjectSecret({project_id:n,keys:l}),Tu([o,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e("Env has been delete successfully")]),Tu([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({message:"env has been delete successfully",key:t,project_id:n,keys:r,secret_ids:l})])}))}(s)};function ku(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function Au(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function Eu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const Iu=t=>{const i=t.command("domain").config({help:{brief:"Manage custom domains for the project",description:"Manage custom domains for deployed projects. Supports adding, listing, and removing domains associated with a project, used to access deployed applications.",examples:[{desc:"List project domains",cmd:"coze code domain list <projectId>"},{desc:"Add custom domain",cmd:"coze code domain add example.com -p <projectId>"},{desc:"Delete domain",cmd:"coze code domain remove example.com -p <projectId>"}],seeAlso:["coze code deploy"]}}).description("Manage custom domains for the project");i.command("list").description("List custom domains of the project").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"List all domains bound to the project",description:"Retrieve a list of all custom domains bound to the specified project.",examples:[{desc:"List domains",cmd:"coze code domain list -p <projectId>",tags:["[RECOMMENDED]"]},{desc:"Output in JSON format",cmd:"coze code domain list -p <projectId> --format json"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"}},output:{type:"array",items:{type:"object",properties:{id:{type:"string",description:"Domain ID"},domain_host:{type:"string",description:"Domain host"}}}}},errors:[{code:e.ErrorCode.E3001,name:"PROJECT_NOT_FOUND",desc:"Project not found",fix:"Please confirm if the project ID is correct"}]}}).action((async function(e,t){const i=t.getContext(),{projectId:s}=e,o=Au([await eu.PublicListDomainRelated({project_id:s}),"access",e=>e.data,"optionalAccess",e=>e.items])||[];Au([i,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e("Fetched domains List successfully")]),Au([i,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(o.map((e=>({id:e.id,domain_host:e.domain_host}))))])})),function(t){t.command("add <domain>").description("Add a custom domain to the project").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"Add custom domain to project",description:"Bind a custom domain to a specified project. The domain must follow standard format (e.g., example.com). Once bound, the deployed application can be accessed via this domain.",examples:[{desc:"Add domain",cmd:"coze code domain add <domain> -p <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},domain:{type:"string",required:!0,description:"Domain to add (e.g., example.com)"}},output:{command:{type:"string",description:"Command name"},status:{type:"string",description:"Execution status"},data:{type:"object",properties:{project_id:{type:"string",description:"Project ID"},domain:{type:"string",description:"Added domain"}}}}},errors:[{code:e.ErrorCode.E1004,name:"INVALID_DOMAIN",desc:"Incorrect domain format",fix:"Please use a standard domain format, e.g., example.com"}]}}).action((async function(t,i,s){const o=s.getContext(),{projectId:n}=i;if(!/^[a-zA-Z0-9][a-zA-Z0-9-]*\.[a-zA-Z0-9][a-zA-Z0-9-]*$/.test(t))throw new e.CozeError(e.ErrorCode.E1004,"Invalid domain",{domain:t});await eu.PublicCreateDomainRelated({project_id:n,domain:t}),Eu([o,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",e=>e(`Domain '${t}' added.`)]),Eu([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({project_id:n,domain:t})])}))}(i),function(t){t.command("remove <domain>").description("Remove a custom domain from the project").requiredOption("-p, --project-id <projectId>","Project ID").config({help:{brief:"Delete custom domain of the project",description:"Remove a bound custom domain from the specified project.",examples:[{desc:"Delete domain",cmd:"coze code domain remove example.com -p <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},domain:{type:"string",required:!0,description:"Domain to delete"}},output:{command:{type:"string",description:"Command name"},status:{type:"string",description:"Execution status"},data:{type:"object",properties:{project_id:{type:"string",description:"Project ID"},domain:{type:"string",description:"Deleted domain"}}}}},errors:[{code:e.ErrorCode.E1004,name:"INVALID_DOMAIN",desc:"Incorrect domain format",fix:"Please use a standard domain format, e.g., example.com"},{code:e.ErrorCode.E3005,name:"DELETE_FAILED",desc:"Failed to remove domain",fix:"Please confirm the domain is bound to the project and you have sufficient permissions"}]}}).action((async function(e,t,i){const s=i.getContext(),{projectId:o}=t;await eu.PublicDeleteDomainRelated({project_id:o,domain:e}),ku([s,"optionalAccess",e=>e.ui,"access",e=>e.success,"call",t=>t(`Domain '${e}' removed.`)]),ku([s,"optionalAccess",e=>e.response,"access",e=>e.print,"call",t=>t({message:`Domain '${e}' removed.`,domain:e})])}))}(i)};function Ru(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function zu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function Uu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function ju(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function Lu(i){const s=i.command("deploy <projectId>").description("Deploy the project to production environment").option("--commit-id <commitId>","Commit ID (optional, queries latest if omitted)").option("--wait","Wait for deployment to complete").config({help:{brief:"Deploy the project to production environment",description:"Deploy the specified project to the production environment. Supports multiple project types (Agent, Workflow, Skill, Web, Mini-program, etc.), automatically fetches the latest commit, and triggers the deployment process.",examples:[{desc:"Deploy latest project",cmd:"coze code deploy <projectId>",tags:["[RECOMMENDED]"]},{desc:"Deploy and wait for completion",cmd:"coze code deploy <projectId> --wait"},{desc:"Deploy a specific commit",cmd:"coze code deploy <projectId> --commit-id <commitId>"},{desc:"View deployment status",cmd:"coze code deploy status <projectId>"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},wait:{type:"boolean",required:!1,description:"Wait for deployment to complete"}},output:{projectId:{type:"string",description:"Project ID"},status:{type:"string",description:"Deployment status"},domain:{type:"string",description:"Deployed domain"},deployHistoryId:{type:"string",description:"Deployment history ID"},commitHash:{type:"string",description:"Commit hash"}}},errors:[{code:e.ErrorCode.E3007,name:"MISSING_COMMIT_HASH",desc:"No commits found in the project",fix:"Please commit your changes first before deploying"},{code:e.ErrorCode.E2002,name:"MINIPROGRAM_NOT_AUTHORIZED",desc:"Mini-program AppID not configured",fix:"Please complete the Mini-program AppID configuration in the project settings"},{code:e.ErrorCode.E1006,name:"UNSUPPORTED_PROJECT_TYPE",desc:"Project type is not supported for deployment",fix:"Please confirm the project type and try again with a supported project"}]}}).description("Deploy the project to production environment").action((async function(i,s,o){const n=o.getContext(),{wait:r,commitId:a}=s,c=ju([(await t.IdeApi.GetVibeProject({project_id:i})).data||{},"access",e=>e.project_info,"optionalAccess",e=>e.project_type]);if(!ru.canDeploy(c)){const t=`Project type ${Kl(c)} is not supported for deployment`;throw new e.CozeError(e.ErrorCode.E1006,t,{projectType:c})}if(c===t.VibeProjectType.AssistantAgent){const t=await e.axiosInstance$1.post("/api/sandbox/coze_coding/devbox/open_claw/deploy",{project_id:i},{headers:{"content-type":"application/json"}});return ju([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Deploying (AssistantAgent)...")]),void ju([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({command:"deploy",status:"ok",data:{type:c,data:ju([t,"optionalAccess",e=>e.data])}})])}let l=a;if(!l){ju([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Fetching latest commit...")]);const e=await ru.getCommitList({projectId:i});l=ju([e,"optionalAccess",e=>e[0],"optionalAccess",e=>e.id])}if(!l){const t="Missing commitHash: pass --commit-hash <commitHash>";throw new e.CozeError(e.ErrorCode.E3007,t,{projectId:i})}if(c===t.VibeProjectType.WechatMiniProgram){ju([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Checking Mini-program authorization...")]);if(!ju([await eu.PublicGetAuthStatus({project_id:i,connector_id:"10000127"}),"access",e=>e.data,"optionalAccess",e=>e.bound_related_id])){const t="Deployment failed, please complete the Mini-program AppID configuration";throw new e.CozeError(e.ErrorCode.E2002,t)}}ju([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Checking deploy config...")]),await eu.PublicGetDeployConfig({project_id:i,commit_hash:l},{__disableErrorToast:!0});let d="";const p=await ns.ListProjectSecret({env:Yi.dev,project_id:i,with_providers:!0}),u=ju([p,"optionalAccess",e=>e.data,"optionalAccess",e=>e.project_secrets,"optionalAccess",e=>e.secrets])||[],_=ju([p,"optionalAccess",e=>e.data,"optionalAccess",e=>e.project_cred_providers])||[];ju([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Encrypting secrets...")]);d=ju([await ns.EncryptProjectSecret({project_id:i,project_type:c===t.VibeProjectType.Skill?Qi.skill:void 0,encrypt_secrets:{secrets:u.map((e=>({secret_key:e.secret_key||"",secret_val:e.secret_val||"",secret_id:e.secret_id||"",secret_type:e.secret_type===Zi.consumer?ki.consumer3:ki.user_custom2}))),...c===t.VibeProjectType.Skill?{cred_providers:_}:{}}}),"optionalAccess",e=>e.data,"optionalAccess",e=>e.sealed_secrets])||"",ju([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Deploying...")]);const m=ju([await eu.PublicCreateDeployHistory({project_id:i,encrypt_env_variable:d,commit_hash:l}),"optionalAccess",e=>e.data,"optionalAccess",e=>e.deploy_history_id]);ju([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Deploy started.")]),r&&m?await ru.pollDeployStatus({projectId:i,deployHistoryId:m,onBeforePoll:()=>{ju([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Polling deployment status...")])},onStatusChange:e=>{const t=su(e.status);ju([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",s=>s({projectId:i,status:t,domain:ju([e,"access",e=>e.domain_list,"optionalAccess",e=>e[0]]),deployHistoryId:m,commitHash:e.commit_hash})])}}):ju([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({projectId:i,status:su(Ip.Pending),domain:"",deployHistoryId:m,commitHash:l})])}));!function(t){t.command("status <projectId>").description("Check deployment status").option("--deploy-id <deployId>","Deployment history ID (optional, queries latest if omitted)").config({help:{brief:"Query project deployment status",description:"Query the deployment status of a specified project. If no deployment history ID is specified, it automatically queries the latest deployment record. Supports viewing deployment progress, results, and error messages.",examples:[{desc:"Query latest deployment status",cmd:"coze code deploy status <projectId>",tags:["[RECOMMENDED]"]},{desc:"Query specific deployment record",cmd:"coze code deploy status <projectId> --deploy-id <deployHistoryId>"},{desc:"Wait for deployment to complete",cmd:"coze code deploy status <projectId> --wait"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},deployId:{type:"string",required:!1,description:"Deployment history ID (optional, queries latest if omitted)"},wait:{type:"boolean",required:!1,description:"Wait for deployment to complete"}},output:{projectId:{type:"string",description:"Project ID"},status:{type:"string",description:"Deployment status"},domain:{type:"string",description:"Deployed domain"},deployHistoryId:{type:"string",description:"Deployment history ID"},commitHash:{type:"string",description:"Commit hash"}}},errors:[{code:e.ErrorCode.E3006,name:"NO_DEPLOYMENT_HISTORY",desc:"No deployment history found for this project",fix:"Please deploy the project first using `coze code deploy <projectId>`"}]}}).action((async function(t,i,s){const o=s.getContext(),{deployId:n}=i,{wait:r}=Ru([s,"access",e=>e.parent,"optionalAccess",e=>e.opts,"call",e=>e()])||{};let a=n;if(!a&&(Ru([o,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("get latest deployment record...")]),a=await ru.getLatestDeployHistoryId({projectId:t}),!a))throw new e.CozeError(e.ErrorCode.E3006,"No deployment history found for this project");if(r)await ru.pollDeployStatus({projectId:t,deployHistoryId:a,onBeforePoll:()=>{Ru([o,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Polling deployment status...")])},onStatusChange:e=>{const i=su(e.status);Ru([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",s=>s({projectId:t,status:i,domain:Ru([e,"access",e=>e.domain_list,"optionalAccess",e=>e[0]]),deployHistoryId:a,commitHash:e.commit_hash})])}});else{Ru([o,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Querying deployment status...")]);const e=await ru.getDeployHistory({projectId:t,deployHistoryId:a}),i=su(e.status),s=e.domain_list||[];Ru([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",o=>o({projectId:t,status:i,domain:s[0],deployHistoryId:a,commitHash:e.commit_hash})])}}))}(s),function(e){e.command("list <projectId>").description("List deployment history for a project").option("--page-size <pageSize>","Number of records per page","10").option("--page-token <pageToken>","Page token for pagination").config({help:{brief:"List project deployment history",description:"List the deployment history of a specified project. Supports pagination to browse historical deployment records including status, commit hash, domains and timestamps.",examples:[{desc:"List deployment history",cmd:"coze code deploy list <projectId>",tags:["[RECOMMENDED]"]},{desc:"List with custom page size",cmd:"coze code deploy list <projectId> --page-size 20"},{desc:"List next page",cmd:"coze code deploy list <projectId> --page-token <token>"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},pageSize:{type:"number",required:!1,description:"Number of records per page (default: 10)"},pageToken:{type:"string",required:!1,description:"Page token for pagination"}},output:{type:"array",items:{deploy_history_id:{type:"string",description:"Deployment history ID"},status:{type:"string",description:"Deployment status"},commit_hash:{type:"string",description:"Commit hash"},domain_list:{type:"array",description:"Deployed domains"},created_at:{type:"string",description:"Creation timestamp"}}}}}}).action((async function(e,t,i){const s=i.getContext(),o=Number(t.pageSize)||10,n=(zu([await eu.PublicListDeployHistory({project_id:e,page_size:o,page_token:t.pageToken}),"optionalAccess",e=>e.data,"optionalAccess",e=>e.deploy_history_list])||[]).map((e=>({deploy_history_id:e.deploy_history_id,project_id:e.project_id,status:su(e.status),commit_hash:e.commit_hash_short||e.commit_hash,domain_list:e.domain_list,created_at:e.created_at,can_rollback:e.can_rollback})));zu([s,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(n)])}))}(s),function(t){t.command("fix <projectId>").description("Fix a failed deployment by sending deploy logs to AI").option("--deploy-id <deployId>","Deployment history ID (optional, queries latest failed if omitted)").option("--wait","Wait for fix message response").config({help:{brief:"Fix a failed deployment",description:"Diagnose and fix a failed deployment. Retrieves deploy logs and sends them to AI for analysis and automatic fix. Only works when the deployment status is Failed.",examples:[{desc:"Fix latest failed deployment",cmd:"coze code deploy fix -p <projectId>",tags:["[RECOMMENDED]"]},{desc:"Fix a specific deployment",cmd:"coze code deploy fix <projectId> --deploy-id <deployId>"},{desc:"Fix and wait for result",cmd:"coze code deploy fix <projectId> --wait"}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"},deployId:{type:"string",required:!1,description:"Deployment history ID (queries latest failed if omitted)"},wait:{type:"boolean",required:!1,description:"Wait for fix message response"}},output:{type:"object",properties:{deploy_history_id:{type:"string"},status:{type:"string"},message:{type:"string"}}}}}}).action((async function(t,i,s){const o=s.getContext();if(!o)throw new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized");const{deployId:n}=i,{wait:r}=Uu([s,"access",e=>e.parent,"optionalAccess",e=>e.opts,"call",e=>e()])||{};let a=n;if(n||(a=await ru.getLatestDeployHistoryId({projectId:t})),!a)throw new e.CozeError(e.ErrorCode.E5002,`No deploy history found for project ${t}`,{project_id:t});const c=Uu([await eu.PublicGetDeployHistory({project_id:t,deploy_history_id:a}),"optionalAccess",e=>e.data]);if(Uu([c,"optionalAccess",e=>e.status])!==Ip.Failed){const t=su(Uu([c,"optionalAccess",e=>e.status]));throw new e.CozeError(e.ErrorCode.E3009,`Deployment ${a} is not in Failed status (current: ${t}). Only failed deployments can be fixed.`,{deploy_history_id:a,status:Uu([c,"optionalAccess",e=>e.status])})}const l=c.deploy_log_url;if(!l)throw new e.CozeError(e.ErrorCode.E5002,`No deploy log URL found for deployment ${a}`,{deploy_history_id:a});const d=await e.customFetch.fetch(l,{method:"GET"}),p=await d.text();if(!p)throw new e.CozeError(e.ErrorCode.E5002,`Deploy log is empty for deployment ${a}`,{deploy_history_id:a,deploy_log_url:l});const u=`修复以下部署错误:\n${p}`,_=await Uu([o,"access",e=>e.auth,"optionalAccess",e=>e.getValidAccessToken,"call",e=>e()]);if(!_)throw new e.CozeError(e.ErrorCode.E2001,"Missing API token: set env COZE_API_TOKEN or run `coze auth login` first");if(r){const e=await ed.sendMessage({projectId:t,prompt:u,apiBaseUrl:o.config.apiBaseUrl,accessToken:_,xTTEnv:o.config.xTTEnv,key:`coze-coding-cli:message:${t}`});Uu([o,"optionalAccess",e=>e.response,"access",e=>e.print,"call",t=>t({deploy_history_id:a,status:"fix_sent",message:e.lastAnswerMessage})])}else ed.sendMessageRunTask({projectId:t,prompt:u,apiBaseUrl:o.config.apiBaseUrl,accessToken:_,xTTEnv:o.config.xTTEnv,key:`coze-coding-cli:message:${t}`})}))}(s)}function Ou(i){const s=i.command("code").description("Coze Coding CLI utilities").config({help:{brief:"Coze Coding project management",description:"Manage Coze Coding projects, including project creation, messaging, deployment, environment variables, domains, skills, and previews.",examples:[{desc:"Create a new project",cmd:'coze code project create --message "Create a chatbot" --type web'},{desc:"Send a message",cmd:'coze code message send "Fix the bug" -p <projectId>'},{desc:"Deploy project",cmd:"coze code deploy <projectId>"},{desc:"Preview project",cmd:"coze code preview <projectId>"}],seeAlso:["coze auth","coze space","coze organization"]}});bu(s),Lu(s),od(s),Cu(s),Iu(s),(e=>{const t=e.command("skill").config({help:{brief:"Manage project skills",description:"Manage skills associated with a project. Skills are important components to extend project capabilities, supporting adding, viewing, and removing project skills.",examples:[{desc:"List project skills",cmd:"coze code skill list -p <projectId>"},{desc:"Add skill",cmd:"coze code skill add <skillId> -p <projectId>"},{desc:"Remove skill",cmd:"coze code skill remove <skillId> -p <projectId>"}],seeAlso:["coze code project"]}}).description("Manage project skills");lc(t),pc(t),rc(t)})(s),function(i){i.command("preview <projectId>").description("Get deployment preview info for the project").config({help:{brief:"Get project preview URL",description:"Get the sandbox preview URL for the project. Supports AssistantAgent and GeneralWeb project types, returning an accessible preview URL. Sandbox initialization takes 1-3 minutes.",examples:[{desc:"Get preview URL",cmd:"coze code preview <projectId>",tags:["[RECOMMENDED]"]}],schema:{input:{projectId:{type:"string",required:!0,description:"Project ID"}},output:{type:{type:"string",description:"Project type"},preview_url:{type:"string",description:"Preview URL"}}},errors:[{code:e.ErrorCode.E1006,name:"UNSUPPORTED_PROJECT_TYPE",desc:"Unsupported project type",fix:"Preview feature only supports AssistantAgent and GeneralWeb project types"},{code:e.ErrorCode.E1000,name:"INVALID_ARGUMENT",desc:"Missing required argument: projectId",fix:"Pass <projectId> as the first argument: `coze code preview <projectId>`",example:"coze code preview 123456"}]}}).action((async function(i,s,o){const n=o.getContext();if(!i)throw new e.CozeError(e.ErrorCode.E1000,"Missing projectId: pass <projectId> as argument");const r=await t.IdeApi.GetVibeProject({project_id:i}),a=au([r,"access",e=>e.data,"optionalAccess",e=>e.project_info,"optionalAccess",e=>e.project_type]),c=au([r,"access",e=>e.data,"optionalAccess",e=>e.project_info,"optionalAccess",e=>e.name]),l={type:Kl(a)};if(!ed.isValidType(a))throw new e.CozeError(e.ErrorCode.E1006,"Unsupported project type",{projectId:i,type:a});if(a===t.VibeProjectType.Skill){const e=await ru.getCommitList({projectId:i});au([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e("Creating preview task...")]);const t=await bp.CreateCozeSpaceTask({task_name:`${c}-preview-${au([e,"access",e=>e[0],"optionalAccess",e=>e.id])}`,task_type:1,is_debug:!0,source_from:ip.UserCreate,mcp_tool_list:[]});l.preview_url=`https://www.coze.cn/task-m/${t.data.task.task_id}`,au([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Preview task created. Please access the preview URL: ${l.preview_url}`)])}else{const e=await t.IdeApi.InitSandbox({project_id:i});l.preview_url=e.token?`https://${e.project_host}?token=${e.token}`:`https://${e.project_host}`,au([n,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(`Sandbox initialization started. Please access the preview URL in 1-3 minutes,preview_url: ${l.preview_url}`)])}au([n,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e(l)])}))}(s)}const Bu=async e=>await new Promise((t=>setTimeout(t,e)));function xu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const qu=e=>{if(!e)return;const t=e.match(/filename\*\s*=\s*UTF-8''([^;]+)/i);if(xu([t,"optionalAccess",e=>e[1]]))return(e=>{try{return decodeURIComponent(e)}catch(t){return URIError,e}})(t[1]);const i=e.match(/filename\s*=\s*"([^"]+)"/i);if(xu([i,"optionalAccess",e=>e[1]]))return i[1];const s=e.match(/filename\s*=\s*([^;]+)/i);return xu([s,"optionalAccess",e=>e[1]])?s[1].trim():void 0},Du=async({url:t,outputPath:i,fetchImpl:s=t=>e.customFetch.fetch(t)})=>{const{buffer:o,response:n}=await(async(t,i)=>{const s=await i(t);if(!s.ok)throw new e.CozeError(e.ErrorCode.E5001,`Failed to download session file: ${s.status} ${s.statusText}`);return{buffer:Buffer.from(await s.arrayBuffer()),response:s}})(t,s),r=i||(e=>{const t=qu((i=e.contentDisposition,s=()=>null,null!=i?i:s()));var i,s;if(t)return t;for(const t of[e.responseUrl,e.requestUrl]){if(!t||!URL.canParse(t))continue;const e=new URL(t),i=c.basename(decodeURIComponent(e.pathname));if(i&&"/"!==i&&"."!==i)return i}return"session-file.bin"})({requestUrl:t,responseUrl:n.url,contentDisposition:n.headers.get("content-disposition")}),a=await vr(r,o);return{path:a,filename:c.basename(a),size:o.byteLength,url:t}},Mu="1008033";function Gu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const $u=async({baseUrl:t,headers:i,xTTEnv:s})=>{const n=new URL("/api/coze_claw/resource/get_frontier_key",o.normalizeBaseUrl(t));o.appendSearchParams(n,{aid:Mu});const r={...i,...o.getPpeHeaders(s)},a=await e.customFetch.fetch(n.toString(),{method:"GET",headers:r}),c=await o.parseServiceResponseBody(a,{}),l=o.getServiceResponseLogId(a);if(!a.ok)throw new Error(o.formatServiceErrorWithLogId({fallback:`Failed to get frontier key: ${a.status} ${a.statusText}`,logId:l,message:c.msg}));const d=Gu([c,"access",e=>e.data,"optionalAccess",e=>e.access_key]),p=Gu([c,"access",e=>e.data,"optionalAccess",e=>e.device_id]);if(!d||!p)throw new Error(o.formatServiceErrorWithLogId({fallback:"Frontier key response is incomplete",logId:l,message:c.msg}));return{accessKey:d,deviceId:p}};function Nu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const Fu=async({filePaths:t,clawId:i,sessionId:s,accessFile:o=u.access,createFileReadStream:n=d.openAsBlob,uploadFile:r})=>{const a=[];for(const l of t){try{await o(l)}catch(t){throw new e.CozeError(e.ErrorCode.E3000,`File not found or not readable: ${l}${t instanceof Error?` (${t.message})`:""}`)}const t=c.basename(l),d=await r({fileName:t,fileContent:await n(l),clawId:i,sessionId:s}),p=Nu([d,"access",e=>e.data,"optionalAccess",e=>e.file]);if(!Nu([p,"optionalAccess",e=>e.file_uri])||!Nu([p,"optionalAccess",e=>e.file_url]))throw new e.CozeError(e.ErrorCode.E5002,d.msg||`Failed to upload session file: ${l}`);a.push({file_name:p.file_name||t,file_uri:p.file_uri,file_url:p.file_url})}return a},Vu=async({filePaths:e,sessionId:t,apiBaseUrl:i,sessionApiBaseUrl:s,sessionSpaceWebId:n,xTTEnv:r,service:a,deps:c})=>{if(!e||0===e.length)return[];const l=Nu([c,"optionalAccess",e=>e.store])||o.createSessionConfigStore(),{sessionClawId:d}=await l.get(),p=d||(await a.getStatus()).clawId;if(!p)throw new o.SessionServiceError("Session token is missing or invalid","SESSION_AUTH_INVALID");const u=s||i,_=await(async({sessionSpaceWebId:e,baseUrl:t,xTTEnv:i})=>{if(e)return e;try{return(await $u({baseUrl:t,headers:{},xTTEnv:i})).deviceId}catch(e){return}})({sessionSpaceWebId:n,baseUrl:u,xTTEnv:r}),m=(Nu([c,"optionalAccess",e=>e.createApi])||o.createSessionApiClient)({baseUrl:u,webOrigin:u,xSpaceWebId:_,xTTEnv:r}),g=Nu([c,"optionalAccess",e=>e.uploadFiles])||Fu;return await g({filePaths:e,clawId:p,sessionId:t,uploadFile:({fileName:e,fileContent:t,clawId:i,sessionId:s})=>m.uploadFile({fileName:e,fileContent:t,clawId:i,sessionId:s})})};function Wu(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const Hu=1048576,Ku=/(?<![\w`])@(\.?[^\s`,.]*(?:\.[^\s`,.]+)*)/g,Ju=({absolutePath:e,root:t})=>{const i=c.relative(t,e);return Boolean(i)&&!i.startsWith("..")&&!c.isAbsolute(i)},Qu=async({onWarn:e,shouldWarnInvalidMention:t=()=>!0,statFile:i=u.stat,userInput:s,workTree:o})=>{(e=>{if(e.length>Hu)throw new Error("Message input is too long: max 1048576 characters")})(s);const n=[...s.matchAll(Ku)];if(0===n.length)return[{type:"text",text:s}];const r=[],a=c.resolve(o);let l=0;for(const o of n){const n=o.index,d=o[0],p=o[1];n>l&&r.push({type:"text",text:s.slice(l,n)});const u=c.resolve(a,p);let _=!1;if(Ju({absolutePath:u,root:a}))try{(await i(u)).isFile()?_=!0:t(p)&&Wu([e,"optionalCall",e=>e(`Uploading directories is not supported: ${p}`)])}catch(i){t(p)&&Wu([e,"optionalCall",e=>e(`File not found: ${p}`)])}_?r.push({type:"file",absolutePath:u,rawMention:d,relativePath:p}):r.push({type:"text",text:d}),l=n+d.length}return l<s.length&&r.push({type:"text",text:s.slice(l)}),r};const Yu=e=>{if(null==e)return null;const t=e.trim();return 0===t.length?null:t},Zu=e=>e.includes("/")||e.includes("\\")||e.includes(".")||e.startsWith("."),Xu=async(e,t={})=>{const i=await(async e=>{const t=await hr(),i=Yu(e),s=Yu(t);return i||s?i&&s?`${i}\n\n${s}`:(n=()=>s,null!=(o=i)?o:n()):null;var o,n})(e);if(!i)return{content:i,filePaths:[]};const s=await Qu({onWarn:t.onWarn,shouldWarnInvalidMention:Zu,userInput:i,workTree:t.cwd||process.cwd()}),o=[];return{content:Yu(s.map((e=>"text"===e.type?e.text:(o.push(e.absolutePath),""))).join("")),filePaths:o}};const e_=e=>function(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}([e,"optionalAccess",e=>e.trim,"call",e=>e(),"access",e=>e.toLowerCase,"call",e=>e()])||"",t_=async({baseUrl:t,xTTEnv:i,fetchImpl:s=e.customFetch.fetch.bind(e.customFetch)})=>{const o={"content-type":"application/json"};i&&(o["x-use-ppe"]="1",o["x-tt-env"]=i);const n=await s(`${(e=>new URL(e).origin)(t)}/api/coze_space/get_podcast_config`,{method:"POST",headers:o,body:"{}"});if(!n.ok)throw new e.CozeError(e.ErrorCode.E5001,`Failed to fetch podcast config: ${String(n.status||"")} ${String(n.statusText||"")}`.trim());const r=await n.json();if(0!==r.code&&void 0!==r.code)throw new e.CozeError(e.ErrorCode.E5002,r.msg||"Failed to fetch podcast config");return r.data||{}},i_=({config:t,mode:i,keyword:s})=>{const o=(({config:t,mode:i})=>{if(!i)return;const s=e_(i),o=(t.mode_options||[]).find((e=>e_(e.value)===s||e_(e.label)===s));if(!o)throw new e.CozeError(e.ErrorCode.E1000,`Podcast mode not found: ${i}`);return o})({config:t,mode:i}),n=e_(s);return(o?[o]:t.mode_options||[]).flatMap((e=>(e.voice_options||[]).map((t=>({mode_label:e.label,mode_value:e.value,label:t.label,value:t.value,sample:t.sample,color_code:t.color_code}))).filter((e=>!n||(e_(e.label).includes(n)||e_(e.value).includes(n))))))};function s_(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}class o_ extends b{constructor(e,t){super((e=>{const t=new URL(e);return t.searchParams.set("aid",Mu),t.toString()})(e),"pbbp2",{headers:{...t,Origin:"https://www.coze.cn"}})}}class n_{constructor(){n_.prototype.__init.call(this)}__init(){this.fws=null}connect(t,i,s){return new Promise(((o,n)=>{let r=!1,a=!1;const c=e=>{if(!a)return a=!0,void n(e);s_([s,"optionalCall",t=>t(e)])},l={fpID:"1289",aID:Mu,accessKey:t.accessKey,deviceID:t.deviceId,url:"wss://frontier.coze.cn",automaticOpen:!0,enableQoS:!1,enableAutoAck:!1,ws:class extends o_{constructor(e){super(e,t.headers)}}};this.fws=new w.FWS(l);const d=setTimeout((()=>{a=!0,this.dispose(),n(new Error("Frontier connection timeout"))}),(p=t.timeoutMs,u=()=>1e4,null!=p?p:u()));var p,u;this.fws.onopen=()=>{r=!0,a=!0,clearTimeout(d),o()},this.fws.onerror=()=>{clearTimeout(d),c(new Error(r?"Frontier connection failed after connect":"Frontier connection failed"))},this.fws.onclose=()=>{clearTimeout(d),c(new Error(r?"Frontier connection closed after connect":"Frontier connection closed"))},this.fws.onmessage=t=>{const s=s_([t,"access",e=>e.message,"optionalAccess",e=>e.payloadType]),o=s_([t,"access",e=>e.message,"optionalAccess",e=>e.service]),n=s_([t,"access",e=>e.message,"optionalAccess",e=>e.payload]);if(!s||!n)return;const r=new TextDecoder("utf-8").decode(n),a=e.safeJsonParse(r,r);i({service:o,event:s,data:a})}}))}dispose(){s_([this,"access",e=>e.fws,"optionalAccess",e=>e.close,"call",e=>e()]),this.fws=null}}function r_(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const a_=(e,t)=>{const i=t.toLowerCase(),s=Object.entries(e).find((([e])=>e.toLowerCase()===i));return r_([s,"optionalAccess",e=>e[1]])},c_=e=>JSON.stringify({accessKey:e.accessKey,authorization:a_(e.headers,"authorization"),deviceId:e.deviceId,serviceId:e.serviceId,xTTEnv:a_(e.headers,"x-tt-env")}),l_=e=>"function"==typeof e.resolveConfig&&"string"==typeof e.scopeKey;class d_{__init(){this.entries=new Map}constructor(e){d_.prototype.__init.call(this),this.createClient=r_([e,"optionalAccess",e=>e.createClient])||(()=>new n_),this.getScopeKey=r_([e,"optionalAccess",e=>e.getScopeKey])||c_}async subscribe(e,t){const i=((e,t)=>l_(e)?e.scopeKey:t(e))(e,this.getScopeKey);let s=this.entries.get(i);s||(s=this.createEntry(i,e),this.entries.set(i,s)),s.subscribers.add(t);try{await s.connectPromise}catch(e){throw s.subscribers.delete(t),e}let o=!1;return{release:()=>{o||(o=!0,this.releaseSubscriber(i,s,t))}}}createEntry(e,t){const i=this.createClient(),s={client:i,connectPromise:Promise.resolve(),subscribers:new Set};return s.connectPromise=(async e=>l_(e)?await e.resolveConfig():e)(t).then((async t=>{await i.connect(t,(t=>{this.emitEvent(e,t)}),(t=>{this.handleConnectionError(e,t)}))})).catch((t=>{throw this.entries.get(e)===s&&this.entries.delete(e),s.subscribers.clear(),i.dispose(),t})),s}emitEvent(e,t){const i=this.entries.get(e);if(i)for(const e of i.subscribers)e.onEvent(t)}handleConnectionError(e,t){const i=this.entries.get(e);if(!i)return;this.entries.delete(e);const s=[...i.subscribers];i.subscribers.clear(),i.client.dispose();for(const e of s)r_([e,"access",e=>e.onError,"optionalCall",e=>e(t)])}releaseSubscriber(e,t,i){t.subscribers.delete(i),t.subscribers.size>0||(this.entries.get(e)===t&&this.entries.delete(e),t.client.dispose())}}const p_=new d_;function u_(e,t){return null!=e?e:t()}function __(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const m_=e=>({...e,files:e.files?[...e.files]:void 0}),g_=e=>e?JSON.stringify(e.map((e=>({file_name:e.file_name,file_uri:e.file_uri,file_url:e.file_url,preview_url:e.preview_url})))):"";class h_{constructor(){h_.prototype.__init.call(this)}__init(){this.sessionStates=new Map}applyReplyEvent(t,i){const s=i.session_id;if(!s||!(e=>2===Number(e.source))(i))return null;const o=(({data:t,event:i})=>{const s=__([e.safeJsonParse(t.content,null),"optionalAccess",e=>e.message_data,"optionalAccess",e=>e.reply]),o=t.id,n="message"===i?__([s,"optionalAccess",e=>e.content])||t.content:__([s,"optionalAccess",e=>e.content]);return o&&n?{answerId:o,content:n,files:t.files,requestMessageId:__([s,"optionalAccess",e=>e.reply_to_message_id])}:null})({data:i,event:t});if(!o)return null;const n=this.getOrCreateSessionState(s),r=n.replies.get(o.answerId),a={answerId:o.answerId,content:"stream"===t&&r?r.content+o.content:o.content,files:u_(o.files,(()=>__([r,"optionalAccess",e=>e.files]))),requestMessageId:u_(o.requestMessageId,(()=>__([r,"optionalAccess",e=>e.requestMessageId])))};return"message"===t&&!r&&(({nextReply:e,sessionState:t})=>{for(const i of t.replies.values())if(i.requestMessageId===e.requestMessageId&&i.content===e.content&&g_(i.files)===g_(e.files))return!0;return!1})({nextReply:a,sessionState:n})?null:(n.replies.has(o.answerId)||n.replyOrder.push(o.answerId),n.replies.set(o.answerId,a),"stream"===t?{type:"reply_chunk",sessionId:s,source:"stream",chunk:{answerId:o.answerId,content:o.content,requestMessageId:o.requestMessageId}}:{type:"reply_update",sessionId:s,source:"message",reply:m_(a)})}applySessionIdleEvent(e){const t=__([e,"optionalAccess",e=>e.session_id]);if(!t||2!==Number(e.status))return null;const i=this.sessionStates.get(t);if(!i)return null;return{type:"session_idle",sessionId:t,replies:i.replyOrder.map((e=>i.replies.get(e))).filter((e=>Boolean(e))).map((e=>m_(e)))}}getOrCreateSessionState(e){const t=this.sessionStates.get(e);if(t)return t;const i={replies:new Map,replyOrder:[]};return this.sessionStates.set(e,i),i}}function f_(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const y_=e=>({type:"progress_update",progress:e});class v_{constructor(){v_.prototype.__init.call(this)}__init(){this.progressStates=new Map}getKnownClawIds(){return this.progressStates.keys()}getKnownProgressEvents(e){const t=this.progressStates.get(e);return t?[...t.values()].map((t=>y_({progressId:t.progressId,clawId:e,name:t.name,progressType:t.progressType,progressStatus:t.progressStatus}))):[]}applyFrontierEvent(e){const t=f_([e,"optionalAccess",e=>e.claw_id]),i=f_([e,"optionalAccess",e=>e.id]);if(!t||!i)return null;const s=2===Number(e.status)?"finished":1===Number(e.status)?"running":null;if(!s)return null;const o={progressId:i,clawId:t,name:e.name,progressType:e.type,progressStatus:s};return this.updateKnownProgressState(o),y_(o)}applySnapshot(e,t){const i=this.getOrCreateProgressState(e),s=new Set,o=[];t.forEach((t=>{s.add(t.progressId);const n={progressId:t.progressId,clawId:e,name:t.name,progressType:t.progressType,progressStatus:t.progressStatus},r=i.get(t.progressId);i.set(t.progressId,n),((e,t)=>Boolean(e&&e.name===t.name&&e.progressType===t.progressType&&e.progressStatus===t.progressStatus))(r,n)||o.push(y_({progressId:n.progressId,clawId:e,name:n.name,progressType:n.progressType,progressStatus:n.progressStatus}))}));for(const t of[...i.values()])s.has(t.progressId)||(i.delete(t.progressId),o.push(y_({progressId:t.progressId,clawId:e,name:t.name,progressType:t.progressType,progressStatus:"finished"})));return 0===i.size&&this.progressStates.delete(e),o}updateKnownProgressState(e){const t=this.getOrCreateProgressState(e.clawId);if("finished"===e.progressStatus)return t.delete(e.progressId),void(0===t.size&&this.progressStates.delete(e.clawId));t.set(e.progressId,{progressId:e.progressId,clawId:e.clawId,name:e.name,progressType:e.progressType,progressStatus:e.progressStatus})}getOrCreateProgressState(e){const t=this.progressStates.get(e);if(t)return t;const i=new Map;return this.progressStates.set(e,i),i}}class b_{__init(){this.progressPollTimers=new Map}__init2(){this.progressRefreshes=new Map}constructor({emitProgressUpdate:e,globalStreamKey:t,hasConnectionError:i,hasSubscribers:s,listProgresses:o,progressPollIntervalMs:n=3e4,progressStateStore:r}){b_.prototype.__init.call(this),b_.prototype.__init2.call(this),this.emitProgressUpdate=e,this.globalStreamKey=t,this.hasConnectionError=i,this.hasSubscribers=s,this.listProgresses=o,this.progressPollIntervalMs=n,this.progressStateStore=r}ensure(e){if(!this.listProgresses||this.progressPollTimers.has(e))return;const t=async()=>{if(this.progressPollTimers.delete(e),!this.hasSubscribers(e)||this.hasConnectionError())return;if(await this.refresh(e),!this.hasSubscribers(e)||this.hasConnectionError())return;const i=setTimeout((()=>{t()}),this.progressPollIntervalMs);this.progressPollTimers.set(e,i)},i=setTimeout((()=>{t()}),this.progressPollIntervalMs);this.progressPollTimers.set(e,i)}stop(e){const t=this.progressPollTimers.get(e);t&&(clearTimeout(t),this.progressPollTimers.delete(e))}stopAll(){for(const e of this.progressPollTimers.values())clearTimeout(e);this.progressPollTimers.clear()}async refresh(e){if(!this.listProgresses)return;const t=this.progressRefreshes.get(e);if(t)return void await t;const i=(async()=>{const{listProgresses:t}=this;if(!t)return;const i=await t(e);this.progressStateStore.applySnapshot(e,i).forEach((t=>{this.emitProgressUpdate(e,t),this.emitProgressUpdate(this.globalStreamKey,t)}))})().finally((()=>{this.progressRefreshes.delete(e)}));this.progressRefreshes.set(e,i),await i}}class w_{__init(){this.closed=!1}__init2(){this.error=null}__init3(){this.queue=[]}constructor(e){this.cleanup=e,w_.prototype.__init.call(this),w_.prototype.__init2.call(this),w_.prototype.__init3.call(this)}push(e){if(!this.closed){if(this.pending){const{pending:t}=this;return this.pending=void 0,void t.resolve({done:!1,value:e})}this.queue.push(e)}}close(){if(!this.closed&&(this.closed=!0,this.cleanup(),this.pending)){const{pending:e}=this;this.pending=void 0,e.resolve({done:!0,value:void 0})}}fail(e){if(!this.closed&&(this.closed=!0,this.error=e,this.queue.length=0,this.cleanup(),this.pending)){const{pending:t}=this;this.pending=void 0,t.reject(e)}}async next(){if(this.queue.length>0){return{done:!1,value:this.queue.shift()}}if(this.error)throw this.error;return this.closed?{done:!0,value:void 0}:await new Promise(((e,t)=>{this.pending={reject:t,resolve:e}}))}async return(){return this.close(),{done:!0,value:void 0}}[Symbol.asyncIterator](){return this}}function P_(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const S_="*";class T_{__init(){this.connectionError=null}__init2(){this.disposed=!1}__init3(){this.replyStateStore=new h_}__init4(){this.progressStateStore=new v_}__init5(){this.sessionStreams=new Map}__init6(){this.progressStreams=new Map}constructor(e){T_.prototype.__init.call(this),T_.prototype.__init2.call(this),T_.prototype.__init3.call(this),T_.prototype.__init4.call(this),T_.prototype.__init5.call(this),T_.prototype.__init6.call(this),this.connectionManager=P_([e,"optionalAccess",e=>e.connectionManager])||(P_([e,"optionalAccess",e=>e.client])?new d_({createClient:()=>e.client}):p_),this.progressPoller=new b_({emitProgressUpdate:(e,t)=>{this.emitToProgress(e,t)},globalStreamKey:S_,hasConnectionError:()=>Boolean(this.connectionError),hasSubscribers:e=>this.hasProgressSubscribers(e),listProgresses:P_([e,"optionalAccess",e=>e.listProgresses]),progressPollIntervalMs:P_([e,"optionalAccess",e=>e.progressPollIntervalMs]),progressStateStore:this.progressStateStore})}async connect(e){if(this.disposed)throw new Error("Frontier watcher disposed");if(this.lastConnectionRequest=e,this.connectionLease)return;this.connecting||(this.connecting=this.connectionManager.subscribe(e,{onError:e=>{this.handleConnectionError(e)},onEvent:e=>{this.handleEvent(e)}}).then((e=>(this.connectionLease=e,this.connectionError=null,e))).finally((()=>{this.connecting=void 0})));const t=await this.connecting;this.disposed&&(t.release(),this.connectionLease=void 0)}async ensureConnected(){if(this.connectionLease||this.connecting)await this.connecting;else{if(!this.lastConnectionRequest){if(this.connectionError)throw this.connectionError;throw new Error("Frontier watcher is not connected")}await this.connect(this.lastConnectionRequest)}}watchSession(e,t){const i=new w_((()=>{this.removeStream(e,i),P_([t,"optionalAccess",e=>e.signal,"optionalAccess",e=>e.removeEventListener,"call",e=>e("abort",s)])})),s=()=>{i.close()};if(this.disposed)return i.fail(new Error("Frontier watcher disposed")),i;if(this.connectionError)return i.fail(this.connectionError),i;if(P_([t,"optionalAccess",e=>e.signal,"optionalAccess",e=>e.aborted]))return i.close(),i;let o=this.sessionStreams.get(e);return o||(o=new Set,this.sessionStreams.set(e,o)),o.add(i),P_([t,"optionalAccess",e=>e.signal,"optionalAccess",e=>e.addEventListener,"call",e=>e("abort",s,{once:!0})]),i}watchProgress(e,t){const i=e||S_,s=new w_((()=>{this.removeProgressStream(i,s),P_([t,"optionalAccess",e=>e.signal,"optionalAccess",e=>e.removeEventListener,"call",e=>e("abort",o)])})),o=()=>{s.close()};if(this.disposed)return s.fail(new Error("Frontier watcher disposed")),s;if(this.connectionError)return s.fail(this.connectionError),s;if(P_([t,"optionalAccess",e=>e.signal,"optionalAccess",e=>e.aborted]))return s.close(),s;let n=this.progressStreams.get(i);if(n||(n=new Set,this.progressStreams.set(i,n)),n.add(s),P_([t,"optionalAccess",e=>e.signal,"optionalAccess",e=>e.addEventListener,"call",e=>e("abort",o,{once:!0})]),e)this.emitKnownProgresses(s,e),this.progressPoller.refresh(e),this.progressPoller.ensure(e);else for(const e of this.progressStateStore.getKnownClawIds())this.emitKnownProgresses(s,e);return s}dispose(){if(!this.disposed){if(this.disposed=!0,this.progressPoller.stopAll(),this.failAllStreams(new Error("Frontier watcher disposed")),this.connectionLease)return this.connectionLease.release(),void(this.connectionLease=void 0);this.connecting&&this.connecting.then((e=>{e.release(),this.connectionLease===e&&(this.connectionLease=void 0)})).catch((()=>{}))}}removeStream(e,t){const i=this.sessionStreams.get(e);i&&(i.delete(t),0===i.size&&this.sessionStreams.delete(e))}removeProgressStream(e,t){const i=this.progressStreams.get(e);i&&(i.delete(t),0===i.size&&(this.progressStreams.delete(e),e!==S_&&this.progressPoller.stop(e)))}failAllStreams(e){for(const t of this.sessionStreams.values())for(const i of t)i.fail(e);this.sessionStreams.clear();for(const t of this.progressStreams.values())for(const i of t)i.fail(e);this.progressStreams.clear()}handleConnectionError(e){this.connectionError=e,this.connectionLease=void 0,this.progressPoller.stopAll(),this.failAllStreams(e)}handleEvent(e){33555657===e.service&&("message"!==e.event&&"stream"!==e.event?"session"!==e.event?"process"===e.event&&this.handleProgressEvent(e.data):this.handleSessionEvent(e.data):this.handleReplyEvent(e.event,e.data))}handleReplyEvent(e,t){const i=this.replyStateStore.applyReplyEvent(e,t);i&&"sessionId"in i&&this.emitToSession(i.sessionId,i)}handleSessionEvent(e){const t=this.replyStateStore.applySessionIdleEvent(e);t&&"sessionId"in t&&this.emitToSession(t.sessionId,t)}handleProgressEvent(e){const t=this.progressStateStore.applyFrontierEvent(e);if(!t)return;const{clawId:i}=t.progress;this.emitToProgress(i,t),this.emitToProgress(S_,t)}emitToSession(e,t){const i=this.sessionStreams.get(e);if(i&&0!==i.size)for(const e of i)e.push(t)}emitToProgress(e,t){const i=this.progressStreams.get(e);if(i&&0!==i.size)for(const e of i)e.push(t)}emitKnownProgresses(e,t){this.progressStateStore.getKnownProgressEvents(t).forEach((t=>{e.push(t)}))}hasProgressSubscribers(e){const t=this.progressStreams.get(e);return Boolean(t&&t.size>0)}}function C_(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const k_=({replies:e,requestMessageId:t,source:i})=>{if(0===e.length)return null;const s=C_([e,"access",t=>t[e.length-1],"optionalAccess",e=>e.answerId]);return s?{answerId:s,content:e.map((e=>e.content)).filter(Boolean).join("\n\n"),files:C_([e,"access",t=>t[e.length-1],"optionalAccess",e=>e.files]),requestMessageId:t,source:i}:null},A_=({replies:e,replyOrder:t,reply:i})=>{e.has(i.answerId)||t.push(i.answerId),e.set(i.answerId,i)},E_=({event:e,replies:t,replyOrder:i})=>{const s=t.get(e.chunk.answerId),o={answerId:e.chunk.answerId,content:`${C_([s,"optionalAccess",e=>e.content])||""}${e.chunk.content}`,files:C_([s,"optionalAccess",e=>e.files]),requestMessageId:e.chunk.requestMessageId||C_([s,"optionalAccess",e=>e.requestMessageId])};return A_({replies:t,reply:o,replyOrder:i}),o},I_=({event:e,replies:t,replyOrder:i})=>(A_({replies:t,reply:e.reply,replyOrder:i}),e.reply);class R_{constructor(e){this.watcher=C_([e,"optionalAccess",e=>e.watcher])||new T_}async connect(e){await this.watcher.connect(e)}async waitForReply(e){const{onReplyChunk:t,onReplyUpdate:i,sessionId:s,requestMessageId:o,timeoutMs:n}=e;if(this.pending)throw new Error("Frontier waiter already has a pending reply request");await this.watcher.ensureConnected();const r=new AbortController;return await new Promise(((e,a)=>{const c=new Map,l=[];let d=!1;const p=t=>{d||(d=!0,C_([this,"access",e=>e.pending,"optionalAccess",e=>e.timer])&&clearTimeout(this.pending.timer),this.pending=void 0,r.abort(),t({reject:a,resolve:e}))},u=void 0===n?void 0:setTimeout((()=>{const e=k_({replies:l.map((e=>c.get(e))).filter((e=>Boolean(e))),requestMessageId:o,source:"timeout"});p((({reject:t,resolve:i})=>{e?i(e):t(new Error("Timed out waiting for Frontier reply"))}))}),n);this.pending={controller:r,reject:a,timer:u},(async()=>{try{const e=(async()=>{for await(const e of this.watcher.watchSession(s,{signal:r.signal})){if("reply_chunk"===e.type){if(e.chunk.requestMessageId!==o)continue;E_({event:e,replies:c,replyOrder:l}),C_([t,"optionalCall",t=>t(e)]);continue}if("reply_update"===e.type){if(e.reply.requestMessageId!==o)continue;I_({event:e,replies:c,replyOrder:l}),C_([i,"optionalCall",t=>t(e)]);continue}if("session_idle"!==e.type)continue;const s=k_({replies:e.replies.filter((e=>e.requestMessageId===o)),requestMessageId:o,source:"idle"});s&&p((({resolve:e})=>{e(s)}))}})();await e}catch(e){p((({reject:t})=>{t(e instanceof Error?e:new Error(String(e)))}))}})()}))}dispose(){this.pending&&(this.pending.timer&&clearTimeout(this.pending.timer),this.pending.controller.abort(),this.pending.reject(new Error("Frontier waiter disposed")),this.pending=void 0),this.watcher.dispose()}}const z_={skipOrgCheck:!0,skipSpaceCheck:!0},U_=async t=>{if(t)return t;const i=o.createSessionConfigStore(),s=await i.get();if(s.sessionId)return s.sessionId;throw new e.CozeError(e.ErrorCode.E1000,"Missing session ID: provide --session-id or run `coze session create` first")},j_=async({clawId:e,sessionId:t})=>{const i=o.createSessionConfigStore();await i.save({sessionId:t,...e?{sessionClawId:e}:{}})},L_=({timeoutMs:e})=>{const t=new AbortController,i=()=>{t.abort()},s=void 0===e?void 0:setTimeout((()=>{i()}),e);return process.once("SIGINT",i),{abort:i,signal:t.signal,dispose:()=>{s&&clearTimeout(s),process.off("SIGINT",i)}}},O_=async(t,i)=>{const s=(t=>{const i=t.getContext();if(!i)throw new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized");return{ctx:i,service:o.createDefaultSessionService(i.config)}})(t);try{await i(s)}catch(t){W((t=>{if(t instanceof e.CozeError)return t;if(t instanceof o.SessionServiceError){const i="SESSION_AUTH_INVALID"===t.code?e.ErrorCode.E2001:e.ErrorCode.E5000;return new e.CozeError(i,t.message,{session_error:t.code})}return t instanceof Error?new e.CozeError(e.ErrorCode.E5000,t.message,t.stack):new e.CozeError(e.ErrorCode.E5000,String(t))})(t),s.ctx)}},B_=t=>{const i=Number.parseInt(t,10);if(!Number.isFinite(i)||i<=0)throw new e.CozeError(e.ErrorCode.E1000,"Invalid value for --limit: expected a positive integer");return i},x_=t=>{const i=Number.parseInt(t,10);if(!Number.isFinite(i)||i<=0)throw new e.CozeError(e.ErrorCode.E1000,"Invalid value for --timeout: expected a positive integer");return i},q_=e=>{if(!e||0===e.length)return null;const t=["Files:"];return e.forEach(((e,i)=>{t.push(`${i+1}. ${String(e.file_name||"unnamed-file")}`),e.file_url&&t.push(`file_url: ${String(e.file_url)}`),e.preview_url&&t.push(`preview_url: ${String(e.preview_url)}`)})),t.join("\n")},D_=(e,t)=>{const i=q_(t);return i?[e,"",i].join("\n"):e},M_=({accessToken:e,apiBaseUrl:t,sessionApiBaseUrl:i,xTTEnv:s})=>{const n=i||t,r=(({accessToken:e,xTTEnv:t})=>{if(!e)throw new o.SessionServiceError("Session token is missing or invalid","SESSION_AUTH_INVALID");const i={Authorization:`Bearer ${e}`};return t&&(i["x-use-ppe"]="1",i["x-tt-env"]=t),i})({accessToken:e,xTTEnv:s});return{resolveConfig:async()=>({...await $u({baseUrl:n,headers:r,xTTEnv:s}),headers:r}),scopeKey:JSON.stringify({baseUrl:n,authorization:r.Authorization,xTTEnv:s})}},G_=async({accessToken:e,apiBaseUrl:t,sessionApiBaseUrl:i,progressPollIntervalMs:s,service:o,xTTEnv:n})=>{const r=new T_({listProgresses:o?async e=>(await o.listProgresses({clawId:e})).map((t=>({progressId:t.progressId,clawId:e,name:t.name,progressType:t.type,progressStatus:t.progressStatus}))):void 0,progressPollIntervalMs:s});return await r.connect(M_({accessToken:e,apiBaseUrl:t,sessionApiBaseUrl:i,xTTEnv:n})),r},$_=e=>[`progress_id: ${e.progressId}`,e.name?`name: ${e.name}`:null,e.type?`type: ${e.type}`:null,`progress_status: ${e.progressStatus}`].filter(Boolean).join("\n"),N_=e=>`${JSON.stringify(e)}\n`;class F_{__init(){this.replyStates=new Map}__init2(){this.requestPrintedContent=new Map}__init3(){this.endsWithNewline=!0}__init4(){this.hasStartedReply=!1}constructor(e){F_.prototype.__init.call(this),F_.prototype.__init2.call(this),F_.prototype.__init3.call(this),F_.prototype.__init4.call(this),this.format=e.format,this.includeReplyMetadata=e.includeReplyMetadata||!1,this.write=e.write||(e=>process.stdout.write(e))}writeChunk({chunk:e,sessionId:t}){if("text"!==this.format)return void this.write(N_({type:"reply_chunk",session_id:t,answer_message_id:e.answerId,reply_to_message_id:e.requestMessageId,delta:e.content}));const i=this.getOrCreateReplyState(e.answerId);this.ensureReplyStarted({answerId:e.answerId,requestMessageId:e.requestMessageId,state:i}),this.writeRaw(e.content),i.printedContent+=e.content,this.updateRequestPrintedContent({requestMessageId:e.requestMessageId,printedContent:i.printedContent})}writeReply({files:e,reply:t,sessionId:i,source:s}){if("text"!==this.format)return void this.write(N_({type:"message"===s?"reply_update":"reply_completed",session_id:i,answer_message_id:t.answerId,reply_to_message_id:t.requestMessageId,content:t.content,files:e,event_source:s}));const o=this.getOrCreateReplyState(t.answerId),n=this.getPreviousPrintedContent({reply:t,state:o}),r=this.getSnapshotDelta({nextContent:t.content,previousContent:n}),a=this.continuesPrintedRequest({reply:t,state:o});if(!r&&"message"!==s)return this.updateReplyStateContent({reply:t,state:o}),void this.writeFinalReplyMetadata({files:e});this.ensureReplyStarted({answerId:t.answerId,requestMessageId:t.requestMessageId,state:o,continuesPrintedRequest:a}),r&&this.writeRaw(r),this.updateReplyStateContent({reply:t,state:o}),"message"!==s&&this.writeFinalReplyMetadata({files:e})}writeFinalReplyMetadata({files:e}){this.endsWithNewline||this.writeRaw("\n");const t=q_(e);t&&this.writeRaw(`\n${t}\n`)}writeProgress({progress:e,sessionId:t}){"text"===this.format?(this.endsWithNewline||this.writeRaw("\n"),this.writeRaw(`\n${$_(e)}\n`)):this.write(N_({type:"background_progress_started",session_id:t,progress_id:e.progressId,progress_name:e.name,progress_type:e.type,progress_status:e.progressStatus}))}getOrCreateReplyState(e){const t=this.replyStates.get(e);if(t)return t;const i={headerPrinted:!1,printedContent:""};return this.replyStates.set(e,i),i}ensureReplyStarted({answerId:e,continuesPrintedRequest:t=!1,requestMessageId:i,state:s}){if(!s.headerPrinted){if(t)return s.headerPrinted=!0,void(this.hasStartedReply=!0);if(this.hasStartedReply&&(this.endsWithNewline||this.writeRaw("\n"),this.writeRaw("\n")),this.includeReplyMetadata){const t=[`answer_message_id: ${e}`,i?`reply_to_message_id: ${i}`:null].filter(Boolean);this.writeRaw(`${t.join("\n")}\n`)}s.headerPrinted=!0,this.hasStartedReply=!0}}getSnapshotDelta({nextContent:e,previousContent:t}){return t?e===t?"":e.startsWith(t)?e.slice(t.length):`\n${e}`:e}getPreviousPrintedContent({reply:e,state:t}){return e.requestMessageId&&this.requestPrintedContent.has(e.requestMessageId)?this.requestPrintedContent.get(e.requestMessageId)||"":t.printedContent}continuesPrintedRequest({reply:e,state:t}){return Boolean(e.requestMessageId&&!t.headerPrinted&&this.requestPrintedContent.has(e.requestMessageId))}updateReplyStateContent({reply:e,state:t}){t.printedContent=e.content,this.updateRequestPrintedContent({requestMessageId:e.requestMessageId,printedContent:e.content})}updateRequestPrintedContent({printedContent:e,requestMessageId:t}){if(!t)return;const i=this.requestPrintedContent.get(t)||"";e.length>=i.length&&this.requestPrintedContent.set(t,e)}writeRaw(e){e&&(this.write(e),this.endsWithNewline=e.endsWith("\n"))}}function V_(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const W_=({ctx:e,sessionId:t,reply:i,files:s,source:o})=>{"text"!==e.format?e.response.print({session_id:t,answer_message_id:i.answerId,reply_to_message_id:i.requestMessageId,content:i.content,files:s,event_source:o}):e.response.print((({reply:e,files:t,source:i})=>`${[`answer_message_id: ${e.answerId}`,e.requestMessageId?`reply_to_message_id: ${e.requestMessageId}`:null,`event_source: ${i}`].filter(Boolean).join("\n")}\n${D_(e.content,t)}`)({files:s,reply:i,source:o}))},H_=({ctx:e,options:t,service:i,streamRenderer:s})=>{const n=t.snapshot?new Map:null,r=async t=>await o.resolveStoredSessionReplyFiles({files:t.files,apiBaseUrl:e.config.apiBaseUrl,sessionApiBaseUrl:e.config.sessionApiBaseUrl,xTTEnv:e.config.xTTEnv,service:i}),a=async({reply:i,source:s})=>{const o=await r(i),a=(({files:e,reply:t})=>JSON.stringify({answerId:t.answerId,content:t.content,files:e,requestMessageId:t.requestMessageId}))({files:o,reply:i});V_([n,"optionalAccess",e=>e.get,"call",e=>e(i.answerId)])!==a&&(V_([n,"optionalAccess",e=>e.set,"call",e=>e(i.answerId,a)]),W_({ctx:e,files:o,reply:i,sessionId:t.sessionId,source:s}))};return{handleReplyChunk:e=>{V_([s,"optionalAccess",e=>e.writeChunk,"call",i=>i({chunk:e.chunk,sessionId:t.sessionId})])},handleReplyUpdate:async e=>{s?s.writeReply({reply:e.reply,sessionId:t.sessionId,source:"message"}):await a({reply:e.reply,source:"message"})},handleIdleReply:async e=>{s?s.writeReply({files:await r(e),reply:e,sessionId:t.sessionId,source:"idle"}):await a({reply:e,source:"idle"})}}},K_=e=>{e.command("watch").description("Watch websocket replies for a claw session").option("-s, --session-id <sessionId>","Target session ID; defaults to the most recently used local session").option("--timeout <timeoutMs>","Stop watching after the specified timeout in milliseconds",x_).option("--snapshot","Print full reply snapshots instead of streaming chunks incrementally").config({...z_,help:{brief:"Continuously watch websocket replies for a session",description:"Subscribe to Frontier websocket events for the specified session and stream assistant output as it arrives. Use --snapshot to keep the previous snapshot-style behavior.",examples:[{desc:"Watch one session until interrupted",cmd:"coze session watch -s 123456789",tags:["[RECOMMENDED]"]},{desc:"Watch one session and exit after 30 seconds",cmd:"coze session watch -s 123456789 --timeout 30000"},{desc:"Keep the old snapshot-style output",cmd:"coze session watch -s 123456789 --snapshot"}],schema:{input:{session_id:{type:"string",required:!1,description:"Target session ID. Defaults to the most recently used local session"},timeout:{type:"number",required:!1,description:"Optional timeout in milliseconds"}},output:{type:"object",properties:{session_id:{type:"string"},answer_message_id:{type:"string"},reply_to_message_id:{type:"string"},content:{type:"string"},event_source:{type:"string"}}}}}}).action((async(e,t)=>{await(async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{const s=await U_(e.sessionId),o={...e,sessionId:s},n=await G_({accessToken:t.config.accessToken,apiBaseUrl:t.config.apiBaseUrl,sessionApiBaseUrl:t.config.sessionApiBaseUrl,xTTEnv:t.config.xTTEnv});await j_({sessionId:s});const r=o.snapshot?null:new F_({format:t.format,includeReplyMetadata:"text"===t.format}),a=L_({timeoutMs:o.timeout}),c=H_({ctx:t,options:o,service:i,streamRenderer:r});try{for await(const e of n.watchSession(s,{signal:a.signal}))if("reply_chunk"!==e.type)if("reply_update"!==e.type){if("progress_update"!==e.type){await i.updateSessionRuntimeStatus({sessionId:s,status:"idle"});for(const t of e.replies)await c.handleIdleReply(t)}}else await c.handleReplyUpdate(e);else c.handleReplyChunk(e)}finally{a.dispose(),n.dispose()}}))})(e,t)}))};function J_(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const Q_=async e=>await new Promise((t=>setTimeout(t,e))),Y_=e=>{const t=e.contentPreview&&e.contentPreview!==e.replyContent?e.contentPreview:void 0,i=e.resultSummary&&e.resultSummary!==e.replyContent&&e.resultSummary!==e.contentPreview?e.resultSummary:void 0;return{contentPreview:t,replyContent:e.replyContent,resultSummary:i}},Z_=e=>{const t=Y_(e);return{answer_message_id:e.answerMessageId,artifacts:J_([e,"access",e=>e.artifacts,"optionalAccess",e=>e.map,"call",e=>e((e=>({file_name:e.fileName,file_uri:e.fileUri,file_url:e.fileUrl,preview_url:e.previewUrl})))]),content_preview:t.contentPreview,created_at:e.createdAt,finished_at:e.finishedAt,kind:e.kind,last_progress_status:e.lastProgressStatus,last_refresh_error:e.lastRefreshError,message_id:e.messageId,progress_id:e.progressId,reply_content:t.replyContent,result_summary:t.resultSummary,session_id:e.sessionId,status:e.status,task_id:e.taskId,updated_at:e.updatedAt,worker_pid:e.workerPid}},X_=e=>{const t=Y_(e);return[`task_id: ${e.taskId}`,`status: ${e.status}`,`session_id: ${e.sessionId}`,`message_id: ${e.messageId}`,`progress_id: ${e.progressId}`,e.answerMessageId?`answer_message_id: ${e.answerMessageId}`:null,t.contentPreview?`content_preview: ${t.contentPreview}`:null,t.replyContent?`reply_content: ${t.replyContent}`:null,t.resultSummary?`result_summary: ${t.resultSummary}`:null,e.lastProgressStatus?`last_progress_status: ${e.lastProgressStatus}`:null,e.lastRefreshError?`last_refresh_error: ${e.lastRefreshError}`:null,`created_at: ${e.createdAt}`,`updated_at: ${e.updatedAt}`,e.finishedAt?`finished_at: ${e.finishedAt}`:null].filter(Boolean).join("\n")},em=({ctx:e,task:t})=>{"text"!==e.format?e.response.print(Z_(t)):e.response.print(X_(t))},tm=t=>t instanceof o.SessionTaskExpiredError||t instanceof o.SessionTaskNotFoundError?new e.CozeError(e.ErrorCode.E3000,t.message,{task_id:t.taskId}):t instanceof o.SessionTaskStoreError?new e.CozeError(e.ErrorCode.E5000,t.message):t instanceof Error?t:new e.CozeError(e.ErrorCode.E5000,String(t)),im=e=>{const t=e.command("task").description("Inspect persisted session background tasks").config({...z_,help:{brief:"Inspect session background tasks",description:"List, show, refresh, watch, and garbage-collect persisted session progress tasks created from `coze session message --wait`."}});t.command("list").description("List persisted session tasks").option("--status <status>","Filter by task status").option("--session-id <sessionId>","Filter by session ID").option("--include-expired","Include expired terminal tasks").action((async(e,t)=>{await(async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{try{const s=o.createSessionTaskService({apiBaseUrl:t.config.apiBaseUrl,service:i,sessionApiBaseUrl:t.config.sessionApiBaseUrl,xTTEnv:t.config.xTTEnv}),n=await s.listTasks({includeExpired:Boolean(e.includeExpired),sessionId:e.sessionId,status:e.status});if("text"===t.format)return void t.response.print(n.length>0?n.map(X_).join("\n\n"):"No session tasks");t.response.print({items:n.map((e=>Z_(e)))})}catch(e){throw tm(e)}}))})(e,t)})),t.command("show <taskId>").description("Show one persisted session task snapshot").option("--include-expired","Read an expired task record").action((async(e,t,i)=>{await(async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{try{const s=o.createSessionTaskService({apiBaseUrl:t.config.apiBaseUrl,service:i,sessionApiBaseUrl:t.config.sessionApiBaseUrl,xTTEnv:t.config.xTTEnv}),n=await s.getTask(e.taskId,{includeExpired:Boolean(e.includeExpired)});em({ctx:t,task:n})}catch(e){throw tm(e)}}))})({includeExpired:t.includeExpired,taskId:e},i)})),t.command("refresh <taskId>").description("Refresh one persisted session task against the server").option("--include-expired","Read an expired task record").action((async(e,t,i)=>{await(async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{try{const s=o.createSessionTaskService({apiBaseUrl:t.config.apiBaseUrl,service:i,sessionApiBaseUrl:t.config.sessionApiBaseUrl,xTTEnv:t.config.xTTEnv}),n=await s.refreshTask(e.taskId,{includeExpired:Boolean(e.includeExpired)});em({ctx:t,task:n})}catch(e){throw tm(e)}}))})({includeExpired:t.includeExpired,taskId:e},i)})),t.command("watch <taskId>").description("Watch one persisted session task until it reaches a terminal state").option("--include-expired","Read an expired task record").option("--timeout <timeoutMs>","Stop watching after the specified timeout in milliseconds",x_).action((async(e,t,i)=>{await(async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{try{const s=o.createSessionTaskService({apiBaseUrl:t.config.apiBaseUrl,service:i,sessionApiBaseUrl:t.config.sessionApiBaseUrl,xTTEnv:t.config.xTTEnv});let n=await s.getTask(e.taskId,{includeExpired:Boolean(e.includeExpired)});if(em({ctx:t,task:n}),o.isSessionTaskTerminal(n.status))return;const r=void 0===e.timeout?void 0:Date.now()+e.timeout;for(;;){const i=void 0===r?1e4:Math.min(1e4,r-Date.now());if(i<=0)return;if(await Q_(i),n=await s.refreshTask(e.taskId,{includeExpired:Boolean(e.includeExpired)}),em({ctx:t,task:n}),o.isSessionTaskTerminal(n.status))return}}catch(e){throw tm(e)}}))})({includeExpired:t.includeExpired,taskId:e,timeout:t.timeout},i)})),t.command("gc").description("Remove expired terminal session tasks from local storage").action((async(e,t)=>{await(async e=>{await O_(e,(async({ctx:e,service:t})=>{try{const i=o.createSessionTaskService({apiBaseUrl:e.config.apiBaseUrl,service:t,sessionApiBaseUrl:e.config.sessionApiBaseUrl,xTTEnv:e.config.xTTEnv}),s=await i.gcTasks();if("text"===e.format)return void e.response.print(s.length>0?`Removed ${s.length} expired task(s)`:"No expired session tasks");e.response.print({count:s.length,items:s.map((e=>Z_(e)))})}catch(e){throw tm(e)}}))})(t)}))},sm=e=>`${[`message_id: ${e.messageId}`,e.replyToMessageId?`reply_to_message_id: ${e.replyToMessageId}`:null,e.messageType?`message_type: ${e.messageType}`:null,e.createTime?`create_time: ${e.createTime}`:null].filter(Boolean).join("\n")}\n${D_(e.content,e.files)}`,om=async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{const s=await U_(e.sessionId),n=await i.listRepliesByMessage({sessionId:s,messageId:e.messageId});await j_({sessionId:n.sessionId});const r=o.createSessionConfigStore(),a=await r.get(),c=n.items.some((e=>e.files&&e.files.length>0)),l=c?a.sessionClawId||(await i.getStatus()).clawId:void 0,d=c?await(async({items:e,store:t,service:i,clawId:s,apiBaseUrl:n,sessionApiBaseUrl:r,xTTEnv:a})=>await Promise.all(e.map((async e=>({...e,files:await o.resolveStoredSessionReplyFiles({files:e.files,clawId:s,apiBaseUrl:n,sessionApiBaseUrl:r,xTTEnv:a,service:i,deps:{store:t}})})))))({items:n.items,store:r,service:i,clawId:l,apiBaseUrl:t.config.apiBaseUrl,sessionApiBaseUrl:t.config.sessionApiBaseUrl,xTTEnv:t.config.xTTEnv}):n.items;if("text"===t.format)return n.requestMessageFound||0!==d.length?0===d.length?void t.response.print(`No replies found for message: ${e.messageId}`):void t.response.print(d.map(sm).join("\n\n")):void t.response.print(`Message not found: ${e.messageId}`);t.response.print({session_id:n.sessionId,message_id:n.requestMessageId,request_message_found:n.requestMessageFound,count:d.length,items:d.map((e=>({message_id:e.messageId,reply_to_message_id:e.replyToMessageId,source:e.source,message_type:e.messageType,content:e.content,files:e.files,create_time:e.createTime,raw:e.raw})))})}))};function nm(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const rm=({ctx:e})=>{const t=new Map;return i=>{const s=t.get(i.progressId);s&&s.progressStatus===i.progressStatus&&s.name===i.name&&s.type===i.type&&"snapshot"!==i.eventSource||(t.set(i.progressId,{name:i.name,progressId:i.progressId,progressStatus:i.progressStatus,type:i.type}),(({ctx:e,progress:t})=>{"text"!==e.format?e.response.print({progress_id:t.progressId,name:t.name,type:t.type,progress_status:t.progressStatus,event_source:t.eventSource}):e.response.print(`${$_(t)}\nevent_source: ${t.eventSource}`)})({ctx:e,progress:i}))}},am=(e,t)=>!t||e.progressId===t,cm=async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{(({ctx:e,progresses:t})=>{"text"!==e.format?e.response.print({items:t.map((e=>({progress_id:e.progressId,name:e.name,type:e.type,progress_status:e.progressStatus,raw:e.raw})))}):e.response.print(t.length>0?t.map((e=>$_(e))).join("\n\n"):"No active progress")})({ctx:t,progresses:await i.listProgresses({size:e.size})})}))},lm=async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{const s=await i.getStatus(),{clawId:n}=s;if(!s.authValid||!n)throw new o.SessionServiceError("Session token is missing or invalid","SESSION_AUTH_INVALID");const r=await G_({accessToken:t.config.accessToken,apiBaseUrl:t.config.apiBaseUrl,progressPollIntervalMs:3e4,sessionApiBaseUrl:t.config.sessionApiBaseUrl,service:i,xTTEnv:t.config.xTTEnv}),a=L_({timeoutMs:e.timeout}),c=rm({ctx:t});try{await(async({clawId:e,emitProgress:t,options:i,service:s})=>{(await s.listProgresses({clawId:e})).filter((e=>am(e,i.progressId))).forEach((e=>{t({...e,eventSource:"snapshot"})}))})({clawId:n,emitProgress:c,options:e,service:i}),await(async({abortScope:e,clawId:t,emitProgress:i,options:s,watcher:o})=>{for await(const n of o.watchProgress(t,{signal:e.signal}))am(n.progress,s.progressId)&&(i({progressId:n.progress.progressId,name:n.progress.name,type:n.progress.progressType,progressStatus:n.progress.progressStatus,eventSource:"websocket"}),s.progressId&&"finished"===n.progress.progressStatus&&e.abort())})({abortScope:a,clawId:n,emitProgress:c,options:e,watcher:r})}finally{a.dispose(),r.dispose()}}))},dm=e=>{const t=e.command("progress").description("Inspect claw background progress").config({...z_,help:{brief:"Inspect claw background progress",description:"List and watch claw process-style background progress driven by websocket and process APIs."}});t.command("list").description("List current background progress").option("--size <size>","Maximum number of progress items to request",B_,100).action(cm),t.command("show <progressId>").description("Show one background progress snapshot").action((async(e,t,i)=>{await(async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{const s=await i.getProgress({progressId:e.progressId});"text"!==t.format?t.response.print({progress_id:e.progressId,found:Boolean(s),name:nm([s,"optionalAccess",e=>e.name]),type:nm([s,"optionalAccess",e=>e.type]),progress_status:nm([s,"optionalAccess",e=>e.progressStatus]),raw:nm([s,"optionalAccess",e=>e.raw])}):t.response.print(s?$_(s):`Progress not found: ${e.progressId}`)}))})({progressId:e},i)})),t.command("poll <progressId>").description("Poll one background progress and treat missing as finished").action((async(e,t,i)=>{await(async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{const s=await i.getProgress({progressId:e.progressId}),o=nm([s,"optionalAccess",e=>e.progressStatus])||"finished";"text"!==t.format?t.response.print({progress_id:e.progressId,name:nm([s,"optionalAccess",e=>e.name]),type:nm([s,"optionalAccess",e=>e.type]),progress_status:o,raw:nm([s,"optionalAccess",e=>e.raw])}):t.response.print($_({progressId:e.progressId,name:nm([s,"optionalAccess",e=>e.name]),type:nm([s,"optionalAccess",e=>e.type]),progressStatus:o}))}))})({progressId:e},i)})),t.command("watch [progressId]").description("Watch one or all background progress updates").option("--timeout <timeoutMs>","Stop watching after the specified timeout in milliseconds",x_).action((async(e,t,i)=>{await lm({progressId:e,timeout:t.timeout},i)}))};function pm(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const um={...z_,help:{brief:"Send a text message to a session",description:"Send a plain text message to the specified claw session. The message can be provided as a positional argument or via stdin. Use @<path> to mention and upload local files as attachments. With --wait, the CLI streams the current turn reply until the session becomes idle. If a new background progress starts within 3 seconds after idle, the CLI returns its progress_id instead of waiting for the background task to finish.",examples:[{desc:"Send a message to a session",cmd:'coze session message "hello" -s 123456789',tags:["[RECOMMENDED]"]},{desc:"Send stdin as the message body",cmd:"cat prompt.txt | coze session message -s 123456789"},{desc:"Wait for the streaming reply until the turn becomes idle",cmd:'coze session message "hello" -s 123456789 --wait'},{desc:"Upload local files and send them with the query",cmd:'coze session message "summarize these" -s 123456789 --file ./a.pdf --file ./b.png'},{desc:"Mention a local file with @ and send it as an attachment",cmd:'coze session message "summarize @docs/notes.md" -s 123456789'},{desc:"Use a podcast voice and inject the voice instruction into the message",cmd:'coze session message "@播客 制作一个介绍潮汕美食的播客" -s 123456789 --podcast-voice "鸡汤女生"'}],schema:{input:{message:{type:"string",required:!1,description:"Plain text message content"},session_id:{type:"string",required:!1,description:"Target session ID. Defaults to the most recently used local session"},file:{type:"array",required:!1,description:"Local file paths to upload and attach"},wait:{type:"boolean",required:!1,description:"Wait for idle and stream assistant reply events"},podcast_voice:{type:"string",required:!1,description:"Podcast voice label or value to inject into the message"},podcast_mode:{type:"string",required:!1,description:"Podcast mode label or value used to disambiguate the voice"}},output:{type:"object",properties:{session_id:{type:"string"},message_id:{type:"string"},status:{type:"string"},content:{type:"string"},answer_message_id:{type:"string"},progress_id:{type:"string"},task_id:{type:"string"},task_status:{type:"string"}}}}}},_m=async({ctx:t,options:i,resolvedContent:s})=>{if(!i.podcastVoice)return s;if(!s)throw new e.CozeError(e.ErrorCode.E1000,"--podcast-voice requires MESSAGE or stdin content");const o=(({config:t,voice:i,mode:s})=>{const o=e_(i),n=i_({config:t,mode:s}).filter((e=>e_(e.label)===o||e_(e.value)===o));if(0===n.length)throw new e.CozeError(e.ErrorCode.E1000,`Podcast voice not found: ${i}`);if(n.length>1){const t=n.map((e=>e.mode_value||e.mode_label||"unknown")).join(", ");throw new e.CozeError(e.ErrorCode.E1000,`Voice "${i}" matched multiple podcast voices; specify --podcast-mode (${t})`)}return n[0]})({config:await t_({baseUrl:t.config.sessionApiBaseUrl||t.config.apiBaseUrl,xTTEnv:t.config.xTTEnv}),voice:i.podcastVoice,mode:i.podcastMode}).label||i.podcastVoice;return(({content:t,voiceLabel:i})=>{if(t.includes('使用音色"'))throw new e.CozeError(e.ErrorCode.E1000,"Message already contains a podcast voice instruction");const s=`使用音色"${i}", `,o=t.length-t.trimStart().length,n=t.slice(0,o),r=t.trimStart();if(/^@播客(?=\s|$)/.test(r))return`${n}@播客 ${s}${r.slice(3).trimStart()}`;return`${s}${t}`})({content:s,voiceLabel:o})},mm=async({ctx:t,message:i,options:s,service:o})=>{const{content:n,filePaths:r}=await Xu(i,{cwd:t.cwd,onWarn:e=>t.ui.warn(e)});(({options:t,resolvedContent:i})=>{if(t.podcastMode&&!t.podcastVoice)throw new e.CozeError(e.ErrorCode.E1000,"--podcast-mode requires --podcast-voice");if(t.podcastVoice&&!i)throw new e.CozeError(e.ErrorCode.E1000,"--podcast-voice requires MESSAGE or stdin content")})({options:s,resolvedContent:n});const a=await Vu({filePaths:[...s.file||[],...r],sessionId:s.sessionId,apiBaseUrl:t.config.apiBaseUrl,sessionApiBaseUrl:t.config.sessionApiBaseUrl,sessionSpaceWebId:t.config.sessionSpaceWebId,xTTEnv:t.config.xTTEnv,service:o}),c=await _m({ctx:t,options:s,resolvedContent:n});if(!c&&0===a.length)throw new e.CozeError(e.ErrorCode.E1000,"Missing message input: provide MESSAGE, stdin content, and/or --file");return{content:c||"",files:a}},gm=async({ctx:e,options:t,service:i})=>{if(!t.wait)return{streamRenderer:null,waiter:null};const s=new F_({format:e.format}),o=pm([await i.getStatus(),"optionalAccess",e=>e.clawId]);return{clawId:o,knownProgressIds:o?await i.listProgresses({clawId:o}).then((e=>new Set(e.map((e=>e.progressId))))).catch((()=>null)):void 0,streamRenderer:s,waiter:await(async({accessToken:e,apiBaseUrl:t,sessionApiBaseUrl:i,xTTEnv:s})=>new R_({watcher:await G_({accessToken:e,apiBaseUrl:t,sessionApiBaseUrl:i,xTTEnv:s})}))({accessToken:e.config.accessToken,apiBaseUrl:e.config.apiBaseUrl,sessionApiBaseUrl:e.config.sessionApiBaseUrl,xTTEnv:e.config.xTTEnv})}},hm=async({ctx:e,knownProgressIds:t,options:i,result:s,service:n,streamRenderer:r,waiter:a,clawId:c})=>{const l=await a.waitForReply({onReplyChunk:r?e=>{r.writeChunk({chunk:e.chunk,sessionId:i.sessionId})}:void 0,onReplyUpdate:r?e=>{r.writeReply({reply:e.reply,sessionId:i.sessionId,source:"message"})}:void 0,sessionId:i.sessionId,requestMessageId:s.messageId,timeoutMs:i.timeout}),d="idle"===l.source&&c&&t?await(async({clawId:e,knownProgressIds:t,listProgresses:i,pollIntervalMs:s=500,timeoutMs:o=3e3})=>{const n=Date.now()+o;for(;;){const o=(await i({clawId:e})).find((e=>!t.has(e.progressId)));if(o)return o;const r=n-Date.now();if(r<=0)return null;await Bu(Math.min(s,r))}})({clawId:c,knownProgressIds:t,listProgresses:e=>n.listProgresses(e),timeoutMs:3e3}):null;"idle"===l.source&&await n.updateSessionRuntimeStatus({sessionId:i.sessionId,status:"idle"});const p=await o.resolveStoredSessionReplyFiles({files:l.files,apiBaseUrl:e.config.apiBaseUrl,sessionApiBaseUrl:e.config.sessionApiBaseUrl,xTTEnv:e.config.xTTEnv,service:n});return r?(r.writeReply({files:p,reply:{answerId:l.answerId,content:l.content,requestMessageId:s.messageId},sessionId:i.sessionId,source:l.source}),d&&r.writeProgress({progress:d,sessionId:i.sessionId}),{answerMessageId:l.answerId,content:l.content,files:p,progress:d,rendered:!0}):{answerMessageId:l.answerId,content:l.content,files:p,progress:d,rendered:!1}},fm=async(e,t,i)=>{await O_(i,(async({ctx:i,service:s})=>{const n=await U_(t.sessionId),r={...t,sessionId:n},a=await mm({ctx:i,message:e,options:r,service:s}),c=await gm({ctx:i,options:r,service:s});try{const e=await s.sendMessage({sessionId:n,content:a.content,files:a.files});if(await j_({sessionId:e.sessionId}),c.waiter){const t=await hm({...c,ctx:i,options:r,result:e,service:s,waiter:c.waiter});if(t.progress)try{const r=o.createSessionTaskService({apiBaseUrl:i.config.apiBaseUrl,service:s,sessionApiBaseUrl:i.config.sessionApiBaseUrl,xTTEnv:i.config.xTTEnv});let a=await r.createOrUpdateTaskFromMessageWait({answerMessageId:t.answerMessageId,content:t.content,files:t.files,messageId:e.messageId,progress:t.progress,sessionId:n});try{const e=await o.startDetachedSessionTaskRefreshWorker({payload:{accessToken:i.config.accessToken||"",apiBaseUrl:i.config.apiBaseUrl,organizationId:i.config.organizationId,sessionApiBaseUrl:i.config.sessionApiBaseUrl,taskId:a.taskId,xTTEnv:i.config.xTTEnv}});e&&(a=await r.patchTask(a.taskId,{lastRefreshError:void 0,workerPid:e}))}catch(e){a=await r.patchTask(a.taskId,{lastRefreshError:e instanceof Error?`Failed to start auto refresh worker: ${e.message}`:`Failed to start auto refresh worker: ${String(e)}`})}if("json"===i.format)return void i.response.print({answer_message_id:t.answerMessageId,content:t.content,files:t.files,message_id:e.messageId,progress_id:t.progress.progressId,session_id:e.sessionId,status:e.status,task_id:a.taskId,task_status:a.status,worker_pid:a.workerPid})}catch(t){if(i.ui.warn(`Failed to persist task: ${t instanceof Error?t.message:String(t)}`),"json"===i.format)return void i.response.print({session_id:e.sessionId,message_id:e.messageId,status:e.status})}if(t.rendered)return}i.response.print({session_id:e.sessionId,message_id:e.messageId,status:e.status})}finally{pm([c,"access",e=>e.waiter,"optionalAccess",e=>e.dispose,"call",e=>e()])}}))};const ym={...z_,help:{brief:"Work with PPT artifacts generated by a session",description:"Target one specific PPT artifact with --file-uri. Page-scoped edit still needs --session-id because it sends a session chat message.",examples:[{desc:"Get PPT information",cmd:"coze session ppt info --file-uri task-1/deck.pptx.html",tags:["[RECOMMENDED]"]},{desc:"List page outline text",cmd:"coze session ppt pages --file-uri task-1/deck.pptx.html"},{desc:"Export the PPTX file",cmd:"coze session ppt export --file-uri task-1/deck.pptx.html --output-path ./deck.pptx"},{desc:"Edit one page through session chat",cmd:'coze session ppt edit "标题更突出" -s 123456789 --page 2 --wait'},{desc:"Create a share link",cmd:"coze session ppt share --file-uri task-1/deck.pptx.html"}]}},vm=t=>{const i=Number.parseInt(t,10);if(!Number.isFinite(i)||i<=0)throw new e.CozeError(e.ErrorCode.E1000,"Invalid value for --page: expected a positive integer");return i},bm=(e,t)=>[...t,vm(e)],wm=t=>{if("ppt"===t||"editable"===t)return t;throw new e.CozeError(e.ErrorCode.E1000,'Invalid value for --export-type: expected "ppt" or "editable"')},Pm=async({options:t})=>{if(t.fileUri)return{fileName:t.fileUri,fileUri:t.fileUri,raw:{file_name:t.fileUri,file_uri:t.fileUri}};throw new e.CozeError(e.ErrorCode.E1000,"Missing PPT identifier: provide --file-uri.")},Sm=t=>{if(!t.fileUri)throw new e.CozeError(e.ErrorCode.E1000,"PPT file_uri is required for this operation. Provide --file-uri.");return t.fileUri},Tm=async({file:e,service:t})=>e.fileUrl?e.fileUrl:t.resolveFileUrl({fileUri:Sm(e)}),Cm=async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{const s=await Pm({options:e}),n=await Tm({file:s,service:i}),r=await o.fetchSessionPptContent({url:n}),a=o.parseSessionPptContent(r);"text"!==t.format?t.response.print({file_name:s.fileName,file_uri:s.fileUri,file_url:n,type:a.type,page_count:a.pageCount}):t.response.print((({file:e,pageCount:t,type:i,url:s})=>[`PPT: ${e.fileName}`,e.fileUri?`file_uri: ${e.fileUri}`:null,`file_url: ${s}`,`type: ${i}`,`pages: ${t}`].filter(Boolean).join("\n"))({file:s,pageCount:a.pageCount,type:a.type,url:n}))}))},km=t=>{const i=t.command("ppt").description("Inspect, export, share, and edit session PPT artifacts").config(ym);i.command("info").description("Get PPT metadata and page count").option("--file-uri <uri>","Specific PPT file_uri").action(((e,t)=>Cm(e,t))),i.command("pages").description("List PPT page outline and preview text").option("--file-uri <uri>","Specific PPT file_uri").option("--limit <limit>","Maximum pages to print",B_).action(((e,t)=>(async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{const s=await Pm({options:e}),n=await Tm({file:s,service:i}),r=await o.fetchSessionPptContent({url:n}),a=o.parseSessionPptContent(r),c=e.limit?a.pages.slice(0,e.limit):a.pages;"text"!==t.format?t.response.print({file_name:s.fileName,file_uri:s.fileUri,file_url:n,type:a.type,page_count:a.pageCount,pages:c}):t.response.print((e=>e.map((e=>{const t=e.title?` ${e.title}`:"",i=(s=e.previewText||(e.previewUrl?`preview_url: ${e.previewUrl}`:"")).length>500?`${s.slice(0,500)}...`:s;var s;return i?`${e.page}.${t}\n${i}`:`${e.page}.${t}`})).join("\n\n"))(c))}))})(e,t))),i.command("export").description("Export a PPT artifact to PPTX").option("--file-uri <uri>","Specific PPT file_uri").option("--output-path <path>","Local path used to save the PPTX").option("--export-type <type>","Export type: ppt or editable",wm,"ppt").action(((e,t)=>(async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{const s=await Pm({options:e}),o=Sm(s),n=await i.exportPpt({fileUri:o,exportType:e.exportType}),r=await Du({url:n.url,outputPath:e.outputPath});"text"!==t.format?t.response.print({status:"saved",path:r.path,filename:r.filename,size:r.size,file_uri:o,export_uri:n.uri,export_url:n.url,export_type:n.exportType}):t.response.print(r.path)}))})(e,t))),i.command("edit <message>").description("Send a page-scoped edit request through session chat").option("-s, --session-id <sessionId>","Target session ID; defaults to the most recently used local session").option("--page <page>","Target PPT page number, can be used multiple times",bm,[]).option("--wait","Wait until the edit turn becomes idle").option("--timeout <timeoutMs>","Timeout for --wait",x_).action(((t,i,s)=>(async(t,i,s)=>{if(!function(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}([i,"access",e=>e.page,"optionalAccess",e=>e.length]))throw new e.CozeError(e.ErrorCode.E1000,"Missing --page: provide one or more target PPT page numbers");await fm(o.formatSessionPptEditQuery({pages:i.page,query:t}),{sessionId:i.sessionId,wait:i.wait,timeout:i.timeout},s)})(t,i,s))),i.command("share").description("Create a share URL for a PPT artifact").option("--file-uri <uri>","Specific PPT file_uri").option("--task-id <taskId>","PPT task ID used by the slide route").option("--no-short","Print the original share URL without short-link exchange").action(((e,t)=>(async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{const s=await Pm({options:e}),n=Sm(s),r=o.buildSessionPptSlideUrl({origin:t.config.sessionApiBaseUrl||t.config.apiBaseUrl,fileUri:n,taskId:e.taskId}),a=!1===e.short?r:await i.shortenWebUrl({url:r});"text"!==t.format?t.response.print({file_name:s.fileName,file_uri:n,url:a,original_url:r,short:!1!==e.short}):t.response.print(a)}))})(e,t)))},Am=e=>[e.mode_label||e.mode_value?`mode: ${e.mode_label||e.mode_value}${e.mode_label&&e.mode_value?` (${e.mode_value})`:""}`:null,`voice: ${e.label||e.value||"unknown"}`,e.value?`value: ${e.value}`:null,e.sample?`sample: ${e.sample}`:null,e.color_code?`color_code: ${e.color_code}`:null].filter(Boolean).join("\n"),Em=async(e,t)=>{await O_(t,(async({ctx:t})=>{const i=await t_({baseUrl:t.config.sessionApiBaseUrl||t.config.apiBaseUrl,xTTEnv:t.config.xTTEnv}),s=i_({config:i,mode:e.mode,keyword:e.keyword});"text"!==t.format?t.response.print({count:s.length,items:s}):t.response.print(s.length>0?s.map(Am).join("\n\n"):"No podcast voices matched")}))},Im=(e,t)=>[...t,e],Rm=async(t,i,s)=>{(t=>{if(t.mode&&!t.voice)throw new e.CozeError(e.ErrorCode.E1000,"--mode requires --voice")})(i),await fm(t,(e=>({file:e.file||[],podcastMode:e.mode,podcastVoice:e.voice,sessionId:e.sessionId,timeout:e.timeout,wait:e.wait}))(i),s)},zm=e=>{const t=e.command("podcast").description("Inspect podcast config");t.config({...z_,help:{brief:"Inspect podcast modes and voices",description:"Query the podcast voice configuration used by Coze Space so you can pick a valid voice name before sending a session message."}}),(e=>{e.command("message [message]").description("Send a podcast-oriented message to a claw session").option("-s, --session-id <sessionId>","Target session ID; defaults to the most recently used local session").option("--voice <voice>","Podcast voice label or value to inject into the message").option("--mode <mode>","Podcast mode label or value used to disambiguate --voice").option("--wait","Wait until the podcast turn becomes idle").option("--timeout <timeoutMs>","Timeout for --wait",x_).option("--file <path>","Local file to upload and attach (can be used multiple times)",Im,[]).config({...z_,help:{brief:"Send a podcast message to a session",description:"Send a podcast-oriented message through the normal session message pipeline. Use --voice to inject a podcast voice instruction; --mode can disambiguate voices with the same label.",examples:[{desc:"Send a podcast message",cmd:'coze session podcast message "@播客 制作一个介绍潮汕美食的播客" -s 123456789 --voice "鸡汤女生" --wait',tags:["[RECOMMENDED]"]},{desc:"Send a podcast message without choosing a voice",cmd:'coze session podcast message "@播客 制作一个介绍潮汕美食的播客" -s 123456789 --wait'}],schema:{input:{message:{type:"string",required:!1,description:"Podcast message content"},session_id:{type:"string",required:!1,description:"Target session ID. Defaults to the most recently used local session"},voice:{type:"string",required:!1,description:"Podcast voice label or value"},mode:{type:"string",required:!1,description:"Podcast mode label or value used to disambiguate --voice"},wait:{type:"boolean",required:!1,description:"Wait for idle and stream assistant reply events"},file:{type:"array",required:!1,description:"Local file paths to upload and attach"}}}}}).action(Rm)})(t),(e=>{e.command("voice").description("Inspect podcast voices").command("list").description("List available podcast voices").option("--mode <mode>","Filter by podcast mode label or value").option("--keyword <keyword>","Filter voices by label or value keyword").config({...z_,help:{brief:"List available podcast voices",description:"Fetch podcast config from Coze Space and print flattened voice options. Text output includes the sample URL for quick inspection.",examples:[{desc:"List all podcast voices",cmd:"coze session podcast voice list",tags:["[RECOMMENDED]"]},{desc:"List solo voices only",cmd:"coze session podcast voice list --mode solo"},{desc:"Filter by keyword",cmd:"coze session podcast voice list --keyword 鸡汤"}],schema:{input:{mode:{type:"string",required:!1,description:"Podcast mode label or value"},keyword:{type:"string",required:!1,description:"Keyword used to filter label or value"}},output:{type:"object",properties:{count:{type:"number"},items:{type:"array"}}}}}}).action(Em)})(t)};function Um(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}const jm=e=>{e.command("current").description("Show the current locally selected default session").config({...z_,help:{brief:"Show the current default session",description:"Read the locally cached default session used by session commands when --session-id is omitted.",examples:[{desc:"Show the current default session",cmd:"coze session current"}],schema:{output:{type:"object",properties:{configured:{type:"boolean"},session_id:{type:"string"},claw_id:{type:"string"}}}}}}).action((async(e,t)=>{await(async e=>{const t=e.getContext(),i=o.createSessionConfigStore(),s=await i.get();if("text"===Um([t,"optionalAccess",e=>e.format])){if(!s.sessionId)return void Um([t,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e("No current session configured")]);const e=[`session_id: ${s.sessionId}`];return s.sessionClawId&&e.push(`claw_id: ${s.sessionClawId}`),void Um([t,"optionalAccess",e=>e.response,"access",e=>e.print,"call",t=>t(e.join("\n"))])}Um([t,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({configured:Boolean(s.sessionId),session_id:s.sessionId,claw_id:s.sessionClawId})])})(t)}))},Lm=e=>{e.command("use <sessionId>").description("Set the current locally selected default session").config({...z_,help:{brief:"Set the current default session",description:"Persist the provided session ID locally so session commands can reuse it by default.",examples:[{desc:"Use one session as the local default",cmd:"coze session use 7627441805839057179"}],schema:{input:{session_id:{type:"string",required:!0,description:"Session ID to persist as the local default"}},output:{type:"object",properties:{status:{type:"string"},session_id:{type:"string"}}}}}}).action((async(e,t,i)=>{await(async({cmd:e,sessionId:t})=>{const i=e.getContext();await j_({sessionId:t}),Um([i,"optionalAccess",e=>e.response,"access",e=>e.print,"call",e=>e({status:"updated",session_id:t})])})({cmd:i,sessionId:e})}))},Om=e=>{const t=e.command("session").description("Manage Coze session-based claw chat").config({...z_,help:{brief:"Manage claw chat sessions with token authentication",description:"Provides claw status lookup, session creation, session listing, and message sending for Coze Space claw chat using the current CLI token. Websocket watch flows also use the current CLI token through request headers.",examples:[{desc:"Check current claw status",cmd:"coze session status"},{desc:"Create a new session",cmd:"coze session create"}]}});(e=>{e.command("status").description("Get current claw status with token auth").option("-s, --session-id <sessionId>","Target session ID").config({...z_,help:{brief:"Validate token auth and resolve claw_id",description:"Use the current CLI token to fetch current claw information. If successful, the CLI refreshes the cached claw_id. With --session-id, the CLI reports session runtime status separately from claw-level background task activity.",examples:[{desc:"Validate token auth and show claw status",cmd:"coze session status"}],schema:{output:{type:"object",properties:{auth_configured:{type:"boolean"},auth_valid:{type:"boolean"},claw_id:{type:"string"},account_id:{type:"string"},updated_at:{type:"number"},display_status:{type:"string"},runtime_status:{type:"string"},claw_busy:{type:"boolean"},claw_progress_count:{type:"number"}}}}}}).action((async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{if(e.sessionId){const s=await i.getSessionDisplayStatus({sessionId:e.sessionId});return void t.response.print({session_id:s.sessionId,display_status:s.displayStatus,claw_busy:s.clawBusy,claw_progress_count:s.clawProgressCount,runtime_status:s.runtimeStatus,updated_at:s.updatedAt})}const s=await i.getStatus();t.response.print({auth_configured:s.authConfigured,auth_valid:s.authValid,claw_id:s.clawId,account_id:s.accountId,updated_at:s.updatedAt})}))}))})(t),(e=>{e.command("create").description("Create a new claw chat session").config({...z_,help:{brief:"Create a new claw session",description:"Create a normal claw chat session with the current claw_id resolved through token auth.",examples:[{desc:"Create a session",cmd:"coze session create"}],schema:{output:{type:"object",properties:{status:{type:"string"},claw_id:{type:"string"},session_id:{type:"string"}}}}}}).action((async(e,t)=>{await O_(t,(async({ctx:e,service:t})=>{const i=await t.createSession();await j_({clawId:i.clawId,sessionId:i.sessionId}),e.response.print({status:"created",claw_id:i.clawId,session_id:i.sessionId})}))}))})(t),jm(t),Lm(t),(e=>{e.command("list").description("List claw chat sessions").option("--offset <offset>","Pagination offset returned by the previous list call").option("--limit <limit>","Maximum number of sessions to return",B_,20).config({...z_,help:{brief:"List sessions with offset pagination",description:"List claw chat sessions using the API native offset/limit pagination model.",examples:[{desc:"List the first 20 sessions",cmd:"coze session list"},{desc:"List the next page",cmd:"coze session list --offset next-token --limit 20"}],schema:{input:{offset:{type:"string",required:!1,description:"Pagination offset from a previous response"},limit:{type:"number",required:!1,description:"Maximum number of sessions to return"}},output:{type:"object",properties:{items:{type:"array",description:"Session items returned by the API"},next_offset:{type:"string",description:"Next pagination offset"},has_more:{type:"boolean",description:"Whether another page exists"}}}}}}).action((async(e,t)=>{await O_(t,(async({ctx:t,service:i})=>{const s=await i.listSessions({offset:e.offset,limit:e.limit});t.response.print({items:s.items,next_offset:s.nextOffset,has_more:s.hasMore})}))}))})(t),(e=>{e.command("file").description("Manage files returned by claw session replies").config({...z_,help:{brief:"Download files returned by session replies",description:"Work with file artifacts returned by session replies. Use the file_url from `coze session message --wait --format json` to save a file locally.",examples:[{desc:"Download a reply artifact to the current directory",cmd:'coze session file download "https://example.com/file"'},{desc:"Download a reply artifact to a specific path",cmd:'coze session file download "https://example.com/file" --output-path ./artifacts/result.md'}]}}).command("download <fileUrl>").description("Download a file from a session reply file_url").option("--output-path <path>","Local path used to save the file").config({...z_,help:{brief:"Download a session reply file",description:"Download a file using the file_url returned by `coze session message --wait`. If --output-path is omitted, the CLI derives a filename from the response headers or URL.",examples:[{desc:"Download using the inferred filename",cmd:'coze session file download "https://example.com/file"',tags:["[RECOMMENDED]"]},{desc:"Save to a custom path",cmd:'coze session file download "https://example.com/file" --output-path ./downloads/result.md'}],schema:{input:{file_url:{type:"string",required:!0,description:"Direct file URL returned by a session reply"},output_path:{type:"string",required:!1,description:"Local output path for the downloaded file"}},output:{type:"object",properties:{status:{type:"string"},path:{type:"string"},filename:{type:"string"},size:{type:"number"},url:{type:"string"}}}}}}).action((async(e,t,i)=>{await O_(i,(async({ctx:i})=>{const s=await Du({url:e,outputPath:t.outputPath});"text"!==i.format?i.response.print({status:"saved",path:s.path,filename:s.filename,size:s.size,url:s.url}):i.response.print(s.path)}))}))})(t),zm(t),(e=>{e.command("message [message]").description("Send a text message to a claw session").option("-s, --session-id <sessionId>","Target session ID; defaults to the most recently used local session").option("--file <path>","Local file to upload and attach (can be used multiple times)",((e,t)=>[...t,e]),[]).option("--wait","Wait until the current turn becomes idle and optionally return a background progress_id").option("--timeout <timeoutMs>","Timeout for waiting until the current turn becomes idle",x_).option("--podcast-voice <voice>","Inject a podcast voice instruction using the specified voice label or value").option("--podcast-mode <mode>","Podcast mode label or value used to disambiguate --podcast-voice").config(um).action(fm)})(t),km(t),(e=>{e.command("replies <messageId>").description("List all replies that belong to one session message").option("-s, --session-id <sessionId>","Target session ID; defaults to the most recently used local session").config({...z_,help:{brief:"List replies for one message",description:"Fetch session messages via ListMessage and return only the replies whose reply_to_message_id matches the specified message ID.",examples:[{desc:"Get all replies for one message",cmd:"coze session replies 8f45d790-9062-4008-8784-999d86825fcc -s 7627441805839057179",tags:["[RECOMMENDED]"]}],schema:{input:{message_id:{type:"string",required:!0,description:"Original user message ID"},session_id:{type:"string",required:!1,description:"Target session ID. Defaults to the most recently used local session"}},output:{type:"object",properties:{session_id:{type:"string"},message_id:{type:"string"},request_message_found:{type:"boolean"},count:{type:"number"}}}}}}).action((async(e,t,i)=>{await om({messageId:e,sessionId:t.sessionId},i)}))})(t),K_(t),dm(t),im(t)};function Bm(t){t.command("upgrade").description("Upgrade Coze CLI to the latest version").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Upgrade CLI to latest version",description:"Check for the latest version of Coze CLI and upgrade if a newer version is available. Detects the package manager used for the original installation (npm/pnpm/yarn) and runs the appropriate global install command.",examples:[{desc:"Upgrade to latest version",cmd:"coze upgrade",tags:["[RECOMMENDED]"]},{desc:"Force check and upgrade",cmd:"coze upgrade --force"},{desc:"Upgrade to a specific tag",cmd:"coze upgrade --tag beta"}],seeAlso:["coze --version"]}}).option("--force","Force upgrade even if already on the latest version").option("--tag <tag>","Specify the dist-tag to upgrade to","latest").action((async(t,o)=>{const n=o.getContext();n||process.exit(e.ExitCode.FAILURE),n.ui.info("Checking for updates...");try{const e=await Y(n,!0,t.tag);if(!e.hasUpdate&&!t.force)return void n.ui.success(`You are already on the latest version (${e.currentVersion}).`);e.hasUpdate&&n.ui.info(`New version available: ${i.gray(e.currentVersion)} → ${i.green(e.latestVersion)}`),n.ui.info("Upgrading Coze CLI...");const o=function(){const e=[{pm:"npm",cmd:"npm ls -g @coze/cli --json 2>/dev/null"},{pm:"pnpm",cmd:"pnpm ls -g @coze/cli --json 2>/dev/null"},{pm:"yarn",cmd:"yarn global list --json 2>/dev/null"}];for(const{pm:t,cmd:i}of e)try{if(s.execSync(i,{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).includes("@coze/cli"))return t}catch(e){}return"npm"}(),r=function(e,t){switch(e){case"pnpm":return`pnpm add -g @coze/cli@${t}`;case"yarn":return`yarn global add @coze/cli@${t}`;default:return`npm install -g @coze/cli@${t}`}}(o,t.tag);n.ui.verbose(`Using package manager: ${o}`),n.ui.verbose(`Running: ${r}`),s.execSync(r,{stdio:"inherit"});const a=J();n.ui.success(`Successfully upgraded Coze CLI to ${e.latestVersion}. (was ${e.currentVersion})`),"json"===n.format&&n.response.print({previousVersion:e.currentVersion,currentVersion:a,latestVersion:e.latestVersion,status:"upgraded"})}catch(t){n.ui.error(`Failed to upgrade: ${t.message}`),n.ui.info("You can try upgrading manually with: npm install -g @coze/cli"),process.exit(e.ExitCode.FAILURE)}}))}function xm(t){!function(t){const i=t.command("auth").description("Manage user authentication and credentials").config({skipAuth:!0,skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Manage authentication and credentials",description:"Manage the full authentication lifecycle for Coze CLI. Supports interactive OAuth login via browser. All other commands require valid authentication.",examples:[{desc:"Interactive login via browser",cmd:"coze auth login --oauth",tags:["[RECOMMENDED]"]},{desc:"Check current login status",cmd:"coze auth status"},{desc:"Logout and clear credentials",cmd:"coze auth logout"}],seeAlso:["coze organization","coze space"]}});i.command("login").description("Login to obtain and persist access credentials").config({skipAuth:!0,help:{brief:"Login to Coze services",description:"Login to Coze services via OAuth authorization. Opens browser to complete authorization.",examples:[{desc:"Interactive login using OAuth",cmd:"coze auth login --oauth",tags:["[RECOMMENDED]"]}],errors:[{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"Authentication failed",fix:"Please try again with `coze auth login --oauth`."}]}}).option("--token <PAT>","Login using an access token").option("--oauth","Start browser-based OAuth device authorization flow").action((async function(t,i){const s=i.getContext();if(!s)return void W(new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized"));await s.auth.login(t);const o=["Please use the following commands to manage organizations and spaces:"," coze organization list"," coze organization use <organization_id>"," coze space list"," coze space use <space_id>"];!function(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}}([s,"optionalAccess",e=>e.ui,"access",e=>e.info,"call",e=>e(o.join("\n"))])})),i.command("logout").description("Logout and clear stored credentials").config({skipOrgCheck:!0,skipAuth:!0,skipSpaceCheck:!0,help:{brief:"Logout",description:"Clear locally stored access credentials and log out of the current account.",examples:[{desc:"Execute logout",cmd:"coze auth logout"}]}}).action((async(t,i)=>{const s=i.getContext();s?await s.auth.logout():W(new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized"))})),i.command("status").description("Check current login status and credential validity").config({skipOrgCheck:!0,skipSpaceCheck:!0,help:{brief:"Check login status",description:"Verify if the current locally cached credentials are valid and display current login account information. If the token was obtained via OAuth and is about to expire, it will be refreshed automatically.",examples:[{desc:"Check current authentication status",cmd:"coze auth status",tags:["[RECOMMENDED]"]},{desc:"Check status in JSON format",cmd:"coze auth status --format json"}],schema:{output:{type:"object",properties:{logged_in:{type:"boolean",description:"Whether the user is currently logged in"},user:{type:"object",description:"Current user profile information"},token_expires_at:{type:"string",description:"Token expiration time in ISO 8601 format"}}}},errors:[{code:e.ErrorCode.E2001,name:"AUTH_FAILED",desc:"No valid credentials found or token has expired",fix:"Run `coze auth login --oauth` to authenticate."}],seeAlso:["coze auth login","coze auth logout"]}}).action((async(t,i)=>{const s=i.getContext();s?await s.auth.status():W(new e.CozeError(e.ErrorCode.E5000,"CLI context is not initialized"))}))}(t),Om(t),sc(t),Ou(t),qa(t),pr(t),mr(t),Ba(t),Na(t),Bm(t),oc()}function qm(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function Dm(e,t){return null!=e?e:t()}function Mm(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function Gm(e){const t=[];let i=e;for(;i;)i.name()&&t.unshift(i.name()),i=i.parent;return t.join(" ")}function $m(e){return e._args.map((e=>e.required?`<${e.name()}>`:`[${e.name()}]`)).join(" ")}const Nm=new Set(["--version","--format","--no-color","--config","--org-id","--space-id","--verbose","--debug","--log-file","--man","--schema","--commands"]);function Fm(e){const t=new Map,i=[];let s=e;for(;s;)i.unshift(s),s=s.parent;for(const e of i)for(const i of e.options){const e=i.flags.split(", ").find((e=>e.startsWith("--")));!e||t.has(e)||Nm.has(e)||t.set(e,i)}return Array.from(t.values())}function Vm(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}class Wm extends P.Command{__init(){this.middlewares=[]}constructor(e){super(e),Wm.prototype.__init.call(this),this.helpInformation=()=>{const e=process.argv.slice(2);if(e.includes("--schema"))return`${JSON.stringify(Vm([this,"access",e=>e.getConfig,"call",e=>e(),"optionalAccess",e=>e.help,"optionalAccess",e=>e.schema])||{},null,2)}\n`;if(e.includes("--commands")){const e=this.commands.filter((e=>!e._hidden)).map((e=>({name:e.name(),description:e.description()})));return`${JSON.stringify(e,null,2)}\n`}if(e.includes("--man")||e.includes("-m"))return`${function(e){const t=Mm([e,"access",e=>e.getConfig,"call",e=>e(),"optionalAccess",e=>e.help]),i=Gm(e);let s=`@MAN ${i}\n\n`;s+=`NAME\n ${i} — ${Mm([t,"optionalAccess",e=>e.brief])||e.description()}\n\n`,s+=`SYNOPSIS\n ${i} ${$m(e)}\n`,Fm(e).forEach((e=>{s+=` [${e.flags}]\n`})),s+="\n",Mm([t,"optionalAccess",e=>e.description])&&(s+=`DESCRIPTION\n ${t.description.replace(/\n/g,"\n ")}\n\n`);const o=Fm(e);return o.length>0&&(s+="OPTIONS\n",o.forEach((e=>{const t=e.flags.split(", "),i=t.find((e=>e.startsWith("-")&&!e.startsWith("--")))||"",o=t.find((e=>e.startsWith("--")))||"";s+=` ${i?`${o}, ${i}`:o}\n`,s+=` Type: ${e.isBoolean()?"flag":"string"}\n`,s+=` Required: ${e.mandatory?"yes":"no"}\n`,s+=` Default: ${void 0!==e.defaultValue?String(e.defaultValue):"-"}\n`,s+=` Desc: ${e.description}\n\n`}))),Mm([t,"optionalAccess",e=>e.schema])&&(s+="SCHEMA\n",t.schema.input&&(s+=` Input:\n ${JSON.stringify(t.schema.input,null,2).replace(/\n/g,"\n ")}\n`),t.schema.output&&(s+=` Output:\n ${JSON.stringify(t.schema.output,null,2).replace(/\n/g,"\n ")}\n`),s+="\n"),Mm([t,"optionalAccess",e=>e.errors])&&t.errors.length>0&&(s+="ERRORS\n",s+=" CODE NAME TRIGGER RECOVERY\n",t.errors.forEach((e=>{s+=` ${e.code.padEnd(6)} ${e.name.padEnd(17)} ${e.desc.padEnd(37)} ${e.fix}\n`})),s+="\n"),Mm([t,"optionalAccess",e=>e.caveats])&&t.caveats.length>0&&(s+="CAVEATS\n",t.caveats.forEach((e=>{s+=` - ${e}\n`})),s+="\n"),Mm([t,"optionalAccess",e=>e.seeAlso])&&t.seeAlso.length>0&&(s+="SEE ALSO\n",t.seeAlso.forEach((e=>{s+=` ${e}\n`})),s+="\n"),s.trimEnd()}(this)}\n`;return e.includes("-h")||e.includes("--help")?`${function(e){const t=Mm([e,"access",e=>e.getConfig,"call",e=>e(),"optionalAccess",e=>e.help]),i=Gm(e);let s=`@HELP ${i}\n\n`;return Mm([t,"optionalAccess",e=>e.brief])?s+=`BRIEF: ${t.brief}\n\n`:s+=`BRIEF: ${e.description()||"No description provided."}\n\n`,e.parent&&"coze"!==e.parent.name()&&(s+=`PARENT: ${Gm(e.parent)}\n\n`),s+=`SYNTAX:\n ${i} ${$m(e)} [options]\n\n`,Mm([t,"optionalAccess",e=>e.description])&&(s+=`DESCRIPTION:\n ${t.description.replace(/\n/g,"\n ")}\n\n`),s+="OPTIONS:\n",s+=" Name Type Required Default Description\n",s+=" ─────────────────────────────────────────────────────────\n",e._args.forEach((e=>{const t=`<${e.name()}>`,i=e.required?"Yes":"No",o=void 0!==e.defaultValue?String(e.defaultValue):"-",n=e.description||"";s+=` ${t.padEnd(16)} ${"string".padEnd(10)} ${i.padEnd(4)} ${o.padEnd(10)} ${n}\n`})),Fm(e).forEach((e=>{const t=e.flags.split(", "),i=t.find((e=>e.startsWith("-")&&!e.startsWith("--")))||"",o=t.find((e=>e.startsWith("--")))||"",n=i?`${o}, ${i}`:o;let r="string";e.isBoolean()&&(r="flag");const a=e.mandatory?"Yes":"No",c=void 0!==e.defaultValue?String(e.defaultValue):"-",l=e.description||"";s+=` ${n.padEnd(16)} ${r.padEnd(10)} ${a.padEnd(4)} ${c.padEnd(10)} ${l}\n`})),s+="\n",Mm([t,"optionalAccess",e=>e.enums])&&(s+="ENUMS:\n",Object.keys(t.enums).forEach((e=>{s+=` --${e}:\n`;const i=Dm(Mm([t,"access",e=>e.enums,"optionalAccess",t=>t[e]]),(()=>({})));Object.keys(i).forEach((e=>{s+=` ${e.padEnd(12)} ${i[e]}\n`}))})),s+="\n"),Mm([t,"optionalAccess",e=>e.examples])&&t.examples.length>0&&(s+="COMMON EXAMPLES:\n",t.examples.forEach((e=>{const t=e.tags?` ${e.tags.join(" ")}`:"";s+=` #${t} ${e.desc}\n ${e.cmd}\n\n`}))),Mm([t,"optionalAccess",e=>e.errors])&&t.errors.length>0&&(s+="COMMON ERRORS:\n",s+=" CODE NAME DESCRIPTION FIX\n",t.errors.slice(0,5).forEach((e=>{s+=` ${e.code.padEnd(6)} ${e.name.padEnd(17)} ${e.desc.padEnd(30)} ${e.fix}\n`})),s+="\n"),Mm([t,"optionalAccess",e=>e.seeAlso])&&t.seeAlso.length>0&&(s+="SEE ALSO:\n",t.seeAlso.forEach((e=>{s+=` ${e}\n`})),s+="\n"),s.trimEnd()}(this)}\n`:`${function(e){const t=Mm([e,"access",e=>e.getConfig,"call",e=>e(),"optionalAccess",e=>e.help]),i=Gm(e);let s=`@USAGE ${i}\n\n`;Mm([t,"optionalAccess",e=>e.brief])?s+=`BRIEF: ${t.brief}\n\n`:s+=`BRIEF: ${e.description()||"No description provided."}\n\n`,s+=`SYNTAX:\n ${i} ${$m(e)} [options]\n\n`,e.commands.length>0&&(s+="ACTIONS:\n",e.commands.forEach((e=>{const t=e;if(!t._hidden){const e=Mm([t,"access",e=>e.getConfig,"optionalCall",e=>e(),"optionalAccess",e=>e.help,"optionalAccess",e=>e.brief])||t.description()||"";s+=` ${t.name().padEnd(10)} ${e}\n`}})),s+="\n"),Mm([t,"optionalAccess",e=>e.examples])&&t.examples.length>0&&(s+="EXAMPLES:\n",t.examples.slice(0,5).forEach((e=>{s+=` # ${e.desc}\n ${e.cmd}\n\n`})));if(Mm([t,"optionalAccess",e=>e.enums])){const e=Object.keys(t.enums).filter((e=>Object.keys(Dm(Mm([t,"access",e=>e.enums,"optionalAccess",t=>t[e]]),(()=>({})))).length<=7));e.length>0&&(s+="ENUMS:\n",e.forEach((e=>{const i=Object.keys(Dm(Mm([t,"access",e=>e.enums,"optionalAccess",t=>t[e]]),(()=>({})))).join(" | ");s+=` --${e}: ${i}\n`})),s+="\n")}return s.trimEnd()}(this)}\n`},this.hook("preAction",(e=>{}))}config(e){return this.commandConfig={...this.commandConfig,...e},this}setConfig(e){return this.commandConfig=e,this}getConfig(){return this.commandConfig}setContext(e){return this.context=e,this}getContext(){return this.context}use(e){return this.middlewares.push(e),this}createCommand(e){const t=new Wm(e);return this.context&&t.setContext(this.context),t}action(e){return super.action((async(...t)=>{const i=this.getContext();let s={},o=[],n=this;if(t.length>0){const e=t[t.length-1];e instanceof Wm&&(n=e),t.length>=2&&(r=t[t.length-2],a=()=>({}),s=null!=r?r:a(),o=t.slice(0,t.length-2))}var r,a;if(i&&(s&&(i.options=s),o&&(i.args=o),n)){i.commandName=n.name();const e=Vm([n,"access",e=>e.getConfig,"optionalCall",e=>e()]);e&&(i.commandConfig=e),n.setContext(i)}if(this.middlewares.length>0&&i){const s=si(this.middlewares);await s(i,(async()=>{await e.apply(this,t)}))}else await e.apply(this,t)}))}}function Hm(e){let t,i=e[0],s=1;for(;s<e.length;){const o=e[s],n=e[s+1];if(s+=2,("optionalAccess"===o||"optionalCall"===o)&&null==i)return;"access"===o||"optionalAccess"===o?(t=i,i=n(i)):"call"!==o&&"optionalCall"!==o||(i=n(((...e)=>i.call(t,...e))),t=void 0)}return i}function Km(e){e.exitOverride(),e.outputError=()=>{},e.commands.forEach((e=>Km(e)))}async function Jm(t){const i=new Wm;i.name("coze").description("Coze Coding CLI").version(H,"-v, --version").option("--format <fmt>","Specify output format (json, text). Default: text").option("--no-color","Disable ANSI color output").option("--config <path>","Specify config file path").option("--org-id <id>","Override Organization ID").option("--space-id <id>","Override Space ID").option("--verbose","Enable verbose mode, output more business process information").option("--debug","Enable debug mode, output all log information for diagnosing CLI execution issues").option("--log-file <path>","Output logs to a file").option("--man","Show full manual information").option("--schema","Output the command's JSON Schema").option("--commands","Output the list of subcommands"),i.config({help:{errors:[{code:e.ErrorCode.E1100,name:"UNKNOWN_OPTION",desc:"Unknown option provided",fix:"Check parameter spelling or use -h for help",example:"coze <command> -h"},{code:e.ErrorCode.E1101,name:"UNKNOWN_COMMAND",desc:"Unknown subcommand provided",fix:"Check subcommand spelling or use -h for help",example:"coze -h"},{code:e.ErrorCode.E1102,name:"MISSING_ARGUMENT",desc:"Missing required argument",fix:"Provide missing required parameters",example:"coze <command> -h"},{code:e.ErrorCode.E1103,name:"MISSING_OPTION",desc:"Missing required option value",fix:"Provide missing required options",example:"coze <command> -h"}]}}),xm(i),await ic(t.config),function(e,t,i){const s=new Set;e.setContext(i),function e(o){s.has(o)||(s.add(o),o.setContext(i),t.forEach((e=>o.use(e))),o.commands.forEach((t=>{const i=qm([o,"access",e=>e.getConfig,"optionalCall",e=>e()]),s=qm([t,"access",e=>e.getConfig,"optionalCall",e=>e()]);t.setConfig({...i,...s}),e(t)})))}(e)}(i,[Rs,rr],t),process.on("uncaughtException",(e=>{W(e,t)})),process.on("unhandledRejection",(e=>{W(e,t)})),(t.argv.includes("--schema")||t.argv.includes("--commands")||t.argv.includes("--man")||t.argv.includes("-m"))&&(t.argv.includes("--help")||t.argv.includes("-h")||t.argv.push("--help")),Km(i);try{await i.parseAsync(t.argv,{from:"user"})}catch(n){const r=n,a=function(e,t,i){let s=e;if(t.command)s=t.command;else if(i.commandName){const t=(e,i)=>{if(e.name()===i)return e;for(const s of e.commands){const e=t(s,i);if(e)return e}return null},o=t(e,i.commandName);o&&(s=o)}let o=e;for(const e of i.argv){if(e.startsWith("-"))break;const t=o.commands.find((t=>t.name()===e));t&&(o=t,s=o)}return s}(i,r,t);"commander.helpDisplayed"!==r.code&&"commander.help"!==r.code&&"commander.version"!==r.code||process.exit(e.ExitCode.SUCCESS);const c=Hm([a,"access",e=>e.getConfig,"optionalCall",e=>e()]),l=Hm([i,"access",e=>e.getConfig,"optionalCall",e=>e()]);if(t.commandConfig=(o=()=>l,null!=(s=c)?s:o()),"commander.unknownOption"===r.code){const i=N(new e.CozeError(e.ErrorCode.E1100,r.message),{argv:t.argv,commandConfig:t.commandConfig});t.response.eprint(i),process.exit(e.exitCodeForError(i.code))}if("commander.unknownCommand"===r.code){const i=N(new e.CozeError(e.ErrorCode.E1101,r.message),{argv:t.argv,commandConfig:t.commandConfig});t.response.eprint(i),process.exit(e.exitCodeForError(i.code))}if("commander.missingArgument"===r.code){const i=N(new e.CozeError(e.ErrorCode.E1102,r.message),{argv:t.argv,commandConfig:t.commandConfig});t.response.eprint(i),"json"!==t.format&&process.stderr.write(`\n${a.helpInformation()}`),process.exit(e.exitCodeForError(i.code))}if("commander.missingMandatoryOptionValue"===r.code||"commander.optionMissingArgument"===r.code){const i=N(new e.CozeError(e.ErrorCode.E1103,r.message),{argv:t.argv,commandConfig:t.commandConfig});t.response.eprint(i),"json"!==t.format&&process.stderr.write(`\n${a.helpInformation()}`),process.exit(e.exitCodeForError(i.code))}W(r,t)}var s,o}(async function(){const e=process.argv.slice(2),{globalOptions:t}=function(e){const t={};let i;const s=[];let o=!1;for(let n=0;n<e.length;n++){const r=e[n];if("--help"!==r&&"-h"!==r)if("--version"!==r&&"-v"!==r)if("--output"!==r)if("--format"!==r)"--no-color"!==r?"--config"!==r?"--org-id"!==r?"--space-id"!==r?"--verbose"!==r?"--debug"!==r?"--log-file"!==r?"--print-logs"!==r?o||r.startsWith("-")?s.push(r):(i=r,o=!0):t.printLogs=!0:t.logFile=e[++n]:t.debug=!0:t.verbose=!0:t.spaceId=e[++n]:t.orgId=e[++n]:t.config=e[++n]:t.noColor=!0;else{const i=e[++n];"json"!==i&&"text"!==i||(t.format=i)}else t.output=e[++n];else t.version=!0;else t.help=!0}return{globalOptions:t,commandName:i,commandArgs:s}}(e),i=function(e){const t=Is(e.cwd,(()=>process.cwd())),i=Is(e.env,(()=>process.env)),s=e.globalOptions||{};s.noColor&&(process.env.NO_COLOR="1");let o="text";s.format&&(o=s.format);const n={...e.config};s.orgId&&(n.organizationId=s.orgId),s.spaceId&&(n.spaceId=s.spaceId);const r=new Pt({format:"text",logFile:s.logFile,printToStderr:s.printLogs});let a="info";s.debug?a="debug":s.verbose&&(a="verbose");const c=new As(r,o,a),l=new Es({format:o}),d={cwd:t,env:i,argv:e.argv,config:n,format:o,log:r,ui:c,response:l,globalOptions:s,auth:void 0};return d.auth=new ds(d),d}({argv:e,config:await o.loadConfig(t.config),globalOptions:t});!function(e){At=e.log,Et=!0===St([e,"access",e=>e.globalOptions,"optionalAccess",e=>e.debug]),Et&&(It||(Ht(),Kt(),It=!0))}(i);const s=si([vt,ti,ii,Z]);await s(i,(async()=>{await Jm(i)}))})().catch((e=>{W(e,void 0),process.exitCode=1}));