feat(tool-config): add categories, interfaces, and config management
Add support for tool categories, interface types, and per-tool configuration. Backend: - Add category and interfaces fields to ToolType model - Create ToolConfig model for storing tool-specific settings - Add tool_configs API endpoints (CRUD) - Update built-in tool types with categories and interfaces: - code-server: editor, [web] - jupyter-notebook: notebook, [web] - opencode: ai-assistant, [terminal] - Update instance API to include tool type interfaces - Create Alembic migrations 0008 and 0009 Frontend: - Update ToolType and Session interfaces with new fields - Conditionally show Open/Terminal buttons based on tool interfaces - Add API client for tool configs OpenSpec: tool-config-management change created and implemented.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""add category and interfaces to tool_types
|
||||
|
||||
Revision ID: 0008_tool_type_category
|
||||
Revises: 0007_instance_container_name
|
||||
Create Date: 2026-05-20 09:00:00.000000
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "0008_tool_type_category"
|
||||
down_revision: Union[str, None] = "0007_instance_container_name"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column(
|
||||
"tool_types",
|
||||
sa.Column("category", sa.String(50), nullable=False, server_default="other")
|
||||
)
|
||||
op.add_column(
|
||||
"tool_types",
|
||||
sa.Column("interfaces", sa.JSON(), nullable=False, server_default='["web"]')
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("tool_types", "interfaces")
|
||||
op.drop_column("tool_types", "category")
|
||||
@@ -0,0 +1,46 @@
|
||||
"""add tool_configs table
|
||||
|
||||
Revision ID: 0009_tool_configs
|
||||
Revises: 0008_tool_type_category
|
||||
Create Date: 2026-05-20 09:00:00.000000
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "0009_tool_configs"
|
||||
down_revision: Union[str, None] = "0008_tool_type_category"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
"tool_configs",
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("tool_type_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("project_id", postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column("key", sa.String(255), nullable=False),
|
||||
sa.Column("value", sa.Text(), nullable=False),
|
||||
sa.Column("config_type", sa.String(20), nullable=False, server_default="env"),
|
||||
sa.Column("file_path", sa.String(1024), nullable=True),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"]),
|
||||
sa.ForeignKeyConstraint(["tool_type_id"], ["tool_types.id"]),
|
||||
sa.ForeignKeyConstraint(["project_id"], ["projects.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index("idx_tool_configs_user_tool", "tool_configs", ["user_id", "tool_type_id"])
|
||||
op.create_index("idx_tool_configs_project", "tool_configs", ["project_id"])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index("idx_tool_configs_project", table_name="tool_configs")
|
||||
op.drop_index("idx_tool_configs_user_tool", table_name="tool_configs")
|
||||
op.drop_table("tool_configs")
|
||||
Reference in New Issue
Block a user