mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
17 lines
550 B
TypeScript
17 lines
550 B
TypeScript
export const PARENT_AGENT_ID_LABEL = "paseo.parent-agent-id";
|
|
|
|
export interface AgentLabelSource {
|
|
labels?: Record<string, unknown> | null;
|
|
}
|
|
|
|
export function getParentAgentIdFromLabels(labels: Record<string, unknown> | null | undefined) {
|
|
const parentAgentId = labels?.[PARENT_AGENT_ID_LABEL];
|
|
return typeof parentAgentId === "string" && parentAgentId.trim().length > 0
|
|
? parentAgentId.trim()
|
|
: null;
|
|
}
|
|
|
|
export function isDelegatedAgent(agent: AgentLabelSource): boolean {
|
|
return getParentAgentIdFromLabels(agent.labels) !== null;
|
|
}
|