@coze/cli 0.3.1-alpha.103a11 → 0.3.1-alpha.920ba1

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 CHANGED
@@ -8,7 +8,17 @@ Coze CLI — A command-line tool for interacting with [Coze](https://www.coze.cn
8
8
  npm install -g @coze/cli
9
9
  ```
10
10
 
11
- After installation the CLI silently runs `coze self skill install`, which installs the bundled skills to your local AI agents (Claude Code, Trae, Comate, ...). If that step is skipped or fails, run it manually:
11
+ After installation the CLI silently runs `coze self skill install`, which installs the bundled skills to your local AI agents (Claude Code, Trae, Comate, ...). On a first install this sync can take up to a minute (it detects every AI agent on your machine and copies/links the skills), so the install may appear to pause near the end — this is expected.
12
+
13
+ > npm 7+ hides lifecycle-script output by default, so you won't see the sync progress. To watch it, install with `--foreground-scripts`:
14
+ >
15
+ > ```bash
16
+ > npm install -g @coze/cli --foreground-scripts
17
+ > ```
18
+ >
19
+ > (pnpm and yarn classic show the progress without any extra flag.)
20
+
21
+ If that step is skipped or fails, run it manually:
12
22
 
13
23
  ```bash
14
24
  coze self skill install
@@ -26,6 +26,14 @@ try {
26
26
  const useColor = !process.env.NO_COLOR;
27
27
  const cyan = text => (useColor ? `[36m${text}[0m` : text);
28
28
 
29
+ // 同步前先给一行"正在进行、请稍候"的预期文案:扇出会探测本机所有 AI agent 并
30
+ // 拷贝/软链 skill,首次安装可能耗时近 1 分钟。注意 npm >= 7 默认丢弃 postinstall
31
+ // 输出(需 --foreground-scripts 才可见),故此提示主要服务 pnpm / yarn / 旧版 npm。
32
+ process.stdout.write(
33
+ `\n${cyan('Coze CLI')}: syncing bundled skills to your AI agents ` +
34
+ '(first install can take up to a minute)...\n',
35
+ );
36
+
29
37
  // 通过包内 CLI 入口走真实的 `coze self skill install` 代码路径(skipAuth,纯本地:
30
38
  // 委托 skills 工具把 bundled skills 拷入中心池 ~/.agents/skills 并软链到已安装的 AI agents)。
31
39
  // 用户改过的 skill 不会被覆盖(sync 默认不带 --force 即阻止)。
package/lib/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";const e=require("./fetch-client-CgQGE-CR.js"),t=require("./index-JxWKC7px.js"),o=require("chalk"),i=require("node:child_process"),s=require("./task-worker-BJO9Ixaq.js"),n=require("node:path"),r=require("node:fs/promises"),a=require("node:fs"),c=require("node:crypto"),l=require("node:http"),d=require("node:https"),p=require("node:buffer"),u=require("undici"),m=require("path"),g=require("fs/promises"),h=require("fs"),f=require("form-data"),_=require("omelette"),y=require("node:os"),b=require("child_process"),v=require("lodash"),w=require("commander"),E=require("ws");function C(e){const t=Object.create(null);if(e)for(const o in e)if("default"!==o){const i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,i.get?i:{enumerable:!0,get:function(){return e[o]}})}return t.default=e,Object.freeze(t)}require("crypto"),require("url"),require("https-proxy-agent"),require("http"),require("https"),require("http2"),require("util"),require("stream"),require("assert"),require("tty"),require("zlib"),require("events"),require("mitt"),require("process");const I=C(n),A=C(r);function S(e,t){return null!=e?e:t()}class k{format(e){const t=JSON.stringify(e,null,2);return t.endsWith("\n")?t:`${t}\n`}formatError(e){const t={code:e.code,errorName:S(e.errorName,(()=>"UNKNOWN_ERROR")),desc:S(e.desc,(()=>e.message)),trigger:S(e.trigger,(()=>null)),fix:S(e.fix,(()=>null)),example:S(e.example,(()=>null))},o=JSON.stringify(t,null,2);return o.endsWith("\n")?o:`${o}\n`}}function j(e,t){return null!=e?e:t()}function P(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}function z(e){const t=String.fromCharCode(27),o=new RegExp(`${t}(?:[@-Z\\\\-_]|\\[[0-?]*[ -/]*[@-~])`,"g");return e.replace(o,"")}function T(e){return e>=4352&&e<=4447||(9001===e||9002===e||(e>=11904&&e<=12350||(e>=12352&&e<=42191||(e>=44032&&e<=55203||(e>=63744&&e<=64255||(e>=65040&&e<=65049||(e>=65072&&e<=65135||(e>=65280&&e<=65376||(e>=65504&&e<=65510||(e>=127744&&e<=129695||e>=131072&&e<=262141))))))))))}function R(e){const t=z(e);if(!t)return 0;const o=/[\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/u;let i=0;const s=Array.from(t);for(let e=0;e<s.length;e+=1){const t=j(s[e],(()=>""));if(o.test(t))continue;const n=t.codePointAt(0);void 0!==n&&(i+=T(n)?2:1)}return i}function x(e,t){const o=R(e);return o>=t?e:`${e}${" ".repeat(t-o)}`}function L(e,t){if(t<=0)return"";if(R(e)<=t)return e;if(1===t)return"…";const o=z(e),i=Array.from(o),s=Math.max(0,t-R("…"));let n="",r=0;for(let e=0;e<i.length;e+=1){const t=j(i[e],(()=>"")),o=R(t);if(r+o>s)break;n+=t,r+=o}return`${n}…`}function O(e,t={}){if(0===e.length)return"";const o=function(e,t){if(0===e.length)return[];const o=new Set,i=[],s=j(e[0],(()=>({})));for(const e of Object.keys(s))o.has(e)||(o.add(e),i.push(e));for(const t of e)for(const e of Object.keys(t))o.has(e)||(o.add(e),i.push(e));const n=[];for(const t of i){let o=R(t);for(const i of e){const e=i[t],s=void 0===e?"":String(e);o=Math.max(o,R(s))}n.push({key:t,width:o})}const r=j(t.columnGap,(()=>2)),a=j(j(t.maxWidth,(()=>process.stdout.columns)),(()=>120)),c=Math.max(1,Math.floor((a+r)/(6+r))),l=Math.min(j(t.maxColumns,(()=>c)),c);n.length>l&&n.splice(l);const d=Math.max(0,a-r*Math.max(0,n.length-1));for(;n.reduce(((e,t)=>e+t.width),0)>d;){let e=-1,t=-1;for(let o=0;o<n.length;o+=1){const i=j(P([n,"access",e=>e[o],"optionalAccess",e=>e.width]),(()=>0));i>t&&(t=i,e=o)}if(-1===e)break;const o=j(P([n,"access",t=>t[e],"optionalAccess",e=>e.width]),(()=>0));if(o<=6)break;n[e]={...n[e],width:o-1}}for(let e=0;e<n.length;e+=1){const t=n[e];t&&(n[e]={...t,width:Math.max(6,t.width)})}return n}(e,t);if(0===o.length)return"";const i=j(t.columnGap,(()=>2)),s=" ".repeat(i),n=o.map((e=>x(L(e.key,e.width),e.width))).join(s),r=o.map((e=>"-".repeat(e.width))).join(s),a=[];for(const t of e){const e=o.map((e=>{const o=t[e.key];return x(L(void 0===o?"":String(o),e.width),e.width)}));a.push(e.join(s))}return`${[n,r,...a].join("\n")}\n`}function D(e,t={}){const o=Object.entries(e);if(0===o.length)return"";let i=0;for(const[e]of o)i=Math.max(i,R(e));const s=j(j(t.maxWidth,(()=>process.stdout.columns)),(()=>120)),n=j(t.columnGap,(()=>2)),r=j(t.minValueWidth,(()=>12));let a=Math.min(i,j(t.keyMaxWidth,(()=>32)));const c=Math.max(6,s-n-r);a=Math.min(a,c);const l=Math.max(0,s-a-n),d=" ".repeat(n);return`${o.map((([e,t])=>{const o=x(L(e,a),a),i=(void 0===t?"undefined":null===t?"null":String(t)).replace(/\s*\n\s*/g," "),s=l>0?L(i,l):"";return`${o}${d}${s}`})).join("\n")}\n`}function U(e,t="",o=0){const i={};if(null==e)return i;if("object"!=typeof(s=e)||null===s||Array.isArray(s))return i;var s;for(const[s,n]of Object.entries(e)){const e=t?`${t}.${s}`:s;if(null!=n)if(Array.isArray(n))o>=5?i[e]="[Array]":0===n.length?i[e]="[]":n.every((e=>"object"!=typeof e||null===e))?i[e]=n.map((e=>{return String((o=()=>"null",null!=(t=e)?t:o()));var t,o})).join(", "):i[e]="[Array]";else if("object"!=typeof n)i[e]=n;else if(o>=5)i[e]="[Object]";else{const t=U(n,e,o+1);Object.assign(i,t)}else i[e]=n}return i}function q(e,t){return null!=e?e:t()}function B(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}class M{format(e){if(null===e)return"null\n";if(void 0===e)return"undefined\n";if(Array.isArray(e)){if(0===e.length)return"\n";if(t=e,Array.isArray(t)&&t.length>0&&t.every(B)){return O(e.map((e=>U(e))))}return function(e){return Array.isArray(e)&&e.length>0&&e.every((e=>null==e||"object"!=typeof e))}(e)?`${e.map((e=>String(q(e,(()=>"null"))))).join("\n")}\n`:"[Array]\n"}var t;if(B(e)){const t=U(e);return 0===Object.keys(t).length?"{}\n":D(t)}return`${String(e)}\n`}formatError(e){const t=[],o=q(e.errorName,(()=>"UNKNOWN_ERROR")),i=q(e.desc,(()=>e.message));return t.push(`ERROR [${e.code}] ${o}: ${i}`),e.trigger&&t.push(` Trigger: ${e.trigger}`),e.fix&&t.push(` Fix: ${e.fix}`),e.example&&t.push(` Example: ${e.example}`),e.details&&(t.push(" Error Details:"),t.push(`${function(e,t){if(null==e)return"";if("string"==typeof e)return`${t}${e}\n`;if(Array.isArray(e))return 0===e.length?"":`${e.map((e=>"object"==typeof e&&null!==e?D(U(e)):String(e))).map((e=>`${t}- ${e.trim()}`)).join("\n")}\n`;if(B(e)){const o=U(e);return 0===Object.keys(o).length?"":`${D(o).split("\n").filter((e=>e.trim())).map((e=>`${t}${e}`)).join("\n")}\n`}return`${t}${String(e)}\n`}(e.details," ")}`)),`${t.join("\n")}\n`}}function N(e,t){return null!=e?e:t()}function $(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}function G(e,t){if(null==e)return;const o=String(e).replace(/\s*\n\s*/g," ").replace(/\s+/g," ").trim();return o?o.length<=t?o:`${o.slice(0,Math.max(0,t-3))}...`:void 0}function F(e){const t=$([e,"optionalAccess",e=>e.help,"optionalAccess",e=>e.errors]);if(t&&t.length>0)return t;const o=$([e,"optionalAccess",e=>e.errors]);return Array.isArray(o)?o:void 0}function V(t,o){const i=N(t.trigger,(()=>function(e){if(!e||0===e.length)return;return G(("coze"===e[0]?e:["coze",...e]).join(" "),150)}($([o,"optionalAccess",e=>e.argv])))),s=$([F,"call",e=>e($([o,"optionalAccess",e=>e.commandConfig])),"optionalAccess",e=>e.find,"call",e=>e((e=>e.code===t.code))]),n=N($([s,"optionalAccess",e=>e.name]),(()=>e.ErrorNameByCode[t.code])),r=N(G(n,80),(()=>"UNKNOWN_ERROR"));let a=n;t.isMessageExplicit&&t.message.trim()?a=t.message:$([s,"optionalAccess",e=>e.desc])&&(a=s.desc);const c=N(G(a,200),(()=>"An unexpected error occurred")),l=N(G(t.fix,150),(()=>G($([s,"optionalAccess",e=>e.fix]),150))),d=N(G(t.example,150),(()=>G($([s,"optionalAccess",e=>e.example]),150)));return{code:t.code,errorName:r,desc:c,trigger:i,fix:l,example:d}}function W(e,t){const o=V(e,t);return e.errorName=o.errorName,e.desc=o.desc,e.message=o.desc,e.trigger=o.trigger,e.fix=o.fix,e.example=o.example,e}function H(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}var J;function K(o,i,s,n){if(o instanceof e.CozeError)throw o;if(e.isHttpError(o)){const e=H([o,"access",e=>e.response,"optionalAccess",e=>e.status]);if("ECONNREFUSED"===o.code||"ETIMEDOUT"===o.code||"number"==typeof e&&e>=500)throw o}if(o instanceof t.ChatCoreError&&"number"==typeof H([o,"access",e=>e.ext,"optionalAccess",e=>e.code])&&o.ext.code>=500)throw o;throw new e.CozeError(i,s,{...n,cause:o instanceof Error?o.message:String(o)})}!function(e){e[e.NOT_LOGIN=700012006]="NOT_LOGIN"}(J||(J={}));const Q=(o,i)=>{const s=W(function(o){if(o instanceof e.CozeError)return o;if(o instanceof t.ChatCoreError){const{ext:t}=o;let i=e.ErrorCode.E5000;"number"==typeof t.code&&(t.code===J.NOT_LOGIN?i=e.ErrorCode.E2001:t.code>=500&&(i=e.ErrorCode.E5002));const{message:s}=o;return new e.CozeError(i,s,t)}if(e.isHttpError(o)){const t=o.toJSON();let i=e.ErrorCode.E5000;const s=H([o,"access",e=>e.response,"optionalAccess",e=>e.status]);o.code===J.NOT_LOGIN||401===s?i=e.ErrorCode.E2001:"ECONNREFUSED"===o.code||"ETIMEDOUT"===o.code?i=e.ErrorCode.E5001:403===s?i=e.ErrorCode.E2003:404===s?i=e.ErrorCode.E3000:429===s?i=e.ErrorCode.E4001:s&&s>=500&&(i=e.ErrorCode.E5002);const n=H([o,"access",e=>e.response,"optionalAccess",e=>e.headers,"optionalAccess",e=>e["x-tt-logid"]]),{message:r}=o;return new e.CozeError(i,r,{logId:n,...t})}return o instanceof Error?new e.CozeError(e.ErrorCode.E5000,o.message,o.stack):"string"==typeof o?new e.CozeError(e.ErrorCode.E5000,o):new e.CozeError(e.ErrorCode.E5000,"An unexpected error occurred")}(o),i?{argv:i.argv,commandConfig:i.commandConfig}:void 0);var n,r;if(s.code===e.ErrorCode.E2001&&process.stdout.write(`${n=s.desc,r=()=>s.message,null!=n?n:r()}\n`),i)i.response.eprint(s);else{const e=new M;process.stderr.write(e.formatError(s))}process.exit(e.exitCodeForError(s.code))};const Y="@coze/cli",Z="0.3.1-alpha.103a11",X=Y;function ee(){const e=[{pm:"npm",cmd:`npm ls -g ${X} --json 2>/dev/null`},{pm:"pnpm",cmd:`pnpm ls -g ${X} --json 2>/dev/null`},{pm:"yarn",cmd:"yarn global list --json 2>/dev/null"}];for(const{pm:t,cmd:o}of e)try{if(i.execSync(o,{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).includes(X))return t}catch(e){}return"npm"}function te(e,t){return null!=e?e:t()}function oe(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}const ie=Y,se=6e5;function ne(){return Z}function re(e){const t=e.trim().replace(/^v/,"").split("+")[0],o=t.indexOf("-"),i=-1===o?t:t.slice(0,o),s=-1===o?"":t.slice(o+1),n=i.split(".");return{major:parseInt(n[0]||"0",10),minor:parseInt(n[1]||"0",10),patch:parseInt(n[2]||"0",10),prerelease:""===s?[]:s.split(".")}}function ae(e,t){const o=/^\d+$/.test(e),i=/^\d+$/.test(t);if(o&&i){const o=parseInt(e,10)-parseInt(t,10);return 0===o?0:o>0?1:-1}return o?-1:i?1:e===t?0:e>t?1:-1}function ce(e,t){const o=re(e),i=re(t);return o.major!==i.major?o.major>i.major?1:-1:o.minor!==i.minor?o.minor>i.minor?1:-1:o.patch!==i.patch?o.patch>i.patch?1:-1:function(e,t){if(0===e.length&&0===t.length)return 0;if(0===e.length)return 1;if(0===t.length)return-1;const o=Math.max(e.length,t.length);for(let i=0;i<o;i++){const o=e[i],s=t[i];if(void 0===o)return-1;if(void 0===s)return 1;const n=ae(o,s);if(0!==n)return n}return 0}(o.prerelease,i.prerelease)}function le(e,t){return ce(t,e)>0}function de(e,t){return re(t).major>re(e).major}function pe(){if(process.env.COZE_CLI_NO_UPDATE_NOTIFIER)return!0;const e=te(process.env.CI,(()=>"")).toLowerCase();return""!==e&&"false"!==e&&"0"!==e||function(e){return!e||"0.0.0"===e||/dev/i.test(e)}(ne())}function ue(e){const t=oe([e,"access",e=>e.upgrade,"optionalAccess",e=>e.mode]);return"auto"===t||"notify"===t||"off"===t?t:"auto"}function me(e){return oe([e,"access",e=>e.upgrade,"optionalAccess",e=>e.channel])||"latest"}async function ge(t,o=!1,n="latest"){const r=ne(),{config:a}=t,c=oe([a,"access",e=>e.upgrade,"optionalAccess",e=>e.cache]);if(!o&&oe([c,"optionalAccess",e=>e.latestVersion])&&c.checkedAt&&Date.now()-c.checkedAt<144e5&&te(c.channel,(()=>"latest"))===n)return{currentVersion:r,latestVersion:c.latestVersion,hasUpdate:le(r,c.latestVersion)};const l=function(){try{return i.execSync("npm config get registry",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim().replace(/\/+$/,"")}catch(e){return"https://registry.npmjs.org"}}(),d=await async function(t,o="latest"){const i=`${t}/${ie}/${o}`,s=await e.customFetch.fetch(i,{headers:{accept:"application/json"}});if(!s.ok)throw new Error(`Failed to fetch latest version: ${s.status} ${s.statusText}`);return(await s.json()).version}(l,n);return await s.saveConfig({upgrade:{cache:{latestVersion:d,checkedAt:Date.now(),channel:n}}},a.configScope),{currentVersion:r,latestVersion:d,hasUpdate:le(r,d)}}async function he(e,t){const o=function(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}([e,"access",e=>e.config,"access",e=>e.upgrade,"optionalAccess",e=>e.cache,"optionalAccess",e=>e.lastAttempt]);if(o&&Date.now()-o<se)return;try{await s.saveConfig({upgrade:{cache:{lastAttempt:Date.now()}}},e.config.configScope)}catch(e){}const n=ee(),{command:r,args:a}=function(e,t){const o=`${X}@${t}`;switch(e){case"pnpm":return{command:"pnpm",args:["add","-g",o]};case"yarn":return{command:"yarn",args:["global","add",o]};default:return{command:"npm",args:["install","-g",o]}}}(n,t);try{i.spawn(r,a,{detached:!0,stdio:"ignore",shell:"win32"===process.platform}).unref()}catch(e){}}function fe(e,t){return null!=e?e:t()}function _e(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}const ye={claude:"claude-code"};let be=null;function ve(){if(be)return be;const t=function(){let e=__dirname;for(let t=0;t<12;t++){const t=n.join(e,"node_modules","skills","package.json");if(a.existsSync(t))return n.dirname(t);const o=n.dirname(e);if(o===e)break;e=o}}();if(t){const o=e.safeJsonParse(a.readFileSync(n.join(t,"package.json"),"utf8")),i="string"==typeof _e([o,"optionalAccess",e=>e.bin])?o.bin:_e([o,"optionalAccess",e=>e.bin,"optionalAccess",e=>e.skills]);if(i)return be={cmd:process.execPath,prefix:[n.join(t,i)]},be}return be={cmd:"skills",prefix:[]},be}function we(e){const{cmd:t,prefix:o}=ve(),s=i.spawnSync(t,[...o,...e],{encoding:"utf8"});return{ok:0===s.status,stdout:fe(s.stdout,(()=>"")),stderr:fe(s.stderr,(()=>"")),code:s.status}}function Ee(e,t={}){const o=["add",e];return t.global&&o.push("-g"),t.yes&&o.push("-y"),t.agents&&t.agents.length>0&&o.push("-a",...t.agents),we(o)}function Ce(e,t={}){const o=["remove",e];return t.global&&o.push("-g"),o.push("-y"),we(o)}function Ie(t={}){const o=["ls","--json"];t.global&&o.push("-g");const i=we(o);if(!i.ok)return[];const s=e.safeJsonParse(i.stdout);return Array.isArray(s)?s:[]}function Ae(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}function Se(){return s.getGlobalSkillLockFile()}async function ke(e){try{return await r.access(e),!0}catch(e){return!1}}async function je(){let t=__dirname;for(let o=0;o<12;o++){const o=n.join(t,"package.json");if(await ke(o)){if("@coze/cli"===Ae([e.safeJsonParse(await r.readFile(o,"utf8")),"optionalAccess",e=>e.name]))return t}const i=n.dirname(t);if(i===t)break;t=i}return n.resolve(__dirname,"..")}async function Pe(){return n.join(await je(),"skills")}async function ze(){return n.join(await je(),"docs","skills")}const Te=new Set(["SKILL.md","MODULE.md"]);function Re(e){return`sha256:${c.createHash("sha256").update(e,"utf8").digest("hex")}`}function xe(e){return Te.has(n.basename(e))}async function Le(e,t=e){const o=await r.readdir(e,{withFileTypes:!0}),i=[];for(const s of o){if(s.name.startsWith("."))continue;const o=n.join(e,s.name);s.isDirectory()?i.push(...await Le(o,t)):s.isFile()&&i.push(n.relative(t,o).split(n.sep).join("/"))}return i.sort()}function Oe(e,t){const o=Ue(e);if(void 0===o)return;const i=new RegExp(`^${t}:\\s*(.+?)\\s*$`,"m"),s=o.match(i);return s?s[1].replace(/^['"]|['"]$/g,"").trim():void 0}function De(e,t){const o=Ue(e);if(void 0===o)return e;const i=`version: ${t}`;let s;return s=/^version:\s*.+$/m.test(o)?o.replace(/^version:\s*.+$/m,i):/^name:\s*.+$/m.test(o)?o.replace(/^(name:\s*.+)$/m,`$1\n${i}`):`${i}\n${o}`,e.replace(o,s)}function Ue(e){if(!e.startsWith("---"))return;const t=e.match(/^---\n([\s\S]*?)\n---/);return t?t[1]:void 0}function qe(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}async function Be(){const e=await Pe();if(await ke(n.join(e,"manifest.json")))return{root:e,source:"bundled"};const t=await ze();if(await ke(t))return{root:t,source:"docs"};throw new Error(`未找到 skill 来源:既无包内 ${e}/manifest.json,也无开发态 ${t}。`)}async function Me(){const t=n.join(await je(),"package.json"),o=e.safeJsonParse(await r.readFile(t,"utf8"));return i=qe([o,"optionalAccess",e=>e.version]),s=()=>"0.0.0",null!=i?i:s();var i,s}async function Ne(){const t=await Pe(),o=n.join(t,"manifest.json");if(await ke(o)){const i=e.safeJsonParse(await r.readFile(o,"utf8")),s=(await Le(t)).filter((e=>"manifest.json"!==e)),a=[];for(const e of s)a.push({rel:e,content:await r.readFile(n.join(t,e),"utf8")});return{manifest:i,files:a,source:"bundled"}}const i=await ze();if(!await ke(i))throw new Error(`未找到 skill 来源:既无包内 ${o},也无开发态 ${i}。`);const s=await Me(),{manifest:a,files:c}=await async function(e,t){const o=await Le(e),i=[],s={};for(const l of o){const o=await r.readFile(n.join(e,l),"utf8"),d=xe(l),p=d?De(o,t):o;i.push({rel:l,content:p}),d&&(s[(a=Oe(p,"name"),c=()=>l,null!=a?a:c())]={path:l,hash:Re(p)})}var a,c;return{manifest:{cliVersion:t,skills:s},files:i}}(i,s);return{manifest:a,files:c,source:"docs"}}async function $e(){try{const t=await r.readFile(Se(),"utf8");return e.safeJsonParse(t)}catch(e){return}}function Ge(e,t){return null!=e?e:t()}function Fe(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}async function Ve(e){try{return Re(await r.readFile(e,"utf8"))}catch(e){return}}function We(e){return[...new Set(Object.values(e.skills).map((e=>e.path.split("/")[0])))]}function He(e){return e[0]?n.dirname(e[0].path):void 0}async function Je(e={}){const{manifest:t}=await Ne(),{root:o}=await Be(),i=We(t),s=await $e(),a=Ie({global:!0}),c=await async function(e,t,o){const i=He(t);if(!i)return[];const s=new Set(t.map((e=>e.name))),r=[];for(const[t,a]of Object.entries(e.skills)){const e=a.path.split("/")[0];if(!s.has(e))continue;const c=await Ve(n.join(i,a.path));if(void 0===c)continue;if(c===a.hash)continue;const l=Fe([o,"optionalAccess",e=>e.skills,"access",e=>e[t],"optionalAccess",e=>e.hash]);void 0!==l&&c===l||r.push(t)}return r}(t,a,s);if(c.length>0&&!e.force)return{blocked:!0,cliVersion:t.cliVersion,sourceRoot:o,linkedTargets:[],skillsOk:!1,unknownTargets:[],modifiedSkills:c};const l=e.targets&&e.targets.length>0&&!e.targets.includes("all")?Ge(e.targets,(()=>[])).map((e=>fe(ye[e],(()=>e)))):void 0;let d=!0;for(const e of i){Ee(n.join(o,e),{global:!0,yes:!0,agents:l}).ok||(d=!1)}const p=Ie({global:!0}).filter((e=>i.includes(e.name))),u=Fe([p,"access",e=>e[0],"optionalAccess",e=>e.path]),m=[...new Set(p.flatMap((e=>e.agents)))],g=(new Date).toISOString(),h={};for(const[e,o]of Object.entries(t.skills))h[e]={hash:o.hash,expectedHash:o.hash,installedAt:g};return await async function(e){const t=Se();await r.mkdir(n.dirname(t),{recursive:!0}),await r.writeFile(t,`${JSON.stringify(e,null,2)}\n`,"utf8")}({version:1,cliVersion:t.cliVersion,installedBin:Ge(process.argv[1],(()=>process.execPath)),poolPath:u,targets:m,skills:h}),{blocked:!1,cliVersion:t.cliVersion,sourceRoot:o,poolPath:u,linkedTargets:m,skillsOk:d,unknownTargets:[],modifiedSkills:[]}}function Ke(e,t,o){return void 0===e?"missing":e===t?"ok":o===e?"drift":"modified"}async function Qe(){const{manifest:e}=await Ne(),t=await $e(),o=Ge(process.argv[1],(()=>process.execPath)),i=Ie({global:!0}),s=He(i),r=new Set(i.map((e=>e.name))),a=[];for(const[o,i]of Object.entries(e.skills)){const e=i.path.split("/")[0],c=Boolean(s)&&r.has(e),l=c?await Ve(n.join(s,i.path)):void 0,d=c?Ke(l,i.hash,Fe([t,"optionalAccess",e=>e.skills,"access",e=>e[o],"optionalAccess",e=>e.hash])):"missing";a.push({name:o,path:i.path,state:d})}const c=Fe([i,"access",e=>e.find,"call",e=>e((e=>r.has(e.name))),"optionalAccess",e=>e.path]);return{lockExists:Boolean(t),cliVersion:e.cliVersion,installedVersion:Fe([t,"optionalAccess",e=>e.cliVersion]),versionMatch:Boolean(t)&&Fe([t,"optionalAccess",e=>e.cliVersion])===e.cliVersion,installedBin:Fe([t,"optionalAccess",e=>e.installedBin]),currentBin:o,binMatch:!Fe([t,"optionalAccess",e=>e.installedBin])||t.installedBin===o,poolPath:c,targets:Ge(Fe([t,"optionalAccess",e=>e.targets]),(()=>[])),skills:a}}async function Ye(){const{manifest:e}=await Ne(),t=We(e),o=Ie({global:!0}),i=[];for(const e of t){const t=o.find((t=>t.name===e));if(!t)continue;Ce(e,{global:!0}).ok&&i.push({name:e,agents:t.agents})}return await async function(){await r.rm(Se(),{force:!0})}(),{removed:i}}async function Ze(){const t=await async function(){const t=n.join(await Pe(),"manifest.json");if(await ke(t)){const o=e.safeJsonParse(await r.readFile(t,"utf8"));if(qe([o,"optionalAccess",e=>e.cliVersion]))return o.cliVersion}return Me()}(),o=await $e();return o?o.cliVersion!==t?{state:"mismatch",cliVersion:t,installedVersion:o.cliVersion,message:`Skills (${o.cliVersion}) are out of sync with CLI (${t}). Run \`coze self skill install\`.`}:{state:"ok",cliVersion:t,installedVersion:o.cliVersion}:{state:"missing",cliVersion:t,message:"Bundled skills not installed yet. Run `coze self skill install` to sync them to your AI tools."}}function Xe(e){const t={};let o;const i=[];let s=!1;for(let n=0;n<e.length;n++){const r=e[n];if("--help"!==r&&"-h"!==r)if("--version"!==r&&"-v"!==r)if("--output"!==r)if("--format"!==r)"--no-color"!==r?"--config"!==r?"--org-id"!==r?"--space-id"!==r?"--verbose"!==r?"--debug"!==r?"--log-file"!==r?"--print-logs"!==r?s||r.startsWith("-")?i.push(r):(o=r,s=!0):t.printLogs=!0:t.logFile=e[++n]:t.debug=!0:t.verbose=!0:t.spaceId=e[++n]:t.orgId=e[++n]:t.config=e[++n]:t.noColor=!0;else{const o=e[++n];"json"!==o&&"text"!==o||(t.format=o)}else t.output=e[++n];else t.version=!0;else t.help=!0}return{globalOptions:t,commandName:o,commandArgs:i}}function et(e,t){return null!=e?e:t()}function ot(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}async function it(e,t){const i=await async function(e){if("self"===Xe(e.argv).commandName)return;const t=function(e){const t=function(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}([e,"access",e=>e.skill,"optionalAccess",e=>e.mode]);return"auto"===t||"notify"===t||"off"===t?t:"auto"}(e.config);if("off"===t)return;if(function(){const e=et(process.env.CI,(()=>"")).toLowerCase();return""!==e&&"false"!==e&&"0"!==e||Boolean(process.env.COZE_CLI_NO_SKILL_NOTIFIER)}())return;try{const o=await Ze();if("ok"===o.state)return;if("auto"===t&&await async function(e){if("mismatch"!==e.state&&"missing"!==e.state)return!1;try{return!(await Je({})).blocked}catch(e){return!1}}(o))return;return"json"===e.format&&e.response.setNotice({skill:{state:o.state,cliVersion:o.cliVersion,installedVersion:o.installedVersion,message:o.message,command:"coze self skill install"}}),o}catch(e){return}}(e),s=await async function(e){if("upgrade"===Xe(e.argv).commandName)return;if(pe())return;const t=ue(e.config);if("off"===t)return;const o=ot([e,"access",e=>e.config,"access",e=>e.upgrade,"optionalAccess",e=>e.cache]),i=ot([o,"optionalAccess",e=>e.latestVersion]);if(!i)return;if(et(o.channel,(()=>"latest"))!==me(e.config))return;const s=ne();if(!le(s,i))return;const n=o.lastAttempt,r="number"==typeof n&&Date.now()-n<se;let a;"auto"===("auto"===t&&de(s,i)?"notify":t)?r?a=`Auto-upgrade to ${i} did not take effect (current ${s}). Run \`coze upgrade\` manually; on an internal network verify your npm registry.`:(a=`Coze CLI ${i} available (current ${s}). Upgrading in the background; it will take effect on next run.`,he(e,i)):a=`Coze CLI ${i} available (current ${s}). Run \`coze upgrade\` to update.`;"json"===e.format&&e.response.setNotice({update:{current:s,latest:i,message:a,command:"coze upgrade"}});return{current:s,latest:i,message:a}}(e);await t(),function(e,t){if(!ot([t,"optionalAccess",e=>e.message]))return;if("json"===e.format)return void(e.response.hasPendingNotice()&&process.stderr.write(`${t.message}\n`));e.ui.info(`\n${t.message}\n`)}(e,i),function(e,t){if(!t)return;if("json"===e.format)return void(e.response.hasPendingNotice()&&process.stderr.write(`${t.message}\n`));e.ui.info(`\n${o.gray(t.current)} → ${o.green(t.latest)} ${t.message}\n`)}(e,s),async function(e){if("upgrade"===Xe(e.argv).commandName)return;if(pe())return;const t=ue(e.config);if("off"===t)return;try{const o=await ge(e,!1,me(e.config));o.hasUpdate&&"auto"===t&&!de(o.currentVersion,o.latestVersion)&&await he(e,o.latestVersion)}catch(e){}}(e)}var st=e.requireSrc();const nt=e.getDefaultExportFromCjs(st);function rt(e){var t,o,i=e.transport,s=e.endpoint,n=e.size,r=void 0===n?10:n,a=e.wait,c=void 0===a?1e3:a,l=[],d=0;function p(){if(l.length){var e=this.getBatchData();i.post({url:s,data:e,fail:function(o){t&&t(o,e)},success:function(){o&&o(e)}}),l=[]}}return{getSize:function(){return r},getWait:function(){return c},setSize:function(e){r=e},setWait:function(e){c=e},getEndpoint:function(){return s},setEndpoint:function(e){s=e},send:function(e){l.push(e),l.length>=r&&p.call(this),clearTimeout(d),d=setTimeout(p.bind(this),c)},flush:function(){clearTimeout(d),p.call(this)},getBatchData:function(){return l.length?(e=l,JSON.stringify({ev_type:"batch",list:e})):"";var e},clear:function(){clearTimeout(d),l=[]},fail:function(e){t=e},success:function(e){o=e}}}
2
+ "use strict";const e=require("./fetch-client-CgQGE-CR.js"),t=require("./index-JxWKC7px.js"),o=require("chalk"),i=require("node:child_process"),s=require("./task-worker-BJO9Ixaq.js"),n=require("node:path"),r=require("node:fs/promises"),a=require("node:fs"),c=require("node:crypto"),l=require("node:http"),d=require("node:https"),p=require("node:buffer"),u=require("undici"),m=require("path"),g=require("fs/promises"),h=require("fs"),f=require("form-data"),_=require("omelette"),y=require("node:os"),b=require("child_process"),v=require("lodash"),w=require("commander"),E=require("ws");function C(e){const t=Object.create(null);if(e)for(const o in e)if("default"!==o){const i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,i.get?i:{enumerable:!0,get:function(){return e[o]}})}return t.default=e,Object.freeze(t)}require("crypto"),require("url"),require("https-proxy-agent"),require("http"),require("https"),require("http2"),require("util"),require("stream"),require("assert"),require("tty"),require("zlib"),require("events"),require("mitt"),require("process");const I=C(n),A=C(r);function S(e,t){return null!=e?e:t()}class k{format(e){const t=JSON.stringify(e,null,2);return t.endsWith("\n")?t:`${t}\n`}formatError(e){const t={code:e.code,errorName:S(e.errorName,(()=>"UNKNOWN_ERROR")),desc:S(e.desc,(()=>e.message)),trigger:S(e.trigger,(()=>null)),fix:S(e.fix,(()=>null)),example:S(e.example,(()=>null))},o=JSON.stringify(t,null,2);return o.endsWith("\n")?o:`${o}\n`}}function j(e,t){return null!=e?e:t()}function P(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}function z(e){const t=String.fromCharCode(27),o=new RegExp(`${t}(?:[@-Z\\\\-_]|\\[[0-?]*[ -/]*[@-~])`,"g");return e.replace(o,"")}function T(e){return e>=4352&&e<=4447||(9001===e||9002===e||(e>=11904&&e<=12350||(e>=12352&&e<=42191||(e>=44032&&e<=55203||(e>=63744&&e<=64255||(e>=65040&&e<=65049||(e>=65072&&e<=65135||(e>=65280&&e<=65376||(e>=65504&&e<=65510||(e>=127744&&e<=129695||e>=131072&&e<=262141))))))))))}function R(e){const t=z(e);if(!t)return 0;const o=/[\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/u;let i=0;const s=Array.from(t);for(let e=0;e<s.length;e+=1){const t=j(s[e],(()=>""));if(o.test(t))continue;const n=t.codePointAt(0);void 0!==n&&(i+=T(n)?2:1)}return i}function x(e,t){const o=R(e);return o>=t?e:`${e}${" ".repeat(t-o)}`}function L(e,t){if(t<=0)return"";if(R(e)<=t)return e;if(1===t)return"…";const o=z(e),i=Array.from(o),s=Math.max(0,t-R("…"));let n="",r=0;for(let e=0;e<i.length;e+=1){const t=j(i[e],(()=>"")),o=R(t);if(r+o>s)break;n+=t,r+=o}return`${n}…`}function O(e,t={}){if(0===e.length)return"";const o=function(e,t){if(0===e.length)return[];const o=new Set,i=[],s=j(e[0],(()=>({})));for(const e of Object.keys(s))o.has(e)||(o.add(e),i.push(e));for(const t of e)for(const e of Object.keys(t))o.has(e)||(o.add(e),i.push(e));const n=[];for(const t of i){let o=R(t);for(const i of e){const e=i[t],s=void 0===e?"":String(e);o=Math.max(o,R(s))}n.push({key:t,width:o})}const r=j(t.columnGap,(()=>2)),a=j(j(t.maxWidth,(()=>process.stdout.columns)),(()=>120)),c=Math.max(1,Math.floor((a+r)/(6+r))),l=Math.min(j(t.maxColumns,(()=>c)),c);n.length>l&&n.splice(l);const d=Math.max(0,a-r*Math.max(0,n.length-1));for(;n.reduce(((e,t)=>e+t.width),0)>d;){let e=-1,t=-1;for(let o=0;o<n.length;o+=1){const i=j(P([n,"access",e=>e[o],"optionalAccess",e=>e.width]),(()=>0));i>t&&(t=i,e=o)}if(-1===e)break;const o=j(P([n,"access",t=>t[e],"optionalAccess",e=>e.width]),(()=>0));if(o<=6)break;n[e]={...n[e],width:o-1}}for(let e=0;e<n.length;e+=1){const t=n[e];t&&(n[e]={...t,width:Math.max(6,t.width)})}return n}(e,t);if(0===o.length)return"";const i=j(t.columnGap,(()=>2)),s=" ".repeat(i),n=o.map((e=>x(L(e.key,e.width),e.width))).join(s),r=o.map((e=>"-".repeat(e.width))).join(s),a=[];for(const t of e){const e=o.map((e=>{const o=t[e.key];return x(L(void 0===o?"":String(o),e.width),e.width)}));a.push(e.join(s))}return`${[n,r,...a].join("\n")}\n`}function D(e,t={}){const o=Object.entries(e);if(0===o.length)return"";let i=0;for(const[e]of o)i=Math.max(i,R(e));const s=j(j(t.maxWidth,(()=>process.stdout.columns)),(()=>120)),n=j(t.columnGap,(()=>2)),r=j(t.minValueWidth,(()=>12));let a=Math.min(i,j(t.keyMaxWidth,(()=>32)));const c=Math.max(6,s-n-r);a=Math.min(a,c);const l=Math.max(0,s-a-n),d=" ".repeat(n);return`${o.map((([e,t])=>{const o=x(L(e,a),a),i=(void 0===t?"undefined":null===t?"null":String(t)).replace(/\s*\n\s*/g," "),s=l>0?L(i,l):"";return`${o}${d}${s}`})).join("\n")}\n`}function U(e,t="",o=0){const i={};if(null==e)return i;if("object"!=typeof(s=e)||null===s||Array.isArray(s))return i;var s;for(const[s,n]of Object.entries(e)){const e=t?`${t}.${s}`:s;if(null!=n)if(Array.isArray(n))o>=5?i[e]="[Array]":0===n.length?i[e]="[]":n.every((e=>"object"!=typeof e||null===e))?i[e]=n.map((e=>{return String((o=()=>"null",null!=(t=e)?t:o()));var t,o})).join(", "):i[e]="[Array]";else if("object"!=typeof n)i[e]=n;else if(o>=5)i[e]="[Object]";else{const t=U(n,e,o+1);Object.assign(i,t)}else i[e]=n}return i}function q(e,t){return null!=e?e:t()}function B(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}class M{format(e){if(null===e)return"null\n";if(void 0===e)return"undefined\n";if(Array.isArray(e)){if(0===e.length)return"\n";if(t=e,Array.isArray(t)&&t.length>0&&t.every(B)){return O(e.map((e=>U(e))))}return function(e){return Array.isArray(e)&&e.length>0&&e.every((e=>null==e||"object"!=typeof e))}(e)?`${e.map((e=>String(q(e,(()=>"null"))))).join("\n")}\n`:"[Array]\n"}var t;if(B(e)){const t=U(e);return 0===Object.keys(t).length?"{}\n":D(t)}return`${String(e)}\n`}formatError(e){const t=[],o=q(e.errorName,(()=>"UNKNOWN_ERROR")),i=q(e.desc,(()=>e.message));return t.push(`ERROR [${e.code}] ${o}: ${i}`),e.trigger&&t.push(` Trigger: ${e.trigger}`),e.fix&&t.push(` Fix: ${e.fix}`),e.example&&t.push(` Example: ${e.example}`),e.details&&(t.push(" Error Details:"),t.push(`${function(e,t){if(null==e)return"";if("string"==typeof e)return`${t}${e}\n`;if(Array.isArray(e))return 0===e.length?"":`${e.map((e=>"object"==typeof e&&null!==e?D(U(e)):String(e))).map((e=>`${t}- ${e.trim()}`)).join("\n")}\n`;if(B(e)){const o=U(e);return 0===Object.keys(o).length?"":`${D(o).split("\n").filter((e=>e.trim())).map((e=>`${t}${e}`)).join("\n")}\n`}return`${t}${String(e)}\n`}(e.details," ")}`)),`${t.join("\n")}\n`}}function N(e,t){return null!=e?e:t()}function $(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}function G(e,t){if(null==e)return;const o=String(e).replace(/\s*\n\s*/g," ").replace(/\s+/g," ").trim();return o?o.length<=t?o:`${o.slice(0,Math.max(0,t-3))}...`:void 0}function F(e){const t=$([e,"optionalAccess",e=>e.help,"optionalAccess",e=>e.errors]);if(t&&t.length>0)return t;const o=$([e,"optionalAccess",e=>e.errors]);return Array.isArray(o)?o:void 0}function V(t,o){const i=N(t.trigger,(()=>function(e){if(!e||0===e.length)return;return G(("coze"===e[0]?e:["coze",...e]).join(" "),150)}($([o,"optionalAccess",e=>e.argv])))),s=$([F,"call",e=>e($([o,"optionalAccess",e=>e.commandConfig])),"optionalAccess",e=>e.find,"call",e=>e((e=>e.code===t.code))]),n=N($([s,"optionalAccess",e=>e.name]),(()=>e.ErrorNameByCode[t.code])),r=N(G(n,80),(()=>"UNKNOWN_ERROR"));let a=n;t.isMessageExplicit&&t.message.trim()?a=t.message:$([s,"optionalAccess",e=>e.desc])&&(a=s.desc);const c=N(G(a,200),(()=>"An unexpected error occurred")),l=N(G(t.fix,150),(()=>G($([s,"optionalAccess",e=>e.fix]),150))),d=N(G(t.example,150),(()=>G($([s,"optionalAccess",e=>e.example]),150)));return{code:t.code,errorName:r,desc:c,trigger:i,fix:l,example:d}}function W(e,t){const o=V(e,t);return e.errorName=o.errorName,e.desc=o.desc,e.message=o.desc,e.trigger=o.trigger,e.fix=o.fix,e.example=o.example,e}function H(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}var J;function K(o,i,s,n){if(o instanceof e.CozeError)throw o;if(e.isHttpError(o)){const e=H([o,"access",e=>e.response,"optionalAccess",e=>e.status]);if("ECONNREFUSED"===o.code||"ETIMEDOUT"===o.code||"number"==typeof e&&e>=500)throw o}if(o instanceof t.ChatCoreError&&"number"==typeof H([o,"access",e=>e.ext,"optionalAccess",e=>e.code])&&o.ext.code>=500)throw o;throw new e.CozeError(i,s,{...n,cause:o instanceof Error?o.message:String(o)})}!function(e){e[e.NOT_LOGIN=700012006]="NOT_LOGIN"}(J||(J={}));const Q=(o,i)=>{const s=W(function(o){if(o instanceof e.CozeError)return o;if(o instanceof t.ChatCoreError){const{ext:t}=o;let i=e.ErrorCode.E5000;"number"==typeof t.code&&(t.code===J.NOT_LOGIN?i=e.ErrorCode.E2001:t.code>=500&&(i=e.ErrorCode.E5002));const{message:s}=o;return new e.CozeError(i,s,t)}if(e.isHttpError(o)){const t=o.toJSON();let i=e.ErrorCode.E5000;const s=H([o,"access",e=>e.response,"optionalAccess",e=>e.status]);o.code===J.NOT_LOGIN||401===s?i=e.ErrorCode.E2001:"ECONNREFUSED"===o.code||"ETIMEDOUT"===o.code?i=e.ErrorCode.E5001:403===s?i=e.ErrorCode.E2003:404===s?i=e.ErrorCode.E3000:429===s?i=e.ErrorCode.E4001:s&&s>=500&&(i=e.ErrorCode.E5002);const n=H([o,"access",e=>e.response,"optionalAccess",e=>e.headers,"optionalAccess",e=>e["x-tt-logid"]]),{message:r}=o;return new e.CozeError(i,r,{logId:n,...t})}return o instanceof Error?new e.CozeError(e.ErrorCode.E5000,o.message,o.stack):"string"==typeof o?new e.CozeError(e.ErrorCode.E5000,o):new e.CozeError(e.ErrorCode.E5000,"An unexpected error occurred")}(o),i?{argv:i.argv,commandConfig:i.commandConfig}:void 0);var n,r;if(s.code===e.ErrorCode.E2001&&process.stdout.write(`${n=s.desc,r=()=>s.message,null!=n?n:r()}\n`),i)i.response.eprint(s);else{const e=new M;process.stderr.write(e.formatError(s))}process.exit(e.exitCodeForError(s.code))};const Y="@coze/cli",Z="0.3.1-alpha.920ba1",X=Y;function ee(){const e=[{pm:"npm",cmd:`npm ls -g ${X} --json 2>/dev/null`},{pm:"pnpm",cmd:`pnpm ls -g ${X} --json 2>/dev/null`},{pm:"yarn",cmd:"yarn global list --json 2>/dev/null"}];for(const{pm:t,cmd:o}of e)try{if(i.execSync(o,{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).includes(X))return t}catch(e){}return"npm"}function te(e,t){return null!=e?e:t()}function oe(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}const ie=Y,se=6e5;function ne(){return Z}function re(e){const t=e.trim().replace(/^v/,"").split("+")[0],o=t.indexOf("-"),i=-1===o?t:t.slice(0,o),s=-1===o?"":t.slice(o+1),n=i.split(".");return{major:parseInt(n[0]||"0",10),minor:parseInt(n[1]||"0",10),patch:parseInt(n[2]||"0",10),prerelease:""===s?[]:s.split(".")}}function ae(e,t){const o=/^\d+$/.test(e),i=/^\d+$/.test(t);if(o&&i){const o=parseInt(e,10)-parseInt(t,10);return 0===o?0:o>0?1:-1}return o?-1:i?1:e===t?0:e>t?1:-1}function ce(e,t){const o=re(e),i=re(t);return o.major!==i.major?o.major>i.major?1:-1:o.minor!==i.minor?o.minor>i.minor?1:-1:o.patch!==i.patch?o.patch>i.patch?1:-1:function(e,t){if(0===e.length&&0===t.length)return 0;if(0===e.length)return 1;if(0===t.length)return-1;const o=Math.max(e.length,t.length);for(let i=0;i<o;i++){const o=e[i],s=t[i];if(void 0===o)return-1;if(void 0===s)return 1;const n=ae(o,s);if(0!==n)return n}return 0}(o.prerelease,i.prerelease)}function le(e,t){return ce(t,e)>0}function de(e,t){return re(t).major>re(e).major}function pe(){if(process.env.COZE_CLI_NO_UPDATE_NOTIFIER)return!0;const e=te(process.env.CI,(()=>"")).toLowerCase();return""!==e&&"false"!==e&&"0"!==e||function(e){return!e||"0.0.0"===e||/dev/i.test(e)}(ne())}function ue(e){const t=oe([e,"access",e=>e.upgrade,"optionalAccess",e=>e.mode]);return"auto"===t||"notify"===t||"off"===t?t:"auto"}function me(e){return oe([e,"access",e=>e.upgrade,"optionalAccess",e=>e.channel])||"latest"}async function ge(t,o=!1,n="latest"){const r=ne(),{config:a}=t,c=oe([a,"access",e=>e.upgrade,"optionalAccess",e=>e.cache]);if(!o&&oe([c,"optionalAccess",e=>e.latestVersion])&&c.checkedAt&&Date.now()-c.checkedAt<144e5&&te(c.channel,(()=>"latest"))===n)return{currentVersion:r,latestVersion:c.latestVersion,hasUpdate:le(r,c.latestVersion)};const l=function(){try{return i.execSync("npm config get registry",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim().replace(/\/+$/,"")}catch(e){return"https://registry.npmjs.org"}}(),d=await async function(t,o="latest"){const i=`${t}/${ie}/${o}`,s=await e.customFetch.fetch(i,{headers:{accept:"application/json"}});if(!s.ok)throw new Error(`Failed to fetch latest version: ${s.status} ${s.statusText}`);return(await s.json()).version}(l,n);return await s.saveConfig({upgrade:{cache:{latestVersion:d,checkedAt:Date.now(),channel:n}}},a.configScope),{currentVersion:r,latestVersion:d,hasUpdate:le(r,d)}}async function he(e,t){const o=function(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}([e,"access",e=>e.config,"access",e=>e.upgrade,"optionalAccess",e=>e.cache,"optionalAccess",e=>e.lastAttempt]);if(o&&Date.now()-o<se)return;try{await s.saveConfig({upgrade:{cache:{lastAttempt:Date.now()}}},e.config.configScope)}catch(e){}const n=ee(),{command:r,args:a}=function(e,t){const o=`${X}@${t}`;switch(e){case"pnpm":return{command:"pnpm",args:["add","-g",o]};case"yarn":return{command:"yarn",args:["global","add",o]};default:return{command:"npm",args:["install","-g",o]}}}(n,t);try{i.spawn(r,a,{detached:!0,stdio:"ignore",shell:"win32"===process.platform}).unref()}catch(e){}}function fe(e,t){return null!=e?e:t()}function _e(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}const ye={claude:"claude-code"};let be=null;function ve(){if(be)return be;const t=function(){let e=__dirname;for(let t=0;t<12;t++){const t=n.join(e,"node_modules","skills","package.json");if(a.existsSync(t))return n.dirname(t);const o=n.dirname(e);if(o===e)break;e=o}}();if(t){const o=e.safeJsonParse(a.readFileSync(n.join(t,"package.json"),"utf8")),i="string"==typeof _e([o,"optionalAccess",e=>e.bin])?o.bin:_e([o,"optionalAccess",e=>e.bin,"optionalAccess",e=>e.skills]);if(i)return be={cmd:process.execPath,prefix:[n.join(t,i)]},be}return be={cmd:"skills",prefix:[]},be}function we(e){const{cmd:t,prefix:o}=ve(),s=i.spawnSync(t,[...o,...e],{encoding:"utf8"});return{ok:0===s.status,stdout:fe(s.stdout,(()=>"")),stderr:fe(s.stderr,(()=>"")),code:s.status}}function Ee(e,t={}){const o=["add",e];return t.global&&o.push("-g"),t.yes&&o.push("-y"),t.agents&&t.agents.length>0&&o.push("-a",...t.agents),we(o)}function Ce(e,t={}){const o=["remove",e];return t.global&&o.push("-g"),o.push("-y"),we(o)}function Ie(t={}){const o=["ls","--json"];t.global&&o.push("-g");const i=we(o);if(!i.ok)return[];const s=e.safeJsonParse(i.stdout);return Array.isArray(s)?s:[]}function Ae(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}function Se(){return s.getGlobalSkillLockFile()}async function ke(e){try{return await r.access(e),!0}catch(e){return!1}}async function je(){let t=__dirname;for(let o=0;o<12;o++){const o=n.join(t,"package.json");if(await ke(o)){if("@coze/cli"===Ae([e.safeJsonParse(await r.readFile(o,"utf8")),"optionalAccess",e=>e.name]))return t}const i=n.dirname(t);if(i===t)break;t=i}return n.resolve(__dirname,"..")}async function Pe(){return n.join(await je(),"skills")}async function ze(){return n.join(await je(),"docs","skills")}const Te=new Set(["SKILL.md","MODULE.md"]);function Re(e){return`sha256:${c.createHash("sha256").update(e,"utf8").digest("hex")}`}function xe(e){return Te.has(n.basename(e))}async function Le(e,t=e){const o=await r.readdir(e,{withFileTypes:!0}),i=[];for(const s of o){if(s.name.startsWith("."))continue;const o=n.join(e,s.name);s.isDirectory()?i.push(...await Le(o,t)):s.isFile()&&i.push(n.relative(t,o).split(n.sep).join("/"))}return i.sort()}function Oe(e,t){const o=Ue(e);if(void 0===o)return;const i=new RegExp(`^${t}:\\s*(.+?)\\s*$`,"m"),s=o.match(i);return s?s[1].replace(/^['"]|['"]$/g,"").trim():void 0}function De(e,t){const o=Ue(e);if(void 0===o)return e;const i=`version: ${t}`;let s;return s=/^version:\s*.+$/m.test(o)?o.replace(/^version:\s*.+$/m,i):/^name:\s*.+$/m.test(o)?o.replace(/^(name:\s*.+)$/m,`$1\n${i}`):`${i}\n${o}`,e.replace(o,s)}function Ue(e){if(!e.startsWith("---"))return;const t=e.match(/^---\n([\s\S]*?)\n---/);return t?t[1]:void 0}function qe(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}async function Be(){const e=await Pe();if(await ke(n.join(e,"manifest.json")))return{root:e,source:"bundled"};const t=await ze();if(await ke(t))return{root:t,source:"docs"};throw new Error(`未找到 skill 来源:既无包内 ${e}/manifest.json,也无开发态 ${t}。`)}async function Me(){const t=n.join(await je(),"package.json"),o=e.safeJsonParse(await r.readFile(t,"utf8"));return i=qe([o,"optionalAccess",e=>e.version]),s=()=>"0.0.0",null!=i?i:s();var i,s}async function Ne(){const t=await Pe(),o=n.join(t,"manifest.json");if(await ke(o)){const i=e.safeJsonParse(await r.readFile(o,"utf8")),s=(await Le(t)).filter((e=>"manifest.json"!==e)),a=[];for(const e of s)a.push({rel:e,content:await r.readFile(n.join(t,e),"utf8")});return{manifest:i,files:a,source:"bundled"}}const i=await ze();if(!await ke(i))throw new Error(`未找到 skill 来源:既无包内 ${o},也无开发态 ${i}。`);const s=await Me(),{manifest:a,files:c}=await async function(e,t){const o=await Le(e),i=[],s={};for(const l of o){const o=await r.readFile(n.join(e,l),"utf8"),d=xe(l),p=d?De(o,t):o;i.push({rel:l,content:p}),d&&(s[(a=Oe(p,"name"),c=()=>l,null!=a?a:c())]={path:l,hash:Re(p)})}var a,c;return{manifest:{cliVersion:t,skills:s},files:i}}(i,s);return{manifest:a,files:c,source:"docs"}}async function $e(){try{const t=await r.readFile(Se(),"utf8");return e.safeJsonParse(t)}catch(e){return}}function Ge(e,t){return null!=e?e:t()}function Fe(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}async function Ve(e){try{return Re(await r.readFile(e,"utf8"))}catch(e){return}}function We(e){return[...new Set(Object.values(e.skills).map((e=>e.path.split("/")[0])))]}function He(e){return e[0]?n.dirname(e[0].path):void 0}async function Je(e={}){const{manifest:t}=await Ne(),{root:o}=await Be(),i=We(t),s=await $e(),a=Ie({global:!0}),c=await async function(e,t,o){const i=He(t);if(!i)return[];const s=new Set(t.map((e=>e.name))),r=[];for(const[t,a]of Object.entries(e.skills)){const e=a.path.split("/")[0];if(!s.has(e))continue;const c=await Ve(n.join(i,a.path));if(void 0===c)continue;if(c===a.hash)continue;const l=Fe([o,"optionalAccess",e=>e.skills,"access",e=>e[t],"optionalAccess",e=>e.hash]);void 0!==l&&c===l||r.push(t)}return r}(t,a,s);if(c.length>0&&!e.force)return{blocked:!0,cliVersion:t.cliVersion,sourceRoot:o,linkedTargets:[],skillsOk:!1,unknownTargets:[],modifiedSkills:c};const l=e.targets&&e.targets.length>0&&!e.targets.includes("all")?Ge(e.targets,(()=>[])).map((e=>fe(ye[e],(()=>e)))):void 0;let d=!0;for(const e of i){Ee(n.join(o,e),{global:!0,yes:!0,agents:l}).ok||(d=!1)}const p=Ie({global:!0}),u=p.filter((e=>i.includes(e.name))),m=Fe([u,"access",e=>e[0],"optionalAccess",e=>e.path]),g=[...new Set(u.flatMap((e=>e.agents)))],h=(new Date).toISOString(),f=He(p),_={};for(const[e,o]of Object.entries(t.skills)){const t=f?await Ve(n.join(f,o.path)):void 0;_[e]={hash:Ge(t,(()=>o.hash)),expectedHash:o.hash,installedAt:h}}return await async function(e){const t=Se();await r.mkdir(n.dirname(t),{recursive:!0}),await r.writeFile(t,`${JSON.stringify(e,null,2)}\n`,"utf8")}({version:1,cliVersion:t.cliVersion,installedBin:Ge(process.argv[1],(()=>process.execPath)),poolPath:m,targets:g,skills:_}),{blocked:!1,cliVersion:t.cliVersion,sourceRoot:o,poolPath:m,linkedTargets:g,skillsOk:d,unknownTargets:[],modifiedSkills:[]}}function Ke(e,t,o){return void 0===e?"missing":e===t?"ok":o===e?"drift":"modified"}async function Qe(){const{manifest:e}=await Ne(),t=await $e(),o=Ge(process.argv[1],(()=>process.execPath)),i=Ie({global:!0}),s=He(i),r=new Set(i.map((e=>e.name))),a=[];for(const[o,i]of Object.entries(e.skills)){const e=i.path.split("/")[0],c=Boolean(s)&&r.has(e),l=c?await Ve(n.join(s,i.path)):void 0,d=c?Ke(l,i.hash,Fe([t,"optionalAccess",e=>e.skills,"access",e=>e[o],"optionalAccess",e=>e.hash])):"missing";a.push({name:o,path:i.path,state:d})}const c=Fe([i,"access",e=>e.find,"call",e=>e((e=>r.has(e.name))),"optionalAccess",e=>e.path]);return{lockExists:Boolean(t),cliVersion:e.cliVersion,installedVersion:Fe([t,"optionalAccess",e=>e.cliVersion]),versionMatch:Boolean(t)&&Fe([t,"optionalAccess",e=>e.cliVersion])===e.cliVersion,installedBin:Fe([t,"optionalAccess",e=>e.installedBin]),currentBin:o,binMatch:!Fe([t,"optionalAccess",e=>e.installedBin])||t.installedBin===o,poolPath:c,targets:Ge(Fe([t,"optionalAccess",e=>e.targets]),(()=>[])),skills:a}}async function Ye(){const{manifest:e}=await Ne(),t=We(e),o=Ie({global:!0}),i=[];for(const e of t){const t=o.find((t=>t.name===e));if(!t)continue;Ce(e,{global:!0}).ok&&i.push({name:e,agents:t.agents})}return await async function(){await r.rm(Se(),{force:!0})}(),{removed:i}}async function Ze(){const t=await async function(){const t=n.join(await Pe(),"manifest.json");if(await ke(t)){const o=e.safeJsonParse(await r.readFile(t,"utf8"));if(qe([o,"optionalAccess",e=>e.cliVersion]))return o.cliVersion}return Me()}(),o=await $e();return o?o.cliVersion!==t?{state:"mismatch",cliVersion:t,installedVersion:o.cliVersion,message:`Skills (${o.cliVersion}) are out of sync with CLI (${t}). Run \`coze self skill install\`.`}:{state:"ok",cliVersion:t,installedVersion:o.cliVersion}:{state:"missing",cliVersion:t,message:"Bundled skills not installed yet. Run `coze self skill install` to sync them to your AI tools."}}function Xe(e){const t={};let o;const i=[];let s=!1;for(let n=0;n<e.length;n++){const r=e[n];if("--help"!==r&&"-h"!==r)if("--version"!==r&&"-v"!==r)if("--output"!==r)if("--format"!==r)"--no-color"!==r?"--config"!==r?"--org-id"!==r?"--space-id"!==r?"--verbose"!==r?"--debug"!==r?"--log-file"!==r?"--print-logs"!==r?s||r.startsWith("-")?i.push(r):(o=r,s=!0):t.printLogs=!0:t.logFile=e[++n]:t.debug=!0:t.verbose=!0:t.spaceId=e[++n]:t.orgId=e[++n]:t.config=e[++n]:t.noColor=!0;else{const o=e[++n];"json"!==o&&"text"!==o||(t.format=o)}else t.output=e[++n];else t.version=!0;else t.help=!0}return{globalOptions:t,commandName:o,commandArgs:i}}function et(e,t){return null!=e?e:t()}function ot(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}async function it(e,t){const i=await async function(e){if("self"===Xe(e.argv).commandName)return;const t=function(e){const t=function(e){let t,o=e[0],i=1;for(;i<e.length;){const s=e[i],n=e[i+1];if(i+=2,("optionalAccess"===s||"optionalCall"===s)&&null==o)return;"access"===s||"optionalAccess"===s?(t=o,o=n(o)):"call"!==s&&"optionalCall"!==s||(o=n(((...e)=>o.call(t,...e))),t=void 0)}return o}([e,"access",e=>e.skill,"optionalAccess",e=>e.mode]);return"auto"===t||"notify"===t||"off"===t?t:"auto"}(e.config);if("off"===t)return;if(function(){const e=et(process.env.CI,(()=>"")).toLowerCase();return""!==e&&"false"!==e&&"0"!==e||Boolean(process.env.COZE_CLI_NO_SKILL_NOTIFIER)}())return;try{const o=await Ze();if("ok"===o.state)return;if("auto"===t&&await async function(e){if("mismatch"!==e.state&&"missing"!==e.state)return!1;try{return!(await Je({})).blocked}catch(e){return!1}}(o))return;return"json"===e.format&&e.response.setNotice({skill:{state:o.state,cliVersion:o.cliVersion,installedVersion:o.installedVersion,message:o.message,command:"coze self skill install"}}),o}catch(e){return}}(e),s=await async function(e){if("upgrade"===Xe(e.argv).commandName)return;if(pe())return;const t=ue(e.config);if("off"===t)return;const o=ot([e,"access",e=>e.config,"access",e=>e.upgrade,"optionalAccess",e=>e.cache]),i=ot([o,"optionalAccess",e=>e.latestVersion]);if(!i)return;if(et(o.channel,(()=>"latest"))!==me(e.config))return;const s=ne();if(!le(s,i))return;const n=o.lastAttempt,r="number"==typeof n&&Date.now()-n<se;let a;"auto"===("auto"===t&&de(s,i)?"notify":t)?r?a=`Auto-upgrade to ${i} did not take effect (current ${s}). Run \`coze upgrade\` manually; on an internal network verify your npm registry.`:(a=`Coze CLI ${i} available (current ${s}). Upgrading in the background; it will take effect on next run.`,he(e,i)):a=`Coze CLI ${i} available (current ${s}). Run \`coze upgrade\` to update.`;"json"===e.format&&e.response.setNotice({update:{current:s,latest:i,message:a,command:"coze upgrade"}});return{current:s,latest:i,message:a}}(e);await t(),function(e,t){if(!ot([t,"optionalAccess",e=>e.message]))return;if("json"===e.format)return void(e.response.hasPendingNotice()&&process.stderr.write(`${t.message}\n`));e.ui.info(`\n${t.message}\n`)}(e,i),function(e,t){if(!t)return;if("json"===e.format)return void(e.response.hasPendingNotice()&&process.stderr.write(`${t.message}\n`));e.ui.info(`\n${o.gray(t.current)} → ${o.green(t.latest)} ${t.message}\n`)}(e,s),async function(e){if("upgrade"===Xe(e.argv).commandName)return;if(pe())return;const t=ue(e.config);if("off"===t)return;try{const o=await ge(e,!1,me(e.config));o.hasUpdate&&"auto"===t&&!de(o.currentVersion,o.latestVersion)&&await he(e,o.latestVersion)}catch(e){}}(e)}var st=e.requireSrc();const nt=e.getDefaultExportFromCjs(st);function rt(e){var t,o,i=e.transport,s=e.endpoint,n=e.size,r=void 0===n?10:n,a=e.wait,c=void 0===a?1e3:a,l=[],d=0;function p(){if(l.length){var e=this.getBatchData();i.post({url:s,data:e,fail:function(o){t&&t(o,e)},success:function(){o&&o(e)}}),l=[]}}return{getSize:function(){return r},getWait:function(){return c},setSize:function(e){r=e},setWait:function(e){c=e},getEndpoint:function(){return s},setEndpoint:function(e){s=e},send:function(e){l.push(e),l.length>=r&&p.call(this),clearTimeout(d),d=setTimeout(p.bind(this),c)},flush:function(){clearTimeout(d),p.call(this)},getBatchData:function(){return l.length?(e=l,JSON.stringify({ev_type:"batch",list:e})):"";var e},clear:function(){clearTimeout(d),l=[]},fail:function(e){t=e},success:function(e){o=e}}}
3
3
  /*! *****************************************************************************
4
4
  Copyright (c) Microsoft Corporation.
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze/cli",
3
- "version": "0.3.1-alpha.103a11",
3
+ "version": "0.3.1-alpha.920ba1",
4
4
  "private": false,
5
5
  "description": "Coze CLI - A command-line interface for Coze platform",
6
6
  "license": "MIT",
@@ -1,25 +1,25 @@
1
1
  {
2
- "cliVersion": "0.3.1-alpha.103a11",
2
+ "cliVersion": "0.3.1-alpha.920ba1",
3
3
  "skills": {
4
4
  "using-coze-cli": {
5
5
  "path": "using-coze-cli/SKILL.md",
6
- "hash": "sha256:a8ed8ffdc19d1df3f6cf757775becda954730ee83287c751c4530a5386c736da"
6
+ "hash": "sha256:367830e19330708c87c036b2713ad2552a2e9cce00fa57c0c09f277fbf6771f0"
7
7
  },
8
8
  "coze-claw": {
9
9
  "path": "using-coze-cli/coze-claw/MODULE.md",
10
- "hash": "sha256:65d6eccb106c3c962faf77ea5d4c77a13996d20470d0145321e9ad9b77dc3b9f"
10
+ "hash": "sha256:0763b5da5ab0bf44d7115fc859cdfd08dc533bceddd055ffaa13d8b250710f6f"
11
11
  },
12
12
  "coze-code": {
13
13
  "path": "using-coze-cli/coze-code/MODULE.md",
14
- "hash": "sha256:6f6bc563a1cb0606c35e570ebf75055366103edc785bfc302bd7c63ac75c48d9"
14
+ "hash": "sha256:6bc8f59bf8e2ff3e1ff9766ff6a26f7fad9ec27015f1dadca09fb6820b13c343"
15
15
  },
16
16
  "coze-file": {
17
17
  "path": "using-coze-cli/coze-file/MODULE.md",
18
- "hash": "sha256:98dec0d8235dd8b9ab535debacd3d9cb58f1e7aa21ae3d5a6ed0010292a217eb"
18
+ "hash": "sha256:572f8049c4eed2b8a1f0dca5c02104dfa2a9712a6a4e2c6e0e750b312652623f"
19
19
  },
20
20
  "coze-generate": {
21
21
  "path": "using-coze-cli/coze-generate/MODULE.md",
22
- "hash": "sha256:4564dd1195ae237b5b04a0583f6f8d55035486a0048e3352013388dc65108e11"
22
+ "hash": "sha256:47f9b89e76768f8c04df874e0542fc64d31e1aa62849feeab37337f914277c1c"
23
23
  }
24
24
  }
25
25
  }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: using-coze-cli
3
- version: 0.3.1-alpha.103a11
3
+ version: 0.3.1-alpha.920ba1
4
4
  description: "Coze CLI(coze 命令)统一入口与共享基础,使用任何 coze 能力前必读(登录授权、组织/空间、配置、错误码与权限排查)。四个子模块:coze code(创建/迭代网页·App·小程序·Agent·工作流等编程项目、发需求、预览、部署、环境变量/域名/数据库)、coze session(Claw 对话、PPT、播客、长任务产物)、coze generate(图片/语音 TTS/视频生成)、coze file(本地文件转在线链接)。触发场景(满足任一即触发,无需用户显式点名 coze):想做网页/App/小程序、开发或迭代项目、上线部署;生成图片/语音/视频;做 PPT/播客;把本地文件转成在线链接;登录授权/No permission/切换组织空间;输入以 /coze-cli、/coze 开头(前缀仅作路由)。"
5
5
  metadata:
6
6
  requires:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: coze-claw
3
- version: 0.3.1-alpha.103a11
3
+ version: 0.3.1-alpha.920ba1
4
4
  description: "Coze Claw Session 会话工作流:创建/找回 claw session、发送 session message、监听回复、查询后台 progress、处理文件/PPT/播客产物。当用户需要使用 coze session * 任意命令时触发。"
5
5
  metadata:
6
6
  requires:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: coze-code
3
- version: 0.3.1-alpha.103a11
3
+ version: 0.3.1-alpha.920ba1
4
4
  description: "Coze Coding 项目开发工作流:创建项目、发送需求消息、查询状态、预览、部署、环境变量管理、域名管理、技能管理、数据库管理。当用户需要创建/管理 Coze 项目、发送开发需求、部署应用、管理数据库、或使用 coze code * 任意命令时触发。"
5
5
  metadata:
6
6
  requires:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: coze-file
3
- version: 0.3.1-alpha.103a11
3
+ version: 0.3.1-alpha.920ba1
4
4
  description: "Coze 文件操作:上传本地文件获取在线访问地址。当用户需要上传文件、或将本地生成的文件转换为在线可访问链接时触发。"
5
5
  metadata:
6
6
  requires:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: coze-generate
3
- version: 0.3.1-alpha.103a11
3
+ version: 0.3.1-alpha.920ba1
4
4
  description: "Coze 媒体生成:文本生成图片、文本转语音(TTS)、视频生成。当用户需要使用 coze generate image/audio/video 生成音频、图片或视频时触发。"
5
5
  metadata:
6
6
  requires: