Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 12:43:05 +08:00

238 lines
6.7 KiB
JavaScript

/**
* Shared helpers for the native capture scripts (capture-android-emu,
* capture-ios-sim): CLI/env arg parsing, capture-path resolution, capture
* logging, starting the device-facing host agent, artifact copying, and writing
* the capture manifest. SKIP_EXIT_CODE (77) is the agreed "device unavailable,
* skip cleanly" exit code across those scripts.
*/
import { spawn } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
export const SKIP_EXIT_CODE = 77;
export function hasArg(args, flag) {
return args.includes(flag);
}
export function argValue(args, flag, fallback = null) {
const index = args.indexOf(flag);
return index >= 0 && args[index + 1] ? args[index + 1] : fallback;
}
export const DEFAULT_API_PORT = 31337;
/**
* Resolve the backend API port a capture run should target. Precedence:
* 1. explicit `--api-port <n>` CLI arg,
* 2. `ELIZA_API_PORT` env (the orchestrator advertises the auto-shifted port
* here so parallel worktree stacks don't collide on 31337),
* 3. the built-in default (31337).
* A bare hardcoded 31337 silently probes the wrong backend on a port-shifted
* stack; this resolver keeps the same default while honoring an override
* (#13624). Only a bare positive integer in range is accepted; anything else
* falls through to the next source.
*
* @param {string[]} [args] argv slice (e.g. process.argv.slice(2))
* @param {Record<string, string | undefined>} [env]
* @returns {number}
*/
export function resolveApiPort(args = [], env = process.env) {
const candidates = [argValue(args, "--api-port"), env?.ELIZA_API_PORT];
for (const raw of candidates) {
if (typeof raw !== "string") continue;
const trimmed = raw.trim();
if (!/^\d+$/.test(trimmed)) continue;
const parsed = Number.parseInt(trimmed, 10);
if (Number.isInteger(parsed) && parsed > 0 && parsed <= 65535) {
return parsed;
}
}
return DEFAULT_API_PORT;
}
export function resolveCapturePaths({ repoRoot, platform, slug, args }) {
const issue = argValue(args, "--issue", process.env.EVIDENCE_ISSUE);
const prefix =
argValue(args, "--evidence-prefix", process.env.EVIDENCE_PREFIX) ??
(issue ? `${issue}-${slug}` : `local-${slug}`);
const evidenceDir = path.resolve(
repoRoot,
argValue(
args,
"--out",
process.env.EVIDENCE_ARTIFACT_DIR ??
path.join(
"e2e-recordings",
platform,
"test-results",
"native-capture",
prefix,
),
),
);
const recordingResultDir = path.join(
repoRoot,
"e2e-recordings",
platform,
"test-results",
"native-capture",
);
fs.mkdirSync(evidenceDir, { recursive: true });
fs.mkdirSync(recordingResultDir, { recursive: true });
return { prefix, evidenceDir, recordingResultDir };
}
export function createCaptureLog(logPath, prefix) {
fs.mkdirSync(path.dirname(logPath), { recursive: true });
const stream = fs.createWriteStream(logPath, { flags: "a" });
return {
logPath,
writeRaw(chunk) {
stream.write(chunk);
},
log(message) {
const line = `[${prefix}] ${message}`;
console.log(line);
stream.write(`${line}\n`);
},
close() {
stream.end();
},
};
}
export async function runCommandWithLog(command, args, options = {}) {
const {
cwd,
env = {},
logSink,
label = `${command} ${args.join(" ")}`,
} = options;
logSink?.log(`running ${label}`);
await new Promise((resolve, reject) => {
const child = spawn(command, args, {
cwd,
env: { ...process.env, ...env },
stdio: ["ignore", "pipe", "pipe"],
});
child.stdout.on("data", (chunk) => {
process.stdout.write(chunk);
logSink?.writeRaw(chunk);
});
child.stderr.on("data", (chunk) => {
process.stderr.write(chunk);
logSink?.writeRaw(chunk);
});
child.on("error", reject);
child.on("close", (code) => {
if (code === 0) {
resolve();
return;
}
reject(new Error(`${label} exited with ${code}`));
});
});
}
async function healthReady(url) {
try {
const response = await fetch(url, {
headers: { "X-ElizaOS-Client-Id": "native-capture" },
});
return response.ok;
} catch {
return false;
}
}
async function waitForHealth(url, timeoutMs) {
const deadline = Date.now() + timeoutMs;
while (Date.now() < deadline) {
if (await healthReady(url)) return true;
await new Promise((resolve) => setTimeout(resolve, 1_000));
}
return false;
}
export async function startDeviceE2EHostAgent({
repoRoot,
port = resolveApiPort(),
timeoutMs = 180_000,
logSink,
}) {
const healthUrl = `http://127.0.0.1:${port}/api/health`;
if (await waitForHealth(healthUrl, 2_000)) {
logSink?.log(`reusing host agent at ${healthUrl}`);
return { started: false, async stop() {} };
}
logSink?.log(`starting deterministic host agent at ${healthUrl}`);
const child = spawn(
process.execPath,
[
"packages/app-core/scripts/run-node-tsx.mjs",
"packages/app-core/scripts/serve-real-local-agent.ts",
],
{
cwd: repoRoot,
env: {
...process.env,
ELIZA_API_PORT: String(port),
ELIZA_PAIRING_DISABLED: "1",
},
stdio: ["ignore", "pipe", "pipe"],
},
);
child.stdout.on("data", (chunk) => {
process.stdout.write(chunk);
logSink?.writeRaw(chunk);
});
child.stderr.on("data", (chunk) => {
process.stderr.write(chunk);
logSink?.writeRaw(chunk);
});
if (!(await waitForHealth(healthUrl, timeoutMs))) {
child.kill("SIGTERM");
throw new Error(`host agent did not become healthy at ${healthUrl}`);
}
return {
started: true,
async stop() {
if (child.exitCode !== null) return;
logSink?.log("stopping deterministic host agent");
child.kill("SIGTERM");
await Promise.race([
new Promise((resolve) => child.once("close", resolve)),
new Promise((resolve) => setTimeout(resolve, 5_000)),
]);
if (child.exitCode === null) child.kill("SIGKILL");
},
};
}
export function copyArtifact(src, destDir, destName, { required = true } = {}) {
if (!src) {
if (required) throw new Error("copyArtifact requires a source path");
return null;
}
try {
if (fs.statSync(src).size <= 0) throw new Error("empty file");
} catch (error) {
if (!required) return null;
throw new Error(`artifact missing or empty: ${src} (${error.message})`);
}
fs.mkdirSync(destDir, { recursive: true });
const dest = path.join(destDir, destName ?? path.basename(src));
fs.copyFileSync(src, dest);
return dest;
}
export function writeCaptureManifest(filePath, data) {
fs.mkdirSync(path.dirname(filePath), { recursive: true });
fs.writeFileSync(filePath, `${JSON.stringify(data, null, 2)}\n`);
}