routstrd 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -23017,7 +23017,47 @@ function parseChoice(input) {
23017
23017
  }
23018
23018
  return 1;
23019
23019
  }
23020
- async function setupIntegration(config) {
23020
+ async function installIntegrationByKey(config, key) {
23021
+ const integrationConfig = CLIENT_CONFIGS[key];
23022
+ if (!integrationConfig) {
23023
+ console.log(`Unknown integration: ${key}`);
23024
+ return;
23025
+ }
23026
+ const { client, created } = await addDaemonClient(integrationConfig.name);
23027
+ if (created) {
23028
+ console.log(`Created new API key for ${integrationConfig.name}`);
23029
+ } else {
23030
+ console.log(`Using existing API key for ${integrationConfig.name}`);
23031
+ }
23032
+ switch (key) {
23033
+ case "opencode":
23034
+ await installOpencodeIntegration(config, client.apiKey, integrationConfig);
23035
+ return;
23036
+ case "openclaw":
23037
+ await installOpenClawIntegration(config, client.apiKey, integrationConfig);
23038
+ return;
23039
+ case "pi-agent":
23040
+ await installPiIntegration(config, client.apiKey, integrationConfig);
23041
+ return;
23042
+ case "claude-code":
23043
+ await installClaudeCodeIntegration(config, client.apiKey, integrationConfig);
23044
+ return;
23045
+ case "hermes":
23046
+ await installHermesIntegration(config, client.apiKey, integrationConfig);
23047
+ return;
23048
+ default:
23049
+ console.log(`Unknown integration: ${key}`);
23050
+ }
23051
+ }
23052
+ async function setupIntegration(config, integrationKey) {
23053
+ if (integrationKey === "skip") {
23054
+ console.log("Skipping integration setup.");
23055
+ return;
23056
+ }
23057
+ if (integrationKey !== undefined) {
23058
+ await installIntegrationByKey(config, integrationKey);
23059
+ return;
23060
+ }
23021
23061
  console.log(`
23022
23062
  Choose an integration to set up:`);
23023
23063
  console.log("1. OpenCode (default)");
@@ -23040,33 +23080,7 @@ Choose an integration to set up:`);
23040
23080
  console.log("Skipping integration setup.");
23041
23081
  return;
23042
23082
  }
23043
- const integrationConfig = CLIENT_CONFIGS[key];
23044
- const { client, created } = await addDaemonClient(integrationConfig.name);
23045
- if (created) {
23046
- console.log(`Created new API key for ${integrationConfig.name}`);
23047
- } else {
23048
- console.log(`Using existing API key for ${integrationConfig.name}`);
23049
- }
23050
- if (key === "opencode") {
23051
- await installOpencodeIntegration(config, client.apiKey, integrationConfig);
23052
- return;
23053
- }
23054
- if (key === "openclaw") {
23055
- await installOpenClawIntegration(config, client.apiKey, integrationConfig);
23056
- return;
23057
- }
23058
- if (key === "pi-agent") {
23059
- await installPiIntegration(config, client.apiKey, integrationConfig);
23060
- return;
23061
- }
23062
- if (key === "claude-code") {
23063
- await installClaudeCodeIntegration(config, client.apiKey, integrationConfig);
23064
- return;
23065
- }
23066
- if (key === "hermes") {
23067
- await installHermesIntegration(config, client.apiKey, integrationConfig);
23068
- return;
23069
- }
23083
+ await installIntegrationByKey(config, key);
23070
23084
  }
23071
23085
 
23072
23086
  // node_modules/@noble/hashes/utils.js
@@ -27170,15 +27184,22 @@ zoo`.split(`
27170
27184
  // package.json
27171
27185
  var package_default = {
27172
27186
  name: "routstrd",
27173
- version: "0.4.5",
27187
+ version: "0.4.6",
27174
27188
  module: "src/index.ts",
27175
27189
  type: "module",
27176
27190
  private: false,
27177
27191
  bin: {
27178
27192
  routstrd: "./dist/index.js"
27179
27193
  },
27194
+ files: [
27195
+ "dist",
27196
+ "src",
27197
+ "README.md",
27198
+ "SECURITY.md"
27199
+ ],
27180
27200
  scripts: {
27181
27201
  start: "bun src/index.ts start",
27202
+ stop: "bun src/index.ts stop",
27182
27203
  monitor: "bun src/index.ts monitor",
27183
27204
  lint: "tsc --noEmit",
27184
27205
  test: "bun test",
@@ -27196,7 +27217,7 @@ var package_default = {
27196
27217
  "@cashu/cashu-ts": "^4.3.0",
27197
27218
  "@cashu/coco-core": "^1.0.1",
27198
27219
  "@cashu/coco-sqlite-bun": "^1.0.1",
27199
- "@routstr/sdk": "^0.4.1",
27220
+ "@routstr/sdk": "^0.4.2",
27200
27221
  "@scure/bip39": "^2.2.0",
27201
27222
  "applesauce-core": "^5.1.0",
27202
27223
  "applesauce-relay": "^5.1.0",
@@ -27320,7 +27341,7 @@ async function requireLocalDaemon() {
27320
27341
  process.exit(1);
27321
27342
  }
27322
27343
  }
27323
- async function initDaemon() {
27344
+ async function initDaemon(integrationKey) {
27324
27345
  console.log("Initializing routstrd...");
27325
27346
  if (!existsSync14(CONFIG_DIR)) {
27326
27347
  console.log(`Created config directory: ${CONFIG_DIR}`);
@@ -27370,7 +27391,7 @@ A new Nostr identity has been generated for authentication.`);
27370
27391
  }
27371
27392
  initializeWallet();
27372
27393
  await startDaemon({ port: String(config.port || 8008), host: config.host || undefined });
27373
- await setupIntegration(config);
27394
+ await setupIntegration(config, integrationKey);
27374
27395
  console.log(`
27375
27396
  Initialization complete!`);
27376
27397
  console.log(`
@@ -27569,10 +27590,32 @@ program.command("local").description("Switch back to local daemon mode (removes
27569
27590
  Use 'routstrd onboard' for first time using local mode or 'routstrd start' to start the local daemon if you already are using it.`);
27570
27591
  console.log(`You can view the config file at: ${CONFIG_FILE}`);
27571
27592
  });
