@hermenics/deepseek-code 0.12.0 → 0.13.1
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 +46 -1
- package/dist/browser-egress-worker.mjs +12 -12
- package/dist/cli.mjs +1402 -809
- package/dist/shell-supervisor.mjs +31 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
- **Settings center** — fullscreen, searchable User/Project/Local configuration with visible origins
|
|
37
37
|
- **MCP support** — connect to any Model Context Protocol server for extended tooling
|
|
38
38
|
- **Project guidance** — loads a root `AGENTS.md` alongside `DEEPSEEK.md`
|
|
39
|
-
- **Optional
|
|
39
|
+
- **Optional code navigation** — session-owned language servers expose definitions, references, hover, symbols, one-document diagnostics and rename previews with source/version provenance; rename proposals apply separately through hash-checked `edit_file` ranges. `lsp` with `operation: "dependency_graph"` queries bounded local TS/JS imports and package.json workspace declarations without a server
|
|
40
40
|
- **Extensible** — slash commands, custom tools, memory, sessions, themes
|
|
41
41
|
|
|
42
42
|
## Quick start
|
|
@@ -122,6 +122,8 @@ The agent has access to these tools out of the box:
|
|
|
122
122
|
|
|
123
123
|
`ReadFile` · `WriteFile` · `EditFile` · `PatchFile` · `Shell` · `Glob` · `Grep` · `Lsp` · `Git` · `ReadFolder` · `WebFetch` · `Skill` · `SubAgent` · `AskAgent` · `Workflow` · `Memory` · `Todo` · `Introspect` · `MoA` · `AskUserQuestions`
|
|
124
124
|
|
|
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
|
+
|
|
125
127
|
Skills are listed by origin and loaded on demand through the read-only `skill` tool. Plugins can contribute skills, slash commands, and MCP servers. Plugin MCP configs require workspace approval before their servers start. See [the extension architecture study](docs/skills-plugins-mcp-research.md).
|
|
126
128
|
|
|
127
129
|
### Experimental browser
|
|
@@ -181,6 +183,49 @@ bun run typecheck # Type check (tsc --noEmit)
|
|
|
181
183
|
bun test # Run tests
|
|
182
184
|
```
|
|
183
185
|
|
|
186
|
+
### Background task recovery
|
|
187
|
+
|
|
188
|
+
`/tasks` and `/task <id> status` distinguish task-attempt state from recorded process observations. Background shell tasks capture their native process identity. On Linux, status checks revalidate boot, PID namespace and process start time, rather than trusting a saved PID. `alive` only describes the recorded leader; it does not establish useful progress, descendant cleanup or completed effects. Native exit events retain their actual exit code/signal; a later kernel observation cannot reconstruct a lost result.
|
|
189
|
+
|
|
190
|
+
For process-backed tasks without an eligible recovery runner, an interrupted attempt remains interrupted even when its recorded leader is alive. Process-backed failures are not automatically retried or replayed through `/task resume`. Inspect status/artifacts, reconcile possible effects and submit a newly authorized command when appropriate. Eligible Linux background Shell tasks are an exception: their detached supervisor can survive a CLI restart and reattach from the persisted task snapshot without replaying the command. Generic task runners, raw stream reconnection and cross-platform process supervision are not supported.
|
|
191
|
+
|
|
192
|
+
### LSP text edit proposals
|
|
193
|
+
|
|
194
|
+
With a user-configured server, `lsp` supports `rename_preview`, `code_actions` and `code_action_preview`. All three are read-only. List actions using a file and 1-based UTF-16 range, then select the returned native ID:
|
|
195
|
+
|
|
196
|
+
```json
|
|
197
|
+
{"operation":"code_actions","path":"src/example.ts","line":1,"character":1,"kind":"source.organizeImports"}
|
|
198
|
+
{"operation":"code_action_preview","path":"src/example.ts","action_id":"<id from the listing>"}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Optional `end_line`/`end_character` default to the starting coordinates. Kinds include matching subkinds. Listings label disabled, command-dependent and deferred actions, and report omissions. Opaque server data remains inside the native session. IDs expire after another listing, observed source changes, configuration changes or server disposal.
|
|
202
|
+
|
|
203
|
+
Read each proposed target with `read_file`, then pass its returned `arguments` to `edit_file`. The writer checks the base hash and the runtime read version before committing. Multi-file application remains atomic per file. Command-dependent actions, resource operations and annotated edits are refused rather than partially applied. Deferred edit-only actions use `codeAction/resolve` when advertised; preview re-queries and requires a unique matching action with unchanged metadata. Actions with unstable provider identities may require a new listing.
|
|
204
|
+
|
|
205
|
+
Source hashes and diagnostic hints do not prove complete semantic indexes or build correctness; verify the resulting change separately.
|
|
206
|
+
|
|
207
|
+
### Real TypeScript LSP check
|
|
208
|
+
|
|
209
|
+
`tests/lsp-real-server.test.ts` uses a temporary project and the repository's `typescript-language-server` development dependency by default. Set `DEEPSEEK_LSP_TEST_SERVER` to override its executable. The fixture runs on Node.js >= 18, uses the repository's TypeScript version, and currently skips Windows. It exercises navigation, diagnostic provenance, rename and code action application, version refresh, and independent compiler checks.
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
bun test tests/lsp-real-server.test.ts
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Set `DEEPSEEK_LSP_TEST_NODE` to select another Node executable. Unversioned publications remain outside the version-bound diagnostic items; their bounded messages appear under `unverified.items` as investigation hints. Compiler/test verification remains separate.
|
|
216
|
+
|
|
217
|
+
User-scoped `lsp.servers` entries accept an `initializationOptions` JSON object (up to 64 KiB). For the tested TypeScript adapter, this option selects a single semantic server and avoids syntax-only startup routing:
|
|
218
|
+
|
|
219
|
+
```json
|
|
220
|
+
{
|
|
221
|
+
"initializationOptions": {
|
|
222
|
+
"tsserver": { "useSyntaxServer": "never" }
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
The fixture also checks a fresh server's first rename request with this configuration. Each server defines its own initialization options; changing them restarts its session connection.
|
|
228
|
+
|
|
184
229
|
### Project structure
|
|
185
230
|
|
|
186
231
|
```
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import{createSecureContext as
|
|
1
|
+
import{createSecureContext as zw}from"node:tls";import{createServer as b,request as l}from"node:http";import{request as c}from"node:https";import{TLSSocket as a}from"node:tls";import{connect as o,createServer as t,isIP as B}from"node:net";import{randomBytes as L,timingSafeEqual as U}from"node:crypto";import{mkdtempSync as r,rmSync as s}from"node:fs";import{tmpdir as e}from"node:os";import{join as x}from"node:path";import{lookup as n}from"dns/promises";import{isIP as R}from"node:net";import{BlockList as m,isIP as q}from"node:net";var i=20000,Zw=i*4;var h=[["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]],p=[["::",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 I(z,w){let Q=new m;for(let[Z,J]of z)Q.addSubnet(Z,J,w);return Q}var k=I(h,"ipv4"),d=I(p,"ipv6");function D(z){let w=q(z);if(w===4)return k.check(z,"ipv4");if(w===6&&/^::ffff:[0-9a-f]{1,4}:[0-9a-f]{1,4}$/i.test(z))return!0;if(w===6)return d.check(z,"ipv6");return!0}var u=2000,H=2048,Y=async(z)=>{let w;try{return(await Promise.race([n(z,{all:!0}),new Promise((Z,J)=>{w=setTimeout(()=>J(Error("DNS timeout")),u)})])).map((Z)=>Z.address)}finally{clearTimeout(w)}};function f(z){return z.replace(/^\[|\]$/g,"").replace(/\.$/,"").toLowerCase()}function O(z){let w=f(z);if(w==="localhost"||w.endsWith(".localhost"))return!0;if(R(w)===4)return w.startsWith("127.");return w==="::1"}async function E(z,w=Y){if(z==="about:blank")return{kind:"loopback",origin:"about:blank"};if(z.length>H)return{kind:"blocked",reason:`URL longer than ${H} characters`};let Q;try{Q=new URL(z)}catch{return{kind:"blocked",reason:"not a valid URL"}}if(Q.protocol!=="http:"&&Q.protocol!=="https:")return{kind:"blocked",reason:`${Q.protocol} URLs are not allowed; use http or https`};if(Q.username||Q.password)return{kind:"blocked",reason:"URLs with embedded credentials are not allowed"};let Z=Q.origin,J=f(Q.hostname);if(O(J))return{kind:"loopback",origin:Z};if(J==="metadata.google.internal")return{kind:"blocked",origin:Z,reason:"cloud metadata endpoints are blocked"};if(R(J))return D(J)?{kind:"blocked",origin:Z,reason:`${J} is not a public address`}:{kind:"public",origin:Z};let G;try{G=await w(J)}catch{return{kind:"blocked",origin:Z,reason:`could not resolve ${J}`}}if(G.length===0)return{kind:"blocked",origin:Z,reason:`could not resolve ${J}`};let $=G.find((K)=>D(K));return $?{kind:"blocked",origin:Z,reason:`${J} resolves to non-public address ${$}`}:{kind:"public",origin:Z}}var ww=["connection","proxy-connection","proxy-authorization","proxy-authenticate","keep-alive","te","trailer","transfer-encoding","upgrade"];function M(z){let w={...z},Q=String(z.connection??"").split(",").map((Z)=>Z.trim().toLowerCase());for(let Z of[...ww,...Q])delete w[Z];return w}function _(z){return z.replace(/^\[|\]$/g,"").replace(/\.$/,"")}class P{certificate;authorize;resolve;certificateAuthority;username="codimium";password=L(32).toString("hex");realm=L(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=b();inner=b();innerTls=t((z)=>this.acceptTls(z));privateDirectory=r(x(e(),"deepseek-egress-tls-"));stopped=!1;_url="";constructor(z,w,Q,Z){this.certificate=z;this.authorize=w;this.resolve=Q;this.certificateAuthority=Z;this.inner.setTimeout(30000);for(let[J,G]of[[this.server,!1],[this.inner,!0]])J.maxHeadersCount=100,J.headersTimeout=15000,J.requestTimeout=30000,J.on("request",($,K)=>{this.forward($,K,G).catch(()=>{if(!K.headersSent)K.writeHead(502);K.end()})}),J.on("upgrade",($,K,N)=>{this.upgrade($,K,N,G).catch(()=>K.destroy())}),J.on("connection",($)=>this.track($)),J.on("clientError",($,K)=>K.destroy());this.server.on("connect",(J,G,$)=>{this.connect(J,G,$).catch(()=>G.destroy())})}static async start(z,w,Q=Y,Z){let J=new P(z,w,Q,Z);try{await new Promise(($,K)=>{J.innerTls.once("error",K),J.innerTls.listen(x(J.privateDirectory,"tls"),()=>{J.innerTls.off("error",K),$()})}),await new Promise(($,K)=>{J.server.once("error",K),J.server.listen(0,"127.0.0.1",()=>{J.server.off("error",K),$()})});let G=J.server.address();if(!G||typeof G==="string")throw J.stop(),Error("Codimium network protection did not bind");return J._url=`http://127.0.0.1:${G.port}`,J}catch(G){throw J.stop(),G}}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 z of this.sockets)z.destroy();this.sockets.clear(),s(this.privateDirectory,{recursive:!0,force:!0})}track(z){this.sockets.add(z),z.once("close",()=>this.sockets.delete(z)),z.on("error",()=>z.destroy())}hasAuth(z,w=!1){if(w&&this.authenticated.has(z.socket))return!0;let Q=Buffer.from(String(z.headers["proxy-authorization"]??""));return Q.length===this.authorization.length&&U(Q,this.authorization)}challenge(z){z.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(z){let w=this.tunnel.get(z.socket),Q=w?new URL(z.url??"/",w):new URL(z.url??"");if(!["http:","https:","ws:","wss:"].includes(Q.protocol)||Q.username||Q.password)throw Error("Unsupported proxy URL");if(w&&(Q.host!==w.host||Q.protocol!==w.protocol))throw Error("Tunnel authority changed");if(w&&new URL(`${w.protocol}//${z.headers.host??""}`).host!==w.host)throw Error("Tunnel Host changed");return Q}async endpoint(z){let w=new URL(z);w.protocol=z.protocol==="ws:"?"http:":z.protocol==="wss:"?"https:":z.protocol;let Q=[];if((await
|
|
6
|
+
`)}destination(z){let w=this.tunnel.get(z.socket),Q=w?new URL(z.url??"/",w):new URL(z.url??"");if(!["http:","https:","ws:","wss:"].includes(Q.protocol)||Q.username||Q.password)throw Error("Unsupported proxy URL");if(w&&(Q.host!==w.host||Q.protocol!==w.protocol))throw Error("Tunnel authority changed");if(w&&new URL(`${w.protocol}//${z.headers.host??""}`).host!==w.host)throw Error("Tunnel Host changed");return Q}async endpoint(z){let w=new URL(z);w.protocol=z.protocol==="ws:"?"http:":z.protocol==="wss:"?"https:":z.protocol;let Q=[];if((await E(w.href,async(K)=>{return Q=await this.resolve(K),Q})).kind==="blocked")throw Error("Blocked egress address");let J=_(z.hostname);if(B(J))Q=[J];else if(O(J))Q=["127.0.0.1"];if(!Q.length)throw Error("No verified egress address");let G=Q[0],$=B(G);if(!$||G==="127.0.0.1"&&Number(z.port)===Number(new URL(this.url).port))throw Error("Invalid or recursive egress address");return{address:G,family:$}}async connect(z,w,Q){if(this.stopped){w.destroy();return}if(!this.hasAuth(z)){this.challenge(w);return}let Z=new URL(`https://${z.url}`);if(Z.username||Z.password||Z.pathname!=="/"||Z.search||Z.hash)throw Error("Invalid CONNECT authority");if(await this.endpoint(Z),this.stopped){w.destroy();return}w.write(`HTTP/1.1 200 Connection Established\r
|
|
7
7
|
\r
|
|
8
|
-
`),w.setTimeout(1e4,()=>w.destroy());let J=(G)=>{if(w.pause(),w.setTimeout(0),G[0]===22){let
|
|
9
|
-
`));let K="",N=(
|
|
10
|
-
`.startsWith(K)){
|
|
11
|
-
`)return
|
|
12
|
-
`))return;z.off("data",Q);try{let J=JSON.parse(w),G=Buffer.from(J.password??"")
|
|
13
|
-
`);let N=new
|
|
8
|
+
`),w.setTimeout(1e4,()=>w.destroy());let J=(G)=>{if(w.pause(),w.setTimeout(0),G[0]===22){let $=o(x(this.privateDirectory,"tls"));this.track($),$.once("connect",()=>$.write(JSON.stringify({password:this.password,target:Z.href})+`
|
|
9
|
+
`));let K="",N=(V)=>{if(K+=V.toString(),!`OK
|
|
10
|
+
`.startsWith(K)){$.destroy();return}if(K!==`OK
|
|
11
|
+
`)return;$.off("data",N),$.write(G),w.pipe($),$.pipe(w)};$.on("data",N),w.once("close",()=>$.destroy()),$.once("close",()=>w.destroy())}else{let $=new URL(`http://${z.url}`);this.authenticated.add(w),this.tunnel.set(w,$),w.unshift(G),this.inner.emit("connection",w),w.resume()}};if(Q.length)J(Q);else w.once("data",J),w.resume()}acceptTls(z){this.track(z),z.setTimeout(5000,()=>z.destroy());let w="",Q=(Z)=>{if(w+=Z.toString(),w.length>4096){z.destroy();return}if(!w.endsWith(`
|
|
12
|
+
`))return;z.off("data",Q);try{let J=JSON.parse(w),G=Buffer.from(J.password??""),$=Buffer.from(this.password);if(G.length!==$.length||!U(G,$)||typeof J.target!=="string")throw Error("Unowned TLS bridge");let K=new URL(J.target);if(K.protocol!=="https:"||K.username||K.password)throw Error("Invalid TLS authority");z.pause(),z.write(`OK
|
|
13
|
+
`);let N=new a(z,{isServer:!0,secureContext:this.certificate.context,ALPNProtocols:["http/1.1"]});this.track(N),this.authenticated.add(N),this.tunnel.set(N,K),N.setTimeout(15000,()=>N.destroy()),N.once("secure",()=>N.setTimeout(30000)),this.inner.emit("connection",N),z.resume()}catch{z.destroy()}};z.on("data",Q)}async forward(z,w,Q){if(this.stopped){w.writeHead(503),w.end();return}if(!this.hasAuth(z,Q)){w.writeHead(407,{"proxy-authenticate":`Basic realm="${this.realm}"`}),w.end();return}let Z=this.destination(z);if(!["http:","https:"].includes(Z.protocol)){w.writeHead(400),w.end();return}let J=await this.endpoint(Z);if(!await this.authorize(Z.href)||this.stopped){w.writeHead(403),w.end();return}let G=this.outgoing(z,Z,J,!1);G.on("response",($)=>{w.writeHead($.statusCode??502,M($.headers)),$.on("error",()=>w.destroy()),$.pipe(w)}),G.on("error",()=>{if(!w.headersSent)w.writeHead(502);w.end()}),z.on("aborted",()=>G.destroy()),w.on("close",()=>G.destroy()),z.pipe(G)}outgoing(z,w,Q,Z){let J=M(z.headers);if(J.host=w.host,Z)J.connection="Upgrade",J.upgrade="websocket";let G=["https:","wss:"].includes(w.protocol),K=(G?c:l)({hostname:_(w.hostname),port:w.port||(G?443:80),path:w.pathname+w.search,method:z.method,headers:J,agent:!1,rejectUnauthorized:!0,ca:this.certificateAuthority,lookup:(N,V,C)=>{if(V.all)C(null,[Q]);else C(null,Q.address,Q.family)}});return K.setTimeout(30000,()=>K.destroy()),K}async upgrade(z,w,Q,Z){if(this.stopped){w.destroy();return}if(!this.hasAuth(z,Z)){this.challenge(w);return}if(String(z.headers.upgrade).toLowerCase()!=="websocket")throw Error("Unsupported upgrade");let J=this.destination(z),G=z.headers.origin;if(typeof G!=="string"||!await this.authorize(J.href,G)){w.end(`HTTP/1.1 403 Forbidden\r
|
|
14
14
|
Connection: close\r
|
|
15
15
|
Content-Length: 0\r
|
|
16
16
|
\r
|
|
17
|
-
`);return}let
|
|
18
|
-
${
|
|
17
|
+
`);return}let $=await this.endpoint(J);if(this.stopped){w.destroy();return}let K=this.outgoing(z,J,$,!0);K.on("upgrade",(N,V,C)=>{if(K.setTimeout(0),V.setTimeout(0),w.setTimeout(0),this.track(V),this.stopped||w.destroyed){V.destroy();return}let W=M(N.headers);W.connection="Upgrade",W.upgrade="websocket";let v=Object.entries(W).flatMap(([g,X])=>(Array.isArray(X)?X:[X]).filter((j)=>j!==void 0).map((j)=>`${g}: ${j}`));if(w.write(`HTTP/1.1 101 Switching Protocols\r
|
|
18
|
+
${v.join(`\r
|
|
19
19
|
`)}\r
|
|
20
20
|
\r
|
|
21
|
-
`),
|
|
21
|
+
`),C.length)w.write(C);if(Q.length)V.write(Q);w.once("close",()=>V.destroy()),V.once("close",()=>w.destroy()),V.pipe(w),w.pipe(V)}),K.on("response",(N)=>{N.resume(),w.end(`HTTP/1.1 502 Bad Gateway\r
|
|
22
22
|
Connection: close\r
|
|
23
23
|
Content-Length: 0\r
|
|
24
24
|
\r
|
|
25
|
-
`)}),
|
|
25
|
+
`)}),K.on("error",()=>w.destroy()),w.once("close",()=>K.destroy()),K.end()}}var F,S=!1,Jw=0,y=new Map;function T(z,w){if(!process.connected||y.size>=512)return Promise.reject(Error("Network owner unavailable"));let Q=++Jw;return new Promise((Z,J)=>{let G=setTimeout(()=>{y.delete(Q),J(Error("Network owner timed out"))},5000);y.set(Q,{done($){clearTimeout(G),Z($)},fail(){clearTimeout(G),J(Error("Network owner disconnected"))}}),process.send({type:z,id:Q,...w})})}function A(){F?.stop();for(let z of y.values())z.fail();y.clear(),process.exit(0)}process.on("disconnect",A);process.on("SIGTERM",A);process.on("SIGINT",A);process.on("message",(z)=>{let w=z;if(w.type==="reply"&&typeof w.id==="number"){let Q=y.get(w.id);y.delete(w.id),Q?.done(w.value);return}if(w.type!=="init"||S)return;S=!0,(async()=>{if(!w.key||!w.cert||!w.spki)throw Error("Missing private network identity");let Q={key:w.key,cert:w.cert,spki:w.spki,context:zw({key:w.key,cert:w.cert})};F=await P.start(Q,async(Z,J)=>await T("authorize",{url:Z,origin:J})===!0,w.customResolver?async(Z)=>{let J=await T("resolve",{host:Z});if(!Array.isArray(J)||!J.every((G)=>typeof G==="string"))throw Error("Invalid resolver result");return J}:Y,w.certificateAuthority),process.send({type:"ready",url:F.url,username:F.username,password:F.password,realm:F.realm,cleanupDirectory:F.cleanupDirectory})})().catch(()=>{process.send?.({type:"error"}),F?.stop(),process.exit(1)})});
|