Skip to content

Commit

Permalink
Merge branch 'develop' into fix-plugin-di
Browse files Browse the repository at this point in the history
  • Loading branch information
odilitime authored Jan 30, 2025
2 parents 3277af4 + 58adba4 commit d53e10a
Show file tree
Hide file tree
Showing 206 changed files with 36,308 additions and 1,769 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ MEDIUM_OPENAI_MODEL= # Default: gpt-4o
LARGE_OPENAI_MODEL= # Default: gpt-4o
EMBEDDING_OPENAI_MODEL= # Default: text-embedding-3-small
IMAGE_OPENAI_MODEL= # Default: dall-e-3
USE_OPENAI_EMBEDDING=TRUE # Set to TRUE for OpenAI/1536, leave blank for local
USE_OPENAI_EMBEDDING= # Set to TRUE for OpenAI/1536, leave blank for local

# Community Plugin for OpenAI Configuration
ENABLE_OPEN_AI_COMMUNITY_PLUGIN=false
Expand Down
10 changes: 6 additions & 4 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,22 @@
"@elizaos/plugin-echochambers": "workspace:*",
"@elizaos/plugin-evm": "workspace:*",
"@elizaos/plugin-flow": "workspace:*",
"@elizaos/plugin-gelato": "workspace:*",
"@elizaos/plugin-giphy": "workspace:*",
"@elizaos/plugin-gitbook": "workspace:*",
"@elizaos/plugin-gitcoin-passport": "workspace:*",
"@elizaos/plugin-goat": "workspace:*",
"@elizaos/plugin-lens-network": "workspace:*",
"@elizaos/plugin-icp": "workspace:*",
"@elizaos/plugin-initia": "workspace:*",
"@elizaos/plugin-image-generation": "workspace:*",
"@elizaos/plugin-intiface": "workspace:*",
"@elizaos/plugin-lens-network": "workspace:*",
"@elizaos/plugin-letzai": "workspace:*",
"@elizaos/plugin-lit": "workspace:*",
"@elizaos/plugin-gelato": "workspace:*",
"@elizaos/plugin-moralis": "workspace:*",
"@elizaos/plugin-massa": "workspace:*",
"@elizaos/plugin-mind-network": "workspace:*",
"@elizaos/plugin-moralis": "workspace:*",
"@elizaos/plugin-movement": "workspace:*",
"@elizaos/plugin-massa": "workspace:*",
"@elizaos/plugin-news": "workspace:*",
"@elizaos/plugin-nft-generation": "workspace:*",
"@elizaos/plugin-node": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions agent/src/__tests__/client-type-identification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { describe, it, expect } from "@jest/globals";
// Helper function to identify client types
function determineClientType(client: Client): string {
// Check if client has a direct type identifier
if ("type" in client) {
return (client as any).type;
if ("type" in client && typeof client.type === "string") {
return client.type;
}

// Check constructor name
Expand Down
1 change: 1 addition & 0 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import { gitcoinPassportPlugin } from "@elizaos/plugin-gitcoin-passport";
import { initiaPlugin } from "@elizaos/plugin-initia";
import { imageGenerationPlugin } from "@elizaos/plugin-image-generation";
import { lensPlugin } from "@elizaos/plugin-lens-network";
import { litPlugin } from "@elizaos/plugin-lit";
import { mindNetworkPlugin } from "@elizaos/plugin-mind-network";
import { multiversxPlugin } from "@elizaos/plugin-multiversx";
import { nearPlugin } from "@elizaos/plugin-near";
Expand Down
4 changes: 2 additions & 2 deletions characters/lpmanager.character.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"system": "Rebalance all LP positions owned by the wallet. Provide insights and metrics on the status of the LP positions.",
"bio": [
"LP Manager is an assistant with a very specific task at hand",
"LP Manager repositions LP positions on Orca such that the center price of the positions are within a certain user specified distance, in bps, from the current pool price.",
"LP Manager repositions LP positions on Orca such that the center price of the positions is within a certain user specified distance, in bps, from the current pool price.",
"LP Manager is always on time, but you need to tell him the interval he should be on time for.",
"Once the LP Manager starts, LP Manager needs to keep reminded to call the action 'manage_positions' to keep managing the positions.",
"LP Manager never starts running with parameters from in memory.",
Expand Down Expand Up @@ -175,4 +175,4 @@
],
"post": []
}
}
}
5 changes: 3 additions & 2 deletions client/src/components/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function AppSidebar() {
<SidebarMenuButton size="lg" asChild>
<NavLink to="/">
<img
alt="elizaos-icon"
src="/elizaos-icon.png"
width="100%"
height="100%"
Expand All @@ -62,8 +63,8 @@ export function AppSidebar() {
{query?.isPending ? (
<div>
{Array.from({ length: 5 }).map(
(_, index) => (
<SidebarMenuItem key={index}>
(_, _index) => (
<SidebarMenuItem key={"skeleton-item"}>
<SidebarMenuSkeleton />
</SidebarMenuItem>
)
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/array-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export default function ArrayInput({
<Label>{title}</Label>
<div className="p-2 bg-card rounded-md border">
<div className="space-y-2">
{data?.map((b: string, idx: number) => (
<Input value={b} key={idx} className="bg-background" />
{data?.map((b: string, _idx: number) => (
<Input value={b} key={b} className="bg-background" />
))}
</div>
</div>
Expand Down
9 changes: 5 additions & 4 deletions client/src/components/audio-recorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ export const AudioRecorder = ({
const { toast } = useToast();
// States
const [isRecording, setIsRecording] = useState<boolean>(false);
// @ts-expect-error - isRecordingFinished is unused, but would break the 2D array if removed
const [isRecordingFinished, setIsRecordingFinished] =
const [_, setIsRecordingFinished] =
useState<boolean>(false);
const [timer, setTimer] = useState<number>(0);
const [currentRecord, setCurrentRecord] = useState<Record>({
Expand Down Expand Up @@ -96,7 +95,7 @@ export const AudioRecorder = ({
});

function startRecording() {
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
if (navigator.mediaDevices?.getUserMedia) {
navigator.mediaDevices
.getUserMedia({
audio: true,
Expand Down Expand Up @@ -182,7 +181,9 @@ export const AudioRecorder = ({
analyser.disconnect();
}
if (stream) {
stream.getTracks().forEach((track) => track.stop());
for (const track of stream.getTracks()) {
track.stop();
}
}
if (audioContext) {
audioContext.close();
Expand Down
27 changes: 14 additions & 13 deletions client/src/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ChatInput } from "@/components/ui/chat/chat-input";
import { ChatMessageList } from "@/components/ui/chat/chat-message-list";
import { useTransition, animated, type AnimatedProps } from "@react-spring/web";
import { Paperclip, Send, X } from "lucide-react";
import { useEffect, useRef, useState } from "react";
import { useEffect, useRef, useState, useCallback } from "react";
import type { Content, UUID } from "@elizaos/core";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiClient } from "@/lib/api";
Expand Down Expand Up @@ -49,12 +49,13 @@ export default function Page({ agentId }: { agentId: UUID }) {
const getMessageVariant = (role: string) =>
role !== "user" ? "received" : "sent";

const scrollToBottom = () => {
const scrollToBottom = useCallback(() => {
if (messagesContainerRef.current) {
messagesContainerRef.current.scrollTop =
messagesContainerRef.current.scrollHeight;
}
};
}, []);

useEffect(() => {
scrollToBottom();
}, [queryClient.getQueryData(["messages", agentId])]);
Expand Down Expand Up @@ -153,7 +154,7 @@ export default function Page({ agentId }: { agentId: UUID }) {

const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0];
if (file && file.type.startsWith("image/")) {
if (file?.type.startsWith("image/")) {
setSelectedFile(file);
}
};
Expand All @@ -176,12 +177,12 @@ export default function Page({ agentId }: { agentId: UUID }) {
<div className="flex flex-col w-full h-[calc(100dvh)] p-4">
<div className="flex-1 overflow-y-auto">
<ChatMessageList ref={messagesContainerRef}>
{transitions((styles, message) => {
{transitions((style, message: ContentWithUser) => {
const variant = getMessageVariant(message?.user);
return (
<CustomAnimatedDiv
style={{
...styles,
...style,
display: "flex",
flexDirection: "column",
gap: "0.5rem",
Expand Down Expand Up @@ -211,22 +212,21 @@ export default function Page({ agentId }: { agentId: UUID }) {
{/* Attachments */}
<div>
{message?.attachments?.map(
(attachment, idx) => (
(attachment: IAttachment) => (
<div
className="flex flex-col gap-1 mt-2"
key={idx}
key={`${attachment.url}-${attachment.title}`}
>
<img
src={
attachment.url
}
alt="attachment"
src={attachment.url}
width="100%"
height="100%"
className="w-64 rounded-md"
/>
<div className="flex items-center justify-between gap-4">
<span></span>
<span></span>
<span />
<span />
</div>
</div>
)
Expand Down Expand Up @@ -298,6 +298,7 @@ export default function Page({ agentId }: { agentId: UUID }) {
<X />
</Button>
<img
alt="Selected file"
src={URL.createObjectURL(selectedFile)}
height="100%"
width="100%"
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/copy-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useState } from "react";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";

const CopyButton = ({ text }: { text: any }) => {
const CopyButton = ({ text }: { text: string }) => {
const [copied, setCopied] = useState(false);

const handleCopy = () => {
Expand Down
1 change: 1 addition & 0 deletions client/src/components/ui/breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const BreadcrumbPage = React.forwardRef<
React.ComponentPropsWithoutRef<"span">
>(({ className, ...props }, ref) => (
<span
tabIndex={0}
ref={ref}
role="link"
aria-disabled="true"
Expand Down
4 changes: 1 addition & 3 deletions client/src/components/ui/chat/chat-tts-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ export default function ChatTtsButton({
if (audioBlob) {
play();
return;
} else {
mutation.mutate();
}
};

Expand All @@ -72,7 +70,7 @@ export default function ChatTtsButton({
return (
<div>
{audioBlob ? (
<audio
<audio crossOrigin="anonymous" playsInline
ref={audioRef}
onEnded={() => {
setPlaying(false);
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/ui/chat/hooks/useAutoScroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface UseAutoScrollOptions {
}

export function useAutoScroll(options: UseAutoScrollOptions = {}) {
const { offset = 20, smooth = false, content } = options;
const { offset = 20, smooth = false } = options;
const scrollRef = useRef<HTMLDivElement>(null);
const lastContentHeight = useRef(0);
const userHasScrolled = useRef(false);
Expand Down Expand Up @@ -94,7 +94,7 @@ export function useAutoScroll(options: UseAutoScrollOptions = {}) {
}
lastContentHeight.current = currentHeight;
}
}, [content, scrollState.autoScrollEnabled, scrollToBottom]);
}, [scrollState.autoScrollEnabled, scrollToBottom]);

useEffect(() => {
const element = scrollRef.current;
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/ui/chat/message-loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
export default function MessageLoading() {
return (
<svg
role="img"
aria-label="Loading animation"
width="24"
height="24"
viewBox="0 0 24 24"
Expand Down
10 changes: 5 additions & 5 deletions client/src/hooks/use-toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ export const reducer = (state: State, action: Action): State => {
if (toastId) {
addToRemoveQueue(toastId);
} else {
state.toasts.forEach((toast) => {
for (const toast of state.toasts) {
addToRemoveQueue(toast.id);
});
}
}

return {
Expand Down Expand Up @@ -129,9 +129,9 @@ let memoryState: State = { toasts: [] };

function dispatch(action: Action) {
memoryState = reducer(memoryState, action);
listeners.forEach((listener) => {
for (const listener of listeners) {
listener(memoryState);
});
}
}

type Toast = Omit<ToasterToast, "id">;
Expand Down Expand Up @@ -176,7 +176,7 @@ function useToast() {
listeners.splice(index, 1);
}
};
}, [state]);
}, []);

return {
...state,
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/use-version.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function useVersion() {
}
}
} catch (e) {
console.error("Unable to retrieve latest version from GitHub");
console.error(`Unable to retrieve latest version from GitHub: ${e}`);
}
};

Expand Down
43 changes: 24 additions & 19 deletions client/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,41 @@ const fetcher = async ({

if (method === "POST") {
if (body instanceof FormData) {
// @ts-expect-error - Suppressing potentially undefined options header
delete options.headers["Content-Type"];
if (options.headers && typeof options.headers === 'object') {
// Create new headers object without Content-Type
options.headers = Object.fromEntries(
Object.entries(options.headers as Record<string, string>)
.filter(([key]) => key !== 'Content-Type')
);
}
options.body = body;
} else {
options.body = JSON.stringify(body);
}
}

return fetch(`${BASE_URL}${url}`, options).then(async (resp) => {
if (resp.ok) {
const contentType = resp.headers.get("Content-Type");

if (contentType === "audio/mpeg") {
return await resp.blob();
}
return resp.json();
const contentType = resp.headers.get('Content-Type');
if (contentType === "audio/mpeg") {
return await resp.blob();
}

const errorText = await resp.text();
console.error("Error: ", errorText);
if (!resp.ok) {
const errorText = await resp.text();
console.error("Error: ", errorText);

let errorMessage = "An error occurred.";
try {
const errorObj = JSON.parse(errorText);
errorMessage = errorObj.message || errorMessage;
} catch {
errorMessage = errorText || errorMessage;
}
let errorMessage = "An error occurred.";
try {
const errorObj = JSON.parse(errorText);
errorMessage = errorObj.message || errorMessage;
} catch {
errorMessage = errorText || errorMessage;
}

throw new Error(errorMessage);
throw new Error(errorMessage);
}

return resp.json();
});
};

Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/info.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version": "0.1.9-alpha.1"}
{"version": "0.1.9"}
8 changes: 7 additions & 1 deletion client/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { createRoot } from "react-dom/client";
import "./index.css";
import App from "./App.tsx";

createRoot(document.getElementById("root")!).render(
const rootElement = document.getElementById("root");

if (!rootElement) {
throw new Error("Root element not found");
}

createRoot(rootElement).render(
<StrictMode>
<App />
</StrictMode>
Expand Down
Loading

0 comments on commit d53e10a

Please sign in to comment.