Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat(pam): backend-driven AI model list, XML log wrapping, backspace semantics fix, haiku alias
bernie-ge91fb7a5feb6
diff --git a/backend/src/ee/routes/v1/pam-resource-routers/pam-resource-router.ts b/backend/src/ee/routes/v1/pam-resource-routers/pam-resource-router.tsindex 838eb308db..4550328310 100644--- a/backend/src/ee/routes/v1/pam-resource-routers/pam-resource-router.ts+++ b/backend/src/ee/routes/v1/pam-resource-routers/pam-resource-router.ts@@ -27,6 +27,7 @@ import {SanitizedMySQLResourceSchema} from "@app/ee/services/pam-resource/mysql/mysql-resource-schemas";import { PamResource, PamResourceOrderBy } from "@app/ee/services/pam-resource/pam-resource-enums";+import { PAM_AI_INSIGHT_MODELS } from "@app/ee/services/pam-resource/pam-resource-schemas";import {PostgresResourceListItemSchema,SanitizedPostgresResourceSchema@@ -80,6 +81,32 @@ const ResourceOptionsSchema = z.discriminatedUnion("resource", []);export const registerPamResourceRouter = async (server: FastifyZodProvider) => {+ server.route({+ method: "GET",+ url: "/ai-insights/models",+ config: {+ rateLimit: readLimit+ },+ schema: {+ description: "List available AI models for PAM session insights, grouped by app connection type",+ response: {+ 200: z.object({+ models: z+ .object({+ connectionApp: z.string(),+ id: z.string(),+ label: z.string()+ })+ .array()+ })+ }+ },+ onRequest: verifyAuth([AuthMode.JWT]),+ handler: () => {+ return { models: PAM_AI_INSIGHT_MODELS };+ }+ });+server.route({method: "GET",url: "/options",diff --git a/backend/src/ee/services/pam-resource/pam-resource-schemas.ts b/backend/src/ee/services/pam-resource/pam-resource-schemas.tsindex 46779bdbdb..dd452d7824 100644--- a/backend/src/ee/services/pam-resource/pam-resource-schemas.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-schemas.ts@@ -16,12 +16,19 @@ export const GatewayAccessResponseSchema = z.object({metadata: z.record(z.string(), z.string().optional()).optional()});+// AI Insights model list — single source of truth for what models are available per provider+export const PAM_AI_INSIGHT_MODELS: { connectionApp: string; id: string; label: string }[] = [+ { connectionApp: "anthropic", id: "claude-opus-4-6", label: "Claude Opus 4.6" },+ { connectionApp: "anthropic", id: "claude-sonnet-4-6", label: "Claude Sonnet 4.6" },+ { connectionApp: "anthropic", id: "claude-haiku-4-5", label: "Claude Haiku 4.5" }+];+// Resourcesexport const SessionSummaryConfigSchema = z.object({aiInsightsEnabled: z.boolean(),connectionId: z.string().uuid(),- model: z.enum(["claude-opus-4-6", "claude-sonnet-4-6", "claude-haiku-4-5-20251001"])+ model: z.enum(["claude-opus-4-6", "claude-sonnet-4-6", "claude-haiku-4-5"])}).nullable().optional();diff --git a/backend/src/ee/services/pam-session/pam-session-summary-fns.ts b/backend/src/ee/services/pam-session/pam-session-summary-fns.tsindex 691cf55e55..d8d15ae170 100644--- a/backend/src/ee/services/pam-session/pam-session-summary-fns.ts+++ b/backend/src/ee/services/pam-session/pam-session-summary-fns.ts@@ -26,9 +26,20 @@ export const formatLogsForSummary = (for (const event of terminalLogs.filter((e) => e.eventType === "input")) {try {const decoded = Buffer.from(event.data, "base64").toString("utf8");- // Keep only printable ASCII and common whitespace, strip ANSI escape codes+ // Strip ANSI escape codes first, then apply backspace/DEL line-editing semantics+ // so that characters the user erased are not sent to the AI// eslint-disable-next-line no-control-regex- const cleaned = decoded.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "").replace(/[^\x20-\x7e\t\n\r]/g, "");+ const noAnsi = decoded.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "");+ let edited = "";+ for (const ch of noAnsi) {+ if (ch === "\x08" || ch === "\x7f") {+ edited = edited.slice(0, -1);+ } else {+ edited += ch;+ }+ }+ // eslint-disable-next-line no-control-regex+ const cleaned = edited.replace(/[^\x20-\x7e\t\n\r]/g, "");if (cleaned.trim()) inputLines.push(cleaned);} catch {// skip malformed base64@@ -77,7 +88,9 @@ export const buildSummaryPrompt = ({- Duration: ${Math.round(durationSeconds)}sSession logs:-${formattedLogs}`;+<formattedLogs>+${formattedLogs}+</formattedLogs>`;return { system, user };};diff --git a/frontend/src/hooks/api/pam/queries.tsx b/frontend/src/hooks/api/pam/queries.tsxindex a89114cd9a..8d7e82dd94 100644--- a/frontend/src/hooks/api/pam/queries.tsx+++ b/frontend/src/hooks/api/pam/queries.tsx@@ -54,7 +54,23 @@ export const pamKeys = {rotationRules: (resourceId: string) => [...pamKeys.resource(), "rotation-rules", resourceId],getSession: (sessionId: string) => [...pamKeys.session(), "get", sessionId],getSessionLogs: (sessionId: string) => [...pamKeys.session(), "logs", sessionId],- listSessions: (projectId: string) => [...pamKeys.session(), "list", projectId]+ listSessions: (projectId: string) => [...pamKeys.session(), "list", projectId],+ aiInsightsModels: () => [...pamKeys.all, "ai-insights-models"] as const+};++export type TPamAiInsightsModel = { connectionApp: string; id: string; label: string };++export const useGetPamAiInsightsModels = () => {+ return useQuery({+ queryKey: pamKeys.aiInsightsModels(),+ queryFn: async () => {+ const { data } = await apiRequest.get<{ models: TPamAiInsightsModel[] }>(+ "/api/v1/pam/resources/ai-insights/models"+ );++ return data.models;+ }+ });};// Resourcesdiff --git a/frontend/src/pages/pam/PamResourceByIDPage/components/PamSessionRecordingModal.tsx b/frontend/src/pages/pam/PamResourceByIDPage/components/PamSessionRecordingModal.tsxindex 8f8b2375b5..cea7f988b3 100644--- a/frontend/src/pages/pam/PamResourceByIDPage/components/PamSessionRecordingModal.tsx+++ b/frontend/src/pages/pam/PamResourceByIDPage/components/PamSessionRecordingModal.tsx@@ -26,24 +26,14 @@ import {} from "@app/components/v3";import { AppConnection } from "@app/hooks/api/appConnections/enums";import { useListAppConnections } from "@app/hooks/api/appConnections/queries";+import { useGetPamAiInsightsModels } from "@app/hooks/api/pam";import { SessionRecordingConfig } from "./PamResourceSessionRecordingSection";// Extend this array as more LLM providers are addedconst LLM_APP_CONNECTIONS = [AppConnection.Anthropic] as const;-type LlmAppConnection = (typeof LLM_APP_CONNECTIONS)[number];-const LLM_MODELS: Record<LlmAppConnection, { id: string; label: string }[]> = {- [AppConnection.Anthropic]: [- { id: "claude-opus-4-6", label: "Claude Opus 4.6" },- { id: "claude-sonnet-4-6", label: "Claude Sonnet 4.6" },- { id: "claude-haiku-4-5-20251001", label: "Claude Haiku 4.5" }- ]-};--const DEFAULT_MODEL: Record<LlmAppConnection, string> = {- [AppConnection.Anthropic]: "claude-sonnet-4-6"-};+const DEFAULT_MODEL = "claude-sonnet-4-6";const formSchema = z.object({aiInsightsEnabled: z.boolean(),@@ -64,6 +54,7 @@ export const PamSessionRecordingModal = ({ isOpen, onOpenChange, config, onSaveconst { data: allConnections = [], isPending } = useListAppConnections(undefined, {enabled: isOpen});+ const { data: aiModels = [] } = useGetPamAiInsightsModels();const llmConnections = allConnections.filter((c) =>(LLM_APP_CONNECTIONS as readonly string[]).includes(c.app)@@ -80,7 +71,7 @@ export const PamSessionRecordingModal = ({ isOpen, onOpenChange, config, onSavedefaultValues: {aiInsightsEnabled: config?.aiInsightsEnabled ?? false,connectionId: config?.connectionId ?? "",- model: config?.model ?? DEFAULT_MODEL[AppConnection.Anthropic]+ model: config?.model ?? DEFAULT_MODEL}});@@ -89,7 +80,7 @@ export const PamSessionRecordingModal = ({ isOpen, onOpenChange, config, onSavereset({aiInsightsEnabled: config?.aiInsightsEnabled ?? false,connectionId: config?.connectionId ?? "",- model: config?.model ?? DEFAULT_MODEL[AppConnection.Anthropic]+ model: config?.model ?? DEFAULT_MODEL});}}, [isOpen, config, reset]);@@ -97,16 +88,19 @@ export const PamSessionRecordingModal = ({ isOpen, onOpenChange, config, onSaveconst aiInsightsEnabled = useWatch({ control, name: "aiInsightsEnabled" });const selectedConnectionId = useWatch({ control, name: "connectionId" });const selectedConnection = llmConnections.find((c) => c.id === selectedConnectionId);- const selectedProvider = selectedConnection?.app as LlmAppConnection | undefined;- const availableModels = selectedProvider ? LLM_MODELS[selectedProvider] : [];+ const selectedProvider = selectedConnection?.app;+ const availableModels = selectedProvider+ ? aiModels.filter((m) => m.connectionApp === selectedProvider)+ : [];// Only reset the model when the user explicitly changes the connection (field is dirty),// not when connections load async and selectedProvider goes undefined → defined on open.useEffect(() => {if (selectedProvider && dirtyFields.connectionId) {- setValue("model", DEFAULT_MODEL[selectedProvider], { shouldDirty: true });+ const firstModel = aiModels.find((m) => m.connectionApp === selectedProvider);+ setValue("model", firstModel?.id ?? DEFAULT_MODEL, { shouldDirty: true });}- }, [selectedProvider, dirtyFields.connectionId, setValue]);+ }, [selectedProvider, dirtyFields.connectionId, setValue, aiModels]);const onSubmit = async (data: FormData) => {try {@@ -117,7 +111,7 @@ export const PamSessionRecordingModal = ({ isOpen, onOpenChange, config, onSaveaiInsightsEnabled: true,connectionId: data.connectionId ?? "",connectionName: selectedConnection?.name ?? data.connectionId ?? "",- model: data.model ?? DEFAULT_MODEL[AppConnection.Anthropic]+ model: data.model ?? DEFAULT_MODEL});}onOpenChange(false);