🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
import urlJoin from 'url-join';
export type AgentProfileTab =
| 'automations'
| 'channel'
| 'engine'
| 'environment'
| 'graph'
| 'instruction'
| 'knowledge'
| 'mail'
| 'opening'
| 'permission'
| 'profile'
| 'self-evolving'
| 'share'
| 'skills'
| 'statistics'
| 'tools'
| 'webhook';
export interface AgentProfileTabOption {
label: string;
value: AgentProfileTab;
}
export type AgentProfileTabGroupKey =
'advanced' | 'general' | 'growth' | 'identity' | 'profile' | 'setup' | 'shape';
export interface AgentProfileTabGroup {
key: AgentProfileTabGroupKey;
options: AgentProfileTabOption[];
}
export const buildAgentProfileTabPath = (agentId: string, tab: AgentProfileTab) =>
urlJoin('/agent', agentId, tab);
const AGENT_PROFILE_ROUTE =
/^(?:\/[^/]+)?\/agent\/[^/]+\/(profile|instruction|knowledge|engine|environment|tools|skills|opening|graph|mail(?:\/[^/]+)?|channel(?:\/[^/]+)?|automations|webhook|self-evolving(?:\/[^/]+)*|statistics|permission|share)\/?$/;
/**
* The profile-group tab a URL belongs to, if any. Anchored on Agent subroutes,
* not substrings: `/channels/:id` and workspace slugs such as `channel-team`
* are not part of the group.
*/
export const getAgentProfileTab = (pathname: string): AgentProfileTab | undefined => {
const segment = AGENT_PROFILE_ROUTE.exec(
pathname.replace(/^\/_dangerous_local_dev_proxy(?=\/)/, ''),
)?.[1];
return segment?.split('/')[0] as AgentProfileTab | undefined;
};
/**
* Which segments the profile-group switcher shows.
*
* `canConfigure` is the same gate `ResourceConfigAccessGate` applies to the
* Profile / Channels routes: without edit-level access those pages bounce the
* member straight back out with a toast, so the segment must not offer the
* click. Statistics carries no such gate and is always listed.
*
* The tab owned by the current page is always kept, even when the gates would
* drop it — otherwise `value` would point at no option and the switcher would
* render with nothing selected on the very page that owns it.
*/
export const buildAgentProfileTabOptions = ({
active,
automationsSupported = false,
canConfigure,
graphSupported = false,
labels,
mailSupported,
openingSupported = false,
permissionSupported = false,
selfLearningSupported,
shareSupported,
heterogeneous,
webhookSupported = false,
}: {
active: AgentProfileTab;
/** Inbound webhooks are switched on for this member (`webhook`). */
automationsSupported?: boolean;
canConfigure: boolean;
/** The Graph runtime option applies to this agent on this surface (`graph`). */
graphSupported?: boolean;
labels: Record<AgentProfileTab, string>;
mailSupported: boolean;
/** This surface lists the opening page; mobile has its own settings screen. */
openingSupported?: boolean;
/** The agent lives in a workspace and this surface lists the page (`permission`). */
permissionSupported?: boolean;
selfLearningSupported: boolean;
shareSupported: boolean;
/**
* Heterogeneous agents (Claude Code, Codex, …) bring their own system prompt, tools and skills,
* so the instruction, tools and skills pages have nothing to configure for them.
*/
heterogeneous: boolean;
/** Generic webhooks are switched on for this member (`webhook`). */
webhookSupported?: boolean;
}): AgentProfileTabOption[] => {
const showProfile = canConfigure || active === 'profile';
// Engine, Instruction, Environment, Tools and Skills edit the same agent config as Profile, so
// they follow its gate.
const showEngine = canConfigure || active === 'engine';
const showKnowledge = (canConfigure && !heterogeneous) || active === 'knowledge';
const showInstruction = (canConfigure && !heterogeneous) || active === 'instruction';
// Where a heterogeneous agent runs and what it needs there; a harness agent has no such page.
const showEnvironment = (canConfigure && heterogeneous) || active === 'environment';
const showTools = (canConfigure && !heterogeneous) || active === 'tools';
const showSkills = (canConfigure && !heterogeneous) || active === 'skills';
const showOpening = (canConfigure && openingSupported) || active === 'opening';
const showGraph = (canConfigure && graphSupported) || active === 'graph';
const showMail = (canConfigure && mailSupported) || active === 'mail';
// Channels can dispatch to a bound device; cloud sandbox support is not required.
const showChannel = canConfigure || active === 'channel';
// What wakes this agent without the user, as in Settings → Automations: every member who can
// see the agent may look, and each row says whether they may check or delete it.
const showAutomations = automationsSupported || active === 'automations';
// Creating a webhook lets outsiders wake the agent, so it needs the same edit access.
const showWebhook = (canConfigure && webhookSupported) || active === 'webhook';
// Sharing hands visitors real execution on the owner's account, so the
// segment follows the same configure gate as Profile / Channels on top of the
// capability gate (personal, non-builtin agents on deployments that allow it).
const showShare = (canConfigure && shareSupported) || active === 'share';
const showSelfLearning = selfLearningSupported || active === 'self-evolving';
// The page applies the same edit gate and bounces anyone else back with a toast.
const showPermission = (canConfigure && permissionSupported) || active === 'permission';
return [
showProfile ? { label: labels.profile, value: 'profile' as const } : null,
showInstruction ? { label: labels.instruction, value: 'instruction' as const } : null,
showKnowledge ? { label: labels.knowledge, value: 'knowledge' as const } : null,
showOpening ? { label: labels.opening, value: 'opening' as const } : null,
showEngine ? { label: labels.engine, value: 'engine' as const } : null,
showEnvironment ? { label: labels.environment, value: 'environment' as const } : null,
showTools ? { label: labels.tools, value: 'tools' as const } : null,
showSkills ? { label: labels.skills, value: 'skills' as const } : null,
showMail ? { label: labels.mail, value: 'mail' as const } : null,
showChannel ? { label: labels.channel, value: 'channel' as const } : null,
showAutomations ? { label: labels.automations, value: 'automations' as const } : null,
showWebhook ? { label: labels.webhook, value: 'webhook' as const } : null,
showGraph ? { label: labels.graph, value: 'graph' as const } : null,
showSelfLearning ? { label: labels['self-evolving'], value: 'self-evolving' as const } : null,
{ label: labels.statistics, value: 'statistics' as const },
showPermission ? { label: labels.permission, value: 'permission' as const } : null,
showShare ? { label: labels.share, value: 'share' as const } : null,
].filter((option) => !!option);
};
const AGENT_PROFILE_TAB_GROUPS: { key: AgentProfileTabGroupKey; tabs: AgentProfileTab[] }[] = [
{ key: 'profile', tabs: ['profile'] },
{ key: 'shape', tabs: ['instruction', 'knowledge', 'opening'] },
{ key: 'setup', tabs: ['engine', 'environment', 'tools', 'skills'] },
{ key: 'identity', tabs: ['mail', 'channel'] },
{ key: 'advanced', tabs: ['automations', 'webhook', 'graph'] },
{ key: 'growth', tabs: ['self-evolving', 'statistics'] },
{ key: 'general', tabs: ['permission', 'share'] },
];
/** Sidebar sections for the visible tabs; a section with nothing to open is left out. */
export const groupAgentProfileTabOptions = (
options: AgentProfileTabOption[],
): AgentProfileTabGroup[] =>
AGENT_PROFILE_TAB_GROUPS.map(({ key, tabs }) => ({
key,
options: tabs.flatMap((tab) => options.filter((option) => option.value === tab)),
})).filter((group) => group.options.length > 0);