Skip to content

Commit 90dc753

Browse files
committed
fix(gateway): forward wizard service install preference
1 parent 23de5c2 commit 90dc753

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

‎packages/gateway-protocol/src/schema/wizard.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const WizardRunStatusSchema = Type.Union([
1616
export const WizardStartParamsSchema = closedObject({
1717
mode: Type.Optional(Type.Union([Type.Literal("local"), Type.Literal("remote")])),
1818
workspace: Type.Optional(Type.String()),
19+
installDaemon: Type.Optional(Type.Boolean()),
1920
// "setup" (default) runs full onboarding; "channels" runs the guided
2021
// channel-setup flow (openclaw channels add) over the same step protocol.
2122
flow: Type.Optional(Type.Union([Type.Literal("setup"), Type.Literal("channels")])),
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { describe, expect, it, vi } from "vitest";
2+
import type { OnboardOptions } from "../../commands/onboard-types.js";
3+
import type { WizardSession } from "../../wizard/session.js";
4+
import { type SetupWizardRunner, wizardHandlers } from "./wizard.js";
5+
6+
type ProjectedOptions = Pick<
7+
OnboardOptions,
8+
"installDaemon" | "skipUi" | "suppressGatewayTokenOutput"
9+
>;
10+
11+
describe("wizard.start", () => {
12+
it.each([
13+
{ label: "false", params: { installDaemon: false }, expected: false },
14+
{ label: "true", params: { installDaemon: true }, expected: true },
15+
{ label: "omitted", params: {}, expected: undefined },
16+
])("projects installDaemon when $label", async ({ params, expected }) => {
17+
let receivedOptions: ProjectedOptions | undefined;
18+
const wizardSessions = new Map<string, WizardSession>();
19+
const respond = vi.fn();
20+
const wizardRunner: SetupWizardRunner = async (opts, _runtime, prompter) => {
21+
receivedOptions = {
22+
installDaemon: opts.installDaemon,
23+
skipUi: opts.skipUi,
24+
suppressGatewayTokenOutput: opts.suppressGatewayTokenOutput,
25+
};
26+
await prompter.note("ready");
27+
};
28+
const context = {
29+
findRunningWizard: () => null,
30+
wizardSessions,
31+
purgeWizardSession: vi.fn(),
32+
wizardRunner,
33+
};
34+
35+
const startWizard = wizardHandlers["wizard.start"];
36+
if (!startWizard) {
37+
throw new Error("wizard.start handler is not registered");
38+
}
39+
40+
await startWizard({
41+
params: { mode: "local", ...params },
42+
respond,
43+
context,
44+
} as never);
45+
46+
expect(receivedOptions).toEqual({
47+
installDaemon: expected,
48+
skipUi: true,
49+
suppressGatewayTokenOutput: true,
50+
});
51+
expect(respond).toHaveBeenCalledWith(
52+
true,
53+
expect.objectContaining({ done: false, status: "running" }),
54+
undefined,
55+
);
56+
57+
for (const session of wizardSessions.values()) {
58+
session.cancel();
59+
}
60+
});
61+
});

‎src/gateway/server-methods/wizard.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ export const wizardHandlers: GatewayRequestHandlers = {
9898
{
9999
mode: params.mode,
100100
workspace: readStringValue(params.workspace),
101+
installDaemon: params.installDaemon,
102+
skipUi: true,
103+
suppressGatewayTokenOutput: true,
101104
},
102105
defaultRuntime,
103106
prompter,

0 commit comments

Comments
 (0)