traderclaw-cli 1.0.110 → 1.0.112

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.
@@ -1585,6 +1585,25 @@ async function cmdGateway(args) {
1585
1585
  process.exit(1);
1586
1586
  }
1587
1587
 
1588
+ async function cmdMaintenance(subArgs) {
1589
+ const sub = subArgs[0];
1590
+ if (sub !== "session-cleanup") {
1591
+ printError("Usage: traderclaw maintenance session-cleanup");
1592
+ print("");
1593
+ printInfo("Archives bloated *.checkpoint.*.jsonl (and heartbeat session logs) under the OpenClaw agent sessions dir,");
1594
+ printInfo("then runs systemctl --user stop / daemon-reload / start on the gateway unit (same as TraderClaw persistence).");
1595
+ printInfo(`Env and cron examples: see ${join(PLUGIN_ROOT, "scripts", "openclaw-session-cleanup.sh")}`);
1596
+ process.exit(sub ? 1 : 0);
1597
+ }
1598
+ const scriptPath = join(PLUGIN_ROOT, "scripts", "openclaw-session-cleanup.sh");
1599
+ if (!existsSync(scriptPath)) {
1600
+ printError(`Session cleanup script not found: ${scriptPath}`);
1601
+ process.exit(1);
1602
+ }
1603
+ const r = spawnSync("bash", [scriptPath, ...subArgs.slice(1)], { stdio: "inherit", env: process.env });
1604
+ process.exit(r.status === null ? 1 : r.status);
1605
+ }
1606
+
1588
1607
  async function cmdLogin(args) {
1589
1608
  const config = readConfig();
1590
1609
  const pluginConfig = getPluginConfig(config);
@@ -3596,7 +3615,10 @@ async function cmdInstall(args) {
3596
3615
 
3597
3616
  /** Guided Codex OAuth sessions keyed by sessionId. */
3598
3617
  const oauthSessions = new Map();
3599
- const OPENAI_OAUTH_AUTHORIZE_RE = /https:\/\/auth\.openai\.com\/oauth\/authorize\S*/;
3618
+ // Matches the OAuth authorize URL from OpenClaw's output.
3619
+ // The \S+ (non-whitespace) tail captures the full query string; see trySendUrl()
3620
+ // for why we run this against a stripAnsi+CR-stripped copy of the output.
3621
+ const OPENAI_OAUTH_AUTHORIZE_RE = /https:\/\/auth\.openai\.com\/(?:oauth\/authorize|authorize)[^\s"]*/;
3600
3622
  const oauthSessionTtlMs = 15 * 60 * 1000;
3601
3623
 
3602
3624
  // Long-lived callback proxy on port 1455. Bound at wizard startup so
@@ -3837,12 +3859,20 @@ async function cmdInstall(args) {
3837
3859
  message:
3838
3860
  "OpenClaw did not provide a ChatGPT sign-in URL in time. Try again.",
3839
3861
  });
3840
- }, 45_000);
3862
+ }, 75_000);
3841
3863
 
