Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/lib/onboard/external-component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,26 @@ The component supplies policy. OpenShell validates effective policy and enforces

This v2 implementation requires authenticated interceptor and middleware APIs,
and interceptor-backed provider profiles.
The current shared runtime pin does not contain all required behavior.
Qualify the accepted behavior against a released runtime before claiming integration support.
The shared runtime pin is OpenShell 0.0.116.
Qualify the accepted behavior against that release before claiming integration support.
Keep runtime qualification and shared version pins in their existing owner.
Dynamic registration is the accepted v2 contract. Do not add an insecure transport fallback.

## Agent selection

Providerless onboarding accepts OpenClaw and Hermes through the existing agent definitions and startup adapters.
Reject other agents before preflight effects, component preparation, or gateway startup.
The requested agent and resolved agent must agree before sandbox creation.
Provider, model, endpoint, credential, and messaging inputs remain incompatible with this path.
Do not discover stored messaging credentials during providerless creation.

Both agents use the same preparation, externally supplied policy, identity proof, and bounded activation lifecycle.
Each agent retains its managed image, configuration generator, and startup integration.
Providerless onboarding does not create an ordinary inference provider; the agent still requires a managed inference route.
This path does not add a requirement to configure that route before sandbox creation.
Verify agent startup and inference after activation with real OpenShell before claiming live qualification.
Failed or ambiguous activation retains incomplete state and does not retry.

## Declaration

The operator installs the existing `external-component.json` file with mode `0600`.
Expand Down Expand Up @@ -101,5 +116,6 @@ NemoClaw does not install or supervise those services.

