Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit d713751

Browse files
committed
fix extensions page
1 parent be5bac1 commit d713751

4 files changed

Lines changed: 22 additions & 14 deletions

File tree

app/settings/abilities/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com
1010
import { Label } from '@/components/ui/label';
1111
import { Switch } from '@/components/ui/switch';
1212
import MarkdownBlock from '@/components/conversation/Message/MarkdownBlock';
13-
import { useCompany } from '@/components/interactive/useUser';
13+
import { useCompany, CompanyWithExtensions } from '@/components/interactive/useUser';
1414
import { Input } from '@/components/ui/input';
1515
import { SidebarPage } from '@/components/layout/SidebarPage';
1616
import { useToast } from '@/components/layout/toast';

app/settings/extensions/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import axios from 'axios';
44
import { getCookie } from 'cookies-next';
55
import { useSearchParams } from 'next/navigation';
66
import { useAgent } from '@/components/interactive/useAgent';
7-
import { useCompany } from '@/components/interactive/useUser';
7+
import { useCompany, CompanyWithExtensions } from '@/components/interactive/useUser';
88
import { useEffect, useState } from 'react';
99
import OAuth2Login from 'react-simple-oauth2-login';
1010
import { providers as oAuth2Providers, loadProviders as loadOAuthProviders } from '@/components/auth/OAuth';

components/interactive/useAgent.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export function useAgents(): SWRResponse<Agent[]> {
2828
company.agents.map((agent) => ({
2929
...agent,
3030
companyName: company.name,
31+
settings: [], // Add empty settings array to match Agent type
3132
})),
3233
) || [],
3334
{ fallbackData: [] },
@@ -45,6 +46,7 @@ export function useAgent(
4546
agent: Agent | null;
4647
commands: string[];
4748
settings: any[];
49+
extensions: any[];
4850
}> {
4951
const getDefaultAgent = () => {
5052
const primaryCompany = companies.find((c) => c.primary);
@@ -67,18 +69,18 @@ export function useAgent(
6769
if (!searchName && companies?.length) {
6870
foundEarly = getDefaultAgent();
6971
}
70-
const swrHook = useSWR<{ agent: Agent | null; commands: string[]; settings: any[] }>(
72+
const swrHook = useSWR<{ agent: Agent | null; commands: string[]; settings: any[]; extensions: any[] }>(
7173
[`/agent?name=${searchName}`, companies, withSettings],
72-
async (): Promise<{ agent: Agent | null; commands: string[]; settings: any[] }> => {
74+
async (): Promise<{ agent: Agent | null; commands: string[]; settings: any[]; extensions: any[] }> => {
7375
try {
7476
if (withSettings) {
7577
const client = createGraphQLClient();
7678
const query = AgentSchema.toGQL('query', 'GetAgent', { name: searchName });
7779
const response = await client.request<{ agent: Agent }>(query, { name: searchName });
7880
const agent = AgentSchema.parse(response.agent);
79-
return { agent, commands: [], settings: [] };
81+
return { agent, commands: [], settings: [], extensions: [] };
8082
} else {
81-
const toReturn = { agent: foundEarly, commands: [], settings: [] };
83+
const toReturn = { agent: foundEarly, commands: [], settings: [], extensions: [] };
8284
if (companies?.length && !toReturn.agent) {
8385
for (const company of companies) {
8486
const agent = company.agents.find((a) => a.name === searchName);
@@ -91,7 +93,7 @@ export function useAgent(
9193
toReturn.agent = getDefaultAgent();
9294
}
9395
if (toReturn.agent) {
94-
toReturn.settings = (
96+
toReturn.extensions = (
9597
await axios.get(`${process.env.NEXT_PUBLIC_AGIXT_SERVER}/api/agent/${toReturn.agent.name}/extensions`, {
9698
headers: {
9799
Authorization: getCookie('jwt'),
@@ -105,10 +107,10 @@ export function useAgent(
105107
}
106108
} catch (error) {
107109
console.error('Error fetching agent:', error);
108-
return { agent: null, commands: [], settings: [] };
110+
return { agent: null, commands: [], settings: [], extensions: [] };
109111
}
110112
},
111-
{ fallbackData: { agent: null, commands: [], settings: [] } },
113+
{ fallbackData: { agent: null, commands: [], settings: [], extensions: [] } },
112114
);
113115
const originalMutate = swrHook.mutate;
114116
swrHook.mutate = chainMutations(companiesHook, originalMutate);

components/interactive/useUser.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export const CompanySchema = z.object({
2424

2525
export type Company = z.infer<typeof CompanySchema>;
2626

27+
// Extended Company type that includes dynamically loaded extensions
28+
export type CompanyWithExtensions = Company & {
29+
extensions?: any[];
30+
};
31+
2732
export function useCompanies(): SWRResponse<Company[]> {
2833
const userHook = useUser();
2934
const { data: user } = userHook;
@@ -36,12 +41,12 @@ export function useCompanies(): SWRResponse<Company[]> {
3641
return swrHook;
3742
}
3843

39-
export function useCompany(id?: string): SWRResponse<Company | null> {
44+
export function useCompany(id?: string): SWRResponse<CompanyWithExtensions | null> {
4045
const companiesHook = useCompanies();
4146
const { data: companies } = companiesHook;
42-
const swrHook = useSWR<Company | null>(
47+
const swrHook = useSWR<CompanyWithExtensions | null>(
4348
[`/company?id=${id}`, companies, getCookie('jwt')],
44-
async (): Promise<Company | null> => {
49+
async (): Promise<CompanyWithExtensions | null> => {
4550
if (!getCookie('jwt')) return null;
4651
try {
4752
if (id) {
@@ -52,7 +57,8 @@ export function useCompany(id?: string): SWRResponse<Company | null> {
5257
companies?.find((c) => (agentName ? c.agents.some((a) => a.name === agentName) : c.primary)) || null;
5358
if (!targetCompany) return null;
5459
setCookie('agixt-company', targetCompany.id);
55-
targetCompany.extensions = (
60+
const extendedCompany = targetCompany as CompanyWithExtensions;
61+
extendedCompany.extensions = (
5662
await axios.get(
5763
`${process.env.NEXT_PUBLIC_AGIXT_SERVER}/v1/companies/${targetCompany.id}/extensions`,
5864

@@ -63,7 +69,7 @@ export function useCompany(id?: string): SWRResponse<Company | null> {
6369
},
6470
)
6571
).data.extensions;
66-
return targetCompany;
72+
return extendedCompany;
6773
}
6874
} catch (error) {
6975
console.error('Error fetching company:', error);

0 commit comments

Comments
 (0)