@lzg14/deepseek-cli 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ds.js +28 -28
- package/package.json +1 -1
package/dist/ds.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`);
|
|
4
|
-
`)}finally{clearTimeout(
|
|
5
|
-
`+
|
|
6
|
-
`),
|
|
7
|
-
`),process.exit(1));let
|
|
2
|
+
var ue=Object.defineProperty;var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var he=(t,e)=>{for(var o in e)ue(t,o,{get:e[o],enumerable:!0})};function O(t,e){let o={};for(let n=0;n<t.length;n++){let r=t[n];if(r==="--"){o._positional=t.slice(n+1);break}if(!r.startsWith("-")){o._positional||(o._positional=[]),o._positional.push(r);continue}let s=r.indexOf("=");if(s!==-1){let c=r.slice(0,s),m=r.slice(s+1);o[c.replace(/^--/,"").replace(/-/g,"_")]=m;continue}let i=r.replace(/^--/,"").replace(/-/g,"_"),a=e.find(c=>{let m=c.flag.split(" ")[0];return m===r||m===`--${i.replace(/_/g,"-")}`}),p=a?.flag.includes(" <")||a?.flag.includes(" ["),l=t[n+1];p&&l&&!l.startsWith("-")?(o[i]=l,n++):o[i]=!0}return o}function M(t,e){let o=[];for(let n of t){if(n.startsWith("-")||n==="--")break;o.push(n)}return o}function h(t){return t.base_url||t.baseUrl||"https://api.ds.com"}var b=f(()=>{"use strict"});var x,I=f(()=>{"use strict";x=class extends Error{code;suggestion;fields;constructor(e,o=1,n,r){super(e),this.name="CLIError",this.code=o,this.suggestion=n,this.fields=r}}});var w,P=f(()=>{"use strict";w={SUCCESS:0,USAGE:1,CONFIG:2,AUTH:3,NETWORK:4,API:5,TIMEOUT:6,ABORT:7,UNKNOWN:99}});var A,T=f(()=>{"use strict";A="0.1.6"});function d(t){return{name:t.name,description:t.description,usage:t.usage,options:t.options,examples:t.examples,apiDocs:t.apiDocs,execute:t.run}}var v,g=f(()=>{"use strict";v=[{flag:"--api-key <key>",description:"ds API key"},{flag:"--base-url <url>",description:"API base URL"},{flag:"--output <format>",description:"Output format: text, json"},{flag:"--timeout <seconds>",description:"Request timeout",type:"number"},{flag:"--quiet",description:"Suppress non-essential output"},{flag:"--verbose",description:"Print HTTP request/response details"},{flag:"--no-color",description:"Disable ANSI colors"},{flag:"--dry-run",description:"Dry run mode"},{flag:"--non-interactive",description:"Disable interactive prompts"},{flag:"--help",description:"Show help"},{flag:"--version",description:"Print version"}]});async function ye(t,e,o,n,r){let s=new AbortController,i=setTimeout(()=>s.abort(),n*1e3);try{let a=await fetch(`${t}/chat/completions`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(o),signal:s.signal});if(clearTimeout(i),!a.ok){let m=await a.text();throw new Error(`API error ${a.status}: ${m}`)}if(!a.body)throw new Error("No response body");let p=a.body.getReader(),l=new TextDecoder,c="";for(;;){let{done:m,value:u}=await p.read();if(m)break;c+=l.decode(u,{stream:!0});let k=c.split(`
|
|
3
|
+
`);c=k.pop()||"";for(let N of k)if(N.startsWith("data: ")){let _=N.slice(6);if(_==="[DONE]")continue;try{let S=JSON.parse(_).choices?.[0]?.delta?.content;S&&process.stdout.write(S)}catch{}}}process.stdout.write(`
|
|
4
|
+
`)}finally{clearTimeout(i)}}async function be(t,e,o,n,r){let s=new AbortController,i=setTimeout(()=>s.abort(),n*1e3);try{let a=await fetch(`${t}/chat/completions`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({...o,stream:!1}),signal:s.signal});if(clearTimeout(i),!a.ok){let c=await a.text();throw new Error(`API error ${a.status}: ${c}`)}let l=(await a.json()).choices?.[0]?.message;l?.reasoning_content&&r.verbose&&console.log(`[Reasoning]:
|
|
5
|
+
`+l.reasoning_content+`
|
|
6
|
+
`),l?.content&&console.log(l.content)}finally{clearTimeout(i)}}var B,H=f(()=>{"use strict";g();b();B=d({name:"chat",description:"Chat with DeepSeek models",usage:"ds chat [options] [message]",examples:['ds chat "Hello, who are you?"','ds chat --model deepseek-v4-flash "Explain quantum computing"',"ds chat --no-stream"],options:[{flag:"--model <model>",description:"Model to use (deepseek-chat, deepseek-v4-flash)"},{flag:"--system <text>",description:"System prompt"},{flag:"--think",description:"Enable reasoning mode"},{flag:"--no-think",description:"Disable reasoning mode"},{flag:"--thinking-effort <0-10>",description:"Reasoning effort level"},{flag:"--stream",description:"Enable streaming (default)"},{flag:"--no-stream",description:"Disable streaming"},{flag:"--temperature <number>",description:"Temperature (0-2)"},{flag:"--max-tokens <n>",description:"Max output tokens"},{flag:"--json",description:"Request JSON mode"},{flag:"--timeout <seconds>",description:"Request timeout"}],run:async(t,e)=>{let o=h(t),n=t.apiKey;if(!n)throw new Error("No API key. Set ds_API_KEY or run ds auth login");let r=e.model||t.model||"deepseek-chat",s=[];e.system&&s.push({role:"system",content:e.system});let i=e._positional||[];i.length>0&&s.push({role:"user",content:i.join(" ")}),s.length===0&&(process.stderr.write(`Error: No message provided. Usage: ds chat <message>
|
|
7
|
+
`),process.exit(1));let a=e.stream!==!1&&e.no_stream===void 0,p=e.think!==void 0?!!e.think:t.thinking,l={model:r,messages:s,stream:a};e.temperature!==void 0&&(l.temperature=parseFloat(e.temperature)),e.max_tokens!==void 0&&(l.max_tokens=parseInt(e.max_tokens)),e.json&&(l.response_format={type:"json_object"});let c=e.timeout||t.timeout||120;if(e.dry_run){console.log(`[Dry run] POST ${o}/chat/completions`),console.log(JSON.stringify(l,null,2));return}a?await ye(o,n,l,c,e):await be(o,n,l,c,e)}})});var Y,q=f(()=>{"use strict";g();b();Y=d({name:"models",description:"List available DeepSeek models",usage:"ds models [flags]",examples:["ds models","ds models --json"],options:[{flag:"--json",description:"Output in JSON format"}],run:async(t,e)=>{let o=h(t),n=t.apiKey;if(!n)throw new Error("No API key. Set ds_API_KEY or run ds auth login");if(e.dry_run){console.log(`[Dry run] GET ${o}/models`);return}let r=new AbortController,s=e.timeout||t.timeout||30,i=setTimeout(()=>r.abort(),s*1e3);try{let a=await fetch(`${o}/models`,{method:"GET",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},signal:r.signal});if(clearTimeout(i),!a.ok){let c=await a.text();throw new Error(`API error ${a.status}: ${c}`)}let p=await a.json();if(e.json){console.log(JSON.stringify(p,null,2));return}let l=p.data||[];console.log(`
|
|
8
8
|
Available ds Models:
|
|
9
|
-
`);for(let
|
|
9
|
+
`);for(let c of l){let m=c.created?new Date(c.created*1e3).toLocaleDateString():"";console.log(` ${c.id} ${c.object} ${m}`),c.owned_by&&console.log(` Owned by: ${c.owned_by}`)}console.log("")}finally{clearTimeout(i)}}})});var z,V=f(()=>{"use strict";g();b();z=d({name:"balance",description:"Check ds account balance",usage:"ds balance [flags]",examples:["ds balance","ds balance --json"],options:[{flag:"--json",description:"Output in JSON format"}],run:async(t,e)=>{let o=h(t),n=t.apiKey;if(!n)throw new Error("No API key. Set ds_API_KEY or run ds auth login");if(e.dry_run){console.log(`[Dry run] GET ${o}/user/balance`);return}let r=new AbortController,s=e.timeout||t.timeout||30,i=setTimeout(()=>r.abort(),s*1e3);try{let a=await fetch(`${o}/user/balance`,{method:"GET",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},signal:r.signal});if(clearTimeout(i),!a.ok){let c=await a.text();throw new Error(`API error ${a.status}: ${c}`)}let p=await a.json();if(e.json){console.log(JSON.stringify(p,null,2));return}let l=p.balance_infos||[];if(l.length===0){console.log(`
|
|
10
10
|
No balance information available.
|
|
11
11
|
`);return}console.log(`
|
|
12
12
|
ds Account Balance:
|
|
13
|
-
`);for(let
|
|
14
|
-
`),process.exit(1));let
|
|
15
|
-
`);for(let
|
|
16
|
-
`)}else{let
|
|
13
|
+
`);for(let c of l){let m=c.currency||"CNY",u=c.total_balance??c.balance??"N/A";console.log(` ${c.model||"Account"}: ${u} ${m}`)}console.log("")}finally{clearTimeout(i)}}})});var X,Q=f(()=>{"use strict";g();b();X=d({name:"complete",description:"FIM code completion (Beta)",usage:"ds complete [flags] [--prompt <prefix>] [--suffix <suffix>]",examples:['ds complete --prompt "fn main()"','ds complete --prompt "class MyClass" --suffix "}"','ds complete --model deepseek-coder --prompt "import"'],options:[{flag:"--model <model>",description:"Model to use (default: deepseek-coder)"},{flag:"--prompt <text>",description:"Prefix text"},{flag:"--suffix <text>",description:"Suffix text"},{flag:"--max-tokens <n>",description:"Max output tokens"},{flag:"--temperature <number>",description:"Temperature (0-2)"},{flag:"--stream",description:"Enable streaming"},{flag:"--no-stream",description:"Disable streaming"}],run:async(t,e)=>{let o=h(t),n=t.apiKey;if(!n)throw new Error("No API key. Set ds_API_KEY or run ds auth login");let r=e.model||"deepseek-coder";if(e.dry_run){console.log(`[Dry run] POST ${o}/completions`);return}let s={model:r,stream:e.stream!==!1&&e.no_stream===void 0};e.prompt&&(s.prompt=e.prompt),e.suffix&&(s.suffix=e.suffix),e.max_tokens!==void 0&&(s.max_tokens=parseInt(e.max_tokens)),e.temperature!==void 0&&(s.temperature=parseFloat(e.temperature)),s.prompt||(process.stderr.write(`Error: --prompt is required for FIM completion
|
|
14
|
+
`),process.exit(1));let i=new AbortController,a=e.timeout||t.timeout||60,p=setTimeout(()=>i.abort(),a*1e3);try{let l=await fetch(`${o}/completions`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify(s),signal:i.signal});if(clearTimeout(p),!l.ok){let m=await l.text();throw new Error(`API error ${l.status}: ${m}`)}if(s.stream){if(!l.body)throw new Error("No response body");let m=l.body.getReader(),u=new TextDecoder,k="";for(;;){let{done:N,value:_}=await m.read();if(N)break;let G=u.decode(_,{stream:!0});k+=G;let S=k.split(`
|
|
15
|
+
`);k=S.pop()||"";for(let ge of S){let j=ge.trim();if(j.startsWith("data:")){let L=j.slice(5).trim();if(L==="[DONE]")continue;try{let J=JSON.parse(L),W=J.choices?.[0]?.delta?.content||J.choices?.[0]?.text;W&&process.stdout.write(W)}catch{}}}}process.stdout.write(`
|
|
16
|
+
`)}else{let m=await l.json(),u=m.choices?.[0]?.text||m.choices?.[0]?.message?.content;u&&console.log(u)}}finally{clearTimeout(p)}}})});import{readFileSync as xe,writeFileSync as we,existsSync as Z,mkdirSync as Ce}from"fs";import{homedir as ke}from"os";import{join as ee}from"path";function y(){if(!Z(K))return{};try{let t=xe(K,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}catch{return{}}}function C(t){Z(F)||Ce(F,{recursive:!0}),we(K,JSON.stringify(t,null,2),"utf-8")}function U(t){let e=y();return{apiKey:t.api_key||e.apiKey||process.env.DEEPSEEK_API_KEY,baseUrl:t.base_url||e.baseUrl||"https://api.ds.com",model:t.model||e.model||"deepseek-chat",output:t.output||e.output||"text",timeout:t.timeout||e.timeout,proxy:e.proxy||process.env.HTTPS_PROXY||process.env.HTTP_PROXY,thinking:t.thinking!==void 0?!!t.thinking:e.thinking,thinkingEffort:t.thinking_effort||e.thinkingEffort||3,stream:t.stream!==void 0?!!t.stream:!0}}var F,K,$=f(()=>{"use strict";F=ee(ke(),".seek"),K=ee(F,"config.json")});import*as oe from"readline";var te,ne=f(()=>{"use strict";g();$();b();te=d({name:"auth login",description:"Login with ds API key",usage:"ds auth login [flags]",examples:["ds auth login","ds auth login --key sk-xxxxx"],options:[{flag:"--key <api-key>",description:"API key (or enter interactively)"},{flag:"--base-url <url>",description:"API base URL"}],run:async(t,e)=>{let o=e.key;if(!o){let n=oe.createInterface({input:process.stdin,output:process.stderr});o=await new Promise(r=>{n.question("Enter your ds API key: ",s=>{n.close(),r(s.trim())})})}if(o||(process.stderr.write(`Error: API key is required
|
|
17
17
|
`),process.exit(1)),e.dry_run){console.log(`[Dry run] Would save API key: ${o.slice(0,8)}...`);return}e.base_url?C({...t,apiKey:o,baseUrl:e.base_url}):C({...t,apiKey:o,baseUrl:h(t)}),console.log("[OK] API key saved successfully"),e.base_url&&console.log(` Base URL: ${e.base_url}`),console.log(` Run "ds models" to verify your credentials.
|
|
18
|
-
`)}})});var
|
|
18
|
+
`)}})});var re,se=f(()=>{"use strict";g();$();re=d({name:"auth logout",description:"Logout and remove stored credentials",usage:"ds auth logout",examples:["ds auth logout"],run:async(t,e)=>{if(e.dry_run){console.log("[Dry run] Would remove stored API key");return}let o=y();if(!o.apiKey&&!o.baseUrl){console.log(`No credentials stored.
|
|
19
19
|
`);return}C({}),console.log(`[OK] Logged out successfully.
|
|
20
|
-
`)}})});var
|
|
20
|
+
`)}})});var ie,ae=f(()=>{"use strict";g();$();ie=d({name:"config show",description:"Show current configuration",usage:"ds config show [flags]",examples:["ds config show","ds config show --json"],options:[{flag:"--json",description:"Output in JSON format"}],run:async(t,e)=>{let o=y();if(e.json){let n={...o};n.apiKey&&(n.apiKey=n.apiKey.slice(0,8)+"..."),console.log(JSON.stringify(n,null,2));return}console.log(`
|
|
21
21
|
ds configuration:
|
|
22
|
-
`),console.log(` API Key: ${o.apiKey?o.apiKey.slice(0,8)+"...":"(not set)"}`),console.log(` Base URL: ${o.baseUrl||"https://api.ds.com (default)"}`),console.log(` Model: ${o.model||"deepseek-chat (default)"}`),console.log(` Proxy: ${o.proxy||"(not set)"}`),console.log(""),console.log(" Environment variables:"),console.log(" DEEPSEEK_API_KEY -> API key"),console.log(" HTTPS_PROXY -> Proxy URL"),console.log(" HTTP_PROXY -> Proxy URL"),console.log("")}})});var
|
|
23
|
-
`),process.exit(1));let s=r.join(" "),
|
|
24
|
-
`)}})});var
|
|
22
|
+
`),console.log(` API Key: ${o.apiKey?o.apiKey.slice(0,8)+"...":"(not set)"}`),console.log(` Base URL: ${o.baseUrl||"https://api.ds.com (default)"}`),console.log(` Model: ${o.model||"deepseek-chat (default)"}`),console.log(` Proxy: ${o.proxy||"(not set)"}`),console.log(""),console.log(" Environment variables:"),console.log(" DEEPSEEK_API_KEY -> API key"),console.log(" HTTPS_PROXY -> Proxy URL"),console.log(" HTTP_PROXY -> Proxy URL"),console.log("")}})});var le,ce=f(()=>{"use strict";g();$();le=d({name:"config set",description:"Set a configuration value",usage:"ds config set <key> <value>",examples:["ds config set model deepseek-chat","ds config set proxy http://localhost:7890"],run:async(t,e)=>{let o=e._positional||[],[n,...r]=o;(!n||r.length===0)&&(process.stderr.write(`Error: Usage: ds config set <key> <value>
|
|
23
|
+
`),process.exit(1));let s=r.join(" "),i=y(),p={model:"model","base-url":"baseUrl",base_url:"baseUrl",proxy:"proxy",timeout:"timeout",thinking:"thinking","thinking-effort":"thinkingEffort",thinking_effort:"thinkingEffort"}[n]||n;if(e.dry_run){console.log(`[Dry run] Would set ${p} = ${s}`);return}i[p]=s,C(i),console.log(`[OK] Set ${n} = ${s}
|
|
24
|
+
`)}})});var me,pe=f(()=>{"use strict";g();me=d({name:"help",description:"Show help information",usage:"ds help [command]",examples:["ds help","ds help chat","ds help models"],run:async(t,e)=>{let o=e._positional||[],{registry:n}=await Promise.resolve().then(()=>(R(),de));n.printHelp(o,process.stdout)}})});var de={};he(de,{registry:()=>E});var D,E,R=f(()=>{"use strict";I();P();T();H();q();V();Q();ne();se();ae();ce();pe();D=class{root={children:new Map};constructor(e){for(let[o,n]of Object.entries(e))this.register(o,n)}register(e,o){let n=e.split(" "),r=this.root;for(let s of n)r.children.has(s)||r.children.set(s,{children:new Map}),r=r.children.get(s);r.command=o}resolve(e){let o=this.root,n=[];for(let r of e){let s=o.children.get(r);if(!s)break;o=s,n.push(r)}if(o.command)return{command:o.command,extra:e.slice(n.length)};if(n.length>0&&o.children.size>0&&o.children.has("show")){let r=o.children.get("show");if(r.command)return{command:r.command,extra:e.slice(n.length+1)}}if(n.length>0&&o.children.size===1){let[,r]=o.children.entries().next().value;if(r.command)return{command:r.command,extra:e.slice(n.length)}}if(n.length>0&&o.children.size>0){let r=Array.from(o.children.entries()).map(([s,i])=>{if(i.command)return` ${n.join(" ")} ${s} ${i.command.description}`;let a=Array.from(i.children.keys()).join(", ");return` ${n.join(" ")} ${s} [${a}]`}).join(`
|
|
25
25
|
`);throw new x(`Unknown command: ds ${e.join(" ")}
|
|
26
26
|
|
|
27
27
|
Available commands:
|
|
28
|
-
${r}`,w.USAGE,`ds ${n.join(" ")} --help`)}throw new x(`Unknown command: ds ${e.join(" ")}`,w.USAGE,"ds --help")}bold=(e,o)=>o.isTTY?`\x1B[1m${e}\x1B[0m`:e;accent=(e,o)=>o.isTTY?`\x1B[38;2;103;58m${e}\x1B[0m`:e;dim=(e,o)=>o.isTTY?`\x1B[2m${e}\x1B[0m`:e;printHelp(e,o=process.stdout){if(e.length===0){this.printRootHelp(o);return}let n=this.root;for(let s of e){let
|
|
28
|
+
${r}`,w.USAGE,`ds ${n.join(" ")} --help`)}throw new x(`Unknown command: ds ${e.join(" ")}`,w.USAGE,"ds --help")}bold=(e,o)=>o.isTTY?`\x1B[1m${e}\x1B[0m`:e;accent=(e,o)=>o.isTTY?`\x1B[38;2;103;58m${e}\x1B[0m`:e;dim=(e,o)=>o.isTTY?`\x1B[2m${e}\x1B[0m`:e;printHelp(e,o=process.stdout){if(e.length===0){this.printRootHelp(o);return}let n=this.root;for(let s of e){let i=n.children.get(s);if(!i){this.printRootHelp(o);return}n=i}if(n.command){this.printCommandHelp(n.command,o);return}let r=e.join(" ");o.write(`
|
|
29
29
|
${this.bold("Usage:",o)} ds ${r} <command> [flags]
|
|
30
30
|
|
|
31
31
|
`),o.write(`${this.bold("Commands:",o)}
|
|
32
32
|
`),this.printChildren(n,r,o),o.write(`
|
|
33
33
|
`)}printRootHelp(e){let o=s=>this.bold(s,e),n=s=>this.accent(s,e),r=s=>this.dim(s,e);e.write(`
|
|
34
|
-
${o("ds")} ${n("v"+
|
|
34
|
+
${o("ds")} ${n("v"+A)} Deepseek CLI
|
|
35
35
|
|
|
36
36
|
${o("Usage:")} ds <command> [flags]
|
|
37
37
|
|
|
@@ -54,18 +54,18 @@ ${this.bold("Usage:",o)} ds ${r} <command> [flags]
|
|
|
54
54
|
${o("Getting Help:")}
|
|
55
55
|
${r("Add --help after any command.")}
|
|
56
56
|
${r("Example:")} ds chat --help
|
|
57
|
-
`)}printCommandHelp(e,o){let n=
|
|
57
|
+
`)}printCommandHelp(e,o){let n=i=>this.bold(i,o),r=i=>this.accent(i,o),s=i=>this.dim(i,o);if(o.write(`
|
|
58
58
|
${e.description}
|
|
59
59
|
`),e.usage&&o.write(`${n("Usage:")} ${e.usage}
|
|
60
|
-
`),e.options&&e.options.length>0){let
|
|
60
|
+
`),e.options&&e.options.length>0){let i=Math.max(...e.options.map(a=>a.flag.length));o.write(`
|
|
61
61
|
${n("Options:")}
|
|
62
|
-
`);for(let
|
|
62
|
+
`);for(let a of e.options)o.write(` ${r(a.flag.padEnd(i+2))} ${s(a.description)}
|
|
63
63
|
`)}if(e.examples&&e.examples.length>0){o.write(`
|
|
64
64
|
${n("Examples:")}
|
|
65
|
-
`);for(let
|
|
65
|
+
`);for(let i of e.examples)o.write(` ${s(i)}
|
|
66
66
|
`)}o.write(`
|
|
67
|
-
`)}printChildren(e,o,n){let r=[],s=(
|
|
68
|
-
`)}},E=new D({chat:
|
|
67
|
+
`)}printChildren(e,o,n){let r=[],s=(a,p)=>{for(let[l,c]of a.children)c.command&&r.push({fullName:`${p} ${l}`,description:c.command.description}),c.children.size>0&&s(c,`${p} ${l}`)};s(e,o);let i=Math.max(...r.map(a=>a.fullName.length));for(let{fullName:a,description:p}of r)n.write(` ${this.accent(a.padEnd(i),n)} ${this.dim(p,n)}
|
|
68
|
+
`)}},E=new D({chat:B,models:Y,balance:z,complete:X,"auth login":te,"auth logout":re,"config show":ie,"config set":le,help:me})});b();R();g();I();P();function fe(t){t instanceof x&&(t.suggestion?process.stderr.write(`
|
|
69
69
|
\x1B[1merror:\x1B[0m ${t.message}
|
|
70
70
|
|
|
71
71
|
-> ${t.suggestion}
|
|
@@ -78,10 +78,10 @@ ${n("Examples:")}
|
|
|
78
78
|
`),process.stderr.write(` -> Or set a proxy: ds config set proxy http://localhost:7890
|
|
79
79
|
`),process.exit(w.NETWORK)),process.exit(w.UNKNOWN)),process.stderr.write(`
|
|
80
80
|
\x1B[1merror:\x1B[0m ${String(t)}
|
|
81
|
-
`),process.exit(w.UNKNOWN)}$();
|
|
81
|
+
`),process.exit(w.UNKNOWN)}$();T();process.on("SIGINT",()=>{process.stderr.write(`
|
|
82
82
|
Interrupted. Exiting.
|
|
83
|
-
`),process.exitCode=130});process.stdout.on("error",()=>{});process.stderr.on("error",()=>{});var
|
|
83
|
+
`),process.exitCode=130});process.stdout.on("error",()=>{});process.stderr.on("error",()=>{});var $e=[["help"],["auth","logout"],["config","show"],["config","set"],["models"]];async function Ee(){let t=process.argv.slice(2);if(t.includes("--version")||t.includes("-v")){console.log(`ds ${A}`),process.exitCode=0;return}let e=M(t,v),o=y();if(t.includes("--help")||t.includes("-h")){E.printHelp(e,process.stderr),process.exitCode=0;return}if(e.length===0){if(E.printHelp([],process.stderr),!!o.apiKey){let{command:c}=E.resolve(["balance"]),m=O(t,[...v]),u=U(m);await c.execute(u,m)}else process.stderr.write(` Not logged in.
|
|
84
84
|
`),process.stderr.write(` ds auth login Login with your ds API key
|
|
85
85
|
|
|
86
|
-
`);process.exitCode=0;return}let{command:
|
|
87
|
-
`),process.exitCode=1;return}
|
|
86
|
+
`);process.exitCode=0;return}let{command:n,extra:r}=E.resolve(e),s=t.slice(e.length),i=O(s,[...v,...n.options??[]]);r.length>0&&(i._positional=r);let a=U(i);if(!$e.some(l=>l.every((c,m)=>e[m]===c))&&!a.apiKey){let l=process.env.DEEPSEEK_API_KEY;if(!l){process.stderr.write(`Error: No API key found. Run "ds auth login" or set DEEPSEEK_API_KEY env var.
|
|
87
|
+
`),process.exitCode=1;return}a.apiKey=l}await n.execute(a,i)}Ee().catch(fe);
|