063a839790
- Add clone_mode and branch fields to tool_instances - Add ssh_key_id to git_repositories for per-repo SSH key assignment - Implement host-side git cloning with branch selection (default: main) - Mount SSH keys into containers for git operations in clone mode - Add dirty state check on clone-mode instance deletion with confirmation - Update SessionsPage with mount/clone selector, branch input, SSH key display - Add SSH key selector to repository creation form - Add dirty delete confirmation modal with changed files list - Update API schemas and endpoints for new fields - Sync delta specs to main specs (git-repo, tool-instances, repo-clone-mode) - Archive completed OpenSpec change: repo-clone-mode-with-ssh - Document git requirement for custom tool types Quality gates: Frontend typecheck and build passed OpenSpec: repo-clone-mode-with-ssh archived with all tasks complete
79 lines
2.6 KiB
Python
79 lines
2.6 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
from typing import TYPE_CHECKING
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Integer, JSON, String
|
|
from sqlalchemy import Uuid as UUID
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from src.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
|
|
|
if TYPE_CHECKING:
|
|
from src.models.git_repository import GitRepository
|
|
from src.models.project import Project
|
|
from src.models.tool_type import ToolType
|
|
from src.models.user import User
|
|
|
|
|
|
class ToolInstance(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
|
__tablename__ = "tool_instances"
|
|
|
|
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
display_name: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
tool_type_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(), ForeignKey("tool_types.id"), nullable=False
|
|
)
|
|
repository_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(), ForeignKey("git_repositories.id"), nullable=False
|
|
)
|
|
project_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(), ForeignKey("projects.id"), nullable=False
|
|
)
|
|
owner_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(), ForeignKey("users.id"), nullable=False
|
|
)
|
|
status: Mapped[str] = mapped_column(
|
|
String(50), nullable=False, default="pending"
|
|
)
|
|
container_id: Mapped[str | None] = mapped_column(
|
|
String(255), nullable=True
|
|
)
|
|
container_name: Mapped[str | None] = mapped_column(
|
|
String(255), nullable=True
|
|
)
|
|
compose_path: Mapped[str | None] = mapped_column(
|
|
String(1024), nullable=True
|
|
)
|
|
url: Mapped[str | None] = mapped_column(
|
|
String(1024), nullable=True
|
|
)
|
|
public_url: Mapped[str | None] = mapped_column(
|
|
String(1024), nullable=True
|
|
)
|
|
tunnel_id: Mapped[str | None] = mapped_column(
|
|
String(255), nullable=True
|
|
)
|
|
port: Mapped[int | None] = mapped_column(
|
|
Integer, nullable=True
|
|
)
|
|
last_started_at: Mapped[datetime | None] = mapped_column(
|
|
DateTime(timezone=True), nullable=True
|
|
)
|
|
last_stopped_at: Mapped[datetime | None] = mapped_column(
|
|
DateTime(timezone=True), nullable=True
|
|
)
|
|
probe_result: Mapped[dict | None] = mapped_column(
|
|
JSON, nullable=True
|
|
)
|
|
clone_mode: Mapped[str] = mapped_column(
|
|
String(20), nullable=False, default="mount"
|
|
)
|
|
branch: Mapped[str | None] = mapped_column(
|
|
String(255), nullable=True, default="main"
|
|
)
|
|
|
|
tool_type: Mapped["ToolType"] = relationship()
|
|
repository: Mapped["GitRepository"] = relationship()
|
|
project: Mapped["Project"] = relationship()
|
|
owner: Mapped["User"] = relationship()
|