3842
3864
  const trySendUrl = () => {
3843
3865
  if (responded) return;
3844
- const m = combined.match(OPENAI_OAUTH_AUTHORIZE_RE);
3866
+ // Strip ANSI escape codes and carriage returns before matching.
3867
+ // Newer OpenClaw uses rich terminal output (spinners, colors) and PTY
3868
+ // column-wrapping inserts \r\n in the middle of long OAuth URLs, causing
3869
+ // the regex to fail on the raw byte stream. Clean first, then match.
3870
+ const cleanedForUrl = stripAnsi(combined).replace(/\r/g, "");
3871
+ const m = cleanedForUrl.match(OPENAI_OAUTH_AUTHORIZE_RE);
3845
3872
  if (!m || !m[0]) return;
3873
+ // Strip any trailing ANSI remnants that slipped through (e.g. \x1b[0m appended by colour reset)
3874
+ const authUrl = m[0].replace(/\x1b[^a-zA-Z]*[a-zA-Z]?$/g, "").trim();
3875
+ if (!authUrl.startsWith("https://")) return;
3846
3876
  clearTimeout(urlTimeout);
3847
3877
  responded = true;
3848
3878
  oauthSessions.set(sessionId, {
@@ -3850,13 +3880,13 @@ async function cmdInstall(args) {
3850
3880
  createdAt: Date.now(),
3851
3881
  updatedAt: Date.now(),
3852
3882
  status: "awaiting_browser_callback",
3853
- authUrl: m[0],
3883
+ authUrl,
3854
3884
  message: "Sign in in this same browser. OpenClaw is waiting for callback...",
3855
3885
  detail: "",
3856
3886
  exitCode: null,
3857
3887
  submitted: false,
3858
3888
  });
3859
- respondJson(200, { ok: true, sessionId, authUrl: m[0] });
3889
+ respondJson(200, { ok: true, sessionId, authUrl });
3860
3890
  };
3861
3891
 
3862
3892
  child.stdout?.on("data", (d) => {
@@ -4481,6 +4511,7 @@ Commands:
4481
4511
  install Launch installer flows (--wizard for localhost GUI)
4482
4512
  repair-openclaw Re-run npm install in the global openclaw package (fixes missing grammy / @buape/carbon; uses --ignore-scripts so @discordjs/opus does not require build tools)
4483
4513
  gateway Gateway helpers (see subcommands below)
4514
+ maintenance Session disk hygiene (checkpoint archive + gateway restart)
4484
4515
  login Re-authenticate (uses refresh token when valid; full challenge only if needed)
4485
4516
  logout Revoke current session and clear tokens
4486
4517
  status Check connection health and wallet status
@@ -4535,6 +4566,9 @@ Gateway subcommands (Linux):
4535
4566
  gateway start Start gateway after manual edits
4536
4567
  gateway ensure-persistent Set up systemd linger + enable unit
4537
4568
 
4569
+ Maintenance:
4570
+ maintenance session-cleanup Archive large session checkpoints + restart gateway (see script header for OPENCLAW_STATE_DIR, STRIP_ALL_CHECKPOINTS, DRY_RUN, ARCHIVE_RETENTION_DAYS)
4571
+
4538
4572
  Install wizard (traderclaw install --wizard):
4539
4573
  --port Local port for the wizard (default 17890)
4540
4574
  --llm-provider e.g. openai, openai-codex, anthropic
@@ -4572,6 +4606,7 @@ Examples:
4572
4606
  traderclaw config set-llm cli-cloud MY_API_KEY
4573
4607
  traderclaw gateway stop # pause gateway to edit openclaw.json manually
4574
4608
  traderclaw gateway start # resume after manual edit
4609
+ STRIP_ALL_CHECKPOINTS=1 OPENCLAW_STATE_DIR=/root/.openclaw traderclaw maintenance session-cleanup
4575
4610
  traderclaw test-session
4576
4611
  traderclaw test-session --wallet-private-key <base58_key>
4577
4612
  traderclaw update
@@ -4833,6 +4868,9 @@ async function main() {
4833
4868
  case "gateway":
4834
4869
  await cmdGateway(args.slice(1));
4835
4870
  break;
4871
+ case "maintenance":
4872
+ await cmdMaintenance(args.slice(1));
4873
+ break;
4836
4874
  case "login":
4837
4875
  await cmdLogin(args.slice(1));
4838
4876
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "traderclaw-cli",
3
- "version": "1.0.110",
3
+ "version": "1.0.112",
4
4
  "description": "Global TraderClaw CLI (install --wizard, setup, precheck). Installs solana-traderclaw as a dependency for OpenClaw plugin files.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,7 +17,7 @@
17
17
  "node": ">=22"
18
18
  },
19
19
  "dependencies": {
20
- "solana-traderclaw": "^1.0.110"
20
+ "solana-traderclaw": "^1.0.112"
21
21
  },
22
22
  "keywords": [
23
23
  "traderclaw",