chore: rename project to clawdbot
This commit is contained in:
@@ -5,9 +5,9 @@ import { fileURLToPath } from "node:url";
|
||||
|
||||
import { detectMime } from "../media/mime.js";
|
||||
|
||||
export const A2UI_PATH = "/__clawdis__/a2ui";
|
||||
export const CANVAS_HOST_PATH = "/__clawdis__/canvas";
|
||||
export const CANVAS_WS_PATH = "/__clawdis/ws";
|
||||
export const A2UI_PATH = "/__clawdbot__/a2ui";
|
||||
export const CANVAS_HOST_PATH = "/__clawdbot__/canvas";
|
||||
export const CANVAS_WS_PATH = "/__clawdbot/ws";
|
||||
|
||||
let cachedA2uiRootReal: string | null | undefined;
|
||||
let resolvingA2uiRoot: Promise<string | null> | null = null;
|
||||
@@ -98,9 +98,9 @@ export function injectCanvasLiveReload(html: string): string {
|
||||
(() => {
|
||||
// Cross-platform action bridge helper.
|
||||
// Works on:
|
||||
// - iOS: window.webkit.messageHandlers.clawdisCanvasA2UIAction.postMessage(...)
|
||||
// - Android: window.clawdisCanvasA2UIAction.postMessage(...)
|
||||
const actionHandlerName = "clawdisCanvasA2UIAction";
|
||||
// - iOS: window.webkit.messageHandlers.clawdbotCanvasA2UIAction.postMessage(...)
|
||||
// - Android: window.clawdbotCanvasA2UIAction.postMessage(...)
|
||||
const actionHandlerName = "clawdbotCanvasA2UIAction";
|
||||
function postToNode(payload) {
|
||||
try {
|
||||
const raw = typeof payload === "string" ? payload : JSON.stringify(payload);
|
||||
@@ -125,11 +125,11 @@ export function injectCanvasLiveReload(html: string): string {
|
||||
const action = { ...userAction, id };
|
||||
return postToNode({ userAction: action });
|
||||
}
|
||||
globalThis.Clawdis = globalThis.Clawdis ?? {};
|
||||
globalThis.Clawdis.postMessage = postToNode;
|
||||
globalThis.Clawdis.sendUserAction = sendUserAction;
|
||||
globalThis.clawdisPostMessage = postToNode;
|
||||
globalThis.clawdisSendUserAction = sendUserAction;
|
||||
globalThis.Clawdbot = globalThis.Clawdbot ?? {};
|
||||
globalThis.Clawdbot.postMessage = postToNode;
|
||||
globalThis.Clawdbot.sendUserAction = sendUserAction;
|
||||
globalThis.clawdbotPostMessage = postToNode;
|
||||
globalThis.clawdbotSendUserAction = sendUserAction;
|
||||
|
||||
try {
|
||||
const proto = location.protocol === "https:" ? "wss" : "ws";
|
||||
|
||||
@@ -17294,7 +17294,7 @@ const cardShadow = isAndroid ? "0 2px 10px rgba(0,0,0,.18)" : "0 10px 30px rgba(
|
||||
const buttonShadow = isAndroid ? "0 2px 10px rgba(6, 182, 212, 0.14)" : "0 10px 25px rgba(6, 182, 212, 0.18)";
|
||||
const statusShadow = isAndroid ? "0 2px 10px rgba(0, 0, 0, 0.18)" : "0 10px 24px rgba(0, 0, 0, 0.25)";
|
||||
const statusBlur = isAndroid ? "10px" : "14px";
|
||||
const clawdisTheme = {
|
||||
const clawdbotTheme = {
|
||||
components: {
|
||||
AudioPlayer: emptyClasses(),
|
||||
Button: emptyClasses(),
|
||||
@@ -17450,7 +17450,7 @@ const clawdisTheme = {
|
||||
Image: { borderRadius: "12px" }
|
||||
}
|
||||
};
|
||||
var ClawdisA2UIHost = class extends i$6 {
|
||||
var ClawdbotA2UIHost = class extends i$6 {
|
||||
static properties = {
|
||||
surfaces: { state: true },
|
||||
pendingAction: { state: true },
|
||||
@@ -17459,7 +17459,7 @@ var ClawdisA2UIHost = class extends i$6 {
|
||||
#processor = Data.createSignalA2uiMessageProcessor();
|
||||
#themeProvider = new i$3(this, {
|
||||
context: themeContext,
|
||||
initialValue: clawdisTheme
|
||||
initialValue: clawdbotTheme
|
||||
});
|
||||
surfaces = [];
|
||||
pendingAction = null;
|
||||
@@ -17472,10 +17472,10 @@ var ClawdisA2UIHost = class extends i$6 {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
padding:
|
||||
var(--clawdis-a2ui-inset-top, 0px)
|
||||
var(--clawdis-a2ui-inset-right, 0px)
|
||||
var(--clawdis-a2ui-inset-bottom, 0px)
|
||||
var(--clawdis-a2ui-inset-left, 0px);
|
||||
var(--clawdbot-a2ui-inset-top, 0px)
|
||||
var(--clawdbot-a2ui-inset-right, 0px)
|
||||
var(--clawdbot-a2ui-inset-bottom, 0px)
|
||||
var(--clawdbot-a2ui-inset-left, 0px);
|
||||
}
|
||||
|
||||
#surfaces {
|
||||
@@ -17484,14 +17484,14 @@ var ClawdisA2UIHost = class extends i$6 {
|
||||
gap: 12px;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
padding-bottom: var(--clawdis-a2ui-scroll-pad-bottom, 0px);
|
||||
padding-bottom: var(--clawdbot-a2ui-scroll-pad-bottom, 0px);
|
||||
}
|
||||
|
||||
.status {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
top: var(--clawdis-a2ui-status-top, 12px);
|
||||
top: var(--clawdbot-a2ui-status-top, 12px);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
@@ -17512,7 +17512,7 @@ var ClawdisA2UIHost = class extends i$6 {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
bottom: var(--clawdis-a2ui-toast-bottom, 12px);
|
||||
bottom: var(--clawdbot-a2ui-toast-bottom, 12px);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
@@ -17538,7 +17538,7 @@ var ClawdisA2UIHost = class extends i$6 {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
top: var(--clawdis-a2ui-empty-top, var(--clawdis-a2ui-status-top, 12px));
|
||||
top: var(--clawdbot-a2ui-empty-top, var(--clawdbot-a2ui-status-top, 12px));
|
||||
text-align: center;
|
||||
opacity: 0.8;
|
||||
padding: 10px 12px;
|
||||
@@ -17570,20 +17570,20 @@ var ClawdisA2UIHost = class extends i$6 {
|
||||
`;
|
||||
connectedCallback() {
|
||||
super.connectedCallback();
|
||||
globalThis.clawdisA2UI = {
|
||||
globalThis.clawdbotA2UI = {
|
||||
applyMessages: (messages) => this.applyMessages(messages),
|
||||
reset: () => this.reset(),
|
||||
getSurfaces: () => Array.from(this.#processor.getSurfaces().keys())
|
||||
};
|
||||
this.addEventListener("a2uiaction", (evt) => this.#handleA2UIAction(evt));
|
||||
this.#statusListener = (evt) => this.#handleActionStatus(evt);
|
||||
globalThis.addEventListener("clawdis:a2ui-action-status", this.#statusListener);
|
||||
globalThis.addEventListener("clawdbot:a2ui-action-status", this.#statusListener);
|
||||
this.#syncSurfaces();
|
||||
}
|
||||
disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
if (this.#statusListener) {
|
||||
globalThis.removeEventListener("clawdis:a2ui-action-status", this.#statusListener);
|
||||
globalThis.removeEventListener("clawdbot:a2ui-action-status", this.#statusListener);
|
||||
this.#statusListener = null;
|
||||
}
|
||||
}
|
||||
@@ -17688,11 +17688,11 @@ var ClawdisA2UIHost = class extends i$6 {
|
||||
timestamp: new Date().toISOString(),
|
||||
...Object.keys(context).length ? { context } : {}
|
||||
};
|
||||
globalThis.__clawdisLastA2UIAction = userAction;
|
||||
const handler = globalThis.webkit?.messageHandlers?.clawdisCanvasA2UIAction ?? globalThis.clawdisCanvasA2UIAction;
|
||||
globalThis.__clawdbotLastA2UIAction = userAction;
|
||||
const handler = globalThis.webkit?.messageHandlers?.clawdbotCanvasA2UIAction ?? globalThis.clawdbotCanvasA2UIAction;
|
||||
if (handler?.postMessage) {
|
||||
try {
|
||||
if (handler === globalThis.clawdisCanvasA2UIAction) {
|
||||
if (handler === globalThis.clawdbotCanvasA2UIAction) {
|
||||
handler.postMessage(JSON.stringify({ userAction }));
|
||||
} else {
|
||||
handler.postMessage({ userAction });
|
||||
@@ -17765,4 +17765,4 @@ var ClawdisA2UIHost = class extends i$6 {
|
||||
</section>`;
|
||||
}
|
||||
};
|
||||
customElements.define("clawdis-a2ui-host", ClawdisA2UIHost);
|
||||
customElements.define("clawdbot-a2ui-host", ClawdbotA2UIHost);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Clawdis Canvas</title>
|
||||
<title>Clawdbot Canvas</title>
|
||||
<script>
|
||||
(() => {
|
||||
try {
|
||||
@@ -57,7 +57,7 @@
|
||||
backface-visibility: hidden;
|
||||
opacity: 0.45;
|
||||
pointer-events: none;
|
||||
animation: clawdis-grid-drift 140s ease-in-out infinite alternate;
|
||||
animation: clawdbot-grid-drift 140s ease-in-out infinite alternate;
|
||||
}
|
||||
:root[data-platform="android"] body::before { opacity: 0.80; }
|
||||
body::after {
|
||||
@@ -75,7 +75,7 @@
|
||||
backface-visibility: hidden;
|
||||
transform: translate3d(0,0,0);
|
||||
pointer-events: none;
|
||||
animation: clawdis-glow-drift 110s ease-in-out infinite alternate;
|
||||
animation: clawdbot-glow-drift 110s ease-in-out infinite alternate;
|
||||
}
|
||||
:root[data-platform="android"] body::after { opacity: 0.85; }
|
||||
@supports (mix-blend-mode: screen) {
|
||||
@@ -84,12 +84,12 @@
|
||||
@supports not (mix-blend-mode: screen) {
|
||||
body::after { opacity: 0.70; }
|
||||
}
|
||||
@keyframes clawdis-grid-drift {
|
||||
@keyframes clawdbot-grid-drift {
|
||||
0% { transform: translate3d(-12px, 8px, 0) rotate(-7deg); opacity: 0.40; }
|
||||
50% { transform: translate3d( 10px,-7px, 0) rotate(-6.6deg); opacity: 0.56; }
|
||||
100% { transform: translate3d(-8px, 6px, 0) rotate(-7.2deg); opacity: 0.42; }
|
||||
}
|
||||
@keyframes clawdis-glow-drift {
|
||||
@keyframes clawdbot-glow-drift {
|
||||
0% { transform: translate3d(-18px, 12px, 0) scale(1.02); opacity: 0.40; }
|
||||
50% { transform: translate3d( 14px,-10px, 0) scale(1.05); opacity: 0.52; }
|
||||
100% { transform: translate3d(-10px, 8px, 0) scale(1.03); opacity: 0.43; }
|
||||
@@ -103,14 +103,14 @@
|
||||
touch-action: none;
|
||||
z-index: 1;
|
||||
}
|
||||
:root[data-platform="android"] #clawdis-canvas {
|
||||
:root[data-platform="android"] #clawdbot-canvas {
|
||||
background:
|
||||
radial-gradient(1100px 800px at 20% 15%, rgba(42, 113, 255, 0.78), rgba(0,0,0,0) 58%),
|
||||
radial-gradient(900px 650px at 82% 28%, rgba(255, 0, 138, 0.66), rgba(0,0,0,0) 62%),
|
||||
radial-gradient(1000px 900px at 60% 88%, rgba(0, 209, 255, 0.58), rgba(0,0,0,0) 62%),
|
||||
#141c33;
|
||||
}
|
||||
#clawdis-status {
|
||||
#clawdbot-status {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
display: none;
|
||||
@@ -122,7 +122,7 @@
|
||||
pointer-events: none;
|
||||
z-index: 3;
|
||||
}
|
||||
#clawdis-status .card {
|
||||
#clawdbot-status .card {
|
||||
width: min(560px, 88vw);
|
||||
text-align: left;
|
||||
padding: 14px 16px 12px;
|
||||
@@ -134,52 +134,52 @@
|
||||
-webkit-backdrop-filter: blur(18px) saturate(140%);
|
||||
backdrop-filter: blur(18px) saturate(140%);
|
||||
}
|
||||
#clawdis-status .title {
|
||||
#clawdbot-status .title {
|
||||
font: 600 12px/1.2 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
|
||||
letter-spacing: 0.45px;
|
||||
text-transform: uppercase;
|
||||
color: rgba(255,255,255,0.7);
|
||||
}
|
||||
#clawdis-status .subtitle {
|
||||
#clawdbot-status .subtitle {
|
||||
margin-top: 8px;
|
||||
font: 500 13px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
|
||||
color: rgba(255,255,255,0.9);
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
clawdis-a2ui-host {
|
||||
clawdbot-a2ui-host {
|
||||
display: block;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 4;
|
||||
--clawdis-a2ui-inset-top: 28px;
|
||||
--clawdis-a2ui-inset-right: 0px;
|
||||
--clawdis-a2ui-inset-bottom: 0px;
|
||||
--clawdis-a2ui-inset-left: 0px;
|
||||
--clawdis-a2ui-scroll-pad-bottom: 0px;
|
||||
--clawdis-a2ui-status-top: calc(50% - 18px);
|
||||
--clawdis-a2ui-empty-top: 18px;
|
||||
--clawdbot-a2ui-inset-top: 28px;
|
||||
--clawdbot-a2ui-inset-right: 0px;
|
||||
--clawdbot-a2ui-inset-bottom: 0px;
|
||||
--clawdbot-a2ui-inset-left: 0px;
|
||||
--clawdbot-a2ui-scroll-pad-bottom: 0px;
|
||||
--clawdbot-a2ui-status-top: calc(50% - 18px);
|
||||
--clawdbot-a2ui-empty-top: 18px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="clawdis-canvas"></canvas>
|
||||
<div id="clawdis-status">
|
||||
<canvas id="clawdbot-canvas"></canvas>
|
||||
<div id="clawdbot-status">
|
||||
<div class="card">
|
||||
<div class="title" id="clawdis-status-title">Ready</div>
|
||||
<div class="subtitle" id="clawdis-status-subtitle">Waiting for agent</div>
|
||||
<div class="title" id="clawdbot-status-title">Ready</div>
|
||||
<div class="subtitle" id="clawdbot-status-subtitle">Waiting for agent</div>
|
||||
</div>
|
||||
</div>
|
||||
<clawdis-a2ui-host></clawdis-a2ui-host>
|
||||
<clawdbot-a2ui-host></clawdbot-a2ui-host>
|
||||
<script src="a2ui.bundle.js"></script>
|
||||
<script>
|
||||
(() => {
|
||||
const canvas = document.getElementById('clawdis-canvas');
|
||||
const canvas = document.getElementById('clawdbot-canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
const statusEl = document.getElementById('clawdis-status');
|
||||
const titleEl = document.getElementById('clawdis-status-title');
|
||||
const subtitleEl = document.getElementById('clawdis-status-subtitle');
|
||||
const statusEl = document.getElementById('clawdbot-status');
|
||||
const titleEl = document.getElementById('clawdbot-status-title');
|
||||
const subtitleEl = document.getElementById('clawdbot-status-subtitle');
|
||||
const debugStatusEnabledByQuery = (() => {
|
||||
try {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
@@ -217,7 +217,7 @@
|
||||
statusEl.style.display = 'none';
|
||||
}
|
||||
|
||||
window.__clawdis = {
|
||||
window.__clawdbot = {
|
||||
canvas,
|
||||
ctx,
|
||||
setDebugStatusEnabled,
|
||||
|
||||
@@ -19,12 +19,12 @@ describe("canvas host", () => {
|
||||
const out = injectCanvasLiveReload("<html><body>Hello</body></html>");
|
||||
expect(out).toContain(CANVAS_WS_PATH);
|
||||
expect(out).toContain("location.reload");
|
||||
expect(out).toContain("clawdisCanvasA2UIAction");
|
||||
expect(out).toContain("clawdisSendUserAction");
|
||||
expect(out).toContain("clawdbotCanvasA2UIAction");
|
||||
expect(out).toContain("clawdbotSendUserAction");
|
||||
});
|
||||
|
||||
it("creates a default index.html when missing", async () => {
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdis-canvas-"));
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-canvas-"));
|
||||
|
||||
const server = await startCanvasHost({
|
||||
runtime: defaultRuntime,
|
||||
@@ -41,7 +41,7 @@ describe("canvas host", () => {
|
||||
const html = await res.text();
|
||||
expect(res.status).toBe(200);
|
||||
expect(html).toContain("Interactive test page");
|
||||
expect(html).toContain("clawdisSendUserAction");
|
||||
expect(html).toContain("clawdbotSendUserAction");
|
||||
expect(html).toContain(CANVAS_WS_PATH);
|
||||
} finally {
|
||||
await server.close();
|
||||
@@ -50,7 +50,7 @@ describe("canvas host", () => {
|
||||
});
|
||||
|
||||
it("skips live reload injection when disabled", async () => {
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdis-canvas-"));
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-canvas-"));
|
||||
await fs.writeFile(
|
||||
path.join(dir, "index.html"),
|
||||
"<html><body>no-reload</body></html>",
|
||||
@@ -86,7 +86,7 @@ describe("canvas host", () => {
|
||||
});
|
||||
|
||||
it("serves canvas content from the mounted base path", async () => {
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdis-canvas-"));
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-canvas-"));
|
||||
await fs.writeFile(
|
||||
path.join(dir, "index.html"),
|
||||
"<html><body>v1</body></html>",
|
||||
@@ -137,7 +137,7 @@ describe("canvas host", () => {
|
||||
});
|
||||
|
||||
it("reuses a handler without closing it twice", async () => {
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdis-canvas-"));
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-canvas-"));
|
||||
await fs.writeFile(
|
||||
path.join(dir, "index.html"),
|
||||
"<html><body>v1</body></html>",
|
||||
@@ -174,7 +174,7 @@ describe("canvas host", () => {
|
||||
});
|
||||
|
||||
it("serves HTML with injection and broadcasts reload on file changes", async () => {
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdis-canvas-"));
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-canvas-"));
|
||||
const index = path.join(dir, "index.html");
|
||||
await fs.writeFile(index, "<html><body>v1</body></html>", "utf8");
|
||||
|
||||
@@ -234,7 +234,7 @@ describe("canvas host", () => {
|
||||
});
|
||||
|
||||
it("serves the gateway-hosted A2UI scaffold", async () => {
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdis-canvas-"));
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-canvas-"));
|
||||
|
||||
const server = await startCanvasHost({
|
||||
runtime: defaultRuntime,
|
||||
@@ -246,19 +246,19 @@ describe("canvas host", () => {
|
||||
|
||||
try {
|
||||
const res = await fetch(
|
||||
`http://127.0.0.1:${server.port}/__clawdis__/a2ui/`,
|
||||
`http://127.0.0.1:${server.port}/__clawdbot__/a2ui/`,
|
||||
);
|
||||
const html = await res.text();
|
||||
expect(res.status).toBe(200);
|
||||
expect(html).toContain("clawdis-a2ui-host");
|
||||
expect(html).toContain("clawdisCanvasA2UIAction");
|
||||
expect(html).toContain("clawdbot-a2ui-host");
|
||||
expect(html).toContain("clawdbotCanvasA2UIAction");
|
||||
|
||||
const bundleRes = await fetch(
|
||||
`http://127.0.0.1:${server.port}/__clawdis__/a2ui/a2ui.bundle.js`,
|
||||
`http://127.0.0.1:${server.port}/__clawdbot__/a2ui/a2ui.bundle.js`,
|
||||
);
|
||||
const js = await bundleRes.text();
|
||||
expect(bundleRes.status).toBe(200);
|
||||
expect(js).toContain("clawdisA2UI");
|
||||
expect(js).toContain("clawdbotA2UI");
|
||||
} finally {
|
||||
await server.close();
|
||||
await fs.rm(dir, { recursive: true, force: true });
|
||||
|
||||
@@ -68,7 +68,7 @@ function defaultIndexHTML() {
|
||||
return `<!doctype html>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Clawdis Canvas</title>
|
||||
<title>Clawdbot Canvas</title>
|
||||
<style>
|
||||
html, body { height: 100%; margin: 0; background: #000; color: #fff; font: 16px/1.4 -apple-system, BlinkMacSystemFont, system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif; }
|
||||
.wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
|
||||
@@ -86,7 +86,7 @@ function defaultIndexHTML() {
|
||||
<div class="wrap">
|
||||
<div class="card">
|
||||
<div class="title">
|
||||
<h1>Clawdis Canvas</h1>
|
||||
<h1>Clawdbot Canvas</h1>
|
||||
<div class="sub">Interactive test page (auto-reload enabled)</div>
|
||||
</div>
|
||||
|
||||
@@ -107,26 +107,26 @@ function defaultIndexHTML() {
|
||||
const statusEl = document.getElementById("status");
|
||||
const log = (msg) => { logEl.textContent = String(msg); };
|
||||
|
||||
const hasIOS = () => !!(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.clawdisCanvasA2UIAction);
|
||||
const hasAndroid = () => !!(window.clawdisCanvasA2UIAction && typeof window.clawdisCanvasA2UIAction.postMessage === "function");
|
||||
const hasHelper = () => typeof window.clawdisSendUserAction === "function";
|
||||
const hasIOS = () => !!(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.clawdbotCanvasA2UIAction);
|
||||
const hasAndroid = () => !!(window.clawdbotCanvasA2UIAction && typeof window.clawdbotCanvasA2UIAction.postMessage === "function");
|
||||
const hasHelper = () => typeof window.clawdbotSendUserAction === "function";
|
||||
statusEl.innerHTML =
|
||||
"Bridge: " +
|
||||
(hasHelper() ? "<span class='ok'>ready</span>" : "<span class='bad'>missing</span>") +
|
||||
" · iOS=" + (hasIOS() ? "yes" : "no") +
|
||||
" · Android=" + (hasAndroid() ? "yes" : "no");
|
||||
|
||||
window.addEventListener("clawdis:a2ui-action-status", (ev) => {
|
||||
window.addEventListener("clawdbot:a2ui-action-status", (ev) => {
|
||||
const d = ev && ev.detail || {};
|
||||
log("Action status: id=" + (d.id || "?") + " ok=" + String(!!d.ok) + (d.error ? (" error=" + d.error) : ""));
|
||||
});
|
||||
|
||||
function send(name, sourceComponentId) {
|
||||
if (!hasHelper()) {
|
||||
log("No action bridge found. Ensure you're viewing this on an iOS/Android Clawdis node canvas.");
|
||||
log("No action bridge found. Ensure you're viewing this on an iOS/Android Clawdbot node canvas.");
|
||||
return;
|
||||
}
|
||||
const ok = window.clawdisSendUserAction({
|
||||
const ok = window.clawdbotSendUserAction({
|
||||
name,
|
||||
surfaceId: "main",
|
||||
sourceComponentId,
|
||||
@@ -184,7 +184,7 @@ async function resolveFilePath(rootReal: string, urlPath: string) {
|
||||
}
|
||||
|
||||
function isDisabledByEnv() {
|
||||
if (process.env.CLAWDIS_SKIP_CANVAS_HOST === "1") return true;
|
||||
if (process.env.CLAWDBOT_SKIP_CANVAS_HOST === "1") return true;
|
||||
if (process.env.NODE_ENV === "test") return true;
|
||||
if (process.env.VITEST) return true;
|
||||
return false;
|
||||
@@ -341,7 +341,7 @@ export async function createCanvasHostHandler(
|
||||
res.statusCode = 404;
|
||||
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
||||
res.end(
|
||||
`<!doctype html><meta charset="utf-8" /><title>Clawdis Canvas</title><pre>Missing file.\nCreate ${rootDir}/index.html</pre>`,
|
||||
`<!doctype html><meta charset="utf-8" /><title>Clawdbot Canvas</title><pre>Missing file.\nCreate ${rootDir}/index.html</pre>`,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user