Files
cindy/packages/browser-control-runtime/scripts/smoke.mjs
Lizi bb3f71d084 chore: Cindy 首次开源提交 / initial open-source release
Cindy 是心动网络 (X.D. Network Inc.) 的跨端 AI Agent 客户端。
本次提交包含 Desktop(Electron)、Mobile(Expo)及全部共享 packages
的完整源码,以 Apache-2.0 协议开源。

This is the first public release of Cindy, X.D. Network's cross-platform
AI agent client: the Electron desktop app, the Expo mobile app, and all
shared workspace packages, licensed under Apache-2.0.

- 许可与合规:根 LICENSE(Apache-2.0)+ NOTICE;第三方组件归属声明与
  SPDX SBOM 收口在 docs/legal/notices/,由 pnpm licenses:generate 生成。
- 社区文件:README / CONTRIBUTING / CODE_OF_CONDUCT / SECURITY / SUPPORT
  中英双语;issue / PR 模板与 CI workflow 在 .github/。
- 协议层以公开 submodule 引入:github.com/makecindy/cindy-protocol。
- 提交前已通过仓库门禁:全量 pnpm test:unit 与涉及 package 的 typecheck。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 08:30:44 +08:00

57 lines
2.0 KiB
JavaScript

/**
* Real end-to-end smoke test (NOT a unit test — launches a real browser).
* Run: node --import tsx scripts/smoke.mjs [url]
*
* Drives the runtime through: status → start → navigate → snapshot →
* screenshot → tabs → stop, printing each step's result. Uses the locally
* detected Chrome (vendored executable detection); no extension required.
*/
import { createBrowserControlRuntime } from '../src/runtime.ts';
const url = process.argv[2] ?? 'https://example.com';
const rt = createBrowserControlRuntime({
config: {
browser: {
enabled: true,
headless: true,
// default managed profile; SSRF allows private net for loopback control
ssrfPolicy: { dangerouslyAllowPrivateNetwork: true },
},
},
logSink: (level, scope, args) => {
if (level === 'warn' || level === 'error') console.error(`[${level}:${scope}]`, ...args);
},
});
function show(label, res) {
const dataPreview =
typeof res.data === 'object' && res.data
? JSON.stringify(res.data).slice(0, 300)
: String(res.data).slice(0, 300);
console.log(
`\n== ${label} == ok=${res.ok} status=${res.status ?? '-'} ${res.errorCode ?? ''}\n ${res.message ?? dataPreview}`,
);
return res;
}
async function main() {
show('status', await rt.call({ action: 'status' }));
show('doctor', await rt.call({ action: 'doctor' }));
show('start', await rt.call({ action: 'start' }));
show('navigate', await rt.call({ action: 'navigate', url }));
const snap = show('snapshot', await rt.call({ action: 'snapshot', snapshotFormat: 'ai', interactive: true }));
show('screenshot', await rt.call({ action: 'screenshot', type: 'jpeg' }));
show('tabs', await rt.call({ action: 'tabs' }));
show('stop', await rt.call({ action: 'stop' }));
const navOk = snap.ok;
console.log(`\n=== SMOKE ${navOk ? 'PASS' : 'FAIL'} (snapshot ok=${navOk}) ===`);
process.exit(navOk ? 0 : 1);
}
main().catch((err) => {
console.error('\n=== SMOKE CRASH ===\n', err);
process.exit(2);
});