Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into chore/dynamic-pl…
Browse files Browse the repository at this point in the history
…ugins
  • Loading branch information
ChristopherTrimboli committed Dec 27, 2024
2 parents d77f058 + c9be71e commit df634eb
Show file tree
Hide file tree
Showing 362 changed files with 9,041 additions and 3,956 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/jsdoc-automation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: JSDoc Automation

on:
workflow_dispatch:
inputs:
pull_number:
description: 'Pull Request Number (if not provided, scans root_directory) - PR must be merged to develop branch'
required: false
type: string
root_directory:
description: 'Only scans files in this directory (relative to repository root, e.g., packages/core/src)'
required: true
default: 'packages/core/src/test_resources'
type: string
excluded_directories:
description: 'Directories to exclude from scanning (comma-separated, relative to root_directory)'
required: true
default: 'node_modules,dist,test'
type: string
reviewers:
description: 'Pull Request Reviewers (comma-separated GitHub usernames)'
required: true
default: ''
type: string

jobs:
generate-docs:
runs-on: ubuntu-latest

env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_PAT }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '23'

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Update lockfile
working-directory: packages/jsdoc-automation
run: |
echo "Updating lockfile..."
pnpm install --no-frozen-lockfile
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add pnpm-lock.yaml
git commit -m "chore: update pnpm lockfile" || echo "No changes to commit"
git push || echo "No changes to push"
- name: Install root dependencies
run: pnpm install --no-frozen-lockfile

- name: Install package dependencies
working-directory: packages/jsdoc-automation
run: pnpm install --no-frozen-lockfile

- name: Run documentation generator
working-directory: packages/jsdoc-automation
run: |
echo "Node version: $(node --version)"
echo "NPM version: $(npm --version)"
echo "Directory contents:"
ls -la
NODE_OPTIONS='--experimental-vm-modules --no-warnings' pnpm start
env:
INPUT_ROOT_DIRECTORY: ${{ inputs.root_directory }}
INPUT_PULL_NUMBER: ${{ inputs.pull_number }}
INPUT_EXCLUDED_DIRECTORIES: ${{ inputs.excluded_directories }}
INPUT_REVIEWERS: ${{ inputs.reviewers }}
1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@elizaos/plugin-multiversx": "workspace:*",
"@elizaos/plugin-near": "workspace:*",
"@elizaos/plugin-zksync-era": "workspace:*",
"@elizaos/plugin-twitter": "workspace:*",
"@elizaos/plugin-cronoszkevm": "workspace:*",
"@elizaos/plugin-3d-generation": "workspace:*",
"readline": "1.3.0",
Expand Down
82 changes: 69 additions & 13 deletions client/src/Chat.tsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,75 @@
import { useState } from "react";
import { useRef, useState } from "react";
import { useParams } from "react-router-dom";
import { useMutation } from "@tanstack/react-query";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { ImageIcon } from "lucide-react";
import { Input } from "@/components/ui/input";
import "./App.css";
import path from "path";

type TextResponse = {
text: string;
user: string;
attachments?: { url: string; contentType: string; title: string }[];
};

export default function Chat() {
const { agentId } = useParams();
const [input, setInput] = useState("");
const [messages, setMessages] = useState<TextResponse[]>([]);
const [selectedFile, setSelectedFile] = useState<File | null>(null);
const fileInputRef = useRef<HTMLInputElement>(null);

const mutation = useMutation({
mutationFn: async (text: string) => {
const formData = new FormData();
formData.append("text", text);
formData.append("userId", "user");
formData.append("roomId", `default-room-${agentId}`);

if (selectedFile) {
formData.append("file", selectedFile);
}

const res = await fetch(`/api/${agentId}/message`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
text,
userId: "user",
roomId: `default-room-${agentId}`,
}),
body: formData,
});
return res.json() as Promise<TextResponse[]>;
},
onSuccess: (data) => {
setMessages((prev) => [...prev, ...data]);
setSelectedFile(null);
},
});

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (!input.trim()) return;
if (!input.trim() && !selectedFile) return;

// Add user message immediately to state
const userMessage: TextResponse = {
text: input,
user: "user",
attachments: selectedFile ? [{ url: URL.createObjectURL(selectedFile), contentType: selectedFile.type, title: selectedFile.name }] : undefined,
};
setMessages((prev) => [...prev, userMessage]);

mutation.mutate(input);
setInput("");
};

const handleFileSelect = () => {
fileInputRef.current?.click();
};

const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0];
if (file && file.type.startsWith('image/')) {
setSelectedFile(file);
}
};

return (
<div className="flex flex-col h-screen max-h-screen w-full">
<div className="flex-1 min-h-0 overflow-y-auto p-4">
Expand All @@ -58,7 +78,7 @@ export default function Chat() {
messages.map((message, index) => (
<div
key={index}
className={`flex ${
className={`text-left flex ${
message.user === "user"
? "justify-end"
: "justify-start"
Expand All @@ -72,7 +92,22 @@ export default function Chat() {
}`}
>
{message.text}
</div>
{message.attachments?.map((attachment, i) => (
attachment.contentType.startsWith('image/') && (
<img
key={i}
src={message.user === "user"
? attachment.url
: attachment.url.startsWith('http')
? attachment.url
: `http://localhost:3000/media/generated/${attachment.url.split('/').pop()}`
}
alt={attachment.title || "Attached image"}
className="mt-2 max-w-full rounded-lg"
/>
)
))}
</div>
</div>
))
) : (
Expand All @@ -86,17 +121,38 @@ export default function Chat() {
<div className="border-t p-4 bg-background">
<div className="max-w-3xl mx-auto">
<form onSubmit={handleSubmit} className="flex gap-2">
<input
type="file"
ref={fileInputRef}
onChange={handleFileChange}
accept="image/*"
className="hidden"
/>
<Input
value={input}
onChange={(e) => setInput(e.target.value)}
placeholder="Type a message..."
className="flex-1"
disabled={mutation.isPending}
/>
<Button
type="button"
variant="outline"
size="icon"
onClick={handleFileSelect}
disabled={mutation.isPending}
>
<ImageIcon className="h-4 w-4" />
</Button>
<Button type="submit" disabled={mutation.isPending}>
{mutation.isPending ? "..." : "Send"}
</Button>
</form>
{selectedFile && (
<div className="mt-2 text-sm text-muted-foreground">
Selected file: {selectedFile.name}
</div>
)}
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit df634eb

Please sign in to comment.