Skip to content

Commit 8f85f94

Browse files
feat: install GitHub-backed ClawHub skills (#90478)
* feat: install GitHub-backed ClawHub skills * fix: satisfy ClawHub install type checks * fix: harden github-backed skill installs * fix: keep heartbeat template non-actionable * feat: support forcing pending ClawHub installs
1 parent 5380d11 commit 8f85f94

14 files changed

Lines changed: 1035 additions & 185 deletions

File tree

‎scripts/e2e/lib/codex-on-demand/assertions.mjs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ function readAuthProfileStoreText(agentDir) {
9090
let db;
9191
try {
9292
db = new DatabaseSync(dbPath, { readOnly: true });
93-
const row = db.prepare("SELECT store_json FROM auth_profile_store WHERE store_key = ?").get(
94-
"primary",
95-
);
93+
const row = db
94+
.prepare("SELECT store_json FROM auth_profile_store WHERE store_key = ?")
95+
.get("primary");
9696
return typeof row?.store_json === "string" ? row.store_json : "";
9797
} finally {
9898
db?.close();

‎scripts/e2e/lib/plugin-lifecycle-matrix/measure.mjs‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,14 @@ function handleParentSignal(signal) {
224224
terminateChildGroup("SIGKILL");
225225
rethrowParentSignal(signal);
226226
}, timeoutKillGraceMs);
227-
parentSignalPollTimer = setInterval(() => {
228-
if (!childGroupExists()) {
229-
rethrowParentSignal(signal);
230-
}
231-
}, Math.min(50, timeoutKillGraceMs));
227+
parentSignalPollTimer = setInterval(
228+
() => {
229+
if (!childGroupExists()) {
230+
rethrowParentSignal(signal);
231+
}
232+
},
233+
Math.min(50, timeoutKillGraceMs),
234+
);
232235
}
233236

234237
for (const signal of ["SIGHUP", "SIGINT", "SIGTERM"]) {

‎scripts/e2e/lib/release-user-journey/clickclack-fixture.mjs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,12 @@ function readBody(req) {
125125
}
126126

127127
function requestBodyTooLargeError() {
128-
return Object.assign(new Error(`ClickClack fixture request body exceeded ${requestMaxBytes} bytes`), {
129-
code: "ETOOBIG",
130-
});
128+
return Object.assign(
129+
new Error(`ClickClack fixture request body exceeded ${requestMaxBytes} bytes`),
130+
{
131+
code: "ETOOBIG",
132+
},
133+
);
131134
}
132135

133136
function isRequestBodyTooLargeError(error) {

‎scripts/ensure-playwright-chromium.mjs‎

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@ import { chromium } from "playwright";
77
import { resolvePnpmRunner } from "./pnpm-runner.mjs";
88

99
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
10-
const playwrightInstallArgs = [
11-
"--dir",
12-
"ui",
13-
"exec",
14-
"playwright",
15-
"install",
16-
"chromium",
17-
];
10+
const playwrightInstallArgs = ["--dir", "ui", "exec", "playwright", "install", "chromium"];
1811
const playwrightInstallWithDepsArgs = [
1912
"--dir",
2013
"ui",
@@ -123,10 +116,7 @@ export function ensurePlaywrightChromium(options = {}) {
123116

124117
const systemExecutablePath =
125118
options.systemExecutablePath ?? resolveSystemChromiumExecutablePath(existsSync, spawnSync);
126-
if (
127-
systemExecutablePath &&
128-
canRunChromiumExecutable(systemExecutablePath, spawnSync)
129-
) {
119+
if (systemExecutablePath && canRunChromiumExecutable(systemExecutablePath, spawnSync)) {
130120
log(`[ui-e2e] Using system Chromium at ${systemExecutablePath}.`);
131121
return 0;
132122
}
@@ -157,11 +147,13 @@ export function ensurePlaywrightChromium(options = {}) {
157147
}
158148

159149
if (!existsSync(executablePath) || !canRunChromiumExecutable(executablePath, spawnSync)) {
160-
if (shouldInstallPlaywrightSystemDependencies({
161-
env,
162-
getuid: options.getuid,
163-
platform: options.platform,
164-
})) {
150+
if (
151+
shouldInstallPlaywrightSystemDependencies({
152+
env,
153+
getuid: options.getuid,
154+
platform: options.platform,
155+
})
156+
) {
165157
log(
166158
`[ui-e2e] Chromium is installed but still cannot start; installing Linux system dependencies.`,
167159
);

‎src/agents/bash-tools.exec-gateway-approval.e2e.test.ts‎

Lines changed: 114 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -67,117 +67,121 @@ describe("gateway-hosted exec approvals", () => {
6767
clearSessionStoreCacheForTest();
6868
});
6969

70-
it("lets OpenClaw-style gateway tool calls request and wait for approval over separate connections", async () => {
71-
const envSnapshot = captureEnv(TEST_ENV_KEYS);
72-
cleanup.push(() => envSnapshot.restore());
73-
74-
const tempHome = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-exec-approval-e2e-"));
75-
cleanup.push(() => fs.rm(tempHome, { recursive: true, force: true, maxRetries: 5 }));
76-
77-
const stateDir = path.join(tempHome, ".openclaw");
78-
const workspaceDir = path.join(tempHome, "workspace");
79-
await fs.mkdir(workspaceDir, { recursive: true });
80-
81-
const port = await getFreeGatewayPort();
82-
const token = "exec-approval-e2e-token";
83-
const configPath = path.join(stateDir, "openclaw.json");
84-
await fs.mkdir(stateDir, { recursive: true });
85-
await fs.writeFile(
86-
configPath,
87-
`${JSON.stringify(
88-
{
89-
gateway: {
90-
port,
91-
auth: { mode: "token", token },
92-
},
93-
tools: {
94-
exec: {
95-
host: "gateway",
96-
security: "allowlist",
97-
ask: "always",
70+
it(
71+
"lets OpenClaw-style gateway tool calls request and wait for approval over separate connections",
72+
async () => {
73+
const envSnapshot = captureEnv(TEST_ENV_KEYS);
74+
cleanup.push(() => envSnapshot.restore());
75+
76+
const tempHome = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-exec-approval-e2e-"));
77+
cleanup.push(() => fs.rm(tempHome, { recursive: true, force: true, maxRetries: 5 }));
78+
79+
const stateDir = path.join(tempHome, ".openclaw");
80+
const workspaceDir = path.join(tempHome, "workspace");
81+
await fs.mkdir(workspaceDir, { recursive: true });
82+
83+
const port = await getFreeGatewayPort();
84+
const token = "exec-approval-e2e-token";
85+
const configPath = path.join(stateDir, "openclaw.json");
86+
await fs.mkdir(stateDir, { recursive: true });
87+
await fs.writeFile(
88+
configPath,
89+
`${JSON.stringify(
90+
{
91+
gateway: {
92+
port,
93+
auth: { mode: "token", token },
94+
},
95+
tools: {
96+
exec: {
97+
host: "gateway",
98+
security: "allowlist",
99+
ask: "always",
100+
},
98101
},
99102
},
103+
null,
104+
2,
105+
)}\n`,
106+
"utf8",
107+
);
108+
109+
process.env.HOME = tempHome;
110+
process.env.OPENCLAW_STATE_DIR = stateDir;
111+
process.env.OPENCLAW_CONFIG_PATH = configPath;
112+
process.env.OPENCLAW_GATEWAY_TOKEN = token;
113+
process.env.OPENCLAW_GATEWAY_PORT = String(port);
114+
process.env.OPENCLAW_SKIP_CHANNELS = "1";
115+
process.env.OPENCLAW_SKIP_GMAIL_WATCHER = "1";
116+
process.env.OPENCLAW_SKIP_CRON = "1";
117+
process.env.OPENCLAW_SKIP_CANVAS_HOST = "1";
118+
process.env.OPENCLAW_SKIP_BROWSER_CONTROL_SERVER = "1";
119+
process.env.OPENCLAW_SKIP_PROVIDERS = "1";
120+
process.env.OPENCLAW_TEST_MINIMAL_GATEWAY = "1";
121+
clearRuntimeConfigSnapshot();
122+
clearConfigCache();
123+
clearSessionStoreCacheForTest();
124+
125+
const server = await startGatewayServer(port, {
126+
bind: "loopback",
127+
auth: { mode: "token", token },
128+
controlUiEnabled: false,
129+
deferStartupSidecars: true,
130+
});
131+
cleanup.push(() => server.close());
132+
133+
const operator = await connectGatewayClient({
134+
url: `ws://127.0.0.1:${port}`,
135+
token,
136+
clientName: GATEWAY_CLIENT_NAMES.TEST,
137+
clientDisplayName: "approval operator",
138+
mode: GATEWAY_CLIENT_MODES.TEST,
139+
scopes: [ADMIN_SCOPE],
140+
requestTimeoutMs: GATEWAY_CONNECT_TIMEOUT_MS,
141+
timeoutMs: GATEWAY_CONNECT_TIMEOUT_MS,
142+
});
143+
cleanup.push(() => disconnectGatewayClient(operator));
144+
145+
let resolveOutcome: (outcome: ExecApprovalFollowupOutcome) => void = () => {};
146+
const outcomePromise = new Promise<ExecApprovalFollowupOutcome>((resolve) => {
147+
resolveOutcome = resolve;
148+
});
149+
150+
const tool = createExecTool({
151+
host: "gateway",
152+
security: "allowlist",
153+
ask: "always",
154+
cwd: workspaceDir,
155+
approvalRunningNoticeMs: 0,
156+
approvalFollowupMode: "direct",
157+
approvalFollowup: ({ outcome }) => {
158+
resolveOutcome(outcome);
159+
return undefined;
100160
},
101-
null,
102-
2,
103-
)}\n`,
104-
"utf8",
105-
);
106-
107-
process.env.HOME = tempHome;
108-
process.env.OPENCLAW_STATE_DIR = stateDir;
109-
process.env.OPENCLAW_CONFIG_PATH = configPath;
110-
process.env.OPENCLAW_GATEWAY_TOKEN = token;
111-
process.env.OPENCLAW_GATEWAY_PORT = String(port);
112-
process.env.OPENCLAW_SKIP_CHANNELS = "1";
113-
process.env.OPENCLAW_SKIP_GMAIL_WATCHER = "1";
114-
process.env.OPENCLAW_SKIP_CRON = "1";
115-
process.env.OPENCLAW_SKIP_CANVAS_HOST = "1";
116-
process.env.OPENCLAW_SKIP_BROWSER_CONTROL_SERVER = "1";
117-
process.env.OPENCLAW_SKIP_PROVIDERS = "1";
118-
process.env.OPENCLAW_TEST_MINIMAL_GATEWAY = "1";
119-
clearRuntimeConfigSnapshot();
120-
clearConfigCache();
121-
clearSessionStoreCacheForTest();
122-
123-
const server = await startGatewayServer(port, {
124-
bind: "loopback",
125-
auth: { mode: "token", token },
126-
controlUiEnabled: false,
127-
deferStartupSidecars: true,
128-
});
129-
cleanup.push(() => server.close());
130-
131-
const operator = await connectGatewayClient({
132-
url: `ws://127.0.0.1:${port}`,
133-
token,
134-
clientName: GATEWAY_CLIENT_NAMES.TEST,
135-
clientDisplayName: "approval operator",
136-
mode: GATEWAY_CLIENT_MODES.TEST,
137-
scopes: [ADMIN_SCOPE],
138-
requestTimeoutMs: GATEWAY_CONNECT_TIMEOUT_MS,
139-
timeoutMs: GATEWAY_CONNECT_TIMEOUT_MS,
140-
});
141-
cleanup.push(() => disconnectGatewayClient(operator));
142-
143-
let resolveOutcome: (outcome: ExecApprovalFollowupOutcome) => void = () => {};
144-
const outcomePromise = new Promise<ExecApprovalFollowupOutcome>((resolve) => {
145-
resolveOutcome = resolve;
146-
});
147-
148-
const tool = createExecTool({
149-
host: "gateway",
150-
security: "allowlist",
151-
ask: "always",
152-
cwd: workspaceDir,
153-
approvalRunningNoticeMs: 0,
154-
approvalFollowupMode: "direct",
155-
approvalFollowup: ({ outcome }) => {
156-
resolveOutcome(outcome);
157-
return undefined;
158-
},
159-
});
160-
161-
const pending = await tool.execute("exec-approval-e2e", {
162-
command: "printf 'smoke\\n'",
163-
workdir: workspaceDir,
164-
timeout: 5,
165-
});
166-
167-
expect(pending.details.status).toBe("approval-pending");
168-
if (pending.details.status !== "approval-pending") {
169-
throw new Error("expected approval-pending exec result");
170-
}
171-
172-
await operator.request(
173-
"exec.approval.resolve",
174-
{ id: pending.details.approvalId, decision: "allow-once" },
175-
{ timeoutMs: 10_000 },
176-
);
177-
178-
const outcome = await withTimeout(outcomePromise, 15_000, "approved exec outcome");
179-
expect(outcome.status).toBe("completed");
180-
expect(outcome.exitCode).toBe(0);
181-
expect(outcome.aggregated).toBe("smoke");
182-
}, EXEC_APPROVAL_E2E_TIMEOUT_MS);
161+
});
162+
163+
const pending = await tool.execute("exec-approval-e2e", {
164+
command: "printf 'smoke\\n'",
165+
workdir: workspaceDir,
166+
timeout: 5,
167+
});
168+
169+
expect(pending.details.status).toBe("approval-pending");
170+
if (pending.details.status !== "approval-pending") {
171+
throw new Error("expected approval-pending exec result");
172+
}
173+
174+
await operator.request(
175+
"exec.approval.resolve",
176+
{ id: pending.details.approvalId, decision: "allow-once" },
177+
{ timeoutMs: 10_000 },
178+
);
179+
180+
const outcome = await withTimeout(outcomePromise, 15_000, "approved exec outcome");
181+
expect(outcome.status).toBe("completed");
182+
expect(outcome.exitCode).toBe(0);
183+
expect(outcome.aggregated).toBe("smoke");
184+
},
185+
EXEC_APPROVAL_E2E_TIMEOUT_MS,
186+
);
183187
});

