





















@@ -63,6 +63,10 @@ function toolResultMessage(content: Extract<Message, { role: "toolResult" }>["co
6363};
6464}
656566+function eventTypes(events: readonly Pick<TrajectoryEvent, "type">[]): string[] {
67+return events.map((event) => event.type);
68+}
69+6670function writeSimpleSessionFile(
6771sessionFile: string,
6872params: { userEntryTimestamp?: string | number } = {},
@@ -332,7 +336,7 @@ describe("exportTrajectoryBundle", () => {
332336});
333337334338expect(bundle.manifest.runtimeEventCount).toBe(1);
335-expect(bundle.events.some((event) => event.type === "session.started")).toBe(true);
339+expect(eventTypes(bundle.events)).toContain("session.started");
336340});
337341338342it("uses the recorded runtime pointer before current environment overrides", async () => {
@@ -395,8 +399,8 @@ describe("exportTrajectoryBundle", () => {
395399});
396400397401expect(bundle.runtimeFile).toBe(recordedRuntimeFile);
398-expect(bundle.events.some((event) => event.type === "recorded-runtime")).toBe(true);
399-expect(bundle.events.some((event) => event.type === "env-runtime")).toBe(false);
402+expect(eventTypes(bundle.events)).toContain("recorded-runtime");
403+expect(eventTypes(bundle.events)).not.toContain("env-runtime");
400404} finally {
401405if (previous === undefined) {
402406delete process.env.OPENCLAW_TRAJECTORY_DIR;
@@ -446,7 +450,7 @@ describe("exportTrajectoryBundle", () => {
446450});
447451448452expect(bundle.runtimeFile).toBeUndefined();
449-expect(bundle.events.some((event) => event.type === "outside-runtime")).toBe(false);
453+expect(eventTypes(bundle.events)).not.toContain("outside-runtime");
450454});
451455452456it("does not fall back to runtime pointer targets that are not regular files", async () => {
@@ -492,7 +496,7 @@ describe("exportTrajectoryBundle", () => {
492496});
493497494498expect(bundle.runtimeFile).toBeUndefined();
495-expect(bundle.events.some((event) => event.type === "symlink-runtime")).toBe(false);
499+expect(eventTypes(bundle.events)).not.toContain("symlink-runtime");
496500});
497501498502it("counts expanded transcript events when enforcing the total event limit", async () => {
@@ -542,7 +546,7 @@ describe("exportTrajectoryBundle", () => {
542546});
543547544548expect(bundle.manifest.runtimeEventCount).toBe(0);
545-expect(bundle.events.some((event) => event.type === "other-runtime")).toBe(false);
549+expect(eventTypes(bundle.events)).not.toContain("other-runtime");
546550});
547551548552it("redacts non-workspace paths in strings that also contain workspace paths", async () => {
@@ -744,9 +748,9 @@ describe("exportTrajectoryBundle", () => {
744748.trim()
745749.split(/\r?\n/u)
746750.map((line) => JSON.parse(line) as TrajectoryEvent);
747-expect(exportedEvents.some((event) => event.type === "tool.call")).toBe(true);
748-expect(exportedEvents.some((event) => event.type === "tool.result")).toBe(true);
749-expect(exportedEvents.some((event) => event.type === "context.compiled")).toBe(true);
751+expect(eventTypes(exportedEvents)).toEqual(
752+ expect.arrayContaining(["tool.call", "tool.result", "context.compiled"]),
753+);
750754expect(JSON.stringify(exportedEvents)).toContain("$WORKSPACE_DIR/inside.txt");
751755expect(JSON.stringify(exportedEvents)).not.toContain("$WORKSPACE_DIR2");
752756@@ -767,7 +771,8 @@ describe("exportTrajectoryBundle", () => {
767771"system-prompt.txt",
768772"tools.json",
769773]);
770-expect(manifest.contents?.every((entry) => entry.bytes > 0)).toBe(true);
774+const emptyContents = (manifest.contents ?? []).filter((entry) => entry.bytes <= 0);
775+expect(emptyContents).toEqual([]);
771776772777const metadata = JSON.parse(fs.readFileSync(path.join(outputDir, "metadata.json"), "utf8")) as {
773778skills?: { entries?: Array<{ id?: string; invoked?: boolean }> };
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。