feat: vendor permission system source

This commit is contained in:
云服务部-叶林立
2026-08-19 14:35:19 +08:00
parent 198584daf8
commit 410c50a3e5
809 changed files with 157793 additions and 139 deletions
@@ -0,0 +1,18 @@
import { describe, expect, it } from "vitest";
import { createPermissionRequestId } from "#src/permission-request-id";
describe("createPermissionRequestId", () => {
it("prefixes the id so it is distinguishable from an SDK tool call id", () => {
expect(createPermissionRequestId()).toMatch(
/^perm-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,
);
});
it("mints a distinct id on every call", () => {
const ids = new Set(
Array.from({ length: 100 }, () => createPermissionRequestId()),
);
expect(ids.size).toBe(100);
});
});