clawrelay 0.3.0 → 0.3.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/package.json +1 -1
- package/src/onboarding.ts +2 -74
package/package.json
CHANGED
package/src/onboarding.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
promptAccountId,
|
|
10
10
|
} from "openclaw/plugin-sdk";
|
|
11
11
|
import crypto from "node:crypto";
|
|
12
|
-
import { execSync } from "node:child_process";
|
|
13
12
|
|
|
14
13
|
const channel = "relay" as const;
|
|
15
14
|
|
|
@@ -75,56 +74,6 @@ function getExistingToken(cfg: OpenClawConfig, accountId: string): string | unde
|
|
|
75
74
|
return relay?.accounts?.[accountId]?.authToken;
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
function isSpriteEnv(): boolean {
|
|
79
|
-
try {
|
|
80
|
-
execSync('which sprite-env', { stdio: 'ignore' });
|
|
81
|
-
return true;
|
|
82
|
-
} catch {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async function setupSpriteService(prompter: WizardPrompter): Promise<void> {
|
|
88
|
-
if (!isSpriteEnv()) return;
|
|
89
|
-
|
|
90
|
-
const setup = await prompter.confirm({
|
|
91
|
-
message: 'Sprite environment detected. Set up service to expose the gateway?',
|
|
92
|
-
initialValue: true,
|
|
93
|
-
});
|
|
94
|
-
if (!setup) return;
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
// Check if a service already exists
|
|
98
|
-
const existing = execSync('sprite-env services list', { encoding: 'utf-8' });
|
|
99
|
-
if (existing.includes('openclaw')) {
|
|
100
|
-
await prompter.note(
|
|
101
|
-
'An openclaw service already exists on this sprite.',
|
|
102
|
-
'Sprite Service',
|
|
103
|
-
);
|
|
104
|
-
} else {
|
|
105
|
-
execSync('sprite-env services create openclaw-gateway --cmd openclaw --args start --http-port 18789');
|
|
106
|
-
await prompter.note(
|
|
107
|
-
'Created sprite service: openclaw-gateway (port 18789)',
|
|
108
|
-
'Sprite Service',
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Check URL auth
|
|
113
|
-
const setPublic = await prompter.confirm({
|
|
114
|
-
message: 'Set sprite URL auth to public? (required for relay to connect without org token)',
|
|
115
|
-
initialValue: true,
|
|
116
|
-
});
|
|
117
|
-
if (setPublic) {
|
|
118
|
-
execSync('sprite url update --auth public');
|
|
119
|
-
}
|
|
120
|
-
} catch (err) {
|
|
121
|
-
await prompter.note(
|
|
122
|
-
`Failed to configure sprite service: ${err}\nYou can set it up manually later.`,
|
|
123
|
-
'Sprite Service',
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
77
|
export const relayOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
129
78
|
channel,
|
|
130
79
|
|
|
@@ -219,30 +168,9 @@ export const relayOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
|
219
168
|
authToken,
|
|
220
169
|
});
|
|
221
170
|
|
|
222
|
-
// --- Sprite service setup ---
|
|
223
|
-
await setupSpriteService(prompter);
|
|
224
|
-
|
|
225
|
-
// --- Next steps ---
|
|
226
171
|
await prompter.note(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
"",
|
|
230
|
-
"The relay connects to your OpenClaw gateway via WebSocket.",
|
|
231
|
-
"",
|
|
232
|
-
"Required env vars for the relay service:",
|
|
233
|
-
` DISCORD_TOKEN=<your-bot-token>`,
|
|
234
|
-
` GATEWAY_URL=<your-sprite-or-gateway-url>`,
|
|
235
|
-
` GATEWAY_AUTH_TOKEN=<gateway-auth-token-from-openclaw-config>`,
|
|
236
|
-
"",
|
|
237
|
-
"The gateway auth token is in your OpenClaw config under",
|
|
238
|
-
"gateway.auth.token (not the relay auth token above).",
|
|
239
|
-
"",
|
|
240
|
-
"Quick start:",
|
|
241
|
-
` docker run -e DISCORD_TOKEN=... -e GATEWAY_URL=https://my-sprite.sprites.dev -e GATEWAY_AUTH_TOKEN=... ghcr.io/kylemclaren/clawrelay:latest`,
|
|
242
|
-
"",
|
|
243
|
-
"Docs: https://github.com/kylemclaren/clawrelay",
|
|
244
|
-
].join("\n"),
|
|
245
|
-
"Next Steps",
|
|
172
|
+
`Relay channel configured (token: ${authToken.slice(0, 12)}...). Select Finished below, then deploy the relay service.`,
|
|
173
|
+
"Relay",
|
|
246
174
|
);
|
|
247
175
|
|
|
248
176
|
return { cfg: next, accountId };
|