OverviewFilesCommitsIssuesDocsReleasesPeers

keet-cli commits / 8336d2f

Fix daemon storage path and import for shared keet-daemon module
Storage default was ~/.config/keet-cli/default (an identity subdir) but IdentityRegistry expects the base dir ~/.config/keet-cli/. Also fix format.js import to use shared keet-daemon package. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8336d2f57b531c1649eb0fb7d5fdb9dfd4de7ab7
by plankatron <fleeky@gmail.com> · 2026-02-19T13:57:17.000Z

Changed files (1) +49 -46

index.js +49 -46
……@@ -3,7 +3,7 @@ import FramedStream from 'framed-stream'
33import b4a from 'b4a'
44import path from 'path'
55import os from 'os'
6import { getGenericEventName } from './lib/format.js'
6import { getGenericEventName } from 'keet-daemon/lib/format.js'
77
88// --- Parse Args ---
99const rawArgs = Pear.config.args || []
……@@ -31,7 +31,7 @@ for (let i = 0; i < rawArgs.length; i++) {
3131 }
3232}
3333
34const STORAGE = customStorage || path.join(os.homedir(), '.config', 'keet-cli', 'default')
34const STORAGE = customStorage || path.join(os.homedir(), '.config', 'keet-cli')
3535const SOCKET = customSocket || '/tmp/keet-daemon.sock'
3636const command = args[0]
3737
……@@ -163,6 +163,52 @@ if (command === 'daemon') {
163163 await new Promise(() => {})
164164}
165165
166// ============================================================
167// UDS client helpers (framed-stream JSON-RPC over Unix socket)
168// ============================================================
169// NOTE: Must be declared BEFORE the client switch to avoid TDZ errors
170
171let _nextId = 1
172const _pending = new Map()
173
174function rpc (method, params) {
175 return new Promise((resolve, reject) => {
176 const id = _nextId++
177 const msg = JSON.stringify({ id, method, params: params || {} })
178
179 const pipe = new Pipe(SOCKET)
180 const framed = new FramedStream(pipe)
181
182 const timeout = setTimeout(() => {
183 framed.destroy()
184 reject(new Error('RPC timeout (5s)'))
185 }, 5000)
186
187 pipe.on('error', (err) => {
188 clearTimeout(timeout)
189 reject(err)
190 })
191
192 framed.on('data', (buf) => {
193 try {
194 const response = JSON.parse(b4a.toString(buf, 'utf8'))
195 if (response.id === id) {
196 clearTimeout(timeout)
197 framed.destroy()
198 resolve(response)
199 }
200 } catch {}
201 })
202
203 framed.on('error', (err) => {
204 clearTimeout(timeout)
205 reject(err)
206 })
207
208 framed.write(b4a.from(msg, 'utf8'))
209 })
210}
211
166212// --- Client Mode ---
167213try {
168214 switch (command) {
……@@ -687,47 +733,4 @@ async function clientIntrospect (api) {
687733 }
688734}
689735
690// ============================================================
691// UDS client helpers (framed-stream JSON-RPC over Unix socket)
692// ============================================================
693
694let _nextId = 1
695const _pending = new Map()
696
697function rpc (method, params) {
698 return new Promise((resolve, reject) => {
699 const id = _nextId++
700 const msg = JSON.stringify({ id, method, params: params || {} })
701
702 const pipe = Pipe.connect(SOCKET)
703 const framed = new FramedStream(pipe)
704
705 const timeout = setTimeout(() => {
706 framed.destroy()
707 reject(new Error('RPC timeout (5s)'))
708 }, 5000)
709
710 pipe.on('error', (err) => {
711 clearTimeout(timeout)
712 reject(err)
713 })
714
715 framed.on('data', (buf) => {
716 try {
717 const response = JSON.parse(b4a.toString(buf, 'utf8'))
718 if (response.id === id) {
719 clearTimeout(timeout)
720 framed.destroy()
721 resolve(response)
722 }
723 } catch {}
724 })
725
726 framed.on('error', (err) => {
727 clearTimeout(timeout)
728 reject(err)
729 })
730
731 framed.write(b4a.from(msg, 'utf8'))
732 })
733}
736// (UDS client helpers moved above client switch to avoid TDZ)