Commit Graph
62 Commits
Author SHA1 Message Date
redshift cee4666f6e nwc integration 2026-05-19 01:25:27 +08:00
redshift 3f14ae8084 Merge branch 'main' of github.com-red:Routstr/routstrd 2026-05-17 11:49:39 +08:00
redshift fdf65ab0c9 reusing routstrclietn 2026-05-17 11:49:28 +08:00
redshift fd8f433a36 feat: add Docker dev environment and fix logging/cashu-ts
- Add Dockerfile, docker-compose.yml, and .dockerignore for Bun dev container
- Fix sdkLogger to use logger.warn instead of logger.log for warnings
- Add proper warn method to logger (writes to file instead of console)
- Use console.log for daemon startup messages to keep them visible
- Update cashu-ts getDecodedToken call with explicit well-known-pubkeys
- Use proof.amount.toNumber() for updated cashu-ts Amount type
2026-05-16 16:22:16 +08:00
redshift f427cc75ea feat: pass routstrPubkey from config to routeRequests when set 2026-05-14 17:43:30 +05:30
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
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
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 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 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 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 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
redshift 97302af836 feat(daemon): make client id required in /clients/add endpoint 2026-04-28 14:48:59 +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 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
redshift 2b6876ccd6 feat: add clients delete command
Add 'routstrd clients delete <id>' CLI command and POST /clients/delete
HTTP endpoint to remove a client by its ID.
2026-04-27 19:22:56 +05:30
redshift 57bfa94c58 fix: include /v1 suffix in all localhost URLs shown to users
Updates all user-facing log messages to include the /v1 path suffix,
so clients know to use http://localhost:${port}/v1 when configuring
their API endpoints.

- src/cli.ts:717 — clients add --setup-all flow
- src/cli.ts:757 — clients add -n ${name} flow
- src/daemon/index.ts:206 — daemon startup message
- src/start-daemon.ts:29 — daemon already running message
2026-04-25 15:45:23 +05:30
redshift 3a5d760b37 replaced routeRequestsNodeResponse with just routeRequests. 2026-04-22 23:39:57 +05:30
redshift 41993831af changed the refund interval to 42 mins 2026-04-21 18:07:23 +02:00
redshift 9ece12d565 removed duplicate entries for rpoviders and clients endpoints. 2026-04-21 08:10:56 +02:00
redshift 86eab89871 fixed the long error trace 2026-04-20 20:05:21 +02:00
redshift 7d439967ce feat(models): add model provider lookup with pricing info
Add -m/--model option to models serving a
specific model with their pricing details (prompt, completion, request,
max_cost in sats). Providers are sorted by max_cost (cheapest first).

New endpoint: GET /models/:id/providers
New function: getModelProviders() in model service
2026-04-09 16:45:32 +01:00
redshift 238f6cdb9d disabled refunding for now. 2026-04-06 18:53:44 +01:00
redshift 5e984e3f5e routstrd skill. decreased refresh interval to 21 mins.
centralized config in registry.
2026-04-03 23:50:10 +02:00
redshift d1574b6e9c integrations are updated automatically on model refresh. 2026-04-03 14:56:40 +02:00
redshift 557489ba4f removed logs 2026-04-03 13:11:56 +02:00
redshift dc363b1c20 Merge branch 'main' of github.com-red:Routstr/routstrd 2026-04-03 13:11:41 +02:00
redshift c04eaf0981 provdier list debugging 2026-04-03 13:11:04 +02:00
Evan Yang 81a1e969fe fix(wallet): silence cocod transport logs in CLI 2026-04-03 14:27:55 +08:00
Evan Yang 249075ad49 fix(wallet): harden cocod response parsing and receive error propagation 2026-04-03 14:27:55 +08:00
redshift cbaf26bda0 allowing xcashu mode right now and removed logs. 2026-04-02 22:45:52 +02:00
Evan Yang f40b0ba4e5 fix(wallet): treat cocod body errors as failures 2026-04-02 21:06:51 +08:00
redshift c0d3063bca added logs 2026-04-02 00:10:27 +02:00
redshift fcae75fa7c provider manage instnace is now persisted across calls. 2026-04-01 21:11:19 +02:00
redshift fe61ea43c0 fix: remove createUsageTracker, use usageTrackingDriver consistently
- Removed broken merge artifact with createUsageTracker
- Updated createDaemonRequestHandler to use usageTrackingDriver for all usage tracking
- Added walletClient to deps type
- Removed unused runWalletCommand and parseBalances from deps type
- Cleaned up unused imports in daemon/index.ts
2026-04-01 16:18:06 +02:00
redshift 243967f7a5 fixing merge issues 2026-04-01 16:14:11 +02:00
redshift dca3ca992f Merge branch 'wallet-integration' of github.com-red:Routstr/routstrd 2026-04-01 15:55:35 +02:00
redshift d0784a5c53 added automatic refund 2026-03-31 11:44:30 +01:00
redshift 849a4b6850 fixed the data limit 2026-03-30 21:54:57 +01:00
redshift 07adab2265 added a way to add clients 2026-03-30 21:06:30 +01:00
redshift e03342d119 fixed v1/messages pass thorugh bug 2026-03-28 19:12:01 +00:00
redshift cb699a3882 added a way to disable providers 2026-03-28 18:17:39 +00:00
redshift f1b388ef43 removed lazyrefund completely 2026-03-28 14:02:19 +00:00
redshift d5656e488c fixed legacySDK reading 2026-03-28 11:09:42 +00:00
redshift 020606d276 fixed usage tracking db 2026-03-28 08:42:25 +00:00
redshift 3c7e0c25ab bun driver to sdk 2026-03-27 21:57:32 +00:00
redshift 631f5832a1 checkpoint 2026-03-26 17:22:03 +00:00
redshift 44e439631e debug logs from sdk are now shown in routstrd logs 2026-03-23 13:24:19 +00:00