Files
openworker/docs-site/scripts/source-examples.mjs
Rohit PrasadandDevika Verma d53e058eda Introduce OpenWorker Harness SDK (in beta), agent service cluster and relevant developer documentation (#844)
Allow developers to easily build AI apps without worrying about the harness part.
Bundles the Rust agent runtime as a SDK (Rust and TypeScript) for building desktop and web applications. Applications can manage a local harness or connect to an authenticated harness service on k8s with separately scaled workers and sandbox execution.

The implementation is primarily contained in harness/, with deployment tooling in deploy/, Markdown guides in docs/harness/guides/, and the static documentation site in docs-site/. It does not replace the existing Python harness or migrate OpenWorker Desktop.

Co-authored-by: Devika Verma <devikaverma11@gmail.com>
2026-11-06 09:45:20 -08:00

65 lines
1.7 KiB
JavaScript

import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
import { join } from "node:path";
// Explicit manifests: never publish directory scans, local state or credentials.
export const manifests = {
desktop: [
"README.md",
"src/agent.ts",
"src/directory.ts",
"desktop/main.mjs",
"desktop/preload.cjs",
"public/desktop.html",
"public/desktop.js",
"public/style.css",
"rust/src/main.rs",
"rust/Cargo.toml",
"package.json",
"tsconfig.json",
"scripts/export-context.mjs",
"scripts/setup.mjs",
"scripts/bundle-runtime.mjs",
],
web: [
"README.md",
"src/agent.ts",
"web/server.mjs",
"web/pdf.mjs",
"web/pdf-worker.mjs",
"public/pdf.html",
"public/pdf.js",
"public/style.css",
"rust/src/main.rs",
"rust/Cargo.toml",
"package.json",
"tsconfig.json",
"scripts/export-context.mjs",
"Dockerfile",
"Dockerfile.dockerignore",
],
};
export function writeSources(root, publicDir) {
const output = join(publicDir, "examples");
mkdirSync(output, { recursive: true });
for (const [track, paths] of Object.entries(manifests)) {
const files = paths.map((path) => ({
path,
content: readFileSync(
join(root, "harness/examples/quickstart", path),
"utf8",
),
}));
writeFileSync(
join(output, `${track}.json`),
JSON.stringify({ track, files }),
);
}
}
export function renderSourceButton(markdown, base) {
return markdown.replace(
/<!-- sdk-source: (desktop|web) -->/g,
(_, track) =>
`<button class="example-source-button" data-example-source="${base}/examples/${track}.json" type="button">Browse example source <span aria-hidden="true">↗</span></button>`,
);
}