Skip to content

Commit 25072e0

Browse files
committed
feat: update imports in suggestions route and ArticleExtractPanel for chat-agent-toolkit; enhance package.json exports
1 parent 8f1f0fe commit 25072e0

38 files changed

Lines changed: 1301 additions & 1295 deletions

File tree

apps/qwksearch-web/app/api/agent/agents/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* resolves the user's API key (or falls back to server-side keys), and
44
* generates a language model response.
55
*/
6-
import { generateLanguageResponse } from "ai-research-agent/agents/generate-language";
6+
import { generateLanguageResponse } from "chat-agent-toolkit/agents/generate-language";
77
import { NextRequest, NextResponse } from "next/server";
88
import { getUserId } from "@/lib/auth/session";
99
import { getDB } from "@/lib/database";

apps/qwksearch-web/app/api/agent/autocomplete/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* search-engine suggest APIs and returns a deduplicated list of suggestions.
44
*/
55
import { NextRequest, NextResponse } from "next/server";
6-
import { searchAutocompleteMulti } from "ai-research-agent/suggest-next-words/autocomplete-search-engines";
6+
import { searchAutocompleteMulti } from "chat-agent-toolkit/suggest-next-words/autocomplete-search-engines";
77

88
const DEFAULT_BACKENDS = ["google", "duckduckgo", "wikipedia"];
99

Lines changed: 100 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,100 @@
1-
/**
2-
* @fileoverview Chat session list management. GET returns all chat sessions
3-
* for the authenticated user with message counts. DELETE removes all of the
4-
* user's chat sessions and their associated messages.
5-
*/
6-
import { getDB } from "@/lib/database";
7-
import { chats, messages } from "@/lib/database/schema";
8-
import { eq, and, inArray, sql, count } from "drizzle-orm";
9-
import { requireUserId } from "@/lib/auth/session";
10-
11-
export const GET = async (req: Request) => {
12-
try {
13-
const db = getDB();
14-
// Require authentication
15-
const userId = await requireUserId();
16-
17-
// Get user's chats with message counts
18-
const userChats = await db
19-
.select({
20-
id: chats.id,
21-
title: chats.title,
22-
createdAt: chats.createdAt,
23-
focusMode: chats.focusMode,
24-
userId: chats.userId,
25-
files: chats.files,
26-
messageCount: count(messages.id),
27-
})
28-
.from(chats)
29-
.leftJoin(
30-
messages,
31-
and(eq(messages.chatId, chats.id), eq(messages.role, "user")),
32-
)
33-
.where(eq(chats.userId, userId))
34-
.groupBy(
35-
chats.id,
36-
chats.title,
37-
chats.createdAt,
38-
chats.focusMode,
39-
chats.userId,
40-
chats.files,
41-
)
42-
.orderBy(sql`${chats.createdAt} DESC`);
43-
44-
return Response.json({ chats: userChats }, { status: 200 });
45-
} catch (err) {
46-
// Handle auth errors
47-
if (err instanceof Error && err.message === "Unauthorized") {
48-
return Response.json(
49-
{ message: "Authentication required" },
50-
{ status: 401 },
51-
);
52-
}
53-
54-
console.error("Error in getting chats: ", err);
55-
return Response.json(
56-
{ message: "An error has occurred." },
57-
{ status: 500 },
58-
);
59-
}
60-
};
61-
62-
export const DELETE = async (req: Request) => {
63-
try {
64-
const db = getDB();
65-
// Require authentication
66-
const userId = await requireUserId();
67-
68-
// Get all chat IDs for the user
69-
const userChats = await db.query.chats.findMany({
70-
where: eq(chats.userId, userId),
71-
columns: { id: true },
72-
});
73-
74-
if (userChats.length > 0) {
75-
const chatIds = userChats.map((chat) => chat.id);
76-
77-
// Delete all messages for these chats first
78-
await db.delete(messages).where(inArray(messages.chatId, chatIds));
79-
80-
// Delete all chats for the user
81-
await db.delete(chats).where(eq(chats.userId, userId));
82-
}
83-
84-
return Response.json({ message: "All chats deleted" }, { status: 200 });
85-
} catch (err) {
86-
// Handle auth errors
87-
if (err instanceof Error && err.message === "Unauthorized") {
88-
return Response.json(
89-
{ message: "Authentication required" },
90-
{ status: 401 },
91-
);
92-
}
93-
94-
console.error("Error in deleting all chats: ", err);
95-
return Response.json(
96-
{ message: "An error has occurred." },
97-
{ status: 500 },
98-
);
99-
}
100-
};
1+
/**
2+
* @fileoverview Chat session list management. GET returns all chat sessions
3+
* for the authenticated user with message counts. DELETE removes all of the
4+
* user's chat sessions and their associated messages.
5+
*/
6+
import { getDB } from "@/lib/database";
7+
import { chats, messages } from "@/lib/database/schema";
8+
import { eq, and, inArray, sql, count } from "drizzle-orm";
9+
import { requireUserId } from "@/lib/auth/session";
10+
11+
export const GET = async (req: Request) => {
12+
try {
13+
const db = getDB();
14+
// Require authentication
15+
const userId = await requireUserId();
16+
17+
// Get user's chats with message counts
18+
const userChats = await db
19+
.select({
20+
id: chats.id,
21+
title: chats.title,
22+
createdAt: chats.createdAt,
23+
focusMode: chats.focusMode,
24+
userId: chats.userId,
25+
files: chats.files,
26+
messageCount: count(messages.id),
27+
})
28+
.from(chats)
29+
.leftJoin(
30+
messages,
31+
and(eq(messages.chatId, chats.id), eq(messages.role, "user")),
32+
)
33+
.where(eq(chats.userId, userId))
34+
.groupBy(
35+
chats.id,
36+
chats.title,
37+
chats.createdAt,
38+
chats.focusMode,
39+
chats.userId,
40+
chats.files,
41+
)
42+
.orderBy(sql`${chats.createdAt} DESC`);
43+
44+
return Response.json({ chats: userChats }, { status: 200 });
45+
} catch (err) {
46+
// Handle auth errors
47+
if (err instanceof Error && err.message === "Unauthorized") {
48+
return Response.json(
49+
{ message: "Authentication required" },
50+
{ status: 401 },
51+
);
52+
}
53+
54+
console.error("Error in getting chats: ", err);
55+
return Response.json(
56+
{ message: "An error has occurred." },
57+
{ status: 500 },
58+
);
59+
}
60+
};
61+
62+
export const DELETE = async (req: Request) => {
63+
try {
64+
const db = getDB();
65+
// Require authentication
66+
const userId = await requireUserId();
67+
68+
// Get all chat IDs for the user
69+
const userChats = await db.query.chats.findMany({
70+
where: eq(chats.userId, userId),
71+
columns: { id: true },
72+
});
73+
74+
if (userChats.length > 0) {
75+
const chatIds = userChats.map((chat) => chat.id);
76+
77+
// Delete all messages for these chats first
78+
await db.delete(messages).where(inArray(messages.chatId, chatIds));
79+
80+
// Delete all chats for the user
81+
await db.delete(chats).where(eq(chats.userId, userId));
82+
}
83+
84+
return Response.json({ message: "All chats deleted" }, { status: 200 });
85+
} catch (err) {
86+
// Handle auth errors
87+
if (err instanceof Error && err.message === "Unauthorized") {
88+
return Response.json(
89+
{ message: "Authentication required" },
90+
{ status: 401 },
91+
);
92+
}
93+
94+
console.error("Error in deleting all chats: ", err);
95+
return Response.json(
96+
{ message: "An error has occurred." },
97+
{ status: 500 },
98+
);
99+
}
100+
};