‎src/auto-reply/heartbeat.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ tasks:
216216
expect(isHeartbeatContentEffectivelyEmpty("Reminder <!-- not scaffolding -->")).toBe(false);
217217
});
218218

219+
it("returns true for HTML comments only", () => {
220+
expect(isHeartbeatContentEffectivelyEmpty("<!-- runtime template note -->")).toBe(true);
221+
expect(
222+
isHeartbeatContentEffectivelyEmpty(`<!-- runtime template note -->
223+
224+
# HEARTBEAT.md
225+
`),
226+
).toBe(true);
227+
});
228+
219229
it("returns false when a template includes plain instructional prose", () => {
220230
const defaultTemplate = `# HEARTBEAT.md
221231

‎src/auto-reply/heartbeat.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ export function isHeartbeatContentEffectivelyEmpty(content: string | undefined |
8282
if (!trimmed) {
8383
continue;
8484
}
85+
// Skip single-line HTML comments used by the bundled runtime template.
86+
if (/^<!--.*-->$/.test(trimmed)) {
87+
continue;
88+
}
8589
// Skip markdown header lines (# followed by space or EOL, ## etc)
8690
// This intentionally does NOT skip lines like "#TODO" or "#hashtag" which might be content
8791
// (Those aren't valid markdown headers - ATX headers require space after #)

0 commit comments

Comments
 (0)