golem-bridge 1.0.2 → 1.0.3
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/README.md +13 -3
- package/cli.js +54 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Connect to my Roblox Studio, Run: npx golem-bridge connect <channelId>
|
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
The line is a session token: Studio mints a fresh channel on every start
|
|
18
|
-
and wipes the old one.
|
|
18
|
+
and wipes the old one.
|
|
19
19
|
|
|
20
20
|
The user sends that line to their AI. It downloads this package, which asks
|
|
21
21
|
the plugin for its two connection files and stores them under `./.golem/`:
|
|
@@ -28,6 +28,18 @@ python3 ./.golem/golem.py ping
|
|
|
28
28
|
`ping` should return `"ok": true` plus the open place name. Then the agent
|
|
29
29
|
reads `./.golem/golem.md` for the full tool reference.
|
|
30
30
|
|
|
31
|
+
After a Studio restart, relink with the new line:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npx golem-bridge reconnect <newChannelId>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Done with a session? Forget it locally (Studio is unaffected):
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npx golem-bridge disconnect
|
|
41
|
+
```
|
|
42
|
+
|
|
31
43
|
## Files
|
|
32
44
|
|
|
33
45
|
- `cli.js` - source of the `golem-bridge` package
|
|
@@ -62,5 +74,3 @@ theater rather than security.
|
|
|
62
74
|
- Socket.dev flags the "URL strings" in this package (the relay address).
|
|
63
75
|
That is informational: the relay address is the product. The setup payload
|
|
64
76
|
is validated as described above before anything is written.
|
|
65
|
-
npm publish
|
|
66
|
-
```
|
package/cli.js
CHANGED
|
@@ -31,13 +31,20 @@ function printHelp() {
|
|
|
31
31
|
|
|
32
32
|
Usage:
|
|
33
33
|
golem-bridge connect <channelId> [--print]
|
|
34
|
+
golem-bridge reconnect <channelId> [--print]
|
|
35
|
+
golem-bridge disconnect
|
|
34
36
|
golem-bridge --help
|
|
35
37
|
golem-bridge --version
|
|
36
38
|
|
|
37
39
|
<channelId> shown in the Golem plugin widget inside Roblox Studio.
|
|
38
|
-
Fresh on every Studio start
|
|
40
|
+
Fresh on every Studio start.
|
|
39
41
|
--print audit mode: fetch and print both files without writing anything.
|
|
40
42
|
|
|
43
|
+
connect link this folder to a Studio session (writes ./.golem/).
|
|
44
|
+
reconnect same, for a rotated token: replaces the old session files.
|
|
45
|
+
Use after a Studio restart, with the new line from the widget.
|
|
46
|
+
disconnect forget this session (removes ./.golem/). Studio is unaffected.
|
|
47
|
+
|
|
41
48
|
connect writes ./.golem/golem.py and ./.golem/golem.md, fetched over HTTPS
|
|
42
49
|
from your own Studio session. Review both files before running anything.`);
|
|
43
50
|
}
|
|
@@ -169,6 +176,41 @@ function sha256(text) {
|
|
|
169
176
|
return crypto.createHash("sha256").update(text, "utf8").digest("hex");
|
|
170
177
|
}
|
|
171
178
|
|
|
179
|
+
function readSavedChannel() {
|
|
180
|
+
try {
|
|
181
|
+
const src = fs.readFileSync(path.join(process.cwd(), ".golem", "golem.py"), "utf8");
|
|
182
|
+
const m = src.match(/CHANNEL = os\.environ\.get\("AIB_CHANNEL", "([0-9a-fA-F]+)"\)/);
|
|
183
|
+
return m ? m[1] : null;
|
|
184
|
+
} catch {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function disconnectLocal() {
|
|
190
|
+
const dir = path.join(process.cwd(), ".golem");
|
|
191
|
+
if (!fs.existsSync(dir)) {
|
|
192
|
+
console.log("Not connected (no .golem/ in this folder).");
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const old = readSavedChannel();
|
|
196
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
197
|
+
console.log(old ? `Disconnected from channel ${old} (removed .golem/).` : "Disconnected (removed .golem/).");
|
|
198
|
+
console.log("Studio is unaffected. To link again: npx golem-bridge connect <channelId>");
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async function reconnect(channelId, printOnly) {
|
|
202
|
+
validateChannel(channelId);
|
|
203
|
+
const old = readSavedChannel();
|
|
204
|
+
if (!printOnly && old && old.toLowerCase() === channelId.toLowerCase()) {
|
|
205
|
+
console.log(`Already linked to channel ${channelId} — nothing to do.`);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (!printOnly && old) {
|
|
209
|
+
console.log(`Replacing session files for channel ${old}.`);
|
|
210
|
+
}
|
|
211
|
+
await connect(channelId, printOnly);
|
|
212
|
+
}
|
|
213
|
+
|
|
172
214
|
async function connect(channelId, printOnly) {
|
|
173
215
|
validateChannel(channelId);
|
|
174
216
|
console.log(`Contacting Golem plugin on channel ${channelId} ...`);
|
|
@@ -225,7 +267,12 @@ async function main() {
|
|
|
225
267
|
console.log(VERSION);
|
|
226
268
|
return;
|
|
227
269
|
}
|
|
228
|
-
if (args[0]
|
|
270
|
+
if (args[0] === "disconnect") {
|
|
271
|
+
disconnectLocal();
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const isReconnect = args[0] === "reconnect";
|
|
275
|
+
if (args[0] !== "connect" && !isReconnect) {
|
|
229
276
|
printHelp();
|
|
230
277
|
process.exit(2);
|
|
231
278
|
}
|
|
@@ -236,7 +283,11 @@ async function main() {
|
|
|
236
283
|
process.exit(2);
|
|
237
284
|
}
|
|
238
285
|
try {
|
|
239
|
-
|
|
286
|
+
if (isReconnect) {
|
|
287
|
+
await reconnect(channelId, printOnly);
|
|
288
|
+
} else {
|
|
289
|
+
await connect(channelId, printOnly);
|
|
290
|
+
}
|
|
240
291
|
} catch (err) {
|
|
241
292
|
fail(err.message, 1);
|
|
242
293
|
}
|