FIX - LAUNCHER: sync Codex Agent API entitlement

This commit is contained in:
DCCONSTRUCTIONS
2026-05-16 14:22:19 +03:00
parent 2618e88e83
commit ec91821fdc
4 changed files with 11 additions and 28 deletions
+6 -16
View File
@@ -168,7 +168,7 @@ export function createControlPlaneStore({ projectRoot }) {
async function updateClient(clientId, payload, identity) {
const data = readData();
const actor = resolveActor(data, identity);
const client = findById(data.clients, clientId, "client");
const client = findClientById(data, clientId);
client.type = pickEnum(payload?.type, clientTypes, client.type);
client.name = optionalString(payload?.name, client.name);
@@ -332,7 +332,7 @@ export function createControlPlaneStore({ projectRoot }) {
async function deleteClient(clientId, identity) {
const data = readData();
const actor = resolveActor(data, identity);
const client = findById(data.clients, clientId, "client");
const client = findClientById(data, clientId);
if (data.clients.length <= 1) {
throw new Error("Cannot delete the last client");
@@ -1564,16 +1564,12 @@ export function createControlPlaneStore({ projectRoot }) {
const serviceId = requireString(payload?.serviceId, "serviceId");
const moduleId = pickEnum(payload?.moduleId, serviceModuleIds, "codex_agents");
const enabled = payload?.enabled === true;
const client = findById(data.clients, clientId, "client");
const client = findClientById(data, clientId);
const user = findById(data.users, userId, "user");
const service = findById(data.services, serviceId, "service");
const existingEntitlement = data.serviceModuleEntitlements.find(
(entitlement) =>
entitlement.clientId === client.id &&
entitlement.userId === user.id &&
entitlement.serviceId === service.id &&
entitlement.moduleId === moduleId
(entitlement) => entitlement.userId === user.id && entitlement.serviceId === service.id && entitlement.moduleId === moduleId
);
let entitlement = null;
@@ -1583,13 +1579,13 @@ export function createControlPlaneStore({ projectRoot }) {
existingEntitlement ??
{
id: uniqueId(data.serviceModuleEntitlements, "svc_module", `${client.id}-${service.slug}-${user.email}-${moduleId}`),
clientId: client.id,
userId: user.id,
serviceId: service.id,
moduleId,
createdByUserId: actor.id,
createdAt: now,
};
entitlement.clientId = client.id;
entitlement.enabled = true;
entitlement.updatedAt = now;
@@ -1598,13 +1594,7 @@ export function createControlPlaneStore({ projectRoot }) {
}
} else {
data.serviceModuleEntitlements = data.serviceModuleEntitlements.filter(
(candidate) =>
!(
candidate.clientId === client.id &&
candidate.userId === user.id &&
candidate.serviceId === service.id &&
candidate.moduleId === moduleId
)
(candidate) => !(candidate.userId === user.id && candidate.serviceId === service.id && candidate.moduleId === moduleId)
);
}