Fix 422 on agent trigger: accept plural data type names
AgentTriggerRequest.what_to_extract now accepts list[str] instead of strict Literal values. _to_data_types normalises all FE variants (tasks/task, notes/note, timelines/timeline/timelineEvents, projects/project) to the canonical plural form the runner expects, with deduplication. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -49,12 +49,19 @@ def _dt_ms_opt(dt: datetime | None) -> int | None:
|
|||||||
|
|
||||||
def _to_data_types(values: list[str]) -> list[str]:
|
def _to_data_types(values: list[str]) -> list[str]:
|
||||||
normalize = {
|
normalize = {
|
||||||
"task": "tasks",
|
"task": "tasks", "tasks": "tasks",
|
||||||
"note": "notes",
|
"note": "notes", "notes": "notes",
|
||||||
"timeline": "timelines",
|
"timeline": "timelines", "timelines": "timelines", "timelineEvents": "timelines",
|
||||||
"project": "projects",
|
"project": "projects", "projects": "projects",
|
||||||
}
|
}
|
||||||
return [normalize[v] for v in values if v in normalize]
|
seen: set[str] = set()
|
||||||
|
result: list[str] = []
|
||||||
|
for v in values:
|
||||||
|
mapped = normalize.get(v)
|
||||||
|
if mapped and mapped not in seen:
|
||||||
|
seen.add(mapped)
|
||||||
|
result.append(mapped)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _to_run_log_response(log: AgentRunLog) -> AgentRunLogResponse:
|
def _to_run_log_response(log: AgentRunLog) -> AgentRunLogResponse:
|
||||||
|
|||||||
@@ -295,11 +295,8 @@ class AgentCreationCheckResponse(BaseModel):
|
|||||||
class AgentTriggerRequest(BaseModel):
|
class AgentTriggerRequest(BaseModel):
|
||||||
directory: str = Field(min_length=1)
|
directory: str = Field(min_length=1)
|
||||||
device_id: str = Field(default="")
|
device_id: str = Field(default="")
|
||||||
what_to_extract: list[Literal["task", "note", "timeline", "project"]] = Field(min_length=1)
|
what_to_extract: list[str] = Field(min_length=1)
|
||||||
actions_by_type: dict[
|
actions_by_type: dict[str, list[str]] | None = None
|
||||||
Literal["task", "note", "timeline", "project"],
|
|
||||||
list[Literal["add", "update"]],
|
|
||||||
] | None = None
|
|
||||||
batch_interval: str = Field(min_length=1)
|
batch_interval: str = Field(min_length=1)
|
||||||
custom_agent_prompt: str = Field(min_length=1)
|
custom_agent_prompt: str = Field(min_length=1)
|
||||||
active_agents: int = Field(ge=0, default=0)
|
active_agents: int = Field(ge=0, default=0)
|
||||||
|
|||||||
Reference in New Issue
Block a user