Files
openworker/harness/tests/linux-client/entry.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

29 lines
1.8 KiB
JavaScript

// Forward the existing developer gateway without changing its configuration or
// TLS identity. This bridge is a test topology, not part of the runtime release.
import {spawn} from 'node:child_process';
import {readFile} from 'node:fs/promises';
import {join} from 'node:path';
// Optional test-only credential bootstrap. It enters through stdin, never a
// Docker environment definition, command-line argument, mount, or on-disk file.
const args=process.argv.slice(2);
if(args[0]==='--credential-stdin'){
args.shift();let secret='';
for await(const chunk of process.stdin){secret+=chunk;if(secret.length>16384)throw new Error('Credential bootstrap exceeds limit');}
const credential=JSON.parse(secret);
if(typeof credential.api_key!=='string'||!credential.api_key)throw new Error('Missing bootstrap credential');
process.env.OPENAI_API_KEY=credential.api_key;
secret='';
}
const home=process.env.XDG_CONFIG_HOME||join(process.env.HOME,'.config');
const active=(await readFile(join(home,'openshell/active_gateway'),'utf8')).trim();
const metadata=JSON.parse(await readFile(join(home,'openshell/gateways',active,'metadata.json'),'utf8'));
const endpoint=new URL(metadata.gateway_endpoint);
if(!['localhost','127.0.0.1'].includes(endpoint.hostname))throw new Error('This test bridge requires a local developer gateway');
const port=endpoint.port;
const proxy=spawn('socat',[`TCP-LISTEN:${port},bind=127.0.0.1,reuseaddr,fork`,`TCP:host.docker.internal:${port}`],{stdio:'inherit'});
await new Promise(resolve=>setTimeout(resolve,500));
const native=args[0]==='--native';
const child=native?spawn(process.env.OPENWORKER_BIN,args.slice(1),{stdio:'inherit',env:process.env}):spawn('node',['examples/stdio-client.mjs',...args],{stdio:'inherit',env:process.env});
const code=await new Promise(resolve=>child.on('exit',resolve));
proxy.kill();process.exitCode=code||0;