@lzg14/deepseek-cli 0.1.1 → 0.1.3
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 +4 -4
- package/package.json +1 -1
package/dist/ds.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var fe=Object.defineProperty;var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var ge=(t,e)=>{for(var o in e)fe(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 l=r.slice(0,s),p=r.slice(s+1);o[l.replace(/^--/,"").replace(/-/g,"_")]=p;continue}let a=r.replace(/^--/,"").replace(/-/g,"_"),i=e.find(l=>{let p=l.flag.split(" ")[0];return p===r||p===`--${a.replace(/_/g,"-")}`}),m=i?.flag.includes(" <")||i?.flag.includes(" ["),c=t[n+1];m&&c&&!c.startsWith("-")?(o[a]=c,n++):o[a]=!0}return o}function W(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,T=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,I=f(()=>{"use strict";w={SUCCESS:0,USAGE:1,CONFIG:2,AUTH:3,NETWORK:4,API:5,TIMEOUT:6,ABORT:7,UNKNOWN:99}});var N,P=f(()=>{"use strict";N="0.1.
|
|
2
|
+
var fe=Object.defineProperty;var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var ge=(t,e)=>{for(var o in e)fe(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 l=r.slice(0,s),p=r.slice(s+1);o[l.replace(/^--/,"").replace(/-/g,"_")]=p;continue}let a=r.replace(/^--/,"").replace(/-/g,"_"),i=e.find(l=>{let p=l.flag.split(" ")[0];return p===r||p===`--${a.replace(/_/g,"-")}`}),m=i?.flag.includes(" <")||i?.flag.includes(" ["),c=t[n+1];m&&c&&!c.startsWith("-")?(o[a]=c,n++):o[a]=!0}return o}function W(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,T=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,I=f(()=>{"use strict";w={SUCCESS:0,USAGE:1,CONFIG:2,AUTH:3,NETWORK:4,API:5,TIMEOUT:6,ABORT:7,UNKNOWN:99}});var N,P=f(()=>{"use strict";N="0.1.3"});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 A,u=f(()=>{"use strict";A=[{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 ue(t,e,o,n,r){let s=new AbortController,a=setTimeout(()=>s.abort(),n*1e3);try{let i=await fetch(`${t}/chat/completions`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(o),signal:s.signal});if(clearTimeout(a),!i.ok){let p=await i.text();throw new Error(`API error ${i.status}: ${p}`)}if(!i.body)throw new Error("No response body");let m=i.body.getReader(),c=new TextDecoder,l="";for(;;){let{done:p,value:g}=await m.read();if(p)break;l+=c.decode(g,{stream:!0});let k=l.split(`
|
|
3
3
|
`);l=k.pop()||"";for(let E of k)if(E.startsWith("data: ")){let v=E.slice(6);if(v==="[DONE]")continue;try{let _=JSON.parse(v).choices?.[0]?.delta?.content;_&&process.stdout.write(_)}catch{}}}process.stdout.write(`
|
|
4
4
|
`)}finally{clearTimeout(a)}}async function he(t,e,o,n,r){let s=new AbortController,a=setTimeout(()=>s.abort(),n*1e3);try{let i=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(a),!i.ok){let l=await i.text();throw new Error(`API error ${i.status}: ${l}`)}let c=(await i.json()).choices?.[0]?.message;c?.reasoning_content&&r.verbose&&console.log(`[Reasoning]:
|
|
5
5
|
`+c.reasoning_content+`
|
|
@@ -80,8 +80,8 @@ ${n("Examples:")}
|
|
|
80
80
|
\x1B[1merror:\x1B[0m ${String(t)}
|
|
81
81
|
`),process.exit(w.UNKNOWN)}$();P();process.on("SIGINT",()=>{process.stderr.write(`
|
|
82
82
|
Interrupted. Exiting.
|
|
83
|
-
`),process.
|
|
83
|
+
`),process.exitCode=130});process.stdout.on("error",()=>{});process.stderr.on("error",()=>{});var Ce=[["auth","logout"],["config","show"],["config","set"],["models"]];async function ke(){let t=process.argv.slice(2);if(t.includes("--version")||t.includes("-v")){console.log(`ds ${N}`),process.exitCode=0;return}let e=W(t,A),o=y(),n=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||o.proxy;if(t.includes("--help")||t.includes("-h")){S.printHelp(e,process.stderr),process.exitCode=0;return}if(e.length===0){if(S.printHelp([],process.stderr),!!o.apiKey){let{command:p}=S.resolve(["balance"]),g=O(t,[...A]),k=R(g);await p.execute(k,g)}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.
|
|
87
|
-
`),process.
|
|
86
|
+
`);process.exitCode=0;return}let{command:r,extra:s}=S.resolve(e),a=t.slice(e.length),i=O(a,[...A,...r.options??[]]);s.length>0&&(i._positional=s);let m=R(i);if(!Ce.some(l=>l.every((p,g)=>e[g]===p))&&!m.apiKey){let l=process.env.ds_API_KEY;if(!l){process.stderr.write(`Error: No API key found. Run "ds auth login" or set ds_API_KEY env var.
|
|
87
|
+
`),process.exitCode=1;return}m.apiKey=l}await r.execute(m,i)}ke().catch(de);
|