@hermenics/deepseek-code 0.13.5 → 0.14.0
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 +1 -1
- package/dist/browser-egress-worker.mjs +2 -2
- package/dist/cli.mjs +909 -800
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -120,7 +120,7 @@ Each provider also exposes provider-specific models (Bedrock, Vertex, local).
|
|
|
120
120
|
|
|
121
121
|
The agent has access to these tools out of the box:
|
|
122
122
|
|
|
123
|
-
`ReadFile` · `WriteFile` · `EditFile` · `PatchFile` · `Shell` · `Glob` · `Grep` · `Lsp` · `Git` · `ReadFolder` · `WebFetch` · `Skill` · `SubAgent` · `AskAgent` · `Workflow` · `Memory` · `Todo` · `Introspect` · `MoA` · `AskUserQuestions`
|
|
123
|
+
`ReadFile` · `WriteFile` · `EditFile` · `PatchFile` · `Shell` · `Glob` · `Grep` · `Lsp` · `Git` · `ReadFolder` · `WebFetch` · `WebSearch` · `Skill` · `SubAgent` · `AskAgent` · `Workflow` · `Memory` · `Todo` · `Introspect` · `MoA` · `AskUserQuestions`
|
|
124
124
|
|
|
125
125
|
Shell command execution currently requires Linux with a working bubblewrap sandbox. On macOS, Windows, or a Linux host where the sandbox cannot start, commands fail closed before execution.
|
|
126
126
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{createSecureContext as re}from"node:tls";import{createServer as
|
|
1
|
+
import{createSecureContext as re}from"node:tls";import{createServer as x,request as G}from"node:http";import{request as X}from"node:https";import{TLSSocket as V}from"node:tls";import{connect as J,createServer as Q,isIP as P}from"node:net";import{randomBytes as C,timingSafeEqual as _}from"node:crypto";import{mkdtempSync as Y,rmSync as Z}from"node:fs";import{tmpdir as ee}from"node:os";import{join as b}from"node:path";import{lookup as F}from"dns/promises";import{isIP as R}from"node:net";import{BlockList as H,isIP as N}from"node:net";var z=20000,ce=z*4;var O=[["0.0.0.0",8],["10.0.0.0",8],["100.64.0.0",10],["127.0.0.0",8],["169.254.0.0",16],["172.16.0.0",12],["192.0.0.0",24],["192.0.2.0",24],["192.31.196.0",24],["192.52.193.0",24],["192.88.99.0",24],["192.168.0.0",16],["192.175.48.0",24],["198.18.0.0",15],["198.51.100.0",24],["203.0.113.0",24],["224.0.0.0",4],["240.0.0.0",4]],W=[["::",96],["::1",128],["::ffff:0:0",96],["64:ff9b::",96],["64:ff9b:1::",48],["100::",64],["2001::",23],["2001:db8::",32],["2002::",16],["3fff::",20],["fc00::",7],["fe80::",10],["ff00::",8]];function k(t,e){let o=new H;for(let[n,r]of t)o.addSubnet(n,r,e);return o}var j=k(O,"ipv4"),q=k(W,"ipv6");function w(t){let e=N(t);if(e===4)return j.check(t,"ipv4");if(e===6&&/^::ffff:[0-9a-f]{1,4}:[0-9a-f]{1,4}$/i.test(t))return!0;if(e===6)return q.check(t,"ipv6");return!0}var K=2000,S=2048,h=async(t)=>{let e;try{return(await Promise.race([F(t,{all:!0}),new Promise((n,r)=>{e=setTimeout(()=>r(Error("DNS timeout")),K)})])).map((n)=>n.address)}finally{clearTimeout(e)}};function L(t){return t.replace(/^\[|\]$/g,"").replace(/\.$/,"").toLowerCase()}function v(t){let e=L(t);if(e==="localhost"||e.endsWith(".localhost"))return!0;if(R(e)===4)return e.startsWith("127.");return e==="::1"}async function U(t,e=h){if(t==="about:blank")return{kind:"loopback",origin:"about:blank"};if(t.length>S)return{kind:"blocked",reason:`URL longer than ${S} characters`};let o;try{o=new URL(t)}catch{return{kind:"blocked",reason:"not a valid URL"}}if(o.protocol!=="http:"&&o.protocol!=="https:")return{kind:"blocked",reason:`${o.protocol} URLs are not allowed; use http or https`};if(o.username||o.password)return{kind:"blocked",reason:"URLs with embedded credentials are not allowed"};let n=o.origin,r=L(o.hostname);if(v(r))return{kind:"loopback",origin:n};if(r==="metadata.google.internal")return{kind:"blocked",origin:n,reason:"cloud metadata endpoints are blocked"};if(R(r))return w(r)?{kind:"blocked",origin:n,reason:`${r} is not a public address`}:{kind:"public",origin:n};let i;try{i=await e(r)}catch{return{kind:"blocked",origin:n,reason:`could not resolve ${r}`}}if(i.length===0)return{kind:"blocked",origin:n,reason:`could not resolve ${r}`};let s=i.find((a)=>w(a));return s?{kind:"blocked",origin:n,reason:`${r} resolves to non-public address ${s}`}:{kind:"public",origin:n}}var te=["connection","proxy-connection","proxy-authorization","proxy-authenticate","keep-alive","te","trailer","transfer-encoding","upgrade"];function T(t){let e={...t},o=String(t.connection??"").split(",").map((n)=>n.trim().toLowerCase());for(let n of[...te,...o])delete e[n];return e}function I(t){return t.replace(/^\[|\]$/g,"").replace(/\.$/,"")}class f{certificate;authorize;resolve;certificateAuthority;username="codimium";password=C(32).toString("hex");realm=C(16).toString("hex");authorization=Buffer.from(`Basic ${Buffer.from(`${this.username}:${this.password}`).toString("base64")}`);sockets=new Set;tunnel=new WeakMap;authenticated=new WeakSet;server=x();inner=x();innerTls=Q((t)=>this.acceptTls(t));privateDirectory=Y(b(ee(),"deepseek-egress-tls-"));stopped=!1;_url="";constructor(t,e,o,n){this.certificate=t;this.authorize=e;this.resolve=o;this.certificateAuthority=n;this.inner.setTimeout(30000);for(let[r,i]of[[this.server,!1],[this.inner,!0]])r.maxHeadersCount=100,r.headersTimeout=15000,r.requestTimeout=30000,r.on("request",(s,a)=>{this.forward(s,a,i).catch(()=>{if(!a.headersSent)a.writeHead(502);a.end()})}),r.on("upgrade",(s,a,c)=>{this.upgrade(s,a,c,i).catch(()=>a.destroy())}),r.on("connection",(s)=>this.track(s)),r.on("clientError",(s,a)=>a.destroy());this.server.on("connect",(r,i,s)=>{this.connect(r,i,s).catch(()=>i.destroy())})}static async start(t,e,o=h,n){let r=new f(t,e,o,n);try{await new Promise((s,a)=>{r.innerTls.once("error",a),r.innerTls.listen(b(r.privateDirectory,"tls"),()=>{r.innerTls.off("error",a),s()})}),await new Promise((s,a)=>{r.server.once("error",a),r.server.listen(0,"127.0.0.1",()=>{r.server.off("error",a),s()})});let i=r.server.address();if(!i||typeof i==="string")throw r.stop(),Error("Codimium network protection did not bind");return r._url=`http://127.0.0.1:${i.port}`,r}catch(i){throw r.stop(),i}}get url(){return this._url}get cleanupDirectory(){return this.privateDirectory}launchOptions(){return{proxyServer:this.url,proxyBypassList:"<-loopback>",certificateSPKI:this.certificate.spki}}stop(){if(this.stopped)return;this.stopped=!0,this.server.close(),this.innerTls.close();for(let t of this.sockets)t.destroy();this.sockets.clear(),Z(this.privateDirectory,{recursive:!0,force:!0})}track(t){this.sockets.add(t),t.once("close",()=>this.sockets.delete(t)),t.on("error",()=>t.destroy())}hasAuth(t,e=!1){if(e&&this.authenticated.has(t.socket))return!0;let o=Buffer.from(String(t.headers["proxy-authorization"]??""));return o.length===this.authorization.length&&_(o,this.authorization)}challenge(t){t.end(`HTTP/1.1 407 Proxy Authentication Required\r
|
|
2
2
|
Proxy-Authenticate: Basic realm="${this.realm}"\r
|
|
3
3
|
Connection: close\r
|
|
4
4
|
Content-Length: 0\r
|
|
5
5
|
\r
|
|
6
|
-
`)}destination(t){let e=this.tunnel.get(t.socket),o=e?new URL(t.url??"/",e):new URL(t.url??"");if(!["http:","https:","ws:","wss:"].includes(o.protocol)||o.username||o.password)throw Error("Unsupported proxy URL");if(e&&(o.host!==e.host||o.protocol!==e.protocol))throw Error("Tunnel authority changed");if(e&&new URL(`${e.protocol}//${t.headers.host??""}`).host!==e.host)throw Error("Tunnel Host changed");return o}async endpoint(t){let e=new URL(t);e.protocol=t.protocol==="ws:"?"http:":t.protocol==="wss:"?"https:":t.protocol;let o=[];if((await
|
|
6
|
+
`)}destination(t){let e=this.tunnel.get(t.socket),o=e?new URL(t.url??"/",e):new URL(t.url??"");if(!["http:","https:","ws:","wss:"].includes(o.protocol)||o.username||o.password)throw Error("Unsupported proxy URL");if(e&&(o.host!==e.host||o.protocol!==e.protocol))throw Error("Tunnel authority changed");if(e&&new URL(`${e.protocol}//${t.headers.host??""}`).host!==e.host)throw Error("Tunnel Host changed");return o}async endpoint(t){let e=new URL(t);e.protocol=t.protocol==="ws:"?"http:":t.protocol==="wss:"?"https:":t.protocol;let o=[];if((await U(e.href,async(a)=>(o=await this.resolve(a),o))).kind==="blocked")throw Error("Blocked egress address");let r=I(t.hostname);if(P(r))o=[r];else if(v(r))o=["127.0.0.1"];if(!o.length)throw Error("No verified egress address");let i=o[0],s=P(i);if(!s||i==="127.0.0.1"&&Number(t.port)===Number(new URL(this.url).port))throw Error("Invalid or recursive egress address");return{address:i,family:s}}async connect(t,e,o){if(this.stopped){e.destroy();return}if(!this.hasAuth(t)){this.challenge(e);return}let n=new URL(`https://${t.url}`);if(n.username||n.password||n.pathname!=="/"||n.search||n.hash)throw Error("Invalid CONNECT authority");if(await this.endpoint(n),this.stopped){e.destroy();return}e.write(`HTTP/1.1 200 Connection Established\r
|
|
7
7
|
\r
|
|
8
8
|
`),e.setTimeout(1e4,()=>e.destroy());let r=(i)=>{if(e.pause(),e.setTimeout(0),i[0]===22){let s=J(b(this.privateDirectory,"tls"));this.track(s),s.once("connect",()=>s.write(JSON.stringify({password:this.password,target:n.href})+`
|
|
9
9
|
`));let a="",c=(l)=>{if(a+=l.toString(),!`OK
|