Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gateway-descriptor-v3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"grok-bot-cli": patch
---

Read Grok Bot gateway descriptor version 3 (same `entries` layout as version 2), which current Grok Bot desktop builds write. The multiple-entries safety check is unchanged.
2 changes: 1 addition & 1 deletion artifact/agent-bundle.compile-evidence.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion artifact/agent-bundle.manifest.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions artifact/bin/gbot-flight.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25825,11 +25825,11 @@ var __webpack_modules__ = {
}
}
function encryptedPayload(wrapped) {
if (wrapped.version != null && wrapped.version !== 1 && wrapped.version !== 2) {
if (wrapped.version != null && wrapped.version !== 1 && wrapped.version !== 2 && wrapped.version !== 3) {
throw new GrokBotGatewaySessionError("UNSUPPORTED_VERSION", `Unsupported Grok Bot gateway descriptor version ${wrapped.version}.`);
}
let encrypted;
if (wrapped.version === 2) {
if (wrapped.version === 2 || wrapped.version === 3) {
const entries = Object.values(wrapped.entries ?? {});
if (entries.length === 0) {
throw new GrokBotGatewaySessionError("EMPTY_ENTRIES", "Grok Bot gateway descriptor has no saved gateway entries.");
Expand Down
4 changes: 2 additions & 2 deletions artifact/bin/gbot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44254,11 +44254,11 @@ var __webpack_modules__ = {
}
}
function encryptedPayload(wrapped) {
if (wrapped.version != null && wrapped.version !== 1 && wrapped.version !== 2) {
if (wrapped.version != null && wrapped.version !== 1 && wrapped.version !== 2 && wrapped.version !== 3) {
throw new GrokBotGatewaySessionError("UNSUPPORTED_VERSION", `Unsupported Grok Bot gateway descriptor version ${wrapped.version}.`);
}
let encrypted;
if (wrapped.version === 2) {
if (wrapped.version === 2 || wrapped.version === 3) {
const entries = Object.values(wrapped.entries ?? {});
if (entries.length === 0) {
throw new GrokBotGatewaySessionError("EMPTY_ENTRIES", "Grok Bot gateway descriptor has no saved gateway entries.");
Expand Down
4 changes: 2 additions & 2 deletions artifact/mcp/mcp-grok-bot-b8c2461e-flight.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24532,11 +24532,11 @@ var __webpack_modules__ = {
}
}
function encryptedPayload(wrapped) {
if (wrapped.version != null && wrapped.version !== 1 && wrapped.version !== 2) {
if (wrapped.version != null && wrapped.version !== 1 && wrapped.version !== 2 && wrapped.version !== 3) {
throw new GrokBotGatewaySessionError("UNSUPPORTED_VERSION", `Unsupported Grok Bot gateway descriptor version ${wrapped.version}.`);
}
let encrypted;
if (wrapped.version === 2) {
if (wrapped.version === 2 || wrapped.version === 3) {
const entries = Object.values(wrapped.entries ?? {});
if (entries.length === 0) {
throw new GrokBotGatewaySessionError("EMPTY_ENTRIES", "Grok Bot gateway descriptor has no saved gateway entries.");
Expand Down
4 changes: 2 additions & 2 deletions artifact/mcp/mcp-grok-bot-b8c2461e.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61747,11 +61747,11 @@ var __webpack_modules__ = {
}
}
function encryptedPayload(wrapped) {
if (wrapped.version != null && wrapped.version !== 1 && wrapped.version !== 2) {
if (wrapped.version != null && wrapped.version !== 1 && wrapped.version !== 2 && wrapped.version !== 3) {
throw new GrokBotGatewaySessionError("UNSUPPORTED_VERSION", `Unsupported Grok Bot gateway descriptor version ${wrapped.version}.`);
}
let encrypted;
if (wrapped.version === 2) {
if (wrapped.version === 2 || wrapped.version === 3) {
const entries = Object.values(wrapped.entries ?? {});
if (entries.length === 0) {
throw new GrokBotGatewaySessionError("EMPTY_ENTRIES", "Grok Bot gateway descriptor has no saved gateway entries.");
Expand Down
4 changes: 2 additions & 2 deletions artifact/scripts/gbot-relay.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21947,11 +21947,11 @@ var __webpack_modules__ = {
}
}
function encryptedPayload(wrapped) {
if (wrapped.version != null && wrapped.version !== 1 && wrapped.version !== 2) {
if (wrapped.version != null && wrapped.version !== 1 && wrapped.version !== 2 && wrapped.version !== 3) {
throw new GrokBotGatewaySessionError("UNSUPPORTED_VERSION", `Unsupported Grok Bot gateway descriptor version ${wrapped.version}.`);
}
let encrypted;
if (wrapped.version === 2) {
if (wrapped.version === 2 || wrapped.version === 3) {
const entries = Object.values(wrapped.entries ?? {});
if (entries.length === 0) {
throw new GrokBotGatewaySessionError("EMPTY_ENTRIES", "Grok Bot gateway descriptor has no saved gateway entries.");
Expand Down
5 changes: 3 additions & 2 deletions src/core/app-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ class GrokBotGatewaySessionError extends Error {
}

function encryptedPayload(wrapped) {
if (wrapped.version != null && wrapped.version !== 1 && wrapped.version !== 2) {
if (wrapped.version != null && wrapped.version !== 1 && wrapped.version !== 2 && wrapped.version !== 3) {
throw new GrokBotGatewaySessionError(
"UNSUPPORTED_VERSION",
`Unsupported Grok Bot gateway descriptor version ${wrapped.version}.`,
);
}
let encrypted;
if (wrapped.version === 2) {
// v3 keeps the v2 `entries` layout (adds `savedAtMs`; the payload adds `vncProxy`, unused here).
if (wrapped.version === 2 || wrapped.version === 3) {
const entries = Object.values(wrapped.entries ?? {});
if (entries.length === 0) {
throw new GrokBotGatewaySessionError(
Expand Down
42 changes: 40 additions & 2 deletions test/app-session.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,44 @@ test("loads a version 2 Grok Bot gateway entry", () => {
});
});

test("loads a version 3 descriptor", () => {
const home = writeWrappedDescriptor({
version: 3,
entries: { primary: { encrypted: ENCRYPTED_DESCRIPTOR, savedAtMs: 1_791_320_229_049 } },
});

const session = loadGrokBotGatewaySession({
platform: "darwin",
home,
getKeychainPassword: () => "demo-password",
});

assert.deepEqual(session, {
gatewayUrl: "https://box.example",
gatewayToken: "gateway-token",
headers: { "x-anyrun-network-token": "route-token" },
});
});

test("rejects a version 3 descriptor with ambiguous entries", () => {
const home = writeWrappedDescriptor({
version: 3,
entries: {
first: { encrypted: ENCRYPTED_DESCRIPTOR, savedAtMs: 1 },
second: { encrypted: ENCRYPTED_DESCRIPTOR, savedAtMs: 2 },
},
});

assert.throws(
() => loadGrokBotGatewaySession({
platform: "darwin",
home,
getKeychainPassword: () => "demo-password",
}),
(error) => error.code === "AMBIGUOUS_ENTRIES",
);
});

test("rejects a version 2 descriptor with no entries", () => {
const home = writeWrappedDescriptor({ version: 2, entries: {} });

Expand Down Expand Up @@ -182,7 +220,7 @@ test("rejects a gateway entry without an encrypted payload", () => {

test("rejects an unsupported gateway descriptor version", () => {
const home = writeWrappedDescriptor({
version: 3,
version: 4,
encrypted: ENCRYPTED_DESCRIPTOR,
});

Expand All @@ -195,7 +233,7 @@ test("rejects an unsupported gateway descriptor version", () => {
(error) => {
assert.equal(error.name, "GrokBotGatewaySessionError");
assert.equal(error.code, "UNSUPPORTED_VERSION");
assert.match(error.message, /unsupported .*gateway descriptor version 3/i);
assert.match(error.message, /unsupported .*gateway descriptor version 4/i);
return true;
},
);
Expand Down