Commit Graph
206 Commits
Author SHA1 Message Date
redshift e8f46c79dc bumped version 2026-05-03 16:22:47 +05:30
redshift 9fac004f05 refactor(usage): remove CLI-side suffix filtering now that auth proxy handles it
The auth proxy intercepts GET /usage and returns only entries belonging to
the authenticated npub's clients, with owner suffixes stripped. The TUI no
longer needs to filter entries client-side.

- Remove getNpubSuffix and loadConfig from tui/usage/data.ts imports
- Remove old suffix-based filtering logic from fetchUsage()
- Remove unused getNpubSuffix from cli.ts imports
2026-05-03 16:21:38 +08:00
redshift 306dec5943 feat(clients): support ownerNpub field and remove CLI-side suffixing
- Add ownerNpub?: string to ClientEntry and DaemonClient interfaces
- Update getClientsFromStore() to preserve ownerNpub field
- GET /clients: include ownerNpub in daemon response
- POST /clients/add: accept and store ownerNpub from auth proxy
- Remove getNpubSuffix/addSuffixToId/removeSuffixFromId from clients.ts (moved to auth proxy)
- Remove CLI-side suffixing in addDaemonClient and deleteClientAction
- Remove config loading from getClientsList (no longer needed for filtering)
- CLI output now shows raw client IDs without suffix stripping
2026-05-03 15:04:57 +08:00
redshift 9a520efb24 added a register command. 2026-04-30 16:45:31 +05:30
redshift a3508b9667 bumped version and also fixed matching clientid to existing ones 2026-04-30 16:16:57 +05:30
redshift 790bf925bb added the suffixed client id. a tiny miss in the code. 2026-04-30 14:06:07 +05:30
redshift 1d556c42e3 version bump 2026-04-30 14:00:38 +05:30
redshift 9628c6bfbd fixed the suffix not being added bug. 2026-04-30 13:59:14 +05:30
redshift 240706f6f1 bumped version. 2026-04-30 13:47:35 +05:30
redshift cdfde85595 fix: prevent race condition spawning multiple cocod and routstrd instances
When multiple routstrd processes (or CLI auto-starts) bootstrap simultaneously,
each process found cocod/routstrd unreachable, spawned its own copy, and
contended for the same database socket. The paired ~200ms burst timestamps
in the logs were the symptom.

Fixes applied:

- Add cross-process startup lock (process-lock.ts)
  - Uses atomic mkdir as the lock primitive.
  - Stores PID + UUID token; verifies ownership on release to avoid
    removing a lock taken by a new process after the original crashed.
  - Removes stale locks (unreachable PID or lock older than staleAfterMs).
  - Exports withCrossProcessLock() for simple RAII-style usage.

- Fix cocod startup race (cocod-client.ts)
  - Wrap ensureDaemonRunning() in a socket-derived lock path.
  - Re-ping inside the lock before spawning; if another process just started
    cocod, the current process detects it and connects instead of spawning.
  - Switch from 'cocod daemon' to 'cocod init' for cleaner daemonization.
  - Allow exit code 0 from 'cocod init' (normal daemon exit without error).

- Consolidate routstrd daemon startup (daemon-client.ts)
  - startDaemonProcess() now delegates to startDaemon() from start-daemon.ts,
    sharing the same lock and health-check logic.

- Add cross-process lock to routstrd daemon startup (start-daemon.ts)
  - Performs pre-lock isDaemonHealthy() check to skip lock entirely when
    already running.
  - Performs re-check inside the lock before spawning to avoid duplicate
    daemon processes.
2026-04-30 13:36:16 +05:30
redshift 55dbb1a6b5 docs: update SKILL.md with new npubs, remote, clients delete, and refresh commands 2026-04-30 12:40:43 +05:30
redshift aa75f1394e docs: rename Usage to Use Routstrd Skill 2026-04-30 12:39:36 +05:30
redshift 40bca1ec72 docs: add skill tip and fix heading formatting 2026-04-30 12:37:53 +05:30
redshift 4862f4e1f2 docs: format OR between install options 2026-04-30 12:29:13 +05:30
redshift d17e732c8d docs: reorganize install into 3 steps 2026-04-30 12:28:47 +05:30
redshift 973f50cb38 docs: use routstrd receive instead of cocod 2026-04-30 12:25:23 +05:30
redshift 2264089ca7 docs: update README with install instructions 2026-04-30 12:24:08 +05:30
redshift 1a620f988b fix build: export getNpubSuffix in daemon-client.ts 2026-04-30 12:13:17 +05:30
redshiftandGitHub 19f806563f Merge pull request #21 from Routstr/clients-refactor
Clients refactor
2026-04-30 06:39:42 +00:00
redshift c1c72bc147 Add 'refresh' CLI command to refresh models and integrations
- Added 'routstrd refresh' command that:
  - Calls /v1/models?refresh=true to refresh routstr21 models
  - Calls runIntegrationsForClients() for all registered clients
