426e9eeabd
Benchmark Bridge Tests / benchmark (bunx @biomejs/biome check packages/lifeops-bench/src, benchmark-lint) (push) Waiting to run
Benchmark Bridge Tests / benchmark (bunx vitest run --config packages/lifeops-bench/vitest.config.ts --root packages/lifeops-bench --passWithNoTests, benchmark-tests) (push) Waiting to run
Build Agent Image / build-and-push (push) Waiting to run
Chat shell gestures / Chat shell gesture + parity e2e (push) Waiting to run
ci / test (push) Waiting to run
ci / lint-and-format (push) Waiting to run
ci / build (push) Waiting to run
ci / dev-startup (push) Waiting to run
Cloud Gateway Discord / Test (push) Waiting to run
Cloud Gateway Webhook / Test (push) Waiting to run
Cloud Tests / lint-and-types (push) Waiting to run
Cloud Tests / unit-tests (push) Waiting to run
Cloud Tests / integration-tests (push) Waiting to run
Cloud Tests / e2e-tests (push) Blocked by required conditions
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Deploy Apps Worker (Product 2) / Determine environment (push) Waiting to run
Deploy Apps Worker (Product 2) / Deploy apps worker to apps-control host (${{ needs.determine-env.outputs.environment }}) (push) Blocked by required conditions
Deploy Eliza Provisioning Worker / Determine environment (push) Waiting to run
Deploy Eliza Provisioning Worker / Deploy worker to Hetzner host (${{ needs.determine-env.outputs.environment }} @ ${{ needs.determine-env.outputs.deployment_sha }}) (push) Blocked by required conditions
Dev Smoke / Classify changed paths (push) Waiting to run
Dev Smoke / bun run dev onboarding chat (push) Blocked by required conditions
Dev Smoke / Vite HMR dependency-level smoke (push) Blocked by required conditions
Electrobun Submodule Guard / electrobun gitlink is fetchable (push) Waiting to run
gitleaks / gitleaks (push) Waiting to run
Markdown Links / Relative Markdown Links (push) Waiting to run
Publish @elizaos/example-code / check_npm (push) Waiting to run
Publish @elizaos/example-code / publish_npm (push) Blocked by required conditions
Publish @elizaos/plugin-elizacloud / verify_version (push) Waiting to run
Publish @elizaos/plugin-elizacloud / publish_npm (push) Blocked by required conditions
Quality (Extended) / Homepage Build (PR smoke) (push) Waiting to run
Quality (Extended) / Comment-only diff guard (push) Waiting to run
Quality (Extended) / Format + Type Safety Ratchet (push) Waiting to run
Quality (Extended) / Develop Gate (secret scan + UI determinism) (push) Waiting to run
Quality (Extended) / Develop Gate (lint) (push) Waiting to run
Sandbox Live Smoke / Sandbox live smoke (push) Waiting to run
Snap Build & Test / Build Snap (amd64) (push) Waiting to run
Snap Build & Test / Build Snap (arm64) (push) Waiting to run
supply-chain / sbom (push) Waiting to run
supply-chain / vulnerability-scan (push) Waiting to run
Build, Push & Deploy to Phala Cloud / build-and-push (push) Waiting to run
Test Packaging / Validate Packaging Configs (push) Waiting to run
Test Packaging / PyPI on Python ${{ matrix.python }} (push) Waiting to run
Test Packaging / Pack & Test JS Tarballs (push) Waiting to run
Test Packaging / elizaos CLI global-install smoke (node + bun) (push) Waiting to run
UI Fixture E2E / ui-fixture-e2e (push) Waiting to run
UI Fixture E2E / fixture-e2e (push) Waiting to run
UI Story Gate / story-gate (push) Waiting to run
vault-ci / test (macos-latest) (push) Waiting to run
vault-ci / test (ubuntu-latest) (push) Waiting to run
vault-ci / test (windows-latest) (push) Waiting to run
vault-ci / app-core wiring tests (push) Waiting to run
verify-patches / verify patches/CHECKSUMS.sha256 (push) Waiting to run
Voice Benchmark Smoke / voice-emotion fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voiceagentbench fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench-quality unit smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench TypeScript unit (no audio) (push) Waiting to run
Voice Benchmark Smoke / voice bench smoke summary (push) Blocked by required conditions
Windows CI / windows ([bun run --cwd packages/app-core test bun run --cwd packages/elizaos test bun run --cwd packages/cloud/shared test], app-and-cli) (push) Waiting to run
Windows CI / windows ([bun run --cwd packages/scenario-runner test bun run --cwd packages/vault test bun run --cwd packages/security test bun run --cwd plugins/plugin-coding-tools test], framework-packages) (push) Waiting to run
Windows CI / windows ([bun run --cwd plugins/plugin-elizacloud test bun run --cwd plugins/plugin-discord test bun run --cwd plugins/plugin-anthropic test bun run --cwd plugins/plugin-openai test bun run --cwd plugins/plugin-app-control test bun run --cwd plugins/pl… (push) Waiting to run
Windows CI / windows ([node packages/scripts/run-turbo.mjs run build --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/agent --concurrency=4 node packages/scripts/run-bash-linux-only.mjs scripts/verify-riscv64-buildpaths.sh node packages/scripts/run… (push) Waiting to run
Windows CI / windows ([node packages/scripts/run-turbo.mjs run typecheck --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/cloud-shared --concurrency=4 bun run --cwd packages/core test bun run --cwd packages/shared test], core-runtime, 75) (push) Waiting to run
Test Packaging / Build & Test PyPI Package (push) Waiting to run
Voice Workbench / headless workbench (mocked backends) (push) Has been cancelled
Voice Workbench / real acoustic lane (nightly, provisioned only) (push) Has been cancelled
240 lines
5.8 KiB
TypeScript
240 lines
5.8 KiB
TypeScript
/**
|
|
* elizaOS Cloudflare Worker Test Client
|
|
*
|
|
* Interactive CLI client for testing the Cloudflare Worker.
|
|
* Supports both regular and streaming chat modes.
|
|
*
|
|
* Usage:
|
|
* bun run test-client.ts # Regular chat
|
|
* bun run test-client.ts --stream # Streaming chat
|
|
* bun run test-client.ts --url <url> # Custom URL
|
|
*/
|
|
|
|
import * as readline from "node:readline";
|
|
|
|
interface ChatResponse {
|
|
response: string;
|
|
conversationId: string;
|
|
character: string;
|
|
}
|
|
|
|
interface InfoResponse {
|
|
name: string;
|
|
bio: string;
|
|
version: string;
|
|
endpoints: Record<string, string>;
|
|
}
|
|
|
|
interface StreamEvent {
|
|
text?: string;
|
|
conversationId?: string;
|
|
character?: string;
|
|
}
|
|
|
|
// Parse command line arguments
|
|
function parseArgs(): { url: string; stream: boolean } {
|
|
const args = process.argv.slice(2);
|
|
let url = "http://localhost:8787";
|
|
let stream = false;
|
|
|
|
for (let i = 0; i < args.length; i++) {
|
|
if (args[i] === "--stream" || args[i] === "-s") {
|
|
stream = true;
|
|
} else if ((args[i] === "--url" || args[i] === "-u") && args[i + 1]) {
|
|
url = args[i + 1];
|
|
i++;
|
|
} else if (args[i] === "--help" || args[i] === "-h") {
|
|
console.log(`
|
|
elizaOS Cloudflare Worker Test Client
|
|
|
|
Usage:
|
|
bun run test-client.ts [options]
|
|
|
|
Options:
|
|
--stream, -s Use streaming mode
|
|
--url, -u <url> Worker URL (default: http://localhost:8787)
|
|
--help, -h Show this help message
|
|
|
|
Examples:
|
|
bun run test-client.ts # Local development
|
|
bun run test-client.ts --stream # Streaming mode
|
|
bun run test-client.ts --url https://your-worker.workers.dev
|
|
`);
|
|
process.exit(0);
|
|
}
|
|
}
|
|
|
|
return { url, stream };
|
|
}
|
|
|
|
async function getWorkerInfo(baseUrl: string): Promise<InfoResponse | null> {
|
|
try {
|
|
const response = await fetch(baseUrl);
|
|
if (response.ok) {
|
|
return (await response.json()) as InfoResponse;
|
|
}
|
|
} catch {
|
|
return null;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
async function sendMessage(
|
|
baseUrl: string,
|
|
message: string,
|
|
conversationId: string | null,
|
|
): Promise<ChatResponse> {
|
|
const response = await fetch(`${baseUrl}/chat`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
message,
|
|
conversationId,
|
|
}),
|
|
});
|
|
|
|
if (!response.ok) {
|
|
const error = await response.text();
|
|
throw new Error(`API error: ${response.status} - ${error}`);
|
|
}
|
|
|
|
return (await response.json()) as ChatResponse;
|
|
}
|
|
|
|
async function sendStreamMessage(
|
|
baseUrl: string,
|
|
message: string,
|
|
conversationId: string | null,
|
|
onChunk: (text: string) => void,
|
|
): Promise<{ conversationId: string; character: string }> {
|
|
const response = await fetch(`${baseUrl}/chat/stream`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
message,
|
|
conversationId,
|
|
}),
|
|
});
|
|
|
|
if (!response.ok) {
|
|
const error = await response.text();
|
|
throw new Error(`API error: ${response.status} - ${error}`);
|
|
}
|
|
|
|
const reader = response.body?.getReader();
|
|
if (!reader) {
|
|
throw new Error("No response body");
|
|
}
|
|
|
|
const decoder = new TextDecoder();
|
|
const metadata = { conversationId: "", character: "" };
|
|
|
|
while (true) {
|
|
const { done, value } = await reader.read();
|
|
if (done) break;
|
|
|
|
const chunk = decoder.decode(value, { stream: true });
|
|
const lines = chunk.split("\n");
|
|
|
|
for (const line of lines) {
|
|
if (line.startsWith("data: ")) {
|
|
const data = line.slice(6);
|
|
if (data === "[DONE]") {
|
|
continue;
|
|
}
|
|
|
|
const event = JSON.parse(data) as StreamEvent;
|
|
if (event.conversationId) {
|
|
metadata.conversationId = event.conversationId;
|
|
}
|
|
if (event.character) {
|
|
metadata.character = event.character;
|
|
}
|
|
if (event.text) {
|
|
onChunk(event.text);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return metadata;
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
const { url, stream } = parseArgs();
|
|
|
|
console.log("\n🚀 elizaOS Cloudflare Worker Test Client\n");
|
|
console.log(`📡 Connecting to: ${url}`);
|
|
console.log(`📨 Mode: ${stream ? "Streaming" : "Regular"}\n`);
|
|
|
|
// Check if worker is available
|
|
const info = await getWorkerInfo(url);
|
|
if (!info) {
|
|
console.log("⚠️ Worker not available at", url);
|
|
console.log(" Skipping integration tests (worker must be running)");
|
|
console.log("\n To run these tests:");
|
|
console.log(" 1. cd examples/cloudflare");
|
|
console.log(" 2. bun run dev");
|
|
console.log(" 3. bun run test\n");
|
|
return;
|
|
}
|
|
|
|
console.log(`🤖 Character: ${info.name}`);
|
|
console.log(`📖 Bio: ${info.bio}\n`);
|
|
console.log('💬 Chat with the agent (type "exit" to quit)\n');
|
|
|
|
const rl = readline.createInterface({
|
|
input: process.stdin,
|
|
output: process.stdout,
|
|
});
|
|
|
|
let conversationId: string | null = null;
|
|
|
|
const prompt = (): void => {
|
|
rl.question("You: ", async (input) => {
|
|
const text = input.trim();
|
|
|
|
if (text.toLowerCase() === "exit" || text.toLowerCase() === "quit") {
|
|
console.log("\n👋 Goodbye!\n");
|
|
rl.close();
|
|
process.exit(0);
|
|
}
|
|
|
|
if (!text) {
|
|
prompt();
|
|
return;
|
|
}
|
|
|
|
if (stream) {
|
|
process.stdout.write(`${info.name}: `);
|
|
|
|
const metadata = await sendStreamMessage(
|
|
url,
|
|
text,
|
|
conversationId,
|
|
(chunk) => {
|
|
process.stdout.write(chunk);
|
|
},
|
|
);
|
|
|
|
conversationId = metadata.conversationId;
|
|
console.log("\n");
|
|
} else {
|
|
const response = await sendMessage(url, text, conversationId);
|
|
conversationId = response.conversationId;
|
|
console.log(`\n${response.character}: ${response.response}\n`);
|
|
}
|
|
|
|
prompt();
|
|
});
|
|
};
|
|
|
|
prompt();
|
|
}
|
|
|
|
main().catch(console.error);
|