openclaw-teleport 0.2.0 → 0.2.2

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/cli.mjs CHANGED
@@ -263,6 +263,21 @@ async function pack(agentId, outputPath) {
263
263
  allFiles.push(`cron/${f}`);
264
264
  }
265
265
  console.log(` \u2705 ${cronFiles.length} cron files`);
266
+ console.log("\u{1F510} Collecting credentials...");
267
+ const credDir = path2.join(OPENCLAW_DIR2, "credentials");
268
+ let credCount = 0;
269
+ if (fs2.existsSync(credDir)) {
270
+ const credFiles = fs2.readdirSync(credDir).filter((f) => f.endsWith(".json"));
271
+ for (const f of credFiles) {
272
+ const src = path2.join(credDir, f);
273
+ const dst = path2.join(stageDir, "credentials", f);
274
+ fs2.mkdirSync(path2.dirname(dst), { recursive: true });
275
+ fs2.copyFileSync(src, dst);
276
+ allFiles.push(`credentials/${f}`);
277
+ credCount++;
278
+ }
279
+ }
280
+ console.log(` \u2705 ${credCount} credential files`);
266
281
  console.log("\u23F0 Extracting cron job definitions...");
267
282
  const cronJobs = loadCronJobs(agent.id);
268
283
  console.log(` \u2705 ${cronJobs.length} cron jobs for ${agent.id}`);
@@ -278,6 +293,7 @@ async function pack(agentId, outputPath) {
278
293
  const agentDefaults = sanitizeAgentDefaults(config.agents?.defaults ?? {});
279
294
  const modelsConfig = config.models ?? {};
280
295
  const bindingsConfig = config.bindings ?? [];
296
+ const gatewayConfig = config.gateway ?? {};
281
297
  const manifest = {
282
298
  agent_id: agent.id,
283
299
  agent_name: agent.name,
@@ -289,7 +305,8 @@ async function pack(agentId, outputPath) {
289
305
  cron_jobs: cronJobs,
290
306
  agent_defaults: agentDefaults,
291
307
  models_config: modelsConfig,
292
- bindings: bindingsConfig
308
+ bindings: bindingsConfig,
309
+ gateway: gatewayConfig
293
310
  };
294
311
  const manifestPath = path2.join(stageDir, "manifest.json");
295
312
  fs2.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
@@ -450,6 +467,10 @@ function writeAgentConfig(manifest, stageDir, targetWorkspace) {
450
467
  console.log(" \u23ED\uFE0F Bindings already exist, skipping");
451
468
  }
452
469
  }
470
+ if (manifest.gateway && Object.keys(manifest.gateway).length > 0) {
471
+ existingConfig.gateway = { ...existingConfig.gateway ?? {}, ...manifest.gateway };
472
+ console.log(" \u2705 Gateway config restored");
473
+ }
453
474
  fs3.writeFileSync(CONFIG_PATH2, JSON.stringify(existingConfig, null, 2));
454
475
  } else {
455
476
  const newConfig = {
@@ -473,6 +494,10 @@ function writeAgentConfig(manifest, stageDir, targetWorkspace) {
473
494
  newConfig.bindings = manifest.bindings;
474
495
  console.log(" \u2705 Bindings restored");
475
496
  }
497
+ if (manifest.gateway && Object.keys(manifest.gateway).length > 0) {
498
+ newConfig.gateway = manifest.gateway;
499
+ console.log(" \u2705 Gateway config restored");
500
+ }
476
501
  fs3.writeFileSync(CONFIG_PATH2, JSON.stringify(newConfig, null, 2));
477
502
  console.log(" \u2705 New openclaw.json created");
478
503
  }
@@ -519,6 +544,22 @@ function restoreCronJobs(manifest, stageDir) {
519
544
  }
520
545
  return manifest.cron_jobs?.length ?? cronFileCount;
521
546
  }
