Commit Graph
230 Commits
Author SHA1 Message Date
redshift f427cc75ea feat: pass routstrPubkey from config to routeRequests when set 2026-05-14 17:43:30 +05:30
redshiftandGitHub d73f8e5e90 Merge pull request #33 from Routstr/feat/structured-logging
feat(daemon): wire SdkLogger with per-request reqId prefixing
2026-05-09 08:44:21 +00:00
redshiftandGitHub 0685428506 Merge pull request #31 from Routstr/worktree-tui-client-column
feat: widen and reposition client column in TUI recent requests
2026-05-09 03:33:48 +00:00
redshiftandGitHub 384f421b62 Merge pull request #32 from Routstr/feat/tui-npubs-tab
feat(tui): add Npubs tab grouping usage by ownerNpub
2026-05-09 03:33:18 +00:00
redshift bcbf5bfc44 feat(daemon): wire SdkLogger through daemon with per-request reqId prefixing
- daemon/index.ts: add makeSdkLogger() factory, wire daemonSdkLogger into
  createBunSqliteDriver, createProviderRegistryFromStore, ModelManager, ProviderManager
- daemon/http/index.ts: add makeSdkLogger() factory, generate per-request
  reqId via randomBytes(4), pass reqLogger = sdkLogger.child("req:${reqId}")
  to routeRequests so every log line from a request is prefixed [req:XXXXXXXX]
- start-daemon.ts: remove >> logfile 2>&1 redirect and getTodayLogFile();
  all file logging now goes through the daemon's writeLog() with daily rotation

Result: Every log line from a request is prefixed [req:XXXXXXXX], all entries
have [ISO] [INFO/ERROR/DEBUG] timestamps, no duplicates, and the log file
rotates correctly at midnight.
2026-05-08 19:20:00 +08:00
redshift d098d25bc0 feat(tui): add Npubs tab grouping usage by ownerNpub
- Add 'npubs' tab between Clients and Recent (key 7)
- Tab is hidden when no clients have ownerNpub set
- Groups usage entries by ownerNpub via client-id → npub mapping
- Shows truncated npub (first 10 + … + last 6) with full npub on detail line
- Displays requests, cost, tokens, avg cost per npub with bar charts
- Includes 'Top Models per Npub' sub-section
- Tab keys dynamically renumbered (1-7 without npubs, 1-8 with)
- Falls back to Clients tab if Npubs becomes unavailable on refresh
2026-05-08 18:59:17 +08:00
redshiftandClaude Opus 4.7 7a3ae208cd feat: move client column to last position and widen to 14 chars
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-08 16:58:07 +08:00
redshift c6290eb356 bump 2026-05-07 21:00:54 +05:30
redshiftandGitHub cd59835e2a Merge pull request #30 from Routstr/worktree-tui-client-column
feat: add client column to recent transactions in TUI
2026-05-07 15:29:30 +00:00
redshiftandGitHub e881a312d0 Merge pull request #29 from Routstr/fix/not-enough-proofs-balance-error
fix: surface cocod "Not enough proofs" as InsufficientBalanceError
2026-05-07 15:29:11 +00:00
redshiftandGitHub ab993d18a5 Merge pull request #28 from Routstr/fix/provider-sync
fix: sync bootstrapped providers into store so providers list is complete
2026-05-07 15:28:43 +00:00
redshiftandClaude Opus 4.7 5aec1af79b feat: add client column to recent transactions in TUI
Adds a CLIENT column between TIME and MODEL in the Recent Requests tab,
color-coded using CLIENT_COLORS. Entries without a client show "unknown".

Closes #25

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 12:38:21 +08:00
redshiftandClaude Sonnet 4 622afb04a5 fix: sync bootstrapped providers into store so providers list is complete
After bootstrapProviders runs, newly discovered URLs (e.g. privateprovider.xyz)
were only known to the ModelManager cache and never written into the store's
baseUrlsList. This caused `providers list` and `models -m <id>` to show
different sets of providers. Now the bootstrap step merges any new URLs into
the store so both commands draw from the same source of truth.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
2026-05-06 20:29:40 +08:00
redshiftandClaude Sonnet 4 3abc028395 fix: surface cocod "Not enough proofs" as InsufficientBalanceError
When cocod cannot assemble enough proofs to send (e.g. due to
denomination fragmentation or stale proof state), it returns
"Send failed: Not enough proofs to send". This was propagating
as a generic Error, causing the HTTP handler to return 500 instead
of the structured 402 insufficient_balance response.

Map that cocod error to InsufficientBalanceError in walletAdapter.sendToken
so the existing handler path returns the correct 402.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
2026-05-06 18:32:46 +08:00
redshift 5771a47054 feat: show available flags when clients add is called without options 2026-05-04 16:11:57 +00:00
redshift a0ba9f337b feat: add --hermes flag to clients add CLI command 2026-05-04 16:03:39 +00:00
redshift ba3d5ff336 Merge branch 'main' of https://github.com/Routstr/routstrd into feat/hermes-integration 2026-05-04 15:55:52 +00:00
redshift a89ff52cbb fix: handle unwrapped response in npubs update command
PATCH /npubs returns { npub, pubkey, role } at the top level, not
wrapped in { output }. Use result.output ?? result to handle both
response formats.
2026-05-04 20:56:36 +05:30
redshift 52dcecbefe working on adding role update feature 2026-05-04 20:48:53 +05:30
redshift 26fd7d3808 bump version to 0.2.15 2026-05-04 11:40:10 +08:00
redshift aaad1162de Merge branch 'main' of github.com-red:Routstr/routstrd 2026-05-04 11:36:12 +08:00
redshift 4cdd05fd98 feat: show role in npubs list output
- Updated npubs list to display role (admin/user) for each npub
- Changed header from 'Admin npubs' to 'Npubs' to reflect all roles
- Updated command descriptions to reflect broader scope
- Also fixed 'admin npub' message in add command output
2026-05-04 11:35:44 +08:00
redshift 84fd05f2d5 fix: properly print npub objects in 'npubs list' command
The daemon now returns npubs as objects with npub/role fields, not plain
strings. Updated the CLI to handle the new NpubEntry type format.
2026-05-04 01:09:11 +08:00
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 10937f851c feat: add Hermes integration
- Add new installHermesIntegration to write ~/.hermes/config.yaml
- Prepend model block with base_url/api_key/default model at top
- Append custom_providers block at the bottom
- Use 3rd model in daemon list as default
- Add Hermes to setup menu and registry
2026-04-30 21:42:53 +05:30
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