Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Publish to Netlify test: load the helper on a Windows checkout (#5495)
Milind Sonica13aa22e913
diff --git a/.gitattributes b/.gitattributesindex 01597a9a35..1461605eb9 100644--- a/.gitattributes+++ b/.gitattributes@@ -54,3 +54,8 @@ relay/test/vectors/** text eol=lf# a CRLF checkout on Windows fails every match for a reason that has nothing to do with the edge.deploy/fly/Caddyfile* text eol=lfdeploy/fly/*.caddy text eol=lf++# Bundled skills ship to Linux Clouds as they are, and server/skill-publish-to-netlify.test.ts imports a skill's helper+# through vitest: Vite's transform (vitest 4.1.11) fails with "Invalid or unexpected token" on a file that starts+# with a shebang and has CRLF line endings, which is what a Windows checkout made of it.+skills/** text eol=lfdiff --git a/server/bot-box/env.test.ts b/server/bot-box/env.test.tsindex b70a4c39de..43f59405bb 100644--- a/server/bot-box/env.test.ts+++ b/server/bot-box/env.test.ts@@ -41,7 +41,7 @@ const SERVER_ONLY_OMB: ReadonlySet<string> = new Set(["OMB_GREENFERENCE_API_KEY", "OMB_GROQ_API_KEY", "OMB_HELPER_INSTANCE", "OMB_HELPER_MODEL", "OMB_HOOKS", "OMB_HOOK_","OMB_HOSTED_", "OMB_HOSTED_MODELS", "OMB_HOSTED_MODEL_TOKEN", "OMB_HOSTED_MODEL_URL", "OMB_INSTALLATION_CREDENTIAL","OMB_JEV_API_KEY", "OMB_LAN", "OMB_LICENSE_KEY", "OMB_LINUX_GPU", "OMB_LIVE_PROVIDER", "OMB_LOCAL_VM_UPDATE_WAIT_MS",- "OMB_LOOPBACK_TRUST", "OMB_LOOP_GUARD", "OMB_LOOP_GUARD_STOP_AT", "OMB_META_API_KEY", "OMB_MODELGO_API_KEY", "OMB_OPENAI_API_KEY",+ "OMB_LOOPBACK_TRUST", "OMB_LOOP_GUARD", "OMB_LOOP_GUARD_STOP_AT", "OMB_META_API_KEY", "OMB_MODELGO_API_KEY", "OMB_NETLIFY_API_URL", "OMB_OPENAI_API_KEY","OMB_OPENAI_IMAGE_KEY", "OMB_OPENAI_LIVE_KEY", "OMB_OPENAI_LIVE_URL", "OMB_OPENROUTER_API_KEY","OMB_OPENROUTER_DECIDER_KEY", "OMB_PERSON_FIRST_MS", "OMB_PHONE_RELAY", "OMB_PHONE_RELAY_URL", "OMB_PHONE_SECRET_PUBLIC_KEY", "OMB_PORT", "OMB_SERVES_TUNNEL", "OMB_POSTIZ_API_KEY","OMB_POSTIZ_CLOUD_URL", "OMB_PROCESS_ID", "OMB_PUBLIC_IPV4", "OMB_PUBLIC_URL", "OMB_QUOTA_SWITCH",diff --git a/server/skill-publish-to-netlify.test.ts b/server/skill-publish-to-netlify.test.tsindex b623a59f86..15489523e5 100644--- a/server/skill-publish-to-netlify.test.ts+++ b/server/skill-publish-to-netlify.test.ts@@ -46,6 +46,21 @@ describe("publish-to-netlify skill guide", () => {expect(readdirSync(SKILL_DIR).sort()).toEqual(["SKILL.md", "deploy.mjs", "manifest.json", "site-record.md"]);});+ it("loads the helper whatever line endings a checkout gave it", async () => {+ const source = readFileSync(HELPER, "utf8");+ expect(source.startsWith("#!")).toBe(false);+ const folder = mkdtempSync(join(tmpdir(), "netlify-skill-crlf-"));+ try {+ const copy = join(folder, "deploy.mjs");+ writeFileSync(copy, source.replace(/\r?\n/g, "\r\n"));+ const loaded = await import(pathToFileURL(copy).href) as Helper;+ expect(loaded.publishable("index.html")).toBe(true);+ expect(loaded.publishable(".env")).toBe(false);+ } finally {+ rmSync(folder, { recursive: true, force: true });+ }+ });+it("mounts when a bot is asked to put a site or app online, and not for a page or a report", () => {for (const text of ["Deploy this to Netlify", "build me a todo web app and deploy it", "make a website for my bakery", "publish the site so customers can see it","turn this into a live app", "can you host it somewhere?"]) {@@ -105,12 +120,14 @@ describe("publish-to-netlify helper: what may be uploaded", () => {writeFileSync(join(site, ".env"), "KEY=1");writeFileSync(join(site, ".openmausbot-secrets", "t1", "card"), "nfp_secret");writeFileSync(join(root, "outside.txt"), "private");- symlinkSync(join(root, "outside.txt"), join(site, "linked.txt"));- symlinkSync(root, join(site, "up"));+ // Windows makes a file link only with a privilege CI lacks; a folder junction needs none.+ const fileLinks = process.platform !== "win32";+ if (fileLinks) symlinkSync(join(root, "outside.txt"), join(site, "linked.txt"));+ symlinkSync(root, join(site, "up"), process.platform === "win32" ? "junction" : "dir");const { files, skipped } = helper.collectFiles(site);expect(files.map((file) => file.path)).toEqual(["assets/a b.css", "assets/copy.css", "index.html"]);- expect(skipped.sort()).toEqual([".env", ".openmausbot-secrets", "linked.txt", "up"]);+ expect(skipped.sort()).toEqual([".env", ".openmausbot-secrets", ...(fileLinks ? ["linked.txt"] : []), "up"]);const { digest, bySha } = helper.buildDigest(files);expect(digest).toEqual({ "/assets/a b.css": sha1("body{}"), "/assets/copy.css": sha1("body{}"), "/index.html": sha1("<h1>hi</h1>") });expect(bySha.get(sha1("body{}"))?.path).toBe("assets/a b.css");@@ -178,7 +195,7 @@ describe("publish-to-netlify helper, end to end against a stand-in on loopback",let tokenFile: string;const run = (args: string[], env: Record<string, string> = {}, cwd = project) => new Promise<{ code: number; stdout: string; stderr: string; json: Record<string, unknown> }>((done) => {- execFile(process.execPath, [HELPER, ...args], { cwd, env: { PATH: process.env.PATH ?? "", HOME: home, OMB_NETLIFY_API_URL: fake.url, ...env } }, (error, stdout, stderr) => {+ execFile(process.execPath, [HELPER, ...args], { cwd, env: { PATH: process.env.PATH ?? "", HOME: home, ...(process.env.SystemRoot ? { SystemRoot: process.env.SystemRoot } : {}), OMB_NETLIFY_API_URL: fake.url, ...env } }, (error, stdout, stderr) => {done({ code: error ? Number(error.code) : 0, stdout, stderr, json: JSON.parse(stdout.trim() || "{}") as Record<string, unknown> });});});diff --git a/skills/publish-to-netlify/deploy.mjs b/skills/publish-to-netlify/deploy.mjsindex 31fdce143e..0f58a3c37e 100644--- a/skills/publish-to-netlify/deploy.mjs+++ b/skills/publish-to-netlify/deploy.mjs@@ -1,4 +1,3 @@-#!/usr/bin/env nodeimport { createHash } from "node:crypto";import { lstatSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";import http from "node:http";