claude-simple 0.1.0 → 0.2.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.
Files changed (46) hide show
  1. package/client.js +31 -2
  2. package/dist/app.0.2.1.min.js +868 -0
  3. package/dist/highlight.min.js +448 -430
  4. package/dist/index.html +2 -2
  5. package/dist/style.0.2.1.min.css +1182 -0
  6. package/package.json +1 -1
  7. package/public/agent-panel.js +44 -0
  8. package/public/api.js +61 -10
  9. package/public/app.js +4 -0
  10. package/public/chat.js +338 -31
  11. package/public/files.js +22 -30
  12. package/public/git.js +21 -17
  13. package/public/icons/icon-180.png +0 -0
  14. package/public/icons/icon-192.png +0 -0
  15. package/public/icons/icon-512.png +0 -0
  16. package/public/icons/icon-maskable-512.png +0 -0
  17. package/public/index.html +16 -3
  18. package/public/lib.js +7 -2
  19. package/public/manifest.webmanifest +36 -0
  20. package/public/offline.html +33 -0
  21. package/public/pwa.js +78 -0
  22. package/public/shell/boot.js +3 -0
  23. package/public/shell/hub.js +4 -2
  24. package/public/shell/notes.js +93 -31
  25. package/public/shell/session-list.js +29 -10
  26. package/public/shell/session-nav.js +7 -2
  27. package/public/shell/templates.js +11 -3
  28. package/public/shell.js +101 -8
  29. package/public/state.js +13 -2
  30. package/public/style.css +135 -3
  31. package/public/sw.js +104 -0
  32. package/public/terminal.js +22 -0
  33. package/public/wake-lock.js +45 -0
  34. package/server.js +5 -1
  35. package/src/agents/claude.js +108 -10
  36. package/src/agents/codex.js +1 -1
  37. package/src/agents/grok.js +40 -32
  38. package/src/agents/meta-agent.js +40 -1
  39. package/src/agents/stream-batch.js +62 -0
  40. package/src/app.js +312 -41
  41. package/src/auto-update.js +215 -0
  42. package/src/runtime/approvals.js +67 -0
  43. package/src/runtime/outbox.js +143 -0
  44. package/src/runtime/protocol.js +224 -0
  45. package/dist/app.0.1.0.min.js +0 -825
  46. package/dist/style.0.1.0.min.css +0 -1050
package/client.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { createApp, init } from './src/app.js';
2
+ import { createApp, init, hasBusyAgent } from './src/app.js';
3
+ import { startAutoUpdate } from './src/auto-update.js';
3
4
  import { WebSocket } from 'ws';
4
5
  import os from 'os';
5
6
  import crypto from 'crypto';
@@ -18,6 +19,10 @@ const { server } = createApp();
18
19
  await new Promise(resolve => server.listen(LOCAL_PORT, '127.0.0.1', resolve));
19
20
  console.log(`[client] Local app listening on 127.0.0.1:${LOCAL_PORT}`);
20
21
 
22
+ // Self-update from npm (default every 12h). Disable with AUTO_UPDATE=0.
23
+ // Requires global install + systemd Restart= (or equivalent) for full apply.
24
+ startAutoUpdate({ role: 'edge-client', isBusy: hasBusyAgent });
25
+
21
26
  // ─── Active WS tunnels: tunnelId → local WebSocket ───────────────────────────
22
27
  const tunnels = new Map();
23
28
 
@@ -35,6 +40,7 @@ function connect() {
35
40
  console.log(`[client] Connecting to gateway ${GATEWAY_URL} ...`);
36
41
  controlWs = new WebSocket(GATEWAY_URL, {
37
42
  headers: { 'x-machine-token': MACHINE_TOKEN },
43
+ perMessageDeflate: true,
38
44
  });
39
45
 
40
46
  controlWs.on('open', () => {
@@ -60,12 +66,35 @@ function connect() {
60
66
  headers: { ...msg.headers, host: `127.0.0.1:${LOCAL_PORT}` },
61
67
  body: msg.body || undefined,
62
68
  });
69
+ const headers = Object.fromEntries(res.headers.entries());
70
+ const contentType = res.headers.get('content-type') || '';
71
+
72
+ // SSE (and any other body-less-until-done response) is forwarded as
73
+ // it arrives instead of buffered in full, so remote/hub viewers get
74
+ // real-time streaming instead of one lump delivered at the end.
75
+ if (contentType.includes('text/event-stream') && res.body) {
76
+ sendControl({ type: 'http-res-start', reqId: msg.reqId, status: res.status, headers });
77
+ const reader = res.body.getReader();
78
+ const decoder = new TextDecoder();
79
+ for (;;) {
80
+ const { done, value } = await reader.read();
81
+ if (done) break;
82
+ sendControl({ type: 'http-chunk', reqId: msg.reqId, data: decoder.decode(value, { stream: true }) });
83
+ }
84
+ // Flush a possibly incomplete UTF-8 code point held by TextDecoder
85
+ // before terminating the stream (SSE payloads often contain Chinese).
86
+ const tail = decoder.decode();
87
+ if (tail) sendControl({ type: 'http-chunk', reqId: msg.reqId, data: tail });
88
+ sendControl({ type: 'http-end', reqId: msg.reqId });
89
+ return;
90
+ }
91
+
63
92
  const body = await res.text();
64
93
  sendControl({
65
94
  type: 'http-res',
66
95
  reqId: msg.reqId,
67
96
  status: res.status,
68
- headers: Object.fromEntries(res.headers.entries()),
97
+ headers,
69
98
  body,
70
99
  });
71
100
  } catch (e) {