Skip to content

Commit f85ab78

Browse files
authored
chore: Refact collections and mcp inspector (#1904)
* wip * Implement migration to remove modelsBindingConnectionId and enhance organization settings - Added a new migration script to remove the modelsBindingConnectionId column from the organization_settings table, addressing SQLite's limitations with direct column drops. - Updated the OrganizationSettingsStorage and related hooks to reflect the removal of the modelsBindingConnectionId. - Introduced new hooks for managing agents and models, enhancing the overall functionality of the application. - Added an empty state component for improved user experience in the UI. - Updated various components and routes to accommodate the changes in organization settings and connections. This commit aims to streamline the organization settings management and improve the integration of agents and models within the application. * Refactor model bindings to use language model binding - Replaced instances of MODELS_BINDING with LANGUAGE_MODEL_BINDING in connection and model hooks. - Updated tool call references from COLLECTION_MODELS_LIST to COLLECTION_LLM_LIST. - Removed the deprecated models.ts file and adjusted related schemas to support language model operations. - Enhanced the language model binding to include new schemas and operations for AI models. This commit streamlines the integration of language models into the application, improving functionality and consistency. * Update dependencies and refactor imports to use Zod v3 - Updated package.json files across multiple applications to include Zod v3 as a dependency. - Refactored import statements in various files to utilize the new Zod v3 syntax. - Ensured compatibility with existing schemas and validation logic. This commit enhances the project's dependency management and ensures the use of the latest Zod features for schema validation. * fmt * fmt&lint * test * test * test * wip * Refactor sidebar state management to use local storage - Replaced the useState hook for sidebarOpen with useLocalStorage to persist the sidebar state across sessions. - This change enhances user experience by maintaining the sidebar's open/closed state even after page reloads. * Refactor connection and collection management components - Updated the ConnectionEntitySchema to enforce string types for created_at and updated_at fields, simplifying date handling. - Introduced new components for agent and collection item details, enhancing the UI for managing agents and collections. - Replaced the deprecated CollectionItemsList component with CollectionsList for improved data display and interaction. - Refactored routes to accommodate new item detail views and streamlined navigation for better user experience. - Implemented caching for collection instances to optimize performance and reduce redundant API calls. This commit enhances the overall structure and usability of the connection and collection management features. * wip * fmtlint * Refactor collections management components - Removed the deprecated CollectionsList component and replaced it with a new structure that includes CollectionCard and CollectionTable for improved data display. - Introduced CollectionsList component to manage both card and table views, enhancing user interaction with collection items. - Added user indicators and action menus for better item management within collections. - Implemented schema handling for collections to streamline data rendering and interaction. - Updated routes to utilize the new collections components, improving navigation and usability. This commit significantly enhances the collections management experience by providing a more flexible and user-friendly interface. * feat: implement MCP tool inspection view with execution stats * more refactoring * wip
1 parent b0bb88b commit f85ab78

213 files changed

Lines changed: 6223 additions & 3615 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cursor/rules/api-development.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This guide provides a step-by-step process for adding new APIs to the decocms sy
1919
### 1.1 Basic File Structure
2020

2121
```typescript
22-
import { z } from "zod";
22+
import { z } from "zod/v3";
2323
import { UserInputError } from "../../errors.ts";
2424
import type { QueryResult } from "../../storage/index.ts";
2525
import {

.cursor/rules/react-ts.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ import { Card, CardContent, CardHeader } from "@deco/ui/components/card.tsx";
189189
// ✅ Good - Use react-hook-form with proper validation
190190
import { useForm } from "react-hook-form";
191191
import { zodResolver } from "@hookform/resolvers/zod";
192-
import { z } from "zod";
192+
import { z } from "zod/v3";
193193

194194
const schema = z.object({
195195
email: z.string().email("Please enter a valid email address"),

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
- name: Install dependencies
2323
run: bun install
2424

25+
- name: Build deps
26+
run: bun run build
27+
working-directory: packages/bindings
28+
2529
- name: Run format
2630
run: bun run fmt:check
2731

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ The **MCP Mesh** is the backbone of Deco — a distributed runtime that manages
8181
_On the hosted platform, usage is metered by MCP calls._
8282

8383
```ts
84-
import { z } from "zod";
84+
import { z } from "zod/v3";
8585
import { defineTool } from "~/core/define-tool";
8686

8787
export const CONNECTION_CREATE = defineTool({

apps/api/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ import { HTTPException } from "hono/http-exception";
7474
import { endTime, startTime } from "hono/timing";
7575
import type { ContentfulStatusCode } from "hono/utils/http-status";
7676
import { studio } from "outerbase-browsable-do-enforced";
77-
import { z } from "zod";
77+
import { z } from "zod/v3";
7878
import { convertJsonSchemaToZod } from "zod-from-json-schema";
7979
import { ROUTES as loginRoutes } from "./auth/index.ts";
8080
import { handleDecopilotStream } from "./decopilot-stream.ts";

apps/api/src/decopilot-stream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
tool,
2525
} from "ai";
2626
import type { Context } from "hono";
27-
import { z } from "zod";
27+
import { z } from "zod/v3";
2828
import { honoCtxToAppCtx } from "./api.ts";
2929
import type { AppEnv } from "./utils/context.ts";
3030
import { State } from "./utils/context.ts";
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/**
2+
* Connection Schema Alignment Migration
3+
*
4+
* Renames columns in the connections table to match ConnectionEntitySchema:
5+
* - camelCase → snake_case
6+
* - name → title (to match BaseCollectionEntitySchema convention)
7+
*
8+
* This eliminates the need for connectionToEntity transformation.
9+
*/
10+
11+
import { Kysely } from "kysely";
12+
13+
export async function up(db: Kysely<unknown>): Promise<void> {
14+
// Rename columns to snake_case and align with entity schema
15+
await db.schema
16+
.alterTable("connections")
17+
.renameColumn("name", "title")
18+
.execute();
19+
20+
await db.schema
21+
.alterTable("connections")
22+
.renameColumn("createdById", "created_by")
23+
.execute();
24+
25+
await db.schema
26+
.alterTable("connections")
27+
.renameColumn("createdAt", "created_at")
28+
.execute();
29+
30+
await db.schema
31+
.alterTable("connections")
32+
.renameColumn("updatedAt", "updated_at")
33+
.execute();
34+
35+
await db.schema
36+
.alterTable("connections")
37+
.renameColumn("organizationId", "organization_id")
38+
.execute();
39+
40+
await db.schema
41+
.alterTable("connections")
42+
.renameColumn("connectionType", "connection_type")
43+
.execute();
44+
45+
await db.schema
46+
.alterTable("connections")
47+
.renameColumn("connectionUrl", "connection_url")
48+
.execute();
49+
50+
await db.schema
51+
.alterTable("connections")
52+
.renameColumn("connectionToken", "connection_token")
53+
.execute();
54+
55+
await db.schema
56+
.alterTable("connections")
57+
.renameColumn("connectionHeaders", "connection_headers")
58+
.execute();
59+
60+
await db.schema
61+
.alterTable("connections")
62+
.renameColumn("oauthConfig", "oauth_config")
63+
.execute();
64+
65+
await db.schema
66+
.alterTable("connections")
67+
.renameColumn("appName", "app_name")
68+
.execute();
69+
70+
await db.schema
71+
.alterTable("connections")
72+
.renameColumn("appId", "app_id")
73+
.execute();
74+
}
75+
76+
export async function down(db: Kysely<unknown>): Promise<void> {
77+
// Revert column names back to camelCase
78+
await db.schema
79+
.alterTable("connections")
80+
.renameColumn("title", "name")
81+
.execute();
82+
83+
await db.schema
84+
.alterTable("connections")
85+
.renameColumn("created_by", "createdById")
86+
.execute();
87+
88+
await db.schema
89+
.alterTable("connections")
90+
.renameColumn("created_at", "createdAt")
91+
.execute();
92+
93+
await db.schema
94+
.alterTable("connections")
95+
.renameColumn("updated_at", "updatedAt")
96+
.execute();
97+
98+
await db.schema
99+
.alterTable("connections")
100+
.renameColumn("organization_id", "organizationId")
101+
.execute();
102+
103+
await db.schema
104+
.alterTable("connections")
105+
.renameColumn("connection_type", "connectionType")
106+
.execute();
107+
108+
await db.schema
109+
.alterTable("connections")
110+
.renameColumn("connection_url", "connectionUrl")
111+
.execute();
112+
113+
await db.schema
114+
.alterTable("connections")
115+
.renameColumn("connection_token", "connectionToken")
116+
.execute();
117+
118+
await db.schema
119+
.alterTable("connections")
120+
.renameColumn("connection_headers", "connectionHeaders")
121+
.execute();
122+
123+
await db.schema
124+
.alterTable("connections")
125+
.renameColumn("oauth_config", "oauthConfig")
126+
.execute();
127+
128+
await db.schema
129+
.alterTable("connections")
130+
.renameColumn("app_name", "appName")
131+
.execute();
132+
133+
await db.schema
134+
.alterTable("connections")
135+
.renameColumn("app_id", "appId")
136+
.execute();
137+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { Kysely } from "kysely";
2+
3+
export async function up(db: Kysely<unknown>): Promise<void> {
4+
// SQLite doesn't support DROP COLUMN directly, so we need to recreate the table
5+
// First, create a new table without the modelsBindingConnectionId column
6+
await db.schema
7+
.createTable("organization_settings_new")
8+
.addColumn("organizationId", "text", (col) => col.primaryKey())
9+
.addColumn("createdAt", "text", (col) => col.notNull())
10+
.addColumn("updatedAt", "text", (col) => col.notNull())
11+
.execute();
12+
13+
// Copy data from old table to new table
14+
await db
15+
.insertInto("organization_settings_new" as never)
16+
.columns(["organizationId", "createdAt", "updatedAt"] as never)
17+
.expression((eb) =>
18+
eb
19+
.selectFrom("organization_settings" as never)
20+
.select([
21+
"organizationId" as never,
22+
"createdAt" as never,
23+
"updatedAt" as never,
24+
]),
25+
)
26+
.execute();
27+
28+
// Drop old table
29+
await db.schema.dropTable("organization_settings").execute();
30+
31+
// Rename new table to original name
32+
await db.schema
33+
.alterTable("organization_settings_new")
34+
.renameTo("organization_settings")
35+
.execute();
36+
}
37+
38+
export async function down(db: Kysely<unknown>): Promise<void> {
39+
// Re-add the modelsBindingConnectionId column by recreating the table
40+
await db.schema
41+
.createTable("organization_settings_new")
42+
.addColumn("organizationId", "text", (col) => col.primaryKey())
43+
.addColumn("modelsBindingConnectionId", "text", (col) =>
44+
col.references("connections.id").onDelete("set null"),
45+
)
46+
.addColumn("createdAt", "text", (col) => col.notNull())
47+
.addColumn("updatedAt", "text", (col) => col.notNull())
48+
.execute();
49+
50+
// Copy data from current table
51+
await db
52+
.insertInto("organization_settings_new" as never)
53+
.columns([
54+
"organizationId",
55+
"modelsBindingConnectionId",
56+
"createdAt",
57+
"updatedAt",
58+
] as never)
59+
.expression((eb) =>
60+
eb
61+
.selectFrom("organization_settings" as never)
62+
.select([
63+
"organizationId" as never,
64+
eb.val(null).as("modelsBindingConnectionId"),
65+
"createdAt" as never,
66+
"updatedAt" as never,
67+
]),
68+
)
69+
.execute();
70+
71+
// Drop current table
72+
await db.schema.dropTable("organization_settings").execute();
73+
74+
// Rename new table to original name
75+
await db.schema
76+
.alterTable("organization_settings_new")
77+
.renameTo("organization_settings")
78+
.execute();
79+
}

apps/mesh/migrations/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { type Migration } from "kysely";
2-
import * as migration_001_initial_schema from "./001-initial-schema.ts";
3-
import * as migration_002_organization_settings from "./002-organization-settings.ts";
2+
import * as migration001initialschema from "./001-initial-schema.ts";
3+
import * as migration002organizationsettings from "./002-organization-settings.ts";
4+
import * as migration003connectionschemaalign from "./003-connection-schema-align.ts";
5+
import * as migration004removemodelsbinding from "./004-remove-models-binding.ts";
46

57
const migrations = {
6-
"001-initial-schema": migration_001_initial_schema,
7-
"002-organization-settings": migration_002_organization_settings,
8+
"001-initial-schema": migration001initialschema,
9+
"002-organization-settings": migration002organizationsettings,
10+
"003-connection-schema-align": migration003connectionschemaalign,
11+
"004-remove-models-binding": migration004removemodelsbinding,
812
} satisfies Record<string, Migration>;
913

1014
export default migrations;

apps/mesh/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"db:migrate": "bun run ./dist-server/migrate.js",
1111
"check": "tsc --noEmit",
1212
"start": "bun run ./dist-server/server.js",
13-
"migrate": "bun run scripts/generate-migrations.ts",
13+
"migrate": "bun run src/database/migrate.ts",
1414
"test": "bun test .",
1515
"better-auth:migrate": "bunx --bun @better-auth/cli migrate -y --config src/auth/index.ts"
1616
},
@@ -68,7 +68,7 @@
6868
"tailwind-merge": "^3.3.1",
6969
"tailwindcss": "^4.1.17",
7070
"use-mcp": "^0.0.21",
71-
"zod": "^4.1.12"
71+
"zod": "^4.1.13"
7272
},
7373
"devDependencies": {
7474
"@better-auth/cli": "1.4.1",

0 commit comments

Comments
 (0)