mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
refactor(automation): rename schema config to params, drop dead fields
This commit is contained in:
parent
c8a89ccac8
commit
9fa35f21cf
11 changed files with 31 additions and 37 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
"""Pydantic schemas for the automation definition and per-type configs."""
|
"""Schemas for the automation definition and per-type configs."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from .actions import AgentTaskActionConfig
|
from .actions import AgentTaskActionParams
|
||||||
from .definition import (
|
from .definition import (
|
||||||
AutomationDefinition,
|
AutomationDefinition,
|
||||||
ExecutionBlock,
|
ExecutionBlock,
|
||||||
|
|
@ -11,16 +11,16 @@ from .definition import (
|
||||||
PlanStep,
|
PlanStep,
|
||||||
TriggerSpec,
|
TriggerSpec,
|
||||||
)
|
)
|
||||||
from .triggers import ManualTriggerConfig, ScheduleTriggerConfig
|
from .triggers import ManualTriggerParams, ScheduleTriggerParams
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"AgentTaskActionConfig",
|
"AgentTaskActionParams",
|
||||||
"AutomationDefinition",
|
"AutomationDefinition",
|
||||||
"ExecutionBlock",
|
"ExecutionBlock",
|
||||||
"InputsBlock",
|
"InputsBlock",
|
||||||
"ManualTriggerConfig",
|
"ManualTriggerParams",
|
||||||
"MetadataBlock",
|
"MetadataBlock",
|
||||||
"PlanStep",
|
"PlanStep",
|
||||||
"ScheduleTriggerConfig",
|
"ScheduleTriggerParams",
|
||||||
"TriggerSpec",
|
"TriggerSpec",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
"""Per-action config schemas, one per action type."""
|
"""Per-action params schemas, one per action type."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from .agent_task import AgentTaskActionConfig
|
from .agent_task import AgentTaskActionParams
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"AgentTaskActionConfig",
|
"AgentTaskActionParams",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
"""``AgentTaskActionConfig`` — config for the ``agent_task`` action type."""
|
"""``AgentTaskActionParams`` — params for the ``agent_task`` action type."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
@ -7,21 +7,21 @@ from typing import Any
|
||||||
from pydantic import BaseModel, ConfigDict, Field
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
|
||||||
|
|
||||||
class AgentTaskActionConfig(BaseModel):
|
class AgentTaskActionParams(BaseModel):
|
||||||
"""Run a LangGraph Deep Agent restricted to a scoped capability list."""
|
"""Run an agent task with a scoped tool allowlist."""
|
||||||
|
|
||||||
model_config = ConfigDict(extra="forbid")
|
model_config = ConfigDict(extra="forbid")
|
||||||
|
|
||||||
prompt: str = Field(..., min_length=1, description="Task prompt; Jinja-rendered.")
|
prompt: str = Field(..., min_length=1, description="Task prompt; rendered at execute time.")
|
||||||
tools: list[str] = Field(
|
tools: list[str] = Field(
|
||||||
default_factory=list,
|
default_factory=list,
|
||||||
description="Capability IDs the agent may call. Empty = no tool access.",
|
description="Tool identifiers the agent may call. Empty = no tool access.",
|
||||||
)
|
)
|
||||||
model: str | None = Field(
|
model: str | None = Field(
|
||||||
default=None,
|
default=None,
|
||||||
description="LiteLLM model id. Defaults to the search space's agent_llm_id.",
|
description="Model identifier. Defaults to the search space's agent_llm_id.",
|
||||||
)
|
)
|
||||||
output_schema: dict[str, Any] | None = Field(
|
output_schema: dict[str, Any] | None = Field(
|
||||||
default=None,
|
default=None,
|
||||||
description="JSON Schema the agent must return. Recommended.",
|
description="JSON Schema (draft 2020-12) the agent must return. Recommended.",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,6 @@ class ExecutionBlock(BaseModel):
|
||||||
max_retries: int = Field(default=2, ge=0, description="Per-step retry budget.")
|
max_retries: int = Field(default=2, ge=0, description="Per-step retry budget.")
|
||||||
retry_backoff: Literal["exponential", "linear", "none"] = "exponential"
|
retry_backoff: Literal["exponential", "linear", "none"] = "exponential"
|
||||||
concurrency: Literal["drop_if_running", "queue", "always"] = "drop_if_running"
|
concurrency: Literal["drop_if_running", "queue", "always"] = "drop_if_running"
|
||||||
budget_cap_usd: float | None = Field(
|
|
||||||
default=None, gt=0, description="Kill the run when accumulated cost exceeds this."
|
|
||||||
)
|
|
||||||
on_failure: list[PlanStep] = Field(
|
on_failure: list[PlanStep] = Field(
|
||||||
default_factory=list,
|
default_factory=list,
|
||||||
description="Steps run when the main plan fails after retries.",
|
description="Steps run when the main plan fails after retries.",
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,5 @@ class InputsBlock(BaseModel):
|
||||||
schema_: dict[str, Any] = Field(
|
schema_: dict[str, Any] = Field(
|
||||||
...,
|
...,
|
||||||
alias="schema",
|
alias="schema",
|
||||||
description="JSON Schema (draft-07) for accepted inputs.",
|
description="JSON Schema (draft 2020-12) for accepted inputs.",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,3 @@ class MetadataBlock(BaseModel):
|
||||||
model_config = ConfigDict(extra="allow")
|
model_config = ConfigDict(extra="allow")
|
||||||
|
|
||||||
tags: list[str] = Field(default_factory=list)
|
tags: list[str] = Field(default_factory=list)
|
||||||
created_from_nl: bool = Field(
|
|
||||||
default=False, description="True when produced by the NL generator."
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ class PlanStep(BaseModel):
|
||||||
action: str = Field(..., min_length=1, description="Action type; resolved via registry.")
|
action: str = Field(..., min_length=1, description="Action type; resolved via registry.")
|
||||||
when: str | None = Field(
|
when: str | None = Field(
|
||||||
default=None,
|
default=None,
|
||||||
description="Optional Jinja expression; step is skipped when falsy.",
|
description="Optional predicate; step is skipped when falsy.",
|
||||||
)
|
)
|
||||||
config: dict[str, Any] = Field(
|
params: dict[str, Any] = Field(
|
||||||
default_factory=dict,
|
default_factory=dict,
|
||||||
description="Action-type-specific config; Jinja-rendered at execute time.",
|
description="Action-type-specific params; rendered at execute time.",
|
||||||
)
|
)
|
||||||
output_as: str | None = Field(
|
output_as: str | None = Field(
|
||||||
default=None,
|
default=None,
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class TriggerSpec(BaseModel):
|
||||||
model_config = ConfigDict(extra="forbid")
|
model_config = ConfigDict(extra="forbid")
|
||||||
|
|
||||||
type: str = Field(..., min_length=1, description="Trigger type; resolved via registry.")
|
type: str = Field(..., min_length=1, description="Trigger type; resolved via registry.")
|
||||||
config: dict[str, Any] = Field(
|
params: dict[str, Any] = Field(
|
||||||
default_factory=dict,
|
default_factory=dict,
|
||||||
description="Type-specific config; validated against the trigger's schema.",
|
description="Type-specific params; validated against the trigger's schema.",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
"""Per-trigger config schemas, one per trigger type."""
|
"""Per-trigger params schemas, one per trigger type."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from .manual import ManualTriggerConfig
|
from .manual import ManualTriggerParams
|
||||||
from .schedule import ScheduleTriggerConfig
|
from .schedule import ScheduleTriggerParams
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"ManualTriggerConfig",
|
"ManualTriggerParams",
|
||||||
"ScheduleTriggerConfig",
|
"ScheduleTriggerParams",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
"""``ManualTriggerConfig`` — config for the ``manual`` trigger (empty in v1)."""
|
"""``ManualTriggerParams`` — params for the ``manual`` trigger (empty in v1)."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict
|
from pydantic import BaseModel, ConfigDict
|
||||||
|
|
||||||
|
|
||||||
class ManualTriggerConfig(BaseModel):
|
class ManualTriggerParams(BaseModel):
|
||||||
model_config = ConfigDict(extra="forbid")
|
model_config = ConfigDict(extra="forbid")
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
"""``ScheduleTriggerConfig`` — config for the ``schedule`` trigger type."""
|
"""``ScheduleTriggerParams`` — params for the ``schedule`` trigger type."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, Field
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
|
||||||
|
|
||||||
class ScheduleTriggerConfig(BaseModel):
|
class ScheduleTriggerParams(BaseModel):
|
||||||
model_config = ConfigDict(extra="forbid")
|
model_config = ConfigDict(extra="forbid")
|
||||||
|
|
||||||
cron: str = Field(..., description="Five-field cron expression.", examples=["0 9 * * 1-5"])
|
cron: str = Field(..., description="Five-field cron expression.", examples=["0 9 * * 1-5"])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue