Skip to content

Commit c29403a

Browse files
committed
fix: restore backup.ts and tps.ts to origin/main (conflict marker cleanup)
1 parent 583967a commit c29403a

2 files changed

Lines changed: 10 additions & 46 deletions

File tree

packages/cli/bin/tps.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ async function main() {
583583
const validMailActions = ["send", "check", "list", "stats", "log", "read", "watch", "search", "relay", "topic", "subscribe", "unsubscribe", "publish"];
584584
if (cli.flags.help || !action || !validMailActions.includes(action)) {
585585
console.log(
586-
"Usage:\n tps mail send <agent> <message> Send mail to a local or remote agent\n tps mail check [agent] Read new messages (marks as read)\n tps mail watch [agent] Watch inbox for new messages\n tps mail list [agent] List all messages (read + unread) [--lines N]\n tps mail read <agent> <id> Show a specific message by ID (prefix ok)\n tps mail search <query> Search mail history using full-text search\n tps mail log [agent] Show audit log [--since YYYY-MM-DD] [--limit N]\n tps mail relay [start|stop|status] Mail relay daemon\n tps mail topic create <name> Create a topic [--desc \"...\"]\n tps mail topic list List all topics\n tps mail subscribe <topic> Subscribe to a topic [--id <agentId>] [--from-beginning]\n tps mail unsubscribe <topic> Unsubscribe from a topic [--id <agentId>]\n tps mail publish <topic> <message> Publish to a topic [--from <agentId>]"
586+
"Usage:\n tps mail send <agent> <message> Send mail to a local or remote agent\n tps mail check [agent] Read new messages (marks as read)\n tps mail watch [agent] Watch inbox for new messages\n tps mail list [agent] List all messages (read + unread)\n tps mail read <agent> <id> Show a specific message by ID (prefix ok)\n tps mail search <query> Search mail history using full-text search\n tps mail log [agent] Show audit log [--since YYYY-MM-DD] [--limit N]\n tps mail relay [start|stop|status] Mail relay daemon\n tps mail topic create <name> Create a topic [--desc \"...\"]\n tps mail topic list List all topics\n tps mail subscribe <topic> Subscribe to a topic [--id <agentId>] [--from-beginning]\n tps mail unsubscribe <topic> Unsubscribe from a topic [--id <agentId>]\n tps mail publish <topic> <message> Publish to a topic [--from <agentId>]"
587587
);
588588
process.exit(cli.flags.help ? 0 : 1);
589589
}
@@ -634,10 +634,7 @@ async function main() {
634634
messageId: action === "read" ? rest[2] : undefined,
635635
json: cli.flags.json,
636636
since: cli.flags.since,
637-
limit:
638-
action === "list"
639-
? Number(cli.flags.lines ?? 20)
640-
: (cli.flags.limit ? Number(cli.flags.limit) : undefined),
637+
limit: cli.flags.limit ? Number(cli.flags.limit) : undefined,
641638
});
642639
}
643640
break;
@@ -683,7 +680,6 @@ async function main() {
683680
break;
684681
}
685682
case "backup": {
686-
<<<<<<< HEAD
687683
const subCmd = rest[0];
688684
if (subCmd === "keys") {
689685
const { runBackupSecrets } = await import("../src/commands/backup.js");
@@ -692,10 +688,6 @@ async function main() {
692688
const { runBackup } = await import("../src/commands/backup.js");
693689
await runBackup({ agentId: subCmd });
694690
}
695-
=======
696-
const { runBackup } = await import("../src/commands/backup.js");
697-
await runBackup({});
698-
>>>>>>> f5544c6 (task complete: bc996f0e-e0c5-435f-afa7-3dda8c11a702)
699691
break;
700692
}
701693
case "restore": {

packages/cli/src/commands/backup.ts

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -490,46 +490,22 @@ function backupFilesWithManifest(workspace: string, entry: OpenClawAgent | null,
490490
}
491491

492492
export async function runBackup(args: BackupArgs): Promise<void> {
493-
<<<<<<< HEAD
494493
if (!args.agentId) throw new Error("Usage: tps backup <agent-id>");
495494
const safeId = sanitizeAgentId(args.agentId);
496495
const workspace = workspacePath(safeId);
497-
=======
498-
void args;
499-
>>>>>>> f5544c6 (task complete: bc996f0e-e0c5-435f-afa7-3dda8c11a702)
500496

501-
const home = homedir();
502-
const backupDir = join(home, ".tps", "backups");
503-
mkdirSync(backupDir, { recursive: true });
504-
505-
const archivePath = join(backupDir, `backup-${new Date().toISOString().slice(0, 10)}.tar.gz`);
506-
const includedFiles = Array.from(new Set([
507-
...globSync(".tps/identity/*.key", { cwd: home }),
508-
...globSync(".tps/secrets/**/*", { cwd: home }),
509-
...globSync(".tps/agents/*/agent.yaml", { cwd: home }),
510-
...globSync(".codex/auth.json", { cwd: home }),
511-
])).filter((relativePath) => {
512-
const absolutePath = join(home, relativePath);
513-
return existsSync(absolutePath) && lstatSync(absolutePath).isFile();
514-
}).sort();
515-
516-
if (includedFiles.length === 0) {
517-
console.log("No TPS backup files found.");
518-
return;
497+
if (!existsSync(workspace)) {
498+
throw new Error(`Workspace not found for ${safeId}`);
519499
}
520500

521-
const shellQuote = (value: string): string => `'${value.replace(/'/g, `'\\''`)}'`;
522-
const tarArgs = includedFiles.map(shellQuote).join(" ");
523-
execSync(`tar czf ${shellQuote(archivePath)} -C ${shellQuote(home)} ${tarArgs}`, {
524-
stdio: "pipe",
525-
});
526-
chmodSync(archivePath, 0o600);
527-
528-
for (const relativePath of includedFiles) {
529-
console.log(relativePath);
501+
const configPath = args.configPath ?? resolveConfigPath();
502+
let config: OpenClawConfig | null = null;
503+
let agentEntry: OpenClawAgent | null = null;
504+
if (configPath) {
505+
config = readOpenClawConfig(configPath);
506+
agentEntry = findOpenClawAgentEntry(config, safeId) ?? null;
530507
}
531508

532-
<<<<<<< HEAD
533509
if (!agentEntry) {
534510
agentEntry = { id: safeId, name: safeId, workspace };
535511
}
@@ -665,10 +641,6 @@ export async function runBackupSecrets(): Promise<void> {
665641
console.log(`Archive: ${archivePath} (${statSync(archivePath).size} bytes)`);
666642
}
667643

668-
=======
669-
console.log(`Archive: ${archivePath} (${statSync(archivePath).size} bytes)`);
670-
}
671-
>>>>>>> f5544c6 (task complete: bc996f0e-e0c5-435f-afa7-3dda8c11a702)
672644
export async function runRestore(args: RestoreArgs): Promise<void> {
673645
const safeTarget = sanitizeAgentId(args.agentId);
674646
const archive = resolve(args.archivePath);

0 commit comments

Comments
 (0)