@coze/cli 0.3.2 → 0.3.3-alpha.471664
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/README.md +36 -0
- package/lib/cli.js +3 -3
- package/lib/fetch-client-DtaPMDxl.js +1 -0
- package/lib/{index-JxWKC7px.js → index-DuCvbCp4.js} +1 -1
- package/lib/send-message.worker.js +1 -1
- package/lib/session-task-refresh.worker.js +1 -1
- package/lib/task-worker-DydgmGrB.js +1 -0
- package/package.json +7 -8
- package/skills/manifest.json +6 -6
- package/skills/using-coze-cli/SKILL.md +36 -3
- package/skills/using-coze-cli/coze-claw/MODULE.md +1 -1
- package/skills/using-coze-cli/coze-code/MODULE.md +77 -15
- package/skills/using-coze-cli/coze-code/references/coze-code-message.md +33 -12
- package/skills/using-coze-cli/coze-code/references/coze-code-project.md +6 -4
- package/skills/using-coze-cli/coze-file/MODULE.md +1 -1
- package/skills/using-coze-cli/coze-generate/MODULE.md +1 -1
- package/lib/fetch-client-CgQGE-CR.js +0 -1
- package/lib/task-worker-BJO9Ixaq.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("process"),r=require("undici"),t=require("./fetch-client-
|
|
1
|
+
"use strict";const e=require("process"),r=require("undici"),t=require("./fetch-client-DtaPMDxl.js"),i=require("./index-DuCvbCp4.js");require("form-data"),require("crypto"),require("url"),require("net"),require("tls"),require("assert"),require("tty"),require("util"),require("events"),require("http"),require("https"),require("http2"),require("path"),require("stream"),require("zlib"),require("lodash"),require("mitt"),require("fs"),require("fs/promises"),async function(){try{const s=e.argv[2];if(!s)throw new Error("No payload provided");const o=t.safeJsonParse(s,void 0);if(!o)throw new Error("Invalid payload");const u=new r.EnvHttpProxyAgent;t.customFetch.setDispatcher(u),t.customFetch.setHeaders({Authorization:`Bearer ${o.accessToken}`}),o.xTTEnv&&t.customFetch.setHeaders({"x-use-ppe":"1","x-tt-env":o.xTTEnv||""}),await i.sendProjectChatMessage(o),e.exit(0)}catch(r){console.error("❌ Worker error:",r),e.exit(1)}}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("process"),r=require("./task-worker-
|
|
1
|
+
"use strict";const e=require("process"),r=require("./task-worker-DydgmGrB.js");require("path"),require("child_process"),require("undici"),require("./fetch-client-DtaPMDxl.js"),require("form-data"),require("crypto"),require("url"),require("net"),require("tls"),require("assert"),require("tty"),require("util"),require("events"),require("http"),require("https"),require("http2"),require("stream"),require("zlib"),require("lodash"),require("node:path"),require("node:fs/promises"),require("node:os"),require("node:fs"),async function(){try{await r.runSessionTaskRefreshWorkerCli(),e.exit(0)}catch(r){console.error("❌ Session task refresh worker error:",r),e.exit(1)}}();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("process"),t=require("path"),s=require("child_process"),i=require("undici"),a=require("./fetch-client-DtaPMDxl.js"),r=require("node:path"),n=require("node:fs/promises"),o=require("node:os");function c(e){const t=Object.create(null);if(e)for(const s in e)if("default"!==s){const i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return e[s]}})}return t.default=e,Object.freeze(t)}require("node:fs");const l=c(r),d=c(n),_=c(o),u=()=>l.join(_.homedir(),".coze"),p=()=>l.join(u(),"cli"),h=()=>u();const m=["upgrade.cache"];function g(e){return m.some((t=>e===t||e.startsWith(`${t}.`)))}const E=l.join(p(),"config.json"),w=l.join(h(),"config.json"),f=l.join(process.cwd(),".cozerc.json"),T={apiBaseUrl:"https://code.coze.cn/",sessionApiBaseUrl:"https://www.coze.cn/",openApiBaseUrl:"https://api.coze.cn",integrationApiBaseUrl:"https://integration.coze.cn",clientId:"95438868623436343239609434490626.app.coze",defaultOutputFormat:"json",upgrade:{mode:"auto",channel:"latest"},skill:{mode:"auto"}};function S(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function R(e,t){return t.split(".").reduce(((e,t)=>{if(S(e))return e[t]}),e)}function P(e,t){const s={...e};for(const[e,i]of Object.entries(t)){const t=s[e];S(t)&&S(i)?s[e]=P(t,i):s[e]=i}return s}function A(e,t){const s=t.split("."),i=[];let a=e;for(let e=0;e<s.length-1;e++){if(!S(a))return!1;i.push(a),a=a[s[e]]}if(!S(a))return!1;const r=s[s.length-1];if(!(r in a))return!1;delete a[r],i.push(a);for(let e=s.length-2;e>=0;e--){const t=i[e+1];if(!S(t)||0!==Object.keys(t).length)break;delete i[e][s[e]]}return!0}function U(e,t=""){const s={};if(!S(e))return s;for(const[i,a]of Object.entries(e)){const e=t?`${t}.${i}`:i;S(a)?Object.assign(s,U(a,e)):s[e]=a}return s}async function I(e){try{const t=await d.readFile(e,"utf8");return JSON.parse(t)}catch(e){return}}async function L(){return await async function(e,t){return null!=e?e:await t()}(await I(E),(async()=>await I(w)))}function C(){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),process.env.COZE_SESSION_SPACE_WEB_ID&&(e.sessionSpaceWebId=process.env.COZE_SESSION_SPACE_WEB_ID),"global"!==process.env.COZE_CONFIG_SCOPE&&"local"!==process.env.COZE_CONFIG_SCOPE||(e.configScope=process.env.COZE_CONFIG_SCOPE),process.env.COZE_DISABLE_TELEMETRY&&(e.disableTelemetry="true"===process.env.COZE_DISABLE_TELEMETRY),e}async function O(e){const t=process.env.COZE_CONFIG_FILE,[s,i,a,r]=await Promise.all([L(),I(f),t?I(t):void 0,e?I(e):void 0]),n=C();return{...T,...s,...i,...a,...r,...n}}async function v(e,t=function(e,t){return null!=e?e:t()}(C().configScope,(()=>"global"))){const s=process.env.COZE_CONFIG_FILE,i=s||("global"===t?E:f),a=l.dirname(i);try{await d.mkdir(a,{recursive:!0});const t=P(await I(i)||{},e);await d.writeFile(i,JSON.stringify(t,null,2),"utf8")}catch(e){throw new Error(`Failed to save config to ${i}: ${e}`)}}function y(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}return s}const B=e=>e.endsWith("/")?e:`${e}/`,b=(e,t)=>{t&&Object.entries(t).forEach((([t,s])=>{null!=s&&e.searchParams.set(t,String(s))}))},z=async(e,t)=>{const s=await e.text();return s?a.safeJsonParse(s,t):t},q=(e,t,s={})=>{if(e.ok)return;const i=s.serviceName||"Service";throw new Error(y([t,"optionalAccess",e=>e.msg])||`${i} API request failed: ${e.status} ${e.statusText}`)},D=e=>e.headers.get("x-tt-logid")||void 0,N=e=>e?{"x-use-ppe":"1","x-tt-env":e}:{},k=e=>{const t=y([e,"optionalAccess",e=>e.trim,"call",e=>e()]);return t?{"x-coze-account":t}:{}},G=e=>{try{return"www.coze.cn"===new URL(e).hostname}catch(e){return!1}},F="coze-account",j=({getOrganizationId:e,organizationId:t})=>{if(!e&&!y([t,"optionalAccess",e=>e.trim,"call",e=>e()]))return void a.customFetch.removeScopedHeadersProvider(F);const s=e||(()=>t);a.customFetch.setScopedHeadersProvider(F,((e,t)=>{const i=(e=>"string"==typeof e?e:e instanceof URL?e.toString():"object"==typeof e&&e&&"url"in e?String(e.url):void 0)(e);return i&&G(i)?k(s()):{}}))};const x=async({url:e,api:t})=>{if(!e||!t.getWebUrl)return e;try{return function(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}return s}([await t.getWebUrl({original_url:e,exchange_for_short_url:!0}),"access",e=>e.data,"optionalAccess",e=>e.short_url])||e}catch(t){return e}},M=({api:e})=>async({url:t})=>await x({url:t,api:e})||t;const H=({accountId:e,authConfigured:t})=>({authConfigured:t,authValid:!1,clawId:void 0,accountId:e,updatedAt:void 0});function W(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}return s}const V=({api:e,resolveClawId:t})=>async(s={})=>{const i=s.clawId||await t();return(W([await e.listProcess({claw_id:i,size:s.size||100}),"access",e=>e.data,"optionalAccess",e=>e.processes])||[]).map((e=>(e=>{const t=String(e.id||"");if(!t)return null;const s=e;return{progressId:t,name:"string"==typeof e.name?e.name:void 0,type:"string"==typeof s.type?s.type:void 0,progressStatus:"running",raw:e}})(e))).filter((e=>null!==e))},$=e=>async({progressId:t,clawId:s})=>(await e({clawId:s})).find((e=>e.progressId===t))||null,Y=({listProgresses:e,runtimeStatusStore:t})=>async({sessionId:s,clawId:i})=>{const a=await e({clawId:i}),r=t.getLive(s),n=W([r,"optionalAccess",e=>e.status])||"idle",o=a.length;return{sessionId:s,displayStatus:"working"===n?"working":"idle",clawBusy:o>0,clawProgressCount:o,runtimeStatus:n,updatedAt:W([r,"optionalAccess",e=>e.updatedAt])}};class Z extends Error{constructor(e,t){super(e),this.code=t,this.name="SessionServiceError"}}const J=()=>new Z("Session token is missing or invalid","SESSION_AUTH_INVALID");function K(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}return s}const X=({api:e,resolveClawId:t})=>async()=>{const s=await t(),i=await e.createSession({claw_id:s}),a=K([i,"access",e=>e.data,"optionalAccess",e=>e.session,"optionalAccess",e=>e.id]);if(!a)throw new Z(i.msg||"Failed to create session","SESSION_CREATE_FAILED");return{clawId:s,sessionId:String(a)}},Q=({api:e,resolveClawId:t})=>async(s={})=>{const i=await t(),a=await e.listSession({claw_id:i,offset:s.offset,limit:s.limit});if(0!==a.code&&void 0!==a.code)throw new Z(a.msg||"Failed to list sessions","SESSION_LIST_FAILED");const r=K([a,"access",e=>e.data,"optionalAccess",e=>e.session_list])||[],n=K([a,"access",e=>e.data,"optionalAccess",e=>e.next_offset]);return{items:r,nextOffset:n,hasMore:Boolean(n)}},ee=({api:e,updateSessionRuntimeStatus:t})=>async({sessionId:s,content:i,files:a})=>{const r=await e.chat({session_id:s,content:i,files:a}),n=K([r,"access",e=>e.data,"optionalAccess",e=>e.message_id]);if(!n)throw new Z(r.msg||"Failed to send session message","SESSION_MESSAGE_FAILED");return await t({sessionId:s,status:"working"}),{sessionId:s,messageId:n,status:"accepted"}};var te,se,ie,ae,re,ne,oe,ce,le,de,_e,ue,pe,he,me,ge,Ee,we,fe,Te,Se,Re,Pe,Ae,Ue,Ie,Le,Ce,Oe,ve,ye,Be,be,ze,qe,De,Ne,ke,Ge,Fe,je,xe,Me,He,We,Ve,$e,Ye,Ze,Je,Ke,Xe,Qe,et,tt,st,it,at;function rt(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}return s}!function(e){e[e.Free=0]="Free";e[e.PremiumLite=10]="PremiumLite";e[e.Premium=15]="Premium";e[e.PremiumPlus=20]="PremiumPlus";e[e.V1ProInstance=100]="V1ProInstance";e[e.ProPersonal=110]="ProPersonal";e[e.CozePersonalPlus=112]="CozePersonalPlus";e[e.CozePersonalAdvanced=114]="CozePersonalAdvanced";e[e.CozePersonalPro=116]="CozePersonalPro";e[e.CozePersonalUltra=118]="CozePersonalUltra";e[e.Team=120]="Team";e[e.EnterpriseBasic=125]="EnterpriseBasic";e[e.Enterprise=130]="Enterprise";e[e.EnterprisePro=135]="EnterprisePro";e[e.CozeTeamAdvanced=2200]="CozeTeamAdvanced";e[e.CozeTeamPro=2300]="CozeTeamPro";e[e.CozeTeamUltra=2400]="CozeTeamUltra"}(te||(te={})),function(e){e[e.Resume=1]="Resume";e[e.Terminate=2]="Terminate"}(se||(se={})),function(e){e[e.CAL_TYPE_UNSPECIFIED=0]="CAL_TYPE_UNSPECIFIED";e[e.CAL_TYPE_CRON=1]="CAL_TYPE_CRON";e[e.CAL_TYPE_HEARTBEAT=2]="CAL_TYPE_HEARTBEAT";e[e.CAL_TYPE_ONCE=3]="CAL_TYPE_ONCE";e[e.CAL_TYPE_DEFAULT=4]="CAL_TYPE_DEFAULT"}(ie||(ie={})),function(e){e[e.EVENT_STATUS_UNSPECIFIED=0]="EVENT_STATUS_UNSPECIFIED";e[e.EVENT_STATUS_PENDING=1]="EVENT_STATUS_PENDING";e[e.EVENT_STATUS_RUNNING=2]="EVENT_STATUS_RUNNING";e[e.EVENT_STATUS_COMPLETED=3]="EVENT_STATUS_COMPLETED";e[e.EVENT_STATUS_PAUSED=4]="EVENT_STATUS_PAUSED";e[e.EVENT_STATUS_FAILED=5]="EVENT_STATUS_FAILED"}(ae||(ae={})),function(e){e[e.UnknownTask=0]="UnknownTask";e[e.SubagentTask=1]="SubagentTask";e[e.CronTask=2]="CronTask";e[e.MobileUseTask=3]="MobileUseTask";e[e.BrowserUseTask=4]="BrowserUseTask";e[e.ComputerUseTask=5]="ComputerUseTask"}(re||(re={})),function(e){e[e.Owner=1]="Owner";e[e.Member=10]="Member"}(ne||(ne={})),function(e){e[e.User=1]="User";e[e.Agent=2]="Agent"}(oe||(oe={})),function(e){e[e.Unread=1]="Unread";e[e.Read=2]="Read";e[e.Overdue=3]="Overdue"}(ce||(ce={})),function(e){e[e.Chat=1]="Chat"}(le||(le={})),function(e){e[e.All=0]="All";e[e.Private=1]="Private";e[e.NormalProject=2]="NormalProject";e[e.VideoProject=3]="VideoProject"}(de||(de={})),function(e){e[e.Common=1]="Common";e[e.Video=2]="Video"}(_e||(_e={})),function(e){e[e.History=0]="History";e[e.Private=1]="Private";e[e.Project=2]="Project"}(ue||(ue={})),function(e){e[e.Asset=1]="Asset";e[e.Material=2]="Material"}(pe||(pe={})),function(e){e[e.Running=1]="Running";e[e.Waiting=2]="Waiting";e[e.Terminated=3]="Terminated";e[e.Finish=4]="Finish"}(he||(he={})),function(e){e[e.PENDING=0]="PENDING";e[e.RUNNING=1]="RUNNING";e[e.COMPLETED=2]="COMPLETED";e[e.FAILED=3]="FAILED";e[e.INTERRUPTED=4]="INTERRUPTED";e[e.CANCELLED=5]="CANCELLED";e[e.TIMEOUT=6]="TIMEOUT";e[e.RESUMED=7]="RESUMED"}(me||(me={})),function(e){e[e.PENDING=0]="PENDING";e[e.RUNNING=1]="RUNNING";e[e.COMPLETED=2]="COMPLETED";e[e.FAILED=3]="FAILED";e[e.INTERRUPTED=4]="INTERRUPTED";e[e.RESUMED=5]="RESUMED";e[e.CANCELLED=6]="CANCELLED"}(ge||(ge={})),function(e){e[e.Managed=1]="Managed";e[e.Cloud=2]="Cloud";e[e.Local=3]="Local"}(Ee||(Ee={})),function(e){e[e.AgentFrameworkCozeClaw=0]="AgentFrameworkCozeClaw";e[e.AgentFrameworkClaudeCode=1]="AgentFrameworkClaudeCode";e[e.AgentFrameworkCodex=2]="AgentFrameworkCodex";e[e.AgentFrameworkOpenClaw=3]="AgentFrameworkOpenClaw"}(we||(we={})),function(e){e[e.Offline=0]="Offline";e[e.Online=1]="Online";e[e.Busy=2]="Busy";e[e.Starting=3]="Starting";e[e.Error=4]="Error"}(fe||(fe={})),function(e){e[e.CreateModeTemplate=1]="CreateModeTemplate";e[e.CreateModeCloudThirdParty=2]="CreateModeCloudThirdParty";e[e.CreateModeLocalThirdParty=3]="CreateModeLocalThirdParty"}(Te||(Te={})),function(e){e[e.ACCOUNT_QUOTA_ZERO=1]="ACCOUNT_QUOTA_ZERO";e[e.MOBILE_LIMIT_EXCEEDED=2]="MOBILE_LIMIT_EXCEEDED"}(Se||(Se={})),function(e){e[e.Terminate=1]="Terminate"}(Re||(Re={})),function(e){e[e.CANCEL=1]="CANCEL"}(Pe||(Pe={})),function(e){e[e.Success=1]="Success";e[e.Failed=2]="Failed";e[e.Timeout=3]="Timeout"}(Ae||(Ae={})),function(e){e[e.Init=1]="Init";e[e.Online=2]="Online";e[e.Busy=3]="Busy";e[e.Offline=4]="Offline";e[e.Error=5]="Error"}(Ue||(Ue={})),function(e){e[e.Unset=0]="Unset";e[e.Disabled=1]="Disabled";e[e.Enabled=2]="Enabled"}(Ie||(Ie={})),function(e){e[e.PENDING=0]="PENDING";e[e.APPROVED=1]="APPROVED";e[e.REJECTED=2]="REJECTED"}(Le||(Le={})),function(e){e[e.IDLE=1]="IDLE";e[e.INTERRUPTED=2]="INTERRUPTED";e[e.REBOOTING=3]="REBOOTING";e[e.INITIALIZING=4]="INITIALIZING";e[e.ARREARS=5]="ARREARS";e[e.RUNNING=6]="RUNNING";e[e.RESERVED=7]="RESERVED";e[e.SCALING=8]="SCALING";e[e.ASSIGN_FAILED=9]="ASSIGN_FAILED";e[e.BUSY=10]="BUSY"}(Ce||(Ce={})),function(e){e[e.PHONE_8C24G=1]="PHONE_8C24G";e[e.PHONE_4C12G=2]="PHONE_4C12G";e[e.PHONE_2C6G=3]="PHONE_2C6G";e[e.PC_2C4G=101]="PC_2C4G";e[e.PC_4C8G=102]="PC_4C8G";e[e.PC_8C16G=103]="PC_8C16G";e[e.PC_16C32G=104]="PC_16C32G";e[e.PC_32C64G=105]="PC_32C64G"}(Oe||(Oe={})),function(e){e[e.MOBILE=1]="MOBILE";e[e.COMPUTER=2]="COMPUTER"}(ve||(ve={})),function(e){e[e.SUBSCRIBING=0]="SUBSCRIBING";e[e.BOOTING=1]="BOOTING";e[e.REBOOTING=2]="REBOOTING";e[e.IDLE=3]="IDLE";e[e.BUSY=4]="BUSY";e[e.INTERRUPTED=5]="INTERRUPTED";e[e.RELEASING=6]="RELEASING";e[e.RELEASED=7]="RELEASED";e[e.OFFLINE=8]="OFFLINE";e[e.ARREARS=9]="ARREARS";e[e.RESERVED=10]="RESERVED";e[e.SCALING=11]="SCALING";e[e.ASSIGN_FAILED=12]="ASSIGN_FAILED"}(ye||(ye={})),function(e){e[e.HEALTHY=1]="HEALTHY";e[e.WARNING=2]="WARNING";e[e.CRITICAL=3]="CRITICAL"}(Be||(Be={})),function(e){e[e.AVAILABLE=1]="AVAILABLE";e[e.NEED_UPGRADE_PLAN=2]="NEED_UPGRADE_PLAN";e[e.NOT_ALLOWED_DOWNGRADE=3]="NOT_ALLOWED_DOWNGRADE";e[e.CURRENT_SPEC=4]="CURRENT_SPEC"}(be||(be={})),function(e){e[e.Send=1]="Send";e[e.Received=2]="Received";e[e.Spam=3]="Spam"}(ze||(ze={})),function(e){e[e.Normal=0]="Normal";e[e.Spoof=1]="Spoof";e[e.Phishing=2]="Phishing";e[e.Spam=3]="Spam";e[e.Malicious=4]="Malicious"}(qe||(qe={})),function(e){e[e.Normal=0]="Normal";e[e.Sending=1]="Sending";e[e.Failed=2]="Failed"}(De||(De={})),function(e){e[e.FILE_PARTITION_UNSPECIFIED=0]="FILE_PARTITION_UNSPECIFIED";e[e.FILE_PARTITION_USER_MEMORY=1]="FILE_PARTITION_USER_MEMORY";e[e.FILE_PARTITION_AGENT_ALL=2]="FILE_PARTITION_AGENT_ALL";e[e.FILE_PARTITION_USER_ALL=3]="FILE_PARTITION_USER_ALL";e[e.FILE_PARTITION_TRASH=9]="FILE_PARTITION_TRASH"}(Ne||(Ne={})),function(e){e[e.FILE_TAG_UNSPECIFIED=0]="FILE_TAG_UNSPECIFIED";e[e.FILE_TAG_FAVORITE=1]="FILE_TAG_FAVORITE";e[e.FILE_TAG_MEMORY=2]="FILE_TAG_MEMORY";e[e.FILE_TAG_TRASH=3]="FILE_TAG_TRASH";e[e.FILE_TAG_ALL=4]="FILE_TAG_ALL"}(ke||(ke={})),function(e){e[e.FILE_TYPE_UNSPECIFIED=0]="FILE_TYPE_UNSPECIFIED";e[e.FILE_TYPE_FAVORITE=1]="FILE_TYPE_FAVORITE";e[e.FILE_TYPE_TEMPLATE=2]="FILE_TYPE_TEMPLATE";e[e.FILE_TYPE_TEMPLATE_COVER=3]="FILE_TYPE_TEMPLATE_COVER";e[e.FILE_TYPE_PLAN_TEMPLATE=4]="FILE_TYPE_PLAN_TEMPLATE";e[e.FILE_TYPE_ARTICLE=5]="FILE_TYPE_ARTICLE"}(Ge||(Ge={})),function(e){e[e.FOLDER_ARCHIVE_STATUS_UNSPECIFIED=0]="FOLDER_ARCHIVE_STATUS_UNSPECIFIED";e[e.FOLDER_ARCHIVE_STATUS_PENDING=1]="FOLDER_ARCHIVE_STATUS_PENDING";e[e.FOLDER_ARCHIVE_STATUS_RUNNING=2]="FOLDER_ARCHIVE_STATUS_RUNNING";e[e.FOLDER_ARCHIVE_STATUS_SUCCEEDED=3]="FOLDER_ARCHIVE_STATUS_SUCCEEDED";e[e.FOLDER_ARCHIVE_STATUS_FAILED=4]="FOLDER_ARCHIVE_STATUS_FAILED";e[e.FOLDER_ARCHIVE_STATUS_REJECTED=5]="FOLDER_ARCHIVE_STATUS_REJECTED";e[e.FOLDER_ARCHIVE_STATUS_EXPIRED=6]="FOLDER_ARCHIVE_STATUS_EXPIRED"}(Fe||(Fe={})),function(e){e[e.WORKSPACE_SEARCH_TAB_UNSPECIFIED=0]="WORKSPACE_SEARCH_TAB_UNSPECIFIED";e[e.WORKSPACE_SEARCH_TAB_ALL=1]="WORKSPACE_SEARCH_TAB_ALL";e[e.WORKSPACE_SEARCH_TAB_DOC=2]="WORKSPACE_SEARCH_TAB_DOC";e[e.WORKSPACE_SEARCH_TAB_SHEET=3]="WORKSPACE_SEARCH_TAB_SHEET";e[e.WORKSPACE_SEARCH_TAB_PPT=4]="WORKSPACE_SEARCH_TAB_PPT";e[e.WORKSPACE_SEARCH_TAB_IMAGE=5]="WORKSPACE_SEARCH_TAB_IMAGE";e[e.WORKSPACE_SEARCH_TAB_WEB=6]="WORKSPACE_SEARCH_TAB_WEB";e[e.WORKSPACE_SEARCH_TAB_VIDEO=7]="WORKSPACE_SEARCH_TAB_VIDEO";e[e.WORKSPACE_SEARCH_TAB_PODCAST=8]="WORKSPACE_SEARCH_TAB_PODCAST"}(je||(je={})),function(e){e[e.Chat=1]="Chat";e[e.ApiTemplate=2]="ApiTemplate"}(xe||(xe={})),function(e){e[e.Add=1]="Add";e[e.Remove=2]="Remove"}(Me||(Me={})),function(e){e[e.User=1]="User";e[e.Agent=2]="Agent";e[e.Project=3]="Project"}(He||(He={})),function(e){e[e.Grant=1]="Grant";e[e.Revoke=2]="Revoke";e[e.UpdateScope=3]="UpdateScope"}(We||(We={})),function(e){e[e.Single=1]="Single";e[e.Desktop=2]="Desktop";e[e.All=3]="All"}(Ve||(Ve={})),function(e){e[e.Session=1]="Session";e[e.Agent=2]="Agent"}($e||($e={})),function(e){e[e.PDF=1]="PDF";e[e.PPT=2]="PPT";e[e.ImageEditablePpt=3]="ImageEditablePpt"}(Ye||(Ye={})),function(e){e[e.PDF=1]="PDF";e[e.DOCX=2]="DOCX"}(Ze||(Ze={})),function(e){e[e.POSITION=0]="POSITION";e[e.ELEMENT=1]="ELEMENT"}(Je||(Je={})),function(e){e[e.STORAGE_RESOURCE_TYPE_UNSPECIFIED=0]="STORAGE_RESOURCE_TYPE_UNSPECIFIED";e[e.STORAGE_RESOURCE_TYPE_AGENT=1]="STORAGE_RESOURCE_TYPE_AGENT";e[e.STORAGE_RESOURCE_TYPE_PROJECT=2]="STORAGE_RESOURCE_TYPE_PROJECT";e[e.STORAGE_RESOURCE_TYPE_VIDEO_PROJECT=3]="STORAGE_RESOURCE_TYPE_VIDEO_PROJECT";e[e.STORAGE_RESOURCE_TYPE_CODING_PROJECT=4]="STORAGE_RESOURCE_TYPE_CODING_PROJECT"}(Ke||(Ke={})),function(e){e[e.ACCOUNT_QUOTA_ZERO=1]="ACCOUNT_QUOTA_ZERO";e[e.RESOURCE_LIMIT_EXCEEDED=2]="RESOURCE_LIMIT_EXCEEDED"}(Xe||(Xe={})),function(e){e[e.MOBILE=1]="MOBILE";e[e.COMPUTER=2]="COMPUTER"}(Qe||(Qe={})),function(e){e[e.Delete=1]="Delete";e[e.Read=2]="Read";e[e.ClearAt=3]="ClearAt";e[e.Hide=4]="Hide"}(et||(et={})),function(e){e[e.Delete=0]="Delete";e[e.Running=1]="Running";e[e.Idle=2]="Idle"}(tt||(tt={})),function(e){e[e.Pin=1]="Pin";e[e.Unpin=2]="Unpin";e[e.Delete=3]="Delete"}(st||(st={})),function(e){e[e.Running=1]="Running";e[e.Idle=2]="Idle"}(it||(it={})),function(e){e[e.Valid=1]="Valid";e[e.Delete=2]="Delete"}(at||(at={}));class nt{__init(){this.request=a.request}__init2(){this.baseURL=""}constructor(e){nt.prototype.__init.call(this),nt.prototype.__init2.call(this),this.request=rt([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=rt([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}ListMessage(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/message/list"),a={session_id:s.session_id,cursor:s.cursor,size:s.size,asc_mode:s.asc_mode,need_reference:s.need_reference,conversation_id:s.conversation_id};return this.request({url:i,method:"POST",data:a},t)}ListSession(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/session/list"),a={claw_id:s.claw_id,limit:s.limit,offset:s.offset,is_pin:s.is_pin,order_by:s.order_by};return this.request({url:i,method:"POST",data:a},t)}ListProcess(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/process/list"),a={claw_id:s.claw_id,size:s.size,cursor:s.cursor};return this.request({url:i,method:"POST",data:a},t)}OperateSession(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/session/operate"),a={session_id:s.session_id,operate_type:s.operate_type,conversation_id:s.conversation_id};return this.request({url:i,method:"POST",data:a},t)}UpdateSession(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/session/update"),a={session_id:s.session_id,name:s.name,is_pin:s.is_pin};return this.request({url:i,method:"POST",data:a},t)}Chat(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/message/chat"),a={session_id:s.session_id,content:s.content,files:s.files,skill_ids:s.skill_ids,reference_message_id:s.reference_message_id,at_members:s.at_members,conversation_id:s.conversation_id,video_option:s.video_option,quick_reply:s.quick_reply};return this.request({url:i,method:"POST",data:a},t)}CreateMessageShare(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/message/create_share"),a={session_id:s.session_id,message_ids:s.message_ids,share_file:s.share_file};return this.request({url:i,method:"POST",data:a},t)}CreateSession(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/session/create"),a={claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}GetMainSession(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/session/get_main"),a={claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}EmailList(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/email/list"),a={claw_id:s.claw_id,email_type:s.email_type,contact_address:s.contact_address,size:s.size,cursor:s.cursor};return this.request({url:i,method:"POST",data:a},t)}CreateMailAddress(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/email/create_address"),a={claw_id:s.claw_id,address:s.address};return this.request({url:i,method:"POST",data:a},t)}BatchGetEmails(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/email/batch"),a={claw_id:s.claw_id,email_ids:s.email_ids};return this.request({url:i,method:"POST",data:a},t)}GetMailAddressInfo(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/email/get_address"),a={claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}UpdateUserClawInfo(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/claw/update_info"),a={claw_id:s.claw_id,file_name:s.file_name,file_content:s.file_content,model_name:s.model_name};return this.request({url:i,method:"POST",data:a},t)}ReceivedCallback(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/email/received_callback"),a={app_id:s.app_id,app_email:s.app_email,mail_id:s.mail_id,ouid:s.ouid,mail_message:s.mail_message,create_time:s.create_time};return this.request({url:i,method:"POST",data:a},t)}ListChannel(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/channel/list"),a={claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}GetUrl(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/resource/get_url"),a={uris:s.uris,share_id:s.share_id};return this.request({url:i,method:"POST",data:a},t)}GetUserClawInfo(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/claw/info"),a={claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}CalendarQueryRange(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/calendar/query_range"),a={start_date:s.start_date,end_date:s.end_date,timezone:s.timezone,claw_id:s.claw_id};return this.request({url:i,method:"GET",params:a},t)}GetRecentFiles(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/recent"),a={limit:s.limit,claw_id:s.claw_id,project_id:s.project_id};return this.request({url:i,method:"GET",params:a},t)}FileUpload(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/upload"),a={file_name:s.file_name,file_content:s.file_content,file_type:s.file_type,tags:s.tags,claw_id:s.claw_id,session_id:s.session_id,project_id:s.project_id,project_dir:s.project_dir};return this.request({url:i,method:"POST",data:a},t)}GetFileTree(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/tree"),a={partition:s.partition,depth:s.depth,claw_id:s.claw_id};return this.request({url:i,method:"GET",params:a},t)}ListFiles(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/list"),a={tag:s.tag,limit:s.limit,offset:s.offset,sort_by:s.sort_by,sort_order:s.sort_order,claw_id:s.claw_id,project_id:s.project_id,keyword:s.keyword};return this.request({url:i,method:"GET",params:a},t)}GetFrontierKey(e,t){const s=this.genBaseURL("/api/coze_claw/resource/get_frontier_key");return this.request({url:s,method:"GET"},t)}GetContacts(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/email/get_contacts"),a={claw_id:s.claw_id,size:s.size,cursor:s.cursor};return this.request({url:i,method:"POST",data:a},t)}CalendarBatchGetEvents(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/calendar/batch_get_events"),a={uids:s.uids,claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}UpdateFile(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/update"),a={file_path:s.file_path,file_content:s.file_content,claw_id:s.claw_id,file_uri:s.file_uri,project_id:s.project_id};return this.request({url:i,method:"POST",data:a},t)}GetFileVersions(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/versions"),a={file_path:s.file_path,claw_id:s.claw_id,file_uri:s.file_uri};return this.request({url:i,method:"GET",params:a},t)}GetSessionInfo(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/session/get_info"),a={session_id:s.session_id};return this.request({url:i,method:"POST",data:a},t)}GetMobileSTSCredentials(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/mobile/sts_credentials"),a={pod_id:s.pod_id};return this.request({url:i,method:"GET",params:a},t)}ListMobileTask(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/mobile/list_task"),a={size:s.size,cursor:s.cursor};return this.request({url:i,method:"POST",data:a},t)}FileSearch(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/search"),a={keyword:s.keyword,file_type:s.file_type,tags:s.tags,trash_only:s.trash_only,partition:s.partition,sort_by:s.sort_by,sort_order:s.sort_order,page_size:s.page_size,page_token:s.page_token,claw_id:s.claw_id,project_id:s.project_id};return this.request({url:i,method:"POST",data:a},t)}OperateMobileTask(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/mobile/operate_task"),a={mobile_task_id:s.mobile_task_id,action:s.action,reason:s.reason};return this.request({url:i,method:"POST",data:a},t)}Reset(e,t){const s=this.genBaseURL("/api/coze_claw/resource/reset");return this.request({url:s,method:"POST"},t)}ListMobile(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/mobile/list"),a={mobile_ids:s.mobile_ids};return this.request({url:i,method:"GET",params:a},t)}EmailSendCallback(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/email/send_callback"),a={otid:s.otid,ouid:s.ouid,mail_id:s.mail_id,message_id:s.message_id,time_stamp:s.time_stamp,from_address:s.from_address,recipient_address:s.recipient_address,event:s.event,src_ip:s.src_ip,return_code:s.return_code,return_msg:s.return_msg,last_update_time_stamp:s.last_update_time_stamp,delivery_error_classify:s.delivery_error_classify};return this.request({url:i,method:"POST",data:a},t)}UnsubscribeMobile(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/mobile/unsubscribe"),a={mobile_id:s.mobile_id};return this.request({url:i,method:"POST",data:a},t)}SubscribeMobile(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/mobile/subscribe"),a={name:s.name};return this.request({url:i,method:"POST",data:a},t)}OperateMobile(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/mobile/operate"),a={mobile_id:s.mobile_id,action:s.action,reason:s.reason,new_name:s.new_name};return this.request({url:i,method:"POST",data:a},t)}CalendarListRecurringEvents(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/calendar/list_recurring_events"),a={claw_id:s.claw_id};return this.request({url:i,method:"GET",params:a},t)}CalendarGetEventDebugURL(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/calendar/get_event_debug_url"),a={calendar_event_uid:s.calendar_event_uid,instance_start:s.instance_start};return this.request({url:i,method:"GET",params:a},t)}GetFeishuAuthInfo(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/channel/feishu/auth_info"),a={claw_id:s.claw_id,bot_name:s.bot_name,redirect_url:s.redirect_url};return this.request({url:i,method:"POST",data:a},t)}ExchangeFeishuAuthCode(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/channel/feishu/exchange_code"),a={code:s.code,verify_state:s.verify_state};return this.request({url:i,method:"POST",data:a},t)}FeishuAuthCallback(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/channel/feishu/auth_callback"),a={code:s.code,verify_state:s.verify_state};return this.request({url:i,method:"POST",data:a},t)}CancelFeishuAuth(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/channel/feishu/cancel_auth"),a={claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}ApiTemplate(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/image/api_template"),a={session_id:s.session_id,prompt:s.prompt,files:s.files,type:s.type};return this.request({url:i,method:"POST",data:a},t)}CreateFeishuApp(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/channel/feishu/create_app"),a={claw_id:s.claw_id,bot_name:s.bot_name,recreate:s.recreate};return this.request({url:i,method:"POST",data:a},t)}GetWebUrl(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/resource/get_web_url"),a={original_url:s.original_url,exchange_for_short_url:s.exchange_for_short_url,exchange_for_qr_code:s.exchange_for_qr_code,exchange_for_long_url:s.exchange_for_long_url};return this.request({url:i,method:"GET",params:a},t)}CalendarDelete(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/calendar/delete"),a={uid:s.uid,instance_start:s.instance_start,claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}CalendarResume(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/calendar/resume"),a={uid:s.uid,instance_start:s.instance_start,claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}CalendarPause(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/calendar/pause"),a={uid:s.uid,instance_start:s.instance_start,claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}DetailMobile(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/mobile/detail"),a={mobile_id:s.mobile_id};return this.request({url:i,method:"GET",params:a},t)}MGetMessage(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/message/mget"),a={session_id:s.session_id,message_ids:s.message_ids};return this.request({url:i,method:"POST",data:a},t)}GenCover(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/resource/gen_cover"),a={original_file_uri:s.original_file_uri,resolution:s.resolution,mode:s.mode,selector_str:s.selector_str,claw_id:s.claw_id,project_id:s.project_id};return this.request({url:i,method:"POST",data:a},t)}GenDoc(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/resource/gen_doc"),a={target_file_type:s.target_file_type,original_file_uri:s.original_file_uri,resource_map:s.resource_map,claw_id:s.claw_id,project_id:s.project_id};return this.request({url:i,method:"POST",data:a},t)}ShareDocs(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/message/share_docs"),a={uris:s.uris};return this.request({url:i,method:"POST",data:a},t)}TerminateProcess(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/process/terminate"),a={claw_id:s.claw_id,process_id:s.process_id};return this.request({url:i,method:"POST",data:a},t)}SearchMessage(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/message/search_message"),a={session_id:s.session_id,query:s.query,limit:s.limit};return this.request({url:i,method:"POST",data:a},t)}WorkspaceSearch(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/workspace_search"),a={keyword:s.keyword,tab:s.tab,page_size:s.page_size,page_token:s.page_token,session_id:s.session_id,claw_id:s.claw_id,project_id:s.project_id};return this.request({url:i,method:"GET",params:a},t)}ExportPPT(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/resource/export_ppt"),a={source_uri:s.source_uri,export_type:s.export_type};return this.request({url:i,method:"POST",data:a},t)}CreateFolderArchive(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/archive/create"),a={claw_id:s.claw_id,file_path:s.file_path,partition:s.partition,project_id:s.project_id};return this.request({url:i,method:"POST",data:a},t)}GetFolderArchiveStatus(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/archive/status"),a={claw_id:s.claw_id,job_id:s.job_id,project_id:s.project_id};return this.request({url:i,method:"GET",params:a},t)}GetSandboxToken(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/browser_use/get_sandbox_token"),a={session_id:s.session_id,claw_id:s.claw_id,session_key:s.session_key,computer_id:s.computer_id};return this.request({url:i,method:"POST",data:a},t)}OperateBrowserUse(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/browser_use/operate"),a={session_id:s.session_id,claw_id:s.claw_id,action:s.action};return this.request({url:i,method:"POST",data:a},t)}ListBrowserUseMessage(e,t){const s=this.genBaseURL("/api/coze_claw/browser_use/list_message");return this.request({url:s,method:"GET"},t)}IntentRecognition(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/image/intent_recognition"),a={session_id:s.session_id,files:s.files,query:s.query};return this.request({url:i,method:"POST",data:a},t)}RestoreFileVersion(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/versions/restore"),a={file_path:s.file_path,claw_id:s.claw_id,file_uri:s.file_uri,version_id:s.version_id};return this.request({url:i,method:"POST",data:a},t)}GetFileVersionURL(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/versions/url"),a={file_path:s.file_path,claw_id:s.claw_id,file_uri:s.file_uri,version_id:s.version_id};return this.request({url:i,method:"GET",params:a},t)}ExportPPTSandbox(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/resource/export_ppt_sandbox"),a={sandbox_identity_ticket:s.sandbox_identity_ticket,html_content:s.html_content,title:s.title,export_type:s.export_type};return this.request({url:i,method:"POST",data:a},t)}CheckSubscribe(e,t){const s=this.genBaseURL("/api/coze_claw/mobile/check_subscribe");return this.request({url:s,method:"GET"},t)}GetMessageShare(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/message/get_share"),a={share_id:s.share_id,need_reference:s.need_reference};return this.request({url:i,method:"POST",data:a},t)}GetModelConfig(e,t){const s=this.genBaseURL("/api/coze_claw/resource/get_model_config");return this.request({url:s,method:"POST"},t)}CheckResourceSubscribe(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/resource/check_subscribe"),a={resource_types:s.resource_types};return this.request({url:i,method:"GET",params:a},t)}UnsubscribeComputer(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/computer/unsubscribe"),a={computer_id:s.computer_id};return this.request({url:i,method:"POST",data:a},t)}ListComputer(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/computer/list"),a={computer_ids:s.computer_ids};return this.request({url:i,method:"GET",params:a},t)}SubscribeComputer(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/computer/subscribe"),a={name:s.name};return this.request({url:i,method:"POST",data:a},t)}OperateComputer(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/computer/operate"),a={computer_id:s.computer_id,action:s.action,new_name:s.new_name};return this.request({url:i,method:"POST",data:a},t)}WechatBindWait(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/channel/wechat/bind_wait"),a={claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}WechatWebhook(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/wechat/webhook"),a={app_id:s.app_id,wechat_messages:s.wechat_messages};return this.request({url:i,method:"POST",data:a},t)}WechatBindStart(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/channel/wechat/bind_start"),a={claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}WechatUnbind(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/channel/wechat/unbind"),a={claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}OperateVideoTask(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/video/operate_task"),a={video_task_id:s.video_task_id,action:s.action,claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}ListVideoTask(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/video/list_task"),a={size:s.size,cursor:s.cursor,claw_id:s.claw_id};return this.request({url:i,method:"GET",params:a},t)}WechatUnbindInternal(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/channel/wechat/unbind_internal"),a={app_id:s.app_id};return this.request({url:i,method:"POST",data:a},t)}GetEmailSettings(e,t){const s=this.genBaseURL("/api/coze_claw/email/get_settings");return this.request({url:s,method:"POST"},t)}GetFileTreeV2(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/tree_v2"),a={partition:s.partition,depth:s.depth,claw_id:s.claw_id,file_path:s.file_path,project_id:s.project_id};return this.request({url:i,method:"GET",params:a},t)}SandboxSkillHubAdd(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/skill/skill_hub_add"),a={sandbox_identity_ticket:s.sandbox_identity_ticket,skill_id:s.skill_id,agent_id:s.agent_id};return this.request({url:i,method:"POST",data:a},t)}SandboxSkillHubShopSearch(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/skill/skill_hub_shop_search"),a={sandbox_identity_ticket:s.sandbox_identity_ticket,keyword:s.keyword};return this.request({url:i,method:"POST",data:a},t)}GetStorageUsage(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/resource/storage_usage"),a={claw_id:s.claw_id,project_id:s.project_id};return this.request({url:i,method:"GET",params:a},t)}MobileScreenShot(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/mobile/screenshot"),a={mobile_id:s.mobile_id};return this.request({url:i,method:"GET",params:a},t)}OperateComputerTask(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/computer/operate_task"),a={run_id:s.run_id,action:s.action};return this.request({url:i,method:"POST",data:a},t)}ListComputerTask(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/computer/list_task"),a={size:s.size,cursor:s.cursor};return this.request({url:i,method:"POST",data:a},t)}ListClaw(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project/list_claw"),a={project_id:s.project_id,limit:s.limit,cursor:s.cursor};return this.request({url:i,method:"POST",data:a},t)}ListProject(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project/list"),a={type:s.type,limit:s.limit,offset:s.offset,is_pin:s.is_pin};return this.request({url:i,method:"POST",data:a},t)}RemoveProjectMember(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project_member/remove"),a={project_id:s.project_id,project_member:s.project_member};return this.request({url:i,method:"POST",data:a},t)}UpdateInviteProjectUser(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project_invite/update"),a={project_id:s.project_id,is_accept:s.is_accept};return this.request({url:i,method:"POST",data:a},t)}CreateProject(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project/create"),a={claw_ids:s.claw_ids,name:s.name,source_message_ids:s.source_message_ids,source_msg_id:s.source_msg_id,sub_type:s.sub_type};return this.request({url:i,method:"POST",data:a},t)}InviteProjectUser(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project_invite/invite"),a={project_id:s.project_id,invite_member:s.invite_member,invite_agent:s.invite_agent};return this.request({url:i,method:"POST",data:a},t)}DeleteProject(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project/delete"),a={project_id:s.project_id};return this.request({url:i,method:"POST",data:a},t)}AddProjectMember(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project_member/add"),a={project_id:s.project_id,members:s.members};return this.request({url:i,method:"POST",data:a},t)}CreateClaw(e,t){const s=this.genBaseURL("/api/coze_claw/project/create_claw");return this.request({url:s,method:"POST"},t)}UpdateProject(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project/update"),a={project_id:s.project_id,name:s.name,description:s.description,is_pin:s.is_pin};return this.request({url:i,method:"POST",data:a},t)}LeaveProject(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project_member/leave"),a={project_id:s.project_id};return this.request({url:i,method:"POST",data:a},t)}GetDeviceCreatePreflight(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/device/create/preflight"),a={cloud_device_type:s.cloud_device_type,cloud_device_id:s.cloud_device_id,enterprise_id:s.enterprise_id};return this.request({url:i,method:"GET",params:a},t)}ListInvitedProject(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project_invite/list_project"),a={limit:s.limit,offset:s.offset};return this.request({url:i,method:"POST",data:a},t)}ListProjectInvitee(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project_invite/list_invitee"),a={project_id:s.project_id};return this.request({url:i,method:"POST",data:a},t)}GetGlobalFileTree(e,t){const s=this.genBaseURL("/api/coze_claw/file/global_tree");return this.request({url:s,method:"GET"},t)}EnterpriseGetDeviceStats(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/stats"),a={enterprise_id:s.enterprise_id};return this.request({url:i,method:"GET",params:a},t)}ListBackgroundSession(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/session/list_background"),a={session_id:s.session_id,filter_running:s.filter_running,cursor:s.cursor,size:s.size};return this.request({url:i,method:"POST",data:a},t)}EnterpriseListMyDevice(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/my"),a={cursor:s.cursor,page_size:s.page_size,enterprise_id:s.enterprise_id};return this.request({url:i,method:"GET",params:a},t)}EnterpriseGetAutoApprove(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/auto_approve"),a={enterprise_id:s.enterprise_id};return this.request({url:i,method:"GET",params:a},t)}EnterpriseAssignDevice(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/assign"),a={cloud_device_id:s.cloud_device_id,target_user_uid:s.target_user_uid,organization_id:s.organization_id,cloud_device_type:s.cloud_device_type,enterprise_id:s.enterprise_id};return this.request({url:i,method:"POST",data:a},t)}GetPairResult(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/get_pair_result"),a={pair_code:s.pair_code};return this.request({url:i,method:"POST",data:a},t)}GetAgentStatus(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/get_status"),a={agent_ids:s.agent_ids};return this.request({url:i,method:"POST",data:a},t)}GetGlobalStorageUsage(e,t){const s=this.genBaseURL("/api/coze_claw/resource/global_storage_usage");return this.request({url:s,method:"GET"},t)}EnterpriseClaimDevice(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/claim"),a={devices:s.devices,enterprise_id:s.enterprise_id};return this.request({url:i,method:"POST",data:a},t)}EnterpriseEditDevice(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/edit"),a={cloud_device_id:s.cloud_device_id,device_name:s.device_name,spec:s.spec,confirm_price_change:s.confirm_price_change,cloud_device_type:s.cloud_device_type,enterprise_id:s.enterprise_id};return this.request({url:i,method:"POST",data:a},t)}SubscribeDevice(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/device/subscribe"),a={cloud_device_type:s.cloud_device_type,spec:s.spec,name:s.name};return this.request({url:i,method:"POST",data:a},t)}ChangeDeviceSpec(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/device/change_spec"),a={cloud_device_type:s.cloud_device_type,cloud_device_id:s.cloud_device_id,target_spec:s.target_spec,name:s.name};return this.request({url:i,method:"POST",data:a},t)}EnterpriseListDeviceClaimRecord(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/claim/list"),a={cursor:s.cursor,page_size:s.page_size,status:s.status,keyword:s.keyword,enterprise_id:s.enterprise_id};return this.request({url:i,method:"GET",params:a},t)}GeneratePairCode(e,t){const s=this.genBaseURL("/api/coze_claw/agent/generate_pair_code");return this.request({url:s,method:"POST"},t)}EnterpriseRejectDeviceClaim(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/claim/reject"),a={claim_record_id:s.claim_record_id,reason:s.reason,enterprise_id:s.enterprise_id};return this.request({url:i,method:"POST",data:a},t)}EnterpriseDeleteDevice(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/delete"),a={cloud_device_id:s.cloud_device_id,cloud_device_type:s.cloud_device_type,enterprise_id:s.enterprise_id};return this.request({url:i,method:"POST",data:a},t)}EnterpriseApproveDeviceClaim(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/claim/approve"),a={claim_record_id:s.claim_record_id,enterprise_id:s.enterprise_id};return this.request({url:i,method:"POST",data:a},t)}EnterpriseListDevice(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/list"),a={cursor:s.cursor,page_size:s.page_size,keyword:s.keyword,cloud_device_type:s.cloud_device_type,status:s.status,enterprise_id:s.enterprise_id};return this.request({url:i,method:"GET",params:a},t)}EnterpriseListAvailableDevice(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/available"),a={cursor:s.cursor,page_size:s.page_size,enterprise_id:s.enterprise_id};return this.request({url:i,method:"GET",params:a},t)}CreateAgent(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/create"),a={agent_name:s.agent_name,create_mode:s.create_mode,template_id:s.template_id,target_device_id:s.target_device_id,framework:s.framework,pair_code:s.pair_code,local_agents:s.local_agents,description:s.description,icon:s.icon};return this.request({url:i,method:"POST",data:a},t)}ListDeviceAgents(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/agent/device/binding/list_by_device"),a={cloud_device_id:s.cloud_device_id,cloud_device_type:s.cloud_device_type,cursor:s.cursor,page_size:s.page_size};return this.request({url:i,method:"GET",params:a},t)}EnterpriseReassignDevice(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/reassign"),a={cloud_device_id:s.cloud_device_id,new_user_uid:s.new_user_uid,new_organization_id:s.new_organization_id,cloud_device_type:s.cloud_device_type,enterprise_id:s.enterprise_id};return this.request({url:i,method:"POST",data:a},t)}EnterpriseSetAutoApprove(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/auto_approve"),a={enabled:s.enabled,enterprise_id:s.enterprise_id};return this.request({url:i,method:"POST",data:a},t)}GetHotWords(e,t){const s=this.genBaseURL("/api/coze_claw/asr/get_hot_words");return this.request({url:s,method:"GET"},t)}GetModelList(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/resource/get_model_list"),a={claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}SelectModel(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/resource/select_model"),a={claw_id:s.claw_id,name:s.name};return this.request({url:i,method:"POST",data:a},t)}CreateSessionConversation(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/session_conversation/create"),a={session_id:s.session_id,name:s.name,description:s.description};return this.request({url:i,method:"POST",data:a},t)}OperateSessionConversation(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/session_conversation/operate"),a={session_conversation_id:s.session_conversation_id,operate_type:s.operate_type};return this.request({url:i,method:"POST",data:a},t)}MessageCardAction(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/message_card/action"),a={name:s.name,surface_id:s.surface_id,source_component_id:s.source_component_id,timestamp:s.timestamp,context:s.context,message_id:s.message_id,claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}UpdateSessionConversation(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/session_conversation/update"),a={session_conversation_id:s.session_conversation_id,name:s.name,description:s.description};return this.request({url:i,method:"POST",data:a},t)}ListConversation(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/conversation/list"),a={type:s.type,is_pin:s.is_pin,limit:s.limit,offset:s.offset,top_claw_id:s.top_claw_id};return this.request({url:i,method:"POST",data:a},t)}EnterpriseBatchCreateDevice(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/enterprise/device/batch_create"),a={cloud_device_type:s.cloud_device_type,device_name:s.device_name,spec:s.spec,quantity:s.quantity,enterprise_id:s.enterprise_id};return this.request({url:i,method:"POST",data:a},t)}ListSessionConversation(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/session_conversation/list"),a={session_id:s.session_id,limit:s.limit,offset:s.offset};return this.request({url:i,method:"POST",data:a},t)}GetAgentFileContent(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/file/content"),a={agent_id:s.agent_id,file_path:s.file_path,file_token:s.file_token};return this.request({url:i,method:"GET",params:a},t)}GetProjectInfo(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project/info"),a={project_id:s.project_id};return this.request({url:i,method:"POST",data:a},t)}OperateDesktop(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/desktop/operate"),a={device_id:s.device_id,action:s.action,new_name:s.new_name};return this.request({url:i,method:"POST",data:a},t)}DesktopHeartbeat(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/desktop/heartbeat"),a={device_id:s.device_id,version:s.version,status:s.status,os:s.os,desktop_name:s.desktop_name};return this.request({url:i,method:"POST",data:a},t)}ReportDesktopCommandResult(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/desktop/report_command_result"),a={command_id:s.command_id,status:s.status,data:s.data,upload_file:s.upload_file};return this.request({url:i,method:"POST",data:a},t)}ListDesktop(e,t){const s=this.genBaseURL("/api/coze_claw/desktop/list");return this.request({url:s,method:"GET"},t)}SearchProject(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project/search"),a={type:s.type,keyword:s.keyword,limit:s.limit,cursor:s.cursor};return this.request({url:i,method:"GET",params:a},t)}GetProjectMembers(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project_member/list"),a={project_id:s.project_id};return this.request({url:i,method:"POST",data:a},t)}UpdateAgent(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/update"),a={agent_id:s.agent_id,agent_name:s.agent_name,description:s.description,file_name:s.file_name,file_content:s.file_content};return this.request({url:i,method:"POST",data:a},t)}ListAgents(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/agent/list"),a={page_size:s.page_size,cursor:s.cursor,deploy_types:s.deploy_types,order_by:s.order_by};return this.request({url:i,method:"POST",data:a},t)}GetAgentDetail(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/detail"),a={agent_id:s.agent_id};return this.request({url:i,method:"POST",data:a},t)}ReconnectAgent(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/reconnect"),a={agent_id:s.agent_id,reason:s.reason};return this.request({url:i,method:"POST",data:a},t)}DisconnectAgent(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/disconnect"),a={agent_id:s.agent_id,reason:s.reason,force:s.force};return this.request({url:i,method:"POST",data:a},t)}GetCozeClawUserInfo(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/user/info"),a={need_onboarding_status:s.need_onboarding_status};return this.request({url:i,method:"POST",data:a},t)}SetCozeClawUserOnboardingStatus(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/user/set_onboarding_status"),a={onboarding_status:s.onboarding_status};return this.request({url:i,method:"POST",data:a},t)}GetGlobalUnread(e,t){const s=this.genBaseURL("/api/coze_claw/unread/get_total");return this.request({url:s,method:"POST"},t)}GenerateAgentName(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/agent/generate_name"),a={create_mode:s.create_mode,template_id:s.template_id,framework:s.framework};return this.request({url:i,method:"POST",data:a},t)}ListProjectFiles(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/project/file/list"),a={project_id:s.project_id,file_path:s.file_path,depth:s.depth};return this.request({url:i,method:"POST",data:a},t)}WriteProjectFile(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/project/file/write"),a={project_id:s.project_id,file_path:s.file_path,content:s.content};return this.request({url:i,method:"POST",data:a},t)}ReadProjectFile(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/project/file/read"),a={project_id:s.project_id,file_path:s.file_path,offset:s.offset,limit:s.limit};return this.request({url:i,method:"POST",data:a},t)}EditProjectFile(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/project/file/edit"),a={project_id:s.project_id,file_path:s.file_path,mode:s.mode,old_string:s.old_string,new_string:s.new_string,append_content:s.append_content};return this.request({url:i,method:"POST",data:a},t)}ComputerScreenShot(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/computer/screenshot"),a={computer_id:s.computer_id};return this.request({url:i,method:"GET",params:a},t)}CancelProjectInvite(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project_invite/cancel"),a={project_id:s.project_id,invite_member:s.invite_member};return this.request({url:i,method:"POST",data:a},t)}GenerateAgentIcon(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/generate_icon"),a={agent_name:s.agent_name,description:s.description};return this.request({url:i,method:"POST",data:a},t)}ListPermission(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/permission/list"),a={session_id:s.session_id};return this.request({url:i,method:"GET",params:a},t)}OperatePermission(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/permission/operate"),a={session_id:s.session_id,action:s.action,target:s.target,permission_id:s.permission_id,desktop_id:s.desktop_id,scope:s.scope,claw_id:s.claw_id,file_path:s.file_path};return this.request({url:i,method:"POST",data:a},t)}RepairAgent(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/repair"),a={agent_id:s.agent_id,reason:s.reason};return this.request({url:i,method:"POST",data:a},t)}ResetAgent(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/reset"),a={agent_id:s.agent_id,reason:s.reason};return this.request({url:i,method:"POST",data:a},t)}MGetConversation(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/conversation/mget"),a={session_ids:s.session_ids,option:s.option,claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}GetProjectByClawID(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project/get_by_claw_id"),a={claw_id:s.claw_id};return this.request({url:i,method:"POST",data:a},t)}GetDesktopCommand(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/desktop/get_command"),a={command_id:s.command_id};return this.request({url:i,method:"GET",params:a},t)}OperateVideoConversation(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/video/operate_conversation"),a={session_id:s.session_id,conversation_id:s.conversation_id,action:s.action};return this.request({url:i,method:"POST",data:a},t)}ValidateAgentName(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/validate_name"),a={agent_name:s.agent_name};return this.request({url:i,method:"POST",data:a},t)}GetLocalFileAccess(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/desktop/local_file_access"),a={device_id:s.device_id};return this.request({url:i,method:"GET",params:a},t)}UpdateLocalFileAccess(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/desktop/update_local_file_access"),a={device_id:s.device_id,status:s.status};return this.request({url:i,method:"POST",data:a},t)}AgentFileUpload(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/agent_upload"),a={file_name:s.file_name,file_content:s.file_content,file_type:s.file_type,tags:s.tags,agent_id:s.agent_id,session_id:s.session_id};return this.request({url:i,method:"POST",data:a},t)}SetNewFeaturePopupStatus(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/user/set_new_feature_popup_status"),a={new_feature_popup_status:s.new_feature_popup_status};return this.request({url:i,method:"POST",data:a},t)}DownloadFile(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/file/download"),a={file_url:s.file_url};return this.request({url:i,method:"GET",params:a},t)}DownloadImage(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/file/download_image"),a={file_content:s.file_content,file_name:s.file_name,file_uri:s.file_uri};return this.request({url:i,method:"POST",data:a},t)}ResetV2(e,t){const s=this.genBaseURL("/api/coze_claw/resource/reset_v2");return this.request({url:s,method:"POST"},t)}AgentWebSearch(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/web_search"),a={agent_id:s.agent_id,query_list:s.query_list,project_id:s.project_id};return this.request({url:i,method:"POST",data:a},t)}AgentWebFetch(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/web_fetch"),a={agent_id:s.agent_id,url:s.url,project_id:s.project_id,response_length:s.response_length};return this.request({url:i,method:"POST",data:a},t)}UpgradeBridge(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/upgrade_bridge"),a={agent_id:s.agent_id};return this.request({url:i,method:"POST",data:a},t)}ListRecentInvitees(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/project_invite/list_recent"),a={project_id:s.project_id,limit:s.limit,offset:s.offset};return this.request({url:i,method:"POST",data:a},t)}GetAgentPermissionMode(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/get_permission_mode"),a={agent_id:s.agent_id,session_id:s.session_id,is_project_session:s.is_project_session};return this.request({url:i,method:"POST",data:a},t)}MGetAgentPermissionMode(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/mget_permission_mode"),a={session_id:s.session_id,agent_ids:s.agent_ids,is_project_session:s.is_project_session};return this.request({url:i,method:"POST",data:a},t)}SetAgentPermissionMode(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/set_permission_mode"),a={agent_id:s.agent_id,session_id:s.session_id,permission_mode:s.permission_mode,is_project_session:s.is_project_session};return this.request({url:i,method:"POST",data:a},t)}UpdateMessageReaction(e,t){const s=e||{},i=this.genBaseURL("/api/coze_claw/message/reaction/update"),a={message_id:s.message_id,name:s.name,action:s.action};return this.request({url:i,method:"POST",data:a},t)}GetMessageReactionConfig(e,t){const s=this.genBaseURL("/api/coze_claw/message/reaction_config");return this.request({url:s,method:"POST"},t)}UpgradeGuide(e,t){const s=e,i=this.genBaseURL("/api/coze_claw/agent/upgrade_guide"),a={agent_id:s.agent_id};return this.request({url:i,method:"POST",data:a},t)}GetPcClientUsageStatus(e,t){const s=this.genBaseURL("/api/coze_claw/user/pc_client_usage_status");return this.request({url:s,method:"POST"},t)}}const ot=new nt({});function ct(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}return s}const lt=Ye.PPT,dt=Ye.ImageEditablePpt,_t=e=>e.replace(/\s+/g," ").trim(),ut=e=>_t(e.replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'")),pt=e=>{const t=e.match(/<title[^>]*>([\s\S]*?)<\/title>/i),s=ct([t,"optionalAccess",e=>e[1]])?ut(t[1]):"";if(s)return s;const i=ut(e);return i?i.split(" ")[0]:void 0},ht=e=>{const t=(e=>{if(e.includes("\x3c!--SPLIT_HTML--\x3e"))return e.split("\x3c!--SPLIT_HTML--\x3e").map((e=>e.trim())).filter(Boolean);const t=e.match(/<html[\s\S]*?<\/html>/gi);return ct([t,"optionalAccess",e=>e.length])?t.map((e=>e.trim())).filter(Boolean):[e.trim()].filter(Boolean)})(e).map(((e,t)=>({page:t+1,title:pt(e),previewText:ut(e)})));return{type:"html",pageCount:t.length,pages:t}},mt=(e,t)=>{if(!(t.length>=80||void 0===e))if("string"!=typeof e)Array.isArray(e)?e.forEach((e=>mt(e,t))):e&&"object"==typeof e&&Object.entries(e).forEach((([e,s])=>{(["title","text","content","description","name"].includes(e)||Array.isArray(s)||s&&"object"==typeof s)&&mt(s,t)}));else{const s=_t(e);s&&t.push(s)}},gt=({api:e})=>async({fileUri:t,exportType:s="ppt"})=>{const i=await e.exportPPT({source_uri:t,export_type:"editable"===s?dt:lt});if(void 0!==i.code&&0!==i.code&&"0"!==i.code)throw new Z(i.msg||"Failed to export PPT","SESSION_PPT_EXPORT_FAILED");const a=ct([i,"access",e=>e.data,"optionalAccess",e=>e.url]);if(!a)throw new Z(i.msg||"PPT export response missing download URL","SESSION_PPT_EXPORT_FAILED");return{uri:ct([i,"access",e=>e.data,"optionalAccess",e=>e.uri]),url:a,exportType:s}};function Et(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}return s}const wt=e=>{const t=String(e.id||"");if(!t)return null;const s="string"==typeof e.content?e.content:"",i=(r=s,a.safeJsonParse(r,void 0));var r;const n=Et([i,"optionalAccess",e=>e.message_data,"optionalAccess",e=>e.reply]),o=void 0===Et([i,"optionalAccess",e=>e.create_time_ms])?void 0:String(i.create_time_ms);return{messageId:t,sessionId:"string"==typeof Et([i,"optionalAccess",e=>e.session_id])?i.session_id:void 0,source:(c=e.source,1===Number(c)?"user":2===Number(c)?"agent":"unknown"),content:"string"==typeof Et([n,"optionalAccess",e=>e.content])&&n.content?n.content:s,files:Array.isArray(e.files)?e.files:void 0,createTime:"string"==typeof e.create_time?e.create_time:o,messageType:"string"==typeof Et([i,"optionalAccess",e=>e.message_type])?i.message_type:void 0,replyToMessageId:"string"==typeof Et([n,"optionalAccess",e=>e.reply_to_message_id])?n.reply_to_message_id:void 0,raw:e};var c};const ft=({api:e})=>async({fileUri:t})=>{const s=await e.getUrl({uris:[t]}),i=function(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}return s}([s,"access",e=>e.data,"optionalAccess",e=>e.urls,"optionalAccess",e=>e[0]]);if(!i)throw new Z(s.msg||"Failed to resolve session file URL","SESSION_FILE_URL_FAILED");return i};const Tt=async({formData:e,request:t})=>{e.append("file_name",t.fileName);const s=await(async e=>{if(e instanceof Blob)return e;if(Buffer.isBuffer(e))return new Blob([e]);if(e instanceof Uint8Array)return new Blob([e]);if(e instanceof ArrayBuffer)return new Blob([e]);if("string"==typeof e)return new Blob([e]);throw new TypeError("Unsupported session upload file content type")})(t.fileContent),i=(a=t.fileContent)instanceof Blob&&a.type?a.type:void 0;var a;const r=i&&s.type!==i?new Blob([s],{type:i}):s;e.append("file_content",r,t.fileName),e.append("claw_id",t.clawId),t.projectId&&e.append("project_id",t.projectId),t.projectDir&&e.append("project_dir",t.projectDir),t.sessionId&&e.append("session_id",t.sessionId)},St=({options:e,requestOptions:t})=>{const s={...(i=t.headers,a=()=>({}),null!=i?i:a())};var i,a;const r=(({baseUrl:e,webOrigin:t})=>{if(t)return t;try{return new URL(B(e)).origin}catch(e){return}})({baseUrl:e.baseUrl,webOrigin:e.webOrigin});return r&&(s.Origin=r),s.Referer=(({baseUrl:e,webOrigin:t})=>t?t.endsWith("/")?t:`${t}/`:B(e))({baseUrl:e.baseUrl,webOrigin:e.webOrigin}),e.xSpaceWebId&&(s["x-space-webid"]=e.xSpaceWebId),Object.assign(s,N(e.xTTEnv)),s},Rt=e=>async(t,s={})=>{const i=new URL("/api/coze_claw/file/upload",B(e.baseUrl)),r=new FormData;await Tt({formData:r,request:t});const n=St({options:e,requestOptions:s}),o=a.customFetch.getRequestHeaders(i.toString(),{headers:n}),c=await globalThis.fetch(i.toString(),{method:"POST",headers:o,body:r});!function(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}}([s,"access",e=>e.onGetLogId,"optionalCall",e=>e(c.headers.get("x-tt-logid")||"")]);const l=await z(c,{});return q(c,l,{serviceName:"Session"}),l};const Pt=async({baseUrl:e,params:t,requestOptions:s={},responseFallback:i,xTTEnv:r})=>{const n=new URL(t.url,B(e));b(n,t.params);const o={"Content-Type":"application/json",...(c=s.headers,l=()=>({}),null!=c?c:l()),...N(r)};var c,l;const d=t.method.toUpperCase(),_="GET"===d?void 0:JSON.stringify(void 0===t.data?{}:t.data),u=await a.customFetch.fetch(n.toString(),{method:d,headers:o,body:_});!function(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}}([s,"access",e=>e.onGetLogId,"optionalCall",e=>e(D(u)||"")]);const p=await z(u,i);return q(u,p,{serviceName:"Session"}),p},At=e=>{const t=async(t,s={})=>await Pt({baseUrl:e.baseUrl,params:t,requestOptions:s,responseFallback:{},xTTEnv:e.xTTEnv}),s=new nt({baseURL:B(e.baseUrl),request:(e,s={})=>t(e,s)}),i=new nt({baseURL:B(e.baseUrl),request:(e,s={})=>t(e,s)});return{getUserClawInfo:(t,s)=>Pt({baseUrl:e.baseUrl,params:{url:"/api/coze_claw/claw/info",method:"POST",data:t},requestOptions:s,responseFallback:{},xTTEnv:e.xTTEnv}),createSession:(e,t)=>s.CreateSession(e,t),listSession:(e,t)=>s.ListSession(e,t),listMessage:(e,t)=>s.ListMessage(e,t),uploadFile:Rt(e),getWebUrl:(e,t)=>i.GetWebUrl(e,t),getUrl:(e,t)=>i.GetUrl(e,t),exportPPT:(e,t)=>i.ExportPPT(e,t),chat:(e,t)=>s.Chat(e,t),listProcess:(e,t)=>s.ListProcess(e,t)}},Ut=e=>{const t=At({baseUrl:e.sessionApiBaseUrl||e.apiBaseUrl,webOrigin:e.sessionApiBaseUrl||e.apiBaseUrl,xSpaceWebId:e.sessionSpaceWebId,xTTEnv:e.xTTEnv});return{getUserClawInfo:(e,s)=>t.getUserClawInfo(e,s),createSession:(e,s)=>t.createSession(e,s),listSession:(e,s)=>t.listSession(e,s),listMessage:(e,s)=>t.listMessage(e,s),uploadFile:(e,s)=>t.uploadFile(e,s),getWebUrl:(e,s)=>t.getWebUrl(e,s),getUrl:(e,s)=>t.getUrl(e,s),exportPPT:(e,s)=>t.exportPPT(e,s),chat:(e,s)=>t.chat(e,s),listProcess:(e,s)=>t.listProcess(e,s)}},It=()=>({async get(){const e=await O();return{sessionId:e.sessionId,sessionClawId:e.sessionClawId}},async save(e){await v(e)}});function Lt(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}return s}const Ct=[".report.html",".podcast.html",".webdoc.html",".socmed.html",".pptx.html",".poster.html",".resume.html",".chart.html"],Ot=({file:e,fileIndex:t,clawId:s,webOrigin:i})=>{const a=e.file_uri;if(!a||!s)return;const r=new URL(i).origin;const n=e.file_name||a.split("/").pop()||"";return(e=>e.endsWith(".html")&&!Ct.some((t=>e.endsWith(t))))(n||a)?`${r}/web?is_shared=1&uri=${encodeURIComponent(a)}&is_claw=1`:`${r}/share-product/${s}?index=${t}&uri=${encodeURIComponent(a)}&filename=${encodeURIComponent(n)}&only_content=1&is_claw=1`},vt=async({files:e,clawId:t,webOrigin:s,api:i})=>e&&0!==e.length?await Promise.all(e.map((async(e,a)=>{const r=Ot({file:e,fileIndex:a,clawId:t,webOrigin:s});return{...e,preview_url:await x({url:r,api:i})}}))):[],yt=async({files:e,clawId:t,apiBaseUrl:s,sessionApiBaseUrl:i,xTTEnv:a,service:r,deps:n})=>{if(!e||0===e.length)return e;const o=Lt([n,"optionalAccess",e=>e.store])||It(),{sessionClawId:c}=await o.get(),l=t||c||(await r.getStatus()).clawId,d=(Lt([n,"optionalAccess",e=>e.createApi])||At)({baseUrl:i||s,xTTEnv:a}),_=Lt([n,"optionalAccess",e=>e.resolveFiles])||vt;return await _({files:e,clawId:l,webOrigin:i||s,api:{getWebUrl:e=>d.getWebUrl(e)}})},Bt=e=>"running"!==e,bt=e=>{if(e&&0!==e.length)return e.map((e=>({fileName:e.file_name,fileUrl:e.file_url,previewUrl:e.preview_url,fileUri:e.file_uri})))};const zt=l.join(p(),"tasks","session-progress-tasks.json");class qt extends Error{constructor(e){super(e),this.name="SessionTaskStoreError"}}class Dt extends Error{constructor(e){super(`Session task expired: ${e}`),this.taskId=e,this.name="SessionTaskExpiredError"}}class Nt extends Error{constructor(e){super(`Session task not found: ${e}`),this.taskId=e,this.name="SessionTaskNotFoundError"}}const kt=(e,t)=>Object.entries(t).reduce(((e,[t,s])=>void 0===s?e:{...e,[t]:s}),{...e}),Gt=e=>{const t=a.safeJsonParse(e,void 0);if(void 0===t)throw new qt("Failed to parse session task store");if(s=t,!Boolean(s)||"object"!=typeof s||Array.isArray(s)||!Array.isArray(t.items))throw new qt("Failed to parse session task store");var s;return{version:1,items:t.items}},Ft=({filePath:e=zt,now:t=Date.now,retentionMs:s=6048e5,writeDocument:i=async(e,t)=>{await(async({content:e,filePath:t})=>{await n.mkdir(r.dirname(t),{recursive:!0});const s=`${t}.tmp.${Date.now()}.${process.pid}`,i=await n.open(s,"w");try{await i.writeFile(e,"utf8"),await i.sync()}finally{await i.close()}try{await n.rename(s,t)}catch(e){throw await n.rm(s,{force:!0}).catch((()=>{})),e}})({content:t,filePath:e})}}={})=>{const a=(e=>async()=>{try{const t=await n.readFile(e,"utf8");return Gt(t)}catch(e){if("ENOENT"===function(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}return s}([e,"optionalAccess",e=>e.code]))return{version:1,items:[]};if(e instanceof qt)throw e;throw new qt(`Failed to read session task store: ${String(e)}`)}})(e),o=(({filePath:e,writeDocument:t})=>async s=>{await t(e,JSON.stringify(s,null,2))})({filePath:e,writeDocument:i}),c=e=>{if(!Bt(e.status))return!1;const i=(a=e.finishedAt,r=()=>e.updatedAt,null!=a?a:r());var a,r;return t()-i>s},l=(({isExpired:e,readDocument:t})=>async({includeExpired:s,taskId:i})=>{const a=(await t()).items.find((e=>e.taskId===i));if(!a)throw new Nt(i);if(!s&&e(a))throw new Dt(i);return a})({isExpired:c,readDocument:a});return{list:async(e={})=>(await a()).items.filter((t=>!(!e.includeExpired&&c(t))&&((!e.sessionId||t.sessionId===e.sessionId)&&(!e.status||t.status===e.status)))).sort(((e,t)=>t.updatedAt-e.updatedAt)),get:async(e,t={})=>await l({includeExpired:t.includeExpired,taskId:e}),async upsert(e){const t=await a(),s=t.items.findIndex((t=>t.taskId===e.taskId));if(s>=0){const[i]=t.items.slice(s,s+1),a=kt(i,e);t.items.splice(s,1,a)}else t.items.push(e);return await o(t),await l({includeExpired:!0,taskId:e.taskId})},async patch(e,t){const s=await a(),i=s.items.findIndex((t=>t.taskId===e));if(i<0)throw new Nt(e);const[r]=s.items.slice(i,i+1),n=kt(r,t);return s.items.splice(i,1,n),await o(s),await l({includeExpired:!0,taskId:e})},async remove(e){const t=await a();t.items=t.items.filter((t=>t.taskId!==e)),await o(t)},async gc(){const e=await a(),t=e.items.filter(c);return e.items=e.items.filter((e=>!c(e))),await o(e),t},isExpired:c}},jt=({api:e,store:t,authConfigured:s=()=>!0,fallbackAccountId:i})=>{const a=(({now:e=Date.now,workingTtlMs:t=3e4}={})=>{const s=new Map;return{clear(){s.clear()},getLive(i){const a=s.get(i);if(a){if(!(e()-a.updatedAt>t))return a;s.delete(i)}},markIdle(e){s.delete(e)},markWorking(t){s.set(t,{status:"working",updatedAt:e()})}}})(),r=(e=>async({sessionId:t,status:s})=>{"idle"!==s?e.markWorking(t):e.markIdle(t)})(a),n=(({api:e,authConfigured:t,fallbackAccountId:s,store:i})=>async()=>{const a=s;if(!t())return H({accountId:a,authConfigured:!1});try{const t=a?{account_id:a}:{},s=function(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}return s}([await e.getUserClawInfo(t),"access",e=>e.data,"optionalAccess",e=>e.user_claw_info,"optionalAccess",e=>e.claw_id]);return s?(await i.save({sessionClawId:s}),{authConfigured:!0,authValid:!0,clawId:s,accountId:a,updatedAt:void 0}):H({accountId:a,authConfigured:!0})}catch(e){return H({accountId:a,authConfigured:!0})}})({api:e,authConfigured:s,fallbackAccountId:i,store:t}),o=(({createAuthInvalidError:e,getStatus:t,getStoredConfig:s})=>async()=>{const i=await s();if(i.sessionClawId)return i.sessionClawId;const a=await t();if(!a.authValid||!a.clawId)throw e();return a.clawId})({createAuthInvalidError:J,getStatus:n,getStoredConfig:async()=>t.get()}),c=V({api:e,resolveClawId:o}),{listMessages:l,listRepliesByMessage:d}=(({api:e,createListError:t})=>{const s=async({sessionId:s,cursor:i,size:a=10,ascMode:r})=>{const n=await e.listMessage({session_id:s,cursor:i,size:a,asc_mode:r});if(0!==n.code&&void 0!==n.code)throw t(n.msg||"Failed to list session messages");const o=(Et([n,"access",e=>e.data,"optionalAccess",e=>e.messages])||[]).map((e=>wt(e))).filter((e=>null!==e)),c=Et([n,"access",e=>e.data,"optionalAccess",e=>e.next_cursor]);return{items:o,nextCursor:c,hasMore:Boolean(c)}};return{listMessages:s,listRepliesByMessage:async({sessionId:e,messageId:t,size:i=10,maxPages:a=100})=>{let r,n=!1;const o=[];for(let c=0;c<a;c+=1){const a=await s({sessionId:e,cursor:r,size:i});if(a.items.forEach((e=>{e.messageId===t&&(n=!0),e.replyToMessageId===t&&o.push(e)})),n||!a.hasMore||!a.nextCursor)break;r=a.nextCursor}return{sessionId:e,requestMessageId:t,requestMessageFound:n,items:o.reverse()}}}})({api:e,createListError:e=>new Z(e,"SESSION_MESSAGE_LIST_FAILED")});return{getStatus:n,createSession:X({api:e,resolveClawId:o}),listSessions:Q({api:e,resolveClawId:o}),listMessages:l,listRepliesByMessage:d,sendMessage:ee({api:e,updateSessionRuntimeStatus:r}),listProgresses:c,getProgress:$(c),getSessionDisplayStatus:Y({listProgresses:c,runtimeStatusStore:a}),resolveFileUrl:ft({api:e}),exportPpt:gt({api:e}),shortenWebUrl:M({api:e}),updateSessionRuntimeStatus:r}},xt=e=>{const t=It();return jt({api:Ut(e),store:t,authConfigured:()=>Boolean(e.accessToken),fallbackAccountId:e.organizationId})};function Mt(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r(((...e)=>s.call(t,...e))),t=void 0)}return s}const Ht=e=>{if(!e)return;const t=(e=>e.replace(/\s+/g," ").trim())(e);return t?t.length>120?`${t.slice(0,117)}...`:t:void 0},Wt=e=>{if(!e)return;const t=e.trim();return t?t.length>200?`${t.slice(0,197)}...`:t:void 0},Vt=({apiBaseUrl:e,now:t=Date.now,resolveReplyFiles:s,service:i,sessionApiBaseUrl:a,store:r=Ft(),xTTEnv:n})=>({async createOrUpdateTaskFromMessageWait({answerMessageId:e,content:s,files:i,messageId:a,progress:n,sessionId:o}){const c=t(),l=s,d=Ht(l),_="running"!==n.progressStatus,u=_?Wt(l):void 0;return await r.upsert({taskId:(p=n.progressId,`stp_${p}`),kind:"session_progress",sessionId:o,messageId:a,progressId:n.progressId,status:_?"finished":"running",contentPreview:d,answerMessageId:e,replyContent:l,resultSummary:u,artifacts:bt(i),lastProgressStatus:n.progressStatus,createdAt:c,updatedAt:c,finishedAt:_?c:void 0});var p},getTask:async(e,t)=>await r.get(e,t),patchTask:async(e,t)=>await r.patch(e,t),listTasks:async e=>await r.list(e),async refreshTask(o,c){const l=await r.get(o,c);if(Bt(l.status))return l;try{const c=await i.getProgress({progressId:l.progressId}),d=t();if(c)return await r.patch(o,{contentPreview:Ht(l.replyContent),lastProgressStatus:c.progressStatus,lastRefreshError:void 0,resultSummary:void 0,status:"running"===c.progressStatus?"running":"finished",updatedAt:d});const _=await(async({apiBaseUrl:e,resolveReplyFiles:t=yt,service:s,sessionApiBaseUrl:i,task:a,xTTEnv:r})=>{const n=await s.listRepliesByMessage({sessionId:a.sessionId,messageId:a.messageId}),o=n.items[n.items.length-1];if(!o)return null;const c=o.files&&o.files.length>0?await t({files:o.files,apiBaseUrl:e,sessionApiBaseUrl:i,service:s,xTTEnv:r}):o.files;return{answerMessageId:o.messageId,files:c,replyContent:o.content,resultSummary:Wt(o.content)}})({apiBaseUrl:e,resolveReplyFiles:s,service:i,sessionApiBaseUrl:a,task:l,xTTEnv:n});return await r.patch(o,{answerMessageId:Mt([_,"optionalAccess",e=>e.answerMessageId]),artifacts:Mt([_,"optionalAccess",e=>e.files])?bt(_.files):void 0,contentPreview:Ht(Mt([_,"optionalAccess",e=>e.replyContent])),finishedAt:d,lastProgressStatus:"finished",lastRefreshError:void 0,replyContent:Mt([_,"optionalAccess",e=>e.replyContent]),resultSummary:Mt([_,"optionalAccess",e=>e.resultSummary]),status:"finished",updatedAt:d})}catch(e){return await r.patch(o,{lastRefreshError:e instanceof Error?e.message:String(e),updatedAt:t()})}},gcTasks:async()=>await r.gc()});function $t(e,t){return null!=e?e:t()}const Yt=({elapsedMs:e})=>e>=3e5?3e4:1e4;exports.Claw=ot,exports.DEFAULT_CONFIG=T,exports.SessionServiceError=Z,exports.SessionTaskExpiredError=Dt,exports.SessionTaskNotFoundError=Nt,exports.SessionTaskStoreError=qt,exports.appendSearchParams=b,exports.buildPatchByPath=function(e,t){const s=e.split("."),i={};let a=i;return s.forEach(((e,i)=>{if(i===s.length-1)a[e]=t;else{const t={};a[e]=t,a=t}})),i},exports.buildSessionPptSlideUrl=({origin:e,fileUri:t,taskId:s,baseHeight:i=720,baseWidth:a=1280})=>{const r=s||(e=>e.split("/").filter(Boolean)[0])(t);if(!r)throw new Z("Missing PPT task id for share URL","SESSION_PPT_SHARE_FAILED");const n=new URL(`/slide/${encodeURIComponent(r)}`,(e=>e.endsWith("/")?e.slice(0,-1):e)(e));return n.searchParams.set("uri",t),n.searchParams.set("baseHeight",String(i)),n.searchParams.set("baseWidth",String(a)),n.searchParams.set("is_claw","1"),n.toString()},exports.createDefaultSessionService=xt,exports.createSessionApiClient=At,exports.createSessionConfigStore=It,exports.createSessionTaskService=Vt,exports.createSessionUploadFile=Rt,exports.deleteConfig=async function(e){const t=process.env.COZE_CONFIG_FILE;if(t){const s=await I(t);if(s&&void 0!==R(s,e)){A(s,e);try{await d.writeFile(t,JSON.stringify(s,null,2),"utf8")}catch(e){throw new Error(`Failed to delete config from ${t}: ${e}`)}return}}let s=f,i=await I(s);if(i&&void 0!==R(i,e)||(s=E,i=await L()),i&&void 0!==R(i,e)){A(i,e);try{await d.writeFile(s,JSON.stringify(i,null,2),"utf8")}catch(e){throw new Error(`Failed to delete config from ${s}: ${e}`)}}},exports.fetchSessionPptContent=async({url:e,fetchImpl:t=e=>a.customFetch.fetch(e),maxBytes:s=10485760})=>{const i=await t(e);if(!i.ok)throw new Z(`Failed to fetch PPT content: ${i.status} ${i.statusText}`,"SESSION_PPT_FETCH_FAILED");const r=i.headers.get("content-length");if(r){const e=Number.parseInt(r,10);if(Number.isFinite(e)&&e>s)throw new Z(`PPT content is too large: ${e} bytes exceeds ${s} bytes`,"SESSION_PPT_FETCH_FAILED")}const n=await i.text(),o=Buffer.byteLength(n,"utf8");if(o>s)throw new Z(`PPT content is too large: ${o} bytes exceeds ${s} bytes`,"SESSION_PPT_FETCH_FAILED");return n},exports.formatServiceErrorWithLogId=({fallback:e,logId:t,message:s})=>{const i=s||e;return t?`${i}\n LogID: ${t}`:i},exports.formatSessionPptEditQuery=({pages:e,query:t})=>{const s=[...new Set(e)].sort(((e,t)=>e-t));return 1===s.length?`对第${s[0]}页进行变更:<${t}>`:`对第${s.join("、")}页进行变更:<${t}>`},exports.getCozeAccountHeaders=k,exports.getGlobalCompletionFile=()=>l.join(p(),"completion.sh"),exports.getGlobalConfigDir=p,exports.getGlobalLogsDir=()=>l.join(p(),"logs"),exports.getGlobalSkillLockFile=()=>l.join(p(),".skill-lock.json"),exports.getLegacyGlobalConfigDir=h,exports.getPpeHeaders=N,exports.getServiceResponseLogId=D,exports.installScopedCozeAccountFetchHeader=j,exports.isInternalConfigPath=g,exports.isSessionTaskTerminal=Bt,exports.listConfigs=async function(){const e=process.env.COZE_CONFIG_FILE,[t,s,i]=await Promise.all([L(),I(f),e?I(e):void 0]),a=[{name:"env",flat:U(C())},{name:"env-file",flat:U(i)},{name:"local",flat:U(s)},{name:"global",flat:U(t)},{name:"default",flat:U(T)}],r=new Set;for(const{flat:e}of a)Object.keys(e).forEach((e=>r.add(e)));const n=[];for(const e of Array.from(r)){if(g(e))continue;let t,s="default";for(const{name:i,flat:r}of a)if(e in r&&void 0!==r[e]){t="env"===i?r[e]:String(r[e]),s=i;break}n.push({key:e,value:t,source:s})}return n},exports.loadConfig=O,exports.normalizeBaseUrl=B,exports.parseServiceResponseBody=z,exports.parseSessionPptContent=e=>{const t=e.trim(),s=(e=>{const t=a.safeJsonParse(e,null),s=Array.isArray(ct([t,"optionalAccess",e=>e.pages]))?t.pages:Array.isArray(ct([t,"optionalAccess",e=>e.data,"optionalAccess",e=>e.pages]))?t.data.pages:null;return s?{type:"json",pageCount:s.length,pages:s.map(((e,t)=>{const s=[];mt(e,s);const i=((e,t)=>{if(!e||"object"!=typeof e)return;const s=e;for(const e of t){const t=s[e];if("string"==typeof t&&t.trim())return t}})(e,["image_url","export_image_url","preview_url","thumbnail_url"]);return{page:t+1,title:s[0]||`第${t+1}页`,previewUrl:i,previewText:_t(s.join(" "))||(i?`preview_url: ${i}`:"")}}))}:null})(t);return s||(/<html[\s>]/i.test(t)||t.includes("\x3c!--SPLIT_HTML--\x3e")?ht(t):{type:"unknown",pageCount:0,pages:[]})},exports.resolveStoredSessionReplyFiles=yt,exports.runSessionTaskRefreshWorkerCli=async()=>{const t=e.argv[2];if(!t)throw new Error("No payload provided");const s=a.safeJsonParse(t,void 0);if(!s)throw new Error("Invalid payload");await(async({now:e=Date.now,payload:t,sleep:s=async e=>await new Promise((t=>setTimeout(t,e))),taskService:r=Vt({apiBaseUrl:t.apiBaseUrl,service:xt({accessToken:t.accessToken,apiBaseUrl:t.apiBaseUrl,organizationId:t.organizationId,sessionApiBaseUrl:$t(t.sessionApiBaseUrl,(()=>"")),xTTEnv:t.xTTEnv}),sessionApiBaseUrl:t.sessionApiBaseUrl,store:Ft(),xTTEnv:t.xTTEnv})})=>{const n=new i.EnvHttpProxyAgent;a.customFetch.setDispatcher(n),a.customFetch.setHeaders({Authorization:`Bearer ${t.accessToken}`}),j({organizationId:t.organizationId}),t.xTTEnv&&a.customFetch.setHeaders({"x-use-ppe":"1","x-tt-env":t.xTTEnv});const o=e();let c=3e3;try{for(;;){await s(c);const i=await r.refreshTask(t.taskId,{includeExpired:!0});if(Bt(i.status))return;c=Yt({elapsedMs:e()-o})}}finally{await r.patchTask(t.taskId,{workerPid:void 0})}})({payload:s})},exports.saveConfig=v,exports.shouldInjectCozeAccountHeader=G,exports.startDetachedSessionTaskRefreshWorker=async({payload:i,spawnImpl:a=s.spawn})=>{const r=a(e.execPath,[t.resolve(__dirname,"./session-task-refresh.worker.js"),JSON.stringify(i)],{detached:!0,stdio:"ignore"});return r.unref(),r.pid};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coze/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3-alpha.471664",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Coze CLI - A command-line interface for Coze platform",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,12 +40,11 @@
|
|
|
40
40
|
"chalk": "^4.1.2",
|
|
41
41
|
"commander": "~12.1.0",
|
|
42
42
|
"form-data": "^4.0.5",
|
|
43
|
-
"http-proxy-agent": "^7.0.2",
|
|
44
|
-
"https-proxy-agent": "^7.0.6",
|
|
45
43
|
"lodash": "^4.18.1",
|
|
46
44
|
"mitt": "~3.0.1",
|
|
47
45
|
"omelette": "~0.4.17",
|
|
48
46
|
"openapi-typescript": "~7.4.0",
|
|
47
|
+
"proxy-agent": "^8.0.2",
|
|
49
48
|
"skills": "latest",
|
|
50
49
|
"swagger2openapi": "^7.0.8",
|
|
51
50
|
"undici": "~7.24.5",
|
|
@@ -67,22 +66,22 @@
|
|
|
67
66
|
"@coze-chat/chat-input": "workspace:*",
|
|
68
67
|
"@coze-coding/env": "workspace:*",
|
|
69
68
|
"@coze-coding/lambda": "workspace:*",
|
|
70
|
-
"@emnapi/runtime": "^1.
|
|
69
|
+
"@emnapi/runtime": "^1.11.1",
|
|
71
70
|
"@rollup/plugin-commonjs": "^28.0.2",
|
|
72
71
|
"@rollup/plugin-json": "~6.0.0",
|
|
73
72
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
74
73
|
"@rollup/plugin-replace": "^6.0.2",
|
|
75
|
-
"@rollup/plugin-sucrase": "^5.0
|
|
74
|
+
"@rollup/plugin-sucrase": "^5.1.0",
|
|
76
75
|
"@rollup/plugin-terser": "^0.4.4",
|
|
77
76
|
"@types/lodash": "^4.17.24",
|
|
78
77
|
"@types/node": "^24",
|
|
79
78
|
"@types/swagger2openapi": "^7.0.4",
|
|
80
|
-
"@vitest/coverage-v8": "~4.1.
|
|
79
|
+
"@vitest/coverage-v8": "~4.1.9",
|
|
81
80
|
"knip": "^5.30.1",
|
|
82
81
|
"rollup": "^4.60.1",
|
|
83
82
|
"sucrase": "^3.35.1",
|
|
84
|
-
"tsx": "^4.22.
|
|
85
|
-
"vitest": "~4.1.
|
|
83
|
+
"tsx": "^4.22.4",
|
|
84
|
+
"vitest": "~4.1.9"
|
|
86
85
|
},
|
|
87
86
|
"publishConfig": {
|
|
88
87
|
"access": "public",
|
package/skills/manifest.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
"cliVersion": "0.3.
|
|
2
|
+
"cliVersion": "0.3.3-alpha.471664",
|
|
3
3
|
"skills": {
|
|
4
4
|
"using-coze-cli": {
|
|
5
5
|
"path": "using-coze-cli/SKILL.md",
|
|
6
|
-
"hash": "sha256:
|
|
6
|
+
"hash": "sha256:450e9e042238382c582668d75802f0ad14ae410adce509a1ff86657e0be167ce"
|
|
7
7
|
},
|
|
8
8
|
"coze-claw": {
|
|
9
9
|
"path": "using-coze-cli/coze-claw/MODULE.md",
|
|
10
|
-
"hash": "sha256:
|
|
10
|
+
"hash": "sha256:9adae3e4622410a4d05359d46f09892b8b6f469ab5d9fffd5002cb841a1e63b6"
|
|
11
11
|
},
|
|
12
12
|
"coze-code": {
|
|
13
13
|
"path": "using-coze-cli/coze-code/MODULE.md",
|
|
14
|
-
"hash": "sha256:
|
|
14
|
+
"hash": "sha256:0e79678547665d774a3ec3d1f9a3595aea04d7c5475c4f12e238cd925d77137d"
|
|
15
15
|
},
|
|
16
16
|
"coze-file": {
|
|
17
17
|
"path": "using-coze-cli/coze-file/MODULE.md",
|
|
18
|
-
"hash": "sha256:
|
|
18
|
+
"hash": "sha256:4eb72a401c1c5429e770208cf0cfac35db28a57334ce857fb4eda9bfb92d76f4"
|
|
19
19
|
},
|
|
20
20
|
"coze-generate": {
|
|
21
21
|
"path": "using-coze-cli/coze-generate/MODULE.md",
|
|
22
|
-
"hash": "sha256:
|
|
22
|
+
"hash": "sha256:2e84d972843af1556b8007114189a174915d37f1529d59ede7eedd502294f348"
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: using-coze-cli
|
|
3
|
-
version: 0.3.
|
|
4
|
-
description: "
|
|
3
|
+
version: 0.3.3-alpha.471664
|
|
4
|
+
description: "【核心触发·软件开发】当用户意图是开发、修改、调试、运行或迭代软件产品时,加载本技能并通过 coze code 调起;典型场景:创建或迭代网页、Web App、App、小程序等可运行、可维护、可迭代的工程项目。判定边界:仅当用户明确想做可维护、可迭代的产品/工程项目时才导流到扣子编程;不要因请求中出现 CLI、文件读写、HTML、可视化、卡片、报告、图片等词就导流。其它子模块(满足任一即触发,无需显式点名 coze):coze code 还覆盖 Agent/工作流/skill 及发需求、预览、部署、环境变量/域名/数据库;coze generate—文生图/语音 TTS/视频;coze session(Claw)—对话、PPT、播客、长任务产物;coze file—本地文件转在线链接;输入以 /coze-cli、/coze 开头(仅作路由)。"
|
|
5
5
|
metadata:
|
|
6
6
|
requires:
|
|
7
7
|
bins: ["coze"]
|
|
@@ -105,6 +105,17 @@ metadata:
|
|
|
105
105
|
- `/coze-cli @PPT 制作介绍海南美食的 PPT` -> `@PPT 制作介绍海南美食的 PPT`
|
|
106
106
|
- 禁止把 `/coze-cli`、`/coze` 原样拼进最终发送给 Claw 的 message。
|
|
107
107
|
|
|
108
|
+
### 7. 长任务不得阻塞回合(通用总纲)
|
|
109
|
+
|
|
110
|
+
- Coze CLI 的多数核心动作是**异步长任务**:`coze code` 的项目创建 / `message send`(分钟级到几十分钟级)、`coze session message` 命中 `progress_id` / `task_id` 的长任务、部署等。**严禁**为了"等到终态"而让单次命令或单个回合一直前台阻塞——这会撞穿宿主工具超时(通常约 10 分钟),表现为 agent"卡住,除非任务完成"。
|
|
111
|
+
- 通用做法:**先 ACK 再跟进**。当前回合先把已有的中间结果(项目链接 / 前置 reply / 已接单说明)回给用户并收尾,再用**非阻塞**方式跟进终态。跟进机制按以下优先级选:
|
|
112
|
+
1. **优先:子 session 后台任务(subagent / 独立子会话)**——先探测当前 agent 是否支持起一个独立的子 session / subagent 在后台运行。支持就用它:让子会话去轮询直到终态,再把最终结果回报到原上下文。这类机制能真正"自行跑完并回唤交付",是非阻塞的首选。
|
|
113
|
+
2. 次选:宿主其它后台 / 定时能力(cron、delayed job 等)登记独立 follow-up,任务结束再回填。
|
|
114
|
+
3. 兜底:以上都不支持时,逐回合短轮询(每回合查一次、让出回合),**不要**把整段轮询 `sleep` 在一次调用里。
|
|
115
|
+
- **终态必须回传**:无论用哪种机制,跟进到终态后都必须主动把最终结果回给用户——只 ACK 不回终态等于任务丢了。
|
|
116
|
+
- **创建结果必须说实话(先动作、后文案)**:只有**真正调用创建工具并拿到回执**(子 session 的真实 `session_id` / 后台任务句柄)才可说"完成后自动回你",且 ACK 要带上该回执 ID;没拿到回执就如实告知并给下一步选项,禁止凭"打算派 / 理论上能派"就声称"已在后台盯着"。
|
|
117
|
+
- 各模块的具体规范:`coze code` 见 [`coze-code/MODULE.md`](coze-code/MODULE.md) 的「阻塞与超时铁律」「长任务 follow-up」;`coze session` 见 [`coze-claw/references/coze-claw-async-followup.md`](coze-claw/references/coze-claw-async-followup.md)。
|
|
118
|
+
|
|
108
119
|
## 安装 CLI
|
|
109
120
|
|
|
110
121
|
```bash
|
|
@@ -257,7 +268,7 @@ coze auth status
|
|
|
257
268
|
|
|
258
269
|
```bash
|
|
259
270
|
# 示例:项目创建 + 轮询(默认非阻塞)
|
|
260
|
-
coze code project create --type web --message "需求描述"
|
|
271
|
+
coze code project create --type web --message "需求描述" --create-source agent_cli
|
|
261
272
|
# 命令立即返回 project_id,然后轮询消息状态
|
|
262
273
|
for i in $(seq 1 60); do
|
|
263
274
|
result=$(coze code message status -p <project_id> --format json)
|
|
@@ -334,6 +345,7 @@ fi
|
|
|
334
345
|
- 指定不存在的组织 ID 会**报错且不修改配置**。
|
|
335
346
|
- 切换到个人账户有三种等价写法:`coze organization use`(省略 org_id)、`coze organization use ""`(显式空串)、`coze organization unset`(别名 `coze organization reset`)。均会清空 `organizationId`/`enterpriseId`(及 `spaceId`),且**不再校验个人账户是否可用**。
|
|
336
347
|
- CLI 的自动上下文补全**仅作用于空间**:未配置空间时,首次执行需要上下文的命令会自动选择第一个可用空间(结果可能不是期望的,建议始终显式设置)。**组织不会自动选择**——未显式设置组织时按上文的个人账户模式处理。
|
|
348
|
+
- 安装了 `default-space` 插件后,未显式传 `--space-id` 时会改为取**服务端为当前组织配置的默认工作空间**(而非"第一个可用空间")。优先级:`--space-id` > 服务端默认空间 > 已存 `spaceId` 配置 > 第一个可用空间。详见"插件(Plugins)"章节。
|
|
337
349
|
|
|
338
350
|
### 遇到 `No permission` 的修正顺序
|
|
339
351
|
|
|
@@ -359,6 +371,27 @@ fi
|
|
|
359
371
|
|
|
360
372
|
详细用法参见各业务模块 reference 文档中的配置相关章节。
|
|
361
373
|
|
|
374
|
+
## 插件(Plugins)
|
|
375
|
+
|
|
376
|
+
插件是**可选启用**的功能开关:只有安装后对应功能才生效,未安装时 CLI 行为与之前完全一致。"安装"只是把开关写进本地配置(`plugins.<id>.enabled`),不调用网络,故 `coze plugin *` 命令**免登录、跳过 org/space 检查**。
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
coze plugin list # 列出全部插件及安装状态
|
|
380
|
+
coze plugin install default-space # 安装(启用)插件
|
|
381
|
+
coze plugin uninstall default-space # 卸载(禁用)插件
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
- 传入未知插件 id 会报 `E1000`(`INVALID_ARGUMENT`),并提示可用插件清单。
|
|
385
|
+
- Agent 场景同样建议加 `--format json` 解析结果(`list` 返回 `{ id, name, description, installed }` 数组)。
|
|
386
|
+
|
|
387
|
+
### 内置插件:`default-space`
|
|
388
|
+
|
|
389
|
+
启用后,未显式传 `--space-id` 时,CLI 会取**服务端为当前组织配置的默认工作空间**,替代默认的"自动选第一个可用空间"。
|
|
390
|
+
|
|
391
|
+
- 优先级:`--space-id` > 服务端默认空间 > 已存 `spaceId` 配置 > 第一个可用空间。
|
|
392
|
+
- 默认工作空间是**组织维度**概念:个人账户(无组织上下文)下该插件不生效,回退到原有逻辑。
|
|
393
|
+
- 解析失败(无默认空间 / 接口异常)会静默回退,不会阻断主命令。
|
|
394
|
+
|
|
362
395
|
## 安全规则
|
|
363
396
|
|
|
364
397
|
- **禁止输出密钥**(token、API Key 等)到终端明文。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: coze-code
|
|
3
|
-
version: 0.3.
|
|
3
|
+
version: 0.3.3-alpha.471664
|
|
4
4
|
description: "Coze Coding 项目开发工作流:创建项目、发送需求消息、查询状态、预览、部署、环境变量管理、域名管理、技能管理、数据库管理。当用户需要创建/管理 Coze 项目、发送开发需求、部署应用、管理数据库、或使用 coze code * 任意命令时触发。"
|
|
5
5
|
metadata:
|
|
6
6
|
requires:
|
|
@@ -63,10 +63,11 @@ coze code message send "对比 @src/old.ts 和 @src/new.ts 的差异" -p <projec
|
|
|
63
63
|
详细参数和示例参见 [`coze-code-project.md`](references/coze-code-project.md)。
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
|
-
coze code project create --message "创建一个聊天机器人" --type web --format json
|
|
66
|
+
coze code project create --message "创建一个聊天机器人" --type web --create-source agent_cli --format json
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
- `--message` 和 `--type` 均为**必填参数**(`--message` 无 `-m` 短别名)。
|
|
70
|
+
- **必须带 `--create-source`**:按自身身份如实取值——身份含 `扣子`/`Coze`/`coze` 传 `coze_agent_cli`,其它 agent(如 `Claude Code` / `Cursor`)传 `agent_cli`,不传则记为人工 `cli`。**不要伪报**。(Coze Claw 环境下 CLI 会据 `COZE_CLAW_AGENT_ID` 自动判为 `coze_agent_cli`。)
|
|
70
71
|
- **`--type` 接受**:`agent | workflow | app | skill | web | miniprogram | assistant`(源码 `resolveProjectType` 还兼容 `webapp`)。其中 `web` / `app` 是最常用类型;`assistant` 走模板复制创建。传入未知类型会报 `E1005`。
|
|
71
72
|
- 其它可选项:`--chat-mode <ask|agent|dangerous_confirm|plan>`、`--model-name`、`--tool-name`(可多次传)、`--design`(`--chat-mode plan` 时自动开启)。
|
|
72
73
|
- `--wait` 选项会等待项目创建完成(包括首次 AI 消息响应)后再返回。
|
|
@@ -121,26 +122,39 @@ coze code project create --message "创建一个聊天机器人" --type web --fo
|
|
|
121
122
|
- 可继续发送需求迭代,或稍候查看开发结果。
|
|
122
123
|
```
|
|
123
124
|
|
|
124
|
-
#### Step 1.4:
|
|
125
|
+
#### Step 1.4: 开发任务的跟进方式(非阻塞,禁止把回合钉死)
|
|
125
126
|
|
|
126
|
-
|
|
127
|
-
- **首选**:创建后**主动轮询** `coze code message status -p <project_id> --format json`(`message status` 无 `--wait`,需自行间隔轮询),直到状态为 `done`,**不要**让用户自己去查状态。
|
|
128
|
-
- 备选:创建时加 `--wait` 让 CLI 等到首次 AI 开发完成再返回(仅在确有需要时使用,状态跟进仍以主动轮询为准)。
|
|
127
|
+
> **核心:第一交付物永远是 Step 1.3 的「项目已创建 + `project_url`」,必须先把它回给用户并收尾当前回合。** AI 开发是分钟级到几十分钟级的长任务,**绝不允许**为了"跟进到 done"而让单次命令/单个回合一直前台阻塞——那正是 agent"卡住,除非任务完成"的根因。
|
|
129
128
|
|
|
130
|
-
|
|
129
|
+
创建成功后,**先探测 agent 是否支持「子 session 后台任务」**,再按下面优先级选**非阻塞**的跟进方式(判定与执行细节见下方「长任务 follow-up」一节):
|
|
130
|
+
|
|
131
|
+
- **优先(分支 A):子 session 后台任务(subagent / 独立子会话)**——若 agent 支持起一个独立的子 session / subagent(如 `sessions_spawn` 等创建工具),就**实际调用该工具**派一个子会话,在后台轮询 `message status` 到 `done` 并把开发完成结果回报到原上下文。当前回合只做 ACK,随即收尾回合。**这是首选**:子会话能自行跑完并回唤交付,天然避免"结果石沉大海"。
|
|
132
|
+
- **次选(分支 A'):宿主其它后台 / 定时调度**——agent 不支持子 session,但宿主有 cron / delayed job / 可回调后台进程时,登记一个独立的 follow-up 去轮询 `message status`,任务结束回填结果。
|
|
133
|
+
- **兜底(分支 B):以上都不支持** → 采用**有界短轮询**——每次只调用一次 `message status`、短 sleep、报一次进度,然后**让出回合**,下一回合再查;单次阻塞时长必须封顶在宿主工具超时以下(见下方约束)。若超出有界次数仍未完成,**明确告知当前进度**并给用户选项("我继续帮你查 / 你稍后让我查"),**禁止**继续静默干等。
|
|
134
|
+
|
|
135
|
+
> 🚦 **执行门禁(先动作、后文案,违反即视为谎报)**:在回复里声称"已派子任务 / 已转后台跟进"之前,**必须先真正调用子会话 / 后台创建工具并拿到回执**——分支 A 要拿到子任务真实的 `session_id`,分支 A' 要拿到后台任务句柄 / PID。**没有这个回执,就不准用分支 A / A' 的文案**,只能退到分支 B 如实说"本回合直接帮你查 / 稍后让我查"。**禁止**凭"打算派 / 理论上能派"就先把"已派子任务"写进回复。
|
|
136
|
+
|
|
137
|
+
分支 A 的 ACK 回复模板(`<session_id>` 必须是上一步创建工具**真实返回**的 ID,填不出就不能用本模板):
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
✅ 项目已创建成功,正在为你开发中…
|
|
141
|
+
- 🔗 打开项目:<project_url>
|
|
142
|
+
- 🛰 已派后台子任务持续跟进(任务 ID:<session_id>),开发完成后我会把结果回给你。
|
|
143
|
+
```
|
|
131
144
|
|
|
132
|
-
|
|
145
|
+
无论哪个分支:
|
|
146
|
+
- **终态必须回传**:轮询到 `done` 后,必须主动把"开发完成结果 + answer + `project_url`"回给用户(详见下方「终态收口」);只 ACK 不回终态 = 任务丢了。
|
|
147
|
+
- **禁止**在没有真正创建子 session / 后台任务时,对用户说"我会持续盯着 / 完成后自动回你"(见「长任务 follow-up」分支 B 约束)。
|
|
148
|
+
- `message status` 无 `--wait`,需自行间隔轮询;`--wait` 仅在确认宿主能容忍长阻塞、且任务预期短于工具超时时才用,状态跟进仍以非阻塞轮询为准。
|
|
133
149
|
|
|
134
|
-
|
|
135
|
-
- **非 `web` 类型**(`app` / `miniprogram` / `agent` / `workflow` / `skill` / `assistant`)一律**省略「预览效果」整行**,不展示预览地址。
|
|
150
|
+
待状态为 `done` 后,向用户给出后续操作引导(**不要**自动执行部署):
|
|
136
151
|
|
|
137
|
-
引导文案(`<project_url>`
|
|
152
|
+
引导文案(`<project_url>` 取自返回值):
|
|
138
153
|
|
|
139
154
|
```
|
|
140
155
|
✅ 开发任务已完成,未自动部署,你可以继续选择:
|
|
141
156
|
- 🛠 继续对话修改页面/文案/功能
|
|
142
157
|
- 🔗 打开项目:<project_url>
|
|
143
|
-
- 👀 预览效果:<preview_url> # 仅 web 类型显示此行
|
|
144
158
|
- 🚀 确认后发起部署
|
|
145
159
|
```
|
|
146
160
|
|
|
@@ -211,12 +225,16 @@ coze code preview <project-id>
|
|
|
211
225
|
## Agent 禁止行为
|
|
212
226
|
|
|
213
227
|
- 不要在 `project create` 后**自动部署**——创建只完成项目创建与首次 AI 开发,部署须等用户明确要求
|
|
214
|
-
-
|
|
228
|
+
- 不要为了"跟进到 done"而**前台阻塞回合**——AI 开发是长任务,必须先交付 `project_url` 收尾,再用**非阻塞**方式跟进(优先派子 session / subagent 后台任务,其次宿主后台 follow-up,都不支持才有界短轮询并让出回合,见 Step 1.4 与「长任务 follow-up」);**禁止**单次命令/单个回合一直干等到任务完成
|
|
229
|
+
- 不要**跟进到终态却不回传结果**——非阻塞跟进里轮询到 `done` 后,必须主动把"开发完成结果 + answer + `project_url`"回给用户;只 ACK 不回终态就是"非阻塞后没有返回开发完成结果"(见「终态收口」)
|
|
230
|
+
- 不要**在未实际调用子会话 / 后台创建工具(如 `sessions_spawn`)的情况下声称"已派子任务 / 已转后台跟进"**——这是"先动作、后文案"的执行门禁:声称分支 A / A' 之前必须先拿到真实回执(子任务 `session_id` 或后台句柄 / PID),ACK 回复里要带上该 `session_id`;拿不到回执就只能退到分支 B 如实回复,**凭"打算派 / 理论上能派"就写"已派子任务"= 谎报,严禁**(见 Step 1.4 执行门禁)
|
|
231
|
+
- 不要**没创建后台任务却说"我会持续盯着 / 完成后自动回你"**——没有真正登记 follow-up 时,必须如实告知当前进度并给出下一步选项(见「长任务 follow-up」分支 B)
|
|
215
232
|
- 不要在项目创建成功后**漏掉「打开项目」入口**——回复必须附上返回值里的 `project_url`(不要自行拼接链接)
|
|
216
233
|
- 不要被功能词带偏项目类型——`--type` 由**产品形态词**(小程序 / App / 网页 …)决定,不由功能品类词(抽奖 / 商城 / 聊天 …)决定;尤其"X 小程序"一律 `--type miniprogram`、"App / 应用"一律 `--type app`,**绝不**默认 `web`,无形态词时先反问(见 Step 1.1)
|
|
217
234
|
- 不要在 message 仍为 **processing** 时直接部署
|
|
218
235
|
- 不要对 deploy 使用 **`--project-id`**(它是位置参数!)
|
|
219
236
|
- 不要给 project create 的 **`--type`** 传受支持列表(`agent|workflow|app|skill|web|miniprogram|assistant`)以外的值,否则报 `E1005`
|
|
237
|
+
- 不要在 `project create` 时**漏掉 `--create-source`** 或**伪报来源**——按自身身份如实取值(扣子/Coze 系→`coze_agent_cli`,其它 agent→`agent_cli`),它是来源分类的依据
|
|
220
238
|
- 不要在没有 `--stdin` 时指望管道输入被读取(`message send` 必须显式加 `--stdin` 才读 stdin)
|
|
221
239
|
- 不要忽略 **NDJSON 事件流的逐行解析要求**
|
|
222
240
|
- 不要把本地路径发给用户(必须走 file upload 返回在线链接)
|
|
@@ -232,13 +250,57 @@ coze code preview <project-id>
|
|
|
232
250
|
|
|
233
251
|
> `message status` **没有** `--wait`,需要等待时请自行轮询;`deploy status` 自身不声明 `--wait`,而是读取父命令 `deploy --wait`。
|
|
234
252
|
|
|
235
|
-
|
|
253
|
+
### 阻塞与超时铁律(避免"卡住")
|
|
254
|
+
|
|
255
|
+
AI 开发(首次 `project create`、`message send`)属于**分钟级到几十分钟级**的长任务,部署相对较短。是否用 `--wait` / 怎么轮询,按下面执行,**核心是任何单次工具调用都不能干等到任务完成**:
|
|
256
|
+
|
|
257
|
+
- **单次阻塞命令时长必须封顶在宿主工具超时以下**。多数宿主单次命令调用上限约 **10 分钟(600 秒)**,超过会被强杀、报错或显得卡死。因此:
|
|
258
|
+
- **严禁**把 `for ... sleep 30 ... done`(如 60 次 ×30 秒 = 30 分钟)塞进**一次** Bash 调用——这是"卡住,除非任务完成"的头号原因。
|
|
259
|
+
- `project create --wait` / `message send --wait` 仅在任务**预期短于工具超时**、且宿主能容忍前台阻塞时才用;预期会超时的一律改走下面的非阻塞跟进。
|
|
260
|
+
- `deploy --wait`(间隔 3 秒)通常较短,可直接用。
|
|
261
|
+
- **优先子 session 后台任务**:先探测 agent 是否支持起独立子会话 / subagent;支持就派一个子任务去轮询到终态并回报结果,当前回合立即 ACK 返回。子会话能自行跑完并回唤交付,是消除"丢终态结果"的首选。
|
|
262
|
+
- **次选其它后台执行**:agent 不支持子 session,但宿主支持后台/分离进程(如 `run_in_background`、cron、delayed job)时,把轮询脚本丢后台跑,当前回合立即 ACK,任务结束时由宿主唤起 agent 回填结果。这与 `SKILL.md` 处理 `auth login` 前台阻塞的范式一致。
|
|
263
|
+
- **都不支持则有界短轮询**:每个回合只 `message status` 查一次、短 sleep、报一次进度,然后**让出回合**;不要在一个调用里长 sleep。
|
|
264
|
+
- **善用 NDJSON 增量进度**:`message send --format json` 是事件流,可边解析边把有语义的 `content` 片段回给用户,而不是全程静默憋到 `finish:true`。
|
|
265
|
+
|
|
266
|
+
到达终态后,必须主动把最终结果反馈给用户。
|
|
267
|
+
|
|
268
|
+
## 长任务 follow-up(非阻塞跟进规范)
|
|
269
|
+
|
|
270
|
+
> 与 Claw 的 [`../coze-claw/references/coze-claw-async-followup.md`](../coze-claw/references/coze-claw-async-followup.md) 同源对齐:`coze code` 的首次开发 / `message send` 命中长任务时,**不要依赖"当前这次回合还在"去前台等终态**。
|
|
271
|
+
|
|
272
|
+
### 核心原则
|
|
273
|
+
|
|
274
|
+
0. **优先用子 session 后台任务**:先探测 agent 是否支持起独立子会话 / subagent;支持就优先派子任务去跟进(详见「执行分支」),它能自行跑完并回唤交付,是首选。
|
|
275
|
+
1. **ACK 与 follow-up 分离**:当前回合只负责快速确认(交付 `project_url`、说明已派子任务 / 已转后台或当前进度),终态通知由后续动作负责。
|
|
276
|
+
2. **创建结果必须说实话(先动作、后文案)**:只有**真正调用创建工具并拿到回执**——子 session 的真实 `session_id`、或后台任务的句柄 / PID——才可以说"已转后台跟进 / 完成后自动回你",且 ACK 回复必须带上该回执 ID。没有回执,必须在同一回合明确告知"当前没有创建后台跟进任务"并给出下一步,**禁止**把"准备创建 / 理论上能创建"说成"我已经在后台盯着"。
|
|
277
|
+
3. **恢复主键**:`projectId` 足以恢复一个 coze code 长任务;follow-up 执行时用 `coze code message status -p <project_id> --format json` 反查当前状态与 answer。只有宿主上下文(回复到哪、用户标识等)才值得额外持久化。
|
|
278
|
+
|
|
279
|
+
### 执行分支(先探测子 session 能力,按优先级落地)
|
|
280
|
+
|
|
281
|
+
- **优先 / 分支 A:子 session 后台任务(subagent / 独立子会话)** → 若 agent 支持起独立子会话 / subagent(如 `sessions_spawn`),**先实际调用创建工具并拿到子任务 `session_id`**,再让它去轮询 `message status` 到终态并回报结果,不要把"要不要后台跟进"抛回给用户做选择题。当前回合明确告知:已派子任务跟进(附 `session_id`)、结果会回到原上下文、本条只是 ACK 非最终结果。子会话能自行跑完并回唤交付,是消除"非阻塞后丢终态结果"的首选。**未拿到 `session_id` 前不得声称已派子任务**(见 Step 1.4 执行门禁)。
|
|
282
|
+
- **次选 / 分支 A':宿主其它后台 / 定时调度** → agent 不支持子 session,但宿主有 cron / delayed job / 可回调后台进程时,登记一个轮询 `message status` 的后台任务,终态后回填结果。
|
|
283
|
+
- **兜底 / 分支 B:以上都不支持** → 在同一回合明确告知"当前未创建后台跟进任务(宿主不支持/权限不足)",并立即给出下一步:要么本回合起做**有界短轮询**(查到终态再回复,单次不超工具超时),要么提示用户稍后让你继续查。**禁止**在没真正创建任务时说"完成后自动回你"。
|
|
284
|
+
|
|
285
|
+
### 轮询与重试建议
|
|
286
|
+
|
|
287
|
+
- 默认:间隔 30 秒,最多 ~60 次(约 30 分钟封顶);能复用宿主 cron / delayed job / workflow 的就复用,不要自建一套平行状态机。
|
|
288
|
+
- 更长任务可退化为:前 10 分钟每 30 秒,之后每 120 秒。
|
|
289
|
+
- **无论间隔多大,单次工具调用都不能把整段轮询 sleep 在一个调用里**——要么后台、要么逐回合短轮询。
|
|
290
|
+
|
|
291
|
+
### 终态收口(必做,缺这一步等于任务没完成)
|
|
292
|
+
|
|
293
|
+
> 非阻塞的代价是终态不会自己回到用户面前——**交付"开发完成结果"是这条链路的最终交付物,和 ACK 同等强制**。子 session 跟进时由子会话回报,逐回合短轮询时由 agent 自己回传,无论哪种都不能只 ACK 不收口。
|
|
294
|
+
|
|
295
|
+
- 状态 `done` 后,`message status` 会自动带回 answer;直接整理成用户可见结果(开发完成结论 + answer + `project_url`,`web` 类型再附 `preview_url`)回到原上下文。
|
|
296
|
+
- **失败 / 超时也要收口**:状态 `failed`、或超出轮询上限仍未 `done` 时,必须如实把当前状态回给用户并给下一步,**禁止**静默停在"还在开发中"。
|
|
297
|
+
- 同一终态只通知一次,避免 ACK 与 follow-up 各发一遍。
|
|
236
298
|
|
|
237
299
|
## 意图 → 命令索引
|
|
238
300
|
|
|
239
301
|
| 意图 | 推荐命令 | 备注 |
|
|
240
302
|
|------|---------|------|
|
|
241
|
-
| 创建新项目 | `coze code project create` | `--type` 支持 agent/workflow/app/skill/web/miniprogram/assistant(常用 web/app) |
|
|
303
|
+
| 创建新项目 | `coze code project create` | 必带 `--create-source`(扣子/Coze 系→coze_agent_cli,否则 agent_cli);`--type` 支持 agent/workflow/app/skill/web/miniprogram/assistant(常用 web/app) |
|
|
242
304
|
| 列出/查看项目 | `coze code project list/get` | 支持按类型/名称筛选 |
|
|
243
305
|
| 删除项目 | `coze code project delete` | 不可逆操作 |
|
|
244
306
|
| 导入项目 | `coze code project import -s <github\|local>` | 导入后自动发后台初始化 query(可用 `message status` 跟进),返回值含 `project_url` |
|