apps/qwksearch-web/app/api/agent/discover/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* category (tech, finance, art, sports, entertainment) from curated sources
44
* via SearXNG news search. Supports normal and preview modes.
55
*/
6-
import { searchSearxng } from "ai-research-agent/search/public-searxng";
6+
import { searchSearxng } from "chat-agent-toolkit/search/public-searxng";
77

88
const websitesForTopic = {
99
tech: {

apps/qwksearch-web/app/api/agent/providers/EXAMPLE_INTEGRATION.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* DO NOT use this file directly - it's a reference implementation.
88
*/
99

10-
import ModelRegistry from "ai-research-agent/models/registry";
10+
import ModelRegistry from "chat-agent-toolkit/models/registry";
1111
import { NextRequest } from "next/server";
1212
import { filterModelsForGuests } from "@/lib/utils/guest-model-filter";
1313

apps/qwksearch-web/app/api/agent/providers/[id]/models/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @fileoverview Provider model management. POST adds a new chat model to
33
* a provider. DELETE removes a specific model from a provider by key.
44
*/
5-
import ModelRegistry from "ai-research-agent/models/registry";
6-
import { Model } from "ai-research-agent/models/types";
5+
import ModelRegistry from "chat-agent-toolkit/models/registry";
6+
import { Model } from "chat-agent-toolkit/models/types";
77
import { NextRequest } from "next/server";
88

99
export const POST = async (

apps/qwksearch-web/app/api/agent/providers/[id]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @fileoverview Single model provider operations. DELETE removes a provider
33
* by ID. PATCH updates an existing provider's name and configuration.
44
*/
5-
import ModelRegistry from "ai-research-agent/models/registry";
5+
import ModelRegistry from "chat-agent-toolkit/models/registry";
66
import { NextRequest } from "next/server";
77

88
export const DELETE = async (

apps/qwksearch-web/app/api/agent/providers/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* and their available chat models. POST registers a new provider with its
44
* type, name, and API configuration.
55
*/
6-
import ModelRegistry from "ai-research-agent/models/registry";
6+
import ModelRegistry from "chat-agent-toolkit/models/registry";
77
import { NextRequest } from "next/server";
88

99
export const GET = async (req: Request) => {

apps/qwksearch-web/app/api/agent/search/__tests__/route.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import { GET } from "../route";
55
import { NextRequest } from "next/server";
6-
import { searchWeb } from "ai-research-agent/search/public-searxng";
6+
import { searchWeb } from "chat-agent-toolkit/search/public-searxng";
77

88
// Mock the searchWeb function
99
jest.mock("ai-research-agent/search/public-searxng", () => ({

apps/qwksearch-web/app/api/agent/search/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* recency, and pagination. Falls back to public instances on empty results.
55
*/
66
import { NextRequest, NextResponse } from "next/server";
7-
import { searchWeb } from "ai-research-agent/search/public-searxng";
7+
import { searchWeb } from "chat-agent-toolkit/search/public-searxng";
88

99
export async function GET(req: NextRequest) {
1010
const url = new URL(req.url);

0 commit comments

Comments
 (0)