mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:41:24 +00:00
chore: merge origin/main into main
This commit is contained in:
@@ -24,6 +24,33 @@ function registerExtraBootstrapFileHook() {
|
||||
});
|
||||
}
|
||||
|
||||
function registerMalformedBootstrapFileHook() {
|
||||
registerInternalHook("agent:bootstrap", (event) => {
|
||||
const context = event.context as AgentBootstrapHookContext;
|
||||
context.bootstrapFiles = [
|
||||
...context.bootstrapFiles,
|
||||
{
|
||||
name: "EXTRA.md",
|
||||
filePath: path.join(context.workspaceDir, "BROKEN.md"),
|
||||
content: "broken",
|
||||
missing: false,
|
||||
} as unknown as WorkspaceBootstrapFile,
|
||||
{
|
||||
name: "EXTRA.md",
|
||||
path: 123,
|
||||
content: "broken",
|
||||
missing: false,
|
||||
} as unknown as WorkspaceBootstrapFile,
|
||||
{
|
||||
name: "EXTRA.md",
|
||||
path: " ",
|
||||
content: "broken",
|
||||
missing: false,
|
||||
} as unknown as WorkspaceBootstrapFile,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
describe("resolveBootstrapFilesForRun", () => {
|
||||
beforeEach(() => clearInternalHooks());
|
||||
afterEach(() => clearInternalHooks());
|
||||
@@ -36,6 +63,23 @@ describe("resolveBootstrapFilesForRun", () => {
|
||||
|
||||
expect(files.some((file) => file.path === path.join(workspaceDir, "EXTRA.md"))).toBe(true);
|
||||
});
|
||||
|
||||
it("drops malformed hook files with missing/invalid paths", async () => {
|
||||
registerMalformedBootstrapFileHook();
|
||||
|
||||
const workspaceDir = await makeTempWorkspace("openclaw-bootstrap-");
|
||||
const warnings: string[] = [];
|
||||
const files = await resolveBootstrapFilesForRun({
|
||||
workspaceDir,
|
||||
warn: (message) => warnings.push(message),
|
||||
});
|
||||
|
||||
expect(
|
||||
files.every((file) => typeof file.path === "string" && file.path.trim().length > 0),
|
||||
).toBe(true);
|
||||
expect(warnings).toHaveLength(3);
|
||||
expect(warnings[0]).toContain('missing or invalid "path" field');
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveBootstrapContextForRun", () => {
|
||||
|
||||
Reference in New Issue
Block a user