Skip to content

Commit 171a385

Browse files
authored
fix: install exact app recommendations and retry failures (#111518)
* fix(onboard): preserve recommendation install retries * fix(onboard): preserve bootstrap recommendation retries * fix(onboard): commit recommendation outcomes after config * fix(onboard): guard recommendation state transitions * fix(onboard): reconcile durable skill installs * docs(clawhub): clarify search publisher contract
1 parent 13ed8b5 commit 171a385

17 files changed

Lines changed: 1075 additions & 108 deletions

‎docs/cli/onboard.md‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ openclaw onboard --import-from hermes --import-source ~/.hermes
4646
openclaw onboard --skip-bootstrap
4747
openclaw onboard recommendations --json
4848
openclaw onboard recommendations acknowledge
49+
openclaw onboard recommendations acknowledge --retry "<failed-id>"
4950
openclaw onboard recommendations refresh
5051
openclaw onboard --mode remote --remote-url wss://gateway-host:18789
5152
```
@@ -63,7 +64,16 @@ onboarding run rescans installed apps and creates a new offer.
6364
Fresh workspaces defer the recommendation choice to the bootstrap conversation.
6465
After that conversation handles the user's choices,
6566
`openclaw onboard recommendations acknowledge` marks the stored offer answered.
66-
The acknowledgement is idempotent.
67+
The acknowledgement is idempotent. If a chosen install fails, pass each failed
68+
opaque ID with `--retry <id...>`; successful and declined matches are consumed,
69+
while failed matches remain pending for a later onboarding run. Unknown IDs
70+
fail without changing the stored offer. After an interrupted ClawHub skill
71+
install, an existing target counts as successful only when
72+
`openclaw skills verify "@owner/slug"` succeeds for the same
73+
publisher-qualified recommendation ID and its JSON output reports
74+
`openclaw.resolution.source: "installed"`. Registry verification alone is not
75+
proof of a local install. Otherwise keep that ID pending with `--retry` and do
76+
not overwrite the existing skill.
6777

6878
- `--classic`: opens the full step-by-step wizard. It cannot be combined with
6979
`--non-interactive`; omit `--classic` for automated setup.

‎docs/reference/templates/BOOTSTRAP.md‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,35 @@ convenience?"**
6262
`openclaw skills install <id>`.
6363
- If there are no stored matches, skip this beat without commentary.
6464

65-
After the user answers and any chosen installs finish, record completion so the
66-
offer never appears again:
65+
After the user answers and every chosen install succeeds, record completion so
66+
the offer never appears again:
6767

6868
```bash
6969
openclaw onboard recommendations acknowledge
7070
```
7171

72+
If an install fails, consume the successful and declined recommendations but
73+
leave every failed ID pending for a later onboarding run:
74+
75+
```bash
76+
openclaw onboard recommendations acknowledge --retry "<failed-id>" ["<failed-id>"...]
77+
```
78+
79+
Use the exact opaque IDs returned by the read command. Never acknowledge a
80+
failed install without `--retry`. One interrupted skill install can report that
81+
its target already exists on the next attempt. In that case, verify the exact
82+
publisher-qualified ID before treating it as successful:
83+
84+
```bash
85+
openclaw skills verify "@owner/slug"
86+
```
87+
88+
Only count it as installed when verification succeeds for that same ID and its
89+
JSON output has `openclaw.resolution.source` set to `installed`. A registry
90+
verification is not proof of a local install. If verification fails, reports a
91+
different publisher, or reports another resolution source, keep the ID pending
92+
with `--retry`; do not overwrite the existing skill.
93+
7294
When the three beats are complete, delete this file. Then say one line:
7395

7496
> Ask me anything; for system things I'll ask OpenClaw.

‎src/cli/program/register.onboard.test.ts‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,27 @@ describe("registerOnboardCommand", () => {
9898
it("routes the recommendations acknowledgement subcommand", async () => {
9999
await runCli(["onboard", "recommendations", "acknowledge"]);
100100

101-
expect(mocks.acknowledgeOnboardRecommendationsCommand).toHaveBeenCalledWith(runtime);
101+
expect(mocks.acknowledgeOnboardRecommendationsCommand).toHaveBeenCalledWith(
102+
{ retry: undefined },
103+
runtime,
104+
);
105+
expect(setupWizardCommandMock).not.toHaveBeenCalled();
106+
});
107+
108+
it("routes failed recommendation ids through acknowledgement", async () => {
109+
await runCli([
110+
"onboard",
111+
"recommendations",
112+
"acknowledge",
113+
"--retry",
114+
"chat-plugin",
115+
"@demo-owner/notes",
116+
]);
117+
118+
expect(mocks.acknowledgeOnboardRecommendationsCommand).toHaveBeenCalledWith(
119+
{ retry: ["chat-plugin", "@demo-owner/notes"] },
120+
runtime,
121+
);
102122
expect(setupWizardCommandMock).not.toHaveBeenCalled();
103123
});
104124

‎src/cli/program/register.onboard.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,13 @@ export function registerOnboardCommand(program: Command): void {
257257
recommendations
258258
.command("acknowledge")
259259
.description("Mark the stored onboarding recommendation offer as answered")
260-
.action(async () => {
260+
.option("--retry <id...>", "Leave failed recommendation IDs pending for a later run")
261+
.action(async (opts: { retry?: string[] }) => {
261262
const { defaultRuntime } = await import("../../runtime.js");
262263
await runCommandWithRuntime(defaultRuntime, async () => {
263264
const { acknowledgeOnboardRecommendationsCommand } =
264265
await import("../../commands/onboard-recommendations.js");
265-
acknowledgeOnboardRecommendationsCommand(defaultRuntime);
266+
acknowledgeOnboardRecommendationsCommand({ retry: opts.retry }, defaultRuntime);
266267
});
267268
});
268269

‎src/commands/onboard-guided.custodian.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ function setupDeps(params: {
135135
})),
136136
persistRiskAcknowledgement: params.persistRiskAcknowledgement ?? vi.fn(async () => undefined),
137137
runSetupMemoryImportStep: params.runSetupMemoryImportStep ?? vi.fn(async () => undefined),
138-
runAppRecommendations: params.runAppRecommendations ?? vi.fn(async ({ config }) => config),
138+
runAppRecommendations:
139+
params.runAppRecommendations ??
140+
vi.fn(async ({ config }) => ({ config, commitResult: vi.fn() })),
139141
runSystemAgentChat,
140142
...(params.handoffMode ? { handoffMode: params.handoffMode } : {}),
141143
} satisfies GuidedOnboardingDeps;

‎src/commands/onboard-guided.test.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ function setupApplyResult() {
110110
};
111111
}
112112

113+
function recommendationOutcome(config: OpenClawConfig) {
114+
return { config, commitResult: vi.fn() };
115+
}
116+
113117
function setupDeps(params: {
114118
prompter: WizardPrompter;
115119
detect?: GuidedOnboardingDeps["detect"];
@@ -149,7 +153,8 @@ function setupDeps(params: {
149153
})),
150154
persistRiskAcknowledgement: params.persistRiskAcknowledgement ?? vi.fn(async () => undefined),
151155
runSetupMemoryImportStep: params.runSetupMemoryImportStep ?? vi.fn(async () => undefined),
152-
runAppRecommendations: params.runAppRecommendations ?? vi.fn(async ({ config }) => config),
156+
runAppRecommendations:
157+
params.runAppRecommendations ?? vi.fn(async ({ config }) => recommendationOutcome(config)),
153158
runBrowserHandoff:
154159
params.runBrowserHandoff ??
155160
(vi.fn(async () => ({
@@ -232,7 +237,7 @@ describe("runGuidedOnboarding", () => {
232237
});
233238
const applySetup = vi.fn(async () => setupApplyResult());
234239
const runAppRecommendations = vi.fn<NonNullable<GuidedOnboardingDeps["runAppRecommendations"]>>(
235-
async ({ config }) => config,
240+
async ({ config }) => recommendationOutcome(config),
236241
);
237242
const deps = setupDeps({ prompter, applySetup, runAppRecommendations });
238243
const runtime = makeRuntime();
@@ -275,7 +280,7 @@ describe("runGuidedOnboarding", () => {
275280
const prompter = createWizardPrompter();
276281
const applySetup = vi.fn(async () => setupApplyResult());
277282
const runAppRecommendations = vi.fn<NonNullable<GuidedOnboardingDeps["runAppRecommendations"]>>(
278-
async ({ config }) => config,
283+
async ({ config }) => recommendationOutcome(config),
279284
);
280285
const probeBrowserHandoffGateway = vi.fn(async () => ({ ok: true }));
281286
const runBrowserHandoff = vi.fn(async () => ({ handedOff: true as const }));

‎src/commands/onboard-guided.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,14 @@ async function runGuidedOnboardingFlow(
449449
const runAppRecommendations =
450450
deps.runAppRecommendations ??
451451
(await import("../wizard/setup.app-recommendations.js")).setupAppRecommendations;
452-
const recommendedConfig = await runAppRecommendations({
452+
const recommendationOutcome = await runAppRecommendations({
453453
config: persistedConfig,
454454
prompter,
455455
runtime,
456456
workspaceDir: workspace,
457457
modelRouteVerified: true,
458458
});
459+
const recommendedConfig = recommendationOutcome.config;
459460
if (recommendedConfig !== persistedConfig) {
460461
const latestSnapshot = await readConfigFileSnapshot();
461462
if (!latestSnapshot.valid) {
@@ -476,6 +477,7 @@ async function runGuidedOnboardingFlow(
476477
});
477478
persistedConfig = mergedConfig;
478479
}
480+
recommendationOutcome.commitResult();
479481
}
480482
const hatchWorkspace = alreadyConfigured
481483
? resolveUserPath(

‎src/commands/onboard-recommendations.test.ts‎

Lines changed: 154 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,165 @@ describe("onboard recommendations command", () => {
9797
matches: [],
9898
}));
9999

100-
acknowledgeOnboardRecommendationsCommand(runtime, { acknowledge });
100+
acknowledgeOnboardRecommendationsCommand({}, runtime, { acknowledge });
101101

102102
expect(acknowledge).toHaveBeenCalledOnce();
103103
expect(runtime.log).toHaveBeenCalledWith("Onboarding recommendations acknowledged.");
104104
});
105105

106+
it("leaves failed bootstrap installs pending and consumes the other matches", () => {
107+
const runtime = makeRuntime();
108+
const updatePending = vi.fn(() => ({
109+
inventoryHash: "hash",
110+
offeredAt: 1,
111+
acceptedAt: null,
112+
updatedAt: 2,
113+
matches: [],
114+
}));
115+
const matches = [
116+
{
117+
appLabel: "Chat",
118+
candidateId: "chat-plugin",
119+
tier: "recommended" as const,
120+
reason: "Connects conversations",
121+
candidate: {
122+
id: "chat-plugin",
123+
displayName: "Chat plugin",
124+
summary: "Chat",
125+
source: "official-channel" as const,
126+
},
127+
},
128+
{
129+
appLabel: "Notes",
130+
candidateId: "@demo-owner/notes",
131+
tier: "optional" as const,
132+
reason: "Connects notes",
133+
candidate: {
134+
id: "@demo-owner/notes",
135+
displayName: "Notes skill",
136+
summary: "Notes",
137+
source: "clawhub-skill" as const,
138+
},
139+
},
140+
];
141+
142+
acknowledgeOnboardRecommendationsCommand({ retry: ["@demo-owner/notes"] }, runtime, {
143+
read: () => ({
144+
inventoryHash: "hash",
145+
offeredAt: 1,
146+
acceptedAt: null,
147+
updatedAt: 1,
148+
matches,
149+
}),
150+
updatePending,
151+
});
152+
153+
expect(updatePending).toHaveBeenCalledWith({
154+
matches: [matches[1]],
155+
expected: {
156+
inventoryHash: "hash",
157+
offeredAt: 1,
158+
acceptedAt: null,
159+
updatedAt: 1,
160+
matches,
161+
},
162+
});
163+
expect(runtime.log).toHaveBeenCalledWith(
164+
"Onboarding recommendations updated; 1 left pending for retry.",
165+
);
166+
});
167+
168+
it("rejects unknown bootstrap retry ids without consuming the offer", () => {
169+
const runtime = makeRuntime();
170+
const acknowledge = vi.fn();
171+
const updatePending = vi.fn();
172+
173+
acknowledgeOnboardRecommendationsCommand({ retry: ["missing-skill"] }, runtime, {
174+
read: () => ({
175+
inventoryHash: "hash",
176+
offeredAt: 1,
177+
acceptedAt: null,
178+
updatedAt: 1,
179+
matches: [],
180+
}),
181+
acknowledge,
182+
updatePending,
183+
});
184+
185+
expect(runtime.error).toHaveBeenCalledWith("Unknown pending recommendation id: missing-skill");
186+
expect(runtime.exit).toHaveBeenCalledWith(1);
187+
expect(acknowledge).not.toHaveBeenCalled();
188+
expect(updatePending).not.toHaveBeenCalled();
189+
});
190+
191+
it("fails closed when the pending offer changes before retry persistence", () => {
192+
const runtime = makeRuntime();
193+
const updatePending = vi.fn(() => null);
194+
const match = {
195+
appLabel: "Notes",
196+
candidateId: "@demo-owner/notes",
197+
tier: "optional" as const,
198+
reason: "Connects notes",
199+
candidate: {
200+
id: "@demo-owner/notes",
201+
displayName: "Notes skill",
202+
summary: "Notes",
203+
source: "clawhub-skill" as const,
204+
},
205+
};
206+
207+
acknowledgeOnboardRecommendationsCommand({ retry: [match.candidateId] }, runtime, {
208+
read: () => ({
209+
inventoryHash: "hash",
210+
offeredAt: 1,
211+
acceptedAt: null,
212+
updatedAt: 1,
213+
matches: [match],
214+
}),
215+
updatePending,
216+
});
217+
218+
expect(runtime.error).toHaveBeenCalledWith(
219+
"Stored recommendations changed; read them again before recording retries.",
220+
);
221+
expect(runtime.exit).toHaveBeenCalledWith(1);
222+
expect(runtime.log).not.toHaveBeenCalled();
223+
});
224+
225+
it("clears pending bootstrap offers with legacy bare ClawHub ids", () => {
226+
const runtime = makeRuntime();
227+
const clearPending = vi.fn(() => true);
228+
229+
onboardRecommendationsCommand({ json: true }, runtime, {
230+
read: () => ({
231+
inventoryHash: "hash",
232+
offeredAt: 1,
233+
acceptedAt: null,
234+
updatedAt: 1,
235+
matches: [
236+
{
237+
appLabel: "Notes",
238+
candidateId: "notes",
239+
tier: "optional",
240+
reason: "Connects notes",
241+
candidate: {
242+
id: "notes",
243+
displayName: "Notes skill",
244+
summary: "Notes",
245+
source: "clawhub-skill",
246+
},
247+
},
248+
],
249+
}),
250+
clearPending,
251+
});
252+
253+
expect(clearPending).toHaveBeenCalledWith({
254+
expected: expect.objectContaining({ inventoryHash: "hash", updatedAt: 1 }),
255+
});
256+
expect(runtime.log).toHaveBeenCalledWith("[]");
257+
});
258+
106259
it("clears a stored offer for the next onboarding scan", () => {
107260
const runtime = makeRuntime();
108261
const clear = vi.fn(() => true);

0 commit comments

Comments
 (0)