feat: refactor HomePage to integrate agents store and update related components
feat: add runtime event handling for providers in ProvidersSection feat: update routing to include Channels and Agents pages feat: extend route types and navigation items for Channels and Agents feat: implement agents store for managing agent data and interactions fix: update chat store to utilize agents store for agent-related functionality chore: export agents store from index fix: enhance runtime types for better event handling fix: update Vite config to handle dev server URL correctly
This commit is contained in:
@@ -1 +1,119 @@
|
||||
export * from './models';
|
||||
export const DEFAULT_AGENT_ID = 'main';
|
||||
export const DEFAULT_MAIN_SESSION_SUFFIX = 'main';
|
||||
export const DEFAULT_CHANNEL_ACCOUNT_ID = 'default';
|
||||
|
||||
export interface AgentSummary {
|
||||
id: string;
|
||||
name: string;
|
||||
isDefault: boolean;
|
||||
providerAccountId: string | null;
|
||||
modelRef: string | null;
|
||||
modelDisplay: string;
|
||||
mainSessionKey: string;
|
||||
vendorId?: string | null;
|
||||
source?: 'synthetic-main' | 'provider-account' | 'agent-config';
|
||||
overrideModelRef?: string | null;
|
||||
inheritedModel?: boolean;
|
||||
workspace?: string;
|
||||
agentDir?: string;
|
||||
channelTypes?: string[];
|
||||
}
|
||||
|
||||
export interface AgentsSnapshot {
|
||||
agents: AgentSummary[];
|
||||
models?: AgentSummary[];
|
||||
defaultAgentId: string;
|
||||
defaultProviderAccountId: string | null;
|
||||
defaultModelRef: string | null;
|
||||
mainSessionSuffix: string;
|
||||
configuredChannelTypes: string[];
|
||||
channelOwners: Record<string, string>;
|
||||
channelAccountOwners: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface AgentChannelBinding {
|
||||
channelType: string;
|
||||
accountId: string;
|
||||
agentId: string;
|
||||
}
|
||||
|
||||
export interface AgentChannelBindingInput {
|
||||
channelType: string;
|
||||
accountId: string;
|
||||
agentId: string;
|
||||
}
|
||||
|
||||
export interface AgentChannelUnbindingInput {
|
||||
channelType: string;
|
||||
accountId: string;
|
||||
}
|
||||
|
||||
export function normalizeAgentId(value: string | null | undefined): string {
|
||||
const normalized = String(value ?? '').trim().toLowerCase();
|
||||
return normalized || DEFAULT_AGENT_ID;
|
||||
}
|
||||
|
||||
export function normalizeSessionSuffix(value: string | null | undefined): string {
|
||||
const normalized = String(value ?? '').trim().toLowerCase();
|
||||
return normalized || DEFAULT_MAIN_SESSION_SUFFIX;
|
||||
}
|
||||
|
||||
export function buildAgentSessionKey(agentId: string, sessionId: string): string {
|
||||
return `agent:${normalizeAgentId(agentId)}:${normalizeSessionSuffix(sessionId)}`;
|
||||
}
|
||||
|
||||
export function buildMainSessionKey(
|
||||
agentId: string,
|
||||
sessionId = DEFAULT_MAIN_SESSION_SUFFIX,
|
||||
): string {
|
||||
return buildAgentSessionKey(agentId, sessionId);
|
||||
}
|
||||
|
||||
export function normalizeChannelType(value: string | null | undefined): string {
|
||||
return String(value ?? '').trim().toLowerCase();
|
||||
}
|
||||
|
||||
export function normalizeChannelAccountId(value: string | null | undefined): string {
|
||||
const normalized = String(value ?? '').trim();
|
||||
return normalized || DEFAULT_CHANNEL_ACCOUNT_ID;
|
||||
}
|
||||
|
||||
export function buildChannelAccountOwnerKey(
|
||||
channelType: string,
|
||||
accountId: string | null | undefined = DEFAULT_CHANNEL_ACCOUNT_ID,
|
||||
): string {
|
||||
return `${normalizeChannelType(channelType)}:${normalizeChannelAccountId(accountId)}`;
|
||||
}
|
||||
|
||||
export function parseChannelAccountOwnerKey(key: string): {
|
||||
channelType: string;
|
||||
accountId: string;
|
||||
} {
|
||||
const trimmed = String(key ?? '').trim();
|
||||
const separatorIndex = trimmed.indexOf(':');
|
||||
if (separatorIndex === -1) {
|
||||
return {
|
||||
channelType: normalizeChannelType(trimmed),
|
||||
accountId: DEFAULT_CHANNEL_ACCOUNT_ID,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
channelType: normalizeChannelType(trimmed.slice(0, separatorIndex)),
|
||||
accountId: normalizeChannelAccountId(trimmed.slice(separatorIndex + 1)),
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveChannelAccountOwner(
|
||||
channelAccountOwners: Record<string, string> | null | undefined,
|
||||
channelType: string,
|
||||
accountId?: string | null,
|
||||
): string | null {
|
||||
if (!channelAccountOwners) return null;
|
||||
const key = buildChannelAccountOwnerKey(channelType, accountId);
|
||||
const owner = channelAccountOwners[key];
|
||||
return typeof owner === 'string' && owner.trim() ? owner : null;
|
||||
}
|
||||
|
||||
export type AgentSummaryLike = AgentSummary;
|
||||
export type AgentsSnapshotLike = AgentsSnapshot;
|
||||
|
||||
@@ -1,44 +1,26 @@
|
||||
export const DEFAULT_AGENT_ID = 'main';
|
||||
export const DEFAULT_MAIN_SESSION_SUFFIX = 'main';
|
||||
export const DEFAULT_MODEL_ID = DEFAULT_AGENT_ID;
|
||||
|
||||
export interface AgentSummary {
|
||||
id: string;
|
||||
name: string;
|
||||
isDefault: boolean;
|
||||
providerAccountId: string | null;
|
||||
modelRef: string | null;
|
||||
modelDisplay: string;
|
||||
mainSessionKey: string;
|
||||
vendorId?: string | null;
|
||||
source?: 'synthetic-main' | 'provider-account';
|
||||
}
|
||||
import {
|
||||
DEFAULT_AGENT_ID,
|
||||
DEFAULT_CHANNEL_ACCOUNT_ID,
|
||||
DEFAULT_MAIN_SESSION_SUFFIX,
|
||||
buildChannelAccountOwnerKey,
|
||||
normalizeChannelAccountId,
|
||||
normalizeChannelType,
|
||||
parseChannelAccountOwnerKey,
|
||||
resolveChannelAccountOwner,
|
||||
type AgentSummary,
|
||||
type AgentChannelBinding,
|
||||
type AgentChannelBindingInput,
|
||||
type AgentChannelUnbindingInput,
|
||||
type AgentsSnapshot,
|
||||
} from './agents';
|
||||
|
||||
export type ModelSummary = AgentSummary;
|
||||
export const DEFAULT_MODEL_ID = DEFAULT_AGENT_ID;
|
||||
|
||||
export interface ModelsSnapshot {
|
||||
export type ModelsSnapshot = AgentsSnapshot & {
|
||||
models: ModelSummary[];
|
||||
agents?: ModelSummary[];
|
||||
defaultAgentId: string;
|
||||
defaultProviderAccountId: string | null;
|
||||
defaultModelRef: string | null;
|
||||
mainSessionSuffix: string;
|
||||
configuredChannelTypes: string[];
|
||||
channelOwners: Record<string, string>;
|
||||
channelAccountOwners: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface AgentsSnapshot {
|
||||
agents: AgentSummary[];
|
||||
models?: AgentSummary[];
|
||||
defaultAgentId: string;
|
||||
defaultProviderAccountId: string | null;
|
||||
defaultModelRef: string | null;
|
||||
mainSessionSuffix: string;
|
||||
configuredChannelTypes: string[];
|
||||
channelOwners: Record<string, string>;
|
||||
channelAccountOwners: Record<string, string>;
|
||||
}
|
||||
};
|
||||
|
||||
export interface ParsedSessionKey {
|
||||
sessionKey: string;
|
||||
@@ -110,3 +92,22 @@ export function normalizeAgentSessionKey(sessionKey: string): string {
|
||||
export const normalizeModelId = normalizeAgentId;
|
||||
export const buildModelSessionKey = buildAgentSessionKey;
|
||||
export const normalizeModelSessionKey = normalizeAgentSessionKey;
|
||||
|
||||
export {
|
||||
DEFAULT_AGENT_ID,
|
||||
DEFAULT_CHANNEL_ACCOUNT_ID,
|
||||
DEFAULT_MAIN_SESSION_SUFFIX,
|
||||
buildChannelAccountOwnerKey,
|
||||
normalizeChannelAccountId,
|
||||
normalizeChannelType,
|
||||
parseChannelAccountOwnerKey,
|
||||
resolveChannelAccountOwner,
|
||||
};
|
||||
|
||||
export type {
|
||||
AgentSummary,
|
||||
AgentChannelBinding,
|
||||
AgentChannelBindingInput,
|
||||
AgentChannelUnbindingInput,
|
||||
AgentsSnapshot,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user