Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

improvement(agent-vault): list variables under stored values

Scott Wilson736f50854f82
diff --git a/backend/e2e-test/routes/v1/agent-vault.spec.ts b/backend/e2e-test/routes/v1/agent-vault.spec.ts
index b5b1888a0c..392da3ba42 100644
--- a/backend/e2e-test/routes/v1/agent-vault.spec.ts
+++ b/backend/e2e-test/routes/v1/agent-vault.spec.ts
@@ -702,7 +702,6 @@ describe("Agent Vault V1 Router", async () => {
field: string;
customHeaderId?: string;
substitutionId?: string;
- isWholeValue: boolean;
};
const createVariable = async (accessBundleId: string, body: { key: string; value: string; isSecret?: boolean }) => {
@@ -796,27 +795,24 @@ describe("Agent Vault V1 Router", async () => {
// Exact entries, because a reference carries only the id its field uses, not the others as null.
expect(service.variableReferences).toEqual(
expect.arrayContaining([
- { variableId: token.id, key: "GITHUB_TOKEN", field: "credential-value", isWholeValue: true },
+ { variableId: token.id, key: "GITHUB_TOKEN", field: "credential-value" },
{
variableId: token.id,
key: "GITHUB_TOKEN",
field: "custom-header",
- customHeaderId: service.customHeaders[0].id,
- isWholeValue: false
+ customHeaderId: service.customHeaders[0].id
},
{
variableId: org.id,
key: "ORG_ID",
field: "custom-header",
- customHeaderId: service.customHeaders[0].id,
- isWholeValue: false
+ customHeaderId: service.customHeaders[0].id
},
{
variableId: org.id,
key: "ORG_ID",
field: "substitution",
- substitutionId: service.substitutions[0].id,
- isWholeValue: true
+ substitutionId: service.substitutions[0].id
}
])
);
@@ -852,7 +848,7 @@ describe("Agent Vault V1 Router", async () => {
accessBundle: { services: { variableReferences: TReference[] }[] };
};
expect(detail.accessBundle.services[0].variableReferences).toEqual([
- expect.objectContaining({ key: "NEW_NAME", field: "credential-value", isWholeValue: true })
+ expect.objectContaining({ key: "NEW_NAME", field: "credential-value" })
]);
expect((await resolve()).services[0].credential).toMatchObject({ value: "first" });
@@ -1032,6 +1028,12 @@ describe("Agent Vault V1 Router", async () => {
test("variables are admin only, reads included", async () => {
const bundle = await createAccessBundle("variables-admin-only");
const variable = await createVariable(bundle.id, { key: "TOKEN", value: "admin_only_value", isSecret: false });
+ const created = await inject("POST", servicesUrl(bundle.id), {
+ name: "uses-token",
+ hostPattern: "api.example.com",
+ credential: { type: "bearer", value: "{{TOKEN}}" }
+ });
+ expect(created.statusCode).toBe(200);
const member = await createUaIdentity(`av-variables-member-${Date.now()}`);
try {
@@ -1047,10 +1049,26 @@ describe("Agent Vault V1 Router", async () => {
).statusCode
).toBe(200);
- // The member reaches the bundle, so the refusals below are about variables and nothing else.
- expect((await member.asIdentity("GET", `/api/v1/agent-vault/access-bundles/${bundle.id}`)).statusCode).toBe(
- 200
- );
+ type TBundleRead = { accessBundle: { services: { name: string; variableReferences?: TReference[] }[] } };
+
+ // The member reaches the bundle, so the refusals below are about variables and nothing else. It sees the
+ // service, but neither the key nor the id of the variable its token comes from.
+ const reached = await member.asIdentity("GET", `/api/v1/agent-vault/access-bundles/${bundle.id}`);
+ expect(reached.statusCode).toBe(200);
+ const { accessBundle } = JSON.parse(reached.payload) as TBundleRead;
+ expect(accessBundle.services.map((service) => service.name)).toEqual(["uses-token"]);
+ expect(accessBundle.services[0]).not.toHaveProperty("variableReferences");
+ expect(reached.payload).not.toContain("variableReferences");
+ expect(reached.payload).not.toContain("TOKEN");
+ expect(reached.payload).not.toContain(variable.id);
+
+ const asAdmin = JSON.parse(
+ (await inject("GET", `/api/v1/agent-vault/access-bundles/${bundle.id}`)).payload
+ ) as TBundleRead;
+ expect(asAdmin.accessBundle.services[0].variableReferences).toEqual([
+ { variableId: variable.id, key: "TOKEN", field: "credential-value" }
+ ]);
+
const listed = await member.asIdentity("GET", variablesUrl(bundle.id));
expect(listed.statusCode).toBe(403);
expect(listed.payload).not.toContain("admin_only_value");
diff --git a/backend/src/db/migrations/20260924143000_agent-vault-variables.ts b/backend/src/db/migrations/20260924143000_agent-vault-variables.ts
index 428a14f189..145977bf43 100644
--- a/backend/src/db/migrations/20260924143000_agent-vault-variables.ts
+++ b/backend/src/db/migrations/20260924143000_agent-vault-variables.ts
@@ -51,8 +51,6 @@ export async function up(knex: Knex): Promise<void> {
t.foreign("substitutionId").references("id").inTable(TableName.AgentVaultServiceSubstitution).onDelete("CASCADE");
t.index("substitutionId");
- t.boolean("isWholeValue").notNullable();
-
t.timestamps(true, true, true);
});
diff --git a/backend/src/db/schemas/agent-vault-service-variable-references.ts b/backend/src/db/schemas/agent-vault-service-variable-references.ts
index 438db6ff45..d688365c60 100644
--- a/backend/src/db/schemas/agent-vault-service-variable-references.ts
+++ b/backend/src/db/schemas/agent-vault-service-variable-references.ts
@@ -14,7 +14,6 @@ export const AgentVaultServiceVariableReferencesSchema = z.object({
field: z.string(),
customHeaderId: z.string().uuid().nullable().optional(),
substitutionId: z.string().uuid().nullable().optional(),
- isWholeValue: z.boolean(),
createdAt: z.date(),
updatedAt: z.date()
});
diff --git a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-access-bundle-router.ts b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-access-bundle-router.ts
index 024c245c3d..46e5085cdf 100644
--- a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-access-bundle-router.ts
+++ b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-access-bundle-router.ts
@@ -172,7 +172,9 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
}),
response: {
200: z.object({
- accessBundle: AccessBundleSchema.extend({ services: AgentVaultServiceSchema.array() })
+ accessBundle: AccessBundleSchema.extend({
+ services: AgentVaultServiceSchema.partial({ variableReferences: true }).array()
+ })
})
}
},
@@ -310,7 +312,7 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
handler: async (req) => {
- const { service } = await server.services.agentVaultAccessBundle.createService({
+ const { service, accessBundleName } = await server.services.agentVaultAccessBundle.createService({
projectId: req.internalAgentVaultProjectId,
ctx: actorContext(req),
accessBundleId: req.params.accessBundleId,
@@ -325,6 +327,7 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
type: EventType.AGENT_VAULT_SERVICE_CREATE,
metadata: {
accessBundleId: req.params.accessBundleId,
+ accessBundleName,
serviceId: service.id,
name: service.name,
hostPattern: service.hostPattern,
@@ -393,7 +396,7 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
handler: async (req) => {
- const { service } = await server.services.agentVaultAccessBundle.updateService({
+ const { service, accessBundleName } = await server.services.agentVaultAccessBundle.updateService({
projectId: req.internalAgentVaultProjectId,
ctx: actorContext(req),
accessBundleId: req.params.accessBundleId,
@@ -410,6 +413,7 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
// Every field comes off the body, so an absent one means the PATCH did not touch it.
metadata: {
accessBundleId: req.params.accessBundleId,
+ accessBundleName,
serviceId: service.id,
name: req.body.name,
hostPattern: req.body.hostPattern,
@@ -478,7 +482,7 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
handler: async (req) => {
- const service = await server.services.agentVaultAccessBundle.deleteService({
+ const { service, accessBundleName } = await server.services.agentVaultAccessBundle.deleteService({
projectId: req.internalAgentVaultProjectId,
ctx: actorContext(req),
accessBundleId: req.params.accessBundleId,
@@ -493,6 +497,7 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
type: EventType.AGENT_VAULT_SERVICE_DELETE,
metadata: {
accessBundleId: req.params.accessBundleId,
+ accessBundleName,
serviceId: service.id,
name: service.name
}
@@ -554,7 +559,7 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
handler: async (req) => {
- const variable = await server.services.agentVaultAccessBundle.createVariable({
+ const { variable, accessBundleName } = await server.services.agentVaultAccessBundle.createVariable({
projectId: req.internalAgentVaultProjectId,
ctx: actorContext(req),
accessBundleId: req.params.accessBundleId,
@@ -569,6 +574,7 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
type: EventType.AGENT_VAULT_VARIABLE_CREATE,
metadata: {
accessBundleId: req.params.accessBundleId,
+ accessBundleName,
variableId: variable.id,
key: variable.key,
isSecret: variable.isSecret
@@ -607,13 +613,14 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
handler: async (req) => {
- const { variable, previousKey, previousIsSecret } = await server.services.agentVaultAccessBundle.updateVariable({
- projectId: req.internalAgentVaultProjectId,
- ctx: actorContext(req),
- accessBundleId: req.params.accessBundleId,
- variableId: req.params.variableId,
- ...req.body
- });
+ const { variable, previousKey, previousIsSecret, accessBundleName } =
+ await server.services.agentVaultAccessBundle.updateVariable({
+ projectId: req.internalAgentVaultProjectId,
+ ctx: actorContext(req),
+ accessBundleId: req.params.accessBundleId,
+ variableId: req.params.variableId,
+ ...req.body
+ });
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
@@ -623,6 +630,7 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
type: EventType.AGENT_VAULT_VARIABLE_UPDATE,
metadata: {
accessBundleId: req.params.accessBundleId,
+ accessBundleName,
variableId: variable.id,
key: variable.key,
previousKey: previousKey === variable.key ? undefined : previousKey,
@@ -654,7 +662,7 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
handler: async (req) => {
- const variable = await server.services.agentVaultAccessBundle.deleteVariable({
+ const { variable, accessBundleName } = await server.services.agentVaultAccessBundle.deleteVariable({
projectId: req.internalAgentVaultProjectId,
ctx: actorContext(req),
accessBundleId: req.params.accessBundleId,
@@ -667,7 +675,12 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
projectId: req.internalAgentVaultProjectId,
event: {
type: EventType.AGENT_VAULT_VARIABLE_DELETE,
- metadata: { accessBundleId: req.params.accessBundleId, variableId: variable.id, key: variable.key }
+ metadata: {
+ accessBundleId: req.params.accessBundleId,
+ accessBundleName,
+ variableId: variable.id,
+ key: variable.key
+ }
}
});
@@ -692,12 +705,13 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
handler: async (req, reply) => {
- const { variableId, key, value } = await server.services.agentVaultAccessBundle.getVariableValue({
- projectId: req.internalAgentVaultProjectId,
- ctx: actorContext(req),
- accessBundleId: req.params.accessBundleId,
- variableId: req.params.variableId
- });
+ const { variableId, key, value, accessBundleName } =
+ await server.services.agentVaultAccessBundle.getVariableValue({
+ projectId: req.internalAgentVaultProjectId,
+ ctx: actorContext(req),
+ accessBundleId: req.params.accessBundleId,
+ variableId: req.params.variableId
+ });
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
@@ -705,7 +719,7 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
projectId: req.internalAgentVaultProjectId,
event: {
type: EventType.AGENT_VAULT_VARIABLE_VALUE_VIEW,
- metadata: { accessBundleId: req.params.accessBundleId, variableId, key }
+ metadata: { accessBundleId: req.params.accessBundleId, accessBundleName, variableId, key }
}
});
diff --git a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-schemas.ts b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-schemas.ts
index 81d0d4003a..b152afb7d1 100644
--- a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-schemas.ts
+++ b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-schemas.ts
@@ -182,8 +182,7 @@ export const AgentVaultSubstitutionsUpdateSchema = AgentVaultSubstitutionUpdateS
const variableReferenceBase = {
variableId: z.string().uuid().describe(AGENT_VAULT.VARIABLE.variableId),
- key: z.string().describe(AGENT_VAULT.VARIABLE.key),
- isWholeValue: z.boolean().describe(AGENT_VAULT.SERVICE.referenceIsWholeValue)
+ key: z.string().describe(AGENT_VAULT.VARIABLE.key)
};
export const AgentVaultVariableReferenceSchema = z.discriminatedUnion("field", [
diff --git a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts
index 626b502750..8113720533 100644
--- a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts
+++ b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts
@@ -46,7 +46,6 @@ import { getAgentVaultReachability } from "../agent-vault/agent-vault-permission
import {
AGENT_VAULT_MAX_VARIABLES,
findVariableKeys,
- isWholeVariableReference,
toStoredVariableReferences,
toVariableReference
} from "../agent-vault/agent-vault-variable-fns";
@@ -378,7 +377,7 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
const summarizeVariableReference = (
reference: TAgentVaultVariableReferenceWithKey
): TAgentVaultVariableReferenceSummary => {
- const base = { variableId: reference.variableId, key: reference.key, isWholeValue: reference.isWholeValue };
+ const base = { variableId: reference.variableId, key: reference.key };
// The field check constraint guarantees the id that matches the field is set.
switch (reference.field as AgentVaultVariableReferenceField) {
case AgentVaultVariableReferenceField.CustomHeader:
@@ -426,11 +425,15 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
updatedAt: service.updatedAt
});
- const loadTransformations = async (serviceIds: string[], tx?: Knex) => {
+ const loadTransformations = async (
+ serviceIds: string[],
+ tx?: Knex,
+ { withVariableReferences = true }: { withVariableReferences?: boolean } = {}
+ ) => {
const [customHeaders, substitutions, variableReferences] = await Promise.all([
agentVaultServiceCustomHeaderDAL.findByServiceIds(serviceIds, tx),
agentVaultServiceSubstitutionDAL.findByServiceIds(serviceIds, tx),
- agentVaultServiceVariableReferenceDAL.findByServiceIds(serviceIds, tx)
+ withVariableReferences ? agentVaultServiceVariableReferenceDAL.findByServiceIds(serviceIds, tx) : []
]);
return { customHeaders, substitutions, variableReferences };
};
@@ -512,8 +515,7 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
variableId,
field,
customHeaderId: customHeaderId ?? null,
- substitutionId: substitutionId ?? null,
- isWholeValue: isWholeVariableReference(text)
+ substitutionId: substitutionId ?? null
}
];
})
@@ -595,10 +597,18 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
ProjectPermissionAgentVaultAccessBundleActions.Read,
ProjectPermissionSub.AgentVaultAccessBundles
);
+ // Variables are admin only, so a member's services leave variableReferences out. An empty list would claim
+ // they use no variables.
+ const canReadVariables = permission.can(
+ ProjectPermissionAgentVaultAccessBundleActions.Edit,
+ ProjectPermissionSub.AgentVaultAccessBundles
+ );
const services = await agentVaultServiceDAL.findByAccessBundleId(bundle.id);
const { customHeaders, substitutions, variableReferences } = await loadTransformations(
- services.map((service) => service.id)
+ services.map((service) => service.id),
+ undefined,
+ { withVariableReferences: canReadVariables }
);
return {
@@ -607,14 +617,15 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
description: bundle.description ?? null,
createdAt: bundle.createdAt,
updatedAt: bundle.updatedAt,
- services: services.map((service) =>
- projectService(
+ services: services.map((service) => {
+ const projected = projectService(
service,
customHeaders.filter((header) => header.serviceId === service.id),
substitutions.filter((substitution) => substitution.serviceId === service.id),
variableReferences.filter((reference) => reference.serviceId === service.id)
- )
- )
+ );
+ return canReadVariables ? projected : { ...projected, variableReferences: undefined };
+ })
};
};
@@ -869,7 +880,8 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
result.insertedCustomHeaders,
result.insertedSubstitutions,
result.variableReferences
- )
+ ),
+ accessBundleName: bundle.name
};
};
@@ -1173,7 +1185,8 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
result.updatedCustomHeaders,
result.updatedSubstitutions,
result.variableReferences
- )
+ ),
+ accessBundleName: bundle.name
};
};
@@ -1190,7 +1203,10 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
// Read before the delete, since CASCADE takes these rows with the service.
const { customHeaders, substitutions, variableReferences } = await loadTransformations([service.id]);
const deleted = await agentVaultServiceDAL.deleteById(service.id);
- return projectService(deleted, customHeaders, substitutions, variableReferences);
+ return {
+ service: projectService(deleted, customHeaders, substitutions, variableReferences),
+ accessBundleName: bundle.name
+ };
};
type TProjectCipher = Awaited<ReturnType<typeof getProjectCipher>>;
@@ -1286,7 +1302,7 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
});
try {
- return projectVariable(await write(), [], value);
+ return { variable: projectVariable(await write(), [], value), accessBundleName: bundle.name };
} catch (err) {
if (isUniqueViolation(err)) throw new BadRequestError({ message: duplicateVariableKeyMessage(key) });
throw err;
@@ -1351,7 +1367,8 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
return {
variable: projectVariable(updated, serviceIdsUsing(references, updated.id), plainValue),
previousKey: previous.key,
- previousIsSecret: previous.isSecret
+ previousIsSecret: previous.isSecret,
+ accessBundleName: bundle.name
};
};
@@ -1404,7 +1421,7 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
const plainValue = deleted.isSecret
? null
: openVariableValue((await getProjectCipher(rest.projectId)).decryptor, deleted.encryptedValue);
- return projectVariable(deleted, [], plainValue);
+ return { variable: projectVariable(deleted, [], plainValue), accessBundleName: bundle.name };
};
const getVariableValue = async ({ accessBundleId, variableId, ...rest }: TVariableByIdDTO) => {
@@ -1414,7 +1431,12 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
if (!variable) throw new NotFoundError({ message: `Variable with ID '${variableId}' not found` });
const { decryptor } = await getProjectCipher(rest.projectId);
- return { variableId: variable.id, key: variable.key, value: openVariableValue(decryptor, variable.encryptedValue) };
+ return {
+ variableId: variable.id,
+ key: variable.key,
+ value: openVariableValue(decryptor, variable.encryptedValue),
+ accessBundleName: bundle.name
+ };
};
const listMembers = async ({ accessBundleId, search, limit, offset, ...rest }: TListMembersDTO) => {
diff --git a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-types.ts b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-types.ts
index 759d211284..18894acdf1 100644
--- a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-types.ts
+++ b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-types.ts
@@ -22,7 +22,7 @@ export type TAgentVaultCredentialSummary =
| { type: AgentVaultCredentialType.Basic }
| { type: AgentVaultCredentialType.Passthrough };
-export type TAgentVaultVariableReferenceSummary = { variableId: string; key: string; isWholeValue: boolean } & (
+export type TAgentVaultVariableReferenceSummary = { variableId: string; key: string } & (
| { field: AgentVaultVariableReferenceField.CredentialValue | AgentVaultVariableReferenceField.CredentialUsername }
| { field: AgentVaultVariableReferenceField.CustomHeader; customHeaderId: string }
| { field: AgentVaultVariableReferenceField.Substitution; substitutionId: string }
diff --git a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-service-variable-reference-dal.ts b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-service-variable-reference-dal.ts
index bb44dc6a12..02d12920e6 100644
--- a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-service-variable-reference-dal.ts
+++ b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-service-variable-reference-dal.ts
@@ -35,13 +35,15 @@ export const agentVaultServiceVariableReferenceDALFactory = (db: TDbClient) => {
}
};
+ // Reads the primary even without a tx, like the variable list it counts usage for, so a service saved a
+ // moment ago shows as using its variables.
const findByVariableIds = async (
variableIds: string[],
tx?: Knex
): Promise<TAgentVaultServiceVariableReferences[]> => {
if (!variableIds.length) return [];
try {
- return (await (tx || db.replicaNode())(TableName.AgentVaultServiceVariableReference)
+ return (await (tx || db)(TableName.AgentVaultServiceVariableReference)
.whereIn("variableId", variableIds)
.select(
selectAllTableCols(TableName.AgentVaultServiceVariableReference)
diff --git a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-variable-dal.test.ts b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-variable-dal.test.ts
new file mode 100644
index 0000000000..00b36838aa
--- /dev/null
+++ b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-variable-dal.test.ts
@@ -0,0 +1,80 @@
+import { TableName } from "@app/db/schemas";
+
+import { agentVaultVariableDALFactory } from "./agent-vault-variable-dal";
+
+type TRow = { id: string; accessBundleId: string; encryptedValue: Buffer };
+
+const BUNDLE_ID = "0b6f6c1e-5a8d-4c2b-9e7f-3d1a2b4c5d6e";
+const FIRST_ID = "4f1e2d3c-6b5a-4978-8a6b-5c4d3e2f1a0b";
+const SECOND_ID = "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d";
+
+const row = (id: string): TRow => ({ id, accessBundleId: BUNDLE_ID, encryptedValue: Buffer.from(id) });
+
+// One database node: it answers with the rows it holds among the ids asked for, and records each lookup,
+// so a test can tell which node was asked for what.
+const buildNode = (rows: TRow[]) => {
+ const lookups: { table: string; ids: string[]; accessBundleIds: string[] }[] = [];
+ const node = (table: string) => {
+ const lookup = { table, ids: [] as string[], accessBundleIds: [] as string[] };
+ const chain = {
+ whereIn: (column: string, values: string[]) => {
+ if (column === "id") lookup.ids = values;
+ if (column === "accessBundleId") lookup.accessBundleIds = values;
+ return chain;
+ },
+ select: async () => {
+ lookups.push(lookup);
+ return rows.filter(
+ (candidate) => lookup.ids.includes(candidate.id) && lookup.accessBundleIds.includes(candidate.accessBundleId)
+ );
+ }
+ };
+ return chain;
+ };
+ return { node, lookups };
+};
+
+const buildDAL = ({ primaryRows, replicaRows }: { primaryRows: TRow[]; replicaRows: TRow[] }) => {
+ const primary = buildNode(primaryRows);
+ const replica = buildNode(replicaRows);
+ const db = Object.assign(primary.node, { replicaNode: () => replica.node });
+ return { dal: agentVaultVariableDALFactory(db as never), primary, replica };
+};
+
+describe("findValuesForResolve", () => {
+ test("a replica that has every id answers alone", async () => {
+ const { dal, primary, replica } = buildDAL({
+ primaryRows: [row(FIRST_ID), row(SECOND_ID)],
+ replicaRows: [row(FIRST_ID), row(SECOND_ID)]
+ });
+
+ const values = await dal.findValuesForResolve({ variableIds: [FIRST_ID, SECOND_ID], accessBundleIds: [BUNDLE_ID] });
+
+ expect(values.map((value) => value.id)).toEqual([FIRST_ID, SECOND_ID]);
+ expect(replica.lookups).toHaveLength(1);
+ expect(primary.lookups).toEqual([]);
+ });
+
+ test("an id the replica has not caught up on is asked of the primary, alone and still scoped to the bundle", async () => {
+ const { dal, primary } = buildDAL({
+ primaryRows: [row(FIRST_ID), row(SECOND_ID)],
+ replicaRows: [row(FIRST_ID)]
+ });
+
+ const values = await dal.findValuesForResolve({ variableIds: [FIRST_ID, SECOND_ID], accessBundleIds: [BUNDLE_ID] });
+
+ expect(values.map((value) => value.id)).toEqual([FIRST_ID, SECOND_ID]);
+ expect(primary.lookups).toEqual([
+ { table: TableName.AgentVaultVariable, ids: [SECOND_ID], accessBundleIds: [BUNDLE_ID] }
+ ]);
+ });
+
+ test("an id neither node has is left out, for resolve to report", async () => {
+ const { dal, primary } = buildDAL({ primaryRows: [row(FIRST_ID)], replicaRows: [row(FIRST_ID)] });
+
+ const values = await dal.findValuesForResolve({ variableIds: [FIRST_ID, SECOND_ID], accessBundleIds: [BUNDLE_ID] });
+
+ expect(values.map((value) => value.id)).toEqual([FIRST_ID]);
+ expect(primary.lookups).toHaveLength(1);
+ });
+});
diff --git a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-variable-dal.ts b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-variable-dal.ts
index c66065893c..010d09cb30 100644
--- a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-variable-dal.ts
+++ b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-variable-dal.ts
@@ -12,9 +12,11 @@ export type TAgentVaultVariableValueRow = Pick<TAgentVaultVariables, "id" | "acc
export const agentVaultVariableDALFactory = (db: TDbClient) => {
const orm = ormify(db, TableName.AgentVaultVariable);
+ // Reads the primary even without a tx. The service sheet refetches this list the moment it creates a
+ // variable, and a replica that has not caught up would drop the new key and fail the reference to it.
const findByAccessBundleId = async (accessBundleId: string, tx?: Knex): Promise<TAgentVaultVariables[]> => {
try {
- return (await (tx || db.replicaNode())(TableName.AgentVaultVariable)
+ return (await (tx || db)(TableName.AgentVaultVariable)
.where({ accessBundleId })
.orderBy("key", "asc")
.select(selectAllTableCols(TableName.AgentVaultVariable))) as TAgentVaultVariables[];
@@ -36,6 +38,9 @@ export const agentVaultVariableDALFactory = (db: TDbClient) => {
}
};
+ // Resolve is the hot path, so it reads a replica. A variable is always saved before any service that uses it,
+ // but each query picks its own replica, and the one serving this read can trail the one that served the
+ // service. So an id the replica does not have is asked of the primary before resolve gives up on it.
const findValuesForResolve = async ({
variableIds,
accessBundleIds
@@ -44,12 +49,16 @@ export const agentVaultVariableDALFactory = (db: TDbClient) => {
accessBundleIds: string[];
}): Promise<TAgentVaultVariableValueRow[]> => {
if (!variableIds.length || !accessBundleIds.length) return [];
- try {
- return await db
- .replicaNode()(TableName.AgentVaultVariable)
- .whereIn("id", variableIds)
+ const read = async (conn: Knex, ids: string[]): Promise<TAgentVaultVariableValueRow[]> =>
+ conn(TableName.AgentVaultVariable)
+ .whereIn("id", ids)
.whereIn("accessBundleId", accessBundleIds)
.select("id", "accessBundleId", "encryptedValue");
+ try {
+ const rows = await read(db.replicaNode(), variableIds);
+ const found = new Set(rows.map((row) => row.id));
+ const missing = variableIds.filter((id) => !found.has(id));
+ return missing.length ? [...rows, ...(await read(db, missing))] : rows;
} catch (error) {
throw new DatabaseError({ error, name: "Find agent vault variable values" });
}
diff --git a/backend/src/ee/services/agent-vault/CLAUDE.md b/backend/src/ee/services/agent-vault/CLAUDE.md
index 9de7636cdd..4e342db5bd 100644
--- a/backend/src/ee/services/agent-vault/CLAUDE.md
+++ b/backend/src/ee/services/agent-vault/CLAUDE.md
@@ -166,9 +166,13 @@ path decides what a service can reach, so it stays literal.
boundary: a service write maps keys to ids before it seals (`toStoredVariableReferences`), reading the
primary, since a variable created a moment earlier may not be on a replica yet. So a rename is one row.
- `agent_vault_service_variable_references` holds a row per field per variable. It drives Used By, the delete
- refusal, and `isWholeValue`, which is how the sheet shows `{{KEY}}` again for a value that never returns.
- **Resolve does not read it**: it pulls the ids out of the decrypted fields, so a service saved mid-poll can
- never leave the two describing different versions of a field.
+ refusal, and the keys the service sheet lists under a stored value. **Resolve does not read it**: it pulls
+ the ids out of the decrypted fields, so a service saved mid-poll can never leave the two describing
+ different versions of a field.
+- A stored value never comes back in any form, a lone `{{KEY}}` included. The sheet lists the keys a stored
+ field uses under the field and keeps the field masked until it is retyped. Settled: putting a lone
+ reference back in its field made it the one stored field that shows, and left a field mixing text with a
+ reference looking like it used none.
- An update rebuilds the rows of only the values it wrote. An omitted value keeps its sealed text and its
rows, a dropped header or substitution takes its rows through the foreign key, and a new credential type
or pass-through clears both credential fields.
@@ -180,12 +184,15 @@ path decides what a service can reach, so it stays literal.
refused without quoting it, because the text was cut from a secret. Placeholders can't contain double
braces. A variable's own value is sent as is and never expanded again, which is also how a service sends a
literal `{{`.
-- Resolve leaves an id with no variable behind as text and logs it rather than dropping the service, which
- would also drop the service's method and path restrictions. Values saved before variables existed hold no
- id tokens, so they pass through untouched.
-- Admin only, reads included: every variable route checks `Edit` on access bundles, which a member lacks.
- Every value is sealed; `isSecret` only decides whether the list returns it. The value route is a GET with
- no-store headers and one audit event per read.
+- Resolve reads variable values on a replica, then asks the primary for any id the replica lacks, since each
+ query can land on a different replica. An id with no variable behind it on either stays as text and is
+ logged rather than dropping the service, which would also drop the service's method and path restrictions.
+ Values saved before variables existed hold no id tokens, so they pass through untouched.
+- Admin only, reads included: every variable route checks `Edit` on access bundles, which a member lacks,
+ and the bundle read gives a member its services without `variableReferences` (left out, not empty, since
+ an empty list would claim they use none). Every value is sealed;
+ `isSecret` only decides whether the list returns it. The value route is a GET with no-store headers and
+ one audit event per read.
## Credentials at rest
diff --git a/backend/src/ee/services/agent-vault/agent-vault-variable-fns.test.ts b/backend/src/ee/services/agent-vault/agent-vault-variable-fns.test.ts
index bcde3e45d3..a0b5cee056 100644
--- a/backend/src/ee/services/agent-vault/agent-vault-variable-fns.test.ts
+++ b/backend/src/ee/services/agent-vault/agent-vault-variable-fns.test.ts
@@ -6,7 +6,6 @@ import {
findVariableKeys,
hasMalformedVariableReference,
isVariableKey,
- isWholeVariableReference,
toStoredVariableReferences
} from "./agent-vault-variable-fns";
@@ -59,18 +58,6 @@ describe("agent vault variable references", () => {
});
});
- describe("whole references", () => {
- it.each([
- ["{{A}}", true],
- ["{{A}} ", false],
- ["Bearer {{A}}", false],
- ["{{A}}{{B}}", false],
- ["{{a}}", false]
- ])("%s is whole: %s", (text, expected) => {
- expect(isWholeVariableReference(text)).toBe(expected);
- });
- });
-
describe("storing", () => {
const idOfKey = new Map([
["GITHUB_TOKEN", GITHUB_ID],
diff --git a/backend/src/ee/services/agent-vault/agent-vault-variable-fns.ts b/backend/src/ee/services/agent-vault/agent-vault-variable-fns.ts
index 74157519d9..8aaadce2c0 100644
--- a/backend/src/ee/services/agent-vault/agent-vault-variable-fns.ts
+++ b/backend/src/ee/services/agent-vault/agent-vault-variable-fns.ts
@@ -15,7 +15,6 @@ export const AGENT_VAULT_MALFORMED_REFERENCE_MESSAGE = `Double braces are reserv
// Every {{...}} counts as a reference, so a mistyped one fails the save instead of reaching a real host as
// literal text.
const REFERENCE_RE = new RE2(/\{\{([^{}]*)\}\}/g);
-const WHOLE_REFERENCE_RE = new RE2(/^\{\{[A-Z][A-Z0-9_]*\}\}$/);
const STORED_REFERENCE_RE = new RE2(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/);
export const toVariableReference = (key: string) => `{{${key}}}`;
@@ -31,9 +30,6 @@ export const findVariableKeys = (text: string) => [
...new Set(findReferenceTokens(text).filter((token) => isVariableKey(token)))
];
-/** A value that is one reference and nothing else holds no secret, so it can be returned on read. */
-export const isWholeVariableReference = (text: string) => WHOLE_REFERENCE_RE.test(text);
-
/**
* Sealed text names a variable by its id, not its key. The key form exists only at the API boundary, so a
* rename touches one row, and resolve can never read a field and a key from either side of one.
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 6113f48991..e8fe867ad9 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -6338,6 +6338,7 @@ interface AgentVaultServiceCreateEvent {
type: EventType.AGENT_VAULT_SERVICE_CREATE;
metadata: {
accessBundleId: string;
+ accessBundleName: string;
serviceId: string;
name: string;
hostPattern: string;
@@ -6357,6 +6358,7 @@ interface AgentVaultServiceUpdateEvent {
type: EventType.AGENT_VAULT_SERVICE_UPDATE;
metadata: {
accessBundleId: string;
+ accessBundleName: string;
serviceId: string;
name?: string;
hostPattern?: string;
@@ -6379,6 +6381,7 @@ interface AgentVaultServiceDeleteEvent {
type: EventType.AGENT_VAULT_SERVICE_DELETE;
metadata: {
accessBundleId: string;
+ accessBundleName: string;
serviceId: string;
name: string;
};
@@ -6389,6 +6392,7 @@ interface AgentVaultVariableCreateEvent {
type: EventType.AGENT_VAULT_VARIABLE_CREATE;
metadata: {
accessBundleId: string;
+ accessBundleName: string;
variableId: string;
key: string;
isSecret: boolean;
@@ -6399,6 +6403,7 @@ interface AgentVaultVariableUpdateEvent {
type: EventType.AGENT_VAULT_VARIABLE_UPDATE;
metadata: {
accessBundleId: string;
+ accessBundleName: string;
variableId: string;
key: string;
// The previous* fields are present only when the update changed them.
@@ -6413,6 +6418,7 @@ interface AgentVaultVariableDeleteEvent {
type: EventType.AGENT_VAULT_VARIABLE_DELETE;
metadata: {
accessBundleId: string;
+ accessBundleName: string;
variableId: string;
key: string;
};
@@ -6422,6 +6428,7 @@ interface AgentVaultVariableValueViewEvent {
type: EventType.AGENT_VAULT_VARIABLE_VALUE_VIEW;
metadata: {
accessBundleId: string;
+ accessBundleName: string;
variableId: string;
key: string;
};
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index c87e5be6e0..e90e1cf9a6 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -4297,12 +4297,12 @@ export const AGENT_VAULT = {
surfaces: "Where in the request to look for the placeholder: path, query, header or body.",
substitutionValue: "The real value the placeholder is replaced with. Never returned once saved.",
updateSubstitutionValue: "The real value the placeholder is replaced with. Omit to keep the value already stored.",
- variableReferences: "The variables this service's credential, custom header values and substitution values use.",
+ variableReferences:
+ "The variables this service's credential, custom header values and substitution values use. Left out for an Agent Vault member, since only admins can see variables.",
referenceField:
"Which value uses the variable: credential-value (a bearer token or a basic password), credential-username, custom-header or substitution.",
referenceCustomHeaderId: "The custom header whose value uses the variable.",
- referenceSubstitutionId: "The substitution whose value uses the variable.",
- referenceIsWholeValue: "Whether the value is this variable and nothing else."
+ referenceSubstitutionId: "The substitution whose value uses the variable."
},
VARIABLE: {
variableId: "The ID of the variable.",
diff --git a/docs/documentation/platform/agent-vault/variables.mdx b/docs/documentation/platform/agent-vault/variables.mdx
index 1f7c6f4fa2..5f341dd43e 100644
--- a/docs/documentation/platform/agent-vault/variables.mdx
+++ b/docs/documentation/platform/agent-vault/variables.mdx
@@ -61,7 +61,7 @@ The **Sends** preview shows each reference in the headers the proxy attaches. If
Variables don't work in any other field, such as a host pattern, a path, a header name or prefix, or a substitution placeholder.
-When you edit a service later, Infisical shows the reference in each field that holds only a reference. If a field mixes a reference with other text, the field stays hidden, like any other stored credential.
+When you edit a service later, each value you saved stays hidden, like any other stored credential. If a value uses variables, Infisical lists the variables under the field. To change a value, enter the whole value again, including any references you want to keep.
## Change or delete a variable
diff --git a/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx b/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx
index 3706a9e17c..6cf2cf53bc 100644
--- a/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx
+++ b/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useLayoutEffect, useRef, useState } from "react";
+import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
import { Controller, ControllerRenderProps, useFormContext } from "react-hook-form";
import { EyeIcon, EyeOffIcon, XIcon } from "lucide-react";
@@ -8,6 +8,7 @@ import {
AlertTitle,
Field,
FieldContent,
+ FieldDescription,
FieldError,
FieldLabel,
Input,
@@ -22,7 +23,7 @@ import {
SelectValue
} from "@app/components/v3";
import { cn } from "@app/components/v3/utils";
-import { isVariableReferenceOnly } from "@app/helpers/agentVaultVariables";
+import { isVariableReferenceOnly, toVariableReference } from "@app/helpers/agentVaultVariables";
import { AgentVaultCredentialType } from "@app/hooks/api/agentVault";
import { SendsPreview } from "./SendsPreview";
@@ -31,6 +32,7 @@ import { useServiceVariables } from "./ServiceVariablesContext";
import {
ReferenceHighlights,
useVariableAutocomplete,
+ VariableChip,
VariableSuggestions
} from "./VariableReferenceInput";
@@ -67,7 +69,7 @@ export const SecretInput = <TName extends SecretName>({
isUntouched,
hasStoredSecret,
canBeCleared,
- storedValue
+ storedKeys
}: {
field: ControllerRenderProps<TServiceForm, TName>;
label: string;
@@ -81,12 +83,13 @@ export const SecretInput = <TName extends SecretName>({
hasStoredSecret: boolean;
/** Whether empty is a value this field can hold. Only such a field offers the clear button. */
canBeCleared: boolean;
- /** A stored value that is one variable reference, which the field shows in place of the sentinel. */
- storedValue?: string;
+ /** The keys of the variables the stored value uses, listed under the field while that value is kept. */
+ storedKeys?: string[];
}) => {
const { setFocus } = useFormContext<TServiceForm>();
const [isVisible, setIsVisible] = useState(false);
const [isCleared, setIsCleared] = useState(false);
+ const descriptionId = useId();
const inputRef = useRef<HTMLInputElement | null>(null);
const overlayRef = useRef<HTMLDivElement | null>(null);
// Where the caret goes after a suggestion is picked. The value is set first, and setting it moves the
@@ -98,6 +101,9 @@ export const SecretInput = <TName extends SecretName>({
// The sentinel must never render as text, and a lone reference holds no secret.
const isShown = (isVisible && !isUntouched) || isReferenceOnly;
const isHighlighted = isShown && value.includes("{{");
+ // Focusing only empties the box: left empty, it gets the stored value back on blur.
+ const isStoredValueKept = isUntouched || (hasStoredSecret && !value && !isCleared);
+ const hasStoredKeys = Boolean(storedKeys?.length);
const autocomplete = useVariableAutocomplete({
inputRef,
@@ -137,79 +143,109 @@ export const SecretInput = <TName extends SecretName>({
const lowerLabel = label.toLowerCase();
return (
- <VariableSuggestions autocomplete={autocomplete}>
- <InputGroup>
- <div className="relative flex min-w-0 flex-1 items-center self-stretch">
- {isHighlighted && <ReferenceHighlights value={value} overlayRef={overlayRef} />}
- <InputGroupInput
- {...field}
- ref={(element) => {
- field.ref(element);
- inputRef.current = element;
- }}
- aria-label={ariaLabel}
- role="combobox"
- aria-autocomplete="list"
- aria-expanded={autocomplete.isOpen}
- aria-controls={autocomplete.isOpen ? autocomplete.listId : undefined}
- aria-activedescendant={autocomplete.activeOptionId}
- type={isShown ? "text" : "password"}
- className={cn(isHighlighted && "text-transparent caret-foreground")}
- onChange={(event) => {
- setIsCleared(false);
- // An emptied field masks again, since what is typed next may be a real secret.
- if (!event.target.value) setIsVisible(false);
- field.onChange(event);
- autocomplete.refresh();
- }}
- onKeyDown={autocomplete.onKeyDown}
- onKeyUp={(event) => {
- if (!SUGGESTION_KEYS.has(event.key)) autocomplete.refresh();
- }}
- onClick={autocomplete.refresh}
- onSelect={syncOverlay}
- onScroll={syncOverlay}
- onFocus={() => {
- if (isUntouched) field.onChange("");
- }}
- // Empty reads the same whether the secret was meant to go or the field was only clicked into,
- // so the clear button is made the one way to say it and passing through loses nothing.
- onBlur={() => {
- autocomplete.close();
- if (hasStoredSecret && !field.value && !isCleared) {
- field.onChange(storedValue ?? UNCHANGED_SECRET);
- }
- field.onBlur();
- }}
- placeholder={placeholder}
- isError={isError}
- />
- </div>
- <InputGroupAddon align="inline-end">
- {canBeCleared && hasStoredSecret && (
- <InputGroupButton
- isDisabled={isCleared}
- aria-label={`Clear ${lowerLabel}`}
- onClick={() => {
- setIsCleared(true);
- field.onChange("");
- setFocus(field.name);
+ <>
+ <VariableSuggestions autocomplete={autocomplete}>
+ <InputGroup>
+ <div className="relative flex min-w-0 flex-1 items-center self-stretch">
+ {isHighlighted && <ReferenceHighlights value={value} overlayRef={overlayRef} />}
+ <InputGroupInput
+ {...field}
+ ref={(element) => {
+ field.ref(element);
+ inputRef.current = element;
+ }}
+ aria-label={ariaLabel}
+ aria-describedby={hasStoredKeys && isStoredValueKept ? descriptionId : undefined}
+ role="combobox"
+ aria-autocomplete="list"
+ aria-expanded={autocomplete.isOpen}
+ aria-controls={autocomplete.isOpen ? autocomplete.listId : undefined}
+ aria-activedescendant={autocomplete.activeOptionId}
+ // Not type="password": that opens the browser's and password managers' autofill menus over
+ // the variable list, so the field is masked in CSS and each manager is told to skip it.
+ className={cn(
+ !isShown && "[-webkit-text-security:disc]",
+ isHighlighted && "text-transparent caret-foreground"
+ )}
+ autoComplete="off"
+ autoCorrect="off"
+ autoCapitalize="off"
+ spellCheck={false}
+ data-form-type="other"
+ data-1p-ignore
+ data-lpignore="true"
+ data-bwignore
+ onChange={(event) => {
+ setIsCleared(false);
+ // An emptied field masks again, since what is typed next may be a real secret.
+ if (!event.target.value) setIsVisible(false);
+ field.onChange(event);
+ autocomplete.refresh();
+ }}
+ onKeyDown={autocomplete.onKeyDown}
+ onKeyUp={(event) => {
+ if (!SUGGESTION_KEYS.has(event.key)) autocomplete.refresh();
+ }}
+ onClick={autocomplete.refresh}
+ onSelect={syncOverlay}
+ onScroll={syncOverlay}
+ onFocus={() => {
+ if (isUntouched) field.onChange("");
}}
+ // Empty reads the same whether the secret was meant to go or the field was only clicked into,
+ // so the clear button is made the one way to say it and passing through loses nothing.
+ onBlur={() => {
+ autocomplete.close();
+ if (hasStoredSecret && !field.value && !isCleared) field.onChange(UNCHANGED_SECRET);
+ field.onBlur();
+ }}
+ placeholder={placeholder}
+ isError={isError}
+ />
+ </div>
+ <InputGroupAddon align="inline-end">
+ {canBeCleared && hasStoredSecret && (
+ <InputGroupButton
+ isDisabled={isCleared}
+ aria-label={`Clear ${lowerLabel}`}
+ onClick={() => {
+ setIsCleared(true);
+ field.onChange("");
+ setFocus(field.name);
+ }}
+ >
+ <XIcon />
+ </InputGroupButton>
+ )}
+ <InputGroupButton
+ // A stored credential is never returned, so until it is replaced there is nothing to reveal.
+ isDisabled={isUntouched || !field.value || isReferenceOnly}
+ aria-label={`${isVisible ? "Hide" : "Show"} ${lowerLabel}`}
+ onClick={() => setIsVisible((prev) => !prev)}
>
- <XIcon />
+ {isVisible ? <EyeOffIcon /> : <EyeIcon />}
</InputGroupButton>
- )}
- <InputGroupButton
- // A stored credential is never returned, so until it is replaced there is nothing to reveal.
- isDisabled={isUntouched || !field.value || isReferenceOnly}
- aria-label={`${isVisible ? "Hide" : "Show"} ${lowerLabel}`}
- onClick={() => setIsVisible((prev) => !prev)}
- >
- {isVisible ? <EyeOffIcon /> : <EyeIcon />}
- </InputGroupButton>
- </InputGroupAddon>
- </InputGroup>
- </VariableSuggestions>
+ </InputGroupAddon>
+ </InputGroup>
+ </VariableSuggestions>
+ {hasStoredKeys && (
+ <FieldDescription
+ id={descriptionId}
+ isOpen={isStoredValueKept}
+ className="flex flex-wrap items-center gap-1"
+ >
+ Current value uses
+ {storedKeys?.map((key) => (
+ <VariableChip
+ key={key}
+ reference={toVariableReference(key)}
+ isKnown
+ className="font-mono"
+ />
+ ))}
+ </FieldDescription>
+ )}
+ </>
);
};
@@ -219,7 +255,7 @@ type Props = {
export const CredentialFields = ({ storedType }: Props) => {
const { control, watch, setValue } = useFormContext<TServiceForm>();
- const { seeded } = useServiceVariables();
+ const { storedKeys } = useServiceVariables();
const credentialType = watch("credentialType");
const secret = watch("secret");
const username = watch("username");
@@ -254,7 +290,7 @@ export const CredentialFields = ({ storedType }: Props) => {
isUntouched={isUntouched}
hasStoredSecret={hasStoredSecret}
canBeCleared={isBasic}
- storedValue={hasStoredSecret ? seeded.secret : undefined}
+ storedKeys={hasStoredSecret ? storedKeys.secret : undefined}
/>
<FieldError>{fieldState.error?.message}</FieldError>
</FieldContent>
@@ -342,7 +378,7 @@ export const CredentialFields = ({ storedType }: Props) => {
isUntouched={isUsernameUntouched}
hasStoredSecret={hasStoredSecret}
canBeCleared
- storedValue={hasStoredSecret ? seeded.username : undefined}
+ storedKeys={hasStoredSecret ? storedKeys.username : undefined}
/>
<FieldError>{fieldState.error?.message}</FieldError>
</FieldContent>
diff --git a/frontend/src/components/agent-vault/service-sheet/ReviewFields.tsx b/frontend/src/components/agent-vault/service-sheet/ReviewFields.tsx
index 79b0c53bff..922a641d9f 100644
--- a/frontend/src/components/agent-vault/service-sheet/ReviewFields.tsx
+++ b/frontend/src/components/agent-vault/service-sheet/ReviewFields.tsx
@@ -18,7 +18,6 @@ import {
TServiceForm,
UNCHANGED_SECRET
} from "./serviceSchema";
-import { useServiceVariables } from "./ServiceVariablesContext";
const MASK = "\u2022".repeat(8);
@@ -40,7 +39,6 @@ type Props = {
export const ReviewFields = ({ isUpdate }: Props) => {
const { watch } = useFormContext<TServiceForm>();
- const { seeded } = useServiceVariables();
const form = watch();
const isBasic = form.credentialType === AgentVaultCredentialType.Basic;
@@ -61,11 +59,9 @@ export const ReviewFields = ({ isUpdate }: Props) => {
: ""
]);
- const outcome = (value: string | undefined, canClear: boolean, seededValue?: string) => {
+ const outcome = (value: string | undefined, canClear: boolean) => {
if (!isUpdate) return value ? "Set" : "None";
- if (value === UNCHANGED_SECRET || (seededValue !== undefined && value === seededValue)) {
- return "Unchanged";
- }
+ if (value === UNCHANGED_SECRET) return "Unchanged";
if (value) return "Replaced";
return canClear ? "Cleared" : "Unchanged";
};
@@ -114,13 +110,13 @@ export const ReviewFields = ({ isUpdate }: Props) => {
{isBasic && (
<Detail>
<DetailLabel>Username</DetailLabel>
- <DetailValue>{outcome(form.username, true, seeded.username)}</DetailValue>
+ <DetailValue>{outcome(form.username, true)}</DetailValue>
</Detail>
)}
{form.credentialType !== AgentVaultCredentialType.Passthrough && (
<Detail>
<DetailLabel>{secretLabel}</DetailLabel>
- <DetailValue>{outcome(form.secret, isBasic, seeded.secret)}</DetailValue>
+ <DetailValue>{outcome(form.secret, isBasic)}</DetailValue>
</Detail>
)}
</div>
diff --git a/frontend/src/components/agent-vault/service-sheet/ServiceSheet.tsx b/frontend/src/components/agent-vault/service-sheet/ServiceSheet.tsx
index f6829648a6..52bdebec85 100644
--- a/frontend/src/components/agent-vault/service-sheet/ServiceSheet.tsx
+++ b/frontend/src/components/agent-vault/service-sheet/ServiceSheet.tsx
@@ -21,7 +21,6 @@ import {
import { ProviderIcon } from "@app/components/v3/platform/ProviderIcon";
import { hostError } from "@app/helpers/agentVaultHostPattern";
import { AgentVaultTemplate } from "@app/helpers/agentVaultTemplates";
-import { toVariableReference } from "@app/helpers/agentVaultVariables";
import { useDiscardChangesGuard, useWizardSteps } from "@app/hooks";
import {
AgentVaultCredentialType,
@@ -53,7 +52,7 @@ import {
TServiceForm,
UNCHANGED_SECRET
} from "./serviceSchema";
-import { NO_SEEDED_REFERENCES, ServiceVariablesContext } from "./ServiceVariablesContext";
+import { NO_STORED_KEYS, ServiceVariablesContext } from "./ServiceVariablesContext";
import { SERVICE_DOCS_URL, SERVICE_STEPS } from "./stepMeta";
import { ADVANCED_ITEM, TransformationsFields } from "./TransformationsFields";
@@ -80,31 +79,25 @@ type Props = {
service?: TAgentVaultService | null;
};
-// A stored value that is one reference and nothing else holds no secret, so it can go back in its field.
-const seedReferences = (service?: TAgentVaultService | null) => {
- if (!service) return NO_SEEDED_REFERENCES;
+const storedVariableKeys = (service?: TAgentVaultService | null) => {
+ const references = service?.variableReferences;
+ if (!service || !references?.length) return NO_STORED_KEYS;
- const whole = service.variableReferences.filter((reference) => reference.isWholeValue);
- const referenceWhere = (match: (reference: TAgentVaultVariableReference) => boolean) => {
- const reference = whole.find(match);
- return reference ? toVariableReference(reference.key) : undefined;
- };
- const byRow = <TRow extends { id: string }>(
- rows: TRow[],
+ const keysWhere = (match: (reference: TAgentVaultVariableReference) => boolean) =>
+ references.filter(match).map((reference) => reference.key);
+ const byRow = (
+ rows: { id: string }[],
idOf: (r: TAgentVaultVariableReference) => string | null
) =>
Object.fromEntries(
- rows.flatMap((row) => {
- const reference = referenceWhere((candidate) => idOf(candidate) === row.id);
- return reference ? [[row.id, reference]] : [];
- })
+ rows.map((row) => [row.id, keysWhere((reference) => idOf(reference) === row.id)])
);
return {
- secret: referenceWhere(
+ secret: keysWhere(
(reference) => reference.field === AgentVaultVariableReferenceField.CredentialValue
),
- username: referenceWhere(
+ username: keysWhere(
(reference) => reference.field === AgentVaultVariableReferenceField.CredentialUsername
),
customHeaders: byRow(service.customHeaders, (reference) =>
@@ -132,7 +125,7 @@ export const ServiceSheet = ({ isOpen, onOpenChange, accessBundleId, service }:
const { data: variables } = useListAgentVaultVariables(accessBundleId, isOpen);
const variableKeys = useMemo(() => variables?.map((variable) => variable.key), [variables]);
- const seeded = useMemo(() => seedReferences(service), [service]);
+ const storedKeys = useMemo(() => storedVariableKeys(service), [service]);
// One dialog for every field. The request settles once the dialog has closed, not when the variable is
// saved: until then the dialog's focus trap would pull focus back from the field that asked.
const [newVariableKey, setNewVariableKey] = useState<string | null>(null);
@@ -151,8 +144,8 @@ export const ServiceSheet = ({ isOpen, onOpenChange, accessBundleId, service }:
);
const serviceVariables = useMemo(
- () => ({ variables, seeded, requestVariable }),
- [variables, seeded, requestVariable]
+ () => ({ variables, storedKeys, requestVariable }),
+ [variables, storedKeys, requestVariable]
);
const [template, setTemplate] = useState<AgentVaultTemplate | null>(null);
@@ -239,35 +232,28 @@ export const ServiceSheet = ({ isOpen, onOpenChange, accessBundleId, service }:
: "Authorization",
headerPrefix:
credential.type === AgentVaultCredentialType.Bearer ? credential.headerPrefix : "Bearer",
- username:
- credential.type === AgentVaultCredentialType.Basic
- ? (seeded.username ?? UNCHANGED_SECRET)
- : undefined,
- secret:
- credential.type === AgentVaultCredentialType.Passthrough
- ? ""
- : (seeded.secret ?? UNCHANGED_SECRET),
+ username: credential.type === AgentVaultCredentialType.Basic ? UNCHANGED_SECRET : undefined,
+ secret: credential.type === AgentVaultCredentialType.Passthrough ? "" : UNCHANGED_SECRET,
methods: service.allowedMethods ?? [...HTTP_METHODS],
pathPrefixes: service.allowedPathPrefixes ?? [],
- // The stored values never come back, so each row carries the sentinel until it is retyped,
- // unless its value is a lone variable reference.
+ // The stored values never come back, so each row carries the sentinel until it is retyped.
customHeaders: service.customHeaders.map((header) => ({
id: header.id,
name: header.name,
prefix: header.prefix,
- value: seeded.customHeaders[header.id] ?? UNCHANGED_SECRET
+ value: UNCHANGED_SECRET
})),
substitutions: service.substitutions.map((substitution) => ({
id: substitution.id,
placeholder: substitution.placeholder,
surfaces: substitution.surfaces,
- value: seeded.substitutions[substitution.id] ?? UNCHANGED_SECRET
+ value: UNCHANGED_SECRET
}))
});
} else {
reset(BLANK_SERVICE_FORM);
}
- }, [isOpen, service, seeded, isUpdate, reset, setStep]);
+ }, [isOpen, service, isUpdate, reset, setStep]);
const handleTemplatePicked = (picked: AgentVaultTemplate | null) => {
setTemplate(picked);
@@ -313,24 +299,16 @@ export const ServiceSheet = ({ isOpen, onOpenChange, accessBundleId, service }:
};
};
- // A seeded reference left as it was is omitted like the sentinel, so a save neither re-seals it nor
- // records it as replaced. Not across a type change, where the stored secret no longer applies.
- const isKept = (value: string | undefined, seededValue: string | undefined) =>
- value === UNCHANGED_SECRET || (seededValue !== undefined && value === seededValue);
-
const buildCredentialPatch = (data: TServiceForm) => {
if (data.credentialType === AgentVaultCredentialType.Passthrough) {
return { type: AgentVaultCredentialType.Passthrough as const };
}
- const isSameType = service?.credential.type === data.credentialType;
- const untouched = isKept(data.secret, isSameType ? seeded.secret : undefined);
+ const untouched = data.secret === UNCHANGED_SECRET;
if (data.credentialType === AgentVaultCredentialType.Basic) {
return {
type: AgentVaultCredentialType.Basic as const,
- username: isKept(data.username, isSameType ? seeded.username : undefined)
- ? undefined
- : (data.username ?? ""),
+ username: data.username === UNCHANGED_SECRET ? undefined : (data.username ?? ""),
password: untouched ? undefined : (data.secret ?? "")
};
}
@@ -352,20 +330,13 @@ export const ServiceSheet = ({ isOpen, onOpenChange, accessBundleId, service }:
...(header.id ? { id: header.id } : {}),
name: header.name,
prefix: header.prefix,
- ...(isKept(header.value, header.id ? seeded.customHeaders[header.id] : undefined)
- ? {}
- : { value: header.value })
+ ...(header.value === UNCHANGED_SECRET ? {} : { value: header.value })
})),
substitutions: data.substitutions.map((substitution) => ({
...(substitution.id ? { id: substitution.id } : {}),
placeholder: substitution.placeholder,
surfaces: substitution.surfaces,
- ...(isKept(
- substitution.value,
- substitution.id ? seeded.substitutions[substitution.id] : undefined
- )
- ? {}
- : { value: substitution.value })
+ ...(substitution.value === UNCHANGED_SECRET ? {} : { value: substitution.value })
}))
});
@@ -591,11 +562,7 @@ export const ServiceSheet = ({ isOpen, onOpenChange, accessBundleId, service }:
</div>
</ServiceVariablesContext.Provider>
)}
- {current.step === ServiceStep.Review && (
- <ServiceVariablesContext.Provider value={serviceVariables}>
- <ReviewFields isUpdate={isUpdate} />
- </ServiceVariablesContext.Provider>
- )}
+ {current.step === ServiceStep.Review && <ReviewFields isUpdate={isUpdate} />}
</div>
<aside className="hidden w-80 shrink-0 flex-col gap-4 overflow-y-auto border-l border-border px-6 py-6 lg:flex">
diff --git a/frontend/src/components/agent-vault/service-sheet/ServiceVariablesContext.ts b/frontend/src/components/agent-vault/service-sheet/ServiceVariablesContext.ts
index 928d4767b9..bc23ef98d7 100644
--- a/frontend/src/components/agent-vault/service-sheet/ServiceVariablesContext.ts
+++ b/frontend/src/components/agent-vault/service-sheet/ServiceVariablesContext.ts
@@ -5,24 +5,26 @@ import { TAgentVaultVariable } from "@app/hooks/api/agentVault/types";
type TServiceVariables = {
/** Undefined while the list loads, when no key can be called unknown yet. */
variables?: TAgentVaultVariable[];
- /** The stored values that are one reference and nothing else, by field, so they can be shown again. */
- seeded: {
- secret?: string;
- username?: string;
- customHeaders: Record<string, string>;
- substitutions: Record<string, string>;
+ /** The keys each stored value uses, by field. The values never return, so the fields list these. */
+ storedKeys: {
+ secret: string[];
+ username: string[];
+ customHeaders: Record<string, string[]>;
+ substitutions: Record<string, string[]>;
};
/** Opens the new-variable dialog on top of the sheet. Resolves to null if it is dismissed. */
requestVariable?: (key: string) => Promise<TAgentVaultVariable | null>;
};
-export const NO_SEEDED_REFERENCES: TServiceVariables["seeded"] = {
+export const NO_STORED_KEYS: TServiceVariables["storedKeys"] = {
+ secret: [],
+ username: [],
customHeaders: {},
substitutions: {}
};
export const ServiceVariablesContext = createContext<TServiceVariables>({
- seeded: NO_SEEDED_REFERENCES
+ storedKeys: NO_STORED_KEYS
});
export const useServiceVariables = () => useContext(ServiceVariablesContext);
diff --git a/frontend/src/components/agent-vault/service-sheet/TransformationsFields.tsx b/frontend/src/components/agent-vault/service-sheet/TransformationsFields.tsx
index a64e7820e0..715fdb7cf3 100644
--- a/frontend/src/components/agent-vault/service-sheet/TransformationsFields.tsx
+++ b/frontend/src/components/agent-vault/service-sheet/TransformationsFields.tsx
@@ -76,7 +76,7 @@ export const TransformationsFields = ({
onOpenChange: (item: string) => void;
}) => {
const { control, getValues } = useFormContext<TServiceForm>();
- const { seeded } = useServiceVariables();
+ const { storedKeys } = useServiceVariables();
const customHeaders = useFieldArray({ control, name: "customHeaders" });
const substitutions = useFieldArray({ control, name: "substitutions" });
@@ -155,8 +155,10 @@ export const TransformationsFields = ({
isUntouched={field.value === UNCHANGED_SECRET}
hasStoredSecret={Boolean(getValues(`customHeaders.${index}.id`))}
canBeCleared={false}
- storedValue={
- seeded.customHeaders[getValues(`customHeaders.${index}.id`) ?? ""]
+ storedKeys={
+ storedKeys.customHeaders[
+ getValues(`customHeaders.${index}.id`) ?? ""
+ ]
}
/>
<FieldError>{fieldState.error?.message}</FieldError>
@@ -253,8 +255,10 @@ export const TransformationsFields = ({
isUntouched={field.value === UNCHANGED_SECRET}
hasStoredSecret={Boolean(getValues(`substitutions.${index}.id`))}
canBeCleared={false}
- storedValue={
- seeded.substitutions[getValues(`substitutions.${index}.id`) ?? ""]
+ storedKeys={
+ storedKeys.substitutions[
+ getValues(`substitutions.${index}.id`) ?? ""
+ ]
}
/>
<FieldError>{fieldState.error?.message}</FieldError>
diff --git a/frontend/src/components/agent-vault/service-sheet/VariableReferenceInput.tsx b/frontend/src/components/agent-vault/service-sheet/VariableReferenceInput.tsx
index 5658139e1d..282165e016 100644
--- a/frontend/src/components/agent-vault/service-sheet/VariableReferenceInput.tsx
+++ b/frontend/src/components/agent-vault/service-sheet/VariableReferenceInput.tsx
@@ -34,16 +34,22 @@ export const useKnownVariableKeys = () => {
const chipTone = (isKnown: boolean) =>
isKnown
- ? "bg-product-av/15 text-product-av ring-product-av/30"
- : "bg-danger/15 text-danger ring-danger/40";
+ ? "bg-foreground/10 text-label"
+ : "bg-danger/15 text-danger ring-1 ring-danger/40 ring-inset";
-export const VariableChip = ({ reference, isKnown }: { reference: string; isKnown: boolean }) => (
- <span className={cn("rounded-[3px] px-1 ring-1 ring-inset", chipTone(isKnown))}>{reference}</span>
-);
+export const VariableChip = ({
+ reference,
+ isKnown,
+ className
+}: {
+ reference: string;
+ isKnown: boolean;
+ className?: string;
+}) => <span className={cn("rounded-[3px] px-1", chipTone(isKnown), className)}>{reference}</span>;
/**
- * The value drawn behind a transparent input, with each reference marked. Marks add colour and a ring
- * but no padding, so every character sits exactly where the input's own would.
+ * The value drawn behind a transparent input, with each reference marked. Marks add colour but no
+ * padding, so every character sits exactly where the input's own would.
*/
export const ReferenceHighlights = ({
value,
@@ -69,7 +75,7 @@ export const ReferenceHighlights = ({
// eslint-disable-next-line react/no-array-index-key
key={index}
className={cn(
- "rounded-[3px] ring-1 ring-inset",
+ "rounded-[3px]",
chipTone(segment.isValid && (!knownKeys || knownKeys.has(segment.key)))
)}
>
@@ -244,78 +250,82 @@ export const VariableSuggestions = ({
<PopoverAnchor asChild>
<div ref={anchorRef}>{children}</div>
</PopoverAnchor>
- <PopoverContent
- align="start"
- className="w-(--radix-popover-trigger-width) min-w-56 p-1"
- // Focus stays in the field the whole time: the list is driven from its keyboard.
- onOpenAutoFocus={(event) => event.preventDefault()}
- onCloseAutoFocus={(event) => event.preventDefault()}
- onInteractOutside={(event) => {
- if (anchorRef.current?.contains(event.target as Node)) event.preventDefault();
- }}
- >
- {suggestions.length > 0 ? (
- <ul
- id={listId}
- role="listbox"
- aria-label="Variables"
- className="max-h-60 overflow-y-auto"
- >
- {suggestions.map((suggestion, index) => (
- <Fragment key={suggestion.type === "variable" ? suggestion.variable.id : "create"}>
- {suggestion.type === "create" && index > 0 && (
- <li role="presentation" className="-mx-1 my-1 h-px bg-border" />
- )}
- {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
- <li
- id={optionId(index)}
- role="option"
- aria-selected={index === activeIndex}
- className={cn(
- "flex cursor-pointer items-center gap-3 rounded-sm px-2 py-1.5",
- index === activeIndex && "bg-container-hover"
+ {/* Unmounted rather than faded out: once it closes nothing is matched, so a fade would show the
+ empty message where the list was. */}
+ {isOpen && (
+ <PopoverContent
+ align="start"
+ className="w-[var(--radix-popover-trigger-width)] min-w-56 p-1"
+ // Focus stays in the field the whole time: the list is driven from its keyboard.
+ onOpenAutoFocus={(event) => event.preventDefault()}
+ onCloseAutoFocus={(event) => event.preventDefault()}
+ onInteractOutside={(event) => {
+ if (anchorRef.current?.contains(event.target as Node)) event.preventDefault();
+ }}
+ >
+ {suggestions.length > 0 ? (
+ <ul
+ id={listId}
+ role="listbox"
+ aria-label="Variables"
+ className="max-h-60 overflow-y-auto"
+ >
+ {suggestions.map((suggestion, index) => (
+ <Fragment key={suggestion.type === "variable" ? suggestion.variable.id : "create"}>
+ {suggestion.type === "create" && index > 0 && (
+ <li role="presentation" className="-mx-1 my-1 h-px bg-border" />
)}
- onMouseEnter={() => setActiveIndex(index)}
- onMouseDown={(event) => event.preventDefault()}
- onClick={() => choose(suggestion)}
- >
- {suggestion.type === "variable" ? (
- <>
- <span className="flex-1 truncate font-mono text-xs">
- {suggestion.variable.key}
- </span>
- {suggestion.variable.isSecret ? (
- <LockIcon className="size-3 shrink-0 text-muted" aria-label="Secret" />
- ) : (
- <span className="max-w-32 truncate text-xs text-muted">
- {suggestion.variable.value}
- </span>
- )}
- </>
- ) : (
- <>
- <PlusIcon className="size-3.5 shrink-0 text-muted" />
- {suggestion.isKeyValid ? (
- <span className="min-w-0 truncate text-xs">
- Create <span className="font-mono">{suggestion.key}</span>
+ {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
+ <li
+ id={optionId(index)}
+ role="option"
+ aria-selected={index === activeIndex}
+ className={cn(
+ "flex cursor-pointer items-center gap-3 rounded-sm px-2 py-1.5",
+ index === activeIndex && "bg-container-hover"
+ )}
+ onMouseEnter={() => setActiveIndex(index)}
+ onMouseDown={(event) => event.preventDefault()}
+ onClick={() => choose(suggestion)}
+ >
+ {suggestion.type === "variable" ? (
+ <>
+ <span className="flex-1 truncate font-mono text-xs">
+ {suggestion.variable.key}
</span>
- ) : (
- <span className="text-xs">Create Variable</span>
- )}
- </>
- )}
- </li>
- </Fragment>
- ))}
- </ul>
- ) : (
- <p className="px-2 py-1.5 text-xs text-muted">
- {variables?.length
- ? "No variable in this bundle matches that name."
- : "This bundle has no variables yet. Add one under Variables."}
- </p>
- )}
- </PopoverContent>
+ {suggestion.variable.isSecret ? (
+ <LockIcon className="size-3 shrink-0 text-muted" aria-label="Secret" />
+ ) : (
+ <span className="max-w-32 truncate text-xs text-muted">
+ {suggestion.variable.value}
+ </span>
+ )}
+ </>
+ ) : (
+ <>
+ <PlusIcon className="size-3.5 shrink-0 text-muted" />
+ {suggestion.isKeyValid ? (
+ <span className="min-w-0 truncate text-xs">
+ Create <span className="font-mono">{suggestion.key}</span>
+ </span>
+ ) : (
+ <span className="text-xs">Create Variable</span>
+ )}
+ </>
+ )}
+ </li>
+ </Fragment>
+ ))}
+ </ul>
+ ) : (
+ <p className="px-2 py-1.5 text-xs text-muted">
+ {variables?.length
+ ? "No variable in this bundle matches that name."
+ : "This bundle has no variables yet. Add one under Variables."}
+ </p>
+ )}
+ </PopoverContent>
+ )}
</Popover>
);
};
diff --git a/frontend/src/hooks/api/agentVault/types.ts b/frontend/src/hooks/api/agentVault/types.ts
index 97bc284bbe..e1c11ff6de 100644
--- a/frontend/src/hooks/api/agentVault/types.ts
+++ b/frontend/src/hooks/api/agentVault/types.ts
@@ -58,11 +58,9 @@ export type TAgentVaultSubstitutionInput = {
value?: string;
};
-/** `isWholeValue` means the value is exactly {{key}}, so the sheet can show it where a value never returns. */
export type TAgentVaultVariableReference = {
variableId: string;
key: string;
- isWholeValue: boolean;
} & (
| {
field:
@@ -84,7 +82,8 @@ export type TAgentVaultService = {
credential: TAgentVaultCredentialSummary;
customHeaders: TAgentVaultCustomHeaderSummary[];
substitutions: TAgentVaultSubstitutionSummary[];
- variableReferences: TAgentVaultVariableReference[];
+ // Left out for a member, who can't see variables.
+ variableReferences?: TAgentVaultVariableReference[];
createdAt: string;
updatedAt: string;
};