F2: persist native job projections and expose task controls

This commit is contained in:
Xin Wang
2026-10-23 16:03:40 +08:00
parent bae5ec3c58
commit 33fde56edd
13 changed files with 550 additions and 5 deletions
+32 -1
View File
@@ -248,7 +248,7 @@ class Tool(Base):
name="uq_tools_mcp_server_remote_name",
),
CheckConstraint(
"type IN ('http', 'mcp', 'client')",
"type IN ('http', 'mcp', 'client', 'task')",
name="ck_tools_external_type",
),
)
@@ -647,3 +647,34 @@ class TestRunCase(Base):
finished_at: Mapped[datetime | None] = mapped_column(
DateTime(timezone=True), nullable=True
)
class BackgroundTask(Base):
"""A durable view of a Pipecat Job and its external execution handle."""
__tablename__ = "background_tasks"
id: Mapped[str] = mapped_column(String(40), primary_key=True)
assistant_id: Mapped[str] = mapped_column(String(40), index=True)
conversation_id: Mapped[str] = mapped_column(String(80), index=True)
tool_id: Mapped[str] = mapped_column(String(40))
instruction: Mapped[str] = mapped_column(Text)
origin_key: Mapped[str] = mapped_column(String(256), unique=True)
connection: Mapped[dict] = mapped_column(JSONB)
secrets: Mapped[dict] = mapped_column(JSONB)
status: Mapped[str] = mapped_column(String(32), index=True)
summary: Mapped[str] = mapped_column(Text)
result: Mapped[str] = mapped_column(Text)
remote_handle: Mapped[dict] = mapped_column(JSONB)
input_request: Mapped[dict] = mapped_column(JSONB)
job_id: Mapped[str] = mapped_column(String(80))
sequence: Mapped[int] = mapped_column(Integer)
created_at: Mapped[str] = mapped_column(String(40))
updated_at: Mapped[str] = mapped_column(String(40))
class BackgroundTaskEvent(Base):
__tablename__ = "background_task_events"
__table_args__ = (UniqueConstraint("task_id", "sequence"),)
id: Mapped[str] = mapped_column(String(40), primary_key=True)
task_id: Mapped[str] = mapped_column(String(40), ForeignKey("background_tasks.id", ondelete="CASCADE"), index=True)
sequence: Mapped[int] = mapped_column(Integer)
data: Mapped[dict] = mapped_column(JSONB)