- Fixed type signature in refreshModelsAndIntegrations (returns any[] not void)
- Imports getClientsList and runIntegrationsForClients in cli.ts
2026-04-30 12:04:13 +05:30
redshift a5d68ccd0d Extract refreshModelsAndIntegrations into src/integrations/index.ts
- Created reusable refreshModelsAndIntegrations() function that combines
  model refresh with client integration refresh
- Updated src/daemon/index.ts to use the new function in both the scheduled
  refresh job and the initial bootstrap refresh
- Merged two chained .then() calls into one in the initial bootstrap flow
- Removed redundant imports (runIntegrationsForClients, getClientsList) from
  daemon/index.ts since they're now encapsulated in the function
2026-04-30 11:56:09 +05:30
redshift a14e24417a fixed a few thigns 2026-04-30 11:31:12 +05:30
redshift 91384b633e fix: use hyphen in addSuffixToId to match removeSuffixFromId 2026-04-30 11:20:16 +05:30
redshift ee6fef9062 fix: standardize on hyphen instead of underscore for client ID suffix 2026-04-30 11:18:53 +05:30
redshift 7a4dc1e3c3 refactor(clients): extract suffix logic into helper functions, stop modifying names
- Add addSuffixToId() and removeSuffixFromId() helper functions
- Only suffix client IDs, never names
- Update getClientsList, deleteClientAction, and addClientAction to use helpers
2026-04-30 11:17:42 +05:30
redshift dc5a5d32c5 refactor: move remote-mode client suffix handling into getClientsList 2026-04-30 09:45:04 +05:30
redshift 0dc40884a5 Simplify client creation: fetch list first instead of catch-and-fallback
Replace ensureDaemonClient (try-create → catch 'already exists' → fetch list) with
a single addDaemonClient that fetches the list first, checks if client exists,
then creates only if needed. Returns { client, created } in all cases.
2026-04-30 09:21:01 +05:30
redshift 366a129c3c refactor: move client logic from cli.ts and daemon-client.ts to clients.ts
- Moved addDaemonClient and ensureDaemonClient from daemon-client.ts to clients.ts
- Moved clients list/delete/add action handlers from cli.ts to clients.ts
- Updated cli.ts to call the new action functions from clients.ts
- Updated integrations/index.ts to import ensureDaemonClient from clients.ts
- Fixed circular dependency by having clients.ts import from ../integrations/registry instead of ../integrations
2026-04-29 23:14:10 +05:30
redshiftandGitHub 8bbb55f7d5 Merge pull request #20 from Routstr/add-remote-command
Added remote command.
2026-04-29 16:46:11 +00:00
redshift 90777f6c07 Added remote command. 2026-04-29 22:14:19 +05:30
redshiftandGitHub 7a986e415e Merge pull request #19 from Routstr/fix/remote-mode-clients-list
Fix/remote mode clients list
2026-04-28 10:19:43 +00:00
redshiftandGitHub f402e36f91 Merge branch 'main' into fix/remote-mode-clients-list 2026-04-28 10:19:34 +00:00
redshift fc7113be4b refactor: read clients list through abstraction for local and remote mode
Replace direct store.getState().clientIds access with a shared utility:
- getClientsFromStore(store) for daemon/local usage
- getClientsList() for remote CLI usage via daemon API

This ensures integration refresh logic and client management work
consistently whether running inside the daemon or connecting to a
remote daemon where store access is unavailable.

Updated:
- src/daemon/index.ts: use getClientsFromStore for integration refresh
- src/daemon/http/index.ts: use getClientsFromStore in /clients endpoints
- src/utils/daemon-client.ts: use getClientsList in ensureDaemonClient
- src/cli.ts: use getClientsList in clients list command
2026-04-28 15:22:21 +05:30
redshiftandGitHub 7fde0faea7 Merge pull request #17 from Routstr/feature/highlight-user-npub
Feature/highlight user npub
2026-04-28 09:50:34 +00:00
redshiftandGitHub 3c61ad2912 Merge pull request #16 from Routstr/add-remote-command
feat(daemon): make client id required in /clients/add endpoint
2026-04-28 09:49:28 +00:00
redshift 711a04f09d refactor: consolidate ensureDaemonClient in daemon-client.ts
- Move get-or-create client logic from integrations/index.ts into
  ensureDaemonClient() in daemon-client.ts as a generic utility.
- Update setupIntegration() and the CLI clients add --<integration>
  paths to use the new helper.