27572
- program.command("onboard").description("Initialize routstrd (creates config directory and initializes wallet)").action(async () => {
27593
+ program.command("onboard").description("Initialize routstrd (creates config directory and initializes wallet)").option("--opencode", "Set up OpenCode integration (non-interactive)").option("--openclaw", "Set up OpenClaw integration (non-interactive)").option("--pi-agent", "Set up Pi Agent integration (non-interactive)").option("--claude-code", "Set up Claude Code integration (non-interactive)").option("--hermes", "Set up Hermes integration (non-interactive)").option("--skip-integration", "Skip integration setup").action(async (options) => {
27573
27594
  await requireLocalDaemon();
27595
+ const integrationFlags = {
27596
+ opencode: options.opencode,
27597
+ openclaw: options.openclaw,
27598
+ "pi-agent": options.piAgent,
27599
+ "claude-code": options.claudeCode,
27600
+ hermes: options.hermes
27601
+ };
27602
+ const selectedIntegrations = Object.keys(integrationFlags).filter((key) => integrationFlags[key]);
27603
+ if (selectedIntegrations.length > 1) {
27604
+ console.error("Error: use only one integration flag, or use 'routstrd clients add' for multiple clients.");
27605
+ process.exit(1);
27606
+ }
27607
+ if (options.skipIntegration && selectedIntegrations.length > 0) {
27608
+ console.error("Error: --skip-integration cannot be combined with an integration flag.");
27609
+ process.exit(1);
27610
+ }
27611
+ let integrationKey;
27612
+ if (options.skipIntegration) {
27613
+ integrationKey = "skip";
27614
+ } else if (selectedIntegrations.length === 1) {
27615
+ integrationKey = selectedIntegrations[0];
27616
+ }
27574
27617
  try {
27575
- await initDaemon();
27618
+ await initDaemon(integrationKey);
27576
27619
  } catch (error) {
27577
27620
  if (error instanceof WalletMigrationConflictError) {
27578
27621
  console.error(error.message);
package/package.json CHANGED
@@ -1,14 +1,21 @@
1
1
  {
2
2
  "name": "routstrd",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "bin": {
8
8
  "routstrd": "./dist/index.js"
9
9
  },
10
+ "files": [
11
+ "dist",
12
+ "src",
13
+ "README.md",
14
+ "SECURITY.md"
15
+ ],
10
16
  "scripts": {
11
17
  "start": "bun src/index.ts start",
18
+ "stop": "bun src/index.ts stop",
12
19
  "monitor": "bun src/index.ts monitor",
13
20
  "lint": "tsc --noEmit",
14
21
  "test": "bun test",
@@ -26,7 +33,7 @@
26
33
  "@cashu/cashu-ts": "^4.3.0",
27
34
  "@cashu/coco-core": "^1.0.1",
28
35
  "@cashu/coco-sqlite-bun": "^1.0.1",
29
- "@routstr/sdk": "^0.4.1",
36
+ "@routstr/sdk": "^0.4.2",
30
37
  "@scure/bip39": "^2.2.0",
31
38
  "applesauce-core": "^5.1.0",
32
39
  "applesauce-relay": "^5.1.0",
package/src/cli.ts CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  type RoutstrdConfig,
29
29
  } from "./utils/config";
30
30
  import { COCO_LOGS_DIR, logger } from "./utils/logger";
31
- import { setupIntegration, runIntegrationsForClients } from "./integrations";
31
+ import { setupIntegration, runIntegrationsForClients, type IntegrationKey } from "./integrations";
32
32
  import {
33
33
  assertLegacyCocodNotRunning,
34
34
  claimLegacyCocodPidFile,
@@ -215,7 +215,7 @@ async function requireLocalDaemon(): Promise<void> {
215
215
  }
216
216
  }
217
217
 
218
- async function initDaemon(): Promise<void> {
218
+ async function initDaemon(integrationKey?: IntegrationKey): Promise<void> {
219
219
  console.log("Initializing routstrd...");
220
220
 
221
221
  // Create config directory (0700, correcting existing installs too)
@@ -273,7 +273,7 @@ async function initDaemon(): Promise<void> {
273
273
 
274
274
  await startDaemon({ port: String(config.port || 8008), host: config.host || undefined });
275
275
 
276
- await setupIntegration(config);
276
+ await setupIntegration(config, integrationKey);
277
277
 
278
278
  console.log("\nInitialization complete!");
279
279
  console.log(
@@ -574,20 +574,68 @@ program
574
574
  .description(
575
575
  "Initialize routstrd (creates config directory and initializes wallet)",
576
576
  )
577
- .action(async () => {
578
- await requireLocalDaemon();
579
- try {
580
- await initDaemon();
581
- } catch (error) {
582
- // An expected, user-actionable refusal — print the structured message
583
- // without Bun's unhandled-rejection source snippet and stack trace.
584
- if (error instanceof WalletMigrationConflictError) {
585
- console.error(error.message);
577
+ .option("--opencode", "Set up OpenCode integration (non-interactive)")
578
+ .option("--openclaw", "Set up OpenClaw integration (non-interactive)")
579
+ .option("--pi-agent", "Set up Pi Agent integration (non-interactive)")
580
+ .option("--claude-code", "Set up Claude Code integration (non-interactive)")
581
+ .option("--hermes", "Set up Hermes integration (non-interactive)")
582
+ .option("--skip-integration", "Skip integration setup")
583
+ .action(
584
+ async (options: {
585
+ opencode?: boolean;
586
+ openclaw?: boolean;
587
+ piAgent?: boolean;
588
+ claudeCode?: boolean;
589
+ hermes?: boolean;
590
+ skipIntegration?: boolean;
591
+ }) => {
592
+ await requireLocalDaemon();
593
+
594
+ const integrationFlags: Record<string, boolean | undefined> = {
595
+ opencode: options.opencode,
596
+ openclaw: options.openclaw,
597
+ "pi-agent": options.piAgent,
598
+ "claude-code": options.claudeCode,
599
+ hermes: options.hermes,
600
+ };
601
+ const selectedIntegrations = Object.keys(integrationFlags).filter(
602
+ (key) => integrationFlags[key],
603
+ );
604
+
605
+ if (selectedIntegrations.length > 1) {
606
+ console.error(
607
+ "Error: use only one integration flag, or use 'routstrd clients add' for multiple clients.",
608
+ );
586
609
  process.exit(1);
587
610
  }
588
- throw error;
589
- }
590
- });
611
+
612
+ if (options.skipIntegration && selectedIntegrations.length > 0) {
613
+ console.error(
614
+ "Error: --skip-integration cannot be combined with an integration flag.",
615
+ );
616
+ process.exit(1);
617
+ }
618
+
619
+ let integrationKey: IntegrationKey | undefined;
620
+ if (options.skipIntegration) {
621
+ integrationKey = "skip";
622
+ } else if (selectedIntegrations.length === 1) {
623
+ integrationKey = selectedIntegrations[0];
624
+ }
625
+
626
+ try {
627
+ await initDaemon(integrationKey);
628
+ } catch (error) {
629
+ // An expected, user-actionable refusal — print the structured message
630
+ // without Bun's unhandled-rejection source snippet and stack trace.
631
+ if (error instanceof WalletMigrationConflictError) {
632
+ console.error(error.message);
633
+ process.exit(1);
634
+ }
635
+ throw error;
636
+ }
637
+ },
638
+ );
591
639
 
592
640
  // Start - start the background daemon
593
641
  program