Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
companion: type fixes for the E2E reference, keep the generator out of the sidecar build
milind-sonif578e88cdc5d
diff --git a/companion/src/e2e/gen-vectors.ts b/companion/src/e2e/gen-vectors.tsindex ed450a02fc..a51ebd20ce 100644--- a/companion/src/e2e/gen-vectors.ts+++ b/companion/src/e2e/gen-vectors.ts@@ -571,7 +571,7 @@ function v8() {const [body, signature] = token.split(".");const keys = (entries: Record<string, Buffer>) => new Map(Object.entries(entries));const tamperedBody = b64u(Buffer.from(JSON.stringify({ ...claims, iid: "00000000-0000-4000-8000-000000000000" })));- const cases = [+ const cases: Array<{ name: string; token: string; keys: Record<string, Buffer>; now: number; expectHid?: string }> = [{ name: "valid", token, keys: { k1: publicKey }, now: iat + 60 },{ name: "valid_two_keys", token, keys: { k2: otherPublic, k1: publicKey }, now: iat + 60 },{ name: "valid_refresh_same_hid", token, keys: { k1: publicKey }, now: claims.exp - 1, expectHid: claims.hid },diff --git a/companion/src/e2e/noise.ts b/companion/src/e2e/noise.tsindex 04246046c1..60bcb4bd22 100644--- a/companion/src/e2e/noise.ts+++ b/companion/src/e2e/noise.ts@@ -93,7 +93,7 @@ export function isPublicKey(bytes: Uint8Array): boolean {export function hkdf(chainingKey: Uint8Array, ikm: Uint8Array, outputs: 2 | 3): Buffer[] {const temp = hmacSha256(chainingKey, ikm);const out: Buffer[] = [];- let previous = Buffer.alloc(0);+ let previous: Buffer = Buffer.alloc(0);for (let index = 1; index <= outputs; index += 1) {previous = hmacSha256(temp, Buffer.concat([previous, Buffer.from([index])]));out.push(previous);diff --git a/companion/test/e2e/credentials.test.ts b/companion/test/e2e/credentials.test.tsindex 1f63e69f2f..cd8d50663a 100644--- a/companion/test/e2e/credentials.test.ts+++ b/companion/test/e2e/credentials.test.ts@@ -20,7 +20,8 @@ describe("base64url", () => {const bytes = Buffer.from([0xfb, 0xff, 0x01]);expect(fromB64u(b64u(bytes))).toEqual(bytes);expect(fromB64u("-_8B")).toEqual(bytes);- for (const bad of ["+/8B", "-_8B=", "-_8", "A", "-_ 8B", "AB==", "AR"]) expect(fromB64u(bad), bad).toBeNull();+ expect(fromB64u("-_8")).toEqual(bytes.subarray(0, 2));+ for (const bad of ["+/8B", "-_8B=", "-_9", "A", "-_ 8B", "AB==", "AR"]) expect(fromB64u(bad), bad).toBeNull();});});diff --git a/companion/test/e2e/vectors.test.ts b/companion/test/e2e/vectors.test.tsindex 6faf020834..75a6a4b73c 100644--- a/companion/test/e2e/vectors.test.ts+++ b/companion/test/e2e/vectors.test.ts@@ -216,8 +216,7 @@ describe("V5 yamux codec", () => {});describe("V6 must fail", () => {- it.each(v.V6.handshake.map((c: { name: string }) => [c.name, c]))("handshake: %s", (_name, testCase) => {- const c = testCase as { side: string; transport: TransportByte; candidates: string[]; message1: string; message2: string };+ it.each(v.V6.handshake as Array<{ name: string; side: string; transport: TransportByte; candidates: string[]; message1: string; message2: string }>)("handshake: $name", (c) => {if (c.side === "computer") {expect(computer(c.transport, c.candidates, bytes(c.message1))).toBeNull();} else {@@ -226,8 +225,7 @@ describe("V6 must fail", () => {}});- it.each(v.V6.records.map((c: { name: string }) => [c.name, c]))("record: %s", (_name, testCase) => {- const c = testCase as { receiver: string; records: string[]; failsAt: number };+ it.each(v.V6.records as Array<{ name: string; receiver: string; records: string[]; failsAt: number }>)("record: $name", (c) => {const keys = v2Sessions();const receiver = c.receiver === "computer" ? keys.computer.receive : keys.phone.receive;let failedAt = -1;@@ -242,12 +240,11 @@ describe("V6 must fail", () => {expect(failedAt).toBe(c.failsAt);});- it.each(v.V6.frames.map((c: { name: string }) => [c.name, c]))("frame: %s", (_name, testCase) => {- expect(() => decodeFrame(bytes((testCase as { hex: string }).hex))).toThrow(YamuxError);+ it.each(v.V6.frames as Array<{ name: string; hex: string }>)("frame: $name", (c) => {+ expect(() => decodeFrame(bytes(c.hex))).toThrow(YamuxError);});- it.each(v.V6.sessions.map((c: { name: string }) => [c.name, c]))("session: %s", (_name, testCase) => {- const c = testCase as { role: Role; accept?: string; steps: ScriptStep[]; expect: { errorAt?: number; sent?: string[] } };+ it.each(v.V6.sessions as Array<{ name: string; role: Role; accept?: string; steps: ScriptStep[]; expect: { errorAt?: number; sent?: string[] } }>)("session: $name", (c) => {expect(runScript(c.role, c.accept, c.steps)).toEqual(c.expect);});});@@ -284,16 +281,14 @@ function runScript(role: Role, accept: string | undefined, steps: ScriptStep[])}describe("V7 pairing descriptor", () => {- it.each(v.V7.valid.map((c: { name: string }) => [c.name, c]))("accepts %s", (_name, testCase) => {- const c = testCase as { value: string; chars: number; parsed: unknown };+ it.each(v.V7.valid as Array<{ name: string; value: string; chars: number; parsed: unknown }>)("accepts $name", (c) => {expect(c.value.length).toBe(c.chars);const result = parseDescriptor(c.value);expect(result.outcome).toBe("ok");if (result.outcome === "ok") expect(result.descriptor).toEqual(c.parsed);});- it.each(v.V7.invalid.map((c: { name: string }) => [c.name, c]))("refuses %s", (_name, testCase) => {- const c = testCase as { value: string; outcome: string };+ it.each(v.V7.invalid as Array<{ name: string; value: string; outcome: string }>)("refuses $name", (c) => {expect(parseDescriptor(c.value).outcome).toBe(c.outcome);});});@@ -306,8 +301,7 @@ describe("V8 relay token", () => {expect(Buffer.from(v.V8.token.split(".")[0], "base64url").toString("utf8")).toBe(v.V8.payloadJson);});- it.each(v.V8.verify.map((c: { name: string }) => [c.name, c]))("verify: %s", (_name, testCase) => {- const c = testCase as { token: string; keys: Record<string, string>; now: number; expectHid?: string; ok: boolean; error?: string };+ it.each(v.V8.verify as Array<{ name: string; token: string; keys: Record<string, string>; now: number; expectHid?: string; ok: boolean; error?: string }>)("verify: $name", (c) => {const keys = new Map(Object.entries(c.keys).map(([kid, raw]) => [kid, fromB64u(raw)!]));const result = verifyRelayToken(c.token, keys, c.now, c.expectHid);expect(result.ok).toBe(c.ok);diff --git a/tsconfig.companion.build.json b/tsconfig.companion.build.jsonindex 605ea236c9..d128c00467 100644--- a/tsconfig.companion.build.json+++ b/tsconfig.companion.build.json@@ -10,5 +10,8 @@},"include": ["companion/src"+ ],+ "exclude": [+ "companion/src/e2e/gen-vectors.ts"]}