- Return { client, created } so callers can decide whether to log.
- Remove IntegrationClient alias and ensureIntegrationClient export.
2026-04-28 15:04:52 +05:30
redshift 2828d7c0ae feat(cli): highlight user npub in npubs list and suggest adding it if missing 2026-04-28 15:04:14 +05:30
redshift 97302af836 feat(daemon): make client id required in /clients/add endpoint 2026-04-28 14:48:59 +05:30
redshift a207acb645 refactor: extract addDaemonClient to eliminate duplicate /clients/add calls
- Add shared DaemonClient type and addDaemonClient() helper in
daemon-client.ts as the single source for POST /clients/add.
- Update ensureIntegrationClient() to use the new helper.
- Update CLI clients add command to use the new helper.
- Keeps existing error handling and 'already exists' fallback in
ensureIntegrationClient().
2026-04-28 14:34:12 +05:30
redshift 3f0a259cd8 feat(tui): filter usage entries by npub suffix in remote mode
- fetchUsage now filters entries to only those whose client ID ends with
  our npub suffix when running in remote daemon mode (daemonUrl + nsec)
- strips the suffix from client names before display, matching CLI behavior
- local mode unchanged: shows all usage entries
2026-04-28 14:05:58 +05:30
redshift cdc2c26c72 feat(cli): suffix client names with last 7 chars of npub in remote mode
- clients add: appends _<npub_suffix> to name when daemonUrl+nsec are set
- clients list: filters to only clients matching our npub suffix, strips suffix for display
- clients delete: auto-appends suffix to id before sending if not already present
- adds getNpubSuffix() helper in daemon-client.ts
2026-04-28 13:51:23 +05:30
redshift f9a7db9ae0 refactor: create integration clients through daemon instead of local sqlite
- clients add --pi-agent/--opencode/--openclaw/--claude-code now call
  /clients/add on the daemon instead of writing to local Bun SQLite
- add ensureIntegrationClient helper that creates via daemon and falls
  back to fetching existing client on 409
- update install*Integration signatures to accept apiKey instead of SdkStore
- update onboard setupIntegration to use daemon-backed path
- update daemon scheduled refresh to pass apiKeys directly
2026-04-28 13:08:00 +05:30
redshift ec8f7b962d fixed formatting when reading npubs 2026-04-28 13:01:08 +05:30
redshift ebec737191 feat(cli): add npubs management commands
- Add normalizeNostrPubkey, npubFromPubkey, npubFromSecretKey to nip98.ts
- Extend callDaemon to accept DELETE method
- Add  subcommands:
  - list: GET /npubs
  - add <npub>: POST /npubs (accepts hex pubkey or npub1...)
  - delete <npub>: DELETE /npubs/:npub (accepts hex pubkey or npub1...)
- All npubs commands go through callDaemon, so they work with
  remote daemons and are automatically NIP-98 signed
2026-04-28 11:16:14 +05:30
redshift 6461b0f84a fix(integrations): use remote daemon URL and callDaemon for client setups
- Export getDaemonBaseUrl from daemon-client for shared URL resolution
- Replace all hardcoded http://localhost: in client integrations
  (opencode, claudecode, openclaw, pi) with getDaemonBaseUrl(config)
- Replace raw fetch(http://localhost:/models) with callDaemon("/models")
  so model fetching works with remote daemons and gets NIP-98 signed
- Fix clients add command output to print the actual daemon base URL
  instead of hardcoded localhost
2026-04-28 10:07:20 +05:30
redshift 8d6a7d7f21 feat(cli): NIP-98 auth for remote daemon URLs
- Add nostr-tools dependency for NIP-98 event signing
- Add nsec field to RoutstrdConfig for remote daemon authentication
- Extract NIP-98 auth utilities into src/utils/nip98.ts (parseSecretKey,
  createNIP98Authorization with SHA-256 payload tags)
- Wire NIP-98 Authorization headers into callDaemon and isDaemonRunning
  whenever both daemonUrl and nsec are configured
- Refactor refund command to use callDaemon instead of hardcoded localhost
  so it works correctly with remote daemon URLs
2026-04-28 10:02:45 +05:30
redshift 7dfed2c052 Add daemonUrl config for remote daemon support
- Add optional daemonUrl field to RoutstrdConfig
- Update callDaemon and isDaemonRunning to use configurable base URL
- Disable auto-start when daemonUrl is set (Option A)
- Gate local-only commands: onboard, start, restart, mode, logs, service install
2026-04-28 09:26:50 +05:30
redshiftandGitHub b6520b5ef0 Merge pull request #12 from Routstr/chore/gitignore-worktrees
chore: ignore worktrees directory
2026-04-27 17:18:03 +00:00
redshiftandGitHub bf82a99957 Merge pull request #11 from Routstr/fix/dynamic-version
fix(cli): dynamically read version from package.json
2026-04-27 17:17:36 +00:00
redshift 927ec863bf feat(wallet): support COCOD_DIR env var for config dir
Allow overriding the default cocod config directory (~/.cocod)
via the COCOD_DIR environment variable. Falls back to existing
HOME/USERPROFILE logic when unset.

Bump version to 0.2.6.
2026-04-27 22:20:33 +05:30