Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(embed): bootstrap pinned standalone source consumers

Steven Enamakel4c6f7a4065fe
diff --git a/crates/openhuman-embed/CONSUMERS.md b/crates/openhuman-embed/CONSUMERS.md
new file mode 100644
index 0000000000..2bc8356464
--- /dev/null
+++ b/crates/openhuman-embed/CONSUMERS.md
@@ -0,0 +1,102 @@
+# Standalone consumers
+
+Embed currently ships as source in the OpenHuman monorepo. Its crates have
+`publish = false`; there is no crates.io release or promised semver boundary.
+Pin a full 40-character commit SHA and commit the consumer's `Cargo.lock`.
+Use a reviewed commit on upstream `main`, or a reviewed release tag resolved
+to its full SHA. Never track a floating `main` dependency in a production
+server. Updating the pin is an explicit dependency change with host tests.
+
+The supported bootstrap generates a fresh consumer workspace. A checkout
+containing the script is enough; its own submodules need not be initialized.
+With Python 3.11+, Git and Rust 1.96.1 installed:
+
+```sh
+python3 scripts/bootstrap-embed-consumer.py \
+ --rev 9d35caa5f142499933e3aacc8fc68bac64aac741 \
+ --destination /path/to/new-host
+cd /path/to/new-host
+cargo check
+cargo check --features embed
+```
+
+The pin above is an example baseline, not a claim that later additions are
+present there. Choose the reviewed commit containing the APIs your host uses.
+`--source /path/to/local/openhuman` can use a local Git checkout. The checkout
+must contain the requested commit; uncommitted files, local `.env` files and
+untracked credentials are not copied. Credential-bearing source URLs are
+refused; use Git credential helpers or SSH authentication. An existing
+destination is never overwritten. Git failures leave no partial destination.
+
+The bootstrap:
+
+1. Clones committed source into `vendor/openhuman`, verifies the exact commit,
+ and initializes recursive submodules at their recorded gitlinks.
+2. Reads that pin's workspace `[patch]` tables and generates the matching
+ consumer-root Cargo patches with relative paths. Paths outside the source
+ checkout and unknown patch forms are refused.
+3. Creates an optional `openhuman-embed` dependency, `embed` feature and pinned
+ toolchain. Seeds the host lockfile from the source lockfile when present,
+ then resolves it and removes only Cargo-reported unused patches. This avoids
+ nondeterministic `patch.unused` ordering causing spurious `--locked` failures.
+ Strips Git metadata from the generated bundle so the host can commit source
+ files normally, without accidentally creating undocumented Git submodules.
+ `OPENHUMAN_REV` records the source pin.
+
+Cargo does not inherit a dependency workspace's patches. A bare git dependency
+on Embed can therefore resolve different TinyTools/TinyInference copies and
+create incompatible types. Cargo normally fetches Git submodules itself; that
+does not make dependency-root patches propagate. The bootstrap owns both
+steps so consumers do not have to initialize submodules or mirror patch lists
+by hand. For an existing host, move the generated dependency, feature and
+patch sections to its workspace-root manifest together, retaining the bundle
+at the same relative path. Regenerate from the new pin when upgrading.
+
+This is a source bundle, not a binary SDK or a registry package. Initial setup
+requires network access unless the needed Git repositories are already local.
+Cargo's registry cache is also needed for a subsequent `--offline` build.
+Pass `--offline` to the bootstrap to resolve Cargo using cached registry sources;
+this flag does not disable Git fetching during source/submodule preparation.
+
+# Feature and HTTP boundaries
+
+The generated host has `default = []`; its default build does not compile
+Embed, the core, or an HTTP client through this dependency. The `embed` feature
+turns on `openhuman-embed` with `default-features = false`, which avoids the
+core's default product feature set and optional hosted modules.
+
+**Enabling Embed still compiles the core and its unconditional HTTP
+libraries.** This pin does not offer an HTTP-free Embed implementation. Do not
+describe `default-features = false` as an offline dependency graph. It controls
+features, not all transitive dependencies. A host that must have no HTTP in
+its default binary must keep Embed optional and feature-gate every reference
+to it, as the generated entry point does. The core does not contact a service
+merely because its HTTP libraries are linked; runtime configuration and the
+chosen operation determine requests.
+
+The supported toolchain is Rust 1.96.1, matching `rust-toolchain.toml`.
+Dependencies use `cfg_select!`, stabilized in Rust 1.96; older toolchains are
+not supported by this source pin. Pinning the exact toolchain also makes
+consumer diagnostics reproducible.
+
+# Sharing a server runtime
+
+Use `openhuman_embed::process::tokio_runtime()` or its configurable
+`tokio_runtime_builder()` to build Tokio. These helpers set the worker stack
+size and blocking-thread limit required by deep agent turns; a host does not
+need to import core constants or hand-assemble the builder.
+
+Create one `Runtime` during server startup and share it with `Arc<Runtime>`.
+Create or reuse independently configured `Agent` handles on that runtime;
+clone an agent handle for concurrent requests and use distinct session IDs
+for unrelated reviews. Do not call `Runtime::builder().build()` per HTTP
+request: process-wide keyring, event bus and subscriber ownership deliberately
+refuse a second live runtime with `RuntimeError::AlreadyRunning`.
+
+Tenants requiring distinct configuration can use `ProfileRuntime`; callers
+must still follow its shared-process isolation contract. A runtime's shared
+bus and process state do not provide arbitrary process isolation. Runtime
+ownership, agent lifetime and session scopes should be tested by the host.
+
+See [runtime](src/runtime/README.md), [profiles](src/profiles.rs) and
+[routing](ROUTING.md).
diff --git a/crates/openhuman-embed/README.md b/crates/openhuman-embed/README.md
index aa99740da4..5d28376921 100644
--- a/crates/openhuman-embed/README.md
+++ b/crates/openhuman-embed/README.md
@@ -9,6 +9,8 @@ OpenCompany and other embedding products use it directly, and
narrative walkthrough is
[`gitbooks/developing/embedding.md`](../../gitbooks/developing/embedding.md).
+Standalone source pins, generated Cargo patches, feature boundaries and shared server runtimes: [consumer setup](CONSUMERS.md).
+
## How it works
The crate has two entry points, and they sit at different heights over the
@@ -79,17 +81,22 @@ for a typed method here.
## Using it
-Add the dependency with the default contributor features, or pick a narrow
-host build:
+Use the [pinned consumer bootstrap](CONSUMERS.md) to prepare source,
+recursive submodules and the consumer-root Cargo patches together. It generates:
```toml
-[dependencies]
-openhuman-embed = { git = "https://github.com/tinyhumansai/openhuman", package = "openhuman-embed" }
+[features]
+default = []
+embed = ["dep:openhuman-embed"]
-# or
-openhuman-embed = { git = "https://github.com/tinyhumansai/openhuman", package = "openhuman-embed", default-features = false, features = ["inference", "mcp"] }
+[dependencies]
+openhuman-embed = { path = "vendor/openhuman/crates/openhuman-embed", optional = true, default-features = false }
```
+The dependency and generated patch sections belong in the host's workspace
+root. Enabling `embed` still includes the core and its HTTP libraries; the
+host's default build can leave that optional dependency disabled.
+
### A runtime and several agents
For hosted TinyHumans inference and services, build the runtime with
diff --git a/crates/openhuman-embed/src/runtime/mod.rs b/crates/openhuman-embed/src/runtime/mod.rs
index 911b32530b..bced2c9093 100644
--- a/crates/openhuman-embed/src/runtime/mod.rs
+++ b/crates/openhuman-embed/src/runtime/mod.rs
@@ -60,11 +60,11 @@
//!
//! # The tokio runtime is yours
//!
-//! Build it with
-//! [`AGENT_WORKER_STACK_BYTES`](openhuman_core::core::runtime::AGENT_WORKER_STACK_BYTES)
-//! and [`MAX_BLOCKING_THREADS`](openhuman_core::core::runtime::MAX_BLOCKING_THREADS);
-//! an agent turn is a very deep async state machine and the default 2 MiB
-//! worker stack overflows.
+//! Use [`crate::process::tokio_runtime`] or
+//! [`crate::process::tokio_runtime_builder`]. These helpers set the worker
+//! stack size and blocking-thread limit for deep agent turns; Tokio's default
+//! 2 MiB worker stack is too small. Create one [`Runtime`] and share it with
+//! `Arc<Runtime>` across server requests, with independent agent/session scopes.
mod api_key;
mod build;
diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.md
index f3a5c2ff69..0bdd61a1ad 100644
--- a/docs/TEST-COVERAGE-MATRIX.md
+++ b/docs/TEST-COVERAGE-MATRIX.md
@@ -663,6 +663,7 @@ The thread JSONL store moved to `tinyagents_session::threads` (`vendor/tinyagent
| 16.1.14 | Host-backed read-only repository toolset | RI | `crates/openhuman-embed/tests/repository_tools.rs`, `crates/openhuman-embed/tests/repository_host_only.rs` | ✅ | Validated tree/range/search/symbol/git queries delegate only to the host; mandatory redaction, fenced bounded output, sanitized failures, and real HostOnly + readonly + untrusted-input refusal of shell/write/network. |
| 16.1.15 | Strict structured output and bounded repair | RI | `crates/openhuman-embed/tests/structured_validation.rs`, `crates/openhuman-embed/tests/structured_turns.rs` | ✅ | Wrong types and numeric combinators refused, invalid/external schemas make no call, repair bounded with usage, terminal length rejected even for complete JSON. |
| 16.1.16 | Explicit routing ladders and required exploration | RI | `crates/openhuman-embed/tests/completion_routing.rs`, `crates/openhuman-embed/tests/tool_required_routing.rs`, `crates/openhuman-embed/tests/structured_turns.rs` | ✅ | Ordered fallbacks, bounded truncation retries, unpinned terminal provider selection, image/options preservation, accumulated reported costs, actual answering model and refusal of schema-valid output before successful tool execution |
+| 16.1.17 | Pinned standalone Embed source consumer | Script+RI | `scripts/__tests__/embed-consumer-bootstrap.test.mjs` | ✅ | Exact SHA verification, inherited workspace edition, generated active patches, stable locked offline builds with optional Embed enabled/disabled, default dependency tree without HTTP, no untracked secrets or Git metadata, refused malformed/escaping patches and existing destinations |
## Summary
diff --git a/scripts/README.md b/scripts/README.md
index 62628cc194..1de55de363 100644
--- a/scripts/README.md
+++ b/scripts/README.md
@@ -4,6 +4,8 @@ Repo-maintenance, CI, dev-loop, and release tooling. This is a map, not a
manual, each entry point below has its own header comment or README with the
details.
+Standalone Embed source bundles: [`bootstrap-embed-consumer.py`](bootstrap-embed-consumer.py) verifies a commit pin, prepares submodules and generates a consumer Cargo workspace; see [consumer setup](../crates/openhuman-embed/CONSUMERS.md).
+
## Sub-directories
The first five have their own README; the rest are documented by the header
diff --git a/scripts/__tests__/embed-consumer-bootstrap.test.mjs b/scripts/__tests__/embed-consumer-bootstrap.test.mjs
new file mode 100644
index 0000000000..1aeb4d70fa
--- /dev/null
+++ b/scripts/__tests__/embed-consumer-bootstrap.test.mjs
@@ -0,0 +1,98 @@
+import assert from 'node:assert/strict';
+import { execFileSync, spawnSync } from 'node:child_process';
+import { mkdirSync, mkdtempSync, writeFileSync, readFileSync, existsSync, rmSync } from 'node:fs';
+import { dirname, join, resolve } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { test } from 'node:test';
+
+const root = resolve(dirname(fileURLToPath(import.meta.url)), '../..');
+const script = join(root, 'scripts/bootstrap-embed-consumer.py');
+function fixture() {
+ mkdirSync(join(root, 'target'), { recursive: true });
+ const directory = mkdtempSync(join(root, 'target/embed-bootstrap-fixture-'));
+ const source = join(directory, 'source');
+ for (const path of ['crates/openhuman-embed/src', 'vendor/local-patch-fixture/src', 'vendor/unused-fixture/src'])
+ mkdirSync(join(source, path), { recursive: true });
+ writeFileSync(join(source, 'Cargo.toml'), '[workspace]\nmembers = ["crates/openhuman-embed", "vendor/local-patch-fixture"]\n[workspace.package]\nedition = "2024"\n[patch.crates-io]\nlocal-patch-fixture = { path = "vendor/local-patch-fixture" }\nunused-fixture = { path = "vendor/unused-fixture" }\n');
+ writeFileSync(join(source, 'crates/openhuman-embed/Cargo.toml'), '[package]\nname = "openhuman-embed"\nversion = "0.0.0"\nedition.workspace = true\n[dependencies]\nlocal-patch-fixture = "1.0.0"\n');
+ writeFileSync(join(source, 'crates/openhuman-embed/src/lib.rs'), '//! Fixture facade.\npub use local_patch_fixture::value;\n');
+ writeFileSync(join(source, 'vendor/local-patch-fixture/Cargo.toml'), '[package]\nname = "local-patch-fixture"\nversion = "1.0.0"\nedition = "2024"\n');
+ writeFileSync(join(source, 'vendor/local-patch-fixture/src/lib.rs'), '//! Fixture dependency.\npub fn value() -> u8 { 7 }\n');
+ writeFileSync(join(source, 'vendor/unused-fixture/Cargo.toml'), '[package]\nname = "unused-fixture"\nversion = "1.0.0"\nedition = "2024"\n');
+ writeFileSync(join(source, 'vendor/unused-fixture/src/lib.rs'), '//! Unused patch fixture.\n');
+ const git = (...args) => execFileSync('git', ['-C', source, ...args], { encoding: 'utf8' }).trim();
+ git('init', '--quiet');
+ git('add', '.');
+ git('-c', 'user.name=Fixture', '-c', '[email protected]', 'commit', '--quiet', '-m', 'fixture');
+ writeFileSync(join(source, '.env'), 'PRIVATE_FIXTURE_TOKEN=must-not-copy');
+ return { directory, source, rev: git('rev-parse', 'HEAD') };
+}
+
+test('a pinned consumer generates patches, excludes local secrets and builds both feature modes offline', () => {
+ const { directory, source, rev } = fixture();
+ try {
+ const destination = join(directory, 'consumer');
+ execFileSync('python3', [script, '--offline', '--source', source, '--rev', rev, '--destination', destination]);
+ const manifest = readFileSync(join(destination, 'Cargo.toml'), 'utf8');
+ assert.match(manifest, /default = \[\]/);
+ assert.match(manifest, /optional = true, default-features = false/);
+ assert.match(manifest, /vendor\/openhuman\/vendor\/local-patch-fixture/);
+ assert.doesNotMatch(manifest, /unused-fixture/);
+ assert.equal(readFileSync(join(destination, 'OPENHUMAN_REV'), 'utf8').trim(), rev);
+ assert.equal(existsSync(join(destination, 'vendor/openhuman/.env')), false);
+ assert.equal(existsSync(join(destination, 'vendor/openhuman/.git')), false);
+ assert.equal(existsSync(join(source, '.git')), true);
+ for (const features of [[], ['--features', 'embed']]) {
+ const output = execFileSync(join(root, 'scripts/ci-cancel-aware.sh'), ['cargo', 'check', '--offline', '--locked', '--manifest-path', join(destination, 'Cargo.toml'), ...features], { cwd: root, encoding: 'utf8', stdio: 'pipe' });
+ assert.equal(typeof output, 'string');
+ }
+ assert.doesNotMatch(readFileSync(join(destination, 'Cargo.lock'), 'utf8'), /patch\.unused/);
+ const tree = execFileSync('cargo', ['tree', '--offline', '--manifest-path', join(destination, 'Cargo.toml'), '-e', 'normal'], { encoding: 'utf8' });
+ assert.doesNotMatch(tree, /openhuman-embed|reqwest/);
+ const again = spawnSync('python3', [script, '--offline', '--source', source, '--rev', rev, '--destination', destination], { encoding: 'utf8' });
+ assert.equal(again.status, 1);
+ assert.equal(readFileSync(join(destination, 'OPENHUMAN_REV'), 'utf8').trim(), rev);
+ } finally { rmSync(directory, { recursive: true, force: true }); }
+});
+
+test('symbolic and missing pins fail without leaving a partial consumer', () => {
+ const { directory, source } = fixture();
+ try {
+ for (const rev of ['main', '0'.repeat(40)]) {
+ const destination = join(directory, 'consumer');
+ const result = spawnSync('python3', [script, '--offline', '--source', source, '--rev', rev, '--destination', destination], { encoding: 'utf8' });
+ assert.equal(result.status, 1);
+ assert.equal(existsSync(destination), false);
+ assert.doesNotMatch(result.stderr, /PRIVATE_FIXTURE_TOKEN/);
+ }
+ } finally { rmSync(directory, { recursive: true, force: true }); }
+});
+
+test('credential-bearing source URLs are refused before Git sees them', () => {
+ const { directory, source, rev } = fixture();
+ try {
+ const destination = join(directory, 'consumer');
+ const result = spawnSync('python3', [script, '--offline', '--source', `file://${source}?token=PRIVATE_FIXTURE_TOKEN`, '--rev', rev, '--destination', destination], { encoding: 'utf8' });
+ assert.equal(result.status, 1);
+ assert.match(result.stderr, /credential-bearing/);
+ assert.doesNotMatch(result.stderr, /PRIVATE_FIXTURE_TOKEN/);
+ assert.equal(existsSync(destination), false);
+ } finally { rmSync(directory, { recursive: true, force: true }); }
+});
+
+test('unsupported and escaping patch specifications fail closed', () => {
+ for (const patch of ['{ git = "https://example.invalid/library" }', '{ path = "../../outside" }', '{ path = 3 }']) {
+ const { directory, source } = fixture();
+ try {
+ writeFileSync(join(source, 'Cargo.toml'), `[workspace]\nmembers = ["crates/openhuman-embed", "vendor/local-patch-fixture"]\n[patch.crates-io]\nlocal-patch-fixture = ${patch}\n`);
+ execFileSync('git', ['-C', source, 'add', 'Cargo.toml']);
+ execFileSync('git', ['-C', source, '-c', 'user.name=Fixture', '-c', '[email protected]', 'commit', '--quiet', '-m', 'invalid patch']);
+ const rev = execFileSync('git', ['-C', source, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
+ const destination = join(directory, 'consumer');
+ const result = spawnSync('python3', [script, '--offline', '--source', source, '--rev', rev, '--destination', destination], { encoding: 'utf8' });
+ assert.equal(result.status, 1);
+ assert.match(result.stderr, /Unsupported workspace patch form|leaves the source checkout/);
+ assert.equal(existsSync(destination), false);
+ } finally { rmSync(directory, { recursive: true, force: true }); }
+ }
+});
diff --git a/scripts/bootstrap-embed-consumer.py b/scripts/bootstrap-embed-consumer.py
new file mode 100644
index 0000000000..a0dff54c8b
--- /dev/null
+++ b/scripts/bootstrap-embed-consumer.py
@@ -0,0 +1,158 @@
+#!/usr/bin/env python3
+"""Create a pinned standalone consumer without hand-maintaining Cargo patches."""
+from __future__ import annotations
+
+import argparse
+import json
+from pathlib import Path
+import re
+import shutil
+import subprocess
+import tomllib
+from urllib.parse import urlsplit
+
+REPOSITORY = "https://github.com/tinyhumansai/openhuman.git"
+
+
+def git(*args: str) -> str:
+ """Run Git without echoing a source URL, credential or helper's output."""
+ result = subprocess.run(["git", *args], capture_output=True, text=True)
+ if result.returncode:
+ raise RuntimeError("Git could not prepare the pinned source checkout")
+ return result.stdout.strip()
+
+
+def consumer_manifest(checkout: Path, unused: frozenset[str] = frozenset()) -> str:
+ """Read patches from this pin, checking they stay in the source bundle."""
+ workspace = tomllib.loads((checkout / "Cargo.toml").read_text())
+ lines = [
+ "# Generated from the pinned OpenHuman workspace; do not mirror patches by hand.",
+ "[workspace]",
+ 'exclude = ["vendor"]',
+ "[package]",
+ 'name = "embed-consumer"',
+ 'version = "0.0.0"',
+ 'edition = "2024"',
+ 'rust-version = "1.96.1"',
+ "publish = false",
+ "[features]",
+ "default = []",
+ 'embed = ["dep:openhuman-embed"]',
+ "[dependencies]",
+ 'openhuman-embed = { path = "vendor/openhuman/crates/openhuman-embed", optional = true, default-features = false }',
+ ]
+ for registry, packages in workspace.get("patch", {}).items():
+ lines.append(f"[patch.{json.dumps(registry)}]")
+ for name, spec in packages.items():
+ if name in unused:
+ continue
+ # A new patch form is a packaging-contract change. Refuse it
+ # rather than quietly generating a different resolution graph.
+ if (not isinstance(spec, dict) or set(spec) != {"path"}
+ or not isinstance(spec["path"], str)):
+ raise ValueError(f"Unsupported workspace patch form: {name}")
+ package = (checkout / spec["path"]).resolve()
+ if not package.is_relative_to(checkout.resolve()):
+ raise ValueError(f"Workspace patch leaves the source checkout: {name}")
+ if not (package / "Cargo.toml").is_file():
+ raise ValueError(f"Workspace patch is not initialized: {name}")
+ relative = package.relative_to(checkout.resolve()).as_posix()
+ lines.append(f"{json.dumps(name)} = {{ path = {json.dumps('vendor/openhuman/' + relative)} }}")
+ lines += ["[profile.dev.package.\"*\"]", "debug = false"]
+ return "\n".join(lines) + "\n"
+
+
+def bootstrap(source: str, rev: str, destination: Path, offline: bool = False) -> None:
+ """Clone only committed source, verify its pin, then generate a consumer."""
+ if not re.fullmatch(r"[0-9a-fA-F]{40}", rev):
+ raise ValueError("--rev must be a full 40-character Git commit SHA")
+ parsed = urlsplit(source)
+ if parsed.query or parsed.fragment or parsed.password or (
+ parsed.scheme in {"http", "https"} and parsed.username
+ ):
+ raise ValueError("A credential-bearing source URL is not supported; use a Git credential helper")
+ destination = destination.resolve()
+ # mkdir is exclusive: an existing host checkout is never overwritten.
+ destination.mkdir(parents=True, exist_ok=False)
+ try:
+ checkout = destination / "vendor" / "openhuman"
+ checkout.parent.mkdir()
+ git("clone", "--quiet", "--no-checkout", "--", source, str(checkout))
+ git("-C", str(checkout), "checkout", "--quiet", "--detach", rev)
+ if git("-C", str(checkout), "rev-parse", "HEAD").lower() != rev.lower():
+ raise RuntimeError("The source checkout does not match the requested pin")
+ git("-C", str(checkout), "submodule", "update", "--init", "--recursive")
+ modules = git("-C", str(checkout), "submodule", "status", "--recursive")
+ if any(line.startswith(("-", "+", "U")) for line in modules.splitlines()):
+ raise RuntimeError("A submodule does not match its recorded pin")
+ (destination / "Cargo.toml").write_text(consumer_manifest(checkout))
+ (destination / "src").mkdir()
+ (destination / "src" / "lib.rs").write_text(
+ '//! Host entry point. Enable `embed` only for workloads using OpenHuman.\n'
+ '#[cfg(feature = "embed")]\npub use openhuman_embed as embed;\n'
+ )
+ (destination / "rust-toolchain.toml").write_text(
+ '[toolchain]\nchannel = "1.96.1"\nprofile = "minimal"\n'
+ )
+ lock = checkout / "Cargo.lock"
+ if lock.is_file():
+ shutil.copyfile(lock, destination / "Cargo.lock")
+ resolve_lock(destination, offline)
+ resolved = tomllib.loads((destination / "Cargo.lock").read_text())
+ unused = frozenset(entry["name"] for entry in resolved.get("patch", {}).get("unused", []))
+ if unused:
+ # Cargo orders unused patches nondeterministically, which can
+ # make --locked refuse an unchanged graph. Remove only entries
+ # the resolver proved unused; keep every active pinned patch.
+ (destination / "Cargo.toml").write_text(consumer_manifest(checkout, unused))
+ resolve_lock(destination, offline)
+ strip_git_metadata(checkout)
+ (destination / "OPENHUMAN_REV").write_text(rev.lower() + "\n")
+ (destination / ".gitignore").write_text("/target/\n")
+ except Exception:
+ # Only this invocation's newly created destination is removed.
+ shutil.rmtree(destination)
+ raise
+
+
+def strip_git_metadata(checkout: Path) -> None:
+ """Turn the verified clone into source files a host can commit normally."""
+ root_metadata = checkout / ".git"
+ if root_metadata.is_dir():
+ shutil.rmtree(root_metadata)
+ elif root_metadata.exists():
+ root_metadata.unlink()
+ for metadata in list(checkout.rglob(".git")):
+ if metadata.is_dir():
+ shutil.rmtree(metadata)
+ else:
+ metadata.unlink()
+
+
+def resolve_lock(destination: Path, offline: bool) -> None:
+ """Resolve the host lockfile, keeping provider/helper output private."""
+ command = ["cargo", "generate-lockfile", "--manifest-path", str(destination / "Cargo.toml")]
+ if offline:
+ command.append("--offline")
+ result = subprocess.run(command, cwd=destination, capture_output=True, text=True)
+ if result.returncode:
+ raise RuntimeError("Cargo could not resolve the consumer lockfile; check registry/cache access")
+
+
+def main() -> None:
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--source", default=REPOSITORY, help="Git repository URL or local checkout")
+ parser.add_argument("--rev", required=True, help="Full OpenHuman commit SHA")
+ parser.add_argument("--destination", type=Path, required=True, help="New consumer directory")
+ parser.add_argument("--offline", action="store_true", help="Resolve Cargo using cached registry sources only")
+ args = parser.parse_args()
+ try:
+ bootstrap(args.source, args.rev, args.destination, args.offline)
+ except (OSError, ValueError, RuntimeError) as error:
+ parser.exit(1, f"Bootstrap failed: {error}\n")
+ print(f"Consumer ready at {args.destination}; OpenHuman pin {args.rev.lower()}")
+ print("Default build leaves Embed disabled; enable it with cargo check --features embed")
+
+
+if __name__ == "__main__":
+ main()