547
+ function restoreCredentials(stageDir) {
548
+ console.log("\u{1F510} Restoring credentials...");
549
+ const credSrc = path3.join(stageDir, "credentials");
550
+ if (!fs3.existsSync(credSrc)) {
551
+ console.log(" (none)");
552
+ return 0;
553
+ }
554
+ const credDst = path3.join(OPENCLAW_DIR3, "credentials");
555
+ fs3.mkdirSync(credDst, { recursive: true });
556
+ const files = fs3.readdirSync(credSrc).filter((f) => f.endsWith(".json"));
557
+ for (const f of files) {
558
+ fs3.copyFileSync(path3.join(credSrc, f), path3.join(credDst, f));
559
+ }
560
+ console.log(` \u2705 ${files.length} credential file(s) restored`);
561
+ return files.length;
562
+ }
522
563
  function cloneGitHubRepos(manifest, targetWorkspace) {
523
564
  const result = { cloned: 0, skipped: 0, failed: 0 };
524
565
  if (!manifest.github_repos || manifest.github_repos.length === 0) {
@@ -679,6 +720,7 @@ async function unpack(soulFile, workspacePath) {
679
720
  }
680
721
  writeAgentConfig(manifest, stageDir, targetWorkspace);
681
722
  const cronCount = restoreCronJobs(manifest, stageDir);
723
+ const credCount = restoreCredentials(stageDir);
682
724
  const repoResult = cloneGitHubRepos(manifest, targetWorkspace);
683
725
  fs3.rmSync(tmpDir, { recursive: true });
684
726
  let gatewayStarted = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-teleport",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Agent soul migration — pack your identity, memory, and tools into one file, unpack on a new machine",
5
5
  "type": "module",
6
6
  "bin": {
package/src/commands.ts CHANGED
@@ -169,6 +169,12 @@ function writeAgentConfig(
169
169
  }
170
170
  }
171
171
 
172
+ // Merge gateway config
173
+ if (manifest.gateway && Object.keys(manifest.gateway).length > 0) {
174
+ existingConfig.gateway = { ...(existingConfig.gateway ?? {}), ...manifest.gateway };
175
+ console.log(' ✅ Gateway config restored');
176
+ }
177
+
172
178
  fs.writeFileSync(CONFIG_PATH, JSON.stringify(existingConfig, null, 2));
173
179
  } else {
174
180
  // Create new config from scratch
@@ -200,6 +206,12 @@ function writeAgentConfig(
200
206
  console.log(' ✅ Bindings restored');
201
207
  }
202
208
 
209
+ // Add gateway config
210
+ if (manifest.gateway && Object.keys(manifest.gateway).length > 0) {
211
+ newConfig.gateway = manifest.gateway;
212
+ console.log(' ✅ Gateway config restored');
213
+ }
214
+
203
215
  fs.writeFileSync(CONFIG_PATH, JSON.stringify(newConfig, null, 2));
204
216
  console.log(' ✅ New openclaw.json created');
205
217
  }
@@ -261,6 +273,27 @@ function restoreCronJobs(manifest: Manifest, stageDir: string): number {
261
273
  return manifest.cron_jobs?.length ?? cronFileCount;
262
274
  }
263
275
 
276
+ // ── Step 3.5: Restore credentials (pairing, allowFrom) ────────────
277
+
278
+ function restoreCredentials(stageDir: string): number {
279
+ console.log('🔐 Restoring credentials...');
280
+ const credSrc = path.join(stageDir, 'credentials');
281
+ if (!fs.existsSync(credSrc)) {
282
+ console.log(' (none)');
283
+ return 0;
284
+ }
285
+
286
+ const credDst = path.join(OPENCLAW_DIR, 'credentials');
287
+ fs.mkdirSync(credDst, { recursive: true });
288
+
289
+ const files = fs.readdirSync(credSrc).filter(f => f.endsWith('.json'));
290
+ for (const f of files) {
291
+ fs.copyFileSync(path.join(credSrc, f), path.join(credDst, f));
292
+ }
293
+ console.log(` ✅ ${files.length} credential file(s) restored`);
294
+ return files.length;
295
+ }
296
+
264
297
  // ── Step 4 & 5: GitHub auth + clone repos ──────────────────────────
265
298
 
266
299
  function cloneGitHubRepos(manifest: Manifest, targetWorkspace: string): { cloned: number; skipped: number; failed: number } {
@@ -467,6 +500,9 @@ export async function unpack(soulFile: string, workspacePath?: string): Promise<
467
500
  // ── Step 6: Restore cron jobs ───────────────────────────────────
468
501
  const cronCount = restoreCronJobs(manifest, stageDir);
469
502
 
503
+ // ── Step 6.5: Restore credentials ─────────────────────────────
504
+ const credCount = restoreCredentials(stageDir);
505
+
470
506
  // ── Step 7: Clone GitHub repos ──────────────────────────────────
471
507
  const repoResult = cloneGitHubRepos(manifest, targetWorkspace);
472
508
 
package/src/pack.ts CHANGED
@@ -106,6 +106,23 @@ export async function pack(agentId?: string, outputPath?: string): Promise<void>
106
106
  }
107
107
  console.log(` ✅ ${cronFiles.length} cron files`);
108
108
 
109
+ // 5.5. Collect credentials (pairing records, allowFrom lists)
110
+ console.log('🔐 Collecting credentials...');
111
+ const credDir = path.join(OPENCLAW_DIR, 'credentials');
112
+ let credCount = 0;
113
+ if (fs.existsSync(credDir)) {
114
+ const credFiles = fs.readdirSync(credDir).filter(f => f.endsWith('.json'));
115
+ for (const f of credFiles) {
116
+ const src = path.join(credDir, f);
117
+ const dst = path.join(stageDir, 'credentials', f);
118
+ fs.mkdirSync(path.dirname(dst), { recursive: true });
119
+ fs.copyFileSync(src, dst);
120
+ allFiles.push(`credentials/${f}`);
121
+ credCount++;
122
+ }
123
+ }
124
+ console.log(` ✅ ${credCount} credential files`);
125
+
109
126
  // 6. Load full cron job content for this agent
110
127
  console.log('⏰ Extracting cron job definitions...');
111
128
  const cronJobs = loadCronJobs(agent.id);
@@ -126,10 +143,11 @@ export async function pack(agentId?: string, outputPath?: string): Promise<void>
126
143
  const channelCount = Object.keys(channelsConfig).length;
127
144
  console.log(` ✅ ${channelCount} channel(s) saved`);
128
145
 
129
- // 10. Extract agent defaults and models config
146
+ // 10. Extract agent defaults, models config, and gateway config
130
147
  const agentDefaults = sanitizeAgentDefaults(config.agents?.defaults ?? {});
131
148
  const modelsConfig = config.models ?? {};
132
149
  const bindingsConfig = config.bindings ?? [];
150
+ const gatewayConfig = config.gateway ?? {};
133
151
 
134
152
  // 11. Generate manifest
135
153
  const manifest: Manifest = {
@@ -144,6 +162,7 @@ export async function pack(agentId?: string, outputPath?: string): Promise<void>
144
162
  agent_defaults: agentDefaults,
145
163
  models_config: modelsConfig,
146
164
  bindings: bindingsConfig as Array<Record<string, unknown>>,
165
+ gateway: gatewayConfig as Record<string, unknown>,
147
166
  };
148
167
 
149
168
  const manifestPath = path.join(stageDir, 'manifest.json');
package/src/utils.ts CHANGED
@@ -35,6 +35,8 @@ export interface Manifest {
35
35
  models_config?: Record<string, unknown>;
36
36
  /** Bindings configuration (added in v0.2) */
37
37
  bindings?: Array<Record<string, unknown>>;
38
+ /** Gateway configuration (added in v0.2.1) */
39
+ gateway?: Record<string, unknown>;
38
40
  }
39
41
 
40
42
  export interface CronJob {