@gajae-gateway/cli 0.1.8 → 0.2.1
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/discord-setup.d.ts +41 -0
- package/dist/discord-setup.d.ts.map +1 -0
- package/dist/gjc-install.d.ts +13 -0
- package/dist/gjc-install.d.ts.map +1 -0
- package/dist/main.d.ts +17 -30
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1318 -582
- package/dist/migrate/hermes.d.ts.map +1 -1
- package/dist/migrate.d.ts.map +1 -1
- package/dist/restart-stack.d.ts +27 -13
- package/dist/restart-stack.d.ts.map +1 -1
- package/dist/services.d.ts +9 -6
- package/dist/services.d.ts.map +1 -1
- package/dist/setup.d.ts +14 -3
- package/dist/setup.d.ts.map +1 -1
- package/dist/up.d.ts +20 -0
- package/dist/up.d.ts.map +1 -0
- package/dist/update.d.ts +10 -6
- package/dist/update.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/discord-setup.ts +103 -0
- package/src/gjc-install.ts +148 -0
- package/src/main.ts +296 -151
- package/src/migrate/hermes.ts +0 -2
- package/src/migrate.ts +36 -4
- package/src/restart-stack.ts +309 -92
- package/src/services.ts +75 -23
- package/src/setup.ts +85 -10
- package/src/up.ts +133 -0
- package/src/update.ts +175 -98
- package/dist/upgrade.d.ts +0 -40
- package/dist/upgrade.d.ts.map +0 -1
- package/src/upgrade.ts +0 -205
package/src/migrate/hermes.ts
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
cronMonitor,
|
|
6
6
|
deliveryOrigin,
|
|
7
7
|
emitChannels,
|
|
8
|
-
emitImportedAxis,
|
|
9
8
|
emitMonitors,
|
|
10
9
|
emptyChannelPlan,
|
|
11
10
|
emptyExtract,
|
|
@@ -107,7 +106,6 @@ export async function readHermes(tree: SourceTree, home: string): Promise<Source
|
|
|
107
106
|
content: entriesToMarkdown("Long-term memory (imported from Hermes)", memoryText),
|
|
108
107
|
mtime: info?.mtime,
|
|
109
108
|
});
|
|
110
|
-
emitImportedAxis(extract);
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
const envPath = join(root, ".env");
|
package/src/migrate.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { chmod, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
2
3
|
import { join } from "node:path";
|
|
4
|
+
import { acquireLease, type Lease, LeaseHeldError } from "@gajae-gateway/home";
|
|
3
5
|
import { detectHermes, readHermes } from "./migrate/hermes";
|
|
4
6
|
import { detectOpenClaw, readOpenClaw } from "./migrate/openclaw";
|
|
5
7
|
import {
|
|
@@ -23,9 +25,26 @@ export interface MigrateOptions {
|
|
|
23
25
|
* reads its configuration, and writes the gajae-way-compatible output.
|
|
24
26
|
*/
|
|
25
27
|
export async function migrate(options: MigrateOptions): Promise<void> {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
+
const targetHome = expandHome(options.target ?? process.env.GAJAEWAY_HOME ?? `${process.env.HOME ?? "~"}/.gajaeway`);
|
|
29
|
+
if (options.dryRun) return migrateUnlocked(options, targetHome);
|
|
30
|
+
|
|
31
|
+
let lease: Lease;
|
|
32
|
+
try {
|
|
33
|
+
lease = await acquireLease(targetHome, "memory");
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (error instanceof LeaseHeldError)
|
|
36
|
+
throw new Error(`${error.message}; stop the gateway first before importing memory data`, { cause: error });
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
await migrateUnlocked(options, targetHome);
|
|
41
|
+
} finally {
|
|
42
|
+
await lease.release();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
28
45
|
|
|
46
|
+
async function migrateUnlocked(options: MigrateOptions, targetHome: string): Promise<void> {
|
|
47
|
+
const sourceRoot = expandHome(options.source ?? ".");
|
|
29
48
|
// Detect source type
|
|
30
49
|
let sourceType: MigrationSource | undefined;
|
|
31
50
|
if (await detectHermes(sourceRoot)) {
|
|
@@ -109,7 +128,20 @@ export async function migrate(options: MigrateOptions): Promise<void> {
|
|
|
109
128
|
for (const file of extract.files) {
|
|
110
129
|
const filePath = join(targetHome, file.target);
|
|
111
130
|
await mkdir(join(filePath, ".."), { recursive: true });
|
|
112
|
-
|
|
131
|
+
if (file.secret) {
|
|
132
|
+
// Atomic 0600 write for secrets
|
|
133
|
+
const temporary = `${filePath}.${randomUUID()}.tmp`;
|
|
134
|
+
try {
|
|
135
|
+
await writeFile(temporary, file.content, { mode: 0o600 });
|
|
136
|
+
await chmod(temporary, 0o600);
|
|
137
|
+
await rename(temporary, filePath);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
await rm(temporary, { force: true });
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
await writeFile(filePath, file.content);
|
|
144
|
+
}
|
|
113
145
|
}
|
|
114
146
|
|
|
115
147
|
// Write merged JSON files
|