an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
feat(persist): SQLite durable store — Phase A (window bounds + history) (#4)
Chaitanya Giri1c98049852f2
diff --git a/electron-builder.yml b/electron-builder.ymlindex 2af5c52a..13b774bc 100644--- a/electron-builder.yml+++ b/electron-builder.yml@@ -20,6 +20,8 @@ files:asarUnpack:- "**/node_modules/node-pty/**"+ # better-sqlite3 is native (bindings/prebuild need the .node on the real FS).+ - "**/node_modules/better-sqlite3/**"# Rebuild native deps (node-pty) for the target during packaging.npmRebuild: truediff --git a/package-lock.json b/package-lock.jsonindex fba67a2a..e10e6d8b 100644--- a/package-lock.json+++ b/package-lock.json@@ -23,6 +23,7 @@"@uiw/react-codemirror": "^4.25.10","@xterm/addon-fit": "^0.10.0","@xterm/xterm": "^5.5.0",+ "better-sqlite3": "^11.10.0","commit-graph": "^2.4.0","localtunnel": "^2.0.2","node-pty": "^1.0.0",@@ -34,6 +35,7 @@"devDependencies": {"@electron/notarize": "^2.5.0","@electron/rebuild": "^3.7.0",+ "@types/better-sqlite3": "^7.6.13","@types/localtunnel": "^2.0.4","@types/node": "^22.7.5","@types/react": "^18.3.11",@@ -2223,6 +2225,16 @@"@babel/types": "^7.28.2"}},+ "node_modules/@types/better-sqlite3": {+ "version": "7.6.13",+ "resolved": "https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-7.6.13.tgz",+ "integrity": "sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@types/node": "*"+ }+ },"node_modules/@types/cacheable-request": {"version": "6.0.3","resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz",@@ -2998,7 +3010,6 @@"version": "1.5.1","resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz","integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",- "dev": true,"funding": [{"type": "github",@@ -3028,11 +3039,30 @@"node": ">=6.0.0"}},+ "node_modules/better-sqlite3": {+ "version": "11.10.0",+ "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-11.10.0.tgz",+ "integrity": "sha512-EwhOpyXiOEL/lKzHz9AW1msWFNzGc/z+LzeB3/jnFJpxu+th2yqvzsSWas1v9jgs9+xiXJcD5A8CJxAG2TaghQ==",+ "hasInstallScript": true,+ "license": "MIT",+ "dependencies": {+ "bindings": "^1.5.0",+ "prebuild-install": "^7.1.1"+ }+ },+ "node_modules/bindings": {+ "version": "1.5.0",+ "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",+ "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",+ "license": "MIT",+ "dependencies": {+ "file-uri-to-path": "1.0.0"+ }+ },"node_modules/bl": {"version": "4.1.0","resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz","integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==",- "dev": true,"license": "MIT","dependencies": {"buffer": "^5.5.0",@@ -3114,7 +3144,6 @@"version": "5.7.1","resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz","integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",- "dev": true,"funding": [{"type": "github",@@ -3817,7 +3846,6 @@"version": "6.0.0","resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz","integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",- "dev": true,"license": "MIT","dependencies": {"mimic-response": "^3.1.0"@@ -3833,7 +3861,6 @@"version": "3.1.0","resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz","integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==",- "dev": true,"license": "MIT","engines": {"node": ">=10"@@ -3842,6 +3869,15 @@"url": "https://github.com/sponsors/sindresorhus"}},+ "node_modules/deep-extend": {+ "version": "0.6.0",+ "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",+ "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==",+ "license": "MIT",+ "engines": {+ "node": ">=4.0.0"+ }+ },"node_modules/defaults": {"version": "1.0.4","resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz",@@ -3924,7 +3960,6 @@"version": "2.1.2","resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz","integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",- "dev": true,"license": "Apache-2.0","engines": {"node": ">=8"@@ -4389,7 +4424,6 @@"version": "1.4.5","resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz","integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==",- "dev": true,"license": "MIT","dependencies": {"once": "^1.4.0"@@ -4537,6 +4571,15 @@"integrity": "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw==","license": "MIT"},+ "node_modules/expand-template": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz",+ "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==",+ "license": "(MIT OR WTFPL)",+ "engines": {+ "node": ">=6"+ }+ },"node_modules/exponential-backoff": {"version": "3.1.3","resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.3.tgz",@@ -4600,6 +4643,12 @@"pend": "~1.2.0"}},+ "node_modules/file-uri-to-path": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",+ "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",+ "license": "MIT"+ },"node_modules/filelist": {"version": "1.0.6","resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.6.tgz",@@ -4681,9 +4730,7 @@"version": "1.0.0","resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz","integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==",- "dev": true,- "license": "MIT",- "peer": true+ "license": "MIT"},"node_modules/fs-extra": {"version": "8.1.0",@@ -4849,6 +4896,12 @@"js-binary-schema-parser": "^2.0.3"}},+ "node_modules/github-from-package": {+ "version": "0.0.0",+ "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz",+ "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==",+ "license": "MIT"+ },"node_modules/glob": {"version": "8.1.0","resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz",@@ -5176,7 +5229,6 @@"version": "1.2.1","resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz","integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",- "dev": true,"funding": [{"type": "github",@@ -5236,7 +5288,12 @@"version": "2.0.4","resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz","integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",- "dev": true,+ "license": "ISC"+ },+ "node_modules/ini": {+ "version": "1.3.8",+ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",+ "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==","license": "ISC"},"node_modules/ip-address": {@@ -5839,7 +5896,6 @@"version": "1.2.8","resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz","integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",- "dev": true,"license": "MIT","funding": {"url": "https://github.com/sponsors/ljharb"@@ -5969,6 +6025,12 @@"node": ">=10"}},+ "node_modules/mkdirp-classic": {+ "version": "0.5.3",+ "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",+ "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==",+ "license": "MIT"+ },"node_modules/ms": {"version": "2.1.3","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",@@ -5995,6 +6057,12 @@"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"}},+ "node_modules/napi-build-utils": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-2.0.0.tgz",+ "integrity": "sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==",+ "license": "MIT"+ },"node_modules/negotiator": {"version": "0.6.4","resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.4.tgz",@@ -6009,7 +6077,6 @@"version": "3.92.0","resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.92.0.tgz","integrity": "sha512-KdHvFWZjEKDf0cakgFjebl371GPsISX2oZHcuyKqM7DtogIsHrqKeLTo8wBHxaXRAQlY2PsPlZmfo+9ZCxEREQ==",- "dev": true,"license": "MIT","dependencies": {"semver": "^7.3.5"@@ -6022,7 +6089,6 @@"version": "7.8.1","resolved": "https://registry.npmjs.org/semver/-/semver-7.8.1.tgz","integrity": "sha512-rkVq3IXh+4FDGch+KwzX3aV9W3kO54GyEgpvBzSyctDA6Xtd7RJQV1xmXbeQp5v7+VzLOfVqiutSE6GICgPFvg==",- "dev": true,"license": "ISC","bin": {"semver": "bin/semver.js"@@ -6246,7 +6312,6 @@"version": "1.4.0","resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz","integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",- "dev": true,"license": "ISC","dependencies": {"wrappy": "1"@@ -6516,6 +6581,33 @@"node": "^10 || ^12 || >=14"}},+ "node_modules/prebuild-install": {+ "version": "7.1.3",+ "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.3.tgz",+ "integrity": "sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==",+ "deprecated": "No longer maintained. Please contact the author of the relevant native addon; alternatives are available.",+ "license": "MIT",+ "dependencies": {+ "detect-libc": "^2.0.0",+ "expand-template": "^2.0.3",+ "github-from-package": "0.0.0",+ "minimist": "^1.2.3",+ "mkdirp-classic": "^0.5.3",+ "napi-build-utils": "^2.0.0",+ "node-abi": "^3.3.0",+ "pump": "^3.0.0",+ "rc": "^1.2.7",+ "simple-get": "^4.0.0",+ "tar-fs": "^2.0.0",+ "tunnel-agent": "^0.6.0"+ },+ "bin": {+ "prebuild-install": "bin.js"+ },+ "engines": {+ "node": ">=10"+ }+ },"node_modules/proc-log": {"version": "2.0.1","resolved": "https://registry.npmjs.org/proc-log/-/proc-log-2.0.1.tgz",@@ -6580,7 +6672,6 @@"version": "3.0.4","resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz","integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==",- "dev": true,"license": "MIT","dependencies": {"end-of-stream": "^1.1.0",@@ -6610,6 +6701,21 @@"url": "https://github.com/sponsors/sindresorhus"}},+ "node_modules/rc": {+ "version": "1.2.8",+ "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",+ "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==",+ "license": "(BSD-2-Clause OR MIT OR Apache-2.0)",+ "dependencies": {+ "deep-extend": "^0.6.0",+ "ini": "~1.3.0",+ "minimist": "^1.2.0",+ "strip-json-comments": "~2.0.1"+ },+ "bin": {+ "rc": "cli.js"+ }+ },"node_modules/react": {"version": "18.3.1","resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",@@ -6716,7 +6822,6 @@"version": "3.6.2","resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz","integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",- "dev": true,"license": "MIT","dependencies": {"inherits": "^2.0.3",@@ -6940,7 +7045,6 @@"version": "5.2.1","resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz","integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",- "dev": true,"funding": [{"type": "github",@@ -7065,6 +7169,51 @@"dev": true,"license": "ISC"},+ "node_modules/simple-concat": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz",+ "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==",+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/feross"+ },+ {+ "type": "patreon",+ "url": "https://www.patreon.com/feross"+ },+ {+ "type": "consulting",+ "url": "https://feross.org/support"+ }+ ],+ "license": "MIT"+ },+ "node_modules/simple-get": {+ "version": "4.0.1",+ "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz",+ "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==",+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/feross"+ },+ {+ "type": "patreon",+ "url": "https://www.patreon.com/feross"+ },+ {+ "type": "consulting",+ "url": "https://feross.org/support"+ }+ ],+ "license": "MIT",+ "dependencies": {+ "decompress-response": "^6.0.0",+ "once": "^1.3.1",+ "simple-concat": "^1.0.0"+ }+ },"node_modules/simple-update-notifier": {"version": "2.0.0","resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz",@@ -7214,7 +7363,6 @@"version": "1.3.0","resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz","integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",- "dev": true,"license": "MIT","dependencies": {"safe-buffer": "~5.2.0"@@ -7276,6 +7424,15 @@"node": ">=8"}},+ "node_modules/strip-json-comments": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",+ "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==",+ "license": "MIT",+ "engines": {+ "node": ">=0.10.0"+ }+ },"node_modules/style-mod": {"version": "4.1.3","resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz",@@ -7327,13 +7484,29 @@"node": ">=10"}},+ "node_modules/tar-fs": {+ "version": "2.1.4",+ "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.4.tgz",+ "integrity": "sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==",+ "license": "MIT",+ "dependencies": {+ "chownr": "^1.1.1",+ "mkdirp-classic": "^0.5.2",+ "pump": "^3.0.0",+ "tar-stream": "^2.1.4"+ }+ },+ "node_modules/tar-fs/node_modules/chownr": {+ "version": "1.1.4",+ "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",+ "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==",+ "license": "ISC"+ },"node_modules/tar-stream": {"version": "2.2.0","resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz","integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==",- "dev": true,"license": "MIT",- "peer": true,"dependencies": {"bl": "^4.0.3","end-of-stream": "^1.4.1",@@ -7450,6 +7623,18 @@"utf8-byte-length": "^1.0.1"}},+ "node_modules/tunnel-agent": {+ "version": "0.6.0",+ "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",+ "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==",+ "license": "Apache-2.0",+ "dependencies": {+ "safe-buffer": "^5.0.1"+ },+ "engines": {+ "node": "*"+ }+ },"node_modules/type-fest": {"version": "0.13.1","resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz",@@ -7582,7 +7767,6 @@"version": "1.0.2","resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz","integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",- "dev": true,"license": "MIT"},"node_modules/verror": {@@ -7743,7 +7927,6 @@"version": "1.0.2","resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz","integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",- "dev": true,"license": "ISC"},"node_modules/xmlbuilder": {diff --git a/package.json b/package.jsonindex ec62dbec..52047aaf 100644--- a/package.json+++ b/package.json@@ -14,7 +14,7 @@"dev": "electron-vite dev","build": "electron-vite build","preview": "electron-vite preview",- "postinstall": "electron-rebuild -f -w node-pty",+ "postinstall": "electron-rebuild -f","typecheck:node": "tsc --noEmit -p tsconfig.node.json","typecheck:web": "tsc --noEmit -p tsconfig.web.json","typecheck": "npm run typecheck:node && npm run typecheck:web",@@ -38,6 +38,7 @@"@uiw/react-codemirror": "^4.25.10","@xterm/addon-fit": "^0.10.0","@xterm/xterm": "^5.5.0",+ "better-sqlite3": "^11.10.0","commit-graph": "^2.4.0","localtunnel": "^2.0.2","node-pty": "^1.0.0",@@ -49,6 +50,7 @@"devDependencies": {"@electron/notarize": "^2.5.0","@electron/rebuild": "^3.7.0",+ "@types/better-sqlite3": "^7.6.13","@types/localtunnel": "^2.0.4","@types/node": "^22.7.5","@types/react": "^18.3.11",diff --git a/src/main/db.ts b/src/main/db.tsnew file mode 100644index 00000000..78aed385--- /dev/null+++ b/src/main/db.ts@@ -0,0 +1,170 @@+/**+ * PersistStore — durable harness state in SQLite (better-sqlite3, synchronous).+ *+ * Phase A scope (the rest of the renderer state stays in localStorage for now):+ * - kv: scalar app state. Today: the main window's bounds.+ * - command_history: NET-NEW — every prompt the user submits to an agent.+ *+ * Lives in the Electron MAIN process (better-sqlite3 is native + synchronous);+ * the renderer reaches it over IPC. The DB file sits next to config.json under+ * app.getPath('userData'). WAL mode so reads never block the single writer.+ *+ * Schema evolves via PRAGMA user_version migrations: an ordered array where+ * migration N runs when user_version < N+1, then bumps it. NEVER edit a shipped+ * migration — only append. Phases B/C (agents + message_queue mirror) and the+ * cross-lane cost_ledger are reserved as future additive migrations (see below);+ * they are deliberately NOT built in v1.+ */+import Database from 'better-sqlite3';+import { app } from 'electron';+import { join } from 'node:path';++/** A captured user prompt, as returned to the renderer (camelCase columns). */+export interface CommandHistoryRow {+ id: number;+ agentId: string;+ cwd: string | null;+ text: string;+ ts: number;+}++/**+ * Ordered, append-only migrations. Index N takes the DB from user_version N to+ * N+1. To evolve the schema, APPEND a new function — never edit an existing one+ * (shipped DBs have already run it).+ *+ * FUTURE (do NOT build in v1 — reserved so the array isn't painted into a corner):+ * - Phase B: `agents` + `message_queue` mirror of the renderer roster/queues+ * (dual-write), enabling the eventual authority flip off localStorage.+ * - Cross-lane (Lane A #6 cost ledger migration onto this DB): a `cost_ledger`+ * table — (id, agent_id, session_id, ts, model, input_tokens, output_tokens,+ * cache_read_tokens, cache_creation_tokens, usd) — so Jim's circuit-breaker+ * can move off transcript-polling. Additive; lands as a later migration.+ */+const MIGRATIONS: Array<(db: Database.Database) => void> = [+ // → user_version 1 (Phase A): scalar kv + net-new command history.+ (db) => {+ db.exec(`+ CREATE TABLE IF NOT EXISTS kv (+ key TEXT PRIMARY KEY,+ value TEXT NOT NULL, -- JSON-encoded+ updated_at INTEGER NOT NULL+ );+ CREATE TABLE IF NOT EXISTS command_history (+ id INTEGER PRIMARY KEY AUTOINCREMENT,+ agent_id TEXT NOT NULL,+ cwd TEXT,+ text TEXT NOT NULL,+ ts INTEGER NOT NULL+ );+ CREATE INDEX IF NOT EXISTS idx_ch_agent_ts ON command_history(agent_id, ts DESC);+ `);+ }+];++export class PersistStore {+ private db: Database.Database | null = null;++ /** @param dbPath Override the DB location (tests). Defaults to userData/harness.db. */+ constructor(private dbPath?: string) {}++ /** Open (creating if needed) and migrate the DB. Idempotent — a second call is+ * a no-op. Throws if the native module fails to load or the file is unusable;+ * callers should guard so a DB failure can't crash app startup. */+ open(): void {+ if (this.db) return;+ const path = this.dbPath ?? join(app.getPath('userData'), 'harness.db');+ const db = new Database(path);+ db.pragma('journal_mode = WAL');+ db.pragma('synchronous = NORMAL');+ db.pragma('busy_timeout = 5000');+ db.pragma('foreign_keys = ON');+ this.migrate(db);+ this.db = db;+ }++ private migrate(db: Database.Database): void {+ const version = db.pragma('user_version', { simple: true }) as number;+ for (let i = version; i < MIGRATIONS.length; i++) {+ // Each migration + its version bump run in one transaction so a crash+ // mid-migration never leaves a half-applied schema at the wrong version.+ const run = db.transaction(() => {+ MIGRATIONS[i](db);+ db.pragma(`user_version = ${i + 1}`);+ });+ run();+ }+ }++ /** Close the handle (checkpoints WAL). Safe to call when already closed. */+ close(): void {+ try { this.db?.close(); } catch { /* best-effort on shutdown */ }+ this.db = null;+ }++ get isOpen(): boolean { return this.db !== null; }++ // ─── kv (scalar app state) ─────────────────────────────────────────────────++ /** Read a JSON-decoded scalar, or undefined if absent/unparseable. */+ getKv<T = unknown>(key: string): T | undefined {+ if (!this.db) return undefined;+ const row = this.db.prepare('SELECT value FROM kv WHERE key = ?').get(key) as { value: string } | undefined;+ if (!row) return undefined;+ try { return JSON.parse(row.value) as T; } catch { return undefined; }+ }++ /** Upsert a JSON-encoded scalar. */+ setKv(key: string, value: unknown): void {+ if (!this.db) return;+ this.db.prepare(+ `INSERT INTO kv (key, value, updated_at) VALUES (?, ?, ?)+ ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at`+ ).run(key, JSON.stringify(value), Date.now());+ }++ // ─── command history (net-new) ─────────────────────────────────────────────++ /** Record one submitted prompt. Empty text or missing agent id are ignored. */+ addHistory(entry: { agentId: string; cwd?: string | null; text: string }): void {+ if (!this.db) return;+ const text = (entry.text ?? '').trim();+ if (!text || !entry.agentId) return;+ this.db.prepare('INSERT INTO command_history (agent_id, cwd, text, ts) VALUES (?, ?, ?, ?)')+ .run(entry.agentId, entry.cwd ?? null, text, Date.now());+ }++ /** Most-recent-first history, optionally scoped to one agent. */+ listHistory(agentId?: string, limit = 100): CommandHistoryRow[] {+ if (!this.db) return [];+ const lim = clampLimit(limit, 100);+ const rows = agentId+ ? this.db.prepare(+ 'SELECT id, agent_id AS agentId, cwd, text, ts FROM command_history WHERE agent_id = ? ORDER BY ts DESC, id DESC LIMIT ?'+ ).all(agentId, lim)+ : this.db.prepare(+ 'SELECT id, agent_id AS agentId, cwd, text, ts FROM command_history ORDER BY ts DESC, id DESC LIMIT ?'+ ).all(lim);+ return rows as CommandHistoryRow[];+ }++ /** Substring search over prompt text, most-recent-first. */+ searchHistory(query: string, limit = 50): CommandHistoryRow[] {+ if (!this.db) return [];+ const q = (query ?? '').trim();+ if (!q) return [];+ const lim = clampLimit(limit, 50);+ // Escape LIKE wildcards so a literal % or _ in the query isn't a metachar.+ const needle = `%${q.replace(/[\\%_]/g, '\\$&')}%`;+ return this.db.prepare(+ "SELECT id, agent_id AS agentId, cwd, text, ts FROM command_history WHERE text LIKE ? ESCAPE '\\' ORDER BY ts DESC, id DESC LIMIT ?"+ ).all(needle, lim) as CommandHistoryRow[];+ }+}++/** Coerce an untrusted limit into [1, 1000] with a sane fallback. */+function clampLimit(n: number, fallback: number): number {+ const v = Math.floor(Number(n));+ if (!Number.isFinite(v) || v <= 0) return fallback;+ return Math.min(1000, v);+}diff --git a/src/main/index.ts b/src/main/index.tsindex 08ca0486..2034feb8 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -1,4 +1,4 @@-import { app, BrowserWindow, clipboard, dialog, ipcMain, shell } from 'electron';+import { app, BrowserWindow, clipboard, dialog, ipcMain, screen, shell } from 'electron';import { spawn } from 'node:child_process';import { rmSync, existsSync, readFileSync, readdirSync, cpSync } from 'node:fs';import { join, resolve, sep } from 'node:path';@@ -16,6 +16,7 @@ import { HiveManager, type AgentMeta, type HiveMessage, type HiveTask } from './import { HookServer } from './hooks';import { MemoryManager } from './memory';import { MemoryReflector, type ReflectSettings } from './reflect';+import { PersistStore } from './db';import { enrichMessage } from './assistant';import { readAgentUsage } from './transcript';import { listIssues, listCIRuns } from './github';@@ -57,6 +58,9 @@ const reflector = new MemoryReflector(reflectSettings,(event) => { try { hive.appendLog(event); } catch { /* best-effort */ } });+// Durable harness state (SQLite, main process). Phase A: window bounds (kv) ++// net-new command history. Opened in whenReady, closed in the teardown blocks.+const persist = new PersistStore();let mainWindow: BrowserWindow | null = null;/** When true, skip the quit interceptor (user already confirmed). */@@ -242,12 +246,48 @@ function stopSlackServer(): void {slackServer = null;}+/** The persisted main-window geometry (kv key `window.bounds`). */+interface WindowBounds { x?: number; y?: number; width: number; height: number }++const DEFAULT_WIN = { width: 1440, height: 900 };+const MIN_WIN = { width: 1280, height: 800 };++/** Validate + clamp restored bounds: enforce the minimum size, and drop a+ * position that no longer lands on any connected display (monitor unplugged) so+ * the window can't open off-screen. Returns null for unusable input. */+function clampBounds(b: unknown): WindowBounds | null {+ if (!b || typeof b !== 'object') return null;+ const r = b as Partial<WindowBounds>;+ if (typeof r.width !== 'number' || typeof r.height !== 'number') return null;+ const width = Math.max(MIN_WIN.width, Math.round(r.width));+ const height = Math.max(MIN_WIN.height, Math.round(r.height));+ if (typeof r.x !== 'number' || typeof r.y !== 'number') return { width, height };+ const x = Math.round(r.x), y = Math.round(r.y);+ // Keep the position only if the window rect overlaps some display's work area.+ const onScreen = screen.getAllDisplays().some((d) => {+ const wa = d.workArea;+ return x < wa.x + wa.width && x + width > wa.x && y < wa.y + wa.height && y + height > wa.y;+ });+ return onScreen ? { x, y, width, height } : { width, height };+}++/** Minimal trailing-edge debounce for the move/resize flood. */+function debounce(fn: () => void, ms: number): () => void {+ let t: NodeJS.Timeout | null = null;+ return () => { if (t) clearTimeout(t); t = setTimeout(() => { t = null; fn(); }, ms); };+}+function createWindow(): void {+ // Restore the last window geometry (kv), falling back to the default size.+ let saved: WindowBounds | null = null;+ try { saved = clampBounds(persist.getKv('window.bounds')); } catch { saved = null; }+const win = new BrowserWindow({- width: 1440,- height: 900,- minWidth: 1280,- minHeight: 800,+ width: saved?.width ?? DEFAULT_WIN.width,+ height: saved?.height ?? DEFAULT_WIN.height,+ ...(saved && saved.x !== undefined && saved.y !== undefined ? { x: saved.x, y: saved.y } : {}),+ minWidth: MIN_WIN.width,+ minHeight: MIN_WIN.height,title: 'Munder Difflin',backgroundColor: '#FFF8E7',titleBarStyle: 'hiddenInset',@@ -262,6 +302,19 @@ function createWindow(): void {mainWindow = win;+ // Persist geometry as the user drags/resizes (debounced) and on close. Skip+ // while maximized/minimized so a restore doesn't save the fullscreen rect.+ const saveBounds = debounce(() => {+ if (win.isDestroyed() || win.isMinimized() || win.isMaximized()) return;+ try { persist.setKv('window.bounds', win.getBounds()); } catch { /* DB best-effort */ }+ }, 400);+ win.on('resized', saveBounds);+ win.on('moved', saveBounds);+ win.on('close', () => {+ if (win.isDestroyed() || win.isMinimized() || win.isMaximized()) return;+ try { persist.setKv('window.bounds', win.getBounds()); } catch { /* DB best-effort */ }+ });+win.once('ready-to-show', () => win.show());win.webContents.setWindowOpenHandler(({ url }) => {@@ -583,6 +636,23 @@ ipcMain.handle('hive:mineNow', () => { memory.mineNow(); return { ok: true }; })ipcMain.handle('memory:reflectNow', (_evt, id: unknown) =>reflector.reflectNow(typeof id === 'string' && id ? id : undefined));+// ─── IPC: command history (SQLite — every prompt submitted to an agent) ──────+ipcMain.handle('history:add', (_evt, payload: unknown) => {+ const p = (payload ?? {}) as { agentId?: unknown; cwd?: unknown; text?: unknown };+ if (typeof p.agentId !== 'string' || typeof p.text !== 'string') return { ok: false, error: 'invalid args' };+ try {+ persist.addHistory({ agentId: p.agentId, cwd: typeof p.cwd === 'string' ? p.cwd : null, text: p.text });+ return { ok: true };+ } catch (e) { return { ok: false, error: e instanceof Error ? e.message : String(e) }; }+});+ipcMain.handle('history:list', (_evt, agentId: unknown, limit: unknown) =>+ persist.listHistory(+ typeof agentId === 'string' && agentId ? agentId : undefined,+ typeof limit === 'number' ? limit : undefined+ ));+ipcMain.handle('history:search', (_evt, query: unknown, limit: unknown) =>+ persist.searchHistory(typeof query === 'string' ? query : '', typeof limit === 'number' ? limit : undefined));+// ─── IPC: quit confirmation ─────────────────────────────────────────────────ipcMain.handle('app:confirmClose', () => {allowQuit = true;@@ -594,6 +664,7 @@ ipcMain.handle('app:confirmClose', () => {try { stopSlackServer(); } catch (e) { console.error('[quit] slack.stop:', e); }try { memory.stop(); } catch (e) { console.error('[quit] memory.stop:', e); }try { reflector.stop(); } catch (e) { console.error('[quit] reflector.stop:', e); }+ try { persist.close(); } catch (e) { console.error('[quit] persist.close:', e); }try { ptyManager.killAll(); } catch (e) { console.error('[quit] killAll:', e); }app.quit();});@@ -611,6 +682,7 @@ ipcMain.handle('app:resetAll', () => {try { stopSlackServer(); } catch (e) { console.error('[reset] slack.stop:', e); }try { memory.stop(); } catch (e) { console.error('[reset] memory.stop:', e); }try { reflector.stop(); } catch (e) { console.error('[reset] reflector.stop:', e); }+ try { persist.close(); } catch (e) { console.error('[reset] persist.close:', e); }try { ptyManager.killAll(); } catch (e) { console.error('[reset] killAll:', e); }// Erase the hive (Michael's + every agent's memory, inboxes, tasks, board,// git history) and the semantic-memory palace. Only these harness-created@@ -737,6 +809,10 @@ function bootstrapHiveServices(): void {}app.whenReady().then(() => {+ // Open the durable store first — createWindow() reads the saved window bounds.+ // Guarded: a DB failure (e.g. a bad native build) must degrade to defaults,+ // never block app startup.+ try { persist.open(); } catch (e) { console.error('[db] open failed:', e); }// Bootstrap the hive (if harnessHome is configured) and start the message router.bootstrapHiveServices();createWindow();diff --git a/src/preload/index.ts b/src/preload/index.tsindex 1b88ae59..933d3703 100644--- a/src/preload/index.ts+++ b/src/preload/index.ts@@ -137,6 +137,15 @@ export interface AgentUsage {estimatedCostUsd: number;}+/** One captured user prompt from the SQLite command_history table. */+export interface CommandHistoryEntry {+ id: number;+ agentId: string;+ cwd: string | null;+ text: string;+ ts: number;+}+/** A GitHub issue, normalized for the renderer (labels/assignees flattened to names). */export interface GHIssue {number: number;@@ -252,6 +261,17 @@ const api = {* the per-agent outcomes ({ id, condensed, reason, oldBytes?, newBytes? }). */reflectNow: (id?: string): Promise<Array<{ id: string; condensed: boolean; reason: string; oldBytes?: number; newBytes?: number }>> =>ipcRenderer.invoke('memory:reflectNow', id),++ // ─── Command history (SQLite — every prompt submitted to an agent) ─────────+ /** Record one submitted prompt. Fire-and-forget from the prompt-detection hook. */+ historyAdd: (entry: { agentId: string; cwd?: string; text: string }): Promise<{ ok: boolean; error?: string }> =>+ ipcRenderer.invoke('history:add', entry),+ /** Most-recent-first history, optionally scoped to one agent. */+ historyList: (agentId?: string, limit?: number): Promise<CommandHistoryEntry[]> =>+ ipcRenderer.invoke('history:list', agentId, limit),+ /** Substring search over prompt text, most-recent-first. */+ historySearch: (query: string, limit?: number): Promise<CommandHistoryEntry[]> =>+ ipcRenderer.invoke('history:search', query, limit),hiveSend: (msg: Partial<HiveMessage>, from?: string): Promise<{ ok: boolean; error?: string; message?: HiveMessage }> =>ipcRenderer.invoke('hive:send', msg, from),diff --git a/src/renderer/src/components/AgentDetailPanel.tsx b/src/renderer/src/components/AgentDetailPanel.tsxindex 9041f5d8..d8869615 100644--- a/src/renderer/src/components/AgentDetailPanel.tsx+++ b/src/renderer/src/components/AgentDetailPanel.tsx@@ -155,7 +155,10 @@ export function AgentDetailPanel({ agent }: AgentDetailPanelProps) {key={agent.ptyId}ptyId={agent.ptyId}onStreamData={onPtyStream}- onUserPrompt={(t) => updateAgent(agent.id, { lastPrompt: t })}+ onUserPrompt={(t) => {+ updateAgent(agent.id, { lastPrompt: t });+ void window.cth.historyAdd({ agentId: agent.id, cwd: agent.cwd, text: t });+ }}onToggleFullscreen={() => setFullscreen(agent.id)}fullscreen={false}embeddeddiff --git a/src/renderer/src/components/CommandCenterPanel.tsx b/src/renderer/src/components/CommandCenterPanel.tsxindex b73d115f..413c312a 100644--- a/src/renderer/src/components/CommandCenterPanel.tsx+++ b/src/renderer/src/components/CommandCenterPanel.tsx@@ -149,7 +149,10 @@ export function CommandCenterPanel({ agent }: { agent: Agent }) {key={agent.ptyId}ptyId={agent.ptyId}onStreamData={onPtyStream}- onUserPrompt={(t) => updateAgent(agent.id, { lastPrompt: t })}+ onUserPrompt={(t) => {+ updateAgent(agent.id, { lastPrompt: t });+ void window.cth.historyAdd({ agentId: agent.id, cwd: agent.cwd, text: t });+ }}onToggleFullscreen={() => setFullscreen(agent.id)}fullscreen={false}embeddeddiff --git a/src/renderer/src/components/FullscreenTerminal.tsx b/src/renderer/src/components/FullscreenTerminal.tsxindex e22da648..d7fc54bb 100644--- a/src/renderer/src/components/FullscreenTerminal.tsx+++ b/src/renderer/src/components/FullscreenTerminal.tsx@@ -136,7 +136,10 @@ export function FullscreenTerminal() {key={agent.ptyId}ptyId={agent.ptyId}onStreamData={parser}- onUserPrompt={(t) => updateAgent(agent.id, { lastPrompt: t })}+ onUserPrompt={(t) => {+ updateAgent(agent.id, { lastPrompt: t });+ void window.cth.historyAdd({ agentId: agent.id, cwd: agent.cwd, text: t });+ }}onToggleFullscreen={() => setFullscreen(null)}fullscreen/>