Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions web/src/app/api/local-agent/cron-tool-execute/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
resolveWorkspacePath,
createLocalToolRegistry,
executeLocalToolCall,
syncWorkspaceFileToBackend,
syncAgentContextFileToBackend,
} from "@/lib/agent/tools/local-execution";
import { INTERNAL_URL } from "@/lib/constants";

Expand Down Expand Up @@ -66,15 +66,15 @@ export async function POST(request: NextRequest): Promise<Response> {
// Execute the tool
const result = await executeLocalToolCall(registry, toolName, toolInput || {});

// Sync workspace file to backend DB after write/edit operations
// Sync agent context file to backend DB after write/edit operations
if (
(toolName === "write_file" || toolName === "edit_file") &&
result.output &&
toolInput?.path
) {
const cookieStr = await getCookieString();
const base = INTERNAL_URL || "http://localhost:8080";
syncWorkspaceFileToBackend(
syncAgentContextFileToBackend(
resolvedPath,
toolInput.path as string,
base,
Expand Down
24 changes: 12 additions & 12 deletions web/src/components/desktop/AgentConfigView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import { useState, useEffect, useCallback } from "react";
import { AgentConfigSkeleton } from "./AgentConfigSkeleton";

interface WorkspaceFile {
interface AgentContextFile {
path: string;
content: string;
created_at: string;
updated_at: string;
}

export function AgentConfigView() {
const [files, setFiles] = useState<WorkspaceFile[]>([]);
const [files, setFiles] = useState<AgentContextFile[]>([]);
const [selectedPath, setSelectedPath] = useState<string | null>(null);
const [editorContent, setEditorContent] = useState("");
const [savedContent, setSavedContent] = useState("");
Expand All @@ -24,9 +24,9 @@ export function AgentConfigView() {
const fetchFiles = useCallback(async () => {
try {
setLoading(true);
const resp = await fetch("/api/agent/workspace-files");
if (!resp.ok) throw new Error("Failed to fetch workspace files");
const data = (await resp.json()) as { files: WorkspaceFile[] };
const resp = await fetch("/api/agent/context");
if (!resp.ok) throw new Error("Failed to fetch context files");
const data = (await resp.json()) as { files: AgentContextFile[] };
setFiles(data.files);
const firstFile = data.files[0];
if (firstFile && !selectedPath) {
Expand Down Expand Up @@ -57,10 +57,10 @@ export function AgentConfigView() {
.map(encodeURIComponent)
.join("/");
const resp = await fetch(
`/api/agent/workspace-files/${encodedPath}`
`/api/agent/context/${encodedPath}`
);
if (!resp.ok) throw new Error("Failed to read file");
const data = (await resp.json()) as WorkspaceFile;
const data = (await resp.json()) as AgentContextFile;
setSelectedPath(path);
setEditorContent(data.content);
setSavedContent(data.content);
Expand All @@ -78,17 +78,17 @@ export function AgentConfigView() {
if (!selectedPath) return;
try {
setSaving(true);
const resp = await fetch("/api/agent/workspace-files", {
const resp = await fetch("/api/agent/context", {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ path: selectedPath, content: editorContent }),
});
if (!resp.ok) throw new Error("Failed to save file");
setSavedContent(editorContent);
// Refresh file list to update timestamps
const listResp = await fetch("/api/agent/workspace-files");
const listResp = await fetch("/api/agent/context");
if (listResp.ok) {
const data = (await listResp.json()) as { files: WorkspaceFile[] };
const data = (await listResp.json()) as { files: AgentContextFile[] };
setFiles(data.files);
}
} catch (err) {
Expand Down Expand Up @@ -118,13 +118,13 @@ export function AgentConfigView() {
Configuration
</h1>
<p className="text-sm text-text-02">
View and edit workspace files that persist across agent sessions.
View and edit context files that persist across agent sessions.
</p>
</div>

{files.length === 0 ? (
<div className="flex-1 flex items-center justify-center text-text-02">
No workspace files found. Start a conversation with the Bud Agent
No context files found. Start a conversation with the Bud Agent
to create them.
</div>
) : (
Expand Down
8 changes: 4 additions & 4 deletions web/src/lib/agent/tools/local-execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ export async function executeLocalToolCall(
}

/**
* Sync a workspace file to the backend database after a local write/edit.
* Sync an agent context file to the backend database after a local write/edit.
* This ensures the backend sees file updates
* made through the agent's file tools.
*/
export async function syncWorkspaceFileToBackend(
export async function syncAgentContextFileToBackend(
workspacePath: string,
filePath: string,
apiBaseUrl: string,
Expand All @@ -154,7 +154,7 @@ export async function syncWorkspaceFileToBackend(

const content = fs.readFileSync(resolvedPath, "utf-8");

const resp = await fetch(`${apiBaseUrl}/api/agent/workspace-files`, {
const resp = await fetch(`${apiBaseUrl}/api/agent/context`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Expand All @@ -164,7 +164,7 @@ export async function syncWorkspaceFileToBackend(
});

if (!resp.ok) {
console.warn(`Failed to sync workspace file ${filePath}: ${resp.status}`);
console.warn(`Failed to sync context file ${filePath}: ${resp.status}`);
}
} catch {
// Non-critical: don't let sync failures affect tool execution
Expand Down
16 changes: 8 additions & 8 deletions web/src/lib/agent/tools/tool-catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,33 +501,33 @@ export const TOOL_CATALOG: ToolCatalogEntry[] = [
],
},
{
name: "workspace_read",
name: "context_read",
description:
"Read a workspace file by path. Workspace files are persistent documents like SOUL.md, USER.md, IDENTITY.md, AGENTS.md, and MEMORY.md.",
"Read a context file by path. Context files are persistent documents like SOUL.md, USER.md, IDENTITY.md, AGENTS.md, and MEMORY.md.",
category: "remote",
requiresApproval: false,
parameters: [
{
name: "path",
type: "string",
description:
"The workspace file path to read. Example: 'SOUL.md', 'USER.md'.",
"The context file path to read. Example: 'SOUL.md', 'USER.md'.",
required: true,
},
],
},
{
name: "workspace_write",
name: "context_write",
description:
"Create or update a workspace file. Use this to persist documents like SOUL.md, USER.md, IDENTITY.md, AGENTS.md, and MEMORY.md.",
"Create or update a context file. Use this to persist documents like SOUL.md, USER.md, IDENTITY.md, AGENTS.md, and MEMORY.md.",
category: "remote",
requiresApproval: false,
parameters: [
{
name: "path",
type: "string",
description:
"The workspace file path to write. Example: 'SOUL.md', 'USER.md'.",
"The context file path to write. Example: 'SOUL.md', 'USER.md'.",
required: true,
},
{
Expand All @@ -539,9 +539,9 @@ export const TOOL_CATALOG: ToolCatalogEntry[] = [
],
},
{
name: "workspace_list",
name: "context_list",
description:
"List workspace files, optionally filtered by a path prefix. Use this to discover available workspace files.",
"List context files, optionally filtered by a path prefix. Use this to discover available context files.",
category: "remote",
requiresApproval: false,
parameters: [
Expand Down
Loading