Working version 6.2

This commit is contained in:
2026-04-10 14:44:03 +02:00
parent d526c1ff4a
commit f20d5f09ae
28 changed files with 1231 additions and 1554 deletions

View File

@@ -20,6 +20,7 @@ export const authConfig: NextAuthConfig = {
issuer: process.env.ZITADEL_ISSUER!,
clientId: process.env.ZITADEL_CLIENT_ID!,
clientSecret: process.env.ZITADEL_CLIENT_SECRET!,
idToken: false,
authorization: {
params: {
scope:
@@ -38,6 +39,7 @@ export const authConfig: NextAuthConfig = {
callbacks: {
async jwt({ token, account, profile }) {
if (account && profile) {
console.log("ZITADEL profile claims:", JSON.stringify(profile, null, 2));
const claims = profile as unknown as ZitadelClaims;
token.orgId = claims["urn:zitadel:iam:user:resourceowner:id"];
token.orgName = claims["urn:zitadel:iam:user:resourceowner:name"];

View File

@@ -31,3 +31,20 @@ export async function getTeamSpendLogs(
if (endDate) params.set("end_date", endDate);
return litellmFetch(`/global/spend/logs?${params}`);
}
export async function getTeamSpendLogsV2(
teamId: string,
startDate: string,
endDate: string,
page: number = 1,
pageSize: number = 100
) {
const params = new URLSearchParams({
team_id: teamId,
start_date: `${startDate} 00:00:00`,
end_date: `${endDate} 23:59:59`,
page: String(page),
page_size: String(pageSize),
});
return litellmFetch(`/spend/logs/v2?${params}`);
}

View File

@@ -2,8 +2,7 @@ import { readFileSync } from "fs";
const OPENBAO_ADDR =
process.env.OPENBAO_ADDR || "http://openbao.openbao.svc:8200";
const SA_TOKEN_PATH =
"/var/run/secrets/kubernetes.io/serviceaccount/token";
const SA_TOKEN_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/token";
const K8S_AUTH_ROLE = process.env.OPENBAO_K8S_ROLE || "pieced-portal";
const K8S_AUTH_MOUNT = process.env.OPENBAO_K8S_MOUNT || "kubernetes";
@@ -15,7 +14,6 @@ async function authenticate(): Promise<string> {
}
const jwt = readFileSync(SA_TOKEN_PATH, "utf-8").trim();
const res = await fetch(
`${OPENBAO_ADDR}/v1/auth/${K8S_AUTH_MOUNT}/login`,
{
@@ -38,14 +36,9 @@ async function authenticate(): Promise<string> {
token,
expiresAt: Date.now() + leaseDuration * 1000,
};
return token;
}
/**
* Write secrets for a tenant package to OpenBao KV v2.
* Path: secret/data/tenants/{tenantId}/{packageId}
*/
export async function writePackageSecrets(
tenantId: string,
packageId: string,
@@ -53,7 +46,6 @@ export async function writePackageSecrets(
): Promise<void> {
const token = await authenticate();
const path = `secret/data/tenants/${tenantId}/${packageId}`;
const res = await fetch(`${OPENBAO_ADDR}/v1/${path}`, {
method: "POST",
headers: {
@@ -69,17 +61,12 @@ export async function writePackageSecrets(
}
}
/**
* Delete secrets for a tenant package from OpenBao KV v2.
* Uses metadata delete to remove all versions.
*/
export async function deletePackageSecrets(
tenantId: string,
packageId: string
): Promise<void> {
const token = await authenticate();
const path = `secret/metadata/tenants/${tenantId}/${packageId}`;
const res = await fetch(`${OPENBAO_ADDR}/v1/${path}`, {
method: "DELETE",
headers: { "X-Vault-Token": token },

View File

@@ -1,16 +1,17 @@
export interface PackageSecretField {
key: string;
labelKey: string;
placeholderKey: string;
}
export interface PackageDef {
id: string;
name: string;
descriptionKey: string; // i18n key
icon: string; // emoji or lucide icon name
descriptionKey: string;
requiresSecrets: boolean;
secrets?: {
key: string;
labelKey: string;
placeholderKey: string;
}[];
customerInstructionsKey?: string; // i18n key for how-to
disclaimerKey?: string; // i18n key
secrets?: PackageSecretField[];
instructionsKey?: string;
disclaimerKey?: string;
category: "channel" | "skill";
}
@@ -19,7 +20,6 @@ export const PACKAGE_CATALOG: PackageDef[] = [
id: "telegram",
name: "Telegram",
descriptionKey: "packages.telegram.description",
icon: "MessageCircle",
requiresSecrets: true,
secrets: [
{
@@ -28,7 +28,7 @@ export const PACKAGE_CATALOG: PackageDef[] = [
placeholderKey: "packages.telegram.botTokenPlaceholder",
},
],
customerInstructionsKey: "packages.telegram.instructions",
instructionsKey: "packages.telegram.instructions",
disclaimerKey: "packages.telegram.disclaimer",
category: "channel",
},
@@ -36,7 +36,6 @@ export const PACKAGE_CATALOG: PackageDef[] = [
id: "discord",
name: "Discord",
descriptionKey: "packages.discord.description",
icon: "Hash",
requiresSecrets: true,
secrets: [
{
@@ -45,7 +44,7 @@ export const PACKAGE_CATALOG: PackageDef[] = [
placeholderKey: "packages.discord.botTokenPlaceholder",
},
],
customerInstructionsKey: "packages.discord.instructions",
instructionsKey: "packages.discord.instructions",
disclaimerKey: "packages.discord.disclaimer",
category: "channel",
},
@@ -53,31 +52,14 @@ export const PACKAGE_CATALOG: PackageDef[] = [
id: "email",
name: "Email",
descriptionKey: "packages.email.description",
icon: "Mail",
requiresSecrets: true,
secrets: [
{
key: "smtp-host",
labelKey: "packages.email.smtpHostLabel",
placeholderKey: "packages.email.smtpHostPlaceholder",
},
{
key: "smtp-user",
labelKey: "packages.email.smtpUserLabel",
placeholderKey: "packages.email.smtpUserPlaceholder",
},
{
key: "smtp-password",
labelKey: "packages.email.smtpPasswordLabel",
placeholderKey: "packages.email.smtpPasswordPlaceholder",
},
{
key: "imap-host",
labelKey: "packages.email.imapHostLabel",
placeholderKey: "packages.email.imapHostPlaceholder",
},
{ key: "smtp-host", labelKey: "packages.email.smtpHostLabel", placeholderKey: "packages.email.smtpHostPlaceholder" },
{ key: "smtp-user", labelKey: "packages.email.smtpUserLabel", placeholderKey: "packages.email.smtpUserPlaceholder" },
{ key: "smtp-password", labelKey: "packages.email.smtpPasswordLabel", placeholderKey: "packages.email.smtpPasswordPlaceholder" },
{ key: "imap-host", labelKey: "packages.email.imapHostLabel", placeholderKey: "packages.email.imapHostPlaceholder" },
],
customerInstructionsKey: "packages.email.instructions",
instructionsKey: "packages.email.instructions",
disclaimerKey: "packages.email.disclaimer",
category: "channel",
},
@@ -85,7 +67,6 @@ export const PACKAGE_CATALOG: PackageDef[] = [
id: "web-search",
name: "Web Search",
descriptionKey: "packages.webSearch.description",
icon: "Search",
requiresSecrets: false,
category: "skill",
},
@@ -93,7 +74,6 @@ export const PACKAGE_CATALOG: PackageDef[] = [
id: "document-processing",
name: "Document Processing",
descriptionKey: "packages.documentProcessing.description",
icon: "FileText",
requiresSecrets: false,
category: "skill",
},