`connections.test.ts` covers declaration restrictions, trust files, generated configuration, drift, and preparation.
Existing activation and gateway-handler tests cover bounded transport, incomplete activation, and unchanged v1 behavior.
The creation and finalization tests share an OpenClaw/Hermes matrix for image identity, startup configuration, policy proof, and activation failures.
Real OpenShell registration, policy and profile delivery, sandbox identity, and middleware outcomes require live evidence.
Record NemoClaw, OpenShell, and combined #11486 revisions separately. Mocked results do not qualify the integration.
13 changes: 9 additions & 4 deletions src/lib/onboard/machine/core-flow-phases.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ describe("core onboard flow phases", () => {

it.each([
["provider-backed input", { model: "gpt-5.4", provider: "nvidia-prod" }],
["a nondefault agent", { agent: { name: "hermes" }, model: null, provider: null }],
["an unsupported agent", { agent: { name: "pi" }, model: null, provider: null }],
])("rejects %s before provider inference or sandbox effects", async (_label, patch) => {
const setupInference = vi.fn(async () => ({ ok: true as const }));
const reserveSandboxInferenceRoute = vi.fn(() => true);
Expand Down Expand Up @@ -833,9 +833,13 @@ describe("core onboard flow phases", () => {
expect(reserveSandboxInferenceRoute).not.toHaveBeenCalled();
});

it.each([false, true])(
"routes verified providerless creation with component %s (#11486)",
async (registered) => {
it.each([
{ agentName: "openclaw", registered: false },
{ agentName: "openclaw", registered: true },
{ agentName: "hermes", registered: true },
])(
"routes $agentName providerless creation with component $registered (#11548)",
async ({ agentName, registered }) => {
const setupNim = vi.fn();
const setupInference = vi.fn(async () => ({ ok: true as const }));
let providerlessReservation: {
Expand Down Expand Up @@ -895,6 +899,7 @@ describe("core onboard flow phases", () => {
},
});
const initial = context({
agent: { name: agentName },
fresh: true,
session,
model: null,
Expand Down
7 changes: 2 additions & 5 deletions src/lib/onboard/machine/core-flow-phases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { WebSearchConfig } from "../../inference/web-search";
import { isN1xManagedVllmProviderModel } from "../../domain/sandbox/n1x-managed-vllm-rebuild";
import type { DcodeAutoApprovalMode } from "../dcode-auto-approval";
import { assertProviderlessInterceptorEnvironment } from "../entry-options";
import { assertProviderlessSandboxAgent } from "../sandbox-agent";
import type {
createProviderRecoveryReceiptLedger,
ProviderRecoveryReceipt,
Expand Down Expand Up @@ -125,10 +126,6 @@ export function isCoreFlowCompleteBeforeFinalization(result: {
}

function hasProviderBackedApfIntent(context: OnboardFlowContext): boolean {
const requestedAgentName = (context.agent as { readonly name?: unknown } | null)?.name;
const requestsNondefaultAgent =
typeof requestedAgentName === "string" &&
requestedAgentName.trim().toLowerCase() !== "openclaw";
const routeValues = [
context.provider,
context.model,
Expand All @@ -141,7 +138,6 @@ function hasProviderBackedApfIntent(context: OnboardFlowContext): boolean {
context.nimContainer,
];
return (
requestsNondefaultAgent ||
routeValues.some((value) => typeof value === "string" && value.trim().length > 0) ||
context.endpointSource != null ||
context.selectedMessagingChannels.length > 0 ||
Expand Down Expand Up @@ -197,6 +193,7 @@ export function createProviderInferenceOnboardFlowPhase<
context.session?.apfInterceptorRequested === true
) {
assertProviderlessInterceptorEnvironment(true, options.env);
assertProviderlessSandboxAgent(context.agent);
if (hasProviderBackedApfIntent(context)) {
throw new Error(
"Interceptor onboarding supports providerless sandbox creation only. No sandbox or provider was created.",
Expand Down
150 changes: 80 additions & 70 deletions src/lib/onboard/machine/final-flow-phases.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,85 +12,95 @@ import { runFinalOnboardFlowSlice } from "./final-flow-phases";
import { advanceTo } from "./result";

describe("final onboard flow phases", () => {
it("completes providerless onboarding only after verified component activation (#11486)", async () => {
const flow = createProviderlessComponentFlow();
const result = await flow.run();
expect(result.session.machine.state).toBe("complete");
expect(flow.transport).toHaveBeenCalledOnce();
expect(flow.revalidate).toHaveBeenCalledTimes(2);
expect(flow.evidence).toHaveBeenLastCalledWith(null);
expect(flow.order).toEqual(["verify-proof", "activate"]);
await expect(createPhases("openclaw")[3].run(flow.initial)).rejects.toThrow(
"Providerless component activation has not completed in this onboarding run.",
);
});

it("preserves failed providerless activation evidence after rejection (#11486)", async () => {
const flow = createProviderlessComponentFlow();
flow.response.result = "rejected";
const result = await flow.run();
expect(result.session.machine.state).toBe("finalizing");
expect(result.session.externalComponentActivation).toMatchObject({
sandboxIdentityFingerprint: flow.proof.sandboxIdentityFingerprint,
lifecycleGeneration: flow.proof.lifecycleGeneration,
resultClass: "failed",
describe.each(["openclaw", "hermes"])("%s providerless component lifecycle", (agentName) => {
it("completes providerless onboarding only after verified component activation (#11486)", async () => {
const flow = createProviderlessComponentFlow(agentName);
const result = await flow.run();
expect(result.session.machine.state).toBe("complete");
expect(flow.transport).toHaveBeenCalledOnce();
expect(flow.revalidate).toHaveBeenCalledTimes(2);
expect(flow.evidence).toHaveBeenLastCalledWith(null);
expect(flow.order).toEqual(["verify-proof", "activate"]);
const branchState = agentName === "openclaw" ? "openclaw" : "agent_setup";
await expect(createPhases(branchState)[3].run(flow.initial)).rejects.toThrow(
"Providerless component activation has not completed in this onboarding run.",
);
});
expect(flow.transport).toHaveBeenCalledOnce();
expect(flow.order).toEqual(["verify-proof", "activate"]);
});

it.each([
{
outcome: "malformed response",
arrange: (flow: ReturnType<typeof createProviderlessComponentFlow>) =>
flow.transport.mockResolvedValue("{}"),
requests: 1,
order: ["verify-proof", "activate"],
},
{
outcome: "changed endpoint",
arrange: (flow: ReturnType<typeof createProviderlessComponentFlow>) =>
flow.revalidateEndpoint.mockImplementation(() => {
throw new Error("changed endpoint");
}),
requests: 0,
order: ["verify-proof"],
},
{
outcome: "changed identity or policy proof",
arrange: (flow: ReturnType<typeof createProviderlessComponentFlow>) =>
flow.revalidate
.mockImplementationOnce(() => undefined)
.mockImplementationOnce(() => {
throw new Error("drift");
}),
requests: 1,
order: ["verify-proof", "activate"],
},
])(
"preserves ambiguous providerless activation evidence for $outcome (#11486)",
async ({ arrange, requests, order }) => {
const flow = createProviderlessComponentFlow();
arrange(flow);
it("preserves failed providerless activation evidence after rejection (#11486)", async () => {
const flow = createProviderlessComponentFlow(agentName);
flow.response.result = "rejected";
const result = await flow.run();
expect(result.session.machine.state).toBe("finalizing");
expect(result.session.externalComponentActivation).toMatchObject({
sandboxIdentityFingerprint: flow.proof.sandboxIdentityFingerprint,
lifecycleGeneration: flow.proof.lifecycleGeneration,
resultClass: "ambiguous",
resultClass: "failed",
});
expect(flow.transport).toHaveBeenCalledOnce();
expect(flow.order).toEqual(["verify-proof", "activate"]);
});

it.each([
{
outcome: "timed-out response",
arrange: (flow: ReturnType<typeof createProviderlessComponentFlow>) =>
flow.transport.mockRejectedValue(new Error("timeout")),
requests: 1,
order: ["verify-proof", "activate"],
},
{
outcome: "malformed response",
arrange: (flow: ReturnType<typeof createProviderlessComponentFlow>) =>
flow.transport.mockResolvedValue("{}"),
requests: 1,
order: ["verify-proof", "activate"],
},
{
outcome: "changed endpoint",
arrange: (flow: ReturnType<typeof createProviderlessComponentFlow>) =>
flow.revalidateEndpoint.mockImplementation(() => {
throw new Error("changed endpoint");
}),
requests: 0,
order: ["verify-proof"],
},
{
outcome: "changed identity or policy proof",
arrange: (flow: ReturnType<typeof createProviderlessComponentFlow>) =>
flow.revalidate
.mockImplementationOnce(() => undefined)
.mockImplementationOnce(() => {
throw new Error("drift");
}),
requests: 1,
order: ["verify-proof", "activate"],
},
])(
"preserves ambiguous providerless activation evidence for $outcome (#11486)",
async ({ arrange, requests, order }) => {
const flow = createProviderlessComponentFlow(agentName);
arrange(flow);
const result = await flow.run();
expect(result.session.machine.state).toBe("finalizing");
expect(result.session.externalComponentActivation).toMatchObject({
sandboxIdentityFingerprint: flow.proof.sandboxIdentityFingerprint,
lifecycleGeneration: flow.proof.lifecycleGeneration,
resultClass: "ambiguous",
});
expect(flow.transport).toHaveBeenCalledTimes(requests);
expect(flow.order).toEqual(order);
},
);

it("refuses providerless activation when policy proof is unavailable (#11486)", async () => {
const flow = createProviderlessComponentFlow(agentName);
flow.createProof.mockImplementation(() => {
throw new Error("policy unavailable");
});
expect(flow.transport).toHaveBeenCalledTimes(requests);
expect(flow.order).toEqual(order);
},
);

it("refuses providerless activation when policy proof is unavailable (#11486)", async () => {
const flow = createProviderlessComponentFlow();
flow.createProof.mockImplementation(() => {
throw new Error("policy unavailable");
await expect(flow.run()).rejects.toThrow("policy unavailable");
expect(flow.transport).not.toHaveBeenCalled();
});
await expect(flow.run()).rejects.toThrow("policy unavailable");
expect(flow.transport).not.toHaveBeenCalled();
});

it("selects the requested branch setup state", () => {
Expand Down
13 changes: 12 additions & 1 deletion src/lib/onboard/machine/initial-flow-phases.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type SandboxGpuConfig = {
sandboxGpuDevice?: string | null;
errors?: string[];
};
type Context = InitialOnboardFlowContext<null, Gpu, SandboxGpuConfig>;
type Context = InitialOnboardFlowContext<{ name: string } | null, Gpu, SandboxGpuConfig>;

function context(overrides: Partial<Context> = {}): Context {
return {
Expand Down Expand Up @@ -280,6 +280,17 @@ describe("initial onboard flow phases", () => {
revalidateBeforeActivation: vi.fn(),
};
prepareExternalComponent.mockReturnValue(component);
await expect(
phases[0].run(
context({
agent: { name: "pi" },
session: createSession({ apfInterceptorRequested: true }),
}),
),
).rejects.toThrow("no qualified integration");
expect(runPreflight).not.toHaveBeenCalled();
expect(configureExternalComponentGateway).not.toHaveBeenCalled();

assertExternalComponentFreshSandbox.mockImplementation(() => {
throw new Error("sandbox is not fresh");
});
Expand Down
4 changes: 4 additions & 0 deletions src/lib/onboard/machine/initial-flow-phases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { spawnSync } from "node:child_process";
import type { GatewayReuseState } from "../../state/gateway";
import { type GatewayOwner, isExternallySupervised } from "../gateway-ownership";
import { formatSandboxGpuPassthroughNote } from "../sandbox-gpu-notes";
import { assertProviderlessSandboxAgent } from "../sandbox-agent";
import {
ExternalComponentContractError,
type PreparedExternalComponent,
Expand Down Expand Up @@ -143,6 +144,9 @@ export function createInitialOnboardFlowPhases<
state: "preflight",
async run(context) {
const externalComponent = options.prepareExternalComponent?.(context.session) ?? null;
if (context.session?.apfInterceptorRequested === true) {
assertProviderlessSandboxAgent(context.agent);
}
if (externalComponent && (context.resume || options.recreateSandbox())) {
throw new ExternalComponentContractError("lifecycle_unsupported");
}
Expand Down
32 changes: 31 additions & 1 deletion src/lib/onboard/sandbox-agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { describe, expect, it, vi } from "vitest";
import { createPromptValidatedSandboxName } from "./sandbox-agent";
import { assertProviderlessSandboxAgent, createPromptValidatedSandboxName } from "./sandbox-agent";

describe("sandbox name prompt", () => {
it("waits for a validated-name checkpoint before returning it to onboarding (#8687)", async () => {
Expand Down Expand Up @@ -74,3 +74,33 @@ describe("sandbox name prompt", () => {
);
});
});

describe("providerless agent validation", () => {
it.each(["openclaw", "hermes"])("accepts matching %s intent (#11548)", (name) => {
expect(() => assertProviderlessSandboxAgent({ name }, name)).not.toThrow();
expect(() => assertProviderlessSandboxAgent({ name })).not.toThrow();
});

it("retains the default OpenClaw identity (#11548)", () => {
expect(() => assertProviderlessSandboxAgent(null, "openclaw")).not.toThrow();
});

it.each(["pi", "langchain-deepagents-code", "unknown", ""])(
"rejects unqualified agent '%s' (#11548)",
(name) => {
expect(() => assertProviderlessSandboxAgent({ name })).toThrow("no qualified integration");
},
);

it.each([{}, { name: null }, { name: 1 }])("rejects malformed agent %j (#11548)", (agent) => {
expect(() => assertProviderlessSandboxAgent(agent)).toThrow("no qualified integration");
});

it.each([
["openclaw", "hermes"],
["hermes", "openclaw"],
["hermes", "pi"],
])("rejects requested %s and resolved %s disagreement (#11548)", (name, resolved) => {
expect(() => assertProviderlessSandboxAgent({ name }, resolved)).toThrow("agents agree");
});
});
25 changes: 25 additions & 0 deletions src/lib/onboard/sandbox-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,31 @@ export function getRequestedSandboxAgentName(agent: AgentDefinition | null | und
return normalizeSandboxAgentName(agent?.name);
}

/** Limit providerless onboarding to qualified agent integrations without changing agent selection. */
export function assertProviderlessSandboxAgent(
agent: unknown,
resolvedAgentName?: string | null,
): void {
const name = (agent as { name?: unknown } | null)?.name;
const requested =
name === undefined && agent == null
? "openclaw"
: typeof name === "string"
? name.trim().toLowerCase()
: "";
const resolved = resolvedAgentName?.trim().toLowerCase() || null;
if (requested !== "openclaw" && requested !== "hermes") {
throw new Error(
"Interceptor onboarding supports providerless sandbox creation only for OpenClaw and Hermes. The selected agent has no qualified integration. No sandbox or provider was created.",
);
}
if (resolved !== null && resolved !== requested) {
throw new Error(
"Interceptor onboarding supports providerless sandbox creation only when requested and resolved agents agree. No sandbox or provider was created.",
);
}
}

export function formatSandboxAgentName(agentName: string | null | undefined): string {
const normalized = normalizeSandboxAgentName(agentName);
if (normalized === "openclaw") return "OpenClaw";
Expand Down
Loading
Loading