Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
import * as Cause from "effect/Cause";
import { describe, expect, it } from "vite-plus/test";
import { findErrorTraceId } from "./errorTrace.ts";
describe("findErrorTraceId", () => {
it("finds trace metadata through wrapped typed errors", () => {
expect(
findErrorTraceId({
cause: {
cause: {
_tag: "RelayInternalError",
traceId: "trace-relay",
},
},
}),
).toBe("trace-relay");
});
it("terminates for cyclic causes", () => {
interface CyclicCause {
cause?: CyclicCause;
}
const error: CyclicCause = {};
error.cause = error;
expect(findErrorTraceId(error)).toBeNull();
});
it("finds trace metadata in Effect cause branches", () => {
const cause = Cause.fromReasons<unknown>([
Cause.makeFailReason(new Error("first failure")),
Cause.makeFailReason({ traceId: "trace-secondary" }),
]);
expect(findErrorTraceId(cause)).toBe("trace-secondary");
});
it("finds trace metadata in aggregate error branches", () => {
const error = new AggregateError(
[new Error("first failure"), { traceId: "trace-aggregate" }],
"request failed",
);
expect(findErrorTraceId(error)).toBe("trace-aggregate");
});
});